@paraswap/dex-lib 2.41.3 → 2.41.5-polygon-migrator
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.
- package/build/abi/polygon-migration/PolygonMigration.abi.json +364 -0
- package/build/config.js +2 -2
- package/build/dex/dexalot/constants.js.map +1 -1
- package/build/dex/dexalot/dexalot.js +18 -10
- package/build/dex/dexalot/dexalot.js.map +1 -1
- package/build/dex/dexalot/rate-fetcher.js +1 -1
- package/build/dex/dexalot/rate-fetcher.js.map +1 -1
- package/build/dex/index.js +4 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/polygon-migrator/config.d.ts +11 -0
- package/build/dex/polygon-migrator/config.js +21 -0
- package/build/dex/polygon-migrator/config.js.map +1 -0
- package/build/dex/polygon-migrator/constants.d.ts +1 -0
- package/build/dex/polygon-migrator/constants.js +5 -0
- package/build/dex/polygon-migrator/constants.js.map +1 -0
- package/build/dex/polygon-migrator/polygon-migrator.d.ts +48 -0
- package/build/dex/polygon-migrator/polygon-migrator.js +109 -0
- package/build/dex/polygon-migrator/polygon-migrator.js.map +1 -0
- package/build/dex/polygon-migrator/types.d.ts +11 -0
- package/build/dex/polygon-migrator/types.js +9 -0
- package/build/dex/polygon-migrator/types.js.map +1 -0
- package/build/dex/solidly/config.js +11 -1
- package/build/dex/solidly/config.js.map +1 -1
- package/build/dex/solidly/forks-override/chronos.js +10 -3
- package/build/dex/solidly/forks-override/chronos.js.map +1 -1
- package/build/dex/solidly/forks-override/usdfi.d.ts +8 -0
- package/build/dex/solidly/forks-override/usdfi.js +15 -0
- package/build/dex/solidly/forks-override/usdfi.js.map +1 -0
- package/build/dex/solidly/forks-override/velocimeter.js +6 -2
- package/build/dex/solidly/forks-override/velocimeter.js.map +1 -1
- package/build/dex/solidly/solidly.js +1 -0
- package/build/dex/solidly/solidly.js.map +1 -1
- package/build/dex/swaap-v2/swaap-v2.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/polygon-migration/PolygonMigration.abi.json +364 -0
- package/src/config.ts +2 -2
- package/src/dex/algebra/algebra-e2e.test.ts +1 -1
- package/src/dex/dexalot/constants.ts +2 -1
- package/src/dex/dexalot/dexalot-e2e.test.ts +9 -9
- package/src/dex/dexalot/dexalot.ts +59 -34
- package/src/dex/dexalot/rate-fetcher.ts +1 -1
- package/src/dex/index.ts +4 -0
- package/src/dex/polygon-migrator/config.ts +25 -0
- package/src/dex/polygon-migrator/constants.ts +2 -0
- package/src/dex/polygon-migrator/polygon-migrator-e2e.test.ts +102 -0
- package/src/dex/polygon-migrator/polygon-migrator-integration.test.ts +140 -0
- package/src/dex/polygon-migrator/polygon-migrator.ts +151 -0
- package/src/dex/polygon-migrator/types.ts +14 -0
- package/src/dex/solidly/config.ts +13 -1
- package/src/dex/solidly/forks-override/chronos.ts +93 -68
- package/src/dex/solidly/forks-override/usdfi.ts +10 -0
- package/src/dex/solidly/forks-override/velocimeter.ts +6 -2
- package/src/dex/solidly/solidly-e2e.test.ts +20 -0
- package/src/dex/solidly/solidly-integration.test.ts +189 -1
- package/src/dex/solidly/solidly.ts +1 -0
- package/src/dex/swaap-v2/swaap-v2.ts +5 -2
- package/tests/constants-e2e.ts +25 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"inputs": [
|
|
4
|
+
{
|
|
5
|
+
"internalType": "address",
|
|
6
|
+
"name": "matic_",
|
|
7
|
+
"type": "address"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"stateMutability": "nonpayable",
|
|
11
|
+
"type": "constructor"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"inputs": [],
|
|
15
|
+
"name": "InvalidAddress",
|
|
16
|
+
"type": "error"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"inputs": [],
|
|
20
|
+
"name": "InvalidAddressOrAlreadySet",
|
|
21
|
+
"type": "error"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"inputs": [],
|
|
25
|
+
"name": "UnmigrationLocked",
|
|
26
|
+
"type": "error"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"anonymous": false,
|
|
30
|
+
"inputs": [
|
|
31
|
+
{
|
|
32
|
+
"indexed": false,
|
|
33
|
+
"internalType": "uint8",
|
|
34
|
+
"name": "version",
|
|
35
|
+
"type": "uint8"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"name": "Initialized",
|
|
39
|
+
"type": "event"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"anonymous": false,
|
|
43
|
+
"inputs": [
|
|
44
|
+
{
|
|
45
|
+
"indexed": true,
|
|
46
|
+
"internalType": "address",
|
|
47
|
+
"name": "account",
|
|
48
|
+
"type": "address"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"indexed": false,
|
|
52
|
+
"internalType": "uint256",
|
|
53
|
+
"name": "amount",
|
|
54
|
+
"type": "uint256"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"name": "Migrated",
|
|
58
|
+
"type": "event"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"anonymous": false,
|
|
62
|
+
"inputs": [
|
|
63
|
+
{
|
|
64
|
+
"indexed": true,
|
|
65
|
+
"internalType": "address",
|
|
66
|
+
"name": "previousOwner",
|
|
67
|
+
"type": "address"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"indexed": true,
|
|
71
|
+
"internalType": "address",
|
|
72
|
+
"name": "newOwner",
|
|
73
|
+
"type": "address"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"name": "OwnershipTransferStarted",
|
|
77
|
+
"type": "event"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"anonymous": false,
|
|
81
|
+
"inputs": [
|
|
82
|
+
{
|
|
83
|
+
"indexed": true,
|
|
84
|
+
"internalType": "address",
|
|
85
|
+
"name": "previousOwner",
|
|
86
|
+
"type": "address"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"indexed": true,
|
|
90
|
+
"internalType": "address",
|
|
91
|
+
"name": "newOwner",
|
|
92
|
+
"type": "address"
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"name": "OwnershipTransferred",
|
|
96
|
+
"type": "event"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"anonymous": false,
|
|
100
|
+
"inputs": [
|
|
101
|
+
{
|
|
102
|
+
"indexed": true,
|
|
103
|
+
"internalType": "address",
|
|
104
|
+
"name": "account",
|
|
105
|
+
"type": "address"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"indexed": true,
|
|
109
|
+
"internalType": "address",
|
|
110
|
+
"name": "recipient",
|
|
111
|
+
"type": "address"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"indexed": false,
|
|
115
|
+
"internalType": "uint256",
|
|
116
|
+
"name": "amount",
|
|
117
|
+
"type": "uint256"
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"name": "Unmigrated",
|
|
121
|
+
"type": "event"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"anonymous": false,
|
|
125
|
+
"inputs": [
|
|
126
|
+
{
|
|
127
|
+
"indexed": false,
|
|
128
|
+
"internalType": "bool",
|
|
129
|
+
"name": "lock",
|
|
130
|
+
"type": "bool"
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
"name": "UnmigrationLockUpdated",
|
|
134
|
+
"type": "event"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"inputs": [],
|
|
138
|
+
"name": "acceptOwnership",
|
|
139
|
+
"outputs": [],
|
|
140
|
+
"stateMutability": "nonpayable",
|
|
141
|
+
"type": "function"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"inputs": [
|
|
145
|
+
{
|
|
146
|
+
"internalType": "uint256",
|
|
147
|
+
"name": "amount",
|
|
148
|
+
"type": "uint256"
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
"name": "burn",
|
|
152
|
+
"outputs": [],
|
|
153
|
+
"stateMutability": "nonpayable",
|
|
154
|
+
"type": "function"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"inputs": [],
|
|
158
|
+
"name": "initialize",
|
|
159
|
+
"outputs": [],
|
|
160
|
+
"stateMutability": "nonpayable",
|
|
161
|
+
"type": "function"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"inputs": [],
|
|
165
|
+
"name": "matic",
|
|
166
|
+
"outputs": [
|
|
167
|
+
{
|
|
168
|
+
"internalType": "contract IERC20",
|
|
169
|
+
"name": "",
|
|
170
|
+
"type": "address"
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"stateMutability": "view",
|
|
174
|
+
"type": "function"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"inputs": [
|
|
178
|
+
{
|
|
179
|
+
"internalType": "uint256",
|
|
180
|
+
"name": "amount",
|
|
181
|
+
"type": "uint256"
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
"name": "migrate",
|
|
185
|
+
"outputs": [],
|
|
186
|
+
"stateMutability": "nonpayable",
|
|
187
|
+
"type": "function"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"inputs": [],
|
|
191
|
+
"name": "owner",
|
|
192
|
+
"outputs": [
|
|
193
|
+
{
|
|
194
|
+
"internalType": "address",
|
|
195
|
+
"name": "",
|
|
196
|
+
"type": "address"
|
|
197
|
+
}
|
|
198
|
+
],
|
|
199
|
+
"stateMutability": "view",
|
|
200
|
+
"type": "function"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"inputs": [],
|
|
204
|
+
"name": "pendingOwner",
|
|
205
|
+
"outputs": [
|
|
206
|
+
{
|
|
207
|
+
"internalType": "address",
|
|
208
|
+
"name": "",
|
|
209
|
+
"type": "address"
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
"stateMutability": "view",
|
|
213
|
+
"type": "function"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"inputs": [],
|
|
217
|
+
"name": "polygon",
|
|
218
|
+
"outputs": [
|
|
219
|
+
{
|
|
220
|
+
"internalType": "contract IERC20",
|
|
221
|
+
"name": "",
|
|
222
|
+
"type": "address"
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
"stateMutability": "view",
|
|
226
|
+
"type": "function"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"inputs": [],
|
|
230
|
+
"name": "renounceOwnership",
|
|
231
|
+
"outputs": [],
|
|
232
|
+
"stateMutability": "nonpayable",
|
|
233
|
+
"type": "function"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"inputs": [
|
|
237
|
+
{
|
|
238
|
+
"internalType": "address",
|
|
239
|
+
"name": "polygon_",
|
|
240
|
+
"type": "address"
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
"name": "setPolygonToken",
|
|
244
|
+
"outputs": [],
|
|
245
|
+
"stateMutability": "nonpayable",
|
|
246
|
+
"type": "function"
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"inputs": [
|
|
250
|
+
{
|
|
251
|
+
"internalType": "address",
|
|
252
|
+
"name": "newOwner",
|
|
253
|
+
"type": "address"
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
"name": "transferOwnership",
|
|
257
|
+
"outputs": [],
|
|
258
|
+
"stateMutability": "nonpayable",
|
|
259
|
+
"type": "function"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"inputs": [
|
|
263
|
+
{
|
|
264
|
+
"internalType": "uint256",
|
|
265
|
+
"name": "amount",
|
|
266
|
+
"type": "uint256"
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
"name": "unmigrate",
|
|
270
|
+
"outputs": [],
|
|
271
|
+
"stateMutability": "nonpayable",
|
|
272
|
+
"type": "function"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"inputs": [
|
|
276
|
+
{
|
|
277
|
+
"internalType": "address",
|
|
278
|
+
"name": "recipient",
|
|
279
|
+
"type": "address"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"internalType": "uint256",
|
|
283
|
+
"name": "amount",
|
|
284
|
+
"type": "uint256"
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
"name": "unmigrateTo",
|
|
288
|
+
"outputs": [],
|
|
289
|
+
"stateMutability": "nonpayable",
|
|
290
|
+
"type": "function"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"inputs": [
|
|
294
|
+
{
|
|
295
|
+
"internalType": "uint256",
|
|
296
|
+
"name": "amount",
|
|
297
|
+
"type": "uint256"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"internalType": "uint256",
|
|
301
|
+
"name": "deadline",
|
|
302
|
+
"type": "uint256"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"internalType": "uint8",
|
|
306
|
+
"name": "v",
|
|
307
|
+
"type": "uint8"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"internalType": "bytes32",
|
|
311
|
+
"name": "r",
|
|
312
|
+
"type": "bytes32"
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"internalType": "bytes32",
|
|
316
|
+
"name": "s",
|
|
317
|
+
"type": "bytes32"
|
|
318
|
+
}
|
|
319
|
+
],
|
|
320
|
+
"name": "unmigrateWithPermit",
|
|
321
|
+
"outputs": [],
|
|
322
|
+
"stateMutability": "nonpayable",
|
|
323
|
+
"type": "function"
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
"inputs": [],
|
|
327
|
+
"name": "unmigrationLocked",
|
|
328
|
+
"outputs": [
|
|
329
|
+
{
|
|
330
|
+
"internalType": "bool",
|
|
331
|
+
"name": "",
|
|
332
|
+
"type": "bool"
|
|
333
|
+
}
|
|
334
|
+
],
|
|
335
|
+
"stateMutability": "view",
|
|
336
|
+
"type": "function"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
"inputs": [
|
|
340
|
+
{
|
|
341
|
+
"internalType": "bool",
|
|
342
|
+
"name": "unmigrationLocked_",
|
|
343
|
+
"type": "bool"
|
|
344
|
+
}
|
|
345
|
+
],
|
|
346
|
+
"name": "updateUnmigrationLock",
|
|
347
|
+
"outputs": [],
|
|
348
|
+
"stateMutability": "nonpayable",
|
|
349
|
+
"type": "function"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"inputs": [],
|
|
353
|
+
"name": "version",
|
|
354
|
+
"outputs": [
|
|
355
|
+
{
|
|
356
|
+
"internalType": "string",
|
|
357
|
+
"name": "",
|
|
358
|
+
"type": "string"
|
|
359
|
+
}
|
|
360
|
+
],
|
|
361
|
+
"stateMutability": "pure",
|
|
362
|
+
"type": "function"
|
|
363
|
+
}
|
|
364
|
+
]
|
package/src/config.ts
CHANGED
|
@@ -52,8 +52,8 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
52
52
|
Adapter01: '0x9bE264469eF954c139Da4A45Cf76CbCC5e3A6A73',
|
|
53
53
|
Adapter02: '0xFC2Ba6E830a04C25e207B8214b26d8C713F6881F',
|
|
54
54
|
Adapter03: '0xfb2a3de6c7B8c77b520E3da16021f3D8A4E93168',
|
|
55
|
-
Adapter04: '
|
|
56
|
-
BuyAdapter: '
|
|
55
|
+
Adapter04: '0x1A23Aa6f7ff4215Fd2d220EA6f4a0DF45A77fc6C',
|
|
56
|
+
BuyAdapter: '0x1310dE2C69e9753bee19B5522bad39c5f788efd9',
|
|
57
57
|
},
|
|
58
58
|
uniswapV2ExchangeRouterAddress:
|
|
59
59
|
'0xF9234CB08edb93c0d4a4d4c70cC3FfD070e78e07',
|
|
@@ -26,6 +26,7 @@ export const DEXALOT_RESTRICT_TTL_S = 60 * 30; // 30 minutes
|
|
|
26
26
|
|
|
27
27
|
export const DEXALOT_RESTRICTED_CACHE_KEY = 'restricted';
|
|
28
28
|
|
|
29
|
-
export const DEXALOT_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION =
|
|
29
|
+
export const DEXALOT_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION =
|
|
30
|
+
new BigNumber('0.001');
|
|
30
31
|
|
|
31
32
|
export const DEXALOT_FIRM_QUOTE_TIMEOUT_MS = 2000;
|
|
@@ -32,15 +32,15 @@ function testForNetwork(
|
|
|
32
32
|
const sleepMs = 10000;
|
|
33
33
|
|
|
34
34
|
const sideToContractMethods = new Map([
|
|
35
|
-
[
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
]],
|
|
35
|
+
[
|
|
36
|
+
SwapSide.SELL,
|
|
37
|
+
[
|
|
38
|
+
ContractMethod.simpleSwap,
|
|
39
|
+
ContractMethod.megaSwap,
|
|
40
|
+
ContractMethod.multiSwap,
|
|
41
|
+
],
|
|
42
|
+
],
|
|
43
|
+
[SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
|
|
44
44
|
]);
|
|
45
45
|
|
|
46
46
|
describe(`${network}`, () => {
|
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
Logger,
|
|
10
10
|
ExchangeTxInfo,
|
|
11
11
|
OptimalSwapExchange,
|
|
12
|
-
PreprocessTransactionOptions,
|
|
12
|
+
PreprocessTransactionOptions,
|
|
13
|
+
TransferFeeParams,
|
|
13
14
|
} from '../../types';
|
|
14
15
|
import {
|
|
15
16
|
SwapSide,
|
|
@@ -34,7 +35,10 @@ import {
|
|
|
34
35
|
TokenAddrDataMap,
|
|
35
36
|
TokenDataMap,
|
|
36
37
|
} from './types';
|
|
37
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
SlippageCheckError,
|
|
40
|
+
TooStrictSlippageCheckError,
|
|
41
|
+
} from '../generic-rfq/types';
|
|
38
42
|
import { SimpleExchange } from '../simple-exchange';
|
|
39
43
|
import { Adapters, DexalotConfig } from './config';
|
|
40
44
|
import { RateFetcher } from './rate-fetcher';
|
|
@@ -202,7 +206,9 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
202
206
|
? [srcAddress, destAddress]
|
|
203
207
|
: [destAddress, srcAddress];
|
|
204
208
|
|
|
205
|
-
return `${
|
|
209
|
+
return `${
|
|
210
|
+
this.dexKey
|
|
211
|
+
}_${sortedAddresses[0].toLowerCase()}_${sortedAddresses[1].toLowerCase()}`;
|
|
206
212
|
}
|
|
207
213
|
|
|
208
214
|
async getPoolIdentifiers(
|
|
@@ -221,10 +227,12 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
221
227
|
|
|
222
228
|
const tokensAddr = (await this.getCachedTokensAddr()) || {};
|
|
223
229
|
|
|
224
|
-
return [
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
230
|
+
return [
|
|
231
|
+
this.getIdentifier(
|
|
232
|
+
tokensAddr[pairData.base.toLowerCase()],
|
|
233
|
+
tokensAddr[pairData.quote.toLowerCase()],
|
|
234
|
+
),
|
|
235
|
+
];
|
|
228
236
|
}
|
|
229
237
|
|
|
230
238
|
async getCachedPairs(): Promise<PairDataMap | null> {
|
|
@@ -385,9 +393,11 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
385
393
|
.toString(),
|
|
386
394
|
);
|
|
387
395
|
if (side === ClobSide.ASK) {
|
|
388
|
-
lQty =
|
|
396
|
+
lQty =
|
|
397
|
+
(lQty * BigInt(10 ** (baseToken.decimals * 2))) /
|
|
389
398
|
(lPrice * BigInt(10 ** quoteToken.decimals));
|
|
390
|
-
rQty =
|
|
399
|
+
rQty =
|
|
400
|
+
(rQty * BigInt(10 ** (baseToken.decimals * 2))) /
|
|
391
401
|
(rPrice * BigInt(10 ** quoteToken.decimals));
|
|
392
402
|
}
|
|
393
403
|
price = lPrice + ((rPrice - lPrice) * (amt - lQty)) / (rQty - lQty);
|
|
@@ -397,9 +407,9 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
397
407
|
if (side === ClobSide.BID) {
|
|
398
408
|
result.push(
|
|
399
409
|
price !== 0n // To avoid division by zero error
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
410
|
+
? (amount * BigInt(10 ** (baseToken.decimals * 2))) /
|
|
411
|
+
(price * BigInt(10 ** quoteToken.decimals))
|
|
412
|
+
: 0n,
|
|
403
413
|
);
|
|
404
414
|
} else {
|
|
405
415
|
result.push(
|
|
@@ -435,13 +445,13 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
435
445
|
|
|
436
446
|
const pools = limitPools
|
|
437
447
|
? limitPools.filter(
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
448
|
+
p =>
|
|
449
|
+
p ===
|
|
450
|
+
this.getIdentifier(
|
|
451
|
+
normalizedSrcToken.address,
|
|
452
|
+
normalizedDestToken.address,
|
|
453
|
+
),
|
|
454
|
+
)
|
|
445
455
|
: await this.getPoolIdentifiers(srcToken, destToken, side, blockNumber);
|
|
446
456
|
|
|
447
457
|
if (pools.length === 0) {
|
|
@@ -464,11 +474,13 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
464
474
|
const tokensAddr = (await this.getCachedTokensAddr()) || {};
|
|
465
475
|
const pairKey = `${pairData.base}/${pairData.quote}`.toLowerCase();
|
|
466
476
|
if (
|
|
467
|
-
!(pairKey in priceMap)
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
477
|
+
!(pairKey in priceMap) ||
|
|
478
|
+
!pools.includes(
|
|
479
|
+
this.getIdentifier(
|
|
480
|
+
tokensAddr[pairData.base.toLowerCase()],
|
|
481
|
+
tokensAddr[pairData.quote.toLowerCase()],
|
|
482
|
+
),
|
|
483
|
+
)
|
|
472
484
|
) {
|
|
473
485
|
return null;
|
|
474
486
|
}
|
|
@@ -640,12 +652,20 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
640
652
|
} else {
|
|
641
653
|
if (
|
|
642
654
|
BigInt(order.takerAmount) >
|
|
643
|
-
BigInt(
|
|
655
|
+
BigInt(
|
|
656
|
+
slippageFactor
|
|
657
|
+
.times(optimalSwapExchange.srcAmount.toString())
|
|
658
|
+
.toFixed(0),
|
|
659
|
+
)
|
|
644
660
|
) {
|
|
645
661
|
isFailOnSlippage = true;
|
|
646
662
|
const message = `${this.dexKey}-${
|
|
647
663
|
this.network
|
|
648
|
-
}: too much slippage on quote ${side} baseTokenAmount ${
|
|
664
|
+
}: too much slippage on quote ${side} baseTokenAmount ${
|
|
665
|
+
order.takerAmount
|
|
666
|
+
} / srcAmount ${
|
|
667
|
+
optimalSwapExchange.srcAmount
|
|
668
|
+
} > ${slippageFactor.toFixed()}`;
|
|
649
669
|
slippageErrorMessage = message;
|
|
650
670
|
this.logger.warn(message);
|
|
651
671
|
}
|
|
@@ -700,7 +720,7 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
700
720
|
);
|
|
701
721
|
}
|
|
702
722
|
} else {
|
|
703
|
-
if(e instanceof TooStrictSlippageCheckError) {
|
|
723
|
+
if (e instanceof TooStrictSlippageCheckError) {
|
|
704
724
|
this.logger.warn(
|
|
705
725
|
`${this.dexKey}-${this.network}: failed to build transaction on side ${side} with too strict slippage. Skipping restriction`,
|
|
706
726
|
);
|
|
@@ -814,7 +834,10 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
814
834
|
return result === 'true';
|
|
815
835
|
}
|
|
816
836
|
|
|
817
|
-
async setBlacklist(
|
|
837
|
+
async setBlacklist(
|
|
838
|
+
txOrigin: Address,
|
|
839
|
+
ttl: number = DEXALOT_BLACKLIST_CACHES_TTL_S,
|
|
840
|
+
): Promise<boolean> {
|
|
818
841
|
const cachedBlacklist = await this.dexHelper.cache.get(
|
|
819
842
|
this.dexKey,
|
|
820
843
|
this.network,
|
|
@@ -852,7 +875,7 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
852
875
|
}
|
|
853
876
|
|
|
854
877
|
// To not show pricing for rate limited users
|
|
855
|
-
if(await this.isRateLimited(txOrigin)) {
|
|
878
|
+
if (await this.isRateLimited(txOrigin)) {
|
|
856
879
|
return true;
|
|
857
880
|
}
|
|
858
881
|
|
|
@@ -954,7 +977,7 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
954
977
|
continue;
|
|
955
978
|
}
|
|
956
979
|
|
|
957
|
-
const [
|
|
980
|
+
const [baseToken, quoteToken] = tokensInPair;
|
|
958
981
|
const addr = tokensAddr[baseToken.toLowerCase()];
|
|
959
982
|
let outputToken = this.getTokenFromAddress(addr);
|
|
960
983
|
if (baseToken === tokenSymbol) {
|
|
@@ -967,10 +990,12 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
967
990
|
pairsByLiquidity.push({
|
|
968
991
|
exchange: this.dexKey,
|
|
969
992
|
address: this.mainnetRFQAddress,
|
|
970
|
-
connectorTokens: [
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
993
|
+
connectorTokens: [
|
|
994
|
+
{
|
|
995
|
+
address: denormalizedToken.address,
|
|
996
|
+
decimals: denormalizedToken.decimals,
|
|
997
|
+
},
|
|
998
|
+
],
|
|
974
999
|
liquidityUSD: pairs[pairName].liquidityUSD,
|
|
975
1000
|
});
|
|
976
1001
|
}
|
package/src/dex/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Jarvis } from './jarvis';
|
|
|
5
5
|
import { JarvisV6 } from './jarvis-v6/jarvis-v6';
|
|
6
6
|
import { StablePool } from './stable-pool';
|
|
7
7
|
import { Weth } from './weth/weth';
|
|
8
|
+
import { PolygonMigrator } from './polygon-migrator/polygon-migrator';
|
|
8
9
|
import { ZeroX } from './zerox';
|
|
9
10
|
import { UniswapV3 } from './uniswap-v3/uniswap-v3';
|
|
10
11
|
import { BalancerV2 } from './balancer-v2/balancer-v2';
|
|
@@ -52,6 +53,7 @@ import { SpiritSwapV2 } from './solidly/forks-override/spiritSwapV2';
|
|
|
52
53
|
import { Synthetix } from './synthetix/synthetix';
|
|
53
54
|
import { Cone } from './solidly/forks-override/cone';
|
|
54
55
|
import { SoliSnek } from './solidly/forks-override/solisnek';
|
|
56
|
+
import { Usdfi } from './solidly/forks-override/usdfi';
|
|
55
57
|
import { Equalizer } from './solidly/forks-override/equalizer';
|
|
56
58
|
import { Velocimeter } from './solidly/forks-override/velocimeter';
|
|
57
59
|
import { BalancerV1 } from './balancer-v1/balancer-v1';
|
|
@@ -123,6 +125,7 @@ const Dexes = [
|
|
|
123
125
|
AaveV3,
|
|
124
126
|
KyberDmm,
|
|
125
127
|
Weth,
|
|
128
|
+
PolygonMigrator,
|
|
126
129
|
MakerPsm,
|
|
127
130
|
Nerve,
|
|
128
131
|
Platypus,
|
|
@@ -143,6 +146,7 @@ const Dexes = [
|
|
|
143
146
|
SoliSnek,
|
|
144
147
|
Equalizer,
|
|
145
148
|
Velocimeter,
|
|
149
|
+
Usdfi,
|
|
146
150
|
Synthetix,
|
|
147
151
|
CurveV1Factory,
|
|
148
152
|
SwaapV1,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DexParams } from './types';
|
|
2
|
+
import { DexConfigMap } from '../../types';
|
|
3
|
+
import { Network } from '../../constants';
|
|
4
|
+
import { SwapSide } from '@paraswap/core';
|
|
5
|
+
|
|
6
|
+
export const PolygonMigratorConfig: DexConfigMap<DexParams> = {
|
|
7
|
+
PolygonMigrator: {
|
|
8
|
+
[Network.MAINNET]: {
|
|
9
|
+
migratorAddress: '0x29e7df7b6a1b2b07b731457f499e1696c60e2c4e',
|
|
10
|
+
polTokenAddress: '0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6',
|
|
11
|
+
maticTokenAddress: '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0'
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const Adapters: {
|
|
17
|
+
[chainId: number]: {
|
|
18
|
+
[side: string]: { name: string; index: number }[];
|
|
19
|
+
};
|
|
20
|
+
} = {
|
|
21
|
+
[Network.MAINNET]: {
|
|
22
|
+
[SwapSide.SELL]: [{ name: 'Adapter04', index: 4 }],
|
|
23
|
+
[SwapSide.BUY]: [{ name: 'BuyAdapter', index: 11 }],
|
|
24
|
+
},
|
|
25
|
+
};
|