@morpho-org/morpho-sdk 5.4.1 → 5.6.0
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/README.md +23 -7
- package/lib/cjs/abis.d.ts +314 -1
- package/lib/cjs/abis.js +169 -1
- package/lib/cjs/actions/blue/borrow.d.ts +21 -15
- package/lib/cjs/actions/blue/borrow.js +25 -18
- package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +1 -1
- package/lib/cjs/actions/blue/buildAssetFundingActions.js +1 -1
- package/lib/cjs/actions/blue/buildReallocationActions.d.ts +62 -19
- package/lib/cjs/actions/blue/buildReallocationActions.js +123 -27
- package/lib/cjs/actions/blue/refinance.d.ts +14 -7
- package/lib/cjs/actions/blue/refinance.js +18 -10
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +28 -19
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +39 -23
- package/lib/cjs/actions/blue/withdraw.d.ts +20 -13
- package/lib/cjs/actions/blue/withdraw.js +23 -18
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +9 -2
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +131 -0
- package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/index.js +1 -0
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +3 -2
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -3
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +91 -0
- package/lib/cjs/actions/signatures/index.d.ts +1 -0
- package/lib/cjs/actions/signatures/index.js +1 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +54 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +96 -0
- package/lib/cjs/actions/vaultV1/index.d.ts +1 -0
- package/lib/cjs/actions/vaultV1/index.js +1 -0
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +56 -0
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +97 -0
- package/lib/cjs/actions/vaultV2/index.d.ts +1 -0
- package/lib/cjs/actions/vaultV2/index.js +1 -0
- package/lib/cjs/bundler/actions.d.ts +118 -2
- package/lib/cjs/bundler/actions.js +212 -6
- package/lib/cjs/bundler/types.d.ts +20 -0
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +3 -1
- package/lib/cjs/entities/blue/blue.d.ts +365 -76
- package/lib/cjs/entities/blue/blue.js +285 -52
- package/lib/cjs/entities/index.d.ts +2 -1
- package/lib/cjs/entities/index.js +6 -3
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +82 -4
- package/lib/cjs/entities/vaultV1/vaultV1.js +164 -0
- package/lib/cjs/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +41 -17
- package/lib/cjs/entities/{reallocationData.js → vaultV1ReallocationData.js} +30 -18
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +89 -3
- package/lib/cjs/entities/vaultV2/vaultV2.js +181 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +511 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +1311 -0
- package/lib/{esm/helpers/computeReallocations.d.ts → cjs/helpers/computeVaultV1Reallocations.d.ts} +14 -8
- package/lib/cjs/helpers/{computeReallocations.js → computeVaultV1Reallocations.js} +27 -13
- package/lib/cjs/helpers/constant.d.ts +5 -3
- package/lib/cjs/helpers/constant.js +6 -4
- package/lib/cjs/helpers/index.d.ts +3 -2
- package/lib/cjs/helpers/index.js +8 -3
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +73 -0
- package/lib/cjs/helpers/validate.d.ts +31 -15
- package/lib/cjs/helpers/validate.js +140 -27
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +2 -1
- package/lib/cjs/types/action.d.ts +33 -1
- package/lib/cjs/types/error.d.ts +363 -5
- package/lib/cjs/types/error.js +455 -6
- package/lib/cjs/types/sharedLiquidity.d.ts +72 -8
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +6 -4
- package/lib/esm/abis.d.ts +314 -1
- package/lib/esm/abis.js +167 -1
- package/lib/esm/actions/blue/borrow.d.ts +21 -15
- package/lib/esm/actions/blue/borrow.js +26 -19
- package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +1 -1
- package/lib/esm/actions/blue/buildAssetFundingActions.js +1 -1
- package/lib/esm/actions/blue/buildReallocationActions.d.ts +62 -19
- package/lib/esm/actions/blue/buildReallocationActions.js +119 -25
- package/lib/esm/actions/blue/refinance.d.ts +14 -7
- package/lib/esm/actions/blue/refinance.js +19 -11
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +28 -19
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +40 -24
- package/lib/esm/actions/blue/withdraw.d.ts +20 -13
- package/lib/esm/actions/blue/withdraw.js +24 -19
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +9 -2
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +127 -0
- package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/index.js +1 -0
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +3 -2
- package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -3
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +87 -0
- package/lib/esm/actions/signatures/index.d.ts +1 -0
- package/lib/esm/actions/signatures/index.js +1 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +54 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.js +92 -0
- package/lib/esm/actions/vaultV1/index.d.ts +1 -0
- package/lib/esm/actions/vaultV1/index.js +1 -0
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +56 -0
- package/lib/esm/actions/vaultV2/inKindRedeem.js +93 -0
- package/lib/esm/actions/vaultV2/index.d.ts +1 -0
- package/lib/esm/actions/vaultV2/index.js +1 -0
- package/lib/esm/bundler/actions.d.ts +118 -2
- package/lib/esm/bundler/actions.js +215 -9
- package/lib/esm/bundler/types.d.ts +20 -0
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +362 -73
- package/lib/esm/entities/blue/blue.js +288 -55
- package/lib/esm/entities/index.d.ts +2 -1
- package/lib/esm/entities/index.js +2 -1
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +80 -2
- package/lib/esm/entities/vaultV1/vaultV1.js +170 -6
- package/lib/esm/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +41 -17
- package/lib/esm/entities/{reallocationData.js → vaultV1ReallocationData.js} +33 -16
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +88 -2
- package/lib/esm/entities/vaultV2/vaultV2.js +187 -6
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +511 -0
- package/lib/esm/entities/vaultV2BlueReallocationData.js +1307 -0
- package/lib/{cjs/helpers/computeReallocations.d.ts → esm/helpers/computeVaultV1Reallocations.d.ts} +14 -8
- package/lib/esm/helpers/{computeReallocations.js → computeVaultV1Reallocations.js} +25 -11
- package/lib/esm/helpers/constant.d.ts +5 -3
- package/lib/esm/helpers/constant.js +5 -3
- package/lib/esm/helpers/index.d.ts +3 -2
- package/lib/esm/helpers/index.js +3 -2
- package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.js +70 -0
- package/lib/esm/helpers/validate.d.ts +31 -15
- package/lib/esm/helpers/validate.js +141 -30
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +2 -1
- package/lib/esm/types/action.d.ts +33 -1
- package/lib/esm/types/error.d.ts +363 -5
- package/lib/esm/types/error.js +428 -4
- package/lib/esm/types/sharedLiquidity.d.ts +72 -8
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +9 -11
|
@@ -44,8 +44,7 @@ const consumeCallValue = (state, call) => {
|
|
|
44
44
|
*
|
|
45
45
|
* @remarks
|
|
46
46
|
* The namespace covers only the Bundler3 actions required by `morpho-sdk`.
|
|
47
|
-
* It does not expose operation population or simulation helpers
|
|
48
|
-
* `@morpho-org/bundler-sdk-viem`.
|
|
47
|
+
* It does not expose operation population or broad simulation helpers.
|
|
49
48
|
*/
|
|
50
49
|
var BundlerAction;
|
|
51
50
|
(function (BundlerAction) {
|
|
@@ -197,6 +196,12 @@ var BundlerAction;
|
|
|
197
196
|
case "reallocateTo": {
|
|
198
197
|
return BundlerAction.publicAllocatorReallocateTo(chainId, ...args);
|
|
199
198
|
}
|
|
199
|
+
case "vaultV2BluePublicAllocatorReallocate": {
|
|
200
|
+
return BundlerAction.vaultV2BluePublicAllocatorReallocate(chainId, ...args);
|
|
201
|
+
}
|
|
202
|
+
case "vaultV2BluePublicAllocatorAllocateFromIdle": {
|
|
203
|
+
return BundlerAction.vaultV2BluePublicAllocatorAllocateFromIdle(chainId, ...args);
|
|
204
|
+
}
|
|
200
205
|
case "wrapNative": {
|
|
201
206
|
return BundlerAction.wrapNative(chainId, ...args);
|
|
202
207
|
}
|
|
@@ -1099,15 +1104,15 @@ var BundlerAction;
|
|
|
1099
1104
|
*/
|
|
1100
1105
|
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1101
1106
|
function publicAllocatorReallocateTo(chainId, vault, fee, withdrawals, supplyMarketParams, skipRevert = false) {
|
|
1102
|
-
const {
|
|
1103
|
-
if (
|
|
1107
|
+
const { vaultV1PublicAllocator } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1108
|
+
if (vaultV1PublicAllocator == null) {
|
|
1104
1109
|
throw new error_js_1.BundlerErrors.UnexpectedAction("reallocateTo", chainId);
|
|
1105
1110
|
}
|
|
1106
1111
|
return [
|
|
1107
1112
|
{
|
|
1108
|
-
to:
|
|
1113
|
+
to: vaultV1PublicAllocator,
|
|
1109
1114
|
data: (0, viem_1.encodeFunctionData)({
|
|
1110
|
-
abi: blue_sdk_viem_1.
|
|
1115
|
+
abi: blue_sdk_viem_1.vaultV1PublicAllocatorAbi,
|
|
1111
1116
|
functionName: "reallocateTo",
|
|
1112
1117
|
args: [vault, withdrawals, supplyMarketParams],
|
|
1113
1118
|
}),
|
|
@@ -1118,6 +1123,207 @@ var BundlerAction;
|
|
|
1118
1123
|
];
|
|
1119
1124
|
}
|
|
1120
1125
|
BundlerAction.publicAllocatorReallocateTo = publicAllocatorReallocateTo;
|
|
1126
|
+
/**
|
|
1127
|
+
* Encodes a Vault V2 Blue Public Allocator market-to-market reallocation.
|
|
1128
|
+
*
|
|
1129
|
+
* @remarks Bundler3 must already hold the computed penalty assets. The
|
|
1130
|
+
* high-level Blue builders add the corresponding GeneralAdapter1 transfer.
|
|
1131
|
+
*
|
|
1132
|
+
* @param chainId - Chain whose canonical Blue Public Allocator is called.
|
|
1133
|
+
* @param vault - Vault whose liquidity is reallocated.
|
|
1134
|
+
* @param deallocateAdapter - Vault V2 adapter supplying the source market.
|
|
1135
|
+
* @param deallocateMarket - Source Morpho Blue market parameters.
|
|
1136
|
+
* @param allocateAdapter - Vault V2 adapter supplying the target market.
|
|
1137
|
+
* @param allocateMarket - Target Morpho Blue market parameters.
|
|
1138
|
+
* @param assets - Assets to reallocate, bounded by `uint128` by the high-level action.
|
|
1139
|
+
* @param penalty - Vault-configured proportional penalty, scaled by WAD.
|
|
1140
|
+
* @param skipRevert - Whether Bundler3 should tolerate a revert.
|
|
1141
|
+
* @returns A zero reset and exact approval when needed, then the allocator call.
|
|
1142
|
+
* @throws {BundlerErrors.UnexpectedAction} when the chain has no Blue Public Allocator deployment.
|
|
1143
|
+
* @throws {BundlerErrors.SkippableAllocatorPenalty} when `skipRevert` is true and a token approval is required.
|
|
1144
|
+
* @example
|
|
1145
|
+
* ```ts
|
|
1146
|
+
* import { ChainId, type InputMarketParams } from "@morpho-org/blue-sdk";
|
|
1147
|
+
* import {
|
|
1148
|
+
* BundlerAction,
|
|
1149
|
+
* type BundlerCall,
|
|
1150
|
+
* } from "@morpho-org/morpho-sdk/bundler";
|
|
1151
|
+
* import type { Address } from "viem";
|
|
1152
|
+
*
|
|
1153
|
+
* const keyrockUsdcVault =
|
|
1154
|
+
* "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145" satisfies Address;
|
|
1155
|
+
* const sourceAdapterFixture =
|
|
1156
|
+
* "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" satisfies Address;
|
|
1157
|
+
* const targetAdapterFixture =
|
|
1158
|
+
* "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" satisfies Address;
|
|
1159
|
+
* const usdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" satisfies Address;
|
|
1160
|
+
* const weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" satisfies Address;
|
|
1161
|
+
* const wbtc = "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599" satisfies Address;
|
|
1162
|
+
* const ethUsdOracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" satisfies Address;
|
|
1163
|
+
* const adaptiveCurveIrm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC" satisfies Address;
|
|
1164
|
+
* const sourceMarket = {
|
|
1165
|
+
* loanToken: usdc,
|
|
1166
|
+
* collateralToken: weth,
|
|
1167
|
+
* oracle: ethUsdOracle,
|
|
1168
|
+
* irm: adaptiveCurveIrm,
|
|
1169
|
+
* lltv: 860_000_000_000_000_000n,
|
|
1170
|
+
* } satisfies InputMarketParams;
|
|
1171
|
+
* const targetMarket = {
|
|
1172
|
+
* ...sourceMarket,
|
|
1173
|
+
* collateralToken: wbtc,
|
|
1174
|
+
* } satisfies InputMarketParams;
|
|
1175
|
+
*
|
|
1176
|
+
* const calls: BundlerCall[] = BundlerAction.vaultV2BluePublicAllocatorReallocate(
|
|
1177
|
+
* ChainId.EthMainnet,
|
|
1178
|
+
* keyrockUsdcVault,
|
|
1179
|
+
* sourceAdapterFixture,
|
|
1180
|
+
* sourceMarket,
|
|
1181
|
+
* targetAdapterFixture,
|
|
1182
|
+
* targetMarket,
|
|
1183
|
+
* 1_000_000n,
|
|
1184
|
+
* 1_000_000_000_000_000n,
|
|
1185
|
+
* );
|
|
1186
|
+
* // Bundler3 resets and approves 1_000 USDC units, then calls `reallocate` with zero native value.
|
|
1187
|
+
* ```
|
|
1188
|
+
*/
|
|
1189
|
+
// biome-ignore lint/complexity/useMaxParams: mirrors the protocol call
|
|
1190
|
+
function vaultV2BluePublicAllocatorReallocate(chainId, vault, deallocateAdapter, deallocateMarket, allocateAdapter, allocateMarket, assets, penalty, skipRevert = false) {
|
|
1191
|
+
const { vaultV2BluePublicAllocator: allocator } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1192
|
+
if (allocator == null) {
|
|
1193
|
+
throw new error_js_1.BundlerErrors.UnexpectedAction("vaultV2BluePublicAllocatorReallocate", chainId);
|
|
1194
|
+
}
|
|
1195
|
+
const calls = [];
|
|
1196
|
+
const penaltyAssets = blue_sdk_1.VaultV2BluePublicAllocatorConfigUtils.getPenaltyAssets({ penalty }, assets);
|
|
1197
|
+
if (skipRevert && penaltyAssets > 0n) {
|
|
1198
|
+
throw new error_js_1.BundlerErrors.SkippableAllocatorPenalty(penaltyAssets);
|
|
1199
|
+
}
|
|
1200
|
+
if (penaltyAssets > 0n) {
|
|
1201
|
+
for (const amount of [0n, penaltyAssets])
|
|
1202
|
+
calls.push({
|
|
1203
|
+
to: allocateMarket.loanToken,
|
|
1204
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
1205
|
+
abi: viem_1.erc20Abi,
|
|
1206
|
+
functionName: "approve",
|
|
1207
|
+
args: [allocator, amount],
|
|
1208
|
+
}),
|
|
1209
|
+
value: 0n,
|
|
1210
|
+
skipRevert,
|
|
1211
|
+
callbackHash: viem_1.zeroHash,
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
calls.push({
|
|
1215
|
+
to: allocator,
|
|
1216
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
1217
|
+
abi: blue_sdk_viem_1.vaultV2BluePublicAllocatorAbi,
|
|
1218
|
+
functionName: "reallocate",
|
|
1219
|
+
args: [
|
|
1220
|
+
vault,
|
|
1221
|
+
deallocateAdapter,
|
|
1222
|
+
deallocateMarket,
|
|
1223
|
+
allocateAdapter,
|
|
1224
|
+
allocateMarket,
|
|
1225
|
+
assets,
|
|
1226
|
+
penalty,
|
|
1227
|
+
],
|
|
1228
|
+
}),
|
|
1229
|
+
value: 0n,
|
|
1230
|
+
skipRevert,
|
|
1231
|
+
callbackHash: viem_1.zeroHash,
|
|
1232
|
+
});
|
|
1233
|
+
return calls;
|
|
1234
|
+
}
|
|
1235
|
+
BundlerAction.vaultV2BluePublicAllocatorReallocate = vaultV2BluePublicAllocatorReallocate;
|
|
1236
|
+
/**
|
|
1237
|
+
* Encodes a Vault V2 Blue Public Allocator allocation from vault idle liquidity.
|
|
1238
|
+
*
|
|
1239
|
+
* @remarks Bundler3 must already hold the computed penalty assets. The
|
|
1240
|
+
* high-level Blue builders add the corresponding GeneralAdapter1 transfer.
|
|
1241
|
+
*
|
|
1242
|
+
* @param chainId - Chain whose canonical Blue Public Allocator is called.
|
|
1243
|
+
* @param vault - Vault whose idle liquidity is allocated.
|
|
1244
|
+
* @param adapter - Vault V2 adapter supplying the target market.
|
|
1245
|
+
* @param market - Target Morpho Blue market parameters.
|
|
1246
|
+
* @param assets - Assets to allocate, bounded by `uint128` by the high-level action.
|
|
1247
|
+
* @param penalty - Vault-configured proportional penalty, scaled by WAD.
|
|
1248
|
+
* @param skipRevert - Whether Bundler3 should tolerate a revert.
|
|
1249
|
+
* @returns A zero reset and exact approval when needed, then the allocator call.
|
|
1250
|
+
* @throws {BundlerErrors.UnexpectedAction} when the chain has no Blue Public Allocator deployment.
|
|
1251
|
+
* @throws {BundlerErrors.SkippableAllocatorPenalty} when `skipRevert` is true and a token approval is required.
|
|
1252
|
+
* @example
|
|
1253
|
+
* ```ts
|
|
1254
|
+
* import { ChainId, type InputMarketParams } from "@morpho-org/blue-sdk";
|
|
1255
|
+
* import {
|
|
1256
|
+
* BundlerAction,
|
|
1257
|
+
* type BundlerCall,
|
|
1258
|
+
* } from "@morpho-org/morpho-sdk/bundler";
|
|
1259
|
+
* import type { Address } from "viem";
|
|
1260
|
+
*
|
|
1261
|
+
* const keyrockUsdcVault =
|
|
1262
|
+
* "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145" satisfies Address;
|
|
1263
|
+
* const targetAdapterFixture =
|
|
1264
|
+
* "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" satisfies Address;
|
|
1265
|
+
* const usdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" satisfies Address;
|
|
1266
|
+
* const weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" satisfies Address;
|
|
1267
|
+
* const ethUsdOracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" satisfies Address;
|
|
1268
|
+
* const adaptiveCurveIrm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC" satisfies Address;
|
|
1269
|
+
* const targetMarket = {
|
|
1270
|
+
* loanToken: usdc,
|
|
1271
|
+
* collateralToken: weth,
|
|
1272
|
+
* oracle: ethUsdOracle,
|
|
1273
|
+
* irm: adaptiveCurveIrm,
|
|
1274
|
+
* lltv: 860_000_000_000_000_000n,
|
|
1275
|
+
* } satisfies InputMarketParams;
|
|
1276
|
+
*
|
|
1277
|
+
* const calls: BundlerCall[] = BundlerAction.vaultV2BluePublicAllocatorAllocateFromIdle(
|
|
1278
|
+
* ChainId.EthMainnet,
|
|
1279
|
+
* keyrockUsdcVault,
|
|
1280
|
+
* targetAdapterFixture,
|
|
1281
|
+
* targetMarket,
|
|
1282
|
+
* 1_000_000n,
|
|
1283
|
+
* 1_000_000_000_000_000n,
|
|
1284
|
+
* );
|
|
1285
|
+
* // Bundler3 resets and approves 1_000 USDC units, then calls `allocateFromIdle` with zero native value.
|
|
1286
|
+
* ```
|
|
1287
|
+
*/
|
|
1288
|
+
// biome-ignore lint/complexity/useMaxParams: mirrors the protocol call
|
|
1289
|
+
function vaultV2BluePublicAllocatorAllocateFromIdle(chainId, vault, adapter, market, assets, penalty, skipRevert = false) {
|
|
1290
|
+
const { vaultV2BluePublicAllocator: allocator } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1291
|
+
if (allocator == null) {
|
|
1292
|
+
throw new error_js_1.BundlerErrors.UnexpectedAction("vaultV2BluePublicAllocatorAllocateFromIdle", chainId);
|
|
1293
|
+
}
|
|
1294
|
+
const calls = [];
|
|
1295
|
+
const penaltyAssets = blue_sdk_1.VaultV2BluePublicAllocatorConfigUtils.getPenaltyAssets({ penalty }, assets);
|
|
1296
|
+
if (skipRevert && penaltyAssets > 0n) {
|
|
1297
|
+
throw new error_js_1.BundlerErrors.SkippableAllocatorPenalty(penaltyAssets);
|
|
1298
|
+
}
|
|
1299
|
+
if (penaltyAssets > 0n) {
|
|
1300
|
+
for (const amount of [0n, penaltyAssets])
|
|
1301
|
+
calls.push({
|
|
1302
|
+
to: market.loanToken,
|
|
1303
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
1304
|
+
abi: viem_1.erc20Abi,
|
|
1305
|
+
functionName: "approve",
|
|
1306
|
+
args: [allocator, amount],
|
|
1307
|
+
}),
|
|
1308
|
+
value: 0n,
|
|
1309
|
+
skipRevert,
|
|
1310
|
+
callbackHash: viem_1.zeroHash,
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
calls.push({
|
|
1314
|
+
to: allocator,
|
|
1315
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
1316
|
+
abi: blue_sdk_viem_1.vaultV2BluePublicAllocatorAbi,
|
|
1317
|
+
functionName: "allocateFromIdle",
|
|
1318
|
+
args: [vault, adapter, market, assets, penalty],
|
|
1319
|
+
}),
|
|
1320
|
+
value: 0n,
|
|
1321
|
+
skipRevert,
|
|
1322
|
+
callbackHash: viem_1.zeroHash,
|
|
1323
|
+
});
|
|
1324
|
+
return calls;
|
|
1325
|
+
}
|
|
1326
|
+
BundlerAction.vaultV2BluePublicAllocatorAllocateFromIdle = vaultV2BluePublicAllocatorAllocateFromIdle;
|
|
1121
1327
|
/**
|
|
1122
1328
|
* Encodes a GeneralAdapter1 native-token wrap call.
|
|
1123
1329
|
*
|
|
@@ -180,6 +180,26 @@ export interface ActionArgs {
|
|
|
180
180
|
supplyMarket: InputMarketParams,
|
|
181
181
|
skipRevert?: boolean
|
|
182
182
|
];
|
|
183
|
+
/** Vault V2 Blue Public Allocator market-to-market reallocation with a WAD-scaled penalty. */
|
|
184
|
+
readonly vaultV2BluePublicAllocatorReallocate: [
|
|
185
|
+
vault: Address,
|
|
186
|
+
deallocateAdapter: Address,
|
|
187
|
+
deallocateMarket: InputMarketParams,
|
|
188
|
+
allocateAdapter: Address,
|
|
189
|
+
allocateMarket: InputMarketParams,
|
|
190
|
+
assets: bigint,
|
|
191
|
+
penalty: bigint,
|
|
192
|
+
skipRevert?: boolean
|
|
193
|
+
];
|
|
194
|
+
/** Vault V2 Blue Public Allocator idle-to-market allocation with a WAD-scaled penalty. */
|
|
195
|
+
readonly vaultV2BluePublicAllocatorAllocateFromIdle: [
|
|
196
|
+
vault: Address,
|
|
197
|
+
adapter: Address,
|
|
198
|
+
market: InputMarketParams,
|
|
199
|
+
assets: bigint,
|
|
200
|
+
penalty: bigint,
|
|
201
|
+
skipRevert?: boolean
|
|
202
|
+
];
|
|
183
203
|
/** GeneralAdapter1 native wrap of `amount` to `recipient`; `skipRevert` controls Bundler3 revert handling. */
|
|
184
204
|
readonly wrapNative: [
|
|
185
205
|
amount: bigint,
|
package/lib/cjs/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, isMarketId, LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType, } from "@morpho-org/blue-sdk";
|
|
2
2
|
export { CBP, COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH, MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE, MAX_SETTLEMENT_FEES, MAX_TICK, OFFER_TYPEHASH, PRICE_ROUNDING_STEP, SETTLEMENT_FEE_BREAKPOINTS, } from "@morpho-org/midnight-sdk";
|
|
3
3
|
export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, CDN_BASE_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, OPTIMIZERS_API_BASE_URL, OPTIMIZERS_BASE_URL, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
|
|
4
|
-
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
|
|
4
|
+
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_LLTV_BUFFER = exports.APPROVE_ONLY_ONCE_TOKENS = exports.ZERO_ADDRESS = exports.REWARDS_BASE_URL = exports.OPTIMIZERS_BASE_URL = exports.OPTIMIZERS_API_BASE_URL = exports.MORPHO_DOMAIN = exports.DOCS_BASE_URL = exports.ChainUtils = exports.ChainId = exports.CDN_BASE_URL = exports.BLUE_API_GRAPHQL_URL = exports.BLUE_API_BASE_URL = exports.SETTLEMENT_FEE_BREAKPOINTS = exports.PRICE_ROUNDING_STEP = exports.OFFER_TYPEHASH = exports.MAX_TICK = exports.MAX_SETTLEMENT_FEES = exports.MAX_CONTINUOUS_FEE = exports.MAX_COLLATERALS_PER_BORROWER = exports.MAX_COLLATERALS = exports.MARKET_TYPEHASH = exports.EIP712_DOMAIN_TYPEHASH = exports.DEFAULT_TICK_SPACING = exports.COLLATERAL_PARAMS_TYPEHASH = exports.CBP = exports.TransactionType = exports.SECONDS_PER_YEAR = exports.ORACLE_PRICE_SCALE = exports.MAX_LIQUIDATION_INCENTIVE_FACTOR = exports.LIQUIDATION_CURSOR = exports.isMarketId = exports.EIP_712_FIELDS = exports.DEFAULT_SLIPPAGE_TOLERANCE = void 0;
|
|
3
|
+
exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.APPROVE_ONLY_ONCE_TOKENS = exports.ZERO_ADDRESS = exports.REWARDS_BASE_URL = exports.OPTIMIZERS_BASE_URL = exports.OPTIMIZERS_API_BASE_URL = exports.MORPHO_DOMAIN = exports.DOCS_BASE_URL = exports.ChainUtils = exports.ChainId = exports.CDN_BASE_URL = exports.BLUE_API_GRAPHQL_URL = exports.BLUE_API_BASE_URL = exports.SETTLEMENT_FEE_BREAKPOINTS = exports.PRICE_ROUNDING_STEP = exports.OFFER_TYPEHASH = exports.MAX_TICK = exports.MAX_SETTLEMENT_FEES = exports.MAX_CONTINUOUS_FEE = exports.MAX_COLLATERALS_PER_BORROWER = exports.MAX_COLLATERALS = exports.MARKET_TYPEHASH = exports.EIP712_DOMAIN_TYPEHASH = exports.DEFAULT_TICK_SPACING = exports.COLLATERAL_PARAMS_TYPEHASH = exports.CBP = exports.TransactionType = exports.SECONDS_PER_YEAR = exports.ORACLE_PRICE_SCALE = exports.MAX_LIQUIDATION_INCENTIVE_FACTOR = exports.LIQUIDATION_CURSOR = exports.isMarketId = exports.EIP_712_FIELDS = exports.DEFAULT_SLIPPAGE_TOLERANCE = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "DEFAULT_SLIPPAGE_TOLERANCE", { enumerable: true, get: function () { return blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE; } });
|
|
6
6
|
Object.defineProperty(exports, "EIP_712_FIELDS", { enumerable: true, get: function () { return blue_sdk_1.EIP_712_FIELDS; } });
|
|
@@ -39,8 +39,10 @@ Object.defineProperty(exports, "ZERO_ADDRESS", { enumerable: true, get: function
|
|
|
39
39
|
var constant_js_1 = require("./helpers/constant.js");
|
|
40
40
|
Object.defineProperty(exports, "APPROVE_ONLY_ONCE_TOKENS", { enumerable: true, get: function () { return constant_js_1.APPROVE_ONLY_ONCE_TOKENS; } });
|
|
41
41
|
Object.defineProperty(exports, "DEFAULT_LLTV_BUFFER", { enumerable: true, get: function () { return constant_js_1.DEFAULT_LLTV_BUFFER; } });
|
|
42
|
+
Object.defineProperty(exports, "DEFAULT_MAX_REALLOCATION_PENALTY", { enumerable: true, get: function () { return constant_js_1.DEFAULT_MAX_REALLOCATION_PENALTY; } });
|
|
42
43
|
Object.defineProperty(exports, "DEFAULT_SUPPLY_TARGET_UTILIZATION", { enumerable: true, get: function () { return constant_js_1.DEFAULT_SUPPLY_TARGET_UTILIZATION; } });
|
|
43
44
|
Object.defineProperty(exports, "DEFAULT_WITHDRAWAL_TARGET_UTILIZATION", { enumerable: true, get: function () { return constant_js_1.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION; } });
|
|
44
45
|
Object.defineProperty(exports, "MAX_ABSOLUTE_SHARE_PRICE", { enumerable: true, get: function () { return constant_js_1.MAX_ABSOLUTE_SHARE_PRICE; } });
|
|
46
|
+
Object.defineProperty(exports, "MAX_REALLOCATION_PENALTY", { enumerable: true, get: function () { return constant_js_1.MAX_REALLOCATION_PENALTY; } });
|
|
45
47
|
Object.defineProperty(exports, "MAX_SLIPPAGE_TOLERANCE", { enumerable: true, get: function () { return constant_js_1.MAX_SLIPPAGE_TOLERANCE; } });
|
|
46
48
|
Object.defineProperty(exports, "MAX_TOKEN_APPROVALS", { enumerable: true, get: function () { return constant_js_1.MAX_TOKEN_APPROVALS; } });
|