@1delta/calldatalib 0.0.10 → 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.
- package/dist/CalldataLib.d.ts +43 -30
- package/dist/CalldataLib.js +164 -58
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +4 -2
- package/package.json +1 -1
package/dist/CalldataLib.d.ts
CHANGED
|
@@ -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
|
|
55
|
+
export declare enum ERC4626Ids {
|
|
51
56
|
DEPOSIT = 0,
|
|
52
57
|
WITHDRAW = 1
|
|
53
58
|
}
|
|
@@ -60,39 +65,39 @@ export declare enum Gen2025ActionIds {
|
|
|
60
65
|
BAL_V3_SETTLE = 5
|
|
61
66
|
}
|
|
62
67
|
export declare enum ComposerCommands {
|
|
63
|
-
SWAPS =
|
|
64
|
-
EXT_CALL =
|
|
65
|
-
LENDING =
|
|
66
|
-
TRANSFERS =
|
|
67
|
-
PERMIT =
|
|
68
|
-
FLASH_LOAN =
|
|
69
|
-
|
|
70
|
-
GEN_2025_SINGELTONS =
|
|
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
|
|
73
|
-
|
|
74
|
-
|
|
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,
|
|
78
|
-
|
|
84
|
+
UNISWAP_V2_ID = 1,
|
|
79
85
|
UNISWAP_V4_ID = 2,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
NATIVE_WRAP_ID = 254
|
|
86
|
+
IZI_ID = 5,
|
|
87
|
+
UNISWAP_V2_FOT_ID = 3,
|
|
88
|
+
CURVE_V1_STANDARD_ID = 64,
|
|
89
|
+
CURVE_RECEIVED_ID = 65,
|
|
90
|
+
CURVE_FORK_ID = 66,
|
|
91
|
+
WOO_FI_ID = 80,
|
|
92
|
+
GMX_ID = 90,
|
|
93
|
+
KTX_ID = 91,
|
|
94
|
+
BALANCER_V2_ID = 128,
|
|
95
|
+
BALANCER_V3_ID = 129,
|
|
96
|
+
LB_ID = 140,
|
|
97
|
+
DODO_ID = 150,
|
|
98
|
+
SYNC_SWAP_ID = 160,
|
|
99
|
+
ERC4626_ID = 253,
|
|
100
|
+
ASSET_WRAP_ID = 254
|
|
96
101
|
}
|
|
97
102
|
export declare enum DexForkMappings {
|
|
98
103
|
UNISWAP_V3 = 0,
|
|
@@ -103,6 +108,13 @@ export declare enum DexForkMappings {
|
|
|
103
108
|
BALANCER_V3 = 0,
|
|
104
109
|
UNISWAP_V2 = 0
|
|
105
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;
|
|
106
118
|
export declare function encodePermit2TransferFrom(token: Address, receiver: Address, amount: bigint): Hex;
|
|
107
119
|
export declare function encodeNextGenDexUnlock(singleton: Address, id: bigint, d: Hex): Hex;
|
|
108
120
|
export declare function encodeBalancerV3FlashLoan(singleton: Address, poolId: bigint, asset: Address, receiver: Address, amount: bigint, flashData: Hex): Hex;
|
|
@@ -128,9 +140,10 @@ export declare function encodeGmxStyleSwap(currentData: Hex, tokenOut: Address,
|
|
|
128
140
|
export declare function encodeKtxStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, cfg: any): Hex;
|
|
129
141
|
export declare function encodeCurveStyleSwap(tokenOut: Address, receiver: Address, pool: Address, indexIn: bigint, indexOut: bigint, selectorId: bigint, cfg: any): Hex;
|
|
130
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;
|
|
131
144
|
export declare function encodeNextGenDexSettle(singleton: Address, nativeAmount: bigint): Hex;
|
|
132
145
|
export declare function encodeNextGenDexSettleBalancer(singleton: Address, asset: Address, amountHint: bigint): Hex;
|
|
133
|
-
export declare function encodeTransferIn(asset: Address,
|
|
146
|
+
export declare function encodeTransferIn(asset: Address, receiver: Address, amount: bigint): Hex;
|
|
134
147
|
export declare function encodeSweep(asset: Address, receiver: Address, amount: bigint, sweepType: any): Hex;
|
|
135
148
|
export declare function encodeWrap(amount: bigint, wrapTarget: Address): Hex;
|
|
136
149
|
export declare function encodeApprove(asset: Address, target: Address): 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, 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
|
|
61
|
-
(function (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
})(
|
|
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,41 +79,41 @@ export var Gen2025ActionIds;
|
|
|
73
79
|
})(Gen2025ActionIds || (Gen2025ActionIds = {}));
|
|
74
80
|
export var ComposerCommands;
|
|
75
81
|
(function (ComposerCommands) {
|
|
76
|
-
ComposerCommands[ComposerCommands["SWAPS"] =
|
|
77
|
-
ComposerCommands[ComposerCommands["EXT_CALL"] =
|
|
78
|
-
ComposerCommands[ComposerCommands["LENDING"] =
|
|
79
|
-
ComposerCommands[ComposerCommands["TRANSFERS"] =
|
|
80
|
-
ComposerCommands[ComposerCommands["PERMIT"] =
|
|
81
|
-
ComposerCommands[ComposerCommands["FLASH_LOAN"] =
|
|
82
|
-
ComposerCommands[ComposerCommands["
|
|
83
|
-
ComposerCommands[ComposerCommands["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
|
|
86
|
-
(function (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})(
|
|
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";
|
|
93
|
-
DexTypeMappings[DexTypeMappings["
|
|
100
|
+
DexTypeMappings[DexTypeMappings["UNISWAP_V2_ID"] = 1] = "UNISWAP_V2_ID";
|
|
94
101
|
DexTypeMappings[DexTypeMappings["UNISWAP_V4_ID"] = 2] = "UNISWAP_V4_ID";
|
|
95
|
-
DexTypeMappings[DexTypeMappings["
|
|
96
|
-
DexTypeMappings[DexTypeMappings["
|
|
97
|
-
DexTypeMappings[DexTypeMappings["
|
|
98
|
-
DexTypeMappings[DexTypeMappings["
|
|
99
|
-
DexTypeMappings[DexTypeMappings["
|
|
100
|
-
DexTypeMappings[DexTypeMappings["
|
|
101
|
-
DexTypeMappings[DexTypeMappings["
|
|
102
|
-
DexTypeMappings[DexTypeMappings["
|
|
103
|
-
DexTypeMappings[DexTypeMappings["
|
|
104
|
-
DexTypeMappings[DexTypeMappings["
|
|
105
|
-
DexTypeMappings[DexTypeMappings["
|
|
106
|
-
DexTypeMappings[DexTypeMappings["
|
|
107
|
-
DexTypeMappings[DexTypeMappings["
|
|
108
|
-
DexTypeMappings[DexTypeMappings["
|
|
109
|
-
DexTypeMappings[DexTypeMappings["
|
|
110
|
-
DexTypeMappings[DexTypeMappings["NATIVE_WRAP_ID"] = 254] = "NATIVE_WRAP_ID";
|
|
102
|
+
DexTypeMappings[DexTypeMappings["IZI_ID"] = 5] = "IZI_ID";
|
|
103
|
+
DexTypeMappings[DexTypeMappings["UNISWAP_V2_FOT_ID"] = 3] = "UNISWAP_V2_FOT_ID";
|
|
104
|
+
DexTypeMappings[DexTypeMappings["CURVE_V1_STANDARD_ID"] = 64] = "CURVE_V1_STANDARD_ID";
|
|
105
|
+
DexTypeMappings[DexTypeMappings["CURVE_RECEIVED_ID"] = 65] = "CURVE_RECEIVED_ID";
|
|
106
|
+
DexTypeMappings[DexTypeMappings["CURVE_FORK_ID"] = 66] = "CURVE_FORK_ID";
|
|
107
|
+
DexTypeMappings[DexTypeMappings["WOO_FI_ID"] = 80] = "WOO_FI_ID";
|
|
108
|
+
DexTypeMappings[DexTypeMappings["GMX_ID"] = 90] = "GMX_ID";
|
|
109
|
+
DexTypeMappings[DexTypeMappings["KTX_ID"] = 91] = "KTX_ID";
|
|
110
|
+
DexTypeMappings[DexTypeMappings["BALANCER_V2_ID"] = 128] = "BALANCER_V2_ID";
|
|
111
|
+
DexTypeMappings[DexTypeMappings["BALANCER_V3_ID"] = 129] = "BALANCER_V3_ID";
|
|
112
|
+
DexTypeMappings[DexTypeMappings["LB_ID"] = 140] = "LB_ID";
|
|
113
|
+
DexTypeMappings[DexTypeMappings["DODO_ID"] = 150] = "DODO_ID";
|
|
114
|
+
DexTypeMappings[DexTypeMappings["SYNC_SWAP_ID"] = 160] = "SYNC_SWAP_ID";
|
|
115
|
+
DexTypeMappings[DexTypeMappings["ERC4626_ID"] = 253] = "ERC4626_ID";
|
|
116
|
+
DexTypeMappings[DexTypeMappings["ASSET_WRAP_ID"] = 254] = "ASSET_WRAP_ID";
|
|
111
117
|
})(DexTypeMappings || (DexTypeMappings = {}));
|
|
112
118
|
export var DexForkMappings;
|
|
113
119
|
(function (DexForkMappings) {
|
|
@@ -119,6 +125,104 @@ export var DexForkMappings;
|
|
|
119
125
|
DexForkMappings[DexForkMappings["BALANCER_V3"] = 0] = "BALANCER_V3";
|
|
120
126
|
DexForkMappings[DexForkMappings["UNISWAP_V2"] = 0] = "UNISWAP_V2";
|
|
121
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
|
+
}
|
|
122
226
|
export function encodePermit2TransferFrom(token, receiver, amount) {
|
|
123
227
|
return encodePacked(["uint8", "uint8", "address", "address", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.PERMIT2_TRANSFER_FROM), token, receiver, uint128(amount)]);
|
|
124
228
|
}
|
|
@@ -177,7 +281,7 @@ export function encodeUniswapV4Take(singleton, asset, receiver, amount) {
|
|
|
177
281
|
export function swapHead(amount, amountOutMin, assetIn) {
|
|
178
282
|
return encodePacked(["uint8", "uint128", "uint128", "address"], [
|
|
179
283
|
uint8(ComposerCommands.SWAPS),
|
|
180
|
-
generateAmountBitmap(uint128(amount), false, false),
|
|
284
|
+
generateAmountBitmap(uint128(amount), false, false, false),
|
|
181
285
|
uint128(amountOutMin),
|
|
182
286
|
assetIn,
|
|
183
287
|
]);
|
|
@@ -236,15 +340,7 @@ export function encodeBalancerV2StyleSwap(currentData, tokenOut, receiver, poolI
|
|
|
236
340
|
export function encodeLbStyleSwap(currentData, tokenOut, receiver, pool, swapForY, cfg) {
|
|
237
341
|
if (cfg === DexPayConfig.FLASH)
|
|
238
342
|
throw new Error("Invalidconfigforv2swap");
|
|
239
|
-
return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8", "
|
|
240
|
-
currentData,
|
|
241
|
-
tokenOut,
|
|
242
|
-
receiver,
|
|
243
|
-
uint8(DexTypeMappings.LB_ID),
|
|
244
|
-
pool,
|
|
245
|
-
uint8(swapForY ? 1 : 0),
|
|
246
|
-
uint16(uint256(cfg)),
|
|
247
|
-
]);
|
|
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))]);
|
|
248
344
|
}
|
|
249
345
|
export function encodeSyncSwapStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
|
|
250
346
|
if (cfg === DexPayConfig.FLASH)
|
|
@@ -315,12 +411,12 @@ export function encodeWooStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
|
|
|
315
411
|
export function encodeGmxStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
|
|
316
412
|
if (cfg === DexPayConfig.FLASH)
|
|
317
413
|
throw new Error("NoflashforWoo");
|
|
318
|
-
return encodePacked(["bytes", "address", "address", "uint8", "address", "
|
|
414
|
+
return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.GMX_ID), pool, uint8(uint256(cfg))]);
|
|
319
415
|
}
|
|
320
416
|
export function encodeKtxStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
|
|
321
417
|
if (cfg === DexPayConfig.FLASH)
|
|
322
418
|
throw new Error("NoflashforWoo");
|
|
323
|
-
return encodePacked(["bytes", "address", "address", "uint8", "address", "
|
|
419
|
+
return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.KTX_ID), pool, uint8(uint256(cfg))]);
|
|
324
420
|
}
|
|
325
421
|
export function encodeCurveStyleSwap(tokenOut, receiver, pool, indexIn, indexOut, selectorId, cfg) {
|
|
326
422
|
if (cfg === DexPayConfig.FLASH)
|
|
@@ -350,6 +446,16 @@ export function encodeCurveNGStyleSwap(tokenOut, receiver, pool, indexIn, indexO
|
|
|
350
446
|
uint16(uint256(cfg)),
|
|
351
447
|
]);
|
|
352
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
|
+
}
|
|
353
459
|
export function encodeNextGenDexSettle(singleton, nativeAmount) {
|
|
354
460
|
return encodePacked(["uint8", "uint8", "address", "uint128"], [
|
|
355
461
|
uint8(ComposerCommands.GEN_2025_SINGELTONS),
|
|
@@ -367,8 +473,8 @@ export function encodeNextGenDexSettleBalancer(singleton, asset, amountHint) {
|
|
|
367
473
|
uint128(amountHint >= 0xffffffffffffffffffffffffffffffn ? 0xffffffffffffffffffffffffffffffn : amountHint),
|
|
368
474
|
]);
|
|
369
475
|
}
|
|
370
|
-
export function encodeTransferIn(asset,
|
|
371
|
-
return encodePacked(["uint8", "uint8", "address", "address", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.TRANSFER_FROM), asset,
|
|
476
|
+
export function encodeTransferIn(asset, receiver, amount) {
|
|
477
|
+
return encodePacked(["uint8", "uint8", "address", "address", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.TRANSFER_FROM), asset, receiver, uint128(amount)]);
|
|
372
478
|
}
|
|
373
479
|
export function encodeSweep(asset, receiver, amount, sweepType) {
|
|
374
480
|
return encodePacked(["uint8", "uint8", "address", "address", "uint8", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.SWEEP), asset, receiver, sweepType, uint128(amount)]);
|
|
@@ -445,7 +551,7 @@ export function encodeMorphoDeposit(market, isShares, assets, receiver, data, mo
|
|
|
445
551
|
uint8(LenderOps.DEPOSIT_LENDING_TOKEN),
|
|
446
552
|
uint16(LenderIds.UP_TO_MORPHO),
|
|
447
553
|
market,
|
|
448
|
-
generateAmountBitmap(uint128(assets), isShares, false),
|
|
554
|
+
generateAmountBitmap(uint128(assets), isShares, false, false),
|
|
449
555
|
receiver,
|
|
450
556
|
morphoB,
|
|
451
557
|
uint16(data.length / 2 - 1 > 0 ? data.length / 2 - 1 + 1 : 0),
|
|
@@ -455,20 +561,20 @@ export function encodeMorphoDeposit(market, isShares, assets, receiver, data, mo
|
|
|
455
561
|
export function encodeErc4646Deposit(asset, vault, isShares, assets, receiver) {
|
|
456
562
|
return encodePacked(["bytes", "uint8", "uint8", "address", "address", "uint128", "address"], [
|
|
457
563
|
encodeApprove(asset, vault),
|
|
458
|
-
uint8(ComposerCommands.
|
|
564
|
+
uint8(ComposerCommands.ERC4626),
|
|
459
565
|
uint8(0),
|
|
460
566
|
asset,
|
|
461
567
|
vault,
|
|
462
|
-
generateAmountBitmap(uint128(assets), isShares, false),
|
|
568
|
+
generateAmountBitmap(uint128(assets), isShares, false, false),
|
|
463
569
|
receiver,
|
|
464
570
|
]);
|
|
465
571
|
}
|
|
466
572
|
export function encodeErc4646Withdraw(vault, isShares, assets, receiver) {
|
|
467
573
|
return encodePacked(["uint8", "uint8", "address", "uint128", "address"], [
|
|
468
|
-
uint8(ComposerCommands.
|
|
574
|
+
uint8(ComposerCommands.ERC4626),
|
|
469
575
|
uint8(1),
|
|
470
576
|
vault,
|
|
471
|
-
generateAmountBitmap(uint128(assets), isShares, false),
|
|
577
|
+
generateAmountBitmap(uint128(assets), isShares, false, false),
|
|
472
578
|
receiver,
|
|
473
579
|
]);
|
|
474
580
|
}
|
|
@@ -478,7 +584,7 @@ export function encodeMorphoWithdraw(market, isShares, assets, receiver, morphoB
|
|
|
478
584
|
uint8(LenderOps.WITHDRAW_LENDING_TOKEN),
|
|
479
585
|
uint16(LenderIds.UP_TO_MORPHO),
|
|
480
586
|
market,
|
|
481
|
-
generateAmountBitmap(uint128(assets), isShares, false),
|
|
587
|
+
generateAmountBitmap(uint128(assets), isShares, false, false),
|
|
482
588
|
receiver,
|
|
483
589
|
morphoB,
|
|
484
590
|
]);
|
|
@@ -500,7 +606,7 @@ export function encodeMorphoBorrow(market, isShares, assets, receiver, morphoB)
|
|
|
500
606
|
uint8(LenderOps.BORROW),
|
|
501
607
|
uint16(LenderIds.UP_TO_MORPHO),
|
|
502
608
|
market,
|
|
503
|
-
generateAmountBitmap(uint128(assets), isShares, false),
|
|
609
|
+
generateAmountBitmap(uint128(assets), isShares, false, false),
|
|
504
610
|
receiver,
|
|
505
611
|
morphoB,
|
|
506
612
|
]);
|
|
@@ -512,7 +618,7 @@ export function encodeMorphoRepay(market, isShares, unsafe, assets, receiver, da
|
|
|
512
618
|
uint8(LenderOps.REPAY),
|
|
513
619
|
uint16(LenderIds.UP_TO_MORPHO),
|
|
514
620
|
market,
|
|
515
|
-
generateAmountBitmap(uint128(assets), isShares, unsafe),
|
|
621
|
+
generateAmountBitmap(uint128(assets), isShares, unsafe, false),
|
|
516
622
|
receiver,
|
|
517
623
|
morphoB,
|
|
518
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
|
|
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
|
|
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) {
|