@paraswap/dex-lib 2.20.3 → 2.21.1-chronos
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/.idea/aws.xml +17 -0
- package/.idea/codeStyles/Project.xml +19 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/paraswap-dex-lib.iml +9 -0
- package/.idea/vcs.xml +6 -0
- package/build/config.js +2 -4
- package/build/config.js.map +1 -1
- package/build/dex/aave-v3/tokens/arbitrum.json +50 -0
- package/build/dex/aave-v3/tokens/avalanche.json +74 -0
- package/build/dex/aave-v3/tokens/fantom.json +62 -0
- package/build/dex/aave-v3/tokens/optimism.json +50 -0
- package/build/dex/aave-v3/tokens/polygon.json +116 -0
- package/build/dex/balancer-v2/balancer-v2.d.ts +3 -9
- package/build/dex/balancer-v2/balancer-v2.js +0 -83
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/constants.d.ts +0 -4
- package/build/dex/balancer-v2/constants.js +1 -6
- package/build/dex/balancer-v2/constants.js.map +1 -1
- package/build/dex/balancer-v2/types.d.ts +1 -20
- package/build/dex/balancer-v2/types.js.map +1 -1
- package/build/dex/curve-v1/constants.d.ts +0 -1
- package/build/dex/curve-v1/constants.js +1 -2
- package/build/dex/curve-v1/constants.js.map +1 -1
- package/build/dex/curve-v1/curve-v1.d.ts +3 -9
- package/build/dex/curve-v1/curve-v1.js +4 -92
- package/build/dex/curve-v1/curve-v1.js.map +1 -1
- package/build/dex/curve-v1/types.d.ts +0 -24
- package/build/dex/curve-v1/types.js +1 -6
- package/build/dex/curve-v1/types.js.map +1 -1
- package/build/dex/curve-v1-factory/constants.d.ts +0 -1
- package/build/dex/curve-v1-factory/constants.js +1 -2
- package/build/dex/curve-v1-factory/constants.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +4 -11
- package/build/dex/curve-v1-factory/curve-v1-factory.js +0 -87
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v1-factory/types.d.ts +0 -24
- package/build/dex/curve-v1-factory/types.js +1 -6
- package/build/dex/curve-v1-factory/types.js.map +1 -1
- package/build/dex/curve-v2.d.ts +7 -29
- package/build/dex/curve-v2.js +1 -91
- package/build/dex/curve-v2.js.map +1 -1
- package/build/dex/idex.d.ts +1 -1
- package/build/dex/index.js +2 -2
- package/build/dex/index.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.d.ts +2 -2
- package/build/dex/pancakeswap-v3/types.d.ts +14 -0
- package/build/dex/pancakeswap-v3/types.js +3 -0
- package/build/dex/pancakeswap-v3/types.js.map +1 -0
- package/build/dex/pancakeswap-v3/utils.js.map +1 -1
- package/build/dex/quickswap/camelot-v3.d.ts +6 -0
- package/build/dex/quickswap/camelot-v3.js +19 -0
- package/build/dex/quickswap/camelot-v3.js.map +1 -0
- package/build/dex/simple-exchange.d.ts +0 -2
- package/build/dex/simple-exchange.js +0 -1
- package/build/dex/simple-exchange.js.map +1 -1
- package/build/dex/solidly/config.js +13 -0
- package/build/dex/solidly/config.js.map +1 -1
- package/build/dex/solidly/forks-override/chronos.d.ts +23 -0
- package/build/dex/solidly/forks-override/chronos.js +132 -0
- package/build/dex/solidly/forks-override/chronos.js.map +1 -0
- package/build/dex/solidly/solidly.js +1 -0
- package/build/dex/solidly/solidly.js.map +1 -1
- package/build/dex/uniswap-v2/uniswap-v2.d.ts +1 -1
- package/build/dex/uniswap-v2/uniswap-v2.js +1 -1
- package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
- package/build/dex/uniswap-v3/constants.d.ts +0 -4
- package/build/dex/uniswap-v3/constants.js +1 -6
- package/build/dex/uniswap-v3/constants.js.map +1 -1
- package/build/dex/uniswap-v3/types.d.ts +3 -20
- package/build/dex/uniswap-v3/types.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.d.ts +1 -7
- package/build/dex/uniswap-v3/uniswap-v3.js +1 -85
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/dex/woo-fi-v2/config.js +6 -6
- package/build/dex/zerox/index.d.ts +1 -1
- package/build/dex/zerox/index.js +1 -1
- package/build/dex/zerox/index.js.map +1 -1
- package/build/implementations/local-paraswap-sdk.js +1 -5
- package/build/implementations/local-paraswap-sdk.js.map +1 -1
- package/build/router/directswap.js +1 -7
- package/build/router/directswap.js.map +1 -1
- package/build/router/index.js.map +1 -1
- package/build/router/payload-encoder.js +6 -16
- package/build/router/payload-encoder.js.map +1 -1
- package/build/types.d.ts +0 -2
- package/build/utils.d.ts +0 -2
- package/build/utils.js +1 -5
- package/build/utils.js.map +1 -1
- package/package.json +4 -6
- package/src/config.ts +2 -5
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +0 -79
- package/src/dex/balancer-v2/balancer-v2.ts +4 -153
- package/src/dex/balancer-v2/constants.ts +0 -5
- package/src/dex/balancer-v2/types.ts +1 -21
- package/src/dex/curve-v1/constants.ts +0 -2
- package/src/dex/curve-v1/curve-v1-e2e.test.ts +0 -57
- package/src/dex/curve-v1/curve-v1.ts +5 -144
- package/src/dex/curve-v1/types.ts +0 -26
- package/src/dex/curve-v1-factory/constants.ts +0 -2
- package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +0 -1
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +4 -140
- package/src/dex/curve-v1-factory/types.ts +0 -26
- package/src/dex/curve-v2.ts +8 -169
- package/src/dex/idex.ts +0 -6
- package/src/dex/index.ts +2 -2
- package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +6 -3
- package/src/dex/pancakeswap-v3/pancakeswap-v3-integration.test.ts +14 -3
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +3 -3
- package/src/dex/pancakeswap-v3/utils.ts +4 -1
- package/src/dex/simple-exchange.ts +0 -6
- package/src/dex/solidly/config.ts +14 -0
- package/src/dex/solidly/forks-override/chronos.ts +206 -0
- package/src/dex/solidly/solidly-e2e.test.ts +205 -31
- package/src/dex/solidly/solidly-integration.test.ts +141 -0
- package/src/dex/solidly/solidly.ts +1 -0
- package/src/dex/uniswap-v2/uniswap-v2.ts +0 -6
- package/src/dex/uniswap-v3/constants.ts +0 -5
- package/src/dex/uniswap-v3/types.ts +3 -23
- package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +2 -100
- package/src/dex/uniswap-v3/uniswap-v3.ts +3 -138
- package/src/dex/woo-fi-v2/config.ts +6 -6
- package/src/dex/zerox/index.ts +0 -7
- package/src/implementations/local-paraswap-sdk.ts +1 -8
- package/src/router/directswap.ts +0 -23
- package/src/router/index.ts +2 -0
- package/src/router/payload-encoder.ts +5 -22
- package/src/types.ts +0 -2
- package/src/utils.ts +0 -5
- package/tests/constants-e2e.ts +9 -4
- package/tests/utils-e2e.ts +20 -140
- package/tests/utils.ts +0 -52
- package/src/abi/DirectSwap.json +0 -1018
- package/src/abi/swaap-v2/vault.json +0 -918
- package/src/dex/swaap-v2/config.ts +0 -19
- package/src/dex/swaap-v2/constants.ts +0 -37
- package/src/dex/swaap-v2/rate-fetcher.ts +0 -214
- package/src/dex/swaap-v2/swaap-v2-e2e.test.ts +0 -172
- package/src/dex/swaap-v2/swaap-v2-integration.test.ts +0 -142
- package/src/dex/swaap-v2/swaap-v2.ts +0 -901
- package/src/dex/swaap-v2/types.ts +0 -95
- package/src/dex/swaap-v2/utils.ts +0 -36
- package/src/dex/swaap-v2/validators.ts +0 -128
|
@@ -11,9 +11,6 @@ import {
|
|
|
11
11
|
Logger,
|
|
12
12
|
NumberAsString,
|
|
13
13
|
PoolPrices,
|
|
14
|
-
TxInfo,
|
|
15
|
-
PreprocessTransactionOptions,
|
|
16
|
-
ExchangeTxInfo,
|
|
17
14
|
} from '../../types';
|
|
18
15
|
import { SwapSide, Network, CACHE_PREFIX } from '../../constants';
|
|
19
16
|
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
@@ -22,7 +19,6 @@ import {
|
|
|
22
19
|
getDexKeysWithNetwork,
|
|
23
20
|
interpolate,
|
|
24
21
|
isTruthy,
|
|
25
|
-
uuidToBytes16,
|
|
26
22
|
} from '../../utils';
|
|
27
23
|
import { IDex } from '../../dex/idex';
|
|
28
24
|
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
@@ -33,7 +29,6 @@ import {
|
|
|
33
29
|
UniswapV3Data,
|
|
34
30
|
UniswapV3Functions,
|
|
35
31
|
UniswapV3Param,
|
|
36
|
-
UniswapV3SimpleSwapParams,
|
|
37
32
|
} from './types';
|
|
38
33
|
import {
|
|
39
34
|
getLocalDeadlineAsFriendlyPlaceholder,
|
|
@@ -44,16 +39,14 @@ import { UniswapV3EventPool } from './uniswap-v3-pool';
|
|
|
44
39
|
import UniswapV3RouterABI from '../../abi/uniswap-v3/UniswapV3Router.abi.json';
|
|
45
40
|
import UniswapV3QuoterABI from '../../abi/uniswap-v3/UniswapV3Quoter.abi.json';
|
|
46
41
|
import UniswapV3MultiABI from '../../abi/uniswap-v3/UniswapMulti.abi.json';
|
|
47
|
-
import DirectSwapABI from '../../abi/DirectSwap.json';
|
|
48
42
|
import UniswapV3StateMulticallABI from '../../abi/uniswap-v3/UniswapV3StateMulticall.abi.json';
|
|
49
43
|
import {
|
|
50
|
-
DirectMethods,
|
|
51
44
|
UNISWAPV3_EFFICIENCY_FACTOR,
|
|
52
45
|
UNISWAPV3_POOL_SEARCH_OVERHEAD,
|
|
53
46
|
UNISWAPV3_TICK_BASE_OVERHEAD,
|
|
54
47
|
UNISWAPV3_TICK_GAS_COST,
|
|
55
48
|
} from './constants';
|
|
56
|
-
import {
|
|
49
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
57
50
|
import { uniswapV3Math } from './contract-math/uniswap-v3-math';
|
|
58
51
|
import { Contract } from 'web3-eth-contract';
|
|
59
52
|
import { AbiItem } from 'web3-utils';
|
|
@@ -63,7 +56,6 @@ import {
|
|
|
63
56
|
DEFAULT_ID_ERC20,
|
|
64
57
|
DEFAULT_ID_ERC20_AS_STRING,
|
|
65
58
|
} from '../../lib/tokens/types';
|
|
66
|
-
import { OptimalSwapExchange } from '@paraswap/core';
|
|
67
59
|
|
|
68
60
|
type PoolPairsInfo = {
|
|
69
61
|
token0: Address;
|
|
@@ -85,8 +77,6 @@ export class UniswapV3
|
|
|
85
77
|
readonly hasConstantPriceLargeAmounts = false;
|
|
86
78
|
readonly needWrapNative = true;
|
|
87
79
|
|
|
88
|
-
readonly directSwapIface = new Interface(DirectSwapABI);
|
|
89
|
-
|
|
90
80
|
intervalTask?: NodeJS.Timeout;
|
|
91
81
|
|
|
92
82
|
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
|
|
@@ -123,7 +113,7 @@ export class UniswapV3
|
|
|
123
113
|
// To receive revert reasons
|
|
124
114
|
this.dexHelper.web3Provider.eth.handleRevert = false;
|
|
125
115
|
|
|
126
|
-
//
|
|
116
|
+
// Normalise once all config addresses and use across all scenarios
|
|
127
117
|
this.config = this._toLowerForAllConfigAddresses();
|
|
128
118
|
|
|
129
119
|
this.notExistingPoolSetKey =
|
|
@@ -459,7 +449,6 @@ export class UniswapV3
|
|
|
459
449
|
fee: pool.feeCodeAsString,
|
|
460
450
|
},
|
|
461
451
|
],
|
|
462
|
-
exchange: pool.poolAddress,
|
|
463
452
|
},
|
|
464
453
|
poolIdentifier: this.getPoolIdentifier(
|
|
465
454
|
pool.token0,
|
|
@@ -742,130 +731,6 @@ export class UniswapV3
|
|
|
742
731
|
return arr;
|
|
743
732
|
}
|
|
744
733
|
|
|
745
|
-
getTokenFromAddress(address: Address): Token {
|
|
746
|
-
// In this Dex decimals are not used
|
|
747
|
-
return { address, decimals: 0 };
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
async preProcessTransaction(
|
|
751
|
-
optimalSwapExchange: OptimalSwapExchange<UniswapV3Data>,
|
|
752
|
-
srcToken: Token,
|
|
753
|
-
_0: Token,
|
|
754
|
-
_1: SwapSide,
|
|
755
|
-
options: PreprocessTransactionOptions,
|
|
756
|
-
): Promise<[OptimalSwapExchange<UniswapV3Data>, ExchangeTxInfo]> {
|
|
757
|
-
if (!options.isDirectMethod) {
|
|
758
|
-
return [
|
|
759
|
-
optimalSwapExchange,
|
|
760
|
-
{
|
|
761
|
-
deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
|
|
762
|
-
},
|
|
763
|
-
];
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
assert(
|
|
767
|
-
optimalSwapExchange.data !== undefined,
|
|
768
|
-
`preProcessTransaction: data field is missing`,
|
|
769
|
-
);
|
|
770
|
-
|
|
771
|
-
let isApproved: boolean | undefined;
|
|
772
|
-
|
|
773
|
-
try {
|
|
774
|
-
this.erc20Contract.options.address =
|
|
775
|
-
this.dexHelper.config.wrapETH(srcToken).address;
|
|
776
|
-
const allowance = await this.erc20Contract.methods
|
|
777
|
-
.allowance(this.augustusAddress, this.config.router)
|
|
778
|
-
.call(undefined, 'latest');
|
|
779
|
-
isApproved =
|
|
780
|
-
BigInt(allowance.toString()) >= BigInt(optimalSwapExchange.srcAmount);
|
|
781
|
-
} catch (e) {
|
|
782
|
-
this.logger.error(
|
|
783
|
-
`preProcessTransaction failed to retrieve allowance info: `,
|
|
784
|
-
e,
|
|
785
|
-
);
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
return [
|
|
789
|
-
{
|
|
790
|
-
...optimalSwapExchange,
|
|
791
|
-
data: {
|
|
792
|
-
...optimalSwapExchange.data,
|
|
793
|
-
isApproved,
|
|
794
|
-
},
|
|
795
|
-
},
|
|
796
|
-
{
|
|
797
|
-
deadline: BigInt(getLocalDeadlineAsFriendlyPlaceholder()),
|
|
798
|
-
},
|
|
799
|
-
];
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
getDirectParam(
|
|
803
|
-
srcToken: Address,
|
|
804
|
-
destToken: Address,
|
|
805
|
-
srcAmount: NumberAsString,
|
|
806
|
-
destAmount: NumberAsString,
|
|
807
|
-
expectedAmount: NumberAsString,
|
|
808
|
-
data: UniswapV3Data,
|
|
809
|
-
side: SwapSide,
|
|
810
|
-
permit: string,
|
|
811
|
-
uuid: string,
|
|
812
|
-
feePercent: NumberAsString,
|
|
813
|
-
deadline: NumberAsString,
|
|
814
|
-
partner: string,
|
|
815
|
-
beneficiary: string,
|
|
816
|
-
contractMethod?: string,
|
|
817
|
-
): TxInfo<UniswapV3Param> {
|
|
818
|
-
if (
|
|
819
|
-
contractMethod !== DirectMethods.directSell &&
|
|
820
|
-
contractMethod !== DirectMethods.directBuy
|
|
821
|
-
) {
|
|
822
|
-
throw new Error(`Invalid contract method ${contractMethod}`);
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
let isApproved: boolean = !!data.isApproved;
|
|
826
|
-
if (data.isApproved === undefined) {
|
|
827
|
-
this.logger.warn(`isApproved is undefined, defaulting to false`);
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
const path = this._encodePath(data.path, side);
|
|
831
|
-
|
|
832
|
-
const swapParams: UniswapV3Param = [
|
|
833
|
-
srcToken,
|
|
834
|
-
destToken,
|
|
835
|
-
this.config.router,
|
|
836
|
-
srcAmount,
|
|
837
|
-
destAmount,
|
|
838
|
-
expectedAmount,
|
|
839
|
-
feePercent,
|
|
840
|
-
deadline,
|
|
841
|
-
partner,
|
|
842
|
-
isApproved,
|
|
843
|
-
beneficiary,
|
|
844
|
-
path,
|
|
845
|
-
permit,
|
|
846
|
-
uuidToBytes16(uuid),
|
|
847
|
-
];
|
|
848
|
-
|
|
849
|
-
const encoder = (...params: UniswapV3Param) => {
|
|
850
|
-
return this.directSwapIface.encodeFunctionData(
|
|
851
|
-
side === SwapSide.SELL
|
|
852
|
-
? DirectMethods.directSell
|
|
853
|
-
: DirectMethods.directBuy,
|
|
854
|
-
[params],
|
|
855
|
-
);
|
|
856
|
-
};
|
|
857
|
-
|
|
858
|
-
return {
|
|
859
|
-
params: swapParams,
|
|
860
|
-
encoder,
|
|
861
|
-
networkFee: '0',
|
|
862
|
-
};
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
static getDirectFunctionName(): string[] {
|
|
866
|
-
return [DirectMethods.directSell, DirectMethods.directBuy];
|
|
867
|
-
}
|
|
868
|
-
|
|
869
734
|
async getSimpleParam(
|
|
870
735
|
srcToken: string,
|
|
871
736
|
destToken: string,
|
|
@@ -880,7 +745,7 @@ export class UniswapV3
|
|
|
880
745
|
: UniswapV3Functions.exactOutput;
|
|
881
746
|
|
|
882
747
|
const path = this._encodePath(data.path, side);
|
|
883
|
-
const swapFunctionParams:
|
|
748
|
+
const swapFunctionParams: UniswapV3Param =
|
|
884
749
|
side === SwapSide.SELL
|
|
885
750
|
? {
|
|
886
751
|
recipient: this.augustusAddress,
|
|
@@ -6,7 +6,7 @@ export const WooFiV2Config: DexConfigMap<DexParams> = {
|
|
|
6
6
|
WooFiV2: {
|
|
7
7
|
[Network.OPTIMISM]: {
|
|
8
8
|
wooPPV2Address: '0xd1778F9DF3eee5473A9640f13682e3846f61fEbC',
|
|
9
|
-
wooOracleV2Address: '
|
|
9
|
+
wooOracleV2Address: '0x464959aD46e64046B891F562cFF202a465D522F3',
|
|
10
10
|
integrationHelperAddress: '0x96329d66074EB8386Ae8bFD6698B2E3FDA87e15E',
|
|
11
11
|
// USDC
|
|
12
12
|
quoteToken: {
|
|
@@ -16,7 +16,7 @@ export const WooFiV2Config: DexConfigMap<DexParams> = {
|
|
|
16
16
|
},
|
|
17
17
|
[Network.BSC]: {
|
|
18
18
|
wooPPV2Address: '0x59dE3B49314Bf5067719364A2Cb43e8525ab93FA',
|
|
19
|
-
wooOracleV2Address: '
|
|
19
|
+
wooOracleV2Address: '0x4B11B9BfAafA840c436a1ddDc13D3738C8ebfD62',
|
|
20
20
|
integrationHelperAddress: '0xAA9c15cd603428cA8ddD45e933F8EfE3Afbcc173',
|
|
21
21
|
// USDT
|
|
22
22
|
quoteToken: {
|
|
@@ -26,7 +26,7 @@ export const WooFiV2Config: DexConfigMap<DexParams> = {
|
|
|
26
26
|
},
|
|
27
27
|
[Network.POLYGON]: {
|
|
28
28
|
wooPPV2Address: '0x7081A38158BD050Ae4a86e38E0225Bc281887d7E',
|
|
29
|
-
wooOracleV2Address: '
|
|
29
|
+
wooOracleV2Address: '0xeFF23B4bE1091b53205E35f3AfCD9C7182bf3062',
|
|
30
30
|
integrationHelperAddress: '0x7Ba560eB735AbDCf9a3a5692272652A0cc81850d',
|
|
31
31
|
// USDC
|
|
32
32
|
quoteToken: {
|
|
@@ -36,7 +36,7 @@ export const WooFiV2Config: DexConfigMap<DexParams> = {
|
|
|
36
36
|
},
|
|
37
37
|
[Network.FANTOM]: {
|
|
38
38
|
wooPPV2Address: '0x286ab107c5E9083dBed35A2B5fb0242538F4f9bf',
|
|
39
|
-
wooOracleV2Address: '
|
|
39
|
+
wooOracleV2Address: '0x8840e26e0ebf7D100A0644DD8576DC62B03cbf04',
|
|
40
40
|
integrationHelperAddress: '0x6641959FE5EED7166F2254cF04b0d20c96776D9A',
|
|
41
41
|
// USDC
|
|
42
42
|
quoteToken: {
|
|
@@ -46,7 +46,7 @@ export const WooFiV2Config: DexConfigMap<DexParams> = {
|
|
|
46
46
|
},
|
|
47
47
|
[Network.ARBITRUM]: {
|
|
48
48
|
wooPPV2Address: '0xeFF23B4bE1091b53205E35f3AfCD9C7182bf3062',
|
|
49
|
-
wooOracleV2Address: '
|
|
49
|
+
wooOracleV2Address: '0x37a9dE70b6734dFCA54395D8061d9411D9910739',
|
|
50
50
|
integrationHelperAddress: '0x28D2B949024FE50627f1EbC5f0Ca3Ca721148E40',
|
|
51
51
|
// USDC
|
|
52
52
|
quoteToken: {
|
|
@@ -56,7 +56,7 @@ export const WooFiV2Config: DexConfigMap<DexParams> = {
|
|
|
56
56
|
},
|
|
57
57
|
[Network.AVALANCHE]: {
|
|
58
58
|
wooPPV2Address: '0x3b3E4b4741e91aF52d0e9ad8660573E951c88524',
|
|
59
|
-
wooOracleV2Address: '
|
|
59
|
+
wooOracleV2Address: '0x9ACA557590F5020BDA4Ba63065Fc3A1253Bf8000',
|
|
60
60
|
integrationHelperAddress: '0x020630613E296c3E9b06186f630D1bF97A2B6Ad1',
|
|
61
61
|
// USDC
|
|
62
62
|
quoteToken: {
|
package/src/dex/zerox/index.ts
CHANGED
|
@@ -269,16 +269,9 @@ export class ZeroX
|
|
|
269
269
|
destToken: Address,
|
|
270
270
|
srcAmount: NumberAsString,
|
|
271
271
|
destAmount: NumberAsString,
|
|
272
|
-
expectedAmount: NumberAsString,
|
|
273
272
|
data: ZeroXData,
|
|
274
273
|
side: SwapSide,
|
|
275
274
|
permit: string,
|
|
276
|
-
uuid: string,
|
|
277
|
-
feePercent: NumberAsString,
|
|
278
|
-
deadline: NumberAsString,
|
|
279
|
-
partner: string,
|
|
280
|
-
beneficiary: string,
|
|
281
|
-
contractMethod?: string,
|
|
282
275
|
): TxInfo<ZeroXParam> {
|
|
283
276
|
const usePermit = permit !== '0x';
|
|
284
277
|
const encoder = (...params: ZeroXParam) => {
|
|
@@ -17,8 +17,6 @@ import {
|
|
|
17
17
|
} from '../types';
|
|
18
18
|
import { SwapSide, NULL_ADDRESS, ContractMethod } from '../constants';
|
|
19
19
|
import { LimitOrderExchange } from '../dex/limit-order-exchange';
|
|
20
|
-
import { v4 as uuid } from 'uuid';
|
|
21
|
-
import { DirectContractMethods } from '@paraswap/core/build/constants';
|
|
22
20
|
|
|
23
21
|
export interface IParaSwapSDK {
|
|
24
22
|
getPrices(
|
|
@@ -207,8 +205,6 @@ export class LocalParaswapSDK implements IParaSwapSDK {
|
|
|
207
205
|
: priceRoute.srcAmount,
|
|
208
206
|
);
|
|
209
207
|
|
|
210
|
-
const contractMethod = priceRoute.contractMethod;
|
|
211
|
-
|
|
212
208
|
// Call preprocessTransaction for each exchange before we build transaction
|
|
213
209
|
try {
|
|
214
210
|
priceRoute.bestRoute = await Promise.all(
|
|
@@ -238,9 +234,6 @@ export class LocalParaswapSDK implements IParaSwapSDK {
|
|
|
238
234
|
{
|
|
239
235
|
slippageFactor,
|
|
240
236
|
txOrigin: userAddress,
|
|
241
|
-
isDirectMethod: DirectContractMethods.includes(
|
|
242
|
-
contractMethod as ContractMethod,
|
|
243
|
-
),
|
|
244
237
|
},
|
|
245
238
|
);
|
|
246
239
|
|
|
@@ -271,7 +264,7 @@ export class LocalParaswapSDK implements IParaSwapSDK {
|
|
|
271
264
|
partnerAddress: NULL_ADDRESS,
|
|
272
265
|
partnerFeePercent: '0',
|
|
273
266
|
deadline: deadline.toString(),
|
|
274
|
-
uuid:
|
|
267
|
+
uuid: '00000000-0000-0000-0000-000000000000',
|
|
275
268
|
});
|
|
276
269
|
}
|
|
277
270
|
}
|
package/src/router/directswap.ts
CHANGED
|
@@ -3,11 +3,6 @@ import { IDex } from '../dex/idex';
|
|
|
3
3
|
import { Address, OptimalRate, TxInfo, Adapters } from '../types';
|
|
4
4
|
import { SwapSide } from '../constants';
|
|
5
5
|
import { DexAdapterService } from '../dex';
|
|
6
|
-
import { assert } from 'ts-essentials';
|
|
7
|
-
import {
|
|
8
|
-
encodeFeePercent,
|
|
9
|
-
encodeFeePercentForReferrer,
|
|
10
|
-
} from './payload-encoder';
|
|
11
6
|
|
|
12
7
|
export class DirectSwap<DexDirectReturn> implements IRouter<DexDirectReturn> {
|
|
13
8
|
// This is just psuedo name as the DirectSwap
|
|
@@ -56,7 +51,6 @@ export class DirectSwap<DexDirectReturn> implements IRouter<DexDirectReturn> {
|
|
|
56
51
|
);
|
|
57
52
|
|
|
58
53
|
const swapExchange = priceRoute.bestRoute[0].swaps[0].swapExchanges[0];
|
|
59
|
-
|
|
60
54
|
const srcAmount =
|
|
61
55
|
priceRoute.side === SwapSide.SELL ? swapExchange.srcAmount : minMaxAmount;
|
|
62
56
|
const destAmount =
|
|
@@ -64,31 +58,14 @@ export class DirectSwap<DexDirectReturn> implements IRouter<DexDirectReturn> {
|
|
|
64
58
|
? minMaxAmount
|
|
65
59
|
: swapExchange.destAmount;
|
|
66
60
|
|
|
67
|
-
const expectedAmount =
|
|
68
|
-
priceRoute.side === SwapSide.SELL
|
|
69
|
-
? priceRoute.destAmount
|
|
70
|
-
: priceRoute.srcAmount;
|
|
71
|
-
|
|
72
61
|
return dex.getDirectParam!(
|
|
73
62
|
priceRoute.srcToken,
|
|
74
63
|
priceRoute.destToken,
|
|
75
64
|
srcAmount,
|
|
76
65
|
destAmount,
|
|
77
|
-
expectedAmount,
|
|
78
66
|
swapExchange.data,
|
|
79
67
|
priceRoute.side,
|
|
80
68
|
permit,
|
|
81
|
-
uuid,
|
|
82
|
-
referrerAddress
|
|
83
|
-
? encodeFeePercentForReferrer(priceRoute.side)
|
|
84
|
-
: encodeFeePercent(
|
|
85
|
-
partnerFeePercent,
|
|
86
|
-
positiveSlippageToUser,
|
|
87
|
-
priceRoute.side,
|
|
88
|
-
),
|
|
89
|
-
deadline,
|
|
90
|
-
referrerAddress || partnerAddress,
|
|
91
|
-
beneficiary,
|
|
92
69
|
priceRoute.contractMethod,
|
|
93
70
|
);
|
|
94
71
|
}
|
package/src/router/index.ts
CHANGED
|
@@ -5,7 +5,9 @@ import { Buy } from './buy';
|
|
|
5
5
|
import { SimpleSwap, SimpleBuy } from './simpleswap';
|
|
6
6
|
import { SimpleBuyNFT } from './simpleswapnft';
|
|
7
7
|
import { DirectSwap } from './directswap';
|
|
8
|
+
import { Adapters } from '../types';
|
|
8
9
|
import { DexAdapterService } from '../dex';
|
|
10
|
+
import { SwapSide } from '../constants';
|
|
9
11
|
|
|
10
12
|
export class RouterService {
|
|
11
13
|
hybridRouters = [
|
|
@@ -16,42 +16,25 @@ import { convertToBasisPoints } from '../utils';
|
|
|
16
16
|
const OneShift14 = 1n << 14n;
|
|
17
17
|
const OneShift15 = 1n << 15n;
|
|
18
18
|
const OneShift16 = 1n << 16n;
|
|
19
|
-
const OneShift17 = 1n << 17n;
|
|
20
19
|
const OneShift248 = 1n << 248n;
|
|
21
20
|
|
|
22
|
-
// Referrer gets 25% of positive slippage
|
|
21
|
+
// Referrer gets 50% of what ParaSwap takes i.e. 25% of positive slippage
|
|
23
22
|
// Set 16th bit to indicate referral program
|
|
24
|
-
const REFERRER_FEE =
|
|
25
|
-
|
|
26
|
-
const HALF_SPLIT = '5000';
|
|
23
|
+
const REFERRER_FEE = 5000n | OneShift14 | OneShift16 | OneShift248;
|
|
27
24
|
|
|
28
25
|
export function encodeFeePercent(
|
|
29
26
|
partnerFeePercent: string,
|
|
30
27
|
positiveSlippageToUser: boolean,
|
|
31
28
|
side: SwapSide,
|
|
32
29
|
) {
|
|
33
|
-
|
|
34
|
-
positiveSlippageToUser === false && BigInt(partnerFeePercent) === 0n;
|
|
35
|
-
|
|
36
|
-
let fee = isNoFeeAndPositiveSlippageToPartner
|
|
37
|
-
? BigInt(HALF_SPLIT)
|
|
38
|
-
: BigInt(partnerFeePercent);
|
|
39
|
-
|
|
30
|
+
let fee = BigInt(partnerFeePercent);
|
|
40
31
|
if (fee > 10000) throw new Error('fee bps should be less than 10000');
|
|
41
32
|
|
|
42
|
-
// Set 16th bit as referrer to split positive slippage for partner and protocol
|
|
43
|
-
// Set 17th bit to flag on Subgraph that this is a special case
|
|
44
|
-
if (isNoFeeAndPositiveSlippageToPartner) {
|
|
45
|
-
fee |= OneShift16;
|
|
46
|
-
fee |= OneShift17;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
33
|
// Set 14th bit if positiveSlippageToUser is true
|
|
50
34
|
if (positiveSlippageToUser) fee |= OneShift14;
|
|
51
35
|
|
|
52
36
|
// Set 15th bit to take fee from srcToken
|
|
53
|
-
if (side === SwapSide.BUY
|
|
54
|
-
fee |= OneShift15;
|
|
37
|
+
if (side === SwapSide.BUY) fee |= OneShift15;
|
|
55
38
|
|
|
56
39
|
// Bits 248 - 255 is used for version;
|
|
57
40
|
// Set version = 1;
|
|
@@ -64,7 +47,7 @@ export function encodeFeePercentForReferrer(side: SwapSide) {
|
|
|
64
47
|
let fee = REFERRER_FEE;
|
|
65
48
|
|
|
66
49
|
// Set 15th bit to take fee from srcToken
|
|
67
|
-
|
|
50
|
+
if (side === SwapSide.BUY) fee |= OneShift15;
|
|
68
51
|
|
|
69
52
|
return fee.toString();
|
|
70
53
|
}
|
package/src/types.ts
CHANGED
|
@@ -275,7 +275,6 @@ export type Config = {
|
|
|
275
275
|
hashFlowAuthToken?: string;
|
|
276
276
|
hashFlowDisabledMMs: string[];
|
|
277
277
|
uniswapV3EventLoggingSampleRate?: number;
|
|
278
|
-
swaapV2AuthToken?: string;
|
|
279
278
|
};
|
|
280
279
|
|
|
281
280
|
export type BigIntAsString = string;
|
|
@@ -289,7 +288,6 @@ export type PreprocessTransactionOptions = {
|
|
|
289
288
|
txOrigin: Address;
|
|
290
289
|
hmac?: string;
|
|
291
290
|
mockRfqAndLO?: boolean;
|
|
292
|
-
isDirectMethod?: boolean;
|
|
293
291
|
};
|
|
294
292
|
|
|
295
293
|
export type TransferFeeParams = {
|
package/src/utils.ts
CHANGED
|
@@ -8,11 +8,6 @@ import _ from 'lodash';
|
|
|
8
8
|
import { MultiResult } from './lib/multi-wrapper';
|
|
9
9
|
import { Contract } from 'web3-eth-contract';
|
|
10
10
|
import Web3 from 'web3';
|
|
11
|
-
import { AxiosError } from 'axios';
|
|
12
|
-
|
|
13
|
-
export const isAxiosError = (e: any): e is AxiosError => {
|
|
14
|
-
return e.isAxiosError === true;
|
|
15
|
-
};
|
|
16
11
|
|
|
17
12
|
export const isETHAddress = (address: string) =>
|
|
18
13
|
address.toLowerCase() === ETHER_ADDRESS.toLowerCase();
|
package/tests/constants-e2e.ts
CHANGED
|
@@ -704,6 +704,10 @@ export const Tokens: {
|
|
|
704
704
|
address: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
|
|
705
705
|
decimals: 18,
|
|
706
706
|
},
|
|
707
|
+
ARB: {
|
|
708
|
+
address: '0x912ce59144191c1204e64559fe8253a0e49e6548',
|
|
709
|
+
decimals: 18,
|
|
710
|
+
},
|
|
707
711
|
WETH: {
|
|
708
712
|
address: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
|
|
709
713
|
decimals: 18,
|
|
@@ -898,10 +902,10 @@ export const Holders: {
|
|
|
898
902
|
[Network.POLYGON]: {
|
|
899
903
|
MATIC: '0xe7804c37c13166fF0b37F5aE0BB07A3aEbb6e245',
|
|
900
904
|
DAI: '0x06959153B974D0D5fDfd87D561db6d8d4FA0bb0B',
|
|
901
|
-
WETH: '
|
|
905
|
+
WETH: '0x72a53cdbbcc1b9efa39c834a540550e23463aacb',
|
|
902
906
|
WMATIC: '0xFffbCD322cEace527C8ec6Da8de2461C6D9d4e6e',
|
|
903
907
|
AMWMATIC: '0x8832924854e3Cedb0a6Abf372e6CCFF9F7654332',
|
|
904
|
-
USDC: '
|
|
908
|
+
USDC: '0x06959153B974D0D5fDfd87D561db6d8d4FA0bb0B',
|
|
905
909
|
POPS: '0x2693b57ee51f4e2a26dfb339a911fa8731061f49',
|
|
906
910
|
MUST: '0x9f2a409848fb9b7bd058b24a23e8dbf1e166a109',
|
|
907
911
|
AMDAI: '0xFA0DCe8280FCDf369a4cbFc1830d3302789307a6',
|
|
@@ -917,8 +921,8 @@ export const Holders: {
|
|
|
917
921
|
RADIO: '0x60531b9c3645546d864604ee0fc5b7d6adc81cc2',
|
|
918
922
|
HANZO: '0x8a151b6ec99c7b90b342ab401d511b480309b220',
|
|
919
923
|
RVLT: '0x815f87ca3db2b9491115a7769aeacb140361c5a9',
|
|
920
|
-
stMATIC: '
|
|
921
|
-
axlUSDC: '
|
|
924
|
+
stMATIC: '0x3b39669766fe815aa91834b3bd258dea3edbb6d5',
|
|
925
|
+
axlUSDC: '0x42875ae5766dfd4d70772a3a956842e4b708d59a',
|
|
922
926
|
deUSDC: '0x94d5ead1f80cf0b4d3480ab59dff16d47c93e9fe',
|
|
923
927
|
amUSDT: '0x832b11846a27b3ba25d68ae80c39fab155d18c49',
|
|
924
928
|
amUSDC: '0x6e7f19cd23049c7118e14470e2bf85d2e26ee0ae',
|
|
@@ -991,6 +995,7 @@ export const Holders: {
|
|
|
991
995
|
YUSD: '0x6c1a5ef2acde1fd2fc68def440d2c1eb35bae24a',
|
|
992
996
|
},
|
|
993
997
|
[Network.ARBITRUM]: {
|
|
998
|
+
ARB: '0xb65edba80a3d81903ecd499c8eb9cf0e19096bd0',
|
|
994
999
|
ETH: '0xF977814e90dA44bFA03b6295A0616a897441aceC',
|
|
995
1000
|
DAI: '0x07d7f291e731a41d3f0ea4f1ae5b6d920ffb3fe0',
|
|
996
1001
|
WETH: '0xc31e54c7a869b9fcbecc14363cf510d1c41fa443',
|