Resolving (binary path)
Resolve
in order:
(1) and
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
§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 commands 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 assets
gate-cli cex assetswap config
gate-cli cex assetswap evaluate
gate-cli cex assetswap order list
gate-cli cex assetswap order get
Execution operations (write, trade scope)
gate-cli cex assetswap order preview
gate-cli cex assetswap order create
Authentication
- Interactive file setup: when and are not both set on the host, run to complete the wizard for API key, secret, profiles, and defaults (see gate-cli).
- Env / flags: is not required when credentials are already supplied — e.g. both and set on the host, or / where 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 ); prefer when running from the host CLI.
- Install (MCP / IDE):
gate-mcp-cursor-installer
, , gate-mcp-claude-installer
, or gate-mcp-openclaw-installer
.
- Credentials: When and are both set (non-empty) for the host, do not require . When both are unset or empty, remind the operator to run or to configure / in 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. or 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 or equivalent 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 the gate-cli cex assetswap order create
body from the preview response only: for each object in and , emit { "asset": <value>, "amount": <value> }
using the preview’s and string fields (use , not , unless published API docs say otherwise).
- Preserve the array order of (and if multiple legs) exactly as returned in ; do not reorder symbols for convenience.
- A preview request may use on ; the create call must still use the resolved + legs from the preview output. Creating with ratio-only while omitting preview amounts often yields quote errors (for example ).
- If the API returns additional preview-bound fields (for example top-level or inside ), mirror them on create when the MCP or Exchange docs require it; otherwise the / legs 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
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:
- : | | | | |
- : conservative | conviction | market_cap | unknown (confirm via config)
- : 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:
- : 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:
- and 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:
- : 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:
- : any quote, token, or expiry fields required for Step 6 (follow response schema exactly)
- : copy of reduced to per element (from preview , not )
- : copy of reduced to per element, same order as preview
- : 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
is
and
is
from Step 5 (each leg
+ from
). Add any other preview-bound fields required by the API (for example values under
such as
or
) only when documentation or repeated failures indicate they are required. Do
not substitute ratio-only
for this step when the preview already returned concrete
per target asset.
Key data to extract:
- or 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:
- : 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:
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 + from / (preview order preserved); re-preview and retry; avoid ratio-only 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 create
without 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 entries with ; use those + pairs (and matching legs) 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
markdown
## 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.