@paraswap/dex-lib 3.8.21 → 3.8.22-infusion
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/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/lite-psm/lite-psm.js +1 -1
- package/build/dex/lite-psm/lite-psm.js.map +1 -1
- package/build/dex/maker-psm/maker-psm.js +1 -1
- package/build/dex/trader-joe-v2.1/base.js +5 -16
- package/build/dex/trader-joe-v2.1/base.js.map +1 -1
- package/build/dex/trader-joe-v2.1/config.js +2 -2
- package/build/dex/trader-joe-v2.1/types.d.ts +3 -3
- package/package.json +1 -1
- package/src/abi/infusion/InfusionFactory.json +147 -0
- package/src/abi/infusion/InfusionPair.json +658 -0
- package/src/abi/infusion/InfusionRouter.json +442 -0
- package/src/dex/index.ts +2 -0
- package/src/dex/infusion/config.ts +27 -0
- package/src/dex/infusion/infusion-e2e.test.ts +110 -0
- package/src/dex/infusion/infusion-integration.test.ts +232 -0
- package/src/dex/infusion/infusion-stable-pool.ts +91 -0
- package/src/dex/infusion/infusion.ts +749 -0
- package/src/dex/infusion/types.ts +60 -0
- package/src/dex/infusion/utils/isStablePair.ts +18 -0
- package/src/dex/lite-psm/lite-psm.ts +1 -1
- package/src/dex/maker-psm/maker-psm.ts +1 -1
- package/src/dex/trader-joe-v2.1/base.ts +5 -16
- package/src/dex/trader-joe-v2.1/config.ts +2 -2
- package/src/dex/trader-joe-v2.1/types.ts +3 -3
- package/tests/constants-e2e.ts +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UniswapV2Data,
|
|
3
|
+
UniswapV2PoolOrderedParams,
|
|
4
|
+
DexParams as UniswapV2DexParams,
|
|
5
|
+
UniswapPool,
|
|
6
|
+
} from '../uniswap-v2/types';
|
|
7
|
+
import { UniswapV2Pair } from '../uniswap-v2/uniswap-v2';
|
|
8
|
+
|
|
9
|
+
export type PoolState = {
|
|
10
|
+
reserves0: string;
|
|
11
|
+
reserves1: string;
|
|
12
|
+
feeCode: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// to calculate prices for stable pool, we need decimals of the stable tokens
|
|
16
|
+
export interface InfusionPoolOrderedParams extends UniswapV2PoolOrderedParams {
|
|
17
|
+
decimalsIn: number;
|
|
18
|
+
decimalsOut: number;
|
|
19
|
+
stable: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type InfusionData = UniswapV2Data & { isFeeTokenInRoute: boolean };
|
|
23
|
+
|
|
24
|
+
export type InfusionPool = UniswapPool;
|
|
25
|
+
|
|
26
|
+
export interface DexParams extends Omit<UniswapV2DexParams, 'feeCode'> {
|
|
27
|
+
feeCode: number;
|
|
28
|
+
stableFee?: number;
|
|
29
|
+
volatileFee?: number;
|
|
30
|
+
feeFactor?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface InfusionPair extends UniswapV2Pair {
|
|
34
|
+
stable: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type InfusionParam = SellOnInfusionParam | SellETHOnInfusionParam;
|
|
38
|
+
|
|
39
|
+
export type SellOnInfusionParam = [
|
|
40
|
+
amountIn: string,
|
|
41
|
+
amountOutMin: string,
|
|
42
|
+
routes: {
|
|
43
|
+
from: string;
|
|
44
|
+
to: string;
|
|
45
|
+
stable: boolean;
|
|
46
|
+
}[],
|
|
47
|
+
to: string,
|
|
48
|
+
deadline: number,
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
export type SellETHOnInfusionParam = [
|
|
52
|
+
amountOutMin: string,
|
|
53
|
+
routes: {
|
|
54
|
+
from: string;
|
|
55
|
+
to: string;
|
|
56
|
+
stable: boolean;
|
|
57
|
+
}[],
|
|
58
|
+
to: string,
|
|
59
|
+
deadline: number,
|
|
60
|
+
];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Network } from '../../../constants';
|
|
2
|
+
|
|
3
|
+
export const stablecoins: Record<number, string[]> = {
|
|
4
|
+
[Network.BASE]: [
|
|
5
|
+
'0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'.toLowerCase(), // usdc
|
|
6
|
+
'0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA'.toLowerCase(), // usdbc
|
|
7
|
+
'0xEB466342C4d449BC9f53A865D5Cb90586f405215'.toLowerCase(), // axelar usdc
|
|
8
|
+
],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function isStablePair(chainId: number, tokenA: string, tokenB: string) {
|
|
12
|
+
const stables = stablecoins[chainId];
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
stables.includes(tokenA.toLocaleLowerCase()) &&
|
|
16
|
+
stables.includes(tokenB.toLocaleLowerCase())
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -53,18 +53,7 @@ export class BaseTraderJoeV2
|
|
|
53
53
|
['tuple(tuple(uint256[],uint8[],address[]),uint256)'],
|
|
54
54
|
[
|
|
55
55
|
[
|
|
56
|
-
[
|
|
57
|
-
[
|
|
58
|
-
data.binStep, // _pairBinSteps: uint256[]
|
|
59
|
-
],
|
|
60
|
-
[
|
|
61
|
-
this.versionIndex, // _versions: uint8[]
|
|
62
|
-
],
|
|
63
|
-
[
|
|
64
|
-
data.tokenIn,
|
|
65
|
-
data.tokenOut, // _tokenPath: address[]
|
|
66
|
-
],
|
|
67
|
-
],
|
|
56
|
+
[data.binSteps, data.versions, data.tokenPath],
|
|
68
57
|
getLocalDeadlineAsFriendlyPlaceholder(), // _deadline: uint256
|
|
69
58
|
],
|
|
70
59
|
],
|
|
@@ -95,14 +84,14 @@ export class BaseTraderJoeV2
|
|
|
95
84
|
? [
|
|
96
85
|
srcAmount,
|
|
97
86
|
destAmount,
|
|
98
|
-
[
|
|
87
|
+
[data.binSteps, data.versions, data.tokenPath],
|
|
99
88
|
this.augustusAddress,
|
|
100
89
|
getLocalDeadlineAsFriendlyPlaceholder(),
|
|
101
90
|
]
|
|
102
91
|
: [
|
|
103
92
|
destAmount,
|
|
104
93
|
srcAmount,
|
|
105
|
-
[
|
|
94
|
+
[data.binSteps, data.versions, data.tokenPath],
|
|
106
95
|
this.augustusAddress,
|
|
107
96
|
getLocalDeadlineAsFriendlyPlaceholder(),
|
|
108
97
|
];
|
|
@@ -143,14 +132,14 @@ export class BaseTraderJoeV2
|
|
|
143
132
|
? [
|
|
144
133
|
srcAmount,
|
|
145
134
|
destAmount,
|
|
146
|
-
[
|
|
135
|
+
[data.binSteps, data.versions, data.tokenPath],
|
|
147
136
|
recipient,
|
|
148
137
|
placeholder,
|
|
149
138
|
]
|
|
150
139
|
: [
|
|
151
140
|
destAmount,
|
|
152
141
|
srcAmount,
|
|
153
|
-
[
|
|
142
|
+
[data.binSteps, data.versions, data.tokenPath],
|
|
154
143
|
recipient,
|
|
155
144
|
placeholder,
|
|
156
145
|
];
|
|
@@ -2,8 +2,8 @@ import { Address } from '@paraswap/core';
|
|
|
2
2
|
import { Network } from '../../constants';
|
|
3
3
|
|
|
4
4
|
export const TRADERJOE_V2_1_ROUTER_ADDRESS: { [network: number]: Address } = {
|
|
5
|
-
[Network.AVALANCHE]: '
|
|
6
|
-
[Network.ARBITRUM]: '
|
|
5
|
+
[Network.AVALANCHE]: '0x18556da13313f3532c54711497a8fedac273220e',
|
|
6
|
+
[Network.ARBITRUM]: '0x18556da13313f3532c54711497a8fedac273220e',
|
|
7
7
|
[Network.BSC]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
|
|
8
8
|
[Network.MAINNET]: '0x9A93a421b74F1c5755b83dD2C211614dC419C44b',
|
|
9
9
|
};
|
|
@@ -27,9 +27,9 @@ export type TraderJoeV2RouterParam =
|
|
|
27
27
|
| TraderJoeV2RouterBuyParams;
|
|
28
28
|
|
|
29
29
|
export type TraderJoeV2Data = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
tokenPath: string[];
|
|
31
|
+
binSteps: string[];
|
|
32
|
+
versions: string[];
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
export enum TraderJoeV2RouterFunctions {
|
package/tests/constants-e2e.ts
CHANGED
|
@@ -1798,7 +1798,7 @@ export const Holders: {
|
|
|
1798
1798
|
PRIME: '0xe3879b7359695f802d6FD56Bb76fD82C362Dafd6',
|
|
1799
1799
|
ETH: '0xd34ea7278e6bd48defe656bbe263aef11101469c',
|
|
1800
1800
|
MAV: '0xf977814e90da44bfa03b6295a0616a897441acec',
|
|
1801
|
-
USDC: '
|
|
1801
|
+
USDC: '0x21bD501F86A0B5cE0907651Df3368DA905B300A9',
|
|
1802
1802
|
USDbC: '0x4bb6b2efe7036020ba6f02a05602546c9f25bf28',
|
|
1803
1803
|
DAI: '0x20f03e26968b179025f65c1f4afadfd3959c8d03',
|
|
1804
1804
|
BAL: '0x854b004700885a61107b458f11ecc169a019b764',
|