Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Remove local native currency
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongeric committed Mar 28, 2024
1 parent 8ebb18f commit 1c2b538
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
28 changes: 2 additions & 26 deletions src/utils/routerTradeAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { MixedRouteSDK, Trade as RouterTrade } from '@uniswap/router-sdk'
import {
ChainId,
Currency,
CurrencyAmount,
Ether,
NativeCurrency as SdkNativeCurrency,
Token,
TradeType,
} from '@uniswap/sdk-core'
import { Pair, Route as V2Route } from '@uniswap/v2-sdk'
import { Pool, Route as V3Route, FeeAmount } from '@uniswap/v3-sdk'
import { BigNumber } from 'ethers'
import { ETH_ADDRESS, E_ETH_ADDRESS, WRAPPED_NATIVE_CURRENCY } from './constants'
import { ETH_ADDRESS, E_ETH_ADDRESS } from './constants'

export type TokenInRoute = {
address: string
Expand Down Expand Up @@ -168,7 +166,7 @@ export class RouterTradeAdapter {

private static toCurrency(isNative: boolean, token: TokenInRoute): Currency {
if (isNative) {
return new NativeCurrency(token.chainId, parseInt(token.decimals))
return Ether.onChain(token.chainId)
}
return this.toToken(token)
}
Expand Down Expand Up @@ -216,25 +214,3 @@ export class RouterTradeAdapter {
return route.every((pool) => pool.type === type)
}
}

export class NativeCurrency extends SdkNativeCurrency {
constructor(chainId: ChainId, decimals: number, symbol?: string, name?: string) {
if (chainId === ChainId.MAINNET) {
return Ether.onChain(chainId)
}
super(chainId, decimals, symbol, name)
}

equals(currency: Currency): boolean {
return currency.isNative && currency.chainId === this.chainId
}

get wrapped(): Token {
const wrapped = WRAPPED_NATIVE_CURRENCY[this.chainId as ChainId]
if (!wrapped) {
throw new Error('unsupported chain')
}

return wrapped
}
}
2 changes: 1 addition & 1 deletion test/forge/interop.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,4 @@
"calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030b000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000003eb3459f0ce6ae000b00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f46b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000",
"value": "1000000000000000000"
}
}
}

0 comments on commit 1c2b538

Please sign in to comment.