@1delta/calldatalib 0.0.20 → 0.0.21

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.
@@ -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),
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type Hex, type Address } from "viem";
2
- export declare const _PRE_PARAM: bigint;
2
+ export declare const _NATIVE_FLAG: bigint;
3
3
  export declare const _SHARES_MASK: bigint;
4
4
  export declare const _UNSAFE_AMOUNT: bigint;
5
5
  export declare function shiftLeft(value: bigint | number, bits: number): bigint;
@@ -12,7 +12,7 @@ export declare function uint112(value: number | bigint): bigint;
12
12
  export declare function uint128(value: number | bigint): bigint;
13
13
  export declare function uint256(value: number | bigint): bigint;
14
14
  export declare function encodePacked(types: string[], values: any[]): Hex;
15
- export declare function generateAmountBitmap(amount: bigint, useShares: boolean, unsafe: boolean): bigint;
15
+ export declare function generateAmountBitmap(amount: bigint, useShares: boolean, unsafe: boolean, native: boolean): bigint;
16
16
  export declare function getMorphoCollateral(market: Hex): Address;
17
17
  export declare function getMorphoLoanAsset(market: Hex): Address;
18
18
  export declare function newbytes(length: number): Hex;
package/dist/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { encodePacked as abiEncodePacked } from "viem";
2
- export const _PRE_PARAM = 1n << 127n;
2
+ export const _NATIVE_FLAG = 1n << 127n;
3
3
  export const _SHARES_MASK = 1n << 126n;
4
4
  export const _UNSAFE_AMOUNT = 1n << 125n;
5
5
  export function shiftLeft(value, bits) {
@@ -35,12 +35,14 @@ export function encodePacked(types, values) {
35
35
  }
36
36
  return abiEncodePacked(types, values);
37
37
  }
38
- export function generateAmountBitmap(amount, useShares, unsafe) {
38
+ export function generateAmountBitmap(amount, useShares, unsafe, native) {
39
39
  let am = amount;
40
40
  if (useShares)
41
41
  am = uint128((am & ~BigInt(_SHARES_MASK)) | _SHARES_MASK);
42
42
  if (unsafe)
43
43
  am = uint128((am & ~BigInt(_UNSAFE_AMOUNT)) | _UNSAFE_AMOUNT);
44
+ if (native)
45
+ am = uint128((am & ~BigInt(_NATIVE_FLAG)) | _NATIVE_FLAG);
44
46
  return am;
45
47
  }
46
48
  export function getMorphoCollateral(market) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1delta/calldatalib",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "Generated CalldataLib TypeScript functions for 1delta smart contracts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",