@paraswap/dex-lib 2.21.0 → 2.21.1-chronos

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 (131) hide show
  1. package/build/config.js +2 -4
  2. package/build/config.js.map +1 -1
  3. package/build/dex/balancer-v2/balancer-v2.d.ts +3 -9
  4. package/build/dex/balancer-v2/balancer-v2.js +0 -83
  5. package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
  6. package/build/dex/balancer-v2/constants.d.ts +0 -4
  7. package/build/dex/balancer-v2/constants.js +1 -6
  8. package/build/dex/balancer-v2/constants.js.map +1 -1
  9. package/build/dex/balancer-v2/types.d.ts +1 -20
  10. package/build/dex/balancer-v2/types.js.map +1 -1
  11. package/build/dex/curve-v1/constants.d.ts +0 -1
  12. package/build/dex/curve-v1/constants.js +1 -2
  13. package/build/dex/curve-v1/constants.js.map +1 -1
  14. package/build/dex/curve-v1/curve-v1.d.ts +3 -9
  15. package/build/dex/curve-v1/curve-v1.js +4 -92
  16. package/build/dex/curve-v1/curve-v1.js.map +1 -1
  17. package/build/dex/curve-v1/types.d.ts +0 -24
  18. package/build/dex/curve-v1/types.js +1 -6
  19. package/build/dex/curve-v1/types.js.map +1 -1
  20. package/build/dex/curve-v1-factory/constants.d.ts +0 -1
  21. package/build/dex/curve-v1-factory/constants.js +1 -2
  22. package/build/dex/curve-v1-factory/constants.js.map +1 -1
  23. package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +4 -11
  24. package/build/dex/curve-v1-factory/curve-v1-factory.js +0 -87
  25. package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
  26. package/build/dex/curve-v1-factory/types.d.ts +0 -24
  27. package/build/dex/curve-v1-factory/types.js +1 -6
  28. package/build/dex/curve-v1-factory/types.js.map +1 -1
  29. package/build/dex/curve-v2.d.ts +7 -29
  30. package/build/dex/curve-v2.js +1 -91
  31. package/build/dex/curve-v2.js.map +1 -1
  32. package/build/dex/idex.d.ts +1 -1
  33. package/build/dex/index.js +2 -4
  34. package/build/dex/index.js.map +1 -1
  35. package/build/dex/pancakeswap-v3/pancakeswap-v3.d.ts +2 -2
  36. package/build/dex/pancakeswap-v3/utils.js.map +1 -1
  37. package/build/dex/quickswap/config.js +0 -8
  38. package/build/dex/quickswap/config.js.map +1 -1
  39. package/build/dex/simple-exchange.d.ts +0 -2
  40. package/build/dex/simple-exchange.js +0 -1
  41. package/build/dex/simple-exchange.js.map +1 -1
  42. package/build/dex/solidly/config.js +13 -0
  43. package/build/dex/solidly/config.js.map +1 -1
  44. package/build/dex/solidly/forks-override/chronos.d.ts +3 -0
  45. package/build/dex/solidly/forks-override/chronos.js +88 -0
  46. package/build/dex/solidly/forks-override/chronos.js.map +1 -1
  47. package/build/dex/solidly/solidly.js +1 -0
  48. package/build/dex/solidly/solidly.js.map +1 -1
  49. package/build/dex/uniswap-v2/uniswap-v2.d.ts +1 -1
  50. package/build/dex/uniswap-v2/uniswap-v2.js +1 -1
  51. package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
  52. package/build/dex/uniswap-v3/constants.d.ts +0 -4
  53. package/build/dex/uniswap-v3/constants.js +1 -6
  54. package/build/dex/uniswap-v3/constants.js.map +1 -1
  55. package/build/dex/uniswap-v3/types.d.ts +3 -20
  56. package/build/dex/uniswap-v3/types.js.map +1 -1
  57. package/build/dex/uniswap-v3/uniswap-v3.d.ts +1 -7
  58. package/build/dex/uniswap-v3/uniswap-v3.js +1 -85
  59. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  60. package/build/dex/woo-fi-v2/config.js +6 -6
  61. package/build/dex/zerox/index.d.ts +1 -1
  62. package/build/dex/zerox/index.js +1 -1
  63. package/build/dex/zerox/index.js.map +1 -1
  64. package/build/implementations/local-paraswap-sdk.js +1 -5
  65. package/build/implementations/local-paraswap-sdk.js.map +1 -1
  66. package/build/router/directswap.js +1 -7
  67. package/build/router/directswap.js.map +1 -1
  68. package/build/router/index.js.map +1 -1
  69. package/build/router/payload-encoder.js +6 -16
  70. package/build/router/payload-encoder.js.map +1 -1
  71. package/build/types.d.ts +0 -2
  72. package/build/utils.d.ts +0 -2
  73. package/build/utils.js +1 -5
  74. package/build/utils.js.map +1 -1
  75. package/package.json +4 -6
  76. package/src/config.ts +2 -5
  77. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +0 -79
  78. package/src/dex/balancer-v2/balancer-v2.ts +4 -153
  79. package/src/dex/balancer-v2/constants.ts +0 -5
  80. package/src/dex/balancer-v2/types.ts +1 -21
  81. package/src/dex/curve-v1/constants.ts +0 -2
  82. package/src/dex/curve-v1/curve-v1-e2e.test.ts +0 -57
  83. package/src/dex/curve-v1/curve-v1.ts +5 -144
  84. package/src/dex/curve-v1/types.ts +0 -26
  85. package/src/dex/curve-v1-factory/constants.ts +0 -2
  86. package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +0 -1
  87. package/src/dex/curve-v1-factory/curve-v1-factory.ts +4 -140
  88. package/src/dex/curve-v1-factory/types.ts +0 -26
  89. package/src/dex/curve-v2.ts +8 -169
  90. package/src/dex/idex.ts +0 -6
  91. package/src/dex/index.ts +2 -4
  92. package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +6 -3
  93. package/src/dex/pancakeswap-v3/pancakeswap-v3-integration.test.ts +14 -3
  94. package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +3 -3
  95. package/src/dex/pancakeswap-v3/utils.ts +4 -1
  96. package/src/dex/quickswap/config.ts +0 -9
  97. package/src/dex/quickswap/quickswap-e2e.test.ts +0 -109
  98. package/src/dex/simple-exchange.ts +0 -6
  99. package/src/dex/solidly/config.ts +14 -0
  100. package/src/dex/solidly/forks-override/chronos.ts +206 -0
  101. package/src/dex/solidly/solidly-e2e.test.ts +205 -31
  102. package/src/dex/solidly/solidly-integration.test.ts +141 -0
  103. package/src/dex/solidly/solidly.ts +1 -0
  104. package/src/dex/uniswap-v2/uniswap-v2.ts +0 -6
  105. package/src/dex/uniswap-v3/constants.ts +0 -5
  106. package/src/dex/uniswap-v3/types.ts +3 -23
  107. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +2 -100
  108. package/src/dex/uniswap-v3/uniswap-v3.ts +3 -138
  109. package/src/dex/woo-fi-v2/config.ts +6 -6
  110. package/src/dex/zerox/index.ts +0 -7
  111. package/src/implementations/local-paraswap-sdk.ts +1 -8
  112. package/src/router/directswap.ts +0 -23
  113. package/src/router/index.ts +2 -0
  114. package/src/router/payload-encoder.ts +5 -22
  115. package/src/types.ts +0 -2
  116. package/src/utils.ts +0 -5
  117. package/tests/constants-e2e.ts +9 -4
  118. package/tests/utils-e2e.ts +20 -140
  119. package/tests/utils.ts +0 -52
  120. package/src/abi/DirectSwap.json +0 -1018
  121. package/src/abi/swaap-v2/vault.json +0 -918
  122. package/src/dex/quickswap/camelot-v3.ts +0 -15
  123. package/src/dex/swaap-v2/config.ts +0 -19
  124. package/src/dex/swaap-v2/constants.ts +0 -37
  125. package/src/dex/swaap-v2/rate-fetcher.ts +0 -214
  126. package/src/dex/swaap-v2/swaap-v2-e2e.test.ts +0 -172
  127. package/src/dex/swaap-v2/swaap-v2-integration.test.ts +0 -142
  128. package/src/dex/swaap-v2/swaap-v2.ts +0 -901
  129. package/src/dex/swaap-v2/types.ts +0 -95
  130. package/src/dex/swaap-v2/utils.ts +0 -36
  131. package/src/dex/swaap-v2/validators.ts +0 -128
@@ -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,128 +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
- // For CurveV1 we work as it is, without wrapping and unwrapping
931
- false,
932
- permit,
933
- uuidToBytes16(uuid),
934
- ];
935
-
936
- const encoder = (...params: DirectCurveV1Param) => {
937
- return this.directSwapIface.encodeFunctionData(DIRECT_METHOD_NAME, [
938
- params,
939
- ]);
940
- };
941
-
942
- return {
943
- params: swapParams,
944
- encoder,
945
- networkFee: '0',
946
- };
947
- }
948
-
949
- static getDirectFunctionName(): string[] {
950
- return [DIRECT_METHOD_NAME];
951
- }
952
-
953
817
  async getSimpleParam(
954
818
  srcToken: string,
955
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,27 +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
- needWrapNative: boolean,
207
- permit: string,
208
- uuid: string,
209
- ];
@@ -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,26 +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
- needWrapNative: boolean,
76
- permit: string,
77
- uuid: string,
78
- ];
79
-
80
46
  enum CurveV2SwapFunctions {
81
47
  exchange = 'exchange(uint256 i, uint256 j, uint256 dx, uint256 minDy)',
82
48
  exchange_underlying = 'exchange_underlying(uint256 i, uint256 j, uint256 dx, uint256 minDy)',
@@ -85,31 +51,25 @@ enum CurveV2SwapFunctions {
85
51
 
86
52
  export class CurveV2
87
53
  extends SimpleExchange
88
- implements IDexTxBuilder<CurveV2Data, DirectCurveV2Param>
54
+ implements IDexTxBuilder<CurveV2Data, CurveV2Param>
89
55
  {
90
56
  static dexKeys = ['curvev2'];
91
57
  exchangeRouterInterface: Interface;
92
58
  genericFactoryZapIface: Interface;
93
59
  minConversionRate = '1';
94
60
  needWrapNative = true;
95
- logger: Logger;
96
-
97
- readonly directSwapIface = new Interface(DirectSwapABI);
98
61
 
99
- constructor(readonly dexHelper: IDexHelper) {
62
+ constructor(dexHelper: IDexHelper) {
100
63
  super(dexHelper, 'curvev2');
101
64
  this.exchangeRouterInterface = new Interface(CurveV2ABI as JsonFragment[]);
102
65
  this.genericFactoryZapIface = new Interface(GenericFactoryZapABI);
103
- this.logger = dexHelper.getLogger(
104
- `CurveV2_${dexHelper.config.data.network}`,
105
- );
106
66
  }
107
67
 
108
68
  getAdapterParam(
109
- _0: string,
110
- _1: string,
111
- _2: string,
112
- _3: string,
69
+ srcToken: string,
70
+ destToken: string,
71
+ srcAmount: string,
72
+ destAmount: string,
113
73
  data: CurveV2Data,
114
74
  side: SwapSide,
115
75
  ): AdapterExchangeParam {
@@ -140,127 +100,6 @@ export class CurveV2
140
100
  };
141
101
  }
142
102
 
143
- getTokenFromAddress(address: Address): Token {
144
- // In this Dex decimals are not used
145
- return { address, decimals: 0 };
146
- }
147
-
148
- async preProcessTransaction(
149
- optimalSwapExchange: OptimalSwapExchange<CurveV2Data>,
150
- srcToken: Token,
151
- _0: Token,
152
- _1: SwapSide,
153
- options: PreprocessTransactionOptions,
154
- ): Promise<[OptimalSwapExchange<CurveV2Data>, ExchangeTxInfo]> {
155
- if (!options.isDirectMethod) {
156
- return [
157
- optimalSwapExchange,
158
- {
159
- deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
160
- },
161
- ];
162
- }
163
-
164
- assert(
165
- optimalSwapExchange.data !== undefined,
166
- `preProcessTransaction: data field is missing`,
167
- );
168
-
169
- let isApproved: boolean | undefined;
170
-
171
- try {
172
- this.erc20Contract.options.address =
173
- this.dexHelper.config.wrapETH(srcToken).address;
174
- const allowance = await this.erc20Contract.methods
175
- .allowance(this.augustusAddress, optimalSwapExchange.data.exchange)
176
- .call(undefined, 'latest');
177
- isApproved =
178
- BigInt(allowance.toString()) >= BigInt(optimalSwapExchange.srcAmount);
179
- } catch (e) {
180
- this.logger.error(
181
- `preProcessTransaction failed to retrieve allowance info: `,
182
- e,
183
- );
184
- }
185
-
186
- return [
187
- {
188
- ...optimalSwapExchange,
189
- data: {
190
- ...optimalSwapExchange.data,
191
- isApproved,
192
- },
193
- },
194
- {
195
- deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
196
- },
197
- ];
198
- }
199
-
200
- getDirectParam(
201
- srcToken: Address,
202
- destToken: Address,
203
- srcAmount: NumberAsString,
204
- destAmount: NumberAsString,
205
- expectedAmount: NumberAsString,
206
- data: CurveV2Data,
207
- side: SwapSide,
208
- permit: string,
209
- uuid: string,
210
- feePercent: NumberAsString,
211
- _0: NumberAsString,
212
- partner: string,
213
- beneficiary: string,
214
- contractMethod?: string,
215
- ): TxInfo<DirectCurveV2Param> {
216
- if (contractMethod !== DIRECT_METHOD_NAME) {
217
- throw new Error(`Invalid contract method ${contractMethod}`);
218
- }
219
- assert(side === SwapSide.SELL, 'Buy not supported');
220
-
221
- let isApproved: boolean = !!data.isApproved;
222
- if (data.isApproved === undefined) {
223
- this.logger.warn(`isApproved is undefined, defaulting to false`);
224
- }
225
-
226
- const swapParams: DirectCurveV2Param = [
227
- srcToken,
228
- destToken,
229
- data.exchange,
230
- data.originalPoolAddress,
231
- srcAmount,
232
- destAmount,
233
- expectedAmount,
234
- feePercent,
235
- data.i.toString(),
236
- data.j.toString(),
237
- partner,
238
- isApproved,
239
- data.swapType,
240
- beneficiary,
241
- // For now we always wrap native. We don't support non native trade
242
- true,
243
- permit,
244
- uuidToBytes16(uuid),
245
- ];
246
-
247
- const encoder = (...params: DirectCurveV2Param) => {
248
- return this.directSwapIface.encodeFunctionData(DIRECT_METHOD_NAME, [
249
- params,
250
- ]);
251
- };
252
-
253
- return {
254
- params: swapParams,
255
- encoder,
256
- networkFee: '0',
257
- };
258
- }
259
-
260
- static getDirectFunctionName(): string[] {
261
- return [DIRECT_METHOD_NAME];
262
- }
263
-
264
103
  async getSimpleParam(
265
104
  srcToken: string,
266
105
  destToken: string,
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
  }
package/src/dex/index.ts CHANGED
@@ -43,6 +43,7 @@ import { ParaSwapLimitOrders } from './paraswap-limit-orders/paraswap-limit-orde
43
43
  import { AugustusRFQOrder } from './augustus-rfq';
44
44
  import { Solidly } from './solidly/solidly';
45
45
  import { Thena } from './solidly/forks-override/thena';
46
+ import { Chronos } from './solidly/forks-override/chronos';
46
47
  import { Velodrome } from './solidly/forks-override/velodrome';
47
48
  import { SpiritSwapV2 } from './solidly/forks-override/spiritSwapV2';
48
49
  import { Synthetix } from './synthetix/synthetix';
@@ -63,9 +64,7 @@ import { SolidlyEthereum } from './solidly/solidly-ethereum';
63
64
  import { MaverickV1 } from './maverick-v1/maverick-v1';
64
65
  import { QuickSwapV3 } from './quickswap/quickswap-v3';
65
66
  import { ZyberSwapV3 } from './quickswap/zyberswap-v3';
66
- import { CamelotV3 } from './quickswap/camelot-v3';
67
67
  import { TraderJoeV2 } from './trader-joe-v2';
68
- import { SwaapV2 } from './swaap-v2/swaap-v2';
69
68
  import { SpiritSwapV3 } from './quickswap/spiritswap-v3';
70
69
  import { TraderJoeV21 } from './trader-joe-v2.1';
71
70
  import { PancakeswapV3 } from './pancakeswap-v3/pancakeswap-v3';
@@ -86,7 +85,6 @@ const LegacyDexes = [
86
85
  DodoV2,
87
86
  QuickSwapV3,
88
87
  ZyberSwapV3,
89
- CamelotV3,
90
88
  SpiritSwapV3,
91
89
  TraderJoeV2,
92
90
  TraderJoeV21,
@@ -124,6 +122,7 @@ const Dexes = [
124
122
  SolidlyEthereum,
125
123
  SpiritSwapV2,
126
124
  Thena,
125
+ Chronos,
127
126
  Velodrome,
128
127
  Cone,
129
128
  SoliSnek,
@@ -134,7 +133,6 @@ const Dexes = [
134
133
  Hashflow,
135
134
  MaverickV1,
136
135
  Camelot,
137
- SwaapV2,
138
136
  ];
139
137
 
140
138
  export type LegacyDexConstructor = new (dexHelper: IDexHelper) => IDexTxBuilder<
@@ -32,7 +32,10 @@ describe('PancakeswapV3 E2E', () => {
32
32
  ContractMethod.megaSwap,
33
33
  ],
34
34
  ],
35
- [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
35
+ [SwapSide.BUY, [
36
+ ContractMethod.simpleBuy,
37
+ ContractMethod.buy,
38
+ ]],
36
39
  ]);
37
40
 
38
41
  const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [
@@ -95,8 +98,8 @@ describe('PancakeswapV3 E2E', () => {
95
98
  sellAmount: '10000000000',
96
99
  buyAmount: '500000000000000000000',
97
100
  },
98
- ],
99
- ];
101
+ ]
102
+ ]
100
103
 
101
104
  sideToContractMethods.forEach((contractMethods, side) =>
102
105
  describe(`${side}`, () => {
@@ -76,6 +76,7 @@ const testingData: Partial<{ [key in Network]: any }> = {
76
76
  };
77
77
 
78
78
  describe('PancakeswapV3', function () {
79
+
79
80
  describe('BSC', () => {
80
81
  describe('WBNB -> USDT', () => {
81
82
  it('getPoolIdentifiers and getPricesVolume SELL', async function () {
@@ -87,7 +88,11 @@ describe('PancakeswapV3', function () {
87
88
  const WBNB = Tokens[network]['WBNB'];
88
89
  const USDT = Tokens[network]['USDT'];
89
90
 
90
- const amounts = [0n, 1n * BI_POWS[18], 2n * BI_POWS[18]];
91
+ const amounts = [
92
+ 0n,
93
+ 1n * BI_POWS[18],
94
+ 2n * BI_POWS[18],
95
+ ];
91
96
 
92
97
  const pools = await pancakeswapV3.getPoolIdentifiers(
93
98
  WBNB,
@@ -95,7 +100,10 @@ describe('PancakeswapV3', function () {
95
100
  SwapSide.SELL,
96
101
  blockNumber,
97
102
  );
98
- console.log(`WBNB <> USDT Pool Identifiers: `, pools);
103
+ console.log(
104
+ `WBNB <> USDT Pool Identifiers: `,
105
+ pools,
106
+ );
99
107
 
100
108
  expect(pools.length).toBeGreaterThan(0);
101
109
 
@@ -107,7 +115,10 @@ describe('PancakeswapV3', function () {
107
115
  blockNumber,
108
116
  pools,
109
117
  );
110
- console.log(`WBNB <> USDT Pool Prices: `, poolPrices);
118
+ console.log(
119
+ `WBNB <> USDT Pool Prices: `,
120
+ poolPrices,
121
+ );
111
122
 
112
123
  expect(poolPrices).not.toBeNull();
113
124
  checkPoolPrices(
@@ -28,7 +28,7 @@ import {
28
28
  PoolState,
29
29
  UniswapV3Data,
30
30
  UniswapV3Functions,
31
- UniswapV3SimpleSwapParams,
31
+ UniswapV3Param,
32
32
  } from '../uniswap-v3/types';
33
33
  import {
34
34
  getLocalDeadlineAsFriendlyPlaceholder,
@@ -69,7 +69,7 @@ const PANCAKESWAPV3_QUOTE_GASLIMIT = 200_000;
69
69
 
70
70
  export class PancakeswapV3
71
71
  extends SimpleExchange
72
- implements IDex<UniswapV3Data>
72
+ implements IDex<UniswapV3Data, UniswapV3Param>
73
73
  {
74
74
  readonly isFeeOnTransferSupported: boolean = false;
75
75
  readonly eventPools: Record<string, PancakeSwapV3EventPool | null> = {};
@@ -733,7 +733,7 @@ export class PancakeswapV3
733
733
  : UniswapV3Functions.exactOutput;
734
734
 
735
735
  const path = this._encodePath(data.path, side);
736
- const swapFunctionParams: UniswapV3SimpleSwapParams =
736
+ const swapFunctionParams: UniswapV3Param =
737
737
  side === SwapSide.SELL
738
738
  ? {
739
739
  recipient: this.augustusAddress,
@@ -2,7 +2,10 @@ import { BytesLike, ethers } from 'ethers';
2
2
  import { assert } from 'ts-essentials';
3
3
  import { extractSuccessAndValue } from '../../lib/decoders';
4
4
  import { MultiResult } from '../../lib/multi-wrapper';
5
- import { DecodedStateMultiCallResultWithRelativeBitmaps } from '../uniswap-v3/types';
5
+ import {
6
+ DecodedStateMultiCallResultWithRelativeBitmaps,
7
+ } from '../uniswap-v3/types';
8
+
6
9
 
7
10
  export function decodeStateMultiCallResultWithRelativeBitmaps(
8
11
  result: MultiResult<BytesLike> | BytesLike,
@@ -3,15 +3,6 @@ import { Network } from '../../constants';
3
3
  import { DexParams } from './types';
4
4
 
5
5
  export const QuickSwapConfig: DexConfigMap<DexParams> = {
6
- CamelotV3: {
7
- [Network.ARBITRUM]: {
8
- factoryAddress: '0x1a3c9B1d2F0529D97f2afC5136Cc23e58f1FD35B',
9
- router: '0x1F721E2E82F6676FCE4eA07A5958cF098D339e18',
10
- quoteAddress: '0x0Fc73040b26E9bC8514fA028D998E73A254Fa76E',
11
- initCode:
12
- '0x6c1bebd370ba84753516bc1393c0d0a6c645856da55f5393ac8ab3d6dbc861d3',
13
- },
14
- },
15
6
  ZyberSwapV3: {
16
7
  [Network.ARBITRUM]: {
17
8
  factoryAddress: '0x9C2ABD632771b433E5E7507BcaA41cA3b25D8544',