@1delta/calldatalib 0.0.35 → 0.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -203,7 +203,7 @@ function encodeExternalCall(target, value, useSelfBalance, data) {
203
203
  return (0, utils_js_1.encodePacked)(["uint8", "address", "uint128", "uint16", "bytes"], [
204
204
  (0, utils_js_1.uint8)(ComposerCommands.EXT_CALL),
205
205
  target,
206
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(value), false, false, useSelfBalance),
206
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(value), false, useSelfBalance),
207
207
  (0, utils_js_1.uint16)(data.length / 2 - 1),
208
208
  data,
209
209
  ]);
@@ -212,7 +212,7 @@ function encodeTryExternalCall(target, value, useSelfBalance, rOnFailure, data,
212
212
  return (0, utils_js_1.encodePacked)(["uint8", "address", "uint128", "uint16", "bytes", "uint8", "uint16", "bytes"], [
213
213
  (0, utils_js_1.uint8)(ComposerCommands.EXT_TRY_CALL),
214
214
  target,
215
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(value), false, false, useSelfBalance),
215
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(value), false, useSelfBalance),
216
216
  (0, utils_js_1.uint16)(data.length / 2 - 1),
217
217
  data,
218
218
  (0, utils_js_1.uint8)(rOnFailure ? 0 : 1),
@@ -238,7 +238,7 @@ function encodePermit(permitId, target, data) {
238
238
  }
239
239
  function encodeStargateV2BridgePartial(amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions) {
240
240
  return (0, utils_js_1.encodePacked)(["uint128", "uint32", "uint128", "uint8", "uint16", "uint16", "bytes", "bytes"], [
241
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, false, isNative),
241
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, isNative),
242
242
  slippage,
243
243
  (0, utils_js_1.uint128)(fee),
244
244
  (0, utils_js_1.uint8)(isBusMode ? 1 : 0),
@@ -276,7 +276,7 @@ function encodeAcrossBridgeToken(spokePool, depositor, sendingAssetId, receiving
276
276
  depositor,
277
277
  sendingAssetId,
278
278
  receivingAssetId,
279
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, false, false),
279
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, false),
280
280
  fixedFee,
281
281
  feePercentage,
282
282
  destinationChainId,
@@ -308,7 +308,7 @@ function encodeAcrossBridgeNative(spokePool, depositor, sendingAssetId, receivin
308
308
  depositor,
309
309
  sendingAssetId,
310
310
  receivingAssetId,
311
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, false, true),
311
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, true),
312
312
  fixedFee,
313
313
  feePercentage,
314
314
  destinationChainId,
@@ -376,7 +376,7 @@ function encodeUniswapV4Take(singleton, asset, receiver, amount) {
376
376
  function swapHead(amount, amountOutMin, assetIn) {
377
377
  return (0, utils_js_1.encodePacked)(["uint8", "uint128", "uint128", "address"], [
378
378
  (0, utils_js_1.uint8)(ComposerCommands.SWAPS),
379
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, false, false),
379
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, false),
380
380
  (0, utils_js_1.uint128)(amountOutMin),
381
381
  assetIn,
382
382
  ]);
@@ -646,7 +646,7 @@ function encodeMorphoDeposit(market, isShares, assets, receiver, data, morphoB,
646
646
  (0, utils_js_1.uint8)(LenderOps.DEPOSIT_LENDING_TOKEN),
647
647
  (0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
648
648
  market,
649
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false, false),
649
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
650
650
  receiver,
651
651
  morphoB,
652
652
  (0, utils_js_1.uint16)(data.length / 2 - 1 > 0 ? data.length / 2 - 1 + 1 : 0),
@@ -660,7 +660,7 @@ function encodeErc4646Deposit(asset, vault, isShares, assets, receiver) {
660
660
  (0, utils_js_1.uint8)(0),
661
661
  asset,
662
662
  vault,
663
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false, false),
663
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
664
664
  receiver,
665
665
  ]);
666
666
  }
@@ -669,7 +669,7 @@ function encodeErc4646Withdraw(vault, isShares, assets, receiver) {
669
669
  (0, utils_js_1.uint8)(ComposerCommands.ERC4626),
670
670
  (0, utils_js_1.uint8)(1),
671
671
  vault,
672
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false, false),
672
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
673
673
  receiver,
674
674
  ]);
675
675
  }
@@ -679,7 +679,7 @@ function encodeMorphoWithdraw(market, isShares, assets, receiver, morphoB) {
679
679
  (0, utils_js_1.uint8)(LenderOps.WITHDRAW_LENDING_TOKEN),
680
680
  (0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
681
681
  market,
682
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false, false),
682
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
683
683
  receiver,
684
684
  morphoB,
685
685
  ]);
@@ -701,19 +701,19 @@ function encodeMorphoBorrow(market, isShares, assets, receiver, morphoB) {
701
701
  (0, utils_js_1.uint8)(LenderOps.BORROW),
702
702
  (0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
703
703
  market,
704
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false, false),
704
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
705
705
  receiver,
706
706
  morphoB,
707
707
  ]);
708
708
  }
709
- function encodeMorphoRepay(market, isShares, unsafe, assets, receiver, data, morphoB, pId) {
709
+ function encodeMorphoRepay(market, isShares, assets, receiver, data, morphoB, pId) {
710
710
  return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "bytes", "uint128", "address", "address", "uint16", "bytes"], [
711
711
  encodeApprove((0, utils_js_1.getMorphoLoanAsset)(market), morphoB),
712
712
  (0, utils_js_1.uint8)(ComposerCommands.LENDING),
713
713
  (0, utils_js_1.uint8)(LenderOps.REPAY),
714
714
  (0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
715
715
  market,
716
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, unsafe, false),
716
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
717
717
  receiver,
718
718
  morphoB,
719
719
  (0, utils_js_1.uint16)(data.length / 2 - 1 > 0 ? data.length / 2 - 1 + 1 : 0),
package/dist/cjs/utils.js CHANGED
@@ -53,14 +53,12 @@ function encodePacked(types, values) {
53
53
  }
54
54
  return (0, viem_1.encodePacked)(types, values);
55
55
  }
56
- function generateAmountBitmap(amount, useShares, unsafe, native) {
56
+ function generateAmountBitmap(amount, useShares, native) {
57
57
  let am = amount;
58
- if (useShares)
59
- am = uint128((am & ~BigInt(exports._SHARES_MASK)) | exports._SHARES_MASK);
60
- if (unsafe)
61
- am = uint128((am & ~BigInt(exports._UNSAFE_AMOUNT)) | exports._UNSAFE_AMOUNT);
62
58
  if (native)
63
59
  am = uint128((am & ~BigInt(exports._NATIVE_FLAG)) | exports._NATIVE_FLAG);
60
+ if (useShares)
61
+ am = uint128((am & ~BigInt(exports._SHARES_MASK)) | exports._SHARES_MASK);
64
62
  return am;
65
63
  }
66
64
  function getMorphoCollateral(market) {
@@ -130,7 +130,7 @@ export function encodeExternalCall(target, value, useSelfBalance, data) {
130
130
  return encodePacked(["uint8", "address", "uint128", "uint16", "bytes"], [
131
131
  uint8(ComposerCommands.EXT_CALL),
132
132
  target,
133
- generateAmountBitmap(uint128(value), false, false, useSelfBalance),
133
+ generateAmountBitmap(uint128(value), false, useSelfBalance),
134
134
  uint16(data.length / 2 - 1),
135
135
  data,
136
136
  ]);
@@ -139,7 +139,7 @@ export function encodeTryExternalCall(target, value, useSelfBalance, rOnFailure,
139
139
  return encodePacked(["uint8", "address", "uint128", "uint16", "bytes", "uint8", "uint16", "bytes"], [
140
140
  uint8(ComposerCommands.EXT_TRY_CALL),
141
141
  target,
142
- generateAmountBitmap(uint128(value), false, false, useSelfBalance),
142
+ generateAmountBitmap(uint128(value), false, useSelfBalance),
143
143
  uint16(data.length / 2 - 1),
144
144
  data,
145
145
  uint8(rOnFailure ? 0 : 1),
@@ -165,7 +165,7 @@ export function encodePermit(permitId, target, data) {
165
165
  }
166
166
  export function encodeStargateV2BridgePartial(amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions) {
167
167
  return encodePacked(["uint128", "uint32", "uint128", "uint8", "uint16", "uint16", "bytes", "bytes"], [
168
- generateAmountBitmap(uint128(amount), false, false, isNative),
168
+ generateAmountBitmap(uint128(amount), false, isNative),
169
169
  slippage,
170
170
  uint128(fee),
171
171
  uint8(isBusMode ? 1 : 0),
@@ -203,7 +203,7 @@ export function encodeAcrossBridgeToken(spokePool, depositor, sendingAssetId, re
203
203
  depositor,
204
204
  sendingAssetId,
205
205
  receivingAssetId,
206
- generateAmountBitmap(uint128(amount), false, false, false),
206
+ generateAmountBitmap(uint128(amount), false, false),
207
207
  fixedFee,
208
208
  feePercentage,
209
209
  destinationChainId,
@@ -235,7 +235,7 @@ export function encodeAcrossBridgeNative(spokePool, depositor, sendingAssetId, r
235
235
  depositor,
236
236
  sendingAssetId,
237
237
  receivingAssetId,
238
- generateAmountBitmap(uint128(amount), false, false, true),
238
+ generateAmountBitmap(uint128(amount), false, true),
239
239
  fixedFee,
240
240
  feePercentage,
241
241
  destinationChainId,
@@ -303,7 +303,7 @@ export function encodeUniswapV4Take(singleton, asset, receiver, amount) {
303
303
  export function swapHead(amount, amountOutMin, assetIn) {
304
304
  return encodePacked(["uint8", "uint128", "uint128", "address"], [
305
305
  uint8(ComposerCommands.SWAPS),
306
- generateAmountBitmap(uint128(amount), false, false, false),
306
+ generateAmountBitmap(uint128(amount), false, false),
307
307
  uint128(amountOutMin),
308
308
  assetIn,
309
309
  ]);
@@ -573,7 +573,7 @@ export function encodeMorphoDeposit(market, isShares, assets, receiver, data, mo
573
573
  uint8(LenderOps.DEPOSIT_LENDING_TOKEN),
574
574
  uint16(LenderIds.UP_TO_MORPHO),
575
575
  market,
576
- generateAmountBitmap(uint128(assets), isShares, false, false),
576
+ generateAmountBitmap(uint128(assets), isShares, false),
577
577
  receiver,
578
578
  morphoB,
579
579
  uint16(data.length / 2 - 1 > 0 ? data.length / 2 - 1 + 1 : 0),
@@ -587,7 +587,7 @@ export function encodeErc4646Deposit(asset, vault, isShares, assets, receiver) {
587
587
  uint8(0),
588
588
  asset,
589
589
  vault,
590
- generateAmountBitmap(uint128(assets), isShares, false, false),
590
+ generateAmountBitmap(uint128(assets), isShares, false),
591
591
  receiver,
592
592
  ]);
593
593
  }
@@ -596,7 +596,7 @@ export function encodeErc4646Withdraw(vault, isShares, assets, receiver) {
596
596
  uint8(ComposerCommands.ERC4626),
597
597
  uint8(1),
598
598
  vault,
599
- generateAmountBitmap(uint128(assets), isShares, false, false),
599
+ generateAmountBitmap(uint128(assets), isShares, false),
600
600
  receiver,
601
601
  ]);
602
602
  }
@@ -606,7 +606,7 @@ export function encodeMorphoWithdraw(market, isShares, assets, receiver, morphoB
606
606
  uint8(LenderOps.WITHDRAW_LENDING_TOKEN),
607
607
  uint16(LenderIds.UP_TO_MORPHO),
608
608
  market,
609
- generateAmountBitmap(uint128(assets), isShares, false, false),
609
+ generateAmountBitmap(uint128(assets), isShares, false),
610
610
  receiver,
611
611
  morphoB,
612
612
  ]);
@@ -628,19 +628,19 @@ export function encodeMorphoBorrow(market, isShares, assets, receiver, morphoB)
628
628
  uint8(LenderOps.BORROW),
629
629
  uint16(LenderIds.UP_TO_MORPHO),
630
630
  market,
631
- generateAmountBitmap(uint128(assets), isShares, false, false),
631
+ generateAmountBitmap(uint128(assets), isShares, false),
632
632
  receiver,
633
633
  morphoB,
634
634
  ]);
635
635
  }
636
- export function encodeMorphoRepay(market, isShares, unsafe, assets, receiver, data, morphoB, pId) {
636
+ export function encodeMorphoRepay(market, isShares, assets, receiver, data, morphoB, pId) {
637
637
  return encodePacked(["bytes", "uint8", "uint8", "uint16", "bytes", "uint128", "address", "address", "uint16", "bytes"], [
638
638
  encodeApprove(getMorphoLoanAsset(market), morphoB),
639
639
  uint8(ComposerCommands.LENDING),
640
640
  uint8(LenderOps.REPAY),
641
641
  uint16(LenderIds.UP_TO_MORPHO),
642
642
  market,
643
- generateAmountBitmap(uint128(assets), isShares, unsafe, false),
643
+ generateAmountBitmap(uint128(assets), isShares, false),
644
644
  receiver,
645
645
  morphoB,
646
646
  uint16(data.length / 2 - 1 > 0 ? data.length / 2 - 1 + 1 : 0),
package/dist/esm/utils.js CHANGED
@@ -35,14 +35,12 @@ export function encodePacked(types, values) {
35
35
  }
36
36
  return abiEncodePacked(types, values);
37
37
  }
38
- export function generateAmountBitmap(amount, useShares, unsafe, native) {
38
+ export function generateAmountBitmap(amount, useShares, native) {
39
39
  let am = amount;
40
- if (useShares)
41
- am = uint128((am & ~BigInt(_SHARES_MASK)) | _SHARES_MASK);
42
- if (unsafe)
43
- am = uint128((am & ~BigInt(_UNSAFE_AMOUNT)) | _UNSAFE_AMOUNT);
44
40
  if (native)
45
41
  am = uint128((am & ~BigInt(_NATIVE_FLAG)) | _NATIVE_FLAG);
42
+ if (useShares)
43
+ am = uint128((am & ~BigInt(_SHARES_MASK)) | _SHARES_MASK);
46
44
  return am;
47
45
  }
48
46
  export function getMorphoCollateral(market) {
@@ -162,7 +162,7 @@ export declare function encodeErc4646Withdraw(vault: Address, isShares: boolean,
162
162
  export declare function encodeMorphoWithdraw(market: Hex, isShares: boolean, assets: bigint, receiver: Address, morphoB: Address): Hex;
163
163
  export declare function encodeMorphoWithdrawCollateral(market: Hex, assets: bigint, receiver: Address, morphoB: Address): Hex;
164
164
  export declare function encodeMorphoBorrow(market: Hex, isShares: boolean, assets: bigint, receiver: Address, morphoB: Address): Hex;
165
- export declare function encodeMorphoRepay(market: Hex, isShares: boolean, unsafe: boolean, assets: bigint, receiver: Address, data: Hex, morphoB: Address, pId: bigint): Hex;
165
+ export declare function encodeMorphoRepay(market: Hex, isShares: boolean, assets: bigint, receiver: Address, data: Hex, morphoB: Address, pId: bigint): Hex;
166
166
  export declare function encodeAaveDeposit(token: Address, amount: bigint, receiver: Address, pool: Address): Hex;
167
167
  export declare function encodeAaveBorrow(token: Address, amount: bigint, receiver: Address, mode: bigint, pool: Address): Hex;
168
168
  export declare function encodeAaveRepay(token: Address, amount: bigint, receiver: Address, mode: bigint, dToken: Address, pool: Address): Hex;
@@ -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, native: boolean): bigint;
15
+ export declare function generateAmountBitmap(amount: bigint, useShares: 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1delta/calldatalib",
3
- "version": "0.0.35",
3
+ "version": "0.0.38",
4
4
  "description": "Generated CalldataLib TypeScript functions for 1delta smart contracts",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",