Repository navigation
feat: Aera money market (lend, borrow, collateral) — 8 tools - #12
Merged
Merged
Conversation
Hand-encoded aera instructions (no IDL anywhere), per-action same-slot prelude, abCOOK-shares collateral handled in one tx, health-factor refusal with a named opt-out, throwaway native-COOK leg, external-signer dry-run verify script.
…al withdrawal Mirror refresh_obligation: an obligation is stressed only when an oracle won't permit Borrow, and RateWarning does. borrow no longer refuses in rateWarning. withdraw_collateral refuses an amount above the deposit instead of clamping it. The position note uses DEFAULT_MIN_HEALTH_FACTOR.
# Conflicts: # src/core/config.ts # src/mcp/createServer.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the Aera overcollateralised COOK money market as a venue: 8 tools (65 total), library subpath
cookie-mcp/lending.Tools
get_lending_markets,get_lending_position(accepts.cooknames)lend/withdraw_lend,deposit_collateral/withdraw_collateral,borrow/repayHow it is built
src/core/lending/program.tshand-encodes every instruction from the program source. Discriminators are Anchor's defaults and a golden test recomputes them from the names; account layouts are pinned against live accounts.math.tsmirrors the program's accounting (index projection, share ⇄ liquidity, kinked rates, obligation health) for pre-flight checks and estimates. Rounding matches the handlers (user-favourable floors, owed ceils).accrue,refresh_oraclewith the stake-pool + ProgramData accounts,refresh_obligationwith[reserve, oracle]pairs) in the same transaction.deposit_collateralsupplies bCOOK and deposits the minted shares in one tx (creating the obligation on first use);withdraw_collateralreverses both. Agents only reason in bCOOK.borrow/withdraw_collateralrefuse before signing when the loan-to-value limit would be exceeded or the health factor would fall underminHealthFactor(default 1.1; 1.0 = liquidation line).getProgramAccounts, so a new reserve shows up without a release.Verification
yarn testgreen: 805 unit tests (54 new), 65 tools in smoke.scripts/verify-lending.ts(no key, nothing sent): reads, 7 guard refusals, then external-signer dry runs of every write flow — each builds its real transaction, simulates it on the RPC and stops atneeds_signature. lend, withdraw_lend, borrow, repay (amount andall), withdraw_collateral (redeem andkeepShares) simulated OK for a live borrower; deposit_collateral + lend bCOOK simulated OK for a bCOOK holder with no obligation. LTV-exceeding borrow and withdraw-all-with-debt refused before simulation.LIVE=1 npx tsx scripts/verify-lending.tsruns a dust round trip (lend 1 COOK, withdraw, deposit 1 bCOOK, borrow 0.5, repay all, withdraw collateral). Not yet run.