earn module

June 3, 2026 · View on GitHub

English | 中文


English

The earn module provides tools for OKX Earn products, split into three sub-modules:

Sub-moduleToolsDescription
earn.savings10Simple Earn: balance, purchase, redeem, lending rate management, rate history; Fixed-term: product query, order list, purchase (two-step), redeem
earn.onchain6On-chain Earn (staking/DeFi): offers, purchase, redeem, cancel, active orders, history
earn.dcd6Dual Currency Deposit (双币赢): currency pairs, products, atomic subscribe, two-step early redeem, order history

earn.savings — Simple Earn

Requires API key with Read permission. Write operations (purchase, redeem, set-rate) require Trade permission.

ToolDescription
earn_get_savings_balanceGet savings balance for all currencies or a specific one
earn_savings_purchasePurchase Simple Earn product (move funds into savings)
earn_savings_redeemRedeem Simple Earn product (withdraw funds from savings)
earn_set_lending_rateSet your lending rate preference
earn_get_lending_historyGet personal lending records (requires auth)
earn_get_lending_rate_historyQuery Simple Earn lending rates and fixed-term offers — use this when asking about current or historical lending rates (requires auth)
earn_get_fixed_earn_productsQuery available fixed-term products with APR, term, min investment, and remaining quota
earn_get_fixed_order_listGet fixed-term earn order list (filter by ccy/state)
earn_fixed_purchasePurchase fixed-term earn product (two-step: preview then confirm). Funds locked until maturity
earn_fixed_redeemRedeem a fixed-term earn order (full amount)

earn.onchain — On-chain Earn (staking/DeFi)

Requires API key with Read permission. Write operations require Trade permission. Not supported in demo/simulated trading mode — involves real fund movements.

ToolDescriptionWrite
onchain_earn_get_offersGet available staking/DeFi offers; always show protocol name (protocol field) and earnings currency (earningData[].ccy field)No
onchain_earn_purchasePurchase (invest in) a productYes
onchain_earn_redeemRedeem an investmentYes
onchain_earn_cancelCancel a pending purchaseYes
onchain_earn_get_active_ordersGet active investmentsNo
onchain_earn_get_order_historyGet investment historyNo

Example prompts

"What is my savings balance?"
"Purchase 1000 USDT into Simple Earn"
"Redeem 500 USDT from savings"
"Set my USDT lending rate to 2%"
"Show my lending history"
"What is the current USDT lending rate?"
"Show available fixed-term earn products for USDT"
"Purchase 1000 USDT into 90-day fixed earn"
"Show my fixed-term earn orders"
"Redeem my fixed-term order"
"Show me available ETH staking offers"
"What are my current on-chain earn positions?"
"Redeem my staking order 12345"

CLI

# --- earn.savings ---
okx earn savings balance
okx earn savings balance USDT
okx earn savings purchase --ccy USDT --amt 1000
okx earn savings purchase --ccy USDT --amt 1000 --rate 0.02
okx earn savings redeem --ccy USDT --amt 500
okx earn savings set-rate --ccy USDT --rate 0.02
okx earn savings lending-history --ccy USDT
okx earn savings rate-history --ccy USDT --limit 10

# --- earn.savings (fixed-term 定期) ---
okx earn savings fixed-orders
okx earn savings fixed-orders --ccy USDT --state earning
okx earn savings fixed-purchase --ccy USDT --amt 1000 --term 90D
okx earn savings fixed-purchase --ccy USDT --amt 1000 --term 90D --confirm
okx earn savings fixed-redeem <reqId>

# --- earn.onchain ---
okx earn onchain offers
okx earn onchain offers --ccy ETH
okx earn onchain offers --protocolType staking
okx earn onchain orders
okx earn onchain history
okx earn onchain purchase --productId xxx --ccy ETH --amt 1
okx earn onchain redeem --ordId 12345 --protocolType staking
okx earn onchain cancel --ordId 12345 --protocolType staking

MCP startup

# All modules including earn (earn is included in "all")
okx-trade-mcp --modules all

# All earn sub-modules only
okx-trade-mcp --modules earn

# Individual sub-modules
okx-trade-mcp --modules earn.savings
okx-trade-mcp --modules earn.onchain

earn.dcd — Dual Currency Deposit (双币赢)

Requires API key with Read permission. Write operations (buy, redeem) require Trade permission. Not supported in demo/simulated trading mode.

ToolDescriptionWrite
dcd_get_currency_pairsGet available DCD currency pairsNo
dcd_get_productsGet active DCD products with yield, strike, term infoNo
dcd_subscribeAtomic subscribe: request quote + execute in one step; optional minAnnualizedYield guardYes
dcd_redeemTwo-step early redeem: first call returns quote for confirmation; second call executes (auto-refreshes expired quote)Yes
dcd_get_order_stateQuery DCD order state by order IDNo
dcd_get_ordersGet DCD order history with optional filtersNo

Example prompts

"Show available DCD currency pairs"
"List BTC-USDT CALL products with at least 5% annual yield"
"Subscribe to BTC-USDT-260327-77000-C with 0.001 BTC, minimum yield 10%"
"Show my DCD orders"
"Redeem order 987654321 early"

CLI

# Query
okx earn dcd pairs
okx earn dcd products --baseCcy BTC --quoteCcy USDT --optType C
okx earn dcd products --baseCcy BTC --quoteCcy USDT --optType C --minYield 0.05 --maxTermDays 7
okx earn dcd products --baseCcy BTC --quoteCcy USDT --optType C --strikeNear 72000

# Subscribe (atomic: quote + execute in one step)
okx --profile live earn dcd quote-and-buy --productId BTC-USDT-260327-77000-C --sz 0.001 --notionalCcy BTC
okx --profile live earn dcd quote-and-buy --productId BTC-USDT-260327-77000-C --sz 0.001 --notionalCcy BTC --minAnnualizedYield 10

# Order management
okx --profile live earn dcd orders
okx --profile live earn dcd orders --state live
okx --profile live earn dcd order --ordId <ordId>

# Early redemption (atomic: re-quote + execute in one step)
okx --profile live earn dcd redeem-execute --ordId <ordId>

MCP startup

# All earn sub-modules
okx-trade-mcp --modules earn

# DCD only
okx-trade-mcp --modules earn.dcd

Notes

  • On-chain earn demo mode: On-chain earn operations are not available in demo/simulated trading mode.
  • Lock periods: Some on-chain products have lock periods. Check allowEarlyRedeem if you need to redeem before the term ends.
  • Protocol types: Main types are staking (PoS validator staking) and defi (DeFi protocol deposits).
  • DCD demo mode: DCD does not support demo/simulated trading mode. Always use a live API key.
  • Quote TTL: DCD quotes expire in ~30 seconds. Execute immediately after requesting.
  • Early redemption: Two-step flow — preview with redeem-quote, then execute with redeem-execute. The preview quote expires before the execute step, so redeem-execute automatically re-fetches a fresh quote.
  • 504 on WRITE operations: Never retry blindly. A 504 means the gateway timed out but the server may have executed the order. Always query dcd orders first to check.

中文

earn 模块提供 OKX 赚币产品工具,分为三个子模块:

子模块工具数说明
earn.savings10简单赚币:余额、申购、赎回、出借利率管理、利率历史;定期赚币:产品查询、订单列表、申购(两步确认)、赎回
earn.onchain6链上赚币(质押/DeFi):产品列表、申购、赎回、取消、活跃订单、历史订单
earn.dcd6双币赢(Dual Currency Deposit):币对、产品、原子化申购、两阶段提前赎回、订单历史

earn.savings — 简单赚币

需要 API Key 的读取权限。申购、赎回、设置利率需额外交易权限。

工具说明
earn_get_savings_balance查询活期赚币余额(指定币种或全部)
earn_savings_purchase申购简单赚币(将资金转入理财)
earn_savings_redeem赎回简单赚币(将资金从理财取出)
earn_set_lending_rate设置出借利率偏好
earn_get_lending_history查询个人出借记录(需认证)
earn_get_lending_rate_history查询简单赚币利率及定期产品——用户询问当前或历史利率时调用此工具(需认证)
earn_get_fixed_earn_products查询可用定期赚币产品(含年化利率、期限、最低投资额、剩余额度)
earn_get_fixed_order_list查询定期赚币订单列表(支持按币种/状态过滤)
earn_fixed_purchase申购定期赚币产品(两步流程:预览后确认)。资金锁定至到期
earn_fixed_redeem赎回定期赚币订单(全额赎回)

earn.onchain — 链上赚币(质押/DeFi)

需要 API Key 的读取权限。写入操作需交易权限。 不支持模拟/演示交易模式——涉及真实资金流动。

工具说明写入
onchain_earn_get_offers获取可用的质押/DeFi 产品;展示时必须显示协议名称(protocol 字段)和收益币种(earningData[].ccy 字段)
onchain_earn_purchase申购产品
onchain_earn_redeem赎回投资
onchain_earn_cancel取消待处理的申购
onchain_earn_get_active_orders获取活跃投资订单
onchain_earn_get_order_history获取投资历史记录

示例提示词

"查看我的赚币余额"
"申购 1000 USDT 活期赚币"
"赎回 500 USDT"
"将 USDT 出借利率设为 2%"
"查看我的出借记录"
"当前 USDT 的市场出借利率是多少?"
"查看 USDT 定期赚币产品"
"申购 1000 USDT 的 90 天定期赚币"
"查看我的定期赚币订单"
"赎回定期赚币订单"
"显示 ETH 的链上赚币产品"
"我目前有哪些链上赚币仓位?"
"赎回我的质押订单 12345"

CLI

# --- earn.savings ---
okx earn savings balance
okx earn savings balance USDT
okx earn savings purchase --ccy USDT --amt 1000
okx earn savings purchase --ccy USDT --amt 1000 --rate 0.02
okx earn savings redeem --ccy USDT --amt 500
okx earn savings set-rate --ccy USDT --rate 0.02
okx earn savings lending-history --ccy USDT  # requires auth
okx earn savings rate-history --ccy USDT --limit 10

# --- earn.savings (fixed-term 定期) ---
okx earn savings fixed-orders
okx earn savings fixed-orders --ccy USDT --state earning
okx earn savings fixed-purchase --ccy USDT --amt 1000 --term 90D
okx earn savings fixed-purchase --ccy USDT --amt 1000 --term 90D --confirm
okx earn savings fixed-redeem <reqId>

# --- earn.onchain ---
okx earn onchain offers
okx earn onchain offers --ccy ETH
okx earn onchain offers --protocolType staking
okx earn onchain orders
okx earn onchain history
okx earn onchain purchase --productId xxx --ccy ETH --amt 1
okx earn onchain redeem --ordId 12345 --protocolType staking
okx earn onchain cancel --ordId 12345 --protocolType staking

MCP 启动

# 所有模块(含赚币,earn 已包含在 "all" 中)
okx-trade-mcp --modules all

# 仅赚币子模块
okx-trade-mcp --modules earn

# 指定子模块
okx-trade-mcp --modules earn.savings
okx-trade-mcp --modules earn.onchain

earn.dcd — 双币赢(Dual Currency Deposit)

需要 API Key 的读取权限。申购、赎回需额外交易权限。 不支持模拟/演示交易模式。

工具说明写入
dcd_get_currency_pairs获取可用双币赢币对
dcd_get_products获取活跃产品(含收益率、行权价、期限信息)
dcd_subscribe原子化申购:一步完成询价+下单;支持 minAnnualizedYield 最低年化保护
dcd_redeem两阶段提前赎回:第一次调用返回赎回报价供确认;第二次调用执行(报价过期自动刷新)
dcd_get_order_state按订单 ID 查询订单状态
dcd_get_orders获取订单历史(支持多种筛选条件)

示例提示词

"查看双币赢支持的币对"
"列出 BTC-USDT 高卖产品,年化至少 5%,7 天以内"
"申购 BTC-USDT-260327-77000-C,投入 0.001 BTC,年化不低于 10%"
"查看我的双币赢订单"
"提前赎回订单 987654321"

CLI

# 查询
okx earn dcd pairs
okx earn dcd products --baseCcy BTC --quoteCcy USDT --optType C
okx earn dcd products --baseCcy BTC --quoteCcy USDT --optType C --minYield 0.05 --maxTermDays 7
okx earn dcd products --baseCcy BTC --quoteCcy USDT --optType C --strikeNear 72000

# 原子化申购(一步完成询价+下单)
okx --profile live earn dcd quote-and-buy --productId BTC-USDT-260327-77000-C --sz 0.001 --notionalCcy BTC
okx --profile live earn dcd quote-and-buy --productId BTC-USDT-260327-77000-C --sz 0.001 --notionalCcy BTC --minAnnualizedYield 10

# 订单管理
okx --profile live earn dcd orders
okx --profile live earn dcd orders --state live
okx --profile live earn dcd order --ordId <ordId>

# 提前赎回(原子化:重新询价+执行一步完成)
okx --profile live earn dcd redeem-execute --ordId <ordId>

MCP 启动

# 所有赚币子模块
okx-trade-mcp --modules earn

# 仅 DCD
okx-trade-mcp --modules earn.dcd

注意事项

  • 链上赚币不支持模拟模式:链上赚币操作涉及真实资金,不支持模拟/演示交易模式。
  • 锁定期:部分链上产品有锁定期,如需提前赎回请确认 allowEarlyRedeem 选项。
  • 协议类型:主要类型包括 staking(PoS 验证者质押)和 defi(DeFi 协议存款)。
  • 双币赢不支持模拟模式:申购和赎回均涉及真实资金,请务必使用实盘 API Key。
  • 报价 TTL:报价约 30 秒后过期,请求后需立即执行。
  • 提前赎回两步流程:先用 redeem-quote 预览,确认后用 redeem-execute 执行。预览报价在执行步骤前已过期,redeem-execute 会自动重新获取最新报价。
  • WRITE 操作遇到 504:不要盲目重试。504 表示网关超时,但服务端可能已执行。请先用 dcd orders 确认订单是否已创建。