🎁 Get the FREE AI Skills Starter Guide β€” Subscribe β†’
BytesAgainBytesAgain
πŸ¦€ ClawHub

Web3-Crypto-Degen

by @stanpoldark

Universal Web3 & Crypto operating skill for AI agents. 12 domains, 60+ API endpoints, 5 providers: OKX DEX aggregator, Binance Web3 intelligence, Binance/Gat...

Versionv1.0.4
Downloads641
TERMINAL
clawhub install web3-crypto-ops-skill

πŸ“– About This Skill


name: web3-crypto-ops description: > Universal Web3 & Crypto operating skill for AI agents. 12 domains, 60+ API endpoints, 5 providers: OKX DEX aggregator, Binance Web3 intelligence, Binance/Gate.io/Bitget Spot. Production-grade patterns: RPC health failover, 10-point token safety scoring, honeypot round-trip simulation, V2/V3 smart routing, direct pool turbo execution, Pump.fun/Jupiter auto-dispatch. Commercial risk gates and compliance controls built-in. license: Apache-2.0

── Invocation policy ───────────────────────────────────────────────────────

always:false β†’ skill is user-invocable only; NOT silently auto-triggered.

Platform must prompt the user before any mainnet fund movement.

always: false metadata: version: "1.0.3" tags: [web3, crypto, dex, cex, swap, portfolio, audit, smart-money, meme, signals, gate, bitget] categories: [trading, defi, analytics, security, market-intelligence] compatibility: [openclaw, gemini-cli] providers: [okx-dex, binance-web3, binance-spot, gate-spot, bitget-spot] chains: [ethereum, bsc, solana, base, arbitrum, polygon, xlayer]

── Required environment variables (surfaced to platform registry) ───────────

CRITICAL: This block MUST match Β§XVI of the skill body exactly.

A mismatch between this list and Β§XVI is a security red flag β€” keep in sync.

requiredEnv: # ── CEX API keys (trade-only, NO withdrawal permission) ── - OKX_API_KEY - OKX_SECRET_KEY - OKX_PASSPHRASE - BINANCE_API_KEY - BINANCE_SECRET_KEY - GATE_API_KEY - GATE_SECRET_KEY - BITGET_API_KEY - BITGET_SECRET_KEY - BITGET_PASSPHRASE # ── Blockchain RPC endpoints ── - RPC_ETH - RPC_BSC - RPC_BASE - RPC_ARB - RPC_SOL # ── On-chain signing keys (CRITICAL β€” highest privilege) ── - DEPLOYER_PRIVATE_KEY - SOL_PRIVATE_KEY # ── Feature flags & configs ── - VAULT_TIMEOUT_MS - ENABLE_TESTNET

Web3 Crypto Ops v3.0.0

Trigger Phrases

Token search / trending / rankings | Price / K-line / charts | Security audit / honeypot scan | Wallet balance / holdings | DEX swap / on-chain trade | Gas estimate / broadcast / track | Binance / Gate / Bitget spot order | Smart money signals / social hype | Meme Rush / Pump.fun / Four.meme | PnL leaderboard / KOL tracking


I. Authentication

> ⚠️ SECURITY: All credentials below are πŸ”΄ Secret-level. They MUST be loaded from > environment variables via process.env.*, NEVER hardcoded in source, logged, or > transmitted in chat. See Β§XVI for the complete credential registry and agent rules.

OKX (HMAC-SHA256)

Headers: OK-ACCESS-KEY, OK-ACCESS-SIGN, OK-ACCESS-PASSPHRASE, OK-ACCESS-TIMESTAMP
SIGN = Base64(HMAC-SHA256(timestamp+method+requestPath+body, SECRET))
GET: body="", requestPath includes queryString
POST: body=JSON, requestPath is path only
Env: OKX_API_KEY, OKX_SECRET_KEY, OKX_PASSPHRASE

Binance Spot (HMAC-SHA256)

Header: X-MBX-APIKEY
Query: timestamp(ms) + signature=HMAC-SHA256(queryString, secret)
Mainnet: api.binance.com | Testnet: testnet.binance.vision
Env: BINANCE_API_KEY, BINANCE_SECRET_KEY

Gate.io v4 (HMAC-SHA512)

Headers: KEY, Timestamp(seconds), SIGN
SIGN = HMAC-SHA512(secret, METHOD\n/api/v4/path\nqueryString\nSHA512(body)\ntimestamp)
Base: api.gateio.ws/api/v4
Env: GATE_API_KEY, GATE_SECRET_KEY
Rate limit: 900 req/s (private spot)
Note: Spot and Futures use SEPARATE API key pairs

Bitget v2 (HMAC-SHA256)

Headers: ACCESS-KEY, ACCESS-SIGN, ACCESS-TIMESTAMP(ms), ACCESS-PASSPHRASE
SIGN = Base64(HMAC-SHA256(timestamp+METHOD+path+body, SECRET))
With queryString: timestamp+METHOD+path+?+queryString+body
Base: api.bitget.com
Env: BITGET_API_KEY, BITGET_SECRET_KEY, BITGET_PASSPHRASE
Note: Timestamp drift must be within Β±10 seconds

Binance Web3 (No Auth)

Public endpoints. Required header: Accept-Encoding: identity
POST also needs: Content-Type: application/json
Base: web3.binance.com
Warning: /bapi/defi/* are undocumented APIs β€” may change without notice, implement fallback


II. Chain ID Mapping

| Chain | OKX | Binance | K-Line Platform | Native Token Address | | -------- | ----- | ------- | --------------- | -------------------------------- | | Ethereum | 1 | 1 | eth | 0xeeee...eeee | | BSC | 56 | 56 | bsc | 0xeeee...eeee | | Solana | 501 | CT_501 | solana | 11111111111111111111111111111111 | | Base | 8453 | 8453 | base | 0xeeee...eeee | | Arbitrum | 42161 | β€” | β€” | 0xeeee...eeee | | Polygon | 137 | β€” | β€” | 0xeeee...eeee |

CRITICAL: Solana native SOL uses 11111111111111111111111111111111. Do NOT use wSOL (So111...112) β€” causes custom program error: 0xb. Exception: candles and trades endpoints require the wSOL address. Binance Solana chainId is CT_501, not 501.

Wrapped Native: BSC 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c | ETH 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 | Base 0x4200000000000000000000000000000000000006


III. Domain 1 β€” Token Discovery

| API | Method | Path | Purpose | | -------------------- | ------ | ------------------------------------------------------------------------- | ----------------------------------------- | | OKX Search | GET | /api/v6/dex/market/token/search?chains=&search= | Search by name/symbol/address | | OKX Ranking | GET | /api/v6/dex/market/token/toplist?chains=&sortBy={2\|5\|6}&timeFrame={1-4} | Rank by change/volume/mcap | | OKX Basic Info | POST | /api/v6/dex/market/token/basic-info | Batch metadata | | OKX Holders | GET | /api/v6/dex/market/token/holder?chainIndex=&tokenContractAddress= | Top 20 holder distribution | | Binance Search | GET | bapi/.../market/token/search?keyword=&chainIds=&orderBy=volume24h | Alternative search source | | Binance Unified Rank | POST | bapi/.../pulse/unified/rank/list | Trending/Alpha/Stock ranking with filters |

Unified Rank rankType: 10=Trending 11=Top Search 20=Alpha 40=Stock period: 10=1m 20=5m 30=1h 40=4h 50=24h sortBy: 40=marketCap 50=priceChange 70=volume 100=uniqueTraders


IV. Domain 2 β€” Market Data

| API | Method | Path | Returns | | ------------------ | -------- | ------------------------------------------------------------------------ | --------------------------------------------------- | | OKX Price Info | POST | /api/v6/dex/market/price-info | price, marketCap, liquidity, volume24H, priceChange | | OKX Realtime Price | POST | /api/v6/dex/market/price | price (USD) | | OKX Candles | GET | /api/v6/dex/market/candles?bar={interval}&limit= | [ts,o,h,l,c,vol,volUsd,confirm] | | OKX Historical | GET | /api/v6/dex/market/historical-candles | Same format, older data | | OKX Trades | GET | /api/v6/dex/market/trades | type, price, volume, dexName | | OKX Index | POST/GET | /api/v6/dex/index/current-price \| historical-price | Multi-source aggregated price | | Binance Dynamic | GET | bapi/.../token/dynamic/info?chainId=&contractAddress= | price, fdv, kolHolders, smartMoneyHolders | | Binance Metadata | GET | bapi/.../token/meta/info?chainId=&contractAddress= | creatorAddress, links, auditInfo | | Binance K-Line | GET | dquery.sintral.io/u-kline/v1/k-line/candles?platform=&address=&interval= | [o,h,l,c,vol,ts,count] |

Intervals: 1s, 1m, 3m, 5m, 15m, 30m, 1H, 2H, 4H, 6H, 12H, 1D, 1W, 1M, 3M


V. Domain 3 β€” Security Audit & Safety Scoring

Binance Token Audit

POST bapi/.../security/token/audit Body: { "binanceChainId": "56|8453|CT_501|1", "contractAddress": "...", "requestId": "uuid" } Results valid ONLY when hasResult=true AND isSupported=true riskLevel: 0-1=LOW 2-3=MEDIUM 4=HIGH 5=BLOCK TRADE

Production 10-Point Safety Scoring

| # | Check | Safe Threshold | | --- | -------------------------- | -------------- | | 1 | LP Lock Rate | β‰₯80% | | 2 | Top10 Holder Concentration | ≀45% | | 3 | Liquidity (USD) | β‰₯$15,000 | | 4 | Market Cap (USD) | β‰₯$20,000 | | 5 | Holder Count | β‰₯150 | | 6 | Insider Holding % | ≀10% | | 7 | Sniper Holding % | ≀8% | | 8 | 24h Transaction Count | β‰₯80 | | 9 | Dev Rug-Pull History | = 0 | | 10 | Dev Coins Launched | ≀5 |

Score = passedCount / totalChecks Γ— 100. Pass requires: all checks passed AND totalChecks β‰₯ 3.

Honeypot Detection (Round-Trip Simulation)

1. Simulate BUY: WNATIVE β†’ Token (record amountOut) 2. Simulate SELL: Token β†’ WNATIVE (use amountOut as input) 3. Recovery ratio = sellOut / originalAmount Γ— 100 4. <50% = honeypot (85% confidence) | =0 = honeypot (90%) | 50-80% = suspicious | >80% = normal

Contract Risk Flags

isHoneypot β†’ BLOCK | hasMintMethod β†’ HIGH risk | isLpNotLocked β†’ Rug risk | hasNotRenounced β†’ MEDIUM | isInBlacklist β†’ MEDIUM


VI. Domain 4 β€” Wallet & Portfolio

| API | Method | Path | | ----------------- | ------ | -------------------------------------------------------------------- | | OKX Total Value | GET | /api/v6/dex/balance/total-value-by-address?address=&chains= | | OKX All Balances | GET | /api/v6/dex/balance/all-token-balances-by-address?address=&chains= | | OKX Token Balance | POST | /api/v6/dex/balance/token-balances-by-address | | Binance Positions | GET | bapi/.../address/pnl/active-position-list?address=&chainId=&offset=0 |

Note: OKX excludeRiskToken is Boolean for total-value but String("0"/"1") for token-balances. Native token: tokenContractAddress = "" (empty string).


VII. Domain 5 β€” DEX Swap Execution

OKX Aggregator (all GET)

| Endpoint | Purpose | | ------------------------------------------------------------------------------------------- | -------------------------------- | | /api/v6/dex/aggregator/quote?chainIndex=&fromTokenAddress=&toTokenAddress=&amount= | Get quote | | /api/v6/dex/aggregator/approve-transaction?chainIndex=&tokenContractAddress=&approveAmount= | ERC20 approval | | /api/v6/dex/aggregator/swap?chainIndex=&...&slippagePercent=1&userWalletAddress= | Swap calldata | | /api/v6/dex/aggregator/swap-instruction?chainIndex=501&... | Solana deserialized instructions |

Amount must be in minimal units (wei/lamports). Default slippage: 1%.

Smart Router (V2/V3 Auto-Selection)

Query all routes in parallel β†’ pick highest amountOut: 1. V2 Router getAmountsOut(amountIn, [tokenIn, tokenOut]) 2. V3 Quoter quoteExactInputSingle across ALL fee tiers (100, 500, 3000, 10000) 3. Sort by amountOut descending β†’ select best

V2 Routers: BSC 0x10ED43C718714eb63d5aA57B78B54704E256024E | ETH 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D | Base 0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24 V3 Routers: ETH 0xE592427A0AEce92De3Edee1F18E0157C05861564 | Base 0x2626664c2603336E57B271c5C0b26F421741e481 | BSC 0x13f4EA83D0bd40E75C8222255bc855a974568Dd4 V3 Fees: 100 (0.01% stables), 500 (0.05%), 3000 (0.3% most pairs), 10000 (1% exotic)

Turbo Direct Pool (~15k-30k gas savings)

Bypass router, call pool contracts directly:
  • V2: transfer token to pair β†’ pair.swap(amount0Out, amount1Out, to, 0x)
  • V3: fallback to SwapRouter exactInputSingle (EOA can't call pool.swap callback)
  • V2 formula: amountOut = amountInΓ—997Γ—reserveOut / (reserveInΓ—1000 + amountInΓ—997)
  • Solana Auto-Dispatch

    isPumpToken? β†’ Pump.fun direct buy/sell : Jupiter aggregator

    Safety Patterns

  • Approve ONLY required amount β€” never maxUint256
  • Quote failure β†’ BLOCK trade (prevents sandwich attacks)
  • Slippage: amountOutMin = expectedOut Γ— (10000 - slippageBps) / 10000

  • VIII. Domain 6 β€” Broadcast & Tracking

    | Endpoint | Method | Purpose | | -------------------------------------------------------- | ------ | --------------------- | | /api/v6/dex/pre-transaction/gas-price?chainIndex= | GET | Gas price | | /api/v6/dex/pre-transaction/gas-limit | POST | Gas limit estimate | | /api/v6/dex/pre-transaction/simulate | POST | Tx simulation | | /api/v6/dex/pre-transaction/broadcast-transaction | POST | Broadcast signed tx | | /api/v6/dex/post-transaction/orders?address=&chainIndex= | GET | Order status tracking |

    Broadcast body: { "signedTx": "0x...", "chainIndex": "1", "address": "0x..." } MEV protection: extraData: { "enableMevProtection": true } (ETH/BSC/SOL/BASE) txStatus: 1=Pending 2=Success 3=Failed


    IX. Domain 7 β€” Binance Spot

    | Endpoint | Method | Purpose | | -------------------- | ------ | -------------------- | | /api/v3/order | POST | Place order | | /api/v3/order | GET | Query order | | /api/v3/order | DELETE | Cancel order | | /api/v3/order/test | POST | Test order (no exec) | | /api/v3/openOrders | GET | Open orders | | /api/v3/account | GET | Account info | | /api/v3/myTrades | GET | Trade history | | /api/v3/ticker/price | GET | Ticker | | /api/v3/klines | GET | K-line | | /api/v3/depth | GET | Order book |

    Order types: MARKET, LIMIT, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER Advanced: OCO, OTO, OTOCO conditional orders


    X. Domain 8 β€” Gate.io Spot

    Auth: HMAC-SHA512 (see Section I)

    | Endpoint | Method | Auth | Purpose | | ----------------------- | ------ | ---- | ------------------------------------------- | | /spot/orders | POST | Yes | Create order | | /spot/orders | GET | Yes | List orders (params: status, market, limit) | | /spot/orders/{order_id} | GET | Yes | Get single order | | /spot/orders/{order_id} | DELETE | Yes | Cancel single order | | /spot/orders | DELETE | Yes | Cancel all orders | | /spot/accounts | GET | Yes | Spot balance | | /spot/tickers | GET | No | Tickers | | /spot/order_book | GET | No | Order book | | /spot/candlesticks | GET | No | K-line | | /spot/currency_pairs | GET | No | Trading pair rules | | /wallet/total_balance | GET | Yes | Total balance across all accounts |

    Order params: currency_pair ("BTC_USDT" underscore format), side (buy/sell), type (limit/market), amount, price, time_in_force (gtc/ioc/poc/fok), account ("spot")

    Rate limit headers: X-Gate-RateLimit-Requests-Remain, X-Gate-RateLimit-Limit


    XI. Domain 9 β€” Bitget Spot

    Auth: HMAC-SHA256 (see Section I)

    | Endpoint | Method | Auth | Purpose | | ------------------------------------- | ------ | ---- | ----------------------------------------- | | /api/v2/spot/trade/place-order | POST | Yes | Place order | | /api/v2/spot/trade/cancel-order | POST | Yes | Cancel order (NOTE: uses POST not DELETE) | | /api/v2/spot/trade/batch-orders | POST | Yes | Batch place (max 50) | | /api/v2/spot/trade/batch-cancel-order | POST | Yes | Batch cancel | | /api/v2/spot/trade/orderInfo | GET | Yes | Query single order | | /api/v2/spot/trade/unfilled-orders | GET | Yes | Open orders | | /api/v2/spot/trade/history-orders | GET | Yes | Order history | | /api/v2/spot/trade/fills | GET | Yes | Trade fills | | /api/v2/spot/account/assets | GET | Yes | Spot assets | | /api/v2/spot/account/info | GET | Yes | Account info | | /api/v2/spot/market/tickers | GET | No | Tickers | | /api/v2/spot/market/orderbook | GET | No | Order book | | /api/v2/spot/market/candles | GET | No | K-line | | /api/v2/spot/market/fills | GET | No | Recent trades | | /api/v2/account/all-account-balance | GET | Yes | All account balances |

    Order params: symbol ("BTCUSDT" no separator), side (buy/sell), orderType (limit/market), force (gtc/ioc/fok/post_only), price, size, clientOid (idempotency key)


    XII. Domain 10 β€” Smart Money Signals

    Smart Money Trading Signals

    POST bapi/.../web/signal/smart-money Body: { "smartSignalType":"", "page":1, "pageSize":100, "chainId":"CT_501" } Chains: BSC (56), Solana (CT_501)

    Key fields: direction (buy/sell), smartMoneyCount, alertPrice, currentPrice, maxGain (%), exitRate (%), status (active/timeout/completed)

    Quality: Higher smartMoneyCount = more reliable. Low exitRate on active = smart money still holding.

    Smart Money Inflow Rank

    POST bapi/.../tracker/wallet/token/inflow/rank/query Body: { "chainId":"56", "period":"24h", "tagType":2 }

    Social Hype Leaderboard

    GET bapi/.../pulse/social/hype/rank/leaderboard?chainId=&sentiment=All&targetLanguage=en&timeRange=1 Returns AI-generated multilingual sentiment summaries.


    XIII. Domain 11 β€” Meme Rush

    Meme Rush Rank

    POST bapi/.../pulse/rank/list Body: { "chainId":"CT_501", "rankType":10, "limit":40 } rankType: 10=New (bonding curve) 20=Finalizing 30=Migrated to DEX

    Protocols: Pump.fun (1001), Four.meme (2001), Moonshot (1010), Raydium (1005-1007), BONK (1008), Flap (2002)

    Advanced filters: progress (curve %), holdersDevPercent, holdersSniperPercent, devSellPercent, tagDevWashTrading, excludeDevWashTrading

    Meme Exclusive Rank

    GET bapi/.../pulse/exclusive/rank/list?chainId=56 Algorithm-scored Top 100 breakout potential memes.

    Topic Rush

    GET bapi/.../social-rush/rank/list?chainId=&rankType={10|20|30}&sort={10|20|30} rankType: 10=Latest 20=Rising (ATH $1k-$20k) 30=Viral (ATH >$20k)


    XIV. Domain 12 β€” PnL Leaderboard

    GET bapi/.../market/leaderboard/query?chainId=&period={7d|30d|90d}&tag={ALL|KOL}&pageNo=1&pageSize=25 Filters: PNLMin/Max, winRateMin/Max, txMin/Max, volumeMin/Max Returns: address, realizedPnl, winRate, totalVolume, topEarningTokens[], dailyPNL[]


    RPC Health-Aware Failover

    Per-chain node health map: { url, healthy, latencyMs, failCount } 1. Select: healthy nodes β†’ sort by latency β†’ return lowest 2. All unhealthy: return node with fewest failures (graceful degradation) 3. On success: reset failCount, update latencyMs 4. On failure: failCount++; β‰₯3 consecutive β†’ mark unhealthy 5. Background probe every 30s: eth_blockNumber to all nodes, 5s timeout


    Risk Gates

    | Condition | Action | | ------------------------------------------------ | ------------------------------------- | | riskLevel=5 OR isHoneypot OR recovery<50% | BLOCK TRADE | | tax>10% OR quote failure OR priceImpact>30% | BLOCK TRADE | | riskLevel=4 | Strongly discourage, require override | | 5%5% | Warn + confirm | | liquidity<$1k | Strongly discourage | | $1k≀liquidity<$10k | Warn slippage | | Safety score<60 OR checks<3 | Warn, show failed items | | devWashTrading=1 OR devPercent>20% OR sniper>30% | Warn manipulation | | Still on bonding curve | Warn high risk | | Mainnet fund movement | Require user CONFIRM |


    Workflows

    A: Discover β†’ Verify β†’ Execute: Search β†’ market data β†’ 10-point safety scoring β†’ honeypot sim β†’ balance check β†’ smart route quote β†’ user CONFIRM β†’ exact-amount approve β†’ execute β†’ track B: Portfolio Analysis: Balance query β†’ enrich holdings β†’ flag risk β†’ suggest actions C: Signal-Driven: Smart money signals β†’ inflow rank β†’ safety filter β†’ watchlist β†’ execute via A D: CEX Spot: Select exchange (Binance/Gate/Bitget) β†’ validate params β†’ mainnet CONFIRM β†’ place order β†’ status. Cross-CEX price comparison E: Meme Sniping: Monitor rankType=10 β†’ filter wash/social β†’ 70-90% curve β†’ smart money cross-ref β†’ safety score β†’ execute via A F: Copy-Trading: PnL leaderboard β†’ filter winRate>60% β†’ query positions β†’ cross-ref signals β†’ research β†’ report G: Topic Narrative: Viral topics β†’ AI summaries β†’ lead tokens β†’ quality verify β†’ execute via A


    Error Handling

    | Source | Code | Meaning | Action | | ------------ | ------------- | ----------------- | ------------------------------------ | | OKX | 50011 | Rate limited | Exponential backoff + jitter | | OKX | 81104 | Chain unsupported | Check /supported/chain | | OKX | 81451 | Node failed | Check gas/nonce/revert | | Binance Spot | -1021 | Timestamp drift | Sync clock | | Binance Spot | -2010 | Order rejected | Check balance/permissions | | Gate.io | 401 | Auth failed | Verify KEY + SIGN | | Gate.io | 429 | Rate limited | Check X-Gate-RateLimit headers | | Bitget | 401 | Auth failed | Verify KEY + SIGN + timestamp (Β±10s) | | Solana | 0xb | Wrong address | Use native SOL address | | EVM | nonce too low | Already mined | Fetch latest nonce |

    Timeout: All APIs 10s timeout. On broadcast/order timeout β†’ check status before retry (prevent double-spend).


    Core Rules

    Security: Never output raw keys. Approve only required amounts. Mainnet ops require CONFIRM. Quote failure = block. See Β§XVI–§XVII for full credential handling rules. Units: APIs use minimal units (wei/lamports); display uses UI units. amount_min = amount_ui Γ— 10^decimal. Formats: Gate.io uses underscore pairs "BTC_USDT"; Bitget uses no separator "BTCUSDT". Fallback: OKX search ↔ Binance search, OKX candles ↔ Sintral K-line, OKX balance ↔ Binance positions. CEX failure β†’ suggest alternative exchange. RPC: Auto-failover via health manager. 30s probe, 5s timeout, 3 consecutive failures = unhealthy. Output: Concise decision summaries β†’ risk flags first β†’ blocked trades get reason + alternatives β†’ disclaimer at end.

    Defaults: slippage=1% | ranking pageSize=20-50 | signals=active only | meme default=rankType=20 (migration) | PnL=30d | V3 fee=3000 | tx deadline=300s


    XVI. Credential & Environment Variable Registry

    This skill requires credentials for 5 providers. Below is the complete registry of all environment variables, their purpose, and security classification.

    Required Environment Variables

    | Variable | Provider | Purpose | Sensitivity | | ---------------------- | ----------------- | ------------------------ | ----------- | | OKX_API_KEY | OKX DEX | HMAC signing (key) | πŸ”΄ Secret | | OKX_SECRET_KEY | OKX DEX | HMAC signing (secret) | πŸ”΄ Secret | | OKX_PASSPHRASE | OKX DEX | API passphrase | πŸ”΄ Secret | | BINANCE_API_KEY | Binance Spot | Request header auth | πŸ”΄ Secret | | BINANCE_SECRET_KEY | Binance Spot | HMAC signing | πŸ”΄ Secret | | GATE_API_KEY | Gate.io | Request header auth | πŸ”΄ Secret | | GATE_SECRET_KEY | Gate.io | HMAC-SHA512 signing | πŸ”΄ Secret | | BITGET_API_KEY | Bitget | Request header auth | πŸ”΄ Secret | | BITGET_SECRET_KEY | Bitget | HMAC signing | πŸ”΄ Secret | | BITGET_PASSPHRASE | Bitget | API passphrase | πŸ”΄ Secret | | RPC_ETH | Ethereum RPC | Chain interaction | 🟑 Sensitive | | RPC_BSC | BSC RPC | Chain interaction | 🟑 Sensitive | | RPC_BASE | Base RPC | Chain interaction | 🟑 Sensitive | | RPC_ARB | Arbitrum RPC | Chain interaction | 🟑 Sensitive | | RPC_SOL | Solana RPC | Chain interaction | 🟑 Sensitive | | DEPLOYER_PRIVATE_KEY | EVM tx signing | On-chain trade execution | πŸ”΄ Critical | | SOL_PRIVATE_KEY | Solana tx signing | On-chain trade execution | πŸ”΄ Critical | | VAULT_TIMEOUT_MS | Vault | Auto-lock duration | βšͺ Config | | ENABLE_TESTNET | Routing | Route through testnets | βšͺ Config |

    Sensitivity Levels

    βšͺ Config:     Safe to commit to .env.example as placeholder values
    🟑 Sensitive:  Must be in .env (gitignored), contains API keys or RPC endpoints with keys
    πŸ”΄ Secret:     Must NEVER appear in logs, code, or git history
    πŸ”΄ Critical:   Private keys β€” highest security; compromise = total fund loss
    

    Agent Behavior: When to Request Credentials

    Rule 1: NEVER invent, generate, or hardcode real API keys or secrets.
            Use placeholder values in .env.example only.
    Rule 2: When scaffolding, create .env.example with descriptive placeholders:
            OKX_API_KEY=your-okx-api-key
            OKX_SECRET_KEY=your-okx-secret-key
            DEPLOYER_PRIVATE_KEY=0x_DO_NOT_COMMIT_REAL_KEY
    Rule 3: Add .env to .gitignore BEFORE any .env file is created.
    Rule 4: When a feature needs a credential not yet configured:
            β†’ Tell the user which variable is needed and which provider dashboard to get it from
            β†’ Provide the provider's API key management URL:
              - OKX: https://www.okx.com/account/my-api
              - Binance: https://www.binance.com/en/my/settings/api-management
              - Gate.io: https://www.gate.io/myaccount/apikeys
              - Bitget: https://www.bitget.com/account/newapi
              - Alchemy (RPC): https://dashboard.alchemy.com
            β†’ Ask the user to set it in .env
            β†’ NEVER ask the user to paste secrets into chat
    Rule 5: For DEPLOYER_PRIVATE_KEY / SOL_PRIVATE_KEY:
            β†’ Recommend generating locally (cast wallet new, solana-keygen new)
            β†’ For mainnet: use hardware wallet or the project Vault system
            β†’ NEVER use a funded mainnet key in .env on a dev machine
    Rule 6: When implementing auth signing functions:
            β†’ Load secrets with process.env.* at module init
            β†’ Validate presence at startup: if (!key) throw new Error('Missing OKX_API_KEY')
            β†’ NEVER pass secrets as function parameters through the call stack
    Rule 7: Agent Scope Limits (Infrastructure):
            β†’ The agent runs purely as a trading helper. Infrastructure secrets 
              (e.g., DATABASE_URL, REDIS_URL, JWT_SECRET) are EXPLICITLY OUT OF SCOPE.
            β†’ NEVER attempt to read, request, or persist data directly using backend services.
            β†’ All state must be passed through safe API layers, never via direct DB connections.
    


    XVII. Security: Agent Rules for Sensitive Key Handling

    Mandatory rules for any AI agent following this skill when handling API keys, private keys, and credential material during development, testing, and deployment.

    Agent MUST Rules (Non-Negotiable)

    1. NEVER echo, log, print, or return API keys/secrets to stdout, stderr, or chat.
       Masking rule: key.slice(0,4) + '****' + key.slice(-4)
    2. NEVER include real secrets in code, comments, commit messages, or artifacts.
    3. NEVER store secrets in source-controlled files.
       Only .env (which MUST be in .gitignore) may contain real credentials.
    4. NEVER transmit secrets over unencrypted channels or embed in URLs.
    5. When writing HMAC signing utilities:
       β†’ Secret key MUST come from process.env exclusively
       β†’ The signing function MUST NOT log the computed signature in production
       β†’ Timestamp synchronization: use server time diff calibration
    6. When writing trade execution code:
       β†’ Private keys MUST be decrypted from Vault at execution time only
       β†’ Zero-fill key Buffer after use: keyBuffer.fill(0)
       β†’ NEVER cache decrypted private keys in global scope
    7. When writing Docker/CI configs:
       β†’ Use secrets managers (Docker secrets, GitHub Actions secrets)
       β†’ NEVER bake API keys into Docker images or CI YAML
    8. When implementing CEX API clients:
       β†’ Use IP whitelisting where the exchange supports it (all 4 do)
       β†’ Enable TRADE-ONLY permissions β€” WITHDRAWAL PERMISSION MUST BE DISABLED on all keys
       β†’ Implement separate key pairs for spot vs futures (Gate.io requirement)
       β†’ Verify no withdrawal permission is enabled before any integration test
    9. Principle of Least Privilege enforcement:
       β†’ OKX:     Read + Trade. Withdrawal = OFF. IP whitelist = REQUIRED.
       β†’ Binance:  Read + Trade. Withdrawal = OFF. Margin = OFF unless explicitly needed.
       β†’ Gate.io:  Spot trade only. Futures = SEPARATE key. Withdrawal = OFF.
       β†’ Bitget:   Read + Trade. Withdrawal = OFF. IP whitelist recommended.
       β†’ EVM key:  Dedicated wallet, minimal balance, never a primary wallet.
       β†’ SOL key:  Dedicated wallet, minimal balance, never a primary wallet.
    10. Testnet-first mandate:
        β†’ Set ENABLE_TESTNET=true and test ALL workflows on testnets BEFORE mainnet.
        β†’ Binance testnet: testnet.binance.vision
        β†’ Only after successful testnet validation may the agent proceed to mainnet.
    

    Exchange-Specific Security Notes

    | Exchange | Key Rotation | IP Whitelist | Permission Granularity | Notes | | -------- | ------------------ | ---------------------- | -------------------------------------- | ----------------------------------------------- | | OKX | 90-day recommended | βœ… Required for trade | Read / Trade / Withdraw | Passphrase adds extra layer | | Binance | No expiry, manual | βœ… Strongly recommended | Read / Trade / Withdraw / Margin | Enable HMAC-only (no Ed25519) for compatibility | | Gate.io | No expiry, manual | βœ… Available | Spot / Futures / Withdrawal (separate) | Spot and Futures need SEPARATE key pairs | | Bitget | No expiry, manual | βœ… Available | Read / Trade / Withdraw | Passphrase required; Β±10s timestamp tolerance |

    Credential Lifecycle

    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚   GENERATION     │───▢│    STORAGE       │───▢│     USAGE        β”‚
    β”‚                  β”‚    β”‚                  β”‚    β”‚                  β”‚
    β”‚ Exchange UI      β”‚    β”‚ .env file (dev)  β”‚    β”‚ process.env.*    β”‚
    β”‚ cast wallet new  β”‚    β”‚ Vault (prod)     β”‚    β”‚ Vault decrypt    β”‚
    β”‚ solana-keygen    β”‚    β”‚ Docker secrets   β”‚    β”‚ HMAC sign()      β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚                        β”‚
                             β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
                             β”‚  ROTATION  β”‚          β”‚  CLEANUP   β”‚
                             β”‚ API: 90d   β”‚          β”‚ Zero-fill  β”‚
                             β”‚ JWT: 15m   β”‚          β”‚ Buffer     β”‚
                             β”‚ Refresh:7d β”‚          β”‚ after use  β”‚
                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    

    .env.example Template

    The agent MUST generate this file when scaffolding a project using this skill:

    # === OKX DEX Aggregator (https://www.okx.com/account/my-api) ===
    OKX_API_KEY=your-okx-api-key
    OKX_SECRET_KEY=your-okx-secret-key
    OKX_PASSPHRASE=your-okx-passphrase

    === Binance Spot (https://www.binance.com/en/my/settings/api-management) ===

    BINANCE_API_KEY=your-binance-api-key BINANCE_SECRET_KEY=your-binance-secret-key

    === Gate.io Spot (https://www.gate.io/myaccount/apikeys) ===

    NOTE: Spot and Futures require SEPARATE key pairs

    GATE_API_KEY=your-gate-spot-api-key GATE_SECRET_KEY=your-gate-spot-secret-key

    === Bitget Spot (https://www.bitget.com/account/newapi) ===

    BITGET_API_KEY=your-bitget-api-key BITGET_SECRET_KEY=your-bitget-secret-key BITGET_PASSPHRASE=your-bitget-passphrase

    === Blockchain RPC (https://dashboard.alchemy.com) ===

    RPC_ETH=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY RPC_BSC=https://bsc-dataseed1.binance.org RPC_BASE=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY RPC_ARB=https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY RPC_SOL=https://api.mainnet-beta.solana.com

    === On-Chain Signing (NEVER commit funded mainnet keys) ===

    Generate a fresh dedicated wallet: cast wallet new (EVM) | solana-keygen new (Solana)

    Use a SMALL-BALANCE ONLY wallet. NEVER use a primary/funded mainnet wallet here.

    DEPLOYER_PRIVATE_KEY=

    ↑ Leave blank. Populate ONLY with a freshly generated, isolated dev/test wallet key.

    SOL_PRIVATE_KEY=

    ↑ Leave blank. Base58 key β€” generate with: solana-keygen new --no-bip39-passphrase

    === Infrastructure ===

    NOTE: Trade_Tool backend services manage their own standalone configuration.

    Infrastructure secrets (DB, Redis, JWT) are completely isolated from this agent skill.

    VAULT_TIMEOUT_MS=28800000 ENABLE_TESTNET=true


    XVIII. Pre-Install Security Checklist

    Before activating this skill with live credentials, verify every item below:

    | # | Check | Status | | --- | ---------------------------------------------------------------------------------------------------------------------------------- | ------ | | 1 | Testnet first β€” ENABLE_TESTNET=true tested successfully before mainnet | ☐ | | 2 | Dedicated wallets β€” DEPLOYER_PRIVATE_KEY / SOL_PRIVATE_KEY are fresh wallets with minimal balance, not your primary wallet | ☐ | | 3 | Withdrawal disabled β€” All CEX API keys (OKX / Binance / Gate / Bitget) have withdrawal permission explicitly OFF | ☐ | | 4 | IP whitelist enabled β€” All exchange API keys locked to your server's IP address | ☐ | | 5 | Trade-only scope β€” No Margin, Futures, or Cross-account permissions granted unless required | ☐ | | 6 | Secrets in .env only β€” Credentials stored in .env (gitignored), never in source code or chat | ☐ | | 7 | Vault for mainnet β€” Production keys stored in the project Vault system, not plain .env | ☐ | | 8 | Provenance verified β€” Skill source confirmed at https://github.com/StanPoldark/Trade_Tool | ☐ | | 9 | Metadata in sync β€” requiredEnv in YAML frontmatter matches Β§XVI table (verify: diff the name: fields in the YAML block against the Β§XVI Variable column, zero delta expected) | ☐ | | 10 | Small balance test β€” First mainnet trade uses smallest viable amount to validate integration | ☐ |

    > How to use: Copy this checklist into your project's SECURITY.md and confirm each item before > going live. Skip any item only if that provider is not used in your deployment.


    ⚠️ This skill provides operational reference only and does not constitute investment advice. Always DYOR.