okx-dex-strategy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Onchain OS DEX Strategy (Phase 1)

Onchain OS DEX 策略(第一阶段)

4 P0 subcommands that wrap the Agentic Wallet limit-order surface —
create-limit
,
cancel
,
list
,
resume
. SA activation (Trader Mode upgrade / re-upgrade) is performed transparently by the CLI when the BE returns
UPGRADE_REQUIRED
; the skill does not need to expose that detail.
4个封装Agentic Wallet限价单功能的P0子命令——
create-limit
cancel
list
resume
。当后端(BE)返回
UPGRADE_REQUIRED
时,CLI会自动执行SA激活(交易员模式升级/重新升级);本技能无需向用户暴露此细节。

Pre-flight Checks

前置检查

Read
../okx-agentic-wallet/_shared/preflight.md
. If that file does not exist, fall back to
_shared/preflight.md
. Strategy endpoints require an authenticated Agentic Wallet session — confirm login before running any subcommand.
阅读
../okx-agentic-wallet/_shared/preflight.md
。若该文件不存在,则回退至
_shared/preflight.md
。策略端点需要已认证的Agentic Wallet会话——运行任何子命令前请确认已登录。

Display labels & output language (single source of truth)

显示标签与输出语言(唯一可信来源)

This section is the canonical rule for user-facing strings. Every other section in this skill defers to it.
Canonical Display labels — the only strings the agent may surface to the user. The CLI returns these directly (
statusLabel
) for
status
; for
strategyType
the agent looks them up from the §
strategyType
and §
status
tables below.
SurfaceCanonical EN Display labels
strategyType
(4 values)
Buy Dip
/
Take Profit
/
Stop Loss
/
Buy Above
status
(9 values)
Expired
/
Cancelling
/
Cancelled
/
Failed
/
Trading
/
Completed
/
Creating
/
Active
/
Suspended
Translation rule — match the user's conversation language. Display labels above are canonical English. When the user converses in another language, the agent translates the label at output time to match the conversation language.
Never (these rules apply everywhere in this skill):
  • mix two languages in one label (pick one — never render the English label and a translation side by side),
  • expose the underlying enum name (
    BUY_DIP
    ,
    CHASE_HIGH
    ,
    COMPLETED
    , …) to the user,
  • expose the underlying CLI flag value (
    buy_dip
    ,
    chase_high
    ,
    completed
    ,
    cancelled
    , …) to the user,
  • pass through the CLI's raw
    statusLabel
    verbatim when the user is conversing in a non-English language — translate it.
Notes:
  • CHASE_HIGH renders as
    Buy Above
    in English (not "Chase High").
  • SPEEDING_UP (-4) was removed 2026-05-08 — not a valid filter or display value.
本节是用户可见字符串的标准规则,本技能的其他所有章节均需遵循此规则。
标准显示标签——Agent可向用户展示的唯一字符串。CLI会直接返回
status
对应的
statusLabel
;对于
strategyType
,Agent需根据下方的§
strategyType
和§
status
表进行查找。
展示场景标准英文显示标签
strategyType
(4种取值)
Buy Dip
/
Take Profit
/
Stop Loss
/
Buy Above
status
(9种取值)
Expired
/
Cancelling
/
Cancelled
/
Failed
/
Trading
/
Completed
/
Creating
/
Active
/
Suspended
翻译规则——匹配用户的对话语言。上述显示标签为标准英文,当用户使用其他语言对话时,Agent需在输出时将标签翻译为对应语言。
绝对禁止(本技能所有场景均适用):
  • 在一个标签中混合两种语言(二选一——绝不能同时显示英文标签和翻译版本),
  • 向用户暴露底层枚举名称(如
    BUY_DIP
    CHASE_HIGH
    COMPLETED
    等),
  • 向用户暴露底层CLI参数值(如
    buy_dip
    chase_high
    completed
    cancelled
    等),
  • 当用户使用非英文对话时,直接透传CLI的原始
    statusLabel
    ——必须进行翻译。
注意事项:
  • CHASE_HIGH在英文中显示为**
    Buy Above
    **(而非"Chase High")。
  • SPEEDING_UP(-4)已于2026-05-08移除——不再作为有效筛选或显示值。

Boundary vs
okx-dex-swap

okx-dex-swap
的边界区分

User intentSkill
"Swap X for Y now" / "Buy 0.5 ETH with USDC"
okx-dex-swap
(market order, immediate execution)
"Buy ETH if it dips to $2000" / "Sell when ETH hits $5000" / "Take profit at X" / "Stop loss at Y"this skill (price-triggered limit order)
"Cancel my pending order"this skill
"What limit orders do I have?"this skill
If the venue is named explicitly (Uniswap, PancakeSwap, Raydium, Curve, ...) → re-route to
okx-dapp-discovery
. This skill is for OKX-aggregated limit orders only.
用户意图对应技能
"立即将X兑换为Y" / "用USDC买入0.5 ETH"
okx-dex-swap
(市价单,立即执行)
"若ETH跌至2000美元则买入" / "当ETH涨到5000美元时卖出" / "在X价位止盈" / "在Y价位止损"本技能(价格触发的限价单)
"取消我的挂单"本技能
"查看我的限价单"本技能
若用户明确指定了交易场所(Uniswap、PancakeSwap、Raydium、Curve等)→ 路由至
okx-dapp-discovery
。本技能仅适用于OKX聚合限价单。

Command Index

命令索引

1.
onchainos strategy create-limit

1.
onchainos strategy create-limit

Place a single price-triggered limit order.
onchainos strategy create-limit \
  --chain-id <id|alias> \
  --from-token <address> \
  --to-token <address> \
  --amount <decimal-string> \
  --direction <buy|sell> \
  --trigger-price <usd> \
  [--current-price <usd>] \
  [--slippage <value>] \
  [--mev-protection <on|off|default>] \
  [--expires-in <secs>]
FlagRequiredNotes
--chain-id
YChain id or alias:
1
,
solana
,
bsc
,
arbitrum
,
base
,
xlayer
--from-token
YSell-side token contract address
--to-token
YBuy-side token contract address
--amount
YAmount of
from_token
to sell (string, no precision loss)
--direction
Y
buy
or
sell
(case-insensitive). Strategy type is derived from
--direction
+
--trigger-price
+ the current market price; the agent does not pass a strategy type explicitly.
--trigger-price
YUSD trigger price. Required for strategy type derivation.
--current-price
NCurrent USD price of the comparison token (to-token for
buy
, from-token for
sell
). When omitted the CLI fetches it via
market price
. Pass it to skip the extra HTTP round-trip when the agent already retrieved the price for the confirmation page.
--slippage
NSlippage tolerance in percent. Default
15
(= 15%). Pass the percent as a plain number — the CLI converts to BE wire format (divides by 100, e.g.
20
"0.2"
). When the user says "slippage 20" / "slippage 20%" / "use 20% slippage" — all map to
--slippage 20
.
--mev-protection
NTri-state value:
on
/
off
/
default
(default =
default
).
on
routerModeType=2
(MEV protection ON),
off
routerModeType=3
(OFF),
default
routerModeType=1
(CLI does not opt in or out; BE picks).
--expires-in
NOrder TTL in seconds. Default 604800 (7 days) — see §Default order expiry.
Output (JSON, always — the CLI has no human-format mode):
json
{
  "ok": true,
  "data": {
    "orderId": "<id>",
    "status": <int>,
    "statusLabel": "<label>",
    "estimatedWaitTime": <int|null>,
    "eventCursor": "<string|null>"
  }
}
Solana orders return
estimatedWaitTime=0
— the order is queryable immediately; for all other chains the agent follows §Async wait pattern (fixed 3-second sleep before re-querying).
下达单个价格触发的限价单。
onchainos strategy create-limit \\
  --chain-id <id|alias> \\
  --from-token <address> \\
  --to-token <address> \\
  --amount <decimal-string> \\
  --direction <buy|sell> \\
  --trigger-price <usd> \\
  [--current-price <usd>] \\
  [--slippage <value>] \\
  [--mev-protection <on|off|default>] \\
  [--expires-in <secs>]
参数是否必填说明
--chain-id
链ID或别名:
1
solana
bsc
arbitrum
base
xlayer
--from-token
卖出方代币合约地址
--to-token
买入方代币合约地址
--amount
卖出的
from_token
数量(字符串格式,无精度损失)
--direction
buy
sell
(大小写不敏感)。策略类型由
--direction
+
--trigger-price
+ 当前市场价格推导得出;Agent无需显式传递策略类型。
--trigger-price
USD计价的触发价格。是推导策略类型的必填项。
--current-price
对比代币的当前USD价格(
buy
方向为
to-token
价格,
sell
方向为
from-token
价格)。若省略,CLI会通过
market price
接口获取。若Agent已在确认页获取该价格,可传入此参数以避免额外的HTTP请求。
--slippage
滑点容忍度(百分比)。默认值为
15
(即15%)。直接传入百分比数值即可——CLI会转换为后端传输格式(除以100,例如
20
"0.2"
)。当用户说"滑点20" / "滑点20%" / "使用20%滑点"时,均映射为
--slippage 20
--mev-protection
三态值:
on
/
off
/
default
(默认值为
default
)。
on
routerModeType=2
(MEV保护开启),
off
routerModeType=3
(MEV保护关闭),
default
routerModeType=1
(CLI不主动选择,由后端决定)。
--expires-in
订单有效期(秒)。默认值为604800(7天)——详见§默认订单有效期。
输出(始终为JSON格式——CLI无人类可读格式):
json
{
  "ok": true,
  "data": {
    "orderId": "<id>",
    "status": <int>,
    "statusLabel": "<label>",
    "estimatedWaitTime": <int|null>,
    "eventCursor": "<string|null>"
  }
}
Solana订单返回
estimatedWaitTime=0
——订单可立即查询;对于其他链,Agent需遵循§异步等待模式(固定等待3秒后重新查询)。

Default order expiry

默认订单有效期

Phase 1 BE default = 7 days (
604800
seconds). This is the single source of truth — everywhere else in this skill that mentions "7 days" (the §Two-step confirmation expiry note, the §list "Expire after" column note, etc.) derives from here. If BE changes the default, update this section and propagate to the other mentions.
Slippage interpretation reminder (no echo from CLI):
--slippage
input is in percent units
0.05
= 0.05% (wire
"0.0005"
), NOT 5%. To set 5% slippage, pass
--slippage 5
. The skill / agent should convey this to the user at input time; the CLI itself does not echo a confirmation line.
第一阶段后端默认值为7天
604800
秒)。此为唯一可信来源——本技能中所有提及"7天"的内容(如§两步确认流程的有效期说明、§list命令的"到期时间"列说明等)均由此推导。若后端修改默认值,需更新本节并同步至其他提及处。
滑点解读提醒(CLI无回显):
--slippage
输入为百分比单位——
0.05
= 0.05%(传输格式为
"0.0005"
),而非5%。若要设置5%滑点,需传入
--slippage 5
。技能/Agent应在用户输入时向其说明此规则;CLI本身不会回显确认信息。

Supported chains (Phase 1, locked)

支持的链(第一阶段,固定)

Strategy orders are only supported on these 6 chains. Any other chain MUST be rejected upfront by the agent — do not call
create-limit
and do not even open the Step 1 confirmation.
chainIndexName
--chain-id
aliases
1Ethereum
ethereum
,
eth
,
1
56BSC
bsc
,
56
196X Layer
xlayer
,
196
501Solana
solana
,
sol
,
501
8453Base
base
,
8453
42161Arbitrum
arbitrum
,
arb
,
42161
Pre-flight rule (agent): when the user mentions a chain, resolve it to its chainIndex and check this list. If the chain is not in the table (e.g. Polygon
137
, Optimism
10
, Avalanche
43114
, Linea
59144
, Sui
784
, Tron
195
, ...), respond directly with:
Strategy orders are only supported on Ethereum / BSC / X Layer / Solana / Base / Arbitrum right now.
<requested chain>
is not supported — pick one of these to continue.
Do NOT proceed to Step 1 confirmation. Do NOT call the CLI. The CLI also defends against this (validates against the same 6-chain whitelist before BE), but the agent catching it earlier saves a round trip and gives a clearer message tied to the user's exact phrasing.
策略订单仅支持以下6条链。Agent需提前拒绝任何其他链的请求——不得调用
create-limit
,甚至不得进入第1步确认流程。
chainIndex名称
--chain-id
别名
1Ethereum
ethereum
eth
1
56BSC
bsc
56
196X Layer
xlayer
196
501Solana
solana
sol
501
8453Base
base
8453
42161Arbitrum
arbitrum
arb
42161
前置规则(Agent):当用户提及某条链时,将其解析为chainIndex并核对此列表。若该链不在列表中(例如Polygon
137
、Optimism
10
、Avalanche
43114
、Linea
59144
、Sui
784
、Tron
195
等),直接回复:
当前仅支持在Ethereum / BSC / X Layer / Solana / Base / Arbitrum上使用策略订单。<请求的链>暂不支持——请从上述链中选择以继续操作。
不得进入第1步确认流程,不得调用CLI。CLI也会对此进行防御(调用后端前验证6链白名单),但Agent提前拦截可避免一次请求往返,并给出与用户表述更契合的清晰提示。

strategyType
enum (BaseOrderStrategyTypeEnum, locked)

strategyType
枚举(BaseOrderStrategyTypeEnum,固定)

Int valueEnum nameDefault directionCLI
--type
value
Display labelSemantics
2BUY_DIPBUY (0)
buy_dip
Buy DipBuy when market price falls to trigger
3TAKE_PROFITSELL (1)
take_profit
Take ProfitSell when market price rises to trigger
4STOP_LOSSSELL (1)
stop_loss
Stop LossSell when market price falls to trigger
5CHASE_HIGHBUY (0)
chase_high
Buy AboveBuy when market price rises above trigger
The Display label column is the only user-facing string — see §Display labels & output language for the cross-cutting rule. The agent never sees, computes, or passes the
strategyType
integer; the CLI maps everything internally.
整数值枚举名称默认方向CLI
--type
显示标签语义
2BUY_DIPBUY (0)
buy_dip
抄底当市场价格跌至触发价时买入
3TAKE_PROFITSELL (1)
take_profit
止盈当市场价格涨至触发价时卖出
4STOP_LOSSSELL (1)
stop_loss
止损当市场价格跌至触发价时卖出
5CHASE_HIGHBUY (0)
chase_high
追高买入当市场价格涨至触发价以上时买入
显示标签列是唯一对用户可见的字符串——请遵循§显示标签与输出语言的通用规则。Agent无需查看、计算或传递
strategyType
整数值;CLI会在内部完成所有映射。

Strategy type derivation (CLI-owned; agent uses table only for display)

策略类型推导(CLI负责;Agent仅用于显示)

strategyType
is fully derived inside the CLI from
(--direction, --trigger-price, current market price)
. The agent must NOT pass a strategy type — there is no
--type
flag. The same table is reproduced here so the agent can compute the Display label for the Step 1 confirmation page without re-deriving the wire integer.
Directiontrigger vs currentInferred strategyTypeDisplay label
buytrigger < currentBUY_DIP (2)Buy Dip
buytrigger ≥ currentCHASE_HIGH (5)Buy Above
selltrigger > currentTAKE_PROFIT(3)Take Profit
selltrigger ≤ currentSTOP_LOSS (4)Stop Loss
Equality is folded into the "aggressive" side (CHASE_HIGH / STOP_LOSS) — same rule the CLI enforces.
Agent flow:
  1. Parse direction (buy / sell) from user intent ("buy" / "ape in" / "snap up" → buy; "sell" / "take profit" / "stop loss" / "exit" → sell). Passed verbatim as
    --direction <buy|sell>
    .
  2. Fetch current price — call
    onchainos market price --chain <chain> --address <token>
    , read
    data[0].price
    . For BUY direction query the to-token's current price; for SELL direction query the from-token's current price. The agent needs this for (a) Step 0 USD-value pre-flight, (b) the Step 1 confirmation page "Trigger Price vs current", and (c) computing the Display label per the table above.
  3. Pass
    --current-price <usd>
    to the CLI
    so it does not re-fetch. (If the agent omits it, the CLI fetches the same value itself — correct but one extra round-trip.)
strategyType
完全由CLI从
(--direction, --trigger-price, 当前市场价格)
推导得出。Agent不得传递策略类型——无
--type
参数。此处重现相同表格,以便Agent无需推导传输用整数值即可为第1步确认页计算显示标签
方向触发价与当前价的关系推导的strategyType显示标签
buy触发价 < 当前价BUY_DIP (2)抄底
buy触发价 ≥ 当前价CHASE_HIGH (5)追高买入
sell触发价 > 当前价TAKE_PROFIT(3)止盈
sell触发价 ≤ 当前价STOP_LOSS (4)止损
相等情况归入"激进"侧(CHASE_HIGH / STOP_LOSS)——与CLI执行的规则一致。
Agent流程:
  1. 解析方向(buy / sell):从用户意图中提取("买入" / "进场" / "抢购" → buy;"卖出" / "止盈" / "止损" / "离场" → sell)。直接传递为
    --direction <buy|sell>
  2. 获取当前价格——调用
    onchainos market price --chain <chain> --address <token>
    ,读取
    data[0].price
    。BUY方向查询to-token的当前价格;SELL方向查询from-token的当前价格。Agent需此价格用于:(a) 第0步USD价值前置检查,(b) 第1步确认页的"触发价 vs 当前价"展示,(c) 根据上述表格计算显示标签。
  3. 向CLI传递
    --current-price <usd>
    :避免CLI重复获取。(若Agent省略此参数,CLI会自行获取相同值——结果正确但多一次请求往返。)

Two-step confirmation flow (Agent must follow)

两步确认流程(Agent必须遵循)

create-limit
is a write operation. The agent MUST present a confirmation summary to the user first and only call the CLI after the user explicitly confirms. The CLI itself does not gate (it calls BE directly); this contract is enforced at the skill layer.
Step 0 — Minimum order value pre-flight (must run before Step 1):
BE enforces a minimum order value of $1 USD (returns error
100010 ORDER_AMOUNT_TOO_SMALL
otherwise). To avoid wasting a round-trip and a confirmation page on an amount that BE will reject, the agent MUST verify the from-side USD value first.
  1. Fetch the from-token price (USD):
    • If from-token is a well-known stablecoin (USDT / USDC / USDG / USDe / DAI / FDUSD / ...): assume
      from_price ≈ 1.0
      without an HTTP call.
    • Otherwise: call
      onchainos market price --chain <chain> --address <from_token>
      , read
      data[0].price
      as
      from_price
      .
  2. Compute USD value:
    usd_value = from_amount × from_price
    .
  3. If
    usd_value < 1.0
    :
    • Compute
      min_from_amount = ceil(1.0 ÷ from_price)
      rounded up to a reasonable display precision for the token (e.g. whole units when
      from_price ≥ 0.1
      ; 2-4 significant digits otherwise).
    • Surface exactly this single canonical line to the user, with no extra prose — no USD-value math, no $1 threshold mention, no echo of the user's original amount, no follow-up sentence, no apology:
      Minimum order amount: <min_from_amount> <from_symbol>
      Translate the prefix at output time per §Display labels & output language (e.g. for a Chinese user the agent renders the same fact in Chinese). The structure stays single-line:
      <localised prefix> <min_from_amount> <from_symbol>
      .
    • STOP. Do NOT render Step 1. Do NOT call the CLI. Wait for the user to provide a larger
      --amount
      , then re-run Step 0 from the top.
  4. If
    usd_value ≥ 1.0
    :
    carry
    from_price
    forward (Step 1's "Value" column reuses it; no need to re-fetch) and proceed to Step 1.
Example (user wants to spend 1 OKB on a chain where OKB ≈ $0.10):
  • from_price = 0.10
    ,
    usd_value = 1 × 0.10 = 0.10 < 1.0
    → fail
  • min_from_amount = ceil(1.0 / 0.10) = 10
  • Output:
    Minimum order amount: 10 OKB
  • Stop. No Step 1, no extra prose.
Step 1 — Show the order summary for the user to confirm. Five top-level categories with sub-items; the agent may freely organise prose at runtime, but no category may be dropped:
#CategorySub-itemsSource
1ChainHuman-readable chain name resolved from
--chain-id
(Arbitrum / BSC / Solana / ...)
2Order TypeDisplay label per the §
strategyType
table (
Buy Dip
/
Take Profit
/
Stop Loss
/
Buy Above
) — translate per §Display labels & output language
Derived per "Strategy type derivation" above
3From tokenSymbol (e.g.
USDC
); Amount (e.g.
10
)
Symbol from token metadata; Amount is raw
--amount
value
4To tokenSymbol (e.g.
ARB
); Trigger Price (e.g.
$0.10
, USD-denominated); Estimated Amount (predicted to-token amount); Value (estimated USD value)
Symbol/Trigger Price direct; Estimated Amount and Value computed by the agent — see formulas below
5SlippageEither
Default 15%
(user did not mention slippage) or
User-specified X%
(user explicitly said "slippage X%")
See Slippage display rules below
Estimated Amount / Value formulas:
  • Buy direction (BUY_DIP / CHASE_HIGH):
    • Estimated Amount
      =
      from_amount
      ÷
      trigger_price
      (in units of to-token)
    • Value
      =
      from_amount
      ×
      from_token_USD_price
      (if from is a stablecoin, ≈
      from_amount
      )
  • Sell direction (TAKE_PROFIT / STOP_LOSS):
    • Estimated Amount
      =
      from_amount
      ×
      trigger_price
      (in units of to-token, usually a stablecoin)
    • Value
      =
      from_amount
      ×
      trigger_price
      (if to is a stablecoin, equals Estimated Amount)
Slippage display rules:
  • User did NOT mention slippage in the conversation → display
    Slippage: Default 15%
    , and omit
    --slippage
    on the CLI call (the CLI default is 15).
  • User explicitly said "slippage X%" / "use X% slippage" / similar → display
    Slippage: User-specified X%
    , and pass
    --slippage X
    on the CLI call.
Structural example (display labels come from the §
strategyType
/ §
status
tables; see §Display labels & output language for the cross-cutting rule):
1. Chain: Arbitrum
2. Order Type: Buy Dip
3. From: USDC 10
4. To:
   - Symbol: ARB
   - Trigger Price: $0.10
   - Estimated Amount: 100 ARB
   - Value: $10
5. Slippage: 15% (default)

If the trigger condition is not met within 7 days, this order auto-expires.

Reply confirm / change / cancel.
Expiry note (mandatory): After the 5 categories and before the reply prompt, the agent must surface that the limit order auto-expires 7 days after creation if the trigger never fires. Default phrasing:
If the trigger condition is not met within 7 days, this order auto-expires.
Step 2 — Handle the user's reply:
  • User says "confirm" / "yes" / "submit" → call
    onchainos strategy create-limit ...
    with the
    --type
    derived in Step 1.
  • User says "change amount = 5" / "set trigger to 0.08" / similar → update the corresponding field and re-render Step 1 for another confirmation.
  • User says "cancel" / "abort" → do NOT call the CLI; acknowledge that the order was discarded.
Hard constraints:
  1. Never call
    strategy create-limit
    until the user has explicitly confirmed.
  2. Estimated Amount
    /
    Value
    are agent-side estimates derived from
    trigger_price
    , not BE quotes. The realised fill amount is decided at BE execution time by slippage and aggregator routing; the agent must not present these estimates as "actual fill amounts".
  3. --trigger-price
    is a USD price. The agent must make this clear to the user to avoid confusion with "exchange rate = X from-token per 1 to-token".
  4. Never render Step 1 when Step 0's USD-value check fails. Output the single-line minimum-amount warning instead and stop — the user must restart with a larger
    --amount
    .
create-limit
是写入操作。Agent必须先向用户展示确认摘要,仅在用户明确确认后才可调用CLI。CLI本身无拦截机制(直接调用后端),此约束在技能层强制执行。
第0步——最小订单价值前置检查(必须在第1步前执行):
后端强制执行最小订单价值为1美元(否则返回错误
100010 ORDER_AMOUNT_TOO_SMALL
)。为避免在后端会拒绝的订单金额上浪费请求往返和确认页,Agent必须先验证卖出方的USD价值。
  1. 获取from-token的USD价格:
    • 若from-token为知名稳定币(USDT / USDC / USDG / USDe / DAI / FDUSD等):无需HTTP请求,直接假设
      from_price ≈ 1.0
    • 其他情况:调用
      onchainos market price --chain <chain> --address <from_token>
      ,读取
      data[0].price
      作为
      from_price
  2. 计算USD价值:
    usd_value = from_amount × from_price
  3. usd_value < 1.0
    • 计算
      min_from_amount = ceil(1.0 ÷ from_price)
      ,并按代币的合理显示精度向上取整(例如当
      from_price ≥ 0.1
      时取整数;否则取2-4位有效数字)。
    • 向用户展示唯一标准语句,不得添加额外内容——无需说明USD价值计算、1美元阈值、回显用户原金额、后续语句或致歉:
      最小订单金额:<min_from_amount> <from_symbol>
      根据§显示标签与输出语言的规则,在输出时翻译前缀(例如对中文用户,Agent需用中文展示相同内容)。格式保持单行:
      <本地化前缀> <min_from_amount> <from_symbol>
    • 停止操作。不得进入第1步,不得调用CLI。 等待用户提供更大的
      --amount
      ,然后重新执行第0步。
  4. usd_value ≥ 1.0
    保留
    from_price
    (第1步的"价值"列会复用此值,无需重新获取),进入第1步。
示例(用户想用1 OKB下单,该链上OKB≈0.10美元):
  • from_price = 0.10
    usd_value = 1 × 0.10 = 0.10 < 1.0
    → 检查不通过
  • min_from_amount = ceil(1.0 / 0.10) = 10
  • 输出:
    最小订单金额:10 OKB
  • 停止操作。不得进入第1步,不得添加额外内容。
第1步——向用户展示订单摘要以确认。 包含5个顶级分类及子项;Agent可在运行时自由组织表述,但不得遗漏任何分类
#分类子项来源
1
--chain-id
解析的人类可读链名(Arbitrum / BSC / Solana等)
2订单类型根据§
strategyType
表生成的显示标签(
抄底
/
止盈
/
止损
/
追高买入
)——根据§显示标签与输出语言的规则翻译
根据上述"策略类型推导"规则得出
3卖出代币符号(例如
USDC
);数量(例如
10
代币元数据中的符号;数量为原始
--amount
4买入代币符号(例如
ARB
);触发价(例如
$0.10
,USD计价);预估数量(预计买入的代币数量);价值(预估USD价值)
符号/触发价直接获取;预估数量和价值由Agent计算——见下方公式
5滑点若用户未提及滑点则显示
默认15%
,若用户明确指定则显示
用户指定X%
见滑点显示规则
预估数量/价值公式:
  • 买入方向(抄底 / 追高买入):
    • 预估数量
      =
      from_amount
      ÷
      trigger_price
      (买入代币单位)
    • 价值
      =
      from_amount
      ×
      from_token_USD_price
      (若为稳定币,≈
      from_amount
  • 卖出方向(止盈 / 止损):
    • 预估数量
      =
      from_amount
      ×
      trigger_price
      (买入代币单位,通常为稳定币)
    • 价值
      =
      from_amount
      ×
      trigger_price
      (若为稳定币,等于预估数量)
滑点显示规则:
  • 用户对话中未提及滑点 → 显示
    滑点:默认15%
    ,且CLI调用时省略
    --slippage
    (CLI默认值为15)。
  • 用户明确表示"滑点X%" / "使用X%滑点"等 → 显示
    滑点:用户指定X%
    ,且CLI调用时传递
    --slippage X
结构示例(显示标签来自§
strategyType
/ §
status
表;请遵循§显示标签与输出语言的通用规则):
1. 链:Arbitrum
2. 订单类型:抄底
3. 卖出:USDC 10
4. 买入:
   - 符号:ARB
   - 触发价:$0.10
   - 预估数量:100 ARB
   - 价值:$10
5. 滑点:15%(默认)

若7天内未满足触发条件,此订单将自动过期。

请回复 confirm / change / cancel。
有效期说明(必填):在5个分类之后、回复提示之前,Agent必须告知用户:若触发条件始终未满足,限价单将在创建7天后自动过期。默认表述:
若7天内未满足触发条件,此订单将自动过期。
第2步——处理用户回复:
  • 用户回复"confirm" / "yes" / "submit" → 调用
    onchainos strategy create-limit ...
    ,传入第1步推导的
    --type
  • 用户回复"change amount = 5" / "set trigger to 0.08"等 → 更新对应字段并重新渲染第1步以再次确认。
  • 用户回复"cancel" / "abort" → 不得调用CLI;告知用户订单已取消。
硬性约束:
  1. 必须在用户明确确认后才可调用
    strategy create-limit
  2. 预估数量
    /
    价值
    是Agent基于
    trigger_price
    的估算值,并非后端报价。实际成交数量由后端执行时的滑点和聚合器路由决定;Agent不得将这些估算值表述为"实际成交数量"。
  3. --trigger-price
    是USD价格。Agent必须向用户明确说明,避免与"汇率=X卖出代币/1买入代币"混淆。
  4. 当第0步的USD价值检查不通过时,不得渲染第1步。 仅输出单行最小金额提示并停止操作——用户必须重新提供更大的
    --amount

2.
onchainos strategy cancel

2.
onchainos strategy cancel

Cancel a single, batch, or all active orders. Pass exactly one of the three flags:
onchainos strategy cancel --order-id <id>
onchainos strategy cancel --order-ids id1,id2,...
onchainos strategy cancel --all
Output (JSON):
{ok:true,data:{updateNum:N,estimatedWaitTime:null|n}}
.
updateNum
is the count BE accepted, not the count that reached terminal state — re-query with
list
after the wait.
取消单个、批量或所有活跃订单。需传递以下三个参数中的任意一个:
onchainos strategy cancel --order-id <id>
onchainos strategy cancel --order-ids id1,id2,...
onchainos strategy cancel --all
输出(JSON):
{ok:true,data:{updateNum:N,estimatedWaitTime:null|n}}
updateNum
是后端接受的订单数量,并非已进入终态的数量——等待后需用
list
重新查询。

3.
onchainos strategy list

3.
onchainos strategy list

onchainos strategy list \
  [--order-id <id>] \
  [--status active,suspended,...] \
  [--chain-id 1,501] \
  [--token <address>] \
  [--limit <int>] \
  [--cursor <string>] \
  [--strategy-mode 7]
Two modes:
  • Single order: pass
    --order-id <id>
    → GET
    openOrderDetail
    (returns full order shape).
  • Page query: omit
    --order-id
    → POST
    getOpenOrder
    . The active wallet's addresses are auto-supplied; pass
    --limit
    (max 100, default 100) and
    --cursor
    from the previous response's
    nextCursor
    for pagination.
Flag accepts-CSV inconsistency
--status
and
--chain-id
accept comma-separated lists (BE fields are
orderStatusList
/
chainIdList
, plural).
--token
accepts a single address only — BE schema 2026-05-09 replaced the prior
tokenAddressList: List<String>
with a singular
tokenAddress: String
field. For multi-token queries, the agent calls
list
once per token and merges the results.
onchainos strategy list \\
  [--order-id <id>] \\
  [--status active,suspended,...] \\
  [--chain-id 1,501] \\
  [--token <address>] \\
  [--limit <int>] \\
  [--cursor <string>] \\
  [--strategy-mode 7]
两种模式:
  • 单个订单:传递
    --order-id <id>
    → 调用
    openOrderDetail
    (返回完整订单结构)。
  • 分页查询:省略
    --order-id
    → 调用
    getOpenOrder
    。CLI会自动传入当前钱包的地址;可传递
    --limit
    (最大值100,默认100)和上一次响应中的
    nextCursor
    作为
    --cursor
    以实现分页。
参数CSV兼容性差异——
--status
--chain-id
接受逗号分隔的列表(后端字段为
orderStatusList
/
chainIdList
,复数形式)。
--token
仅接受单个地址——2026-05-09更新的后端架构将原有的
tokenAddressList: List<String>
替换为单数
tokenAddress: String
字段。若需查询多个代币,Agent需为每个代币调用一次
list
并合并结果。

getOpenOrder
request body fields (locked)

getOpenOrder
请求体字段(固定)

fieldtyperequiredmeaning
accountId
StringYAccount ID, used for JWT auth. CLI auto-injects from the current session; the agent does not pass this
walletAddressList
List<String>YWallet address list. CLI auto-injects from the current wallet context (EVM + SOL)
chainIdList
List<String>NChain ID filter; omit to query all chains. Mapped from
--chain-id
orderStatusList
List<Integer>NStatus filter (enum below). CLI defaults to the 5 non-terminal codes when
--status
is omitted — see §Default status filter
orderTypeList
List<Integer>NOrder-type filter (BE §3.3 enum); not used in Phase 1
idList
List<String>NExact-match filter by order ID; no dedicated flag in Phase 1 — use
--order-id
(detail mode) instead
tokenAddress
StringNFilter by a single token address. Mapped from
--token
. For multi-token queries, the agent calls
list
once per token (CLI rejects CSV input with a friendly error). BE schema 2026-05-09 dropped the previous multi-string
tokenAddressList
.
limit
IntegerNPage size; BE default 100, max 100. Agent must pass
--limit 10
for default list rendering
cursor
StringNPagination cursor (Base64). Omit on first page; pass the previous response's
nextCursor
. Mapped from
--cursor
字段类型是否必填含义
accountId
String账户ID,用于JWT认证。CLI会从当前会话自动注入;Agent无需传递
walletAddressList
List<String>钱包地址列表。CLI会从当前钱包上下文自动注入(EVM + SOL)
chainIdList
List<String>链ID筛选;省略则查询所有链。由
--chain-id
映射而来
orderStatusList
List<Integer>状态筛选(见下方枚举)。当省略
--status
时,CLI默认传入5种非终态代码——详见§默认状态筛选
orderTypeList
List<Integer>订单类型筛选(后端§3.3枚举);第一阶段未使用
idList
List<String>按订单ID精确匹配筛选;第一阶段无专用参数——使用
--order-id
(详情模式)替代
tokenAddress
String按单个代币地址筛选。由
--token
映射而来。若需查询多个代币,Agent需为每个代币调用一次
list
(CLI会友好拒绝CSV输入)。后端架构于2026-05-09移除了原有的多字符串
tokenAddressList
limit
Integer分页大小;后端默认100,最大值100。Agent在默认列表渲染时必须传递
--limit 10
cursor
String分页游标(Base64格式)。首次查询省略;后续查询传递上一次响应中的
nextCursor
。由
--cursor
映射而来

status
enum (TeeSaOpenOrderStatusEnum, locked)

status
枚举(TeeSaOpenOrderStatusEnum,固定)

Full 10-state mapping — agent reads
data.list[].status
integer and looks up the display label here:
Int valueEnum nameCLI
--status
value
Display labelTerminal?
-7EXPIRED
expired
ExpiredYes
-3CANCELLING
cancelling
CancellingNo (transient)
-2CANCELLED
cancelled
CancelledYes
-1FAILED
failed
FailedYes
0TRADING
processing
or
trading
TradingNo
1COMPLETED
completed
CompletedYes
2CREATING
creating
CreatingNo
3ACTIVE
active
ActiveNo
4SUSPENDED
suspended
SuspendedNo
SPEEDING_UP (-4) was removed 2026-05-08 — not surfaced and not a valid filter option. The Display label column is the only user-facing string; see §Display labels & output language. CLI's
statusLabel
already returns the display label, so just translate it per conversation language.
Non-terminal set (5):
{-3, 0, 2, 3, 4}
= CANCELLING / TRADING / CREATING / ACTIVE / SUSPENDED Terminal set (4):
{-7, -2, -1, 1}
= EXPIRED / CANCELLED / FAILED / COMPLETED
Default status filter (when
--status
is omitted)
: the CLI puts
orderStatusList=[-3, 0, 2, 3, 4]
into the request body — the 5 non-terminal states (CANCELLING / TRADING / CREATING / ACTIVE / SUSPENDED) — and BE applies the filter server-side, returning only matching orders. Terminal orders (Cancelled / Completed / Failed / Expired) are excluded by default. Rationale: when a user asks "show my orders" they almost always mean live ones; surfacing historical terminal records pollutes the answer.
To see terminal orders the agent must pass
--status
explicitly:
User intent
--status
value to pass
"show my completed orders"
completed
(orderStatusList=[1])
"show my cancelled orders"
cancelled
(orderStatusList=[-2])
"show failed orders"
failed
(orderStatusList=[-1])
"show expired orders"
expired
(orderStatusList=[-7])
"show all orders including terminal"
active,suspended,creating,trading,cancelling,completed,cancelled,failed,expired
(full 9)
"show my live orders" / no qualifier(omit
--status
— uses non-terminal default)
--status
accepts comma-separated values; each entry is either an integer (e.g.
4
) or a string label (
active
,
suspended
,
processing
,
creating
,
cancelling
,
cancelled
,
completed
,
failed
,
expired
).
完整的10状态映射——Agent读取
data.list[].status
整数值并在此查找显示标签:
整数值枚举名称CLI
--status
显示标签是否终态
-7EXPIRED
expired
已过期
-3CANCELLING
cancelling
取消中否(临时状态)
-2CANCELLED
cancelled
已取消
-1FAILED
failed
已失败
0TRADING
processing
trading
交易中
1COMPLETED
completed
已完成
2CREATING
creating
创建中
3ACTIVE
active
活跃中
4SUSPENDED
suspended
已暂停
SPEEDING_UP(-4)已于2026-05-08移除——不再展示,也不作为有效筛选选项。显示标签列是唯一对用户可见的字符串;请遵循§显示标签与输出语言的规则。CLI的
statusLabel
已返回显示标签,只需根据对话语言翻译即可。
非终态集合(5种):
{-3, 0, 2, 3, 4}
= 取消中 / 交易中 / 创建中 / 活跃中 / 已暂停 终态集合(4种):
{-7, -2, -1, 1}
= 已过期 / 已取消 / 已失败 / 已完成
默认状态筛选(省略
--status
时)
:CLI会在请求体中传入
orderStatusList=[-3, 0, 2, 3, 4]
——即5种非终态(取消中 / 交易中 / 创建中 / 活跃中 / 已暂停)——后端会在服务器端应用此筛选,仅返回匹配的订单。终态订单(已取消 / 已完成 / 已失败 / 已过期)默认排除。设计理由:当用户询问"查看我的订单"时,几乎总是指活跃订单;展示历史终态记录会干扰回答。
若要查看终态订单,Agent必须显式传递
--status
用户意图需传递的
--status
"查看我的已完成订单"
completed
(orderStatusList=[1])
"查看我的已取消订单"
cancelled
(orderStatusList=[-2])
"查看已失败订单"
failed
(orderStatusList=[-1])
"查看已过期订单"
expired
(orderStatusList=[-7])
"查看所有订单(包括终态)"
active,suspended,creating,trading,cancelling,completed,cancelled,failed,expired
(全部9种)
"查看我的活跃订单" / 无限定词(省略
--status
——使用非终态默认值)
--status
接受逗号分隔的值;每个值可以是整数(例如
4
)或字符串标签(
active
suspended
processing
creating
cancelling
cancelled
completed
failed
expired
)。

Agent rendering rules (when the user asks for orders without naming a specific status)

Agent渲染规则(用户未指定具体状态时)

User prompts that match this rule include: "show my strategy orders" / "list orders" / "show my limit orders" / "what orders do I have" — i.e. any general "show me my orders" intent without a status qualifier.
Steps the agent must follow:
  1. Run
    onchainos strategy list --limit 10
    (no
    --status
    ) — the CLI puts
    orderStatusList=[-3, 0, 2, 3, 4]
    (non-terminal set) into the request body; BE applies the filter server-side and returns only matching orders. Always pass
    --limit 10
    for general "show my orders" queries; full pagination is opt-in via "next page" follow-up.
  2. Render the response
    data.list
    as a Markdown table with exactly these 8 columns (locked):
    Order idOrder StatusOrder TypeEstimated AmountTo Token addrValueTrigger priceExpire after
    Per-row mapping (order matters, no extra columns):
    ColumnSourceNotes
    Order id
    data.list[i].orderId
    Order Status
    data.list[i].statusLabel
    (Display label per the §
    status
    table)
    Translate per §Display labels & output language
    Order TypeDisplay label per the §
    strategyType
    table, derived from
    data.list[i].strategyType
    integer (
    2 → Buy Dip
    /
    3 → Take Profit
    /
    4 → Stop Loss
    /
    5 → Buy Above
    )
    Translate per §Display labels & output language
    Estimated Amount
    data.list[i].toToken.tokenAmount
    +
     
    +
    data.list[i].toToken.tokenSymbol
    e.g.
    0.2 SOL
    To Token addr
    data.list[i].toToken.tokenContractAddress
    , truncated to first-6 + last-4
    EVM:
    0x1234...cdef
    (
    0x
    + 4 chars +
    ...
    + 4 chars); Solana base58: first 6 +
    ...
    + last 4
    Value
    data.list[i].toToken.tokenUsd
    , formatted as
    <n> USD
    e.g.
    16 USD
    (round or 2-decimal, follow BE precision)
    Trigger price
    data.list[i].triggerInfo.triggerPrice
    , prefixed with
    $
    e.g.
    $80
    ; if empty (trigger-rate path, not used in Phase 1) display
    data.list[i].triggerInfo.triggerRate
    Expire after
    data.list[i].expireTime
    (13-digit ms UTC), converted to the user's current timezone, formatted
    MM/DD/YYYY HH:MM:SS
    e.g.
    05/15/2026 17:50:49
    (semantically = createTime + 7 days by default)
    Sample row (Solana SOL→USDC take_profit):
    | 17262791359882688 | Active | Take Profit | 0.2 SOL | 9xQeWv...vEjz | 16 USD | $80 | 05/15/2026 17:50:49 |
    Address shortening rules:
    • EVM (
      0x
      prefix): first 6 chars (
      0x
      + 4) +
      ...
      + last 4 chars
    • Solana / other non-prefixed base58: first 6 +
      ...
      + last 4
    • Strings shorter than 10 chars: do not truncate; display verbatim
    Expire timezone conversion:
    • expireTime
      from BE is a UTC millisecond timestamp
    • The agent must convert to the user's current local timezone at render time (e.g. JS
      Intl.DateTimeFormat
      , Rust
      chrono::Local
      , or equivalent)
    • Fixed format:
      MM/DD/YYYY HH:MM:SS
      , 24-hour clock
  3. After the table, append a single combined reminder covering pagination + status filter. Include the pagination line only when
    nextCursor
    is non-empty
    .
    Canonical EN; the agent translates per §Display labels & output language:
    Showing live orders by default (10 per page).
    • Reply "next page" to load more.
    • To filter by a specific state, ask for orders by their Display label — e.g.
      Completed
      ,
      Cancelled
      ,
      Failed
      ,
      Expired
      . Example: "show my completed orders" → I'll re-query with that filter.
    If
    nextCursor
    is empty (no more pages), drop the "next page" bullet and keep only the status-filter bullet.
  4. If the user replies "next page" / similar, re-run with
    --limit 10 --cursor <nextCursor>
    carrying the previous response's
    nextCursor
    . Render with the same table format.
  5. If the user names a specific status (any of the 9 Display labels), re-run as
    list --limit 10 --status <label>
    (single value) and render the same table. Drop the status-filter bullet from the reminder; keep the pagination bullet if
    nextCursor
    is non-empty.
符合此规则的用户提示包括:"查看我的策略订单" / "列出订单" / "查看我的限价单" / "我有哪些订单"——即任何无状态限定的"查看我的订单"通用意图。
Agent必须遵循以下步骤:
  1. 运行
    onchainos strategy list --limit 10
    (无
    --status
    )——CLI会在请求体中传入
    orderStatusList=[-3, 0, 2, 3, 4]
    (非终态集合);后端会在服务器端应用此筛选,仅返回匹配的订单。通用"查看我的订单"查询必须始终传递
    --limit 10
    ;分页需通过"下一页"后续请求触发。
  2. 将响应
    data.list
    渲染为Markdown表格,必须包含以下8列(固定):
    订单ID订单状态订单类型预估数量买入代币地址价值触发价到期时间
    每行映射(列顺序固定,不得添加额外列):
    来源说明
    订单ID
    data.list[i].orderId
    订单状态
    data.list[i].statusLabel
    (根据§
    status
    表生成的显示标签)
    根据§显示标签与输出语言的规则翻译
    订单类型根据§
    strategyType
    表生成的显示标签,由
    data.list[i].strategyType
    整数值推导(
    2 → 抄底
    /
    3 → 止盈
    /
    4 → 止损
    /
    5 → 追高买入
    根据§显示标签与输出语言的规则翻译
    预估数量
    data.list[i].toToken.tokenAmount
    +
     
    +
    data.list[i].toToken.tokenSymbol
    例如
    0.2 SOL
    买入代币地址
    data.list[i].toToken.tokenContractAddress
    截断为前6位 + 后4位
    EVM:
    0x1234...cdef
    0x
    + 4个字符 +
    ...
    + 4个字符);Solana base58:前6位 +
    ...
    + 后4位
    价值
    data.list[i].toToken.tokenUsd
    ,格式化为
    <n> USD
    例如
    16 USD
    (四舍五入或保留两位小数,遵循后端精度)
    触发价
    data.list[i].triggerInfo.triggerPrice
    ,前缀添加
    $
    例如
    $80
    ;若为空(触发率路径,第一阶段未使用)则显示
    data.list[i].triggerInfo.triggerRate
    到期时间
    data.list[i].expireTime
    (13位毫秒级UTC时间戳),转换为用户当前时区,格式为
    MM/DD/YYYY HH:MM:SS
    例如
    05/15/2026 17:50:49
    (语义上默认=创建时间+7天)
    示例行(Solana SOL→USDC止盈单):
    | 17262791359882688 | 活跃中 | 止盈 | 0.2 SOL | 9xQeWv...vEjz | 16 USD | $80 | 05/15/2026 17:50:49 |
    地址截断规则:
    • EVM(
      0x
      前缀):前6个字符(
      0x
      + 4个字符) +
      ...
      + 后4个字符
    • Solana / 其他无前缀base58地址:前6位 +
      ...
      + 后4位
    • 长度小于10的字符串:不截断,完整显示
    到期时间时区转换:
    • 后端返回的
      expireTime
      是UTC毫秒时间戳
    • Agent必须在渲染时转换为用户当前本地时区(例如JS
      Intl.DateTimeFormat
      、Rust
      chrono::Local
      或等效工具)
    • 固定格式:
      MM/DD/YYYY HH:MM:SS
      ,24小时制
  3. 在表格后添加合并提示,包含分页+状态筛选说明。仅当
    nextCursor
    非空时才包含分页提示。
    标准英文表述;Agent需根据§显示标签与输出语言的规则翻译:
    默认显示活跃订单(每页10条)。
    • 回复"下一页"加载更多。
    • 若要按特定状态筛选,请按显示标签查询订单——例如
      已完成
      已取消
      已失败
      已过期
      。示例:"查看我的已完成订单" → 我会使用该筛选重新查询。
    nextCursor
    为空(无更多页),则移除"下一页"项目符号,仅保留状态筛选提示。
  4. 若用户回复"下一页"等,重新运行
    list --limit 10 --cursor <nextCursor>
    ,传入上一次响应中的
    nextCursor
    。使用相同表格格式渲染。
  5. 若用户指定了具体状态(9种显示标签中的任意一种),重新运行
    list --limit 10 --status <label>
    (单个值)并使用相同表格渲染。移除提示中的状态筛选项目符号;若
    nextCursor
    非空则保留分页提示。

4.
onchainos strategy resume

4.
onchainos strategy resume

onchainos strategy resume                          # auto-discover all SUSPENDED + canResume=true on active wallet
onchainos strategy resume --order-ids id1,id2      # explicit
When ids are omitted, the CLI runs
list
filtered to
status=4
and keeps only orders whose
canResume
flag is true; the discovered ids are then submitted to
reactivate
. After resume, the agent should advise the user that orders whose trigger condition was already met may execute immediately — re-query with
list
to confirm.
onchainos strategy resume                          # 自动发现当前钱包中所有状态为SUSPENDED且canResume=true的订单
onchainos strategy resume --order-ids id1,id2      # 显式指定订单
若省略订单ID,CLI会运行
list
并筛选
status=4
的订单,仅保留
canResume
为true的订单;然后将发现的订单ID提交至
reactivate
接口。恢复后,Agent应告知用户:已满足触发条件的订单可能会立即执行——请用
list
重新查询以确认状态。

Error code → Agent action

错误码 → Agent操作

The CLI surfaces the BE error code in human-readable form. Map each code to a recommended next step:
CodeNameWhat the agent should do
100REQUEST_PARAM_ERRORSurface the BE message; ask the user to fix the offending flag
10019INSUFFICIENT_NATIVE_GAS_BALANCEWallet's native token balance is below the BE-required minimum (the response msg includes
minAmount = <N>
, e.g.
0.001
BNB on BSC). Tell the user their native gas balance is insufficient to pay this chain's gas fees and prompt them to top up — deposit from an exchange, transfer from another account, or swap a stablecoin to native via
onchainos swap execute
. Do NOT auto-retry.
10026JWT_TOKEN_VERIFY_FAILEDSuggest
onchainos wallet login
then retry
10106CHAIN_NOT_SUPPORT_ERRORTell the user the chain is not supported; suggest a supported alternative
60002NO_ORDER_FOUNDCancel/resume target id is wrong or already terminal — suggest
list
60003LIMIT_ORDER_NO_AUTHORITYTrader Mode may not be activated yet; the next CLI call will trigger SD-A automatically — retry once
60006LIMIT_ORDER_OUT_LIMIT_FAILPending order count is at the per-account limit (max 100); ask the user to cancel some pending orders (
cancel --all
or
cancel --order-id
) and retry
60009LIMIT_ORDER_ILLIQUIDITY_ERRORNo liquidity for the pair at the trigger; suggest a different pair or wider trigger
60014LIMIT_ORDER_EXPIRED_CANNOT_OPERATEOrder already expired
60015LIMIT_ORDER_PENDING_CANNOT_OPERATEOrder is mid-lifecycle; wait for terminal state
60017LIMIT_ORDER_SUCCESS_CANNOT_OPERATEOrder already completed
60018LIMIT_ORDER_TEE_SA_VERSION_UPGRADE_REQUIREDTransparent — CLI handles via SD-A retry; the agent should NOT see this code in normal flow. If it leaks, just retry the same command
60030QUOTA_EXCEEDEDAccount-level quota reached
100005WALLET_ADDRESS_BLACKLISTEDWallet address flagged by risk control; ask the user to contact support — do not retry
100007TEE_SIGN_FAILURETransient TEE issue — retry once
100010ORDER_AMOUNT_TOO_SMALLOrder value is below the BE-enforced minimum of $1 USD. Ask the user to increase
--amount
so the order value clears $1, then retry
100008TEE_SERVICE_UNAVAILABLETEE service is temporarily unavailable; ask the user to retry later
100012LIMIT_ORDER_INSUFFICIENT_BALANCEInsufficient balance; suggest checking with
onchainos wallet balance
Match by integer code, not msg string. The msg text is for humans and may change.
CLI会以人类可读形式展示后端错误码。请将每个错误码映射至推荐的后续操作:
错误码名称Agent应执行的操作
100REQUEST_PARAM_ERROR展示后端错误信息;请用户修正对应的参数
10019INSUFFICIENT_NATIVE_GAS_BALANCE钱包原生代币余额低于后端要求的最小值(响应信息包含
minAmount = <N>
,例如BSC上为
0.001
BNB)。告知用户其原生Gas余额不足以支付该链的Gas费用,并提示用户充值——从交易所存入、从其他账户转账,或通过
onchainos swap execute
将稳定币兑换为原生代币。不得自动重试。
10026JWT_TOKEN_VERIFY_FAILED建议用户执行
onchainos wallet login
后重试
10106CHAIN_NOT_SUPPORT_ERROR告知用户该链不支持;建议使用支持的替代链
60002NO_ORDER_FOUND取消/恢复的目标订单ID错误或已进入终态——建议用户使用
list
查询
60003LIMIT_ORDER_NO_AUTHORITY交易员模式可能尚未激活;下一次CLI调用会自动触发SD-A——重试一次
60006LIMIT_ORDER_OUT_LIMIT_FAIL挂单数量已达账户上限(最多100个);请用户取消部分挂单(
cancel --all
cancel --order-id
)后重试
60009LIMIT_ORDER_ILLIQUIDITY_ERROR触发价下该交易对无流动性;建议更换交易对或扩大触发价范围
60014LIMIT_ORDER_EXPIRED_CANNOT_OPERATE订单已过期
60015LIMIT_ORDER_PENDING_CANNOT_OPERATE订单处于中间生命周期;等待进入终态
60017LIMIT_ORDER_SUCCESS_CANNOT_OPERATE订单已完成
60018LIMIT_ORDER_TEE_SA_VERSION_UPGRADE_REQUIRED自动处理——CLI会通过SD-A重试;正常流程下Agent不会看到此错误码。若意外出现,只需重试相同命令即可
60030QUOTA_EXCEEDED账户级配额已达上限
100005WALLET_ADDRESS_BLACKLISTED钱包地址被风控标记;请用户联系客服——不得重试
100007TEE_SIGN_FAILURETEE临时问题——重试一次
100010ORDER_AMOUNT_TOO_SMALL订单价值低于后端强制执行的1美元最小值。请用户提高
--amount
使订单价值超过1美元后重试
100008TEE_SERVICE_UNAVAILABLETEE服务暂时不可用;请用户稍后重试
100012LIMIT_ORDER_INSUFFICIENT_BALANCE余额不足;建议用户使用
onchainos wallet balance
查询
请按整数错误码匹配,而非错误信息字符串。 错误信息面向人类,可能会变更。

Execution event codes (
executionHistoryList[].code
)

执行事件码(
executionHistoryList[].code

A separate stream from the BE error codes above. Emitted by the TEE swap-trade engine while it attempts to execute an active order. Read the latest entry first; older entries are historical context.
CLI enriches each entry directly — no sidecar table needed. For every code the CLI recognises (35+ codes covering the 3xxx active series + 2xxx legacy series),
list
and detail responses inject three fields next to the raw
code
:
FieldSourceUse
name
Catalog (
tradeSuccessed
/
noLiquidty
/ ...)
Internal label; do NOT surface to the user
message
Catalog — matches OKX wallet UI wordingSurface verbatim to the user (translate per §Display labels & output language)
terminal
Catalog
true
⇒ TEE engine will not retry; stop polling and surface.
false
⇒ engine retries; safe to wait
For codes the CLI does not recognise (BE added a new code we haven't catalogued yet), the entry passes through unchanged —
name
/
message
/
terminal
are absent and the agent should surface the raw BE
msg
field if present, or fall back to
"event code <N>"
.
与上述后端错误码为独立流。由TEE兑换交易引擎在尝试执行活跃订单时触发。请先查看最新条目;旧条目仅为历史上下文。
CLI会直接丰富每个条目——无需额外表格。对于CLI可识别的所有代码(35+种,涵盖3xxx活跃系列+2xxx legacy系列),
list
和详情响应会在原始
code
旁注入三个字段:
字段来源用途
name
目录(
tradeSuccessed
/
noLiquidty
等)
内部标签;不得向用户展示
message
目录——与OKX钱包UI表述一致直接向用户展示(根据§显示标签与输出语言的规则翻译)
terminal
目录
true
⇒ TEE引擎不会重试;停止轮询并向用户展示。
false
⇒ 引擎会重试;可继续等待
对于CLI无法识别的代码(后端新增了未收录的代码),条目会直接透传——无
name
/
message
/
terminal
字段;若后端返回了
msg
字段,Agent可展示该字段;否则 fallback 至
"事件码<N>"

Reading patterns

解读模式

  • Latest entry wins. Render the most recent
    executionHistoryList[]
    item; older entries are historical context only.
  • Repeated same code. When the same code recurs every ~10s without a
    txHash
    appearing, the engine is in a soft retry loop. Surface the latest
    message
    , mention the repeat count ("this is the 5th
    No quote due to low liquidity
    event"), and ask the user whether to wait, cancel, or adjust parameters.
  • terminal=true
    codes.
    Stop polling immediately and surface to the user; engine will not retry.
  • terminal=false
    codes that repeat 3+ times.
    Treat as user-actionable: suggest changing slippage / amount / pair / chain, or cancelling.
  • Code
    0
    with
    txHash
    .
    Trade succeeded; surface
    txHash
    and explorer link.
  • 最新条目优先。渲染
    executionHistoryList[]
    中最新的条目;旧条目仅作为历史上下文。
  • 重复相同代码。当相同代码每10秒左右重复出现且未生成
    txHash
    时,引擎处于软重试循环。展示最新的
    message
    ,提及重复次数("这是第5次
    因流动性不足无法获取报价
    事件"),并询问用户是否等待、取消或调整参数。
  • terminal=true
    代码
    。立即停止轮询并向用户展示;引擎不会重试。
  • terminal=false
    代码重复3次及以上
    。视为需要用户操作:建议调整滑点/金额/交易对/链,或取消订单。
  • 代码
    0
    且带有
    txHash
    。交易成功;展示
    txHash
    和浏览器链接。

Action hints by hot code

热门代码对应的操作提示

The
message
field is the user-facing string. The agent additionally chooses one of these action hints based on
code
:
codewhat the agent should do
0report success; surface
txHash
+ explorer link
3013suggest topping up the from-token or recreating with smaller amount
3014tell user to fund the chain's native fee token (SOL / ETH / BNB / ...)
3015suggest widening
--slippage
3016non-transient — suggest different pair, smaller amount, wider trigger, or different chain
3017engine retries; if recurring 3+ times, treat like 3016
3019terminal — destination token is blocklisted; order will not execute
3020terminal — wallet address is flagged; surface explicitly
3023recreate with longer
--expires-in
Codes outside this table: read
terminal
from the CLI output.
terminal=true
⇒ surface and stop.
terminal=false
⇒ surface and wait one more cycle.
message
字段是面向用户的字符串。Agent需根据
code
选择以下操作提示之一:
代码Agent应执行的操作
0报告成功;展示
txHash
+ 浏览器链接
3013建议用户补充卖出代币或创建金额更小的订单
3014告知用户为该链的原生手续费代币(SOL / ETH / BNB等)充值
3015建议扩大
--slippage
3016非临时问题——建议更换交易对、减小金额、扩大触发价范围或更换链
3017引擎会重试;若重复3次及以上,按3016处理
3019终态——目标代币被封禁;订单无法执行
3020终态——钱包地址被标记;明确告知用户
3023创建订单时设置更长的
--expires-in
不在此表中的代码:从CLI输出读取
terminal
值。
terminal=true
⇒ 展示并停止。
terminal=false
⇒ 展示并等待下一轮。

Async wait pattern

异步等待模式

create-limit
,
cancel
, and
resume
return after the request has been accepted, not after the order reached a terminal state. The CLI surfaces
estimatedWaitTime
(seconds, BE-supplied — typically 0 for Solana, ~3 for BSC, ~12 for ETH-class chains).
Agent recipe (locked):
  1. Run the subcommand.
  2. Sleep 3 seconds. A single fixed 3-second wait is enough across all supported chains in practice — empirically validated 2026-05-11. Do not read
    estimatedWaitTime
    from the response and sleep by that value; the BE-supplied number is conservative and inflates the wait unnecessarily (especially on ETH-class chains).
  3. Re-query with
    onchainos strategy list --order-id <orderId>
    to read the final state.
  4. If still pending after the first re-query, surface the partial state to the user; do not loop indefinitely.
Do not run a long polling loop. The CLI is not designed for that; the BE backs the order finalisation off-chain and one targeted re-query is sufficient in normal conditions.
create-limit
cancel
resume
在请求被接受后即返回,而非订单进入终态后。CLI会展示
estimatedWaitTime
(秒,由后端提供——Solana通常为0,BSC约3秒,ETH类链约12秒)。
Agent流程(固定):
  1. 运行子命令。
  2. 等待3秒。在所有支持的链上,单次固定等待3秒已足够——2026-05-11经验证有效。不得读取响应中的
    estimatedWaitTime
    并按该值等待;后端提供的数值较为保守,会不必要地延长等待时间(尤其是ETH类链)。
  3. 使用
    onchainos strategy list --order-id <orderId>
    重新查询以读取最终状态。
  4. 若第一次重新查询后仍处于挂起状态,向用户展示部分状态;不得无限循环轮询。
不得运行长轮询循环。CLI并非为此设计;后端在链下处理订单终态,正常情况下一次定向重新查询已足够。

SA activation transparency

SA激活透明化

Trader Mode upgrade / re-upgrade is performed transparently by the CLI:
  • On
    create-limit
    or
    resume
    , if the BE returns code
    60018
    (
    UPGRADE_REQUIRED
    ), the CLI calls the Agentic Wallet attestation endpoints (
    getAttestDocHex
    → ed25519 sign with the session key →
    registerTeeInfo
    ), then retries the original op once. On success the user sees
    Trader Mode activated.
    followed by the normal command output.
  • The agent should not ask the user to "activate Trader Mode" first — the CLI does it on demand.
  • If activation fails, the original command aborts and the activation error is surfaced. Suggest
    onchainos wallet status
    to inspect the session.
交易员模式升级/重新升级由CLI自动执行:
  • create-limit
    resume
    时,若后端返回错误码
    60018
    UPGRADE_REQUIRED
    ),CLI会调用Agentic Wallet认证端点(
    getAttestDocHex
    → 使用会话密钥进行ed25519签名 →
    registerTeeInfo
    ),然后重试原操作一次。成功后用户会看到
    已激活交易员模式。
    ,随后显示正常命令输出。
  • Agent无需要求用户"先激活交易员模式"——CLI会按需执行。
  • 若激活失败,原命令会终止并展示激活错误。建议用户执行
    onchainos wallet status
    检查会话状态。

Output format conventions

输出格式约定

All strategy subcommands always emit the standard onchainos JSON envelope
{ok: true, data: { ... }}
on stdout. There is no
--format
flag — strategy CLI is agent-facing, so structured JSON is the only output and the agent renders any user-visible tables (e.g. the §
list
8-column Markdown table) from that JSON.
所有策略子命令始终在标准输出中输出标准onchainos JSON信封
{ok: true, data: { ... }}
。无
--format
参数——策略CLI面向Agent,因此结构化JSON是唯一输出格式;Agent需从此JSON渲染所有用户可见表格(例如§
list
命令的8列Markdown表格)。

Phase 1 limitations

第一阶段限制

ItemPhase 1 status
Symbol → address resolution for
--from-token
/
--to-token
Not in scope; pass token addresses directly
Custom preset (advanced fee tiers, dexId filter)Default preset only — Phase 2. MEV protection is already supported via
--mev-protection <on/off/default>
(see §1 flag table).
Events stream / cursor consumption
eventCursor
is surfaced verbatim; no consumer in Phase 1
cancel --all
source-channel filter (KD-009)
Pass-through to BE default; CLI does not pre-filter
Multi-account batchOut of scope; CLI uses the active account only
get_account_status
(PRD §5.1)
Intentionally not implemented. SA activation / expiry is handled transparently inside the 60018 (UPGRADE_REQUIRED) flow — the CLI runs SD-A and retries silently. The agent does not need to query SA state up-front; just call the intended subcommand and let the CLI handle activation on demand.
第一阶段状态
--from-token
/
--to-token
的符号→地址解析
不在范围内;直接传递代币地址
自定义预设(高级手续费档位、dexId筛选)仅支持默认预设——第二阶段实现。已通过
--mev-protection <on/off/default>
支持MEV保护(见§1参数表)。
事件流/游标消费
eventCursor
直接展示;第一阶段无消费者
cancel --all
的源渠道筛选(KD-009)
透传至后端默认值;CLI不做前置筛选
多账户批量操作不在范围内;CLI仅使用当前账户
get_account_status
(PRD §5.1)
故意未实现。SA激活/过期在60018(UPGRADE_REQUIRED)流程中自动处理——CLI会运行SD-A并静默重试。Agent无需提前查询SA状态;只需调用目标子命令,CLI会按需处理激活。
",