Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example for avax. #408

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/lib/subgraphPoolDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const Query: { [chainId: number]: string } = {
42161: queryWithLinear,
100: queryWithLinear,
1101: queryWithLinear,
43114: queryWithLinear,
};

export class SubgraphPoolDataService implements PoolDataService {
Expand Down
31 changes: 31 additions & 0 deletions test/testScripts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export enum Network {
OPTIMISM = 10,
GNOSIS = 100,
ZKEVM = 1101,
AVALANCHE = 43114,
}

export const SOR_CONFIG: Record<Network, SorConfig> = {
Expand Down Expand Up @@ -125,6 +126,11 @@ export const SOR_CONFIG: Record<Network, SorConfig> = {
},
],
},
[Network.AVALANCHE]: {
chainId: Network.AVALANCHE,
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
weth: '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7',
},
};

export const PROVIDER_URLS = {
Expand All @@ -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 } = {
Expand All @@ -147,6 +154,7 @@ export const MULTIADDR: { [chainId: number]: string } = {
99: '0xeefba1e63905ef1d7acba5a8513c70307c1ce441',
100: '0xbb6fab6b627947dae0a75808250d8b2652952cb5',
1101: '0xca11bde05977b3631167028862be2a173976ca11',
43114: '0xcA11bde05977b3631167028862bE2a173976CA11',
};

export const SUBGRAPH_URLS = {
Expand All @@ -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
Expand Down Expand Up @@ -315,6 +324,11 @@ export const ADDRESSES = {
decimals: 2,
symbol: 'EURS',
},
swETH: {
address: '0xf951e335afb289353dc249e82926178eac7ded78',
decimals: 18,
symbol: 'swETH',
},
},
[Network.POLYGON]: {
MATIC: {
Expand Down Expand Up @@ -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',
},
},
};
8 changes: 4 additions & 4 deletions test/testScripts/swapExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ function setUp(networkId: Network, provider: JsonRpcProvider): SOR {
}

export async function swap(): Promise<void> {
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);

Expand Down
Loading