Skip to content

Commit

Permalink
Merge pull request paraswap#440 from paraswap/aburkut/back-1189-uni-v…
Browse files Browse the repository at this point in the history
…3-avalanche

BACK-1189: add UniswapV3 on Avalanche
  • Loading branch information
mwamedacen authored Jul 15, 2023
2 parents fccf3bc + 6d5bd4c commit 9ab6247
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@paraswap/dex-lib",
"version": "2.23.4",
"version": "2.24.0",
"main": "build/index.js",
"types": "build/index.d.ts",
"repository": "https://github.com/paraswap/paraswap-dex-lib",
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ const baseConfigs: { [network: number]: BaseConfig } = {
process.env[`HASHFLOW_DISABLED_MMS_43114`]?.split(',') || [],
adapterAddresses: {
AvalancheAdapter01: '0x745Ec73855CeC7249E5fF4c9DD81cc65b4D297a9',
AvalancheAdapter02: '0xa003dFBA51C9e1e56C67ae445b852bdEd7aC5EEd',
AvalancheBuyAdapter: '0xfa072107a2CCfE5664794282EF36400735ABB70F',
AvalancheAdapter02: '0xDCf4EE5B700e2a5Fec458e06B763A4a3E3004494',
AvalancheBuyAdapter: '0xeBF40A40CA3D4310Bf53048F48e860656e1D7C81',
},
uniswapV2ExchangeRouterAddress:
'0x53e693c6C7FFC4446c53B205Cf513105Bf140D7b',
Expand Down
16 changes: 16 additions & 0 deletions src/dex/uniswap-v3/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ export const UniswapV3Config: DexConfigMap<DexParams> = {
subgraphURL:
'https://api.thegraph.com/subgraphs/name/ianlapham/optimism-post-regenesis',
},
[Network.AVALANCHE]: {
factory: '0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD',
quoter: '0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F',
router: '0x33895c09a0ec0718ce66ab35dfd0b656d77cd053',
supportedFees: SUPPORTED_FEES,
stateMulticall: '0x30F6B9b6485ff0B67E881f5ac80D3F1c70A4B23d',
uniswapMulticall: '0x0139141Cd4Ee88dF3Cdb65881D411bAE271Ef0C2',
chunksCount: 10,
initHash: `0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54`,
subgraphURL:
'https://api.thegraph.com/subgraphs/name/lynnshaoyu/uniswap-v3-avax',
},
},
};

Expand Down Expand Up @@ -113,4 +125,8 @@ export const Adapters: Record<number, AdapterMappings> = {
[SwapSide.SELL]: [{ name: 'FantomAdapter01', index: 11 }],
[SwapSide.BUY]: [{ name: 'FantomBuyAdapter', index: 3 }],
},
[Network.AVALANCHE]: {
[SwapSide.SELL]: [{ name: 'AvalancheAdapter02', index: 5 }],
[SwapSide.BUY]: [{ name: 'AvalancheBuyAdapter', index: 6 }],
}
};
86 changes: 86 additions & 0 deletions src/dex/uniswap-v3/uniswap-v3-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,90 @@ describe('UniswapV3 E2E', () => {
}),
);
});

describe('UniswapV3 Avalanche', () => {
const network = Network.AVALANCHE;
const tokens = Tokens[network];
const holders = Holders[network];
const provider = new StaticJsonRpcProvider(
generateConfig(network).privateHttpProvider,
network,
);

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

const pairs: { name: string; sellAmount: string, buyAmount: string }[][] = [
[
{ name: 'AVAX', sellAmount: '1000000000000000000', buyAmount: '500000', },
{ name: 'USDT', sellAmount: '1000000', buyAmount: '10000000000000000000', },
],
[
{ name: 'AVAX', sellAmount: '1000000000000000000', buyAmount: '500000', },
{ name: 'USDC', sellAmount: '1000000', buyAmount: '1000000000000000000', },
],
[
{ name: 'WAVAX', sellAmount: '1000000000000000000', buyAmount: '500000', },
{ name: 'USDC', sellAmount: '1000000', buyAmount: '20000000000000000', },
],
[
{ name: 'WAVAX', sellAmount: '1000000000000000000', buyAmount: '10000000', },
{ name: 'USDT', sellAmount: '1000000', buyAmount: '2000000000000', },
],
[
{ name: 'USDC', sellAmount: '1000000', buyAmount: '100000000', },
{ name: 'USDT', sellAmount: '100000000', buyAmount: '100000000', },
],
];

sideToContractMethods.forEach((contractMethods, side) =>
describe(`${side}`, () => {
contractMethods.forEach((contractMethod: ContractMethod) => {
pairs.forEach(pair => {
describe(`${contractMethod}`, () => {
it(`${pair[0].name} -> ${pair[1].name}`, async () => {
await testE2E(
tokens[pair[0].name],
tokens[pair[1].name],
holders[pair[0].name],
side === SwapSide.SELL
? pair[0].sellAmount
: pair[0].buyAmount,
side,
dexKey,
contractMethod,
network,
provider,
);
});
it(`${pair[1].name} -> ${pair[0].name}`, async () => {
await testE2E(
tokens[pair[1].name],
tokens[pair[0].name],
holders[pair[1].name],
side === SwapSide.SELL
? pair[1].sellAmount
: pair[1].buyAmount,
side,
dexKey,
contractMethod,
network,
provider,
);
});
});
});
});
}),
);
});
});

0 comments on commit 9ab6247

Please sign in to comment.