@1delta/calldatalib 0.0.37 → 0.0.39

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