| name | tronclaw-defi |
| description | Use this skill for TRON DeFi operations: query yield rates on SunSwap and JustLend, get AI-powered yield optimization strategies, or execute token swaps. TRIGGER: "收益", "DeFi", "yield", "APY", "swap", "兑换", "优化", "JustLend", "SunSwap"
|
| version | 1.0.0 |
TronClaw DeFi Skill
Call TronClaw Gateway REST API for DeFi operations on TRON.
Setup
const GATEWAY = process.env.TRONCLAW_GATEWAY ?? 'http://localhost:3000'
async function tron(path, method = 'GET', body = null) {
const res = await fetch(`${GATEWAY}${path}`, {
method,
headers: { 'Content-Type': 'application/json' },
body: body ? JSON.stringify(body) : undefined,
})
return (await res.json()).data
}
Query DeFi Yields
const pools = await tron('/api/v1/defi/yields?protocol=all')
AI Yield Optimizer
const strategy = await tron('/api/v1/defi/optimize', 'POST', {
portfolio: [
{ token: 'USDT', amount: '1000' },
{ token: 'TRX', amount: '500' },
],
riskPreference: 'low'
})
Swap Tokens (SunSwap)
const swap = await tron('/api/v1/defi/swap', 'POST', {
fromToken: 'TRX',
toToken: 'USDT',
amount: '100',
slippage: 0.5
})
Supply to JustLend
const lend = await tron('/api/v1/defi/lend', 'POST', {
token: 'USDT',
amount: '500'
})
Demo Scenario
User: "帮我把1000 USDT找个低风险的最优收益策略"
→ Call /api/v1/defi/optimize with portfolio=[{token:"USDT",amount:"1000"}], riskPreference="low"
→ Present strategy with APY and steps to user