Skip to content

feat(hyperliquid-mcp): hl_swap β€” convert USDH, USDT0 or USDE into USDC - #170

Merged
cryptolir merged 2 commits into
mainfrom
feat/hl-swap-tool
Sep 29, 2026
Merged

cryptolir merged 2 commits into
mainfrom
feat/hl-swap-tool

Conversation

@cryptolir

Copy link
Copy Markdown
Owner

Adds hl_swap: convert a stablecoin held on spot β€” USDH, USDT0 or USDE β€” into USDC so it can back perp trades.

Why. The integration is perps-only, so an agent funded in any dollar coin other than USDC could read the balance but never use it. The pilot account held 123.27 USDH against 23.16 USDC.

This side is thin on purpose. The tool passes exactly {from, amount} to POST /api/runtime/hyperliquid/swap and adds nothing. Everything that makes the swap narrow lives on the runtime (companion dashboard PR): the coin allowlist, the fixed USDC target, the sell side, and the 0.99 price floor.

Tests (tools.test.ts, 6 pass):

  • invented arguments β€” a target, a price, a side β€” never reach the runtime
  • the schema advertises only the three coins
  • a missing coin or amount throws before any call

pnpm build green; hl_swap present in dist/mcp/hyperliquid/server.js.

πŸ€– Generated with Claude Code

Liran Peretz and others added 2 commits September 29, 2026 11:52
Perp margin is USDC. An agent funded in another dollar coin had money it
could see but never use: the integration is perps-only, and no tool could
touch spot. The pilot account held 123.27 USDH against 23.16 USDC β€” 84%
of its balance stranded.

hl_swap is the one spot action, and it is narrow by construction on the
runtime side (openclaw-dashboard): three hand-picked coins in, USDC out,
never below 0.99 USDC per coin, sell-side IOC so nothing rests. This tool
passes exactly {from, amount} through and adds nothing β€” tests pin that
invented arguments (a target, a price, a side) never reach the runtime.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The exchange values an order at its limit price. At the 0.99 floor, 10
coins is $9.90 β€” under Hyperliquid\x27s $10 minimum β€” so a swap of exactly 10
would always be rejected. 11 clears it ($10.89).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cryptolir
cryptolir merged commit 897b4aa into main Sep 29, 2026
18 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant