@paraswap/dex-lib 2.16.3-rfq-direct.0 → 2.16.4-traderjoev2.1.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 (92) hide show
  1. package/build/abi/TraderJoeV21Router.json +1489 -0
  2. package/build/config.js +2 -2
  3. package/build/dex/generic-rfq/generic-rfq.d.ts +4 -8
  4. package/build/dex/generic-rfq/generic-rfq.js +0 -39
  5. package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
  6. package/build/dex/generic-rfq/types.d.ts +1 -17
  7. package/build/dex/generic-rfq/types.js +1 -6
  8. package/build/dex/generic-rfq/types.js.map +1 -1
  9. package/build/dex/index.js +5 -1
  10. package/build/dex/index.js.map +1 -1
  11. package/build/dex/maverick-v1/config.js +1 -1
  12. package/build/dex/maverick-v1/config.js.map +1 -1
  13. package/build/dex/paraswap-limit-orders/types.d.ts +6 -7
  14. package/build/dex/quickswap/config.js +8 -0
  15. package/build/dex/quickswap/config.js.map +1 -1
  16. package/build/dex/quickswap/spiritswap-v3.d.ts +6 -0
  17. package/build/dex/quickswap/spiritswap-v3.js +19 -0
  18. package/build/dex/quickswap/spiritswap-v3.js.map +1 -0
  19. package/build/dex/trader-joe-v2.1.d.ts +43 -0
  20. package/build/dex/trader-joe-v2.1.js +74 -0
  21. package/build/dex/trader-joe-v2.1.js.map +1 -0
  22. package/build/dex/uniswap-v3/config.js +4 -0
  23. package/build/dex/uniswap-v3/config.js.map +1 -1
  24. package/package.json +3 -3
  25. package/src/abi/TraderJoeV21Router.json +1489 -0
  26. package/src/config.ts +2 -2
  27. package/src/dex/generic-rfq/generic-rfq.ts +2 -70
  28. package/src/dex/generic-rfq/types.ts +1 -26
  29. package/src/dex/index.ts +5 -1
  30. package/src/dex/maverick-v1/config.ts +1 -1
  31. package/src/dex/paraswap-limit-orders/types.ts +9 -11
  32. package/src/dex/quickswap/config.ts +9 -0
  33. package/src/dex/quickswap/quickswap-e2e.test.ts +94 -0
  34. package/src/dex/quickswap/spiritswap-v3.ts +19 -0
  35. package/src/dex/trader-joe-v2.1.ts +151 -0
  36. package/src/dex/uniswap-v3/config.ts +4 -0
  37. package/tests/constants-e2e.ts +2 -2
  38. package/tests/utils-e2e.ts +2 -2
  39. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  40. package/.idea/misc.xml +0 -6
  41. package/.idea/modules.xml +0 -8
  42. package/.idea/vcs.xml +0 -6
  43. package/.vscode/launch.json +0 -21
  44. package/build/abi/AugustusRFQRouter.abi.json +0 -1248
  45. package/build/abi/woo-fi/WooFeeManager.abi.json +0 -318
  46. package/build/abi/woo-fi/WooPP.abi.json +0 -548
  47. package/build/abi/woo-fi/Wooracle.abi.json +0 -260
  48. package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
  49. package/build/dex/aave-v3/tokens/avalanche.json +0 -50
  50. package/build/dex/aave-v3/tokens/fantom.json +0 -62
  51. package/build/dex/aave-v3/tokens/mainnet.json +0 -44
  52. package/build/dex/aave-v3/tokens/optimism.json +0 -50
  53. package/build/dex/aave-v3/tokens/polygon.json +0 -98
  54. package/build/dex/balancer-v2/VirtualBoostedPool.d.ts +0 -79
  55. package/build/dex/balancer-v2/VirtualBoostedPool.js +0 -382
  56. package/build/dex/balancer-v2/VirtualBoostedPool.js.map +0 -1
  57. package/build/dex/quickswap-v3.d.ts +0 -21
  58. package/build/dex/quickswap-v3.js +0 -40
  59. package/build/dex/quickswap-v3.js.map +0 -1
  60. package/build/dex/test-aave-v3/config.d.ts +0 -4
  61. package/build/dex/test-aave-v3/config.js +0 -15
  62. package/build/dex/test-aave-v3/config.js.map +0 -1
  63. package/build/dex/test-aave-v3/test-aave-v3-pool.d.ts +0 -39
  64. package/build/dex/test-aave-v3/test-aave-v3-pool.js +0 -63
  65. package/build/dex/test-aave-v3/test-aave-v3-pool.js.map +0 -1
  66. package/build/dex/test-aave-v3/test-aave-v3.d.ts +0 -37
  67. package/build/dex/test-aave-v3/test-aave-v3.js +0 -126
  68. package/build/dex/test-aave-v3/test-aave-v3.js.map +0 -1
  69. package/build/dex/test-aave-v3/types.d.ts +0 -6
  70. package/build/dex/test-aave-v3/types.js +0 -3
  71. package/build/dex/test-aave-v3/types.js.map +0 -1
  72. package/build/dex/woo-fi/config.d.ts +0 -4
  73. package/build/dex/woo-fi/config.js +0 -141
  74. package/build/dex/woo-fi/config.js.map +0 -1
  75. package/build/dex/woo-fi/constants.d.ts +0 -5
  76. package/build/dex/woo-fi/constants.js +0 -20
  77. package/build/dex/woo-fi/constants.js.map +0 -1
  78. package/build/dex/woo-fi/types.d.ts +0 -48
  79. package/build/dex/woo-fi/types.js +0 -3
  80. package/build/dex/woo-fi/types.js.map +0 -1
  81. package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +0 -14
  82. package/build/dex/woo-fi/woo-fi-decimal-math.js +0 -42
  83. package/build/dex/woo-fi/woo-fi-decimal-math.js.map +0 -1
  84. package/build/dex/woo-fi/woo-fi-math.d.ts +0 -31
  85. package/build/dex/woo-fi/woo-fi-math.js +0 -300
  86. package/build/dex/woo-fi/woo-fi-math.js.map +0 -1
  87. package/build/dex/woo-fi/woo-fi.d.ts +0 -65
  88. package/build/dex/woo-fi/woo-fi.js +0 -480
  89. package/build/dex/woo-fi/woo-fi.js.map +0 -1
  90. package/compare-quotes.ts +0 -12
  91. package/fetch-rfq-quotes.ts +0 -148
  92. package/src/abi/AugustusRFQRouter.abi.json +0 -1248
package/src/config.ts CHANGED
@@ -240,8 +240,8 @@ const baseConfigs: { [network: number]: BaseConfig } = {
240
240
  process.env[`HASHFLOW_DISABLED_MMS_250`]?.split(',') || [],
241
241
 
242
242
  adapterAddresses: {
243
- FantomAdapter01: '0x66152A2a538644Ae125570De522ADEaC9E41D865',
244
- FantomBuyAdapter: '0x27eb327B7255a2bF666EBB4D60AB4752dA4611b9',
243
+ FantomAdapter01: '0x434C1Cca4842629230067674Dd54E21a14D9FD5D',
244
+ FantomBuyAdapter: '0xFb8773AA4Fd02e54bbd352061D8Be1911FAa210a',
245
245
  },
246
246
  uniswapV2ExchangeRouterAddress:
247
247
  '0xAB86e2bC9ec5485a9b60E684BA6d49bf4686ACC2',
@@ -6,7 +6,6 @@ import {
6
6
  PreprocessTransactionOptions,
7
7
  Config,
8
8
  PoolLiquidity,
9
- TxInfo,
10
9
  } from '../../types';
11
10
  import { Network, SwapSide } from '../../constants';
12
11
  import { IDexHelper } from '../../dex-helper';
@@ -16,19 +15,12 @@ import { ParaSwapLimitOrdersData } from '../paraswap-limit-orders/types';
16
15
  import { ONE_ORDER_GASCOST } from '../paraswap-limit-orders/constant';
17
16
  import { RateFetcher } from './rate-fetcher';
18
17
  import {
19
- AugustusRFQRouterFunctions,
20
- GenericRFQParam,
21
18
  PriceAndAmountBigNumber,
22
19
  RFQConfig,
23
20
  SlippageCheckError,
24
21
  } from './types';
25
- import { Address, NumberAsString, OptimalSwapExchange } from '@paraswap/core';
22
+ import { OptimalSwapExchange } from '@paraswap/core';
26
23
  import { BI_MAX_UINT256 } from '../../bigint-constants';
27
- import { Interface } from 'ethers/lib/utils';
28
- import AugustusRFQRouterABI from '../../abi/AugustusRFQRouter.abi.json';
29
- import { IDexTxBuilder } from '../idex';
30
- import { isETHAddress } from '../../utils';
31
- import { assert } from 'ts-essentials';
32
24
 
33
25
  export const OVERORDER_BPS = 100;
34
26
  export const BPS_MAX_VALUE = 10000n;
@@ -36,15 +28,10 @@ export const BPS_MAX_VALUE = 10000n;
36
28
  export const overOrder = (amount: string, bps: number) =>
37
29
  ((BigInt(amount) * (BPS_MAX_VALUE + BigInt(bps))) / BPS_MAX_VALUE).toString();
38
30
 
39
- export class GenericRFQ
40
- extends ParaSwapLimitOrders
41
- implements IDexTxBuilder<ParaSwapLimitOrdersData, GenericRFQParam>
42
- {
31
+ export class GenericRFQ extends ParaSwapLimitOrders {
43
32
  readonly isStatePollingDex = true;
44
33
  private rateFetcher: RateFetcher;
45
34
 
46
- private routerInterface: Interface;
47
-
48
35
  public static dexKeysWithNetwork: { key: string; networks: Network[] }[] = [];
49
36
 
50
37
  static builderDexKeysWithNetwork(config: Config): void {
@@ -64,7 +51,6 @@ export class GenericRFQ
64
51
  ) {
65
52
  super(network, dexKey, dexHelper);
66
53
  this.rateFetcher = new RateFetcher(dexHelper, config, dexKey, this.logger);
67
- this.routerInterface = new Interface(AugustusRFQRouterABI);
68
54
  }
69
55
 
70
56
  async initializePricing(blockNumber: number): Promise<void> {
@@ -311,58 +297,4 @@ export class GenericRFQ
311
297
  this.rateFetcher.stop();
312
298
  }
313
299
  }
314
-
315
- getDirectParam(
316
- srcToken: Address,
317
- destToken: Address,
318
- srcAmount: NumberAsString,
319
- destAmount: NumberAsString,
320
- data: ParaSwapLimitOrdersData,
321
- side: SwapSide,
322
- permit: string,
323
- contractMethod: string,
324
- ): TxInfo<GenericRFQParam> {
325
- const usePermit = permit !== '0x';
326
-
327
- assert(
328
- contractMethod ===
329
- (usePermit
330
- ? AugustusRFQRouterFunctions.swapOnAugustusRFQWithPermit
331
- : AugustusRFQRouterFunctions.swapOnAugustusRFQ),
332
- );
333
-
334
- if (data.orderInfos === null && data.orderInfos!.length === 1) {
335
- throw new Error('`orderInfos` cannot be empty');
336
- }
337
-
338
- const encoder = (...params: GenericRFQParam) => {
339
- return this.routerInterface.encodeFunctionData(
340
- usePermit
341
- ? AugustusRFQRouterFunctions.swapOnAugustusRFQWithPermit
342
- : AugustusRFQRouterFunctions.swapOnAugustusRFQ,
343
- params,
344
- );
345
- };
346
-
347
- const wrapETH = isETHAddress(srcAmount) ? 1 : 0;
348
- return {
349
- params: usePermit
350
- ? [
351
- data.orderInfos![0].order,
352
- data.orderInfos![0].signature,
353
- wrapETH,
354
- permit,
355
- ]
356
- : [data.orderInfos![0].order, data.orderInfos![0].signature, wrapETH],
357
- encoder,
358
- networkFee: '0',
359
- };
360
- }
361
-
362
- static getDirectFunctionName(): string[] {
363
- return [
364
- AugustusRFQRouterFunctions.swapOnAugustusRFQ,
365
- AugustusRFQRouterFunctions.swapOnAugustusRFQWithPermit,
366
- ];
367
- }
368
300
  }
@@ -1,10 +1,7 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { RequestConfig } from '../../dex-helper/irequest-wrapper';
3
3
  import { Address, Token } from '../../types';
4
- import {
5
- AugustusOrderWithString,
6
- OrderInfoType,
7
- } from '../paraswap-limit-orders/types';
4
+ import { AugustusOrderWithString } from '../paraswap-limit-orders/types';
8
5
 
9
6
  export type Pair = {
10
7
  base: string;
@@ -99,25 +96,3 @@ export type RFQFirmRateResponse = {
99
96
  };
100
97
 
101
98
  export class SlippageCheckError extends Error {}
102
-
103
- export enum AugustusRFQRouterFunctions {
104
- swapOnAugustusRFQ = 'swapOnAugustusRFQ',
105
- swapOnAugustusRFQWithPermit = 'swapOnAugustusRFQWithPermit',
106
- }
107
-
108
- export type SwapOnGenericRFQParam = [
109
- order: OrderInfoType,
110
- signature: string,
111
- wrapETH: number,
112
- ];
113
-
114
- export type SwapOnGenericRFQWithPermitParam = [
115
- order: OrderInfoType,
116
- signature: string,
117
- wrapETH: number,
118
- permit: string,
119
- ];
120
-
121
- export type GenericRFQParam =
122
- | SwapOnGenericRFQParam
123
- | SwapOnGenericRFQWithPermitParam;
package/src/dex/index.ts CHANGED
@@ -63,7 +63,9 @@ import { MaverickV1 } from './maverick-v1/maverick-v1';
63
63
  import { QuickSwapV3 } from './quickswap/quickswap-v3';
64
64
  import { ZyberSwapV3 } from './quickswap/zyberswap-v3';
65
65
  import { TraderJoeV2 } from './trader-joe-v2';
66
+ import { SpiritSwapV3 } from './quickswap/spiritswap-v3';
66
67
  import { PancakeswapV3 } from './uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3';
68
+ import { TraderJoeV21 } from './trader-joe-v2.1';
67
69
 
68
70
  const LegacyDexes = [
69
71
  CurveV2,
@@ -81,7 +83,9 @@ const LegacyDexes = [
81
83
  DodoV2,
82
84
  QuickSwapV3,
83
85
  ZyberSwapV3,
86
+ SpiritSwapV3,
84
87
  TraderJoeV2,
88
+ TraderJoeV21,
85
89
  Jarvis,
86
90
  Lido,
87
91
  AugustusRFQOrder,
@@ -215,7 +219,7 @@ export class DexAdapterService {
215
219
  this.genericRFQDexKeys.add(rfqName.toLowerCase());
216
220
  });
217
221
 
218
- this.directFunctionsNames = [...LegacyDexes, ...Dexes, GenericRFQ]
222
+ this.directFunctionsNames = [...LegacyDexes, ...Dexes]
219
223
  .flatMap(dexAdapter => {
220
224
  const _dexAdapter = dexAdapter as IGetDirectFunctionName;
221
225
  return _dexAdapter.getDirectFunctionName
@@ -10,7 +10,7 @@ export const MaverickV1Config: DexConfigMap<DexParams> = {
10
10
  MaverickV1: {
11
11
  [Network.MAINNET]: {
12
12
  subgraphURL:
13
- 'https://gateway.thegraph.com/api/4b42aaaee3e81a3f29390e9df7010cbc/subgraphs/id/9n4uEbt1XV6DnYH7AGHJ84Gh2fpu68iwxwBKnWqVMX9G',
13
+ 'https://api.thegraph.com/subgraphs/name/maverickprotocol/maverick-mainnet',
14
14
  routerAddress: '0x4a585e0f7c18e2c414221d6402652d5e0990e5f8',
15
15
  poolInspectorAddress: '0xaA5BF61a664109e959D69C38734d4EA7dF74e456',
16
16
  },
@@ -58,18 +58,16 @@ export type DexParams = {
58
58
  rfqAddress: string;
59
59
  };
60
60
 
61
- export type OrderInfoType = Omit<
62
- AugustusOrder,
63
- 'nonceAndMeta' | 'makerAmount' | 'takerAmount' | 'expiry'
64
- > & {
65
- expiry: string;
66
- nonceAndMeta: BigIntAsString;
67
- makerAmount: BigIntAsString;
68
- takerAmount: BigIntAsString;
69
- };
70
-
71
61
  export type OrderInfo = {
72
- order: OrderInfoType;
62
+ order: Omit<
63
+ AugustusOrder,
64
+ 'nonceAndMeta' | 'makerAmount' | 'takerAmount' | 'expiry'
65
+ > & {
66
+ expiry: string;
67
+ nonceAndMeta: BigIntAsString;
68
+ makerAmount: BigIntAsString;
69
+ takerAmount: BigIntAsString;
70
+ };
73
71
  signature: string;
74
72
  takerTokenFillAmount: BigIntAsString;
75
73
  permitTakerAsset: string;
@@ -21,4 +21,13 @@ export const QuickSwapConfig: DexConfigMap<DexParams> = {
21
21
  '0xfa2ad44b9e39d38a7d396bb44a41ea957ac7b622c5c6afdc285728c300b3382a',
22
22
  },
23
23
  },
24
+ SpiritSwapV3: {
25
+ [Network.FANTOM]: {
26
+ factoryAddress: '0xC58A98644fCeee73bc2B6d349B3102627e2Ec58e',
27
+ router: '0x03108EDEd4902e89781839c885496c6de9D21956',
28
+ quoteAddress: '0xc4D1310D60A36c7d849A332Be8Dcff29603fe907',
29
+ initCode:
30
+ '0xa360004fb86ddf4cd7fe9aa67d0c6a7f7812d9069142659003dc503e1d7d241f',
31
+ },
32
+ },
24
33
  };
@@ -354,4 +354,98 @@ describe('QuickSwap', () => {
354
354
  });
355
355
  });
356
356
  });
357
+
358
+ describe('Fantom', () => {
359
+ const network = Network.FANTOM;
360
+ const tokens = Tokens[network];
361
+ const holders = Holders[network];
362
+ const provider = new StaticJsonRpcProvider(
363
+ generateConfig(network).privateHttpProvider,
364
+ network,
365
+ );
366
+ describe('SpiritSwapV3', () => {
367
+ const dexKey = 'SpiritSwapV3';
368
+
369
+ const sideToContractMethods = new Map([
370
+ [
371
+ SwapSide.SELL,
372
+ [
373
+ ContractMethod.simpleSwap,
374
+ ContractMethod.multiSwap,
375
+ ContractMethod.megaSwap,
376
+ ],
377
+ ],
378
+ [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
379
+ ]);
380
+
381
+ const pairs: { name: string; sellAmount: string; buyAmount: string }[][] =
382
+ [
383
+ [
384
+ {
385
+ name: 'USDC',
386
+ sellAmount: '100',
387
+ buyAmount: '10000000000000000',
388
+ },
389
+ {
390
+ name: 'WFTM',
391
+ sellAmount: '10000000000000000',
392
+ buyAmount: '100',
393
+ },
394
+ ],
395
+ [
396
+ {
397
+ name: 'FTM',
398
+ sellAmount: '1000000000000000',
399
+ buyAmount: '100',
400
+ },
401
+ {
402
+ name: 'USDC',
403
+ sellAmount: '100',
404
+ buyAmount: '10000000000000000',
405
+ },
406
+ ],
407
+ ];
408
+
409
+ sideToContractMethods.forEach((contractMethods, side) =>
410
+ describe(`${side}`, () => {
411
+ contractMethods.forEach((contractMethod: ContractMethod) => {
412
+ pairs.forEach(pair => {
413
+ describe(`${contractMethod}`, () => {
414
+ it(`${pair[0].name} -> ${pair[1].name}`, async () => {
415
+ await testE2E(
416
+ tokens[pair[0].name],
417
+ tokens[pair[1].name],
418
+ holders[pair[0].name],
419
+ side === SwapSide.SELL
420
+ ? pair[0].sellAmount
421
+ : pair[0].buyAmount,
422
+ side,
423
+ dexKey,
424
+ contractMethod,
425
+ network,
426
+ provider,
427
+ );
428
+ });
429
+ it(`${pair[1].name} -> ${pair[0].name}`, async () => {
430
+ await testE2E(
431
+ tokens[pair[1].name],
432
+ tokens[pair[0].name],
433
+ holders[pair[1].name],
434
+ side === SwapSide.SELL
435
+ ? pair[1].sellAmount
436
+ : pair[1].buyAmount,
437
+ side,
438
+ dexKey,
439
+ contractMethod,
440
+ network,
441
+ provider,
442
+ );
443
+ });
444
+ });
445
+ });
446
+ });
447
+ }),
448
+ );
449
+ });
450
+ });
357
451
  });
@@ -0,0 +1,19 @@
1
+ import { IDexHelper } from '../../dex-helper';
2
+ import _ from 'lodash';
3
+ import { QuickSwapConfig } from './config';
4
+ import { QuickSwapV3 } from './quickswap-v3';
5
+
6
+ const config = _.pick(QuickSwapConfig, ['SpiritSwapV3']).SpiritSwapV3;
7
+
8
+ export class SpiritSwapV3 extends QuickSwapV3 {
9
+ static dexKeys = ['spiritswapv3'];
10
+
11
+ // public static dexKeysWithNetwork
12
+ constructor(dexHelper: IDexHelper) {
13
+ super(
14
+ dexHelper,
15
+ 'spiritswapv3',
16
+ config[dexHelper.config.data.network].router,
17
+ );
18
+ }
19
+ }
@@ -0,0 +1,151 @@
1
+ import { Network, SwapSide } from '../constants';
2
+ import { AdapterExchangeParam, Address, SimpleExchangeParam } from '../types';
3
+ import { IDexTxBuilder } from './idex';
4
+ import { IDexHelper } from '../dex-helper';
5
+ import {
6
+ getLocalDeadlineAsFriendlyPlaceholder,
7
+ SimpleExchange,
8
+ } from './simple-exchange';
9
+ import { NumberAsString } from '@paraswap/core';
10
+ import { AsyncOrSync } from 'ts-essentials';
11
+ import { Interface, JsonFragment } from '@ethersproject/abi';
12
+ import TraderJoeV21RouterABI from '../abi/TraderJoeV21Router.json';
13
+
14
+ const TRADERJOE_V2_1_ROUTER_ADDRESS: { [network: number]: Address } = {
15
+ [Network.AVALANCHE]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
16
+ [Network.ARBITRUM]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
17
+ [Network.BSC]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
18
+ };
19
+
20
+ type RouterPath = [
21
+ pairBinSteps: NumberAsString[],
22
+ versions: NumberAsString[],
23
+ tokenPath: Address[],
24
+ ];
25
+ type TraderJoeV2RouterSellParams = [
26
+ _amountIn: NumberAsString,
27
+ _amountOutMin: NumberAsString,
28
+ _routerPath: RouterPath,
29
+ to: Address,
30
+ _deadline: string,
31
+ ];
32
+
33
+ type TraderJoeV2RouterBuyParams = [
34
+ _amountOut: NumberAsString,
35
+ _amountInMax: NumberAsString,
36
+ _routerPath: RouterPath,
37
+ to: Address,
38
+ _deadline: string,
39
+ ];
40
+
41
+ type TraderJoeV2RouterParam =
42
+ | TraderJoeV2RouterSellParams
43
+ | TraderJoeV2RouterBuyParams;
44
+
45
+ export type TraderJoeV2Data = {
46
+ tokenIn: string; // redundant
47
+ tokenOut: string; // redundant
48
+ binStep: string;
49
+ };
50
+
51
+ enum TraderJoeV2RouterFunctions {
52
+ swapExactTokensForTokens = 'swapExactTokensForTokens',
53
+ swapTokensForExactTokens = 'swapTokensForExactTokens',
54
+ }
55
+ export class TraderJoeV21
56
+ extends SimpleExchange
57
+ implements IDexTxBuilder<TraderJoeV2Data, TraderJoeV2RouterParam>
58
+ {
59
+ static dexKeys = ['traderjoev2.1'];
60
+ protected routerAddress: string;
61
+ exchangeRouterInterface: Interface;
62
+ needWrapNative = true;
63
+
64
+ constructor(dexHelper: IDexHelper) {
65
+ super(dexHelper, 'traderjoev2.1');
66
+
67
+ this.routerAddress =
68
+ TRADERJOE_V2_1_ROUTER_ADDRESS[dexHelper.config.data.network];
69
+
70
+ this.exchangeRouterInterface = new Interface(
71
+ TraderJoeV21RouterABI as JsonFragment[],
72
+ );
73
+ }
74
+
75
+ getAdapterParam(
76
+ srcToken: Address,
77
+ destToken: Address,
78
+ srcAmount: NumberAsString,
79
+ destAmount: NumberAsString,
80
+ data: TraderJoeV2Data,
81
+ side: SwapSide,
82
+ ): AdapterExchangeParam {
83
+ const payload = this.abiCoder.encodeParameter(
84
+ {
85
+ ParentStruct: {
86
+ _pairBinSteps: 'uint256[]',
87
+ _tokenPath: 'address[]',
88
+ _deadline: 'uint256',
89
+ _mintOutAmount: 'uint256',
90
+ },
91
+ },
92
+ {
93
+ _pairBinSteps: [data.binStep],
94
+ _tokenPath: [data.tokenIn, data.tokenOut], // FIXME: redundant, shoot & read from contract
95
+ _deadline: getLocalDeadlineAsFriendlyPlaceholder(), // FIXME: more gas efficient to pass block.timestamp in adapter
96
+ _minOutAmount: destAmount,
97
+ },
98
+ );
99
+
100
+ return {
101
+ targetExchange: this.routerAddress,
102
+ payload,
103
+ networkFee: '0',
104
+ };
105
+ }
106
+
107
+ getSimpleParam(
108
+ srcToken: Address,
109
+ destToken: Address,
110
+ srcAmount: NumberAsString,
111
+ destAmount: NumberAsString,
112
+ data: TraderJoeV2Data,
113
+ side: SwapSide,
114
+ ): AsyncOrSync<SimpleExchangeParam> {
115
+ const swapFunction =
116
+ side === SwapSide.SELL
117
+ ? TraderJoeV2RouterFunctions.swapExactTokensForTokens
118
+ : TraderJoeV2RouterFunctions.swapTokensForExactTokens;
119
+
120
+ const swapFunctionParams: TraderJoeV2RouterParam =
121
+ side === SwapSide.SELL
122
+ ? [
123
+ srcAmount,
124
+ destAmount,
125
+ [[data.binStep], ['2'], [srcToken, destToken]],
126
+ this.augustusAddress,
127
+ getLocalDeadlineAsFriendlyPlaceholder(),
128
+ ]
129
+ : [
130
+ destAmount,
131
+ srcAmount,
132
+ [[data.binStep], ['2'], [srcToken, destToken]],
133
+ this.augustusAddress,
134
+ getLocalDeadlineAsFriendlyPlaceholder(),
135
+ ];
136
+
137
+ const swapData = this.exchangeRouterInterface.encodeFunctionData(
138
+ swapFunction,
139
+ swapFunctionParams,
140
+ );
141
+
142
+ return this.buildSimpleParamWithoutWETHConversion(
143
+ srcToken,
144
+ srcAmount,
145
+ destToken,
146
+ destAmount,
147
+ swapData,
148
+ this.routerAddress,
149
+ );
150
+ }
151
+ }
@@ -141,4 +141,8 @@ export const Adapters: Record<number, AdapterMappings> = {
141
141
  [SwapSide.SELL]: [{ name: 'OptimismAdapter01', index: 3 }],
142
142
  [SwapSide.BUY]: [{ name: 'OptimismBuyAdapter', index: 2 }],
143
143
  },
144
+ [Network.FANTOM]: {
145
+ [SwapSide.SELL]: [{ name: 'FantomAdapter01', index: 11 }],
146
+ [SwapSide.BUY]: [{ name: 'FantomBuyAdapter', index: 3 }],
147
+ },
144
148
  };
@@ -904,7 +904,7 @@ export const Holders: {
904
904
  [Network.FANTOM]: {
905
905
  DAI: '0x370f4b2dcf75c94d8d4450b493661a9c6170d0b5',
906
906
  FTM: '0x431e81E5dfB5A24541b5Ff8762bDEF3f32F96354',
907
- WFTM: '0x431e81E5dfB5A24541b5Ff8762bDEF3f32F96354',
907
+ WFTM: '0x3e923747ca2675e096d812c3b24846ac39aed645',
908
908
  USDC: '0xe48793b1533b351ae184e1c3119d0955dde7b330',
909
909
  FUSDT: '0x9ade1c17d25246c405604344f89E8F23F8c1c632',
910
910
  POPS: '0x4b78b52e7de4d8b7d367297cb8a87c1875a9d591',
@@ -913,7 +913,7 @@ export const Holders: {
913
913
  MIM: '0xbcab7d083cf6a01e0dda9ed7f8a02b47d125e682',
914
914
  FRAX: '0x4423ac71f53ca92e2f2be5917a9c2468e7412f4a',
915
915
  nETH: '0x16b658270ac50c0063940ed287c401b3df7ccf70',
916
- WETH: '0x4ad64fd7ca6d6150614179b9bce4094bc18f29cb',
916
+ WETH: '0x7b7b957c284c2c227c980d6e2f804311947b84d0',
917
917
  SPIRIT: '0x0d0707963952f2fba59dd06f2b425ace40b492fe',
918
918
  wBOMB: '0x28aa4f9ffe21365473b64c161b566c3cdead0108',
919
919
  TOR: '0x70de4b5ed310fd93da3c0bae824fb99cb4d44dd8',
@@ -468,7 +468,7 @@ export async function newTestE2E({
468
468
  .addAllowance(
469
469
  senderAddress,
470
470
  config.tokenTransferProxyAddress,
471
- MAX_UINT,
471
+ amount.toString(),
472
472
  );
473
473
  } else {
474
474
  srcToken
@@ -476,7 +476,7 @@ export async function newTestE2E({
476
476
  .addAllowance(
477
477
  senderAddress,
478
478
  config.tokenTransferProxyAddress,
479
- MAX_UINT,
479
+ (BigInt(MAX_UINT) / 8n).toString(),
480
480
  );
481
481
  }
482
482
 
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
- </state>
5
- </component>
package/.idea/misc.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager">
4
- <output url="file://$PROJECT_DIR$/out" />
5
- </component>
6
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/paraswap-dex-lib.iml" filepath="$PROJECT_DIR$/paraswap-dex-lib.iml" />
6
- </modules>
7
- </component>
8
- </project>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>
@@ -1,21 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "Launch Program",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "program": "${workspaceFolder}/build/index.js",
15
- "preLaunchTask": "tsc: build - tsconfig.json",
16
- "outFiles": [
17
- "${workspaceFolder}/build/**/*.js"
18
- ]
19
- }
20
- ]
21
- }