@1delta/calldatalib 0.0.37 → 0.0.39
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/dist/cjs/CalldataLib.js +562 -68
- package/dist/cjs/utils.js +3 -5
- package/dist/esm/CalldataLib.js +560 -68
- package/dist/esm/utils.js +3 -5
- package/dist/types/CalldataLib.d.ts +4 -1
- package/dist/types/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/CalldataLib.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// @ts-nocheck
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.DexForkMappings = exports.DexTypeMappings = exports.BridgeIds = exports.ComposerCommands = exports.Gen2025ActionIds = exports.ERC4626Ids = exports.FlashLoanIds = exports.LenderOps = exports.LenderIds = exports.PermitIds = exports.TransferIds = exports.WrapOperation = exports.DodoSelector = exports.DexPayConfig = exports.SweepType = void 0;
|
|
5
4
|
exports.encodeExternalCall = encodeExternalCall;
|
|
@@ -11,6 +10,8 @@ exports.encodeStargateV2BridgeSimpleTaxi = encodeStargateV2BridgeSimpleTaxi;
|
|
|
11
10
|
exports.encodeStargateV2BridgeSimpleBus = encodeStargateV2BridgeSimpleBus;
|
|
12
11
|
exports.encodeAcrossBridgeToken = encodeAcrossBridgeToken;
|
|
13
12
|
exports.encodeAcrossBridgeNative = encodeAcrossBridgeNative;
|
|
13
|
+
exports.encodeSquidRouterCall = encodeSquidRouterCall;
|
|
14
|
+
exports.encodeSquidRouterCallPartial = encodeSquidRouterCallPartial;
|
|
14
15
|
exports.encodePermit2TransferFrom = encodePermit2TransferFrom;
|
|
15
16
|
exports.encodeNextGenDexUnlock = encodeNextGenDexUnlock;
|
|
16
17
|
exports.encodeBalancerV3FlashLoan = encodeBalancerV3FlashLoan;
|
|
@@ -72,6 +73,7 @@ exports.encodeCompoundV2Deposit = encodeCompoundV2Deposit;
|
|
|
72
73
|
exports.encodeCompoundV2Borrow = encodeCompoundV2Borrow;
|
|
73
74
|
exports.encodeCompoundV2Repay = encodeCompoundV2Repay;
|
|
74
75
|
exports.encodeCompoundV2Withdraw = encodeCompoundV2Withdraw;
|
|
76
|
+
// @ts-nocheck
|
|
75
77
|
const viem_1 = require("viem");
|
|
76
78
|
const utils_js_1 = require("./utils.js");
|
|
77
79
|
var SweepType;
|
|
@@ -167,6 +169,7 @@ var BridgeIds;
|
|
|
167
169
|
(function (BridgeIds) {
|
|
168
170
|
BridgeIds[BridgeIds["STARGATE_V2"] = 0] = "STARGATE_V2";
|
|
169
171
|
BridgeIds[BridgeIds["ACROSS"] = 10] = "ACROSS";
|
|
172
|
+
BridgeIds[BridgeIds["SQUID_ROUTER"] = 20] = "SQUID_ROUTER";
|
|
170
173
|
})(BridgeIds || (exports.BridgeIds = BridgeIds = {}));
|
|
171
174
|
var DexTypeMappings;
|
|
172
175
|
(function (DexTypeMappings) {
|
|
@@ -200,20 +203,53 @@ var DexForkMappings;
|
|
|
200
203
|
DexForkMappings[DexForkMappings["UNISWAP_V2"] = 0] = "UNISWAP_V2";
|
|
201
204
|
})(DexForkMappings || (exports.DexForkMappings = DexForkMappings = {}));
|
|
202
205
|
function encodeExternalCall(target, value, useSelfBalance, data) {
|
|
203
|
-
return (0, utils_js_1.encodePacked)([
|
|
206
|
+
return (0, utils_js_1.encodePacked)(["uint8", "address", "uint128", "uint16", "bytes"], [
|
|
207
|
+
(0, utils_js_1.uint8)(ComposerCommands.EXT_CALL),
|
|
208
|
+
target,
|
|
209
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(value), false, useSelfBalance),
|
|
210
|
+
(0, utils_js_1.uint16)(data.length / 2 - 1),
|
|
211
|
+
data,
|
|
212
|
+
]);
|
|
204
213
|
}
|
|
205
214
|
function encodeTryExternalCall(target, value, useSelfBalance, rOnFailure, data, catchData) {
|
|
206
|
-
return (0, utils_js_1.encodePacked)([
|
|
215
|
+
return (0, utils_js_1.encodePacked)(["uint8", "address", "uint128", "uint16", "bytes", "uint8", "uint16", "bytes"], [
|
|
216
|
+
(0, utils_js_1.uint8)(ComposerCommands.EXT_TRY_CALL),
|
|
217
|
+
target,
|
|
218
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(value), false, useSelfBalance),
|
|
219
|
+
(0, utils_js_1.uint16)(data.length / 2 - 1),
|
|
220
|
+
data,
|
|
221
|
+
(0, utils_js_1.uint8)(rOnFailure ? 0 : 1),
|
|
222
|
+
(0, utils_js_1.uint16)(catchData.length / 2 - 1),
|
|
223
|
+
catchData,
|
|
224
|
+
]);
|
|
207
225
|
}
|
|
208
226
|
function encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions) {
|
|
209
227
|
const partialData = encodeStargateV2BridgePartial(amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions);
|
|
210
|
-
return (0, utils_js_1.encodePacked)([
|
|
228
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "uint32", "bytes32", "address", "bytes"], [
|
|
229
|
+
(0, utils_js_1.uint8)(ComposerCommands.BRIDGING),
|
|
230
|
+
(0, utils_js_1.uint8)(BridgeIds.STARGATE_V2),
|
|
231
|
+
asset,
|
|
232
|
+
stargatePool,
|
|
233
|
+
dstEid,
|
|
234
|
+
receiver,
|
|
235
|
+
refundReceiver,
|
|
236
|
+
partialData,
|
|
237
|
+
]);
|
|
211
238
|
}
|
|
212
239
|
function encodePermit(permitId, target, data) {
|
|
213
|
-
return (0, utils_js_1.encodePacked)([
|
|
240
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "uint16", "bytes"], [(0, utils_js_1.uint8)(ComposerCommands.PERMIT), (0, utils_js_1.uint8)(permitId), target, (0, utils_js_1.uint16)(data.length / 2 - 1), data]);
|
|
214
241
|
}
|
|
215
242
|
function encodeStargateV2BridgePartial(amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions) {
|
|
216
|
-
return (0, utils_js_1.encodePacked)([
|
|
243
|
+
return (0, utils_js_1.encodePacked)(["uint128", "uint32", "uint128", "uint8", "uint16", "uint16", "bytes", "bytes"], [
|
|
244
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, isNative),
|
|
245
|
+
slippage,
|
|
246
|
+
(0, utils_js_1.uint128)(fee),
|
|
247
|
+
(0, utils_js_1.uint8)(isBusMode ? 1 : 0),
|
|
248
|
+
(0, utils_js_1.uint16)(composeMsg.length / 2 - 1),
|
|
249
|
+
(0, utils_js_1.uint16)(extraOptions.length / 2 - 1),
|
|
250
|
+
composeMsg,
|
|
251
|
+
extraOptions,
|
|
252
|
+
]);
|
|
217
253
|
}
|
|
218
254
|
function encodeStargateV2BridgeSimpleTaxi(asset, stargatePool, dstEid, receiver, refundReceiver, amount, isNative, slippage, fee) {
|
|
219
255
|
return encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, false, isNative, (0, utils_js_1.newbytes)(0), (0, utils_js_1.newbytes)(0));
|
|
@@ -222,18 +258,107 @@ function encodeStargateV2BridgeSimpleBus(asset, stargatePool, dstEid, receiver,
|
|
|
222
258
|
return encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, true, isNative, (0, utils_js_1.newbytes)(0), (0, utils_js_1.newbytes)(0));
|
|
223
259
|
}
|
|
224
260
|
function encodeAcrossBridgeToken(spokePool, depositor, sendingAssetId, receivingAssetId, amount, fixedFee, feePercentage, destinationChainId, receiver, message) {
|
|
225
|
-
const bridgeData = (0, utils_js_1.encodePacked)([
|
|
261
|
+
const bridgeData = (0, utils_js_1.encodePacked)([
|
|
262
|
+
"uint8",
|
|
263
|
+
"uint8",
|
|
264
|
+
"address",
|
|
265
|
+
"address",
|
|
266
|
+
"address",
|
|
267
|
+
"bytes32",
|
|
268
|
+
"uint128",
|
|
269
|
+
"uint128",
|
|
270
|
+
"uint32",
|
|
271
|
+
"uint32",
|
|
272
|
+
"bytes32",
|
|
273
|
+
"uint16",
|
|
274
|
+
"bytes",
|
|
275
|
+
], [
|
|
276
|
+
(0, utils_js_1.uint8)(ComposerCommands.BRIDGING),
|
|
277
|
+
(0, utils_js_1.uint8)(BridgeIds.ACROSS),
|
|
278
|
+
spokePool,
|
|
279
|
+
depositor,
|
|
280
|
+
sendingAssetId,
|
|
281
|
+
receivingAssetId,
|
|
282
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, false),
|
|
283
|
+
fixedFee,
|
|
284
|
+
feePercentage,
|
|
285
|
+
destinationChainId,
|
|
286
|
+
receiver,
|
|
287
|
+
(0, utils_js_1.uint16)(message.length / 2 - 1),
|
|
288
|
+
message,
|
|
289
|
+
]);
|
|
226
290
|
return bridgeData;
|
|
227
291
|
}
|
|
228
292
|
function encodeAcrossBridgeNative(spokePool, depositor, sendingAssetId, receivingAssetId, amount, fixedFee, feePercentage, destinationChainId, receiver, message) {
|
|
229
|
-
const bridgeData = (0, utils_js_1.encodePacked)([
|
|
293
|
+
const bridgeData = (0, utils_js_1.encodePacked)([
|
|
294
|
+
"uint8",
|
|
295
|
+
"uint8",
|
|
296
|
+
"address",
|
|
297
|
+
"address",
|
|
298
|
+
"address",
|
|
299
|
+
"bytes32",
|
|
300
|
+
"uint128",
|
|
301
|
+
"uint128",
|
|
302
|
+
"uint32",
|
|
303
|
+
"uint32",
|
|
304
|
+
"bytes32",
|
|
305
|
+
"uint16",
|
|
306
|
+
"bytes",
|
|
307
|
+
], [
|
|
308
|
+
(0, utils_js_1.uint8)(ComposerCommands.BRIDGING),
|
|
309
|
+
(0, utils_js_1.uint8)(BridgeIds.ACROSS),
|
|
310
|
+
spokePool,
|
|
311
|
+
depositor,
|
|
312
|
+
sendingAssetId,
|
|
313
|
+
receivingAssetId,
|
|
314
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, true),
|
|
315
|
+
fixedFee,
|
|
316
|
+
feePercentage,
|
|
317
|
+
destinationChainId,
|
|
318
|
+
receiver,
|
|
319
|
+
(0, utils_js_1.uint16)(message.length / 2 - 1),
|
|
320
|
+
message,
|
|
321
|
+
]);
|
|
230
322
|
return bridgeData;
|
|
231
323
|
}
|
|
324
|
+
function encodeSquidRouterCall(asset, gateway, bridgedTokenSymbol, amount, destinationChain, destinationAddress, payload, gasRefundRecipient, enableExpress, nativeAmount) {
|
|
325
|
+
const partialData = encodeSquidRouterCallPartial(asset, gateway, bridgedTokenSymbol, amount, destinationChain, destinationAddress, payload);
|
|
326
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint128", "address", "uint8", "bytes", "bytes", "bytes", "bytes"], [
|
|
327
|
+
partialData,
|
|
328
|
+
(0, utils_js_1.uint128)(nativeAmount),
|
|
329
|
+
gasRefundRecipient,
|
|
330
|
+
(0, utils_js_1.uint8)(enableExpress ? 1 : 0),
|
|
331
|
+
bridgedTokenSymbol,
|
|
332
|
+
destinationChain,
|
|
333
|
+
destinationAddress,
|
|
334
|
+
payload,
|
|
335
|
+
]);
|
|
336
|
+
}
|
|
337
|
+
function encodeSquidRouterCallPartial(asset, gateway, bridgedTokenSymbol, amount, destinationChain, destinationAddress, payload) {
|
|
338
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "uint16", "uint16", "uint16", "uint16", "uint128"], [
|
|
339
|
+
(0, utils_js_1.uint8)(ComposerCommands.BRIDGING),
|
|
340
|
+
(0, utils_js_1.uint8)(BridgeIds.SQUID_ROUTER),
|
|
341
|
+
gateway,
|
|
342
|
+
asset,
|
|
343
|
+
(0, utils_js_1.uint16)(bridgedTokenSymbol.length / 2 - 1),
|
|
344
|
+
(0, utils_js_1.uint16)(destinationChain.length / 2 - 1),
|
|
345
|
+
(0, utils_js_1.uint16)(destinationAddress.length / 2 - 1),
|
|
346
|
+
(0, utils_js_1.uint16)(payload.length / 2 - 1),
|
|
347
|
+
(0, utils_js_1.uint128)(amount),
|
|
348
|
+
]);
|
|
349
|
+
}
|
|
232
350
|
function encodePermit2TransferFrom(token, receiver, amount) {
|
|
233
|
-
return (0, utils_js_1.encodePacked)([
|
|
351
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "uint128"], [(0, utils_js_1.uint8)(ComposerCommands.TRANSFERS), (0, utils_js_1.uint8)(TransferIds.PERMIT2_TRANSFER_FROM), token, receiver, (0, utils_js_1.uint128)(amount)]);
|
|
234
352
|
}
|
|
235
353
|
function encodeNextGenDexUnlock(singleton, id, d) {
|
|
236
|
-
return (0, utils_js_1.encodePacked)([
|
|
354
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "uint16", "uint8", "bytes"], [
|
|
355
|
+
(0, utils_js_1.uint8)(ComposerCommands.GEN_2025_SINGELTONS),
|
|
356
|
+
(0, utils_js_1.uint8)(Gen2025ActionIds.UNLOCK),
|
|
357
|
+
singleton,
|
|
358
|
+
(0, utils_js_1.uint16)(d.length / 2 - 1 + 1),
|
|
359
|
+
(0, utils_js_1.uint8)(id),
|
|
360
|
+
d,
|
|
361
|
+
]);
|
|
237
362
|
}
|
|
238
363
|
function encodeBalancerV3FlashLoan(singleton, poolId, asset, receiver, amount, flashData) {
|
|
239
364
|
const take = encodeBalancerV3Take(singleton, asset, receiver, amount);
|
|
@@ -241,7 +366,7 @@ function encodeBalancerV3FlashLoan(singleton, poolId, asset, receiver, amount, f
|
|
|
241
366
|
return encodeNextGenDexUnlock(singleton, poolId, encodeBalancerV3FlashLoanData(take, flashData, settle));
|
|
242
367
|
}
|
|
243
368
|
function encodeBalancerV3FlashLoanData(take, flashData, settle) {
|
|
244
|
-
return (0, utils_js_1.encodePacked)([
|
|
369
|
+
return (0, utils_js_1.encodePacked)(["bytes", "bytes", "bytes"], [take, flashData, settle]);
|
|
245
370
|
}
|
|
246
371
|
function encodeUniswapV4FlashLoan(singleton, poolId, asset, receiver, amount, flashData) {
|
|
247
372
|
const take = encodeUniswapV4Take(singleton, asset, receiver, amount);
|
|
@@ -250,201 +375,570 @@ function encodeUniswapV4FlashLoan(singleton, poolId, asset, receiver, amount, fl
|
|
|
250
375
|
return encodeNextGenDexUnlock(singleton, poolId, encodeUniswapV4FlashLoanData(take, sync, flashData, settle));
|
|
251
376
|
}
|
|
252
377
|
function encodeUniswapV4FlashLoanData(take, sync, flashData, settle) {
|
|
253
|
-
return (0, utils_js_1.encodePacked)([
|
|
378
|
+
return (0, utils_js_1.encodePacked)(["bytes", "bytes", "bytes", "bytes"], [take, sync, flashData, settle]);
|
|
254
379
|
}
|
|
255
380
|
function encodeBalancerV3Take(singleton, asset, receiver, amount) {
|
|
256
|
-
return (0, utils_js_1.encodePacked)([
|
|
381
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "address", "uint128"], [
|
|
382
|
+
(0, utils_js_1.uint8)(ComposerCommands.GEN_2025_SINGELTONS),
|
|
383
|
+
(0, utils_js_1.uint8)(Gen2025ActionIds.BAL_V3_TAKE),
|
|
384
|
+
singleton,
|
|
385
|
+
asset,
|
|
386
|
+
receiver,
|
|
387
|
+
(0, utils_js_1.uint128)(amount),
|
|
388
|
+
]);
|
|
257
389
|
}
|
|
258
390
|
function encodeUniswapV4Sync(singleton, asset) {
|
|
259
391
|
if (asset === viem_1.zeroAddress)
|
|
260
392
|
return `0x0`;
|
|
261
|
-
;
|
|
262
|
-
return (0, utils_js_1.encodePacked)(['uint8', 'uint8', 'address', 'address'], [(0, utils_js_1.uint8)(ComposerCommands.GEN_2025_SINGELTONS), (0, utils_js_1.uint8)(Gen2025ActionIds.UNI_V4_SYNC), singleton, asset]);
|
|
393
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address"], [(0, utils_js_1.uint8)(ComposerCommands.GEN_2025_SINGELTONS), (0, utils_js_1.uint8)(Gen2025ActionIds.UNI_V4_SYNC), singleton, asset]);
|
|
263
394
|
}
|
|
264
395
|
function encodeUniswapV4Take(singleton, asset, receiver, amount) {
|
|
265
|
-
return (0, utils_js_1.encodePacked)([
|
|
396
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "address", "uint128"], [
|
|
397
|
+
(0, utils_js_1.uint8)(ComposerCommands.GEN_2025_SINGELTONS),
|
|
398
|
+
(0, utils_js_1.uint8)(Gen2025ActionIds.UNI_V4_TAKE),
|
|
399
|
+
singleton,
|
|
400
|
+
asset,
|
|
401
|
+
receiver,
|
|
402
|
+
(0, utils_js_1.uint128)(amount),
|
|
403
|
+
]);
|
|
266
404
|
}
|
|
267
405
|
function swapHead(amount, amountOutMin, assetIn) {
|
|
268
|
-
return (0, utils_js_1.encodePacked)([
|
|
406
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint128", "uint128", "address"], [
|
|
407
|
+
(0, utils_js_1.uint8)(ComposerCommands.SWAPS),
|
|
408
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, false),
|
|
409
|
+
(0, utils_js_1.uint128)(amountOutMin),
|
|
410
|
+
assetIn,
|
|
411
|
+
]);
|
|
269
412
|
}
|
|
270
413
|
function attachBranch(data, hops, splits, splitsData) {
|
|
271
414
|
if (hops !== 0n && splits !== 0n)
|
|
272
415
|
throw new Error("Invalidbranching");
|
|
273
416
|
if (splitsData.length / 2 - 1 > 0 && splits === 0n)
|
|
274
417
|
throw new Error("Nosplitsbutsplitdataprovided");
|
|
275
|
-
return (0, utils_js_1.encodePacked)([
|
|
418
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "bytes"], [data, (0, utils_js_1.uint8)(hops), (0, utils_js_1.uint8)(splits), splitsData]);
|
|
276
419
|
}
|
|
277
420
|
function encodeUniswapV2StyleSwap(tokenOut, receiver, forkId, pool, feeDenom, cfg, flashCalldata) {
|
|
278
421
|
if ((0, utils_js_1.uint256)(cfg) < 2 && flashCalldata.length / 2 - 1 > 2)
|
|
279
422
|
throw new Error("Invalidconfigforv2swap");
|
|
280
|
-
return (0, utils_js_1.encodePacked)([
|
|
423
|
+
return (0, utils_js_1.encodePacked)(["address", "address", "uint8", "address", "uint16", "uint8", "uint16", "bytes"], [
|
|
424
|
+
tokenOut,
|
|
425
|
+
receiver,
|
|
426
|
+
(0, utils_js_1.uint8)(DexTypeMappings.UNISWAP_V2_ID),
|
|
427
|
+
pool,
|
|
428
|
+
(0, utils_js_1.uint16)(feeDenom),
|
|
429
|
+
(0, utils_js_1.uint8)(forkId),
|
|
430
|
+
(0, utils_js_1.uint16)(cfg === DexPayConfig.FLASH ? flashCalldata.length / 2 - 1 : (0, utils_js_1.uint256)(cfg)),
|
|
431
|
+
(0, utils_js_1.bytes)(cfg === DexPayConfig.FLASH ? flashCalldata : (0, utils_js_1.newbytes)(0)),
|
|
432
|
+
]);
|
|
281
433
|
}
|
|
282
434
|
function encodeUniswapV4StyleSwap(currentData, tokenOut, receiver, manager, fee, tickSpacing, hooks, hookData, cfg) {
|
|
283
435
|
if (cfg === DexPayConfig.FLASH)
|
|
284
436
|
throw new Error("Invalidconfigforv2swap");
|
|
285
|
-
return (0, utils_js_1.encodePacked)([
|
|
437
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "address", "address", "uint24", "uint24", "uint8", "uint16", "bytes"], [
|
|
438
|
+
currentData,
|
|
439
|
+
tokenOut,
|
|
440
|
+
receiver,
|
|
441
|
+
(0, utils_js_1.uint8)(DexTypeMappings.UNISWAP_V4_ID),
|
|
442
|
+
hooks,
|
|
443
|
+
manager,
|
|
444
|
+
fee,
|
|
445
|
+
tickSpacing,
|
|
446
|
+
(0, utils_js_1.uint8)((0, utils_js_1.uint256)(cfg)),
|
|
447
|
+
(0, utils_js_1.uint16)(hookData.length / 2 - 1),
|
|
448
|
+
hookData,
|
|
449
|
+
]);
|
|
286
450
|
}
|
|
287
451
|
function encodeBalancerV2StyleSwap(currentData, tokenOut, receiver, poolId, balancerVault, cfg) {
|
|
288
452
|
if (cfg === DexPayConfig.FLASH)
|
|
289
453
|
throw new Error("Invalidconfigforv2swap");
|
|
290
|
-
return (0, utils_js_1.encodePacked)([
|
|
454
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "bytes32", "address", "uint8"], [
|
|
455
|
+
currentData,
|
|
456
|
+
tokenOut,
|
|
457
|
+
receiver,
|
|
458
|
+
(0, utils_js_1.uint8)(DexTypeMappings.BALANCER_V2_ID),
|
|
459
|
+
poolId,
|
|
460
|
+
balancerVault,
|
|
461
|
+
(0, utils_js_1.uint8)((0, utils_js_1.uint256)(cfg)),
|
|
462
|
+
]);
|
|
291
463
|
}
|
|
292
464
|
function encodeLbStyleSwap(currentData, tokenOut, receiver, pool, swapForY, cfg) {
|
|
293
465
|
if (cfg === DexPayConfig.FLASH)
|
|
294
466
|
throw new Error("Invalidconfigforv2swap");
|
|
295
|
-
return (0, utils_js_1.encodePacked)([
|
|
467
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "address", "uint8", "uint8"], [currentData, tokenOut, receiver, (0, utils_js_1.uint8)(DexTypeMappings.LB_ID), pool, (0, utils_js_1.uint8)(swapForY ? 1 : 0), (0, utils_js_1.uint8)((0, utils_js_1.uint256)(cfg))]);
|
|
296
468
|
}
|
|
297
469
|
function encodeSyncSwapStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
|
|
298
470
|
if (cfg === DexPayConfig.FLASH)
|
|
299
471
|
throw new Error("Invalidconfigforv2swap");
|
|
300
|
-
return (0, utils_js_1.encodePacked)([
|
|
472
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, (0, utils_js_1.uint8)(DexTypeMappings.SYNC_SWAP_ID), pool, (0, utils_js_1.uint8)((0, utils_js_1.uint256)(cfg))]);
|
|
301
473
|
}
|
|
302
474
|
function encodeUniswapV3StyleSwap(currentData, tokenOut, receiver, forkId, pool, feeTier, cfg, flashCalldata) {
|
|
303
475
|
if ((0, utils_js_1.uint256)(cfg) < 2 && flashCalldata.length / 2 - 1 > 2)
|
|
304
476
|
throw new Error("Invalidconfigforv2swap");
|
|
305
|
-
return (0, utils_js_1.encodePacked)([
|
|
477
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "address", "uint8", "uint16", "uint16", "bytes"], [
|
|
478
|
+
currentData,
|
|
479
|
+
tokenOut,
|
|
480
|
+
receiver,
|
|
481
|
+
(0, utils_js_1.uint8)(DexTypeMappings.UNISWAP_V3_ID),
|
|
482
|
+
pool,
|
|
483
|
+
(0, utils_js_1.uint8)(forkId),
|
|
484
|
+
(0, utils_js_1.uint16)(feeTier),
|
|
485
|
+
(0, utils_js_1.uint16)(cfg === DexPayConfig.FLASH ? flashCalldata.length / 2 - 1 : (0, utils_js_1.uint256)(cfg)),
|
|
486
|
+
(0, utils_js_1.bytes)(cfg === DexPayConfig.FLASH ? flashCalldata : (0, utils_js_1.newbytes)(0)),
|
|
487
|
+
]);
|
|
306
488
|
}
|
|
307
489
|
function encodeIzumiStyleSwap(currentData, tokenOut, receiver, forkId, pool, feeTier, cfg, flashCalldata) {
|
|
308
490
|
if ((0, utils_js_1.uint256)(cfg) < 2 && flashCalldata.length / 2 - 1 > 2)
|
|
309
491
|
throw new Error("Invalidconfigforv2swap");
|
|
310
|
-
return (0, utils_js_1.encodePacked)([
|
|
492
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "address", "uint8", "uint16", "uint16", "bytes"], [
|
|
493
|
+
currentData,
|
|
494
|
+
tokenOut,
|
|
495
|
+
receiver,
|
|
496
|
+
(0, utils_js_1.uint8)(DexTypeMappings.IZI_ID),
|
|
497
|
+
pool,
|
|
498
|
+
(0, utils_js_1.uint8)(forkId),
|
|
499
|
+
(0, utils_js_1.uint16)(feeTier),
|
|
500
|
+
(0, utils_js_1.uint16)(cfg === DexPayConfig.FLASH ? flashCalldata.length / 2 - 1 : (0, utils_js_1.uint256)(cfg)),
|
|
501
|
+
(0, utils_js_1.bytes)(cfg === DexPayConfig.FLASH ? flashCalldata : (0, utils_js_1.newbytes)(0)),
|
|
502
|
+
]);
|
|
311
503
|
}
|
|
312
504
|
function encodeBalancerV3StyleSwap(currentData, tokenOut, receiver, balancerV3Vault, pool, cfg, poolUserData) {
|
|
313
|
-
return (0, utils_js_1.encodePacked)([
|
|
505
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "address", "address", "uint8", "uint16", "bytes"], [
|
|
506
|
+
currentData,
|
|
507
|
+
tokenOut,
|
|
508
|
+
receiver,
|
|
509
|
+
(0, utils_js_1.uint8)(DexTypeMappings.BALANCER_V3_ID),
|
|
510
|
+
pool,
|
|
511
|
+
balancerV3Vault,
|
|
512
|
+
(0, utils_js_1.uint8)(cfg),
|
|
513
|
+
(0, utils_js_1.uint16)(poolUserData.length / 2 - 1),
|
|
514
|
+
poolUserData,
|
|
515
|
+
]);
|
|
314
516
|
}
|
|
315
517
|
function encodeDodoStyleSwap(currentData, tokenOut, receiver, pool, selector, poolId, cfg, flashCalldata) {
|
|
316
|
-
return (0, utils_js_1.encodePacked)([
|
|
518
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "address", "uint8", "uint16", "uint16", "bytes"], [
|
|
519
|
+
currentData,
|
|
520
|
+
tokenOut,
|
|
521
|
+
receiver,
|
|
522
|
+
(0, utils_js_1.uint8)(DexTypeMappings.DODO_ID),
|
|
523
|
+
pool,
|
|
524
|
+
(0, utils_js_1.uint8)(selector),
|
|
525
|
+
(0, utils_js_1.uint16)(poolId),
|
|
526
|
+
(0, utils_js_1.uint16)(cfg === DexPayConfig.FLASH ? flashCalldata.length / 2 - 1 : (0, utils_js_1.uint256)(cfg)),
|
|
527
|
+
(0, utils_js_1.bytes)(cfg === DexPayConfig.FLASH ? flashCalldata : (0, utils_js_1.newbytes)(0)),
|
|
528
|
+
]);
|
|
317
529
|
}
|
|
318
530
|
function encodeWooStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
|
|
319
531
|
if (cfg === DexPayConfig.FLASH)
|
|
320
532
|
throw new Error("NoflashforWoo");
|
|
321
|
-
return (0, utils_js_1.encodePacked)([
|
|
533
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, (0, utils_js_1.uint8)(DexTypeMappings.WOO_FI_ID), pool, (0, utils_js_1.uint8)((0, utils_js_1.uint256)(cfg))]);
|
|
322
534
|
}
|
|
323
535
|
function encodeGmxStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
|
|
324
536
|
if (cfg === DexPayConfig.FLASH)
|
|
325
537
|
throw new Error("NoflashforWoo");
|
|
326
|
-
return (0, utils_js_1.encodePacked)([
|
|
538
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, (0, utils_js_1.uint8)(DexTypeMappings.GMX_ID), pool, (0, utils_js_1.uint8)((0, utils_js_1.uint256)(cfg))]);
|
|
327
539
|
}
|
|
328
540
|
function encodeKtxStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
|
|
329
541
|
if (cfg === DexPayConfig.FLASH)
|
|
330
542
|
throw new Error("NoflashforWoo");
|
|
331
|
-
return (0, utils_js_1.encodePacked)([
|
|
543
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, (0, utils_js_1.uint8)(DexTypeMappings.KTX_ID), pool, (0, utils_js_1.uint8)((0, utils_js_1.uint256)(cfg))]);
|
|
332
544
|
}
|
|
333
545
|
function encodeCurveStyleSwap(tokenOut, receiver, pool, indexIn, indexOut, selectorId, cfg) {
|
|
334
546
|
if (cfg === DexPayConfig.FLASH)
|
|
335
547
|
throw new Error("FlashnotyetsupportedforCurve");
|
|
336
|
-
return (0, utils_js_1.encodePacked)([
|
|
548
|
+
return (0, utils_js_1.encodePacked)(["address", "address", "uint8", "address", "uint8", "uint8", "uint8", "uint16"], [
|
|
549
|
+
tokenOut,
|
|
550
|
+
receiver,
|
|
551
|
+
(0, utils_js_1.uint8)(DexTypeMappings.CURVE_V1_STANDARD_ID),
|
|
552
|
+
pool,
|
|
553
|
+
(0, utils_js_1.uint8)(indexIn),
|
|
554
|
+
(0, utils_js_1.uint8)(indexOut),
|
|
555
|
+
(0, utils_js_1.uint8)(selectorId),
|
|
556
|
+
(0, utils_js_1.uint16)((0, utils_js_1.uint256)(cfg)),
|
|
557
|
+
]);
|
|
337
558
|
}
|
|
338
559
|
function encodeCurveNGStyleSwap(tokenOut, receiver, pool, indexIn, indexOut, selectorId, cfg) {
|
|
339
560
|
if (cfg === DexPayConfig.FLASH)
|
|
340
561
|
throw new Error("FlashnotyetsupportedforCurve");
|
|
341
|
-
return (0, utils_js_1.encodePacked)([
|
|
562
|
+
return (0, utils_js_1.encodePacked)(["address", "address", "uint8", "address", "uint8", "uint8", "uint8", "uint16"], [
|
|
563
|
+
tokenOut,
|
|
564
|
+
receiver,
|
|
565
|
+
(0, utils_js_1.uint8)(DexTypeMappings.CURVE_RECEIVED_ID),
|
|
566
|
+
pool,
|
|
567
|
+
(0, utils_js_1.uint8)(indexIn),
|
|
568
|
+
(0, utils_js_1.uint8)(indexOut),
|
|
569
|
+
(0, utils_js_1.uint8)(selectorId),
|
|
570
|
+
(0, utils_js_1.uint16)((0, utils_js_1.uint256)(cfg)),
|
|
571
|
+
]);
|
|
342
572
|
}
|
|
343
573
|
function encodeWrapperSwap(currentData, assetOut, receiver, operation, cfg) {
|
|
344
|
-
return (0, utils_js_1.encodePacked)([
|
|
574
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "uint8", "uint8"], [
|
|
575
|
+
currentData,
|
|
576
|
+
assetOut,
|
|
577
|
+
receiver,
|
|
578
|
+
(0, utils_js_1.uint8)(DexTypeMappings.ASSET_WRAP_ID),
|
|
579
|
+
(0, utils_js_1.uint8)((0, utils_js_1.uint256)(operation)),
|
|
580
|
+
(0, utils_js_1.uint8)((0, utils_js_1.uint256)(cfg)),
|
|
581
|
+
]);
|
|
345
582
|
}
|
|
346
583
|
function encodeNextGenDexSettle(singleton, nativeAmount) {
|
|
347
|
-
return (0, utils_js_1.encodePacked)([
|
|
584
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "uint128"], [
|
|
585
|
+
(0, utils_js_1.uint8)(ComposerCommands.GEN_2025_SINGELTONS),
|
|
586
|
+
(0, utils_js_1.uint8)(Gen2025ActionIds.UNI_V4_SETTLE),
|
|
587
|
+
singleton,
|
|
588
|
+
(0, utils_js_1.uint128)(nativeAmount),
|
|
589
|
+
]);
|
|
348
590
|
}
|
|
349
591
|
function encodeNextGenDexSettleBalancer(singleton, asset, amountHint) {
|
|
350
|
-
return (0, utils_js_1.encodePacked)([
|
|
592
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "uint128"], [
|
|
593
|
+
(0, utils_js_1.uint8)(ComposerCommands.GEN_2025_SINGELTONS),
|
|
594
|
+
(0, utils_js_1.uint8)(Gen2025ActionIds.BAL_V3_SETTLE),
|
|
595
|
+
singleton,
|
|
596
|
+
asset,
|
|
597
|
+
(0, utils_js_1.uint128)(amountHint >= 0xffffffffffffffffffffffffffffffn ? 0xffffffffffffffffffffffffffffffn : amountHint),
|
|
598
|
+
]);
|
|
351
599
|
}
|
|
352
600
|
function encodeTransferIn(asset, receiver, amount) {
|
|
353
|
-
return (0, utils_js_1.encodePacked)([
|
|
601
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "uint128"], [(0, utils_js_1.uint8)(ComposerCommands.TRANSFERS), (0, utils_js_1.uint8)(TransferIds.TRANSFER_FROM), asset, receiver, (0, utils_js_1.uint128)(amount)]);
|
|
354
602
|
}
|
|
355
603
|
function encodeSweep(asset, receiver, amount, sweepType) {
|
|
356
|
-
return (0, utils_js_1.encodePacked)([
|
|
604
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "uint8", "uint128"], [(0, utils_js_1.uint8)(ComposerCommands.TRANSFERS), (0, utils_js_1.uint8)(TransferIds.SWEEP), asset, receiver, sweepType, (0, utils_js_1.uint128)(amount)]);
|
|
357
605
|
}
|
|
358
606
|
function encodeWrap(amount, wrapTarget) {
|
|
359
|
-
return (0, utils_js_1.encodePacked)([
|
|
607
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "uint8", "uint128"], [
|
|
608
|
+
(0, utils_js_1.uint8)(ComposerCommands.TRANSFERS),
|
|
609
|
+
(0, utils_js_1.uint8)(TransferIds.SWEEP),
|
|
610
|
+
viem_1.zeroAddress,
|
|
611
|
+
wrapTarget,
|
|
612
|
+
(0, utils_js_1.uint8)(SweepType.AMOUNT),
|
|
613
|
+
(0, utils_js_1.uint128)(amount),
|
|
614
|
+
]);
|
|
360
615
|
}
|
|
361
616
|
function encodeApprove(asset, target) {
|
|
362
|
-
return (0, utils_js_1.encodePacked)([
|
|
617
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address"], [(0, utils_js_1.uint8)(ComposerCommands.TRANSFERS), (0, utils_js_1.uint8)(TransferIds.APPROVE), asset, target]);
|
|
363
618
|
}
|
|
364
619
|
function encodeUnwrap(target, receiver, amount, sweepType) {
|
|
365
|
-
return (0, utils_js_1.encodePacked)([
|
|
620
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "uint8", "uint128"], [
|
|
621
|
+
(0, utils_js_1.uint8)(ComposerCommands.TRANSFERS),
|
|
622
|
+
(0, utils_js_1.uint8)(TransferIds.UNWRAP_WNATIVE),
|
|
623
|
+
target,
|
|
624
|
+
receiver,
|
|
625
|
+
sweepType,
|
|
626
|
+
(0, utils_js_1.uint128)(amount),
|
|
627
|
+
]);
|
|
366
628
|
}
|
|
367
629
|
function encodeBalancerV2FlashLoan(asset, amount, poolId, data) {
|
|
368
|
-
return (0, utils_js_1.encodePacked)([
|
|
630
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "uint128", "uint16", "bytes"], [
|
|
631
|
+
(0, utils_js_1.uint8)(ComposerCommands.FLASH_LOAN),
|
|
632
|
+
(0, utils_js_1.uint8)(FlashLoanIds.BALANCER_V2),
|
|
633
|
+
asset,
|
|
634
|
+
(0, utils_js_1.uint128)(amount),
|
|
635
|
+
(0, utils_js_1.uint16)(data.length / 2 - 1 + 1),
|
|
636
|
+
encodeUint8AndBytes(poolId, data),
|
|
637
|
+
]);
|
|
369
638
|
}
|
|
370
639
|
function encodeFlashLoan(asset, amount, pool, poolType, poolId, data) {
|
|
371
|
-
return (0, utils_js_1.encodePacked)([
|
|
640
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "address", "address", "uint128", "uint16", "bytes"], [
|
|
641
|
+
encodeApprove(asset, pool),
|
|
642
|
+
(0, utils_js_1.uint8)(ComposerCommands.FLASH_LOAN),
|
|
643
|
+
poolType,
|
|
644
|
+
asset,
|
|
645
|
+
pool,
|
|
646
|
+
(0, utils_js_1.uint128)(amount),
|
|
647
|
+
(0, utils_js_1.uint16)(data.length / 2 - 1 + 1),
|
|
648
|
+
encodeUint8AndBytes(poolId, data),
|
|
649
|
+
]);
|
|
372
650
|
}
|
|
373
651
|
function encodeUint8AndBytes(poolId, data) {
|
|
374
|
-
return (0, utils_js_1.encodePacked)([
|
|
652
|
+
return (0, utils_js_1.encodePacked)(["uint8", "bytes"], [(0, utils_js_1.uint8)(poolId), data]);
|
|
375
653
|
}
|
|
376
654
|
function encodeMorphoMarket(loanToken, collateralToken, oracle, irm, lltv) {
|
|
377
|
-
return (0, utils_js_1.encodePacked)([
|
|
655
|
+
return (0, utils_js_1.encodePacked)(["address", "address", "address", "address", "uint128"], [loanToken, collateralToken, oracle, irm, (0, utils_js_1.uint128)(lltv)]);
|
|
378
656
|
}
|
|
379
657
|
function encodeMorphoDepositCollateral(market, assets, receiver, data, morphoB, pId) {
|
|
380
|
-
return (0, utils_js_1.encodePacked)([
|
|
658
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "bytes", "uint128", "address", "address", "uint16", "bytes"], [
|
|
659
|
+
encodeApprove((0, utils_js_1.getMorphoCollateral)(market), morphoB),
|
|
660
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
661
|
+
(0, utils_js_1.uint8)(LenderOps.DEPOSIT),
|
|
662
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
|
|
663
|
+
market,
|
|
664
|
+
(0, utils_js_1.uint128)(assets),
|
|
665
|
+
receiver,
|
|
666
|
+
morphoB,
|
|
667
|
+
(0, utils_js_1.uint16)(data.length / 2 - 1 > 0 ? data.length / 2 - 1 + 1 : 0),
|
|
668
|
+
data.length / 2 - 1 === 0 ? (0, utils_js_1.newbytes)(0) : encodeUint8AndBytes((0, utils_js_1.uint8)(pId), data),
|
|
669
|
+
]);
|
|
381
670
|
}
|
|
382
671
|
function encodeMorphoDeposit(market, isShares, assets, receiver, data, morphoB, pId) {
|
|
383
|
-
return (0, utils_js_1.encodePacked)([
|
|
672
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "bytes", "uint128", "address", "address", "uint16", "bytes"], [
|
|
673
|
+
encodeApprove((0, utils_js_1.getMorphoLoanAsset)(market), morphoB),
|
|
674
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
675
|
+
(0, utils_js_1.uint8)(LenderOps.DEPOSIT_LENDING_TOKEN),
|
|
676
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
|
|
677
|
+
market,
|
|
678
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
|
|
679
|
+
receiver,
|
|
680
|
+
morphoB,
|
|
681
|
+
(0, utils_js_1.uint16)(data.length / 2 - 1 > 0 ? data.length / 2 - 1 + 1 : 0),
|
|
682
|
+
data.length / 2 - 1 === 0 ? (0, utils_js_1.newbytes)(0) : encodeUint8AndBytes((0, utils_js_1.uint8)(pId), data),
|
|
683
|
+
]);
|
|
384
684
|
}
|
|
385
685
|
function encodeErc4646Deposit(asset, vault, isShares, assets, receiver) {
|
|
386
|
-
return (0, utils_js_1.encodePacked)([
|
|
686
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "address", "address", "uint128", "address"], [
|
|
687
|
+
encodeApprove(asset, vault),
|
|
688
|
+
(0, utils_js_1.uint8)(ComposerCommands.ERC4626),
|
|
689
|
+
(0, utils_js_1.uint8)(0),
|
|
690
|
+
asset,
|
|
691
|
+
vault,
|
|
692
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
|
|
693
|
+
receiver,
|
|
694
|
+
]);
|
|
387
695
|
}
|
|
388
696
|
function encodeErc4646Withdraw(vault, isShares, assets, receiver) {
|
|
389
|
-
return (0, utils_js_1.encodePacked)([
|
|
697
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "uint128", "address"], [
|
|
698
|
+
(0, utils_js_1.uint8)(ComposerCommands.ERC4626),
|
|
699
|
+
(0, utils_js_1.uint8)(1),
|
|
700
|
+
vault,
|
|
701
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
|
|
702
|
+
receiver,
|
|
703
|
+
]);
|
|
390
704
|
}
|
|
391
705
|
function encodeMorphoWithdraw(market, isShares, assets, receiver, morphoB) {
|
|
392
|
-
return (0, utils_js_1.encodePacked)([
|
|
706
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "bytes", "uint128", "address", "address"], [
|
|
707
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
708
|
+
(0, utils_js_1.uint8)(LenderOps.WITHDRAW_LENDING_TOKEN),
|
|
709
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
|
|
710
|
+
market,
|
|
711
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
|
|
712
|
+
receiver,
|
|
713
|
+
morphoB,
|
|
714
|
+
]);
|
|
393
715
|
}
|
|
394
716
|
function encodeMorphoWithdrawCollateral(market, assets, receiver, morphoB) {
|
|
395
|
-
return (0, utils_js_1.encodePacked)([
|
|
717
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "bytes", "uint128", "address", "address"], [
|
|
718
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
719
|
+
(0, utils_js_1.uint8)(LenderOps.WITHDRAW),
|
|
720
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
|
|
721
|
+
market,
|
|
722
|
+
(0, utils_js_1.uint128)(assets),
|
|
723
|
+
receiver,
|
|
724
|
+
morphoB,
|
|
725
|
+
]);
|
|
396
726
|
}
|
|
397
727
|
function encodeMorphoBorrow(market, isShares, assets, receiver, morphoB) {
|
|
398
|
-
return (0, utils_js_1.encodePacked)([
|
|
728
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "bytes", "uint128", "address", "address"], [
|
|
729
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
730
|
+
(0, utils_js_1.uint8)(LenderOps.BORROW),
|
|
731
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
|
|
732
|
+
market,
|
|
733
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
|
|
734
|
+
receiver,
|
|
735
|
+
morphoB,
|
|
736
|
+
]);
|
|
399
737
|
}
|
|
400
738
|
function encodeMorphoRepay(market, isShares, assets, receiver, data, morphoB, pId) {
|
|
401
|
-
return (0, utils_js_1.encodePacked)([
|
|
739
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "bytes", "uint128", "address", "address", "uint16", "bytes"], [
|
|
740
|
+
encodeApprove((0, utils_js_1.getMorphoLoanAsset)(market), morphoB),
|
|
741
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
742
|
+
(0, utils_js_1.uint8)(LenderOps.REPAY),
|
|
743
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
|
|
744
|
+
market,
|
|
745
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
|
|
746
|
+
receiver,
|
|
747
|
+
morphoB,
|
|
748
|
+
(0, utils_js_1.uint16)(data.length / 2 - 1 > 0 ? data.length / 2 - 1 + 1 : 0),
|
|
749
|
+
data.length / 2 - 1 === 0 ? (0, utils_js_1.newbytes)(0) : encodeUint8AndBytes((0, utils_js_1.uint8)(pId), data),
|
|
750
|
+
]);
|
|
402
751
|
}
|
|
403
752
|
function encodeAaveDeposit(token, amount, receiver, pool) {
|
|
404
|
-
return (0, utils_js_1.encodePacked)([
|
|
753
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
754
|
+
encodeApprove(token, pool),
|
|
755
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
756
|
+
(0, utils_js_1.uint8)(LenderOps.DEPOSIT),
|
|
757
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_AAVE_V3 - 1),
|
|
758
|
+
token,
|
|
759
|
+
(0, utils_js_1.uint128)(amount),
|
|
760
|
+
receiver,
|
|
761
|
+
pool,
|
|
762
|
+
]);
|
|
405
763
|
}
|
|
406
764
|
function encodeAaveBorrow(token, amount, receiver, mode, pool) {
|
|
407
|
-
return (0, utils_js_1.encodePacked)([
|
|
765
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "address", "uint128", "address", "uint8", "address"], [
|
|
766
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
767
|
+
(0, utils_js_1.uint8)(LenderOps.BORROW),
|
|
768
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_AAVE_V3 - 1),
|
|
769
|
+
token,
|
|
770
|
+
(0, utils_js_1.uint128)(amount),
|
|
771
|
+
receiver,
|
|
772
|
+
(0, utils_js_1.uint8)(mode),
|
|
773
|
+
pool,
|
|
774
|
+
]);
|
|
408
775
|
}
|
|
409
776
|
function encodeAaveRepay(token, amount, receiver, mode, dToken, pool) {
|
|
410
|
-
return (0, utils_js_1.encodePacked)([
|
|
777
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "uint8", "address", "address"], [
|
|
778
|
+
encodeApprove(token, pool),
|
|
779
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
780
|
+
(0, utils_js_1.uint8)(LenderOps.REPAY),
|
|
781
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_AAVE_V3 - 1),
|
|
782
|
+
token,
|
|
783
|
+
(0, utils_js_1.uint128)(amount),
|
|
784
|
+
receiver,
|
|
785
|
+
(0, utils_js_1.uint8)(mode),
|
|
786
|
+
dToken,
|
|
787
|
+
pool,
|
|
788
|
+
]);
|
|
411
789
|
}
|
|
412
790
|
function encodeAaveWithdraw(token, amount, receiver, aToken, pool) {
|
|
413
|
-
return (0, utils_js_1.encodePacked)([
|
|
791
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "address", "uint128", "address", "address", "address"], [
|
|
792
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
793
|
+
(0, utils_js_1.uint8)(LenderOps.WITHDRAW),
|
|
794
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_AAVE_V3 - 1),
|
|
795
|
+
token,
|
|
796
|
+
(0, utils_js_1.uint128)(amount),
|
|
797
|
+
receiver,
|
|
798
|
+
aToken,
|
|
799
|
+
pool,
|
|
800
|
+
]);
|
|
414
801
|
}
|
|
415
802
|
function encodeAaveV2Deposit(token, amount, receiver, pool) {
|
|
416
|
-
return (0, utils_js_1.encodePacked)([
|
|
803
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
804
|
+
encodeApprove(token, pool),
|
|
805
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
806
|
+
(0, utils_js_1.uint8)(LenderOps.DEPOSIT),
|
|
807
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_AAVE_V2 - 1),
|
|
808
|
+
token,
|
|
809
|
+
(0, utils_js_1.uint128)(amount),
|
|
810
|
+
receiver,
|
|
811
|
+
pool,
|
|
812
|
+
]);
|
|
417
813
|
}
|
|
418
814
|
function encodeAaveV2Borrow(token, amount, receiver, mode, pool) {
|
|
419
|
-
return (0, utils_js_1.encodePacked)([
|
|
815
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "address", "uint128", "address", "uint8", "address"], [
|
|
816
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
817
|
+
(0, utils_js_1.uint8)(LenderOps.BORROW),
|
|
818
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_AAVE_V2 - 1),
|
|
819
|
+
token,
|
|
820
|
+
(0, utils_js_1.uint128)(amount),
|
|
821
|
+
receiver,
|
|
822
|
+
(0, utils_js_1.uint8)(mode),
|
|
823
|
+
pool,
|
|
824
|
+
]);
|
|
420
825
|
}
|
|
421
826
|
function encodeAaveV2Repay(token, amount, receiver, mode, dToken, pool) {
|
|
422
|
-
return (0, utils_js_1.encodePacked)([
|
|
827
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "uint8", "address", "address"], [
|
|
828
|
+
encodeApprove(token, pool),
|
|
829
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
830
|
+
(0, utils_js_1.uint8)(LenderOps.REPAY),
|
|
831
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_AAVE_V2 - 1),
|
|
832
|
+
token,
|
|
833
|
+
(0, utils_js_1.uint128)(amount),
|
|
834
|
+
receiver,
|
|
835
|
+
(0, utils_js_1.uint8)(mode),
|
|
836
|
+
dToken,
|
|
837
|
+
pool,
|
|
838
|
+
]);
|
|
423
839
|
}
|
|
424
840
|
function encodeAaveV2Withdraw(token, amount, receiver, aToken, pool) {
|
|
425
|
-
return (0, utils_js_1.encodePacked)([
|
|
841
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "address", "uint128", "address", "address", "address"], [
|
|
842
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
843
|
+
(0, utils_js_1.uint8)(LenderOps.WITHDRAW),
|
|
844
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_AAVE_V2 - 1),
|
|
845
|
+
token,
|
|
846
|
+
(0, utils_js_1.uint128)(amount),
|
|
847
|
+
receiver,
|
|
848
|
+
aToken,
|
|
849
|
+
pool,
|
|
850
|
+
]);
|
|
426
851
|
}
|
|
427
852
|
function encodeCompoundV3Deposit(token, amount, receiver, comet) {
|
|
428
|
-
return (0, utils_js_1.encodePacked)([
|
|
853
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
854
|
+
encodeApprove(token, comet),
|
|
855
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
856
|
+
(0, utils_js_1.uint8)(LenderOps.DEPOSIT),
|
|
857
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_COMPOUND_V3 - 1),
|
|
858
|
+
token,
|
|
859
|
+
(0, utils_js_1.uint128)(amount),
|
|
860
|
+
receiver,
|
|
861
|
+
comet,
|
|
862
|
+
]);
|
|
429
863
|
}
|
|
430
864
|
function encodeCompoundV3Borrow(token, amount, receiver, comet) {
|
|
431
|
-
return (0, utils_js_1.encodePacked)([
|
|
865
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
866
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
867
|
+
(0, utils_js_1.uint8)(LenderOps.BORROW),
|
|
868
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_COMPOUND_V3 - 1),
|
|
869
|
+
token,
|
|
870
|
+
(0, utils_js_1.uint128)(amount),
|
|
871
|
+
receiver,
|
|
872
|
+
comet,
|
|
873
|
+
]);
|
|
432
874
|
}
|
|
433
875
|
function encodeCompoundV3Repay(token, amount, receiver, comet) {
|
|
434
|
-
return (0, utils_js_1.encodePacked)([
|
|
876
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
877
|
+
encodeApprove(token, comet),
|
|
878
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
879
|
+
(0, utils_js_1.uint8)(LenderOps.REPAY),
|
|
880
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_COMPOUND_V3 - 1),
|
|
881
|
+
token,
|
|
882
|
+
(0, utils_js_1.uint128)(amount),
|
|
883
|
+
receiver,
|
|
884
|
+
comet,
|
|
885
|
+
]);
|
|
435
886
|
}
|
|
436
887
|
function encodeCompoundV3Withdraw(token, amount, receiver, comet, isBase) {
|
|
437
|
-
return (0, utils_js_1.encodePacked)([
|
|
888
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "address", "uint128", "address", "uint8", "address"], [
|
|
889
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
890
|
+
(0, utils_js_1.uint8)(LenderOps.WITHDRAW),
|
|
891
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_COMPOUND_V3 - 1),
|
|
892
|
+
token,
|
|
893
|
+
(0, utils_js_1.uint128)(amount),
|
|
894
|
+
receiver,
|
|
895
|
+
isBase ? (0, utils_js_1.uint8)(1) : (0, utils_js_1.uint8)(0),
|
|
896
|
+
comet,
|
|
897
|
+
]);
|
|
438
898
|
}
|
|
439
899
|
function encodeCompoundV2Deposit(token, amount, receiver, cToken) {
|
|
440
|
-
return (0, utils_js_1.encodePacked)([
|
|
900
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
901
|
+
token === viem_1.zeroAddress ? (0, utils_js_1.newbytes)(0) : encodeApprove(token, cToken),
|
|
902
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
903
|
+
(0, utils_js_1.uint8)(LenderOps.DEPOSIT),
|
|
904
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_COMPOUND_V2 - 1),
|
|
905
|
+
token,
|
|
906
|
+
(0, utils_js_1.uint128)(amount),
|
|
907
|
+
receiver,
|
|
908
|
+
cToken,
|
|
909
|
+
]);
|
|
441
910
|
}
|
|
442
911
|
function encodeCompoundV2Borrow(token, amount, receiver, cToken) {
|
|
443
|
-
return (0, utils_js_1.encodePacked)([
|
|
912
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
913
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
914
|
+
(0, utils_js_1.uint8)(LenderOps.BORROW),
|
|
915
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_COMPOUND_V2 - 1),
|
|
916
|
+
token,
|
|
917
|
+
(0, utils_js_1.uint128)(amount),
|
|
918
|
+
receiver,
|
|
919
|
+
cToken,
|
|
920
|
+
]);
|
|
444
921
|
}
|
|
445
922
|
function encodeCompoundV2Repay(token, amount, receiver, cToken) {
|
|
446
|
-
return (0, utils_js_1.encodePacked)([
|
|
923
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
924
|
+
token === viem_1.zeroAddress ? (0, utils_js_1.newbytes)(0) : encodeApprove(token, cToken),
|
|
925
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
926
|
+
(0, utils_js_1.uint8)(LenderOps.REPAY),
|
|
927
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_COMPOUND_V2 - 1),
|
|
928
|
+
token,
|
|
929
|
+
(0, utils_js_1.uint128)(amount),
|
|
930
|
+
receiver,
|
|
931
|
+
cToken,
|
|
932
|
+
]);
|
|
447
933
|
}
|
|
448
934
|
function encodeCompoundV2Withdraw(token, amount, receiver, cToken) {
|
|
449
|
-
return (0, utils_js_1.encodePacked)([
|
|
935
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
936
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
937
|
+
(0, utils_js_1.uint8)(LenderOps.WITHDRAW),
|
|
938
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_COMPOUND_V2 - 1),
|
|
939
|
+
token,
|
|
940
|
+
(0, utils_js_1.uint128)(amount),
|
|
941
|
+
receiver,
|
|
942
|
+
cToken,
|
|
943
|
+
]);
|
|
450
944
|
}
|