$npx -y skills add okx/onchainos-skills --skill okx-defiOKX-aggregated DeFi (no specific DApp named) — product discovery, deposit/withdraw/claim execution, AND positions viewing. **If the user names ANY third-party protocol/DApp (Aave, Lido, PancakeSwap, Uniswap, Curve, Compound, Morpho, Pendle, Kamino, Raydium, Hyperliquid, Polymarke
| 1 | # OKX DeFi (experimental merge of okx-defi-invest + okx-defi-portfolio) |
| 2 | |
| 3 | Multi-chain, OKX-aggregated DeFi in two capabilities behind one skill. Both wrap the same `onchainos defi` CLI command group. |
| 4 | |
| 5 | ## Pre-flight Checks |
| 6 | |
| 7 | > Read `../okx-agentic-wallet/_shared/preflight.md`. If that file does not exist, read `_shared/preflight.md` instead. |
| 8 | |
| 9 | ## Intent Routing |
| 10 | |
| 11 | | User Intent | Reference | |
| 12 | |---|---| |
| 13 | | Discover / search DeFi products, find best APY | [invest.md](references/invest.md) | |
| 14 | | Product detail (APY, TVL, accepted tokens) | [invest.md](references/invest.md) | |
| 15 | | Deposit / stake / provide liquidity | [invest.md](references/invest.md) | |
| 16 | | Withdraw / redeem a position (full or partial) | [invest.md](references/invest.md) | |
| 17 | | Claim rewards (platform / investment / V3 fee / bonus / unlocked principal) | [invest.md](references/invest.md) | |
| 18 | | APY history, TVL history, V3 depth / price charts | [invest.md](references/invest.md) | |
| 19 | | View DeFi positions / holdings overview (持仓) | [portfolio.md](references/portfolio.md) | |
| 20 | | Per-protocol position detail (持仓详情) | [portfolio.md](references/portfolio.md) | |
| 21 | | Exact parameters / return schemas — invest & charts commands | [invest-cli-reference.md](references/invest-cli-reference.md) | |
| 22 | | Exact parameters / return schemas — positions commands | [portfolio-cli-reference.md](references/portfolio-cli-reference.md) | |
| 23 | | Errors / failed deposits / expired calldata | [invest-troubleshooting.md](references/invest-troubleshooting.md) | |
| 24 | | Errors / empty positions / address-format issues | [portfolio-troubleshooting.md](references/portfolio-troubleshooting.md) | |
| 25 | |
| 26 | Typical flow spans both: view positions (Portfolio) → redeem or claim (Invest). Read both reference files when the request chains them. |
| 27 | |
| 28 | ## Skill Routing |
| 29 | |
| 30 | - For DApp-named investing/lending/staking/positions ("on Aave", "my Hyperliquid balance") → use `okx-dapp-discovery` |
| 31 | - For token price/chart or token search by name/contract → use `okx-dex-market` |
| 32 | - For DEX spot swap execution → use `okx-agentic-wallet` |
| 33 | - For wallet token balances → use `okx-agentic-wallet` |
| 34 | - For broadcasting signed transactions → use `okx-agentic-wallet` |
| 35 | - For Agentic Wallet login, balance, contract-call → use `okx-agentic-wallet` |
| 36 | |
| 37 | ## Chain Support |
| 38 | |
| 39 | CLI resolves chain names automatically (e.g. `ethereum` → `1`, `bsc` → `56`, `solana` → `501`). Full alias table: `references/portfolio.md` §Chain Support. |
| 40 | |
| 41 | ## Step 0: Address Resolution (shared by both capabilities) |
| 42 | |
| 43 | When the user does NOT provide a wallet address, resolve it automatically from the Agentic Wallet **before** running any defi command: |
| 44 | |
| 45 | ``` |
| 46 | 1. onchainos wallet status → check if logged in, get active account |
| 47 | 2. onchainos wallet addresses → get addresses grouped by chain category: |
| 48 | - XLayer addresses |
| 49 | - EVM addresses (Ethereum, BSC, Polygon, etc.) |
| 50 | - Solana addresses |
| 51 | 3. Match address to target chain: |
| 52 | - EVM chains → use EVM address |
| 53 | - Solana → use Solana address |
| 54 | - XLayer → use XLayer address |
| 55 | ``` |
| 56 | |
| 57 | Rules: |
| 58 | - If the user provides an explicit address, use it directly — skip this step |
| 59 | - If wallet is not logged in, ask the user to log in first (→ `okx-agentic-wallet`) or provide an address manually |
| 60 | - 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 |
| 61 | - Always confirm the resolved address with the user before proceeding if the account has multiple addresses of the same type |
| 62 | |
| 63 | ## Address-Chain Compatibility (shared — CRITICAL) |
| 64 | |
| 65 | 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). |
| 66 | |
| 67 | - `0x…` address → only pass EV |