@paraswap/dex-lib 2.42.11 → 2.42.13
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/kyberswap-elastic/IAntiSnipAttackPositionManager.json +1276 -0
- package/build/abi/kyberswap-elastic/IFactory.json +550 -0
- package/build/abi/kyberswap-elastic/IPool.json +1042 -0
- package/build/abi/kyberswap-elastic/IQuoterV2.json +226 -0
- package/build/abi/kyberswap-elastic/IRouter.json +239 -0
- package/build/abi/kyberswap-elastic/TicksFeesReader.json +142 -0
- package/build/abi/wombat/asset.json +769 -0
- package/build/abi/wombat/bmw.json +1247 -0
- package/build/abi/wombat/pool.json +1364 -0
- package/build/dex/baseswap-v3/baseswap-v3-factory.d.ts +26 -0
- package/build/dex/baseswap-v3/baseswap-v3-factory.js +44 -0
- package/build/dex/baseswap-v3/baseswap-v3-factory.js.map +1 -0
- package/build/dex/{algebra/algebra-pool.d.ts → baseswap-v3/baseswap-v3-pool.d.ts} +16 -16
- package/build/dex/{algebra/algebra-pool.js → baseswap-v3/baseswap-v3-pool.js} +137 -161
- package/build/dex/baseswap-v3/baseswap-v3-pool.js.map +1 -0
- package/build/dex/baseswap-v3/baseswap-v3.d.ts +71 -0
- package/build/dex/baseswap-v3/baseswap-v3.js +752 -0
- package/build/dex/baseswap-v3/baseswap-v3.js.map +1 -0
- package/build/dex/baseswap-v3/config.d.ts +9 -0
- package/build/dex/baseswap-v3/config.js +48 -0
- package/build/dex/baseswap-v3/config.js.map +1 -0
- package/build/dex/baseswap-v3/constants.d.ts +28 -0
- package/build/dex/baseswap-v3/constants.js +35 -0
- package/build/dex/baseswap-v3/constants.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/BitMath.d.ts +4 -0
- package/build/dex/baseswap-v3/contract-math/BitMath.js +93 -0
- package/build/dex/baseswap-v3/contract-math/BitMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/FixedPoint128.d.ts +3 -0
- package/build/dex/baseswap-v3/contract-math/FixedPoint128.js +8 -0
- package/build/dex/baseswap-v3/contract-math/FixedPoint128.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/FixedPoint96.d.ts +4 -0
- package/build/dex/baseswap-v3/contract-math/FixedPoint96.js +9 -0
- package/build/dex/baseswap-v3/contract-math/FixedPoint96.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/FullMath.d.ts +4 -0
- package/build/dex/baseswap-v3/contract-math/FullMath.js +19 -0
- package/build/dex/baseswap-v3/contract-math/FullMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/LiquidityMath.d.ts +3 -0
- package/build/dex/baseswap-v3/contract-math/LiquidityMath.js +22 -0
- package/build/dex/baseswap-v3/contract-math/LiquidityMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/Oracle.d.ts +10 -0
- package/build/dex/baseswap-v3/contract-math/Oracle.js +133 -0
- package/build/dex/baseswap-v3/contract-math/Oracle.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.d.ts +10 -0
- package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.js +91 -0
- package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/SwapMath.d.ts +8 -0
- package/build/dex/baseswap-v3/contract-math/SwapMath.js +70 -0
- package/build/dex/baseswap-v3/contract-math/SwapMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/Tick.d.ts +7 -0
- package/build/dex/baseswap-v3/contract-math/Tick.js +45 -0
- package/build/dex/baseswap-v3/contract-math/Tick.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/TickBitMap.d.ts +7 -0
- package/build/dex/baseswap-v3/contract-math/TickBitMap.js +84 -0
- package/build/dex/baseswap-v3/contract-math/TickBitMap.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/TickMath.d.ts +8 -0
- package/build/dex/baseswap-v3/contract-math/TickMath.js +162 -0
- package/build/dex/baseswap-v3/contract-math/TickMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/UnsafeMath.d.ts +3 -0
- package/build/dex/baseswap-v3/contract-math/UnsafeMath.js +10 -0
- package/build/dex/baseswap-v3/contract-math/UnsafeMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.d.ts +37 -0
- package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.js +393 -0
- package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/utils.d.ts +7 -0
- package/build/dex/baseswap-v3/contract-math/utils.js +42 -0
- package/build/dex/baseswap-v3/contract-math/utils.js.map +1 -0
- package/build/dex/baseswap-v3/types.d.ts +164 -0
- package/build/dex/baseswap-v3/types.js +9 -0
- package/build/dex/baseswap-v3/types.js.map +1 -0
- package/build/dex/baseswap-v3/utils.d.ts +6 -0
- package/build/dex/baseswap-v3/utils.js +65 -0
- package/build/dex/baseswap-v3/utils.js.map +1 -0
- package/build/dex/dexalot/dexalot.d.ts +3 -2
- package/build/dex/dexalot/dexalot.js +33 -19
- package/build/dex/dexalot/dexalot.js.map +1 -1
- package/build/dex/hello/config.d.ts +4 -0
- package/build/dex/hello/config.js +15 -0
- package/build/dex/hello/config.js.map +1 -0
- package/build/dex/hello/hello-pool.d.ts +39 -0
- package/build/dex/hello/hello-pool.js +64 -0
- package/build/dex/hello/hello-pool.js.map +1 -0
- package/build/dex/hello/hello.d.ts +37 -0
- package/build/dex/hello/hello.js +126 -0
- package/build/dex/hello/hello.js.map +1 -0
- package/build/dex/hello/types.d.ts +6 -0
- package/build/dex/hello/types.js +3 -0
- package/build/dex/hello/types.js.map +1 -0
- package/build/dex/kyberswap-elastic/config.d.ts +4 -0
- package/build/dex/kyberswap-elastic/config.js +80 -0
- package/build/dex/kyberswap-elastic/config.js.map +1 -0
- package/build/dex/kyberswap-elastic/constants.d.ts +17 -0
- package/build/dex/kyberswap-elastic/constants.js +42 -0
- package/build/dex/kyberswap-elastic/constants.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.d.ts +4 -0
- package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.js +9 -0
- package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/FullMath.d.ts +5 -0
- package/build/dex/kyberswap-elastic/contract-math/FullMath.js +22 -0
- package/build/dex/kyberswap-elastic/contract-math/FullMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.d.ts +3 -0
- package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.js +12 -0
- package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.d.ts +3 -0
- package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.js +22 -0
- package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.d.ts +5 -0
- package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.js +25 -0
- package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/QuadMath.d.ts +4 -0
- package/build/dex/kyberswap-elastic/contract-math/QuadMath.js +27 -0
- package/build/dex/kyberswap-elastic/contract-math/QuadMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.d.ts +3 -0
- package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.js +14 -0
- package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/SafeCast.d.ts +8 -0
- package/build/dex/kyberswap-elastic/contract-math/SafeCast.js +30 -0
- package/build/dex/kyberswap-elastic/contract-math/SafeCast.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.d.ts +10 -0
- package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.js +91 -0
- package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/SwapMath.d.ts +13 -0
- package/build/dex/kyberswap-elastic/contract-math/SwapMath.js +188 -0
- package/build/dex/kyberswap-elastic/contract-math/SwapMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.d.ts +6 -0
- package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.js +41 -0
- package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/TickMath.d.ts +9 -0
- package/build/dex/kyberswap-elastic/contract-math/TickMath.js +165 -0
- package/build/dex/kyberswap-elastic/contract-math/TickMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.d.ts +3 -0
- package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.js +10 -0
- package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.d.ts +28 -0
- package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.js +502 -0
- package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/utils.d.ts +3 -0
- package/build/dex/kyberswap-elastic/contract-math/utils.js +16 -0
- package/build/dex/kyberswap-elastic/contract-math/utils.js.map +1 -0
- package/build/dex/kyberswap-elastic/errors.d.ts +2 -0
- package/build/dex/kyberswap-elastic/errors.js +6 -0
- package/build/dex/kyberswap-elastic/errors.js.map +1 -0
- package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.d.ts +80 -0
- package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.js +458 -0
- package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.js.map +1 -0
- package/build/dex/kyberswap-elastic/kyberswap-elastic.d.ts +53 -0
- package/build/dex/kyberswap-elastic/kyberswap-elastic.js +610 -0
- package/build/dex/kyberswap-elastic/kyberswap-elastic.js.map +1 -0
- package/build/dex/kyberswap-elastic/types.d.ts +134 -0
- package/build/dex/kyberswap-elastic/types.js +9 -0
- package/build/dex/kyberswap-elastic/types.js.map +1 -0
- package/build/dex/kyberswap-elastic/utils/decoders.d.ts +9 -0
- package/build/dex/kyberswap-elastic/utils/decoders.js +78 -0
- package/build/dex/kyberswap-elastic/utils/decoders.js.map +1 -0
- package/build/dex/morphex/config.d.ts +11 -0
- package/build/dex/morphex/config.js +43 -0
- package/build/dex/morphex/config.js.map +1 -0
- package/build/dex/morphex/morphex.d.ts +25 -0
- package/build/dex/morphex/morphex.js +19 -0
- package/build/dex/morphex/morphex.js.map +1 -0
- package/build/dex/my-test-dex/config.d.ts +4 -0
- package/build/dex/my-test-dex/config.js +15 -0
- package/build/dex/my-test-dex/config.js.map +1 -0
- package/build/dex/my-test-dex/my-test-dex-pool.d.ts +39 -0
- package/build/dex/my-test-dex/my-test-dex-pool.js +64 -0
- package/build/dex/my-test-dex/my-test-dex-pool.js.map +1 -0
- package/build/dex/my-test-dex/my-test-dex.d.ts +37 -0
- package/build/dex/my-test-dex/my-test-dex.js +126 -0
- package/build/dex/my-test-dex/my-test-dex.js.map +1 -0
- package/build/dex/my-test-dex/types.d.ts +6 -0
- package/build/dex/my-test-dex/types.js +3 -0
- package/build/dex/my-test-dex/types.js.map +1 -0
- package/build/dex/solidly/forks-override/fvm.d.ts +20 -0
- package/build/dex/solidly/forks-override/fvm.js +42 -0
- package/build/dex/solidly/forks-override/fvm.js.map +1 -0
- package/build/dex/swaap-v2/constants.d.ts +7 -3
- package/build/dex/swaap-v2/constants.js +8 -4
- package/build/dex/swaap-v2/constants.js.map +1 -1
- package/build/dex/swaap-v2/rate-fetcher.d.ts +2 -1
- package/build/dex/swaap-v2/rate-fetcher.js +25 -0
- package/build/dex/swaap-v2/rate-fetcher.js.map +1 -1
- package/build/dex/swaap-v2/swaap-v2.d.ts +4 -2
- package/build/dex/swaap-v2/swaap-v2.js +57 -20
- package/build/dex/swaap-v2/swaap-v2.js.map +1 -1
- package/build/dex/swaap-v2/types.d.ts +8 -0
- package/build/dex/swaap-v2/utils.d.ts +3 -3
- package/build/dex/swaap-v2/utils.js +6 -8
- package/build/dex/swaap-v2/utils.js.map +1 -1
- package/build/dex/swaap-v2/validators.d.ts +1 -0
- package/build/dex/swaap-v2/validators.js +6 -1
- package/build/dex/swaap-v2/validators.js.map +1 -1
- package/build/dex/wombat/config.d.ts +5 -0
- package/build/dex/wombat/config.js +50 -0
- package/build/dex/wombat/config.js.map +1 -0
- package/build/dex/wombat/types.d.ts +33 -0
- package/build/dex/wombat/types.js +3 -0
- package/build/dex/wombat/types.js.map +1 -0
- package/build/dex/wombat/utils.d.ts +9 -0
- package/build/dex/wombat/utils.js +66 -0
- package/build/dex/wombat/utils.js.map +1 -0
- package/build/dex/wombat/wombat-bmw.d.ts +40 -0
- package/build/dex/wombat/wombat-bmw.js +145 -0
- package/build/dex/wombat/wombat-bmw.js.map +1 -0
- package/build/dex/wombat/wombat-pool.d.ts +22 -0
- package/build/dex/wombat/wombat-pool.js +161 -0
- package/build/dex/wombat/wombat-pool.js.map +1 -0
- package/build/dex/wombat/wombat-quoter.d.ts +16 -0
- package/build/dex/wombat/wombat-quoter.js +176 -0
- package/build/dex/wombat/wombat-quoter.js.map +1 -0
- package/build/dex/wombat/wombat.d.ts +55 -0
- package/build/dex/wombat/wombat.js +292 -0
- package/build/dex/wombat/wombat.js.map +1 -0
- package/package.json +1 -1
- package/src/dex/dexalot/dexalot.ts +48 -22
- package/src/dex/swaap-v2/constants.ts +11 -3
- package/src/dex/swaap-v2/rate-fetcher.ts +51 -1
- package/src/dex/swaap-v2/swaap-v2.ts +97 -43
- package/src/dex/swaap-v2/types.ts +10 -0
- package/src/dex/swaap-v2/utils.ts +9 -16
- package/src/dex/swaap-v2/validators.ts +6 -0
- package/build/abi/algebra/AlgebraPool.abi.json +0 -727
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
- package/build/dex/algebra/algebra-pool.js.map +0 -1
- package/build/dex/quickswap/camelot-v3.d.ts +0 -6
- package/build/dex/quickswap/camelot-v3.js +0 -19
- package/build/dex/quickswap/camelot-v3.js.map +0 -1
- package/build/dex/quickswap/zyberswap-v3.d.ts +0 -6
- package/build/dex/quickswap/zyberswap-v3.js +0 -19
- package/build/dex/quickswap/zyberswap-v3.js.map +0 -1
|
@@ -395,7 +395,8 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
395
395
|
.toString(),
|
|
396
396
|
);
|
|
397
397
|
if (isInputQuote) {
|
|
398
|
-
lQty =
|
|
398
|
+
lQty =
|
|
399
|
+
(lQty * BigInt(10 ** (baseToken.decimals * 2))) /
|
|
399
400
|
(lPrice * BigInt(10 ** quoteToken.decimals));
|
|
400
401
|
rQty =
|
|
401
402
|
(rQty * BigInt(10 ** (baseToken.decimals * 2))) /
|
|
@@ -432,10 +433,6 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
432
433
|
transferFees?: TransferFeeParams,
|
|
433
434
|
): Promise<null | ExchangePrices<DexalotData>> {
|
|
434
435
|
try {
|
|
435
|
-
if (await this.isRestricted()) {
|
|
436
|
-
return null;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
436
|
const normalizedSrcToken = this.normalizeToken(srcToken);
|
|
440
437
|
const normalizedDestToken = this.normalizeToken(destToken);
|
|
441
438
|
|
|
@@ -444,7 +441,7 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
444
441
|
return null;
|
|
445
442
|
}
|
|
446
443
|
|
|
447
|
-
|
|
444
|
+
let pools = limitPools
|
|
448
445
|
? limitPools.filter(
|
|
449
446
|
p =>
|
|
450
447
|
p ===
|
|
@@ -455,6 +452,9 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
455
452
|
)
|
|
456
453
|
: await this.getPoolIdentifiers(srcToken, destToken, side, blockNumber);
|
|
457
454
|
|
|
455
|
+
pools = await Promise.all(
|
|
456
|
+
pools.map(async p => !(await this.isRestrictedPool(p))),
|
|
457
|
+
).then(res => pools.filter((_v, i) => res[i]));
|
|
458
458
|
if (pools.length === 0) {
|
|
459
459
|
return null;
|
|
460
460
|
}
|
|
@@ -505,14 +505,16 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
505
505
|
throw new Error(`Empty orderbook for ${pairKey}`);
|
|
506
506
|
}
|
|
507
507
|
|
|
508
|
-
const isInputQuote =
|
|
508
|
+
const isInputQuote =
|
|
509
|
+
(clobSide === ClobSide.ASK && side === SwapSide.SELL) ||
|
|
510
|
+
(clobSide === ClobSide.BID && side === SwapSide.BUY);
|
|
509
511
|
|
|
510
512
|
const prices = this.calculateOrderPrice(
|
|
511
513
|
amounts,
|
|
512
514
|
orderbook,
|
|
513
515
|
baseToken,
|
|
514
516
|
quoteToken,
|
|
515
|
-
isInputQuote
|
|
517
|
+
isInputQuote,
|
|
516
518
|
);
|
|
517
519
|
const outDecimals =
|
|
518
520
|
clobSide === ClobSide.BID ? baseToken.decimals : quoteToken.decimals;
|
|
@@ -579,15 +581,24 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
579
581
|
const makerToken = normalizedDestToken;
|
|
580
582
|
const takerToken = normalizedSrcToken;
|
|
581
583
|
|
|
584
|
+
const isSell = side === SwapSide.SELL;
|
|
585
|
+
const isBuy = side === SwapSide.BUY;
|
|
586
|
+
|
|
587
|
+
const slippageBps = isSell
|
|
588
|
+
? BigNumber(1)
|
|
589
|
+
.minus(options.slippageFactor)
|
|
590
|
+
.multipliedBy(10000)
|
|
591
|
+
.toFixed(0)
|
|
592
|
+
: options.slippageFactor.minus(1).multipliedBy(10000).toFixed(0);
|
|
582
593
|
const rfqParams = {
|
|
583
594
|
makerAsset: ethers.utils.getAddress(makerToken.address),
|
|
584
595
|
takerAsset: ethers.utils.getAddress(takerToken.address),
|
|
585
|
-
makerAmount:
|
|
586
|
-
|
|
587
|
-
takerAmount:
|
|
588
|
-
side === SwapSide.SELL ? optimalSwapExchange.srcAmount : undefined,
|
|
596
|
+
makerAmount: isBuy ? optimalSwapExchange.destAmount : undefined,
|
|
597
|
+
takerAmount: isSell ? optimalSwapExchange.srcAmount : undefined,
|
|
589
598
|
userAddress: options.txOrigin,
|
|
590
599
|
chainid: this.network,
|
|
600
|
+
partner: options.partner,
|
|
601
|
+
slippage: slippageBps,
|
|
591
602
|
};
|
|
592
603
|
|
|
593
604
|
const rfq: RFQResponse = await this.dexHelper.httpRequest.post(
|
|
@@ -616,7 +627,7 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
616
627
|
order.takerAsset.toLowerCase() === takerToken.address,
|
|
617
628
|
`QuoteData takerAsset=${order.takerAsset} is different from Paraswap takerAsset=${takerToken.address}`,
|
|
618
629
|
);
|
|
619
|
-
if (
|
|
630
|
+
if (isSell) {
|
|
620
631
|
assert(
|
|
621
632
|
order.takerAmount === optimalSwapExchange.srcAmount,
|
|
622
633
|
`QuoteData takerAmount=${order.takerAmount} is different from Paraswap srcAmount=${optimalSwapExchange.srcAmount}`,
|
|
@@ -635,7 +646,7 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
635
646
|
let isFailOnSlippage = false;
|
|
636
647
|
let slippageErrorMessage = '';
|
|
637
648
|
|
|
638
|
-
if (
|
|
649
|
+
if (isSell) {
|
|
639
650
|
if (
|
|
640
651
|
BigInt(order.makerAmount) <
|
|
641
652
|
BigInt(
|
|
@@ -674,7 +685,7 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
674
685
|
let isTooStrictSlippage = false;
|
|
675
686
|
if (
|
|
676
687
|
isFailOnSlippage &&
|
|
677
|
-
|
|
688
|
+
isSell &&
|
|
678
689
|
new BigNumber(1)
|
|
679
690
|
.minus(slippageFactor)
|
|
680
691
|
.lt(DEXALOT_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION)
|
|
@@ -682,7 +693,7 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
682
693
|
isTooStrictSlippage = true;
|
|
683
694
|
} else if (
|
|
684
695
|
isFailOnSlippage &&
|
|
685
|
-
|
|
696
|
+
isBuy &&
|
|
686
697
|
slippageFactor
|
|
687
698
|
.minus(1)
|
|
688
699
|
.lt(DEXALOT_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION)
|
|
@@ -725,10 +736,18 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
725
736
|
`${this.dexKey}-${this.network}: failed to build transaction on side ${side} with too strict slippage. Skipping restriction`,
|
|
726
737
|
);
|
|
727
738
|
} else {
|
|
739
|
+
const poolIdentifiers = await this.getPoolIdentifiers(
|
|
740
|
+
srcToken,
|
|
741
|
+
destToken,
|
|
742
|
+
side,
|
|
743
|
+
0,
|
|
744
|
+
);
|
|
728
745
|
this.logger.warn(
|
|
729
|
-
`${this.dexKey}-${this.network}: protocol is restricted`,
|
|
746
|
+
`${this.dexKey}-${this.network}: protocol is restricted for pools ${poolIdentifiers} due to swap: ${swapIdentifier}`,
|
|
747
|
+
);
|
|
748
|
+
await Promise.all(
|
|
749
|
+
poolIdentifiers.map(async p => await this.restrictPool(p)),
|
|
730
750
|
);
|
|
731
|
-
await this.restrict();
|
|
732
751
|
}
|
|
733
752
|
}
|
|
734
753
|
|
|
@@ -813,22 +832,29 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
813
832
|
};
|
|
814
833
|
}
|
|
815
834
|
|
|
816
|
-
|
|
835
|
+
getRestrictedPoolKey(poolIdentifier: string): string {
|
|
836
|
+
return `${DEXALOT_RESTRICTED_CACHE_KEY}-${poolIdentifier}`;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
async restrictPool(
|
|
840
|
+
poolIdentifier: string,
|
|
841
|
+
ttl: number = DEXALOT_RESTRICT_TTL_S,
|
|
842
|
+
): Promise<boolean> {
|
|
817
843
|
await this.dexHelper.cache.setex(
|
|
818
844
|
this.dexKey,
|
|
819
845
|
this.network,
|
|
820
|
-
|
|
846
|
+
this.getRestrictedPoolKey(poolIdentifier),
|
|
821
847
|
ttl,
|
|
822
848
|
'true',
|
|
823
849
|
);
|
|
824
850
|
return true;
|
|
825
851
|
}
|
|
826
852
|
|
|
827
|
-
async
|
|
853
|
+
async isRestrictedPool(poolIdentifier: string): Promise<boolean> {
|
|
828
854
|
const result = await this.dexHelper.cache.get(
|
|
829
855
|
this.dexKey,
|
|
830
856
|
this.network,
|
|
831
|
-
|
|
857
|
+
this.getRestrictedPoolKey(poolIdentifier),
|
|
832
858
|
);
|
|
833
859
|
|
|
834
860
|
return result === 'true';
|
|
@@ -20,13 +20,15 @@ export const SWAAP_RFQ_PRICES_ENDPOINT = 'prices';
|
|
|
20
20
|
|
|
21
21
|
export const SWAAP_RFQ_QUOTE_ENDPOINT = 'quote';
|
|
22
22
|
|
|
23
|
+
export const SWAAP_NOTIFY_ENDPOINT = 'notify';
|
|
24
|
+
|
|
23
25
|
export const SWAAP_RFQ_TOKENS_ENDPOINT = 'tokens';
|
|
24
26
|
|
|
25
|
-
export const
|
|
27
|
+
export const SWAAP_403_TTL_S = 60 * 60 * 24; // 24 hours
|
|
26
28
|
|
|
27
|
-
export const
|
|
29
|
+
export const SWAAP_429_TTL_S = 60 * 60 * 1; // 1 hour
|
|
28
30
|
|
|
29
|
-
export const
|
|
31
|
+
export const SWAAP_POOL_RESTRICT_TTL_S = 60 * 30; // 30 minutes
|
|
30
32
|
|
|
31
33
|
export const GAS_COST_ESTIMATION = 170_000;
|
|
32
34
|
|
|
@@ -40,3 +42,9 @@ export const SWAAP_ORDER_TYPE_BUY = 2;
|
|
|
40
42
|
|
|
41
43
|
export const SWAAP_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION =
|
|
42
44
|
new BigNumber('0.001');
|
|
45
|
+
|
|
46
|
+
export const SWAAP_NOTIFY_TIMEOUT_MS = 2000;
|
|
47
|
+
|
|
48
|
+
export const SWAAP_NOTIFICATION_ORIGIN = 'paraswap';
|
|
49
|
+
|
|
50
|
+
export const SWAAP_BANNED_CODE = 1;
|
|
@@ -11,14 +11,21 @@ import {
|
|
|
11
11
|
SwaapV2OrderType,
|
|
12
12
|
SwaapV2TokensResponse,
|
|
13
13
|
TokensMap,
|
|
14
|
+
SwaapV2NotificationRequest,
|
|
15
|
+
SwaapV2NotificationResponse,
|
|
14
16
|
} from './types';
|
|
15
17
|
import {
|
|
16
18
|
priceLevelsResponseValidator,
|
|
17
19
|
getQuoteResponseValidator,
|
|
18
20
|
getTokensResponseValidator,
|
|
21
|
+
notifyResponseValidator,
|
|
19
22
|
} from './validators';
|
|
20
23
|
import { normalizeTokenAddress } from './utils';
|
|
21
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
SWAAP_RFQ_QUOTE_TIMEOUT_MS,
|
|
26
|
+
SWAAP_NOTIFY_TIMEOUT_MS,
|
|
27
|
+
SWAAP_NOTIFICATION_ORIGIN,
|
|
28
|
+
} from './constants';
|
|
22
29
|
import { RequestConfig } from '../../dex-helper/irequest-wrapper';
|
|
23
30
|
|
|
24
31
|
export class RateFetcher {
|
|
@@ -211,4 +218,47 @@ export class RateFetcher {
|
|
|
211
218
|
throw e;
|
|
212
219
|
}
|
|
213
220
|
}
|
|
221
|
+
|
|
222
|
+
async notify(
|
|
223
|
+
code: number,
|
|
224
|
+
message: string,
|
|
225
|
+
requestParameters: RequestConfig,
|
|
226
|
+
): Promise<SwaapV2NotificationResponse> {
|
|
227
|
+
const _payload: SwaapV2NotificationRequest = {
|
|
228
|
+
origin: SWAAP_NOTIFICATION_ORIGIN,
|
|
229
|
+
code: code,
|
|
230
|
+
message: message,
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
let payload: RequestConfig = {
|
|
235
|
+
data: _payload,
|
|
236
|
+
...requestParameters,
|
|
237
|
+
timeout: SWAAP_NOTIFY_TIMEOUT_MS,
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
this.logger.info(
|
|
241
|
+
'Notify Request:',
|
|
242
|
+
JSON.stringify(payload).replace(/(?:\r\n|\r|\n)/g, ' '),
|
|
243
|
+
);
|
|
244
|
+
const { data } = await this.dexHelper.httpRequest.request<unknown>(
|
|
245
|
+
payload,
|
|
246
|
+
);
|
|
247
|
+
this.logger.info(
|
|
248
|
+
'Notify Response: ',
|
|
249
|
+
JSON.stringify(data).replace(/(?:\r\n|\r|\n)/g, ' '),
|
|
250
|
+
);
|
|
251
|
+
const notifyResp = validateAndCast<SwaapV2NotificationResponse>(
|
|
252
|
+
data,
|
|
253
|
+
notifyResponseValidator,
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
success: notifyResp.success,
|
|
258
|
+
};
|
|
259
|
+
} catch (e) {
|
|
260
|
+
this.logger.error(e);
|
|
261
|
+
throw e;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
214
264
|
}
|
|
@@ -11,7 +11,13 @@ import {
|
|
|
11
11
|
OptimalSwapExchange,
|
|
12
12
|
PreprocessTransactionOptions,
|
|
13
13
|
} from '../../types';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
SwapSide,
|
|
16
|
+
Network,
|
|
17
|
+
MAX_INT,
|
|
18
|
+
MAX_UINT,
|
|
19
|
+
CACHE_PREFIX,
|
|
20
|
+
} from '../../constants';
|
|
15
21
|
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
16
22
|
import { getDexKeysWithNetwork, isAxiosError } from '../../utils';
|
|
17
23
|
import { IDex } from '../idex';
|
|
@@ -23,6 +29,7 @@ import {
|
|
|
23
29
|
SwaapV2APIParameters,
|
|
24
30
|
SwaapV2QuoteError,
|
|
25
31
|
TokensMap,
|
|
32
|
+
SwaapV2NotificationResponse,
|
|
26
33
|
} from './types';
|
|
27
34
|
import { SimpleExchange } from '../simple-exchange';
|
|
28
35
|
import { Adapters, SwaapV2Config } from './config';
|
|
@@ -41,10 +48,10 @@ import {
|
|
|
41
48
|
GAS_COST_ESTIMATION,
|
|
42
49
|
BATCH_SWAP_SELECTOR,
|
|
43
50
|
CALLER_SLOT,
|
|
44
|
-
|
|
51
|
+
SWAAP_403_TTL_S,
|
|
52
|
+
SWAAP_429_TTL_S,
|
|
45
53
|
SWAAP_RFQ_TOKENS_ENDPOINT,
|
|
46
|
-
|
|
47
|
-
SWAAP_RESTRICTED_CACHE_KEY,
|
|
54
|
+
SWAAP_POOL_RESTRICT_TTL_S,
|
|
48
55
|
SWAAP_RFQ_API_TOKENS_POLLING_INTERVAL_MS,
|
|
49
56
|
SWAAP_RFQ_TOKENS_CACHES_TTL_S,
|
|
50
57
|
SWAAP_PRICES_CACHE_KEY,
|
|
@@ -52,6 +59,8 @@ import {
|
|
|
52
59
|
SWAAP_ORDER_TYPE_SELL,
|
|
53
60
|
SWAAP_ORDER_TYPE_BUY,
|
|
54
61
|
SWAAP_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION,
|
|
62
|
+
SWAAP_BANNED_CODE,
|
|
63
|
+
SWAAP_NOTIFY_ENDPOINT,
|
|
55
64
|
} from './constants';
|
|
56
65
|
import { getPoolIdentifier, normalizeTokenAddress, getPairName } from './utils';
|
|
57
66
|
import { Method } from '../../dex-helper/irequest-wrapper';
|
|
@@ -71,6 +80,7 @@ export class SwaapV2 extends SimpleExchange implements IDex<SwaapV2Data> {
|
|
|
71
80
|
private rateFetcher: RateFetcher;
|
|
72
81
|
private swaapV2AuthToken: string;
|
|
73
82
|
private tokensMap: TokensMap = {};
|
|
83
|
+
private runtimeMMsRestrictHashMapKey: string;
|
|
74
84
|
|
|
75
85
|
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
|
|
76
86
|
getDexKeysWithNetwork(SwaapV2Config);
|
|
@@ -113,6 +123,9 @@ export class SwaapV2 extends SimpleExchange implements IDex<SwaapV2Data> {
|
|
|
113
123
|
},
|
|
114
124
|
},
|
|
115
125
|
);
|
|
126
|
+
|
|
127
|
+
this.runtimeMMsRestrictHashMapKey =
|
|
128
|
+
`${CACHE_PREFIX}_${this.dexKey}_${this.network}_restricted_mms`.toLowerCase();
|
|
116
129
|
}
|
|
117
130
|
|
|
118
131
|
async initializePricing(blockNumber: number): Promise<void> {
|
|
@@ -298,22 +311,22 @@ export class SwaapV2 extends SimpleExchange implements IDex<SwaapV2Data> {
|
|
|
298
311
|
blockNumber: number,
|
|
299
312
|
limitPools?: string[],
|
|
300
313
|
): Promise<null | ExchangePrices<SwaapV2Data>> {
|
|
314
|
+
const normalizedSrcToken = this.normalizeToken(srcToken);
|
|
315
|
+
const normalizedDestToken = this.normalizeToken(destToken);
|
|
316
|
+
|
|
317
|
+
const requestedPoolIdentifier: string = getPoolIdentifier(
|
|
318
|
+
this.dexKey,
|
|
319
|
+
normalizedSrcToken.address,
|
|
320
|
+
normalizedDestToken.address,
|
|
321
|
+
);
|
|
322
|
+
|
|
301
323
|
try {
|
|
302
|
-
if (await this.
|
|
324
|
+
if (await this.isRestrictedPool(requestedPoolIdentifier)) {
|
|
303
325
|
return null;
|
|
304
326
|
}
|
|
305
327
|
|
|
306
328
|
this.tokensMap = (await this.getCachedTokens()) || {};
|
|
307
329
|
|
|
308
|
-
const normalizedSrcToken = this.normalizeToken(srcToken);
|
|
309
|
-
const normalizedDestToken = this.normalizeToken(destToken);
|
|
310
|
-
|
|
311
|
-
const requestedPoolIdentifier: string = getPoolIdentifier(
|
|
312
|
-
this.dexKey,
|
|
313
|
-
normalizedSrcToken.address,
|
|
314
|
-
normalizedDestToken.address,
|
|
315
|
-
);
|
|
316
|
-
|
|
317
330
|
if (normalizedSrcToken.address === normalizedDestToken.address) {
|
|
318
331
|
return null;
|
|
319
332
|
}
|
|
@@ -561,11 +574,13 @@ export class SwaapV2 extends SimpleExchange implements IDex<SwaapV2Data> {
|
|
|
561
574
|
{ deadline: minDeadline },
|
|
562
575
|
];
|
|
563
576
|
} catch (e) {
|
|
564
|
-
if (
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
577
|
+
if (isAxiosError(e) && e.response?.status === 403) {
|
|
578
|
+
await this.setBlacklist(options.txOrigin, SWAAP_403_TTL_S);
|
|
579
|
+
this.logger.warn(
|
|
580
|
+
`${this.dexKey}-${this.network}: Encountered blacklisted user=${options.txOrigin}. Adding to local blacklist cache`,
|
|
581
|
+
);
|
|
582
|
+
} else if (isAxiosError(e) && e.response?.status === 429) {
|
|
583
|
+
await this.setBlacklist(options.txOrigin, SWAAP_429_TTL_S);
|
|
569
584
|
this.logger.warn(
|
|
570
585
|
`${this.dexKey}-${this.network}: Encountered restricted user=${options.txOrigin}. Adding to local blacklist cache`,
|
|
571
586
|
);
|
|
@@ -578,7 +593,16 @@ export class SwaapV2 extends SimpleExchange implements IDex<SwaapV2Data> {
|
|
|
578
593
|
this.logger.warn(
|
|
579
594
|
`${this.dexKey}-${this.network}: protocol is restricted`,
|
|
580
595
|
);
|
|
581
|
-
|
|
596
|
+
const poolIdentifier = getPoolIdentifier(
|
|
597
|
+
this.dexKey,
|
|
598
|
+
normalizedSrcToken.address,
|
|
599
|
+
normalizedDestToken.address,
|
|
600
|
+
);
|
|
601
|
+
var message = 'Unknown error';
|
|
602
|
+
if (e instanceof Error) {
|
|
603
|
+
message = `${e.name}: ${e.message}`;
|
|
604
|
+
}
|
|
605
|
+
await this.restrictPool(message, poolIdentifier);
|
|
582
606
|
}
|
|
583
607
|
}
|
|
584
608
|
|
|
@@ -586,25 +610,45 @@ export class SwaapV2 extends SimpleExchange implements IDex<SwaapV2Data> {
|
|
|
586
610
|
}
|
|
587
611
|
}
|
|
588
612
|
|
|
589
|
-
async
|
|
590
|
-
|
|
591
|
-
this.dexKey
|
|
592
|
-
this.network,
|
|
593
|
-
SWAAP_RESTRICTED_CACHE_KEY,
|
|
594
|
-
ttl,
|
|
595
|
-
'true',
|
|
613
|
+
async restrictPool(message: string, poolIdentifier: string): Promise<void> {
|
|
614
|
+
this.logger.warn(
|
|
615
|
+
`${this.dexKey}-${this.network}: ${poolIdentifier} was restricted for ${SWAAP_POOL_RESTRICT_TTL_S} sec. due to fails`,
|
|
596
616
|
);
|
|
597
|
-
return true;
|
|
598
|
-
}
|
|
599
617
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
this.
|
|
603
|
-
|
|
604
|
-
|
|
618
|
+
// We use timestamp for creation date to later discern if it already expired or not
|
|
619
|
+
await this.dexHelper.cache.hset(
|
|
620
|
+
this.runtimeMMsRestrictHashMapKey,
|
|
621
|
+
poolIdentifier,
|
|
622
|
+
Date.now().toString(),
|
|
605
623
|
);
|
|
606
624
|
|
|
607
|
-
|
|
625
|
+
this.rateFetcher
|
|
626
|
+
.notify(SWAAP_BANNED_CODE, message, this.getNotifyReqParams())
|
|
627
|
+
.then((answer: SwaapV2NotificationResponse) => {
|
|
628
|
+
if (answer.success) {
|
|
629
|
+
this.logger.info(`Successfully notified Swaap API`);
|
|
630
|
+
} else {
|
|
631
|
+
this.logger.error(`Swaap API was not successfully notified`);
|
|
632
|
+
}
|
|
633
|
+
})
|
|
634
|
+
.catch(e => {
|
|
635
|
+
// Must never happen
|
|
636
|
+
this.logger.error(`Swaap API notification failed: ${e}`);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
async isRestrictedPool(poolIdentifier: string): Promise<boolean> {
|
|
641
|
+
const expirationThreshold = Date.now() - SWAAP_POOL_RESTRICT_TTL_S * 1000;
|
|
642
|
+
const createdAt = await this.dexHelper.cache.hget(
|
|
643
|
+
this.runtimeMMsRestrictHashMapKey,
|
|
644
|
+
poolIdentifier,
|
|
645
|
+
);
|
|
646
|
+
const wasNotRestricted = createdAt === null;
|
|
647
|
+
if (wasNotRestricted) {
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
const restrictionExpired = +createdAt < expirationThreshold;
|
|
651
|
+
return !restrictionExpired;
|
|
608
652
|
}
|
|
609
653
|
|
|
610
654
|
async isBlacklisted(txOrigin: Address): Promise<boolean> {
|
|
@@ -622,7 +666,7 @@ export class SwaapV2 extends SimpleExchange implements IDex<SwaapV2Data> {
|
|
|
622
666
|
|
|
623
667
|
async setBlacklist(
|
|
624
668
|
txOrigin: Address,
|
|
625
|
-
ttl: number =
|
|
669
|
+
ttl: number = SWAAP_403_TTL_S,
|
|
626
670
|
): Promise<boolean> {
|
|
627
671
|
await this.dexHelper.cache.setex(
|
|
628
672
|
this.dexKey,
|
|
@@ -866,10 +910,6 @@ export class SwaapV2 extends SimpleExchange implements IDex<SwaapV2Data> {
|
|
|
866
910
|
tokenAddress: Address,
|
|
867
911
|
limit: number,
|
|
868
912
|
): Promise<PoolLiquidity[]> {
|
|
869
|
-
if (await this.isRestricted()) {
|
|
870
|
-
return [];
|
|
871
|
-
}
|
|
872
|
-
|
|
873
913
|
this.tokensMap = (await this.getCachedTokens()) || {};
|
|
874
914
|
const normalizedTokenAddress = normalizeTokenAddress(tokenAddress);
|
|
875
915
|
|
|
@@ -880,12 +920,22 @@ export class SwaapV2 extends SimpleExchange implements IDex<SwaapV2Data> {
|
|
|
880
920
|
}
|
|
881
921
|
|
|
882
922
|
return Object.keys(pLevels)
|
|
883
|
-
.filter((pair: string) => {
|
|
923
|
+
.filter(async (pair: string) => {
|
|
884
924
|
const { base, quote } = pLevels[pair];
|
|
885
925
|
|
|
886
|
-
|
|
887
|
-
normalizedTokenAddress
|
|
926
|
+
const levelDoesNotIncludeToken =
|
|
927
|
+
normalizedTokenAddress !== base && normalizedTokenAddress !== quote;
|
|
928
|
+
if (levelDoesNotIncludeToken) {
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
const poolIdentifier: string = getPoolIdentifier(
|
|
933
|
+
this.dexKey,
|
|
934
|
+
base,
|
|
935
|
+
quote,
|
|
888
936
|
);
|
|
937
|
+
const isRestrictedPool = await this.isRestrictedPool(poolIdentifier);
|
|
938
|
+
return !isRestrictedPool;
|
|
889
939
|
})
|
|
890
940
|
.map((pair: string) => {
|
|
891
941
|
return {
|
|
@@ -924,6 +974,10 @@ export class SwaapV2 extends SimpleExchange implements IDex<SwaapV2Data> {
|
|
|
924
974
|
return this.getAPIReqParams(SWAAP_RFQ_QUOTE_ENDPOINT, 'POST');
|
|
925
975
|
}
|
|
926
976
|
|
|
977
|
+
getNotifyReqParams(): SwaapV2APIParameters {
|
|
978
|
+
return this.getAPIReqParams(SWAAP_NOTIFY_ENDPOINT, 'POST');
|
|
979
|
+
}
|
|
980
|
+
|
|
927
981
|
getTokensReqParams(): SwaapV2APIParameters {
|
|
928
982
|
return this.getAPIReqParams(SWAAP_RFQ_TOKENS_ENDPOINT, 'GET');
|
|
929
983
|
}
|
|
@@ -93,3 +93,13 @@ export type SwaapV2APIParameters = {
|
|
|
93
93
|
export type TokensMap = {
|
|
94
94
|
[address: string]: Token;
|
|
95
95
|
};
|
|
96
|
+
|
|
97
|
+
export type SwaapV2NotificationRequest = {
|
|
98
|
+
origin: string;
|
|
99
|
+
code: number;
|
|
100
|
+
message: string;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export type SwaapV2NotificationResponse = {
|
|
104
|
+
success: boolean;
|
|
105
|
+
};
|
|
@@ -1,32 +1,25 @@
|
|
|
1
1
|
import { Address } from '../../types';
|
|
2
|
-
import {
|
|
2
|
+
import { ETHER_ADDRESS, NULL_ADDRESS } from '../../constants';
|
|
3
3
|
|
|
4
4
|
export const getIdentifierPrefix = (
|
|
5
5
|
dexKey: string,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
tokenA: Address,
|
|
7
|
+
tokenB: Address,
|
|
8
8
|
) => {
|
|
9
|
-
return `${dexKey}_${getPairName(
|
|
9
|
+
return `${dexKey}_${getPairName(tokenA, tokenB)}`.toLowerCase();
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
export const getPairName = (
|
|
13
|
-
const sortedAddresses =
|
|
14
|
-
srcAddress < destAddress
|
|
15
|
-
? [srcAddress, destAddress]
|
|
16
|
-
: [destAddress, srcAddress];
|
|
12
|
+
export const getPairName = (tokenA: Address, tokenB: Address) => {
|
|
13
|
+
const sortedAddresses = tokenA < tokenB ? [tokenA, tokenB] : [tokenB, tokenA];
|
|
17
14
|
return `${sortedAddresses[0]}_${sortedAddresses[1]}`.toLowerCase();
|
|
18
15
|
};
|
|
19
16
|
|
|
20
17
|
export const getPoolIdentifier = (
|
|
21
18
|
dexKey: string,
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
tokenA: Address,
|
|
20
|
+
tokenB: Address,
|
|
24
21
|
) => {
|
|
25
|
-
return `${getIdentifierPrefix(
|
|
26
|
-
dexKey,
|
|
27
|
-
srcAddress,
|
|
28
|
-
destAddress,
|
|
29
|
-
)}`.toLowerCase();
|
|
22
|
+
return `${getIdentifierPrefix(dexKey, tokenA, tokenB)}`.toLowerCase();
|
|
30
23
|
};
|
|
31
24
|
|
|
32
25
|
export const normalizeTokenAddress = (address: string): string => {
|