@1delta/calldatalib 0.0.39 → 0.0.45
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/cjs/CalldataLib.js +118 -60
- package/dist/cjs/utils.js +12 -0
- package/dist/esm/CalldataLib.js +110 -60
- package/dist/esm/utils.js +9 -0
- package/dist/types/CalldataLib.d.ts +26 -6
- package/dist/types/utils.d.ts +3 -0
- package/package.json +1 -1
package/dist/cjs/CalldataLib.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
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
6
|
exports.encodeStargateV2Bridge = encodeStargateV2Bridge;
|
|
@@ -10,8 +10,12 @@ exports.encodeStargateV2BridgeSimpleTaxi = encodeStargateV2BridgeSimpleTaxi;
|
|
|
10
10
|
exports.encodeStargateV2BridgeSimpleBus = encodeStargateV2BridgeSimpleBus;
|
|
11
11
|
exports.encodeAcrossBridgeToken = encodeAcrossBridgeToken;
|
|
12
12
|
exports.encodeAcrossBridgeNative = encodeAcrossBridgeNative;
|
|
13
|
+
exports.encodeAcrossHeader = encodeAcrossHeader;
|
|
14
|
+
exports.encodeAcrossParams = encodeAcrossParams;
|
|
13
15
|
exports.encodeSquidRouterCall = encodeSquidRouterCall;
|
|
14
16
|
exports.encodeSquidRouterCallPartial = encodeSquidRouterCallPartial;
|
|
17
|
+
exports.encodeGasZipBridge = encodeGasZipBridge;
|
|
18
|
+
exports.encodeGasZipEvmBridge = encodeGasZipEvmBridge;
|
|
15
19
|
exports.encodePermit2TransferFrom = encodePermit2TransferFrom;
|
|
16
20
|
exports.encodeNextGenDexUnlock = encodeNextGenDexUnlock;
|
|
17
21
|
exports.encodeBalancerV3FlashLoan = encodeBalancerV3FlashLoan;
|
|
@@ -70,9 +74,13 @@ exports.encodeCompoundV3Borrow = encodeCompoundV3Borrow;
|
|
|
70
74
|
exports.encodeCompoundV3Repay = encodeCompoundV3Repay;
|
|
71
75
|
exports.encodeCompoundV3Withdraw = encodeCompoundV3Withdraw;
|
|
72
76
|
exports.encodeCompoundV2Deposit = encodeCompoundV2Deposit;
|
|
77
|
+
exports.encodeSiloV2Deposit = encodeSiloV2Deposit;
|
|
78
|
+
exports.encodeSiloV2Borrow = encodeSiloV2Borrow;
|
|
73
79
|
exports.encodeCompoundV2Borrow = encodeCompoundV2Borrow;
|
|
74
80
|
exports.encodeCompoundV2Repay = encodeCompoundV2Repay;
|
|
75
81
|
exports.encodeCompoundV2Withdraw = encodeCompoundV2Withdraw;
|
|
82
|
+
exports.encodeSiloV2Withdraw = encodeSiloV2Withdraw;
|
|
83
|
+
exports.encodeSiloV2Repay = encodeSiloV2Repay;
|
|
76
84
|
// @ts-nocheck
|
|
77
85
|
const viem_1 = require("viem");
|
|
78
86
|
const utils_js_1 = require("./utils.js");
|
|
@@ -121,6 +129,7 @@ var LenderIds;
|
|
|
121
129
|
LenderIds[LenderIds["UP_TO_COMPOUND_V3"] = 3000] = "UP_TO_COMPOUND_V3";
|
|
122
130
|
LenderIds[LenderIds["UP_TO_COMPOUND_V2"] = 4000] = "UP_TO_COMPOUND_V2";
|
|
123
131
|
LenderIds[LenderIds["UP_TO_MORPHO"] = 5000] = "UP_TO_MORPHO";
|
|
132
|
+
LenderIds[LenderIds["UP_TO_SILO_V2"] = 6000] = "UP_TO_SILO_V2";
|
|
124
133
|
})(LenderIds || (exports.LenderIds = LenderIds = {}));
|
|
125
134
|
var LenderOps;
|
|
126
135
|
(function (LenderOps) {
|
|
@@ -170,7 +179,20 @@ var BridgeIds;
|
|
|
170
179
|
BridgeIds[BridgeIds["STARGATE_V2"] = 0] = "STARGATE_V2";
|
|
171
180
|
BridgeIds[BridgeIds["ACROSS"] = 10] = "ACROSS";
|
|
172
181
|
BridgeIds[BridgeIds["SQUID_ROUTER"] = 20] = "SQUID_ROUTER";
|
|
182
|
+
BridgeIds[BridgeIds["GASZIP"] = 30] = "GASZIP";
|
|
173
183
|
})(BridgeIds || (exports.BridgeIds = BridgeIds = {}));
|
|
184
|
+
var CompoundV2Selector;
|
|
185
|
+
(function (CompoundV2Selector) {
|
|
186
|
+
CompoundV2Selector[CompoundV2Selector["MINT_BEHALF"] = 0] = "MINT_BEHALF";
|
|
187
|
+
CompoundV2Selector[CompoundV2Selector["MINT"] = 1] = "MINT";
|
|
188
|
+
CompoundV2Selector[CompoundV2Selector["REDEEM"] = 0] = "REDEEM";
|
|
189
|
+
CompoundV2Selector[CompoundV2Selector["REDEEM_BEHALF"] = 1] = "REDEEM_BEHALF";
|
|
190
|
+
})(CompoundV2Selector || (exports.CompoundV2Selector = CompoundV2Selector = {}));
|
|
191
|
+
var SiloV2CollateralType;
|
|
192
|
+
(function (SiloV2CollateralType) {
|
|
193
|
+
SiloV2CollateralType[SiloV2CollateralType["PROTECTED"] = 0] = "PROTECTED";
|
|
194
|
+
SiloV2CollateralType[SiloV2CollateralType["COLLATERAL"] = 1] = "COLLATERAL";
|
|
195
|
+
})(SiloV2CollateralType || (exports.SiloV2CollateralType = SiloV2CollateralType = {}));
|
|
174
196
|
var DexTypeMappings;
|
|
175
197
|
(function (DexTypeMappings) {
|
|
176
198
|
DexTypeMappings[DexTypeMappings["UNISWAP_V3_ID"] = 0] = "UNISWAP_V3_ID";
|
|
@@ -257,69 +279,41 @@ function encodeStargateV2BridgeSimpleTaxi(asset, stargatePool, dstEid, receiver,
|
|
|
257
279
|
function encodeStargateV2BridgeSimpleBus(asset, stargatePool, dstEid, receiver, refundReceiver, amount, isNative, slippage, fee) {
|
|
258
280
|
return encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, true, isNative, (0, utils_js_1.newbytes)(0), (0, utils_js_1.newbytes)(0));
|
|
259
281
|
}
|
|
260
|
-
function encodeAcrossBridgeToken(spokePool, depositor, sendingAssetId, receivingAssetId, amount, fixedFee, feePercentage, destinationChainId, receiver, message) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
"uint32",
|
|
271
|
-
"uint32",
|
|
272
|
-
"bytes32",
|
|
273
|
-
"uint16",
|
|
274
|
-
"bytes",
|
|
275
|
-
], [
|
|
276
|
-
(0, utils_js_1.uint8)(ComposerCommands.BRIDGING),
|
|
277
|
-
(0, utils_js_1.uint8)(BridgeIds.ACROSS),
|
|
278
|
-
spokePool,
|
|
279
|
-
depositor,
|
|
280
|
-
sendingAssetId,
|
|
281
|
-
receivingAssetId,
|
|
282
|
-
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, false),
|
|
283
|
-
fixedFee,
|
|
284
|
-
feePercentage,
|
|
285
|
-
destinationChainId,
|
|
286
|
-
receiver,
|
|
287
|
-
(0, utils_js_1.uint16)(message.length / 2 - 1),
|
|
288
|
-
message,
|
|
282
|
+
function encodeAcrossBridgeToken(spokePool, depositor, sendingAssetId, receivingAssetId, amount, fixedFee, feePercentage, destinationChainId, fromTokenDecimals, toTokenDecimals, receiver, deadline, message) {
|
|
283
|
+
return (0, utils_js_1.encodePacked)(["bytes", "bytes"], [
|
|
284
|
+
encodeAcrossHeader(spokePool, depositor, sendingAssetId, receivingAssetId, amount, false),
|
|
285
|
+
encodeAcrossParams(fixedFee, feePercentage, destinationChainId, fromTokenDecimals, toTokenDecimals, receiver, deadline, message),
|
|
286
|
+
]);
|
|
287
|
+
}
|
|
288
|
+
function encodeAcrossBridgeNative(spokePool, depositor, sendingAssetId, receivingAssetId, amount, fixedFee, feePercentage, destinationChainId, fromTokenDecimals, toTokenDecimals, receiver, deadline, message) {
|
|
289
|
+
return (0, utils_js_1.encodePacked)(["bytes", "bytes"], [
|
|
290
|
+
encodeAcrossHeader(spokePool, depositor, sendingAssetId, receivingAssetId, amount, true),
|
|
291
|
+
encodeAcrossParams(fixedFee, feePercentage, destinationChainId, fromTokenDecimals, toTokenDecimals, receiver, deadline, message),
|
|
289
292
|
]);
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
const bridgeData = (0, utils_js_1.encodePacked)([
|
|
294
|
-
"uint8",
|
|
295
|
-
"uint8",
|
|
296
|
-
"address",
|
|
297
|
-
"address",
|
|
298
|
-
"address",
|
|
299
|
-
"bytes32",
|
|
300
|
-
"uint128",
|
|
301
|
-
"uint128",
|
|
302
|
-
"uint32",
|
|
303
|
-
"uint32",
|
|
304
|
-
"bytes32",
|
|
305
|
-
"uint16",
|
|
306
|
-
"bytes",
|
|
307
|
-
], [
|
|
293
|
+
}
|
|
294
|
+
function encodeAcrossHeader(spokePool, depositor, sendingAssetId, receivingAssetId, amount, isNative) {
|
|
295
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "address", "bytes32", "uint128"], [
|
|
308
296
|
(0, utils_js_1.uint8)(ComposerCommands.BRIDGING),
|
|
309
297
|
(0, utils_js_1.uint8)(BridgeIds.ACROSS),
|
|
310
298
|
spokePool,
|
|
311
299
|
depositor,
|
|
312
300
|
sendingAssetId,
|
|
313
301
|
receivingAssetId,
|
|
314
|
-
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false,
|
|
302
|
+
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(amount), false, isNative),
|
|
303
|
+
]);
|
|
304
|
+
}
|
|
305
|
+
function encodeAcrossParams(fixedFee, feePercentage, destinationChainId, fromTokenDecimals, toTokenDecimals, receiver, deadline, message) {
|
|
306
|
+
return (0, utils_js_1.encodePacked)(["uint128", "uint32", "uint32", "uint8", "uint8", "bytes32", "uint32", "uint16", "bytes"], [
|
|
315
307
|
fixedFee,
|
|
316
308
|
feePercentage,
|
|
317
309
|
destinationChainId,
|
|
310
|
+
fromTokenDecimals,
|
|
311
|
+
toTokenDecimals,
|
|
318
312
|
receiver,
|
|
313
|
+
deadline,
|
|
319
314
|
(0, utils_js_1.uint16)(message.length / 2 - 1),
|
|
320
315
|
message,
|
|
321
316
|
]);
|
|
322
|
-
return bridgeData;
|
|
323
317
|
}
|
|
324
318
|
function encodeSquidRouterCall(asset, gateway, bridgedTokenSymbol, amount, destinationChain, destinationAddress, payload, gasRefundRecipient, enableExpress, nativeAmount) {
|
|
325
319
|
const partialData = encodeSquidRouterCallPartial(asset, gateway, bridgedTokenSymbol, amount, destinationChain, destinationAddress, payload);
|
|
@@ -347,6 +341,26 @@ function encodeSquidRouterCallPartial(asset, gateway, bridgedTokenSymbol, amount
|
|
|
347
341
|
(0, utils_js_1.uint128)(amount),
|
|
348
342
|
]);
|
|
349
343
|
}
|
|
344
|
+
function encodeGasZipBridge(gasZipRouter, receiver, amount, destinationChainId) {
|
|
345
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "bytes32", "uint128", "uint256"], [
|
|
346
|
+
(0, utils_js_1.uint8)(ComposerCommands.BRIDGING),
|
|
347
|
+
(0, utils_js_1.uint8)(BridgeIds.GASZIP),
|
|
348
|
+
gasZipRouter,
|
|
349
|
+
receiver,
|
|
350
|
+
(0, utils_js_1.uint128)(amount),
|
|
351
|
+
destinationChainId,
|
|
352
|
+
]);
|
|
353
|
+
}
|
|
354
|
+
function encodeGasZipEvmBridge(gasZipRouter, receiver, amount, destinationChainId) {
|
|
355
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "bytes32", "uint128", "uint256"], [
|
|
356
|
+
(0, utils_js_1.uint8)(ComposerCommands.BRIDGING),
|
|
357
|
+
(0, utils_js_1.uint8)(BridgeIds.GASZIP),
|
|
358
|
+
gasZipRouter,
|
|
359
|
+
(0, utils_js_1.rightPadZero)(receiver),
|
|
360
|
+
(0, utils_js_1.uint128)(amount),
|
|
361
|
+
destinationChainId,
|
|
362
|
+
]);
|
|
363
|
+
}
|
|
350
364
|
function encodePermit2TransferFrom(token, receiver, amount) {
|
|
351
365
|
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "address", "address", "uint128"], [(0, utils_js_1.uint8)(ComposerCommands.TRANSFERS), (0, utils_js_1.uint8)(TransferIds.PERMIT2_TRANSFER_FROM), token, receiver, (0, utils_js_1.uint128)(amount)]);
|
|
352
366
|
}
|
|
@@ -659,7 +673,7 @@ function encodeMorphoDepositCollateral(market, assets, receiver, data, morphoB,
|
|
|
659
673
|
encodeApprove((0, utils_js_1.getMorphoCollateral)(market), morphoB),
|
|
660
674
|
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
661
675
|
(0, utils_js_1.uint8)(LenderOps.DEPOSIT),
|
|
662
|
-
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
|
|
676
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO - 1),
|
|
663
677
|
market,
|
|
664
678
|
(0, utils_js_1.uint128)(assets),
|
|
665
679
|
receiver,
|
|
@@ -673,7 +687,7 @@ function encodeMorphoDeposit(market, isShares, assets, receiver, data, morphoB,
|
|
|
673
687
|
encodeApprove((0, utils_js_1.getMorphoLoanAsset)(market), morphoB),
|
|
674
688
|
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
675
689
|
(0, utils_js_1.uint8)(LenderOps.DEPOSIT_LENDING_TOKEN),
|
|
676
|
-
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
|
|
690
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO - 1),
|
|
677
691
|
market,
|
|
678
692
|
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
|
|
679
693
|
receiver,
|
|
@@ -706,7 +720,7 @@ function encodeMorphoWithdraw(market, isShares, assets, receiver, morphoB) {
|
|
|
706
720
|
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "bytes", "uint128", "address", "address"], [
|
|
707
721
|
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
708
722
|
(0, utils_js_1.uint8)(LenderOps.WITHDRAW_LENDING_TOKEN),
|
|
709
|
-
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
|
|
723
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO - 1),
|
|
710
724
|
market,
|
|
711
725
|
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
|
|
712
726
|
receiver,
|
|
@@ -717,7 +731,7 @@ function encodeMorphoWithdrawCollateral(market, assets, receiver, morphoB) {
|
|
|
717
731
|
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "bytes", "uint128", "address", "address"], [
|
|
718
732
|
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
719
733
|
(0, utils_js_1.uint8)(LenderOps.WITHDRAW),
|
|
720
|
-
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
|
|
734
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO - 1),
|
|
721
735
|
market,
|
|
722
736
|
(0, utils_js_1.uint128)(assets),
|
|
723
737
|
receiver,
|
|
@@ -728,7 +742,7 @@ function encodeMorphoBorrow(market, isShares, assets, receiver, morphoB) {
|
|
|
728
742
|
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "bytes", "uint128", "address", "address"], [
|
|
729
743
|
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
730
744
|
(0, utils_js_1.uint8)(LenderOps.BORROW),
|
|
731
|
-
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
|
|
745
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO - 1),
|
|
732
746
|
market,
|
|
733
747
|
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
|
|
734
748
|
receiver,
|
|
@@ -740,7 +754,7 @@ function encodeMorphoRepay(market, isShares, assets, receiver, data, morphoB, pI
|
|
|
740
754
|
encodeApprove((0, utils_js_1.getMorphoLoanAsset)(market), morphoB),
|
|
741
755
|
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
742
756
|
(0, utils_js_1.uint8)(LenderOps.REPAY),
|
|
743
|
-
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO),
|
|
757
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_MORPHO - 1),
|
|
744
758
|
market,
|
|
745
759
|
(0, utils_js_1.generateAmountBitmap)((0, utils_js_1.uint128)(assets), isShares, false),
|
|
746
760
|
receiver,
|
|
@@ -896,18 +910,40 @@ function encodeCompoundV3Withdraw(token, amount, receiver, comet, isBase) {
|
|
|
896
910
|
comet,
|
|
897
911
|
]);
|
|
898
912
|
}
|
|
899
|
-
function encodeCompoundV2Deposit(token, amount, receiver, cToken) {
|
|
913
|
+
function encodeCompoundV2Deposit(token, amount, receiver, cToken, selectorId) {
|
|
900
914
|
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
901
915
|
token === viem_1.zeroAddress ? (0, utils_js_1.newbytes)(0) : encodeApprove(token, cToken),
|
|
902
916
|
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
903
917
|
(0, utils_js_1.uint8)(LenderOps.DEPOSIT),
|
|
904
918
|
(0, utils_js_1.uint16)(LenderIds.UP_TO_COMPOUND_V2 - 1),
|
|
905
919
|
token,
|
|
906
|
-
(0, utils_js_1.uint128)(amount),
|
|
920
|
+
(0, utils_js_1.encodeCompoundV2SelectorId)((0, utils_js_1.uint128)(amount), selectorId),
|
|
907
921
|
receiver,
|
|
908
922
|
cToken,
|
|
909
923
|
]);
|
|
910
924
|
}
|
|
925
|
+
function encodeSiloV2Deposit(token, amount, receiver, silo, collateralMode) {
|
|
926
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
927
|
+
token === viem_1.zeroAddress ? (0, utils_js_1.newbytes)(0) : encodeApprove(token, silo),
|
|
928
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
929
|
+
(0, utils_js_1.uint8)(LenderOps.DEPOSIT),
|
|
930
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_SILO_V2 - 1),
|
|
931
|
+
token,
|
|
932
|
+
(0, utils_js_1.encodeSiloV2CollateralMode)((0, utils_js_1.uint128)(amount), collateralMode),
|
|
933
|
+
receiver,
|
|
934
|
+
silo,
|
|
935
|
+
]);
|
|
936
|
+
}
|
|
937
|
+
function encodeSiloV2Borrow(amount, receiver, silo) {
|
|
938
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "uint128", "address", "address"], [
|
|
939
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
940
|
+
(0, utils_js_1.uint8)(LenderOps.BORROW),
|
|
941
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_SILO_V2 - 1),
|
|
942
|
+
(0, utils_js_1.uint128)(amount),
|
|
943
|
+
receiver,
|
|
944
|
+
silo,
|
|
945
|
+
]);
|
|
946
|
+
}
|
|
911
947
|
function encodeCompoundV2Borrow(token, amount, receiver, cToken) {
|
|
912
948
|
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
913
949
|
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
@@ -931,14 +967,36 @@ function encodeCompoundV2Repay(token, amount, receiver, cToken) {
|
|
|
931
967
|
cToken,
|
|
932
968
|
]);
|
|
933
969
|
}
|
|
934
|
-
function encodeCompoundV2Withdraw(token, amount, receiver, cToken) {
|
|
970
|
+
function encodeCompoundV2Withdraw(token, amount, receiver, cToken, selectorId) {
|
|
935
971
|
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
936
972
|
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
937
973
|
(0, utils_js_1.uint8)(LenderOps.WITHDRAW),
|
|
938
974
|
(0, utils_js_1.uint16)(LenderIds.UP_TO_COMPOUND_V2 - 1),
|
|
939
975
|
token,
|
|
940
|
-
(0, utils_js_1.uint128)(amount),
|
|
976
|
+
(0, utils_js_1.encodeCompoundV2SelectorId)((0, utils_js_1.uint128)(amount), selectorId),
|
|
941
977
|
receiver,
|
|
942
978
|
cToken,
|
|
943
979
|
]);
|
|
944
980
|
}
|
|
981
|
+
function encodeSiloV2Withdraw(amount, receiver, silo, collateralMode) {
|
|
982
|
+
return (0, utils_js_1.encodePacked)(["uint8", "uint8", "uint16", "uint128", "address", "address"], [
|
|
983
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
984
|
+
(0, utils_js_1.uint8)(LenderOps.WITHDRAW),
|
|
985
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_SILO_V2 - 1),
|
|
986
|
+
(0, utils_js_1.encodeSiloV2CollateralMode)((0, utils_js_1.uint128)(amount), collateralMode),
|
|
987
|
+
receiver,
|
|
988
|
+
silo,
|
|
989
|
+
]);
|
|
990
|
+
}
|
|
991
|
+
function encodeSiloV2Repay(token, amount, receiver, silo) {
|
|
992
|
+
return (0, utils_js_1.encodePacked)(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
993
|
+
token === viem_1.zeroAddress ? (0, utils_js_1.newbytes)(0) : encodeApprove(token, silo),
|
|
994
|
+
(0, utils_js_1.uint8)(ComposerCommands.LENDING),
|
|
995
|
+
(0, utils_js_1.uint8)(LenderOps.REPAY),
|
|
996
|
+
(0, utils_js_1.uint16)(LenderIds.UP_TO_SILO_V2 - 1),
|
|
997
|
+
token,
|
|
998
|
+
(0, utils_js_1.uint128)(amount),
|
|
999
|
+
receiver,
|
|
1000
|
+
silo,
|
|
1001
|
+
]);
|
|
1002
|
+
}
|
package/dist/cjs/utils.js
CHANGED
|
@@ -14,8 +14,11 @@ exports.encodePacked = encodePacked;
|
|
|
14
14
|
exports.generateAmountBitmap = generateAmountBitmap;
|
|
15
15
|
exports.getMorphoCollateral = getMorphoCollateral;
|
|
16
16
|
exports.getMorphoLoanAsset = getMorphoLoanAsset;
|
|
17
|
+
exports.rightPadZero = rightPadZero;
|
|
17
18
|
exports.newbytes = newbytes;
|
|
18
19
|
exports.bytes = bytes;
|
|
20
|
+
exports.encodeCompoundV2SelectorId = encodeCompoundV2SelectorId;
|
|
21
|
+
exports.encodeSiloV2CollateralMode = encodeSiloV2CollateralMode;
|
|
19
22
|
const viem_1 = require("viem");
|
|
20
23
|
exports._NATIVE_FLAG = 1n << 127n;
|
|
21
24
|
exports._SHARES_MASK = 1n << 126n;
|
|
@@ -69,9 +72,18 @@ function getMorphoLoanAsset(market) {
|
|
|
69
72
|
const slice = market.slice(2, 42);
|
|
70
73
|
return `0x${slice}`;
|
|
71
74
|
}
|
|
75
|
+
function rightPadZero(address) {
|
|
76
|
+
return (address.toLowerCase() + "0".repeat(24));
|
|
77
|
+
}
|
|
72
78
|
function newbytes(length) {
|
|
73
79
|
return ("0x" + "0".repeat(length * 2));
|
|
74
80
|
}
|
|
75
81
|
function bytes(value) {
|
|
76
82
|
return value;
|
|
77
83
|
}
|
|
84
|
+
function encodeCompoundV2SelectorId(amount, selectorId) {
|
|
85
|
+
return uint128(amount) | (uint128(selectorId) << 120n);
|
|
86
|
+
}
|
|
87
|
+
function encodeSiloV2CollateralMode(amount, mode) {
|
|
88
|
+
return uint128(amount) | (uint128(mode) << 120n);
|
|
89
|
+
}
|
package/dist/esm/CalldataLib.js
CHANGED
|
@@ -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.js";
|
|
3
|
+
import { encodePacked, uint128, uint8, uint16, uint256, generateAmountBitmap, newbytes, bytes, getMorphoCollateral, getMorphoLoanAsset, rightPadZero, encodeCompoundV2SelectorId, encodeSiloV2CollateralMode, } from "./utils.js";
|
|
4
4
|
export var SweepType;
|
|
5
5
|
(function (SweepType) {
|
|
6
6
|
SweepType[SweepType["VALIDATE"] = 0] = "VALIDATE";
|
|
@@ -46,6 +46,7 @@ export var LenderIds;
|
|
|
46
46
|
LenderIds[LenderIds["UP_TO_COMPOUND_V3"] = 3000] = "UP_TO_COMPOUND_V3";
|
|
47
47
|
LenderIds[LenderIds["UP_TO_COMPOUND_V2"] = 4000] = "UP_TO_COMPOUND_V2";
|
|
48
48
|
LenderIds[LenderIds["UP_TO_MORPHO"] = 5000] = "UP_TO_MORPHO";
|
|
49
|
+
LenderIds[LenderIds["UP_TO_SILO_V2"] = 6000] = "UP_TO_SILO_V2";
|
|
49
50
|
})(LenderIds || (LenderIds = {}));
|
|
50
51
|
export var LenderOps;
|
|
51
52
|
(function (LenderOps) {
|
|
@@ -95,7 +96,20 @@ export var BridgeIds;
|
|
|
95
96
|
BridgeIds[BridgeIds["STARGATE_V2"] = 0] = "STARGATE_V2";
|
|
96
97
|
BridgeIds[BridgeIds["ACROSS"] = 10] = "ACROSS";
|
|
97
98
|
BridgeIds[BridgeIds["SQUID_ROUTER"] = 20] = "SQUID_ROUTER";
|
|
99
|
+
BridgeIds[BridgeIds["GASZIP"] = 30] = "GASZIP";
|
|
98
100
|
})(BridgeIds || (BridgeIds = {}));
|
|
101
|
+
export var CompoundV2Selector;
|
|
102
|
+
(function (CompoundV2Selector) {
|
|
103
|
+
CompoundV2Selector[CompoundV2Selector["MINT_BEHALF"] = 0] = "MINT_BEHALF";
|
|
104
|
+
CompoundV2Selector[CompoundV2Selector["MINT"] = 1] = "MINT";
|
|
105
|
+
CompoundV2Selector[CompoundV2Selector["REDEEM"] = 0] = "REDEEM";
|
|
106
|
+
CompoundV2Selector[CompoundV2Selector["REDEEM_BEHALF"] = 1] = "REDEEM_BEHALF";
|
|
107
|
+
})(CompoundV2Selector || (CompoundV2Selector = {}));
|
|
108
|
+
export var SiloV2CollateralType;
|
|
109
|
+
(function (SiloV2CollateralType) {
|
|
110
|
+
SiloV2CollateralType[SiloV2CollateralType["PROTECTED"] = 0] = "PROTECTED";
|
|
111
|
+
SiloV2CollateralType[SiloV2CollateralType["COLLATERAL"] = 1] = "COLLATERAL";
|
|
112
|
+
})(SiloV2CollateralType || (SiloV2CollateralType = {}));
|
|
99
113
|
export var DexTypeMappings;
|
|
100
114
|
(function (DexTypeMappings) {
|
|
101
115
|
DexTypeMappings[DexTypeMappings["UNISWAP_V3_ID"] = 0] = "UNISWAP_V3_ID";
|
|
@@ -182,69 +196,41 @@ export function encodeStargateV2BridgeSimpleTaxi(asset, stargatePool, dstEid, re
|
|
|
182
196
|
export function encodeStargateV2BridgeSimpleBus(asset, stargatePool, dstEid, receiver, refundReceiver, amount, isNative, slippage, fee) {
|
|
183
197
|
return encodeStargateV2Bridge(asset, stargatePool, dstEid, receiver, refundReceiver, amount, slippage, fee, true, isNative, newbytes(0), newbytes(0));
|
|
184
198
|
}
|
|
185
|
-
export function encodeAcrossBridgeToken(spokePool, depositor, sendingAssetId, receivingAssetId, amount, fixedFee, feePercentage, destinationChainId, receiver, message) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
"uint32",
|
|
196
|
-
"uint32",
|
|
197
|
-
"bytes32",
|
|
198
|
-
"uint16",
|
|
199
|
-
"bytes",
|
|
200
|
-
], [
|
|
201
|
-
uint8(ComposerCommands.BRIDGING),
|
|
202
|
-
uint8(BridgeIds.ACROSS),
|
|
203
|
-
spokePool,
|
|
204
|
-
depositor,
|
|
205
|
-
sendingAssetId,
|
|
206
|
-
receivingAssetId,
|
|
207
|
-
generateAmountBitmap(uint128(amount), false, false),
|
|
208
|
-
fixedFee,
|
|
209
|
-
feePercentage,
|
|
210
|
-
destinationChainId,
|
|
211
|
-
receiver,
|
|
212
|
-
uint16(message.length / 2 - 1),
|
|
213
|
-
message,
|
|
199
|
+
export function encodeAcrossBridgeToken(spokePool, depositor, sendingAssetId, receivingAssetId, amount, fixedFee, feePercentage, destinationChainId, fromTokenDecimals, toTokenDecimals, receiver, deadline, message) {
|
|
200
|
+
return encodePacked(["bytes", "bytes"], [
|
|
201
|
+
encodeAcrossHeader(spokePool, depositor, sendingAssetId, receivingAssetId, amount, false),
|
|
202
|
+
encodeAcrossParams(fixedFee, feePercentage, destinationChainId, fromTokenDecimals, toTokenDecimals, receiver, deadline, message),
|
|
203
|
+
]);
|
|
204
|
+
}
|
|
205
|
+
export function encodeAcrossBridgeNative(spokePool, depositor, sendingAssetId, receivingAssetId, amount, fixedFee, feePercentage, destinationChainId, fromTokenDecimals, toTokenDecimals, receiver, deadline, message) {
|
|
206
|
+
return encodePacked(["bytes", "bytes"], [
|
|
207
|
+
encodeAcrossHeader(spokePool, depositor, sendingAssetId, receivingAssetId, amount, true),
|
|
208
|
+
encodeAcrossParams(fixedFee, feePercentage, destinationChainId, fromTokenDecimals, toTokenDecimals, receiver, deadline, message),
|
|
214
209
|
]);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const bridgeData = encodePacked([
|
|
219
|
-
"uint8",
|
|
220
|
-
"uint8",
|
|
221
|
-
"address",
|
|
222
|
-
"address",
|
|
223
|
-
"address",
|
|
224
|
-
"bytes32",
|
|
225
|
-
"uint128",
|
|
226
|
-
"uint128",
|
|
227
|
-
"uint32",
|
|
228
|
-
"uint32",
|
|
229
|
-
"bytes32",
|
|
230
|
-
"uint16",
|
|
231
|
-
"bytes",
|
|
232
|
-
], [
|
|
210
|
+
}
|
|
211
|
+
export function encodeAcrossHeader(spokePool, depositor, sendingAssetId, receivingAssetId, amount, isNative) {
|
|
212
|
+
return encodePacked(["uint8", "uint8", "address", "address", "address", "bytes32", "uint128"], [
|
|
233
213
|
uint8(ComposerCommands.BRIDGING),
|
|
234
214
|
uint8(BridgeIds.ACROSS),
|
|
235
215
|
spokePool,
|
|
236
216
|
depositor,
|
|
237
217
|
sendingAssetId,
|
|
238
218
|
receivingAssetId,
|
|
239
|
-
generateAmountBitmap(uint128(amount), false,
|
|
219
|
+
generateAmountBitmap(uint128(amount), false, isNative),
|
|
220
|
+
]);
|
|
221
|
+
}
|
|
222
|
+
export function encodeAcrossParams(fixedFee, feePercentage, destinationChainId, fromTokenDecimals, toTokenDecimals, receiver, deadline, message) {
|
|
223
|
+
return encodePacked(["uint128", "uint32", "uint32", "uint8", "uint8", "bytes32", "uint32", "uint16", "bytes"], [
|
|
240
224
|
fixedFee,
|
|
241
225
|
feePercentage,
|
|
242
226
|
destinationChainId,
|
|
227
|
+
fromTokenDecimals,
|
|
228
|
+
toTokenDecimals,
|
|
243
229
|
receiver,
|
|
230
|
+
deadline,
|
|
244
231
|
uint16(message.length / 2 - 1),
|
|
245
232
|
message,
|
|
246
233
|
]);
|
|
247
|
-
return bridgeData;
|
|
248
234
|
}
|
|
249
235
|
export function encodeSquidRouterCall(asset, gateway, bridgedTokenSymbol, amount, destinationChain, destinationAddress, payload, gasRefundRecipient, enableExpress, nativeAmount) {
|
|
250
236
|
const partialData = encodeSquidRouterCallPartial(asset, gateway, bridgedTokenSymbol, amount, destinationChain, destinationAddress, payload);
|
|
@@ -272,6 +258,26 @@ export function encodeSquidRouterCallPartial(asset, gateway, bridgedTokenSymbol,
|
|
|
272
258
|
uint128(amount),
|
|
273
259
|
]);
|
|
274
260
|
}
|
|
261
|
+
export function encodeGasZipBridge(gasZipRouter, receiver, amount, destinationChainId) {
|
|
262
|
+
return encodePacked(["uint8", "uint8", "address", "bytes32", "uint128", "uint256"], [
|
|
263
|
+
uint8(ComposerCommands.BRIDGING),
|
|
264
|
+
uint8(BridgeIds.GASZIP),
|
|
265
|
+
gasZipRouter,
|
|
266
|
+
receiver,
|
|
267
|
+
uint128(amount),
|
|
268
|
+
destinationChainId,
|
|
269
|
+
]);
|
|
270
|
+
}
|
|
271
|
+
export function encodeGasZipEvmBridge(gasZipRouter, receiver, amount, destinationChainId) {
|
|
272
|
+
return encodePacked(["uint8", "uint8", "address", "bytes32", "uint128", "uint256"], [
|
|
273
|
+
uint8(ComposerCommands.BRIDGING),
|
|
274
|
+
uint8(BridgeIds.GASZIP),
|
|
275
|
+
gasZipRouter,
|
|
276
|
+
rightPadZero(receiver),
|
|
277
|
+
uint128(amount),
|
|
278
|
+
destinationChainId,
|
|
279
|
+
]);
|
|
280
|
+
}
|
|
275
281
|
export function encodePermit2TransferFrom(token, receiver, amount) {
|
|
276
282
|
return encodePacked(["uint8", "uint8", "address", "address", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.PERMIT2_TRANSFER_FROM), token, receiver, uint128(amount)]);
|
|
277
283
|
}
|
|
@@ -584,7 +590,7 @@ export function encodeMorphoDepositCollateral(market, assets, receiver, data, mo
|
|
|
584
590
|
encodeApprove(getMorphoCollateral(market), morphoB),
|
|
585
591
|
uint8(ComposerCommands.LENDING),
|
|
586
592
|
uint8(LenderOps.DEPOSIT),
|
|
587
|
-
uint16(LenderIds.UP_TO_MORPHO),
|
|
593
|
+
uint16(LenderIds.UP_TO_MORPHO - 1),
|
|
588
594
|
market,
|
|
589
595
|
uint128(assets),
|
|
590
596
|
receiver,
|
|
@@ -598,7 +604,7 @@ export function encodeMorphoDeposit(market, isShares, assets, receiver, data, mo
|
|
|
598
604
|
encodeApprove(getMorphoLoanAsset(market), morphoB),
|
|
599
605
|
uint8(ComposerCommands.LENDING),
|
|
600
606
|
uint8(LenderOps.DEPOSIT_LENDING_TOKEN),
|
|
601
|
-
uint16(LenderIds.UP_TO_MORPHO),
|
|
607
|
+
uint16(LenderIds.UP_TO_MORPHO - 1),
|
|
602
608
|
market,
|
|
603
609
|
generateAmountBitmap(uint128(assets), isShares, false),
|
|
604
610
|
receiver,
|
|
@@ -631,7 +637,7 @@ export function encodeMorphoWithdraw(market, isShares, assets, receiver, morphoB
|
|
|
631
637
|
return encodePacked(["uint8", "uint8", "uint16", "bytes", "uint128", "address", "address"], [
|
|
632
638
|
uint8(ComposerCommands.LENDING),
|
|
633
639
|
uint8(LenderOps.WITHDRAW_LENDING_TOKEN),
|
|
634
|
-
uint16(LenderIds.UP_TO_MORPHO),
|
|
640
|
+
uint16(LenderIds.UP_TO_MORPHO - 1),
|
|
635
641
|
market,
|
|
636
642
|
generateAmountBitmap(uint128(assets), isShares, false),
|
|
637
643
|
receiver,
|
|
@@ -642,7 +648,7 @@ export function encodeMorphoWithdrawCollateral(market, assets, receiver, morphoB
|
|
|
642
648
|
return encodePacked(["uint8", "uint8", "uint16", "bytes", "uint128", "address", "address"], [
|
|
643
649
|
uint8(ComposerCommands.LENDING),
|
|
644
650
|
uint8(LenderOps.WITHDRAW),
|
|
645
|
-
uint16(LenderIds.UP_TO_MORPHO),
|
|
651
|
+
uint16(LenderIds.UP_TO_MORPHO - 1),
|
|
646
652
|
market,
|
|
647
653
|
uint128(assets),
|
|
648
654
|
receiver,
|
|
@@ -653,7 +659,7 @@ export function encodeMorphoBorrow(market, isShares, assets, receiver, morphoB)
|
|
|
653
659
|
return encodePacked(["uint8", "uint8", "uint16", "bytes", "uint128", "address", "address"], [
|
|
654
660
|
uint8(ComposerCommands.LENDING),
|
|
655
661
|
uint8(LenderOps.BORROW),
|
|
656
|
-
uint16(LenderIds.UP_TO_MORPHO),
|
|
662
|
+
uint16(LenderIds.UP_TO_MORPHO - 1),
|
|
657
663
|
market,
|
|
658
664
|
generateAmountBitmap(uint128(assets), isShares, false),
|
|
659
665
|
receiver,
|
|
@@ -665,7 +671,7 @@ export function encodeMorphoRepay(market, isShares, assets, receiver, data, morp
|
|
|
665
671
|
encodeApprove(getMorphoLoanAsset(market), morphoB),
|
|
666
672
|
uint8(ComposerCommands.LENDING),
|
|
667
673
|
uint8(LenderOps.REPAY),
|
|
668
|
-
uint16(LenderIds.UP_TO_MORPHO),
|
|
674
|
+
uint16(LenderIds.UP_TO_MORPHO - 1),
|
|
669
675
|
market,
|
|
670
676
|
generateAmountBitmap(uint128(assets), isShares, false),
|
|
671
677
|
receiver,
|
|
@@ -821,18 +827,40 @@ export function encodeCompoundV3Withdraw(token, amount, receiver, comet, isBase)
|
|
|
821
827
|
comet,
|
|
822
828
|
]);
|
|
823
829
|
}
|
|
824
|
-
export function encodeCompoundV2Deposit(token, amount, receiver, cToken) {
|
|
830
|
+
export function encodeCompoundV2Deposit(token, amount, receiver, cToken, selectorId) {
|
|
825
831
|
return encodePacked(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
826
832
|
token === zeroAddress ? newbytes(0) : encodeApprove(token, cToken),
|
|
827
833
|
uint8(ComposerCommands.LENDING),
|
|
828
834
|
uint8(LenderOps.DEPOSIT),
|
|
829
835
|
uint16(LenderIds.UP_TO_COMPOUND_V2 - 1),
|
|
830
836
|
token,
|
|
831
|
-
uint128(amount),
|
|
837
|
+
encodeCompoundV2SelectorId(uint128(amount), selectorId),
|
|
832
838
|
receiver,
|
|
833
839
|
cToken,
|
|
834
840
|
]);
|
|
835
841
|
}
|
|
842
|
+
export function encodeSiloV2Deposit(token, amount, receiver, silo, collateralMode) {
|
|
843
|
+
return encodePacked(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
844
|
+
token === zeroAddress ? newbytes(0) : encodeApprove(token, silo),
|
|
845
|
+
uint8(ComposerCommands.LENDING),
|
|
846
|
+
uint8(LenderOps.DEPOSIT),
|
|
847
|
+
uint16(LenderIds.UP_TO_SILO_V2 - 1),
|
|
848
|
+
token,
|
|
849
|
+
encodeSiloV2CollateralMode(uint128(amount), collateralMode),
|
|
850
|
+
receiver,
|
|
851
|
+
silo,
|
|
852
|
+
]);
|
|
853
|
+
}
|
|
854
|
+
export function encodeSiloV2Borrow(amount, receiver, silo) {
|
|
855
|
+
return encodePacked(["uint8", "uint8", "uint16", "uint128", "address", "address"], [
|
|
856
|
+
uint8(ComposerCommands.LENDING),
|
|
857
|
+
uint8(LenderOps.BORROW),
|
|
858
|
+
uint16(LenderIds.UP_TO_SILO_V2 - 1),
|
|
859
|
+
uint128(amount),
|
|
860
|
+
receiver,
|
|
861
|
+
silo,
|
|
862
|
+
]);
|
|
863
|
+
}
|
|
836
864
|
export function encodeCompoundV2Borrow(token, amount, receiver, cToken) {
|
|
837
865
|
return encodePacked(["uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
838
866
|
uint8(ComposerCommands.LENDING),
|
|
@@ -856,14 +884,36 @@ export function encodeCompoundV2Repay(token, amount, receiver, cToken) {
|
|
|
856
884
|
cToken,
|
|
857
885
|
]);
|
|
858
886
|
}
|
|
859
|
-
export function encodeCompoundV2Withdraw(token, amount, receiver, cToken) {
|
|
887
|
+
export function encodeCompoundV2Withdraw(token, amount, receiver, cToken, selectorId) {
|
|
860
888
|
return encodePacked(["uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
861
889
|
uint8(ComposerCommands.LENDING),
|
|
862
890
|
uint8(LenderOps.WITHDRAW),
|
|
863
891
|
uint16(LenderIds.UP_TO_COMPOUND_V2 - 1),
|
|
864
892
|
token,
|
|
865
|
-
uint128(amount),
|
|
893
|
+
encodeCompoundV2SelectorId(uint128(amount), selectorId),
|
|
866
894
|
receiver,
|
|
867
895
|
cToken,
|
|
868
896
|
]);
|
|
869
897
|
}
|
|
898
|
+
export function encodeSiloV2Withdraw(amount, receiver, silo, collateralMode) {
|
|
899
|
+
return encodePacked(["uint8", "uint8", "uint16", "uint128", "address", "address"], [
|
|
900
|
+
uint8(ComposerCommands.LENDING),
|
|
901
|
+
uint8(LenderOps.WITHDRAW),
|
|
902
|
+
uint16(LenderIds.UP_TO_SILO_V2 - 1),
|
|
903
|
+
encodeSiloV2CollateralMode(uint128(amount), collateralMode),
|
|
904
|
+
receiver,
|
|
905
|
+
silo,
|
|
906
|
+
]);
|
|
907
|
+
}
|
|
908
|
+
export function encodeSiloV2Repay(token, amount, receiver, silo) {
|
|
909
|
+
return encodePacked(["bytes", "uint8", "uint8", "uint16", "address", "uint128", "address", "address"], [
|
|
910
|
+
token === zeroAddress ? newbytes(0) : encodeApprove(token, silo),
|
|
911
|
+
uint8(ComposerCommands.LENDING),
|
|
912
|
+
uint8(LenderOps.REPAY),
|
|
913
|
+
uint16(LenderIds.UP_TO_SILO_V2 - 1),
|
|
914
|
+
token,
|
|
915
|
+
uint128(amount),
|
|
916
|
+
receiver,
|
|
917
|
+
silo,
|
|
918
|
+
]);
|
|
919
|
+
}
|
package/dist/esm/utils.js
CHANGED
|
@@ -51,9 +51,18 @@ export function getMorphoLoanAsset(market) {
|
|
|
51
51
|
const slice = market.slice(2, 42);
|
|
52
52
|
return `0x${slice}`;
|
|
53
53
|
}
|
|
54
|
+
export function rightPadZero(address) {
|
|
55
|
+
return (address.toLowerCase() + "0".repeat(24));
|
|
56
|
+
}
|
|
54
57
|
export function newbytes(length) {
|
|
55
58
|
return ("0x" + "0".repeat(length * 2));
|
|
56
59
|
}
|
|
57
60
|
export function bytes(value) {
|
|
58
61
|
return value;
|
|
59
62
|
}
|
|
63
|
+
export function encodeCompoundV2SelectorId(amount, selectorId) {
|
|
64
|
+
return uint128(amount) | (uint128(selectorId) << 120n);
|
|
65
|
+
}
|
|
66
|
+
export function encodeSiloV2CollateralMode(amount, mode) {
|
|
67
|
+
return uint128(amount) | (uint128(mode) << 120n);
|
|
68
|
+
}
|
|
@@ -36,7 +36,8 @@ export declare enum LenderIds {
|
|
|
36
36
|
UP_TO_AAVE_V2 = 2000,
|
|
37
37
|
UP_TO_COMPOUND_V3 = 3000,
|
|
38
38
|
UP_TO_COMPOUND_V2 = 4000,
|
|
39
|
-
UP_TO_MORPHO = 5000
|
|
39
|
+
UP_TO_MORPHO = 5000,
|
|
40
|
+
UP_TO_SILO_V2 = 6000
|
|
40
41
|
}
|
|
41
42
|
export declare enum LenderOps {
|
|
42
43
|
DEPOSIT = 0,
|
|
@@ -79,7 +80,18 @@ export declare enum ComposerCommands {
|
|
|
79
80
|
export declare enum BridgeIds {
|
|
80
81
|
STARGATE_V2 = 0,
|
|
81
82
|
ACROSS = 10,
|
|
82
|
-
SQUID_ROUTER = 20
|
|
83
|
+
SQUID_ROUTER = 20,
|
|
84
|
+
GASZIP = 30
|
|
85
|
+
}
|
|
86
|
+
export declare enum CompoundV2Selector {
|
|
87
|
+
MINT_BEHALF = 0,
|
|
88
|
+
MINT = 1,
|
|
89
|
+
REDEEM = 0,
|
|
90
|
+
REDEEM_BEHALF = 1
|
|
91
|
+
}
|
|
92
|
+
export declare enum SiloV2CollateralType {
|
|
93
|
+
PROTECTED = 0,
|
|
94
|
+
COLLATERAL = 1
|
|
83
95
|
}
|
|
84
96
|
export declare enum DexTypeMappings {
|
|
85
97
|
UNISWAP_V3_ID = 0,
|
|
@@ -117,10 +129,14 @@ export declare function encodePermit(permitId: bigint, target: Address, data: He
|
|
|
117
129
|
export declare function encodeStargateV2BridgePartial(amount: bigint, slippage: number, fee: bigint, isBusMode: boolean, isNative: boolean, composeMsg: Hex, extraOptions: Hex): Hex;
|
|
118
130
|
export declare function encodeStargateV2BridgeSimpleTaxi(asset: Address, stargatePool: Address, dstEid: number, receiver: Hex, refundReceiver: Address, amount: bigint, isNative: boolean, slippage: number, fee: bigint): Hex;
|
|
119
131
|
export declare function encodeStargateV2BridgeSimpleBus(asset: Address, stargatePool: Address, dstEid: number, receiver: Hex, refundReceiver: Address, amount: bigint, isNative: boolean, slippage: number, fee: bigint): Hex;
|
|
120
|
-
export declare function encodeAcrossBridgeToken(spokePool: Address, depositor: Address, sendingAssetId: Address, receivingAssetId: Hex, amount: bigint, fixedFee: bigint, feePercentage: number, destinationChainId: number, receiver: Hex, message: Hex): Hex;
|
|
121
|
-
export declare function encodeAcrossBridgeNative(spokePool: Address, depositor: Address, sendingAssetId: Address, receivingAssetId: Hex, amount: bigint, fixedFee: bigint, feePercentage: number, destinationChainId: number, receiver: Hex, message: Hex): Hex;
|
|
132
|
+
export declare function encodeAcrossBridgeToken(spokePool: Address, depositor: Address, sendingAssetId: Address, receivingAssetId: Hex, amount: bigint, fixedFee: bigint, feePercentage: number, destinationChainId: number, fromTokenDecimals: number, toTokenDecimals: number, receiver: Hex, deadline: number, message: Hex): Hex;
|
|
133
|
+
export declare function encodeAcrossBridgeNative(spokePool: Address, depositor: Address, sendingAssetId: Address, receivingAssetId: Hex, amount: bigint, fixedFee: bigint, feePercentage: number, destinationChainId: number, fromTokenDecimals: number, toTokenDecimals: number, receiver: Hex, deadline: number, message: Hex): Hex;
|
|
134
|
+
export declare function encodeAcrossHeader(spokePool: Address, depositor: Address, sendingAssetId: Address, receivingAssetId: Hex, amount: bigint, isNative: boolean): Hex;
|
|
135
|
+
export declare function encodeAcrossParams(fixedFee: bigint, feePercentage: number, destinationChainId: number, fromTokenDecimals: number, toTokenDecimals: number, receiver: Hex, deadline: number, message: Hex): Hex;
|
|
122
136
|
export declare function encodeSquidRouterCall(asset: Address, gateway: Address, bridgedTokenSymbol: Hex, amount: bigint, destinationChain: Hex, destinationAddress: Hex, payload: Hex, gasRefundRecipient: Address, enableExpress: boolean, nativeAmount: bigint): Hex;
|
|
123
137
|
export declare function encodeSquidRouterCallPartial(asset: Address, gateway: Address, bridgedTokenSymbol: Hex, amount: bigint, destinationChain: Hex, destinationAddress: Hex, payload: Hex): Hex;
|
|
138
|
+
export declare function encodeGasZipBridge(gasZipRouter: Address, receiver: Hex, amount: bigint, destinationChainId: bigint): Hex;
|
|
139
|
+
export declare function encodeGasZipEvmBridge(gasZipRouter: Address, receiver: Address, amount: bigint, destinationChainId: bigint): Hex;
|
|
124
140
|
export declare function encodePermit2TransferFrom(token: Address, receiver: Address, amount: bigint): Hex;
|
|
125
141
|
export declare function encodeNextGenDexUnlock(singleton: Address, id: bigint, d: Hex): Hex;
|
|
126
142
|
export declare function encodeBalancerV3FlashLoan(singleton: Address, poolId: bigint, asset: Address, receiver: Address, amount: bigint, flashData: Hex): Hex;
|
|
@@ -178,7 +194,11 @@ export declare function encodeCompoundV3Deposit(token: Address, amount: bigint,
|
|
|
178
194
|
export declare function encodeCompoundV3Borrow(token: Address, amount: bigint, receiver: Address, comet: Address): Hex;
|
|
179
195
|
export declare function encodeCompoundV3Repay(token: Address, amount: bigint, receiver: Address, comet: Address): Hex;
|
|
180
196
|
export declare function encodeCompoundV3Withdraw(token: Address, amount: bigint, receiver: Address, comet: Address, isBase: boolean): Hex;
|
|
181
|
-
export declare function encodeCompoundV2Deposit(token: Address, amount: bigint, receiver: Address, cToken: Address): Hex;
|
|
197
|
+
export declare function encodeCompoundV2Deposit(token: Address, amount: bigint, receiver: Address, cToken: Address, selectorId: number): Hex;
|
|
198
|
+
export declare function encodeSiloV2Deposit(token: Address, amount: bigint, receiver: Address, silo: Address, collateralMode: number): Hex;
|
|
199
|
+
export declare function encodeSiloV2Borrow(amount: bigint, receiver: Address, silo: Address): Hex;
|
|
182
200
|
export declare function encodeCompoundV2Borrow(token: Address, amount: bigint, receiver: Address, cToken: Address): Hex;
|
|
183
201
|
export declare function encodeCompoundV2Repay(token: Address, amount: bigint, receiver: Address, cToken: Address): Hex;
|
|
184
|
-
export declare function encodeCompoundV2Withdraw(token: Address, amount: bigint, receiver: Address, cToken: Address): Hex;
|
|
202
|
+
export declare function encodeCompoundV2Withdraw(token: Address, amount: bigint, receiver: Address, cToken: Address, selectorId: number): Hex;
|
|
203
|
+
export declare function encodeSiloV2Withdraw(amount: bigint, receiver: Address, silo: Address, collateralMode: number): Hex;
|
|
204
|
+
export declare function encodeSiloV2Repay(token: Address, amount: bigint, receiver: Address, silo: Address): Hex;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -15,5 +15,8 @@ export declare function encodePacked(types: string[], values: any[]): Hex;
|
|
|
15
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
|
+
export declare function rightPadZero(address: Address): Hex;
|
|
18
19
|
export declare function newbytes(length: number): Hex;
|
|
19
20
|
export declare function bytes(value: Hex): Hex;
|
|
21
|
+
export declare function encodeCompoundV2SelectorId(amount: bigint, selectorId: number): bigint;
|
|
22
|
+
export declare function encodeSiloV2CollateralMode(amount: bigint, mode: number): bigint;
|