Loading...
Loading...
DeFi operations on Stacks — ALEX DEX token swaps and liquidity pool queries, plus Zest Protocol lending (supply, withdraw, borrow, repay, claim rewards). All operations are mainnet-only. Write operations require an unlocked wallet.
npx skill4agent add aibtcdev/skills defibun run wallet/wallet.ts unlockbun run defi/defi.ts <subcommand> [options]bun run defi/defi.ts alex-get-swap-quote --token-x <contractId> --token-y <contractId> --amount-in <units>--token-xSP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx-v2STXALEX--token-y--amount-in{
"network": "mainnet",
"quote": {
"tokenIn": "SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx-v2",
"tokenOut": "SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.token-alex",
"amountIn": "1000000",
"expectedAmountOut": "52341",
"route": ["STX", "ALEX"]
}
}bun run defi/defi.ts alex-swap --token-x <contractId> --token-y <contractId> --amount-in <units> [--min-amount-out <units>]--token-x--token-y--amount-in--min-amount-out{
"success": true,
"txid": "abc123...",
"swap": {
"tokenIn": "SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx-v2",
"tokenOut": "SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.token-alex",
"amountIn": "1000000",
"minAmountOut": "0"
},
"network": "mainnet",
"explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet"
}bun run defi/defi.ts alex-get-pool-info --token-x <contractId> --token-y <contractId>--token-x--token-y{
"network": "mainnet",
"pool": {
"poolId": "SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx-v2-SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.token-alex",
"tokenX": "SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx-v2",
"tokenY": "SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.token-alex",
"reserveX": "5000000000",
"reserveY": "12000000000",
"totalShares": "8000000000"
}
}bun run defi/defi.ts alex-list-pools [--limit <n>]--limit{
"network": "mainnet",
"poolCount": 3,
"pools": [
{
"id": 1,
"pair": "wstx-v2/alex",
"tokenX": "SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx-v2",
"tokenY": "SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.token-alex",
"factor": "100000000"
}
],
"usage": "Use the tokenX and tokenY contract IDs with alex-get-swap-quote or alex-swap"
}bun run defi/defi.ts zest-list-assets{
"network": "mainnet",
"assetCount": 3,
"assets": [
{
"symbol": "sBTC",
"name": "Stacked Bitcoin",
"contractId": "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token"
},
{
"symbol": "stSTX",
"name": "Stacked STX",
"contractId": "SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token"
}
],
"usage": "Use the symbol (e.g., 'stSTX') or full contract ID in other zest-* commands"
}bun run defi/defi.ts zest-get-position --asset <symbolOrContractId> [--address <addr>]--assetstSTXaeUSDC--address{
"network": "mainnet",
"address": "SP2...",
"position": {
"asset": "SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token",
"supplied": "5000000",
"borrowed": "0"
}
}bun run defi/defi.ts zest-supply --asset <symbolOrContractId> --amount <units> [--on-behalf-of <addr>]--asset--amount--on-behalf-of{
"success": true,
"txid": "abc123...",
"action": "supply",
"asset": "SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token",
"amount": "5000000",
"onBehalfOf": "SP2...",
"network": "mainnet",
"explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet"
}bun run defi/defi.ts zest-withdraw --asset <symbolOrContractId> --amount <units>--asset--amount{
"success": true,
"txid": "abc123...",
"action": "withdraw",
"asset": "SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token",
"amount": "5000000",
"network": "mainnet",
"explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet"
}bun run defi/defi.ts zest-borrow --asset <symbolOrContractId> --amount <units>--asset--amount{
"success": true,
"txid": "abc123...",
"action": "borrow",
"asset": "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token",
"amount": "100000",
"network": "mainnet",
"explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet"
}bun run defi/defi.ts zest-repay --asset <symbolOrContractId> --amount <units> [--on-behalf-of <addr>]--asset--amount--on-behalf-of{
"success": true,
"txid": "abc123...",
"action": "repay",
"asset": "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token",
"amount": "100000",
"onBehalfOf": "SP2...",
"network": "mainnet",
"explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet"
}bun run defi/defi.ts zest-claim-rewards [--asset <symbolOrContractId>]--assetsBTC{
"success": true,
"txid": "abc123...",
"action": "claim_rewards",
"asset": "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token",
"rewardAsset": "wSTX",
"network": "mainnet",
"explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet",
"note": "Rewards will be sent to your wallet once the transaction confirms."
}STXALEXalex-list-poolsstSTXaeUSDCsBTCzest-list-assetsbun run wallet/wallet.ts unlock