[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6GWK232RK3DGRE6955KF619":3,"skill-same:01M6GWK232RK3DGRE6955KF619":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":35,"linkOnly":36,"markdownContent":37,"markdownBody":38,"frontMatter":39,"refName":40,"commitSha":41,"skillDirectory":42,"forksCount":43,"repositoryHtmlUrl":44,"repositoryHomepageUrl":6,"ownerHtmlUrl":45,"ownerBlogUrl":46,"ownerDescription":47,"updatedAt":48,"install":49,"resources":62},"01M6GWK232RK3DGRE6955KF619","gdex-sdk-debugging",null,"Troubleshoot GDEX SDK errors — error codes, encryption debugging, chain-specific quirks, HL gotchas, and copy trade pitfalls","jiayaoqijia\u002Fcryptoskill","jiayaoqijia","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1453879?v=4","01M6GMYTX7Q7S504VC6E756ENR","YQ","01M6GMYV1QKJ1CC75MTTGT9PR0",81,"MIT","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fgemachdao-gdex-sdk-debugging\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fgemachdao-gdex-sdk-debugging\u002FSKILL.md",[],[20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"sdk","debugging","gdex sdk debugging","troubleshoot","encryption","trade","hl","chain","copy","error","codes","errors","pitfalls","copy trade","error codes","2026-11-10 10:12:30",false,"---\nname: gdex-sdk-debugging\ndescription: Troubleshoot GDEX SDK errors — error codes, encryption debugging, chain-specific quirks, HL gotchas, and copy trade pitfalls\n---\n\n# GDEX: SDK Debugging & Troubleshooting\n\nComprehensive troubleshooting guide for GDEX SDK errors, covering API error codes, encryption debugging, chain-specific quirks, HyperLiquid gotchas, and copy trade pitfalls. All issues documented from live E2E testing.\n\n## When to Use\n\n- Getting unexpected API errors (103, 102, TIMEOUT)\n- Trades failing silently or returning wrong data\n- Debugging encryption \u002F `computedData` payload issues\n- Chain-specific problems (wrong chainId, wrong managed wallet)\n- HyperLiquid perp issues\n- Copy trade configuration problems\n\n## API Error Codes\n\n| Code | Error | Common Cause | Fix |\n|------|-------|-------------|-----|\n| `103` | Unauthorized | Wrong `walletAddress` (using managed instead of control), wrong ABI type, signing with wrong key | Use **control wallet address** as `walletAddress` \u002F `userId`. Verify session key matches sign-in. |\n| `102` | Invalid chainId | Using wrong chainId for HL operations | HL operations require `chainId: 42161` (Arbitrum). Copy trades need specific chainIds (see below). |\n| `102` | Invalid params | Reused nonce, unsupported token, or malformed ABI payload | Check nonce is fresh (`Date.now()`). Verify token is supported on chain. |\n| `400` | Bad Request | Missing required fields or wrong field types | Check all required params are present and correctly typed. |\n| `TIMEOUT` | Request timeout | Backend processing delay (common with `hlCloseAll`) | Retry once, or use alternative approach (reduce-only order to close). |\n| `JSON parse error` | Invalid response | Backend returned non-JSON (HTML error page, Cloudflare block) | Check User-Agent header is set. Verify API key is valid. |\n\n## Critical: Control Wallet vs Managed Wallet\n\nThis is the **#1 source of errors**:\n\n```\nControl wallet:  0x53D029a671bd1CF61a2fB1F4F6e4bD830BFBb2eD  ← used for API calls (userId, walletAddress)\nManaged wallet:  0x9967179de55bd67e6b90fcc4f908556d93938c0f  ← server-side, executes trades on-chain\n```\n\n**Rule:** All API calls use the **control address** — the one you signed in with. The managed address is only used when querying on-chain state directly (e.g., `user_stats` on HL needs the managed address).\n\n> The `\u002Fv1\u002Fuser` endpoint returns a **different managed wallet per chainId**:\n> - `chainId=1` → EVM managed: `0x9967...`\n> - `chainId=622112261` → Solana managed: `CFSi4Y...` (base58)\n\n## Chain ID Gotchas\n\n| Issue | Wrong | Correct | Notes |\n|-------|-------|---------|-------|\n| Solana chain ID | `900` | `622112261` (`ChainId.SOLANA`) | `900` returns EVM managed address with `balance: null` |\n| Copy trade sign-in | `chainId: 1` | `chainId: 622112261` | Solana copy trades need Solana chainId for sign-in |\n| Perp copy trade sign-in | `chainId: 622112261` | `chainId: 1` | HL perp copy trades need EVM chainId for sign-in |\n| HL operations | Any other | `42161` (Arbitrum) | HL deposit, create order, close — all use Arbitrum chainId |\n\n## HyperLiquid-Specific Issues\n\n### `hlCloseAll` is Unreliable\n\nThe `\u002Fv1\u002Fhl\u002Fclose_all_positions` endpoint frequently returns `TIMEOUT` or JSON parse errors.\n\n**Workaround:** Close each coin with `closePerpPosition` (MCP: `close_perp_position`). It reads the live\nposition and sends a reduce-only market order for the exact size on the opposite side:\n```typescript\n\u002F\u002F Instead of skill.hlCloseAll() — use this:\nconst positions = await skill.getPerpPositions({ walletAddress: managedEvmAddress }); \u002F\u002F positions live on the managed wallet\nfor (const pos of positions) {\n  await skill.closePerpPosition({\n    coin: pos.coin,\n    positionAddress: managedEvmAddress,\n    apiKey,\n    walletAddress: controlAddress,  \u002F\u002F control wallet signs\n    sessionPrivateKey,\n  });\n}\n```\n\n### Leverage Is Set Per Order\n\nThe standalone `hlUpdateLeverage` \u002F `\u002Fv1\u002Fhl\u002Fupdate_leverage` endpoint returns **404**. Set leverage on the\norder instead: `hlCreateOrder({ ..., leverage: 5 })` (MCP: `open_perp_position` with `leverage`). The SDK\nsends it as a top-level field next to `computedData`, which is where the backend reads it. Omitted, HL\nuses its default (20x on most markets).\n\n### HL Signature Format\n\n```\nmessage = \"{action}-{userId.toLowerCase()}-{dataHex}\"\ndigest  = keccak256(utf8Bytes(message))\noutput  = r(64hex) + s(64hex) + v(2hex)  \u002F\u002F 130 chars total, v=00\u002F01, no 0x prefix\n```\n\nCommon signature errors:\n- Wrong `userId` (must be control wallet, lowercase)\n- Wrong `action` string (e.g., `\"hl_deposit\"` not `\"deposit\"`)\n- Leading `0x` on signature output (must be stripped)\n- Wrong `v` value (must be `00` or `01`, not `27`\u002F`28`)\n\n## Encryption Debugging\n\nAll managed-custody trades use AES-256-CBC encrypted `computedData`:\n\n```\n1. ABI-encode trade parameters → hex string (no 0x prefix)\n2. Sign: keccak256(action + userId + dataHex) → r+s+v (130 chars)\n3. Encrypt: AES-256-CBC(dataHex + signature, derivedKey, iv)\n4. POST to backend with { computedData, userId, chainId }\n```\n\n### Common Encryption Errors\n\n| Symptom | Cause | Fix |\n|---------|-------|-----|\n| `103 Unauthorized` | ABI using `uint256` when backend expects `uint64`, or vice versa | Check the exact ABI types for each endpoint — HL deposit uses `uint64`, not `uint256` |\n| `Invalid signature` | Signing with wrong key or wrong message format | Ensure session key (not control wallet key) signs the message. Check action string exactly matches. |\n| Empty response | `computedData` encrypted with wrong key | Verify AES key derivation: `SHA256(SHA256(SHA256(apiKey)))` |\n| `Reused nonce` | Same nonce value in consecutive trades | Always use fresh `Date.now()` or incrementing nonce |\n\n### AES Key Derivation\n\n```typescript\nconst key = SHA256(SHA256(SHA256(apiKey)));  \u002F\u002F 3× SHA256 hash chain\nconst iv = randomBytes(16);                  \u002F\u002F fresh IV per request\nconst encrypted = AES_CBC_encrypt(payload, key, iv);\n\u002F\u002F computedData = iv.hex + encrypted.hex (concatenated)\n```\n\n## Solana-Specific Issues\n\n### Meteora Swaps Are Broken\n\nTokens routed through Meteora DLMM (e.g., BONK) fail with `Program error: 1` because the backend doesn't wrap SOL into WSOL.\n\n**Workaround:** Use Raydium-routed tokens. Check `token.dexId`:\n- `\"raydium\"` \u002F `\"raydium_v2\"` → works\n- `\"meteora\"` → **will fail**\n- `\"orca\"` → works\n\n### ATA Creation Costs\n\nFirst trade on a new Solana token incurs ~0.007 SOL overhead:\n- ATA creation: ~0.002 SOL\n- Priority fee: ~0.0005 SOL (default)\n- Keep at least 0.01 SOL in the managed wallet for safety\n\n### Solana Managed Wallet\n\nAfter sign-in with `chainId: 622112261`, the Solana managed wallet is a **base58 address** (not hex):\n```\nCFSi4YimeCbfSNqH2WmHwJKwj1YYG1cWBtQyVPB4sCe1\n```\n\n## Copy Trade Pitfalls\n\n### `isDelete` Deletes, `isChangeStatus` Toggles\n\nOn both Solana and HyperLiquid the backend deletes only on `isDelete`; `isChangeStatus`\nflips `isActive` (`isActive = !existing.isActive`). Neither closes positions or cancels\ntheir TP\u002FSL orders. Use `pauseCopyTrade`\u002F`resumeCopyTrade`\u002F`deleteCopyTrade` (and the\n`Hl` variants), which read the current state before toggling.\n\nSDK versions up to 4.12 ABI-encoded every copy-trade field as a string. The backend\ndecodes `uint64`\u002F`bool` slots, so those versions sent `isDelete=true` on every update\n(the old \"both flags delete\" behaviour) and stored `copyMode=416\u002F480`,\n`oppositeCopy=true`. The SDK now encodes the typed ABI the backend and gdex.pro use.\n\n### Legacy Values in Responses\n\n`copyMode` 416\u002F480 and `oppositeCopy: true` in a response come from configs written by\nSDK \u003C= 4.12. Repair them with `updateHlCopyTradeSettings` and explicit values.\n\n### Max 3 HL Copy Trades\n\nThe HyperLiquid perp copy trading system allows a maximum of 3 active copy trades per user. Creating a 4th will fail.\n\n## Network Issues\n\n### Cloudflare Blocking\n\nThe GDEX backend sits behind Cloudflare. Requests without a browser-like `User-Agent` may be blocked.\n\n```typescript\n\u002F\u002F The SDK handles this automatically, but for manual requests:\nheaders: {\n  'User-Agent': 'Mozilla\u002F5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\u002F537.36',\n  'Content-Type': 'application\u002Fjson',\n  'Authorization': `Bearer ${apiKey}`,\n}\n```\n\n### Bridge Endpoint Paths\n\nBridge endpoints use non-obvious paths:\n- `GET \u002Fv1\u002Fbridge\u002Festimate_bridge` (not `\u002Fbridge\u002Festimate`)\n- `POST \u002Fv1\u002Fbridge\u002Frequest_bridge` (not `\u002Fbridge\u002Fexecute`)\n- `GET \u002Fv1\u002Fbridge\u002Fbridge_orders` (not `\u002Fbridge\u002Forders`)\n\n## Debugging Checklist\n\nWhen a trade fails, check in order:\n\n1. **Auth:** Is `loginWithApiKey()` called? Is the API key valid?\n2. **Wallet:** Are you using the **control** wallet address (not managed)?\n3. **Chain ID:** Is chain ID correct for the operation? (See table above)\n4. **Nonce:** Is the nonce fresh (`Date.now()`)?\n5. **ABI types:** Do the ABI types exactly match what the backend expects?\n6. **Signature:** Is the session key signing (not control key)? Is the message format correct?\n7. **Balance:** Does the managed wallet have enough funds + gas?\n\n## Portfolio \u002F Balances \u002F Trade History (Fixed in SDK)\n\nThe high-level methods now send what the backend reads; no raw-client workaround is needed.\n\n| Method | Backend call |\n|--------|--------------|\n| `getPortfolio({ walletAddress, sessionPrivateKey, apiKey, chain })` | `GET \u002Fv1\u002Fportfolio?userId&data&chainId` → `{ holding: [] }` |\n| `getBalances({ ..., chain, tokenAddress? })` | same read, filtered |\n| `getTradingFunds({ ..., chain })` | `GET \u002Fv1\u002Fuser?userId&data&chainId` → native `balance` |\n| `getTradeHistory({ walletAddress, chain, limit?, cursor? })` | `GET \u002Fv1\u002Fuser_history?user&chainId&limit&cursor` (no session) |\n\n- `walletAddress` \u002F `userId` is the **control** wallet; `data` is derived from the session key.\n- A refused or malformed response throws (`GdexApiError`); `[]` only means the backend reported no holdings.\n- History pages with `cursor` (= `nextCursor`), at most 50 per page; `page`\u002F`startTime`\u002F`endTime` are rejected.\n- Solana history uses the same chain id as every other Solana read (`622112261`); older notes said `900`. If a live Solana history call comes back empty, compare both.\n\n## Limit Order ABI Bug (Fixed in SDK)\n\nThe `limit_buy` and `update_order` ABI schemas encode `profitPercent` and `lossPercent` as `uint256`, NOT `string`. Using `string` type causes the backend to receive ABI byte-offsets (e.g. 192) instead of the actual percentage values, which always fails the 0-100 range validation.\n\n**Symptom:** `\"lossPercent must be between 0 and 100\"` even with valid values like `lossPercent: '25'`\n**Cause:** ABI `string` type → encoded offset (192) → fails range check\n**Fix:** SDK encodes as `uint256` (correct). Only matters if encoding manually.\n8. **Token support:** Is the token supported on this chain? Is the DEX working? (Meteora is broken)\n\n## Backend-Limited Behavior (Not SDK Bugs)\n\nThese are server-side behaviors, verified live. They are **not fixable in the SDK** — don't\nwaste a debugging loop on them. Treat the listed responses as expected.\n\n### Deposit returns HTTP 400 even when the transfer succeeds\n\n`perpDeposit` (USDC → HyperLiquid) frequently returns HTTP 400 while the on-chain transfer\n**still completes**. The error is a backend response-handling bug, not a failed deposit.\n\n**Symptom:** `perpDeposit` throws a 400, but the USDC arrives in the HL account moments later.\n**Do:** Don't retry blindly on the 400 (you'll double-deposit). Poll the HL perp balance \u002F\n`getHlAccount` to confirm before retrying. Verify state, not the HTTP status.\n\n### Outcome-market listings are controlled by the backend, not the SDK\n\nThe SDK can place\u002Fcancel\u002Fclose orders on **any** outcome market (coin format\n`#\u003CoutcomeId>\u003CsideIndex>`, e.g. `#1010` = outcome 101, Yes side), but *which* markets exist —\nand that they may currently be limited (e.g. only a BTC over\u002Funder) — is decided by the\nbackend \u002F HIP-3 deployer, not the SDK.\n\n**Symptom:** `listOutcomeMarkets` returns few\u002Flimited markets, or a `#…` coin you expect is absent.\n**Do:** Only trade markets returned by `listOutcomeMarkets` \u002F the outcome account query. An empty\nor short list is a market-config state on the backend, not a discovery bug. HIP-3\u002FHIP-4 markets\nmay also quote in non-USDC collateral (USDH\u002FUSDE\u002FUSDT0) — use `swap_collateral` first.\n\n## Related Skills\n\n- **gdex-authentication** — Full auth flow and encryption details\n- **gdex-spot-trading** — Spot trade parameters and chain support\n- **gdex-perp-trading** — HL perp specifics\n- **gdex-copy-trading** — Solana copy trade ABI format\n- **gdex-perp-copy-trading** — HL perp copy trade ABI format\n","# GDEX: SDK Debugging & Troubleshooting\n\nComprehensive troubleshooting guide for GDEX SDK errors, covering API error codes, encryption debugging, chain-specific quirks, HyperLiquid gotchas, and copy trade pitfalls. All issues documented from live E2E testing.\n\n## When to Use\n\n- Getting unexpected API errors (103, 102, TIMEOUT)\n- Trades failing silently or returning wrong data\n- Debugging encryption \u002F `computedData` payload issues\n- Chain-specific problems (wrong chainId, wrong managed wallet)\n- HyperLiquid perp issues\n- Copy trade configuration problems\n\n## API Error Codes\n\n| Code | Error | Common Cause | Fix |\n|------|-------|-------------|-----|\n| `103` | Unauthorized | Wrong `walletAddress` (using managed instead of control), wrong ABI type, signing with wrong key | Use **control wallet address** as `walletAddress` \u002F `userId`. Verify session key matches sign-in. |\n| `102` | Invalid chainId | Using wrong chainId for HL operations | HL operations require `chainId: 42161` (Arbitrum). Copy trades need specific chainIds (see below). |\n| `102` | Invalid params | Reused nonce, unsupported token, or malformed ABI payload | Check nonce is fresh (`Date.now()`). Verify token is supported on chain. |\n| `400` | Bad Request | Missing required fields or wrong field types | Check all required params are present and correctly typed. |\n| `TIMEOUT` | Request timeout | Backend processing delay (common with `hlCloseAll`) | Retry once, or use alternative approach (reduce-only order to close). |\n| `JSON parse error` | Invalid response | Backend returned non-JSON (HTML error page, Cloudflare block) | Check User-Agent header is set. Verify API key is valid. |\n\n## Critical: Control Wallet vs Managed Wallet\n\nThis is the **#1 source of errors**:\n\n```\nControl wallet:  0x53D029a671bd1CF61a2fB1F4F6e4bD830BFBb2eD  ← used for API calls (userId, walletAddress)\nManaged wallet:  0x9967179de55bd67e6b90fcc4f908556d93938c0f  ← server-side, executes trades on-chain\n```\n\n**Rule:** All API calls use the **control address** — the one you signed in with. The managed address is only used when querying on-chain state directly (e.g., `user_stats` on HL needs the managed address).\n\n> The `\u002Fv1\u002Fuser` endpoint returns a **different managed wallet per chainId**:\n> - `chainId=1` → EVM managed: `0x9967...`\n> - `chainId=622112261` → Solana managed: `CFSi4Y...` (base58)\n\n## Chain ID Gotchas\n\n| Issue | Wrong | Correct | Notes |\n|-------|-------|---------|-------|\n| Solana chain ID | `900` | `622112261` (`ChainId.SOLANA`) | `900` returns EVM managed address with `balance: null` |\n| Copy trade sign-in | `chainId: 1` | `chainId: 622112261` | Solana copy trades need Solana chainId for sign-in |\n| Perp copy trade sign-in | `chainId: 622112261` | `chainId: 1` | HL perp copy trades need EVM chainId for sign-in |\n| HL operations | Any other | `42161` (Arbitrum) | HL deposit, create order, close — all use Arbitrum chainId |\n\n## HyperLiquid-Specific Issues\n\n### `hlCloseAll` is Unreliable\n\nThe `\u002Fv1\u002Fhl\u002Fclose_all_positions` endpoint frequently returns `TIMEOUT` or JSON parse errors.\n\n**Workaround:** Close each coin with `closePerpPosition` (MCP: `close_perp_position`). It reads the live\nposition and sends a reduce-only market order for the exact size on the opposite side:\n```typescript\n\u002F\u002F Instead of skill.hlCloseAll() — use this:\nconst positions = await skill.getPerpPositions({ walletAddress: managedEvmAddress }); \u002F\u002F positions live on the managed wallet\nfor (const pos of positions) {\n  await skill.closePerpPosition({\n    coin: pos.coin,\n    positionAddress: managedEvmAddress,\n    apiKey,\n    walletAddress: controlAddress,  \u002F\u002F control wallet signs\n    sessionPrivateKey,\n  });\n}\n```\n\n### Leverage Is Set Per Order\n\nThe standalone `hlUpdateLeverage` \u002F `\u002Fv1\u002Fhl\u002Fupdate_leverage` endpoint returns **404**. Set leverage on the\norder instead: `hlCreateOrder({ ..., leverage: 5 })` (MCP: `open_perp_position` with `leverage`). The SDK\nsends it as a top-level field next to `computedData`, which is where the backend reads it. Omitted, HL\nuses its default (20x on most markets).\n\n### HL Signature Format\n\n```\nmessage = \"{action}-{userId.toLowerCase()}-{dataHex}\"\ndigest  = keccak256(utf8Bytes(message))\noutput  = r(64hex) + s(64hex) + v(2hex)  \u002F\u002F 130 chars total, v=00\u002F01, no 0x prefix\n```\n\nCommon signature errors:\n- Wrong `userId` (must be control wallet, lowercase)\n- Wrong `action` string (e.g., `\"hl_deposit\"` not `\"deposit\"`)\n- Leading `0x` on signature output (must be stripped)\n- Wrong `v` value (must be `00` or `01`, not `27`\u002F`28`)\n\n## Encryption Debugging\n\nAll managed-custody trades use AES-256-CBC encrypted `computedData`:\n\n```\n1. ABI-encode trade parameters → hex string (no 0x prefix)\n2. Sign: keccak256(action + userId + dataHex) → r+s+v (130 chars)\n3. Encrypt: AES-256-CBC(dataHex + signature, derivedKey, iv)\n4. POST to backend with { computedData, userId, chainId }\n```\n\n### Common Encryption Errors\n\n| Symptom | Cause | Fix |\n|---------|-------|-----|\n| `103 Unauthorized` | ABI using `uint256` when backend expects `uint64`, or vice versa | Check the exact ABI types for each endpoint — HL deposit uses `uint64`, not `uint256` |\n| `Invalid signature` | Signing with wrong key or wrong message format | Ensure session key (not control wallet key) signs the message. Check action string exactly matches. |\n| Empty response | `computedData` encrypted with wrong key | Verify AES key derivation: `SHA256(SHA256(SHA256(apiKey)))` |\n| `Reused nonce` | Same nonce value in consecutive trades | Always use fresh `Date.now()` or incrementing nonce |\n\n### AES Key Derivation\n\n```typescript\nconst key = SHA256(SHA256(SHA256(apiKey)));  \u002F\u002F 3× SHA256 hash chain\nconst iv = randomBytes(16);                  \u002F\u002F fresh IV per request\nconst encrypted = AES_CBC_encrypt(payload, key, iv);\n\u002F\u002F computedData = iv.hex + encrypted.hex (concatenated)\n```\n\n## Solana-Specific Issues\n\n### Meteora Swaps Are Broken\n\nTokens routed through Meteora DLMM (e.g., BONK) fail with `Program error: 1` because the backend doesn't wrap SOL into WSOL.\n\n**Workaround:** Use Raydium-routed tokens. Check `token.dexId`:\n- `\"raydium\"` \u002F `\"raydium_v2\"` → works\n- `\"meteora\"` → **will fail**\n- `\"orca\"` → works\n\n### ATA Creation Costs\n\nFirst trade on a new Solana token incurs ~0.007 SOL overhead:\n- ATA creation: ~0.002 SOL\n- Priority fee: ~0.0005 SOL (default)\n- Keep at least 0.01 SOL in the managed wallet for safety\n\n### Solana Managed Wallet\n\nAfter sign-in with `chainId: 622112261`, the Solana managed wallet is a **base58 address** (not hex):\n```\nCFSi4YimeCbfSNqH2WmHwJKwj1YYG1cWBtQyVPB4sCe1\n```\n\n## Copy Trade Pitfalls\n\n### `isDelete` Deletes, `isChangeStatus` Toggles\n\nOn both Solana and HyperLiquid the backend deletes only on `isDelete`; `isChangeStatus`\nflips `isActive` (`isActive = !existing.isActive`). Neither closes positions or cancels\ntheir TP\u002FSL orders. Use `pauseCopyTrade`\u002F`resumeCopyTrade`\u002F`deleteCopyTrade` (and the\n`Hl` variants), which read the current state before toggling.\n\nSDK versions up to 4.12 ABI-encoded every copy-trade field as a string. The backend\ndecodes `uint64`\u002F`bool` slots, so those versions sent `isDelete=true` on every update\n(the old \"both flags delete\" behaviour) and stored `copyMode=416\u002F480`,\n`oppositeCopy=true`. The SDK now encodes the typed ABI the backend and gdex.pro use.\n\n### Legacy Values in Responses\n\n`copyMode` 416\u002F480 and `oppositeCopy: true` in a response come from configs written by\nSDK \u003C= 4.12. Repair them with `updateHlCopyTradeSettings` and explicit values.\n\n### Max 3 HL Copy Trades\n\nThe HyperLiquid perp copy trading system allows a maximum of 3 active copy trades per user. Creating a 4th will fail.\n\n## Network Issues\n\n### Cloudflare Blocking\n\nThe GDEX backend sits behind Cloudflare. Requests without a browser-like `User-Agent` may be blocked.\n\n```typescript\n\u002F\u002F The SDK handles this automatically, but for manual requests:\nheaders: {\n  'User-Agent': 'Mozilla\u002F5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\u002F537.36',\n  'Content-Type': 'application\u002Fjson',\n  'Authorization': `Bearer ${apiKey}`,\n}\n```\n\n### Bridge Endpoint Paths\n\nBridge endpoints use non-obvious paths:\n- `GET \u002Fv1\u002Fbridge\u002Festimate_bridge` (not `\u002Fbridge\u002Festimate`)\n- `POST \u002Fv1\u002Fbridge\u002Frequest_bridge` (not `\u002Fbridge\u002Fexecute`)\n- `GET \u002Fv1\u002Fbridge\u002Fbridge_orders` (not `\u002Fbridge\u002Forders`)\n\n## Debugging Checklist\n\nWhen a trade fails, check in order:\n\n1. **Auth:** Is `loginWithApiKey()` called? Is the API key valid?\n2. **Wallet:** Are you using the **control** wallet address (not managed)?\n3. **Chain ID:** Is chain ID correct for the operation? (See table above)\n4. **Nonce:** Is the nonce fresh (`Date.now()`)?\n5. **ABI types:** Do the ABI types exactly match what the backend expects?\n6. **Signature:** Is the session key signing (not control key)? Is the message format correct?\n7. **Balance:** Does the managed wallet have enough funds + gas?\n\n## Portfolio \u002F Balances \u002F Trade History (Fixed in SDK)\n\nThe high-level methods now send what the backend reads; no raw-client workaround is needed.\n\n| Method | Backend call |\n|--------|--------------|\n| `getPortfolio({ walletAddress, sessionPrivateKey, apiKey, chain })` | `GET \u002Fv1\u002Fportfolio?userId&data&chainId` → `{ holding: [] }` |\n| `getBalances({ ..., chain, tokenAddress? })` | same read, filtered |\n| `getTradingFunds({ ..., chain })` | `GET \u002Fv1\u002Fuser?userId&data&chainId` → native `balance` |\n| `getTradeHistory({ walletAddress, chain, limit?, cursor? })` | `GET \u002Fv1\u002Fuser_history?user&chainId&limit&cursor` (no session) |\n\n- `walletAddress` \u002F `userId` is the **control** wallet; `data` is derived from the session key.\n- A refused or malformed response throws (`GdexApiError`); `[]` only means the backend reported no holdings.\n- History pages with `cursor` (= `nextCursor`), at most 50 per page; `page`\u002F`startTime`\u002F`endTime` are rejected.\n- Solana history uses the same chain id as every other Solana read (`622112261`); older notes said `900`. If a live Solana history call comes back empty, compare both.\n\n## Limit Order ABI Bug (Fixed in SDK)\n\nThe `limit_buy` and `update_order` ABI schemas encode `profitPercent` and `lossPercent` as `uint256`, NOT `string`. Using `string` type causes the backend to receive ABI byte-offsets (e.g. 192) instead of the actual percentage values, which always fails the 0-100 range validation.\n\n**Symptom:** `\"lossPercent must be between 0 and 100\"` even with valid values like `lossPercent: '25'`\n**Cause:** ABI `string` type → encoded offset (192) → fails range check\n**Fix:** SDK encodes as `uint256` (correct). Only matters if encoding manually.\n8. **Token support:** Is the token supported on this chain? Is the DEX working? (Meteora is broken)\n\n## Backend-Limited Behavior (Not SDK Bugs)\n\nThese are server-side behaviors, verified live. They are **not fixable in the SDK** — don't\nwaste a debugging loop on them. Treat the listed responses as expected.\n\n### Deposit returns HTTP 400 even when the transfer succeeds\n\n`perpDeposit` (USDC → HyperLiquid) frequently returns HTTP 400 while the on-chain transfer\n**still completes**. The error is a backend response-handling bug, not a failed deposit.\n\n**Symptom:** `perpDeposit` throws a 400, but the USDC arrives in the HL account moments later.\n**Do:** Don't retry blindly on the 400 (you'll double-deposit). Poll the HL perp balance \u002F\n`getHlAccount` to confirm before retrying. Verify state, not the HTTP status.\n\n### Outcome-market listings are controlled by the backend, not the SDK\n\nThe SDK can place\u002Fcancel\u002Fclose orders on **any** outcome market (coin format\n`#\u003CoutcomeId>\u003CsideIndex>`, e.g. `#1010` = outcome 101, Yes side), but *which* markets exist —\nand that they may currently be limited (e.g. only a BTC over\u002Funder) — is decided by the\nbackend \u002F HIP-3 deployer, not the SDK.\n\n**Symptom:** `listOutcomeMarkets` returns few\u002Flimited markets, or a `#…` coin you expect is absent.\n**Do:** Only trade markets returned by `listOutcomeMarkets` \u002F the outcome account query. An empty\nor short list is a market-config state on the backend, not a discovery bug. HIP-3\u002FHIP-4 markets\nmay also quote in non-USDC collateral (USDH\u002FUSDE\u002FUSDT0) — use `swap_collateral` first.\n\n## Related Skills\n\n- **gdex-authentication** — Full auth flow and encryption details\n- **gdex-spot-trading** — Spot trade parameters and chain support\n- **gdex-perp-trading** — HL perp specifics\n- **gdex-copy-trading** — Solana copy trade ABI format\n- **gdex-perp-copy-trading** — HL perp copy trade ABI format\n",{"name":5,"description":7},"main","3df1d0d67b30ff15236561f8c0f9f06d33f42dfd","skills\u002Fmcp-servers\u002Fgemachdao-gdex-sdk-debugging",17,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia","https:\u002F\u002Feth2030.com","Hardcore infra. Building @alt-research and applied cryptography.","2026-11-15 02:28:10",{"source":8,"skillName":5,"commands":50,"prompt":60,"zipAvailable":61},[51,54,57],{"tool":52,"command":53},"npx","npx skills add jiayaoqijia\u002Fcryptoskill --skill gdex-sdk-debugging",{"tool":55,"command":56},"bunx","bunx skills add jiayaoqijia\u002Fcryptoskill --skill gdex-sdk-debugging",{"tool":58,"command":59},"pnpm","pnpm dlx skills add jiayaoqijia\u002Fcryptoskill --skill gdex-sdk-debugging","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fgemachdao-gdex-sdk-debugging\u002FSKILL.md",true,[63,67,73],{"path":64,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":66,"sourceHtmlUrl":16},"LICENSE","许可证",1066,{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"SOURCE.md","REFERENCE","参考文档",347,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fgemachdao-gdex-sdk-debugging\u002FSOURCE.md",{"path":74,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":75,"sourceHtmlUrl":76},"TRUST.auto.yaml",2217,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fgemachdao-gdex-sdk-debugging\u002FTRUST.auto.yaml",[78,87,94,102,110,118],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":82,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":86},"01M7DTKCERMV0RNX3HZJP4CZ26","troves","Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say \"Troves\" explicitly.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-troves\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-troves\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":88,"name":25,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":90,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":86},"01M7DTK6CJSMGC8KCQHGNYFZBD","Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say \"swap\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-trade\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-trade\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":98,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":86},"01M7DTJZ6A0X4PAW3Y8W4J9K64","staking","Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say \"stake\" explicitly.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-staking\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-staking\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":106,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":86},"01M7DTJSDZJKCDMW7GHRF4BRH5","send","Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say \"pay 10 STRK to 0x...\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-send\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-send\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":114,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":86},"01M7DTJG1E480D51ZQ7WKDQ26K","portfolio","View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks \"what do I have\", \"show me everything\", \"how much am I worth\", \"my positions\", \"my investments\", \"rebalance my portfolio\", \"I want 50% ETH\", \"optimize my holdings\", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say \"portfolio\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-portfolio\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-portfolio\u002FSKILL.md",[],[],{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":122,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":86},"01M7DTJ7M8TE9R2N36HFBZDGVD","multi-swap","Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions \"two swaps\", \"three swaps\", \"swap X and Y at the same time\", or wants to convert multiple tokens in a single call.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-multi-swap\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-multi-swap\u002FSKILL.md",[],[]]