@paraswap/dex-lib 2.16.5-direct-swaps.0 → 2.16.6

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 (123) hide show
  1. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  2. package/.idea/misc.xml +6 -0
  3. package/.idea/modules.xml +8 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/.vscode/launch.json +21 -0
  6. package/build/abi/AugustusRFQRouter.abi.json +1248 -0
  7. package/build/dex/aave-v3/tokens/arbitrum.json +20 -20
  8. package/build/dex/aave-v3/tokens/avalanche.json +20 -44
  9. package/build/dex/aave-v3/tokens/fantom.json +30 -30
  10. package/build/dex/aave-v3/tokens/mainnet.json +44 -0
  11. package/build/dex/aave-v3/tokens/optimism.json +18 -18
  12. package/build/dex/aave-v3/tokens/polygon.json +42 -60
  13. package/build/dex/balancer-v2/VirtualBoostedPool.d.ts +79 -0
  14. package/build/dex/balancer-v2/VirtualBoostedPool.js +382 -0
  15. package/build/dex/balancer-v2/VirtualBoostedPool.js.map +1 -0
  16. package/build/dex/balancer-v2/balancer-v2.d.ts +3 -9
  17. package/build/dex/balancer-v2/balancer-v2.js +0 -81
  18. package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
  19. package/build/dex/balancer-v2/constants.d.ts +0 -4
  20. package/build/dex/balancer-v2/constants.js +1 -6
  21. package/build/dex/balancer-v2/constants.js.map +1 -1
  22. package/build/dex/balancer-v2/types.d.ts +1 -18
  23. package/build/dex/balancer-v2/types.js.map +1 -1
  24. package/build/dex/curve-v1/constants.d.ts +0 -1
  25. package/build/dex/curve-v1/constants.js +1 -2
  26. package/build/dex/curve-v1/constants.js.map +1 -1
  27. package/build/dex/curve-v1/curve-v1.d.ts +3 -9
  28. package/build/dex/curve-v1/curve-v1.js +4 -90
  29. package/build/dex/curve-v1/curve-v1.js.map +1 -1
  30. package/build/dex/curve-v1/types.d.ts +0 -23
  31. package/build/dex/curve-v1/types.js +1 -6
  32. package/build/dex/curve-v1/types.js.map +1 -1
  33. package/build/dex/curve-v1-factory/constants.d.ts +0 -1
  34. package/build/dex/curve-v1-factory/constants.js +1 -2
  35. package/build/dex/curve-v1-factory/constants.js.map +1 -1
  36. package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +4 -11
  37. package/build/dex/curve-v1-factory/curve-v1-factory.js +0 -85
  38. package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
  39. package/build/dex/curve-v1-factory/types.d.ts +0 -23
  40. package/build/dex/curve-v1-factory/types.js +1 -6
  41. package/build/dex/curve-v1-factory/types.js.map +1 -1
  42. package/build/dex/curve-v2.d.ts +7 -28
  43. package/build/dex/curve-v2.js +1 -89
  44. package/build/dex/curve-v2.js.map +1 -1
  45. package/build/dex/generic-rfq/generic-rfq.js +0 -1
  46. package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
  47. package/build/dex/idex.d.ts +1 -1
  48. package/build/dex/simple-exchange.d.ts +0 -2
  49. package/build/dex/simple-exchange.js +0 -1
  50. package/build/dex/simple-exchange.js.map +1 -1
  51. package/build/dex/{test-dex → test-aave-v3}/config.d.ts +1 -1
  52. package/build/dex/{test-dex → test-aave-v3}/config.js +3 -3
  53. package/build/dex/test-aave-v3/config.js.map +1 -0
  54. package/build/dex/{test-dex/test-dex-pool.d.ts → test-aave-v3/test-aave-v3-pool.d.ts} +3 -3
  55. package/build/dex/{test-dex/test-dex-pool.js → test-aave-v3/test-aave-v3-pool.js} +7 -7
  56. package/build/dex/test-aave-v3/test-aave-v3-pool.js.map +1 -0
  57. package/build/dex/{test-dex/test-dex.d.ts → test-aave-v3/test-aave-v3.d.ts} +8 -8
  58. package/build/dex/{test-dex/test-dex.js → test-aave-v3/test-aave-v3.js} +7 -7
  59. package/build/dex/test-aave-v3/test-aave-v3.js.map +1 -0
  60. package/build/dex/{test-dex → test-aave-v3}/types.d.ts +1 -1
  61. package/build/dex/{test-dex → test-aave-v3}/types.js.map +1 -1
  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 +0 -4
  68. package/build/dex/uniswap-v3/constants.js +1 -6
  69. package/build/dex/uniswap-v3/constants.js.map +1 -1
  70. package/build/dex/uniswap-v3/types.d.ts +3 -20
  71. package/build/dex/uniswap-v3/types.js.map +1 -1
  72. package/build/dex/uniswap-v3/uniswap-v3.d.ts +1 -7
  73. package/build/dex/uniswap-v3/uniswap-v3.js +1 -85
  74. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  75. package/build/dex/zerox/index.d.ts +1 -1
  76. package/build/dex/zerox/index.js +1 -1
  77. package/build/dex/zerox/index.js.map +1 -1
  78. package/build/implementations/local-paraswap-sdk.js +1 -5
  79. package/build/implementations/local-paraswap-sdk.js.map +1 -1
  80. package/build/router/directswap.js +1 -3
  81. package/build/router/directswap.js.map +1 -1
  82. package/build/router/index.js.map +1 -1
  83. package/build/types.d.ts +0 -1
  84. package/package.json +3 -5
  85. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +0 -71
  86. package/src/dex/balancer-v2/balancer-v2.ts +3 -150
  87. package/src/dex/balancer-v2/constants.ts +0 -5
  88. package/src/dex/balancer-v2/types.ts +1 -19
  89. package/src/dex/curve-v1/constants.ts +0 -2
  90. package/src/dex/curve-v1/curve-v1-e2e.test.ts +0 -57
  91. package/src/dex/curve-v1/curve-v1.ts +5 -142
  92. package/src/dex/curve-v1/types.ts +0 -25
  93. package/src/dex/curve-v1-factory/constants.ts +0 -2
  94. package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +0 -1
  95. package/src/dex/curve-v1-factory/curve-v1-factory.ts +4 -138
  96. package/src/dex/curve-v1-factory/types.ts +0 -25
  97. package/src/dex/curve-v2.ts +8 -166
  98. package/src/dex/generic-rfq/generic-rfq.ts +0 -1
  99. package/src/dex/idex.ts +0 -6
  100. package/src/dex/simple-exchange.ts +0 -6
  101. package/src/dex/uniswap-v2/config.ts +2 -1
  102. package/src/dex/uniswap-v2/uniswap-v2.ts +0 -6
  103. package/src/dex/uniswap-v3/constants.ts +0 -5
  104. package/src/dex/uniswap-v3/types.ts +3 -23
  105. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +2 -100
  106. package/src/dex/uniswap-v3/uniswap-v3.ts +3 -138
  107. package/src/dex/zerox/index.ts +0 -7
  108. package/src/implementations/local-paraswap-sdk.ts +1 -8
  109. package/src/router/directswap.ts +0 -9
  110. package/src/router/index.ts +2 -0
  111. package/src/types.ts +0 -1
  112. package/tests/constants-e2e.ts +3 -3
  113. package/tests/utils-e2e.ts +20 -135
  114. package/tests/utils.ts +0 -52
  115. package/build/abi/DirectSwap.json +0 -970
  116. package/build/dex/test-dex/config.js.map +0 -1
  117. package/build/dex/test-dex/test-dex-pool.js.map +0 -1
  118. package/build/dex/test-dex/test-dex.js.map +0 -1
  119. package/build/dex/woo-fi-v2/woo-fi-math.d.ts +0 -16
  120. package/build/dex/woo-fi-v2/woo-fi-math.js +0 -137
  121. package/build/dex/woo-fi-v2/woo-fi-math.js.map +0 -1
  122. package/src/abi/DirectSwap.json +0 -970
  123. /package/build/dex/{test-dex → test-aave-v3}/types.js +0 -0
@@ -1,7 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { AbiItem } from 'web3-utils';
3
- import { NumberAsString, OptimalSwapExchange } from '@paraswap/core';
4
- import { assert, AsyncOrSync } from 'ts-essentials';
2
+ import { AsyncOrSync } from 'ts-essentials';
5
3
  import { Interface, JsonFragment } from '@ethersproject/abi';
6
4
  import {
7
5
  Token,
@@ -13,9 +11,6 @@ import {
13
11
  PoolLiquidity,
14
12
  Logger,
15
13
  TransferFeeParams,
16
- TxInfo,
17
- PreprocessTransactionOptions,
18
- ExchangeTxInfo,
19
14
  } from '../../types';
20
15
  import {
21
16
  SwapSide,
@@ -28,7 +23,6 @@ import {
28
23
  getBigIntPow,
29
24
  getDexKeysWithNetwork,
30
25
  isSrcTokenTransferFeeToBeExchanged,
31
- uuidToBytes16,
32
26
  } from '../../utils';
33
27
  import { IDex } from '../idex';
34
28
  import { IDexHelper } from '../../dex-helper/idex-helper';
@@ -36,19 +30,13 @@ import {
36
30
  CurveSwapFunctions,
37
31
  CurveV1FactoryData,
38
32
  CurveV1FactoryIfaces,
39
- CurveV1SwapType,
40
33
  CustomImplementationNames,
41
34
  ImplementationNames,
42
35
  PoolConstants,
43
- DirectCurveV1Param,
44
36
  } from './types';
45
- import {
46
- getLocalDeadlineAsFriendlyPlaceholder,
47
- SimpleExchange,
48
- } from '../simple-exchange';
37
+ import { SimpleExchange } from '../simple-exchange';
49
38
  import { CurveV1FactoryConfig, Adapters } from './config';
50
39
  import {
51
- DIRECT_METHOD_NAME,
52
40
  FACTORY_MAX_PLAIN_COINS,
53
41
  FACTORY_MAX_PLAIN_IMPLEMENTATIONS_FOR_COIN,
54
42
  MIN_AMOUNT_TO_RECEIVE,
@@ -56,7 +44,6 @@ import {
56
44
  } from './constants';
57
45
  import { CurveV1FactoryPoolManager } from './curve-v1-pool-manager';
58
46
  import CurveABI from '../../abi/Curve.json';
59
- import DirectSwapABI from '../../abi/DirectSwap.json';
60
47
  import FactoryCurveV1ABI from '../../abi/curve-v1-factory/FactoryCurveV1.json';
61
48
  import ThreePoolABI from '../../abi/curve-v1-factory/ThreePool.json';
62
49
  import ERC20ABI from '../../abi/erc20.json';
@@ -74,6 +61,7 @@ import { CustomBasePoolForFactory } from './state-polling-pools/custom-pool-poll
74
61
  import ImplementationConstants from './price-handlers/functions/constants';
75
62
  import { applyTransferFee } from '../../lib/token-transfer-fee';
76
63
  import { PriceHandler } from './price-handlers/price-handler';
64
+ import { AbiItem } from 'web3-utils';
77
65
 
78
66
  const DefaultCoinsABI: AbiItem = {
79
67
  type: 'function',
@@ -94,7 +82,7 @@ const DefaultCoinsABI: AbiItem = {
94
82
 
95
83
  export class CurveV1Factory
96
84
  extends SimpleExchange
97
- implements IDex<CurveV1FactoryData, DirectCurveV1Param>
85
+ implements IDex<CurveV1FactoryData>
98
86
  {
99
87
  readonly hasConstantPriceLargeAmounts = false;
100
88
  readonly needWrapNative = false;
@@ -110,8 +98,6 @@ export class CurveV1Factory
110
98
  readonly SRC_TOKEN_DEX_TRANSFERS = 1;
111
99
  readonly DEST_TOKEN_DEX_TRANSFERS = 1;
112
100
 
113
- readonly directSwapIface = new Interface(DirectSwapABI);
114
-
115
101
  public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
116
102
  getDexKeysWithNetwork(CurveV1FactoryConfig);
117
103
 
@@ -828,126 +814,6 @@ export class CurveV1Factory
828
814
  };
829
815
  }
830
816
 
831
- getTokenFromAddress(address: Address): Token {
832
- // In this Dex decimals are not used
833
- return { address, decimals: 0 };
834
- }
835
-
836
- async preProcessTransaction(
837
- optimalSwapExchange: OptimalSwapExchange<CurveV1FactoryData>,
838
- srcToken: Token,
839
- _0: Token,
840
- _1: SwapSide,
841
- options: PreprocessTransactionOptions,
842
- ): Promise<[OptimalSwapExchange<CurveV1FactoryData>, ExchangeTxInfo]> {
843
- if (!options.isDirectMethod) {
844
- return [
845
- optimalSwapExchange,
846
- {
847
- deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
848
- },
849
- ];
850
- }
851
-
852
- assert(
853
- optimalSwapExchange.data !== undefined,
854
- `preProcessTransaction: data field is missing`,
855
- );
856
-
857
- let isApproved: boolean | undefined;
858
-
859
- try {
860
- this.erc20Contract.options.address =
861
- this.dexHelper.config.wrapETH(srcToken).address;
862
- const allowance = await this.erc20Contract.methods
863
- .allowance(this.augustusAddress, optimalSwapExchange.data.exchange)
864
- .call(undefined, 'latest');
865
- isApproved =
866
- BigInt(allowance.toString()) >= BigInt(optimalSwapExchange.srcAmount);
867
- } catch (e) {
868
- this.logger.error(
869
- `preProcessTransaction failed to retrieve allowance info: `,
870
- e,
871
- );
872
- }
873
-
874
- return [
875
- {
876
- ...optimalSwapExchange,
877
- data: {
878
- ...optimalSwapExchange.data,
879
- isApproved,
880
- },
881
- },
882
- {
883
- deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
884
- },
885
- ];
886
- }
887
-
888
- getDirectParam(
889
- srcToken: Address,
890
- destToken: Address,
891
- srcAmount: NumberAsString,
892
- destAmount: NumberAsString,
893
- expectedAmount: NumberAsString,
894
- data: CurveV1FactoryData,
895
- side: SwapSide,
896
- permit: string,
897
- uuid: string,
898
- feePercent: NumberAsString,
899
- deadline: NumberAsString,
900
- partner: string,
901
- beneficiary: string,
902
- contractMethod?: string,
903
- ): TxInfo<DirectCurveV1Param> {
904
- if (contractMethod !== DIRECT_METHOD_NAME) {
905
- throw new Error(`Invalid contract method ${contractMethod}`);
906
- }
907
- assert(side === SwapSide.SELL, 'Buy not supported');
908
-
909
- let isApproved: boolean = !!data.isApproved;
910
- if (data.isApproved === undefined) {
911
- this.logger.warn(`isApproved is undefined, defaulting to false`);
912
- }
913
-
914
- const swapParams: DirectCurveV1Param = [
915
- srcToken,
916
- destToken,
917
- data.exchange,
918
- srcAmount,
919
- destAmount,
920
- expectedAmount,
921
- feePercent,
922
- data.i.toString(),
923
- data.j.toString(),
924
- partner,
925
- isApproved,
926
- data.underlyingSwap
927
- ? CurveV1SwapType.EXCHANGE_UNDERLYING
928
- : CurveV1SwapType.EXCHANGE,
929
- beneficiary,
930
- permit,
931
- uuidToBytes16(uuid),
932
- ];
933
-
934
- const encoder = (...params: DirectCurveV1Param) => {
935
- return this.directSwapIface.encodeFunctionData(DIRECT_METHOD_NAME, [
936
- params,
937
- ]);
938
- };
939
-
940
- return {
941
- params: swapParams,
942
- encoder,
943
- networkFee: '0',
944
- };
945
- }
946
-
947
- static getDirectFunctionName(): string[] {
948
- return [DIRECT_METHOD_NAME];
949
- }
950
-
951
817
  async getSimpleParam(
952
818
  srcToken: string,
953
819
  destToken: string,
@@ -1,5 +1,4 @@
1
1
  import { Interface } from '@ethersproject/abi';
2
- import { NumberAsString } from '@paraswap/core';
3
2
  import { Address } from '../../types';
4
3
 
5
4
  // The difference between PoolContextConstants and PoolConstants lies in the fact
@@ -70,7 +69,6 @@ export type CurveV1FactoryData = {
70
69
  i: number;
71
70
  j: number;
72
71
  underlyingSwap: boolean;
73
- isApproved?: boolean;
74
72
  };
75
73
 
76
74
  export enum FactoryImplementationNames {
@@ -183,26 +181,3 @@ export type CurveV1FactoryIfaces = {
183
181
  };
184
182
 
185
183
  export type LiquidityInCache = Record<string, number>;
186
-
187
- export enum CurveV1SwapType {
188
- EXCHANGE,
189
- EXCHANGE_UNDERLYING,
190
- }
191
-
192
- export type DirectCurveV1Param = [
193
- fromToken: Address,
194
- toToken: Address,
195
- exchange: Address,
196
- fromAmount: NumberAsString,
197
- toAmount: NumberAsString,
198
- expectedAmount: NumberAsString,
199
- feePercent: NumberAsString,
200
- i: NumberAsString,
201
- j: NumberAsString,
202
- partner: Address,
203
- isApproved: boolean,
204
- swapType: CurveV1SwapType,
205
- beneficiary: Address,
206
- permit: string,
207
- uuid: string,
208
- ];
@@ -3,26 +3,15 @@ import { SwapSide } from '../constants';
3
3
  import {
4
4
  AdapterExchangeParam,
5
5
  Address,
6
- ExchangeTxInfo,
7
6
  NumberAsString,
8
- PreprocessTransactionOptions,
9
7
  SimpleExchangeParam,
10
- Token,
11
- TxInfo,
12
8
  } from '../types';
13
9
  import { IDexTxBuilder } from './idex';
14
- import {
15
- getLocalDeadlineAsFriendlyPlaceholder,
16
- SimpleExchange,
17
- } from './simple-exchange';
10
+ import { SimpleExchange } from './simple-exchange';
18
11
  import GenericFactoryZapABI from '../abi/curve-v2/GenericFactoryZap.json';
19
- import DirectSwapABI from '../abi/DirectSwap.json';
20
12
  import CurveV2ABI from '../abi/CurveV2.json';
13
+ import Web3 from 'web3';
21
14
  import { IDexHelper } from '../dex-helper';
22
- import { assert } from 'ts-essentials';
23
- import { Logger } from 'log4js';
24
- import { OptimalSwapExchange } from '@paraswap/core';
25
- import { uuidToBytes16 } from '../utils';
26
15
 
27
16
  export enum CurveV2SwapType {
28
17
  EXCHANGE,
@@ -30,15 +19,12 @@ export enum CurveV2SwapType {
30
19
  EXCHANGE_GENERIC_FACTORY_ZAP,
31
20
  }
32
21
 
33
- const DIRECT_METHOD_NAME = 'directCurveV2Swap';
34
-
35
22
  type CurveV2Data = {
36
23
  i: number;
37
24
  j: number;
38
25
  exchange: string;
39
26
  originalPoolAddress: Address;
40
27
  swapType: CurveV2SwapType;
41
- isApproved?: boolean;
42
28
  };
43
29
 
44
30
  type CurveV2Param = [
@@ -57,25 +43,6 @@ type CurveV2ParamsForGenericFactoryZap = [
57
43
  min_dy: NumberAsString,
58
44
  ];
59
45
 
60
- export type DirectCurveV2Param = [
61
- fromToken: Address,
62
- toToken: Address,
63
- exchange: Address,
64
- poolAddress: Address,
65
- fromAmount: NumberAsString,
66
- toAmount: NumberAsString,
67
- expectedAmount: NumberAsString,
68
- feePercent: NumberAsString,
69
- i: NumberAsString,
70
- j: NumberAsString,
71
- partner: Address,
72
- isApproved: boolean,
73
- swapType: CurveV2SwapType,
74
- beneficiary: Address,
75
- permit: string,
76
- uuid: string,
77
- ];
78
-
79
46
  enum CurveV2SwapFunctions {
80
47
  exchange = 'exchange(uint256 i, uint256 j, uint256 dx, uint256 minDy)',
81
48
  exchange_underlying = 'exchange_underlying(uint256 i, uint256 j, uint256 dx, uint256 minDy)',
@@ -84,31 +51,25 @@ enum CurveV2SwapFunctions {
84
51
 
85
52
  export class CurveV2
86
53
  extends SimpleExchange
87
- implements IDexTxBuilder<CurveV2Data, DirectCurveV2Param>
54
+ implements IDexTxBuilder<CurveV2Data, CurveV2Param>
88
55
  {
89
56
  static dexKeys = ['curvev2'];
90
57
  exchangeRouterInterface: Interface;
91
58
  genericFactoryZapIface: Interface;
92
59
  minConversionRate = '1';
93
60
  needWrapNative = true;
94
- logger: Logger;
95
-
96
- readonly directSwapIface = new Interface(DirectSwapABI);
97
61
 
98
- constructor(readonly dexHelper: IDexHelper) {
62
+ constructor(dexHelper: IDexHelper) {
99
63
  super(dexHelper, 'curvev2');
100
64
  this.exchangeRouterInterface = new Interface(CurveV2ABI as JsonFragment[]);
101
65
  this.genericFactoryZapIface = new Interface(GenericFactoryZapABI);
102
- this.logger = dexHelper.getLogger(
103
- `CurveV2_${dexHelper.config.data.network}`,
104
- );
105
66
  }
106
67
 
107
68
  getAdapterParam(
108
- _0: string,
109
- _1: string,
110
- _2: string,
111
- _3: string,
69
+ srcToken: string,
70
+ destToken: string,
71
+ srcAmount: string,
72
+ destAmount: string,
112
73
  data: CurveV2Data,
113
74
  side: SwapSide,
114
75
  ): AdapterExchangeParam {
@@ -139,125 +100,6 @@ export class CurveV2
139
100
  };
140
101
  }
141
102
 
142
- getTokenFromAddress(address: Address): Token {
143
- // In this Dex decimals are not used
144
- return { address, decimals: 0 };
145
- }
146
-
147
- async preProcessTransaction(
148
- optimalSwapExchange: OptimalSwapExchange<CurveV2Data>,
149
- srcToken: Token,
150
- _0: Token,
151
- _1: SwapSide,
152
- options: PreprocessTransactionOptions,
153
- ): Promise<[OptimalSwapExchange<CurveV2Data>, ExchangeTxInfo]> {
154
- if (!options.isDirectMethod) {
155
- return [
156
- optimalSwapExchange,
157
- {
158
- deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
159
- },
160
- ];
161
- }
162
-
163
- assert(
164
- optimalSwapExchange.data !== undefined,
165
- `preProcessTransaction: data field is missing`,
166
- );
167
-
168
- let isApproved: boolean | undefined;
169
-
170
- try {
171
- this.erc20Contract.options.address =
172
- this.dexHelper.config.wrapETH(srcToken).address;
173
- const allowance = await this.erc20Contract.methods
174
- .allowance(this.augustusAddress, optimalSwapExchange.data.exchange)
175
- .call(undefined, 'latest');
176
- isApproved =
177
- BigInt(allowance.toString()) >= BigInt(optimalSwapExchange.srcAmount);
178
- } catch (e) {
179
- this.logger.error(
180
- `preProcessTransaction failed to retrieve allowance info: `,
181
- e,
182
- );
183
- }
184
-
185
- return [
186
- {
187
- ...optimalSwapExchange,
188
- data: {
189
- ...optimalSwapExchange.data,
190
- isApproved,
191
- },
192
- },
193
- {
194
- deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
195
- },
196
- ];
197
- }
198
-
199
- getDirectParam(
200
- srcToken: Address,
201
- destToken: Address,
202
- srcAmount: NumberAsString,
203
- destAmount: NumberAsString,
204
- expectedAmount: NumberAsString,
205
- data: CurveV2Data,
206
- side: SwapSide,
207
- permit: string,
208
- uuid: string,
209
- feePercent: NumberAsString,
210
- _0: NumberAsString,
211
- partner: string,
212
- beneficiary: string,
213
- contractMethod?: string,
214
- ): TxInfo<DirectCurveV2Param> {
215
- if (contractMethod !== DIRECT_METHOD_NAME) {
216
- throw new Error(`Invalid contract method ${contractMethod}`);
217
- }
218
- assert(side === SwapSide.SELL, 'Buy not supported');
219
-
220
- let isApproved: boolean = !!data.isApproved;
221
- if (data.isApproved === undefined) {
222
- this.logger.warn(`isApproved is undefined, defaulting to false`);
223
- }
224
-
225
- const swapParams: DirectCurveV2Param = [
226
- srcToken,
227
- destToken,
228
- data.exchange,
229
- data.originalPoolAddress,
230
- srcAmount,
231
- destAmount,
232
- expectedAmount,
233
- feePercent,
234
- data.i.toString(),
235
- data.j.toString(),
236
- partner,
237
- isApproved,
238
- data.swapType,
239
- beneficiary,
240
- permit,
241
- uuidToBytes16(uuid),
242
- ];
243
-
244
- const encoder = (...params: DirectCurveV2Param) => {
245
- return this.directSwapIface.encodeFunctionData(DIRECT_METHOD_NAME, [
246
- params,
247
- ]);
248
- };
249
-
250
- return {
251
- params: swapParams,
252
- encoder,
253
- networkFee: '0',
254
- };
255
- }
256
-
257
- static getDirectFunctionName(): string[] {
258
- return [DIRECT_METHOD_NAME];
259
- }
260
-
261
103
  async getSimpleParam(
262
104
  srcToken: string,
263
105
  destToken: string,
@@ -179,7 +179,6 @@ export class GenericRFQ extends ParaSwapLimitOrders {
179
179
  data: {
180
180
  orderInfos: null,
181
181
  },
182
- poolAddresses: [this.augustusRFQAddress],
183
182
  },
184
183
  ];
185
184
  }
package/src/dex/idex.ts CHANGED
@@ -76,15 +76,9 @@ export interface IDexTxBuilder<ExchangeData, DirectParam = null> {
76
76
  destToken: Address,
77
77
  srcAmount: NumberAsString,
78
78
  destAmount: NumberAsString,
79
- expectedAmount: NumberAsString,
80
79
  data: ExchangeData,
81
80
  side: SwapSide,
82
81
  permit: string,
83
- uuid: string,
84
- feePercent: NumberAsString,
85
- deadline: NumberAsString,
86
- partner: string,
87
- beneficiary: string,
88
82
  contractMethod?: string,
89
83
  ): TxInfo<DirectParam>;
90
84
  }
@@ -1,6 +1,5 @@
1
1
  import { Interface } from '@ethersproject/abi';
2
2
  import Web3Abi, { AbiCoder } from 'web3-eth-abi';
3
- import { Contract } from 'web3-eth-contract';
4
3
  import { Address, SimpleExchangeParam, NumberAsString } from '../types';
5
4
  import { CACHE_PREFIX, ETHER_ADDRESS } from '../constants';
6
5
  import SimpleSwapHelperABI from '../abi/SimpleSwapHelperRouter.json';
@@ -10,7 +9,6 @@ import { isETHAddress } from '../utils';
10
9
  import { MAX_UINT } from '../constants';
11
10
  import Web3 from 'web3';
12
11
  import { IDexHelper } from '../dex-helper';
13
- import { AbiItem } from 'web3-utils';
14
12
 
15
13
  /*
16
14
  * Context: Augustus routers have all a deadline protection logic implemented globally.
@@ -28,7 +26,6 @@ export class SimpleExchange {
28
26
  simpleSwapHelper: Interface;
29
27
  protected abiCoder: AbiCoder;
30
28
  erc20Interface: Interface;
31
- erc20Contract: Contract;
32
29
 
33
30
  needWrapNative = false;
34
31
  isFeeOnTransferSupported = false;
@@ -45,9 +42,6 @@ export class SimpleExchange {
45
42
  constructor(dexHelper: IDexHelper, public dexKey: string) {
46
43
  this.simpleSwapHelper = new Interface(SimpleSwapHelperABI);
47
44
  this.erc20Interface = new Interface(ERC20ABI);
48
- this.erc20Contract = new dexHelper.web3Provider.eth.Contract(
49
- ERC20ABI as AbiItem[],
50
- );
51
45
  this.abiCoder = Web3Abi as unknown as AbiCoder;
52
46
 
53
47
  this.network = dexHelper.config.data.network;
@@ -518,7 +518,8 @@ export const UniswapV2Config: DexConfigMap<DexParams> = {
518
518
  },
519
519
  QuickSwap: {
520
520
  [Network.POLYGON]: {
521
- subgraphURL: 'https://api.fura.org/subgraphs/name/quickswap',
521
+ subgraphURL:
522
+ 'https://api.thegraph.com/subgraphs/name/sameepsi/quickswap06',
522
523
  factoryAddress: '0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32',
523
524
  initCode:
524
525
  '0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f',
@@ -788,15 +788,9 @@ export class UniswapV2
788
788
  destToken: Address,
789
789
  srcAmount: NumberAsString,
790
790
  destAmount: NumberAsString,
791
- expectedAmount: NumberAsString,
792
791
  _data: UniswapData,
793
792
  side: SwapSide,
794
793
  permit: string,
795
- uuid: string,
796
- feePercent: NumberAsString,
797
- deadline: NumberAsString,
798
- partner: string,
799
- beneficiary: string,
800
794
  contractMethod?: string,
801
795
  ): TxInfo<UniswapParam> {
802
796
  if (!contractMethod) throw new Error(`contractMethod need to be passed`);
@@ -33,8 +33,3 @@ export const ZERO_ORACLE_OBSERVATION = {
33
33
  export const OUT_OF_RANGE_ERROR_POSTFIX = `INVALID_TICK_BIT_MAP_RANGES`;
34
34
 
35
35
  export const DEFAULT_POOL_INIT_CODE_HASH = `0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54`;
36
-
37
- export enum DirectMethods {
38
- directSell = 'directUniV3Swap',
39
- directBuy = 'directUniV3Buy',
40
- }
@@ -57,7 +57,6 @@ export type UniswapV3Data = {
57
57
  tokenOut: Address;
58
58
  fee: NumberAsString;
59
59
  }[];
60
- isApproved?: boolean;
61
60
  };
62
61
 
63
62
  export type DexParams = {
@@ -73,7 +72,7 @@ export type DexParams = {
73
72
  initHash: string;
74
73
  };
75
74
 
76
- export type UniswapV3SimpleSwapSellParam = {
75
+ export type UniswapV3SellParam = {
77
76
  path: string;
78
77
  recipient: Address;
79
78
  deadline: string;
@@ -81,7 +80,7 @@ export type UniswapV3SimpleSwapSellParam = {
81
80
  amountOutMinimum: NumberAsString;
82
81
  };
83
82
 
84
- export type UniswapV3SimpleSwapBuyParam = {
83
+ export type UniswapV3BuyParam = {
85
84
  path: string;
86
85
  recipient: Address;
87
86
  deadline: string;
@@ -89,26 +88,7 @@ export type UniswapV3SimpleSwapBuyParam = {
89
88
  amountInMaximum: NumberAsString;
90
89
  };
91
90
 
92
- export type UniswapV3SimpleSwapParams =
93
- | UniswapV3SimpleSwapSellParam
94
- | UniswapV3SimpleSwapBuyParam;
95
-
96
- export type UniswapV3Param = [
97
- fromToken: Address,
98
- toToken: Address,
99
- exchange: Address,
100
- fromAmount: NumberAsString,
101
- toAmount: NumberAsString,
102
- expectedAmount: NumberAsString,
103
- feePercent: NumberAsString,
104
- deadline: NumberAsString,
105
- partner: Address,
106
- isApproved: boolean,
107
- beneficiary: Address,
108
- path: string,
109
- permit: string,
110
- uuid: string,
111
- ];
91
+ export type UniswapV3Param = UniswapV3SellParam | UniswapV3BuyParam;
112
92
 
113
93
  export enum UniswapV3Functions {
114
94
  exactInput = 'exactInput',