From 3bbd05baa27dd590cb53858ec325a6c1f57c2ab2 Mon Sep 17 00:00:00 2001 From: nick8319 Date: Fri, 25 Aug 2023 16:19:24 +0200 Subject: [PATCH] fix: routing for native currency on harmony --- src/constants/tokens.ts | 2 +- src/state/routing/types.ts | 1 + src/state/routing/utils.ts | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/constants/tokens.ts b/src/constants/tokens.ts index 6d16f312d78..30e0d4950e7 100644 --- a/src/constants/tokens.ts +++ b/src/constants/tokens.ts @@ -489,7 +489,7 @@ class BscNativeCurrency extends NativeCurrency { } } -function isHarmony(chainId: number): chainId is ChainId.HARMONY { +export function isHarmony(chainId: number): chainId is ChainId.HARMONY { return chainId === ChainId.HARMONY } diff --git a/src/state/routing/types.ts b/src/state/routing/types.ts index 0f5c9bc92a1..675a4363b55 100644 --- a/src/state/routing/types.ts +++ b/src/state/routing/types.ts @@ -276,6 +276,7 @@ export enum SwapRouterNativeAssets { BNB = 'BNB', AVAX = 'AVAX', ETH = 'ETH', + ONE = 'ONE', } export enum URAQuoteType { diff --git a/src/state/routing/utils.ts b/src/state/routing/utils.ts index 2f2664d59c2..fef629b5842 100644 --- a/src/state/routing/utils.ts +++ b/src/state/routing/utils.ts @@ -7,7 +7,7 @@ import { Pair, Route as V2Route } from '@uniswap/v2-sdk' import { FeeAmount, Pool, Route as V3Route } from '@uniswap/v3-sdk' import { asSupportedChain } from 'constants/chains' import { RPC_PROVIDERS } from 'constants/providers' -import { isAvalanche, isBsc, isMatic, nativeOnChain } from 'constants/tokens' +import { isAvalanche, isBsc, isMatic, isHarmony, nativeOnChain } from 'constants/tokens' import { toSlippagePercent } from 'utils/slippage' import { getApproveInfo, getWrapInfo } from './gas' @@ -307,6 +307,7 @@ export function isExactInput(tradeType: TradeType): boolean { export function currencyAddressForSwapQuote(currency: Currency): string { if (currency.isNative) { + if (isHarmony(currency.chainId)) return SwapRouterNativeAssets.ONE if (isMatic(currency.chainId)) return SwapRouterNativeAssets.MATIC if (isBsc(currency.chainId)) return SwapRouterNativeAssets.BNB if (isAvalanche(currency.chainId)) return SwapRouterNativeAssets.AVAX