@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
@@ -11,9 +11,6 @@ import {
11
11
  SimpleExchangeParam,
12
12
  PoolLiquidity,
13
13
  Logger,
14
- TxInfo,
15
- PreprocessTransactionOptions,
16
- ExchangeTxInfo,
17
14
  } from '../../types';
18
15
  import {
19
16
  SwapSide,
@@ -29,13 +26,8 @@ import { StablePool, WeightedPool } from './balancer-v2-pool';
29
26
  import { PhantomStablePool } from './PhantomStablePool';
30
27
  import { LinearPool } from './LinearPool';
31
28
  import VaultABI from '../../abi/balancer-v2/vault.json';
32
- import DirectSwapABI from '../../abi/DirectSwap.json';
33
29
  import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
34
- import {
35
- getDexKeysWithNetwork,
36
- getBigIntPow,
37
- uuidToBytes16,
38
- } from '../../utils';
30
+ import { getDexKeysWithNetwork, getBigIntPow } from '../../utils';
39
31
  import { IDex } from '../../dex/idex';
40
32
  import { IDexHelper } from '../../dex-helper';
41
33
  import {
@@ -50,12 +42,8 @@ import {
50
42
  PoolStateCache,
51
43
  BalancerPoolTypes,
52
44
  SubgraphPoolAddressDictionary,
53
- BalancerV2DirectParam,
54
45
  } from './types';
55
- import {
56
- getLocalDeadlineAsFriendlyPlaceholder,
57
- SimpleExchange,
58
- } from '../simple-exchange';
46
+ import { SimpleExchange } from '../simple-exchange';
59
47
  import { BalancerConfig, Adapters } from './config';
60
48
  import {
61
49
  getAllPoolsUsedInPaths,
@@ -64,12 +52,10 @@ import {
64
52
  poolGetPathForTokenInOut,
65
53
  } from './utils';
66
54
  import {
67
- DirectMethods,
68
55
  MIN_USD_LIQUIDITY_TO_FETCH,
69
56
  STABLE_GAS_COST,
70
57
  VARIABLE_GAS_COST_PER_CYCLE,
71
58
  } from './constants';
72
- import { NumberAsString, OptimalSwapExchange } from '@paraswap/core';
73
59
 
74
60
  const fetchAllPools = `query ($count: Int) {
75
61
  pools: pools(
@@ -488,16 +474,13 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
488
474
 
489
475
  export class BalancerV2
490
476
  extends SimpleExchange
491
- implements
492
- IDex<BalancerV2Data, BalancerV2DirectParam, OptimizedBalancerV2Data>
477
+ implements IDex<BalancerV2Data, BalancerParam, OptimizedBalancerV2Data>
493
478
  {
494
479
  protected eventPools: BalancerV2EventPool;
495
480
 
496
481
  readonly hasConstantPriceLargeAmounts = false;
497
482
  readonly isFeeOnTransferSupported = false;
498
483
 
499
- readonly directSwapIface = new Interface(DirectSwapABI);
500
-
501
484
  public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
502
485
  getDexKeysWithNetwork(BalancerConfig);
503
486
 
@@ -1010,136 +993,6 @@ export class BalancerV2
1010
993
  return params;
1011
994
  }
1012
995
 
1013
- static getDirectFunctionName(): string[] {
1014
- return [DirectMethods.directSell, DirectMethods.directBuy];
1015
- }
1016
-
1017
- getTokenFromAddress(address: Address): Token {
1018
- // In this Dex decimals are not used
1019
- return { address, decimals: 0 };
1020
- }
1021
-
1022
- async preProcessTransaction(
1023
- optimalSwapExchange: OptimalSwapExchange<OptimizedBalancerV2Data>,
1024
- srcToken: Token,
1025
- _0: Token,
1026
- _1: SwapSide,
1027
- options: PreprocessTransactionOptions,
1028
- ): Promise<[OptimalSwapExchange<OptimizedBalancerV2Data>, ExchangeTxInfo]> {
1029
- if (!options.isDirectMethod) {
1030
- return [
1031
- optimalSwapExchange,
1032
- {
1033
- deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
1034
- },
1035
- ];
1036
- }
1037
-
1038
- assert(
1039
- optimalSwapExchange.data !== undefined,
1040
- `preProcessTransaction: data field is missing`,
1041
- );
1042
-
1043
- let isApproved: boolean | undefined;
1044
-
1045
- try {
1046
- this.erc20Contract.options.address =
1047
- this.dexHelper.config.wrapETH(srcToken).address;
1048
- const allowance = await this.erc20Contract.methods
1049
- .allowance(this.augustusAddress, this.vaultAddress)
1050
- .call(undefined, 'latest');
1051
- isApproved =
1052
- BigInt(allowance.toString()) >= BigInt(optimalSwapExchange.srcAmount);
1053
- } catch (e) {
1054
- this.logger.error(
1055
- `preProcessTransaction failed to retrieve allowance info: `,
1056
- e,
1057
- );
1058
- }
1059
-
1060
- return [
1061
- {
1062
- ...optimalSwapExchange,
1063
- data: {
1064
- ...optimalSwapExchange.data,
1065
- isApproved,
1066
- },
1067
- },
1068
- {
1069
- deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
1070
- },
1071
- ];
1072
- }
1073
-
1074
- getDirectParam(
1075
- srcToken: Address,
1076
- destToken: Address,
1077
- srcAmount: NumberAsString,
1078
- destAmount: NumberAsString,
1079
- expectedAmount: NumberAsString,
1080
- data: OptimizedBalancerV2Data,
1081
- side: SwapSide,
1082
- permit: string,
1083
- uuid: string,
1084
- feePercent: NumberAsString,
1085
- deadline: NumberAsString,
1086
- partner: string,
1087
- beneficiary: string,
1088
- contractMethod?: string,
1089
- ): TxInfo<BalancerV2DirectParam> {
1090
- if (
1091
- contractMethod !== DirectMethods.directSell &&
1092
- contractMethod !== DirectMethods.directBuy
1093
- ) {
1094
- throw new Error(`Invalid contract method ${contractMethod}`);
1095
- }
1096
-
1097
- let isApproved: boolean = !!data.isApproved;
1098
- if (data.isApproved === undefined) {
1099
- this.logger.warn(`isApproved is undefined, defaulting to false`);
1100
- }
1101
-
1102
- const [, swaps, assets, funds, limits, _deadline] = this.getBalancerParam(
1103
- srcToken,
1104
- destToken,
1105
- srcAmount,
1106
- destAmount,
1107
- data,
1108
- side,
1109
- );
1110
-
1111
- const swapParams: BalancerV2DirectParam = [
1112
- swaps,
1113
- assets,
1114
- funds,
1115
- limits,
1116
- expectedAmount,
1117
- _deadline,
1118
- feePercent,
1119
- this.vaultAddress,
1120
- partner,
1121
- isApproved,
1122
- beneficiary,
1123
- permit,
1124
- uuidToBytes16(uuid),
1125
- ];
1126
-
1127
- const encoder = (...params: BalancerV2DirectParam) => {
1128
- return this.directSwapIface.encodeFunctionData(
1129
- side === SwapSide.SELL
1130
- ? DirectMethods.directSell
1131
- : DirectMethods.directBuy,
1132
- [params],
1133
- );
1134
- };
1135
-
1136
- return {
1137
- params: swapParams,
1138
- encoder,
1139
- networkFee: '0',
1140
- };
1141
- }
1142
-
1143
996
  async getSimpleParam(
1144
997
  srcToken: string,
1145
998
  destToken: string,
@@ -8,8 +8,3 @@ export const STABLE_GAS_COST = 84_000;
8
8
 
9
9
  // I see three pools used in trade: (57856 + 79098 + 51041) / 3 = 62665 ~ 63k
10
10
  export const VARIABLE_GAS_COST_PER_CYCLE = 63_000;
11
-
12
- export enum DirectMethods {
13
- directSell = 'directBalancerV2GivenInSwap',
14
- directBuy = 'directBalancerV2GivenOutSwap',
15
- }
@@ -1,4 +1,3 @@
1
- import { NumberAsString } from '@paraswap/core';
2
1
  import { Address } from '../../types';
3
2
 
4
3
  // These should match the Balancer Pool types available on Subgraph
@@ -85,13 +84,12 @@ export type BalancerSwapV2 = {
85
84
 
86
85
  export type OptimizedBalancerV2Data = {
87
86
  swaps: BalancerSwapV2[];
88
- isApproved?: boolean;
89
87
  };
90
88
 
91
89
  export type BalancerFunds = {
92
90
  sender: string;
93
- fromInternalBalance: boolean;
94
91
  recipient: string;
92
+ fromInternalBalance: boolean;
95
93
  toInternalBalance: boolean;
96
94
  };
97
95
 
@@ -118,22 +116,6 @@ export type BalancerParam = [
118
116
  deadline: string,
119
117
  ];
120
118
 
121
- export type BalancerV2DirectParam = [
122
- swaps: BalancerSwap[],
123
- assets: Address[],
124
- funds: BalancerFunds,
125
- limits: NumberAsString[],
126
- expectedAmount: NumberAsString,
127
- deadline: NumberAsString,
128
- feePercent: NumberAsString,
129
- vault: Address,
130
- partner: Address,
131
- isApproved: boolean,
132
- beneficiary: Address,
133
- permit: string,
134
- uuid: string,
135
- ];
136
-
137
119
  export type BalancerV2Data = {
138
120
  poolId: string;
139
121
  };
@@ -2,8 +2,6 @@ import { CurveV1Config } from './config';
2
2
  import { SwerveConfig } from './forks/swerve/config';
3
3
  import { CurveForksConfig } from './forks/curve-forks/config';
4
4
 
5
- export const DIRECT_METHOD_NAME = 'directCurveV1Swap';
6
-
7
5
  export const AllCurveForks = [
8
6
  ...Object.keys(CurveV1Config),
9
7
  ...Object.keys(CurveForksConfig),
@@ -133,63 +133,6 @@ describe('CurveV1 E2E', () => {
133
133
  });
134
134
  });
135
135
 
136
- describe('CurveV1 POLYGON', () => {
137
- const network = Network.POLYGON;
138
- const tokens = Tokens[network];
139
- const holders = Holders[network];
140
- const provider = new StaticJsonRpcProvider(
141
- generateConfig(network).privateHttpProvider,
142
- network,
143
- );
144
-
145
- const tokensToTest = [
146
- [
147
- {
148
- symbol: 'USDT',
149
- amount: (10 ** 8).toString(),
150
- },
151
- {
152
- symbol: 'DAI',
153
- amount: (10 ** 8).toString(),
154
- },
155
- ],
156
- ];
157
-
158
- const sideToContractMethods = new Map([
159
- [
160
- SwapSide.SELL,
161
- [
162
- ContractMethod.simpleSwap,
163
- ContractMethod.multiSwap,
164
- ContractMethod.megaSwap,
165
- ContractMethod.directCurveV1Swap,
166
- ],
167
- ],
168
- ]);
169
-
170
- sideToContractMethods.forEach((contractMethods, side) =>
171
- contractMethods.forEach((contractMethod: ContractMethod) => {
172
- tokensToTest.forEach(pair => {
173
- describe(`${contractMethod}`, () => {
174
- it(`${pair[0].symbol} -> ${pair[1].symbol}`, async () => {
175
- await testE2E(
176
- tokens[pair[0].symbol],
177
- tokens[pair[1].symbol],
178
- holders[pair[0].symbol],
179
- side === SwapSide.SELL ? pair[0].amount : pair[1].amount,
180
- side,
181
- dexKey,
182
- contractMethod,
183
- network,
184
- provider,
185
- );
186
- });
187
- });
188
- });
189
- }),
190
- );
191
- });
192
-
193
136
  describe('FANTOM', () => {
194
137
  const network = Network.FANTOM;
195
138
  const tokens = Tokens[network];
@@ -1,24 +1,17 @@
1
1
  import { Interface, AbiCoder, JsonFragment } from '@ethersproject/abi';
2
- import _ from 'lodash';
3
- import { NumberAsString, OptimalSwapExchange } from '@paraswap/core';
4
- import { assert } from 'ts-essentials';
5
2
  import BigNumber from 'bignumber.js';
6
3
  import CurveABI from '../../abi/Curve.json';
7
- import DirectSwapABI from '../../abi/DirectSwap.json';
8
4
  import { Adapters, CurveV1Config } from './config';
9
5
 
10
6
  import {
11
7
  AdapterExchangeParam,
12
8
  Address,
13
9
  ExchangePrices,
14
- ExchangeTxInfo,
15
10
  PoolLiquidity,
16
11
  PoolPrices,
17
- PreprocessTransactionOptions,
18
12
  SimpleExchangeParam,
19
13
  Token,
20
14
  TransferFeeParams,
21
- TxInfo,
22
15
  } from '../../types';
23
16
  import {
24
17
  Network,
@@ -55,6 +48,8 @@ import { TBTCPool, address as TBTCPoolAddress } from './pools/tBTCpool';
55
48
  import { USDKPool, address as USDKPoolAddress } from './pools/usdkpool';
56
49
  import { USTPool, address as USTPoolAddress } from './pools/ustpool';
57
50
  import { SLINKPool, address as SLINKPoolAddress } from './pools/sLinkpool';
51
+
52
+ import * as _ from 'lodash';
58
53
  import {
59
54
  getBigIntPow,
60
55
  getDexKeysWithNetwork,
@@ -62,13 +57,9 @@ import {
62
57
  isDestTokenTransferFeeToBeExchanged,
63
58
  isSrcTokenTransferFeeToBeExchanged,
64
59
  Utils,
65
- uuidToBytes16,
66
60
  } from '../../utils';
67
61
  import { BN_0 } from '../../bignumber-constants';
68
- import {
69
- getLocalDeadlineAsFriendlyPlaceholder,
70
- SimpleExchange,
71
- } from '../simple-exchange';
62
+ import { SimpleExchange } from '../simple-exchange';
72
63
  import { IDex } from '../idex';
73
64
  import { IDexHelper } from '../../dex-helper';
74
65
  import { Logger } from 'log4js';
@@ -80,12 +71,9 @@ import {
80
71
  CurveV1Data,
81
72
  TokenWithReasonableVolume,
82
73
  CurveSwapFunctions,
83
- CurveV1SwapType,
84
- DirectCurveV1Param,
85
74
  } from './types';
86
75
  import { erc20Iface } from '../../lib/utils-interfaces';
87
76
  import { applyTransferFee } from '../../lib/token-transfer-fee';
88
- import { DIRECT_METHOD_NAME } from './constants';
89
77
 
90
78
  const CURVE_DEFAULT_CHUNKS = 10;
91
79
 
@@ -94,10 +82,7 @@ const CURVE_POOL_GAS = 200 * 1000;
94
82
 
95
83
  const coder = new AbiCoder();
96
84
 
97
- export class CurveV1
98
- extends SimpleExchange
99
- implements IDex<CurveV1Data, DirectCurveV1Param>
100
- {
85
+ export class CurveV1 extends SimpleExchange implements IDex<CurveV1Data> {
101
86
  exchangeRouterInterface: Interface;
102
87
  minConversionRate = '1';
103
88
 
@@ -117,8 +102,6 @@ export class CurveV1
117
102
 
118
103
  protected disableFeeOnTransferTokenAddresses: Set<string>;
119
104
 
120
- readonly directSwapIface = new Interface(DirectSwapABI);
121
-
122
105
  readonly SRC_TOKEN_DEX_TRANSFERS = 1;
123
106
  readonly DEST_TOKEN_DEX_TRANSFERS = 1;
124
107
 
@@ -857,126 +840,6 @@ export class CurveV1
857
840
  return this.adapters[side];
858
841
  }
859
842
 
860
- static getDirectFunctionName(): string[] {
861
- return [DIRECT_METHOD_NAME];
862
- }
863
-
864
- getTokenFromAddress(address: Address): Token {
865
- // In this Dex decimals are not used
866
- return { address, decimals: 0 };
867
- }
868
-
869
- async preProcessTransaction(
870
- optimalSwapExchange: OptimalSwapExchange<CurveV1Data>,
871
- srcToken: Token,
872
- _0: Token,
873
- _1: SwapSide,
874
- options: PreprocessTransactionOptions,
875
- ): Promise<[OptimalSwapExchange<CurveV1Data>, ExchangeTxInfo]> {
876
- if (!options.isDirectMethod) {
877
- return [
878
- optimalSwapExchange,
879
- {
880
- deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
881
- },
882
- ];
883
- }
884
-
885
- assert(
886
- optimalSwapExchange.data !== undefined,
887
- `preProcessTransaction: data field is missing`,
888
- );
889
-
890
- let isApproved: boolean | undefined;
891
-
892
- try {
893
- this.erc20Contract.options.address =
894
- this.dexHelper.config.wrapETH(srcToken).address;
895
- const allowance = await this.erc20Contract.methods
896
- .allowance(this.augustusAddress, optimalSwapExchange.data.exchange)
897
- .call(undefined, 'latest');
898
- isApproved =
899
- BigInt(allowance.toString()) >= BigInt(optimalSwapExchange.srcAmount);
900
- } catch (e) {
901
- this.logger.error(
902
- `preProcessTransaction failed to retrieve allowance info: `,
903
- e,
904
- );
905
- }
906
-
907
- return [
908
- {
909
- ...optimalSwapExchange,
910
- data: {
911
- ...optimalSwapExchange.data,
912
- isApproved,
913
- },
914
- },
915
- {
916
- deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
917
- },
918
- ];
919
- }
920
-
921
- getDirectParam(
922
- srcToken: Address,
923
- destToken: Address,
924
- srcAmount: NumberAsString,
925
- destAmount: NumberAsString,
926
- expectedAmount: NumberAsString,
927
- data: CurveV1Data,
928
- side: SwapSide,
929
- permit: string,
930
- uuid: string,
931
- feePercent: NumberAsString,
932
- deadline: NumberAsString,
933
- partner: string,
934
- beneficiary: string,
935
- contractMethod?: string,
936
- ): TxInfo<DirectCurveV1Param> {
937
- if (contractMethod !== DIRECT_METHOD_NAME) {
938
- throw new Error(`Invalid contract method ${contractMethod}`);
939
- }
940
- assert(side === SwapSide.SELL, 'Buy not supported');
941
-
942
- let isApproved: boolean = !!data.isApproved;
943
- if (data.isApproved === undefined) {
944
- this.logger.warn(`isApproved is undefined, defaulting to false`);
945
- }
946
-
947
- const swapParams: DirectCurveV1Param = [
948
- srcToken,
949
- destToken,
950
- data.exchange,
951
- srcAmount,
952
- destAmount,
953
- expectedAmount,
954
- feePercent,
955
- data.i.toString(),
956
- data.j.toString(),
957
- partner,
958
- isApproved,
959
- data.underlyingSwap
960
- ? CurveV1SwapType.EXCHANGE_UNDERLYING
961
- : CurveV1SwapType.EXCHANGE,
962
- beneficiary,
963
- permit,
964
- uuidToBytes16(uuid),
965
- ];
966
-
967
- const encoder = (...params: DirectCurveV1Param) => {
968
- return this.directSwapIface.encodeFunctionData(DIRECT_METHOD_NAME, [
969
- params,
970
- ]);
971
- };
972
-
973
- return {
974
- params: swapParams,
975
- encoder,
976
- networkFee: '0',
977
- };
978
- }
979
-
980
843
  async getSimpleParam(
981
844
  srcToken: string,
982
845
  destToken: string,
@@ -1080,7 +943,7 @@ export class CurveV1
1080
943
  // the balances array in the pool as it was a mess to have each curve abi
1081
944
  // Some have balances[uint128] some have balances[uint256]
1082
945
  // One of the consequence for such a hack is below for ETH Pools
1083
- // TODO: below can be highly optimized
946
+ // TODO: below can be highly optimised
1084
947
  // * we don't need to query token decimals every iteration
1085
948
  // * we can use the decimals from the tokens list using the api
1086
949
 
@@ -1,4 +1,3 @@
1
- import { NumberAsString } from '@paraswap/core';
2
1
  import { Address, Token } from '../../types';
3
2
 
4
3
  export type CurveV1Data = {
@@ -7,7 +6,6 @@ export type CurveV1Data = {
7
6
  j: number;
8
7
  underlyingSwap: boolean;
9
8
  deadline: number;
10
- isApproved?: boolean;
11
9
  };
12
10
 
13
11
  export type PoolConfig = {
@@ -44,26 +42,3 @@ export enum CurveSwapFunctions {
44
42
  exchange = 'exchange',
45
43
  exchange_underlying = 'exchange_underlying',
46
44
  }
47
-
48
- export enum CurveV1SwapType {
49
- EXCHANGE,
50
- EXCHANGE_UNDERLYING,
51
- }
52
-
53
- export type DirectCurveV1Param = [
54
- fromToken: Address,
55
- toToken: Address,
56
- exchange: Address,
57
- fromAmount: NumberAsString,
58
- toAmount: NumberAsString,
59
- expectedAmount: NumberAsString,
60
- feePercent: NumberAsString,
61
- i: NumberAsString,
62
- j: NumberAsString,
63
- partner: Address,
64
- isApproved: boolean,
65
- swapType: CurveV1SwapType,
66
- beneficiary: Address,
67
- permit: string,
68
- uuid: string,
69
- ];
@@ -34,5 +34,3 @@ export const NETWORK_ID_TO_NAME: Record<number, string> = {
34
34
  // revisited
35
35
  export const FACTORY_MAX_PLAIN_COINS = 4;
36
36
  export const FACTORY_MAX_PLAIN_IMPLEMENTATIONS_FOR_COIN = 10;
37
-
38
- export const DIRECT_METHOD_NAME = 'directCurveV1Swap';
@@ -29,7 +29,6 @@ function testForNetwork(
29
29
  ContractMethod.simpleSwap,
30
30
  ContractMethod.multiSwap,
31
31
  ContractMethod.megaSwap,
32
- ContractMethod.directCurveV1Swap,
33
32
  ],
34
33
  ],
35
34
  ]);