zest-yield-manager

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Zest Yield Manager

Zest收益管理器

What it does

功能介绍

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.
在Zest Protocol(Stacks L2)上管理sBTC借贷仓位。将闲置sBTC供应至协议以获取借款人支付的收益,监控仓位健康状况,领取wSTX激励奖励,并在需要时提取资产。所有操作均通过Zest经过审计的池借贷合约执行,使用Pyth预言机价格喂价。

Why agents need it

为什么Agent需要它

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.
任何持有sBTC的Agent都会面临闲置资本的机会成本损失。本Skill可自动化供应/提取/领取奖励的循环,让Agent无需手动干预即可赚取收益。它会处理Pyth预言机费用、后置条件以及困扰手动操作者的borrow-helper版本问题。

On-chain proof

链上证明

Tested on Stacks mainnet with real sBTC (agent address
SP4DXVEC16FS6QR7RBKGWZYJKTXPC81W49W0ATJE
):
OperationTxidBlockResult
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.
已在Stacks主网使用真实sBTC测试(Agent地址
SP4DXVEC16FS6QR7RBKGWZYJKTXPC81W49W0ATJE
):
操作交易ID区块高度结果
供应1000聪
8f9eed21...
7,352,592
(ok true)
提取1000聪
a61c7b59...
7,352,600
(ok true)
完整往返流程已验证:主网上的供应和提取操作均成功。

Safety notes

安全说明

  • Writes to chain. Supply and withdraw submit Stacks transactions (cost ~50k uSTX gas + ~2 uSTX Pyth fee).
  • Moves funds. sBTC leaves the wallet when supplied; returns on withdraw. Funds are in Zest's audited lending pool, not a custodial address.
  • Mainnet only. Zest Protocol is deployed on Stacks mainnet.
  • Supply-only. v1 does not implement borrowing. Borrowing is not available — there is no
    --allow-borrow
    flag. Future versions may add borrow support with explicit opt-in and liquidation safeguards.
  • Spend limit enforced. Default max supply per call: 500,000 sats (
    DEFAULT_MAX_SUPPLY_SATS
    ). Override with
    --max-supply-sats
    . Amounts above the limit return a
    blocked
    status — the skill refuses to proceed.
  • Pre-flight checks. Before any write operation, the skill validates: (1) STX gas balance >= 100,000 uSTX, (2) sBTC balance >= requested amount, (3) amount within spend limit. If any check fails, the skill returns
    blocked
    with a specific error code and suggested fix.
  • No transaction simulation. Broadcasting relies on pre-flight checks plus Zest contract-level validation. Transaction simulation (stxer dry-run) is not yet implemented.
  • Withdrawal always allowed. No confirmation gate on withdrawing your own funds (but position size is validated).
  • 写入区块链:供应和提取操作会提交Stacks交易(成本约50k uSTX gas + 约2 uSTX Pyth费用)。
  • 转移资金:供应时sBTC会离开钱包;提取时返回。资金存放在Zest经过审计的借贷池中,而非托管地址。
  • 仅支持主网:Zest Protocol部署在Stacks主网。
  • 仅供应功能:v1版本未实现借贷功能。当前不支持借贷——没有
    --allow-borrow
    参数。未来版本可能会添加借贷支持,并包含明确的 opt-in 机制和清算保护措施。
  • 执行额度限制:默认每次调用的最大供应额度为500,000聪(
    DEFAULT_MAX_SUPPLY_SATS
    )。可通过
    --max-supply-sats
    参数覆盖。超过限额的请求会返回
    blocked
    状态——Skill将拒绝执行。
  • 预执行检查:在任何写入操作前,Skill会验证:(1) STX gas余额 >= 100,000 uSTX,(2) sBTC余额 >= 请求金额,(3) 金额在执行限额内。若任何检查失败,Skill会返回
    blocked
    状态,并附带具体错误代码和建议修复方案。
  • 无交易模拟:交易广播依赖预执行检查和Zest合约层面的验证。暂未实现交易模拟(stxer dry-run)。
  • 提取不受限制:提取自有资金无需确认门槛(但会验证仓位规模)。

Commands

命令

doctor

doctor

Checks wallet STX balance (for gas), sBTC balance, Zest contract availability, current position, and pending rewards. Safe to run anytime — read-only.
bash
bun run zest-yield-manager/zest-yield-manager.ts doctor
检查钱包的STX余额(用于gas)、sBTC余额、Zest合约可用性、当前仓位状态以及待领取奖励。任何时候都可安全运行——仅读取数据。
bash
bun run zest-yield-manager/zest-yield-manager.ts doctor

run

run

Core execution. Accepts sub-commands:
Check position (default, read-only):
bash
bun run zest-yield-manager/zest-yield-manager.ts run --action=status
Supply sBTC to earn yield:
bash
bun run zest-yield-manager/zest-yield-manager.ts run --action=supply --amount=50000
Withdraw sBTC from pool:
bash
bun run zest-yield-manager/zest-yield-manager.ts run --action=withdraw --amount=50000
Claim wSTX incentive rewards:
bash
bun run zest-yield-manager/zest-yield-manager.ts run --action=claim
核心执行命令。接受子命令:
检查仓位状态(默认,仅读取):
bash
bun run zest-yield-manager/zest-yield-manager.ts run --action=status
供应sBTC以赚取收益:
bash
bun run zest-yield-manager/zest-yield-manager.ts run --action=supply --amount=50000
从池中提取sBTC:
bash
bun run zest-yield-manager/zest-yield-manager.ts run --action=withdraw --amount=50000
领取wSTX激励奖励:
bash
bun run zest-yield-manager/zest-yield-manager.ts run --action=claim

install-packs

install-packs

Checks and reports on required dependencies:
@stacks/transactions
,
@stacks/network
.
bash
bun run zest-yield-manager/zest-yield-manager.ts install-packs --pack all
检查并报告所需依赖:
@stacks/transactions
@stacks/network
bash
bun run zest-yield-manager/zest-yield-manager.ts install-packs --pack all

Output contract

输出格式

All outputs are JSON to stdout. The
status
field determines how the agent should route:
Status check (
--action=status
):
json
{
  "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
):
json
{
  "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):
json
{
  "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.
所有输出均为JSON格式并打印至标准输出。
status
字段决定Agent的后续处理逻辑:
状态检查(
--action=status
):
json
{
  "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
}
供应/提取/领取奖励(
--action=supply|withdraw|claim
):
json
{
  "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
}
被阻止(安全检查失败):
json
{
  "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"
  }
}
关键字段:
  • rewards_pending_ustx
    (数字)——待领取的wSTX激励奖励,单位为microSTX。若该值
    > 0
    则可考虑领取奖励。
  • mcp_command
    ——Agent框架需执行的精确MCP工具调用及参数。
  • pre_checks_passed
    ——生成交易 payload 前通过的安全检查项。

Known constraints

已知限制

  • Requires STX for gas (~50,000 uSTX per transaction). Doctor command checks this.
  • Pyth oracle must be reachable (Zest uses it for price feeds). Rare outages possible.
  • Zest uses borrow-helper-v2-1-7 on mainnet. Older versions will fail.
  • Withdrawal may fail if pool utilization is 100% (all supplied funds are borrowed). Retry later.
  • wSTX reward claims return 0 if no rewards have accrued since last claim.
  • v1 is supply-only. Borrowing is not implemented and there is no flag to enable it.
  • 交易需要STX作为gas(每笔交易约50,000 uSTX)。doctor命令会检查此条件。
  • 必须能连接到Pyth预言机(Zest使用其提供价格喂价)。可能出现罕见的停机情况。
  • Zest在主网上使用的是borrow-helper-v2-1-7版本。旧版本会执行失败。
  • 若池利用率为100%(所有供应资金均被借出),提取操作可能失败。请稍后重试。
  • 若自上次领取后未产生任何奖励,wSTX奖励领取操作会返回0。
  • v1版本仅支持供应功能。未实现借贷功能,也没有启用借贷的参数。

Origin

起源

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
AIBTC x Bitflow Skills Pay the Bills比赛第一天的获胜作品。 原作者:@secret-mars 比赛PR:https://github.com/BitflowFinance/bff-skills/pull/11