@1delta/calldatalib 0.0.27 → 0.0.29
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/dist/CalldataLib.d.ts +3 -1
- package/dist/CalldataLib.js +25 -6
- package/dist/cjs/CalldataLib.d.ts +3 -1
- package/dist/cjs/CalldataLib.js +25 -5
- package/package.json +1 -1
package/dist/CalldataLib.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export declare enum Gen2025ActionIds {
|
|
|
67
67
|
export declare enum ComposerCommands {
|
|
68
68
|
SWAPS = 16,
|
|
69
69
|
EXT_CALL = 32,
|
|
70
|
+
EXT_TRY_CALL = 33,
|
|
70
71
|
LENDING = 48,
|
|
71
72
|
TRANSFERS = 64,
|
|
72
73
|
PERMIT = 80,
|
|
@@ -108,7 +109,8 @@ export declare enum DexForkMappings {
|
|
|
108
109
|
BALANCER_V3 = 0,
|
|
109
110
|
UNISWAP_V2 = 0
|
|
110
111
|
}
|
|
111
|
-
export declare function encodeExternalCall(target: Address, value: bigint, data: Hex): Hex;
|
|
112
|
+
export declare function encodeExternalCall(target: Address, value: bigint, useSelfBalance: boolean, data: Hex): Hex;
|
|
113
|
+
export declare function encodeTryExternalCall(target: Address, value: bigint, useSelfBalance: boolean, rOnFailure: boolean, data: Hex, catchData: Hex): Hex;
|
|
112
114
|
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
115
|
export declare function encodeStargateV2BridgePartial(amount: bigint, slippage: number, fee: bigint, isBusMode: boolean, isNative: boolean, composeMsg: Hex, extraOptions: Hex): Hex;
|
|
114
116
|
export declare function encodeStargateV2BridgeSimpleTaxi(asset: Address, stargatePool: Address, dstEid: number, receiver: Hex, refundReceiver: Address, amount: bigint, isNative: boolean, slippage: number, fee: bigint): Hex;
|
package/dist/CalldataLib.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import { zeroAddress } from "viem";
|
|
3
|
-
import { encodePacked, uint128, uint8,
|
|
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";
|
|
@@ -81,6 +81,7 @@ export var ComposerCommands;
|
|
|
81
81
|
(function (ComposerCommands) {
|
|
82
82
|
ComposerCommands[ComposerCommands["SWAPS"] = 16] = "SWAPS";
|
|
83
83
|
ComposerCommands[ComposerCommands["EXT_CALL"] = 32] = "EXT_CALL";
|
|
84
|
+
ComposerCommands[ComposerCommands["EXT_TRY_CALL"] = 33] = "EXT_TRY_CALL";
|
|
84
85
|
ComposerCommands[ComposerCommands["LENDING"] = 48] = "LENDING";
|
|
85
86
|
ComposerCommands[ComposerCommands["TRANSFERS"] = 64] = "TRANSFERS";
|
|
86
87
|
ComposerCommands[ComposerCommands["PERMIT"] = 80] = "PERMIT";
|
|
@@ -125,8 +126,26 @@ export var DexForkMappings;
|
|
|
125
126
|
DexForkMappings[DexForkMappings["BALANCER_V3"] = 0] = "BALANCER_V3";
|
|
126
127
|
DexForkMappings[DexForkMappings["UNISWAP_V2"] = 0] = "UNISWAP_V2";
|
|
127
128
|
})(DexForkMappings || (DexForkMappings = {}));
|
|
128
|
-
export function encodeExternalCall(target, value, data) {
|
|
129
|
-
return encodePacked(["uint8", "address", "
|
|
129
|
+
export function encodeExternalCall(target, value, useSelfBalance, data) {
|
|
130
|
+
return encodePacked(["uint8", "address", "uint128", "uint16", "bytes"], [
|
|
131
|
+
uint8(ComposerCommands.EXT_CALL),
|
|
132
|
+
target,
|
|
133
|
+
generateAmountBitmap(uint128(value), false, false, useSelfBalance),
|
|
134
|
+
uint16(data.length / 2 - 1),
|
|
135
|
+
data,
|
|
136
|
+
]);
|
|
137
|
+
}
|
|
138
|
+
export function encodeTryExternalCall(target, value, useSelfBalance, rOnFailure, data, catchData) {
|
|
139
|
+
return encodePacked(["uint8", "address", "uint128", "uint16", "bytes", "uint8", "uint16", "bytes"], [
|
|
140
|
+
uint8(ComposerCommands.EXT_TRY_CALL),
|
|
141
|
+
target,
|
|
142
|
+
generateAmountBitmap(uint128(value), false, false, useSelfBalance),
|
|
143
|
+
uint16(data.length / 2 - 1),
|
|
144
|
+
data,
|
|
145
|
+
uint8(rOnFailure ? 0 : 1),
|
|
146
|
+
uint16(catchData.length / 2 - 1),
|
|
147
|
+
catchData,
|
|
148
|
+
]);
|
|
130
149
|
}
|
|
131
150
|
export function encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions) {
|
|
132
151
|
const partialData = encodeStargateV2BridgePartial(amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions);
|
|
@@ -327,14 +346,14 @@ export function encodeUniswapV4StyleSwap(currentData, tokenOut, receiver, manage
|
|
|
327
346
|
export function encodeBalancerV2StyleSwap(currentData, tokenOut, receiver, poolId, balancerVault, cfg) {
|
|
328
347
|
if (cfg === DexPayConfig.FLASH)
|
|
329
348
|
throw new Error("Invalidconfigforv2swap");
|
|
330
|
-
return encodePacked(["bytes", "address", "address", "uint8", "bytes32", "address", "
|
|
349
|
+
return encodePacked(["bytes", "address", "address", "uint8", "bytes32", "address", "uint8"], [
|
|
331
350
|
currentData,
|
|
332
351
|
tokenOut,
|
|
333
352
|
receiver,
|
|
334
353
|
uint8(DexTypeMappings.BALANCER_V2_ID),
|
|
335
354
|
poolId,
|
|
336
355
|
balancerVault,
|
|
337
|
-
|
|
356
|
+
uint8(uint256(cfg)),
|
|
338
357
|
]);
|
|
339
358
|
}
|
|
340
359
|
export function encodeLbStyleSwap(currentData, tokenOut, receiver, pool, swapForY, cfg) {
|
|
@@ -345,7 +364,7 @@ export function encodeLbStyleSwap(currentData, tokenOut, receiver, pool, swapFor
|
|
|
345
364
|
export function encodeSyncSwapStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
|
|
346
365
|
if (cfg === DexPayConfig.FLASH)
|
|
347
366
|
throw new Error("Invalidconfigforv2swap");
|
|
348
|
-
return encodePacked(["bytes", "address", "address", "uint8", "address", "
|
|
367
|
+
return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.SYNC_SWAP_ID), pool, uint8(uint256(cfg))]);
|
|
349
368
|
}
|
|
350
369
|
export function encodeUniswapV3StyleSwap(currentData, tokenOut, receiver, forkId, pool, feeTier, cfg, flashCalldata) {
|
|
351
370
|
if (uint256(cfg) < 2 && flashCalldata.length / 2 - 1 > 2)
|
|
@@ -67,6 +67,7 @@ export declare enum Gen2025ActionIds {
|
|
|
67
67
|
export declare enum ComposerCommands {
|
|
68
68
|
SWAPS = 16,
|
|
69
69
|
EXT_CALL = 32,
|
|
70
|
+
EXT_TRY_CALL = 33,
|
|
70
71
|
LENDING = 48,
|
|
71
72
|
TRANSFERS = 64,
|
|
72
73
|
PERMIT = 80,
|
|
@@ -108,7 +109,8 @@ export declare enum DexForkMappings {
|
|
|
108
109
|
BALANCER_V3 = 0,
|
|
109
110
|
UNISWAP_V2 = 0
|
|
110
111
|
}
|
|
111
|
-
export declare function encodeExternalCall(target: Address, value: bigint, data: Hex): Hex;
|
|
112
|
+
export declare function encodeExternalCall(target: Address, value: bigint, useSelfBalance: boolean, data: Hex): Hex;
|
|
113
|
+
export declare function encodeTryExternalCall(target: Address, value: bigint, useSelfBalance: boolean, rOnFailure: boolean, data: Hex, catchData: Hex): Hex;
|
|
112
114
|
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
115
|
export declare function encodeStargateV2BridgePartial(amount: bigint, slippage: number, fee: bigint, isBusMode: boolean, isNative: boolean, composeMsg: Hex, extraOptions: Hex): Hex;
|
|
114
116
|
export declare function encodeStargateV2BridgeSimpleTaxi(asset: Address, stargatePool: Address, dstEid: number, receiver: Hex, refundReceiver: Address, amount: bigint, isNative: boolean, slippage: number, fee: bigint): Hex;
|
package/dist/cjs/CalldataLib.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DexForkMappings = exports.DexTypeMappings = 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
|
+
exports.encodeTryExternalCall = encodeTryExternalCall;
|
|
5
6
|
exports.encodeStargateV2Bridge = encodeStargateV2Bridge;
|
|
6
7
|
exports.encodeStargateV2BridgePartial = encodeStargateV2BridgePartial;
|
|
7
8
|
exports.encodeStargateV2BridgeSimpleTaxi = encodeStargateV2BridgeSimpleTaxi;
|
|
@@ -152,6 +153,7 @@ var ComposerCommands;
|
|
|
152
153
|
(function (ComposerCommands) {
|
|
153
154
|
ComposerCommands[ComposerCommands["SWAPS"] = 16] = "SWAPS";
|
|
154
155
|
ComposerCommands[ComposerCommands["EXT_CALL"] = 32] = "EXT_CALL";
|
|
156
|
+
ComposerCommands[ComposerCommands["EXT_TRY_CALL"] = 33] = "EXT_TRY_CALL";
|
|
155
157
|
ComposerCommands[ComposerCommands["LENDING"] = 48] = "LENDING";
|
|
156
158
|
ComposerCommands[ComposerCommands["TRANSFERS"] = 64] = "TRANSFERS";
|
|
157
159
|
ComposerCommands[ComposerCommands["PERMIT"] = 80] = "PERMIT";
|
|
@@ -196,8 +198,26 @@ var DexForkMappings;
|
|
|
196
198
|
DexForkMappings[DexForkMappings["BALANCER_V3"] = 0] = "BALANCER_V3";
|
|
197
199
|
DexForkMappings[DexForkMappings["UNISWAP_V2"] = 0] = "UNISWAP_V2";
|
|
198
200
|
})(DexForkMappings || (exports.DexForkMappings = DexForkMappings = {}));
|
|
199
|
-
function encodeExternalCall(target, value, data) {
|
|
200
|
-
return (0, utils_js_1.encodePacked)(["uint8", "address", "
|
|
201
|
+
function encodeExternalCall(target, value, useSelfBalance, data) {
|
|
202
|
+
return (0, utils_js_1.encodePacked)(["uint8", "address", "uint128", "uint16", "bytes"], [
|
|
203
|
+
(0, utils_js_1.uint8)(ComposerCommands.EXT_CALL),
|
|
204
|
+
target,
|
|
205
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(value), false, false, useSelfBalance),
|
|
206
|
+
(0, utils_js_1.uint16)(data.length / 2 - 1),
|
|
207
|
+
data,
|
|
208
|
+
]);
|
|
209
|
+
}
|
|
210
|
+
function encodeTryExternalCall(target, value, useSelfBalance, rOnFailure, data, catchData) {
|
|
211
|
+
return (0, utils_js_1.encodePacked)(["uint8", "address", "uint128", "uint16", "bytes", "uint8", "uint16", "bytes"], [
|
|
212
|
+
(0, utils_js_1.uint8)(ComposerCommands.EXT_TRY_CALL),
|
|
213
|
+
target,
|
|
214
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(value), false, false, useSelfBalance),
|
|
215
|
+
(0, utils_js_1.uint16)(data.length / 2 - 1),
|
|
216
|
+
data,
|
|
217
|
+
(0, utils_js_1.uint8)(rOnFailure ? 0 : 1),
|
|
218
|
+
(0, utils_js_1.uint16)(catchData.length / 2 - 1),
|
|
219
|
+
catchData,
|
|
220
|
+
]);
|
|
201
221
|
}
|
|
202
222
|
function encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions) {
|
|
203
223
|
const partialData = encodeStargateV2BridgePartial(amount, slippage, fee, isBusMode, isNative, composeMsg, extraOptions);
|
|
@@ -398,14 +418,14 @@ function encodeUniswapV4StyleSwap(currentData, tokenOut, receiver, manager, fee,
|
|
|
398
418
|
function encodeBalancerV2StyleSwap(currentData, tokenOut, receiver, poolId, balancerVault, cfg) {
|
|
399
419
|
if (cfg === DexPayConfig.FLASH)
|
|
400
420
|
throw new Error("Invalidconfigforv2swap");
|
|
401
|
-
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "bytes32", "address", "
|
|
421
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "bytes32", "address", "uint8"], [
|
|
402
422
|
currentData,
|
|
403
423
|
tokenOut,
|
|
404
424
|
receiver,
|
|
405
425
|
(0, utils_js_1.uint8)(DexTypeMappings.BALANCER_V2_ID),
|
|
406
426
|
poolId,
|
|
407
427
|
balancerVault,
|
|
408
|
-
(0, utils_js_1.
|
|
428
|
+
(0, utils_js_1.uint8)((0, utils_js_1.uint256)(cfg)),
|
|
409
429
|
]);
|
|
410
430
|
}
|
|
411
431
|
function encodeLbStyleSwap(currentData, tokenOut, receiver, pool, swapForY, cfg) {
|
|
@@ -416,7 +436,7 @@ function encodeLbStyleSwap(currentData, tokenOut, receiver, pool, swapForY, cfg)
|
|
|
416
436
|
function encodeSyncSwapStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
|
|
417
437
|
if (cfg === DexPayConfig.FLASH)
|
|
418
438
|
throw new Error("Invalidconfigforv2swap");
|
|
419
|
-
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "address", "
|
|
439
|
+
return (0, utils_js_1.encodePacked)(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, (0, utils_js_1.uint8)(DexTypeMappings.SYNC_SWAP_ID), pool, (0, utils_js_1.uint8)((0, utils_js_1.uint256)(cfg))]);
|
|
420
440
|
}
|
|
421
441
|
function encodeUniswapV3StyleSwap(currentData, tokenOut, receiver, forkId, pool, feeTier, cfg, flashCalldata) {
|
|
422
442
|
if ((0, utils_js_1.uint256)(cfg) < 2 && flashCalldata.length / 2 - 1 > 2)
|