Skip to content

Commit

Permalink
fix: routing for native currency on harmony
Browse files Browse the repository at this point in the history
  • Loading branch information
nick8319 committed Aug 25, 2023
1 parent b4e66f4 commit 3bbd05b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions src/state/routing/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export enum SwapRouterNativeAssets {
BNB = 'BNB',
AVAX = 'AVAX',
ETH = 'ETH',
ONE = 'ONE',
}

export enum URAQuoteType {
Expand Down
3 changes: 2 additions & 1 deletion src/state/routing/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3bbd05b

Please sign in to comment.