@paraswap/dex-lib 2.35.3-quick-perps-proxy.2 → 2.35.3-quick-perps-proxy.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/build/abi/aerodrome/aerodrome-pool-factory.json +586 -0
  2. package/build/config.js +39 -13
  3. package/build/config.js.map +1 -1
  4. package/build/constants.d.ts +2 -1
  5. package/build/constants.js +1 -0
  6. package/build/constants.js.map +1 -1
  7. package/build/dex/balancer-v2/config.js +10 -2
  8. package/build/dex/balancer-v2/config.js.map +1 -1
  9. package/build/dex/generic-rfq/generic-rfq.d.ts +2 -1
  10. package/build/dex/generic-rfq/generic-rfq.js +5 -4
  11. package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
  12. package/build/dex/index.js +2 -0
  13. package/build/dex/index.js.map +1 -1
  14. package/build/dex/maverick-v1/config.js +9 -0
  15. package/build/dex/maverick-v1/config.js.map +1 -1
  16. package/build/dex/maverick-v1/maverick-v1.js +11 -2
  17. package/build/dex/maverick-v1/maverick-v1.js.map +1 -1
  18. package/build/dex/pancakeswap-v3/config.js +17 -0
  19. package/build/dex/pancakeswap-v3/config.js.map +1 -1
  20. package/build/dex/solidly/config.js +22 -1
  21. package/build/dex/solidly/config.js.map +1 -1
  22. package/build/dex/solidly/forks-override/aerodrome.d.ts +14 -0
  23. package/build/dex/solidly/forks-override/aerodrome.js +48 -0
  24. package/build/dex/solidly/forks-override/aerodrome.js.map +1 -0
  25. package/build/dex/solidly/solidly.js +1 -0
  26. package/build/dex/solidly/solidly.js.map +1 -1
  27. package/build/dex/uniswap-v3/config.js +29 -1
  28. package/build/dex/uniswap-v3/config.js.map +1 -1
  29. package/build/dex/weth/config.js +3 -0
  30. package/build/dex/weth/config.js.map +1 -1
  31. package/build/dex/woo-fi-v2/config.js +13 -0
  32. package/build/dex/woo-fi-v2/config.js.map +1 -1
  33. package/build/dex-helper/dummy-dex-helper.js +4 -1
  34. package/build/dex-helper/dummy-dex-helper.js.map +1 -1
  35. package/build/stateful-event-subscriber.d.ts +0 -1
  36. package/build/stateful-event-subscriber.js +2 -12
  37. package/build/stateful-event-subscriber.js.map +1 -1
  38. package/build/workers.d.ts +0 -0
  39. package/build/workers.js +2 -0
  40. package/build/workers.js.map +1 -0
  41. package/package.json +1 -1
  42. package/src/abi/aerodrome/aerodrome-pool-factory.json +586 -0
  43. package/src/config.ts +40 -14
  44. package/src/constants.ts +1 -0
  45. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +120 -1
  46. package/src/dex/balancer-v2/config.ts +11 -2
  47. package/src/dex/generic-rfq/generic-rfq.ts +7 -4
  48. package/src/dex/hashflow/hashflow-e2e.test.ts +36 -3
  49. package/src/dex/index.ts +2 -0
  50. package/src/dex/maverick-v1/config.ts +10 -0
  51. package/src/dex/maverick-v1/maverick-v1-e2e.test.ts +115 -1
  52. package/src/dex/maverick-v1/maverick-v1.ts +12 -2
  53. package/src/dex/pancakeswap-v3/config.ts +19 -0
  54. package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +114 -0
  55. package/src/dex/solidly/config.ts +24 -1
  56. package/src/dex/solidly/forks-override/aerodrome.ts +53 -0
  57. package/src/dex/solidly/solidly-e2e.test.ts +88 -0
  58. package/src/dex/solidly/solidly-integration.test.ts +66 -0
  59. package/src/dex/solidly/solidly.ts +1 -0
  60. package/src/dex/uniswap-v3/config.ts +30 -1
  61. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +110 -0
  62. package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +140 -0
  63. package/src/dex/weth/config.ts +3 -0
  64. package/src/dex/woo-fi-v2/config.ts +13 -0
  65. package/src/dex/woo-fi-v2/woo-fi-v2-e2e.test.ts +64 -0
  66. package/src/dex-helper/dummy-dex-helper.ts +4 -1
  67. package/src/stateful-event-subscriber.ts +2 -12
  68. package/tests/constants-e2e.ts +47 -0
  69. package/tests/tenderly-simulation.ts +2 -2
  70. package/tests/utils-e2e.ts +3 -1
@@ -2,7 +2,11 @@ import dotenv from 'dotenv';
2
2
  dotenv.config();
3
3
 
4
4
  import { testE2E } from '../../../tests/utils-e2e';
5
- import { Holders, Tokens } from '../../../tests/constants-e2e';
5
+ import {
6
+ Holders,
7
+ NativeTokenSymbols,
8
+ Tokens,
9
+ } from '../../../tests/constants-e2e';
6
10
  import { ContractMethod, Network, SwapSide } from '../../constants';
7
11
  import { StaticJsonRpcProvider } from '@ethersproject/providers';
8
12
 
@@ -10,6 +14,99 @@ import { generateConfig } from '../../config';
10
14
 
11
15
  jest.setTimeout(50 * 1000);
12
16
 
17
+ function testForNetwork(
18
+ network: Network,
19
+ dexKey: string,
20
+ tokenASymbol: string,
21
+ tokenBSymbol: string,
22
+ tokenAAmount: string,
23
+ tokenBAmount: string,
24
+ nativeTokenAmount: string,
25
+ slippage?: number | undefined,
26
+ ) {
27
+ const provider = new StaticJsonRpcProvider(
28
+ generateConfig(network).privateHttpProvider,
29
+ network,
30
+ );
31
+ const tokens = Tokens[network];
32
+ const holders = Holders[network];
33
+ const nativeTokenSymbol = NativeTokenSymbols[network];
34
+
35
+ const sideToContractMethods = new Map([
36
+ [
37
+ SwapSide.SELL,
38
+ [
39
+ ContractMethod.simpleSwap,
40
+ ContractMethod.multiSwap,
41
+ ContractMethod.megaSwap,
42
+ ],
43
+ ],
44
+ [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
45
+ ]);
46
+
47
+ describe(`${network}`, () => {
48
+ sideToContractMethods.forEach((contractMethods, side) =>
49
+ describe(`${side}`, () => {
50
+ contractMethods.forEach((contractMethod: ContractMethod) => {
51
+ describe(`${contractMethod}`, () => {
52
+ it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
53
+ await testE2E(
54
+ tokens[nativeTokenSymbol],
55
+ tokens[tokenASymbol],
56
+ holders[nativeTokenSymbol],
57
+ side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
58
+ side,
59
+ dexKey,
60
+ contractMethod,
61
+ network,
62
+ provider,
63
+ undefined,
64
+ undefined,
65
+ undefined,
66
+ slippage,
67
+ );
68
+ });
69
+ it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
70
+ await testE2E(
71
+ tokens[tokenASymbol],
72
+ tokens[nativeTokenSymbol],
73
+ holders[tokenASymbol],
74
+ side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
75
+ side,
76
+ dexKey,
77
+ contractMethod,
78
+ network,
79
+ provider,
80
+ undefined,
81
+ undefined,
82
+ undefined,
83
+ slippage,
84
+ );
85
+ });
86
+ it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
87
+ await testE2E(
88
+ tokens[tokenASymbol],
89
+ tokens[tokenBSymbol],
90
+ holders[tokenASymbol],
91
+ side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
92
+ side,
93
+ dexKey,
94
+ contractMethod,
95
+ network,
96
+ provider,
97
+ undefined,
98
+ undefined,
99
+ undefined,
100
+ slippage,
101
+ );
102
+ });
103
+ });
104
+ });
105
+ }),
106
+ );
107
+ });
108
+ }
109
+
13
110
  describe('BalancerV2 E2E', () => {
14
111
  describe('BalancerV2 MAINNET', () => {
15
112
  const dexKey = 'BalancerV2';
@@ -1195,6 +1292,28 @@ describe('BalancerV2 E2E', () => {
1195
1292
  });
1196
1293
  });
1197
1294
 
1295
+ describe('BalancerV2 Base', () => {
1296
+ const dexKey = 'BalancerV2';
1297
+ const network = Network.BASE;
1298
+
1299
+ const tokenASymbol: string = 'USDC';
1300
+ const tokenBSymbol: string = 'GOLD';
1301
+
1302
+ const tokenAAmount: string = '11110010';
1303
+ const tokenBAmount: string = '210000000000000000000';
1304
+ const nativeTokenAmount = '1000000000000000000';
1305
+
1306
+ testForNetwork(
1307
+ network,
1308
+ dexKey,
1309
+ tokenASymbol,
1310
+ tokenBSymbol,
1311
+ tokenAAmount,
1312
+ tokenBAmount,
1313
+ nativeTokenAmount,
1314
+ );
1315
+ });
1316
+
1198
1317
  describe('BeetsFi OPTIMISM', () => {
1199
1318
  const dexKey = 'BeetsFi';
1200
1319
  const network = Network.OPTIMISM;
@@ -23,7 +23,12 @@ export const BalancerConfig: DexConfigMap<DexParams> = {
23
23
  subgraphURL:
24
24
  'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-avalanche-v2',
25
25
  vaultAddress: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
26
- }
26
+ },
27
+ [Network.BASE]: {
28
+ subgraphURL:
29
+ 'https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest',
30
+ vaultAddress: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
31
+ },
27
32
  },
28
33
  BeetsFi: {
29
34
  [Network.FANTOM]: {
@@ -71,5 +76,9 @@ export const Adapters: Record<number, AdapterMappings> = {
71
76
  [Network.AVALANCHE]: {
72
77
  [SwapSide.SELL]: [{ name: 'AvalancheAdapter01', index: 8 }],
73
78
  [SwapSide.BUY]: [{ name: 'AvalancheBuyAdapter', index: 7 }],
74
- }
79
+ },
80
+ [Network.BASE]: {
81
+ [SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 4 }],
82
+ [SwapSide.BUY]: [{ name: 'BaseBuyAdapter', index: 3 }],
83
+ },
75
84
  };
@@ -6,6 +6,7 @@ import {
6
6
  PreprocessTransactionOptions,
7
7
  Config,
8
8
  PoolLiquidity,
9
+ Address,
9
10
  } from '../../types';
10
11
  import { Network, SwapSide } from '../../constants';
11
12
  import { IDexHelper } from '../../dex-helper';
@@ -61,17 +62,19 @@ export class GenericRFQ extends ParaSwapLimitOrders {
61
62
  return;
62
63
  }
63
64
 
65
+ getIdentifier(srcToken: Address, destToken: Address) {
66
+ // Keep only destination token in order to prevent taping into the same market maker liquidity during same swap (double spending)
67
+ return `${this.dexKey}_${destToken}`.toLowerCase();
68
+ }
69
+
64
70
  async getPoolIdentifiers(
65
71
  srcToken: Token,
66
72
  destToken: Token,
67
73
  side: SwapSide,
68
74
  blockNumber: number,
69
75
  ): Promise<string[]> {
70
- const _srcToken = this.dexHelper.config.wrapETH(srcToken);
71
76
  const _destToken = this.dexHelper.config.wrapETH(destToken);
72
- return [
73
- `${this.dexKey}_${_srcToken.address}_${_destToken.address}`.toLowerCase(),
74
- ];
77
+ return [this.getIdentifier(srcToken.address, _destToken.address)];
75
78
  }
76
79
 
77
80
  calcOutsFromAmounts(
@@ -11,6 +11,9 @@ import { Network, ContractMethod, SwapSide } from '../../constants';
11
11
  import { StaticJsonRpcProvider } from '@ethersproject/providers';
12
12
  import { generateConfig } from '../../config';
13
13
 
14
+ // Give time for rate fetcher to fill the cache
15
+ const sleepMs = 3000;
16
+
14
17
  function testForNetwork(
15
18
  network: Network,
16
19
  dexKey: string,
@@ -58,6 +61,11 @@ function testForNetwork(
58
61
  contractMethod,
59
62
  network,
60
63
  provider,
64
+ undefined,
65
+ undefined,
66
+ undefined,
67
+ undefined,
68
+ sleepMs,
61
69
  );
62
70
  });
63
71
  it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
@@ -71,6 +79,11 @@ function testForNetwork(
71
79
  contractMethod,
72
80
  network,
73
81
  provider,
82
+ undefined,
83
+ undefined,
84
+ undefined,
85
+ undefined,
86
+ sleepMs,
74
87
  );
75
88
  });
76
89
  } else {
@@ -85,6 +98,11 @@ function testForNetwork(
85
98
  contractMethod,
86
99
  network,
87
100
  provider,
101
+ undefined,
102
+ undefined,
103
+ undefined,
104
+ undefined,
105
+ sleepMs,
88
106
  );
89
107
  });
90
108
  it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
@@ -98,6 +116,11 @@ function testForNetwork(
98
116
  contractMethod,
99
117
  network,
100
118
  provider,
119
+ undefined,
120
+ undefined,
121
+ undefined,
122
+ undefined,
123
+ sleepMs,
101
124
  );
102
125
  });
103
126
  it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
@@ -111,6 +134,11 @@ function testForNetwork(
111
134
  contractMethod,
112
135
  network,
113
136
  provider,
137
+ undefined,
138
+ undefined,
139
+ undefined,
140
+ undefined,
141
+ sleepMs,
114
142
  );
115
143
  });
116
144
  it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
@@ -124,6 +152,11 @@ function testForNetwork(
124
152
  contractMethod,
125
153
  network,
126
154
  provider,
155
+ undefined,
156
+ undefined,
157
+ undefined,
158
+ undefined,
159
+ sleepMs,
127
160
  );
128
161
  });
129
162
  }
@@ -163,9 +196,9 @@ describe('Hashflow E2E', () => {
163
196
  const tokenASymbol: string = 'USDC';
164
197
  const tokenBSymbol: string = 'DAI';
165
198
 
166
- const tokenAAmount: string = '100000000';
167
- const tokenBAmount: string = '100000000000000000000';
168
- const nativeTokenAmount = '1000000000000000000';
199
+ const tokenAAmount: string = '1000000000';
200
+ const tokenBAmount: string = '1000000000000000000000';
201
+ const nativeTokenAmount = '100000000000000000000';
169
202
 
170
203
  testForNetwork(
171
204
  network,
package/src/dex/index.ts CHANGED
@@ -47,6 +47,7 @@ import { Thena } from './solidly/forks-override/thena';
47
47
  import { Chronos } from './solidly/forks-override/chronos';
48
48
  import { Velodrome } from './solidly/forks-override/velodrome';
49
49
  import { VelodromeV2 } from './solidly/forks-override/velodromeV2';
50
+ import { Aerodrome } from './solidly/forks-override/aerodrome';
50
51
  import { SpiritSwapV2 } from './solidly/forks-override/spiritSwapV2';
51
52
  import { Synthetix } from './synthetix/synthetix';
52
53
  import { Cone } from './solidly/forks-override/cone';
@@ -134,6 +135,7 @@ const Dexes = [
134
135
  Chronos,
135
136
  Velodrome,
136
137
  VelodromeV2,
138
+ Aerodrome,
137
139
  Cone,
138
140
  SoliSnek,
139
141
  Equalizer,
@@ -14,6 +14,12 @@ export const MaverickV1Config: DexConfigMap<DexParams> = {
14
14
  routerAddress: '0x4a585e0f7c18e2c414221d6402652d5e0990e5f8',
15
15
  poolInspectorAddress: '0xaA5BF61a664109e959D69C38734d4EA7dF74e456',
16
16
  },
17
+ [Network.BASE]: {
18
+ subgraphURL:
19
+ 'https://api.studio.thegraph.com/query/42519/maverick-base/version/latest',
20
+ routerAddress: '0x32AED3Bce901DA12ca8489788F3A99fCe1056e14',
21
+ poolInspectorAddress: '0x65A3AD03Be97619284bA7AA1E3Ca05638B9d6364',
22
+ },
17
23
  },
18
24
  };
19
25
 
@@ -22,4 +28,8 @@ export const Adapters: Record<number, AdapterMappings> = {
22
28
  [SwapSide.SELL]: [{ name: 'Adapter04', index: 2 }],
23
29
  [SwapSide.BUY]: [{ name: 'BuyAdapter', index: 8 }],
24
30
  },
31
+ [Network.BASE]: {
32
+ [SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 2 }],
33
+ [SwapSide.BUY]: [{ name: 'BaseBuyAdapter', index: 2 }],
34
+ },
25
35
  };
@@ -11,10 +11,103 @@ import { Network, ContractMethod, SwapSide } from '../../constants';
11
11
  import { StaticJsonRpcProvider } from '@ethersproject/providers';
12
12
  import { generateConfig } from '../../config';
13
13
 
14
+ function testForNetwork(
15
+ network: Network,
16
+ dexKey: string,
17
+ tokenASymbol: string,
18
+ tokenBSymbol: string,
19
+ tokenAAmount: string,
20
+ tokenBAmount: string,
21
+ nativeTokenAmount: string,
22
+ slippage?: number | undefined,
23
+ ) {
24
+ const provider = new StaticJsonRpcProvider(
25
+ generateConfig(network).privateHttpProvider,
26
+ network,
27
+ );
28
+ const tokens = Tokens[network];
29
+ const holders = Holders[network];
30
+ const nativeTokenSymbol = NativeTokenSymbols[network];
31
+
32
+ const sideToContractMethods = new Map([
33
+ [
34
+ SwapSide.SELL,
35
+ [
36
+ ContractMethod.simpleSwap,
37
+ ContractMethod.multiSwap,
38
+ ContractMethod.megaSwap,
39
+ ],
40
+ ],
41
+ [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
42
+ ]);
43
+
44
+ describe(`${network}`, () => {
45
+ sideToContractMethods.forEach((contractMethods, side) =>
46
+ describe(`${side}`, () => {
47
+ contractMethods.forEach((contractMethod: ContractMethod) => {
48
+ describe(`${contractMethod}`, () => {
49
+ it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
50
+ await testE2E(
51
+ tokens[nativeTokenSymbol],
52
+ tokens[tokenASymbol],
53
+ holders[nativeTokenSymbol],
54
+ side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
55
+ side,
56
+ dexKey,
57
+ contractMethod,
58
+ network,
59
+ provider,
60
+ undefined,
61
+ undefined,
62
+ undefined,
63
+ slippage,
64
+ );
65
+ });
66
+ it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
67
+ await testE2E(
68
+ tokens[tokenASymbol],
69
+ tokens[nativeTokenSymbol],
70
+ holders[tokenASymbol],
71
+ side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
72
+ side,
73
+ dexKey,
74
+ contractMethod,
75
+ network,
76
+ provider,
77
+ undefined,
78
+ undefined,
79
+ undefined,
80
+ slippage,
81
+ );
82
+ });
83
+ it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
84
+ await testE2E(
85
+ tokens[tokenASymbol],
86
+ tokens[tokenBSymbol],
87
+ holders[tokenASymbol],
88
+ side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
89
+ side,
90
+ dexKey,
91
+ contractMethod,
92
+ network,
93
+ provider,
94
+ undefined,
95
+ undefined,
96
+ undefined,
97
+ slippage,
98
+ );
99
+ });
100
+ });
101
+ });
102
+ }),
103
+ );
104
+ });
105
+ }
106
+
14
107
  describe('MaverickV1 E2E', () => {
15
108
  const dexKey = 'MaverickV1';
16
109
 
17
- describe('MaverickV1 MAINNET', () => {
110
+ describe('MAINNET', () => {
18
111
  const network = Network.MAINNET;
19
112
  const tokens = Tokens[network];
20
113
  const holders = Holders[network];
@@ -121,4 +214,25 @@ describe('MaverickV1 E2E', () => {
121
214
  );
122
215
  });
123
216
  });
217
+
218
+ describe('BASE', () => {
219
+ const network = Network.BASE;
220
+
221
+ const tokenASymbol: string = 'USDbC';
222
+ const tokenBSymbol: string = 'MAV';
223
+
224
+ const tokenAAmount: string = '1111100000';
225
+ const tokenBAmount: string = '1100000000000000000';
226
+ const nativeTokenAmount = '100000000000000000';
227
+
228
+ testForNetwork(
229
+ network,
230
+ dexKey,
231
+ tokenASymbol,
232
+ tokenBSymbol,
233
+ tokenAAmount,
234
+ tokenBAmount,
235
+ nativeTokenAmount,
236
+ );
237
+ });
124
238
  });
@@ -78,6 +78,7 @@ export class MaverickV1
78
78
 
79
79
  async setupEventPools(blockNumber: number) {
80
80
  const pools = await this.fetchAllSubgraphPools();
81
+
81
82
  await Promise.all(
82
83
  pools.map(async (pool: any) => {
83
84
  const eventPool = new MaverickV1EventPool(
@@ -181,8 +182,17 @@ export class MaverickV1
181
182
  getCalldataGasCost(
182
183
  poolPrices: PoolPrices<MaverickV1Data>,
183
184
  ): number | number[] {
184
- // TODO: update if there is any payload in getAdapterParam
185
- return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
185
+ const gasCost = CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
186
+
187
+ const arr = new Array(poolPrices.prices.length);
188
+ poolPrices.prices.forEach((p, index) => {
189
+ if (p == 0n) {
190
+ arr[index] = 0;
191
+ } else {
192
+ arr[index] = gasCost;
193
+ }
194
+ });
195
+ return arr;
186
196
  }
187
197
 
188
198
  // Returns pool prices for amounts.
@@ -53,6 +53,21 @@ export const PancakeswapV3Config: DexConfigMap<DexParams> = {
53
53
  subgraphURL:
54
54
  'https://api.studio.thegraph.com/query/45376/exchange-v3-arbitrum/version/latest',
55
55
  },
56
+ [Network.BASE]: {
57
+ factory: '0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865',
58
+ deployer: '0x41ff9AA7e16B8B1a8a8dc4f0eFacd93D02d071c9',
59
+ quoter: '0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997',
60
+ router: '0x1b81D678ffb9C0263b24A97847620C99d213eB14',
61
+ supportedFees: PANCAKE_SUPPORTED_FEES,
62
+ stateMulticall: '0xeBF40A40CA3D4310Bf53048F48e860656e1D7C81',
63
+ uniswapMulticall: '0x091e99cb1C49331a94dD62755D168E941AbD0693',
64
+ chunksCount: 10,
65
+ initRetryFrequency: 30,
66
+ initHash:
67
+ '0x6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2',
68
+ subgraphURL:
69
+ 'https://api.studio.thegraph.com/query/45376/exchange-v3-base/version/latest',
70
+ },
56
71
  },
57
72
  };
58
73
 
@@ -69,4 +84,8 @@ export const Adapters: Record<number, AdapterMappings> = {
69
84
  [SwapSide.SELL]: [{ name: 'ArbitrumAdapter01', index: 3 }],
70
85
  [SwapSide.BUY]: [{ name: 'ArbitrumBuyAdapter', index: 2 }],
71
86
  },
87
+ [Network.BASE]: {
88
+ [SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 1 }],
89
+ [SwapSide.BUY]: [{ name: 'BaseBuyAdapter', index: 1 }],
90
+ },
72
91
  };
@@ -11,6 +11,99 @@ import { Network, ContractMethod, SwapSide } from '../../constants';
11
11
  import { StaticJsonRpcProvider } from '@ethersproject/providers';
12
12
  import { generateConfig } from '../../config';
13
13
 
14
+ function testForNetwork(
15
+ network: Network,
16
+ dexKey: string,
17
+ tokenASymbol: string,
18
+ tokenBSymbol: string,
19
+ tokenAAmount: string,
20
+ tokenBAmount: string,
21
+ nativeTokenAmount: string,
22
+ slippage?: number | undefined,
23
+ ) {
24
+ const provider = new StaticJsonRpcProvider(
25
+ generateConfig(network).privateHttpProvider,
26
+ network,
27
+ );
28
+ const tokens = Tokens[network];
29
+ const holders = Holders[network];
30
+ const nativeTokenSymbol = NativeTokenSymbols[network];
31
+
32
+ const sideToContractMethods = new Map([
33
+ [
34
+ SwapSide.SELL,
35
+ [
36
+ ContractMethod.simpleSwap,
37
+ ContractMethod.multiSwap,
38
+ ContractMethod.megaSwap,
39
+ ],
40
+ ],
41
+ [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
42
+ ]);
43
+
44
+ describe(`${network}`, () => {
45
+ sideToContractMethods.forEach((contractMethods, side) =>
46
+ describe(`${side}`, () => {
47
+ contractMethods.forEach((contractMethod: ContractMethod) => {
48
+ describe(`${contractMethod}`, () => {
49
+ it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
50
+ await testE2E(
51
+ tokens[nativeTokenSymbol],
52
+ tokens[tokenASymbol],
53
+ holders[nativeTokenSymbol],
54
+ side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
55
+ side,
56
+ dexKey,
57
+ contractMethod,
58
+ network,
59
+ provider,
60
+ undefined,
61
+ undefined,
62
+ undefined,
63
+ slippage,
64
+ );
65
+ });
66
+ it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
67
+ await testE2E(
68
+ tokens[tokenASymbol],
69
+ tokens[nativeTokenSymbol],
70
+ holders[tokenASymbol],
71
+ side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
72
+ side,
73
+ dexKey,
74
+ contractMethod,
75
+ network,
76
+ provider,
77
+ undefined,
78
+ undefined,
79
+ undefined,
80
+ slippage,
81
+ );
82
+ });
83
+ it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
84
+ await testE2E(
85
+ tokens[tokenASymbol],
86
+ tokens[tokenBSymbol],
87
+ holders[tokenASymbol],
88
+ side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
89
+ side,
90
+ dexKey,
91
+ contractMethod,
92
+ network,
93
+ provider,
94
+ undefined,
95
+ undefined,
96
+ undefined,
97
+ slippage,
98
+ );
99
+ });
100
+ });
101
+ });
102
+ }),
103
+ );
104
+ });
105
+ }
106
+
14
107
  describe('PancakeswapV3 E2E', () => {
15
108
  const dexKey = 'PancakeswapV3';
16
109
 
@@ -307,4 +400,25 @@ describe('PancakeswapV3 E2E', () => {
307
400
  }),
308
401
  );
309
402
  });
403
+
404
+ describe('PancakeswapV3 Base', () => {
405
+ const network = Network.BASE;
406
+
407
+ const tokenASymbol: string = 'USDbC';
408
+ const tokenBSymbol: string = 'DAI';
409
+
410
+ const tokenAAmount: string = '11111000000';
411
+ const tokenBAmount: string = '210000000000000000';
412
+ const nativeTokenAmount = '110000000000000000000';
413
+
414
+ testForNetwork(
415
+ network,
416
+ dexKey,
417
+ tokenASymbol,
418
+ tokenBSymbol,
419
+ tokenAAmount,
420
+ tokenBAmount,
421
+ nativeTokenAmount,
422
+ );
423
+ });
310
424
  });
@@ -83,6 +83,17 @@ export const SolidlyConfig: DexConfigMap<DexParams> = {
83
83
  feeCode: 0,
84
84
  },
85
85
  },
86
+ Aerodrome: {
87
+ [Network.BASE]: {
88
+ // There is no subgraph for Aerodrome
89
+ factoryAddress: '0x420DD381b31aEf6683db6B902084cB0FFECe40Da',
90
+ router: '0xDCf4EE5B700e2a5Fec458e06B763A4a3E3004494',
91
+ initCode:
92
+ '0x1a8f01f7eab324003d9388f229ea17991eee9c9d14586f429799f3656790eba0',
93
+ poolGasCost: 180 * 1000,
94
+ feeCode: 0,
95
+ },
96
+ },
86
97
  Cone: {
87
98
  [Network.BSC]: {
88
99
  subgraphURL: 'https://api.thegraph.com/subgraphs/name/cone-exchange/cone',
@@ -157,6 +168,15 @@ export const SolidlyConfig: DexConfigMap<DexParams> = {
157
168
  feeCode: 0,
158
169
  poolGasCost: 180 * 1000,
159
170
  },
171
+ [Network.BASE]: {
172
+ factoryAddress: '0xed8db60acc29e14bc867a497d94ca6e3ceb5ec04',
173
+ router: '0xDCf4EE5B700e2a5Fec458e06B763A4a3E3004494',
174
+ initCode:
175
+ '0x7ba31a081e879b8e7f06d4e8bf5ee26b5c2680669c5701f4cdbdcde51727b275',
176
+ feeCode: 0,
177
+ feeFactor: 1e18,
178
+ poolGasCost: 180 * 1000,
179
+ },
160
180
  },
161
181
  };
162
182
 
@@ -165,7 +185,7 @@ export const Adapters: Record<number, AdapterMappings> = {
165
185
  [SwapSide.SELL]: [{ name: 'PolygonAdapter02', index: 3 }], // dystopia
166
186
  },
167
187
  [Network.FANTOM]: {
168
- [SwapSide.SELL]: [{ name: 'FantomAdapter01', index: 10 }], // solidly + spiritSwapV2 + Equalizer
188
+ [SwapSide.SELL]: [{ name: 'FantomAdapter01', index: 10 }], // solidly, spiritSwapV2, equalizer
169
189
  },
170
190
  [Network.OPTIMISM]: {
171
191
  [SwapSide.SELL]: [{ name: 'OptimismAdapter01', index: 8 }], // velodrome
@@ -182,4 +202,7 @@ export const Adapters: Record<number, AdapterMappings> = {
182
202
  [Network.ARBITRUM]: {
183
203
  [SwapSide.SELL]: [{ name: 'ArbitrumAdapter02', index: 1 }], // chronos, ramses
184
204
  },
205
+ [Network.BASE]: {
206
+ [SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 3 }], // aerodrome, equalizer
207
+ },
185
208
  };