@paraswap/dex-lib 2.42.20 → 2.42.21

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.
@@ -0,0 +1,281 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ { "internalType": "address", "name": "_factory", "type": "address" },
5
+ { "internalType": "address", "name": "_WNativeToken", "type": "address" },
6
+ { "internalType": "address", "name": "_poolDeployer", "type": "address" }
7
+ ],
8
+ "stateMutability": "nonpayable",
9
+ "type": "constructor"
10
+ },
11
+ {
12
+ "inputs": [],
13
+ "name": "WNativeToken",
14
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
15
+ "stateMutability": "view",
16
+ "type": "function"
17
+ },
18
+ {
19
+ "inputs": [
20
+ { "internalType": "int256", "name": "amount0Delta", "type": "int256" },
21
+ { "internalType": "int256", "name": "amount1Delta", "type": "int256" },
22
+ { "internalType": "bytes", "name": "_data", "type": "bytes" }
23
+ ],
24
+ "name": "algebraSwapCallback",
25
+ "outputs": [],
26
+ "stateMutability": "nonpayable",
27
+ "type": "function"
28
+ },
29
+ {
30
+ "inputs": [
31
+ {
32
+ "components": [
33
+ { "internalType": "bytes", "name": "path", "type": "bytes" },
34
+ { "internalType": "address", "name": "recipient", "type": "address" },
35
+ { "internalType": "uint256", "name": "deadline", "type": "uint256" },
36
+ { "internalType": "uint256", "name": "amountIn", "type": "uint256" },
37
+ {
38
+ "internalType": "uint256",
39
+ "name": "amountOutMinimum",
40
+ "type": "uint256"
41
+ }
42
+ ],
43
+ "internalType": "struct ISwapRouter.ExactInputParams",
44
+ "name": "params",
45
+ "type": "tuple"
46
+ }
47
+ ],
48
+ "name": "exactInput",
49
+ "outputs": [
50
+ { "internalType": "uint256", "name": "amountOut", "type": "uint256" }
51
+ ],
52
+ "stateMutability": "payable",
53
+ "type": "function"
54
+ },
55
+ {
56
+ "inputs": [
57
+ {
58
+ "components": [
59
+ { "internalType": "address", "name": "tokenIn", "type": "address" },
60
+ { "internalType": "address", "name": "tokenOut", "type": "address" },
61
+ { "internalType": "address", "name": "recipient", "type": "address" },
62
+ { "internalType": "uint256", "name": "deadline", "type": "uint256" },
63
+ { "internalType": "uint256", "name": "amountIn", "type": "uint256" },
64
+ {
65
+ "internalType": "uint256",
66
+ "name": "amountOutMinimum",
67
+ "type": "uint256"
68
+ },
69
+ {
70
+ "internalType": "uint160",
71
+ "name": "limitSqrtPrice",
72
+ "type": "uint160"
73
+ }
74
+ ],
75
+ "internalType": "struct ISwapRouter.ExactInputSingleParams",
76
+ "name": "params",
77
+ "type": "tuple"
78
+ }
79
+ ],
80
+ "name": "exactInputSingleSupportingFeeOnTransferTokens",
81
+ "outputs": [
82
+ { "internalType": "uint256", "name": "amountOut", "type": "uint256" }
83
+ ],
84
+ "stateMutability": "nonpayable",
85
+ "type": "function"
86
+ },
87
+ {
88
+ "inputs": [
89
+ {
90
+ "components": [
91
+ { "internalType": "bytes", "name": "path", "type": "bytes" },
92
+ { "internalType": "address", "name": "recipient", "type": "address" },
93
+ { "internalType": "uint256", "name": "deadline", "type": "uint256" },
94
+ { "internalType": "uint256", "name": "amountOut", "type": "uint256" },
95
+ {
96
+ "internalType": "uint256",
97
+ "name": "amountInMaximum",
98
+ "type": "uint256"
99
+ }
100
+ ],
101
+ "internalType": "struct ISwapRouter.ExactOutputParams",
102
+ "name": "params",
103
+ "type": "tuple"
104
+ }
105
+ ],
106
+ "name": "exactOutput",
107
+ "outputs": [
108
+ { "internalType": "uint256", "name": "amountIn", "type": "uint256" }
109
+ ],
110
+ "stateMutability": "payable",
111
+ "type": "function"
112
+ },
113
+ {
114
+ "inputs": [
115
+ {
116
+ "components": [
117
+ { "internalType": "address", "name": "tokenIn", "type": "address" },
118
+ { "internalType": "address", "name": "tokenOut", "type": "address" },
119
+ { "internalType": "uint24", "name": "fee", "type": "uint24" },
120
+ { "internalType": "address", "name": "recipient", "type": "address" },
121
+ { "internalType": "uint256", "name": "deadline", "type": "uint256" },
122
+ { "internalType": "uint256", "name": "amountOut", "type": "uint256" },
123
+ {
124
+ "internalType": "uint256",
125
+ "name": "amountInMaximum",
126
+ "type": "uint256"
127
+ },
128
+ {
129
+ "internalType": "uint160",
130
+ "name": "limitSqrtPrice",
131
+ "type": "uint160"
132
+ }
133
+ ],
134
+ "internalType": "struct ISwapRouter.ExactOutputSingleParams",
135
+ "name": "params",
136
+ "type": "tuple"
137
+ }
138
+ ],
139
+ "name": "exactOutputSingle",
140
+ "outputs": [
141
+ { "internalType": "uint256", "name": "amountIn", "type": "uint256" }
142
+ ],
143
+ "stateMutability": "payable",
144
+ "type": "function"
145
+ },
146
+ {
147
+ "inputs": [],
148
+ "name": "factory",
149
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
150
+ "stateMutability": "view",
151
+ "type": "function"
152
+ },
153
+ {
154
+ "inputs": [
155
+ { "internalType": "bytes[]", "name": "data", "type": "bytes[]" }
156
+ ],
157
+ "name": "multicall",
158
+ "outputs": [
159
+ { "internalType": "bytes[]", "name": "results", "type": "bytes[]" }
160
+ ],
161
+ "stateMutability": "payable",
162
+ "type": "function"
163
+ },
164
+ {
165
+ "inputs": [],
166
+ "name": "poolDeployer",
167
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
168
+ "stateMutability": "view",
169
+ "type": "function"
170
+ },
171
+ {
172
+ "inputs": [],
173
+ "name": "refundNativeToken",
174
+ "outputs": [],
175
+ "stateMutability": "payable",
176
+ "type": "function"
177
+ },
178
+ {
179
+ "inputs": [
180
+ { "internalType": "address", "name": "token", "type": "address" },
181
+ { "internalType": "uint256", "name": "value", "type": "uint256" },
182
+ { "internalType": "uint256", "name": "deadline", "type": "uint256" },
183
+ { "internalType": "uint8", "name": "v", "type": "uint8" },
184
+ { "internalType": "bytes32", "name": "r", "type": "bytes32" },
185
+ { "internalType": "bytes32", "name": "s", "type": "bytes32" }
186
+ ],
187
+ "name": "selfPermit",
188
+ "outputs": [],
189
+ "stateMutability": "payable",
190
+ "type": "function"
191
+ },
192
+ {
193
+ "inputs": [
194
+ { "internalType": "address", "name": "token", "type": "address" },
195
+ { "internalType": "uint256", "name": "nonce", "type": "uint256" },
196
+ { "internalType": "uint256", "name": "expiry", "type": "uint256" },
197
+ { "internalType": "uint8", "name": "v", "type": "uint8" },
198
+ { "internalType": "bytes32", "name": "r", "type": "bytes32" },
199
+ { "internalType": "bytes32", "name": "s", "type": "bytes32" }
200
+ ],
201
+ "name": "selfPermitAllowed",
202
+ "outputs": [],
203
+ "stateMutability": "payable",
204
+ "type": "function"
205
+ },
206
+ {
207
+ "inputs": [
208
+ { "internalType": "address", "name": "token", "type": "address" },
209
+ { "internalType": "uint256", "name": "nonce", "type": "uint256" },
210
+ { "internalType": "uint256", "name": "expiry", "type": "uint256" },
211
+ { "internalType": "uint8", "name": "v", "type": "uint8" },
212
+ { "internalType": "bytes32", "name": "r", "type": "bytes32" },
213
+ { "internalType": "bytes32", "name": "s", "type": "bytes32" }
214
+ ],
215
+ "name": "selfPermitAllowedIfNecessary",
216
+ "outputs": [],
217
+ "stateMutability": "payable",
218
+ "type": "function"
219
+ },
220
+ {
221
+ "inputs": [
222
+ { "internalType": "address", "name": "token", "type": "address" },
223
+ { "internalType": "uint256", "name": "value", "type": "uint256" },
224
+ { "internalType": "uint256", "name": "deadline", "type": "uint256" },
225
+ { "internalType": "uint8", "name": "v", "type": "uint8" },
226
+ { "internalType": "bytes32", "name": "r", "type": "bytes32" },
227
+ { "internalType": "bytes32", "name": "s", "type": "bytes32" }
228
+ ],
229
+ "name": "selfPermitIfNecessary",
230
+ "outputs": [],
231
+ "stateMutability": "payable",
232
+ "type": "function"
233
+ },
234
+ {
235
+ "inputs": [
236
+ { "internalType": "address", "name": "token", "type": "address" },
237
+ { "internalType": "uint256", "name": "amountMinimum", "type": "uint256" },
238
+ { "internalType": "address", "name": "recipient", "type": "address" }
239
+ ],
240
+ "name": "sweepToken",
241
+ "outputs": [],
242
+ "stateMutability": "payable",
243
+ "type": "function"
244
+ },
245
+ {
246
+ "inputs": [
247
+ { "internalType": "address", "name": "token", "type": "address" },
248
+ { "internalType": "uint256", "name": "amountMinimum", "type": "uint256" },
249
+ { "internalType": "address", "name": "recipient", "type": "address" },
250
+ { "internalType": "uint256", "name": "feeBips", "type": "uint256" },
251
+ { "internalType": "address", "name": "feeRecipient", "type": "address" }
252
+ ],
253
+ "name": "sweepTokenWithFee",
254
+ "outputs": [],
255
+ "stateMutability": "payable",
256
+ "type": "function"
257
+ },
258
+ {
259
+ "inputs": [
260
+ { "internalType": "uint256", "name": "amountMinimum", "type": "uint256" },
261
+ { "internalType": "address", "name": "recipient", "type": "address" }
262
+ ],
263
+ "name": "unwrapWNativeToken",
264
+ "outputs": [],
265
+ "stateMutability": "payable",
266
+ "type": "function"
267
+ },
268
+ {
269
+ "inputs": [
270
+ { "internalType": "uint256", "name": "amountMinimum", "type": "uint256" },
271
+ { "internalType": "address", "name": "recipient", "type": "address" },
272
+ { "internalType": "uint256", "name": "feeBips", "type": "uint256" },
273
+ { "internalType": "address", "name": "feeRecipient", "type": "address" }
274
+ ],
275
+ "name": "unwrapWNativeTokenWithFee",
276
+ "outputs": [],
277
+ "stateMutability": "payable",
278
+ "type": "function"
279
+ },
280
+ { "stateMutability": "payable", "type": "receive" }
281
+ ]
package/src/config.ts CHANGED
@@ -281,7 +281,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
281
281
  process.env[`HASHFLOW_DISABLED_MMS_42161`]?.split(',') || [],
282
282
  adapterAddresses: {
283
283
  ArbitrumAdapter01: '0xD8134ACfc9c71Ab51452b5bA23A31354F4739032',
284
- ArbitrumAdapter02: '0x248009f6F78b5AcD5EA2fc86d56b77A7AeEe2eFc',
284
+ ArbitrumAdapter02: '0x7b0c7f946c845bb0d43ad41ece7027e1fc11bea7',
285
285
  ArbitrumBuyAdapter: '0xEECA9223063bD13e8ca77ed9e39a07f2BD1923E6',
286
286
  },
287
287
  uniswapV2ExchangeRouterAddress:
@@ -11,6 +11,7 @@ import {
11
11
  import { Network, ContractMethod, SwapSide } from '../../constants';
12
12
  import { StaticJsonRpcProvider } from '@ethersproject/providers';
13
13
  import { generateConfig } from '../../config';
14
+ import { TransferFeeParams } from '../../types';
14
15
 
15
16
  /*
16
17
  README
@@ -59,6 +60,12 @@ function testForNetwork(
59
60
  tokenAAmount: string,
60
61
  tokenBAmount: string,
61
62
  nativeTokenAmount: string,
63
+ transferFees: TransferFeeParams = {
64
+ srcFee: 0,
65
+ destFee: 0,
66
+ srcDexFee: 0,
67
+ destDexFee: 0,
68
+ },
62
69
  ) {
63
70
  const provider = new StaticJsonRpcProvider(
64
71
  generateConfig(network).privateHttpProvider,
@@ -80,6 +87,7 @@ function testForNetwork(
80
87
  ],
81
88
  // TODO: If buy is not supported remove the buy contract methods
82
89
  [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
90
+ // [SwapSide.BUY, [ContractMethod.simpleBuy]],
83
91
  ]);
84
92
 
85
93
  describe(`${network}`, () => {
@@ -87,43 +95,81 @@ function testForNetwork(
87
95
  describe(`${side}`, () => {
88
96
  contractMethods.forEach((contractMethod: ContractMethod) => {
89
97
  describe(`${contractMethod}`, () => {
90
- it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
98
+ // if src token is tax token and BUY side, then should fail (skip)
99
+ if (!!transferFees?.srcDexFee && side === SwapSide.BUY) return;
100
+
101
+ it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
91
102
  await testE2E(
92
- tokens[nativeTokenSymbol],
93
103
  tokens[tokenASymbol],
94
- holders[nativeTokenSymbol],
95
- side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
104
+ tokens[tokenBSymbol],
105
+ holders[tokenASymbol],
106
+ side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
96
107
  side,
97
108
  dexKey,
98
109
  contractMethod,
99
110
  network,
100
111
  provider,
112
+ undefined,
113
+ undefined,
114
+ transferFees,
101
115
  );
102
116
  });
103
- it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
117
+ it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
104
118
  await testE2E(
119
+ tokens[tokenBSymbol],
105
120
  tokens[tokenASymbol],
121
+ holders[tokenBSymbol],
122
+ side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
123
+ side,
124
+ dexKey,
125
+ contractMethod,
126
+ network,
127
+ provider,
128
+ undefined,
129
+ undefined,
130
+ // switch src and dest fee when tax token is dest token
131
+ {
132
+ ...transferFees,
133
+ srcDexFee: transferFees.destDexFee,
134
+ destDexFee: transferFees.srcDexFee,
135
+ },
136
+ );
137
+ });
138
+ it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
139
+ await testE2E(
106
140
  tokens[nativeTokenSymbol],
107
- holders[tokenASymbol],
108
- side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
141
+ tokens[tokenASymbol],
142
+ holders[nativeTokenSymbol],
143
+ side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
109
144
  side,
110
145
  dexKey,
111
146
  contractMethod,
112
147
  network,
113
148
  provider,
149
+ undefined,
150
+ undefined,
151
+ // switch src and dest fee when tax token is dest token
152
+ {
153
+ ...transferFees,
154
+ srcDexFee: transferFees.destDexFee,
155
+ destDexFee: transferFees.srcDexFee,
156
+ },
114
157
  );
115
158
  });
116
- it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
159
+ it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
117
160
  await testE2E(
118
161
  tokens[tokenASymbol],
119
- tokens[tokenBSymbol],
162
+ tokens[nativeTokenSymbol],
120
163
  holders[tokenASymbol],
121
- side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
164
+ side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
122
165
  side,
123
166
  dexKey,
124
167
  contractMethod,
125
168
  network,
126
169
  provider,
170
+ undefined,
171
+ undefined,
172
+ transferFees,
127
173
  );
128
174
  });
129
175
  });
@@ -204,10 +250,35 @@ describe('Algebra', () => {
204
250
 
205
251
  describe('CamelotV3', () => {
206
252
  const dexKey = 'CamelotV3';
253
+ const network = Network.ARBITRUM;
207
254
 
208
- describe('Arbitrum', () => {
209
- const network = Network.ARBITRUM;
210
- const tokenASymbol: string = 'USDC';
255
+ describe('Arbitrum: Tax Tokens', () => {
256
+ const tokenASymbol: string = 'RDPX';
257
+ const tokenBSymbol: string = 'WETH';
258
+
259
+ const tokenAAmount: string = '100000000000000000000';
260
+ const tokenBAmount: string = '100000000000000000';
261
+ const nativeTokenAmount = '1000000000000000000';
262
+
263
+ testForNetwork(
264
+ network,
265
+ dexKey,
266
+ tokenASymbol,
267
+ tokenBSymbol,
268
+ tokenAAmount,
269
+ tokenBAmount,
270
+ nativeTokenAmount,
271
+ {
272
+ srcFee: 0,
273
+ destFee: 0,
274
+ srcDexFee: 1000,
275
+ destDexFee: 0,
276
+ },
277
+ );
278
+ });
279
+
280
+ describe('Arbitrum: Non-Tax tokens', () => {
281
+ const tokenASymbol: string = 'USDCe';
211
282
  const tokenBSymbol: string = 'USDT';
212
283
 
213
284
  const tokenAAmount: string = '1000000000';