[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M76K785PRRHNH6YBMCE8H90F":3,"skill-same:01M76K785PRRHNH6YBMCE8H90F":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":13,"repositoryHtmlUrl":48,"repositoryHomepageUrl":6,"ownerHtmlUrl":49,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":50,"install":51,"resources":64},"01M76K785PRRHNH6YBMCE8H90F","okx-dex-quote",null,"Fetch optimal swap quotes from OKX DEX Aggregator API (v6). Use this skill when a user wants to: 1. Get the best price for swapping tokens on any supported EVM\u002FSolana chain 2. Compare DEX routing paths and price impact for token swaps 3. Build applications or scripts that query real-time DEX aggregator pricing Core value: Generates correct, authenticated API calls with proper token decimals, amount formatting, HMAC-SHA256 signing, and comprehensive error handling.","meghal86\u002Fstacksignal","meghal86","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F37388715?v=4","01M6CS2EW8SK89GH52R2ZEN8QQ","01M728J5CGY456EETEFG6HJBTM",0,"MIT","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fokx-dex-quote\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: okx-dex-quote\ndescription: >\n  Fetch optimal swap quotes from OKX DEX Aggregator API (v6). Use this skill when a user wants to:\n  1. Get the best price for swapping tokens on any supported EVM\u002FSolana chain\n  2. Compare DEX routing paths and price impact for token swaps\n  3. Build applications or scripts that query real-time DEX aggregator pricing\n  Core value: Generates correct, authenticated API calls with proper token decimals,\n  amount formatting, HMAC-SHA256 signing, and comprehensive error handling.\nversion: 1.0.0\nallowed_tools: [bash_tool, create_file, str_replace, view]\nrequired_context: [api_key, secret_key, passphrase]\nlicense: MIT\nauthor: Claude Assistant\ntags: [defi, dex, okx, swap, quote, web3, aggregator, evm, solana]\n---\n\n# OKX DEX Aggregator Quote Skill\n\n## Overview\n\nThis skill generates production-ready code for fetching optimal swap quotes from the **OKX DEX Aggregator API v6**. The API finds the best price across multiple DEX protocols (Uniswap, SushiSwap, Curve, etc.) and returns detailed routing information including price impact, gas estimates, and token safety flags.\n\n**Key capabilities:**\n- Authenticated API requests with HMAC-SHA256 signing\n- Correct handling of token decimals and amount formatting\n- Support for `exactIn` (fixed input) and `exactOut` (fixed output) swap modes\n- Multi-chain support (Ethereum, BSC, Arbitrum, Base, Solana, and 20+ chains)\n- Price impact protection and honeypot detection\n- Fee\u002Fcommission splitting configuration\n\n## Prerequisites\n\n### Required Credentials\nUsers must have an OKX Web3 API key set. The skill needs three values:\n- `OKX_ACCESS_KEY` — API key\n- `OKX_SECRET_KEY` — Secret key for HMAC signing\n- `OKX_PASSPHRASE` — Account passphrase\n\n### Environment\n- **Python**: `requests`, `hmac`, `hashlib`, `base64`, `datetime` (all stdlib except `requests`)\n- **Node.js**: `axios` or `node-fetch`, built-in `crypto`\n- No additional blockchain dependencies required (this is a read-only quote endpoint)\n\n### API Endpoint\n```\nGET https:\u002F\u002Fweb3.okx.com\u002Fapi\u002Fv6\u002Fdex\u002Faggregator\u002Fquote\n```\n\n## Workflow\n\n### Step 1: Validate User Input\n\nBefore constructing the API call, validate:\n\n1. **Chain ID (`chainIndex`)** — Must be a supported chain. Common values:\n   - `1` = Ethereum\n   - `56` = BSC\n   - `137` = Polygon\n   - `42161` = Arbitrum\n   - `8453` = Base\n   - `130` = Unichain\n   - `501` = Solana\n\n2. **Token addresses** — Must be valid contract addresses or the native token placeholder:\n   - Native tokens (ETH, BNB, etc.): `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`\n   - Contract tokens: Full 42-character hex address (EVM) or base58 (Solana)\n\n3. **Amount** — MUST include token decimals. This is the #1 source of errors:\n   - 1 ETH (18 decimals) → `\"1000000000000000000\"`\n   - 1 USDT (6 decimals) → `\"1000000\"`\n   - 1 WBTC (8 decimals) → `\"100000000\"`\n   - Formula: `amount_raw = human_amount * (10 ** token_decimals)`\n\n4. **Swap mode** — `exactIn` (default) or `exactOut`\n   - `exactOut` only supported on: Ethereum, Base, BSC, Arbitrum\n   - `exactOut` only works with Uniswap V2\u002FV3 pools\n\n### Step 2: Construct Authentication Headers\n\nOKX API requires HMAC-SHA256 signed requests with 4 headers:\n\n```\nOK-ACCESS-KEY: \u003Capi_key>\nOK-ACCESS-SIGN: \u003Chmac_signature>\nOK-ACCESS-PASSPHRASE: \u003Cpassphrase>\nOK-ACCESS-TIMESTAMP: \u003Ciso8601_timestamp>\n```\n\n**Signing algorithm:**\n```\ntimestamp = ISO 8601 UTC time (e.g., \"2025-01-15T12:00:00.000Z\")\nprehash = timestamp + \"GET\" + request_path_with_query\nsignature = Base64(HMAC-SHA256(secret_key, prehash))\n```\n\n**CRITICAL**: The `request_path_with_query` must include the full path starting from `\u002Fapi\u002F...` plus the query string. Example:\n```\n\u002Fapi\u002Fv6\u002Fdex\u002Faggregator\u002Fquote?chainIndex=1&amount=1000000000000000000&fromTokenAddress=0xeee...&toTokenAddress=0xa0b...\n```\n\n### Step 3: Send Request and Parse Response\n\n**Success response structure:**\n```json\n{\n  \"code\": \"0\",\n  \"data\": [{\n    \"chainIndex\": \"1\",\n    \"fromToken\": { \"tokenSymbol\": \"ETH\", \"decimal\": \"18\", ... },\n    \"toToken\": { \"tokenSymbol\": \"USDC\", \"decimal\": \"6\", ... },\n    \"fromTokenAmount\": \"1000000000000000000\",\n    \"toTokenAmount\": \"3521432100\",\n    \"dexRouterList\": [...],\n    \"tradeFee\": \"2.45\",\n    \"estimateGasFee\": \"150000\",\n    \"priceImpactPercent\": \"-0.12\"\n  }],\n  \"msg\": \"\"\n}\n```\n\n**Key fields to extract:**\n- `toTokenAmount` — The amount you'll receive (in raw units with decimals)\n- `tradeFee` — Estimated network fee in USD\n- `priceImpactPercent` — Negative = losing value; large negative = danger\n- `dexRouterList` — Routing path through various DEX protocols\n- `fromToken.isHoneyPot` \u002F `toToken.isHoneyPot` — Scam token flag\n- `fromToken.taxRate` \u002F `toToken.taxRate` — Token buy\u002Fsell tax\n\n### Step 4: Format Output for User\n\nConvert raw amounts back to human-readable:\n```\nhuman_amount = raw_amount \u002F (10 ** decimal)\n```\n\nAlways display:\n1. Exchange rate (e.g., \"1 ETH = 3,521.43 USDC\")\n2. Price impact percentage with warning if > 3%\n3. Estimated gas fee in USD\n4. Routing summary (which DEXes are used)\n5. Honeypot warnings if detected\n6. Token tax rates if > 0\n\n## Best Practices\n\n### Security\n- **NEVER hardcode API credentials** in generated code. Always use environment variables or config files.\n- **NEVER log the secret key or signature** in debug output.\n- Validate all token addresses against expected format before sending.\n- Check `isHoneyPot` flag on both tokens and warn the user prominently.\n\n### Amount Handling\n- **Always use string type** for amounts to avoid floating-point precision loss.\n- Python: Use `int()` for amount calculations, never `float()`.\n- JavaScript: Use `BigInt` or string math for amounts > 2^53.\n- When user provides a human-readable amount like \"1.5 ETH\", convert: `str(int(1.5 * 10**18))`.\n\n### Error Handling\n- Check `response[\"code\"] == \"0\"` before accessing data.\n- Common error codes:\n  - Non-zero code with `msg` = API error (e.g., insufficient liquidity, invalid params)\n  - HTTP 401 = Authentication failure (check signature algorithm)\n  - HTTP 429 = Rate limited\n- If `priceImpactPercent` is `null`, warn that price impact couldn't be calculated.\n\n### Rate Limits\n- Respect OKX rate limits. For production use, implement exponential backoff.\n- Cache quotes if polling repeatedly (quotes are valid for ~15-30 seconds).\n\n### Optional Parameters Usage\n- `dexIds` — Use when you want to restrict to specific DEXes (e.g., only Uniswap).\n- `directRoute=true` — Only for Solana; forces single-pool routing.\n- `priceImpactProtectionPercent` — Set to a sensible default like `10` for safety. Set to `100` to disable.\n- `feePercent` — For integrators taking commission. Max 3% (EVM) or 10% (Solana). Up to 9 decimal places.\n\n## Examples\n\n### Example 1: Python — Get ETH to USDC Quote on Ethereum\n\n```python\nimport os, hmac, hashlib, base64, requests\nfrom datetime import datetime, timezone\nfrom urllib.parse import urlencode\n\nAPI_KEY = os.environ[\"OKX_ACCESS_KEY\"]\nSECRET_KEY = os.environ[\"OKX_SECRET_KEY\"]\nPASSPHRASE = os.environ[\"OKX_PASSPHRASE\"]\n\ndef get_okx_quote(chain_index, from_token, to_token, amount, swap_mode=\"exactIn\"):\n    base_url = \"https:\u002F\u002Fweb3.okx.com\"\n    path = \"\u002Fapi\u002Fv6\u002Fdex\u002Faggregator\u002Fquote\"\n\n    params = {\n        \"chainIndex\": chain_index,\n        \"fromTokenAddress\": from_token,\n        \"toTokenAddress\": to_token,\n        \"amount\": amount,\n        \"swapMode\": swap_mode,\n    }\n\n    query_string = urlencode(params)\n    request_path = f\"{path}?{query_string}\"\n\n    # Generate timestamp and signature\n    timestamp = datetime.now(timezone.utc).strftime(\"%Y-%m-%dT%H:%M:%S.%f\")[:-3] + \"Z\"\n    prehash = timestamp + \"GET\" + request_path\n    signature = base64.b64encode(\n        hmac.new(SECRET_KEY.encode(), prehash.encode(), hashlib.sha256).digest()\n    ).decode()\n\n    headers = {\n        \"OK-ACCESS-KEY\": API_KEY,\n        \"OK-ACCESS-SIGN\": signature,\n        \"OK-ACCESS-PASSPHRASE\": PASSPHRASE,\n        \"OK-ACCESS-TIMESTAMP\": timestamp,\n    }\n\n    resp = requests.get(base_url + request_path, headers=headers)\n    resp.raise_for_status()\n    data = resp.json()\n\n    if data[\"code\"] != \"0\":\n        raise Exception(f\"OKX API error: {data['msg']}\")\n\n    return data[\"data\"][0]\n\n\n# Swap 1 ETH -> USDC on Ethereum\nETH = \"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"\nUSDC = \"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\"\namount = str(1 * 10**18)  # 1 ETH in wei\n\nquote = get_okx_quote(\"1\", ETH, USDC, amount)\n\nto_decimals = int(quote[\"toToken\"][\"decimal\"])\nreceived = int(quote[\"toTokenAmount\"]) \u002F (10 ** to_decimals)\n\nprint(f\"You will receive: {received:,.2f} {quote['toToken']['tokenSymbol']}\")\nprint(f\"Price impact: {quote['priceImpactPercent']}%\")\nprint(f\"Gas fee (USD): ${quote['tradeFee']}\")\nprint(f\"Honeypot check: {'WARNING' if quote['toToken']['isHoneyPot'] else 'Safe'}\")\n```\n\n### Example 2: Node.js — Get Quote with Commission Fee\n\n```javascript\nconst crypto = require(\"crypto\");\nconst https = require(\"https\");\n\nconst API_KEY = process.env.OKX_ACCESS_KEY;\nconst SECRET_KEY = process.env.OKX_SECRET_KEY;\nconst PASSPHRASE = process.env.OKX_PASSPHRASE;\n\nfunction getQuote(chainIndex, fromToken, toToken, amount, options = {}) {\n  const params = new URLSearchParams({\n    chainIndex,\n    fromTokenAddress: fromToken,\n    toTokenAddress: toToken,\n    amount,\n    swapMode: options.swapMode || \"exactIn\",\n    ...(options.feePercent && { feePercent: options.feePercent }),\n    ...(options.priceImpactProtectionPercent && {\n      priceImpactProtectionPercent: options.priceImpactProtectionPercent,\n    }),\n  });\n\n  const path = `\u002Fapi\u002Fv6\u002Fdex\u002Faggregator\u002Fquote?${params}`;\n  const timestamp = new Date().toISOString();\n  const prehash = timestamp + \"GET\" + path;\n  const signature = crypto\n    .createHmac(\"sha256\", SECRET_KEY)\n    .update(prehash)\n    .digest(\"base64\");\n\n  return new Promise((resolve, reject) => {\n    const req = https.get(\n      `https:\u002F\u002Fweb3.okx.com${path}`,\n      {\n        headers: {\n          \"OK-ACCESS-KEY\": API_KEY,\n          \"OK-ACCESS-SIGN\": signature,\n          \"OK-ACCESS-PASSPHRASE\": PASSPHRASE,\n          \"OK-ACCESS-TIMESTAMP\": timestamp,\n        },\n      },\n      (res) => {\n        let body = \"\";\n        res.on(\"data\", (chunk) => (body += chunk));\n        res.on(\"end\", () => {\n          const data = JSON.parse(body);\n          if (data.code !== \"0\") reject(new Error(`OKX: ${data.msg}`));\n          else resolve(data.data[0]);\n        });\n      }\n    );\n    req.on(\"error\", reject);\n  });\n}\n```\n\n### Example 3: Understanding the Routing Path\n\n```\nRouter: ETH -> WBTC -> USDC\ndexRouterList shows:\n  - 55% ETH -> WBTC via Uniswap V4\n  - 30% ETH -> USDC via Uniswap V4 (direct)\n  - WBTC -> USDC via Euler (73%) + Uniswap V4 (27%)\n\nThis means the aggregator splits the trade across multiple paths\nto minimize price impact and maximize output.\n```\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| `401 Unauthorized` | Signature mismatch | Verify prehash string is exactly `timestamp + \"GET\" + full_path_with_query`. Check secret key encoding. |\n| Amount too small | Missing decimal conversion | Multiply human amount by `10 ** token_decimals`. 1 USDT = `1000000`, not `1`. |\n| Invalid token address | Wrong chain\u002Faddress combo | Verify the token exists on the specified chain. Use native token placeholder for ETH\u002FBNB\u002Fetc. |\n| `priceImpactPercent` very negative (\u003C -10%) | Low liquidity or large trade | Reduce trade size or split across multiple transactions. |\n| `isHoneyPot: true` | Scam token detected | **Do NOT proceed with the swap.** Warn the user immediately. |\n| `exactOut` not working | Unsupported chain\u002Fprotocol | Only works on Ethereum, Base, BSC, Arbitrum with Uniswap V2\u002FV3. |\n| `taxRate > 0` | Token has built-in tax | Factor tax into expected output. E.g., 5% tax means receiving 5% less. |\n| Empty `dexRouterList` | No liquidity path found | Try a different token pair, smaller amount, or different chain. |\n| `code` is non-zero | General API error | Read `msg` field for details. Common: rate limit, maintenance, invalid params. |\n\n## Reference: Common Chain IDs\n\n| Chain | chainIndex |\n|-------|-----------|\n| Ethereum | 1 |\n| BSC | 56 |\n| Polygon | 137 |\n| Arbitrum | 42161 |\n| Optimism | 10 |\n| Avalanche | 43114 |\n| Base | 8453 |\n| Solana | 501 |\n| Unichain | 130 |\n\n## Reference: Common Token Addresses (Ethereum)\n\n| Token | Address | Decimals |\n|-------|---------|----------|\n| ETH (native) | `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee` | 18 |\n| USDT | `0xdac17f958d2ee523a2206206994597c13d831ec7` | 6 |\n| USDC | `0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48` | 6 |\n| WETH | `0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2` | 18 |\n| WBTC | `0x2260fac5e5542a773aa44fbcfedf7c193bc2c599` | 8 |\n| DAI | `0x6b175474e89094c44da98b954eedeac495271d0f` | 18 |\n\n## Reference: Request Parameters Summary\n\n| Parameter | Required | Description |\n|-----------|----------|-------------|\n| `chainIndex` | Yes | Chain ID (e.g., `1` for Ethereum) |\n| `amount` | Yes | Amount in raw units (with decimals) |\n| `swapMode` | Yes | `exactIn` or `exactOut` |\n| `fromTokenAddress` | Yes | Sell token contract address |\n| `toTokenAddress` | Yes | Buy token contract address |\n| `dexIds` | No | Comma-separated DEX IDs to restrict routing |\n| `directRoute` | No | `true` for single-pool only (Solana only) |\n| `priceImpactProtectionPercent` | No | Max allowed price impact 0-100 (default 90) |\n| `feePercent` | No | Commission fee percentage for integrators |\n","# OKX DEX Aggregator Quote Skill\n\n## Overview\n\nThis skill generates production-ready code for fetching optimal swap quotes from the **OKX DEX Aggregator API v6**. The API finds the best price across multiple DEX protocols (Uniswap, SushiSwap, Curve, etc.) and returns detailed routing information including price impact, gas estimates, and token safety flags.\n\n**Key capabilities:**\n- Authenticated API requests with HMAC-SHA256 signing\n- Correct handling of token decimals and amount formatting\n- Support for `exactIn` (fixed input) and `exactOut` (fixed output) swap modes\n- Multi-chain support (Ethereum, BSC, Arbitrum, Base, Solana, and 20+ chains)\n- Price impact protection and honeypot detection\n- Fee\u002Fcommission splitting configuration\n\n## Prerequisites\n\n### Required Credentials\nUsers must have an OKX Web3 API key set. The skill needs three values:\n- `OKX_ACCESS_KEY` — API key\n- `OKX_SECRET_KEY` — Secret key for HMAC signing\n- `OKX_PASSPHRASE` — Account passphrase\n\n### Environment\n- **Python**: `requests`, `hmac`, `hashlib`, `base64`, `datetime` (all stdlib except `requests`)\n- **Node.js**: `axios` or `node-fetch`, built-in `crypto`\n- No additional blockchain dependencies required (this is a read-only quote endpoint)\n\n### API Endpoint\n```\nGET https:\u002F\u002Fweb3.okx.com\u002Fapi\u002Fv6\u002Fdex\u002Faggregator\u002Fquote\n```\n\n## Workflow\n\n### Step 1: Validate User Input\n\nBefore constructing the API call, validate:\n\n1. **Chain ID (`chainIndex`)** — Must be a supported chain. Common values:\n   - `1` = Ethereum\n   - `56` = BSC\n   - `137` = Polygon\n   - `42161` = Arbitrum\n   - `8453` = Base\n   - `130` = Unichain\n   - `501` = Solana\n\n2. **Token addresses** — Must be valid contract addresses or the native token placeholder:\n   - Native tokens (ETH, BNB, etc.): `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`\n   - Contract tokens: Full 42-character hex address (EVM) or base58 (Solana)\n\n3. **Amount** — MUST include token decimals. This is the #1 source of errors:\n   - 1 ETH (18 decimals) → `\"1000000000000000000\"`\n   - 1 USDT (6 decimals) → `\"1000000\"`\n   - 1 WBTC (8 decimals) → `\"100000000\"`\n   - Formula: `amount_raw = human_amount * (10 ** token_decimals)`\n\n4. **Swap mode** — `exactIn` (default) or `exactOut`\n   - `exactOut` only supported on: Ethereum, Base, BSC, Arbitrum\n   - `exactOut` only works with Uniswap V2\u002FV3 pools\n\n### Step 2: Construct Authentication Headers\n\nOKX API requires HMAC-SHA256 signed requests with 4 headers:\n\n```\nOK-ACCESS-KEY: \u003Capi_key>\nOK-ACCESS-SIGN: \u003Chmac_signature>\nOK-ACCESS-PASSPHRASE: \u003Cpassphrase>\nOK-ACCESS-TIMESTAMP: \u003Ciso8601_timestamp>\n```\n\n**Signing algorithm:**\n```\ntimestamp = ISO 8601 UTC time (e.g., \"2025-01-15T12:00:00.000Z\")\nprehash = timestamp + \"GET\" + request_path_with_query\nsignature = Base64(HMAC-SHA256(secret_key, prehash))\n```\n\n**CRITICAL**: The `request_path_with_query` must include the full path starting from `\u002Fapi\u002F...` plus the query string. Example:\n```\n\u002Fapi\u002Fv6\u002Fdex\u002Faggregator\u002Fquote?chainIndex=1&amount=1000000000000000000&fromTokenAddress=0xeee...&toTokenAddress=0xa0b...\n```\n\n### Step 3: Send Request and Parse Response\n\n**Success response structure:**\n```json\n{\n  \"code\": \"0\",\n  \"data\": [{\n    \"chainIndex\": \"1\",\n    \"fromToken\": { \"tokenSymbol\": \"ETH\", \"decimal\": \"18\", ... },\n    \"toToken\": { \"tokenSymbol\": \"USDC\", \"decimal\": \"6\", ... },\n    \"fromTokenAmount\": \"1000000000000000000\",\n    \"toTokenAmount\": \"3521432100\",\n    \"dexRouterList\": [...],\n    \"tradeFee\": \"2.45\",\n    \"estimateGasFee\": \"150000\",\n    \"priceImpactPercent\": \"-0.12\"\n  }],\n  \"msg\": \"\"\n}\n```\n\n**Key fields to extract:**\n- `toTokenAmount` — The amount you'll receive (in raw units with decimals)\n- `tradeFee` — Estimated network fee in USD\n- `priceImpactPercent` — Negative = losing value; large negative = danger\n- `dexRouterList` — Routing path through various DEX protocols\n- `fromToken.isHoneyPot` \u002F `toToken.isHoneyPot` — Scam token flag\n- `fromToken.taxRate` \u002F `toToken.taxRate` — Token buy\u002Fsell tax\n\n### Step 4: Format Output for User\n\nConvert raw amounts back to human-readable:\n```\nhuman_amount = raw_amount \u002F (10 ** decimal)\n```\n\nAlways display:\n1. Exchange rate (e.g., \"1 ETH = 3,521.43 USDC\")\n2. Price impact percentage with warning if > 3%\n3. Estimated gas fee in USD\n4. Routing summary (which DEXes are used)\n5. Honeypot warnings if detected\n6. Token tax rates if > 0\n\n## Best Practices\n\n### Security\n- **NEVER hardcode API credentials** in generated code. Always use environment variables or config files.\n- **NEVER log the secret key or signature** in debug output.\n- Validate all token addresses against expected format before sending.\n- Check `isHoneyPot` flag on both tokens and warn the user prominently.\n\n### Amount Handling\n- **Always use string type** for amounts to avoid floating-point precision loss.\n- Python: Use `int()` for amount calculations, never `float()`.\n- JavaScript: Use `BigInt` or string math for amounts > 2^53.\n- When user provides a human-readable amount like \"1.5 ETH\", convert: `str(int(1.5 * 10**18))`.\n\n### Error Handling\n- Check `response[\"code\"] == \"0\"` before accessing data.\n- Common error codes:\n  - Non-zero code with `msg` = API error (e.g., insufficient liquidity, invalid params)\n  - HTTP 401 = Authentication failure (check signature algorithm)\n  - HTTP 429 = Rate limited\n- If `priceImpactPercent` is `null`, warn that price impact couldn't be calculated.\n\n### Rate Limits\n- Respect OKX rate limits. For production use, implement exponential backoff.\n- Cache quotes if polling repeatedly (quotes are valid for ~15-30 seconds).\n\n### Optional Parameters Usage\n- `dexIds` — Use when you want to restrict to specific DEXes (e.g., only Uniswap).\n- `directRoute=true` — Only for Solana; forces single-pool routing.\n- `priceImpactProtectionPercent` — Set to a sensible default like `10` for safety. Set to `100` to disable.\n- `feePercent` — For integrators taking commission. Max 3% (EVM) or 10% (Solana). Up to 9 decimal places.\n\n## Examples\n\n### Example 1: Python — Get ETH to USDC Quote on Ethereum\n\n```python\nimport os, hmac, hashlib, base64, requests\nfrom datetime import datetime, timezone\nfrom urllib.parse import urlencode\n\nAPI_KEY = os.environ[\"OKX_ACCESS_KEY\"]\nSECRET_KEY = os.environ[\"OKX_SECRET_KEY\"]\nPASSPHRASE = os.environ[\"OKX_PASSPHRASE\"]\n\ndef get_okx_quote(chain_index, from_token, to_token, amount, swap_mode=\"exactIn\"):\n    base_url = \"https:\u002F\u002Fweb3.okx.com\"\n    path = \"\u002Fapi\u002Fv6\u002Fdex\u002Faggregator\u002Fquote\"\n\n    params = {\n        \"chainIndex\": chain_index,\n        \"fromTokenAddress\": from_token,\n        \"toTokenAddress\": to_token,\n        \"amount\": amount,\n        \"swapMode\": swap_mode,\n    }\n\n    query_string = urlencode(params)\n    request_path = f\"{path}?{query_string}\"\n\n    # Generate timestamp and signature\n    timestamp = datetime.now(timezone.utc).strftime(\"%Y-%m-%dT%H:%M:%S.%f\")[:-3] + \"Z\"\n    prehash = timestamp + \"GET\" + request_path\n    signature = base64.b64encode(\n        hmac.new(SECRET_KEY.encode(), prehash.encode(), hashlib.sha256).digest()\n    ).decode()\n\n    headers = {\n        \"OK-ACCESS-KEY\": API_KEY,\n        \"OK-ACCESS-SIGN\": signature,\n        \"OK-ACCESS-PASSPHRASE\": PASSPHRASE,\n        \"OK-ACCESS-TIMESTAMP\": timestamp,\n    }\n\n    resp = requests.get(base_url + request_path, headers=headers)\n    resp.raise_for_status()\n    data = resp.json()\n\n    if data[\"code\"] != \"0\":\n        raise Exception(f\"OKX API error: {data['msg']}\")\n\n    return data[\"data\"][0]\n\n\n# Swap 1 ETH -> USDC on Ethereum\nETH = \"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"\nUSDC = \"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\"\namount = str(1 * 10**18)  # 1 ETH in wei\n\nquote = get_okx_quote(\"1\", ETH, USDC, amount)\n\nto_decimals = int(quote[\"toToken\"][\"decimal\"])\nreceived = int(quote[\"toTokenAmount\"]) \u002F (10 ** to_decimals)\n\nprint(f\"You will receive: {received:,.2f} {quote['toToken']['tokenSymbol']}\")\nprint(f\"Price impact: {quote['priceImpactPercent']}%\")\nprint(f\"Gas fee (USD): ${quote['tradeFee']}\")\nprint(f\"Honeypot check: {'WARNING' if quote['toToken']['isHoneyPot'] else 'Safe'}\")\n```\n\n### Example 2: Node.js — Get Quote with Commission Fee\n\n```javascript\nconst crypto = require(\"crypto\");\nconst https = require(\"https\");\n\nconst API_KEY = process.env.OKX_ACCESS_KEY;\nconst SECRET_KEY = process.env.OKX_SECRET_KEY;\nconst PASSPHRASE = process.env.OKX_PASSPHRASE;\n\nfunction getQuote(chainIndex, fromToken, toToken, amount, options = {}) {\n  const params = new URLSearchParams({\n    chainIndex,\n    fromTokenAddress: fromToken,\n    toTokenAddress: toToken,\n    amount,\n    swapMode: options.swapMode || \"exactIn\",\n    ...(options.feePercent && { feePercent: options.feePercent }),\n    ...(options.priceImpactProtectionPercent && {\n      priceImpactProtectionPercent: options.priceImpactProtectionPercent,\n    }),\n  });\n\n  const path = `\u002Fapi\u002Fv6\u002Fdex\u002Faggregator\u002Fquote?${params}`;\n  const timestamp = new Date().toISOString();\n  const prehash = timestamp + \"GET\" + path;\n  const signature = crypto\n    .createHmac(\"sha256\", SECRET_KEY)\n    .update(prehash)\n    .digest(\"base64\");\n\n  return new Promise((resolve, reject) => {\n    const req = https.get(\n      `https:\u002F\u002Fweb3.okx.com${path}`,\n      {\n        headers: {\n          \"OK-ACCESS-KEY\": API_KEY,\n          \"OK-ACCESS-SIGN\": signature,\n          \"OK-ACCESS-PASSPHRASE\": PASSPHRASE,\n          \"OK-ACCESS-TIMESTAMP\": timestamp,\n        },\n      },\n      (res) => {\n        let body = \"\";\n        res.on(\"data\", (chunk) => (body += chunk));\n        res.on(\"end\", () => {\n          const data = JSON.parse(body);\n          if (data.code !== \"0\") reject(new Error(`OKX: ${data.msg}`));\n          else resolve(data.data[0]);\n        });\n      }\n    );\n    req.on(\"error\", reject);\n  });\n}\n```\n\n### Example 3: Understanding the Routing Path\n\n```\nRouter: ETH -> WBTC -> USDC\ndexRouterList shows:\n  - 55% ETH -> WBTC via Uniswap V4\n  - 30% ETH -> USDC via Uniswap V4 (direct)\n  - WBTC -> USDC via Euler (73%) + Uniswap V4 (27%)\n\nThis means the aggregator splits the trade across multiple paths\nto minimize price impact and maximize output.\n```\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| `401 Unauthorized` | Signature mismatch | Verify prehash string is exactly `timestamp + \"GET\" + full_path_with_query`. Check secret key encoding. |\n| Amount too small | Missing decimal conversion | Multiply human amount by `10 ** token_decimals`. 1 USDT = `1000000`, not `1`. |\n| Invalid token address | Wrong chain\u002Faddress combo | Verify the token exists on the specified chain. Use native token placeholder for ETH\u002FBNB\u002Fetc. |\n| `priceImpactPercent` very negative (\u003C -10%) | Low liquidity or large trade | Reduce trade size or split across multiple transactions. |\n| `isHoneyPot: true` | Scam token detected | **Do NOT proceed with the swap.** Warn the user immediately. |\n| `exactOut` not working | Unsupported chain\u002Fprotocol | Only works on Ethereum, Base, BSC, Arbitrum with Uniswap V2\u002FV3. |\n| `taxRate > 0` | Token has built-in tax | Factor tax into expected output. E.g., 5% tax means receiving 5% less. |\n| Empty `dexRouterList` | No liquidity path found | Try a different token pair, smaller amount, or different chain. |\n| `code` is non-zero | General API error | Read `msg` field for details. Common: rate limit, maintenance, invalid params. |\n\n## Reference: Common Chain IDs\n\n| Chain | chainIndex |\n|-------|-----------|\n| Ethereum | 1 |\n| BSC | 56 |\n| Polygon | 137 |\n| Arbitrum | 42161 |\n| Optimism | 10 |\n| Avalanche | 43114 |\n| Base | 8453 |\n| Solana | 501 |\n| Unichain | 130 |\n\n## Reference: Common Token Addresses (Ethereum)\n\n| Token | Address | Decimals |\n|-------|---------|----------|\n| ETH (native) | `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee` | 18 |\n| USDT | `0xdac17f958d2ee523a2206206994597c13d831ec7` | 6 |\n| USDC | `0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48` | 6 |\n| WETH | `0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2` | 18 |\n| WBTC | `0x2260fac5e5542a773aa44fbcfedf7c193bc2c599` | 8 |\n| DAI | `0x6b175474e89094c44da98b954eedeac495271d0f` | 18 |\n\n## Reference: Request Parameters Summary\n\n| Parameter | Required | Description |\n|-----------|----------|-------------|\n| `chainIndex` | Yes | Chain ID (e.g., `1` for Ethereum) |\n| `amount` | Yes | Amount in raw units (with decimals) |\n| `swapMode` | Yes | `exactIn` or `exactOut` |\n| `fromTokenAddress` | Yes | Sell token contract address |\n| `toTokenAddress` | Yes | Buy token contract address |\n| `dexIds` | No | Comma-separated DEX IDs to restrict routing |\n| `directRoute` | No | `true` for single-pool only (Solana only) |\n| `priceImpactProtectionPercent` | No | Max allowed price impact 0-100 (default 90) |\n| `feePercent` | No | Commission fee percentage for integrators |\n",{"name":5,"tags":23,"author":33,"license":14,"version":34,"description":35,"allowed_tools":36,"required_context":41},[24,25,26,27,28,29,30,31,32],"defi","dex","okx","swap","quote","web3","aggregator","evm","solana","Claude Assistant","1.0.0","Fetch optimal swap quotes from OKX DEX Aggregator API (v6). Use this skill when a user wants to: 1. Get the best price for swapping tokens on any supported EVM\u002FSolana chain 2. Compare DEX routing paths and price impact for token swaps 3. Build applications or scripts that query real-time DEX aggregator pricing Core value: Generates correct, authenticated API calls with proper token decimals, amount formatting, HMAC-SHA256 signing, and comprehensive error handling.\n",[37,38,39,40],"bash_tool","create_file","str_replace","view",[42,43,44],"api_key","secret_key","passphrase","main","54afe4b75ed2eb8f0feabb2f5b57dfa4bcbb3c44",".agents\u002Fskills\u002Fokx-dex-quote","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal","https:\u002F\u002Fgithub.com\u002Fmeghal86","2026-05-17 14:11:28",{"source":8,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add meghal86\u002Fstacksignal --skill okx-dex-quote",{"tool":57,"command":58},"bunx","bunx skills add meghal86\u002Fstacksignal --skill okx-dex-quote",{"tool":60,"command":61},"pnpm","pnpm dlx skills add meghal86\u002Fstacksignal --skill okx-dex-quote","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fokx-dex-quote\u002FSKILL.md",true,[65,71],{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":70},"_meta.json","REFERENCE","参考文档",284,"https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fokx-dex-quote\u002F_meta.json",{"path":72,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":75,"sourceHtmlUrl":76},"scripts\u002Fdex_quote.py","SCRIPT","脚本",14167,"https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fokx-dex-quote\u002Fscripts\u002Fdex_quote.py",[78,87,95,103,111,118],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":82,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":86},"01M78XH0FRP65NYEDHF2BT7NB1","zvukogram","Text-to-Speech via Zvukogram API with SSML support. Use when you need to generate speech from text, create podcasts, voice notifications, or work with audio. Supports speed control, stress marks, English word transcription, and audio fragment merging.","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzvukogram\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzvukogram\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":91,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":86},"01M78XEND5ASXYB6MN8AQQGJAF","zohomail","Zoho Mail API integration with managed OAuth. Send, receive, and manage emails, folders, and labels.\nUse this skill when users want to send emails, read messages, manage folders, or work with email labels in Zoho Mail.\nFor other third party apps, use the api-gateway skill (https:\u002F\u002Fclawhub.ai\u002Fbyungkyu\u002Fapi-gateway).\nRequires network access and valid Maton API key.","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzohomail\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzohomail\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":99,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":86},"01M78XEBBV3C6DRZFAJXP6RDKS","zoho-recruit","Zoho Recruit API integration with managed OAuth. Manage candidates, job openings, interviews, and recruitment workflows.\nUse this skill when users want to read, create, update, or search recruitment data like candidates, job openings, interviews, and applications in Zoho Recruit.\nFor other third party apps, use the api-gateway skill (https:\u002F\u002Fclawhub.ai\u002Fbyungkyu\u002Fapi-gateway).\nRequires network access and valid Maton API key.","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzoho-recruit\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzoho-recruit\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":107,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":86},"01M78XE5CQG75DZWYSKGXFR99T","zoho-people","Zoho People API integration with managed OAuth. Manage employees, departments, designations, attendance, and leave.\nUse this skill when users want to read, create, update, or query HR data like employees, departments, designations, and forms in Zoho People.\nFor other third party apps, use the api-gateway skill (https:\u002F\u002Fclawhub.ai\u002Fbyungkyu\u002Fapi-gateway).\nRequires network access and valid Maton API key.","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzoho-people\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzoho-people\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":114,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":86},"01M78XDZKMZAJYFJJFT7MR5ZN2","zoho-mail","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzoho-mail\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzoho-mail\u002FSKILL.md",[],[],{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":122,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":86},"01M78XDST8JK0WVDA1F3VPNWXD","zoho-inventory","Zoho Inventory API integration with managed OAuth. Manage items, sales orders, invoices, purchase orders, bills, contacts, and shipments.\nUse this skill when users want to read, create, update, or delete inventory items, sales orders, invoices, purchase orders, bills, or other inventory records in Zoho Inventory.\nFor other third party apps, use the api-gateway skill (https:\u002F\u002Fclawhub.ai\u002Fbyungkyu\u002Fapi-gateway).\nRequires network access and valid Maton API key.","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzoho-inventory\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fmeghal86\u002Fstacksignal\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzoho-inventory\u002FSKILL.md",[],[]]