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