@paraswap/dex-lib 2.41.4 → 2.42.0-traderjoe-mainnet
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/index.js +2 -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 +114 -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/trader-joe-v2.1.js +1 -0
- package/build/dex/trader-joe-v2.1.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/index.ts +2 -0
- package/src/dex/polygon-migrator/config.ts +25 -0
- package/src/dex/polygon-migrator/constants.ts +1 -0
- package/src/dex/polygon-migrator/polygon-migrator-e2e.test.ts +96 -0
- package/src/dex/polygon-migrator/polygon-migrator-integration.test.ts +139 -0
- package/src/dex/polygon-migrator/polygon-migrator.ts +167 -0
- package/src/dex/polygon-migrator/types.ts +14 -0
- package/src/dex/trader-joe-v2.1.ts +1 -0
- package/tests/constants-e2e.ts +10 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/polygon-migrator/types.ts"],"names":[],"mappings":";;;AAUA,IAAY,wBAGX;AAHD,WAAY,wBAAwB;IAClC,+CAAmB,CAAA;IACnB,mDAAuB,CAAA;AACzB,CAAC,EAHW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAGnC"}
|
|
@@ -12,6 +12,7 @@ const TRADERJOE_V2_1_ROUTER_ADDRESS = {
|
|
|
12
12
|
[constants_1.Network.AVALANCHE]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
|
|
13
13
|
[constants_1.Network.ARBITRUM]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
|
|
14
14
|
[constants_1.Network.BSC]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
|
|
15
|
+
[constants_1.Network.MAINNET]: '0x9A93a421b74F1c5755b83dD2C211614dC419C44b',
|
|
15
16
|
};
|
|
16
17
|
var TraderJoeV2RouterFunctions;
|
|
17
18
|
(function (TraderJoeV2RouterFunctions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trader-joe-v2.1.js","sourceRoot":"","sources":["../../src/dex/trader-joe-v2.1.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAiD;AAIjD,uDAG2B;AAG3B,4CAA6D;AAC7D,6FAAmE;AAEnE,MAAM,6BAA6B,GAAmC;IACpE,CAAC,mBAAO,CAAC,SAAS,CAAC,EAAE,4CAA4C;IACjE,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE,4CAA4C;IAChE,CAAC,mBAAO,CAAC,GAAG,CAAC,EAAE,4CAA4C;
|
|
1
|
+
{"version":3,"file":"trader-joe-v2.1.js","sourceRoot":"","sources":["../../src/dex/trader-joe-v2.1.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAiD;AAIjD,uDAG2B;AAG3B,4CAA6D;AAC7D,6FAAmE;AAEnE,MAAM,6BAA6B,GAAmC;IACpE,CAAC,mBAAO,CAAC,SAAS,CAAC,EAAE,4CAA4C;IACjE,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE,4CAA4C;IAChE,CAAC,mBAAO,CAAC,GAAG,CAAC,EAAE,4CAA4C;IAC3D,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,4CAA4C;CAChE,CAAC;AAiCF,IAAK,0BAGJ;AAHD,WAAK,0BAA0B;IAC7B,mFAAqD,CAAA;IACrD,mFAAqD,CAAA;AACvD,CAAC,EAHI,0BAA0B,KAA1B,0BAA0B,QAG9B;AACD,MAAa,YACX,SAAQ,gCAAc;IAQtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAHpC,mBAAc,GAAG,IAAI,CAAC;QAKpB,IAAI,CAAC,aAAa;YAChB,6BAA6B,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE/D,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAS,CAC1C,iCAAuC,CACxC,CAAC;IACJ,CAAC;IAED,eAAe,CACb,QAAiB,EACjB,SAAkB,EAClB,SAAyB,EACzB,UAA0B,EAC1B,IAAqB,EACrB,IAAc;QAEd,IAAI,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAC1C,CAAC,mDAAmD,CAAC,EACrD;YACE;gBACE;oBACE;wBACE,IAAI,CAAC,OAAO,EAAE,2BAA2B;qBAC1C;oBACD;wBACE,CAAC,EAAE,qBAAqB;qBACzB;oBACD;wBACE,IAAI,CAAC,OAAO;wBACZ,IAAI,CAAC,QAAQ,EAAE,wBAAwB;qBACxC;iBACF;gBACD,IAAA,uDAAqC,GAAE,EAAE,qBAAqB;aAC/D;SACF,CACF,CAAC;QAEF,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,aAAa;YAClC,OAAO;YACP,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,cAAc,CACZ,QAAiB,EACjB,SAAkB,EAClB,SAAyB,EACzB,UAA0B,EAC1B,IAAqB,EACrB,IAAc;QAEd,MAAM,YAAY,GAChB,IAAI,KAAK,oBAAQ,CAAC,IAAI;YACpB,CAAC,CAAC,0BAA0B,CAAC,wBAAwB;YACrD,CAAC,CAAC,0BAA0B,CAAC,wBAAwB,CAAC;QAE1D,MAAM,kBAAkB,GACtB,IAAI,KAAK,oBAAQ,CAAC,IAAI;YACpB,CAAC,CAAC;gBACE,SAAS;gBACT,UAAU;gBACV,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;gBAC9C,IAAI,CAAC,eAAe;gBACpB,IAAA,uDAAqC,GAAE;aACxC;YACH,CAAC,CAAC;gBACE,UAAU;gBACV,SAAS;gBACT,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;gBAC9C,IAAI,CAAC,eAAe;gBACpB,IAAA,uDAAqC,GAAE;aACxC,CAAC;QAER,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,YAAY,EACZ,kBAAkB,CACnB,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,aAAa,CACnB,CAAC;IACJ,CAAC;;AAnGH,oCAoGC;AAhGQ,oBAAO,GAAG,CAAC,eAAe,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -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',
|
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';
|
|
@@ -124,6 +125,7 @@ const Dexes = [
|
|
|
124
125
|
AaveV3,
|
|
125
126
|
KyberDmm,
|
|
126
127
|
Weth,
|
|
128
|
+
PolygonMigrator,
|
|
127
129
|
MakerPsm,
|
|
128
130
|
Nerve,
|
|
129
131
|
Platypus,
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const POLYGON_MIGRATION_GAS_COST = 90_000;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
4
|
+
import { ContractMethod, Network, SwapSide } from '../../constants';
|
|
5
|
+
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
6
|
+
import { generateConfig } from '../../config';
|
|
7
|
+
import { Holders, Tokens } from '../../../tests/constants-e2e';
|
|
8
|
+
import { testE2E } from '../../../tests/utils-e2e';
|
|
9
|
+
|
|
10
|
+
function testForNetwork(
|
|
11
|
+
network: Network,
|
|
12
|
+
dexKey: string,
|
|
13
|
+
tokenASymbol: string,
|
|
14
|
+
tokenBSymbol: string,
|
|
15
|
+
tokenAAmount: string,
|
|
16
|
+
tokenBAmount: string,
|
|
17
|
+
) {
|
|
18
|
+
const provider = new StaticJsonRpcProvider(
|
|
19
|
+
generateConfig(network).privateHttpProvider,
|
|
20
|
+
network,
|
|
21
|
+
);
|
|
22
|
+
const tokens = Tokens[network];
|
|
23
|
+
const holders = Holders[network];
|
|
24
|
+
|
|
25
|
+
const sideToContractMethods = new Map([
|
|
26
|
+
[
|
|
27
|
+
SwapSide.SELL,
|
|
28
|
+
[
|
|
29
|
+
ContractMethod.simpleSwap,
|
|
30
|
+
ContractMethod.multiSwap,
|
|
31
|
+
ContractMethod.megaSwap,
|
|
32
|
+
],
|
|
33
|
+
],
|
|
34
|
+
[SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
describe(`${network}`, () => {
|
|
38
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
39
|
+
describe(`${side}`, () => {
|
|
40
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
41
|
+
describe(`${contractMethod}`, () => {
|
|
42
|
+
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
|
|
43
|
+
await testE2E(
|
|
44
|
+
tokens[tokenASymbol],
|
|
45
|
+
tokens[tokenBSymbol],
|
|
46
|
+
holders[tokenASymbol],
|
|
47
|
+
side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
|
|
48
|
+
side,
|
|
49
|
+
dexKey,
|
|
50
|
+
contractMethod,
|
|
51
|
+
network,
|
|
52
|
+
provider,
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
|
|
56
|
+
await testE2E(
|
|
57
|
+
tokens[tokenBSymbol],
|
|
58
|
+
tokens[tokenASymbol],
|
|
59
|
+
holders[tokenBSymbol],
|
|
60
|
+
side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
|
|
61
|
+
side,
|
|
62
|
+
dexKey,
|
|
63
|
+
contractMethod,
|
|
64
|
+
network,
|
|
65
|
+
provider,
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
describe('PolygonMigrator E2E', () => {
|
|
76
|
+
const dexKey = 'PolygonMigrator';
|
|
77
|
+
|
|
78
|
+
describe('Mainnet', () => {
|
|
79
|
+
const network = Network.MAINNET;
|
|
80
|
+
|
|
81
|
+
const tokenASymbol: string = 'POL';
|
|
82
|
+
const tokenBSymbol: string = 'MATIC';
|
|
83
|
+
|
|
84
|
+
const tokenAAmount: string = '10000000000000000000';
|
|
85
|
+
const tokenBAmount: string = '20000000000000000000000';
|
|
86
|
+
|
|
87
|
+
testForNetwork(
|
|
88
|
+
network,
|
|
89
|
+
dexKey,
|
|
90
|
+
tokenASymbol,
|
|
91
|
+
tokenBSymbol,
|
|
92
|
+
tokenAAmount,
|
|
93
|
+
tokenBAmount,
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
4
|
+
import { DummyDexHelper } from '../../dex-helper/index';
|
|
5
|
+
import { Network, SwapSide } from '../../constants';
|
|
6
|
+
import { checkConstantPoolPrices } from '../../../tests/utils';
|
|
7
|
+
import { Tokens } from '../../../tests/constants-e2e';
|
|
8
|
+
import { BI_POWS } from '../../bigint-constants';
|
|
9
|
+
import { PolygonMigrator } from './polygon-migrator';
|
|
10
|
+
|
|
11
|
+
const network = Network.MAINNET;
|
|
12
|
+
|
|
13
|
+
const MaticSymbol = 'MATIC';
|
|
14
|
+
const MaticToken = Tokens[network][MaticSymbol];
|
|
15
|
+
|
|
16
|
+
const PolSymbol = 'POL';
|
|
17
|
+
const PolToken = Tokens[network][PolSymbol];
|
|
18
|
+
|
|
19
|
+
const amounts = [0n, BI_POWS[18], 2000000000000000000n];
|
|
20
|
+
|
|
21
|
+
const dexKey = 'PolygonMigrator';
|
|
22
|
+
|
|
23
|
+
describe('PolygonMigrator', function () {
|
|
24
|
+
it('getPoolIdentifiers and getPricesVolume MATIC -> POL SELL', async function () {
|
|
25
|
+
const dexHelper = new DummyDexHelper(network);
|
|
26
|
+
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
27
|
+
const polygonMigrator = new PolygonMigrator(network, dexKey, dexHelper);
|
|
28
|
+
|
|
29
|
+
const pools = await polygonMigrator.getPoolIdentifiers(
|
|
30
|
+
MaticToken,
|
|
31
|
+
PolToken,
|
|
32
|
+
SwapSide.SELL,
|
|
33
|
+
blocknumber,
|
|
34
|
+
);
|
|
35
|
+
console.log(`${MaticSymbol} <> ${PolSymbol} Pool Identifiers: `, pools);
|
|
36
|
+
|
|
37
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
38
|
+
|
|
39
|
+
const poolPrices = await polygonMigrator.getPricesVolume(
|
|
40
|
+
MaticToken,
|
|
41
|
+
PolToken,
|
|
42
|
+
amounts,
|
|
43
|
+
SwapSide.SELL,
|
|
44
|
+
blocknumber,
|
|
45
|
+
pools,
|
|
46
|
+
);
|
|
47
|
+
console.log(`${MaticSymbol} <> ${PolSymbol} Pool Prices: `, poolPrices);
|
|
48
|
+
|
|
49
|
+
expect(poolPrices).not.toBeNull();
|
|
50
|
+
checkConstantPoolPrices(poolPrices!, amounts, dexKey);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('getPoolIdentifiers and getPricesVolume POL -> MATIC SELL', async function () {
|
|
54
|
+
const dexHelper = new DummyDexHelper(network);
|
|
55
|
+
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
56
|
+
const polygonMigrator = new PolygonMigrator(network, dexKey, dexHelper);
|
|
57
|
+
|
|
58
|
+
const pools = await polygonMigrator.getPoolIdentifiers(
|
|
59
|
+
PolToken,
|
|
60
|
+
MaticToken,
|
|
61
|
+
SwapSide.SELL,
|
|
62
|
+
blocknumber,
|
|
63
|
+
);
|
|
64
|
+
console.log(`${PolSymbol} <> ${MaticSymbol} Pool Identifiers: `, pools);
|
|
65
|
+
|
|
66
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
67
|
+
|
|
68
|
+
const poolPrices = await polygonMigrator.getPricesVolume(
|
|
69
|
+
PolToken,
|
|
70
|
+
MaticToken,
|
|
71
|
+
amounts,
|
|
72
|
+
SwapSide.SELL,
|
|
73
|
+
blocknumber,
|
|
74
|
+
pools,
|
|
75
|
+
);
|
|
76
|
+
console.log(`${PolSymbol} <> ${MaticSymbol} Pool Prices: `, poolPrices);
|
|
77
|
+
|
|
78
|
+
expect(poolPrices).not.toBeNull();
|
|
79
|
+
checkConstantPoolPrices(poolPrices!, amounts, dexKey);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('getPoolIdentifiers and getPricesVolume MATIC -> POL BUY', async function () {
|
|
83
|
+
const dexHelper = new DummyDexHelper(network);
|
|
84
|
+
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
85
|
+
const polygonMigrator = new PolygonMigrator(network, dexKey, dexHelper);
|
|
86
|
+
|
|
87
|
+
const pools = await polygonMigrator.getPoolIdentifiers(
|
|
88
|
+
MaticToken,
|
|
89
|
+
PolToken,
|
|
90
|
+
SwapSide.BUY,
|
|
91
|
+
blocknumber,
|
|
92
|
+
);
|
|
93
|
+
console.log(`${MaticSymbol} <> ${PolSymbol} Pool Identifiers: `, pools);
|
|
94
|
+
|
|
95
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
96
|
+
|
|
97
|
+
const poolPrices = await polygonMigrator.getPricesVolume(
|
|
98
|
+
MaticToken,
|
|
99
|
+
PolToken,
|
|
100
|
+
amounts,
|
|
101
|
+
SwapSide.BUY,
|
|
102
|
+
blocknumber,
|
|
103
|
+
pools,
|
|
104
|
+
);
|
|
105
|
+
console.log(`${MaticSymbol} <> ${PolSymbol} Pool Prices: `, poolPrices);
|
|
106
|
+
|
|
107
|
+
expect(poolPrices).not.toBeNull();
|
|
108
|
+
checkConstantPoolPrices(poolPrices!, amounts, dexKey);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('getPoolIdentifiers and getPricesVolume POL -> MATIC BUY', async function () {
|
|
112
|
+
const dexHelper = new DummyDexHelper(network);
|
|
113
|
+
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
114
|
+
const polygonMigrator = new PolygonMigrator(network, dexKey, dexHelper);
|
|
115
|
+
|
|
116
|
+
const pools = await polygonMigrator.getPoolIdentifiers(
|
|
117
|
+
PolToken,
|
|
118
|
+
MaticToken,
|
|
119
|
+
SwapSide.BUY,
|
|
120
|
+
blocknumber,
|
|
121
|
+
);
|
|
122
|
+
console.log(`${PolSymbol} <> ${MaticSymbol} Pool Identifiers: `, pools);
|
|
123
|
+
|
|
124
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
125
|
+
|
|
126
|
+
const poolPrices = await polygonMigrator.getPricesVolume(
|
|
127
|
+
PolToken,
|
|
128
|
+
MaticToken,
|
|
129
|
+
amounts,
|
|
130
|
+
SwapSide.BUY,
|
|
131
|
+
blocknumber,
|
|
132
|
+
pools,
|
|
133
|
+
);
|
|
134
|
+
console.log(`${PolSymbol} <> ${MaticSymbol} Pool Prices: `, poolPrices);
|
|
135
|
+
|
|
136
|
+
expect(poolPrices).not.toBeNull();
|
|
137
|
+
checkConstantPoolPrices(poolPrices!, amounts, dexKey);
|
|
138
|
+
});
|
|
139
|
+
});
|