@paraswap/dex-lib 2.22.3 → 2.23.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.
@@ -21,13 +21,22 @@ export const QuickSwapConfig: DexConfigMap<DexParams> = {
21
21
  '0x6ec6c9c8091d160c0aa74b2b14ba9c1717e95093bd3ac085cee99a49aab294a4',
22
22
  },
23
23
  },
24
+ ThenaFusion: {
25
+ [Network.BSC]: {
26
+ factoryAddress: '0x306F06C147f064A010530292A1EB6737c3e378e4',
27
+ router: '0x327Dd3208f0bCF590A66110aCB6e5e6941A4EfA0',
28
+ quoteAddress: '0xeA68020D6A9532EeC42D4dB0f92B83580c39b2cA',
29
+ initCode:
30
+ '0xd61302e7691f3169f5ebeca3a0a4ab8f7f998c01e55ec944e62cfb1109fd2736',
31
+ },
32
+ },
24
33
  QuickSwapV3: {
25
34
  [Network.POLYGON]: {
26
35
  factoryAddress: '0x411b0fAcC3489691f28ad58c47006AF5E3Ab3A28',
27
36
  router: '0xf5b509bb0909a69b1c207e495f687a596c168e12',
28
37
  quoteAddress: '0xa15f0d7377b2a0c0c10db057f641bed21028fc89',
29
38
  initCode:
30
- '0xfa2ad44b9e39d38a7d396bb44a41ea957ac7b622c5c6afdc285728c300b3382a',
39
+ '0x6ec6c9c8091d160c0aa74b2b14ba9c1717e95093bd3ac085cee99a49aab294a4',
31
40
  },
32
41
  },
33
42
  SpiritSwapV3: {
@@ -1,4 +1,5 @@
1
1
  import dotenv from 'dotenv';
2
+
2
3
  dotenv.config();
3
4
 
4
5
  import { testE2E } from '../../../tests/utils-e2e';
@@ -161,7 +162,7 @@ describe('QuickSwap', () => {
161
162
  provider,
162
163
  undefined,
163
164
  undefined,
164
- { srcFee: 0, destFee: 0, srcDexFee: 0, destDexFee: 500 },
165
+ {srcFee: 0, destFee: 0, srcDexFee: 0, destDexFee: 500},
165
166
  );
166
167
  });
167
168
  it('HANZO -> WMATIC', async () => {
@@ -177,7 +178,7 @@ describe('QuickSwap', () => {
177
178
  provider,
178
179
  undefined,
179
180
  undefined,
180
- { srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0 },
181
+ {srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0},
181
182
  );
182
183
  });
183
184
  });
@@ -195,7 +196,7 @@ describe('QuickSwap', () => {
195
196
  provider,
196
197
  undefined,
197
198
  undefined,
198
- { srcFee: 0, destFee: 0, srcDexFee: 0, destDexFee: 500 },
199
+ {srcFee: 0, destFee: 0, srcDexFee: 0, destDexFee: 500},
199
200
  );
200
201
  });
201
202
  it('HANZO -> WMATIC', async () => {
@@ -211,7 +212,7 @@ describe('QuickSwap', () => {
211
212
  provider,
212
213
  undefined,
213
214
  undefined,
214
- { srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0 },
215
+ {srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0},
215
216
  );
216
217
  });
217
218
  });
@@ -231,7 +232,7 @@ describe('QuickSwap', () => {
231
232
  provider,
232
233
  undefined,
233
234
  undefined,
234
- { srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0 },
235
+ {srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0},
235
236
  );
236
237
  });
237
238
  });
@@ -249,7 +250,7 @@ describe('QuickSwap', () => {
249
250
  provider,
250
251
  undefined,
251
252
  undefined,
252
- { srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0 },
253
+ {srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0},
253
254
  );
254
255
  });
255
256
  });
@@ -258,104 +259,16 @@ describe('QuickSwap', () => {
258
259
  });
259
260
  });
260
261
 
261
- describe('Arbitrum', () => {
262
- const network = Network.ARBITRUM;
262
+ describe('Bsc', () => {
263
+ const network = Network.BSC;
263
264
  const tokens = Tokens[network];
264
265
  const holders = Holders[network];
265
266
  const provider = new StaticJsonRpcProvider(
266
267
  generateConfig(network).privateHttpProvider,
267
268
  network,
268
269
  );
269
- describe('Zyberswapv3', () => {
270
- const dexKey = 'Zyberswapv3';
271
-
272
- describe('Simpleswap', () => {
273
- it('WETH -> USDC', async () => {
274
- await testE2E(
275
- tokens.WETH,
276
- tokens.USDC,
277
- holders.WETH,
278
- '7000000000000000000',
279
- SwapSide.SELL,
280
- dexKey,
281
- ContractMethod.simpleSwap,
282
- network,
283
- provider,
284
- );
285
- });
286
- it('USDC -> WETH', async () => {
287
- await testE2E(
288
- tokens.USDC,
289
- tokens.WETH,
290
- holders.USDC,
291
- '100000',
292
- SwapSide.SELL,
293
- dexKey,
294
- ContractMethod.simpleSwap,
295
- network,
296
- provider,
297
- );
298
- });
299
- it('WBTC -> USDC', async () => {
300
- await testE2E(
301
- tokens.WBTC,
302
- tokens.USDC,
303
- holders.WBTC,
304
- '10000000',
305
- SwapSide.SELL,
306
- dexKey,
307
- ContractMethod.simpleSwap,
308
- network,
309
- provider,
310
- );
311
- });
312
- });
313
-
314
- describe('Multiswap', () => {
315
- it('WETH -> USDC', async () => {
316
- await testE2E(
317
- tokens.WETH,
318
- tokens.USDC,
319
- holders.WETH,
320
- '7000000000000000000',
321
- SwapSide.SELL,
322
- dexKey,
323
- ContractMethod.multiSwap,
324
- network,
325
- provider,
326
- );
327
- });
328
- it('USDC -> WETH', async () => {
329
- await testE2E(
330
- tokens.USDC,
331
- tokens.WETH,
332
- holders.USDC,
333
- '100000',
334
- SwapSide.SELL,
335
- dexKey,
336
- ContractMethod.multiSwap,
337
- network,
338
- provider,
339
- );
340
- });
341
- it('WBTC -> USDC', async () => {
342
- await testE2E(
343
- tokens.WBTC,
344
- tokens.USDC,
345
- holders.WBTC,
346
- '10000000',
347
- SwapSide.SELL,
348
- dexKey,
349
- ContractMethod.multiSwap,
350
- network,
351
- provider,
352
- );
353
- });
354
- });
355
- });
356
-
357
- describe('CamelotV3', () => {
358
- const dexKey = 'CamelotV3';
270
+ describe('ThenaFusion', () => {
271
+ const dexKey = 'ThenaFusion';
359
272
 
360
273
  const sideToContractMethods = new Map([
361
274
  [
@@ -366,60 +279,63 @@ describe('QuickSwap', () => {
366
279
  ContractMethod.megaSwap,
367
280
  ],
368
281
  ],
369
- [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
282
+ [ SwapSide.BUY, [ ContractMethod.simpleBuy, ContractMethod.buy ] ],
370
283
  ]);
371
284
 
372
- const pairs: { name: string; sellAmount: string; buyAmount: string }[][] =
285
+ const pairs: {
286
+ name: string;
287
+ sellAmount: string;
288
+ buyAmount: string;
289
+ }[][] = [
373
290
  [
374
- [
375
- {
376
- name: 'WBTC',
377
- sellAmount: '1000',
378
- buyAmount: '151080000000000',
379
- },
380
- {
381
- name: 'WETH',
382
- sellAmount: '1050000000000',
383
- buyAmount: '1000',
384
- },
385
- ],
386
- [
387
- {
388
- name: 'WBTC',
389
- sellAmount: '1000',
390
- buyAmount: '1300000',
391
- },
392
- {
393
- name: 'USDC',
394
- sellAmount: '1000000',
395
- buyAmount: '1000',
396
- },
397
- ],
398
- [
399
- {
400
- name: 'WETH',
401
- sellAmount: '10000000000',
402
- buyAmount: '10000000',
403
- },
404
- {
405
- name: 'USDC',
406
- sellAmount: '10000000',
407
- buyAmount: '10000000000',
408
- },
409
- ],
410
- [
411
- {
412
- name: 'ETH',
413
- sellAmount: '10000000000',
414
- buyAmount: '10000000',
415
- },
416
- {
417
- name: 'USDC',
418
- sellAmount: '10000000',
419
- buyAmount: '10000000000',
420
- },
421
- ],
422
- ];
291
+ {
292
+ name: 'BNB',
293
+ sellAmount: '7000000000000',
294
+ buyAmount: '2000000000000',
295
+ },
296
+ {
297
+ name: 'USDT',
298
+ sellAmount: '7000000000000',
299
+ buyAmount: '5000000000000',
300
+ },
301
+ ],
302
+ [
303
+ {
304
+ name: 'WBNB',
305
+ sellAmount: '3000000000000',
306
+ buyAmount: '6000000000000',
307
+ },
308
+ {
309
+ name: 'USDT',
310
+ sellAmount: '1000000000000',
311
+ buyAmount: '2000000000000',
312
+ },
313
+ ],
314
+ [
315
+ {
316
+ name: 'USDC',
317
+ sellAmount: '2000000000000',
318
+ buyAmount: '2000000000000',
319
+ },
320
+ {
321
+ name: 'USDT',
322
+ sellAmount: '7000000000000',
323
+ buyAmount: '7000000000000',
324
+ },
325
+ ],
326
+ [
327
+ {
328
+ name: 'BNB',
329
+ sellAmount: '5000000000000',
330
+ buyAmount: '6000000000000',
331
+ },
332
+ {
333
+ name: 'USDT',
334
+ sellAmount: '7000000000000',
335
+ buyAmount: '2000000000000',
336
+ },
337
+ ],
338
+ ];
423
339
 
424
340
  sideToContractMethods.forEach((contractMethods, side) =>
425
341
  describe(`${side}`, () => {
@@ -462,99 +378,305 @@ describe('QuickSwap', () => {
462
378
  }),
463
379
  );
464
380
  });
465
- });
466
381
 
467
- describe('Fantom', () => {
468
- const network = Network.FANTOM;
469
- const tokens = Tokens[network];
470
- const holders = Holders[network];
471
- const provider = new StaticJsonRpcProvider(
472
- generateConfig(network).privateHttpProvider,
473
- network,
474
- );
475
- describe('SpiritSwapV3', () => {
476
- const dexKey = 'SpiritSwapV3';
382
+ describe('Arbitrum', () => {
383
+ const network = Network.ARBITRUM;
384
+ const tokens = Tokens[network];
385
+ const holders = Holders[network];
386
+ const provider = new StaticJsonRpcProvider(
387
+ generateConfig(network).privateHttpProvider,
388
+ network,
389
+ );
390
+ describe('Zyberswapv3', () => {
391
+ const dexKey = 'Zyberswapv3';
477
392
 
478
- const sideToContractMethods = new Map([
479
- [
480
- SwapSide.SELL,
393
+ describe('Simpleswap', () => {
394
+ it('WETH -> USDC', async () => {
395
+ await testE2E(
396
+ tokens.WETH,
397
+ tokens.USDC,
398
+ holders.WETH,
399
+ '7000000000000000000',
400
+ SwapSide.SELL,
401
+ dexKey,
402
+ ContractMethod.simpleSwap,
403
+ network,
404
+ provider,
405
+ );
406
+ });
407
+ it('USDC -> WETH', async () => {
408
+ await testE2E(
409
+ tokens.USDC,
410
+ tokens.WETH,
411
+ holders.USDC,
412
+ '100000',
413
+ SwapSide.SELL,
414
+ dexKey,
415
+ ContractMethod.simpleSwap,
416
+ network,
417
+ provider,
418
+ );
419
+ });
420
+ it('WBTC -> USDC', async () => {
421
+ await testE2E(
422
+ tokens.WBTC,
423
+ tokens.USDC,
424
+ holders.WBTC,
425
+ '10000000',
426
+ SwapSide.SELL,
427
+ dexKey,
428
+ ContractMethod.simpleSwap,
429
+ network,
430
+ provider,
431
+ );
432
+ });
433
+ });
434
+
435
+ describe('Multiswap', () => {
436
+ it('WETH -> USDC', async () => {
437
+ await testE2E(
438
+ tokens.WETH,
439
+ tokens.USDC,
440
+ holders.WETH,
441
+ '7000000000000000000',
442
+ SwapSide.SELL,
443
+ dexKey,
444
+ ContractMethod.multiSwap,
445
+ network,
446
+ provider,
447
+ );
448
+ });
449
+ it('USDC -> WETH', async () => {
450
+ await testE2E(
451
+ tokens.USDC,
452
+ tokens.WETH,
453
+ holders.USDC,
454
+ '100000',
455
+ SwapSide.SELL,
456
+ dexKey,
457
+ ContractMethod.multiSwap,
458
+ network,
459
+ provider,
460
+ );
461
+ });
462
+ it('WBTC -> USDC', async () => {
463
+ await testE2E(
464
+ tokens.WBTC,
465
+ tokens.USDC,
466
+ holders.WBTC,
467
+ '10000000',
468
+ SwapSide.SELL,
469
+ dexKey,
470
+ ContractMethod.multiSwap,
471
+ network,
472
+ provider,
473
+ );
474
+ });
475
+ });
476
+ });
477
+
478
+ describe('CamelotV3', () => {
479
+ const dexKey = 'CamelotV3';
480
+
481
+ const sideToContractMethods = new Map([
481
482
  [
482
- ContractMethod.simpleSwap,
483
- ContractMethod.multiSwap,
484
- ContractMethod.megaSwap,
483
+ SwapSide.SELL,
484
+ [
485
+ ContractMethod.simpleSwap,
486
+ ContractMethod.multiSwap,
487
+ ContractMethod.megaSwap,
488
+ ],
485
489
  ],
486
- ],
487
- [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
488
- ]);
490
+ [ SwapSide.BUY, [ ContractMethod.simpleBuy, ContractMethod.buy ] ],
491
+ ]);
489
492
 
490
- const pairs: { name: string; sellAmount: string; buyAmount: string }[][] =
491
- [
493
+ const pairs: { name: string; sellAmount: string; buyAmount: string }[][] =
492
494
  [
493
- {
494
- name: 'USDC',
495
- sellAmount: '100',
496
- buyAmount: '10000000000000000',
497
- },
498
- {
499
- name: 'WFTM',
500
- sellAmount: '10000000000000000',
501
- buyAmount: '100',
502
- },
503
- ],
495
+ [
496
+ {
497
+ name: 'WBTC',
498
+ sellAmount: '1000',
499
+ buyAmount: '151080000000000',
500
+ },
501
+ {
502
+ name: 'WETH',
503
+ sellAmount: '1050000000000',
504
+ buyAmount: '1000',
505
+ },
506
+ ],
507
+ [
508
+ {
509
+ name: 'WBTC',
510
+ sellAmount: '1000',
511
+ buyAmount: '1300000',
512
+ },
513
+ {
514
+ name: 'USDC',
515
+ sellAmount: '1000000',
516
+ buyAmount: '1000',
517
+ },
518
+ ],
519
+ [
520
+ {
521
+ name: 'WETH',
522
+ sellAmount: '10000000000',
523
+ buyAmount: '10000000',
524
+ },
525
+ {
526
+ name: 'USDC',
527
+ sellAmount: '10000000',
528
+ buyAmount: '10000000000',
529
+ },
530
+ ],
531
+ [
532
+ {
533
+ name: 'ETH',
534
+ sellAmount: '10000000000',
535
+ buyAmount: '10000000',
536
+ },
537
+ {
538
+ name: 'USDC',
539
+ sellAmount: '10000000',
540
+ buyAmount: '10000000000',
541
+ },
542
+ ],
543
+ ];
544
+
545
+ sideToContractMethods.forEach((contractMethods, side) =>
546
+ describe(`${side}`, () => {
547
+ contractMethods.forEach((contractMethod: ContractMethod) => {
548
+ pairs.forEach(pair => {
549
+ describe(`${contractMethod}`, () => {
550
+ it(`${pair[0].name} -> ${pair[1].name}`, async () => {
551
+ await testE2E(
552
+ tokens[pair[0].name],
553
+ tokens[pair[1].name],
554
+ holders[pair[0].name],
555
+ side === SwapSide.SELL
556
+ ? pair[0].sellAmount
557
+ : pair[0].buyAmount,
558
+ side,
559
+ dexKey,
560
+ contractMethod,
561
+ network,
562
+ provider,
563
+ );
564
+ });
565
+ it(`${pair[1].name} -> ${pair[0].name}`, async () => {
566
+ await testE2E(
567
+ tokens[pair[1].name],
568
+ tokens[pair[0].name],
569
+ holders[pair[1].name],
570
+ side === SwapSide.SELL
571
+ ? pair[1].sellAmount
572
+ : pair[1].buyAmount,
573
+ side,
574
+ dexKey,
575
+ contractMethod,
576
+ network,
577
+ provider,
578
+ );
579
+ });
580
+ });
581
+ });
582
+ });
583
+ }),
584
+ );
585
+ });
586
+ });
587
+
588
+ describe('Fantom', () => {
589
+ const network = Network.FANTOM;
590
+ const tokens = Tokens[network];
591
+ const holders = Holders[network];
592
+ const provider = new StaticJsonRpcProvider(
593
+ generateConfig(network).privateHttpProvider,
594
+ network,
595
+ );
596
+ describe('SpiritSwapV3', () => {
597
+ const dexKey = 'SpiritSwapV3';
598
+
599
+ const sideToContractMethods = new Map([
504
600
  [
505
- {
506
- name: 'FTM',
507
- sellAmount: '1000000000000000',
508
- buyAmount: '100',
509
- },
510
- {
511
- name: 'USDC',
512
- sellAmount: '100',
513
- buyAmount: '10000000000000000',
514
- },
601
+ SwapSide.SELL,
602
+ [
603
+ ContractMethod.simpleSwap,
604
+ ContractMethod.multiSwap,
605
+ ContractMethod.megaSwap,
606
+ ],
515
607
  ],
516
- ];
608
+ [ SwapSide.BUY, [ ContractMethod.simpleBuy, ContractMethod.buy ] ],
609
+ ]);
517
610
 
518
- sideToContractMethods.forEach((contractMethods, side) =>
519
- describe(`${side}`, () => {
520
- contractMethods.forEach((contractMethod: ContractMethod) => {
521
- pairs.forEach(pair => {
522
- describe(`${contractMethod}`, () => {
523
- it(`${pair[0].name} -> ${pair[1].name}`, async () => {
524
- await testE2E(
525
- tokens[pair[0].name],
526
- tokens[pair[1].name],
527
- holders[pair[0].name],
528
- side === SwapSide.SELL
529
- ? pair[0].sellAmount
530
- : pair[0].buyAmount,
531
- side,
532
- dexKey,
533
- contractMethod,
534
- network,
535
- provider,
536
- );
537
- });
538
- it(`${pair[1].name} -> ${pair[0].name}`, async () => {
539
- await testE2E(
540
- tokens[pair[1].name],
541
- tokens[pair[0].name],
542
- holders[pair[1].name],
543
- side === SwapSide.SELL
544
- ? pair[1].sellAmount
545
- : pair[1].buyAmount,
546
- side,
547
- dexKey,
548
- contractMethod,
549
- network,
550
- provider,
551
- );
611
+ const pairs: { name: string; sellAmount: string; buyAmount: string }[][] =
612
+ [
613
+ [
614
+ {
615
+ name: 'USDC',
616
+ sellAmount: '100',
617
+ buyAmount: '10000000000000000',
618
+ },
619
+ {
620
+ name: 'WFTM',
621
+ sellAmount: '10000000000000000',
622
+ buyAmount: '100',
623
+ },
624
+ ],
625
+ [
626
+ {
627
+ name: 'FTM',
628
+ sellAmount: '1000000000000000',
629
+ buyAmount: '100',
630
+ },
631
+ {
632
+ name: 'USDC',
633
+ sellAmount: '100',
634
+ buyAmount: '10000000000000000',
635
+ },
636
+ ],
637
+ ];
638
+
639
+ sideToContractMethods.forEach((contractMethods, side) =>
640
+ describe(`${side}`, () => {
641
+ contractMethods.forEach((contractMethod: ContractMethod) => {
642
+ pairs.forEach(pair => {
643
+ describe(`${contractMethod}`, () => {
644
+ it(`${pair[0].name} -> ${pair[1].name}`, async () => {
645
+ await testE2E(
646
+ tokens[pair[0].name],
647
+ tokens[pair[1].name],
648
+ holders[pair[0].name],
649
+ side === SwapSide.SELL
650
+ ? pair[0].sellAmount
651
+ : pair[0].buyAmount,
652
+ side,
653
+ dexKey,
654
+ contractMethod,
655
+ network,
656
+ provider,
657
+ );
658
+ });
659
+ it(`${pair[1].name} -> ${pair[0].name}`, async () => {
660
+ await testE2E(
661
+ tokens[pair[1].name],
662
+ tokens[pair[0].name],
663
+ holders[pair[1].name],
664
+ side === SwapSide.SELL
665
+ ? pair[1].sellAmount
666
+ : pair[1].buyAmount,
667
+ side,
668
+ dexKey,
669
+ contractMethod,
670
+ network,
671
+ provider,
672
+ );
673
+ });
552
674
  });
553
675
  });
554
676
  });
555
- });
556
- }),
557
- );
677
+ }),
678
+ );
679
+ });
558
680
  });
559
681
  });
560
682
  });