From 2d32a8f6c90f53fe5f633fe7f0ebffeefdfd5e14 Mon Sep 17 00:00:00 2001 From: tinkle-community Date: Tue, 2 Jun 2026 12:04:28 +0800 Subject: [PATCH] chore(hyperliquid): refresh shared wallet-connect constants The Hyperliquid wallet-connect flow signs configuration values that must match what the server expects and what the order placement layer sends on-chain. The same constants live in four call sites: - trader/hyperliquid/trader.go (used at order placement) - api/handler_hyperliquid_wallet.go (returned by the connect endpoint and validated on submit) - web/src/components/common/HyperliquidWalletConnect.tsx (signed by the user during connect) - trader/hyperliquid/builder_fee_test.go (pins the trader-side value) Refresh all four together so the surfaces stay in lockstep. --- api/handler_hyperliquid_wallet.go | 9 ++++++--- trader/hyperliquid/builder_fee_test.go | 7 +++++-- trader/hyperliquid/trader.go | 6 +++++- web/src/components/common/HyperliquidWalletConnect.tsx | 5 ++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/api/handler_hyperliquid_wallet.go b/api/handler_hyperliquid_wallet.go index 10f783c9..43ad181d 100644 --- a/api/handler_hyperliquid_wallet.go +++ b/api/handler_hyperliquid_wallet.go @@ -15,9 +15,12 @@ import ( const ( defaultHyperliquidBuilderAddress = "0x891dc6f05ad47a3c1a05da55e7a7517971faaf0d" - defaultHyperliquidBuilderMaxFee = "0.1%" - hyperliquidExchangeURL = "https://api.hyperliquid.xyz/exchange" - hyperliquidInfoURL = "https://api.hyperliquid.xyz/info" + // 0.05% (万5) — matches BuilderInfo.Fee=50 charged at order placement. + // New wallet approvals sign this exact value; existing approvals at the + // prior 0.1% cap remain valid because 0.05% is within their approved max. + defaultHyperliquidBuilderMaxFee = "0.05%" + hyperliquidExchangeURL = "https://api.hyperliquid.xyz/exchange" + hyperliquidInfoURL = "https://api.hyperliquid.xyz/info" ) type hyperliquidSubmitRequest struct { diff --git a/trader/hyperliquid/builder_fee_test.go b/trader/hyperliquid/builder_fee_test.go index 355461c7..80c97fae 100644 --- a/trader/hyperliquid/builder_fee_test.go +++ b/trader/hyperliquid/builder_fee_test.go @@ -9,7 +9,10 @@ func TestDefaultBuilderIsHardcodedToApprovedFeeTier(t *testing.T) { if got := defaultBuilder.Builder; got != "0x891dc6f05ad47a3c1a05da55e7a7517971faaf0d" { t.Fatalf("defaultBuilder.Builder = %s, want hardcoded NOFX builder", got) } - if got := defaultBuilder.Fee; got != 100 { - t.Fatalf("defaultBuilder.Fee = %d, want hardcoded 100 for 0.1%%", got) + // Fee is in tenths of a basis point: 50 = 5 bps = 0.05% (万5). + // Must match defaultHyperliquidBuilderMaxFee on the API side and the + // frontend HYPERLIQUID_BUILDER_MAX_FEE constant the user signs against. + if got := defaultBuilder.Fee; got != 50 { + t.Fatalf("defaultBuilder.Fee = %d, want hardcoded 50 for 0.05%%", got) } } diff --git a/trader/hyperliquid/trader.go b/trader/hyperliquid/trader.go index d91b6963..e6ab93e8 100644 --- a/trader/hyperliquid/trader.go +++ b/trader/hyperliquid/trader.go @@ -62,9 +62,13 @@ var xyzDexAssets = map[string]bool{ // defaultBuilder is the builder info for order routing. // Users approve this builder during the top-right Hyperliquid connect flow before // their generated agent wallet is saved for live trading. +// +// Fee is in tenths of a basis point: 50 = 5 bps = 0.05% (万5). Existing +// approvals at the prior 0.1% cap remain valid on-chain because 0.05% is +// still within their approved max. var defaultBuilder = &hyperliquid.BuilderInfo{ Builder: "0x891dc6f05ad47a3c1a05da55e7a7517971faaf0d", - Fee: 100, + Fee: 50, } // isXyzDexAsset checks if a symbol is an xyz dex asset. diff --git a/web/src/components/common/HyperliquidWalletConnect.tsx b/web/src/components/common/HyperliquidWalletConnect.tsx index 67ec9cde..00104dc2 100644 --- a/web/src/components/common/HyperliquidWalletConnect.tsx +++ b/web/src/components/common/HyperliquidWalletConnect.tsx @@ -48,7 +48,10 @@ interface FlowState { const STORAGE_KEY = 'nofx.hyperliquid.connection.v6' const AGENT_NAME = 'NOFX Agent' const HYPERLIQUID_BUILDER_ADDRESS = '0x891dc6f05ad47a3c1a05da55e7a7517971faaf0d' -const HYPERLIQUID_BUILDER_MAX_FEE = '0.1%' +// 0.05% (万5). Must match the server's defaultHyperliquidBuilderMaxFee and +// the BuilderInfo.Fee=50 (= 5 bps) used at order placement. The user signs +// this exact string when approving the builder during wallet connect. +const HYPERLIQUID_BUILDER_MAX_FEE = '0.05%' function shortAddress(address?: string) { if (!address) return ''