@paraswap/dex-lib 2.13.0 → 2.14.0

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 (74) hide show
  1. package/build/config.js +5 -23
  2. package/build/config.js.map +1 -1
  3. package/build/dex/curve-v1/config.js +0 -2
  4. package/build/dex/curve-v1/config.js.map +1 -1
  5. package/build/dex/curve-v1/curve-v1.js +0 -2
  6. package/build/dex/curve-v1/curve-v1.js.map +1 -1
  7. package/build/dex/curve-v1/types.d.ts +0 -1
  8. package/build/dex/curve-v1/types.js.map +1 -1
  9. package/build/dex/index.js +2 -2
  10. package/build/dex/index.js.map +1 -1
  11. package/build/dex/simple-exchange.d.ts +0 -1
  12. package/build/dex/simple-exchange.js +1 -3
  13. package/build/dex/simple-exchange.js.map +1 -1
  14. package/build/lib/decoders.d.ts +1 -2
  15. package/build/lib/decoders.js +1 -8
  16. package/build/lib/decoders.js.map +1 -1
  17. package/build/lib/multi-wrapper.d.ts +1 -2
  18. package/build/lib/multi-wrapper.js.map +1 -1
  19. package/build/lib/tokens/balancer-fetcher.js +5 -4
  20. package/build/lib/tokens/balancer-fetcher.js.map +1 -1
  21. package/build/lib/tokens/utils.d.ts +2 -2
  22. package/build/lib/tokens/utils.js +1 -1
  23. package/build/lib/tokens/utils.js.map +1 -1
  24. package/build/types.d.ts +0 -3
  25. package/dex-template/__DexName__-e2e.test.ts.template +0 -1
  26. package/dex-template/__DexName__-events.test.ts.template +0 -1
  27. package/dex-template/__DexName__-integration.test.ts.template +0 -1
  28. package/dex-template/__DexName__-pool.ts.template +5 -8
  29. package/package.json +1 -1
  30. package/scripts/generate-bytecode.ts +0 -2
  31. package/src/abi/woo-fi/WooFeeManager.abi.json +318 -0
  32. package/src/abi/{woo-fi-v2/WooPPV2.abi.json → woo-fi/WooPP.abi.json} +169 -201
  33. package/src/abi/{woo-fi-v2/WooOracleV2.abi.json → woo-fi/Wooracle.abi.json} +50 -148
  34. package/src/config.ts +5 -27
  35. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +1 -0
  36. package/src/dex/curve-v1/config.ts +0 -2
  37. package/src/dex/curve-v1/curve-v1-e2e.test.ts +37 -18
  38. package/src/dex/curve-v1/curve-v1.ts +0 -2
  39. package/src/dex/curve-v1/types.ts +0 -1
  40. package/src/dex/index.ts +2 -2
  41. package/src/dex/simple-exchange.ts +1 -4
  42. package/src/dex/woo-fi/config.ts +141 -0
  43. package/src/dex/woo-fi/constants.ts +21 -0
  44. package/src/dex/woo-fi/types.ts +55 -0
  45. package/src/dex/woo-fi/woo-fi-decimal-math.ts +45 -0
  46. package/src/dex/woo-fi/woo-fi-e2e.test.ts +183 -0
  47. package/src/dex/woo-fi/woo-fi-integration.test.ts +416 -0
  48. package/src/dex/woo-fi/woo-fi-math.ts +527 -0
  49. package/src/dex/woo-fi/woo-fi.ts +693 -0
  50. package/src/lib/decoders.ts +1 -12
  51. package/src/lib/multi-wrapper.ts +1 -2
  52. package/src/lib/tokens/balancer-fetcher.ts +6 -5
  53. package/src/lib/tokens/utils.ts +3 -5
  54. package/src/types.ts +0 -4
  55. package/tests/constants-e2e.ts +9 -9
  56. package/tests/tenderly-simulation.ts +1 -1
  57. package/tests/utils-e2e.ts +0 -2
  58. package/tests/utils.ts +0 -2
  59. package/src/abi/woo-fi-v2/IntegrationHelper.abi.json +0 -116
  60. package/src/dex/woo-fi-v2/config.ts +0 -87
  61. package/src/dex/woo-fi-v2/constants.ts +0 -22
  62. package/src/dex/woo-fi-v2/decoders.ts +0 -45
  63. package/src/dex/woo-fi-v2/types.ts +0 -63
  64. package/src/dex/woo-fi-v2/utils.ts +0 -19
  65. package/src/dex/woo-fi-v2/woo-fi-v2-e2e.test.ts +0 -216
  66. package/src/dex/woo-fi-v2/woo-fi-v2-integration.test.ts +0 -495
  67. package/src/dex/woo-fi-v2/woo-fi-v2-math.ts +0 -195
  68. package/src/dex/woo-fi-v2/woo-fi-v2-pool.ts +0 -112
  69. package/src/dex/woo-fi-v2/woo-fi-v2.ts +0 -487
  70. package/src/lib/log-messages-suppressor.ts +0 -173
  71. package/src/lib/stateful-rpc-poller/state-polling-manager.ts +0 -320
  72. package/src/lib/stateful-rpc-poller/stateful-rpc-poller.ts +0 -604
  73. package/src/lib/stateful-rpc-poller/types.ts +0 -66
  74. package/src/lib/stateful-rpc-poller/utils.ts +0 -23
@@ -1,216 +0,0 @@
1
- import dotenv from 'dotenv';
2
- dotenv.config();
3
-
4
- import { testE2E } from '../../../tests/utils-e2e';
5
- import { Tokens, Holders } from '../../../tests/constants-e2e';
6
- import { Network, ContractMethod, SwapSide } from '../../constants';
7
- import { StaticJsonRpcProvider } from '@ethersproject/providers';
8
- import { generateConfig } from '../../config';
9
-
10
- function testForNetwork(
11
- network: Network,
12
- dexKey: string,
13
- tokenBaseA: string,
14
- tokenBaseB: string,
15
- tokenQuote: string,
16
- tokenBaseAAmount: string,
17
- tokenQuoteAmount: string,
18
- ) {
19
- const provider = new StaticJsonRpcProvider(
20
- generateConfig(network).privateHttpProvider,
21
- network,
22
- );
23
- const tokens = Tokens[network];
24
- const holders = Holders[network];
25
-
26
- const sideToContractMethods = new Map([
27
- [
28
- SwapSide.SELL,
29
- [
30
- ContractMethod.simpleSwap,
31
- ContractMethod.multiSwap,
32
- ContractMethod.megaSwap,
33
- ],
34
- ],
35
- ]);
36
-
37
- describe(`${network}`, () => {
38
- sideToContractMethods.forEach((contractMethods, side) =>
39
- describe(`${side}`, () => {
40
- contractMethods.forEach((contractMethod: ContractMethod) => {
41
- describe(`${contractMethod}`, () => {
42
- it(`${tokenBaseA} -> ${tokenQuote}`, async () => {
43
- await testE2E(
44
- tokens[tokenBaseA],
45
- tokens[tokenQuote],
46
- holders[tokenBaseA],
47
- tokenBaseAAmount,
48
- side,
49
- dexKey,
50
- contractMethod,
51
- network,
52
- provider,
53
- );
54
- });
55
- it(`${tokenQuote} -> ${tokenBaseA}`, async () => {
56
- await testE2E(
57
- tokens[tokenQuote],
58
- tokens[tokenBaseA],
59
- holders[tokenQuote],
60
- tokenQuoteAmount,
61
- side,
62
- dexKey,
63
- contractMethod,
64
- network,
65
- provider,
66
- );
67
- });
68
- it(`${tokenBaseA} -> ${tokenBaseB}`, async () => {
69
- await testE2E(
70
- tokens[tokenBaseA],
71
- tokens[tokenBaseB],
72
- holders[tokenBaseA],
73
- tokenBaseAAmount,
74
- side,
75
- dexKey,
76
- contractMethod,
77
- network,
78
- provider,
79
- );
80
- });
81
- });
82
- });
83
- }),
84
- );
85
- });
86
- }
87
-
88
- describe('WooFiV2 E2E', () => {
89
- const dexKey = 'WooFiV2';
90
-
91
- describe('Optimism', () => {
92
- const network = Network.OPTIMISM;
93
-
94
- const baseATokenSymbol = 'WETH';
95
- const baseBTokenSymbol = 'WBTC';
96
- const quoteTokenSymbol = 'USDC';
97
-
98
- const tokenBaseAAmount = '1000000000000000000';
99
- const tokenQuoteAmount = '1000000';
100
-
101
- testForNetwork(
102
- network,
103
- dexKey,
104
- baseATokenSymbol,
105
- baseBTokenSymbol,
106
- quoteTokenSymbol,
107
- tokenBaseAAmount,
108
- tokenQuoteAmount,
109
- );
110
- });
111
-
112
- describe('BSC', () => {
113
- const network = Network.BSC;
114
-
115
- const baseATokenSymbol = 'WBNB';
116
- const baseBTokenSymbol = 'bBTC';
117
- const quoteTokenSymbol = 'BUSD';
118
-
119
- const tokenBaseAAmount = '1000000000000000000';
120
- const tokenQuoteAmount = '1000000000000000000';
121
-
122
- testForNetwork(
123
- network,
124
- dexKey,
125
- baseATokenSymbol,
126
- baseBTokenSymbol,
127
- quoteTokenSymbol,
128
- tokenBaseAAmount,
129
- tokenQuoteAmount,
130
- );
131
- });
132
-
133
- describe('Polygon', () => {
134
- const network = Network.POLYGON;
135
-
136
- const baseATokenSymbol = 'WMATIC';
137
- const baseBTokenSymbol = 'WETH';
138
- const quoteTokenSymbol = 'USDC';
139
-
140
- const tokenBaseAAmount = '1000000000000000000';
141
- const tokenQuoteAmount = '1000000';
142
-
143
- testForNetwork(
144
- network,
145
- dexKey,
146
- baseATokenSymbol,
147
- baseBTokenSymbol,
148
- quoteTokenSymbol,
149
- tokenBaseAAmount,
150
- tokenQuoteAmount,
151
- );
152
- });
153
-
154
- describe('Fantom', () => {
155
- const network = Network.FANTOM;
156
-
157
- const baseATokenSymbol = 'WFTM';
158
- const quoteTokenSymbol = 'USDC';
159
- const baseBTokenSymbol = 'ETH';
160
-
161
- const tokenBaseAAmount = '1000000000000000000';
162
- const tokenQuoteAmount = '1000000';
163
-
164
- testForNetwork(
165
- network,
166
- dexKey,
167
- baseATokenSymbol,
168
- baseBTokenSymbol,
169
- quoteTokenSymbol,
170
- tokenBaseAAmount,
171
- tokenQuoteAmount,
172
- );
173
- });
174
-
175
- describe('Arbitrum', () => {
176
- const network = Network.ARBITRUM;
177
-
178
- const baseATokenSymbol = 'WETH';
179
- const baseBTokenSymbol = 'WBTC';
180
- const quoteTokenSymbol = 'USDC';
181
-
182
- const tokenBaseAAmount = '1000000000000000000';
183
- const tokenQuoteAmount = '1000000';
184
-
185
- testForNetwork(
186
- network,
187
- dexKey,
188
- baseATokenSymbol,
189
- baseBTokenSymbol,
190
- quoteTokenSymbol,
191
- tokenBaseAAmount,
192
- tokenQuoteAmount,
193
- );
194
- });
195
-
196
- describe('Avalanche', () => {
197
- const network = Network.AVALANCHE;
198
-
199
- const baseATokenSymbol = 'WAVAX';
200
- const baseBTokenSymbol = 'BTCb';
201
- const quoteTokenSymbol = 'USDC';
202
-
203
- const tokenBaseAAmount = '1000000000000000000';
204
- const tokenQuoteAmount = '1000000';
205
-
206
- testForNetwork(
207
- network,
208
- dexKey,
209
- baseATokenSymbol,
210
- baseBTokenSymbol,
211
- quoteTokenSymbol,
212
- tokenBaseAAmount,
213
- tokenQuoteAmount,
214
- );
215
- });
216
- });
@@ -1,495 +0,0 @@
1
- /* eslint-disable no-console */
2
- import dotenv from 'dotenv';
3
- dotenv.config();
4
-
5
- import { Interface, Result } from '@ethersproject/abi';
6
- import { DummyDexHelper } from '../../dex-helper/index';
7
- import { Network, SwapSide } from '../../constants';
8
- import { BI_POWS } from '../../bigint-constants';
9
- import { WooFiV2 } from './woo-fi-v2';
10
- import {
11
- checkPoolPrices,
12
- checkPoolsLiquidity,
13
- checkConstantPoolPrices,
14
- } from '../../../tests/utils';
15
- import { Tokens } from '../../../tests/constants-e2e';
16
- import { Address } from '@paraswap/core';
17
- import { ifaces } from './utils';
18
-
19
- function getReaderCalldata(
20
- exchangeAddress: string,
21
- readerIface: Interface,
22
- amounts: bigint[],
23
- funcName: string,
24
- srcTokenAddress: Address,
25
- destTokenAddress: Address,
26
- ) {
27
- return amounts.map(amount => ({
28
- target: exchangeAddress,
29
- callData: readerIface.encodeFunctionData(funcName, [
30
- srcTokenAddress,
31
- destTokenAddress,
32
- amount,
33
- ]),
34
- }));
35
- }
36
-
37
- function decodeReaderResult(
38
- results: Result,
39
- readerIface: Interface,
40
- funcName: string,
41
- ) {
42
- return results.map(result => {
43
- const parsed = readerIface.decodeFunctionResult(funcName, result);
44
- return BigInt(parsed[0]._hex);
45
- });
46
- }
47
-
48
- async function checkOnChainPricing(
49
- wooFiV2: WooFiV2,
50
- funcName: string,
51
- blockNumber: number,
52
- prices: bigint[],
53
- amounts: bigint[],
54
- srcTokenAddress: Address,
55
- destTokenAddress: Address,
56
- ) {
57
- const exchangeAddress = wooFiV2.config.wooPPV2Address;
58
-
59
- const readerIface = ifaces.PPV2;
60
-
61
- const readerCallData = getReaderCalldata(
62
- exchangeAddress,
63
- readerIface,
64
- amounts.slice(1),
65
- funcName,
66
- srcTokenAddress,
67
- destTokenAddress,
68
- );
69
- const readerResult = (
70
- await wooFiV2.dexHelper.multiContract.methods
71
- .aggregate(readerCallData)
72
- .call({}, blockNumber)
73
- ).returnData;
74
-
75
- const expectedPrices = [0n].concat(
76
- decodeReaderResult(readerResult, readerIface, funcName),
77
- );
78
-
79
- expect(prices).toEqual(expectedPrices);
80
- }
81
-
82
- async function testPricingForPair(
83
- wooFiV2: WooFiV2,
84
- network: Network,
85
- dexKey: string,
86
- blockNumber: number,
87
- srcTokenSymbol: string,
88
- destTokenSymbol: string,
89
- side: SwapSide,
90
- amounts: bigint[],
91
- funcNameToCheck: string,
92
- expectNoLiquidity: boolean = false,
93
- ) {
94
- const networkTokens = Tokens[network];
95
-
96
- const pools = await wooFiV2.getPoolIdentifiers(
97
- networkTokens[srcTokenSymbol],
98
- networkTokens[destTokenSymbol],
99
- side,
100
- blockNumber,
101
- );
102
- console.log(
103
- `${srcTokenSymbol} <> ${destTokenSymbol} Pool Identifiers: `,
104
- pools,
105
- );
106
-
107
- if (expectNoLiquidity) {
108
- expect(pools.length).toEqual(0);
109
- return;
110
- }
111
-
112
- expect(pools.length).toBeGreaterThan(0);
113
-
114
- const poolPrices = await wooFiV2.getPricesVolume(
115
- networkTokens[srcTokenSymbol],
116
- networkTokens[destTokenSymbol],
117
- amounts,
118
- side,
119
- blockNumber,
120
- pools,
121
- );
122
- console.log(
123
- `${srcTokenSymbol} <> ${destTokenSymbol} Pool Prices: `,
124
- poolPrices,
125
- );
126
-
127
- expect(poolPrices).not.toBeNull();
128
- if (wooFiV2.hasConstantPriceLargeAmounts) {
129
- checkConstantPoolPrices(poolPrices!, amounts, dexKey);
130
- } else {
131
- checkPoolPrices(poolPrices!, amounts, side, dexKey);
132
- }
133
-
134
- // Check if onchain pricing equals to calculated ones
135
- await checkOnChainPricing(
136
- wooFiV2,
137
- funcNameToCheck,
138
- blockNumber,
139
- poolPrices![0].prices,
140
- amounts,
141
- networkTokens[srcTokenSymbol].address,
142
- networkTokens[destTokenSymbol].address,
143
- );
144
- }
145
-
146
- function runTestsForChain(
147
- dexHelper: DummyDexHelper,
148
- initProps: { dex: WooFiV2; blockNumber: number },
149
- baseATokenSymbol: string,
150
- quoteTokenSymbol: string,
151
- baseBTokenSymbol: string,
152
- untradableSymbol: string,
153
- pricingCheckFuncName: string,
154
- amountDecimalsDiff: number = 0,
155
- ) {
156
- const network = dexHelper.config.data.network;
157
- const tokens = Tokens[network];
158
-
159
- it(`getPoolIdentifiers and getPricesVolume SELL: ${baseATokenSymbol} -> ${quoteTokenSymbol}`, async function () {
160
- const { dex: wooFiV2, blockNumber } = initProps;
161
- const dexKey = wooFiV2.dexKey;
162
- const srcTokenSymbol = baseATokenSymbol;
163
- const destTokenSymbol = quoteTokenSymbol;
164
-
165
- const amountsToTrade = [
166
- 0n,
167
- 1n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
168
- 2n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
169
- 3n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
170
- 4n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
171
- 5n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
172
- 6n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
173
- 7n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
174
- 8n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
175
- 9n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
176
- 10n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
177
- ];
178
-
179
- await testPricingForPair(
180
- wooFiV2,
181
- network,
182
- dexKey,
183
- blockNumber,
184
- srcTokenSymbol,
185
- destTokenSymbol,
186
- SwapSide.SELL,
187
- amountsToTrade,
188
- pricingCheckFuncName,
189
- );
190
- });
191
-
192
- it(`getPoolIdentifiers and getPricesVolume SELL: ${quoteTokenSymbol} -> ${baseATokenSymbol}`, async function () {
193
- const { dex: wooFiV2, blockNumber } = initProps;
194
- const dexKey = wooFiV2.dexKey;
195
- const srcTokenSymbol = quoteTokenSymbol;
196
- const destTokenSymbol = baseATokenSymbol;
197
-
198
- const amountsToTrade = [
199
- 0n,
200
- 1n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
201
- 2n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
202
- 3n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
203
- 4n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
204
- 5n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
205
- 6n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
206
- 7n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
207
- 8n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
208
- 9n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
209
- 10n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
210
- ];
211
-
212
- await testPricingForPair(
213
- wooFiV2,
214
- network,
215
- dexKey,
216
- blockNumber,
217
- srcTokenSymbol,
218
- destTokenSymbol,
219
- SwapSide.SELL,
220
- amountsToTrade,
221
- pricingCheckFuncName,
222
- );
223
- });
224
-
225
- it(`getPoolIdentifiers and getPricesVolume SELL: ${baseATokenSymbol} -> ${baseBTokenSymbol}`, async function () {
226
- const { dex: wooFiV2, blockNumber } = initProps;
227
- const dexKey = wooFiV2.dexKey;
228
- const srcTokenSymbol = baseATokenSymbol;
229
- const destTokenSymbol = baseBTokenSymbol;
230
-
231
- const amountsToTrade = [
232
- 0n,
233
- 1n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
234
- 2n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
235
- 3n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
236
- 4n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
237
- 5n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
238
- 6n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
239
- 7n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
240
- 8n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
241
- 9n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
242
- 10n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
243
- ];
244
-
245
- await testPricingForPair(
246
- wooFiV2,
247
- network,
248
- dexKey,
249
- blockNumber,
250
- srcTokenSymbol,
251
- destTokenSymbol,
252
- SwapSide.SELL,
253
- amountsToTrade,
254
- pricingCheckFuncName,
255
- );
256
- });
257
-
258
- it('getPoolIdentifiers and getPricesVolume SELL: No Pool', async function () {
259
- const { dex: wooFiV2, blockNumber } = initProps;
260
- const dexKey = wooFiV2.dexKey;
261
- const srcTokenSymbol = quoteTokenSymbol;
262
- const destTokenSymbol = untradableSymbol;
263
-
264
- const amountsToTrade = [
265
- 0n,
266
- 1n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
267
- 2n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
268
- 3n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
269
- 4n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
270
- 5n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
271
- 6n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
272
- 7n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
273
- 8n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
274
- 9n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
275
- 10n * BI_POWS[tokens[srcTokenSymbol].decimals - amountDecimalsDiff],
276
- ];
277
- await testPricingForPair(
278
- wooFiV2,
279
- network,
280
- dexKey,
281
- blockNumber,
282
- srcTokenSymbol,
283
- destTokenSymbol,
284
- SwapSide.SELL,
285
- amountsToTrade,
286
- pricingCheckFuncName,
287
- true,
288
- );
289
- });
290
-
291
- it('getTopPoolsForToken', async function () {
292
- const { dex: wooFiV2 } = initProps;
293
- const dexKey = wooFiV2.dexKey;
294
- // We have to check without calling initializePricing, because
295
- // pool-tracker is not calling that function
296
- const newWooFiV2 = new WooFiV2(network, dexKey, dexHelper);
297
- if (newWooFiV2.updatePoolState) {
298
- await newWooFiV2.updatePoolState();
299
- }
300
- const poolLiquidity = await newWooFiV2.getTopPoolsForToken(
301
- tokens[quoteTokenSymbol].address,
302
- 10,
303
- );
304
- console.log(`${quoteTokenSymbol} Top Pools:`, poolLiquidity);
305
-
306
- if (!newWooFiV2.hasConstantPriceLargeAmounts) {
307
- checkPoolsLiquidity(
308
- poolLiquidity,
309
- Tokens[network][quoteTokenSymbol].address,
310
- dexKey,
311
- );
312
- }
313
- });
314
- }
315
-
316
- describe('WooFiV2', function () {
317
- const dexKey = 'WooFiV2';
318
- const pricingCheckFuncName = 'tryQuery';
319
-
320
- describe('Optimism', () => {
321
- const network = Network.OPTIMISM;
322
- const dexHelper = new DummyDexHelper(network);
323
- const initProps: { dex: WooFiV2; blockNumber: number } = {
324
- dex: new WooFiV2(network, dexKey, dexHelper),
325
- blockNumber: 0,
326
- };
327
-
328
- beforeAll(async () => {
329
- initProps.blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
330
- await initProps.dex.initializePricing(initProps.blockNumber);
331
- });
332
-
333
- const baseATokenSymbol = 'WETH';
334
- const quoteTokenSymbol = 'USDC';
335
- const baseBTokenSymbol = 'WBTC';
336
- const untradableSymbol = 'POPS';
337
-
338
- runTestsForChain(
339
- dexHelper,
340
- initProps,
341
- baseATokenSymbol,
342
- quoteTokenSymbol,
343
- baseBTokenSymbol,
344
- untradableSymbol,
345
- pricingCheckFuncName,
346
- );
347
- });
348
-
349
- describe('BSC', () => {
350
- const network = Network.BSC;
351
- const dexHelper = new DummyDexHelper(network);
352
- const initProps: { dex: WooFiV2; blockNumber: number } = {
353
- dex: new WooFiV2(network, dexKey, dexHelper),
354
- blockNumber: 0,
355
- };
356
-
357
- beforeAll(async () => {
358
- initProps.blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
359
- await initProps.dex.initializePricing(initProps.blockNumber);
360
- });
361
-
362
- const baseATokenSymbol = 'WBNB';
363
- const quoteTokenSymbol = 'BUSD';
364
- const baseBTokenSymbol = 'bBTC';
365
- const untradableSymbol = 'POPS';
366
-
367
- runTestsForChain(
368
- dexHelper,
369
- initProps,
370
- baseATokenSymbol,
371
- quoteTokenSymbol,
372
- baseBTokenSymbol,
373
- untradableSymbol,
374
- pricingCheckFuncName,
375
- 2,
376
- );
377
- });
378
-
379
- describe('Polygon', () => {
380
- const network = Network.POLYGON;
381
- const dexHelper = new DummyDexHelper(network);
382
- const initProps: { dex: WooFiV2; blockNumber: number } = {
383
- dex: new WooFiV2(network, dexKey, dexHelper),
384
- blockNumber: 0,
385
- };
386
-
387
- beforeAll(async () => {
388
- initProps.blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
389
- await initProps.dex.initializePricing(initProps.blockNumber);
390
- });
391
-
392
- const baseATokenSymbol = 'WMATIC';
393
- const quoteTokenSymbol = 'USDC';
394
- const baseBTokenSymbol = 'WETH';
395
- const untradableSymbol = 'POPS';
396
-
397
- runTestsForChain(
398
- dexHelper,
399
- initProps,
400
- baseATokenSymbol,
401
- quoteTokenSymbol,
402
- baseBTokenSymbol,
403
- untradableSymbol,
404
- pricingCheckFuncName,
405
- );
406
- });
407
-
408
- describe('Fantom', () => {
409
- const network = Network.FANTOM;
410
- const dexHelper = new DummyDexHelper(network);
411
- const initProps: { dex: WooFiV2; blockNumber: number } = {
412
- dex: new WooFiV2(network, dexKey, dexHelper),
413
- blockNumber: 0,
414
- };
415
-
416
- beforeAll(async () => {
417
- initProps.blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
418
- await initProps.dex.initializePricing(initProps.blockNumber);
419
- });
420
-
421
- const baseATokenSymbol = 'WFTM';
422
- const quoteTokenSymbol = 'USDC';
423
- const baseBTokenSymbol = 'ETH';
424
- const untradableSymbol = 'POPS';
425
-
426
- runTestsForChain(
427
- dexHelper,
428
- initProps,
429
- baseATokenSymbol,
430
- quoteTokenSymbol,
431
- baseBTokenSymbol,
432
- untradableSymbol,
433
- pricingCheckFuncName,
434
- );
435
- });
436
-
437
- describe('Arbitrum', () => {
438
- const network = Network.ARBITRUM;
439
- const dexHelper = new DummyDexHelper(network);
440
- const initProps: { dex: WooFiV2; blockNumber: number } = {
441
- dex: new WooFiV2(network, dexKey, dexHelper),
442
- blockNumber: 0,
443
- };
444
-
445
- beforeAll(async () => {
446
- initProps.blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
447
- await initProps.dex.initializePricing(initProps.blockNumber);
448
- });
449
-
450
- const baseATokenSymbol = 'WETH';
451
- const quoteTokenSymbol = 'USDC';
452
- const baseBTokenSymbol = 'WBTC';
453
- const untradableSymbol = 'POPS';
454
-
455
- runTestsForChain(
456
- dexHelper,
457
- initProps,
458
- baseATokenSymbol,
459
- quoteTokenSymbol,
460
- baseBTokenSymbol,
461
- untradableSymbol,
462
- pricingCheckFuncName,
463
- );
464
- });
465
-
466
- describe('Avalanche', () => {
467
- const network = Network.AVALANCHE;
468
- const dexHelper = new DummyDexHelper(network);
469
- const initProps: { dex: WooFiV2; blockNumber: number } = {
470
- dex: new WooFiV2(network, dexKey, dexHelper),
471
- blockNumber: 0,
472
- };
473
-
474
- beforeAll(async () => {
475
- initProps.blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
476
- await initProps.dex.initializePricing(initProps.blockNumber);
477
- });
478
-
479
- const baseATokenSymbol = 'WAVAX';
480
- const quoteTokenSymbol = 'USDC';
481
- const baseBTokenSymbol = 'BTCb';
482
- const untradableSymbol = 'POPS';
483
-
484
- runTestsForChain(
485
- dexHelper,
486
- initProps,
487
- baseATokenSymbol,
488
- quoteTokenSymbol,
489
- baseBTokenSymbol,
490
- untradableSymbol,
491
- pricingCheckFuncName,
492
- 3,
493
- );
494
- });
495
- });