okx-defi-portfolio
OKX DeFi Portfolio
2 commands for viewing DeFi positions and holdings across protocols and chains.
Skill Routing
- For DeFi deposit/redeem/claim → use
okx-defi-invest - For token price/chart → use
okx-dex-market - For wallet token balances → use
okx-wallet-portfolio - For DEX spot swap → use
okx-dex-swap
Quickstart
# Get DeFi holdings overview across chains
onchainos defi positions \
--address 0xYourWallet \
--chains ethereum,bsc,solana
# Get detailed holdings for a specific protocol (analysisPlatformId from positions output)
onchainos defi position-detail \
--address 0xYourWallet \
--chain ethereum \
--platform-id 67890
Command Index
| # | Command | Description |
|---|---|---|
| 1 | onchainos defi support-chains |
Get supported chains for DeFi |
| 2 | onchainos defi support-platforms |
Get supported platforms for DeFi |
| 3 | onchainos defi positions --address <addr> --chains <chains> |
Get user DeFi holdings overview |
| 4 | onchainos defi position-detail --address <addr> --chain <chain> --platform-id <id> |
Get detailed holdings for a protocol |
Chain Support
| Chain | Name / Aliases | chainIndex |
|---|---|---|
| Ethereum | ethereum, eth |
1 |
| BSC | bsc, bnb |
56 |
| Polygon | polygon, matic |
137 |
| Arbitrum | arbitrum, arb |
42161 |
| Base | base |
8453 |
| X Layer | xlayer, okb |
196 |
| Avalanche | avalanche, avax |
43114 |
| Optimism | optimism, op |
10 |
| Fantom | fantom, ftm |
250 |
| Sui | sui |
784 |
| Tron | tron, trx |
195 |
| TON | ton |
607 |
| Linea | linea |
59144 |
| Scroll | scroll |
534352 |
| zkSync | zksync |
324 |
| Solana | solana, sol |
501 |
Operation Flow
Step 0: Address Resolution
When the user does NOT provide a wallet address, resolve it automatically from the Agentic Wallet before running any defi command:
1. onchainos wallet status → check if logged in, get active account
2. onchainos wallet addresses → get addresses grouped by chain category:
- XLayer addresses
- EVM addresses (Ethereum, BSC, Polygon, etc.)
- Solana addresses
3. Match address to target chain:
- EVM chains → use EVM address
- Solana → use Solana address
- XLayer → use XLayer address
Rules:
- If the user provides an explicit address, use it directly — skip this step
- If wallet is not logged in, ask the user to log in first (→
okx-agentic-wallet) or provide an address manually - If the user says "check all accounts" or "all wallets", use
wallet balance --allto get all account IDs, thenwallet switch <id>+wallet addressesfor each account, and query positions for each - Always confirm the resolved address with the user before proceeding if the account has multiple addresses of the same type
Step 1: Identify Intent
| User says | Action |
|---|---|
| View positions / portfolio / holdings | onchainos defi positions |
| View detail for a protocol | onchainos defi position-detail |
| Redeem / claim after viewing | Suggest → use okx-defi-invest |
Step 2: Collect Parameters
- Missing wallet address → resolve via Step 0 (wallet status → wallet addresses), or ask user if not logged in
- Missing chains → ask user which chains to query, or suggest common ones (ethereum, bsc, solana)
- Missing platform-id → run
defi positionsfirst to getanalysisPlatformId
Step 3: Display Results
Displaying Positions Results
When displaying defi positions output, you MUST use exactly these columns in this order — no substitutions, no omissions:
| # | Platform | analysisPlatformId | Chains | Positions | Value(USD) |
|---|---|---|---|---|---|
| 1 | Aave V3 | 12345 | ETH,BSC | 2 | $120.00 |
Rules:
analysisPlatformIdis MANDATORY in every row — users must copy this value to runposition-detail- Never omit, hide, or replace
analysisPlatformIdwith any other field - Never group platforms — show every platform as its own row regardless of value size
- Raw JSON path:
walletIdPlatformList[*].platformList[*]— each element is one platform rowplatformName→ PlatformanalysisPlatformId→ analysisPlatformIdnetworkBalanceList[*].network→ Chains (join with comma)investmentCount→ PositionscurrencyAmount→ Value(USD)
Displaying Position Detail Results
Output shape: { "ok": true, "data": [ { "walletIdPlatformDetailList": [...] }, ... ] } — data is an array. Never call .get() on data directly; iterate over it as a list.
When displaying defi position-detail output, render all tokens in a single flat table with these exact columns:
| Type | Asset | Amount | Value(USD) | investmentId | aggregateProductId | Token Contract | Rewards |
|---|---|---|---|---|---|---|---|
| Supply | USDT | 1.002285 | $1.0025 | 127 | 71931 | 0x970223...7 | 0.000080 AVAX |
| Pending | sAVAX | 0.00000091 | $0.000012 | – | – | – | Platform reward |
Rules:
- Each token row is one row; merge in
investmentIdandaggregateProductIdfrom its parent investment entry investmentIdis MANDATORY in every row — users need it forredeem/claim(viaokx-defi-invest)aggregateProductId— show if present, otherwise–- Token Contract: show the full contract address without truncation; show
–if native/empty - Rewards: show pending reward amount + symbol if present,
–if none; for platform rewards showPlatform reward - Type: map investType → Supply/Borrow/Stake/Farm/Pool etc; pending rewards row uses
Pending - Health rate: show separately below the table with warning if
healthRate < 1.5
V3 Pool Positions — Extra Fields
For V3 Pool positions (positionList present), show an additional section per position:
| tokenId | Status | Range | tickLower | tickUpper |
|---|---|---|---|---|
| 93828 | ACTIVE | 0.892 – 0.992 USDC/DAI | -33500 | -30450 |
tokenId: frompositionList[].tokenIdpositionStatus:ACTIVEorINACTIVErange: frompositionList[].rangetickLower/tickUpper: frompositionList[].rangeInfo.tickLower/rangeInfo.tickUpper- These fields are critical for V3 operations (add liquidity, withdraw, collect V3 fees)
investType Reference
| investType | Description |
|---|---|
| 1 | Save (savings/yield) |
| 2 | Pool (liquidity pool) |
| 3 | Farm (yield farming) |
| 4 | Vaults |
| 5 | Stake |
| 6 | Borrow |
| 7 | Staking |
| 8 | Locked |
| 9 | Deposit |
| 10 | Vesting |
Post-execution Suggestions
| Just completed | Suggest |
|---|---|
defi positions |
1. View detail → defi position-detail 2. Redeem → okx-defi-invest 3. Claim rewards → okx-defi-invest |
defi position-detail |
1. Redeem position → use okx-defi-invest with investmentId from table 2. Claim rewards → use okx-defi-invest 3. Add more → use okx-defi-invest |
defi position-detail (V3 Pool) |
1. View depth chart → defi depth-price-chart --investment-id <id> (via okx-defi-invest) 2. View price history → defi depth-price-chart --investment-id <id> --chart-type PRICE |
Global Notes
- CRITICAL — Address-chain compatibility: The
--addressand--chainsparameters must be compatible. EVM addresses (0x…) can only query EVM chains; Solana addresses (base58) can only querysolana. Never mix them in a single call — the API will return error 84019 (Address format error).0x…address → only pass EVM chains:ethereum,bsc,polygon,arbitrum,base,xlayer,avalanche,optimism,fantom,linea,scroll,zksync- base58 address → only pass
solana - Sui address → only pass
sui - Tron address (
T…) → only passtron - TON address → only pass
ton - If the user wants positions across both EVM and Solana, make two separate calls with the respective addresses
defi positionsuses--chains(plural, comma-separated, e.g.--chains ethereum,bsc) — do NOT use--chaindefi position-detailuses--chain(singular) — do NOT use--chains- The wallet address parameter is
--addressfor both commands position-detailrequiresanalysisPlatformIdfrompositionsoutput as--platform-id- The CLI resolves chain names automatically (
ethereum→1,bsc→56,solana→501)
More from okx/onchainos-skills
okx-dex-market
HARD BLOCK — NEVER use this skill for prediction-market / Polymarket UpDown queries. Route to okx-dapp-discovery when (a) a named DApp (Polymarket/Aave/Hyperliquid/PancakeSwap/Morpho) appears with any timeframe, OR (b) any 涨跌 / updown / 'up or down' phrase appears for BTC/ETH/SOL/XRP/BNB/DOGE/HYPE (e.g. '<COIN> 涨跌市场', '5 分钟涨跌', 'BTC up or down'). Example: 'BTC 5 分钟涨跌市场' → okx-dapp-discovery (NOT K-line). These are Polymarket prediction markets, not on-chain price queries. Use THIS skill for on-chain market data: token prices/价格, K-line/OHLC/candlestick/K线 charts, index prices, and wallet PnL/盈亏分析 (win rate, my wallet's DEX trade history, realized/unrealized PnL per token). Triggers: 'token price', 'price chart', 'K线', 'OHLC', 'how much is X worth', 'show my PnL', '胜率', '盈亏', 'my wallet DEX history', 'realized/unrealized profit'. NOTE: WebSocket script/脚本/bot → okx-dex-ws. ALSO the OWNER of Market API payment handling — route here (NOT okx-x402-payment) for: 'onchainos market 报 402', 'market price 402', 'market API pricing/计费/收费', Basic/Premium tier/quota/额度/免费额度, 'ok-web3-openapi-pay' header, 30 天过渡期/grace period, any MARKET_API_* notification code (NEW_USER_INTRO / OLD_USER_GRACE / OLD_USER_POST_GRACE_* / *_OVER_QUOTA), or 'confirming:true' response from onchainos market commands.
5.8Kokx-dex-token
Use this skill for token-level data: search tokens, trending/hot tokens (热门, 代币榜单), liquidity pools, holder distribution (whale/巨鲸, sniper, bundler-tagged holder %), token risk metadata (riskControlLevel, tokenTags, dev stats, suspicious/bundle holding % via advanced-info), recent buy/sell activity, trade feed/逐笔成交/每笔交易/stream trades, top profit addresses, token trade history, detailed price info with market cap volume liquidity and holder count (price-info), or holder cluster analysis (持仓集中度, cluster overview, cluster rug pull risk/跑路风险, new wallet percentage/新钱包持仓比例, holder clusters, 'are top holders in same cluster'). Also handles Market API payment/计费/x402/402, Basic/Premium tier/quota/额度 questions, and MARKET_API_*_OVER_QUOTA / confirming:true responses on token endpoints (advanced-info, top-trader, cluster-*, trades, hot-tokens). NOTE: if the user wants to write a WebSocket script/脚本/bot, use okx-dex-ws instead.
5.7Kokx-wallet-portfolio
Use this skill when the user provides a specific wallet address and wants to check its balance, token holdings, portfolio value, or DeFi positions. Typical triggers: 'check balance of 0xAbc...', 'show tokens in this address', 'what tokens does 0xAbc hold', 'portfolio value of this address', address portfolio value, multi-chain balance lookup for a given address. Supports XLayer, Solana, Ethereum, Base, BSC, Arbitrum, Polygon, and 20+ other chains. Do NOT use when the user asks about their own wallet without providing an address (e.g., 'check my wallet balance', 'show my assets', '查看我的余额') — use okx-agentic-wallet instead, which queries the logged-in wallet. Do NOT use for PnL analysis, DEX history, realized/unrealized profit — use okx-dex-market. Do NOT use for signal tracking — use okx-dex-signal. Do NOT use for meme scanning — use okx-dex-trenches. Do NOT use for programming questions about balance APIs or integration.
5.7Kokx-dex-swap
NOTE (gating): route to okx-dapp-discovery (NOT this skill) when prompt names a specific DApp as the swap venue: Polymarket, Aave V3, Hyperliquid, PancakeSwap, Morpho, Raydium, Curve, Compound V3, Pendle, Lido, ether.fi, GMX V2, Kamino, Orca, Meteora, Clanker, pump.fun, Uniswap. Examples that go to okx-dapp-discovery: 'swap on PancakeSwap', 'swap SOL for USDC on Raydium', 'use Hyperliquid to long ETH', '在 Curve 上换 USDT', 'swap on Uniswap'. okx-dapp-discovery installs the DApp's plugin and uses its native interface; this skill is for OKX-aggregated swaps without a named venue. Use this skill to 'swap tokens', 'trade OKB for USDC', 'buy tokens', 'sell tokens', 'exchange crypto', 'convert tokens', 'swap SOL for USDC', 'get a swap quote', 'execute a trade', 'find the best swap route', 'cheapest way to swap', 'optimal swap', 'compare swap rates', 'get swap calldata', 'build unsigned tx', or mentions swapping/trading/buying/selling/exchanging tokens across XLayer, Solana, Ethereum, Base, BSC, Arbitrum, Polygon, or any 20+ supported chains. Aggregates 500+ DEX sources for optimal routing/price. Supports slippage control, price impact protection, and cross-DEX route optimization.
5.7Kokx-onchain-gateway
Use this skill to 'broadcast transaction', 'send tx', 'estimate gas', 'simulate transaction', 'check tx status', 'track my transaction', 'get gas price', 'gas limit', 'broadcast signed tx', 'transaction hash confirmed on-chain', '交易哈希是否上链', '是否确认', or mentions broadcasting transactions, sending transactions on-chain, gas estimation, transaction simulation, tracking broadcast orders, or checking transaction status. Covers gas price, gas limit estimation, transaction simulation, transaction broadcasting, and order tracking across XLayer, Solana, Ethereum, Base, BSC, Arbitrum, Polygon, and 20+ other chains. Do NOT use for swap quote or execution - use okx-dex-swap instead. Do NOT use for general programming questions about transaction handling. Do NOT use when the user says only a single word like 'gas' or 'broadcast' without specifying a chain, transaction, or any other context.
5.6Kokx-dex-signal
Use this skill for smart-money/whale/KOL/大户 activity tracking, aggregated buy signal/信号 alerts, and leaderboard/牛人榜 rankings. Covers: (1) address tracker — raw DEX transaction feed for smart money, KOL, or custom wallet addresses; (2) aggregated buy-only signal alerts — tokens bought collectively by smart money/KOL/whales; (3) leaderboard — top traders by PnL, win rate, volume, or ROI. Use when the user asks 'what are smart money buying', '聪明钱最新交易', 'KOL交易动态', '追踪聪明钱', 'track address trades', '大户在买什么', 'whale signals', 'smart money alerts', '信号', '大户信号', 'top traders', '牛人榜', or wants to monitor notable wallet activity. Also handles Market API payment/计费/x402/402, Basic/Premium tier/quota/额度 questions, and MARKET_API_*_OVER_QUOTA / confirming:true responses on signal, leaderboard, or tracker endpoints. NOTE: if the user wants to write a WebSocket script/脚本/bot, use okx-dex-ws instead.
3.6K