Summary
zest_withdraw and zest_repay MCP tools fail for positions that live on the newer v0-4-market contracts (SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-4-market). The tools only target the legacy v2 contracts.
Reproduction
- Have a position on
SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-4-market (confirmed via v0-market-vault.get-position)
- Call
zest_withdraw(asset="sBTC", amount="102976") → tx aborts with (err none)
- Call
zest_repay(asset="sBTC", amount="1") → tx aborts with (err u30000)
Failed TXs:
Root Cause
The MCP server's Zest implementation calls SP2VCQJGH7PHP2DJK7Z0V48AGBHQAW3R3ZW1QF4N.borrow-helper-v2-1-5 with:
- LP:
zsbtc-v2-0
- Pool reserve:
pool-0-reserve-v2-0
- Oracle:
stx-btc-oracle-v1-4
These are the legacy Zest v2 contracts. Positions that were migrated (or created) on the v0-4-market (SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7) are invisible to these tools because:
zest_get_position queries the v2 pool — returns 0/0 for migrated positions
zest_withdraw calls borrow-helper-v2-1-5.withdraw — no position found → (err none)
zest_repay calls borrow-helper-v2-1-5.repay — no position found → (err u30000)
Position Data (confirmed on-chain)
Calling SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-market-vault.get-position returns:
- Collateral: asset ID 3, amount 102,976 (zsBTC shares)
- Debt: asset ID 2, scaled 1 (dust)
- Position ID: 415
What's Needed
The v0-4-market contract exposes different functions:
collateral-remove(ft, amount, receiver, price-feeds) — withdraw collateral
collateral-remove-redeem(ft, amount, min-underlying, receiver, price-feeds) — withdraw + redeem to underlying
repay(ft, amount, on-behalf-of) — repay debt
To support v0-4-market positions, the MCP server needs:
- A way to detect which market version holds a user's position (v2 vs v4)
- New contract references for v4: the correct zsBTC ft trait, Pyth price feed buffers
- Updated
zest_get_position to also query v0-market-vault.get-position
- Updated
zest_withdraw / zest_repay to route to the correct contract version
Environment
- MCP server version: v1.33.1
- Network: mainnet
- Wallet:
SP4DXVEC16FS6QR7RBKGWZYJKTXPC81W49W0ATJE
🤖 Generated with Claude Code
Summary
zest_withdrawandzest_repayMCP tools fail for positions that live on the newer v0-4-market contracts (SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-4-market). The tools only target the legacy v2 contracts.Reproduction
SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-4-market(confirmed viav0-market-vault.get-position)zest_withdraw(asset="sBTC", amount="102976")→ tx aborts with(err none)zest_repay(asset="sBTC", amount="1")→ tx aborts with(err u30000)Failed TXs:
42579342f52264c8e449ab3221d37e241447e3ff41df14cf543b398dfe631ade496dbf8ce4441b9eaa55cdb39ef0297dacf03ba56624d06477d04839a6f856caRoot Cause
The MCP server's Zest implementation calls
SP2VCQJGH7PHP2DJK7Z0V48AGBHQAW3R3ZW1QF4N.borrow-helper-v2-1-5with:zsbtc-v2-0pool-0-reserve-v2-0stx-btc-oracle-v1-4These are the legacy Zest v2 contracts. Positions that were migrated (or created) on the v0-4-market (
SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7) are invisible to these tools because:zest_get_positionqueries the v2 pool — returns 0/0 for migrated positionszest_withdrawcallsborrow-helper-v2-1-5.withdraw— no position found →(err none)zest_repaycallsborrow-helper-v2-1-5.repay— no position found →(err u30000)Position Data (confirmed on-chain)
Calling
SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-market-vault.get-positionreturns:What's Needed
The v0-4-market contract exposes different functions:
collateral-remove(ft, amount, receiver, price-feeds)— withdraw collateralcollateral-remove-redeem(ft, amount, min-underlying, receiver, price-feeds)— withdraw + redeem to underlyingrepay(ft, amount, on-behalf-of)— repay debtTo support v0-4-market positions, the MCP server needs:
zest_get_positionto also queryv0-market-vault.get-positionzest_withdraw/zest_repayto route to the correct contract versionEnvironment
SP4DXVEC16FS6QR7RBKGWZYJKTXPC81W49W0ATJE🤖 Generated with Claude Code