gate-exchange-assetswap
Resolving gate-cli (binary path)
Resolve gate-cli in order: (1) command -v gate-cli and gate-cli --version succeeds; (2) ${HOME}/.local/bin/gate-cli if executable; (3) ${HOME}/.openclaw/skills/bin/gate-cli if executable. Canonical rules: exchange-runtime-rules.md §4 (or gate-runtime-rules.md §4).
Gate Exchange Asset Allocation Optimization
General Rules
⚠️ STOP — You MUST read and strictly follow the shared runtime rules before proceeding. Do NOT select or call any tool until all rules are read. These rules have the highest priority. → Read gate-runtime-rules.md
- Only use the
gate-clicommands explicitly listed in this skill. Commands not documented here must NOT be run for these workflows, even if other interfaces expose them.
Skill Dependencies
gate-cli commands used
Query operations (read-only, profile scope)
gate-cli cex assetswap assetsgate-cli cex assetswap configgate-cli cex assetswap evaluategate-cli cex assetswap order listgate-cli cex assetswap order get
Execution operations (write, trade scope)
gate-cli cex assetswap order previewgate-cli cex assetswap order create
Authentication
- Interactive file setup: when
GATE_API_KEYandGATE_API_SECRETare not both set on the host, rungate-cli config initto complete the wizard for API key, secret, profiles, and defaults (see gate-cli). - Env / flags:
gate-cli config initis not required when credentials are already supplied — e.g. bothGATE_API_KEYandGATE_API_SECRETset on the host, or--api-key/--api-secretwhere supported — never ask the user to paste secrets into chat. - API Key required: Yes
- Permissions: Profile (read) for listing, config, evaluation, and order queries; Trade for preview and order creation
- Portal: create or rotate keys outside the chat: https://www.gate.com/myaccount/profile/api-key/manage
Installation Check
- Required: Gate (main) MCP with asset allocation optimization tools enabled (MCP names
cex_assetswap_*); prefergate-cli cex assetswap …when running from the host CLI. - Install (MCP / IDE):
gate-mcp-cursor-installer,gate-mcp-codex-installer,gate-mcp-claude-installer, orgate-mcp-openclaw-installer. - Credentials: When
GATE_API_KEYandGATE_API_SECRETare both set (non-empty) for the host, do not requiregate-cli config init. When both are unset or empty, remind the operator to rungate-cli config initor to configureGATE_API_KEY/GATE_API_SECRETin the matching skill from the skill library (never ask the user to paste secrets into chat). - Sanity check: Before preview or order creation, confirm the runtime works (e.g.
gate-cli --versionor deployment-specific checks).
Trigger Conditions
Activate this skill when the user wants any of the following:
- Multi-asset spot portfolio optimization or rebalancing into a strategy (conservative stablecoin, conviction single asset, or market-cap-weighted basket)
- To see which spot balances are eligible for asset allocation optimization
- Preview estimated execution, slippage, or risk hints before committing
- Submit an asset allocation optimization order after confirmation
- Query historical allocation optimization orders or one order’s status and child orders
Do not use this skill for: transfers between accounts or products, Launchpool or earn subscriptions, single manual spot limit/market orders without the allocation product, or dust handling below product thresholds (route to the appropriate transfer, earn, spot, or small-balance product skill instead).
Data privacy and collection
- AI interaction information: User prompts, follow-up instructions, and tool arguments used while following this skill qualify as AI interaction data under the Gate Privacy Policy (see §4.2.7). Do not ask for or repeat API keys, secrets, or unrelated personal data in user-visible output.
- Data flow: Account and trading data for this skill flow only through the configured Gate (main) MCP to Gate Exchange APIs via the asset-swap tools above (MCP
cex_assetswap_*or equivalentgate-cli cex assetswap …calls). Do not relay the same data to undocumented third-party services, scrapers, or custom backends as part of this workflow. - Minimization: Pass only parameters required by each documented MCP call (symbols, amounts, strategy fields, pagination). Do not send full chat transcripts or unrelated context fields into tool payloads.
Domain Knowledge
Product: Asset Allocation Optimization exposes Exchange capability for restructuring multiple spot holdings into a target mix. One optimization may map to multiple internal execution legs at the order layer.
Strategy types (conceptual; exact enums and parameters come from gate-cli cex assetswap config):
| Strategy | Typical targets | Meaning |
|---|---|---|
| Conservative | USDT, GUSD, USDC (examples) | Consolidate into a single stablecoin; risk-off / idle cash posture |
| Conviction ("faith") | BTC, ETH, GT (examples) | Reallocate selected spot toward target weights in the chosen asset(s); intermediate steps follow the product and API |
| Market cap | Top 2, Top 5 (examples) | Index-like exposure weighted by market cap into a basket such as BTC, ETH, SOL, BNB, XRP (actual list from API) |
Listing rules (for agent interpretation; product may filter server-side):
- Default presentation may exclude major reserve assets (e.g. BTC, ETH, USDT, USDC) unless the user explicitly asks to include them in the sell set.
- Only spot available balances participate; locked balances from earn, borrow, staking, or similar are out of scope.
- Very small balances (e.g. below roughly USD 10 equivalent) may be hidden or routed to small-balance handling; exact thresholds follow API or product rules.
Out of scope for public skill documentation (do not document as standard Exchange MCP capabilities):
- Banner or UI-only feature flags
- Non-standard semantic "validate and fill parameters" helpers not published as Exchange MCP
Rate limiting: Align with wallet or Exchange API limits when documented (example: 200 requests per 10 seconds per user or key); confirm in published API docs.
Preview → create payload (mandatory for agents):
- After a successful
gate-cli cex assetswap order preview, construct thegate-cli cex assetswap order createbody from the preview responsedata.orderonly: for each object indata.order.fromanddata.order.to, emit{ "asset": <value>, "amount": <value> }using the preview’sassetandamountstring fields (useamount, notamount_show, unless published API docs say otherwise). - Preserve the array order of
to(andfromif multiple legs) exactly as returned indata.order; do not reorder symbols for convenience. - A preview request may use
ratioonto; the create call must still use the resolvedasset+amountlegs from the preview output. Creating with ratio-onlytowhile omitting preview amounts often yields quote errors (for examplecode: 4). - If the API returns additional preview-bound fields (for example top-level
usdt_evaluated_valueortransaction_feeinsidedata), mirror them on create when the MCP or Exchange docs require it; otherwise thefrom/tolegs from preview are the primary contract.
Main chain (mandatory order for placement):
- Case 1 — list eligible assets
- Case 2 — get strategy and parameter configuration
- Case 3 — pre-trade evaluation and preview (3a optional, 3b strongly required or mandatory per product rules)
- Case 4 — create order after explicit user confirmation of preview
Do not jump from Case 2 to Case 4 without Case 3b preview unless product rules explicitly allow it.
Supplemental queries (do not reorder the main chain):
- Case 5 — paginated order list
- Case 6 — single order detail
Order states (examples): configuring, completed, partially completed, failed — use API field names and values from responses.
Tool scope summary:
| Tool | Type | Scope |
|---|---|---|
gate-cli cex assetswap assets |
Read | profile |
gate-cli cex assetswap config |
Read | profile |
gate-cli cex assetswap evaluate |
Read | profile |
gate-cli cex assetswap order list |
Read | profile |
gate-cli cex assetswap order get |
Read | profile |
gate-cli cex assetswap order preview |
Write | trade |
gate-cli cex assetswap order create |
Write | trade |
Compliance: Restricted regions, KYC, and disabled accounts are enforced by the API. On compliance errors, relay the message and stop; do not promise outcomes the platform does not guarantee.
Agent must not: guarantee PnL, VIP tier level changes, or bypass eligibility rules.
Workflow
Step 1: Resolve user goal and route requests outside asset allocation optimization
Classify the request as: (A) discovery only, (B) full optimization through preview and optional order, (C) history or single-order status.
From the user message and session context only, infer intent and routing. Do not call any cex_* MCP tool in this step. If the user wants a single conventional spot order, transfer, grid bot, or earn action, stop using this skill and route to the appropriate Gate Exchange skill.
Key data to extract:
goal:list_only|evaluate_only|preview|place_order|order_list|order_detailstrategy_hint: conservative | conviction | market_cap | unknown (confirm via config)symbols_or_scope: which assets the user wants to include or exclude
Step 2: Case 1 — List assets eligible for optimization
Call gate-cli cex assetswap assets with: parameters per MCP and API documentation (no undocumented fields).
Key data to extract:
eligible_assets: symbols, available amounts, valuation hints returned by the API- Whether the user must narrow the set for the next steps
Step 3: Case 2 — Load configuration
Call gate-cli cex assetswap config with: no required body unless the API specifies optional filters; obtain allowed strategies, targets, limits, and precision rules.
Key data to extract:
allowed_strategiesand parameter shapes for TopN, target asset, and limits- Constraints the agent must enforce when building the next request payload
Step 4: Case 3a — Evaluation (optional)
When the user needs a quick estimate before final parameters, or while iterating on strategy choice:
Call gate-cli cex assetswap evaluate with: payload required by the API for the selected assets and strategy.
Key data to extract:
evaluation_summary: estimated notionals or other returned metrics- Any warnings or validation errors
Step 5: Case 3b — Preview order (required before create in normal flow)
After the user confirms the asset set and strategy parameters:
Call gate-cli cex assetswap order preview with: candidate selection and strategy fields per API docs.
Present preview outputs clearly: estimated fills, slippage or risk hints, and any server-side notices. Obtain explicit user confirmation after preview before Step 6.
If the market moves or the preview expires, repeat Step 5 (and Step 4 if needed) before creating an order.
Key data to extract:
preview_reference_fields: any quote, token, or expiry fields required for Step 6 (follow response schema exactly)create_from_legs: copy ofdata.order.fromreduced to{ asset, amount }per element (from previewamount, notamount_show)create_to_legs: copy ofdata.order.toreduced to{ asset, amount }per element, same order as previewuser_confirmed: boolean — must be true to proceed
Step 6: Case 4 — Create optimization order
Only after successful preview and explicit confirmation:
Call gate-cli cex assetswap order create with: JSON body whose from is create_from_legs and to is create_to_legs from Step 5 (each leg asset + amount from data.order). Add any other preview-bound fields required by the API (for example values under data such as usdt_evaluated_value or transaction_fee) only when documentation or repeated failures indicate they are required. Do not substitute ratio-only to for this step when the preview already returned concrete amount per target asset.
Key data to extract:
order_idor equivalent identifier- Initial status and timestamps
- Next-step guidance (poll detail or show history)
Step 7: Case 5 — List orders (supplemental)
When the user asks for recent history:
Call gate-cli cex assetswap order list with: pagination parameters per API (for example recent months as defined by product).
Key data to extract:
orders[]: identifiers, statuses, created times- Pagination cursors or flags if present
Step 8: Case 6 — Order detail (supplemental)
When the user supplies an order id or picks one from a list:
Call gate-cli cex assetswap order get with: order_id string per MCP and API documentation.
Key data to extract:
- Aggregate status and per-child order states if returned
- Amounts consumed and received as returned by the API
Error Handling
| Situation | Action |
|---|---|
| Preview expired or price invalid | Re-run gate-cli cex assetswap order preview (and evaluation if needed); explain briefly |
| Create returns quote error after successful preview | Confirm create body uses asset + amount from data.order.from / data.order.to (preview order preserved); re-preview and retry; avoid ratio-only to if preview returned amounts |
| Insufficient available balance | Stop create; ask user to free balance or adjust selection |
| Rate limit | Back off and retry later; show the API message |
| Compliance or region block | Stop; relay compliance message; do not retry with workarounds |
| Partial completion | Report actual status from gate-cli cex assetswap order get; no guaranteed completion time |
Safety Rules
- Trading risk: Digital asset trading involves significant risk and may result in partial or total loss of your investment. See the Gate Risk Disclosure and User Agreement.
- Never call
gate-cli cex assetswap order createwithout a successful preview and clear user confirmation of preview contents, except where the user’s own explicit one-shot authorization is defined by runtime rules for this product (default: require confirmation). - Never build the create payload with ratio-only target legs when the preview response already includes
data.order.toentries withamount; use thoseasset+amountpairs (and matchingfromlegs) for create. - Never fabricate order IDs, preview tokens, or success when the API returned an error.
- Display rates and amounts as estimates until execution; final settlement is authoritative.
- Do not expose API keys or secrets in user-visible output.
Judgment Logic Summary
| Condition | Action |
|---|---|
| User wants eligible spot assets for portfolio optimization | Case 1 only (gate-cli cex assetswap assets) |
| User needs strategy options or limits | Case 2 (gate-cli cex assetswap config) |
| User wants a quick estimate | Case 3a (gate-cli cex assetswap evaluate) |
| User is ready to see executable preview | Case 3b (gate-cli cex assetswap order preview) |
| User confirmed preview | Case 4 (gate-cli cex assetswap order create) |
| User asks for past optimizations | Case 5 (gate-cli cex assetswap order list) |
| User asks for one order’s progress | Case 6 (gate-cli cex assetswap order get) |
| User wants single spot order or grid bot | Route out of this skill |
| Preview failed or expired | Re-preview; do not create |
Report Template
## Asset allocation optimization
**Goal**: {list | evaluate | preview | order placed | history | detail}
**Eligible assets (summary)**: {N} items, {optional total valuation if API provides}
**Strategy**: {conservative | conviction | market_cap | from API}
**Preview** (if run):
- Key figures: {from API}
- Create legs (if placing order): {`from`/`to` as `asset`+`amount` from `data.order`}
- Risk or slippage notes: {from API}
**Order** (if created):
- Order ID: {id}
- Status: {status}
**History / detail** (if queried):
- {table or bullet list from API}
**Disclaimer**: Digital asset trading involves significant risk and may result in partial or total loss of your investment. Figures are from Gate Exchange APIs; final balances and fees follow account records. No PnL or VIP impact is guaranteed.
More from gate/gate-skills
gate-exchange-futures
Gate Exchange USDT perpetual futures trading skill. Use when the user wants to trade contracts, open/close perpetual positions, or manage futures leverage. Triggers on 'open long', 'close short', 'USDT perpetual', 'futures TP/SL'.
125gate-exchange-spot
Gate spot trading and account operations skill. Use when the user asks to buy/sell crypto on spot, check account value, list spot balances, or place conditional/trigger orders. Triggers on 'buy coin', 'sell spot', 'take profit', 'stop loss', 'cancel order', 'my spot balance', '查看我的现货账户余额', or '现货账户余额'.
113gate-exchange-marketanalysis
Gate Exchange market analysis tool. Use when the user asks for deep market metrics like liquidity, slippage, funding arbitrage, or manipulation risk. Triggers on 'liquidity', 'depth', 'slippage', 'momentum', 'buy/sell pressure', 'squeeze', 'funding rate', 'arbitrage', 'basis', 'premium'.
102gate-news-briefing
News briefing. Use this skill ONLY when the user's query is exclusively about recent news or headlines with no other analysis dimensions. Trigger phrases: what happened recently, today's highlights, crypto news, any new updates. If the query ALSO mentions coin analysis, risk check, technicals, or any other analysis dimension, use gate-info-research instead — it handles multi-dimension queries in a single unified report.
95gate-info-trendanalysis
Trend and technical analysis. Use this skill ONLY when the user's query is exclusively about technical indicators or trend analysis for one coin with no other analysis dimensions. Trigger phrases: technical analysis, K-line, RSI, MACD, trend, support, resistance. If the query ALSO mentions fundamentals, risk, news, sentiment, or any other analysis dimension, use gate-info-research instead — it handles multi-dimension queries in a single unified report.
84gate-dex-market
On-chain DEX market data queries via Gate: token prices/价格, K-line/OHLC candlestick charts, token rankings, security risk audits, new token discovery, holder analysis, and trading volume stats. Read-only — no transactions. Use when the user asks for 'token price', 'price of ETH', 'check SOL price', '查价格', 'K线', 'candlestick', 'OHLC', 'top gainers', 'trending tokens', 'is this token safe', 'honeypot check', 'new tokens', 'trading volume', or 'liquidity events'. Do NOT use for swap/trade execution (use gate-dex-trade) or wallet balance/account queries (use gate-dex-wallet).
76