Repository navigation
feat(hyperliquid-mcp): hl_swap β convert USDH, USDT0 or USDE into USDC - #170
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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}toPOST /api/runtime/hyperliquid/swapand 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):pnpm buildgreen;hl_swappresent indist/mcp/hyperliquid/server.js.π€ Generated with Claude Code