From db2c027d47fe8cccd28f6cac413a896ff30152b6 Mon Sep 17 00:00:00 2001 From: Florent Tapponnier <160007691+Flotapponnier@users.noreply.github.com> Date: Wed, 26 Aug 2026 16:04:35 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20GMX=20live=20rate=20=E2=80=94=20filter?= =?UTF-8?q?=20to=20USDC=20collateral=20only=20(non-USDC=20decimals=20break?= =?UTF-8?q?=20/1e6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/fee-compare/route.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/app/api/fee-compare/route.ts b/src/app/api/fee-compare/route.ts index 7155a649..b68fa1f8 100644 --- a/src/app/api/fee-compare/route.ts +++ b/src/app/api/fee-compare/route.ts @@ -241,9 +241,19 @@ async function fetchEdgeXRate(): Promise<{ rate: number; note: string }> { async function fetchGmxLiveRate(): Promise<{ rate: number; note: string }> { const cached = rateCache["gmx-v2"]; if (cached && Date.now() - cached.ts < RATE_CACHE_TTL_MS) return cached; + // Filter to USDC-collateral only: other tokens have different decimals, + // making positionFeeAmount/1e6 astronomically wrong. const query = `{ tradeActions( - where: { positionFeeAmount_isNull: false sizeDeltaUsd_gt: "0" orderType_in: [2, 3, 4] } + where: { + positionFeeAmount_isNull: false + sizeDeltaUsd_gt: "0" + orderType_in: [2, 3, 4] + initialCollateralTokenAddress_in: [ + "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", + "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8" + ] + } orderBy: timestamp_DESC limit: 50 ) { sizeDeltaUsd positionFeeAmount } @@ -373,6 +383,10 @@ async function fetchGmxTrades(wallet: string): Promise { positionFeeAmount_isNull: false sizeDeltaUsd_gt: "0" orderType_in: [2, 3, 4] + initialCollateralTokenAddress_in: [ + "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", + "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8" + ] } orderBy: timestamp_DESC limit: 200