Skip to content

Commit

Permalink
update subgraph url for SushiV3 on Base chain
Browse files Browse the repository at this point in the history
  • Loading branch information
aburkut committed Sep 25, 2023
1 parent 52884b5 commit fcf6648
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 3 deletions.
123 changes: 122 additions & 1 deletion src/dex/balancer-v2/balancer-v2-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,113 @@ import dotenv from 'dotenv';
dotenv.config();

import { testE2E } from '../../../tests/utils-e2e';
import { Holders, Tokens } from '../../../tests/constants-e2e';
import { Holders, NativeTokenSymbols, Tokens } from '../../../tests/constants-e2e';
import { ContractMethod, Network, SwapSide } from '../../constants';
import { StaticJsonRpcProvider } from '@ethersproject/providers';

import { generateConfig } from '../../config';

jest.setTimeout(50 * 1000);

function testForNetwork(
network: Network,
dexKey: string,
tokenASymbol: string,
tokenBSymbol: string,
tokenAAmount: string,
tokenBAmount: string,
nativeTokenAmount: string,
slippage?: number | undefined,
) {
const provider = new StaticJsonRpcProvider(
generateConfig(network).privateHttpProvider,
network,
);
const tokens = Tokens[network];
const holders = Holders[network];
const nativeTokenSymbol = NativeTokenSymbols[network];

const sideToContractMethods = new Map([
[
SwapSide.SELL,
[
ContractMethod.simpleSwap,
ContractMethod.multiSwap,
ContractMethod.megaSwap,
],
],
[
SwapSide.BUY,
[
ContractMethod.simpleBuy,
ContractMethod.buy,
],
],
]);

describe(`${network}`, () => {
sideToContractMethods.forEach((contractMethods, side) =>
describe(`${side}`, () => {
contractMethods.forEach((contractMethod: ContractMethod) => {
describe(`${contractMethod}`, () => {
it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
await testE2E(
tokens[nativeTokenSymbol],
tokens[tokenASymbol],
holders[nativeTokenSymbol],
side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
side,
dexKey,
contractMethod,
network,
provider,
undefined,
undefined,
undefined,
slippage,
);
});
it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
await testE2E(
tokens[tokenASymbol],
tokens[nativeTokenSymbol],
holders[tokenASymbol],
side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
side,
dexKey,
contractMethod,
network,
provider,
undefined,
undefined,
undefined,
slippage,
);
});
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
await testE2E(
tokens[tokenASymbol],
tokens[tokenBSymbol],
holders[tokenASymbol],
side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
side,
dexKey,
contractMethod,
network,
provider,
undefined,
undefined,
undefined,
slippage,
);
});
});
});
}),
);
});
}

describe('BalancerV2 E2E', () => {
describe('BalancerV2 MAINNET', () => {
const dexKey = 'BalancerV2';
Expand Down Expand Up @@ -1195,6 +1294,28 @@ describe('BalancerV2 E2E', () => {
});
});

describe('BalancerV2 Base', () => {
const dexKey = 'BalancerV2';
const network = Network.BASE;

const tokenASymbol: string = 'USDC';
const tokenBSymbol: string = 'GOLD';

const tokenAAmount: string = '11110010';
const tokenBAmount: string = '210000000000000000000';
const nativeTokenAmount = '1000000000000000000';

testForNetwork(
network,
dexKey,
tokenASymbol,
tokenBSymbol,
tokenAAmount,
tokenBAmount,
nativeTokenAmount,
);
});

describe('BeetsFi OPTIMISM', () => {
const dexKey = 'BeetsFi';
const network = Network.OPTIMISM;
Expand Down
7 changes: 6 additions & 1 deletion src/dex/balancer-v2/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export const BalancerConfig: DexConfigMap<DexParams> = {
subgraphURL:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-avalanche-v2',
vaultAddress: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
}
},
[Network.BASE]: {
subgraphURL:
'https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest',
vaultAddress: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
},
},
BeetsFi: {
[Network.FANTOM]: {
Expand Down
2 changes: 1 addition & 1 deletion src/dex/uniswap-v3/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export const UniswapV3Config: DexConfigMap<DexParams> = {
initRetryFrequency: 10,
initHash: `0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54`,
subgraphURL:
'https://api.thegraph.com/subgraphs/name/sushi-v3/v3-base', // incorrect url
'https://api.studio.thegraph.com/query/32073/v3-base/v0.0.1',
},
},
ChronosV3: {
Expand Down
10 changes: 10 additions & 0 deletions tests/constants-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,14 @@ export const Tokens: {
address: '0x50c5725949a6f0c72e6c4a641f24049a917db0cb',
decimals: 18,
},
BAL: {
address: '0x4158734d47fc9692176b5085e0f52ee0da5d47f1',
decimals: 18,
},
GOLD: {
address: '0xbeFD5C25A59ef2C1316c5A4944931171F30Cd3E4',
decimals: 18,
},
ETH: { address: ETHER_ADDRESS, decimals: 18 },
},
};
Expand Down Expand Up @@ -1137,6 +1145,8 @@ export const Holders: {
USDC: '0xaac391f166f33cdaefaa4afa6616a3bea66b694d',
USDbC: '0xc9d05a1c3c8e01dcb701d6185cdc21a5bb94becb',
DAI: '0x20f03e26968b179025f65c1f4afadfd3959c8d03',
BAL: '0x854b004700885a61107b458f11ecc169a019b764',
GOLD: '0x1374c25b3710758c326ee0c70ec48b595d5ccf8c',
},
};

Expand Down

0 comments on commit fcf6648

Please sign in to comment.