From 755af3a8d20b2ed4a6ffca67803ea0d15d27d229 Mon Sep 17 00:00:00 2001 From: isreallee82 Date: Tue, 21 May 2024 03:34:03 +0100 Subject: [PATCH] (refactor) Uniswap_avalanche on avalanche chain --- src/connectors/uniswap/uniswap.config.ts | 10 ++++++++++ src/connectors/uniswap/uniswap.ts | 5 ++++- src/templates/ethereum.yml | 7 ------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/connectors/uniswap/uniswap.config.ts b/src/connectors/uniswap/uniswap.config.ts index a117548b01..70acb151ba 100644 --- a/src/connectors/uniswap/uniswap.config.ts +++ b/src/connectors/uniswap/uniswap.config.ts @@ -54,6 +54,16 @@ export namespace UniswapConfig { ).includes(network), ), }, + { + chain: 'avalanche', + networks: Object.keys( + ConfigManagerV2.getInstance().get('uniswap.contractAddresses'), + ).filter((network) => + Object.keys( + ConfigManagerV2.getInstance().get('avalanche.networks'), + ).includes(network), + ), + }, { chain: 'polygon', networks: Object.keys( diff --git a/src/connectors/uniswap/uniswap.ts b/src/connectors/uniswap/uniswap.ts index 936420d11b..4df21b9f85 100644 --- a/src/connectors/uniswap/uniswap.ts +++ b/src/connectors/uniswap/uniswap.ts @@ -36,13 +36,14 @@ import { import { logger } from '../../services/logger'; import { percentRegexp } from '../../services/config-manager-v2'; import { Ethereum } from '../../chains/ethereum/ethereum'; +import { Avalanche } from '../../chains/avalanche/avalanche'; import { Polygon } from '../../chains/polygon/polygon'; import { ExpectedTrade, Uniswapish } from '../../services/common-interfaces'; import { getAddress } from 'ethers/lib/utils'; export class Uniswap implements Uniswapish { private static _instances: { [name: string]: Uniswap }; - private chain: Ethereum | Polygon; + private chain: Ethereum | Polygon | Avalanche; private _alphaRouter: AlphaRouter; private _router: string; private _v3Factory: string; @@ -61,6 +62,8 @@ export class Uniswap implements Uniswapish { const config = UniswapConfig.config; if (chain === 'ethereum') { this.chain = Ethereum.getInstance(network); + } else if (chain === 'avalanche') { + this.chain = Avalanche.getInstance(network); } else { this.chain = Polygon.getInstance(network); } diff --git a/src/templates/ethereum.yml b/src/templates/ethereum.yml index abaa35a2f8..56b7512f06 100644 --- a/src/templates/ethereum.yml +++ b/src/templates/ethereum.yml @@ -12,13 +12,6 @@ networks: tokenListType: FILE tokenListSource: /home/gateway/conf/lists/arbitrum_rinkeby_tokens.json nativeCurrencySymbol: ETH - avalanche: - chainID: 43114 - nodeURL: https://rpc.ankr.com/avalanche - tokenListType: FILE - tokenListSource: /home/gateway/conf/lists/avalanche_tokens.json - nativeCurrencySymbol: AVAX - gasPriceRefreshInterval: 60 mainnet: chainID: 1 nodeURL: https://rpc.ankr.com/eth