@paraswap/dex-lib 2.16.4 → 2.16.5-direct-swaps.1

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 (138) hide show
  1. package/build/abi/DirectSwap.json +970 -0
  2. package/build/abi/woo-fi/WooFeeManager.abi.json +318 -0
  3. package/build/abi/woo-fi/WooPP.abi.json +548 -0
  4. package/build/abi/woo-fi/Wooracle.abi.json +260 -0
  5. package/build/config.js +14 -8
  6. package/build/config.js.map +1 -1
  7. package/build/dex/aave-v3/tokens/arbitrum.json +50 -0
  8. package/build/dex/aave-v3/tokens/avalanche.json +74 -0
  9. package/build/dex/aave-v3/tokens/fantom.json +62 -0
  10. package/build/dex/aave-v3/tokens/optimism.json +50 -0
  11. package/build/dex/aave-v3/tokens/polygon.json +116 -0
  12. package/build/dex/balancer-v2/balancer-v2.d.ts +9 -3
  13. package/build/dex/balancer-v2/balancer-v2.js +81 -0
  14. package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
  15. package/build/dex/balancer-v2/constants.d.ts +4 -0
  16. package/build/dex/balancer-v2/constants.js +6 -1
  17. package/build/dex/balancer-v2/constants.js.map +1 -1
  18. package/build/dex/balancer-v2/types.d.ts +18 -1
  19. package/build/dex/balancer-v2/types.js.map +1 -1
  20. package/build/dex/curve-v1/constants.d.ts +1 -0
  21. package/build/dex/curve-v1/constants.js +2 -1
  22. package/build/dex/curve-v1/constants.js.map +1 -1
  23. package/build/dex/curve-v1/curve-v1.d.ts +9 -3
  24. package/build/dex/curve-v1/curve-v1.js +90 -4
  25. package/build/dex/curve-v1/curve-v1.js.map +1 -1
  26. package/build/dex/curve-v1/types.d.ts +23 -0
  27. package/build/dex/curve-v1/types.js +6 -1
  28. package/build/dex/curve-v1/types.js.map +1 -1
  29. package/build/dex/curve-v1-factory/constants.d.ts +1 -0
  30. package/build/dex/curve-v1-factory/constants.js +2 -1
  31. package/build/dex/curve-v1-factory/constants.js.map +1 -1
  32. package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +11 -4
  33. package/build/dex/curve-v1-factory/curve-v1-factory.js +85 -0
  34. package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
  35. package/build/dex/curve-v1-factory/types.d.ts +23 -0
  36. package/build/dex/curve-v1-factory/types.js +6 -1
  37. package/build/dex/curve-v1-factory/types.js.map +1 -1
  38. package/build/dex/curve-v2.d.ts +28 -7
  39. package/build/dex/curve-v2.js +89 -1
  40. package/build/dex/curve-v2.js.map +1 -1
  41. package/build/dex/generic-rfq/generic-rfq.js +0 -1
  42. package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
  43. package/build/dex/idex.d.ts +1 -1
  44. package/build/dex/quickswap-v3.d.ts +21 -0
  45. package/build/dex/quickswap-v3.js +40 -0
  46. package/build/dex/quickswap-v3.js.map +1 -0
  47. package/build/dex/simple-exchange.d.ts +2 -0
  48. package/build/dex/simple-exchange.js +1 -0
  49. package/build/dex/simple-exchange.js.map +1 -1
  50. package/build/dex/test-dex/config.d.ts +4 -0
  51. package/build/dex/test-dex/config.js +15 -0
  52. package/build/dex/test-dex/config.js.map +1 -0
  53. package/build/dex/test-dex/test-dex-pool.d.ts +39 -0
  54. package/build/dex/test-dex/test-dex-pool.js +63 -0
  55. package/build/dex/test-dex/test-dex-pool.js.map +1 -0
  56. package/build/dex/test-dex/test-dex.d.ts +37 -0
  57. package/build/dex/test-dex/test-dex.js +126 -0
  58. package/build/dex/test-dex/test-dex.js.map +1 -0
  59. package/build/dex/test-dex/types.d.ts +6 -0
  60. package/build/dex/test-dex/types.js +3 -0
  61. package/build/dex/test-dex/types.js.map +1 -0
  62. package/build/dex/uniswap-v2/config.js +1 -1
  63. package/build/dex/uniswap-v2/config.js.map +1 -1
  64. package/build/dex/uniswap-v2/uniswap-v2.d.ts +1 -1
  65. package/build/dex/uniswap-v2/uniswap-v2.js +1 -1
  66. package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
  67. package/build/dex/uniswap-v3/constants.d.ts +4 -0
  68. package/build/dex/uniswap-v3/constants.js +6 -1
  69. package/build/dex/uniswap-v3/constants.js.map +1 -1
  70. package/build/dex/uniswap-v3/types.d.ts +20 -3
  71. package/build/dex/uniswap-v3/types.js.map +1 -1
  72. package/build/dex/uniswap-v3/uniswap-v3.d.ts +7 -1
  73. package/build/dex/uniswap-v3/uniswap-v3.js +85 -1
  74. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  75. package/build/dex/woo-fi/config.d.ts +4 -0
  76. package/build/dex/woo-fi/config.js +141 -0
  77. package/build/dex/woo-fi/config.js.map +1 -0
  78. package/build/dex/woo-fi/constants.d.ts +5 -0
  79. package/build/dex/woo-fi/constants.js +20 -0
  80. package/build/dex/woo-fi/constants.js.map +1 -0
  81. package/build/dex/woo-fi/types.d.ts +48 -0
  82. package/build/dex/woo-fi/types.js +3 -0
  83. package/build/dex/woo-fi/types.js.map +1 -0
  84. package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +14 -0
  85. package/build/dex/woo-fi/woo-fi-decimal-math.js +42 -0
  86. package/build/dex/woo-fi/woo-fi-decimal-math.js.map +1 -0
  87. package/build/dex/woo-fi/woo-fi-math.d.ts +31 -0
  88. package/build/dex/woo-fi/woo-fi-math.js +300 -0
  89. package/build/dex/woo-fi/woo-fi-math.js.map +1 -0
  90. package/build/dex/woo-fi/woo-fi.d.ts +65 -0
  91. package/build/dex/woo-fi/woo-fi.js +480 -0
  92. package/build/dex/woo-fi/woo-fi.js.map +1 -0
  93. package/build/dex/woo-fi-v2/woo-fi-math.d.ts +16 -0
  94. package/build/dex/woo-fi-v2/woo-fi-math.js +137 -0
  95. package/build/dex/woo-fi-v2/woo-fi-math.js.map +1 -0
  96. package/build/dex/zerox/index.d.ts +1 -1
  97. package/build/dex/zerox/index.js +1 -1
  98. package/build/dex/zerox/index.js.map +1 -1
  99. package/build/implementations/local-paraswap-sdk.js +5 -1
  100. package/build/implementations/local-paraswap-sdk.js.map +1 -1
  101. package/build/router/directswap.js +3 -1
  102. package/build/router/directswap.js.map +1 -1
  103. package/build/router/index.js.map +1 -1
  104. package/build/types.d.ts +1 -0
  105. package/package.json +5 -3
  106. package/src/abi/DirectSwap.json +970 -0
  107. package/src/config.ts +14 -8
  108. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +71 -0
  109. package/src/dex/balancer-v2/balancer-v2.ts +150 -3
  110. package/src/dex/balancer-v2/constants.ts +5 -0
  111. package/src/dex/balancer-v2/types.ts +19 -1
  112. package/src/dex/curve-v1/constants.ts +2 -0
  113. package/src/dex/curve-v1/curve-v1-e2e.test.ts +57 -0
  114. package/src/dex/curve-v1/curve-v1.ts +142 -5
  115. package/src/dex/curve-v1/types.ts +25 -0
  116. package/src/dex/curve-v1-factory/constants.ts +2 -0
  117. package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +1 -0
  118. package/src/dex/curve-v1-factory/curve-v1-factory.ts +138 -4
  119. package/src/dex/curve-v1-factory/types.ts +25 -0
  120. package/src/dex/curve-v2.ts +166 -8
  121. package/src/dex/generic-rfq/generic-rfq-e2e.test.ts +2 -2
  122. package/src/dex/generic-rfq/generic-rfq.ts +0 -1
  123. package/src/dex/idex.ts +6 -0
  124. package/src/dex/simple-exchange.ts +6 -0
  125. package/src/dex/uniswap-v2/config.ts +2 -1
  126. package/src/dex/uniswap-v2/uniswap-v2.ts +6 -0
  127. package/src/dex/uniswap-v3/constants.ts +5 -0
  128. package/src/dex/uniswap-v3/types.ts +23 -3
  129. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +100 -2
  130. package/src/dex/uniswap-v3/uniswap-v3.ts +138 -3
  131. package/src/dex/zerox/index.ts +7 -0
  132. package/src/implementations/local-paraswap-sdk.ts +8 -1
  133. package/src/router/directswap.ts +9 -0
  134. package/src/router/index.ts +0 -2
  135. package/src/types.ts +1 -0
  136. package/tests/constants-e2e.ts +3 -3
  137. package/tests/utils-e2e.ts +135 -20
  138. package/tests/utils.ts +52 -0
@@ -49,6 +49,20 @@ describe('UniswapV3 E2E', () => {
49
49
  provider,
50
50
  );
51
51
  });
52
+
53
+ it('directSwap SELL WETH -> USDC', async () => {
54
+ await testE2E(
55
+ tokens['WETH'],
56
+ tokens['USDC'],
57
+ holders['WETH'],
58
+ '1000000000000000000',
59
+ SwapSide.SELL,
60
+ dexKey,
61
+ ContractMethod.directUniV3Swap,
62
+ network,
63
+ provider,
64
+ );
65
+ });
52
66
  });
53
67
 
54
68
  describe('UniswapV3 POLYGON', () => {
@@ -64,7 +78,7 @@ describe('UniswapV3 E2E', () => {
64
78
  const tokenBSymbol: string = 'WETH';
65
79
  const nativeTokenSymbol = NativeTokenSymbols[network];
66
80
 
67
- const tokenAAmount: string = '11111000000';
81
+ const tokenAAmount: string = '11000000';
68
82
  const tokenBAmount: string = '11000000000000000000';
69
83
  const nativeTokenAmount = '11000000000000000000';
70
84
 
@@ -75,9 +89,17 @@ describe('UniswapV3 E2E', () => {
75
89
  ContractMethod.simpleSwap,
76
90
  ContractMethod.multiSwap,
77
91
  ContractMethod.megaSwap,
92
+ ContractMethod.directUniV3Swap,
93
+ ],
94
+ ],
95
+ [
96
+ SwapSide.BUY,
97
+ [
98
+ ContractMethod.simpleBuy,
99
+ ContractMethod.buy,
100
+ ContractMethod.directUniV3Buy,
78
101
  ],
79
102
  ],
80
- [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
81
103
  ]);
82
104
 
83
105
  sideToContractMethods.forEach((contractMethods, side) =>
@@ -202,6 +224,82 @@ describe('UniswapV3 E2E', () => {
202
224
  }),
203
225
  );
204
226
  });
227
+
228
+ describe('UniswapV3 Optimism', () => {
229
+ const network = Network.OPTIMISM;
230
+ const tokens = Tokens[network];
231
+ const holders = Holders[network];
232
+ const provider = new StaticJsonRpcProvider(
233
+ generateConfig(network).privateHttpProvider,
234
+ network,
235
+ );
236
+
237
+ const tokenASymbol: string = 'OP';
238
+ const tokenBSymbol: string = 'ETH';
239
+ const nativeTokenSymbol = NativeTokenSymbols[network];
240
+
241
+ const tokenAAmount: string = '1000000000000000000';
242
+ const tokenBAmount: string = '1000000000000000000';
243
+ const nativeTokenAmount = '1000000000000000000';
244
+
245
+ const sideToContractMethods = new Map([
246
+ [
247
+ SwapSide.SELL,
248
+ [
249
+ ContractMethod.simpleSwap,
250
+ ContractMethod.multiSwap,
251
+ ContractMethod.megaSwap,
252
+ ],
253
+ ],
254
+ [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
255
+ ]);
256
+
257
+ sideToContractMethods.forEach((contractMethods, side) =>
258
+ contractMethods.forEach((contractMethod: ContractMethod) => {
259
+ describe(`${contractMethod}`, () => {
260
+ it(`${network} ${side} ${contractMethod} ${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
261
+ await testE2E(
262
+ tokens[nativeTokenSymbol],
263
+ tokens[tokenASymbol],
264
+ holders[nativeTokenSymbol],
265
+ side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
266
+ side,
267
+ dexKey,
268
+ contractMethod,
269
+ network,
270
+ provider,
271
+ );
272
+ });
273
+ it(`${network} ${side} ${contractMethod} ${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
274
+ await testE2E(
275
+ tokens[tokenASymbol],
276
+ tokens[nativeTokenSymbol],
277
+ holders[tokenASymbol],
278
+ side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
279
+ side,
280
+ dexKey,
281
+ contractMethod,
282
+ network,
283
+ provider,
284
+ );
285
+ });
286
+ it(`${network} ${side} ${contractMethod} ${tokenASymbol} -> ${tokenBSymbol}`, async () => {
287
+ await testE2E(
288
+ tokens[tokenASymbol],
289
+ tokens[tokenBSymbol],
290
+ holders[tokenASymbol],
291
+ side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
292
+ side,
293
+ dexKey,
294
+ contractMethod,
295
+ network,
296
+ provider,
297
+ );
298
+ });
299
+ });
300
+ }),
301
+ );
302
+ });
205
303
  });
206
304
 
207
305
  describe('PancakeswapV3 E2E', () => {
@@ -11,6 +11,9 @@ import {
11
11
  Logger,
12
12
  NumberAsString,
13
13
  PoolPrices,
14
+ TxInfo,
15
+ PreprocessTransactionOptions,
16
+ ExchangeTxInfo,
14
17
  } from '../../types';
15
18
  import { SwapSide, Network, CACHE_PREFIX } from '../../constants';
16
19
  import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
@@ -19,6 +22,7 @@ import {
19
22
  getDexKeysWithNetwork,
20
23
  interpolate,
21
24
  isTruthy,
25
+ uuidToBytes16,
22
26
  } from '../../utils';
23
27
  import { IDex } from '../../dex/idex';
24
28
  import { IDexHelper } from '../../dex-helper/idex-helper';
@@ -29,6 +33,7 @@ import {
29
33
  UniswapV3Data,
30
34
  UniswapV3Functions,
31
35
  UniswapV3Param,
36
+ UniswapV3SimpleSwapParams,
32
37
  } from './types';
33
38
  import {
34
39
  getLocalDeadlineAsFriendlyPlaceholder,
@@ -39,13 +44,15 @@ import { UniswapV3EventPool } from './uniswap-v3-pool';
39
44
  import UniswapV3RouterABI from '../../abi/uniswap-v3/UniswapV3Router.abi.json';
40
45
  import UniswapV3QuoterABI from '../../abi/uniswap-v3/UniswapV3Quoter.abi.json';
41
46
  import UniswapV3MultiABI from '../../abi/uniswap-v3/UniswapMulti.abi.json';
47
+ import DirectSwapABI from '../../abi/DirectSwap.json';
42
48
  import UniswapV3StateMulticallABI from '../../abi/uniswap-v3/UniswapV3StateMulticall.abi.json';
43
49
  import {
50
+ DirectMethods,
44
51
  UNISWAPV3_EFFICIENCY_FACTOR,
45
52
  UNISWAPV3_FUNCTION_CALL_GAS_COST,
46
53
  UNISWAPV3_TICK_GAS_COST,
47
54
  } from './constants';
48
- import { DeepReadonly } from 'ts-essentials';
55
+ import { assert, DeepReadonly } from 'ts-essentials';
49
56
  import { uniswapV3Math } from './contract-math/uniswap-v3-math';
50
57
  import { Contract } from 'web3-eth-contract';
51
58
  import { AbiItem } from 'web3-utils';
@@ -55,6 +62,7 @@ import {
55
62
  DEFAULT_ID_ERC20,
56
63
  DEFAULT_ID_ERC20_AS_STRING,
57
64
  } from '../../lib/tokens/types';
65
+ import { OptimalSwapExchange } from '@paraswap/core';
58
66
 
59
67
  type PoolPairsInfo = {
60
68
  token0: Address;
@@ -76,6 +84,8 @@ export class UniswapV3
76
84
  readonly hasConstantPriceLargeAmounts = false;
77
85
  readonly needWrapNative = true;
78
86
 
87
+ readonly directSwapIface = new Interface(DirectSwapABI);
88
+
79
89
  intervalTask?: NodeJS.Timeout;
80
90
 
81
91
  public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
@@ -112,7 +122,7 @@ export class UniswapV3
112
122
  // To receive revert reasons
113
123
  this.dexHelper.web3Provider.eth.handleRevert = false;
114
124
 
115
- // Normalise once all config addresses and use across all scenarios
125
+ // Normalize once all config addresses and use across all scenarios
116
126
  this.config = this._toLowerForAllConfigAddresses();
117
127
 
118
128
  this.notExistingPoolSetKey =
@@ -445,6 +455,7 @@ export class UniswapV3
445
455
  fee: pool.feeCodeAsString,
446
456
  },
447
457
  ],
458
+ exchange: pool.poolAddress,
448
459
  },
449
460
  poolIdentifier: this.getPoolIdentifier(
450
461
  pool.token0,
@@ -726,6 +737,130 @@ export class UniswapV3
726
737
  return arr;
727
738
  }
728
739
 
740
+ getTokenFromAddress(address: Address): Token {
741
+ // In this Dex decimals are not used
742
+ return { address, decimals: 0 };
743
+ }
744
+
745
+ async preProcessTransaction(
746
+ optimalSwapExchange: OptimalSwapExchange<UniswapV3Data>,
747
+ srcToken: Token,
748
+ _0: Token,
749
+ _1: SwapSide,
750
+ options: PreprocessTransactionOptions,
751
+ ): Promise<[OptimalSwapExchange<UniswapV3Data>, ExchangeTxInfo]> {
752
+ if (!options.isDirectMethod) {
753
+ return [
754
+ optimalSwapExchange,
755
+ {
756
+ deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
757
+ },
758
+ ];
759
+ }
760
+
761
+ assert(
762
+ optimalSwapExchange.data !== undefined,
763
+ `preProcessTransaction: data field is missing`,
764
+ );
765
+
766
+ let isApproved: boolean | undefined;
767
+
768
+ try {
769
+ this.erc20Contract.options.address =
770
+ this.dexHelper.config.wrapETH(srcToken).address;
771
+ const allowance = await this.erc20Contract.methods
772
+ .allowance(this.augustusAddress, this.config.router)
773
+ .call(undefined, 'latest');
774
+ isApproved =
775
+ BigInt(allowance.toString()) >= BigInt(optimalSwapExchange.srcAmount);
776
+ } catch (e) {
777
+ this.logger.error(
778
+ `preProcessTransaction failed to retrieve allowance info: `,
779
+ e,
780
+ );
781
+ }
782
+
783
+ return [
784
+ {
785
+ ...optimalSwapExchange,
786
+ data: {
787
+ ...optimalSwapExchange.data,
788
+ isApproved,
789
+ },
790
+ },
791
+ {
792
+ deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
793
+ },
794
+ ];
795
+ }
796
+
797
+ getDirectParam(
798
+ srcToken: Address,
799
+ destToken: Address,
800
+ srcAmount: NumberAsString,
801
+ destAmount: NumberAsString,
802
+ expectedAmount: NumberAsString,
803
+ data: UniswapV3Data,
804
+ side: SwapSide,
805
+ permit: string,
806
+ uuid: string,
807
+ feePercent: NumberAsString,
808
+ deadline: NumberAsString,
809
+ partner: string,
810
+ beneficiary: string,
811
+ contractMethod?: string,
812
+ ): TxInfo<UniswapV3Param> {
813
+ if (
814
+ contractMethod !== DirectMethods.directSell &&
815
+ contractMethod !== DirectMethods.directBuy
816
+ ) {
817
+ throw new Error(`Invalid contract method ${contractMethod}`);
818
+ }
819
+
820
+ let isApproved: boolean = !!data.isApproved;
821
+ if (data.isApproved === undefined) {
822
+ this.logger.warn(`isApproved is undefined, defaulting to false`);
823
+ }
824
+
825
+ const path = this._encodePath(data.path, side);
826
+
827
+ const swapParams: UniswapV3Param = [
828
+ srcToken,
829
+ destToken,
830
+ this.config.router,
831
+ srcAmount,
832
+ destAmount,
833
+ expectedAmount,
834
+ feePercent,
835
+ deadline,
836
+ partner,
837
+ isApproved,
838
+ beneficiary,
839
+ path,
840
+ permit,
841
+ uuidToBytes16(uuid),
842
+ ];
843
+
844
+ const encoder = (...params: UniswapV3Param) => {
845
+ return this.directSwapIface.encodeFunctionData(
846
+ side === SwapSide.SELL
847
+ ? DirectMethods.directSell
848
+ : DirectMethods.directBuy,
849
+ [params],
850
+ );
851
+ };
852
+
853
+ return {
854
+ params: swapParams,
855
+ encoder,
856
+ networkFee: '0',
857
+ };
858
+ }
859
+
860
+ static getDirectFunctionName(): string[] {
861
+ return [DirectMethods.directSell, DirectMethods.directBuy];
862
+ }
863
+
729
864
  async getSimpleParam(
730
865
  srcToken: string,
731
866
  destToken: string,
@@ -740,7 +875,7 @@ export class UniswapV3
740
875
  : UniswapV3Functions.exactOutput;
741
876
 
742
877
  const path = this._encodePath(data.path, side);
743
- const swapFunctionParams: UniswapV3Param =
878
+ const swapFunctionParams: UniswapV3SimpleSwapParams =
744
879
  side === SwapSide.SELL
745
880
  ? {
746
881
  recipient: this.augustusAddress,
@@ -269,9 +269,16 @@ export class ZeroX
269
269
  destToken: Address,
270
270
  srcAmount: NumberAsString,
271
271
  destAmount: NumberAsString,
272
+ expectedAmount: NumberAsString,
272
273
  data: ZeroXData,
273
274
  side: SwapSide,
274
275
  permit: string,
276
+ uuid: string,
277
+ feePercent: NumberAsString,
278
+ deadline: NumberAsString,
279
+ partner: string,
280
+ beneficiary: string,
281
+ contractMethod?: string,
275
282
  ): TxInfo<ZeroXParam> {
276
283
  const usePermit = permit !== '0x';
277
284
  const encoder = (...params: ZeroXParam) => {
@@ -17,6 +17,8 @@ import {
17
17
  } from '../types';
18
18
  import { SwapSide, NULL_ADDRESS, ContractMethod } from '../constants';
19
19
  import { LimitOrderExchange } from '../dex/limit-order-exchange';
20
+ import { v4 as uuid } from 'uuid';
21
+ import { DirectContractMethods } from '@paraswap/core/build/constants';
20
22
 
21
23
  export interface IParaSwapSDK {
22
24
  getPrices(
@@ -196,6 +198,8 @@ export class LocalParaswapSDK implements IParaSwapSDK {
196
198
  : priceRoute.srcAmount,
197
199
  );
198
200
 
201
+ const contractMethod = priceRoute.contractMethod;
202
+
199
203
  // Call preprocessTransaction for each exchange before we build transaction
200
204
  try {
201
205
  priceRoute.bestRoute = await Promise.all(
@@ -225,6 +229,9 @@ export class LocalParaswapSDK implements IParaSwapSDK {
225
229
  {
226
230
  slippageFactor,
227
231
  txOrigin: userAddress,
232
+ isDirectMethod: DirectContractMethods.includes(
233
+ contractMethod as ContractMethod,
234
+ ),
228
235
  },
229
236
  );
230
237
 
@@ -255,7 +262,7 @@ export class LocalParaswapSDK implements IParaSwapSDK {
255
262
  partnerAddress: NULL_ADDRESS,
256
263
  partnerFeePercent: '0',
257
264
  deadline: deadline.toString(),
258
- uuid: '00000000-0000-0000-0000-000000000000',
265
+ uuid: uuid(),
259
266
  });
260
267
  }
261
268
  }
@@ -3,6 +3,7 @@ import { IDex } from '../dex/idex';
3
3
  import { Address, OptimalRate, TxInfo, Adapters } from '../types';
4
4
  import { SwapSide } from '../constants';
5
5
  import { DexAdapterService } from '../dex';
6
+ import { assert } from 'ts-essentials';
6
7
 
7
8
  export class DirectSwap<DexDirectReturn> implements IRouter<DexDirectReturn> {
8
9
  // This is just psuedo name as the DirectSwap
@@ -51,6 +52,7 @@ export class DirectSwap<DexDirectReturn> implements IRouter<DexDirectReturn> {
51
52
  );
52
53
 
53
54
  const swapExchange = priceRoute.bestRoute[0].swaps[0].swapExchanges[0];
55
+
54
56
  const srcAmount =
55
57
  priceRoute.side === SwapSide.SELL ? swapExchange.srcAmount : minMaxAmount;
56
58
  const destAmount =
@@ -63,9 +65,16 @@ export class DirectSwap<DexDirectReturn> implements IRouter<DexDirectReturn> {
63
65
  priceRoute.destToken,
64
66
  srcAmount,
65
67
  destAmount,
68
+ minMaxAmount,
66
69
  swapExchange.data,
67
70
  priceRoute.side,
68
71
  permit,
72
+ uuid,
73
+ // TODO: CLARIFY BEFORE PUTTING TO PROD IF PARTNER FEE IS EQUAL TO FEE PERCENT IN CONTRACT
74
+ partnerFeePercent,
75
+ deadline,
76
+ partnerAddress,
77
+ beneficiary,
69
78
  priceRoute.contractMethod,
70
79
  );
71
80
  }
@@ -5,9 +5,7 @@ import { Buy } from './buy';
5
5
  import { SimpleSwap, SimpleBuy } from './simpleswap';
6
6
  import { SimpleBuyNFT } from './simpleswapnft';
7
7
  import { DirectSwap } from './directswap';
8
- import { Adapters } from '../types';
9
8
  import { DexAdapterService } from '../dex';
10
- import { SwapSide } from '../constants';
11
9
 
12
10
  export class RouterService {
13
11
  hybridRouters = [
package/src/types.ts CHANGED
@@ -288,6 +288,7 @@ export type PreprocessTransactionOptions = {
288
288
  txOrigin: Address;
289
289
  hmac?: string;
290
290
  mockRfqAndLO?: boolean;
291
+ isDirectMethod?: boolean;
291
292
  };
292
293
 
293
294
  export type TransferFeeParams = {
@@ -875,10 +875,10 @@ export const Holders: {
875
875
  [Network.POLYGON]: {
876
876
  MATIC: '0xe7804c37c13166fF0b37F5aE0BB07A3aEbb6e245',
877
877
  DAI: '0x06959153B974D0D5fDfd87D561db6d8d4FA0bb0B',
878
- WETH: '0x72a53cdbbcc1b9efa39c834a540550e23463aacb',
878
+ WETH: '0x62ac55b745f9b08f1a81dcbbe630277095cf4be1',
879
879
  WMATIC: '0xFffbCD322cEace527C8ec6Da8de2461C6D9d4e6e',
880
880
  AMWMATIC: '0x8832924854e3Cedb0a6Abf372e6CCFF9F7654332',
881
- USDC: '0x06959153B974D0D5fDfd87D561db6d8d4FA0bb0B',
881
+ USDC: '0xf89d7b9c864f589bbf53a82105107622b35eaa40',
882
882
  POPS: '0x2693b57ee51f4e2a26dfb339a911fa8731061f49',
883
883
  MUST: '0x9f2a409848fb9b7bd058b24a23e8dbf1e166a109',
884
884
  AMDAI: '0xFA0DCe8280FCDf369a4cbFc1830d3302789307a6',
@@ -894,7 +894,7 @@ export const Holders: {
894
894
  RADIO: '0x60531b9c3645546d864604ee0fc5b7d6adc81cc2',
895
895
  HANZO: '0x8a151b6ec99c7b90b342ab401d511b480309b220',
896
896
  RVLT: '0x815f87ca3db2b9491115a7769aeacb140361c5a9',
897
- stMATIC: '0x3b39669766fe815aa91834b3bd258dea3edbb6d5',
897
+ stMATIC: '0x644ad5235a9155053d9bc0fce5a74b234c24fce3',
898
898
  axlUSDC: '0x42875ae5766dfd4d70772a3a956842e4b708d59a',
899
899
  deUSDC: '0x94d5ead1f80cf0b4d3480ab59dff16d47c93e9fe',
900
900
  amUSDT: '0x832b11846a27b3ba25d68ae80c39fab155d18c49',