From efb9ae6cae58f4c672f95d5cd8f895774a2fcdf4 Mon Sep 17 00:00:00 2001 From: johngrantuk Date: Tue, 1 Aug 2023 13:32:22 +0100 Subject: [PATCH] Add example for avax. --- test/lib/subgraphPoolDataService.ts | 1 + test/testScripts/constants.ts | 31 +++++++++++++++++++++++++++++ test/testScripts/swapExample.ts | 8 ++++---- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/test/lib/subgraphPoolDataService.ts b/test/lib/subgraphPoolDataService.ts index 23e3ebc1..5c38735e 100644 --- a/test/lib/subgraphPoolDataService.ts +++ b/test/lib/subgraphPoolDataService.ts @@ -125,6 +125,7 @@ export const Query: { [chainId: number]: string } = { 42161: queryWithLinear, 100: queryWithLinear, 1101: queryWithLinear, + 43114: queryWithLinear, }; export class SubgraphPoolDataService implements PoolDataService { diff --git a/test/testScripts/constants.ts b/test/testScripts/constants.ts index ebe97f6b..ad663f8e 100644 --- a/test/testScripts/constants.ts +++ b/test/testScripts/constants.ts @@ -9,6 +9,7 @@ export enum Network { OPTIMISM = 10, GNOSIS = 100, ZKEVM = 1101, + AVALANCHE = 43114, } export const SOR_CONFIG: Record = { @@ -125,6 +126,11 @@ export const SOR_CONFIG: Record = { }, ], }, + [Network.AVALANCHE]: { + chainId: Network.AVALANCHE, + vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', + weth: '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7', + }, }; export const PROVIDER_URLS = { @@ -134,6 +140,7 @@ export const PROVIDER_URLS = { [Network.ARBITRUM]: process.env.RPC_URL_ARBITRUM, [Network.GNOSIS]: process.env.RPC_URL_GNOSIS, [Network.ZKEVM]: process.env.RPC_URL_ZKEVM, + [Network.AVALANCHE]: process.env.RPC_URL_AVALANCHE, }; export const MULTIADDR: { [chainId: number]: string } = { @@ -147,6 +154,7 @@ export const MULTIADDR: { [chainId: number]: string } = { 99: '0xeefba1e63905ef1d7acba5a8513c70307c1ce441', 100: '0xbb6fab6b627947dae0a75808250d8b2652952cb5', 1101: '0xca11bde05977b3631167028862be2a173976ca11', + 43114: '0xcA11bde05977b3631167028862bE2a173976CA11', }; export const SUBGRAPH_URLS = { @@ -159,6 +167,7 @@ export const SUBGRAPH_URLS = { [Network.ARBITRUM]: `https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-arbitrum-v2`, [Network.GNOSIS]: `https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gnosis-chain-v2`, [Network.ZKEVM]: `https://api.studio.thegraph.com/query/24660/balancer-polygon-zk-v2/version/latest`, + [Network.AVALANCHE]: `https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-avalanche-v2`, }; // This is the same across networks @@ -315,6 +324,11 @@ export const ADDRESSES = { decimals: 2, symbol: 'EURS', }, + swETH: { + address: '0xf951e335afb289353dc249e82926178eac7ded78', + decimals: 18, + symbol: 'swETH', + }, }, [Network.POLYGON]: { MATIC: { @@ -501,4 +515,21 @@ export const ADDRESSES = { symbol: 'USDC', }, }, + [Network.AVALANCHE]: { + EUROC: { + address: '0xC891EB4cbdEFf6e073e859e987815Ed1505c2ACD', + decimals: 6, + symbol: 'EUROC', + }, + USDC: { + address: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', + decimals: 6, + symbol: 'USDC', + }, + STETH: { + address: 'TOD', + decimals: 6, + symbol: 'stETH', + }, + }, }; diff --git a/test/testScripts/swapExample.ts b/test/testScripts/swapExample.ts index 58d4d8b6..7d242a2b 100644 --- a/test/testScripts/swapExample.ts +++ b/test/testScripts/swapExample.ts @@ -58,17 +58,17 @@ function setUp(networkId: Network, provider: JsonRpcProvider): SOR { } export async function swap(): Promise { - const networkId = Network.MAINNET; + const networkId = Network.AVALANCHE; const provider = new JsonRpcProvider(PROVIDER_URLS[networkId]); // gasPrice is used by SOR as a factor to determine how many pools to swap against. // i.e. higher cost means more costly to trade against lots of different pools. const gasPrice = BigNumber.from('14000000000'); // This determines the max no of pools the SOR will use to swap. const maxPools = 4; - const tokenIn = ADDRESSES[networkId].DAI; - const tokenOut = ADDRESSES[networkId].USDC; + const tokenIn = ADDRESSES[networkId].USDC; + const tokenOut = ADDRESSES[networkId].EUROC; const swapType: SwapTypes = SwapTypes.SwapExactIn; - const swapAmount = parseFixed('100', 18); + const swapAmount = parseFixed('10', 6); const sor = setUp(networkId, provider);