gate-exchange-flashswap-assistant
L2 flash swap orchestration: fc preview and create (1:1, 1:N, N:1), spot balance checks, min/max gates, optional dust-to-GT, order history. Use this skill whenever the user wants flash swap, instant convert, consolidate alts to one coin, split one asset into several via flash, diagnose below-minimum flash size, or convert wallet dust to GT. Trigger phrases include "flash swap", "flash convert", "swap to USDT", "consolidate to USDT", "dust to GT", "small balance to GT", or "flash swap history".
What this skill does
### 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`](https://github.com/gate/gate-skills/blob/master/skills/exchange-runtime-rules.md) §4 (or [`gate-runtime-rules.md`](https://github.com/gate/gate-skills/blob/master/skills/gate-runtime-rules.md) §4).
# gate-exchange-flashswap-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 [gate-runtime-rules.md](https://github.com/gate/gate-skills/blob/master/skills/gate-runtime-rules.md)
- **Only use the `gate-cli` 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)**
- `gate-cli cex flash-swap order`
- `gate-cli cex flash-swap pairs`
- `gate-cli cex flash-swap orders`
- `gate-cli cex flash-swap preview-many-to-one`
- `gate-cli cex flash-swap preview-one-to-many`
- `gate-cli cex flash-swap preview-v1`
- `gate-cli cex spot account get`
- `gate-cli cex wallet balance small`
- `gate-cli cex wallet balance small-history`
**Execution Operations (Write)**
- `gate-cli cex flash-swap create-many-to-one`
- `gate-cli cex flash-swap create-one-to-many`
- `gate-cli cex flash-swap create-v1`
- `gate-cli cex wallet balance convert-small`
### Authentication
- **Interactive file setup:** when **`GATE_API_KEY`** and **`GATE_API_SECRET`** are **not** both set on the host, run **`gate-cli config init`** to complete the wizard for API key, secret, profiles, and defaults (see [gate-cli](https://github.com/gate/gate-cli)).
- **Env / flags:** **`gate-cli config init`** is **not** required when credentials are already supplied — e.g. **both** **`GATE_API_KEY`** and **`GATE_API_SECRET`** set on the host, or **`--api-key`** / **`--api-secret`** where supported — never ask the user to paste secrets into chat.
- API Key Required: Yes (authenticated Gate Exchange MCP)
- **Permissions:** Flash convert write (`gate-cli cex flash-swap preview` / `create` or `preview-v1` / `create-v1` / multi-currency variants; MCP `cex_fc_*` when using Exchange MCP), spot account read, wallet small-balance read and convert as required by the gateway (configure keys with least privilege)
- **Portal:** create or rotate keys outside the chat: https://www.gate.com/myaccount/profile/api-key/manage
### Installation Check
- **Required:** Gate (main); **`gate-cli`** when using CLI-backed flows (install via [`setup.sh`](./setup.sh) from this skill when applicable).
- **Install (MCP / IDE):** Cursor: `gate-mcp-cursor-installer`; Codex: `gate-mcp-codex-installer`; Claude: `gate-mcp-claude-installer`; OpenClaw: `gate-mcp-openclaw-installer`.
- **Credentials:** When **`GATE_API_KEY`** and **`GATE_API_SECRET`** are both set (non-empty) for the host, **do not** require **`gate-cli config init`**. When **both** are unset or empty, **remind** the operator to run **`gate-cli config init`** **or** to configure **`GATE_API_KEY`** / **`GATE_API_SECRET`** in the **matching skill** from the skill library (never ask the user to paste secrets into chat).
- **Sanity check:** Before mutating flash-swap or small-balance calls, confirm the runtime works (e.g. **`gate-cli --version`** or a read-only check appropriate to this skill).
---
## Domain Knowledge
### What this skill covers
- **Flash swap (fc)**: Instant convert using preview then create. Three modes: **one-to-one**, **one-to-many** (one sell asset to multiple buy assets), **many-to-one** (multiple sell assets to one buy asset, consolidation).
- **On-path balance checks**: Use `gate-cli cex spot account get` for the sell-side (and USDT side for one-to-many) **only** for this flow. Do **not** pull full portfolio views here.
- **Two different “small balance” paths (must explain to the user)**:
- **Flash swap**: Subject to per-pair `sell_min_amount` / `sell_max_amount` from `gate-cli cex flash-swap pairs`. If below minimum, **do not** call fc preview to fake a quote.
- **Wallet dust → GT**: `gate-cli cex wallet balance small` / `gate-cli cex wallet balance convert-small` converts platform-classified dust to **GT** (not USDT). Rules differ from flash minima; never silently substitute this when the user asked for USDT flash swap.
### Core concepts
- **quote_id**: From preview; required for create. Validity comes from `valid_timestamp` in the response — never assume a fixed TTL.
- **sell_amount / buy_amount**: Use one per leg as required by the API; one-to-many can use per-target `sell_amount` or `buy_amount`; many-to-one uses per-source `sell_amount`.
- **Order status**: `status=1` success, `status=2` failure — verify after each create.
- **Precision**: Show tiny receive amounts with clear precision; optional rough fiat hint only when clearly justified.
### Explicitly out of scope for tools in this skill
- Do **not** call `gate-cli cex spot market tickers`, `gate-cli cex spot market orderbook`, or `gate-cli cex wallet balance total` from this skill. Market depth, “is it a good time”, and full asset audits belong to other skills (see Judgment Logic Summary).
### Regulatory and risk notices
- Digital asset trading involves significant risk and may result in partial or total loss of your investment.
- This skill is intended for users aged 18 or above with full civil capacity. Users must comply with applicable laws in their jurisdiction.
- AI-assisted outputs and tool results are for general information only and do not constitute investment, financial, tax, or legal advice, or any representation or warranty by Gate.
- Prompts and trading-related inputs are processed to call the Gate API via MCP; do not collect unnecessary personal data.
---
## Atomic Tool Call Chains (mandatory)
**Execution rule:** Map the user request to **scenario #1–#21** below when possible. **Follow the listed tool order.** Do not skip gates (balance, `sell_min_amount`, preview before create).
**Notation**
- **`[P1] Parallel`**: Invoke the listed tools in the same wave (any order among them is acceptable unless a later step depends on their output).
- **`→`**: Serial — complete the previous step before starting the next.
- **`[P0] Plan`**: No MCP call — parse amounts, split ratios, or restrict the coin set (e.g. user-supplied list only).
- **`[Confirm]`**: Present Action Draft; wait for explicit **Y** before any **write** tool in that branch.
- **`(W)`**: Write tool — only after **Confirm** unless the scenario explicitly ends at preview-only.
**Routing reminders (from spec)**
- One-to-many rows **#4**, **#5**, **#11**: If the user uses **only** spot **buy / market buy** language with **no** flash swap / convert / swap anchor, route **`gate-exchange-trading`** instead of fc tools.
- **#8**, **#20**: Preview-only until the user opts in to create.
- **#21**: Never mix dust→GT silently into a “swap to USDT” story without explaining the different product path.
### Base scenarios (#1–#8)
| # | User intent (paraphrase) | Mode | Signal | Atomic chain |
|---|--------------------------|------|--------|----------------|
| 1 | Swap a fixed amount (e.g. 1 BTC) to USDT | 1→1 | S1 | **[P1]** `gate-cli cex flash-swap pairs`(sell asset) · `gate-cli cex spot account get`(sell asset) **→** Check available ≥ sell amount and sell amount ≥ `sell_min_amount` **→** `gate-cli cex flash-swap preview-v1`(sell_asset, sell_amount, buy_asset) **→** Show rate, estimated receive, validity → Action Draft **→** **[Confirm]** **→** **(W)** `gate-cli cex flash-swap create-v1`(quote_id, matching amounts) **→** Verify `status` **→** Report result |
| 2 | Swap **full** aRelated in Web3
xaut-trade
IncludedBuy or sell XAUT (Tether Gold) on Ethereum. Supports market orders (Uniswap V3) and limit orders (UniswapX). Wallet modes: Foundry keystore or WDK. Delegates non-XAUT intents to registered skills (e.g. Polymarket prediction markets, Hyperliquid trading). Triggers: buy XAUT, XAUT trade, swap USDT for XAUT, sell XAUT, swap XAUT for USDT, limit order, limit buy XAUT, limit sell XAUT, check limit order, cancel limit order, XAUT when, create wallet, setup wallet, polymarket, prediction market, bet on, odds on, hyperliquid, perp, perpetual, long, short, open long, open short, close position, leverage.
qfc-openclaw-skill
IncludedQFC blockchain interaction — wallet, faucet, chain queries, staking, epoch & finality, AI inference
gate-dex-trade
IncludedExecutes on-chain token swaps via Gate DEX. Use when user wants to swap, buy, sell, exchange, or convert tokens, or bridge cross-chain. Covers full swap flow: price quotes, transaction build, signing, and submission. Do NOT use for read-only data lookups or wallet account management.
hunch
IncludedDiscover, bet on, track, and settle Hunch prediction markets in natural language. Trigger when a user wants to bet, take a position, or get odds on a crypto outcome — token market-cap milestones and flips, launchpad races (Bankr vs pump.fun volume / #1-days / launches over a cap), token head-to-head outperformance, mcap strike-ladders, and up/down price rounds. Also trigger on "what can I bet on about $TOKEN", "odds on …", "take YES/NO on …", "show my Hunch bets", "did my market resolve". Settles in USDC on Base via x402 (≤ $10 / bet); every bet returns an on-chain proof.
opensea
IncludedQuery NFT data, trade on the Seaport marketplace, and swap ERC20 tokens across Ethereum, Base, Arbitrum, Optimism, Polygon, and more.
polymarket
IncludedTrade on Polymarket prediction markets (CLOB V2) from a Privy EOA wallet. Search markets, place/cancel orders, manage positions. No private key handling. Use when the user wants to bet on event outcomes (e.g. "buy YES at 0.65 on the ceasefire market", "what are my open positions", "close my Trump bet").