Add DeFi skill index and Blend v2 lending/backstop playbook by aristidesstaffieri · Pull Request #55 · stellar/stellar-dev-skill · GitHub
Skip to content

Add DeFi skill index and Blend v2 lending/backstop playbook - #55

Open
aristidesstaffieri wants to merge 6 commits into
feat/wallet-skills-clifrom
feat/defi-blend-skill
Open

aristidesstaffieri wants to merge 6 commits into
feat/wallet-skills-clifrom
feat/defi-blend-skill

Conversation

@aristidesstaffieri

@aristidesstaffieri aristidesstaffieri commented Jul 10, 2026 •

Copy link
Copy Markdown
Collaborator

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 invoke commands, plus a thin defi index 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 playbooks
  • skills/defi/blend/SKILL.md — Blend v2 overview: architecture, v2 mainnet/testnet contract references, deriving all other addresses on-chain
  • skills/defi/blend/lending.md — the submit model and RequestType table, supply/borrow/repay/withdraw, pool discovery, state reads, emissions check/claim, projected-earnings math
  • skills/defi/blend/backstop.md — LP-token minting, deposit, Q4W lifecycle, auto-compounding claim, backstop APR methodology
  • skills/defi/blend/scripts/rank-backstops.sh — executable scaffold that ranks reward-zone pools by approximate backstop APR, RPC only
  • site/src/data/skills.ts, site/src/app/styles.scss — DeFi filter and skill card for skills.stellar.org

Test plan

  • All lending commands run on testnet against the deployed v2 pool (supply, borrow, over-repay refund, withdraw, batched submit)
  • Full backstop lifecycle on testnet: single-sided Comet LP join, deposit, queue (17-day exp confirmed), premature-withdraw rejection, dequeue, claim preview
  • Emissions getters, claim simulation, Comet spot-price and oracle lastprice reads verified on testnet
  • scripts/rank-backstops.sh run against the testnet backstop (both reward-zone pools ranked)
  • Mainnet addresses cross-checked against blend-utils mainnet.contracts.json and docs.blend.capital
  • CI green
  • Site skill card renders correctly

Companion PRs

aristidesstaffieri and others added 5 commits July 8, 2026 13:06
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.
@aristidesstaffieri aristidesstaffieri self-assigned this Jul 10, 2026
@aristidesstaffieri aristidesstaffieri changed the title Feat/defi blend skill Add DeFi skill index and Blend v2 lending/backstop playbook Jul 10, 2026
@oceans404

Copy link
Copy Markdown
Contributor

  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.
@aristidesstaffieri

Copy link
Copy Markdown
Collaborator Author

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants