@1delta/calldatalib 0.0.37 → 0.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,20 +127,53 @@ 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'], [uint8(ComposerCommands.EXT_CALL), target, generateAmountBitmap(uint128(value), false, useSelfBalance), uint16(data.length / 2 - 1), data]);
130
+ return encodePacked(["uint8", "address", "uint128", "uint16", "bytes"], [
131
+ uint8(ComposerCommands.EXT_CALL),
132
+ target,
133
+ generateAmountBitmap(uint128(value), false, useSelfBalance),
134
+ uint16(data.length / 2 - 1),
135
+ data,
136
+ ]);
131
137
  }
132
138
  export function encodeTryExternalCall(target, value, useSelfBalance, rOnFailure, data, catchData) {
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]);
139
+ return encodePacked(["uint8", "address", "uint128", "uint16", "bytes", "uint8", "uint16", "bytes"], [
140
+ uint8(ComposerCommands.EXT_TRY_CALL),
141
+ target,
142
+ generateAmountBitmap(uint128(value), false, useSelfBalance),
143
+ uint16(data.length / 2 - 1),
144
+ data,
145
+ uint8(rOnFailure ? 0 : 1),
146
+ uint16(catchData.length / 2 - 1),
147
+ catchData,
148
+ ]);
134
149
  }
135
150
  export function encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions) {
136
151
  const partialData = encodeStargateV2BridgePartial(amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions);
137
- return encodePacked(['uint8', 'uint8', 'address', 'address', 'uint32', 'bytes32', 'address', 'bytes'], [uint8(ComposerCommands.BRIDGING), uint8(BridgeIds.STARGATE_V2), asset, stargatePool, dstEid, receiver, refundReceiver, partialData]);
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
+ ]);
138
162
  }
139
163
  export function encodePermit(permitId, target, data) {
140
- return encodePacked(['uint8', 'uint8', 'address', 'uint16', 'bytes'], [uint8(ComposerCommands.PERMIT), uint8(permitId), target, uint16(data.length / 2 - 1), data]);
164
+ return encodePacked(["uint8", "uint8", "address", "uint16", "bytes"], [uint8(ComposerCommands.PERMIT), uint8(permitId), target, uint16(data.length / 2 - 1), data]);
141
165
  }
142
166
  export function encodeStargateV2BridgePartial(amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions) {
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]);
167
+ return encodePacked(["uint128", "uint32", "uint128", "uint8", "uint16", "uint16", "bytes", "bytes"], [
168
+ generateAmountBitmap(uint128(amount), 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
+ ]);
144
177
  }
145
178
  export function encodeStargateV2BridgeSimpleTaxi(asset, stargatePool, dstEid, receiver, refundReceiver, amount, isNative, slippage, fee) {
146
179
  return encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, false, isNative, newbytes(0), newbytes(0));
@@ -149,18 +182,81 @@ export function encodeStargateV2BridgeSimpleBus(asset, stargatePool, dstEid, rec
149
182
  return encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, true, isNative, newbytes(0), newbytes(0));
150
183
  }
151
184
  export function encodeAcrossBridgeToken(spokePool, depositor, sendingAssetId, receivingAssetId, amount, fixedFee, feePercentage, destinationChainId, receiver, message) {
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]);
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),
207
+ fixedFee,
208
+ feePercentage,
209
+ destinationChainId,
210
+ receiver,
211
+ uint16(message.length / 2 - 1),
212
+ message,
213
+ ]);
153
214
  return bridgeData;
154
215
  }
155
216
  export function encodeAcrossBridgeNative(spokePool, depositor, sendingAssetId, receivingAssetId, amount, fixedFee, feePercentage, destinationChainId, receiver, message) {
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]);
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, true),
239
+ fixedFee,
240
+ feePercentage,
241
+ destinationChainId,
242
+ receiver,
243
+ uint16(message.length / 2 - 1),
244
+ message,
245
+ ]);
157
246
  return bridgeData;
158
247
  }
159
248
  export function encodePermit2TransferFrom(token, receiver, amount) {
160
- return encodePacked(['uint8', 'uint8', 'address', 'address', 'uint128'], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.PERMIT2_TRANSFER_FROM), token, receiver, uint128(amount)]);
249
+ return encodePacked(["uint8", "uint8", "address", "address", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.PERMIT2_TRANSFER_FROM), token, receiver, uint128(amount)]);
161
250
  }
162
251
  export function encodeNextGenDexUnlock(singleton, id, d) {
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]);
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
+ ]);
164
260
  }
165
261
  export function encodeBalancerV3FlashLoan(singleton, poolId, asset, receiver, amount, flashData) {
166
262
  const take = encodeBalancerV3Take(singleton, asset, receiver, amount);
@@ -168,7 +264,7 @@ export function encodeBalancerV3FlashLoan(singleton, poolId, asset, receiver, am
168
264
  return encodeNextGenDexUnlock(singleton, poolId, encodeBalancerV3FlashLoanData(take, flashData, settle));
169
265
  }
170
266
  export function encodeBalancerV3FlashLoanData(take, flashData, settle) {
171
- return encodePacked(['bytes', 'bytes', 'bytes'], [take, flashData, settle]);
267
+ return encodePacked(["bytes", "bytes", "bytes"], [take, flashData, settle]);
172
268
  }
173
269
  export function encodeUniswapV4FlashLoan(singleton, poolId, asset, receiver, amount, flashData) {
174
270
  const take = encodeUniswapV4Take(singleton, asset, receiver, amount);
@@ -177,201 +273,570 @@ export function encodeUniswapV4FlashLoan(singleton, poolId, asset, receiver, amo
177
273
  return encodeNextGenDexUnlock(singleton, poolId, encodeUniswapV4FlashLoanData(take, sync, flashData, settle));
178
274
  }
179
275
  export function encodeUniswapV4FlashLoanData(take, sync, flashData, settle) {
180
- return encodePacked(['bytes', 'bytes', 'bytes', 'bytes'], [take, sync, flashData, settle]);
276
+ return encodePacked(["bytes", "bytes", "bytes", "bytes"], [take, sync, flashData, settle]);
181
277
  }
182
278
  export function encodeBalancerV3Take(singleton, asset, receiver, amount) {
183
- return encodePacked(['uint8', 'uint8', 'address', 'address', 'address', 'uint128'], [uint8(ComposerCommands.GEN_2025_SINGELTONS), uint8(Gen2025ActionIds.BAL_V3_TAKE), singleton, asset, receiver, uint128(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
+ ]);
184
287
  }
185
288
  export function encodeUniswapV4Sync(singleton, asset) {
186
289
  if (asset === zeroAddress)
187
290
  return `0x0`;
188
- ;
189
- return encodePacked(['uint8', 'uint8', 'address', 'address'], [uint8(ComposerCommands.GEN_2025_SINGELTONS), uint8(Gen2025ActionIds.UNI_V4_SYNC), singleton, asset]);
291
+ return encodePacked(["uint8", "uint8", "address", "address"], [uint8(ComposerCommands.GEN_2025_SINGELTONS), uint8(Gen2025ActionIds.UNI_V4_SYNC), singleton, asset]);
190
292
  }
191
293
  export function encodeUniswapV4Take(singleton, asset, receiver, amount) {
192
- return encodePacked(['uint8', 'uint8', 'address', 'address', 'address', 'uint128'], [uint8(ComposerCommands.GEN_2025_SINGELTONS), uint8(Gen2025ActionIds.UNI_V4_TAKE), singleton, asset, receiver, uint128(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
+ ]);
193
302
  }
194
303
  export function swapHead(amount, amountOutMin, assetIn) {
195
- return encodePacked(['uint8', 'uint128', 'uint128', 'address'], [uint8(ComposerCommands.SWAPS), generateAmountBitmap(uint128(amount), false, false), uint128(amountOutMin), assetIn]);
304
+ return encodePacked(["uint8", "uint128", "uint128", "address"], [
305
+ uint8(ComposerCommands.SWAPS),
306
+ generateAmountBitmap(uint128(amount), false, false),
307
+ uint128(amountOutMin),
308
+ assetIn,
309
+ ]);
196
310
  }
197
311
  export function attachBranch(data, hops, splits, splitsData) {
198
312
  if (hops !== 0n && splits !== 0n)
199
313
  throw new Error("Invalidbranching");
200
314
  if (splitsData.length / 2 - 1 > 0 && splits === 0n)
201
315
  throw new Error("Nosplitsbutsplitdataprovided");
202
- return encodePacked(['bytes', 'uint8', 'uint8', 'bytes'], [data, uint8(hops), uint8(splits), splitsData]);
316
+ return encodePacked(["bytes", "uint8", "uint8", "bytes"], [data, uint8(hops), uint8(splits), splitsData]);
203
317
  }
204
318
  export function encodeUniswapV2StyleSwap(tokenOut, receiver, forkId, pool, feeDenom, cfg, flashCalldata) {
205
319
  if (uint256(cfg) < 2 && flashCalldata.length / 2 - 1 > 2)
206
320
  throw new Error("Invalidconfigforv2swap");
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))]);
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
+ ]);
208
331
  }
209
332
  export function encodeUniswapV4StyleSwap(currentData, tokenOut, receiver, manager, fee, tickSpacing, hooks, hookData, cfg) {
210
333
  if (cfg === DexPayConfig.FLASH)
211
334
  throw new Error("Invalidconfigforv2swap");
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]);
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
+ ]);
213
348
  }
214
349
  export function encodeBalancerV2StyleSwap(currentData, tokenOut, receiver, poolId, balancerVault, cfg) {
215
350
  if (cfg === DexPayConfig.FLASH)
216
351
  throw new Error("Invalidconfigforv2swap");
217
- return encodePacked(['bytes', 'address', 'address', 'uint8', 'bytes32', 'address', 'uint8'], [currentData, tokenOut, receiver, uint8(DexTypeMappings.BALANCER_V2_ID), poolId, balancerVault, uint8(uint256(cfg))]);
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
+ ]);
218
361
  }
219
362
  export function encodeLbStyleSwap(currentData, tokenOut, receiver, pool, swapForY, cfg) {
220
363
  if (cfg === DexPayConfig.FLASH)
221
364
  throw new Error("Invalidconfigforv2swap");
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))]);
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))]);
223
366
  }
224
367
  export function encodeSyncSwapStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
225
368
  if (cfg === DexPayConfig.FLASH)
226
369
  throw new Error("Invalidconfigforv2swap");
227
- return encodePacked(['bytes', 'address', 'address', 'uint8', 'address', 'uint8'], [currentData, tokenOut, receiver, uint8(DexTypeMappings.SYNC_SWAP_ID), pool, uint8(uint256(cfg))]);
370
+ return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.SYNC_SWAP_ID), pool, uint8(uint256(cfg))]);
228
371
  }
229
372
  export function encodeUniswapV3StyleSwap(currentData, tokenOut, receiver, forkId, pool, feeTier, cfg, flashCalldata) {
230
373
  if (uint256(cfg) < 2 && flashCalldata.length / 2 - 1 > 2)
231
374
  throw new Error("Invalidconfigforv2swap");
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))]);
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
+ ]);
233
386
  }
234
387
  export function encodeIzumiStyleSwap(currentData, tokenOut, receiver, forkId, pool, feeTier, cfg, flashCalldata) {
235
388
  if (uint256(cfg) < 2 && flashCalldata.length / 2 - 1 > 2)
236
389
  throw new Error("Invalidconfigforv2swap");
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))]);
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
+ ]);
238
401
  }
239
402
  export function encodeBalancerV3StyleSwap(currentData, tokenOut, receiver, balancerV3Vault, pool, cfg, poolUserData) {
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]);
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
+ ]);
241
414
  }
242
415
  export function encodeDodoStyleSwap(currentData, tokenOut, receiver, pool, selector, poolId, cfg, flashCalldata) {
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))]);
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
+ ]);
244
427
  }
245
428
  export function encodeWooStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
246
429
  if (cfg === DexPayConfig.FLASH)
247
430
  throw new Error("NoflashforWoo");
248
- return encodePacked(['bytes', 'address', 'address', 'uint8', 'address', 'uint8'], [currentData, tokenOut, receiver, uint8(DexTypeMappings.WOO_FI_ID), pool, uint8(uint256(cfg))]);
431
+ return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.WOO_FI_ID), pool, uint8(uint256(cfg))]);
249
432
  }
250
433
  export function encodeGmxStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
251
434
  if (cfg === DexPayConfig.FLASH)
252
435
  throw new Error("NoflashforWoo");
253
- return encodePacked(['bytes', 'address', 'address', 'uint8', 'address', 'uint8'], [currentData, tokenOut, receiver, uint8(DexTypeMappings.GMX_ID), pool, uint8(uint256(cfg))]);
436
+ return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.GMX_ID), pool, uint8(uint256(cfg))]);
254
437
  }
255
438
  export function encodeKtxStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
256
439
  if (cfg === DexPayConfig.FLASH)
257
440
  throw new Error("NoflashforWoo");
258
- return encodePacked(['bytes', 'address', 'address', 'uint8', 'address', 'uint8'], [currentData, tokenOut, receiver, uint8(DexTypeMappings.KTX_ID), pool, uint8(uint256(cfg))]);
441
+ return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.KTX_ID), pool, uint8(uint256(cfg))]);
259
442
  }
260
443
  export function encodeCurveStyleSwap(tokenOut, receiver, pool, indexIn, indexOut, selectorId, cfg) {
261
444
  if (cfg === DexPayConfig.FLASH)
262
445
  throw new Error("FlashnotyetsupportedforCurve");
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))]);
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
+ ]);
264
456
  }
265
457
  export function encodeCurveNGStyleSwap(tokenOut, receiver, pool, indexIn, indexOut, selectorId, cfg) {
266
458
  if (cfg === DexPayConfig.FLASH)
267
459
  throw new Error("FlashnotyetsupportedforCurve");
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))]);
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
+ ]);
269
470
  }
270
471
  export function encodeWrapperSwap(currentData, assetOut, receiver, operation, cfg) {
271
- return encodePacked(['bytes', 'address', 'address', 'uint8', 'uint8', 'uint8'], [currentData, assetOut, receiver, uint8(DexTypeMappings.ASSET_WRAP_ID), uint8(uint256(operation)), uint8(uint256(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
+ ]);
272
480
  }
273
481
  export function encodeNextGenDexSettle(singleton, nativeAmount) {
274
- return encodePacked(['uint8', 'uint8', 'address', 'uint128'], [uint8(ComposerCommands.GEN_2025_SINGELTONS), uint8(Gen2025ActionIds.UNI_V4_SETTLE), singleton, uint128(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
+ ]);
275
488
  }
276
489
  export function encodeNextGenDexSettleBalancer(singleton, asset, amountHint) {
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)]);
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
+ ]);
278
497
  }
279
498
  export function encodeTransferIn(asset, receiver, amount) {
280
- return encodePacked(['uint8', 'uint8', 'address', 'address', 'uint128'], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.TRANSFER_FROM), asset, receiver, uint128(amount)]);
499
+ return encodePacked(["uint8", "uint8", "address", "address", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.TRANSFER_FROM), asset, receiver, uint128(amount)]);
281
500
  }
282
501
  export function encodeSweep(asset, receiver, amount, sweepType) {
283
- return encodePacked(['uint8', 'uint8', 'address', 'address', 'uint8', 'uint128'], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.SWEEP), asset, receiver, sweepType, uint128(amount)]);
502
+ return encodePacked(["uint8", "uint8", "address", "address", "uint8", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.SWEEP), asset, receiver, sweepType, uint128(amount)]);
284
503
  }
285
504
  export function encodeWrap(amount, wrapTarget) {
286
- return encodePacked(['uint8', 'uint8', 'address', 'address', 'uint8', 'uint128'], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.SWEEP), zeroAddress, wrapTarget, uint8(SweepType.AMOUNT), uint128(amount)]);
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
+ ]);
287
513
  }
288
514
  export function encodeApprove(asset, target) {
289
- return encodePacked(['uint8', 'uint8', 'address', 'address'], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.APPROVE), asset, target]);
515
+ return encodePacked(["uint8", "uint8", "address", "address"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.APPROVE), asset, target]);
290
516
  }
291
517
  export function encodeUnwrap(target, receiver, amount, sweepType) {
292
- return encodePacked(['uint8', 'uint8', 'address', 'address', 'uint8', 'uint128'], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.UNWRAP_WNATIVE), target, receiver, sweepType, uint128(amount)]);
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
+ ]);
293
526
  }
294
527
  export function encodeBalancerV2FlashLoan(asset, amount, poolId, data) {
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)]);
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
+ ]);
296
536
  }
297
537
  export function encodeFlashLoan(asset, amount, pool, poolType, poolId, data) {
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)]);
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
+ ]);
299
548
  }
300
549
  export function encodeUint8AndBytes(poolId, data) {
301
- return encodePacked(['uint8', 'bytes'], [uint8(poolId), data]);
550
+ return encodePacked(["uint8", "bytes"], [uint8(poolId), data]);
302
551
  }
303
552
  export function encodeMorphoMarket(loanToken, collateralToken, oracle, irm, lltv) {
304
- return encodePacked(['address', 'address', 'address', 'address', 'uint128'], [loanToken, collateralToken, oracle, irm, uint128(lltv)]);
553
+ return encodePacked(["address", "address", "address", "address", "uint128"], [loanToken, collateralToken, oracle, irm, uint128(lltv)]);
305
554
  }
306
555
  export function encodeMorphoDepositCollateral(market, assets, receiver, data, morphoB, pId) {
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)]);
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
+ ]);
308
568
  }
309
569
  export function encodeMorphoDeposit(market, isShares, assets, receiver, data, morphoB, pId) {
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)]);
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),
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
+ ]);
311
582
  }
312
583
  export function encodeErc4646Deposit(asset, vault, isShares, assets, receiver) {
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]);
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),
591
+ receiver,
592
+ ]);
314
593
  }
315
594
  export function encodeErc4646Withdraw(vault, isShares, assets, receiver) {
316
- return encodePacked(['uint8', 'uint8', 'address', 'uint128', 'address'], [uint8(ComposerCommands.ERC4626), uint8(1), vault, generateAmountBitmap(uint128(assets), isShares, false), receiver]);
595
+ return encodePacked(["uint8", "uint8", "address", "uint128", "address"], [
596
+ uint8(ComposerCommands.ERC4626),
597
+ uint8(1),
598
+ vault,
599
+ generateAmountBitmap(uint128(assets), isShares, false),
600
+ receiver,
601
+ ]);
317
602
  }
318
603
  export function encodeMorphoWithdraw(market, isShares, assets, receiver, morphoB) {
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]);
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),
610
+ receiver,
611
+ morphoB,
612
+ ]);
320
613
  }
321
614
  export function encodeMorphoWithdrawCollateral(market, assets, receiver, morphoB) {
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]);
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
+ ]);
323
624
  }
324
625
  export function encodeMorphoBorrow(market, isShares, assets, receiver, morphoB) {
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]);
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),
632
+ receiver,
633
+ morphoB,
634
+ ]);
326
635
  }
327
636
  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)]);
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, 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
+ ]);
329
649
  }
330
650
  export function encodeAaveDeposit(token, amount, receiver, pool) {
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]);
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
+ ]);
332
661
  }
333
662
  export function encodeAaveBorrow(token, amount, receiver, mode, pool) {
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]);
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
+ ]);
335
673
  }
336
674
  export function encodeAaveRepay(token, amount, receiver, mode, dToken, pool) {
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]);
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
+ ]);
338
687
  }
339
688
  export function encodeAaveWithdraw(token, amount, receiver, aToken, pool) {
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]);
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
+ ]);
341
699
  }
342
700
  export function encodeAaveV2Deposit(token, amount, receiver, pool) {
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]);
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
+ ]);
344
711
  }
345
712
  export function encodeAaveV2Borrow(token, amount, receiver, mode, pool) {
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]);
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
+ ]);
347
723
  }
348
724
  export function encodeAaveV2Repay(token, amount, receiver, mode, dToken, pool) {
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]);
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
+ ]);
350
737
  }
351
738
  export function encodeAaveV2Withdraw(token, amount, receiver, aToken, pool) {
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]);
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
+ ]);
353
749
  }
354
750
  export function encodeCompoundV3Deposit(token, amount, receiver, comet) {
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]);
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
+ ]);
356
761
  }
357
762
  export function encodeCompoundV3Borrow(token, amount, receiver, comet) {
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]);
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
+ ]);
359
772
  }
360
773
  export function encodeCompoundV3Repay(token, amount, receiver, comet) {
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]);
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
+ ]);
362
784
  }
363
785
  export function encodeCompoundV3Withdraw(token, amount, receiver, comet, isBase) {
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]);
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
+ ]);
365
796
  }
366
797
  export function encodeCompoundV2Deposit(token, amount, receiver, cToken) {
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]);
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
+ ]);
368
808
  }
369
809
  export function encodeCompoundV2Borrow(token, amount, receiver, cToken) {
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]);
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
+ ]);
371
819
  }
372
820
  export function encodeCompoundV2Repay(token, amount, receiver, cToken) {
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]);
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
+ ]);
374
831
  }
375
832
  export function encodeCompoundV2Withdraw(token, amount, receiver, cToken) {
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]);
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
+ ]);
377
842
  }