{"skill":{"slug":"spandex-trader","displayName":"spanDEX Trader","summary":"Trade tokens on Base using spanDEX, the open-source meta-aggregator. Supports market swaps (races 6 providers for best price with automatic fallback), limit...","description":"---\nname: spandex-trader\ndescription: Trade tokens on Base using spanDEX, the open-source meta-aggregator. Supports market swaps (races 6 providers for best price with automatic fallback), limit orders via KyberSwap, balance checks, and provider comparison. Works with all token types including Clanker V4, Flaunch DERC20, and standard ERC-20. Use when the user wants to swap tokens, place limit orders, check wallet balances, or execute trades on Base chain. Triggers on \"swap\", \"buy\", \"sell\", \"trade\", \"limit order\", \"spanDEX\", \"best price\", \"meta-aggregator\".\n---\n\n# spanDEX Trader\n\nTrade on Base chain using [spanDEX](https://spandex.sh) — the free, open-source meta-aggregator by [@_nonlinear](https://x.com/_nonlinear) / [Fabric](https://github.com/withfabricxyz/spandex).\n\nRaces 6 DEX aggregators (Fabric, KyberSwap, Odos, Velora, LI.FI, Relay) per swap, simulates on-chain, picks the winner, and executes with automatic fallback if the best-priced provider fails.\n\n## Setup\n\n**Prerequisites:** Node.js 18+, npm\n\n```bash\n# Install dependencies (run once in skill directory)\ncd <skill-dir>/scripts && npm init -y && npm i viem @spandex/core\n```\n\n**Required env vars:**\n| Var | Purpose |\n|-----|---------|\n| `BASE_RPC_URL` | Base chain RPC endpoint (Alchemy, Infura, dRPC, etc.) |\n| `SPANDEX_PRIVATE_KEY` | Wallet private key (hex). OR use `SPANDEX_KEY_PATH` for file-based key |\n\n**Optional env vars:**\n| Var | Default | Purpose |\n|-----|---------|---------|\n| `SPANDEX_KEY_PATH` | — | Path to file containing private key (alternative to raw key) |\n| `SPANDEX_APP_ID` | `spandex-trader-skill` | App identifier for provider APIs |\n| `SPANDEX_STRATEGY` | `bestPrice` | Default quote strategy |\n| `SPANDEX_PRIORITY_GWEI` | `0.03` | Priority fee floor (gwei) for Base sequencer |\n| `SPANDEX_SKIP_LOCK` | — | Set `1` to disable anti-double-execution lock |\n| `SPANDEX_DEBUG` | — | Enable debug logging |\n\n## Commands\n\nAll output is JSON. TOKEN can be a contract address or alias (USDC, WETH, ETH, DAI, USDT).\n\n```bash\n# Compare prices across all 6 providers\nnode scripts/spandex_trade.mjs quote --sell USDC --buy 0xTOKEN --amount 50\n\n# Execute swap (best price, automatic fallback)\nnode scripts/spandex_trade.mjs swap --sell USDC --buy 0xTOKEN --amount 50\nnode scripts/spandex_trade.mjs swap --sell USDC --buy 0xTOKEN --amount 50 --slippage 500 --dry-run\n\n# KyberSwap limit orders (gasless EIP-712)\nnode scripts/spandex_trade.mjs limit --sell 0xTOKEN --buy USDC --sell-amount 1000000 --buy-amount 50 --expiry 7d\nnode scripts/spandex_trade.mjs orders --status active\nnode scripts/spandex_trade.mjs cancel-order --order-id 123\n\n# Wallet\nnode scripts/spandex_trade.mjs balance\nnode scripts/spandex_trade.mjs balance --token 0xTOKEN\nnode scripts/spandex_trade.mjs providers\n```\n\n## Slippage defaults\n\nAuto-applied based on token pair:\n- Major ↔ Major (USDC/WETH/ETH): **0.5%** (50 bps)\n- Major ↔ Microcap: **3%** (300 bps)\n- Microcap ↔ Microcap: **5%** (500 bps)\n\nOverride with `--slippage <bps>`.\n\n## Execution flow\n\n1. `getQuotes()` — fetch + simulate from all 6 providers in parallel\n2. `sortQuotesByPerformance()` — rank by output amount (best first)\n3. For each quote: `buildCalls()` → `sendTransaction()` with priority fee → if fail, try next provider\n4. `netOutputs()` — extract actual output from TX receipt logs\n5. Final balance verification\n\n## Key behaviors\n\n- **Anti-double-execution:** 120s lockfile per token prevents accidental duplicate swaps\n- **Fallback routing:** If best-price provider fails execution, automatically tries next\n- **V4/DERC20 compatible:** Uses `buildCalls()` for proper Clanker V4 and Flaunch DERC20 settlement\n- **No API keys needed:** All 6 providers work without registration\n\n## Token compatibility by provider\n\n| Provider | Standard ERC-20 | Clanker V4 | Flaunch DERC20 |\n|----------|----------------|------------|----------------|\n| KyberSwap | ✅ | ✅ | ✅ |\n| LI.FI | ✅ | ✅ | ✅ |\n| Fabric | ✅ | ⚠️ | ⚠️ |\n| Odos | ✅ | ❌ | ❌ |\n| Velora | ✅ | ❌ | ❌ |\n| Relay | ✅ | ⚠️ | ⚠️ |\n\nFor detailed integration notes and architecture, see `references/INTEGRATION.md`.\n","topics":["Wallet"],"tags":{"latest":"1.0.0"},"stats":{"comments":0,"downloads":247,"installsAllTime":9,"installsCurrent":0,"stars":0,"versions":1},"createdAt":1772554641240,"updatedAt":1779078632896},"latestVersion":{"version":"1.0.0","createdAt":1772554641240,"changelog":"Initial release: meta-aggregator trading on Base with 6 providers, market swaps, limit orders, automatic fallback, Clanker/DERC20 support","license":null},"metadata":null,"owner":{"handle":"axiom89","userId":"s17f6zvag0gt9246zca3yarhxs8853xe","displayName":"Axiom89","image":"https://avatars.githubusercontent.com/u/81260927?v=4"},"moderation":{"isSuspicious":false,"isMalwareBlocked":false,"verdict":"clean","reasonCodes":["review.llm_review"],"summary":"Review: review.llm_review","engineVersion":"v2.4.24","updatedAt":1780089744877}}