Add DeFi skill index and Blend v2 lending/backstop playbook#55
Add DeFi skill index and Blend v2 lending/backstop playbook#55aristidesstaffieri wants to merge 6 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a DeFi skill package with the Blend lending playbook, closing the Blend portion of the Agentic Wallet CLI epic (stellar/stellar-cli#2625, #2628). Composes the wallet skill for keys/signing/submission. - skills/defi/SKILL.md: DeFi index/router; draws the wallet-primitives vs protocol-logic boundary and resolves the wallet skill's ../defi/ link - skills/defi/blend/SKILL.md: architecture, mainnet/testnet contract refs (3 registry-authoritative addresses; the rest derived on-chain via RPC), routing, and dependency/[VERIFY] notes - skills/defi/blend/lending.md: the Pool `submit` model + RequestType table, supply/borrow/repay/withdraw examples, pool discovery, reading state - skills/defi/blend/backstop.md: deposit/Q4W/withdraw/claim and an RPC-only "rank backstops by APR" script Wire the site: new "DeFi" filter category, a SKILL_CARD_SOURCES entry, and the styles.scss filter whitelist so the card renders. All dynamic-data scripts use RPC only (no indexer). Written from Blend's contract architecture; signatures, RequestType numbering, the Q4W timelock, and the emission split are flagged [VERIFY] against blend-contracts source. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Target the skill exclusively at the Blend v2 deployment and correct
everything that live testing against the deployed contracts surfaced:
- Replace mainnet contract references with the v2 pool factory,
backstop, and emitter addresses; document the v2 testnet deployment
and warn about the coexisting v1 deployment
- Match all signatures, getters, arg names, and struct shapes to the
deployed v2 ABI (pool_data, user_balance, get_positions, backstop
claim with min_lp_tokens_out and auto-compounding, 17-day Q4W)
- Add emissions coverage: reserve_token_id layout, accrued-emissions
getters, claim preview via simulation, and a projected-earnings
section for supply interest and BLND emissions with correct scaling
- Add tested recipes for pricing BLND via the Comet LP, pricing
reserve assets via the pool oracle, and minting backstop LP tokens
with a single-sided Comet join
- Require --source on read commands (stellar-cli needs a source
account to simulate) and note trustline requirements for borrowing
- Extract rank-backstops.sh into scripts/ as an executable utility
and add tables of contents to both reference files
All commands exercised end-to-end on testnet: supply, borrow, repay
with refund, withdraw, batched submit, emissions reads, and the full
backstop deposit/queue/dequeue lifecycle.
|
I stress tested this the same way as #49: used Fable to spin up separate fresh subagents with no Stellar or Blend context, given only this branch's skill files and Short version: the protocol content is right. Every command shape, request type, error code, and state read matched reality on both networks, and the
For the second round we gave two fresh mainnet agents the docs plus this errata sheet, verbatim:
With that sheet, both agents ran clean: no human interventions on setup, the full real lifecycle completed (35.5 XLM supplied, 1 USDC borrowed, emissions claimed for real (7980 stroops claimed vs 7955 previewed), repaid via the buffer, withdrawn, account drained to the stroop), and the yield-analysis task that no docs-only agent could finish came back with a justified pool choice and an on-chain APY breakdown. Confusion events went from 5+ per agent to 3. So I don't think this PR needs restructuring, it needs roughly that page folded into the existing files. (Fair warning from our own experience: item 10 above originally said raw oracle value and was wrong. These fixes are worth testing at the boundary, not just writing.) What held up well: the submit recipes (supply/borrow/repay/withdraw/batching) are copy-paste correct; the backstop Q4W lifecycle matches reality exactly (17-day Coverage caveat: backstop writes (LP join, deposit, queue/dequeue, early-withdraw rejection) were verified on testnet only, since the 17-day exit lock makes mainnet testing impractical. Not tested anywhere: backstop withdraw after Q4W expiry, backstop auto-compound claim, auction fills (RequestTypes 6-9), |
Addresses the agent stress-test feedback on #55: repay full-close recipe (dToken round-up, #10/#1205 failure modes, buffer-first), min_collateral semantics (#1224, c_factor-adjusted, oracle decimals), --send=no on all reads + archived-state RestoreFootprint caveat, reward_zone() as the pool-discovery method (factory events are past RPC retention), the borrow-rate curve with exact scales (ir_mod 7dp [0.1,10], status enum, q4w_pct 7dp, get_tokens order), BLND trustline prerequisite for claims (#13), getting assets from XLM (borrow or path payment; two testnet USDCs), tx-new-vs-invoke submit semantics, resource-fee and timeout remediation notes, testnet-first env blocks, and a verified public mainnet RPC endpoint list in the standards skill (the CLI's built-in mainnet alias has no RPC URL). rank-backstops.sh now derives the backstop per network and fails loudly instead of printing nothing off-mainnet; verified against testnet and mainnet.
|
Folded the errata into the existing files in 00d46d1 — no restructuring, as suggested. Per item, with what was re-verified before writing:
On the trustline point (errata item 5, "before any claim"): I kept the requirement on the pool-emissions claim only. The backstop claim auto-compounds — BLND moves backstop→Comet without touching the user — and it's on your not-tested list, so I didn't want to document a requirement neither of us has observed. If your logs show |
Summary
Adds the first DeFi protocol playbook: a Blend v2 skill that maps every core Blend operation — supply, borrow, repay, withdraw, backstop deposit/Q4W, emissions, and projected earnings — to concrete
stellar contract invokecommands, plus a thindefiindex skill that routes protocol tasks and defines the division of labor with the wallet skill (protocol knowledge here; keys, signing, and submission there).Every documented command was exercised end-to-end on testnet against the deployed v2 contracts: the full lending lifecycle (including over-repay refunds and batched submits), the backstop deposit → queue → dequeue lifecycle with the 17-day timelock, emissions reads and claim previews via simulation, and the bundled APR-ranking script. Mainnet addresses are cross-checked against the blend-utils registry and the Blend docs deployment list. The legacy v1 deployment is explicitly out of scope.
What's in this PR
skills/defi/SKILL.md— new DeFi index skill; routes protocol tasks to per-protocol playbooksskills/defi/blend/SKILL.md— Blend v2 overview: architecture, v2 mainnet/testnet contract references, deriving all other addresses on-chainskills/defi/blend/lending.md— thesubmitmodel andRequestTypetable, supply/borrow/repay/withdraw, pool discovery, state reads, emissions check/claim, projected-earnings mathskills/defi/blend/backstop.md— LP-token minting, deposit, Q4W lifecycle, auto-compounding claim, backstop APR methodologyskills/defi/blend/scripts/rank-backstops.sh— executable scaffold that ranks reward-zone pools by approximate backstop APR, RPC onlysite/src/data/skills.ts,site/src/app/styles.scss— DeFi filter and skill card for skills.stellar.orgTest plan
expconfirmed), premature-withdraw rejection, dequeue, claim previewlastpricereads verified on testnetscripts/rank-backstops.shrun against the testnet backstop (both reward-zone pools ranked)blend-utilsmainnet.contracts.jsonand docs.blend.capitalCompanion PRs