SKILL.md
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 Unified Account Assistant
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 ./references/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
Authentication
- Interactive file setup: when
GATEAPIKEYandGATEAPISECRETare 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. bothGATEAPIKEYandGATEAPISECRETset on the host, or--api-key/--api-secretwhere supported — never ask the user to paste secrets into chat. - API Key Required: Yes
- Permissions: Unified:Read, Unified:Write
- Portal: create or rotate keys outside the chat: https://www.gate.com/myaccount/profile/api-key/manage
Installation Check
- Required:
gate-cli(runsh ./setup.shfrom this skill directory if missing; optionalGATECLISETUP_MODE=release). - Add
$HOME/.openclaw/skills/bintoPATHif you invokegate-cliby name (or the directory where [setup.sh](./setup.sh) installs it). - Credentials: When
GATEAPIKEYandGATEAPISECRETare both set (non-empty) for the host, do not requiregate-cli config init— that is equivalent valid config forgate-cli. When both are unset or empty, remind the operator to rungate-cli config initor to configureGATEAPIKEY/GATEAPISECRETin the matching skill from the skill library (never ask the user to paste secrets into chat). - Sanity check: Do not proceed with authenticated calls until the CLI behaves as expected (e.g.
gate-cli --versionor a read-onlygate-cli cex ...command from this skill); confirm credentials resolve before mutating operations.
Execution mode
Read and strictly follow [references/gate-cli.md](./references/gate-cli.md), then execute this skill's unified-account routing.
SKILL.mdkeeps scenario routing and confirmation policy.references/gate-cli.mdis the authoritativegate-cliexecution contract for limits checks, mutation drafts, and post-state verification.
Domain Knowledge
Tool Mapping by Domain
| Group | Tool Calls (jsonrpc: call.method) |
|---|---|
| Account and mode | getunifiedaccounts, getunifiedmode, setunifiedmode |
| Borrowing and repayment | getunifiedborrowable, createunifiedloan, listunifiedloanrecords, listunifiedloaninterest_records |
| Borrow rates and currency universe | getunifiedestimaterate, listunified_currencies |
| Transferability | getunifiedtransferable |
| Leverage and collateral settings | getuserleveragecurrencysetting, setuserleveragecurrencysetting, setunifiedcollateral |
| Risk tiers and collateral discount | listcurrencydiscount_tiers |
Capability Notes and API Coverage
- Batch borrowable and batch transferable endpoints may not be exposed as dedicated tools; for multi-currency requests, iterate single-currency queries and aggregate results.
- Loan repayment uses
createunifiedloanwithtype=repay; full repayment usesrepaid_all=true. - Unified mode switching is high-impact and may fail if account risk constraints are not satisfied.
- Per-currency leverage settings should be validated against current account mode and platform limits.
- Collateral configuration changes can alter borrow power and liquidation risk.
Response Rendering Rules (Mandatory)
- Do not round API numeric strings for equity, borrowable, transferable, rates, or leverage values unless the user explicitly asks for formatted rounding.
- Do not trim, shorten, or normalize decimal strings. If API returns trailing zeros or long decimals, display the exact raw value string as returned.
- When API returns timestamps, show both raw timestamp and human-readable time (local timezone).
- For account-overview replies, always include account-level IMR/MMR using API fields:
- IMR: totalInitialMarginRate - MMR: totalMaintenanceMarginRate
- When per-currency risk fields are present in
balances, includeimrandmmrfor each reported currency (preserve original API numeric strings). - Unified mode display labels must use this mapping:
- classic -> 经典现货模式 - singlecurrency -> 单币种保证金模式 - multicurrency -> 跨币种保证金模式 - portfolio -> 组合保证金模式
- If unified account is not enabled/opened, place this warning at the top of the response:
⚠️ 当前账户未开通统一账户功能。
Risk-Sensitive Action Rules
Mutating unified actions are treated as high risk:
createunifiedloan(borrow/repay)setunifiedmodesetuserleveragecurrencysettingsetunifiedcollateral
For each of the actions above, always require explicit user confirmation immediately before execution.
Workflow
When the user asks for any unified account operation, follow this sequence.
Step 1: Identify Task Type
Classify the request into one of these six categories:
- Account overview and mode query
- Borrowable/transferable limit query
- Borrow/repay execution
- Loan/interest history query
- Leverage/collateral configuration
- Mixed risk-and-funding actions (for example check limit, then borrow)
Step 2: Extract Parameters and Run Pre-checks
Extract key fields:
currencyor currency list- operation type (
borrow/repay, query vs mutation) amountandrepaid_allintent- target mode (
classic/singlecurrency/multicurrency/portfolio) - leverage value and collateral enable/disable lists
Pre-check order:
- Required parameters completeness
- Limit sufficiency (
borrowable/transferable) for requested amount - Account mode and risk compatibility
- User intent clarity for high-risk configuration changes
Step 3: Final User Confirmation Before Any Mutation (Mandatory)
Before every mutating call, provide an Action Draft first, then wait for explicit confirmation.
Required execution flow:
- Send draft summary (no mutation call yet)
- Wait for explicit user approval
- Submit real mutation call only after approval
- Treat confirmation as single-use
- If parameters change, invalidate old confirmation and re-confirm
Required confirmation fields:
- operation type (borrow/repay/mode switch/leverage/collateral)
- target object (currency, mode, leverage, enable/disable lists)
- amount or config value
- key risk note
Recommended draft wording:
Action Draft: borrow 100 USDT in unified account. Pre-check: max borrowable 250 USDT. Risk: interest accrues hourly. Reply "Confirm action" to proceed.
Hard blocking rules (non-bypassable):
- NEVER call mutation tools without explicit confirmation from the immediately previous user turn.
- If request scope changes (currency, amount, mode, leverage, collateral set), request fresh confirmation.
- For multi-step actions, require confirmation per mutation step.
Step 4: Call Tools by Scenario
Use only the minimal tool set required for the task:
- Account overview:
getunifiedaccounts - Mode query/switch:
getunifiedmode/setunifiedmode - Borrowable checks:
getunifiedborrowable - Transferable checks:
getunifiedtransferable - Borrow/repay:
createunifiedloan - Loan and interest records:
listunifiedloanrecords,listunifiedloaninterest_records - Currency support and rates:
listunifiedcurrencies,getunifiedestimate_rate - Leverage settings:
getuserleveragecurrencysetting,setuserleveragecurrencysetting - Collateral settings:
setunifiedcollateral - Risk tiers:
listcurrencydiscount_tiers
Step 5: Return Actionable Result and Status
The response must include:
- Whether execution succeeded (or why it did not execute)
- Core numbers (amount, limit, rate, leverage, mode, key risk fields)
- For overview queries: explicitly include IMR/MMR (
totalInitialMarginRate/totalMaintenanceMarginRate) and include per-currencyimr/mmrwhen present - For all money/rate outputs: preserve exact API string precision; do not trim or format decimals automatically
- For record queries: provide readable time alongside timestamps
- If condition not met, clearly explain gap and next option
Case Routing Map (1-18)
A. Account and Mode (1-3)
| Case | User Intent | Core Decision | Tool Sequence |
|---|---|---|---|
| 1 | Unified account overview | Return total equity and margin indicators (including IMR/MMR when available) | getunifiedaccounts |
| 2 | Query current unified mode | Return current mode with readable label | getunifiedmode |
| 3 | Switch unified mode | Validate target mode, then switch after confirmation | getunifiedmode -> setunifiedmode |
B. Borrow Limits and Borrowing (4-8)
| Case | User Intent | Core Decision | Tool Sequence |
|---|---|---|---|
| 4 | Single-currency borrowable | Return max borrowable for one currency | getunifiedborrowable |
| 5 | Multi-currency borrowable | Iterate per currency and aggregate | getunifiedborrowable(loop) |
| 6 | Borrow specific amount | Check max borrowable then submit borrow after confirmation | getunifiedborrowable -> createunifiedloan |
| 7 | List borrowable currencies | Return supported currency list | listunifiedcurrencies |
| 8 | Query estimated borrow rate | Return estimated rate with disclaimer | getunifiedestimate_rate |
C. Repayment and Records (9-12)
| Case | User Intent | Core Decision | Tool Sequence |
|---|---|---|---|
| 9 | Partial repay | Validate repay amount and submit after confirmation | createunifiedloan |
| 10 | Full repay | Submit repaid_all=true after confirmation |
createunifiedloan |
| 11 | Query loan records | Return borrow/repay history by filter | listunifiedloan_records |
| 12 | Query interest records | Return charged-interest history with time/rate | listunifiedloaninterestrecords |
D. Transferability and Risk Config (13-18)
| Case | User Intent | Core Decision | Tool Sequence |
|---|---|---|---|
| 13 | Single-currency transferable | Return max transferable amount | getunifiedtransferable |
| 14 | Multi-currency transferable | Iterate per currency and aggregate | getunifiedtransferable(loop) |
| 15 | Query leverage setting | Return leverage by currency (single/all) | getuserleveragecurrencysetting |
| 16 | Set leverage setting | Update leverage after confirmation | setuserleveragecurrencysetting |
| 17 | Set collateral currencies | Enable/disable collateral list after confirmation | setunifiedcollateral |
| 18 | Query collateral discount tiers | Return risk-tier/discount reference | listcurrencydiscount_tiers |
Judgment Logic Summary
| Condition | Action |
|---|---|
| User asks "how much can I borrow" for one coin | Use getunifiedborrowable with that currency |
| User asks borrowable for several coins | Iterate getunifiedborrowable per coin and aggregate |
| User requests borrow execution | Pre-check limit first, then require confirmation before createunifiedloan |
| User requests repay execution | Clarify partial vs full repay and confirm before mutation |
| User asks "all repay" but currency unclear | Ask user to specify currency or propose per-currency execution |
| User asks transferable for several coins | Iterate getunifiedtransferable per coin and aggregate |
| User asks to switch mode | Query current mode first, show impact, then confirm and execute |
| User asks to set leverage | Query/validate currency and target leverage, then confirm mutation |
| User asks to set collateral | Confirm enable/disable list and risk note before mutation |
| User confirmation missing/ambiguous/stale | Keep task pending and do not execute mutation |
| Requested amount exceeds borrowable/transferable | Return max available and ask user whether to adjust |
| Query-only request | Never perform mutation calls |
Report Template
## Execution Result
| Item | Value |
|------|-----|
| Scenario | {case_name} |
| Scope | {currency_or_mode_scope} |
| Action | {action} |
| Status | {status} |
| Key Metrics | {key_metrics} |
{decision_text}
Example decision_text:
✅ Action completed successfully.📝 Action draft ready. Reply "Confirm action" to proceed.⏸️ Not executed: requested amount exceeds current limit.❌ Not executed: required parameter is missing.
Error Handling
| Error Type | Typical Cause | Handling Strategy |
|---|---|---|
| Missing required parameter | Currency/amount/mode omitted | Ask for the missing field before tool call |
| Limit exceeded | Requested amount > borrowable/transferable | Return current max and suggest adjusted amount |
| Unsupported/hidden batch endpoint | Batch method not exposed as tool | Iterate single-currency calls and merge result |
| Mode switch rejected | Position/risk constraints prevent switch | Return rejection reason and suggest cleanup checks |
| Invalid leverage setting | Out-of-range leverage value | Return valid range and ask for revised value |
| Collateral config risk | Enable/disable list changes borrowing power | Show risk note and require explicit confirmation |
Collateral mutation API error (500) |
Backend-side failure even with valid payload | Return non-user-fault message, keep params for retry, and ask whether to retry later |
| Missing final confirmation | User has not approved draft | Keep pending and request explicit confirmation |
| Stale confirmation | Draft no longer matches user intent | Invalidate and re-draft for reconfirmation |
Cross-Skill Workflows
Workflow A: Unified Borrow Then Spot Buy
- Use
gate-exchange-unifiedto borrow quote currency (Case 6) - Use
gate-exchange-spotto execute buy order with borrowed funds
Workflow B: Spot Sell Then Unified Repay
- Use
gate-exchange-spotto liquidate target asset into quote currency - Use
gate-exchange-unifiedto repay outstanding loan (Case 9/10)
Safety Rules
- Before any mutation, restate target currency/mode/value and key risk.
- For borrowing, explicitly disclose that interest accrues and rates may vary.
- For mode or leverage changes, mention potential impact on margin and liquidation risk.
- For collateral changes, show both enable and disable sets before execution.
- Without explicit confirmation, stay in read-only mode.
- Do not reuse stale confirmations; re-confirm if any parameter changes.
- If constraints are not met, do not force execution; provide alternatives.