okx-defi-portfolio

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OKX 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
undefined
bash
undefined

Get DeFi holdings overview across chains

获取跨链DeFi持仓概览

onchainos defi positions
--address 0xYourWallet
--chains ethereum,bsc,solana
onchainos defi positions
--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
undefined
onchainos defi position-detail
--address 0xYourWallet
--chain ethereum
--platform-id 67890
undefined

Command Index

命令索引

#CommandDescription
1
onchainos defi positions --address <addr> --chains <chains>
Get user DeFi holdings overview
2
onchainos defi position-detail --address <addr> --chain <chain> --platform-id <id>
Get detailed holdings for a protocol
#命令描述
1
onchainos defi positions --address <addr> --chains <chains>
获取用户DeFi持仓概览
2
onchainos defi position-detail --address <addr> --chain <chain> --platform-id <id>
获取特定协议的详细持仓信息

Chain Support

支持的链

ChainName / AliaseschainIndex
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
名称/别名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

步骤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 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 --all
    to get all account IDs, then
    wallet switch <id>
    +
    wallet addresses
    for 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
当用户未提供钱包地址时,需先通过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
    )或手动提供地址
  • 若用户说“检查所有账户”或“所有钱包”,使用
    wallet balance --all
    获取所有账户ID,然后对每个账户执行
    wallet switch <id>
    +
    wallet addresses
    ,再查询每个账户的头寸
  • 若账户存在多个同类型地址,必须先与用户确认解析出的地址,再继续操作

Step 1: Identify Intent

步骤1:识别用户意图

User saysAction
View positions / portfolio / holdings
onchainos defi positions
View detail for a protocol
onchainos defi position-detail
Redeem / claim after viewingSuggest → use
okx-defi-invest
用户表述操作
查看头寸/投资组合/持仓
onchainos defi positions
查看某一协议的详情
onchainos defi position-detail
查看后要进行赎回/领取建议→ 使用
okx-defi-invest

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
    defi positions
    first to get
    analysisPlatformId
  • 缺少钱包地址 → 通过步骤0解析(钱包状态→钱包地址),若未登录则询问用户
  • 缺少链参数 → 询问用户要查询哪些链,或推荐常用链(ethereum、bsc、solana)
  • 缺少platform-id → 先执行
    defi positions
    获取
    analysisPlatformId

Step 3: Display Results

步骤3:展示结果

Displaying Positions Results

展示positions结果

When displaying
defi positions
output, you MUST use exactly these columns in this order — no substitutions, no omissions:
#PlatformanalysisPlatformIdChainsPositionsValue(USD)
1Aave V312345ETH,BSC2$120.00
Rules:
  • analysisPlatformId
    is MANDATORY in every row
    — users must copy this value to run
    position-detail
  • Never omit, hide, or replace
    analysisPlatformId
    with 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 row
    • platformName
      → Platform
    • analysisPlatformId
      → analysisPlatformId
    • networkBalanceList[*].network
      → Chains (join with comma)
    • investmentCount
      → Positions
    • currencyAmount
      → Value(USD)
展示
defi positions
输出时,必须严格按照以下顺序使用这些列——不得替换、不得遗漏:
#平台analysisPlatformId头寸数量价值(USD)
1Aave V312345ETH,BSC2$120.00
规则:
  • 每行必须包含
    analysisPlatformId
    ——用户需要复制该值来执行
    position-detail
  • **不得省略、隐藏或替换
    analysisPlatformId
    **为其他字段
  • 不得对平台进行分组——无论价值大小,每个平台单独显示为一行
  • 原始JSON路径:
    walletIdPlatformList[*].platformList[*]
    ——每个元素对应一行平台数据
    • platformName
      → 平台
    • analysisPlatformId
      → analysisPlatformId
    • networkBalanceList[*].network
      → 链(用逗号连接)
    • investmentCount
      → 头寸数量
    • currencyAmount
      → 价值(USD)

Displaying Position Detail Results

展示position-detail结果

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:
TypeAssetAmountValue(USD)investmentIdaggregateProductIdToken ContractRewards
SupplyUSDT1.002285$1.0025127719310x970223...70.000080 AVAX
PendingsAVAX0.00000091$0.000012Platform reward
Rules:
  • Each token row is one row; merge in
    investmentId
    and
    aggregateProductId
    from its parent investment entry
  • investmentId
    is MANDATORY in every row
    — users need it for
    redeem
    /
    claim
    (via
    okx-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 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": [...] }, ... ] }
——
data
是一个数组。请勿直接对
data
调用
.get()
;需将其作为列表遍历。
展示
defi position-detail
输出时,需将所有代币渲染为单一扁平表格,并使用以下列:
类型资产数量价值(USD)investmentIdaggregateProductId代币合约奖励
供给USDT1.002285$1.0025127719310x970223...70.000080 AVAX
待领取sAVAX0.00000091$0.000012平台奖励
规则:
  • 每个代币对应一行;将其父级投资条目中的
    investmentId
    aggregateProductId
    合并到该行
  • 每行必须包含
    investmentId
    ——用户在执行赎回/领取操作时(通过
    okx-defi-invest
    )需要该值
  • aggregateProductId
    ——若存在则显示,否则显示
  • 代币合约:显示完整合约地址,不得截断;若为原生代币或为空则显示
  • 奖励:若有待领取奖励则显示奖励数量+代币符号,否则显示
    ;平台奖励显示
    Platform reward
  • 类型:将investType映射为供给/借贷/质押/流动性挖矿/资金池等;待领取奖励行使用
    待领取
  • 健康率:若
    healthRate < 1.5
    ,需在表格下方单独显示并给出警告

investType Reference

investType 参考

investTypeDescription
1Save (savings/yield)
2Pool (liquidity pool)
3Farm (yield farming)
4Vaults
5Stake
6Borrow
7Staking
8Locked
9Deposit
10Vesting
investType描述
1储蓄(生息产品)
2资金池(流动性池)
3流动性挖矿
4金库
5质押
6借贷
7质押(Staking)
8锁仓
9存入
10解锁(Vesting)

Post-execution Suggestions

执行后建议

Just completedSuggest
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 positions
1. 查看详情→
defi position-detail
2. 赎回→
okx-defi-invest
3. 领取奖励→
okx-defi-invest
defi position-detail
1. 赎回头寸→使用
okx-defi-invest
并带上表格中的
investmentId
2. 领取奖励→使用
okx-defi-invest
3. 追加投资→使用
okx-defi-invest

Global Notes

全局注意事项

  • CRITICAL — Address-chain compatibility: The
    --address
    and
    --chains
    parameters must be compatible. EVM addresses (
    0x…
    ) can only query EVM chains; Solana addresses (base58) can only query
    solana
    . 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 pass
      tron
    • TON address → only pass
      ton
    • If the user wants positions across both EVM and Solana, make two separate calls with the respective addresses
  • defi positions
    uses
    --chains
    (plural, comma-separated, e.g.
    --chains ethereum,bsc
    ) — do NOT use
    --chain
  • defi position-detail
    uses
    --chain
    (singular) — do NOT use
    --chains
  • The wallet address parameter is
    --address
    for both commands
  • position-detail
    requires
    analysisPlatformId
    from
    positions
    output as
    --platform-id
  • The CLI resolves chain names automatically (
    ethereum
    1
    ,
    bsc
    56
    ,
    solana
    501
    )
  • 关键注意事项——地址与链的兼容性
    --address
    --chains
    参数必须兼容。EVM地址(
    0x…
    )仅可查询EVM链;Solana地址(base58格式)仅可查询
    solana
    。请勿在单次调用中混合使用——否则API会返回错误码84019(地址格式错误)。
    • 0x…
      地址 → 仅传入EVM链:
      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