From b9a511ddbe2496c807a1507d842b4a01fba708ec Mon Sep 17 00:00:00 2001 From: ReflectiveChimp <55021052+ReflectiveChimp@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:03:33 +0100 Subject: [PATCH] fix for native (#1513) --- src/api/zap/proxy/common.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/zap/proxy/common.ts b/src/api/zap/proxy/common.ts index 3a6321331..275f43c43 100644 --- a/src/api/zap/proxy/common.ts +++ b/src/api/zap/proxy/common.ts @@ -1,5 +1,5 @@ import Koa from 'koa'; -import { getTokenByAddress } from '../../tokens/tokens'; +import { getTokenByAddress, getTokenNative } from '../../tokens/tokens'; import { AnyChain, ApiChain, toApiChain } from '../../../utils/chain'; import { getAmmPrice } from '../../stats/getAmmPrices'; import { fromWeiString } from '../../../utils/big-number'; @@ -7,6 +7,7 @@ import { fromWeiString } from '../../../utils/big-number'; const MIN_QUOTE_VALUE: Partial> = { optimism: 5, }; +const NATIVE_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'; export function setNoCacheHeaders(ctx: Koa.Context) { ctx.set('Cache-Control', 'no-store, no-cache, must-revalidate'); @@ -25,7 +26,10 @@ export async function isQuoteValueTooLow( return undefined; } - const srcToken = getTokenByAddress(inputAddress, apiChainId); + const srcToken = + inputAddress.toLowerCase() === NATIVE_ADDRESS.toLowerCase() + ? getTokenNative(apiChainId) + : getTokenByAddress(inputAddress, apiChainId); if (!srcToken) { return { code: 400,