okx-defi-portfolio
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOKX DeFi Portfolio
OKX DeFi Portfolio
2 commands for viewing DeFi positions and holdings across protocols and chains.
2个用于跨协议、跨链查看DeFi头寸与持仓的命令。
Skill Routing
Skill 路由规则
- 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
- 若需进行DeFi存入/赎回/领取操作 → 使用
okx-defi-invest - 若需查询代币价格/行情图 → 使用
okx-dex-market - 若需查询钱包代币余额 → 使用
okx-wallet-portfolio - 若需进行DEX现货兑换 → 使用
okx-dex-swap
Quickstart
快速开始
bash
undefinedbash
undefinedGet DeFi holdings overview across chains
获取跨链DeFi持仓概览
onchainos defi positions
--address 0xYourWallet
--chains ethereum,bsc,solana
--address 0xYourWallet
--chains ethereum,bsc,solana
onchainos defi positions
--address 0xYourWallet
--chains ethereum,bsc,solana
--address 0xYourWallet
--chains ethereum,bsc,solana
Get detailed holdings for a specific protocol (analysisPlatformId from positions output)
获取特定协议的详细持仓信息(positions输出中的analysisPlatformId)
onchainos defi position-detail
--address 0xYourWallet
--chain ethereum
--platform-id 67890
--address 0xYourWallet
--chain ethereum
--platform-id 67890
undefinedonchainos defi position-detail
--address 0xYourWallet
--chain ethereum
--platform-id 67890
--address 0xYourWallet
--chain ethereum
--platform-id 67890
undefinedCommand Index
命令索引
| # | Command | Description |
|---|---|---|
| 1 | | Get user DeFi holdings overview |
| 2 | | Get detailed holdings for a protocol |
| # | 命令 | 描述 |
|---|---|---|
| 1 | | 获取用户DeFi持仓概览 |
| 2 | | 获取特定协议的详细持仓信息 |
Chain Support
支持的链
| Chain | Name / Aliases | chainIndex |
|---|---|---|
| Ethereum | | |
| BSC | | |
| Polygon | | |
| Arbitrum | | |
| Base | | |
| X Layer | | |
| Avalanche | | |
| Optimism | | |
| Fantom | | |
| Sui | | |
| Tron | | |
| TON | | |
| Linea | | |
| Scroll | | |
| zkSync | | |
| Solana | | |
| 链 | 名称/别名 | chainIndex |
|---|---|---|
| Ethereum | | |
| BSC | | |
| Polygon | | |
| Arbitrum | | |
| Base | | |
| X Layer | | |
| Avalanche | | |
| Optimism | | |
| Fantom | | |
| Sui | | |
| Tron | | |
| TON | | |
| Linea | | |
| Scroll | | |
| zkSync | | |
| Solana | | |
Operation Flow
操作流程
Step 0: Address Resolution
步骤0:地址解析
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 addressRules:
- 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 (→ ) or provide an address manually
okx-agentic-wallet - If the user says "check all accounts" or "all wallets", use to get all account IDs, then
wallet balance --all+wallet switch <id>for each account, and query positions for eachwallet addresses - Always confirm the resolved address with the user before proceeding if the account has multiple addresses of the same type
当用户未提供钱包地址时,需先通过Agentic Wallet自动解析地址,再执行任何DeFi命令:
1. onchainos wallet status → 检查是否已登录,获取活跃账户
2. onchainos wallet addresses → 获取按链分类的地址:
- XLayer地址
- EVM地址(Ethereum、BSC、Polygon等)
- Solana地址
3. 匹配地址与目标链:
- EVM链 → 使用EVM地址
- Solana → 使用Solana地址
- XLayer → 使用XLayer地址规则:
- 若用户提供了明确地址,直接使用该地址——跳过此步骤
- 若钱包未登录,先提示用户登录(→ )或手动提供地址
okx-agentic-wallet - 若用户说“检查所有账户”或“所有钱包”,使用获取所有账户ID,然后对每个账户执行
wallet balance --all+wallet switch <id>,再查询每个账户的头寸wallet addresses - 若账户存在多个同类型地址,必须先与用户确认解析出的地址,再继续操作
Step 1: Identify Intent
步骤1:识别用户意图
| User says | Action |
|---|---|
| View positions / portfolio / holdings | |
| View detail for a protocol | |
| Redeem / claim after viewing | Suggest → use |
| 用户表述 | 操作 |
|---|---|
| 查看头寸/投资组合/持仓 | |
| 查看某一协议的详情 | |
| 查看后要进行赎回/领取 | 建议→ 使用 |
Step 2: Collect Parameters
步骤2:收集参数
- 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 first to get
defi positionsanalysisPlatformId
- 缺少钱包地址 → 通过步骤0解析(钱包状态→钱包地址),若未登录则询问用户
- 缺少链参数 → 询问用户要查询哪些链,或推荐常用链(ethereum、bsc、solana)
- 缺少platform-id → 先执行获取
defi positionsanalysisPlatformId
Step 3: Display Results
步骤3:展示结果
Displaying Positions Results
展示positions结果
When displaying output, you MUST use exactly these columns in this order — no substitutions, no omissions:
defi positions| # | Platform | analysisPlatformId | Chains | Positions | Value(USD) |
|---|---|---|---|---|---|
| 1 | Aave V3 | 12345 | ETH,BSC | 2 | $120.00 |
Rules:
- is MANDATORY in every row — users must copy this value to run
analysisPlatformIdposition-detail - Never omit, hide, or replace with any other field
analysisPlatformId - Never group platforms — show every platform as its own row regardless of value size
- Raw JSON path: — each element is one platform row
walletIdPlatformList[*].platformList[*]- → Platform
platformName - → analysisPlatformId
analysisPlatformId - → Chains (join with comma)
networkBalanceList[*].network - → Positions
investmentCount - → Value(USD)
currencyAmount
展示输出时,必须严格按照以下顺序使用这些列——不得替换、不得遗漏:
defi positions| # | 平台 | analysisPlatformId | 链 | 头寸数量 | 价值(USD) |
|---|---|---|---|---|---|
| 1 | Aave V3 | 12345 | ETH,BSC | 2 | $120.00 |
规则:
- 每行必须包含——用户需要复制该值来执行
analysisPlatformIdposition-detail - **不得省略、隐藏或替换**为其他字段
analysisPlatformId - 不得对平台进行分组——无论价值大小,每个平台单独显示为一行
- 原始JSON路径:——每个元素对应一行平台数据
walletIdPlatformList[*].platformList[*]- → 平台
platformName - → analysisPlatformId
analysisPlatformId - → 链(用逗号连接)
networkBalanceList[*].network - → 头寸数量
investmentCount - → 价值(USD)
currencyAmount
Displaying Position Detail Results
展示position-detail结果
Output shape: — is an array. Never call on directly; iterate over it as a list.
{ "ok": true, "data": [ { "walletIdPlatformDetailList": [...] }, ... ] }data.get()dataWhen displaying output, render all tokens in a single flat table with these exact columns:
defi position-detail| 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 and
investmentIdfrom its parent investment entryaggregateProductId - is MANDATORY in every row — users need it for
investmentId/redeem(viaclaim)okx-defi-invest - — show if present, otherwise
aggregateProductId– - 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 show
–Platform 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
输出格式: —— 是一个数组。请勿直接对调用;需将其作为列表遍历。
{ "ok": true, "data": [ { "walletIdPlatformDetailList": [...] }, ... ] }datadata.get()展示输出时,需将所有代币渲染为单一扁平表格,并使用以下列:
defi position-detail| 类型 | 资产 | 数量 | 价值(USD) | investmentId | aggregateProductId | 代币合约 | 奖励 |
|---|---|---|---|---|---|---|---|
| 供给 | USDT | 1.002285 | $1.0025 | 127 | 71931 | 0x970223...7 | 0.000080 AVAX |
| 待领取 | sAVAX | 0.00000091 | $0.000012 | – | – | – | 平台奖励 |
规则:
- 每个代币对应一行;将其父级投资条目中的和
investmentId合并到该行aggregateProductId - 每行必须包含——用户在执行赎回/领取操作时(通过
investmentId)需要该值okx-defi-invest - ——若存在则显示,否则显示
aggregateProductId– - 代币合约:显示完整合约地址,不得截断;若为原生代币或为空则显示
– - 奖励:若有待领取奖励则显示奖励数量+代币符号,否则显示;平台奖励显示
–Platform reward - 类型:将investType映射为供给/借贷/质押/流动性挖矿/资金池等;待领取奖励行使用
待领取 - 健康率:若,需在表格下方单独显示并给出警告
healthRate < 1.5
investType Reference
investType 参考
| 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 |
| investType | 描述 |
|---|---|
| 1 | 储蓄(生息产品) |
| 2 | 资金池(流动性池) |
| 3 | 流动性挖矿 |
| 4 | 金库 |
| 5 | 质押 |
| 6 | 借贷 |
| 7 | 质押(Staking) |
| 8 | 锁仓 |
| 9 | 存入 |
| 10 | 解锁(Vesting) |
Post-execution Suggestions
执行后建议
| Just completed | Suggest |
|---|---|
| 1. View detail → |
| 1. Redeem position → use |
| 刚完成的操作 | 建议 |
|---|---|
| 1. 查看详情→ |
| 1. 赎回头寸→使用 |
Global Notes
全局注意事项
- CRITICAL — Address-chain compatibility: The and
--addressparameters must be compatible. EVM addresses (--chains) can only query EVM chains; Solana addresses (base58) can only query0x…. Never mix them in a single call — the API will return error 84019 (Address format error).solana- address → only pass EVM chains:
0x…ethereum,bsc,polygon,arbitrum,base,xlayer,avalanche,optimism,fantom,linea,scroll,zksync - base58 address → only pass
solana - Sui address → only pass
sui - Tron address () → only pass
T…tron - TON address → only pass
ton - If the user wants positions across both EVM and Solana, make two separate calls with the respective addresses
- uses
defi positions(plural, comma-separated, e.g.--chains) — do NOT use--chains ethereum,bsc--chain - uses
defi position-detail(singular) — do NOT use--chain--chains - The wallet address parameter is for both commands
--address - requires
position-detailfromanalysisPlatformIdoutput aspositions--platform-id - The CLI resolves chain names automatically (→
ethereum,1→bsc,56→solana)501
- 关键注意事项——地址与链的兼容性:和
--address参数必须兼容。EVM地址(--chains)仅可查询EVM链;Solana地址(base58格式)仅可查询0x…。请勿在单次调用中混合使用——否则API会返回错误码84019(地址格式错误)。solana- 地址 → 仅传入EVM链:
0x…ethereum,bsc,polygon,arbitrum,base,xlayer,avalanche,optimism,fantom,linea,scroll,zksync - base58地址 → 仅传入
solana - Sui地址 → 仅传入
sui - Tron地址()→ 仅传入
T…tron - TON地址 → 仅传入
ton - 若用户要同时查询EVM和Solana上的头寸,需分两次调用,分别使用对应地址
- 使用
defi positions(复数,逗号分隔,例如--chains)——请勿使用--chains ethereum,bsc--chain - 使用
defi position-detail(单数)——请勿使用--chain--chains - 两个命令的钱包地址参数均为
--address - 需要
position-detail输出中的positions作为analysisPlatformId参数--platform-id - CLI会自动解析链名称(→
ethereum,1→bsc,56→solana)501