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