Autonomous sBTC yield management on Zest Protocol — supply, withdraw, claim rewards, and monitor positions with safety controls.
Manages sBTC lending positions on Zest Protocol (Stacks L2). Supplies idle sBTC to earn yield from borrowers, monitors position health, claims wSTX incentive rewards, and withdraws when needed. All operations go through Zest's audited pool-borrow contracts with Pyth oracle price feeds.
Any agent holding sBTC has idle capital losing value to opportunity cost. This skill automates the supply/withdraw/claim cycle so agents earn yield without manual intervention. It handles the Pyth oracle fee, post-conditions, and borrow-helper versioning that trip up manual callers.
Tested on Stacks mainnet with real sBTC (agent address SP4DXVEC16FS6QR7RBKGWZYJKTXPC81W49W0ATJE):
| Operation | Txid | Block | Result |
|---|---|---|---|
| Supply 1000 sats |
8f9eed21...| 7,352,592 |
(ok true) |
| Withdraw 1000 sats | a61c7b59... | 7,352,600 | (ok true) |
Full round-trip verified: supply and withdraw both succeed on mainnet.
--allow-borrow flag. Future versions may add borrow support with explicit opt-in and liquidation safeguards.DEFAULT_MAX_SUPPLY_SATS). Override with --max-supply-sats. Amounts above the limit return a blocked status — the skill refuses to proceed.blocked with a specific error code and suggested fix.Checks wallet STX balance (for gas), sBTC balance, Zest contract availability, current position, and pending rewards. Safe to run anytime — read-only.
bun run zest-yield-manager/zest-yield-manager.ts doctor
Core execution. Accepts sub-commands:
Check position (default, read-only):
bun run zest-yield-manager/zest-yield-manager.ts run --action=status
Supply sBTC to earn yield:
bun run zest-yield-manager/zest-yield-manager.ts run --action=supply --amount=50000
Withdraw sBTC from pool:
bun run zest-yield-manager/zest-yield-manager.ts run --action=withdraw --amount=50000
Claim wSTX incentive rewards:
bun run zest-yield-manager/zest-yield-manager.ts run --action=claim
Checks and reports on required dependencies: @stacks/transactions, @stacks/network.
bun run zest-yield-manager/zest-yield-manager.ts install-packs --pack all
All outputs are JSON to stdout. The status field determines how the agent should route:
Status check (--action=status):
{
"status": "success",
"action": "Idle sBTC detected — consider supplying with --action=supply",
"data": {
"position": {
"supplied_sats": 0,
"borrowed_sats": 0,
"rewards_pending_ustx": 0,
"asset": "sBTC"
},
"balances": {
"sbtc_sats": 295574,
"stx_ustx": 33405629
}
},
"error": null
}
Supply/withdraw/claim (--action=supply|withdraw|claim):
{
"status": "success",
"action": "Execute supply transaction via MCP zest_supply tool",
"data": {
"operation": "supply",
"asset": "sBTC",
"amount_sats": 1000,
"mcp_command": {
"tool": "zest_supply",
"params": { "asset": "sBTC", "amount": "1000" }
},
"pre_checks_passed": {
"gas_sufficient": true,
"balance_sufficient": true,
"within_spend_limit": true
}
},
"error": null
}
Blocked (safety check failed):
{
"status": "blocked",
"action": "Reduce amount or set --max-supply-sats=600000 to override",
"data": {},
"error": {
"code": "exceeds_limit",
"message": "Requested 600000 sats exceeds max supply limit of 500000 sats",
"next": "Reduce amount or set --max-supply-sats=600000 to override"
}
}
Key fields:
rewards_pending_ustx (number) — wSTX incentive rewards in microSTX. Check > 0 to decide whether to claim.mcp_command — the exact MCP tool call and parameters for the agent framework to execute.pre_checks_passed — which safety gates passed before generating the transaction payload.Winner of AIBTC x Bitflow Skills Pay the Bills competition Day 1. Original author: @secret-mars Competition PR: https://github.com/BitflowFinance/bff-skills/pull/11