gTrade with CAI (Route B)
CAI E-mode lets an agent trade gTrade perps using the custodial wallet after the user enables the platform at /automation-settings and completes one hosted enrollment on cai.com /act. Prefer unified defi_trade over legacy per-platform tools.
When to Use
- "Trade gTrade with my CAI wallet"
- "Enable agent trading on Gains / gTrade"
- "Open a small BTC perp on Arbitrum or Polygon via CAI"
- "Check my gTrade order status after placing a trade"
Route B task flow (preferred)
- User enables gtrade at
https://cai.com/automation-settings(browser; not API-key callable). platform_readinesswithplatform_slug=gtrade(optionalchain:arbitrum|polygon). Ifready_to_tradeis false, showblocking_reasonsand stop.- If not enrolled:
platform_automation_enrollwithplatform_slug=gtradeandchain→ returnurl; user must complete/act(agent must not confirm for the user). - Markets:
defi_marketswithplatform_slug=gtradeandchain— resolvepair_indexfrom catalog. - Preflight:
defi_preflightuntilvalid: true. - Place:
defi_tradewith body example:platform_slug:gtradeaction:placecollateral_amount,pair_index,leverage,buy,chain,intent_usd
- Status (primary): poll
defi_order_statuswith returnedorder_iduntilis_terminal: true. - Status (secondary): use
defi_orderswith?platform_slug=gtrade&status=activefor resting orders;status=terminalfor history. - Close:
defi_tradewithaction:close, optionaltrade_index(omit when exactly one matching long),symbol/pair_index,close_mode=full,chain. - Sell guard:
place+buy=falsewithout long → preflightNO_POSITION_TO_CLOSE— useaction=closeinstead.
Legacy aliases (deprecated)
gtrade_open_trade/gtrade_close_trade— do not use in new flows.
Chain parameter
chain:arbitrum(default) |polygon- Enrollment may require
enroll_approveper chain (gtrade_arb_v1,gtrade_pol_v1).
Honesty
gap_id:GAP_DEFI_GTRADE_V1,GAP_DEFI_AUTOMATION_V1—partial_liveuntil enrollment + trade smokes pass in your environment.- Server must include
gtradeinDEFI_ENABLED_PLATFORMSandCUSTODIAL_DEFI_AUTOMATION_ENABLED=true. - Do not use raw EVM calldata, generic sign-and-broadcast, or
CAI_EVM_TX_PATH.
Quick Setup
openclaw secrets set CAI_API_KEY "your_dashboard_api_key"
Scope: platform or full.
