okx-cex-earn

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OKX CEX Earn CLI

OKX CEX 赚币 CLI工具

Prerequisites

前提条件

  1. Install
    okx
    CLI:
    bash
    npm install -g @okx_ai/okx-trade-cli
  2. Configure credentials:
    bash
    okx config add-profile AK=<your_api_key> SK=<your_secret_key> PP=<your_passphrase> name=live
    # or interactive wizard:
    okx config init
  3. Verify:
    okx --profile live earn savings balance

  1. 安装
    okx
    CLI:
    bash
    npm install -g @okx_ai/okx-trade-cli
  2. 配置凭证:
    bash
    okx config add-profile AK=<your_api_key> SK=<your_secret_key> PP=<your_passphrase> name=live
    # 或使用交互式向导:
    okx config init
  3. 验证:
    okx --profile live earn savings balance

Credential & Profile Check

凭证与配置文件检查

Run
okx config show
before any authenticated command.
  • Error or no configuration → stop, guide user to run
    okx config init
    , wait for completion.
  • Credentials configured → proceed.
OKX Earn does not support demo mode. Always use
--profile live
silently — don't mention it unless there's an error.
On 401 errors: stop immediately, tell the user their credentials may be invalid or expired, guide them to update
~/.okx/config.toml
(do NOT ask them to paste credentials into chat), then verify with
okx config show
and retry.

在执行任何需要认证的命令之前,请先运行
okx config show
  • 出现错误或无配置 → 停止操作,引导用户运行
    okx config init
    ,等待配置完成。
  • 已配置凭证 → 继续操作。
OKX赚币不支持演示模式。请默认使用
--profile live
参数——除非出现错误,否则无需提及该参数。
**遇到401错误时:**立即停止操作,告知用户其凭证可能无效或已过期,引导他们更新
~/.okx/config.toml
(请勿要求用户在聊天中粘贴凭证),然后使用
okx config show
验证并重试。

Skill Routing

技能路由

User intentRoute to skill
Market prices, tickers, candles
okx-cex-market
Spot / swap / futures / options orders
okx-cex-trade
Account balance, positions, transfers
okx-cex-portfolio
Grid / DCA trading bots
okx-cex-bot
Simple Earn, On-chain Earn, or Dual Investment (双币赢)This skill

用户意图路由至技能
市场价格、行情、K线
okx-cex-market
现货/永续/期货/期权订单
okx-cex-trade
账户余额、持仓、转账
okx-cex-portfolio
网格/DCA交易机器人
okx-cex-bot
活期赚币、链上赚币或双币赢本技能

Command Index

命令索引

earn savings — Simple Earn (7 commands)

earn savings — 活期赚币(7个命令)

CommandTypeAuthDescription
earn savings balance [ccy]
READRequiredSavings balance (all or specific currency)
earn savings purchase --ccy --amt
WRITERequiredSubscribe funds to Simple Earn
earn savings redeem --ccy --amt
WRITERequiredRedeem funds from Simple Earn
earn savings set-rate --ccy --rate
WRITERequiredSet minimum lending rate
earn savings lending-history
READRequiredLending records with earnings detail
earn savings rate-summary [ccy]
READRequiredMarket lending rate summary
earn savings rate-history
READRequiredHistorical lending rates
For full command syntax, rate field semantics, and confirmation templates, read
{baseDir}/references/savings-commands.md
.
命令类型认证要求描述
earn savings balance [ccy]
读取必填储蓄余额(全部或特定币种)
earn savings purchase --ccy --amt
写入必填申购活期赚币产品
earn savings redeem --ccy --amt
写入必填赎回活期赚币产品
earn savings set-rate --ccy --rate
写入必填设置最低借贷利率
earn savings lending-history
读取必填借贷记录及收益详情
earn savings rate-summary [ccy]
读取必填市场借贷利率汇总
earn savings rate-history
读取必填借贷利率历史数据
如需完整命令语法、利率字段语义及确认模板,请参阅
{baseDir}/references/savings-commands.md

earn dcd — Dual Investment / 双币赢 (10 commands)

earn dcd — 双币赢(DCD/双币赢,10个命令)

CommandTypeAuthDescription
earn dcd pairs
READRequiredAvailable DCD currency pairs
earn dcd products
READRequiredActive products with filters
earn dcd quote --productId --sz --notionalCcy
READRequiredRequest real-time quote (TTL 30s)
earn dcd buy --quoteId
WRITERequiredExecute an existing quote
earn dcd quote-and-buy --productId --sz --notionalCcy
WRITERequiredQuote + execute in one step (AI preferred)
earn dcd order --ordId
READRequiredQuick state check for a single order
earn dcd orders
READRequiredFull order list / history
earn dcd redeem-quote --ordId
READRequiredEarly redemption preview (TTL 15s)
earn dcd redeem-execute --ordId
WRITERequiredRe-quote + execute redemption (AI preferred)
earn dcd redeem --ordId --quoteId
WRITERequiredExecute redemption with existing quoteId (low-level)
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
.
命令类型认证要求描述
earn dcd pairs
读取必填可用DCD币种对
earn dcd products
读取必填在售产品(支持筛选)
earn dcd quote --productId --sz --notionalCcy
读取必填请求实时报价(有效期30秒)
earn dcd buy --quoteId
写入必填执行已有报价
earn dcd quote-and-buy --productId --sz --notionalCcy
写入必填报价+申购一步完成(AI推荐使用)
earn dcd order --ordId
读取必填单个订单状态快速查询
earn dcd orders
读取必填全部订单列表/历史记录
earn dcd redeem-quote --ordId
读取必填提前赎回预览(有效期15秒)
earn dcd redeem-execute --ordId
写入必填重新报价+执行赎回(AI推荐使用)
earn dcd redeem --ordId --quoteId
写入必填使用已有quoteId执行赎回(底层命令)
DCD 支持演示/模拟交易模式。请始终使用
--profile live
参数。
如需完整命令语法、产品概念及错误码说明,请参阅
{baseDir}/references/dcd-commands.md

earn onchain — On-chain Earn (6 commands)

earn onchain — 链上赚币(6个命令)

CommandTypeAuthDescription
earn onchain offers
READRequiredAvailable staking/DeFi products
earn onchain purchase --productId --ccy --amt
WRITERequiredSubscribe to on-chain product
earn onchain redeem --ordId --protocolType
WRITERequiredRedeem on-chain investment
earn onchain cancel --ordId --protocolType
WRITERequiredCancel pending on-chain order
earn onchain orders
READRequiredActive on-chain orders
earn onchain history
READRequiredHistorical on-chain orders
For full command syntax and parameters, read
{baseDir}/references/onchain-commands.md
.

命令类型认证要求描述
earn onchain offers
读取必填可用质押/DeFi产品
earn onchain purchase --productId --ccy --amt
写入必填申购链上赚币产品
earn onchain redeem --ordId --protocolType
写入必填赎回链上投资产品
earn onchain cancel --ordId --protocolType
写入必填取消待处理的链上订单
earn onchain orders
读取必填活跃链上订单
earn onchain history
读取必填链上订单历史记录
如需完整命令语法及参数说明,请参阅
{baseDir}/references/onchain-commands.md

Operation Flow

操作流程

Step 0 — Credential & Profile Check

步骤0 — 凭证与配置文件检查

Before any authenticated command: see Credential & Profile Check. Always use
--profile live
silently.
在执行任何需要认证的命令之前:请参阅凭证与配置文件检查。请默认使用
--profile live
参数。

Step 1 — Identify earn intent

步骤1 — 识别赚币意图

Simple Earn / On-chain Earn:
  • Query balance / history / rates → READ command, proceed directly.
  • Subscribe / redeem / set-rate / on-chain purchase → WRITE command, go to Step 2.
When user asks to view "earn positions" or "赚币持仓" (regardless of whether they mention DCD explicitly), query all three simultaneously:
bash
okx --profile live earn savings balance --json    # Simple Earn
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: translate state codes using the table in
{baseDir}/references/dcd-commands.md
.
Dual Investment (DCD / 双币赢):
  • 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)
For multi-step workflows (idle fund analysis, subscribe + verify, redeem + transfer, on-chain subscribe), read
{baseDir}/references/workflows.md
.
活期赚币/链上赚币:
  • 查询余额/历史记录/利率 → 使用读取命令,直接执行。
  • 申购/赎回/设置利率/链上申购 → 使用写入命令,进入步骤2。
当用户要求查看"赚币持仓"或"赚币持仓"时(无论是否明确提及DCD),请同时查询三类产品:
bash
okx --profile live earn savings balance --json    # 活期赚币
okx --profile live earn onchain orders --json     # 链上赚币
okx --profile live earn dcd orders --json         # 双币赢
仅展示有实际持仓的部分。对于DCD:请使用
{baseDir}/references/dcd-commands.md
中的表格翻译状态码。
双币赢(DCD/双币赢):
  • 浏览产品/币种对 → 读取操作;当用户指定币种时,请在渲染产品表格前参阅
    {baseDir}/references/workflows.md
    (DCD浏览流程)进行强制并行预获取
  • 申购(quote-and-buy) → 写入操作 → 参阅
    {baseDir}/references/workflows.md
    (DCD申购流程)
  • 提前赎回 → 写入操作 → 参阅
    {baseDir}/references/workflows.md
    (DCD提前赎回流程)
对于多步骤流程(闲置资金分析、申购+验证、赎回+转账、链上申购),请参阅
{baseDir}/references/workflows.md

Step 2 — Confirm write operation

步骤2 — 确认写入操作

For all WRITE commands, present a summary and wait for explicit confirmation.
"just do it" / "直接搞" is NOT valid confirmation — the user must see the summary first.
For Simple Earn confirmation dialog format, read
{baseDir}/references/savings-commands.md
. For On-chain confirmation, read
{baseDir}/references/onchain-commands.md
.
对于所有写入命令,请展示操作摘要并等待用户明确确认。
"直接操作" / "直接搞" 不属于有效确认——用户必须先看到操作摘要。
活期赚币确认对话框格式请参阅
{baseDir}/references/savings-commands.md
。链上赚币确认格式请参阅
{baseDir}/references/onchain-commands.md

Step 3 — Execute and verify

步骤3 — 执行与验证

After any purchase, verify based on product type:
  • DCD
    quote-and-buy
    succeeded → run
    earn dcd orders --json
    , show only the matching order.
  • On-chain purchase (response contains
    ordId
    ) → run
    earn onchain orders --json
    , show only the matching order.
  • Simple Earn purchase (no
    ordId
    in response) → run
    earn savings balance --ccy <ccy> --json
    .
Simple Earn purchase: Run in parallel —
earn savings balance --ccy <ccy>
and
earn savings rate-history --ccy <ccy> --limit 1 --json
. For output format, read
{baseDir}/references/savings-commands.md
.
Simple Earn redeem: Run
earn savings balance --ccy <ccy>
to confirm updated balance. Inform user funds returned to funding account.
On-chain redeem: Query
earn onchain orders
to confirm state. Show
estSettlementTime
as estimated arrival time.
On-chain cancel: Query
earn onchain orders
after submission:
  • Order gone from list → inform user: cancellation complete, funds returned to funding account.
  • state: 3
    (cancelling) → inform user: cancellation in progress, funds will return to funding account shortly.

完成任何申购操作后,请根据产品类型进行验证:
  • DCD
    quote-and-buy
    成功后 → 执行
    earn dcd orders --json
    ,仅展示匹配的订单。
  • 链上赚币申购成功后(响应包含
    ordId
    ) → 执行
    earn onchain orders --json
    ,仅展示匹配的订单。
  • 活期赚币申购成功后(响应无
    ordId
    ) → 执行
    earn savings balance --ccy <ccy> --json
活期赚币申购: 并行执行以下命令 —
earn savings balance --ccy <ccy>
earn savings rate-history --ccy <ccy> --limit 1 --json
。输出格式请参阅
{baseDir}/references/savings-commands.md
活期赚币赎回: 执行
earn savings balance --ccy <ccy>
确认余额更新。告知用户资金已返回资金账户。
链上赚币赎回: 查询
earn onchain orders
确认状态。将
estSettlementTime
展示为预计到账时间。
链上赚币取消订单: 提交取消请求后查询
earn onchain orders
  • 订单已从列表中消失 → 告知用户:取消完成,资金将返回资金账户。
  • state: 3
    (取消中) → 告知用户:取消操作进行中,资金将很快返回资金账户。

Global Notes

全局注意事项

  • Security: Never ask users to paste API keys or secrets into chat.
  • Output: Always pass
    --json
    to list/query commands and render results as a Markdown table — never paste raw terminal output.
  • Network errors: If commands fail with a connection error, prompt user to check VPN:
    curl -I https://www.okx.com
  • Language: Always respond in the user's language.
For number/time formatting and response structure conventions, read
{baseDir}/references/templates.md
.
  • **安全:**切勿要求用户在聊天中粘贴API密钥或机密信息。
  • **输出:**对列表/查询命令始终添加
    --json
    参数,并将结果渲染为Markdown表格——切勿粘贴原始终端输出。
  • **网络错误:**如果命令因连接错误失败,提示用户检查VPN:
    curl -I https://www.okx.com
  • **语言:**始终使用用户的语言回复。
有关数字/时间格式和响应结构约定,请参阅
{baseDir}/references/templates.md