@dhedge/v2-sdk 1.10.5 → 1.10.6
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/README.md +20 -0
- package/dist/entities/pool.d.ts +9 -0
- package/dist/services/oneInch/index.d.ts +4 -1
- package/dist/services/toros/easySwapper.d.ts +2 -1
- package/dist/test/constants.d.ts +7 -0
- package/dist/test/utils/testingHelper.d.ts +0 -1
- package/dist/v2-sdk.cjs.development.js +516 -1305
- package/dist/v2-sdk.cjs.development.js.map +1 -1
- package/dist/v2-sdk.cjs.production.min.js +1 -1
- package/dist/v2-sdk.cjs.production.min.js.map +1 -1
- package/dist/v2-sdk.esm.js +516 -1305
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/IDhedgeEasySwapper.json +184 -303
- package/src/config.ts +6 -4
- package/src/entities/pool.ts +33 -3
- package/src/services/oneInch/index.ts +9 -6
- package/src/services/toros/easySwapper.ts +64 -22
- package/src/test/constants.ts +11 -4
- package/src/test/toros.test.ts +81 -53
- package/src/test/utils/testingHelper.ts +3 -2
package/package.json
CHANGED
|
@@ -1,303 +1,184 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
],
|
|
186
|
-
"name": "depositQuote",
|
|
187
|
-
"outputs": [
|
|
188
|
-
{
|
|
189
|
-
"internalType": "uint256",
|
|
190
|
-
"name": "expectedLiquidityMinted",
|
|
191
|
-
"type": "uint256"
|
|
192
|
-
}
|
|
193
|
-
],
|
|
194
|
-
"stateMutability": "view",
|
|
195
|
-
"type": "function"
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
"inputs": [],
|
|
199
|
-
"name": "feeDenominator",
|
|
200
|
-
"outputs": [
|
|
201
|
-
{
|
|
202
|
-
"internalType": "uint256",
|
|
203
|
-
"name": "",
|
|
204
|
-
"type": "uint256"
|
|
205
|
-
}
|
|
206
|
-
],
|
|
207
|
-
"stateMutability": "view",
|
|
208
|
-
"type": "function"
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
"inputs": [],
|
|
212
|
-
"name": "feeNumerator",
|
|
213
|
-
"outputs": [
|
|
214
|
-
{
|
|
215
|
-
"internalType": "uint256",
|
|
216
|
-
"name": "",
|
|
217
|
-
"type": "uint256"
|
|
218
|
-
}
|
|
219
|
-
],
|
|
220
|
-
"stateMutability": "view",
|
|
221
|
-
"type": "function"
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
"inputs": [
|
|
225
|
-
{
|
|
226
|
-
"internalType": "address",
|
|
227
|
-
"name": "pool",
|
|
228
|
-
"type": "address"
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
"internalType": "uint256",
|
|
232
|
-
"name": "fundTokenAmount",
|
|
233
|
-
"type": "uint256"
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
"internalType": "contract IERC20Extended",
|
|
237
|
-
"name": "withdrawalAsset",
|
|
238
|
-
"type": "address"
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
"internalType": "uint256",
|
|
242
|
-
"name": "expectedAmountOut",
|
|
243
|
-
"type": "uint256"
|
|
244
|
-
}
|
|
245
|
-
],
|
|
246
|
-
"name": "withdraw",
|
|
247
|
-
"outputs": [],
|
|
248
|
-
"stateMutability": "nonpayable",
|
|
249
|
-
"type": "function"
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
"inputs": [
|
|
253
|
-
{
|
|
254
|
-
"internalType": "address",
|
|
255
|
-
"name": "pool",
|
|
256
|
-
"type": "address"
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
"internalType": "uint256",
|
|
260
|
-
"name": "fundTokenAmount",
|
|
261
|
-
"type": "uint256"
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
"internalType": "uint256",
|
|
265
|
-
"name": "expectedAmountOut",
|
|
266
|
-
"type": "uint256"
|
|
267
|
-
}
|
|
268
|
-
],
|
|
269
|
-
"name": "withdrawNative",
|
|
270
|
-
"outputs": [],
|
|
271
|
-
"stateMutability": "nonpayable",
|
|
272
|
-
"type": "function"
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
"inputs": [
|
|
276
|
-
{
|
|
277
|
-
"internalType": "address",
|
|
278
|
-
"name": "pool",
|
|
279
|
-
"type": "address"
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
"internalType": "uint256",
|
|
283
|
-
"name": "fundTokenAmount",
|
|
284
|
-
"type": "uint256"
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
"internalType": "contract IERC20Extended",
|
|
288
|
-
"name": "intermediateAsset",
|
|
289
|
-
"type": "address"
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
"internalType": "uint256",
|
|
293
|
-
"name": "expectedAmountSUSD",
|
|
294
|
-
"type": "uint256"
|
|
295
|
-
}
|
|
296
|
-
],
|
|
297
|
-
"name": "withdrawSUSD",
|
|
298
|
-
"outputs": [],
|
|
299
|
-
"stateMutability": "nonpayable",
|
|
300
|
-
"type": "function"
|
|
301
|
-
}
|
|
302
|
-
]
|
|
303
|
-
}
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"inputs": [
|
|
4
|
+
{
|
|
5
|
+
"components": [
|
|
6
|
+
{
|
|
7
|
+
"components": [
|
|
8
|
+
{
|
|
9
|
+
"internalType": "contract IERC20",
|
|
10
|
+
"name": "token",
|
|
11
|
+
"type": "address"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"internalType": "uint256",
|
|
15
|
+
"name": "amount",
|
|
16
|
+
"type": "uint256"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"components": [
|
|
20
|
+
{
|
|
21
|
+
"internalType": "bytes32",
|
|
22
|
+
"name": "routerKey",
|
|
23
|
+
"type": "bytes32"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"internalType": "bytes",
|
|
27
|
+
"name": "swapData",
|
|
28
|
+
"type": "bytes"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"internalType": "struct ISwapper.AggregatorData",
|
|
32
|
+
"name": "aggregatorData",
|
|
33
|
+
"type": "tuple"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"internalType": "struct ISwapper.SrcTokenSwapDetails[]",
|
|
37
|
+
"name": "srcData",
|
|
38
|
+
"type": "tuple[]"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"components": [
|
|
42
|
+
{
|
|
43
|
+
"internalType": "contract IERC20",
|
|
44
|
+
"name": "destToken",
|
|
45
|
+
"type": "address"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"internalType": "uint256",
|
|
49
|
+
"name": "minDestAmount",
|
|
50
|
+
"type": "uint256"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"internalType": "struct ISwapper.DestData",
|
|
54
|
+
"name": "destData",
|
|
55
|
+
"type": "tuple"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"internalType": "struct IWithdrawalVault.MultiInSingleOutData",
|
|
59
|
+
"name": "_swapData",
|
|
60
|
+
"type": "tuple"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"internalType": "uint256",
|
|
64
|
+
"name": "_expectedDestTokenAmount",
|
|
65
|
+
"type": "uint256"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"name": "completeWithdrawal",
|
|
69
|
+
"outputs": [],
|
|
70
|
+
"stateMutability": "nonpayable",
|
|
71
|
+
"type": "function"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"inputs": [
|
|
75
|
+
{
|
|
76
|
+
"internalType": "address",
|
|
77
|
+
"name": "_dHedgeVault",
|
|
78
|
+
"type": "address"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"internalType": "address",
|
|
82
|
+
"name": "_vaultDepositToken",
|
|
83
|
+
"type": "address"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"internalType": "uint256",
|
|
87
|
+
"name": "_depositAmount",
|
|
88
|
+
"type": "uint256"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"name": "depositQuote",
|
|
92
|
+
"outputs": [
|
|
93
|
+
{
|
|
94
|
+
"internalType": "uint256",
|
|
95
|
+
"name": "expectedAmountReceived",
|
|
96
|
+
"type": "uint256"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"stateMutability": "view",
|
|
100
|
+
"type": "function"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"inputs": [
|
|
104
|
+
{
|
|
105
|
+
"internalType": "address",
|
|
106
|
+
"name": "_dHedgeVault",
|
|
107
|
+
"type": "address"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"internalType": "contract IERC20",
|
|
111
|
+
"name": "_vaultDepositToken",
|
|
112
|
+
"type": "address"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"internalType": "uint256",
|
|
116
|
+
"name": "_depositAmount",
|
|
117
|
+
"type": "uint256"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"internalType": "uint256",
|
|
121
|
+
"name": "_expectedAmountReceived",
|
|
122
|
+
"type": "uint256"
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"name": "depositWithCustomCooldown",
|
|
126
|
+
"outputs": [],
|
|
127
|
+
"stateMutability": "nonpayable",
|
|
128
|
+
"type": "function"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"inputs": [
|
|
132
|
+
{
|
|
133
|
+
"internalType": "address",
|
|
134
|
+
"name": "_depositor",
|
|
135
|
+
"type": "address"
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"name": "getTrackedAssets",
|
|
139
|
+
"outputs": [
|
|
140
|
+
{
|
|
141
|
+
"components": [
|
|
142
|
+
{
|
|
143
|
+
"internalType": "address",
|
|
144
|
+
"name": "token",
|
|
145
|
+
"type": "address"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"internalType": "uint256",
|
|
149
|
+
"name": "balance",
|
|
150
|
+
"type": "uint256"
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
"internalType": "struct IWithdrawalVault.TrackedAsset[]",
|
|
154
|
+
"name": "trackedAssets_",
|
|
155
|
+
"type": "tuple[]"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"stateMutability": "view",
|
|
159
|
+
"type": "function"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"inputs": [
|
|
163
|
+
{
|
|
164
|
+
"internalType": "address",
|
|
165
|
+
"name": "_dHedgeVault",
|
|
166
|
+
"type": "address"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"internalType": "uint256",
|
|
170
|
+
"name": "_amountIn",
|
|
171
|
+
"type": "uint256"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"internalType": "uint256",
|
|
175
|
+
"name": "_slippageTolerance",
|
|
176
|
+
"type": "uint256"
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"name": "initWithdrawal",
|
|
180
|
+
"outputs": [],
|
|
181
|
+
"stateMutability": "nonpayable",
|
|
182
|
+
"type": "function"
|
|
183
|
+
}
|
|
184
|
+
]
|
package/src/config.ts
CHANGED
|
@@ -30,7 +30,7 @@ export const routerAddress: AddressDappNetworkMap = {
|
|
|
30
30
|
[Dapp.BALANCER]: "0xBA12222222228d8Ba445958a75a0704d566BF2C8",
|
|
31
31
|
[Dapp.UNISWAPV3]: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
|
|
32
32
|
[Dapp.ARRAKIS]: "0xc73fb100a995b33f9fa181d420f4c8d74506df66",
|
|
33
|
-
[Dapp.TOROS]: "
|
|
33
|
+
[Dapp.TOROS]: "0x45b90480D6F643dE2f128db091A357C3c90399f2",
|
|
34
34
|
[Dapp.ZEROEX]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff"
|
|
35
35
|
},
|
|
36
36
|
[Network.OPTIMISM]: {
|
|
@@ -38,7 +38,7 @@ export const routerAddress: AddressDappNetworkMap = {
|
|
|
38
38
|
[Dapp.SYNTHETIX]: "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4",
|
|
39
39
|
[Dapp.AAVEV3]: "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
|
|
40
40
|
[Dapp.ONEINCH]: "0x111111125421ca6dc452d289314280a0f8842a65",
|
|
41
|
-
[Dapp.TOROS]: "
|
|
41
|
+
[Dapp.TOROS]: "0x2Ed1bd7f66e47113672f3870308b5E867C5bb743",
|
|
42
42
|
[Dapp.VELODROME]: "0x9c12939390052919aF3155f41Bf4160Fd3666A6f",
|
|
43
43
|
[Dapp.VELODROMEV2]: "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858",
|
|
44
44
|
[Dapp.LYRA]: "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B",
|
|
@@ -51,13 +51,15 @@ export const routerAddress: AddressDappNetworkMap = {
|
|
|
51
51
|
[Dapp.AAVEV3]: "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
|
|
52
52
|
[Dapp.BALANCER]: "0xBA12222222228d8Ba445958a75a0704d566BF2C8",
|
|
53
53
|
[Dapp.RAMSES]: "0xaaa87963efeb6f7e0a2711f397663105acb1805e",
|
|
54
|
-
[Dapp.ZEROEX]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff"
|
|
54
|
+
[Dapp.ZEROEX]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
|
55
|
+
[Dapp.TOROS]: "0xA5679C4272A056Bb83f039961fae7D99C48529F5"
|
|
55
56
|
},
|
|
56
57
|
[Network.BASE]: {
|
|
57
58
|
[Dapp.ONEINCH]: "0x111111125421ca6dc452d289314280a0f8842a65",
|
|
58
59
|
[Dapp.ZEROEX]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
|
59
60
|
[Dapp.AERODROME]: "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43",
|
|
60
|
-
[Dapp.AAVEV3]: "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5"
|
|
61
|
+
[Dapp.AAVEV3]: "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5",
|
|
62
|
+
[Dapp.TOROS]: "0xf067575Eb60c7587C11e867907AA7284833704d1"
|
|
61
63
|
}
|
|
62
64
|
};
|
|
63
65
|
|
package/src/entities/pool.ts
CHANGED
|
@@ -40,7 +40,10 @@ import {
|
|
|
40
40
|
getUniswapV3MintTxData
|
|
41
41
|
} from "../services/uniswap/V3Liquidity";
|
|
42
42
|
import { getUniswapV3SwapTxData } from "../services/uniswap/V3Trade";
|
|
43
|
-
import {
|
|
43
|
+
import {
|
|
44
|
+
getCompleteWithdrawalTxData,
|
|
45
|
+
getEasySwapperTxData
|
|
46
|
+
} from "../services/toros/easySwapper";
|
|
44
47
|
import { getAaveV3ClaimTxData } from "../services/aave/incentives";
|
|
45
48
|
import {
|
|
46
49
|
getVelodromeAddLiquidityTxData,
|
|
@@ -371,13 +374,13 @@ export class Pool {
|
|
|
371
374
|
);
|
|
372
375
|
break;
|
|
373
376
|
case Dapp.ONEINCH:
|
|
374
|
-
swapTxData = await getOneInchSwapTxData(
|
|
377
|
+
({ swapTxData } = await getOneInchSwapTxData(
|
|
375
378
|
this,
|
|
376
379
|
assetFrom,
|
|
377
380
|
assetTo,
|
|
378
381
|
amountIn,
|
|
379
382
|
slippage
|
|
380
|
-
);
|
|
383
|
+
));
|
|
381
384
|
break;
|
|
382
385
|
case Dapp.BALANCER:
|
|
383
386
|
swapTxData = await this.utils.getBalancerSwapTx(
|
|
@@ -1842,4 +1845,31 @@ export class Pool {
|
|
|
1842
1845
|
const tx = await cancelOrderViaFlatMoney(this, options, estimateGas);
|
|
1843
1846
|
return tx;
|
|
1844
1847
|
}
|
|
1848
|
+
|
|
1849
|
+
/**
|
|
1850
|
+
* Complete a Toros withdrawal to a single asset
|
|
1851
|
+
* @param {string} destinationToken Address of destination asset
|
|
1852
|
+
* @param {number} slippage Slippage tolerance in %
|
|
1853
|
+
* @param {any} options Transaction options
|
|
1854
|
+
* @param {boolean} estimateGas Simulate/estimate gas
|
|
1855
|
+
* @returns {Promise<any>} Transaction
|
|
1856
|
+
*/
|
|
1857
|
+
async completeTorosWithdrawal(
|
|
1858
|
+
destinationToken: string,
|
|
1859
|
+
slippage = 0.5,
|
|
1860
|
+
options: any = null,
|
|
1861
|
+
estimateGas = false
|
|
1862
|
+
): Promise<any> {
|
|
1863
|
+
const txData = await getCompleteWithdrawalTxData(
|
|
1864
|
+
this,
|
|
1865
|
+
destinationToken,
|
|
1866
|
+
slippage
|
|
1867
|
+
);
|
|
1868
|
+
const tx = await getPoolTxOrGasEstimate(
|
|
1869
|
+
this,
|
|
1870
|
+
[routerAddress[this.network].toros, txData, options],
|
|
1871
|
+
estimateGas
|
|
1872
|
+
);
|
|
1873
|
+
return tx;
|
|
1874
|
+
}
|
|
1845
1875
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
import { ApiError, ethers } from "../..";
|
|
4
|
-
import { networkChainIdMap } from "../../config";
|
|
4
|
+
import { networkChainIdMap, routerAddress } from "../../config";
|
|
5
5
|
import { Pool } from "../../entities";
|
|
6
6
|
|
|
7
7
|
const oneInchBaseUrl = "https://api.1inch.dev/swap/v6.0/";
|
|
@@ -11,8 +11,9 @@ export async function getOneInchSwapTxData(
|
|
|
11
11
|
assetFrom: string,
|
|
12
12
|
assetTo: string,
|
|
13
13
|
amountIn: ethers.BigNumber | string,
|
|
14
|
-
slippage: number
|
|
15
|
-
|
|
14
|
+
slippage: number,
|
|
15
|
+
forEasySwapper = false
|
|
16
|
+
): Promise<{ swapTxData: string; dstAmount: string }> {
|
|
16
17
|
if (!process.env.ONEINCH_API_KEY)
|
|
17
18
|
throw new Error("ONEINCH_API_KEY not configured in .env file");
|
|
18
19
|
|
|
@@ -22,8 +23,8 @@ export async function getOneInchSwapTxData(
|
|
|
22
23
|
src: assetFrom,
|
|
23
24
|
dst: assetTo,
|
|
24
25
|
amount: amountIn.toString(),
|
|
25
|
-
from: pool.address,
|
|
26
|
-
|
|
26
|
+
from: forEasySwapper ? routerAddress[pool.network].toros : pool.address,
|
|
27
|
+
receiver: forEasySwapper ? routerAddress[pool.network].toros : pool.address,
|
|
27
28
|
slippage: slippage,
|
|
28
29
|
disableEstimate: true,
|
|
29
30
|
usePermit2: false
|
|
@@ -35,7 +36,9 @@ export async function getOneInchSwapTxData(
|
|
|
35
36
|
},
|
|
36
37
|
params
|
|
37
38
|
});
|
|
38
|
-
|
|
39
|
+
const swapTxData = response.data.tx.data;
|
|
40
|
+
const dstAmount = response.data.dstAmount;
|
|
41
|
+
return { swapTxData, dstAmount };
|
|
39
42
|
} catch (e) {
|
|
40
43
|
throw new ApiError("Swap api request of 1inch failed");
|
|
41
44
|
}
|