-
Notifications
You must be signed in to change notification settings - Fork 43
fix(stacks-alpha-engine): post-#339 audit sweep — rebase of #346 #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,7 +5,7 @@ metadata: | |||||||||||||||||
| author: "cliqueengagements" | ||||||||||||||||||
| author-agent: "Micro Basilisk (Agent 77) — SP219TWC8G12CSX5AB093127NC82KYQWEH8ADD1AY | bc1qzh2z92dlvccxq5w756qppzz8fymhgrt2dv8cf5" | ||||||||||||||||||
| user-invocable: "false" | ||||||||||||||||||
| arguments: "doctor | scan | deploy | withdraw | rebalance | migrate | emergency | install-packs" | ||||||||||||||||||
| arguments: "doctor | scan | deploy | withdraw | borrow | repay | rebalance | migrate | emergency | install-packs" | ||||||||||||||||||
| entry: "stacks-alpha-engine/stacks-alpha-engine.ts" | ||||||||||||||||||
| requires: "wallet, signing, settings" | ||||||||||||||||||
| tags: "defi, write, mainnet-only, requires-funds, l2" | ||||||||||||||||||
|
|
@@ -19,12 +19,12 @@ Cross-protocol yield executor covering **all 4 major Stacks DeFi protocols** — | |||||||||||||||||
|
|
||||||||||||||||||
| **Protocol coverage:** | ||||||||||||||||||
|
|
||||||||||||||||||
| | Protocol | Token(s) | Deposit | Withdraw | Method | | ||||||||||||||||||
| |----------|---------|---------|----------|--------| | ||||||||||||||||||
| | Zest v2 | sBTC, wSTX, stSTX, USDC, USDh | `zest_supply` | `zest_withdraw` | MCP native | | ||||||||||||||||||
| | Hermetica | USDh -> sUSDh | `staking-v1-1.stake(amount, affiliate)` | `staking-v1-1.unstake` + `silo.withdraw` | call_contract | | ||||||||||||||||||
| | Granite | aeUSDC | `liquidity-provider-v1.deposit` | `.redeem` (ERC-4626 shares) | call_contract | | ||||||||||||||||||
| | HODLMM | sBTC, STX, USDCx, USDh, aeUSDC (per pool) | `add-liquidity-simple` | `withdraw-liquidity-simple` | Bitflow skill | | ||||||||||||||||||
| | Protocol | Token(s) | Deposit | Withdraw | Debt (borrow/repay) | Method | | ||||||||||||||||||
| |----------|---------|---------|----------|---------------------|--------| | ||||||||||||||||||
| | Zest v2 | sBTC (supply), USDh (borrow) | `zest_supply` | `zest_withdraw` | `zest_borrow` / `zest_repay` — USDh only | MCP native | | ||||||||||||||||||
| | Hermetica | USDh -> sUSDh | `staking-v1-1.stake(amount, affiliate)` | `staking-v1-1.unstake` + `silo.withdraw` | — | call_contract | | ||||||||||||||||||
| | Granite | aeUSDC | `liquidity-provider-v1.deposit` | `.redeem` (ERC-4626 shares) | — | call_contract | | ||||||||||||||||||
| | HODLMM | sBTC, STX, USDCx, USDh, aeUSDC (per pool) | `add-liquidity-simple` | `withdraw-liquidity-simple` | — | Bitflow skill | | ||||||||||||||||||
|
|
||||||||||||||||||
| **3-tier yield mapping:** | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -41,26 +41,95 @@ No other skill covers all 4 Stacks DeFi protocols with working read AND write pa | |||||||||||||||||
| ## On-chain proof | ||||||||||||||||||
|
|
||||||||||||||||||
| - **Zest sBTC supply**: [txid b8ec03c3ba85c40840cdc933b61a14faf2a9516e1ce1314d9768228f3328803f](https://explorer.hiro.so/txid/b8ec03c3ba85c40840cdc933b61a14faf2a9516e1ce1314d9768228f3328803f?chain=mainnet) — 14,336 zsBTC shares received (block 7,495,066) | ||||||||||||||||||
| - **Zest sBTC supply (refresh)**: [`0x315a6d54…`](https://explorer.hiro.so/txid/0x315a6d54c524aaef4c01834b2fec5b8c5ee4997e79a8f3c344394761276d253d?chain=mainnet) — 10,000 sats → 9,995 zsBTC via `v0-4-market.supply-collateral-add` (same contract MCP `zest_supply` routes to) | ||||||||||||||||||
| - **Zest sBTC withdraw**: [`0x016c3996…`](https://explorer.hiro.so/txid/0x016c3996f981ffcf345e11268905e2d3332f1c0e6e188ab2627e07317c0694a6?chain=mainnet) — 15,335 zsBTC → 15,342 sats sBTC via `v0-4-market.collateral-remove-redeem` | ||||||||||||||||||
| - **Zest USDh borrow**: [`0x2b465aae…`](https://explorer.hiro.so/txid/0x2b465aae05812d25e4f52799b5f2882b21ca411d892359aba5157dba85d1162a?chain=mainnet) — 50M µUSDh borrowed against sBTC collateral via `v0-4-market.borrow` | ||||||||||||||||||
| - **Zest USDh repay**: [`0xd3b46ae7…`](https://explorer.hiro.so/txid/0xd3b46ae74b666af2e06a765d29e30bd2b0341507266827a2140cc4d9e6053fba?chain=mainnet) — full 50M µUSDh debt cleared via `v0-4-market.repay` | ||||||||||||||||||
| - **Hermetica staking**: USDh stake via `staking-v1-1.stake` — [`e8b2213d...`](https://explorer.hiro.so/txid/e8b2213d39faf2e9ccfe52bc3cbe33885303aa01c63f93badd3e8a41900a2ecf?chain=mainnet) (block 7,512,730) | ||||||||||||||||||
| - **Granite aeUSDC deposit**: `liquidity-provider-v1.deposit` — [`205bf3f1...`](https://explorer.hiro.so/txid/205bf3f135c5f1cddd8323c1a1a054f3a63ac81904c4244a763b0ce4b26c3352?chain=mainnet) (block 7,512,722) | ||||||||||||||||||
| - **Hermetica unstake**: sUSDh → 7-day silo claim via `staking-v1-1.unstake` — [`0x7834cd32…`](https://explorer.hiro.so/txid/0x7834cd325b986f2db2275b3fe867ca094c3c375d67a77d7f5fb3858d0f94eaad?chain=mainnet) — 408,500,348 sUSDh burned → 5.007 USDh in silo claim 2157 (ratio 1.2257, block 7,703,650) | ||||||||||||||||||
| - **Granite aeUSDC deposit** (write-path proof for `lp-v1.deposit`): [`0x205bf3f1`](https://explorer.hiro.so/txid/0x205bf3f135c5f1cddd8323c1a1a054f3a63ac81904c4244a763b0ce4b26c3352?chain=mainnet) — 4,997,500 µaeUSDC supplied → 4,936,276 lp-token minted on `state-v1` (block 7,512,722) | ||||||||||||||||||
| - **Granite redeem** (with corrected 3-PC shape): [`0xd4aa0c4e…`](https://explorer.hiro.so/txid/0xd4aa0c4ed51b0951e91bb6680e44bc01da36722525fa7b28c39d98219e3eeba9?chain=mainnet) — 4,936,276 lp-token burned → 4,999,538 aeUSDC (ratio 1.0128) | ||||||||||||||||||
| - **HODLMM add-liquidity**: [`f2ffb41e...`](https://explorer.hiro.so/txid/f2ffb41e1f29a5c5ee5fa0df628a700e21bf14a4aabbd334b5f49b98bab9e315?chain=mainnet) — dlmm-liquidity-router (block 7,423,687) | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Leveraged-yield pattern | ||||||||||||||||||
|
|
||||||||||||||||||
| A composition of Zest supply + Zest borrow + Hermetica stake unlocks positive-carry leveraged yield without selling sBTC. Each leg is a supported skill command: | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| # ---- enter position ---- | ||||||||||||||||||
| deploy --protocol zest --token sbtc --amount <collateral_sats> # supply sBTC to Zest | ||||||||||||||||||
| borrow --protocol zest --token usdh --amount <debt_micro_usdh> # take USDh debt (~7% APR) | ||||||||||||||||||
| deploy --protocol hermetica --token usdh --amount <debt_micro_usdh> # stake for 40% APY | ||||||||||||||||||
|
|
||||||||||||||||||
| # ---- earning ~33% positive carry on debt_micro_usdh while sBTC exposure preserved ---- | ||||||||||||||||||
|
Comment on lines
+61
to
+64
|
||||||||||||||||||
| borrow --protocol zest --token usdh --amount <debt_micro_usdh> # take USDh debt (~7% APR) | |
| deploy --protocol hermetica --token usdh --amount <debt_micro_usdh> # stake for 40% APY | |
| # ---- earning ~33% positive carry on debt_micro_usdh while sBTC exposure preserved ---- | |
| borrow --protocol zest --token usdh --amount <debt_atomic_usdh> # take USDh debt (~7% APR) | |
| deploy --protocol hermetica --token usdh --amount <debt_atomic_usdh> # stake for 40% APY | |
| # ---- earning ~33% positive carry on debt_atomic_usdh while sBTC exposure preserved ---- |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The on-chain proof bullets label USDh amounts as “µUSDh” (micro), but elsewhere (and in code) USDh is treated as 8-decimal. Using “µUSDh” implies 6 decimals and can lead to 100× mis-sized amounts. Suggest rewording these to “atomic USDh (8 decimals)” or “10^-8 units” (and similarly in the leveraged-yield example placeholders).