OKX DeFi
Discover and manage multi-chain, OKX-aggregated DeFi products and positions through the onchainos defi CLI group.
Preflight
Preflight checks: At the start of each thread, complete the checks in ../okx-agentic-wallet/_shared/preflight.md. If missing, read _shared/preflight.md.
Intent Routing
Load only the reference files required by the selected route.
| User Intent |
Reference |
| Discover / search DeFi products, find best APY |
invest.md |
| Product detail (APY, TVL, accepted tokens) |
invest.md |
| Deposit / stake / provide liquidity |
invest.md |
| Withdraw / redeem a position (full or partial) |
invest.md |
| Claim rewards (platform / investment / V3 fee / bonus / unlocked principal) |
invest.md |
| APY history, TVL history, V3 depth / price charts |
invest.md |
| View DeFi positions / holdings overview |
portfolio.md |
| Per-protocol position detail |
portfolio.md |
| Exact parameters / return schemas — invest, shared support, and charts commands |
invest-cli-reference.md |
| Exact parameters / return schemas — positions commands |
portfolio-cli-reference.md |
| Errors / failed deposits / expired calldata |
invest-troubleshooting.md |
| Errors / empty positions / address-format issues |
portfolio-troubleshooting.md |
Typical flow spans both: view positions (Portfolio) → redeem or claim (Invest). Read both reference files when the request chains them.
Route a named third-party DApp request—including protocol-specific APY, TVL,
volume, history, or timeframe analysis—to okx-dapp-discovery. Generic
cross-protocol yield/APY/TVL and V3-liquidity analysis stays here. Route token
search/price/chart requests to okx-dex-market, and spot swaps, wallet
balances, login, contract calls, or transaction broadcasts to
okx-agentic-wallet.
Chain Name Support
The CLI resolves chain names automatically (for example, ethereum → 1, bsc → 56, solana → 501). Use the Chain Support table in portfolio.md for the DeFi-specific aliases.
Security
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 --all to get all account IDs, then wallet switch <id> + wallet addresses for each account
- Always confirm the resolved address with the user before proceeding if the account has multiple addresses of the same type
Address-Chain Compatibility
The --address and chain parameters must be compatible. EVM addresses (0x…) can only query EVM chains; Solana addresses (base58) can only query solana. Never mix them — 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
Global Notes
- The wallet address parameter for ALL defi commands is
--address
defi positions uses --chains (plural, comma-separated); defi position-detail uses --chain (singular)
- Before reporting completion, verify the selected command succeeded, apply the output format and safety checks from its routed reference, and report any partial or failed on-chain step explicitly.
1---2name: okx-defi3description: "Discover and manage OKX-aggregated DeFi products and positions across protocols and chains. Use for generic or venue-agnostic yield, APY, or TVL discovery and history; DeFi deposits, staking, liquidity, withdrawals, rewards, lending, CLMM analysis; and DeFi portfolio or position views. Requests targeting a named protocol belong to DApp discovery. Triggers include earn yield, best APY, DeFi product, APY/TVL history, deposit, stake, withdraw, redeem, provide or remove liquidity, claim rewards, borrow or repay, CLMM, V3 liquidity charts, DeFi portfolio, and DeFi holdings."4license: MIT5metadata:6 source: https://skillmd.com/skills/jiayaoqijia/okx-defi7 author: okx8 version: "4.6.11"9 homepage: "https://web3.okx.com"10---1112# OKX DeFi1314Discover and manage multi-chain, OKX-aggregated DeFi products and positions through the `onchainos defi` CLI group.1516## Preflight1718Preflight checks: At the start of each thread, complete the checks in `../okx-agentic-wallet/_shared/preflight.md`. If missing, read `_shared/preflight.md`.1920## Intent Routing2122Load only the reference files required by the selected route.2324| User Intent | Reference |25|---|---|26| Discover / search DeFi products, find best APY | [invest.md](references/invest.md) |27| Product detail (APY, TVL, accepted tokens) | [invest.md](references/invest.md) |28| Deposit / stake / provide liquidity | [invest.md](references/invest.md) |29| Withdraw / redeem a position (full or partial) | [invest.md](references/invest.md) |30| Claim rewards (platform / investment / V3 fee / bonus / unlocked principal) | [invest.md](references/invest.md) |31| APY history, TVL history, V3 depth / price charts | [invest.md](references/invest.md) |32| View DeFi positions / holdings overview | [portfolio.md](references/portfolio.md) |33| Per-protocol position detail | [portfolio.md](references/portfolio.md) |34| Exact parameters / return schemas — invest, shared support, and charts commands | [invest-cli-reference.md](references/invest-cli-reference.md) |35| Exact parameters / return schemas — positions commands | [portfolio-cli-reference.md](references/portfolio-cli-reference.md) |36| Errors / failed deposits / expired calldata | [invest-troubleshooting.md](references/invest-troubleshooting.md) |37| Errors / empty positions / address-format issues | [portfolio-troubleshooting.md](references/portfolio-troubleshooting.md) |3839Typical flow spans both: view positions (Portfolio) → redeem or claim (Invest). Read both reference files when the request chains them.4041Route a named third-party DApp request—including protocol-specific APY, TVL,42volume, history, or timeframe analysis—to `okx-dapp-discovery`. Generic43cross-protocol yield/APY/TVL and V3-liquidity analysis stays here. Route token44search/price/chart requests to `okx-dex-market`, and spot swaps, wallet45balances, login, contract calls, or transaction broadcasts to46`okx-agentic-wallet`.4748## Chain Name Support4950The CLI resolves chain names automatically (for example, `ethereum` → `1`, `bsc` → `56`, `solana` → `501`). Use the Chain Support table in [portfolio.md](references/portfolio.md) for the DeFi-specific aliases.5152## Security5354### Address Resolution5556When the user does NOT provide a wallet address, resolve it automatically from the Agentic Wallet **before** running any defi command:5758```591. onchainos wallet status → check if logged in, get active account602. onchainos wallet addresses → get addresses grouped by chain category:61 - XLayer addresses62 - EVM addresses (Ethereum, BSC, Polygon, etc.)63 - Solana addresses643. Match address to target chain:65 - EVM chains → use EVM address66 - Solana → use Solana address67 - XLayer → use XLayer address68```6970Rules:71- If the user provides an explicit address, use it directly — skip this step72- If wallet is not logged in, ask the user to log in first (→ `okx-agentic-wallet`) or provide an address manually73- 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 account74- Always confirm the resolved address with the user before proceeding if the account has multiple addresses of the same type7576### Address-Chain Compatibility7778The `--address` and chain parameters must be compatible. EVM addresses (`0x…`) can only query EVM chains; Solana addresses (base58) can only query `solana`. Never mix them — the API will return error 84019 (Address format error).7980- `0x…` address → only pass EVM chains: `ethereum,bsc,polygon,arbitrum,base,xlayer,avalanche,optimism,fantom,linea,scroll,zksync`81- base58 address → only pass `solana`82- Sui address → only pass `sui`; Tron address (`T…`) → only pass `tron`; TON address → only pass `ton`83- If the user wants positions across both EVM and Solana, make **two separate calls** with the respective addresses8485## Global Notes8687- The wallet address parameter for ALL defi commands is `--address`88- `defi positions` uses `--chains` (plural, comma-separated); `defi position-detail` uses `--chain` (singular)89- Before reporting completion, verify the selected command succeeded, apply the output format and safety checks from its routed reference, and report any partial or failed on-chain step explicitly.