@1delta/calldatalib 0.0.34 → 0.0.37

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