@paraswap/dex-lib 2.42.20 → 2.42.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abi/algebra/SwapRouter.json +281 -0
- package/build/config.js +1 -1
- package/build/dex/algebra/algebra.d.ts +6 -5
- package/build/dex/algebra/algebra.js +92 -36
- package/build/dex/algebra/algebra.js.map +1 -1
- package/build/dex/algebra/config.js +1 -1
- package/build/dex/algebra/types.d.ts +10 -0
- package/build/dex/algebra/types.js +7 -0
- package/build/dex/algebra/types.js.map +1 -1
- package/build/dex/swaap-v2/constants.d.ts +1 -2
- package/build/dex/swaap-v2/constants.js +2 -3
- package/build/dex/swaap-v2/constants.js.map +1 -1
- package/build/dex/swaap-v2/swaap-v2.js +1 -4
- package/build/dex/swaap-v2/swaap-v2.js.map +1 -1
- package/build/dex/swaap-v2/utils.d.ts +0 -2
- package/build/dex/swaap-v2/utils.js +1 -11
- package/build/dex/swaap-v2/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/algebra/SwapRouter.json +281 -0
- package/src/config.ts +1 -1
- package/src/dex/algebra/algebra-e2e.test.ts +84 -13
- package/src/dex/algebra/algebra.ts +156 -49
- package/src/dex/algebra/config.ts +1 -1
- package/src/dex/algebra/types.ts +12 -0
- package/src/dex/swaap-v2/constants.ts +1 -3
- package/src/dex/swaap-v2/swaap-v2.ts +3 -17
- package/src/dex/swaap-v2/utils.ts +1 -18
- package/tests/constants-e2e.ts +6 -1
- package/src/dex/swaap-v2/stable-coins.ts +0 -25
|
@@ -4,21 +4,34 @@ import { AbiItem } from 'web3-utils';
|
|
|
4
4
|
import { pack } from '@ethersproject/solidity';
|
|
5
5
|
import _ from 'lodash';
|
|
6
6
|
import {
|
|
7
|
-
Token,
|
|
8
|
-
Address,
|
|
9
7
|
ExchangePrices,
|
|
10
8
|
PoolPrices,
|
|
11
9
|
AdapterExchangeParam,
|
|
12
10
|
SimpleExchangeParam,
|
|
13
|
-
PoolLiquidity,
|
|
14
11
|
Logger,
|
|
12
|
+
TransferFeeParams,
|
|
13
|
+
Address,
|
|
14
|
+
PoolLiquidity,
|
|
15
|
+
Token,
|
|
15
16
|
} from '../../types';
|
|
16
17
|
import { SwapSide, Network, CACHE_PREFIX } from '../../constants';
|
|
17
18
|
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
18
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
_require,
|
|
21
|
+
getBigIntPow,
|
|
22
|
+
getDexKeysWithNetwork,
|
|
23
|
+
interpolate,
|
|
24
|
+
isDestTokenTransferFeeToBeExchanged,
|
|
25
|
+
isSrcTokenTransferFeeToBeExchanged,
|
|
26
|
+
} from '../../utils';
|
|
19
27
|
import { IDex } from '../../dex/idex';
|
|
20
28
|
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
21
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
AlgebraData,
|
|
31
|
+
AlgebraFunctions,
|
|
32
|
+
DexParams,
|
|
33
|
+
IAlgebraPoolState,
|
|
34
|
+
} from './types';
|
|
22
35
|
import {
|
|
23
36
|
SimpleExchange,
|
|
24
37
|
getLocalDeadlineAsFriendlyPlaceholder,
|
|
@@ -26,19 +39,16 @@ import {
|
|
|
26
39
|
import { AlgebraConfig, Adapters } from './config';
|
|
27
40
|
import { Contract } from 'web3-eth-contract';
|
|
28
41
|
import { Interface } from 'ethers/lib/utils';
|
|
29
|
-
import
|
|
42
|
+
import SwapRouter from '../../abi/algebra/SwapRouter.json';
|
|
30
43
|
import AlgebraQuoterABI from '../../abi/algebra/AlgebraQuoter.abi.json';
|
|
31
44
|
import UniswapV3MultiABI from '../../abi/uniswap-v3/UniswapMulti.abi.json';
|
|
32
45
|
import AlgebraStateMulticallABI from '../../abi/algebra/AlgebraStateMulticall.abi.json';
|
|
33
|
-
import {
|
|
34
|
-
OutputResult,
|
|
35
|
-
UniswapV3Functions,
|
|
36
|
-
UniswapV3SimpleSwapParams,
|
|
37
|
-
} from '../uniswap-v3/types';
|
|
46
|
+
import { OutputResult } from '../uniswap-v3/types';
|
|
38
47
|
import { AlgebraMath } from './lib/AlgebraMath';
|
|
39
48
|
import { AlgebraEventPoolV1_1 } from './algebra-pool-v1_1';
|
|
40
49
|
import { AlgebraEventPoolV1_9 } from './algebra-pool-v1_9';
|
|
41
50
|
import { AlgebraFactory, OnPoolCreatedCallback } from './algebra-factory';
|
|
51
|
+
import { applyTransferFee } from '../../lib/token-transfer-fee';
|
|
42
52
|
|
|
43
53
|
type PoolPairsInfo = {
|
|
44
54
|
token0: Address;
|
|
@@ -61,7 +71,7 @@ type IAlgebraEventPool = AlgebraEventPoolV1_1 | AlgebraEventPoolV1_9;
|
|
|
61
71
|
|
|
62
72
|
export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
63
73
|
private readonly factory: AlgebraFactory;
|
|
64
|
-
readonly isFeeOnTransferSupported: boolean =
|
|
74
|
+
readonly isFeeOnTransferSupported: boolean = true;
|
|
65
75
|
protected eventPools: Record<string, IAlgebraEventPool | null> = {};
|
|
66
76
|
|
|
67
77
|
private newlyCreatedPoolKeys: Set<string> = new Set();
|
|
@@ -85,12 +95,15 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
85
95
|
| typeof AlgebraEventPoolV1_1
|
|
86
96
|
| typeof AlgebraEventPoolV1_9;
|
|
87
97
|
|
|
98
|
+
readonly SRC_TOKEN_DEX_TRANSFERS = 1;
|
|
99
|
+
readonly DEST_TOKEN_DEX_TRANSFERS = 1;
|
|
100
|
+
|
|
88
101
|
constructor(
|
|
89
102
|
protected network: Network,
|
|
90
103
|
dexKey: string,
|
|
91
104
|
protected dexHelper: IDexHelper,
|
|
92
105
|
protected adapters = Adapters[network] || {},
|
|
93
|
-
readonly routerIface = new Interface(
|
|
106
|
+
readonly routerIface = new Interface(SwapRouter),
|
|
94
107
|
readonly quoterIface = new Interface(AlgebraQuoterABI),
|
|
95
108
|
readonly config = AlgebraConfig[dexKey][network],
|
|
96
109
|
) {
|
|
@@ -409,6 +422,12 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
409
422
|
amounts: bigint[],
|
|
410
423
|
side: SwapSide,
|
|
411
424
|
pool: IAlgebraEventPool,
|
|
425
|
+
transferFees: TransferFeeParams = {
|
|
426
|
+
srcFee: 0,
|
|
427
|
+
destFee: 0,
|
|
428
|
+
srcDexFee: 0,
|
|
429
|
+
destDexFee: 0,
|
|
430
|
+
},
|
|
412
431
|
): Promise<ExchangePrices<AlgebraData> | null> {
|
|
413
432
|
if (!this.config.forceRPC) {
|
|
414
433
|
this.logger.warn(
|
|
@@ -416,6 +435,11 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
416
435
|
);
|
|
417
436
|
}
|
|
418
437
|
|
|
438
|
+
const _isSrcTokenTransferFeeToBeExchanged =
|
|
439
|
+
isSrcTokenTransferFeeToBeExchanged(transferFees);
|
|
440
|
+
const _isDestTokenTransferFeeToBeExchanged =
|
|
441
|
+
isDestTokenTransferFeeToBeExchanged(transferFees);
|
|
442
|
+
|
|
419
443
|
const unitVolume = getBigIntPow(
|
|
420
444
|
(side === SwapSide.SELL ? from : to).decimals,
|
|
421
445
|
);
|
|
@@ -430,7 +454,16 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
430
454
|
),
|
|
431
455
|
);
|
|
432
456
|
|
|
433
|
-
const
|
|
457
|
+
const _amountsWithFee = _isSrcTokenTransferFeeToBeExchanged
|
|
458
|
+
? applyTransferFee(
|
|
459
|
+
_amounts,
|
|
460
|
+
side,
|
|
461
|
+
transferFees.srcDexFee,
|
|
462
|
+
this.SRC_TOKEN_DEX_TRANSFERS,
|
|
463
|
+
)
|
|
464
|
+
: _amounts;
|
|
465
|
+
|
|
466
|
+
const calldata = _amountsWithFee.map(_amount => ({
|
|
434
467
|
target: this.config.quoter,
|
|
435
468
|
gasLimit: ALGEBRA_QUOTE_GASLIMIT,
|
|
436
469
|
callData:
|
|
@@ -471,12 +504,22 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
471
504
|
: Math.round(totalGasCost / totalSuccessFullSwaps);
|
|
472
505
|
|
|
473
506
|
let i = 0;
|
|
474
|
-
const _rates =
|
|
475
|
-
|
|
507
|
+
const _rates = _amountsWithFee.map(() => decode(i++));
|
|
508
|
+
|
|
509
|
+
const _ratesWithFee = _isDestTokenTransferFeeToBeExchanged
|
|
510
|
+
? applyTransferFee(
|
|
511
|
+
_rates,
|
|
512
|
+
side,
|
|
513
|
+
transferFees.destDexFee,
|
|
514
|
+
this.DEST_TOKEN_DEX_TRANSFERS,
|
|
515
|
+
)
|
|
516
|
+
: _rates;
|
|
517
|
+
|
|
518
|
+
const unit: bigint = _ratesWithFee[0];
|
|
476
519
|
|
|
477
520
|
const prices = interpolate(
|
|
478
|
-
|
|
479
|
-
|
|
521
|
+
_amountsWithFee.slice(1),
|
|
522
|
+
_ratesWithFee.slice(1),
|
|
480
523
|
amounts,
|
|
481
524
|
side,
|
|
482
525
|
);
|
|
@@ -486,6 +529,7 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
486
529
|
prices,
|
|
487
530
|
unit,
|
|
488
531
|
data: {
|
|
532
|
+
feeOnTransfer: _isSrcTokenTransferFeeToBeExchanged,
|
|
489
533
|
path: [
|
|
490
534
|
{
|
|
491
535
|
tokenIn: from.address,
|
|
@@ -508,6 +552,12 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
508
552
|
side: SwapSide,
|
|
509
553
|
blockNumber: number,
|
|
510
554
|
limitPools?: string[],
|
|
555
|
+
transferFees: TransferFeeParams = {
|
|
556
|
+
srcFee: 0,
|
|
557
|
+
destFee: 0,
|
|
558
|
+
srcDexFee: 0,
|
|
559
|
+
destDexFee: 0,
|
|
560
|
+
},
|
|
511
561
|
): Promise<null | ExchangePrices<AlgebraData>> {
|
|
512
562
|
try {
|
|
513
563
|
const _srcToken = this.dexHelper.config.wrapETH(srcToken);
|
|
@@ -518,6 +568,11 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
518
568
|
_destToken,
|
|
519
569
|
);
|
|
520
570
|
|
|
571
|
+
const _isSrcTokenTransferFeeToBeExchanged =
|
|
572
|
+
isSrcTokenTransferFeeToBeExchanged(transferFees);
|
|
573
|
+
const _isDestTokenTransferFeeToBeExchanged =
|
|
574
|
+
isDestTokenTransferFeeToBeExchanged(transferFees);
|
|
575
|
+
|
|
521
576
|
if (_srcAddress === _destAddress) return null;
|
|
522
577
|
|
|
523
578
|
if (
|
|
@@ -526,9 +581,15 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
526
581
|
return null;
|
|
527
582
|
|
|
528
583
|
const pool = await this.getPool(_srcAddress, _destAddress, blockNumber);
|
|
529
|
-
|
|
530
584
|
if (!pool) return null;
|
|
531
585
|
|
|
586
|
+
if (_isSrcTokenTransferFeeToBeExchanged && side == SwapSide.BUY) {
|
|
587
|
+
this.logger.error(
|
|
588
|
+
`pool: ${pool.poolAddress} doesn't support buy for tax srcToken ${srcToken.address}`,
|
|
589
|
+
);
|
|
590
|
+
return null;
|
|
591
|
+
}
|
|
592
|
+
|
|
532
593
|
if (this.config.forceRPC) {
|
|
533
594
|
const rpcPrice = await this.getPricingFromRpc(
|
|
534
595
|
_srcToken,
|
|
@@ -536,6 +597,7 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
536
597
|
amounts,
|
|
537
598
|
side,
|
|
538
599
|
pool,
|
|
600
|
+
transferFees,
|
|
539
601
|
);
|
|
540
602
|
|
|
541
603
|
return rpcPrice;
|
|
@@ -570,6 +632,7 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
570
632
|
amounts,
|
|
571
633
|
side,
|
|
572
634
|
pool,
|
|
635
|
+
transferFees,
|
|
573
636
|
);
|
|
574
637
|
|
|
575
638
|
return rpcPrice;
|
|
@@ -601,16 +664,26 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
601
664
|
const balanceDestToken =
|
|
602
665
|
_destAddress === pool.token0 ? state.balance0 : state.balance1;
|
|
603
666
|
|
|
667
|
+
const [unitAmountWithFee, ...amountsWithFee] =
|
|
668
|
+
_isSrcTokenTransferFeeToBeExchanged
|
|
669
|
+
? applyTransferFee(
|
|
670
|
+
[unitAmount, ..._amounts],
|
|
671
|
+
side,
|
|
672
|
+
transferFees.srcDexFee,
|
|
673
|
+
this.SRC_TOKEN_DEX_TRANSFERS,
|
|
674
|
+
)
|
|
675
|
+
: [unitAmount, ..._amounts];
|
|
676
|
+
|
|
604
677
|
const unitResult = this._getOutputs(
|
|
605
678
|
state,
|
|
606
|
-
[
|
|
679
|
+
[unitAmountWithFee],
|
|
607
680
|
zeroForOne,
|
|
608
681
|
side,
|
|
609
682
|
balanceDestToken,
|
|
610
683
|
);
|
|
611
684
|
const pricesResult = this._getOutputs(
|
|
612
685
|
state,
|
|
613
|
-
|
|
686
|
+
amountsWithFee,
|
|
614
687
|
zeroForOne,
|
|
615
688
|
side,
|
|
616
689
|
balanceDestToken,
|
|
@@ -621,10 +694,20 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
621
694
|
return null;
|
|
622
695
|
}
|
|
623
696
|
|
|
624
|
-
const
|
|
697
|
+
const [unitResultWithFee, ...pricesResultWithFee] =
|
|
698
|
+
_isDestTokenTransferFeeToBeExchanged
|
|
699
|
+
? applyTransferFee(
|
|
700
|
+
[unitResult.outputs[0], ...pricesResult.outputs],
|
|
701
|
+
side,
|
|
702
|
+
transferFees.destDexFee,
|
|
703
|
+
this.DEST_TOKEN_DEX_TRANSFERS,
|
|
704
|
+
)
|
|
705
|
+
: [unitResult.outputs[0], ...pricesResult.outputs];
|
|
706
|
+
|
|
707
|
+
const prices = [0n, ...pricesResultWithFee];
|
|
625
708
|
const gasCost = [
|
|
626
709
|
0,
|
|
627
|
-
...
|
|
710
|
+
...pricesResultWithFee.map((p, index) => {
|
|
628
711
|
if (p == 0n) {
|
|
629
712
|
return 0;
|
|
630
713
|
} else {
|
|
@@ -639,9 +722,10 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
639
722
|
|
|
640
723
|
return [
|
|
641
724
|
{
|
|
642
|
-
unit:
|
|
725
|
+
unit: unitResultWithFee,
|
|
643
726
|
prices,
|
|
644
727
|
data: {
|
|
728
|
+
feeOnTransfer: _isSrcTokenTransferFeeToBeExchanged,
|
|
645
729
|
path: [
|
|
646
730
|
{
|
|
647
731
|
tokenIn: _srcAddress,
|
|
@@ -674,19 +758,20 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
674
758
|
data: AlgebraData,
|
|
675
759
|
side: SwapSide,
|
|
676
760
|
): AdapterExchangeParam {
|
|
677
|
-
|
|
678
|
-
const path = this._encodePath(rawPath, side);
|
|
761
|
+
let path = this._encodePath(data.path, side);
|
|
679
762
|
|
|
680
763
|
const payload = this.abiCoder.encodeParameter(
|
|
681
764
|
{
|
|
682
765
|
ParentStruct: {
|
|
683
766
|
path: 'bytes',
|
|
684
767
|
deadline: 'uint256',
|
|
768
|
+
feeOnTransfer: 'bool',
|
|
685
769
|
},
|
|
686
770
|
},
|
|
687
771
|
{
|
|
688
772
|
path,
|
|
689
773
|
deadline: getLocalDeadlineAsFriendlyPlaceholder(), // FIXME: more gas efficient to pass block.timestamp in adapter
|
|
774
|
+
feeOnTransfer: data.feeOnTransfer,
|
|
690
775
|
},
|
|
691
776
|
);
|
|
692
777
|
|
|
@@ -730,30 +815,52 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
730
815
|
data: AlgebraData,
|
|
731
816
|
side: SwapSide,
|
|
732
817
|
): Promise<SimpleExchangeParam> {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
:
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
818
|
+
let swapFunction;
|
|
819
|
+
let swapParams;
|
|
820
|
+
|
|
821
|
+
if (data.feeOnTransfer) {
|
|
822
|
+
_require(
|
|
823
|
+
data.path.length !== 1,
|
|
824
|
+
`LOGIC ERROR: multihop is not supported for feeOnTransfer token, passed: ${data.path
|
|
825
|
+
.map(p => `${p?.tokenIn}->${p?.tokenOut}`)
|
|
826
|
+
.join(' ')}`,
|
|
827
|
+
);
|
|
828
|
+
swapFunction = AlgebraFunctions.exactInputWithFeeToken;
|
|
829
|
+
swapParams = {
|
|
830
|
+
limitSqrtPrice: '0',
|
|
831
|
+
recipient: this.augustusAddress,
|
|
832
|
+
deadline: getLocalDeadlineAsFriendlyPlaceholder(),
|
|
833
|
+
amountIn: srcAmount,
|
|
834
|
+
amountOutMinimum: destAmount,
|
|
835
|
+
tokenIn: data.path[0].tokenIn,
|
|
836
|
+
tokenOut: data.path[0].tokenOut,
|
|
837
|
+
};
|
|
838
|
+
} else {
|
|
839
|
+
swapFunction =
|
|
840
|
+
side === SwapSide.SELL
|
|
841
|
+
? AlgebraFunctions.exactInput
|
|
842
|
+
: AlgebraFunctions.exactOutput;
|
|
843
|
+
const path = this._encodePath(data.path, side);
|
|
844
|
+
swapParams =
|
|
845
|
+
side === SwapSide.SELL
|
|
846
|
+
? {
|
|
847
|
+
recipient: this.augustusAddress,
|
|
848
|
+
deadline: getLocalDeadlineAsFriendlyPlaceholder(),
|
|
849
|
+
amountIn: srcAmount,
|
|
850
|
+
amountOutMinimum: destAmount,
|
|
851
|
+
path,
|
|
852
|
+
}
|
|
853
|
+
: {
|
|
854
|
+
recipient: this.augustusAddress,
|
|
855
|
+
deadline: getLocalDeadlineAsFriendlyPlaceholder(),
|
|
856
|
+
amountOut: destAmount,
|
|
857
|
+
amountInMaximum: srcAmount,
|
|
858
|
+
path,
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
|
|
755
862
|
const swapData = this.routerIface.encodeFunctionData(swapFunction, [
|
|
756
|
-
|
|
863
|
+
swapParams,
|
|
757
864
|
]);
|
|
758
865
|
|
|
759
866
|
return this.buildSimpleParamWithoutWETHConversion(
|
|
@@ -98,7 +98,7 @@ export const Adapters: Record<number, AdapterMappings> = {
|
|
|
98
98
|
[SwapSide.BUY]: [{ name: 'PolygonZkEvmBuyAdapter', index: 1 }],
|
|
99
99
|
},
|
|
100
100
|
[Network.ARBITRUM]: {
|
|
101
|
-
[SwapSide.SELL]: [{ name: '
|
|
101
|
+
[SwapSide.SELL]: [{ name: 'ArbitrumAdapter02', index: 7 }],
|
|
102
102
|
[SwapSide.BUY]: [{ name: 'ArbitrumBuyAdapter', index: 2 }],
|
|
103
103
|
},
|
|
104
104
|
[Network.OPTIMISM]: {
|
package/src/dex/algebra/types.ts
CHANGED
|
@@ -58,9 +58,21 @@ export type AlgebraData = {
|
|
|
58
58
|
tokenIn: Address;
|
|
59
59
|
tokenOut: Address;
|
|
60
60
|
}[];
|
|
61
|
+
feeOnTransfer: boolean;
|
|
61
62
|
isApproved?: boolean;
|
|
62
63
|
};
|
|
63
64
|
|
|
65
|
+
export type AlgebraDataWithFee = {
|
|
66
|
+
tokenIn: Address;
|
|
67
|
+
tokenOut: Address;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export enum AlgebraFunctions {
|
|
71
|
+
exactInput = 'exactInput',
|
|
72
|
+
exactOutput = 'exactOutput',
|
|
73
|
+
exactInputWithFeeToken = 'exactInputSingleSupportingFeeOnTransferTokens',
|
|
74
|
+
}
|
|
75
|
+
|
|
64
76
|
export type DexParams = {
|
|
65
77
|
router: Address;
|
|
66
78
|
quoter: Address;
|
|
@@ -30,9 +30,7 @@ export const SWAAP_429_TTL_S = 60 * 60 * 1; // 1 hour
|
|
|
30
30
|
|
|
31
31
|
export const SWAAP_POOL_RESTRICT_TTL_S = 60 * 30; // 30 minutes
|
|
32
32
|
|
|
33
|
-
export const
|
|
34
|
-
|
|
35
|
-
export const VOLATILE_SWAP_GAS_COST_ESTIMATION = 150_000;
|
|
33
|
+
export const GAS_COST_ESTIMATION = 170_000;
|
|
36
34
|
|
|
37
35
|
export const BATCH_SWAP_SELECTOR = '0x945bcec9';
|
|
38
36
|
|
|
@@ -45,8 +45,7 @@ import {
|
|
|
45
45
|
SWAAP_RFQ_QUOTE_ENDPOINT,
|
|
46
46
|
SWAAP_RFQ_API_PRICES_POLLING_INTERVAL_MS,
|
|
47
47
|
SWAAP_RFQ_PRICES_CACHES_TTL_S,
|
|
48
|
-
|
|
49
|
-
VOLATILE_SWAP_GAS_COST_ESTIMATION,
|
|
48
|
+
GAS_COST_ESTIMATION,
|
|
50
49
|
BATCH_SWAP_SELECTOR,
|
|
51
50
|
CALLER_SLOT,
|
|
52
51
|
SWAAP_403_TTL_S,
|
|
@@ -63,12 +62,7 @@ import {
|
|
|
63
62
|
SWAAP_BANNED_CODE,
|
|
64
63
|
SWAAP_NOTIFY_ENDPOINT,
|
|
65
64
|
} from './constants';
|
|
66
|
-
import {
|
|
67
|
-
getPoolIdentifier,
|
|
68
|
-
normalizeTokenAddress,
|
|
69
|
-
getPairName,
|
|
70
|
-
isStablePair,
|
|
71
|
-
} from './utils';
|
|
65
|
+
import { getPoolIdentifier, normalizeTokenAddress, getPairName } from './utils';
|
|
72
66
|
import { Method } from '../../dex-helper/irequest-wrapper';
|
|
73
67
|
import {
|
|
74
68
|
SlippageCheckError,
|
|
@@ -410,16 +404,8 @@ export class SwaapV2 extends SimpleExchange implements IDex<SwaapV2Data> {
|
|
|
410
404
|
return null;
|
|
411
405
|
}
|
|
412
406
|
|
|
413
|
-
const gasCost = isStablePair(
|
|
414
|
-
this.network,
|
|
415
|
-
normalizedSrcToken.address,
|
|
416
|
-
normalizedDestToken.address,
|
|
417
|
-
)
|
|
418
|
-
? STABLE_SWAP_GAS_COST_ESTIMATION
|
|
419
|
-
: VOLATILE_SWAP_GAS_COST_ESTIMATION;
|
|
420
|
-
|
|
421
407
|
return {
|
|
422
|
-
gasCost:
|
|
408
|
+
gasCost: GAS_COST_ESTIMATION,
|
|
423
409
|
exchange: this.dexKey,
|
|
424
410
|
data: {},
|
|
425
411
|
prices,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { Address
|
|
1
|
+
import { Address } from '../../types';
|
|
2
2
|
import { ETHER_ADDRESS, NULL_ADDRESS } from '../../constants';
|
|
3
|
-
import { Network } from '../../constants';
|
|
4
|
-
import { STABLE_COINS } from './stable-coins';
|
|
5
3
|
|
|
6
4
|
export const getIdentifierPrefix = (
|
|
7
5
|
dexKey: string,
|
|
@@ -29,18 +27,3 @@ export const normalizeTokenAddress = (address: string): string => {
|
|
|
29
27
|
? NULL_ADDRESS
|
|
30
28
|
: address.toLowerCase();
|
|
31
29
|
};
|
|
32
|
-
|
|
33
|
-
export const isStablePair = (
|
|
34
|
-
network: Network,
|
|
35
|
-
normalizedSrcTokenAddress: string,
|
|
36
|
-
normalizedDestTokenAddress: string,
|
|
37
|
-
): boolean => {
|
|
38
|
-
const networkStableCoins = STABLE_COINS[network];
|
|
39
|
-
if (networkStableCoins === undefined) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return (
|
|
43
|
-
networkStableCoins[normalizedSrcTokenAddress] === true &&
|
|
44
|
-
networkStableCoins[normalizedDestTokenAddress] === true
|
|
45
|
-
);
|
|
46
|
-
};
|
package/tests/constants-e2e.ts
CHANGED
|
@@ -853,6 +853,10 @@ export const Tokens: {
|
|
|
853
853
|
address: '0x3d9907f9a368ad0a51be60f7da3b97cf940982d8',
|
|
854
854
|
decimals: 18,
|
|
855
855
|
},
|
|
856
|
+
RDPX: {
|
|
857
|
+
address: '0x32eb7902d4134bf98a28b963d26de779af92a212',
|
|
858
|
+
decimals: 18,
|
|
859
|
+
},
|
|
856
860
|
},
|
|
857
861
|
[Network.OPTIMISM]: {
|
|
858
862
|
DAI: {
|
|
@@ -1145,12 +1149,13 @@ export const Holders: {
|
|
|
1145
1149
|
AMPL: '0xfcaA5ea7F8eb0631BcA72C345025C0A5a6D93f0E',
|
|
1146
1150
|
},
|
|
1147
1151
|
[Network.ARBITRUM]: {
|
|
1152
|
+
RDPX: '0x2fa6f21ecfe274f594f470c376f5bdd061e08a37',
|
|
1148
1153
|
ARB: '0xb65edba80a3d81903ecd499c8eb9cf0e19096bd0',
|
|
1149
1154
|
ETH: '0xF977814e90dA44bFA03b6295A0616a897441aceC',
|
|
1150
1155
|
DAI: '0x07d7f291e731a41d3f0ea4f1ae5b6d920ffb3fe0',
|
|
1151
1156
|
WETH: '0xc31e54c7a869b9fcbecc14363cf510d1c41fa443',
|
|
1152
1157
|
USDCe: '0x62383739d68dd0f844103db8dfb05a7eded5bbe6',
|
|
1153
|
-
USDC: '
|
|
1158
|
+
USDC: '0x489ee077994b6658eafa855c308275ead8097c4a',
|
|
1154
1159
|
OHM: '0xebce5f29ff5ca9aa330ebdf7ec6b5f474bff271e',
|
|
1155
1160
|
USDT: '0x5ff47d4ab75bcaff6807c81f1367abb53439883c',
|
|
1156
1161
|
POPS: '0x4b78b52e7de4d8b7d367297cb8a87c1875a9d591',
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Network } from '../../constants';
|
|
2
|
-
|
|
3
|
-
// addresses must be consistant with utils.normalizeTokenAddress
|
|
4
|
-
export const STABLE_COINS: {
|
|
5
|
-
[network: number]: { [symbol: string]: boolean };
|
|
6
|
-
} = {
|
|
7
|
-
[Network.MAINNET]: {
|
|
8
|
-
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': true, // USDT
|
|
9
|
-
'0xdac17f958d2ee523a2206206994597c13d831ec7': true, // USDC
|
|
10
|
-
'0x6b175474e89094c44da98b954eedeac495271d0f': true, // DAI
|
|
11
|
-
'0x853d955acef822db058eb8505911ed77f175b99e': true, // FRAX
|
|
12
|
-
},
|
|
13
|
-
[Network.POLYGON]: {
|
|
14
|
-
'0x3c499c542cef5e3811e1192ce70d8cc03d5c3359': true, // USDC
|
|
15
|
-
'0x2791bca1f2de4661ed88a30c99a7a9449aa84174': true, // USDC.e
|
|
16
|
-
'0xc2132d05d31c914a87c6611c10748aeb04b58e8f': true, // USDT
|
|
17
|
-
'0x8f3cf7ad23cd3cadbd9735aff958023239c6a063': true, // DAI
|
|
18
|
-
},
|
|
19
|
-
[Network.ARBITRUM]: {
|
|
20
|
-
'0xaf88d065e77c8cc2239327c5edb3a432268e5831': true, // USDC
|
|
21
|
-
'0xff970a61a04b1ca14834a43f5de4533ebddb5cc8': true, // USDC.e
|
|
22
|
-
'0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': true, // USDT
|
|
23
|
-
'0xda10009cbd5d07dd0cecc66161fc93d7c9000da1': true, // DAI
|
|
24
|
-
},
|
|
25
|
-
};
|