@paraswap/dex-lib 4.6.7 → 4.6.8
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/lite-psm/psm.json +3 -1
- package/build/abi/miro-migrator/MiroMigrator.abi.json +36 -19
- package/build/dex/idle-dao/idle-dao.d.ts +1 -0
- package/build/dex/idle-dao/idle-dao.js +23 -11
- package/build/dex/idle-dao/idle-dao.js.map +1 -1
- package/build/dex/maker-psm/maker-psm.d.ts +4 -41
- package/build/dex/maker-psm/maker-psm.js +41 -144
- package/build/dex/maker-psm/maker-psm.js.map +1 -1
- package/build/dex/miro-migrator/config.js +3 -10
- package/build/dex/miro-migrator/config.js.map +1 -1
- package/build/dex/miro-migrator/constants.d.ts +2 -1
- package/build/dex/miro-migrator/constants.js +3 -2
- package/build/dex/miro-migrator/constants.js.map +1 -1
- package/build/dex/miro-migrator/miro-migrator-pool.d.ts +9 -5
- package/build/dex/miro-migrator/miro-migrator-pool.js +49 -28
- package/build/dex/miro-migrator/miro-migrator-pool.js.map +1 -1
- package/build/dex/miro-migrator/miro-migrator.d.ts +5 -4
- package/build/dex/miro-migrator/miro-migrator.js +41 -83
- package/build/dex/miro-migrator/miro-migrator.js.map +1 -1
- package/build/dex/miro-migrator/types.d.ts +2 -4
- package/build/dex/miro-migrator/types.js +1 -2
- package/build/dex/miro-migrator/types.js.map +1 -1
- package/package.json +1 -1
- package/build/abi/algebra-integral/blackhole-cl/Quoter.abi.json +0 -325
- package/build/abi/pangolin-v3/PangolinV3StateMulticall.abi.json +0 -796
- package/build/abi/ring-v2/few-wrapped-token.json +0 -587
- package/build/abi/ring-v2/ring-v2-factory.json +0 -125
- package/build/abi/ring-v2/ring-v2-pool.json +0 -461
- package/build/abi/ring-v2/ring-v2-router.json +0 -332
- package/build/abi/uniswap-v4/hooks/cabalcoin-hook.abi.json +0 -682
- package/build/abi/uniswap-v4/hooks/fee-hook.abi.json +0 -1335
- package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.d.ts +0 -52
- package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.js +0 -363
- package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.js.map +0 -1
- package/build/dex/aave-pt-to-usdc/config.d.ts +0 -3
- package/build/dex/aave-pt-to-usdc/config.js +0 -59
- package/build/dex/aave-pt-to-usdc/config.js.map +0 -1
- package/build/dex/aave-pt-to-usdc/constants.d.ts +0 -6
- package/build/dex/aave-pt-to-usdc/constants.js +0 -13
- package/build/dex/aave-pt-to-usdc/constants.js.map +0 -1
- package/build/dex/aave-pt-to-usdc/types.d.ts +0 -34
- package/build/dex/aave-pt-to-usdc/types.js +0 -3
- package/build/dex/aave-pt-to-usdc/types.js.map +0 -1
- package/build/dex/algebra-integral/constants.d.ts +0 -3
- package/build/dex/algebra-integral/constants.js +0 -7
- package/build/dex/algebra-integral/constants.js.map +0 -1
- package/build/dex/algebra-integral/forks/blackhole-cl.d.ts +0 -20
- package/build/dex/algebra-integral/forks/blackhole-cl.js +0 -118
- package/build/dex/algebra-integral/forks/blackhole-cl.js.map +0 -1
- package/build/dex/ekubo/pools/math/sqrt-ratio.d.ts +0 -8
- package/build/dex/ekubo/pools/math/sqrt-ratio.js +0 -113
- package/build/dex/ekubo/pools/math/sqrt-ratio.js.map +0 -1
- package/build/dex/ekubo/pools/mev-resist.d.ts +0 -7
- package/build/dex/ekubo/pools/mev-resist.js +0 -40
- package/build/dex/ekubo/pools/mev-resist.js.map +0 -1
- package/build/dex/ekubo/pools/pool.d.ts +0 -47
- package/build/dex/ekubo/pools/pool.js +0 -76
- package/build/dex/ekubo/pools/pool.js.map +0 -1
- package/build/dex/miro-migrator/miro-migrator-state.d.ts +0 -27
- package/build/dex/miro-migrator/miro-migrator-state.js +0 -89
- package/build/dex/miro-migrator/miro-migrator-state.js.map +0 -1
- package/build/dex/solidly/forks-override/blackhole.d.ts +0 -23
- package/build/dex/solidly/forks-override/blackhole.js +0 -81
- package/build/dex/solidly/forks-override/blackhole.js.map +0 -1
- package/build/dex/uniswap-v3/forks/pangolin-v3/utils.d.ts +0 -4
- package/build/dex/uniswap-v3/forks/pangolin-v3/utils.js +0 -56
- package/build/dex/uniswap-v3/forks/pangolin-v3/utils.js.map +0 -1
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.d.ts +0 -7
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.js +0 -28
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.js.map +0 -1
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.d.ts +0 -0
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.js +0 -2
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.js.map +0 -1
- package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.d.ts +0 -7
- package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.js +0 -28
- package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.js.map +0 -1
- package/build/dex/uniswap-v4/hooks/fee-hook/types.d.ts +0 -0
- package/build/dex/uniswap-v4/hooks/fee-hook/types.js +0 -2
- package/build/dex/uniswap-v4/hooks/fee-hook/types.js.map +0 -1
- package/build/dex/uniswap-v4/hooks/index.d.ts +0 -2
- package/build/dex/uniswap-v4/hooks/index.js +0 -8
- package/build/dex/uniswap-v4/hooks/index.js.map +0 -1
- package/build/dex/usdc-transmuter/usdc-transmuter-pool.d.ts +0 -26
- package/build/dex/usdc-transmuter/usdc-transmuter-pool.js +0 -75
- package/build/dex/usdc-transmuter/usdc-transmuter-pool.js.map +0 -1
|
@@ -199,7 +199,9 @@
|
|
|
199
199
|
{ "internalType": "uint256", "name": "gemAmt", "type": "uint256" }
|
|
200
200
|
],
|
|
201
201
|
"name": "sellGem",
|
|
202
|
-
"outputs": [
|
|
202
|
+
"outputs": [
|
|
203
|
+
{ "internalType": "uint256", "name": "daiOutWad", "type": "uint256" }
|
|
204
|
+
],
|
|
203
205
|
"stateMutability": "nonpayable",
|
|
204
206
|
"type": "function"
|
|
205
207
|
},
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"inputs": [
|
|
4
4
|
{
|
|
5
5
|
"components": [
|
|
6
|
-
{ "internalType": "address", "name": "
|
|
6
|
+
{ "internalType": "address", "name": "xyz", "type": "address" },
|
|
7
7
|
{ "internalType": "address", "name": "weth", "type": "address" },
|
|
8
8
|
{
|
|
9
9
|
"internalType": "address",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
{ "internalType": "address", "name": "sePSP1", "type": "address" },
|
|
24
24
|
{ "internalType": "address", "name": "sePSP2", "type": "address" },
|
|
25
|
-
{ "internalType": "address", "name": "
|
|
25
|
+
{ "internalType": "address", "name": "seXYZ", "type": "address" },
|
|
26
26
|
{
|
|
27
27
|
"internalType": "contract IAcrossSpokePool",
|
|
28
28
|
"name": "spokePool",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
{
|
|
114
114
|
"indexed": true,
|
|
115
115
|
"internalType": "uint256",
|
|
116
|
-
"name": "
|
|
116
|
+
"name": "xyzAmount",
|
|
117
117
|
"type": "uint256"
|
|
118
118
|
},
|
|
119
119
|
{
|
|
@@ -151,6 +151,13 @@
|
|
|
151
151
|
"name": "Unpaused",
|
|
152
152
|
"type": "event"
|
|
153
153
|
},
|
|
154
|
+
{
|
|
155
|
+
"inputs": [],
|
|
156
|
+
"name": "BURN_ADDR",
|
|
157
|
+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
|
158
|
+
"stateMutability": "view",
|
|
159
|
+
"type": "function"
|
|
160
|
+
},
|
|
154
161
|
{
|
|
155
162
|
"inputs": [],
|
|
156
163
|
"name": "PSP",
|
|
@@ -174,7 +181,7 @@
|
|
|
174
181
|
},
|
|
175
182
|
{
|
|
176
183
|
"inputs": [],
|
|
177
|
-
"name": "
|
|
184
|
+
"name": "SE_XYZ",
|
|
178
185
|
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
|
179
186
|
"stateMutability": "view",
|
|
180
187
|
"type": "function"
|
|
@@ -194,14 +201,14 @@
|
|
|
194
201
|
},
|
|
195
202
|
{
|
|
196
203
|
"inputs": [],
|
|
197
|
-
"name": "
|
|
204
|
+
"name": "WETH",
|
|
198
205
|
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
|
199
206
|
"stateMutability": "view",
|
|
200
207
|
"type": "function"
|
|
201
208
|
},
|
|
202
209
|
{
|
|
203
210
|
"inputs": [],
|
|
204
|
-
"name": "
|
|
211
|
+
"name": "XYZ",
|
|
205
212
|
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
|
206
213
|
"stateMutability": "view",
|
|
207
214
|
"type": "function"
|
|
@@ -212,7 +219,7 @@
|
|
|
212
219
|
],
|
|
213
220
|
"name": "bridgeConfigs",
|
|
214
221
|
"outputs": [
|
|
215
|
-
{ "internalType": "address", "name": "
|
|
222
|
+
{ "internalType": "address", "name": "xyz", "type": "address" },
|
|
216
223
|
{ "internalType": "address", "name": "weth", "type": "address" },
|
|
217
224
|
{ "internalType": "address", "name": "bridgeStaking", "type": "address" },
|
|
218
225
|
{ "internalType": "uint256", "name": "destChainId", "type": "uint256" }
|
|
@@ -222,7 +229,7 @@
|
|
|
222
229
|
},
|
|
223
230
|
{
|
|
224
231
|
"inputs": [
|
|
225
|
-
{ "internalType": "uint256", "name": "
|
|
232
|
+
{ "internalType": "uint256", "name": "xyzAmount", "type": "uint256" },
|
|
226
233
|
{ "internalType": "uint256", "name": "wethAmount", "type": "uint256" },
|
|
227
234
|
{ "internalType": "uint256", "name": "destChainId", "type": "uint256" },
|
|
228
235
|
{
|
|
@@ -260,7 +267,7 @@
|
|
|
260
267
|
}
|
|
261
268
|
],
|
|
262
269
|
"internalType": "struct IMiroMigrator.BridgeData",
|
|
263
|
-
"name": "
|
|
270
|
+
"name": "xyzBridgeData",
|
|
264
271
|
"type": "tuple"
|
|
265
272
|
},
|
|
266
273
|
{
|
|
@@ -297,7 +304,7 @@
|
|
|
297
304
|
},
|
|
298
305
|
{ "internalType": "bytes", "name": "permitData", "type": "bytes" }
|
|
299
306
|
],
|
|
300
|
-
"name": "
|
|
307
|
+
"name": "bridgeXYZAndStake",
|
|
301
308
|
"outputs": [],
|
|
302
309
|
"stateMutability": "payable",
|
|
303
310
|
"type": "function"
|
|
@@ -309,7 +316,7 @@
|
|
|
309
316
|
{ "internalType": "uint256", "name": "minBptOut", "type": "uint256" },
|
|
310
317
|
{ "internalType": "bytes", "name": "permitData", "type": "bytes" }
|
|
311
318
|
],
|
|
312
|
-
"name": "
|
|
319
|
+
"name": "migratePSPtoSeXYZ",
|
|
313
320
|
"outputs": [],
|
|
314
321
|
"stateMutability": "payable",
|
|
315
322
|
"type": "function"
|
|
@@ -319,7 +326,7 @@
|
|
|
319
326
|
{ "internalType": "uint256", "name": "pspAmount", "type": "uint256" },
|
|
320
327
|
{ "internalType": "bytes", "name": "permitData", "type": "bytes" }
|
|
321
328
|
],
|
|
322
|
-
"name": "
|
|
329
|
+
"name": "migratePSPtoXYZ",
|
|
323
330
|
"outputs": [],
|
|
324
331
|
"stateMutability": "nonpayable",
|
|
325
332
|
"type": "function"
|
|
@@ -331,7 +338,7 @@
|
|
|
331
338
|
{ "internalType": "uint256", "name": "minBptOut", "type": "uint256" },
|
|
332
339
|
{ "internalType": "bytes", "name": "permitData", "type": "bytes" }
|
|
333
340
|
],
|
|
334
|
-
"name": "
|
|
341
|
+
"name": "migrateSePSP1toSeXYZ",
|
|
335
342
|
"outputs": [],
|
|
336
343
|
"stateMutability": "payable",
|
|
337
344
|
"type": "function"
|
|
@@ -341,7 +348,7 @@
|
|
|
341
348
|
{ "internalType": "uint256", "name": "sePSP1Amount", "type": "uint256" },
|
|
342
349
|
{ "internalType": "bytes", "name": "permitData", "type": "bytes" }
|
|
343
350
|
],
|
|
344
|
-
"name": "
|
|
351
|
+
"name": "migrateSePSP1toXYZ",
|
|
345
352
|
"outputs": [],
|
|
346
353
|
"stateMutability": "nonpayable",
|
|
347
354
|
"type": "function"
|
|
@@ -354,7 +361,7 @@
|
|
|
354
361
|
{ "internalType": "uint256", "name": "minBptOut", "type": "uint256" },
|
|
355
362
|
{ "internalType": "bytes", "name": "permitData", "type": "bytes" }
|
|
356
363
|
],
|
|
357
|
-
"name": "
|
|
364
|
+
"name": "migrateSePSP2toSeXYZ",
|
|
358
365
|
"outputs": [],
|
|
359
366
|
"stateMutability": "nonpayable",
|
|
360
367
|
"type": "function"
|
|
@@ -400,7 +407,7 @@
|
|
|
400
407
|
}
|
|
401
408
|
],
|
|
402
409
|
"internalType": "struct IMiroMigrator.BridgeData",
|
|
403
|
-
"name": "
|
|
410
|
+
"name": "xyzBridgeData",
|
|
404
411
|
"type": "tuple"
|
|
405
412
|
},
|
|
406
413
|
{
|
|
@@ -437,7 +444,7 @@
|
|
|
437
444
|
},
|
|
438
445
|
{ "internalType": "bytes", "name": "permitData", "type": "bytes" }
|
|
439
446
|
],
|
|
440
|
-
"name": "
|
|
447
|
+
"name": "migrateSePSP2toSeXYZAndBridge",
|
|
441
448
|
"outputs": [],
|
|
442
449
|
"stateMutability": "nonpayable",
|
|
443
450
|
"type": "function"
|
|
@@ -463,9 +470,19 @@
|
|
|
463
470
|
"stateMutability": "view",
|
|
464
471
|
"type": "function"
|
|
465
472
|
},
|
|
473
|
+
{
|
|
474
|
+
"inputs": [
|
|
475
|
+
{ "internalType": "address", "name": "token", "type": "address" },
|
|
476
|
+
{ "internalType": "address", "name": "to", "type": "address" }
|
|
477
|
+
],
|
|
478
|
+
"name": "reClaimERC20",
|
|
479
|
+
"outputs": [],
|
|
480
|
+
"stateMutability": "nonpayable",
|
|
481
|
+
"type": "function"
|
|
482
|
+
},
|
|
466
483
|
{
|
|
467
484
|
"inputs": [{ "internalType": "address", "name": "to", "type": "address" }],
|
|
468
|
-
"name": "
|
|
485
|
+
"name": "reClaimETH",
|
|
469
486
|
"outputs": [],
|
|
470
487
|
"stateMutability": "nonpayable",
|
|
471
488
|
"type": "function"
|
|
@@ -481,7 +498,7 @@
|
|
|
481
498
|
"inputs": [
|
|
482
499
|
{
|
|
483
500
|
"components": [
|
|
484
|
-
{ "internalType": "address", "name": "
|
|
501
|
+
{ "internalType": "address", "name": "xyz", "type": "address" },
|
|
485
502
|
{ "internalType": "address", "name": "weth", "type": "address" },
|
|
486
503
|
{
|
|
487
504
|
"internalType": "address",
|
|
@@ -38,5 +38,6 @@ export declare class IdleDao extends SimpleExchange implements IDex<IdleDaoData>
|
|
|
38
38
|
getCalldataGasCost(poolPrices: PoolPrices<IdleDaoData>): number | number[];
|
|
39
39
|
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: IdleDaoData, side: SwapSide): AdapterExchangeParam;
|
|
40
40
|
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: IdleDaoData, side: SwapSide, _: Context, executorAddress: Address): DexExchangeParam;
|
|
41
|
+
updatePoolState(): Promise<void>;
|
|
41
42
|
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
42
43
|
}
|
|
@@ -242,25 +242,36 @@ class IdleDao extends simple_exchange_1.SimpleExchange {
|
|
|
242
242
|
skipApproval: data.fromIdleToken,
|
|
243
243
|
};
|
|
244
244
|
}
|
|
245
|
-
async
|
|
245
|
+
async updatePoolState() {
|
|
246
246
|
await this.initializeTokens();
|
|
247
|
+
}
|
|
248
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
247
249
|
const idleTokens = (0, tokens_1.getPoolsByTokenAddress)(this.network, tokenAddress);
|
|
248
250
|
if (idleTokens.length > 0) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
251
|
+
const poolMap = {};
|
|
252
|
+
idleTokens.forEach((idleToken) => {
|
|
253
|
+
const cdoAddress = idleToken.cdoAddress;
|
|
254
|
+
const token = (0, tokens_1.getTokenFromIdleToken)(idleToken);
|
|
255
|
+
if (!poolMap[cdoAddress]) {
|
|
256
|
+
poolMap[cdoAddress] = {
|
|
257
|
+
exchange: this.dexKey,
|
|
258
|
+
address: cdoAddress,
|
|
259
|
+
connectorTokens: [token],
|
|
260
|
+
liquidityUSD: constants_1.UNLIMITED_USD_LIQUIDITY,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
if (!poolMap[cdoAddress].connectorTokens.some(t => t.address.toLowerCase() === token.address.toLowerCase())) {
|
|
265
|
+
poolMap[cdoAddress].connectorTokens.push(token);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
return Object.values(poolMap);
|
|
258
270
|
}
|
|
259
271
|
const idleToken = (0, tokens_1.getIdleTokenByAddress)(this.network, tokenAddress.toLowerCase());
|
|
260
272
|
if (idleToken) {
|
|
261
273
|
return [
|
|
262
274
|
{
|
|
263
|
-
liquidityUSD: 1e9,
|
|
264
275
|
exchange: this.dexKey,
|
|
265
276
|
address: idleToken.cdoAddress,
|
|
266
277
|
connectorTokens: [
|
|
@@ -269,6 +280,7 @@ class IdleDao extends simple_exchange_1.SimpleExchange {
|
|
|
269
280
|
decimals: idleToken.decimals,
|
|
270
281
|
},
|
|
271
282
|
],
|
|
283
|
+
liquidityUSD: constants_1.UNLIMITED_USD_LIQUIDITY,
|
|
272
284
|
},
|
|
273
285
|
];
|
|
274
286
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idle-dao.js","sourceRoot":"","sources":["../../../src/dex/idle-dao/idle-dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"idle-dao.js","sourceRoot":"","sources":["../../../src/dex/idle-dao/idle-dao.ts"],"names":[],"mappings":";;;;;;;;;;;;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ACD,CAAC;wBACD,OAAO,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAClD,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QAED,MAAM,SAAS,GAAG,IAAA,8BAAqB,EACrC,IAAI,CAAC,OAAO,EACZ,YAAY,CAAC,WAAW,EAAE,CAC3B,CAAC;QAEF,IAAI,SAAS,EAAE,CAAC;YACd,OAAO;gBACL;oBACE,QAAQ,EAAE,IAAI,CAAC,MAAM;oBACrB,OAAO,EAAE,SAAS,CAAC,UAAU;oBAC7B,eAAe,EAAE;wBACf;4BACE,OAAO,EAAE,SAAS,CAAC,OAAO;4BAC1B,QAAQ,EAAE,SAAS,CAAC,QAAQ;yBAC7B;qBACF;oBACD,YAAY,EAAE,mCAAuB;iBACtC;aACF,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;;AA/XH,0BAgYC"}
|
|
@@ -1,50 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Token, Address, ExchangePrices, PoolPrices, Log, AdapterExchangeParam, SimpleExchangeParam, PoolLiquidity, Logger, NumberAsString, DexExchangeParam, ExchangeTxInfo, PreprocessTransactionOptions } from '../../types';
|
|
1
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, SimpleExchangeParam, PoolLiquidity, Logger, NumberAsString, DexExchangeParam, ExchangeTxInfo, PreprocessTransactionOptions } from '../../types';
|
|
3
2
|
import { SwapSide, Network } from '../../constants';
|
|
4
|
-
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
5
3
|
import { IDex } from '../../dex/idex';
|
|
6
4
|
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
7
5
|
import { MakerPsmData, PoolState, PoolConfig, MakerPsmDirectPayload } from './types';
|
|
8
6
|
import { SimpleExchange } from '../simple-exchange';
|
|
9
7
|
import { OptimalSwapExchange } from '@paraswap/core';
|
|
10
|
-
|
|
11
|
-
protected network: number;
|
|
12
|
-
protected dexHelper: IDexHelper;
|
|
13
|
-
poolConfig: PoolConfig;
|
|
14
|
-
protected vatAddress: Address;
|
|
15
|
-
handlers: {
|
|
16
|
-
[event: string]: (event: any, pool: PoolState, log: Log) => PoolState;
|
|
17
|
-
};
|
|
18
|
-
logDecoder: (log: Log) => any;
|
|
19
|
-
to18ConversionFactor: bigint;
|
|
20
|
-
bytes32Tout: string;
|
|
21
|
-
bytes32Tin: string;
|
|
22
|
-
constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, poolConfig: PoolConfig, vatAddress: Address);
|
|
23
|
-
handleFile(event: any, pool: PoolState, log: Log): PoolState;
|
|
24
|
-
handleSellGem(event: any, pool: PoolState, log: Log): PoolState;
|
|
25
|
-
handleBuyGem(event: any, pool: PoolState, log: Log): PoolState;
|
|
26
|
-
getIdentifier(): string;
|
|
27
|
-
/**
|
|
28
|
-
* The function is called every time any of the subscribed
|
|
29
|
-
* addresses release log. The function accepts the current
|
|
30
|
-
* state, updates the state according to the log, and returns
|
|
31
|
-
* the updated state.
|
|
32
|
-
* @param state - Current state of event subscriber
|
|
33
|
-
* @param log - Log released by one of the subscribed addresses
|
|
34
|
-
* @returns Updates state of the event subscriber after the log
|
|
35
|
-
*/
|
|
36
|
-
protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
|
|
37
|
-
/**
|
|
38
|
-
* The function generates state using on-chain calls. This
|
|
39
|
-
* function is called to regenerate state if the event based
|
|
40
|
-
* system fails to fetch events and the local state is no
|
|
41
|
-
* more correct.
|
|
42
|
-
* @param blockNumber - Blocknumber for which the state should
|
|
43
|
-
* should be generated
|
|
44
|
-
* @returns state of the event subscriber at blocknumber
|
|
45
|
-
*/
|
|
46
|
-
generateState(blockNumber: number): Promise<Readonly<PoolState>>;
|
|
47
|
-
}
|
|
8
|
+
import { MakerPsmEventPool } from './maker-psm-event-pool';
|
|
48
9
|
export declare class MakerPsm extends SimpleExchange implements IDex<MakerPsmData, MakerPsmDirectPayload> {
|
|
49
10
|
protected network: Network;
|
|
50
11
|
protected dexHelper: IDexHelper;
|
|
@@ -75,6 +36,7 @@ export declare class MakerPsm extends SimpleExchange implements IDex<MakerPsmDat
|
|
|
75
36
|
}, dai?: Token, vatAddress?: Address, poolConfigs?: PoolConfig[]);
|
|
76
37
|
static getDirectFunctionNameV6(): string[];
|
|
77
38
|
initializePricing(blockNumber: number): Promise<void>;
|
|
39
|
+
private initializeEventPools;
|
|
78
40
|
getAdapters(side: SwapSide): {
|
|
79
41
|
name: string;
|
|
80
42
|
index: number;
|
|
@@ -99,5 +61,6 @@ export declare class MakerPsm extends SimpleExchange implements IDex<MakerPsmDat
|
|
|
99
61
|
encoder: (...params: (string | MakerPsmDirectPayload)[]) => string;
|
|
100
62
|
networkFee: string;
|
|
101
63
|
};
|
|
64
|
+
updatePoolState(): Promise<void>;
|
|
102
65
|
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
103
66
|
}
|
|
@@ -36,143 +36,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.MakerPsm =
|
|
39
|
+
exports.MakerPsm = void 0;
|
|
40
40
|
const abi_1 = require("@ethersproject/abi");
|
|
41
41
|
const constants_1 = require("../../constants");
|
|
42
42
|
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
43
|
-
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
44
43
|
const utils_1 = require("../../utils");
|
|
45
44
|
const simple_exchange_1 = require("../simple-exchange");
|
|
46
45
|
const config_1 = require("./config");
|
|
47
46
|
const psm_json_1 = __importDefault(require("../../abi/maker-psm/psm.json"));
|
|
48
|
-
const vat_json_1 = __importDefault(require("../../abi/maker-psm/vat.json"));
|
|
49
47
|
const bigint_constants_1 = require("../../bigint-constants");
|
|
50
48
|
const types_1 = require("../../executor/types");
|
|
51
49
|
const bytes_1 = require("@ethersproject/bytes");
|
|
52
50
|
const core_1 = require("@paraswap/core");
|
|
53
51
|
const ethers_1 = require("ethers");
|
|
54
|
-
const
|
|
52
|
+
const maker_psm_event_pool_1 = require("./maker-psm-event-pool");
|
|
55
53
|
const psmInterface = new abi_1.Interface(psm_json_1.default);
|
|
56
54
|
const WAD = bigint_constants_1.BI_POWS[18];
|
|
57
|
-
const bigIntify = (b) => BigInt(b.toString());
|
|
58
55
|
const ceilDiv = (a, b) => (a + b - 1n) / b;
|
|
59
|
-
async function getOnChainState(multiContract, poolConfigs, vatAddress, blockNumber) {
|
|
60
|
-
const callData = poolConfigs
|
|
61
|
-
.map(c => [
|
|
62
|
-
{
|
|
63
|
-
target: c.psmAddress,
|
|
64
|
-
callData: psmInterface.encodeFunctionData('tin', []),
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
target: c.psmAddress,
|
|
68
|
-
callData: psmInterface.encodeFunctionData('tout', []),
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
target: vatAddress,
|
|
72
|
-
callData: vatInterface.encodeFunctionData('ilks', [c.identifier]),
|
|
73
|
-
},
|
|
74
|
-
])
|
|
75
|
-
.flat();
|
|
76
|
-
const res = await multiContract.methods
|
|
77
|
-
.aggregate(callData)
|
|
78
|
-
.call({}, blockNumber);
|
|
79
|
-
let i = 0;
|
|
80
|
-
return poolConfigs.map(c => {
|
|
81
|
-
const tin = bigIntify(psmInterface.decodeFunctionResult('tin', res.returnData[i++])[0]);
|
|
82
|
-
const tout = bigIntify(psmInterface.decodeFunctionResult('tout', res.returnData[i++])[0]);
|
|
83
|
-
const ilks = vatInterface.decodeFunctionResult('ilks', res.returnData[i++]);
|
|
84
|
-
const Art = bigIntify(ilks.Art);
|
|
85
|
-
const line = bigIntify(ilks.line);
|
|
86
|
-
const rate = bigIntify(ilks.rate);
|
|
87
|
-
return {
|
|
88
|
-
tin,
|
|
89
|
-
tout,
|
|
90
|
-
Art,
|
|
91
|
-
line,
|
|
92
|
-
rate,
|
|
93
|
-
};
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
class MakerPsmEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
97
|
-
network;
|
|
98
|
-
dexHelper;
|
|
99
|
-
poolConfig;
|
|
100
|
-
vatAddress;
|
|
101
|
-
handlers = {};
|
|
102
|
-
logDecoder;
|
|
103
|
-
to18ConversionFactor;
|
|
104
|
-
bytes32Tout = '0x746f757400000000000000000000000000000000000000000000000000000000'; // bytes32('tout')
|
|
105
|
-
bytes32Tin = '0x74696e0000000000000000000000000000000000000000000000000000000000'; // bytes32('tin')
|
|
106
|
-
constructor(parentName, network, dexHelper, logger, poolConfig, vatAddress) {
|
|
107
|
-
super(parentName, poolConfig.identifier, dexHelper, logger);
|
|
108
|
-
this.network = network;
|
|
109
|
-
this.dexHelper = dexHelper;
|
|
110
|
-
this.poolConfig = poolConfig;
|
|
111
|
-
this.vatAddress = vatAddress;
|
|
112
|
-
this.logDecoder = (log) => psmInterface.parseLog(log);
|
|
113
|
-
this.addressesSubscribed = [poolConfig.psmAddress];
|
|
114
|
-
this.to18ConversionFactor = (0, utils_1.getBigIntPow)(18 - poolConfig.gem.decimals);
|
|
115
|
-
// Add handlers
|
|
116
|
-
this.handlers['File'] = this.handleFile.bind(this);
|
|
117
|
-
this.handlers['SellGem'] = this.handleSellGem.bind(this);
|
|
118
|
-
this.handlers['BuyGem'] = this.handleBuyGem.bind(this);
|
|
119
|
-
}
|
|
120
|
-
handleFile(event, pool, log) {
|
|
121
|
-
if (event.args.what === this.bytes32Tin) {
|
|
122
|
-
pool.tin = bigIntify(event.args.data);
|
|
123
|
-
}
|
|
124
|
-
else if (event.args.what === this.bytes32Tout) {
|
|
125
|
-
pool.tout = bigIntify(event.args.data);
|
|
126
|
-
}
|
|
127
|
-
return pool;
|
|
128
|
-
}
|
|
129
|
-
handleSellGem(event, pool, log) {
|
|
130
|
-
pool.Art += bigIntify(event.args.value) * this.to18ConversionFactor;
|
|
131
|
-
return pool;
|
|
132
|
-
}
|
|
133
|
-
handleBuyGem(event, pool, log) {
|
|
134
|
-
pool.Art -= bigIntify(event.args.value) * this.to18ConversionFactor;
|
|
135
|
-
return pool;
|
|
136
|
-
}
|
|
137
|
-
getIdentifier() {
|
|
138
|
-
return `${this.parentName}_${this.poolConfig.psmAddress}`.toLowerCase();
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* The function is called every time any of the subscribed
|
|
142
|
-
* addresses release log. The function accepts the current
|
|
143
|
-
* state, updates the state according to the log, and returns
|
|
144
|
-
* the updated state.
|
|
145
|
-
* @param state - Current state of event subscriber
|
|
146
|
-
* @param log - Log released by one of the subscribed addresses
|
|
147
|
-
* @returns Updates state of the event subscriber after the log
|
|
148
|
-
*/
|
|
149
|
-
processLog(state, log) {
|
|
150
|
-
try {
|
|
151
|
-
const event = this.logDecoder(log);
|
|
152
|
-
if (event.name in this.handlers) {
|
|
153
|
-
return this.handlers[event.name](event, state, log);
|
|
154
|
-
}
|
|
155
|
-
return state;
|
|
156
|
-
}
|
|
157
|
-
catch (e) {
|
|
158
|
-
this.logger.error(`Error_${this.parentName}_processLog could not parse the log with topic ${log.topics}:`, e);
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* The function generates state using on-chain calls. This
|
|
164
|
-
* function is called to regenerate state if the event based
|
|
165
|
-
* system fails to fetch events and the local state is no
|
|
166
|
-
* more correct.
|
|
167
|
-
* @param blockNumber - Blocknumber for which the state should
|
|
168
|
-
* should be generated
|
|
169
|
-
* @returns state of the event subscriber at blocknumber
|
|
170
|
-
*/
|
|
171
|
-
async generateState(blockNumber) {
|
|
172
|
-
return (await getOnChainState(this.dexHelper.multiContract, [this.poolConfig], this.vatAddress, blockNumber))[0];
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
exports.MakerPsmEventPool = MakerPsmEventPool;
|
|
176
56
|
class MakerPsm extends simple_exchange_1.SimpleExchange {
|
|
177
57
|
network;
|
|
178
58
|
dexHelper;
|
|
@@ -196,18 +76,23 @@ class MakerPsm extends simple_exchange_1.SimpleExchange {
|
|
|
196
76
|
this.poolConfigs = poolConfigs;
|
|
197
77
|
this.logger = dexHelper.getLogger(dexKey);
|
|
198
78
|
this.eventPools = {};
|
|
199
|
-
poolConfigs.forEach(p => (this.eventPools[p.gem.address.toLowerCase()] = new MakerPsmEventPool(dexKey, network, dexHelper, this.logger, p, this.vatAddress)));
|
|
79
|
+
poolConfigs.forEach(p => (this.eventPools[p.gem.address.toLowerCase()] = new maker_psm_event_pool_1.MakerPsmEventPool(dexKey, network, dexHelper, this.logger, p, this.vatAddress)));
|
|
200
80
|
}
|
|
201
81
|
static getDirectFunctionNameV6() {
|
|
202
82
|
return [core_1.ContractMethodV6.swapExactAmountInOutOnMakerPSM];
|
|
203
83
|
}
|
|
204
84
|
async initializePricing(blockNumber) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
85
|
+
await this.initializeEventPools(blockNumber);
|
|
86
|
+
}
|
|
87
|
+
async initializeEventPools(blockNumber, subscribe = true) {
|
|
88
|
+
await Promise.all(Object.values(this.eventPools).map(async (eventPool) => {
|
|
89
|
+
if (subscribe) {
|
|
90
|
+
await eventPool.initialize(blockNumber);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const state = await eventPool.generateState(blockNumber);
|
|
94
|
+
eventPool.setState(state, blockNumber);
|
|
95
|
+
}
|
|
211
96
|
}));
|
|
212
97
|
}
|
|
213
98
|
// Returns the list of contract adapters (name and index)
|
|
@@ -303,7 +188,7 @@ class MakerPsm extends simple_exchange_1.SimpleExchange {
|
|
|
303
188
|
poolAddresses: [eventPool.poolConfig.psmAddress],
|
|
304
189
|
exchange: this.dexKey,
|
|
305
190
|
gasCost: 200 * 1000,
|
|
306
|
-
|
|
191
|
+
poolIdentifier,
|
|
307
192
|
},
|
|
308
193
|
];
|
|
309
194
|
}
|
|
@@ -460,33 +345,45 @@ class MakerPsm extends simple_exchange_1.SimpleExchange {
|
|
|
460
345
|
};
|
|
461
346
|
return { params: payload, encoder, networkFee: '0' };
|
|
462
347
|
}
|
|
348
|
+
async updatePoolState() {
|
|
349
|
+
const blockNumber = await this.dexHelper.web3Provider.eth.getBlockNumber();
|
|
350
|
+
await this.initializeEventPools(blockNumber, false);
|
|
351
|
+
}
|
|
463
352
|
// Returns list of top pools based on liquidity. Max
|
|
464
353
|
// limit number pools should be returned.
|
|
465
354
|
async getTopPoolsForToken(tokenAddress, limit) {
|
|
466
|
-
const
|
|
355
|
+
const token = tokenAddress.toLowerCase();
|
|
356
|
+
const isDAI = this.dai.address.toLowerCase() === token;
|
|
467
357
|
// Liquidity depends on the swapping side hence we simply use the min
|
|
468
358
|
// Its always in terms of stable coin hence liquidityUSD = liquidity
|
|
469
359
|
const minLiq = (poolState) => {
|
|
470
360
|
const buyLimit = poolState.Art;
|
|
471
361
|
const sellLimit = (poolState.line - poolState.Art * poolState.rate) / poolState.rate;
|
|
472
|
-
|
|
473
|
-
|
|
362
|
+
const minLimit = buyLimit < sellLimit ? buyLimit : sellLimit;
|
|
363
|
+
const liquidity = Number(minLimit) / Number(bigint_constants_1.BI_POWS[18]);
|
|
364
|
+
return liquidity > 0 ? 2 * liquidity : 0;
|
|
474
365
|
};
|
|
475
|
-
const
|
|
476
|
-
const validPoolConfigs = isDai
|
|
366
|
+
const validPoolConfigs = isDAI
|
|
477
367
|
? this.poolConfigs
|
|
478
|
-
: this.eventPools[
|
|
479
|
-
? [this.eventPools[
|
|
368
|
+
: this.eventPools[token]
|
|
369
|
+
? [this.eventPools[token].poolConfig]
|
|
480
370
|
: [];
|
|
481
371
|
if (!validPoolConfigs.length)
|
|
482
372
|
return [];
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
373
|
+
const pools = validPoolConfigs.map(config => {
|
|
374
|
+
const eventPoolKey = config.gem.address.toLowerCase();
|
|
375
|
+
const eventPool = this.eventPools[eventPoolKey];
|
|
376
|
+
const state = eventPool?.getStaleState();
|
|
377
|
+
if (!state)
|
|
378
|
+
return null;
|
|
379
|
+
return {
|
|
380
|
+
exchange: this.dexKey,
|
|
381
|
+
address: config.psmAddress,
|
|
382
|
+
liquidityUSD: minLiq(state),
|
|
383
|
+
connectorTokens: [isDAI ? config.gem : this.dai],
|
|
384
|
+
};
|
|
385
|
+
});
|
|
386
|
+
return pools.filter(p => !!p).slice(0, limit);
|
|
490
387
|
}
|
|
491
388
|
}
|
|
492
389
|
exports.MakerPsm = MakerPsm;
|