Skip to content

Commit

Permalink
Merge pull request #409 from balancer/develop
Browse files Browse the repository at this point in the history
Release 4.1.1-beta.15
  • Loading branch information
John Grant authored Aug 1, 2023
2 parents a836829 + a987fb3 commit b1c50f1
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@balancer-labs/sor",
"version": "4.1.1-beta.14",
"version": "4.1.1-beta.15",
"license": "GPL-3.0-only",
"main": "dist/index.js",
"module": "dist/index.esm.js",
Expand Down
5 changes: 3 additions & 2 deletions src/pools/xaveFxPool/fxPoolMath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ interface ReservesInNumeraire {

const isUSDC = (address: string) => {
if (
address == '0x2791bca1f2de4661ed88a30c99a7a9449aa84174' ||
address == '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
address == '0x2791bca1f2de4661ed88a30c99a7a9449aa84174' || // Polygon
address == '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' || // Mainnet
address == '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E' // AVAX
) {
return true;
} else {
Expand Down
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

0 comments on commit b1c50f1

Please sign in to comment.