mirror of
https://github.com/okx/agent-skills.git
synced 2026-09-14 13:28:20 +08:00
Merge branch 'fix/okx-cex-earn-post-merge' into 'master'
fix(earn): post-merge bug fixes for okx-cex-earn See merge request retail-ai/agent-skills!26
This commit is contained in:
@@ -33,8 +33,6 @@ metadata:
|
||||
```
|
||||
3. Verify: `okx --profile live earn savings balance`
|
||||
|
||||
> `earn savings rate-summary` and `earn savings rate-history` are public endpoints — no credentials required.
|
||||
|
||||
---
|
||||
|
||||
## Credential & Profile Check
|
||||
@@ -73,8 +71,8 @@ OKX Earn does not support demo mode. Always use `--profile live` silently — do
|
||||
| `earn savings redeem --ccy --amt` | WRITE | Required | Redeem funds from Simple Earn |
|
||||
| `earn savings set-rate --ccy --rate` | WRITE | Required | Set minimum lending rate |
|
||||
| `earn savings lending-history` | READ | Required | Lending records with earnings detail |
|
||||
| `earn savings rate-summary [ccy]` | READ | None | Market lending rate summary (public) |
|
||||
| `earn savings rate-history` | READ | None | Historical lending rates (public) |
|
||||
| `earn savings rate-summary [ccy]` | READ | Required | Market lending rate summary |
|
||||
| `earn savings rate-history` | READ | Required | Historical lending rates |
|
||||
|
||||
For full command syntax, rate field semantics, and confirmation templates, read `{baseDir}/references/savings-commands.md`.
|
||||
|
||||
@@ -82,18 +80,17 @@ For full command syntax, rate field semantics, and confirmation templates, read
|
||||
|
||||
| Command | Type | Auth | Description |
|
||||
|---|---|---|---|
|
||||
| `earn dcd pairs` | READ | None | Available DCD currency pairs |
|
||||
| `earn dcd products` | READ | None | Active products with filters |
|
||||
| `earn dcd quote --productId --notionalSz --notionalCcy` | READ | Required | Request real-time quote (TTL 30s) |
|
||||
| `earn dcd pairs` | READ | Required | Available DCD currency pairs |
|
||||
| `earn dcd products` | READ | Required | Active products with filters |
|
||||
| `earn dcd quote --productId --sz --notionalCcy` | READ | Required | Request real-time quote (TTL 30s) |
|
||||
| `earn dcd buy --quoteId` | WRITE | Required | Execute an existing quote |
|
||||
| `earn dcd quote-and-buy --productId --notionalSz --notionalCcy` | WRITE | Required | Quote + execute in one step (AI preferred) |
|
||||
| `earn dcd quote-and-buy --productId --sz --notionalCcy` | WRITE | Required | Quote + execute in one step (AI preferred) |
|
||||
| `earn dcd order --ordId` | READ | Required | Quick state check for a single order |
|
||||
| `earn dcd orders` | READ | Required | Full order list / history |
|
||||
| `earn dcd redeem-quote --ordId` | READ | Required | Early redemption preview (TTL 15s) |
|
||||
| `earn dcd redeem-execute --ordId` | WRITE | Required | Re-quote + execute redemption (AI preferred) |
|
||||
| `earn dcd redeem --ordId --quoteId` | WRITE | Required | Execute redemption with existing quoteId (low-level) |
|
||||
|
||||
> `earn dcd pairs` and `earn dcd products` are public endpoints — no credentials required.
|
||||
> DCD does **not** support demo/simulated trading mode. Always use `--profile live`.
|
||||
|
||||
For full command syntax, product concepts, and error codes, read `{baseDir}/references/dcd-commands.md`.
|
||||
@@ -133,10 +130,10 @@ okx --profile live earn onchain orders --json # On-chain Earn
|
||||
okx --profile live earn dcd orders --json # Dual Investment (双币赢)
|
||||
```
|
||||
|
||||
Only present sections that have actual holdings. For DCD: do NOT use `--state` parameter (API returns HTTP 400); translate state codes using the table in `{baseDir}/references/dcd-commands.md`.
|
||||
Only present sections that have actual holdings. For DCD: translate state codes using the table in `{baseDir}/references/dcd-commands.md`.
|
||||
|
||||
**Dual Investment (DCD / 双币赢):**
|
||||
- Browse products / pairs → public READ; when user specifies a currency, read `{baseDir}/references/workflows.md` (DCD browse flow) for the mandatory parallel pre-fetch before rendering the product table
|
||||
- Browse products / pairs → READ; when user specifies a currency, read `{baseDir}/references/workflows.md` (DCD browse flow) for the mandatory parallel pre-fetch before rendering the product table
|
||||
- Subscribe (quote-and-buy) → WRITE → see `{baseDir}/references/workflows.md` (DCD subscribe flow)
|
||||
- Early redeem → WRITE → see `{baseDir}/references/workflows.md` (DCD early redeem flow)
|
||||
|
||||
|
||||
@@ -33,18 +33,19 @@ Average index price between 15:00–16:00 (UTC+8) on the expiry date — not rea
|
||||
## earn dcd pairs
|
||||
|
||||
```bash
|
||||
okx earn dcd pairs
|
||||
okx --profile live earn dcd pairs
|
||||
```
|
||||
|
||||
Output fields: `baseCcy` · `quoteCcy` · `optType`
|
||||
> The API may return duplicate entries for the same (baseCcy, quoteCcy, optType) combination. Deduplicate client-side before displaying.
|
||||
|
||||
---
|
||||
|
||||
## earn dcd products
|
||||
|
||||
```bash
|
||||
okx earn dcd products --baseCcy BTC --quoteCcy USDT --optType C
|
||||
okx earn dcd products --baseCcy BTC --quoteCcy USDT --optType C --strikeNear 72000 --minYield 0.05 --maxTermDays 7
|
||||
okx --profile live earn dcd products --baseCcy BTC --quoteCcy USDT --optType C
|
||||
okx --profile live earn dcd products --baseCcy BTC --quoteCcy USDT --optType C --strikeNear 72000 --minYield 0.05 --maxTermDays 7
|
||||
```
|
||||
|
||||
| Parameter | Required | Description |
|
||||
@@ -90,16 +91,34 @@ okx earn dcd products --baseCcy BTC --quoteCcy USDT --optType C --strikeNear 720
|
||||
|
||||
---
|
||||
|
||||
## earn dcd quote-and-buy
|
||||
## earn dcd quote
|
||||
|
||||
Request a real-time quote (TTL 30s). Use `earn dcd buy --quoteId <id>` to execute, or prefer `quote-and-buy` to do both in one step.
|
||||
|
||||
```bash
|
||||
okx --profile live earn dcd quote-and-buy --productId BTC-USDT-260327-72000-CALL --notionalSz 100 --notionalCcy USDT
|
||||
okx --profile live earn dcd quote --productId BTC-USDT-260327-72000-C --sz 100 --notionalCcy USDT
|
||||
```
|
||||
|
||||
| Parameter | Required | Description |
|
||||
|---|---|---|
|
||||
| `--productId` | Yes | From `earn dcd products` |
|
||||
| `--notionalSz` | Yes | Notional size |
|
||||
| `--sz` | Yes | Notional size |
|
||||
| `--notionalCcy` | Yes | baseCcy or quoteCcy of the product |
|
||||
|
||||
Output fields: `quoteId` · `annualizedYield` · `absYield` · `notionalSz` · `notionalCcy` · `idxPx` · `validUntil`
|
||||
|
||||
---
|
||||
|
||||
## earn dcd quote-and-buy
|
||||
|
||||
```bash
|
||||
okx --profile live earn dcd quote-and-buy --productId BTC-USDT-260327-72000-C --sz 100 --notionalCcy USDT
|
||||
```
|
||||
|
||||
| Parameter | Required | Description |
|
||||
|---|---|---|
|
||||
| `--productId` | Yes | From `earn dcd products` |
|
||||
| `--sz` | Yes | Notional size |
|
||||
| `--notionalCcy` | Yes | baseCcy or quoteCcy of the product |
|
||||
| `--clOrdId` | No | Client order ID for idempotency |
|
||||
|
||||
@@ -133,10 +152,9 @@ okx --profile live earn dcd orders --ordId <id> --json
|
||||
| Parameter | Required | Description |
|
||||
|---|---|---|
|
||||
| `--ordId` | No | Specific order (ignores other filters) |
|
||||
| `--state` | No | Filter by order state (see State translation table below) |
|
||||
| `--limit` | No | Max results (default 100) |
|
||||
|
||||
> **Do NOT use `--state` parameter** — the API may reject it (HTTP 400). Query all orders and filter client-side.
|
||||
|
||||
**Always use `--json` flag** — render JSON as Markdown table, never paste raw CLI output.
|
||||
|
||||
**Display columns** (translate to user's language): index · order ID · product · term · invested amount · reference APR · yield · settlement amount (— if not settled) · status
|
||||
|
||||
@@ -55,9 +55,27 @@ okx --profile live earn onchain redeem --ordId 12345 --protocolType staking --al
|
||||
|---|---|---|
|
||||
| `--ordId` | Yes | Order ID |
|
||||
| `--protocolType` | Yes | `staking` or `defi` |
|
||||
| `--allowEarlyRedeem` | No | Allow early redemption (may incur penalty) |
|
||||
| `--allowEarlyRedeem` | No | Force early exit from a fixed-term product before maturity (may incur penalty) |
|
||||
|
||||
Show `estSettlementTime` as estimated arrival time. If early redemption, explicitly state any penalty. Wait for confirmation.
|
||||
### `earlyRedeem` field semantics
|
||||
|
||||
`earlyRedeem` is a field on the **order or product**, not the redeem command itself:
|
||||
|
||||
| Value | Meaning |
|
||||
|---|---|
|
||||
| `false` | No forced-early-exit option available. For **flexible products** (`term: 0`) this is irrelevant — normal redemption is always supported. For **fixed-term products** (`term > 0`) this means the lock cannot be broken early. |
|
||||
| `true` | Fixed-term product supports forced early exit via `--allowEarlyRedeem`, but a penalty applies. |
|
||||
|
||||
**Do NOT show an "early redemption not supported" warning** unless:
|
||||
- The product is **fixed-term** (`term > 0`), AND
|
||||
- The user explicitly wants to exit **before maturity**
|
||||
|
||||
For **flexible/open-ended products** (`term: 0`), normal redemption is always available — do not mention `earlyRedeem` at all.
|
||||
|
||||
**Pre-redeem confirmation** — include in the summary:
|
||||
- `estSettlementTime` → estimated arrival time
|
||||
- If `--allowEarlyRedeem` is used on a fixed-term product: explicitly state the penalty applies
|
||||
- For flexible products: no penalty note needed
|
||||
|
||||
> `cancelRedemptionDeadline` is returned by the API but cancelling a redemption is not supported — do not show this field.
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ okx --profile live earn savings purchase --ccy USDT --amt 1000 --rate 0.02
|
||||
|
||||
**Pre-execution checklist:**
|
||||
1. Check balance: `okx --profile live account asset-balance <ccy>` — verify user has sufficient funds; if insufficient, inform user and stop
|
||||
2. Fetch rates (in parallel with step 1): `earn savings rate-history --ccy <ccy> --limit 1 --json`
|
||||
2. Fetch rates (in parallel with step 1): `okx --profile live earn savings rate-history --ccy <ccy> --limit 1 --json`
|
||||
3. Show confirmation summary (see [Confirmation Templates](#confirmation-templates))
|
||||
4. Wait for user confirmation — if user declines, acknowledge and offer to adjust the amount or currency
|
||||
|
||||
@@ -77,11 +77,11 @@ Output fields: `ccy` · `amt` · `earnings` · `rate` · `ts`
|
||||
|
||||
## earn savings rate-summary
|
||||
|
||||
Public endpoint — no credentials required.
|
||||
Requires `--profile live`.
|
||||
|
||||
```bash
|
||||
okx earn savings rate-summary # all currencies
|
||||
okx earn savings rate-summary USDT
|
||||
okx --profile live earn savings rate-summary # all currencies
|
||||
okx --profile live earn savings rate-summary USDT
|
||||
```
|
||||
|
||||
Output fields: `ccy` · `avgRate` (historical average) · `estRate` (estimated) · `avgAmt`
|
||||
@@ -92,11 +92,11 @@ Output fields: `ccy` · `avgRate` (historical average) · `estRate` (estimated)
|
||||
|
||||
## earn savings rate-history
|
||||
|
||||
Public endpoint — no credentials required.
|
||||
Requires `--profile live`.
|
||||
|
||||
```bash
|
||||
okx earn savings rate-history --ccy USDT --limit 1 --json # current real APY
|
||||
okx earn savings rate-history --ccy USDT --limit 30 # recent trend
|
||||
okx --profile live earn savings rate-history --ccy USDT --limit 1 --json # current real APY
|
||||
okx --profile live earn savings rate-history --ccy USDT --limit 30 # recent trend
|
||||
```
|
||||
|
||||
| Parameter | Required | Description |
|
||||
|
||||
@@ -12,8 +12,8 @@ Found the following {CALL/PUT} Dual Investment products:
|
||||
|
||||
| # | Product | Target Price | vs Spot | Ref APR | Term | Expiry | Min. Size |
|
||||
|---|---------|-------------|---------|---------|------|--------|-----------|
|
||||
| 1 | BTC-USDT-260319-72000-CALL | $72,000 | ↑3.63% | 26.4% | 7d | Mar 19 | 0.001 BTC |
|
||||
| 2 | BTC-USDT-260319-73000-CALL | $73,000 | ↑5.08% | 8.3% | 7d | Mar 19 | 0.001 BTC |
|
||||
| 1 | BTC-USDT-260319-72000-C | $72,000 | ↑3.63% | 26.4% | 7d | Mar 19 | 0.001 BTC |
|
||||
| 2 | BTC-USDT-260319-73000-C | $73,000 | ↑5.08% | 8.3% | 7d | Mar 19 | 0.001 BTC |
|
||||
|
||||
Notes:
|
||||
- Target price closer to spot → higher trigger probability, higher ref APR
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
1. `okx --profile live account asset-balance <ccy>` → idle funds in funding account
|
||||
2. `okx --profile live account balance <ccy>` → idle funds in trading account
|
||||
3. `okx --profile live earn savings balance <ccy>` → already in earn
|
||||
4. `okx earn savings rate-history --ccy <ccy> --limit 1 --json` → current `rate` (threshold) and `lendingRate` (actual yield)
|
||||
4. `okx --profile live earn savings rate-history --ccy <ccy> --limit 1 --json` → current `rate` (threshold) and `lendingRate` (actual yield)
|
||||
→ summarize idle funds and suggest subscribing if lendingRate is acceptable
|
||||
|
||||
---
|
||||
@@ -18,12 +18,12 @@
|
||||
|
||||
1. Run in parallel:
|
||||
- `okx --profile live account asset-balance USDT` → verify balance ≥ 1000
|
||||
- `okx earn savings rate-history --ccy USDT --limit 1 --json` → current APY
|
||||
- `okx --profile live earn savings rate-history --ccy USDT --limit 1 --json` → current APY
|
||||
2. Show confirmation summary (see savings-commands.md), wait for user confirmation
|
||||
3. `okx --profile live earn savings purchase --ccy USDT --amt 1000`
|
||||
4. Run in parallel to verify:
|
||||
- `okx --profile live earn savings balance USDT --json` → confirm position updated
|
||||
- `okx earn savings rate-history --ccy USDT --limit 1 --json` → show current lendingRate in position summary
|
||||
- `okx --profile live earn savings rate-history --ccy USDT --limit 1 --json` → show current lendingRate in position summary
|
||||
|
||||
---
|
||||
|
||||
@@ -33,7 +33,10 @@
|
||||
|
||||
1. `okx --profile live earn savings balance USDT` → check redeemable amount; show summary, wait for confirmation
|
||||
2. `okx --profile live earn savings redeem --ccy USDT --amt <amt>`
|
||||
3. `okx --profile live account transfer --ccy USDT --amt <amt> --from 18 --to 6` (CLI account type IDs: 18=funding, 6=trading; run `okx account types` to confirm if needed)
|
||||
3. _(Optional — requires **Withdraw** permission on the API key)_
|
||||
`okx --profile live account transfer --ccy USDT --amt <amt> --from 18 --to 6` (CLI account type IDs: 18=funding, 6=trading)
|
||||
|
||||
If step 3 fails with a permission error, inform the user that their API key does not have Withdraw permission and they should complete the transfer manually in the OKX app.
|
||||
|
||||
---
|
||||
|
||||
@@ -55,9 +58,9 @@
|
||||
When user does **not** specify a currency pair, run in parallel:
|
||||
|
||||
```bash
|
||||
okx earn dcd pairs # supported pairs
|
||||
okx market ticker BTC-USDT # spot price
|
||||
okx earn dcd products --baseCcy BTC --quoteCcy USDT --optType <C|P> # default BTC-USDT
|
||||
okx --profile live earn dcd pairs # supported pairs
|
||||
okx --profile live market ticker BTC-USDT # spot price
|
||||
okx --profile live earn dcd products --baseCcy BTC --quoteCcy USDT --optType <C|P> # default BTC-USDT
|
||||
```
|
||||
|
||||
- Show BTC-USDT as default result
|
||||
@@ -106,7 +109,7 @@ Cross-skill: `okx-cex-market` for spot price, `okx-cex-portfolio` for balance if
|
||||
- Execute `earn dcd quote-and-buy` immediately, no extra confirmation step.
|
||||
|
||||
**Path B — Preview quote first:**
|
||||
1. `earn dcd quote --productId ... --notionalSz ... --notionalCcy ...`
|
||||
1. `earn dcd quote --productId ... --sz ... --notionalCcy ...`
|
||||
2. Show `annualizedYield`, `absYield`, `idxPx`, `validUntil` (quote expires in 30s)
|
||||
3. Explicitly warn the user the quote expires at `{validUntil}` and execution will be immediate upon confirmation.
|
||||
4. User confirms → `earn dcd buy --quoteId <quoteId>`
|
||||
@@ -143,7 +146,7 @@ This is the **only DCD WRITE operation requiring explicit user confirmation**.
|
||||
|
||||
"我想在72000卖出BTC"
|
||||
|
||||
1. `okx-cex-market` `okx market ticker BTC-USDT`
|
||||
2. `okx earn dcd products --baseCcy BTC --quoteCcy USDT --optType C --strikeNear 72000`
|
||||
1. `okx-cex-market` `okx --profile live market ticker BTC-USDT`
|
||||
2. `okx --profile live earn dcd products --baseCcy BTC --quoteCcy USDT --optType C --strikeNear 72000`
|
||||
→ explain CALL mechanics, show table, guide user to select term
|
||||
3. `okx --profile live earn dcd quote-and-buy --productId <id> --notionalSz <sz> --notionalCcy BTC`
|
||||
3. `okx --profile live earn dcd quote-and-buy --productId <id> --sz <sz> --notionalCcy BTC`
|
||||
|
||||
Reference in New Issue
Block a user