@1delta/calldatalib 0.0.20 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # @1delta/calldatalib
2
+
3
+ Generated TypeScript functions for 1delta smart contracts calldata encoding.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @1delta/calldatalib
9
+ # or
10
+ yarn add @1delta/calldatalib
11
+ # or
12
+ pnpm add @1delta/calldatalib
13
+ ```
14
+
15
+ This package requires `viem` as a peer dependency, so make sure to install it as well:
16
+
17
+ ```bash
18
+ npm install viem
19
+ # or
20
+ yarn add viem
21
+ # or
22
+ pnpm add viem
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```typescript
28
+ import { encodeExternalCall } from "@1delta/calldatalib";
29
+ import { parseEther } from "viem";
30
+
31
+ // Example usage
32
+ const calldata = encodeExternalCall(
33
+ "0x1234567890123456789012345678901234567890",
34
+ parseEther("0.1"),
35
+ "0x1234"
36
+ );
37
+ ```
@@ -13,6 +13,11 @@ export declare enum DodoSelector {
13
13
  SELL_BASE = 0,
14
14
  SELL_QUOTE = 1
15
15
  }
16
+ export declare enum WrapOperation {
17
+ NATIVE = 0,
18
+ ERC4626_DEPOSIT = 1,
19
+ ERC4626_REDEEM = 2
20
+ }
16
21
  export declare enum TransferIds {
17
22
  TRANSFER_FROM = 0,
18
23
  SWEEP = 1,
@@ -47,7 +52,7 @@ export declare enum FlashLoanIds {
47
52
  AAVE_V3 = 2,
48
53
  AAVE_V2 = 3
49
54
  }
50
- export declare enum ERC4646Ids {
55
+ export declare enum ERC4626Ids {
51
56
  DEPOSIT = 0,
52
57
  WITHDRAW = 1
53
58
  }
@@ -60,18 +65,19 @@ export declare enum Gen2025ActionIds {
60
65
  BAL_V3_SETTLE = 5
61
66
  }
62
67
  export declare enum ComposerCommands {
63
- SWAPS = 32,
64
- EXT_CALL = 64,
65
- LENDING = 96,
66
- TRANSFERS = 128,
67
- PERMIT = 160,
68
- FLASH_LOAN = 192,
69
- ERC4646 = 224,
70
- GEN_2025_SINGELTONS = 225
68
+ SWAPS = 16,
69
+ EXT_CALL = 32,
70
+ LENDING = 48,
71
+ TRANSFERS = 64,
72
+ PERMIT = 80,
73
+ FLASH_LOAN = 96,
74
+ ERC4626 = 112,
75
+ GEN_2025_SINGELTONS = 128,
76
+ BRIDGING = 144
71
77
  }
72
- export declare enum ForwarderCommands {
73
- EXT_CALL = 64,
74
- ASSET_HANDLING = 128
78
+ export declare enum BridgeIds {
79
+ STARGATE_V2 = 0,
80
+ ACROSS = 10
75
81
  }
76
82
  export declare enum DexTypeMappings {
77
83
  UNISWAP_V3_ID = 0,
@@ -90,8 +96,8 @@ export declare enum DexTypeMappings {
90
96
  LB_ID = 140,
91
97
  DODO_ID = 150,
92
98
  SYNC_SWAP_ID = 160,
93
- ERC4646_ID = 253,
94
- NATIVE_WRAP_ID = 254
99
+ ERC4626_ID = 253,
100
+ ASSET_WRAP_ID = 254
95
101
  }
96
102
  export declare enum DexForkMappings {
97
103
  UNISWAP_V3 = 0,
@@ -102,6 +108,13 @@ export declare enum DexForkMappings {
102
108
  BALANCER_V3 = 0,
103
109
  UNISWAP_V2 = 0
104
110
  }
111
+ export declare function encodeExternalCall(target: Address, value: bigint, data: Hex): Hex;
112
+ export declare function encodeStargateV2Bridge(asset: Address, stargatePool: Address, dstEid: number, receiver: Hex, refundReceiver: Address, amount: bigint, slippage: number, fee: bigint, isBusMode: boolean, isNative: boolean, composeMsg: Hex, extraOptions: Hex): Hex;
113
+ export declare function encodeStargateV2BridgePartial(amount: bigint, slippage: number, fee: bigint, isBusMode: boolean, isNative: boolean, composeMsg: Hex, extraOptions: Hex): Hex;
114
+ export declare function encodeStargateV2BridgeSimpleTaxi(asset: Address, stargatePool: Address, dstEid: number, receiver: Hex, refundReceiver: Address, amount: bigint, isNative: boolean, slippage: number, fee: bigint): Hex;
115
+ export declare function encodeStargateV2BridgeSimpleBus(asset: Address, stargatePool: Address, dstEid: number, receiver: Hex, refundReceiver: Address, amount: bigint, isNative: boolean, slippage: number, fee: bigint): Hex;
116
+ export declare function encodeAcrossBridgeToken(spokePool: Address, depositor: Address, sendingAssetId: Address, receivingAssetId: Address, amount: bigint, fixedFee: bigint, feePercentage: number, destinationChainId: number, receiver: Address, message: Hex): Hex;
117
+ export declare function encodeAcrossBridgeNative(spokePool: Address, depositor: Address, sendingAssetId: Address, receivingAssetId: Address, amount: bigint, fixedFee: bigint, feePercentage: number, destinationChainId: number, receiver: Address, message: Hex): Hex;
105
118
  export declare function encodePermit2TransferFrom(token: Address, receiver: Address, amount: bigint): Hex;
106
119
  export declare function encodeNextGenDexUnlock(singleton: Address, id: bigint, d: Hex): Hex;
107
120
  export declare function encodeBalancerV3FlashLoan(singleton: Address, poolId: bigint, asset: Address, receiver: Address, amount: bigint, flashData: Hex): Hex;
@@ -127,6 +140,7 @@ export declare function encodeGmxStyleSwap(currentData: Hex, tokenOut: Address,
127
140
  export declare function encodeKtxStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, cfg: any): Hex;
128
141
  export declare function encodeCurveStyleSwap(tokenOut: Address, receiver: Address, pool: Address, indexIn: bigint, indexOut: bigint, selectorId: bigint, cfg: any): Hex;
129
142
  export declare function encodeCurveNGStyleSwap(tokenOut: Address, receiver: Address, pool: Address, indexIn: bigint, indexOut: bigint, selectorId: bigint, cfg: any): Hex;
143
+ export declare function encodeWrapperSwap(currentData: Hex, assetOut: Address, receiver: Address, operation: any, cfg: any): Hex;
130
144
  export declare function encodeNextGenDexSettle(singleton: Address, nativeAmount: bigint): Hex;
131
145
  export declare function encodeNextGenDexSettleBalancer(singleton: Address, asset: Address, amountHint: bigint): Hex;
132
146
  export declare function encodeTransferIn(asset: Address, receiver: Address, amount: bigint): Hex;
@@ -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";
3
+ import { encodePacked, uint128, uint8, uint112, uint16, uint256, generateAmountBitmap, newbytes, bytes, getMorphoCollateral, getMorphoLoanAsset, } from "./utils";
4
4
  export var SweepType;
5
5
  (function (SweepType) {
6
6
  SweepType[SweepType["VALIDATE"] = 0] = "VALIDATE";
@@ -18,6 +18,12 @@ export var DodoSelector;
18
18
  DodoSelector[DodoSelector["SELL_BASE"] = 0] = "SELL_BASE";
19
19
  DodoSelector[DodoSelector["SELL_QUOTE"] = 1] = "SELL_QUOTE";
20
20
  })(DodoSelector || (DodoSelector = {}));
21
+ export var WrapOperation;
22
+ (function (WrapOperation) {
23
+ WrapOperation[WrapOperation["NATIVE"] = 0] = "NATIVE";
24
+ WrapOperation[WrapOperation["ERC4626_DEPOSIT"] = 1] = "ERC4626_DEPOSIT";
25
+ WrapOperation[WrapOperation["ERC4626_REDEEM"] = 2] = "ERC4626_REDEEM";
26
+ })(WrapOperation || (WrapOperation = {}));
21
27
  export var TransferIds;
22
28
  (function (TransferIds) {
23
29
  TransferIds[TransferIds["TRANSFER_FROM"] = 0] = "TRANSFER_FROM";
@@ -57,11 +63,11 @@ export var FlashLoanIds;
57
63
  FlashLoanIds[FlashLoanIds["AAVE_V3"] = 2] = "AAVE_V3";
58
64
  FlashLoanIds[FlashLoanIds["AAVE_V2"] = 3] = "AAVE_V2";
59
65
  })(FlashLoanIds || (FlashLoanIds = {}));
60
- export var ERC4646Ids;
61
- (function (ERC4646Ids) {
62
- ERC4646Ids[ERC4646Ids["DEPOSIT"] = 0] = "DEPOSIT";
63
- ERC4646Ids[ERC4646Ids["WITHDRAW"] = 1] = "WITHDRAW";
64
- })(ERC4646Ids || (ERC4646Ids = {}));
66
+ export var ERC4626Ids;
67
+ (function (ERC4626Ids) {
68
+ ERC4626Ids[ERC4626Ids["DEPOSIT"] = 0] = "DEPOSIT";
69
+ ERC4626Ids[ERC4626Ids["WITHDRAW"] = 1] = "WITHDRAW";
70
+ })(ERC4626Ids || (ERC4626Ids = {}));
65
71
  export var Gen2025ActionIds;
66
72
  (function (Gen2025ActionIds) {
67
73
  Gen2025ActionIds[Gen2025ActionIds["UNLOCK"] = 0] = "UNLOCK";
@@ -73,20 +79,21 @@ export var Gen2025ActionIds;
73
79
  })(Gen2025ActionIds || (Gen2025ActionIds = {}));
74
80
  export var ComposerCommands;
75
81
  (function (ComposerCommands) {
76
- ComposerCommands[ComposerCommands["SWAPS"] = 32] = "SWAPS";
77
- ComposerCommands[ComposerCommands["EXT_CALL"] = 64] = "EXT_CALL";
78
- ComposerCommands[ComposerCommands["LENDING"] = 96] = "LENDING";
79
- ComposerCommands[ComposerCommands["TRANSFERS"] = 128] = "TRANSFERS";
80
- ComposerCommands[ComposerCommands["PERMIT"] = 160] = "PERMIT";
81
- ComposerCommands[ComposerCommands["FLASH_LOAN"] = 192] = "FLASH_LOAN";
82
- ComposerCommands[ComposerCommands["ERC4646"] = 224] = "ERC4646";
83
- ComposerCommands[ComposerCommands["GEN_2025_SINGELTONS"] = 225] = "GEN_2025_SINGELTONS";
82
+ ComposerCommands[ComposerCommands["SWAPS"] = 16] = "SWAPS";
83
+ ComposerCommands[ComposerCommands["EXT_CALL"] = 32] = "EXT_CALL";
84
+ ComposerCommands[ComposerCommands["LENDING"] = 48] = "LENDING";
85
+ ComposerCommands[ComposerCommands["TRANSFERS"] = 64] = "TRANSFERS";
86
+ ComposerCommands[ComposerCommands["PERMIT"] = 80] = "PERMIT";
87
+ ComposerCommands[ComposerCommands["FLASH_LOAN"] = 96] = "FLASH_LOAN";
88
+ ComposerCommands[ComposerCommands["ERC4626"] = 112] = "ERC4626";
89
+ ComposerCommands[ComposerCommands["GEN_2025_SINGELTONS"] = 128] = "GEN_2025_SINGELTONS";
90
+ ComposerCommands[ComposerCommands["BRIDGING"] = 144] = "BRIDGING";
84
91
  })(ComposerCommands || (ComposerCommands = {}));
85
- export var ForwarderCommands;
86
- (function (ForwarderCommands) {
87
- ForwarderCommands[ForwarderCommands["EXT_CALL"] = 64] = "EXT_CALL";
88
- ForwarderCommands[ForwarderCommands["ASSET_HANDLING"] = 128] = "ASSET_HANDLING";
89
- })(ForwarderCommands || (ForwarderCommands = {}));
92
+ export var BridgeIds;
93
+ (function (BridgeIds) {
94
+ BridgeIds[BridgeIds["STARGATE_V2"] = 0] = "STARGATE_V2";
95
+ BridgeIds[BridgeIds["ACROSS"] = 10] = "ACROSS";
96
+ })(BridgeIds || (BridgeIds = {}));
90
97
  export var DexTypeMappings;
91
98
  (function (DexTypeMappings) {
92
99
  DexTypeMappings[DexTypeMappings["UNISWAP_V3_ID"] = 0] = "UNISWAP_V3_ID";
@@ -105,8 +112,8 @@ export var DexTypeMappings;
105
112
  DexTypeMappings[DexTypeMappings["LB_ID"] = 140] = "LB_ID";
106
113
  DexTypeMappings[DexTypeMappings["DODO_ID"] = 150] = "DODO_ID";
107
114
  DexTypeMappings[DexTypeMappings["SYNC_SWAP_ID"] = 160] = "SYNC_SWAP_ID";
108
- DexTypeMappings[DexTypeMappings["ERC4646_ID"] = 253] = "ERC4646_ID";
109
- DexTypeMappings[DexTypeMappings["NATIVE_WRAP_ID"] = 254] = "NATIVE_WRAP_ID";
115
+ DexTypeMappings[DexTypeMappings["ERC4626_ID"] = 253] = "ERC4626_ID";
116
+ DexTypeMappings[DexTypeMappings["ASSET_WRAP_ID"] = 254] = "ASSET_WRAP_ID";
110
117
  })(DexTypeMappings || (DexTypeMappings = {}));
111
118
  export var DexForkMappings;
112
119
  (function (DexForkMappings) {
@@ -118,6 +125,104 @@ export var DexForkMappings;
118
125
  DexForkMappings[DexForkMappings["BALANCER_V3"] = 0] = "BALANCER_V3";
119
126
  DexForkMappings[DexForkMappings["UNISWAP_V2"] = 0] = "UNISWAP_V2";
120
127
  })(DexForkMappings || (DexForkMappings = {}));
128
+ export function encodeExternalCall(target, value, data) {
129
+ return encodePacked(["uint8", "address", "uint112", "uint16", "bytes"], [uint8(ComposerCommands.EXT_CALL), target, uint112(value), uint16(data.length / 2 - 1), data]);
130
+ }
131
+ export function encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions) {
132
+ const partialData = encodeStargateV2BridgePartial(amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions);
133
+ return encodePacked(["uint8", "uint8", "address", "address", "uint32", "bytes32", "address", "bytes"], [
134
+ uint8(ComposerCommands.BRIDGING),
135
+ uint8(BridgeIds.STARGATE_V2),
136
+ asset,
137
+ stargatePool,
138
+ dstEid,
139
+ receiver,
140
+ refundReceiver,
141
+ partialData,
142
+ ]);
143
+ }
144
+ export function encodeStargateV2BridgePartial(amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions) {
145
+ return encodePacked(["uint128", "uint32", "uint128", "uint8", "uint16", "uint16", "bytes", "bytes"], [
146
+ generateAmountBitmap(uint128(amount), false, false, isNative),
147
+ slippage,
148
+ uint128(fee),
149
+ uint8(isBusMode ? 1 : 0),
150
+ uint16(composeMsg.length / 2 - 1),
151
+ uint16(extraOptions.length / 2 - 1),
152
+ composeMsg,
153
+ extraOptions,
154
+ ]);
155
+ }
156
+ export function encodeStargateV2BridgeSimpleTaxi(asset, stargatePool, dstEid, receiver, refundReceiver, amount, isNative, slippage, fee) {
157
+ return encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, false, isNative, newbytes(0), newbytes(0));
158
+ }
159
+ export function encodeStargateV2BridgeSimpleBus(asset, stargatePool, dstEid, receiver, refundReceiver, amount, isNative, slippage, fee) {
160
+ return encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, true, isNative, newbytes(0), newbytes(0));
161
+ }
162
+ export function encodeAcrossBridgeToken(spokePool, depositor, sendingAssetId, receivingAssetId, amount, fixedFee, feePercentage, destinationChainId, receiver, message) {
163
+ const bridgeData = encodePacked([
164
+ "uint8",
165
+ "uint8",
166
+ "address",
167
+ "address",
168
+ "address",
169
+ "address",
170
+ "uint128",
171
+ "uint128",
172
+ "uint32",
173
+ "uint32",
174
+ "address",
175
+ "uint16",
176
+ "bytes",
177
+ ], [
178
+ uint8(ComposerCommands.BRIDGING),
179
+ uint8(BridgeIds.ACROSS),
180
+ spokePool,
181
+ depositor,
182
+ sendingAssetId,
183
+ receivingAssetId,
184
+ generateAmountBitmap(uint128(amount), false, false, false),
185
+ fixedFee,
186
+ feePercentage,
187
+ destinationChainId,
188
+ receiver,
189
+ uint16(message.length / 2 - 1),
190
+ message,
191
+ ]);
192
+ return bridgeData;
193
+ }
194
+ export function encodeAcrossBridgeNative(spokePool, depositor, sendingAssetId, receivingAssetId, amount, fixedFee, feePercentage, destinationChainId, receiver, message) {
195
+ const bridgeData = encodePacked([
196
+ "uint8",
197
+ "uint8",
198
+ "address",
199
+ "address",
200
+ "address",
201
+ "address",
202
+ "uint128",
203
+ "uint128",
204
+ "uint32",
205
+ "uint32",
206
+ "address",
207
+ "uint16",
208
+ "bytes",
209
+ ], [
210
+ uint8(ComposerCommands.BRIDGING),
211
+ uint8(BridgeIds.ACROSS),
212
+ spokePool,
213
+ depositor,
214
+ sendingAssetId,
215
+ receivingAssetId,
216
+ generateAmountBitmap(uint128(amount), false, false, true),
217
+ fixedFee,
218
+ feePercentage,
219
+ destinationChainId,
220
+ receiver,
221
+ uint16(message.length / 2 - 1),
222
+ message,
223
+ ]);
224
+ return bridgeData;
225
+ }
121
226
  export function encodePermit2TransferFrom(token, receiver, amount) {
122
227
  return encodePacked(["uint8", "uint8", "address", "address", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.PERMIT2_TRANSFER_FROM), token, receiver, uint128(amount)]);
123
228
  }
@@ -176,7 +281,7 @@ export function encodeUniswapV4Take(singleton, asset, receiver, amount) {
176
281
  export function swapHead(amount, amountOutMin, assetIn) {
177
282
  return encodePacked(["uint8", "uint128", "uint128", "address"], [
178
283
  uint8(ComposerCommands.SWAPS),
179
- generateAmountBitmap(uint128(amount), false, false),
284
+ generateAmountBitmap(uint128(amount), false, false, false),
180
285
  uint128(amountOutMin),
181
286
  assetIn,
182
287
  ]);
@@ -235,15 +340,7 @@ export function encodeBalancerV2StyleSwap(currentData, tokenOut, receiver, poolI
235
340
  export function encodeLbStyleSwap(currentData, tokenOut, receiver, pool, swapForY, cfg) {
236
341
  if (cfg === DexPayConfig.FLASH)
237
342
  throw new Error("Invalidconfigforv2swap");
238
- return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8", "uint16"], [
239
- currentData,
240
- tokenOut,
241
- receiver,
242
- uint8(DexTypeMappings.LB_ID),
243
- pool,
244
- uint8(swapForY ? 1 : 0),
245
- uint16(uint256(cfg)),
246
- ]);
343
+ return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8", "uint8"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.LB_ID), pool, uint8(swapForY ? 1 : 0), uint8(uint256(cfg))]);
247
344
  }
248
345
  export function encodeSyncSwapStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
249
346
  if (cfg === DexPayConfig.FLASH)
@@ -314,12 +411,12 @@ export function encodeWooStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
314
411
  export function encodeGmxStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
315
412
  if (cfg === DexPayConfig.FLASH)
316
413
  throw new Error("NoflashforWoo");
317
- return encodePacked(["bytes", "address", "address", "uint8", "address", "uint16"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.GMX_ID), pool, uint16(uint256(cfg))]);
414
+ return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.GMX_ID), pool, uint8(uint256(cfg))]);
318
415
  }
319
416
  export function encodeKtxStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
320
417
  if (cfg === DexPayConfig.FLASH)
321
418
  throw new Error("NoflashforWoo");
322
- return encodePacked(["bytes", "address", "address", "uint8", "address", "uint16"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.KTX_ID), pool, uint16(uint256(cfg))]);
419
+ return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.KTX_ID), pool, uint8(uint256(cfg))]);
323
420
  }
324
421
  export function encodeCurveStyleSwap(tokenOut, receiver, pool, indexIn, indexOut, selectorId, cfg) {
325
422
  if (cfg === DexPayConfig.FLASH)
@@ -349,6 +446,16 @@ export function encodeCurveNGStyleSwap(tokenOut, receiver, pool, indexIn, indexO
349
446
  uint16(uint256(cfg)),
350
447
  ]);
351
448
  }
449
+ export function encodeWrapperSwap(currentData, assetOut, receiver, operation, cfg) {
450
+ return encodePacked(["bytes", "address", "address", "uint8", "uint8", "uint8"], [
451
+ currentData,
452
+ assetOut,
453
+ receiver,
454
+ uint8(DexTypeMappings.ASSET_WRAP_ID),
455
+ uint8(uint256(operation)),
456
+ uint8(uint256(cfg)),
457
+ ]);
458
+ }
352
459
  export function encodeNextGenDexSettle(singleton, nativeAmount) {
353
460
  return encodePacked(["uint8", "uint8", "address", "uint128"], [
354
461
  uint8(ComposerCommands.GEN_2025_SINGELTONS),
@@ -444,7 +551,7 @@ export function encodeMorphoDeposit(market, isShares, assets, receiver, data, mo
444
551
  uint8(LenderOps.DEPOSIT_LENDING_TOKEN),
445
552
  uint16(LenderIds.UP_TO_MORPHO),
446
553
  market,
447
- generateAmountBitmap(uint128(assets), isShares, false),
554
+ generateAmountBitmap(uint128(assets), isShares, false, false),
448
555
  receiver,
449
556
  morphoB,
450
557
  uint16(data.length / 2 - 1 > 0 ? data.length / 2 - 1 + 1 : 0),
@@ -454,20 +561,20 @@ export function encodeMorphoDeposit(market, isShares, assets, receiver, data, mo
454
561
  export function encodeErc4646Deposit(asset, vault, isShares, assets, receiver) {
455
562
  return encodePacked(["bytes", "uint8", "uint8", "address", "address", "uint128", "address"], [
456
563
  encodeApprove(asset, vault),
457
- uint8(ComposerCommands.ERC4646),
564
+ uint8(ComposerCommands.ERC4626),
458
565
  uint8(0),
459
566
  asset,
460
567
  vault,
461
- generateAmountBitmap(uint128(assets), isShares, false),
568
+ generateAmountBitmap(uint128(assets), isShares, false, false),
462
569
  receiver,
463
570
  ]);
464
571
  }
465
572
  export function encodeErc4646Withdraw(vault, isShares, assets, receiver) {
466
573
  return encodePacked(["uint8", "uint8", "address", "uint128", "address"], [
467
- uint8(ComposerCommands.ERC4646),
574
+ uint8(ComposerCommands.ERC4626),
468
575
  uint8(1),
469
576
  vault,
470
- generateAmountBitmap(uint128(assets), isShares, false),
577
+ generateAmountBitmap(uint128(assets), isShares, false, false),
471
578
  receiver,
472
579
  ]);
473
580
  }
@@ -477,7 +584,7 @@ export function encodeMorphoWithdraw(market, isShares, assets, receiver, morphoB
477
584
  uint8(LenderOps.WITHDRAW_LENDING_TOKEN),
478
585
  uint16(LenderIds.UP_TO_MORPHO),
479
586
  market,
480
- generateAmountBitmap(uint128(assets), isShares, false),
587
+ generateAmountBitmap(uint128(assets), isShares, false, false),
481
588
  receiver,
482
589
  morphoB,
483
590
  ]);
@@ -499,7 +606,7 @@ export function encodeMorphoBorrow(market, isShares, assets, receiver, morphoB)
499
606
  uint8(LenderOps.BORROW),
500
607
  uint16(LenderIds.UP_TO_MORPHO),
501
608
  market,
502
- generateAmountBitmap(uint128(assets), isShares, false),
609
+ generateAmountBitmap(uint128(assets), isShares, false, false),
503
610
  receiver,
504
611
  morphoB,
505
612
  ]);
@@ -511,7 +618,7 @@ export function encodeMorphoRepay(market, isShares, unsafe, assets, receiver, da
511
618
  uint8(LenderOps.REPAY),
512
619
  uint16(LenderIds.UP_TO_MORPHO),
513
620
  market,
514
- generateAmountBitmap(uint128(assets), isShares, unsafe),
621
+ generateAmountBitmap(uint128(assets), isShares, unsafe, false),
515
622
  receiver,
516
623
  morphoB,
517
624
  uint16(data.length / 2 - 1 > 0 ? data.length / 2 - 1 + 1 : 0),
@@ -0,0 +1,178 @@
1
+ import { type Hex, type Address } from "viem";
2
+ export declare enum SweepType {
3
+ VALIDATE = 0,
4
+ AMOUNT = 1
5
+ }
6
+ export declare enum DexPayConfig {
7
+ CALLER_PAYS = 0,
8
+ CONTRACT_PAYS = 1,
9
+ PRE_FUND = 2,
10
+ FLASH = 3
11
+ }
12
+ export declare enum DodoSelector {
13
+ SELL_BASE = 0,
14
+ SELL_QUOTE = 1
15
+ }
16
+ export declare enum WrapOperation {
17
+ NATIVE = 0,
18
+ ERC4626_DEPOSIT = 1,
19
+ ERC4626_REDEEM = 2
20
+ }
21
+ export declare enum TransferIds {
22
+ TRANSFER_FROM = 0,
23
+ SWEEP = 1,
24
+ WRAP_NATIVE = 2,
25
+ UNWRAP_WNATIVE = 3,
26
+ PERMIT2_TRANSFER_FROM = 4,
27
+ APPROVE = 5
28
+ }
29
+ export declare enum PermitIds {
30
+ TOKEN_PERMIT = 0,
31
+ AAVE_V3_CREDIT_PERMIT = 1,
32
+ ALLOW_CREDIT_PERMIT = 2
33
+ }
34
+ export declare enum LenderIds {
35
+ UP_TO_AAVE_V3 = 1000,
36
+ UP_TO_AAVE_V2 = 2000,
37
+ UP_TO_COMPOUND_V3 = 3000,
38
+ UP_TO_COMPOUND_V2 = 4000,
39
+ UP_TO_MORPHO = 5000
40
+ }
41
+ export declare enum LenderOps {
42
+ DEPOSIT = 0,
43
+ BORROW = 1,
44
+ REPAY = 2,
45
+ WITHDRAW = 3,
46
+ DEPOSIT_LENDING_TOKEN = 4,
47
+ WITHDRAW_LENDING_TOKEN = 5
48
+ }
49
+ export declare enum FlashLoanIds {
50
+ MORPHO = 0,
51
+ BALANCER_V2 = 1,
52
+ AAVE_V3 = 2,
53
+ AAVE_V2 = 3
54
+ }
55
+ export declare enum ERC4626Ids {
56
+ DEPOSIT = 0,
57
+ WITHDRAW = 1
58
+ }
59
+ export declare enum Gen2025ActionIds {
60
+ UNLOCK = 0,
61
+ UNI_V4_TAKE = 1,
62
+ UNI_V4_SETTLE = 2,
63
+ UNI_V4_SYNC = 3,
64
+ BAL_V3_TAKE = 4,
65
+ BAL_V3_SETTLE = 5
66
+ }
67
+ export declare enum ComposerCommands {
68
+ SWAPS = 16,
69
+ EXT_CALL = 32,
70
+ LENDING = 48,
71
+ TRANSFERS = 64,
72
+ PERMIT = 80,
73
+ FLASH_LOAN = 96,
74
+ ERC4626 = 112,
75
+ GEN_2025_SINGELTONS = 128,
76
+ BRIDGING = 144
77
+ }
78
+ export declare enum BridgeIds {
79
+ STARGATE_V2 = 0,
80
+ ACROSS = 10
81
+ }
82
+ export declare enum DexTypeMappings {
83
+ UNISWAP_V3_ID = 0,
84
+ UNISWAP_V2_ID = 1,
85
+ UNISWAP_V4_ID = 2,
86
+ IZI_ID = 5,
87
+ UNISWAP_V2_FOT_ID = 3,
88
+ CURVE_V1_STANDARD_ID = 64,
89
+ CURVE_RECEIVED_ID = 65,
90
+ CURVE_FORK_ID = 66,
91
+ WOO_FI_ID = 80,
92
+ GMX_ID = 90,
93
+ KTX_ID = 91,
94
+ BALANCER_V2_ID = 128,
95
+ BALANCER_V3_ID = 129,
96
+ LB_ID = 140,
97
+ DODO_ID = 150,
98
+ SYNC_SWAP_ID = 160,
99
+ ERC4626_ID = 253,
100
+ ASSET_WRAP_ID = 254
101
+ }
102
+ export declare enum DexForkMappings {
103
+ UNISWAP_V3 = 0,
104
+ IZI = 0,
105
+ ANY_V3 = 255,
106
+ ANY_IZI = 255,
107
+ UNISWAP_V4 = 0,
108
+ BALANCER_V3 = 0,
109
+ UNISWAP_V2 = 0
110
+ }
111
+ export declare function encodeExternalCall(target: Address, value: bigint, data: Hex): Hex;
112
+ export declare function encodeStargateV2Bridge(asset: Address, stargatePool: Address, dstEid: number, receiver: Hex, refundReceiver: Address, amount: bigint, slippage: number, fee: bigint, isBusMode: boolean, isNative: boolean, composeMsg: Hex, extraOptions: Hex): Hex;
113
+ export declare function encodeStargateV2BridgePartial(amount: bigint, slippage: number, fee: bigint, isBusMode: boolean, isNative: boolean, composeMsg: Hex, extraOptions: Hex): Hex;
114
+ export declare function encodeStargateV2BridgeSimpleTaxi(asset: Address, stargatePool: Address, dstEid: number, receiver: Hex, refundReceiver: Address, amount: bigint, isNative: boolean, slippage: number, fee: bigint): Hex;
115
+ export declare function encodeStargateV2BridgeSimpleBus(asset: Address, stargatePool: Address, dstEid: number, receiver: Hex, refundReceiver: Address, amount: bigint, isNative: boolean, slippage: number, fee: bigint): Hex;
116
+ export declare function encodeAcrossBridgeToken(spokePool: Address, depositor: Address, sendingAssetId: Address, receivingAssetId: Address, amount: bigint, fixedFee: bigint, feePercentage: number, destinationChainId: number, receiver: Address, message: Hex): Hex;
117
+ export declare function encodeAcrossBridgeNative(spokePool: Address, depositor: Address, sendingAssetId: Address, receivingAssetId: Address, amount: bigint, fixedFee: bigint, feePercentage: number, destinationChainId: number, receiver: Address, message: Hex): Hex;
118
+ export declare function encodePermit2TransferFrom(token: Address, receiver: Address, amount: bigint): Hex;
119
+ export declare function encodeNextGenDexUnlock(singleton: Address, id: bigint, d: Hex): Hex;
120
+ export declare function encodeBalancerV3FlashLoan(singleton: Address, poolId: bigint, asset: Address, receiver: Address, amount: bigint, flashData: Hex): Hex;
121
+ export declare function encodeBalancerV3FlashLoanData(take: Hex, flashData: Hex, settle: Hex): Hex;
122
+ export declare function encodeUniswapV4FlashLoan(singleton: Address, poolId: bigint, asset: Address, receiver: Address, amount: bigint, flashData: Hex): Hex;
123
+ export declare function encodeUniswapV4FlashLoanData(take: Hex, sync: Hex, flashData: Hex, settle: Hex): Hex;
124
+ export declare function encodeBalancerV3Take(singleton: Address, asset: Address, receiver: Address, amount: bigint): Hex;
125
+ export declare function encodeUniswapV4Sync(singleton: Address, asset: Address): Hex;
126
+ export declare function encodeUniswapV4Take(singleton: Address, asset: Address, receiver: Address, amount: bigint): Hex;
127
+ export declare function swapHead(amount: bigint, amountOutMin: bigint, assetIn: Address): Hex;
128
+ export declare function attachBranch(data: Hex, hops: bigint, splits: bigint, splitsData: Hex): Hex;
129
+ export declare function encodeUniswapV2StyleSwap(tokenOut: Address, receiver: Address, forkId: bigint, pool: Address, feeDenom: bigint, cfg: any, flashCalldata: Hex): Hex;
130
+ export declare function encodeUniswapV4StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, manager: Address, fee: number, tickSpacing: number, hooks: Address, hookData: Hex, cfg: any): Hex;
131
+ export declare function encodeBalancerV2StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, poolId: Hex, balancerVault: Address, cfg: any): Hex;
132
+ export declare function encodeLbStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, swapForY: boolean, cfg: any): Hex;
133
+ export declare function encodeSyncSwapStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, cfg: any): Hex;
134
+ export declare function encodeUniswapV3StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, forkId: bigint, pool: Address, feeTier: bigint, cfg: any, flashCalldata: Hex): Hex;
135
+ export declare function encodeIzumiStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, forkId: bigint, pool: Address, feeTier: bigint, cfg: any, flashCalldata: Hex): Hex;
136
+ export declare function encodeBalancerV3StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, balancerV3Vault: Address, pool: Address, cfg: any, poolUserData: Hex): Hex;
137
+ export declare function encodeDodoStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, selector: any, poolId: bigint, cfg: any, flashCalldata: Hex): Hex;
138
+ export declare function encodeWooStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, cfg: any): Hex;
139
+ export declare function encodeGmxStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, cfg: any): Hex;
140
+ export declare function encodeKtxStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, cfg: any): Hex;
141
+ export declare function encodeCurveStyleSwap(tokenOut: Address, receiver: Address, pool: Address, indexIn: bigint, indexOut: bigint, selectorId: bigint, cfg: any): Hex;
142
+ export declare function encodeCurveNGStyleSwap(tokenOut: Address, receiver: Address, pool: Address, indexIn: bigint, indexOut: bigint, selectorId: bigint, cfg: any): Hex;
143
+ export declare function encodeWrapperSwap(currentData: Hex, assetOut: Address, receiver: Address, operation: any, cfg: any): Hex;
144
+ export declare function encodeNextGenDexSettle(singleton: Address, nativeAmount: bigint): Hex;
145
+ export declare function encodeNextGenDexSettleBalancer(singleton: Address, asset: Address, amountHint: bigint): Hex;
146
+ export declare function encodeTransferIn(asset: Address, receiver: Address, amount: bigint): Hex;
147
+ export declare function encodeSweep(asset: Address, receiver: Address, amount: bigint, sweepType: any): Hex;
148
+ export declare function encodeWrap(amount: bigint, wrapTarget: Address): Hex;
149
+ export declare function encodeApprove(asset: Address, target: Address): Hex;
150
+ export declare function encodeUnwrap(target: Address, receiver: Address, amount: bigint, sweepType: any): Hex;
151
+ export declare function encodeBalancerV2FlashLoan(asset: Address, amount: bigint, poolId: number, data: Hex): Hex;
152
+ export declare function encodeFlashLoan(asset: Address, amount: bigint, pool: Address, poolType: number, poolId: number, data: Hex): Hex;
153
+ export declare function encodeUint8AndBytes(poolId: number, data: Hex): Hex;
154
+ export declare function encodeMorphoMarket(loanToken: Address, collateralToken: Address, oracle: Address, irm: Address, lltv: bigint): Hex;
155
+ export declare function encodeMorphoDepositCollateral(market: Hex, assets: bigint, receiver: Address, data: Hex, morphoB: Address, pId: bigint): Hex;
156
+ export declare function encodeMorphoDeposit(market: Hex, isShares: boolean, assets: bigint, receiver: Address, data: Hex, morphoB: Address, pId: bigint): Hex;
157
+ export declare function encodeErc4646Deposit(asset: Address, vault: Address, isShares: boolean, assets: bigint, receiver: Address): Hex;
158
+ export declare function encodeErc4646Withdraw(vault: Address, isShares: boolean, assets: bigint, receiver: Address): Hex;
159
+ export declare function encodeMorphoWithdraw(market: Hex, isShares: boolean, assets: bigint, receiver: Address, morphoB: Address): Hex;
160
+ export declare function encodeMorphoWithdrawCollateral(market: Hex, assets: bigint, receiver: Address, morphoB: Address): Hex;
161
+ export declare function encodeMorphoBorrow(market: Hex, isShares: boolean, assets: bigint, receiver: Address, morphoB: Address): Hex;
162
+ export declare function encodeMorphoRepay(market: Hex, isShares: boolean, unsafe: boolean, assets: bigint, receiver: Address, data: Hex, morphoB: Address, pId: bigint): Hex;
163
+ export declare function encodeAaveDeposit(token: Address, amount: bigint, receiver: Address, pool: Address): Hex;
164
+ export declare function encodeAaveBorrow(token: Address, amount: bigint, receiver: Address, mode: bigint, pool: Address): Hex;
165
+ export declare function encodeAaveRepay(token: Address, amount: bigint, receiver: Address, mode: bigint, dToken: Address, pool: Address): Hex;
166
+ export declare function encodeAaveWithdraw(token: Address, amount: bigint, receiver: Address, aToken: Address, pool: Address): Hex;
167
+ export declare function encodeAaveV2Deposit(token: Address, amount: bigint, receiver: Address, pool: Address): Hex;
168
+ export declare function encodeAaveV2Borrow(token: Address, amount: bigint, receiver: Address, mode: bigint, pool: Address): Hex;
169
+ export declare function encodeAaveV2Repay(token: Address, amount: bigint, receiver: Address, mode: bigint, dToken: Address, pool: Address): Hex;
170
+ export declare function encodeAaveV2Withdraw(token: Address, amount: bigint, receiver: Address, aToken: Address, pool: Address): Hex;
171
+ export declare function encodeCompoundV3Deposit(token: Address, amount: bigint, receiver: Address, comet: Address): Hex;
172
+ export declare function encodeCompoundV3Borrow(token: Address, amount: bigint, receiver: Address, comet: Address): Hex;
173
+ export declare function encodeCompoundV3Repay(token: Address, amount: bigint, receiver: Address, comet: Address): Hex;
174
+ export declare function encodeCompoundV3Withdraw(token: Address, amount: bigint, receiver: Address, comet: Address, isBase: boolean): Hex;
175
+ export declare function encodeCompoundV2Deposit(token: Address, amount: bigint, receiver: Address, cToken: Address): Hex;
176
+ export declare function encodeCompoundV2Borrow(token: Address, amount: bigint, receiver: Address, cToken: Address): Hex;
177
+ export declare function encodeCompoundV2Repay(token: Address, amount: bigint, receiver: Address, cToken: Address): Hex;
178
+ export declare function encodeCompoundV2Withdraw(token: Address, amount: bigint, receiver: Address, cToken: Address): Hex;