@paraswap/dex-lib 2.16.3 → 2.16.4-traderjoev2.1.1
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/TraderJoeV21Router.json +1489 -0
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/trader-joe-v2.1.d.ts +43 -0
- package/build/dex/trader-joe-v2.1.js +78 -0
- package/build/dex/trader-joe-v2.1.js.map +1 -0
- package/package.json +1 -1
- package/src/abi/TraderJoeV21Router.json +1489 -0
- package/src/dex/index.ts +2 -0
- package/src/dex/trader-joe-v2.1.ts +155 -0
- package/build/abi/DirectSwap.json +0 -970
- package/build/abi/woo-fi/WooFeeManager.abi.json +0 -318
- package/build/abi/woo-fi/WooPP.abi.json +0 -548
- package/build/abi/woo-fi/Wooracle.abi.json +0 -260
- package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
- package/build/dex/aave-v3/tokens/avalanche.json +0 -74
- package/build/dex/aave-v3/tokens/fantom.json +0 -62
- package/build/dex/aave-v3/tokens/optimism.json +0 -50
- package/build/dex/aave-v3/tokens/polygon.json +0 -116
- package/build/dex/quickswap-v3.d.ts +0 -21
- package/build/dex/quickswap-v3.js +0 -40
- package/build/dex/quickswap-v3.js.map +0 -1
- package/build/dex/test-dex/config.d.ts +0 -4
- package/build/dex/test-dex/config.js +0 -15
- package/build/dex/test-dex/config.js.map +0 -1
- package/build/dex/test-dex/test-dex-pool.d.ts +0 -39
- package/build/dex/test-dex/test-dex-pool.js +0 -63
- package/build/dex/test-dex/test-dex-pool.js.map +0 -1
- package/build/dex/test-dex/test-dex.d.ts +0 -37
- package/build/dex/test-dex/test-dex.js +0 -126
- package/build/dex/test-dex/test-dex.js.map +0 -1
- package/build/dex/test-dex/types.d.ts +0 -6
- package/build/dex/test-dex/types.js +0 -3
- package/build/dex/test-dex/types.js.map +0 -1
- package/build/dex/woo-fi/config.d.ts +0 -4
- package/build/dex/woo-fi/config.js +0 -141
- package/build/dex/woo-fi/config.js.map +0 -1
- package/build/dex/woo-fi/constants.d.ts +0 -5
- package/build/dex/woo-fi/constants.js +0 -20
- package/build/dex/woo-fi/constants.js.map +0 -1
- package/build/dex/woo-fi/types.d.ts +0 -48
- package/build/dex/woo-fi/types.js +0 -3
- package/build/dex/woo-fi/types.js.map +0 -1
- package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +0 -14
- package/build/dex/woo-fi/woo-fi-decimal-math.js +0 -42
- package/build/dex/woo-fi/woo-fi-decimal-math.js.map +0 -1
- package/build/dex/woo-fi/woo-fi-math.d.ts +0 -31
- package/build/dex/woo-fi/woo-fi-math.js +0 -300
- package/build/dex/woo-fi/woo-fi-math.js.map +0 -1
- package/build/dex/woo-fi/woo-fi.d.ts +0 -65
- package/build/dex/woo-fi/woo-fi.js +0 -480
- package/build/dex/woo-fi/woo-fi.js.map +0 -1
- package/build/dex/woo-fi-v2/woo-fi-math.d.ts +0 -16
- package/build/dex/woo-fi-v2/woo-fi-math.js +0 -137
- package/build/dex/woo-fi-v2/woo-fi-math.js.map +0 -1
package/src/dex/index.ts
CHANGED
|
@@ -65,6 +65,7 @@ import { ZyberSwapV3 } from './quickswap/zyberswap-v3';
|
|
|
65
65
|
import { TraderJoeV2 } from './trader-joe-v2';
|
|
66
66
|
import { SpiritSwapV3 } from './quickswap/spiritswap-v3';
|
|
67
67
|
import { PancakeswapV3 } from './uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3';
|
|
68
|
+
import { TraderJoeV21 } from './trader-joe-v2.1';
|
|
68
69
|
|
|
69
70
|
const LegacyDexes = [
|
|
70
71
|
CurveV2,
|
|
@@ -84,6 +85,7 @@ const LegacyDexes = [
|
|
|
84
85
|
ZyberSwapV3,
|
|
85
86
|
SpiritSwapV3,
|
|
86
87
|
TraderJoeV2,
|
|
88
|
+
TraderJoeV21,
|
|
87
89
|
Jarvis,
|
|
88
90
|
Lido,
|
|
89
91
|
AugustusRFQOrder,
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Network, SwapSide } from '../constants';
|
|
2
|
+
import { AdapterExchangeParam, Address, SimpleExchangeParam } from '../types';
|
|
3
|
+
import { IDexTxBuilder } from './idex';
|
|
4
|
+
import { IDexHelper } from '../dex-helper';
|
|
5
|
+
import {
|
|
6
|
+
getLocalDeadlineAsFriendlyPlaceholder,
|
|
7
|
+
SimpleExchange,
|
|
8
|
+
} from './simple-exchange';
|
|
9
|
+
import { NumberAsString } from '@paraswap/core';
|
|
10
|
+
import { AsyncOrSync } from 'ts-essentials';
|
|
11
|
+
import { Interface, JsonFragment } from '@ethersproject/abi';
|
|
12
|
+
import TraderJoeV21RouterABI from '../abi/TraderJoeV21Router.json';
|
|
13
|
+
|
|
14
|
+
const TRADERJOE_V2_1_ROUTER_ADDRESS: { [network: number]: Address } = {
|
|
15
|
+
[Network.AVALANCHE]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
|
|
16
|
+
[Network.ARBITRUM]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
|
|
17
|
+
[Network.BSC]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type RouterPath = [
|
|
21
|
+
pairBinSteps: NumberAsString[],
|
|
22
|
+
versions: NumberAsString[],
|
|
23
|
+
tokenPath: Address[],
|
|
24
|
+
];
|
|
25
|
+
type TraderJoeV2RouterSellParams = [
|
|
26
|
+
_amountIn: NumberAsString,
|
|
27
|
+
_amountOutMin: NumberAsString,
|
|
28
|
+
_routerPath: RouterPath,
|
|
29
|
+
to: Address,
|
|
30
|
+
_deadline: string,
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
type TraderJoeV2RouterBuyParams = [
|
|
34
|
+
_amountOut: NumberAsString,
|
|
35
|
+
_amountInMax: NumberAsString,
|
|
36
|
+
_routerPath: RouterPath,
|
|
37
|
+
to: Address,
|
|
38
|
+
_deadline: string,
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
type TraderJoeV2RouterParam =
|
|
42
|
+
| TraderJoeV2RouterSellParams
|
|
43
|
+
| TraderJoeV2RouterBuyParams;
|
|
44
|
+
|
|
45
|
+
export type TraderJoeV2Data = {
|
|
46
|
+
tokenIn: string; // redundant
|
|
47
|
+
tokenOut: string; // redundant
|
|
48
|
+
binStep: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
enum TraderJoeV2RouterFunctions {
|
|
52
|
+
swapExactTokensForTokens = 'swapExactTokensForTokens',
|
|
53
|
+
swapTokensForExactTokens = 'swapTokensForExactTokens',
|
|
54
|
+
}
|
|
55
|
+
export class TraderJoeV21
|
|
56
|
+
extends SimpleExchange
|
|
57
|
+
implements IDexTxBuilder<TraderJoeV2Data, TraderJoeV2RouterParam>
|
|
58
|
+
{
|
|
59
|
+
static dexKeys = ['traderjoev2.1'];
|
|
60
|
+
protected routerAddress: string;
|
|
61
|
+
exchangeRouterInterface: Interface;
|
|
62
|
+
needWrapNative = true;
|
|
63
|
+
|
|
64
|
+
constructor(dexHelper: IDexHelper) {
|
|
65
|
+
super(dexHelper, 'traderjoev2.1');
|
|
66
|
+
|
|
67
|
+
this.routerAddress =
|
|
68
|
+
TRADERJOE_V2_1_ROUTER_ADDRESS[dexHelper.config.data.network];
|
|
69
|
+
|
|
70
|
+
this.exchangeRouterInterface = new Interface(
|
|
71
|
+
TraderJoeV21RouterABI as JsonFragment[],
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getAdapterParam(
|
|
76
|
+
srcToken: Address,
|
|
77
|
+
destToken: Address,
|
|
78
|
+
srcAmount: NumberAsString,
|
|
79
|
+
destAmount: NumberAsString,
|
|
80
|
+
data: TraderJoeV2Data,
|
|
81
|
+
side: SwapSide,
|
|
82
|
+
): AdapterExchangeParam {
|
|
83
|
+
let payload = this.abiCoder.encodeParameters(
|
|
84
|
+
['tuple(tuple(uint256[],uint8[],address[]),uint256)'],
|
|
85
|
+
[
|
|
86
|
+
[
|
|
87
|
+
[
|
|
88
|
+
[
|
|
89
|
+
data.binStep, // _pairBinSteps: uint256[]
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
2, // _versions: uint8[]
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
data.tokenIn,
|
|
96
|
+
data.tokenOut, // _tokenPath: address[]
|
|
97
|
+
],
|
|
98
|
+
],
|
|
99
|
+
getLocalDeadlineAsFriendlyPlaceholder(), // _deadline: uint256
|
|
100
|
+
],
|
|
101
|
+
],
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
targetExchange: this.routerAddress,
|
|
106
|
+
payload,
|
|
107
|
+
networkFee: '0',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
getSimpleParam(
|
|
112
|
+
srcToken: Address,
|
|
113
|
+
destToken: Address,
|
|
114
|
+
srcAmount: NumberAsString,
|
|
115
|
+
destAmount: NumberAsString,
|
|
116
|
+
data: TraderJoeV2Data,
|
|
117
|
+
side: SwapSide,
|
|
118
|
+
): AsyncOrSync<SimpleExchangeParam> {
|
|
119
|
+
const swapFunction =
|
|
120
|
+
side === SwapSide.SELL
|
|
121
|
+
? TraderJoeV2RouterFunctions.swapExactTokensForTokens
|
|
122
|
+
: TraderJoeV2RouterFunctions.swapTokensForExactTokens;
|
|
123
|
+
|
|
124
|
+
const swapFunctionParams: TraderJoeV2RouterParam =
|
|
125
|
+
side === SwapSide.SELL
|
|
126
|
+
? [
|
|
127
|
+
srcAmount,
|
|
128
|
+
destAmount,
|
|
129
|
+
[[data.binStep], ['2'], [srcToken, destToken]],
|
|
130
|
+
this.augustusAddress,
|
|
131
|
+
getLocalDeadlineAsFriendlyPlaceholder(),
|
|
132
|
+
]
|
|
133
|
+
: [
|
|
134
|
+
destAmount,
|
|
135
|
+
srcAmount,
|
|
136
|
+
[[data.binStep], ['2'], [srcToken, destToken]],
|
|
137
|
+
this.augustusAddress,
|
|
138
|
+
getLocalDeadlineAsFriendlyPlaceholder(),
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
const swapData = this.exchangeRouterInterface.encodeFunctionData(
|
|
142
|
+
swapFunction,
|
|
143
|
+
swapFunctionParams,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
return this.buildSimpleParamWithoutWETHConversion(
|
|
147
|
+
srcToken,
|
|
148
|
+
srcAmount,
|
|
149
|
+
destToken,
|
|
150
|
+
destAmount,
|
|
151
|
+
swapData,
|
|
152
|
+
this.routerAddress,
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|