@1delta/calldatalib 0.0.45 → 0.0.49

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.
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DexForkMappings = exports.DexTypeMappings = exports.SiloV2CollateralType = exports.CompoundV2Selector = exports.BridgeIds = exports.ComposerCommands = exports.Gen2025ActionIds = exports.ERC4626Ids = exports.FlashLoanIds = exports.LenderOps = exports.LenderIds = exports.PermitIds = exports.TransferIds = exports.WrapOperation = exports.DodoSelector = exports.DexPayConfig = exports.SweepType = void 0;
4
4
  exports.encodeExternalCall = encodeExternalCall;
5
5
  exports.encodeTryExternalCall = encodeTryExternalCall;
6
+ exports.encodeExternalCallWithReplace = encodeExternalCallWithReplace;
7
+ exports.encodeTryExternalCallWithReplace = encodeTryExternalCallWithReplace;
6
8
  exports.encodeStargateV2Bridge = encodeStargateV2Bridge;
7
9
  exports.encodePermit = encodePermit;
8
10
  exports.encodeStargateV2BridgePartial = encodeStargateV2BridgePartial;
@@ -47,6 +49,7 @@ exports.encodeNextGenDexSettleBalancer = encodeNextGenDexSettleBalancer;
47
49
  exports.encodeTransferIn = encodeTransferIn;
48
50
  exports.encodeSweep = encodeSweep;
49
51
  exports.encodeWrap = encodeWrap;
52
+ exports.encodeWrapWithReceiver = encodeWrapWithReceiver;
50
53
  exports.encodeApprove = encodeApprove;
51
54
  exports.encodeUnwrap = encodeUnwrap;
52
55
  exports.encodeBalancerV2FlashLoan = encodeBalancerV2FlashLoan;
@@ -55,7 +58,7 @@ exports.encodeUint8AndBytes = encodeUint8AndBytes;
55
58
  exports.encodeMorphoMarket = encodeMorphoMarket;
56
59
  exports.encodeMorphoDepositCollateral = encodeMorphoDepositCollateral;
57
60
  exports.encodeMorphoDeposit = encodeMorphoDeposit;
58
- exports.encodeErc4646Deposit = encodeErc4646Deposit;
61
+ exports.encodeErc4626Deposit = encodeErc4626Deposit;
59
62
  exports.encodeErc4646Withdraw = encodeErc4646Withdraw;
60
63
  exports.encodeMorphoWithdraw = encodeMorphoWithdraw;
61
64
  exports.encodeMorphoWithdrawCollateral = encodeMorphoWithdrawCollateral;
@@ -115,6 +118,7 @@ var TransferIds;
115
118
  TransferIds[TransferIds["UNWRAP_WNATIVE"] = 3] = "UNWRAP_WNATIVE";
116
119
  TransferIds[TransferIds["PERMIT2_TRANSFER_FROM"] = 4] = "PERMIT2_TRANSFER_FROM";
117
120
  TransferIds[TransferIds["APPROVE"] = 5] = "APPROVE";
121
+ TransferIds[TransferIds["WRAP"] = 6] = "WRAP";
118
122
  })(TransferIds || (exports.TransferIds = TransferIds = {}));
119
123
  var PermitIds;
120
124
  (function (PermitIds) {
@@ -166,6 +170,8 @@ var ComposerCommands;
166
170
  ComposerCommands[ComposerCommands["SWAPS"] = 16] = "SWAPS";
167
171
  ComposerCommands[ComposerCommands["EXT_CALL"] = 32] = "EXT_CALL";
168
172
  ComposerCommands[ComposerCommands["EXT_TRY_CALL"] = 33] = "EXT_TRY_CALL";
173
+ ComposerCommands[ComposerCommands["EXT_CALL_WITH_REPLACE"] = 34] = "EXT_CALL_WITH_REPLACE";
174
+ ComposerCommands[ComposerCommands["EXT_TRY_CALL_WITH_REPLACE"] = 35] = "EXT_TRY_CALL_WITH_REPLACE";
169
175
  ComposerCommands[ComposerCommands["LENDING"] = 48] = "LENDING";
170
176
  ComposerCommands[ComposerCommands["TRANSFERS"] = 64] = "TRANSFERS";
171
177
  ComposerCommands[ComposerCommands["PERMIT"] = 80] = "PERMIT";
@@ -245,6 +251,31 @@ function encodeTryExternalCall(target, value, useSelfBalance, rOnFailure, data,
245
251
  catchData,
246
252
  ]);
247
253
  }
254
+ function encodeExternalCallWithReplace(target, value, useSelfBalance, token, replaceOffset, data) {
255
+ return (0, utils_js_1.encodePacked)(["uint8", "address", "uint128", "address", "uint16", "uint16", "bytes"], [
256
+ (0, utils_js_1.uint8)(ComposerCommands.EXT_CALL_WITH_REPLACE),
257
+ target,
258
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(value), false, useSelfBalance),
259
+ token,
260
+ replaceOffset,
261
+ (0, utils_js_1.uint16)(data.length / 2 - 1),
262
+ data,
263
+ ]);
264
+ }
265
+ function encodeTryExternalCallWithReplace(target, value, useSelfBalance, token, replaceOffset, data, rOnFailure, catchData) {
266
+ return (0, utils_js_1.encodePacked)(["uint8", "address", "uint128", "address", "uint16", "uint16", "uint8", "uint16", "bytes", "bytes"], [
267
+ (0, utils_js_1.uint8)(ComposerCommands.EXT_TRY_CALL_WITH_REPLACE),
268
+ target,
269
+ (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(value), false, useSelfBalance),
270
+ token,
271
+ replaceOffset,
272
+ (0, utils_js_1.uint16)(data.length / 2 - 1),
273
+ (0, utils_js_1.uint8)(rOnFailure ? 0 : 1),
274
+ (0, utils_js_1.uint16)(catchData.length / 2 - 1),
275
+ data,
276
+ catchData,
277
+ ]);
278
+ }
248
279
  function encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions) {
249
280
  const partialData = encodeStargateV2BridgePartial(amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions);
250
281
  return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "uint32", "bytes32", "address", "bytes"], [
@@ -417,12 +448,7 @@ function encodeUniswapV4Take(singleton, asset, receiver, amount) {
417
448
  ]);
418
449
  }
419
450
  function swapHead(amount, amountOutMin, assetIn) {
420
- return (0, utils_js_1.encodePacked)(["uint8", "uint128", "uint128", "address"], [
421
- (0, utils_js_1.uint8)(ComposerCommands.SWAPS),
422
- (0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, false),
423
- (0, utils_js_1.uint128)(amountOutMin),
424
- assetIn,
425
- ]);
451
+ return (0, utils_js_1.encodePacked)(["uint8", "uint128", "uint128", "address"], [(0, utils_js_1.uint8)(ComposerCommands.SWAPS), (0, utils_js_1.uint128)(amount), (0, utils_js_1.uint128)(amountOutMin), assetIn]);
426
452
  }
427
453
  function attachBranch(data, hops, splits, splitsData) {
428
454
  if (hops !== 0n && splits !== 0n)
@@ -627,6 +653,9 @@ function encodeWrap(amount, wrapTarget) {
627
653
  (0, utils_js_1.uint128)(amount),
628
654
  ]);
629
655
  }
656
+ function encodeWrapWithReceiver(amount, weth, receiver) {
657
+ return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "uint128"], [(0, utils_js_1.uint8)(ComposerCommands.TRANSFERS), (0, utils_js_1.uint8)(TransferIds.WRAP), weth, receiver, (0, utils_js_1.uint128)(amount)]);
658
+ }
630
659
  function encodeApprove(asset, target) {
631
660
  return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address"], [(0, utils_js_1.uint8)(ComposerCommands.TRANSFERS), (0, utils_js_1.uint8)(TransferIds.APPROVE), asset, target]);
632
661
  }
@@ -696,7 +725,7 @@ function encodeMorphoDeposit(market, isShares, assets, receiver, data, morphoB,
696
725
  data.length / 2 - 1 === 0 ? (0, utils_js_1.newbytes)(0) : encodeUint8AndBytes((0, utils_js_1.uint8)(pId), data),
697
726
  ]);
698
727
  }
699
- function encodeErc4646Deposit(asset, vault, isShares, assets, receiver) {
728
+ function encodeErc4626Deposit(asset, vault, isShares, assets, receiver) {
700
729
  return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "address", "address", "uint128", "address"], [
701
730
  encodeApprove(asset, vault),
702
731
  (0, utils_js_1.uint8)(ComposerCommands.ERC4626),
@@ -32,6 +32,7 @@ export var TransferIds;
32
32
  TransferIds[TransferIds["UNWRAP_WNATIVE"] = 3] = "UNWRAP_WNATIVE";
33
33
  TransferIds[TransferIds["PERMIT2_TRANSFER_FROM"] = 4] = "PERMIT2_TRANSFER_FROM";
34
34
  TransferIds[TransferIds["APPROVE"] = 5] = "APPROVE";
35
+ TransferIds[TransferIds["WRAP"] = 6] = "WRAP";
35
36
  })(TransferIds || (TransferIds = {}));
36
37
  export var PermitIds;
37
38
  (function (PermitIds) {
@@ -83,6 +84,8 @@ export var ComposerCommands;
83
84
  ComposerCommands[ComposerCommands["SWAPS"] = 16] = "SWAPS";
84
85
  ComposerCommands[ComposerCommands["EXT_CALL"] = 32] = "EXT_CALL";
85
86
  ComposerCommands[ComposerCommands["EXT_TRY_CALL"] = 33] = "EXT_TRY_CALL";
87
+ ComposerCommands[ComposerCommands["EXT_CALL_WITH_REPLACE"] = 34] = "EXT_CALL_WITH_REPLACE";
88
+ ComposerCommands[ComposerCommands["EXT_TRY_CALL_WITH_REPLACE"] = 35] = "EXT_TRY_CALL_WITH_REPLACE";
86
89
  ComposerCommands[ComposerCommands["LENDING"] = 48] = "LENDING";
87
90
  ComposerCommands[ComposerCommands["TRANSFERS"] = 64] = "TRANSFERS";
88
91
  ComposerCommands[ComposerCommands["PERMIT"] = 80] = "PERMIT";
@@ -162,6 +165,31 @@ export function encodeTryExternalCall(target, value, useSelfBalance, rOnFailure,
162
165
  catchData,
163
166
  ]);
164
167
  }
168
+ export function encodeExternalCallWithReplace(target, value, useSelfBalance, token, replaceOffset, data) {
169
+ return encodePacked(["uint8", "address", "uint128", "address", "uint16", "uint16", "bytes"], [
170
+ uint8(ComposerCommands.EXT_CALL_WITH_REPLACE),
171
+ target,
172
+ generateAmountBitmap(uint128(value), false, useSelfBalance),
173
+ token,
174
+ replaceOffset,
175
+ uint16(data.length / 2 - 1),
176
+ data,
177
+ ]);
178
+ }
179
+ export function encodeTryExternalCallWithReplace(target, value, useSelfBalance, token, replaceOffset, data, rOnFailure, catchData) {
180
+ return encodePacked(["uint8", "address", "uint128", "address", "uint16", "uint16", "uint8", "uint16", "bytes", "bytes"], [
181
+ uint8(ComposerCommands.EXT_TRY_CALL_WITH_REPLACE),
182
+ target,
183
+ generateAmountBitmap(uint128(value), false, useSelfBalance),
184
+ token,
185
+ replaceOffset,
186
+ uint16(data.length / 2 - 1),
187
+ uint8(rOnFailure ? 0 : 1),
188
+ uint16(catchData.length / 2 - 1),
189
+ data,
190
+ catchData,
191
+ ]);
192
+ }
165
193
  export function encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions) {
166
194
  const partialData = encodeStargateV2BridgePartial(amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions);
167
195
  return encodePacked(["uint8", "uint8", "address", "address", "uint32", "bytes32", "address", "bytes"], [
@@ -334,12 +362,7 @@ export function encodeUniswapV4Take(singleton, asset, receiver, amount) {
334
362
  ]);
335
363
  }
336
364
  export function swapHead(amount, amountOutMin, assetIn) {
337
- return encodePacked(["uint8", "uint128", "uint128", "address"], [
338
- uint8(ComposerCommands.SWAPS),
339
- generateAmountBitmap(uint128(amount), false, false),
340
- uint128(amountOutMin),
341
- assetIn,
342
- ]);
365
+ return encodePacked(["uint8", "uint128", "uint128", "address"], [uint8(ComposerCommands.SWAPS), uint128(amount), uint128(amountOutMin), assetIn]);
343
366
  }
344
367
  export function attachBranch(data, hops, splits, splitsData) {
345
368
  if (hops !== 0n && splits !== 0n)
@@ -544,6 +567,9 @@ export function encodeWrap(amount, wrapTarget) {
544
567
  uint128(amount),
545
568
  ]);
546
569
  }
570
+ export function encodeWrapWithReceiver(amount, weth, receiver) {
571
+ return encodePacked(["uint8", "uint8", "address", "address", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.WRAP), weth, receiver, uint128(amount)]);
572
+ }
547
573
  export function encodeApprove(asset, target) {
548
574
  return encodePacked(["uint8", "uint8", "address", "address"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.APPROVE), asset, target]);
549
575
  }
@@ -613,7 +639,7 @@ export function encodeMorphoDeposit(market, isShares, assets, receiver, data, mo
613
639
  data.length / 2 - 1 === 0 ? newbytes(0) : encodeUint8AndBytes(uint8(pId), data),
614
640
  ]);
615
641
  }
616
- export function encodeErc4646Deposit(asset, vault, isShares, assets, receiver) {
642
+ export function encodeErc4626Deposit(asset, vault, isShares, assets, receiver) {
617
643
  return encodePacked(["bytes", "uint8", "uint8", "address", "address", "uint128", "address"], [
618
644
  encodeApprove(asset, vault),
619
645
  uint8(ComposerCommands.ERC4626),
@@ -24,7 +24,8 @@ export declare enum TransferIds {
24
24
  WRAP_NATIVE = 2,
25
25
  UNWRAP_WNATIVE = 3,
26
26
  PERMIT2_TRANSFER_FROM = 4,
27
- APPROVE = 5
27
+ APPROVE = 5,
28
+ WRAP = 6
28
29
  }
29
30
  export declare enum PermitIds {
30
31
  TOKEN_PERMIT = 0,
@@ -69,6 +70,8 @@ export declare enum ComposerCommands {
69
70
  SWAPS = 16,
70
71
  EXT_CALL = 32,
71
72
  EXT_TRY_CALL = 33,
73
+ EXT_CALL_WITH_REPLACE = 34,
74
+ EXT_TRY_CALL_WITH_REPLACE = 35,
72
75
  LENDING = 48,
73
76
  TRANSFERS = 64,
74
77
  PERMIT = 80,
@@ -124,6 +127,8 @@ export declare enum DexForkMappings {
124
127
  }
125
128
  export declare function encodeExternalCall(target: Address, value: bigint, useSelfBalance: boolean, data: Hex): Hex;
126
129
  export declare function encodeTryExternalCall(target: Address, value: bigint, useSelfBalance: boolean, rOnFailure: boolean, data: Hex, catchData: Hex): Hex;
130
+ export declare function encodeExternalCallWithReplace(target: Address, value: bigint, useSelfBalance: boolean, token: Address, replaceOffset: number, data: Hex): Hex;
131
+ export declare function encodeTryExternalCallWithReplace(target: Address, value: bigint, useSelfBalance: boolean, token: Address, replaceOffset: number, data: Hex, rOnFailure: boolean, catchData: Hex): Hex;
127
132
  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;
128
133
  export declare function encodePermit(permitId: bigint, target: Address, data: Hex): Hex;
129
134
  export declare function encodeStargateV2BridgePartial(amount: bigint, slippage: number, fee: bigint, isBusMode: boolean, isNative: boolean, composeMsg: Hex, extraOptions: Hex): Hex;
@@ -168,6 +173,7 @@ export declare function encodeNextGenDexSettleBalancer(singleton: Address, asset
168
173
  export declare function encodeTransferIn(asset: Address, receiver: Address, amount: bigint): Hex;
169
174
  export declare function encodeSweep(asset: Address, receiver: Address, amount: bigint, sweepType: any): Hex;
170
175
  export declare function encodeWrap(amount: bigint, wrapTarget: Address): Hex;
176
+ export declare function encodeWrapWithReceiver(amount: bigint, weth: Address, receiver: Address): Hex;
171
177
  export declare function encodeApprove(asset: Address, target: Address): Hex;
172
178
  export declare function encodeUnwrap(target: Address, receiver: Address, amount: bigint, sweepType: any): Hex;
173
179
  export declare function encodeBalancerV2FlashLoan(asset: Address, amount: bigint, poolId: number, data: Hex): Hex;
@@ -176,7 +182,7 @@ export declare function encodeUint8AndBytes(poolId: number, data: Hex): Hex;
176
182
  export declare function encodeMorphoMarket(loanToken: Address, collateralToken: Address, oracle: Address, irm: Address, lltv: bigint): Hex;
177
183
  export declare function encodeMorphoDepositCollateral(market: Hex, assets: bigint, receiver: Address, data: Hex, morphoB: Address, pId: bigint): Hex;
178
184
  export declare function encodeMorphoDeposit(market: Hex, isShares: boolean, assets: bigint, receiver: Address, data: Hex, morphoB: Address, pId: bigint): Hex;
179
- export declare function encodeErc4646Deposit(asset: Address, vault: Address, isShares: boolean, assets: bigint, receiver: Address): Hex;
185
+ export declare function encodeErc4626Deposit(asset: Address, vault: Address, isShares: boolean, assets: bigint, receiver: Address): Hex;
180
186
  export declare function encodeErc4646Withdraw(vault: Address, isShares: boolean, assets: bigint, receiver: Address): Hex;
181
187
  export declare function encodeMorphoWithdraw(market: Hex, isShares: boolean, assets: bigint, receiver: Address, morphoB: Address): Hex;
182
188
  export declare function encodeMorphoWithdrawCollateral(market: Hex, assets: bigint, receiver: Address, morphoB: Address): Hex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1delta/calldatalib",
3
- "version": "0.0.45",
3
+ "version": "0.0.49",
4
4
  "description": "Generated CalldataLib TypeScript functions for 1delta smart contracts",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",