@morpho-org/morpho-sdk 5.5.0 → 5.7.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 +11 -7
- package/lib/cjs/abis.d.ts +15 -3
- package/lib/cjs/abis.js +15 -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/midnight/mempoolSubmitOffers.d.ts +2 -2
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +2 -2
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +1 -1
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +2 -1
- package/lib/cjs/blue/abis.d.ts +2 -0
- package/lib/cjs/blue/abis.js +33 -0
- package/lib/cjs/blue/addresses.d.ts +2 -0
- package/lib/cjs/blue/addresses.js +19 -0
- package/lib/cjs/blue/constants.d.ts +1 -0
- package/lib/cjs/blue/constants.js +13 -0
- package/lib/cjs/blue/entities.d.ts +2 -0
- package/lib/cjs/blue/entities.js +37 -0
- package/lib/cjs/blue/errors.d.ts +2 -0
- package/lib/cjs/blue/errors.js +29 -0
- package/lib/cjs/blue/fetch.d.ts +1 -0
- package/lib/cjs/blue/fetch.js +33 -0
- package/lib/cjs/blue/types.d.ts +2 -0
- package/lib/cjs/blue/types.js +2 -0
- package/lib/cjs/blue/utils.d.ts +3 -0
- package/lib/cjs/blue/utils.js +29 -0
- package/lib/cjs/bundler/actions.d.ts +122 -3
- package/lib/cjs/bundler/actions.js +216 -7
- package/lib/cjs/bundler/types.d.ts +20 -0
- package/lib/cjs/constants.d.ts +37 -3
- package/lib/cjs/constants.js +41 -1
- package/lib/cjs/entities/blue/blue.d.ts +362 -71
- package/lib/cjs/entities/blue/blue.js +286 -52
- package/lib/cjs/entities/index.d.ts +64 -4
- package/lib/cjs/entities/index.js +37 -22
- package/lib/cjs/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +40 -15
- package/lib/cjs/entities/{reallocationData.js → vaultV1ReallocationData.js} +29 -16
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +1 -1
- package/lib/cjs/entities/vaultV2/vaultV2.js +1 -1
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +511 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +1300 -0
- package/lib/cjs/errors.d.ts +48 -3
- package/lib/cjs/errors.js +62 -1
- package/lib/cjs/fetch.d.ts +16 -1
- package/lib/cjs/fetch.js +24 -1
- 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 +2 -2
- package/lib/cjs/helpers/index.js +6 -3
- package/lib/cjs/helpers/validate.d.ts +32 -16
- package/lib/cjs/helpers/validate.js +142 -29
- package/lib/cjs/midnight/abis.d.ts +1 -0
- package/lib/cjs/midnight/abis.js +8 -0
- package/lib/cjs/midnight/constants.d.ts +1 -0
- package/lib/cjs/midnight/constants.js +19 -0
- package/lib/cjs/midnight/entities.d.ts +2 -0
- package/lib/cjs/midnight/entities.js +11 -0
- package/lib/cjs/midnight/errors.d.ts +1 -0
- package/lib/cjs/midnight/errors.js +24 -0
- package/lib/cjs/midnight/fetch.d.ts +1 -0
- package/lib/cjs/midnight/fetch.js +9 -0
- package/lib/cjs/midnight/types.d.ts +1 -0
- package/lib/cjs/midnight/types.js +2 -0
- package/lib/cjs/midnight/utils.d.ts +1 -0
- package/lib/cjs/midnight/utils.js +17 -0
- package/lib/cjs/types/action.d.ts +12 -0
- package/lib/cjs/types/error.d.ts +224 -5
- package/lib/cjs/types/error.js +269 -7
- package/lib/cjs/types/sharedLiquidity.d.ts +72 -8
- package/lib/cjs/types.d.ts +17 -2
- package/lib/cjs/utils.d.ts +31 -4
- package/lib/cjs/utils.js +44 -4
- package/lib/esm/abis.d.ts +15 -3
- package/lib/esm/abis.js +15 -3
- 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/midnight/mempoolSubmitOffers.d.ts +2 -2
- package/lib/esm/actions/midnight/mempoolSubmitOffers.js +2 -2
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +1 -1
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.js +2 -1
- package/lib/esm/blue/abis.d.ts +2 -0
- package/lib/esm/blue/abis.js +2 -0
- package/lib/esm/blue/addresses.d.ts +2 -0
- package/lib/esm/blue/addresses.js +1 -0
- package/lib/esm/blue/constants.d.ts +1 -0
- package/lib/esm/blue/constants.js +1 -0
- package/lib/esm/blue/entities.d.ts +2 -0
- package/lib/esm/blue/entities.js +1 -0
- package/lib/esm/blue/errors.d.ts +2 -0
- package/lib/esm/blue/errors.js +2 -0
- package/lib/esm/blue/fetch.d.ts +1 -0
- package/lib/esm/blue/fetch.js +1 -0
- package/lib/esm/blue/types.d.ts +2 -0
- package/lib/esm/blue/types.js +1 -0
- package/lib/esm/blue/utils.d.ts +3 -0
- package/lib/esm/blue/utils.js +2 -0
- package/lib/esm/bundler/actions.d.ts +122 -3
- package/lib/esm/bundler/actions.js +219 -10
- package/lib/esm/bundler/types.d.ts +20 -0
- package/lib/esm/constants.d.ts +37 -3
- package/lib/esm/constants.js +37 -3
- package/lib/esm/entities/blue/blue.d.ts +362 -71
- package/lib/esm/entities/blue/blue.js +289 -55
- package/lib/esm/entities/index.d.ts +64 -4
- package/lib/esm/entities/index.js +19 -3
- package/lib/esm/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +40 -15
- package/lib/esm/entities/{reallocationData.js → vaultV1ReallocationData.js} +32 -14
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +1 -1
- package/lib/esm/entities/vaultV2/vaultV2.js +1 -1
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +511 -0
- package/lib/esm/entities/vaultV2BlueReallocationData.js +1296 -0
- package/lib/esm/errors.d.ts +48 -3
- package/lib/esm/errors.js +48 -3
- package/lib/esm/fetch.d.ts +16 -1
- package/lib/esm/fetch.js +16 -1
- 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 +2 -2
- package/lib/esm/helpers/index.js +2 -2
- package/lib/esm/helpers/validate.d.ts +32 -16
- package/lib/esm/helpers/validate.js +143 -32
- package/lib/esm/midnight/abis.d.ts +1 -0
- package/lib/esm/midnight/abis.js +1 -0
- package/lib/esm/midnight/constants.d.ts +1 -0
- package/lib/esm/midnight/constants.js +1 -0
- package/lib/esm/midnight/entities.d.ts +2 -0
- package/lib/esm/midnight/entities.js +1 -0
- package/lib/esm/midnight/errors.d.ts +1 -0
- package/lib/esm/midnight/errors.js +1 -0
- package/lib/esm/midnight/fetch.d.ts +1 -0
- package/lib/esm/midnight/fetch.js +1 -0
- package/lib/esm/midnight/types.d.ts +1 -0
- package/lib/esm/midnight/types.js +1 -0
- package/lib/esm/midnight/utils.d.ts +1 -0
- package/lib/esm/midnight/utils.js +1 -0
- package/lib/esm/types/action.d.ts +12 -0
- package/lib/esm/types/error.d.ts +224 -5
- package/lib/esm/types/error.js +253 -4
- package/lib/esm/types/sharedLiquidity.d.ts +72 -8
- package/lib/esm/types.d.ts +17 -2
- package/lib/esm/utils.d.ts +31 -4
- package/lib/esm/utils.js +31 -4
- package/package.json +23 -7
|
@@ -3,7 +3,7 @@ import { BundlerAction } from "../../bundler/index.js";
|
|
|
3
3
|
import { addTransactionMetadata } from "../../helpers/index.js";
|
|
4
4
|
import { MutuallyExclusiveWithdrawAmountsError, NegativeInputError, NonPositiveInputError, } from "../../types/index.js";
|
|
5
5
|
import { getBlueAuthorizationAction } from "../signatures/getBlueAuthorizationAction.js";
|
|
6
|
-
import {
|
|
6
|
+
import { buildBlueReallocationActions } from "./buildReallocationActions.js";
|
|
7
7
|
/**
|
|
8
8
|
* Prepares a loan-asset withdraw transaction for a Morpho Blue market.
|
|
9
9
|
*
|
|
@@ -13,10 +13,11 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
13
13
|
* - **By shares** (`assets = 0, shares > 0`): burns an exact share count (typical for a full
|
|
14
14
|
* supplier position close; immune to interest accrual between tx construction and execution).
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* A `reallocations` plan contains either V1 entries or V2 market/idle entries,
|
|
17
|
+
* never both. The calls run before the withdraw. V1
|
|
18
|
+
* fees accumulate in `tx.value`; V2 penalties are paid in the target loan
|
|
19
|
+
* token and donated to the vaults. The on-chain `morphoWithdraw` sends the
|
|
20
|
+
* assets computed on-chain directly to `receiver`; no skim is required.
|
|
20
21
|
*
|
|
21
22
|
* The withdraw is performed on behalf of the transaction initiator (signer) — there is no
|
|
22
23
|
* separate `onBehalf` field; mirror `blueBorrow`. The entity layer keeps `receiver` aligned
|
|
@@ -30,17 +31,23 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
30
31
|
* @param params.args.receiver - Address that receives the withdrawn assets.
|
|
31
32
|
* @param params.args.minSharePrice - Minimum acceptable withdraw share price (in ray). Slippage
|
|
32
33
|
* protection.
|
|
33
|
-
* @param params.args.reallocations - Optional
|
|
34
|
-
*
|
|
34
|
+
* @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
|
|
35
|
+
* execute before withdrawing.
|
|
35
36
|
* @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
|
|
36
37
|
* a `setAuthorizationWithSig` call is prepended to the bundle.
|
|
37
38
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
38
39
|
* @returns A deep-frozen `Transaction<BlueWithdrawAction>` with `to`, `value`, `data`, and
|
|
39
40
|
* the typed `action` discriminator the simulation layer consumes.
|
|
40
|
-
* @throws {NegativeInputError} when `assets`, `shares`, `minSharePrice`, or
|
|
41
|
-
* is negative.
|
|
41
|
+
* @throws {NegativeInputError} when `assets`, `shares`, `minSharePrice`, a V1 fee, or a V2
|
|
42
|
+
* penalty is negative.
|
|
42
43
|
* @throws {NonPositiveInputError} when both `assets` and `shares` are zero or any reallocation
|
|
43
44
|
* withdrawal amount is non-positive.
|
|
45
|
+
* @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
|
|
46
|
+
* @throws {InconsistentReallocationPenaltyError} when V2 entries for one vault use different penalties.
|
|
47
|
+
* @throws {InvalidReallocationAddressError} when a V2 vault or adapter address is malformed.
|
|
48
|
+
* @throws {InvalidReallocationSourceTypeError} when a V2 source is absent, incomplete, or has an unknown discriminator.
|
|
49
|
+
* @throws {InvalidReallocationShapeError} when an entry matches both or neither V1/V2 shape.
|
|
50
|
+
* @throws {MixedReallocationVersionsError} when one plan contains both V1 and V2 entries.
|
|
44
51
|
* @throws {MutuallyExclusiveWithdrawAmountsError} when both `assets` and `shares` are non-zero.
|
|
45
52
|
* @throws {EmptyReallocationWithdrawalsError} when any reallocation has no withdrawals.
|
|
46
53
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a reallocation withdrawal references
|
|
@@ -83,23 +90,20 @@ export const blueWithdraw = ({ market: { chainId, marketParams }, args: { assets
|
|
|
83
90
|
throw new NegativeInputError("minSharePrice", minSharePrice);
|
|
84
91
|
}
|
|
85
92
|
const actions = [];
|
|
86
|
-
let reallocationFee = 0n;
|
|
87
93
|
if (authorizationSignature) {
|
|
88
94
|
actions.push(getBlueAuthorizationAction(chainId, authorizationSignature));
|
|
89
95
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
96
|
+
const { actions: reallocationActions, fee: reallocationFee, penaltyAssets: reallocationPenaltyAssets, } = buildBlueReallocationActions({
|
|
97
|
+
chainId,
|
|
98
|
+
reallocations,
|
|
99
|
+
targetMarketParams: marketParams,
|
|
100
|
+
});
|
|
101
|
+
actions.push(...reallocationActions);
|
|
95
102
|
actions.push({
|
|
96
103
|
type: "morphoWithdraw",
|
|
97
104
|
args: [marketParams, assets, shares, minSharePrice, receiver, false],
|
|
98
105
|
});
|
|
99
|
-
let tx =
|
|
100
|
-
...BundlerAction.encodeBundle(chainId, actions),
|
|
101
|
-
value: reallocationFee,
|
|
102
|
-
};
|
|
106
|
+
let tx = BundlerAction.encodeBundle(chainId, actions);
|
|
103
107
|
if (metadata) {
|
|
104
108
|
tx = addTransactionMetadata(tx, metadata);
|
|
105
109
|
}
|
|
@@ -114,6 +118,7 @@ export const blueWithdraw = ({ market: { chainId, marketParams }, args: { assets
|
|
|
114
118
|
receiver,
|
|
115
119
|
minSharePrice,
|
|
116
120
|
reallocationFee,
|
|
121
|
+
reallocationPenaltyAssets,
|
|
117
122
|
},
|
|
118
123
|
},
|
|
119
124
|
});
|
|
@@ -33,10 +33,10 @@ export interface MempoolSubmitOffersParams {
|
|
|
33
33
|
* @throws {InvalidTreeError} when `offers <= 0`.
|
|
34
34
|
* @example
|
|
35
35
|
* ```ts
|
|
36
|
-
* import {
|
|
36
|
+
* import { MidnightPayload } from "@morpho-org/morpho-sdk/utils";
|
|
37
37
|
* import { mempoolSubmitOffers } from "@morpho-org/morpho-sdk";
|
|
38
38
|
*
|
|
39
|
-
* const payload = await
|
|
39
|
+
* const payload = await MidnightPayload.encode(items);
|
|
40
40
|
* const tx = mempoolSubmitOffers({
|
|
41
41
|
* chainId: 8453,
|
|
42
42
|
* groups,
|
|
@@ -22,10 +22,10 @@ import { addTransactionMetadata } from "../../helpers/index.js";
|
|
|
22
22
|
* @throws {InvalidTreeError} when `offers <= 0`.
|
|
23
23
|
* @example
|
|
24
24
|
* ```ts
|
|
25
|
-
* import {
|
|
25
|
+
* import { MidnightPayload } from "@morpho-org/morpho-sdk/utils";
|
|
26
26
|
* import { mempoolSubmitOffers } from "@morpho-org/morpho-sdk";
|
|
27
27
|
*
|
|
28
|
-
* const payload = await
|
|
28
|
+
* const payload = await MidnightPayload.encode(items);
|
|
29
29
|
* const tx = mempoolSubmitOffers({
|
|
30
30
|
* chainId: 8453,
|
|
31
31
|
* groups,
|
package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ interface GeneralAdapterPermit2Erc20Allowances {
|
|
|
28
28
|
* bookkeeping invariants break (should not happen with the values this function passes).
|
|
29
29
|
* @example
|
|
30
30
|
* ```ts
|
|
31
|
-
* import { getChainAddresses } from "@morpho-org/
|
|
31
|
+
* import { getChainAddresses } from "@morpho-org/morpho-sdk/addresses";
|
|
32
32
|
* import { getGeneralAdapterRequirementsPermit2 } from "@morpho-org/morpho-sdk";
|
|
33
33
|
*
|
|
34
34
|
* const { permit2 } = getChainAddresses(1);
|
|
@@ -26,7 +26,7 @@ import { getRequirementsApproval } from "../getRequirementsApproval.js";
|
|
|
26
26
|
* bookkeeping invariants break (should not happen with the values this function passes).
|
|
27
27
|
* @example
|
|
28
28
|
* ```ts
|
|
29
|
-
* import { getChainAddresses } from "@morpho-org/
|
|
29
|
+
* import { getChainAddresses } from "@morpho-org/morpho-sdk/addresses";
|
|
30
30
|
* import { getGeneralAdapterRequirementsPermit2 } from "@morpho-org/morpho-sdk";
|
|
31
31
|
*
|
|
32
32
|
* const { permit2 } = getChainAddresses(1);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isAddressEqual } from "viem";
|
|
1
2
|
import { APPROVE_ONLY_ONCE_TOKENS } from "../../helpers/constant.js";
|
|
2
3
|
import { ApprovalAmountLessThanSpendAmountError, } from "../../types/index.js";
|
|
3
4
|
import { encodeErc20Approval } from "./encode/encodeErc20Approval.js";
|
|
@@ -47,7 +48,7 @@ export const getRequirementsApproval = (params) => {
|
|
|
47
48
|
}
|
|
48
49
|
const approvals = [];
|
|
49
50
|
if (allowances < spendAmount) {
|
|
50
|
-
if (APPROVE_ONLY_ONCE_TOKENS[chainId]?.
|
|
51
|
+
if (APPROVE_ONLY_ONCE_TOKENS[chainId]?.some((token) => isAddressEqual(token, address)) &&
|
|
51
52
|
allowances > 0n) {
|
|
52
53
|
approvals.push(encodeErc20Approval({
|
|
53
54
|
token: address,
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { marketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
+
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi, preLiquidationFactoryAbi, publicAllocatorAbi, vaultV1AdapterAbi, vaultV1AdapterFactoryAbi, vaultV1PublicAllocatorAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { marketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
+
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi, preLiquidationFactoryAbi, publicAllocatorAbi, vaultV1AdapterAbi, vaultV1AdapterFactoryAbi, vaultV1PublicAllocatorAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { AddressLabel, AddressRegistry, ChainAddresses, ChainDeployments, DeploymentRegistry, } from "@morpho-org/blue-sdk";
|
|
2
|
+
export { addresses, addressesRegistry, convexWrapperTokens, deployments, erc20WrapperTokens, getChainAddress, getChainAddresses, getPermissionedCoinbaseTokens, getUnwrappedToken, NATIVE_ADDRESS, permissionedBackedTokens, permissionedCoinbaseTokens, permissionedWrapperTokens, registerCustomAddresses, unwrappedTokensMapping, } from "@morpho-org/blue-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { addresses, addressesRegistry, convexWrapperTokens, deployments, erc20WrapperTokens, getChainAddress, getChainAddresses, getPermissionedCoinbaseTokens, getUnwrappedToken, NATIVE_ADDRESS, permissionedBackedTokens, permissionedCoinbaseTokens, permissionedWrapperTokens, registerCustomAddresses, unwrappedTokensMapping, } from "@morpho-org/blue-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId, LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType, } from "@morpho-org/blue-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId, LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType, } from "@morpho-org/blue-sdk";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition, IPreLiquidationParams, IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultMarketPublicAllocatorConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, VaultPublicAllocatorConfig, } from "@morpho-org/blue-sdk";
|
|
2
|
+
export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position, PreLiquidationParams, PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position, PreLiquidationParams, PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
2
|
+
export { getUnsupportedVaultV2Adapter, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
2
|
+
export { getUnsupportedVaultV2Adapter, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition, fetchPreLiquidationParams, fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition, fetchPreLiquidationParams, fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { BigIntish, CollateralAllocation, Eip712Field, Erc20AllowanceRecipient, Failable, Fetchable, InputMarketParams, IPermit2Allowance, Loadable, MarketId, MaxBorrowOptions, MaxPositionCapacities, MaxWithdrawCollateralOptions, Pending, Permit2Allowance, } from "@morpho-org/blue-sdk";
|
|
2
|
+
export type { AuthorizationArgs, DaiPermitArgs, DeploylessFetchParameters, FetchParameters, InputAllocation, MetaMorphoCall, Permit2PermitArgs, Permit2TransferFromArgs, PermitArgs, } from "@morpho-org/blue-sdk-viem";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { CapacityLimit, RoundingDirection } from "@morpho-org/blue-sdk";
|
|
2
|
+
export { AdaptiveCurveIrmLib, CapacityLimitReason, defaultPreLiquidationParamsRegistry, getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
3
|
+
export { decodeBytes32String, getAuthorizationTypedData, getDaiPermitTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { AdaptiveCurveIrmLib, CapacityLimitReason, defaultPreLiquidationParamsRegistry, getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
2
|
+
export { decodeBytes32String, getAuthorizationTypedData, getDaiPermitTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
|
@@ -50,7 +50,7 @@ export declare namespace BundlerAction {
|
|
|
50
50
|
*
|
|
51
51
|
* @example
|
|
52
52
|
* ```ts
|
|
53
|
-
* import { getChainAddresses } from "@morpho-org/
|
|
53
|
+
* import { getChainAddresses } from "@morpho-org/morpho-sdk/addresses";
|
|
54
54
|
* import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
|
|
55
55
|
*
|
|
56
56
|
* const { generalAdapter1 } = getChainAddresses(1).bundler3;
|
|
@@ -137,7 +137,7 @@ export declare namespace BundlerAction {
|
|
|
137
137
|
*
|
|
138
138
|
* @example
|
|
139
139
|
* ```ts
|
|
140
|
-
* import { getChainAddresses } from "@morpho-org/
|
|
140
|
+
* import { getChainAddresses } from "@morpho-org/morpho-sdk/addresses";
|
|
141
141
|
* import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
|
|
142
142
|
*
|
|
143
143
|
* const adapter = getChainAddresses(1).bundler3.generalAdapter1;
|
|
@@ -351,7 +351,7 @@ export declare namespace BundlerAction {
|
|
|
351
351
|
*
|
|
352
352
|
* @example
|
|
353
353
|
* ```ts
|
|
354
|
-
* import { getChainAddresses } from "@morpho-org/
|
|
354
|
+
* import { getChainAddresses } from "@morpho-org/morpho-sdk/addresses";
|
|
355
355
|
* import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
|
|
356
356
|
*
|
|
357
357
|
* const { generalAdapter1 } = getChainAddresses(1).bundler3;
|
|
@@ -650,6 +650,125 @@ export declare namespace BundlerAction {
|
|
|
650
650
|
* ```
|
|
651
651
|
*/
|
|
652
652
|
function publicAllocatorReallocateTo(chainId: number, vault: Address, fee: bigint, withdrawals: InputReallocation[], supplyMarketParams: InputMarketParams, skipRevert?: boolean): BundlerCall[];
|
|
653
|
+
/**
|
|
654
|
+
* Encodes a Vault V2 Blue Public Allocator market-to-market reallocation.
|
|
655
|
+
*
|
|
656
|
+
* @remarks Bundler3 must already hold the computed penalty assets. The
|
|
657
|
+
* high-level Blue builders add the corresponding GeneralAdapter1 transfer.
|
|
658
|
+
*
|
|
659
|
+
* @param chainId - Chain whose canonical Blue Public Allocator is called.
|
|
660
|
+
* @param vault - Vault whose liquidity is reallocated.
|
|
661
|
+
* @param deallocateAdapter - Vault V2 adapter supplying the source market.
|
|
662
|
+
* @param deallocateMarket - Source Morpho Blue market parameters.
|
|
663
|
+
* @param allocateAdapter - Vault V2 adapter supplying the target market.
|
|
664
|
+
* @param allocateMarket - Target Morpho Blue market parameters.
|
|
665
|
+
* @param assets - Assets to reallocate, bounded by `uint128` by the high-level action.
|
|
666
|
+
* @param penalty - Vault-configured proportional penalty, scaled by WAD.
|
|
667
|
+
* @param skipRevert - Whether Bundler3 should tolerate a revert.
|
|
668
|
+
* @returns A zero reset and exact approval when needed, then the allocator call.
|
|
669
|
+
* @throws {BundlerErrors.UnexpectedAction} when the chain has no Blue Public Allocator deployment.
|
|
670
|
+
* @throws {BundlerErrors.SkippableAllocatorPenalty} when `skipRevert` is true and a token approval is required.
|
|
671
|
+
* @example
|
|
672
|
+
* ```ts
|
|
673
|
+
* import { ChainId } from "@morpho-org/morpho-sdk/constants";
|
|
674
|
+
* import type { BlueInputMarketParams } from "@morpho-org/morpho-sdk/types";
|
|
675
|
+
* import {
|
|
676
|
+
* BundlerAction,
|
|
677
|
+
* type BundlerCall,
|
|
678
|
+
* } from "@morpho-org/morpho-sdk/bundler";
|
|
679
|
+
* import type { Address } from "viem";
|
|
680
|
+
*
|
|
681
|
+
* const keyrockUsdcVault =
|
|
682
|
+
* "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145" satisfies Address;
|
|
683
|
+
* const sourceAdapterFixture =
|
|
684
|
+
* "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" satisfies Address;
|
|
685
|
+
* const targetAdapterFixture =
|
|
686
|
+
* "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" satisfies Address;
|
|
687
|
+
* const usdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" satisfies Address;
|
|
688
|
+
* const weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" satisfies Address;
|
|
689
|
+
* const wbtc = "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599" satisfies Address;
|
|
690
|
+
* const ethUsdOracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" satisfies Address;
|
|
691
|
+
* const adaptiveCurveIrm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC" satisfies Address;
|
|
692
|
+
* const sourceMarket = {
|
|
693
|
+
* loanToken: usdc,
|
|
694
|
+
* collateralToken: weth,
|
|
695
|
+
* oracle: ethUsdOracle,
|
|
696
|
+
* irm: adaptiveCurveIrm,
|
|
697
|
+
* lltv: 860_000_000_000_000_000n,
|
|
698
|
+
* } satisfies BlueInputMarketParams;
|
|
699
|
+
* const targetMarket = {
|
|
700
|
+
* ...sourceMarket,
|
|
701
|
+
* collateralToken: wbtc,
|
|
702
|
+
* } satisfies BlueInputMarketParams;
|
|
703
|
+
*
|
|
704
|
+
* const calls: BundlerCall[] = BundlerAction.vaultV2BluePublicAllocatorReallocate(
|
|
705
|
+
* ChainId.EthMainnet,
|
|
706
|
+
* keyrockUsdcVault,
|
|
707
|
+
* sourceAdapterFixture,
|
|
708
|
+
* sourceMarket,
|
|
709
|
+
* targetAdapterFixture,
|
|
710
|
+
* targetMarket,
|
|
711
|
+
* 1_000_000n,
|
|
712
|
+
* 1_000_000_000_000_000n,
|
|
713
|
+
* );
|
|
714
|
+
* // Bundler3 resets and approves 1_000 USDC units, then calls `reallocate` with zero native value.
|
|
715
|
+
* ```
|
|
716
|
+
*/
|
|
717
|
+
function vaultV2BluePublicAllocatorReallocate(chainId: number, vault: Address, deallocateAdapter: Address, deallocateMarket: InputMarketParams, allocateAdapter: Address, allocateMarket: InputMarketParams, assets: bigint, penalty: bigint, skipRevert?: boolean): BundlerCall[];
|
|
718
|
+
/**
|
|
719
|
+
* Encodes a Vault V2 Blue Public Allocator allocation from vault idle liquidity.
|
|
720
|
+
*
|
|
721
|
+
* @remarks Bundler3 must already hold the computed penalty assets. The
|
|
722
|
+
* high-level Blue builders add the corresponding GeneralAdapter1 transfer.
|
|
723
|
+
*
|
|
724
|
+
* @param chainId - Chain whose canonical Blue Public Allocator is called.
|
|
725
|
+
* @param vault - Vault whose idle liquidity is allocated.
|
|
726
|
+
* @param adapter - Vault V2 adapter supplying the target market.
|
|
727
|
+
* @param market - Target Morpho Blue market parameters.
|
|
728
|
+
* @param assets - Assets to allocate, bounded by `uint128` by the high-level action.
|
|
729
|
+
* @param penalty - Vault-configured proportional penalty, scaled by WAD.
|
|
730
|
+
* @param skipRevert - Whether Bundler3 should tolerate a revert.
|
|
731
|
+
* @returns A zero reset and exact approval when needed, then the allocator call.
|
|
732
|
+
* @throws {BundlerErrors.UnexpectedAction} when the chain has no Blue Public Allocator deployment.
|
|
733
|
+
* @throws {BundlerErrors.SkippableAllocatorPenalty} when `skipRevert` is true and a token approval is required.
|
|
734
|
+
* @example
|
|
735
|
+
* ```ts
|
|
736
|
+
* import { ChainId } from "@morpho-org/morpho-sdk/constants";
|
|
737
|
+
* import type { BlueInputMarketParams } from "@morpho-org/morpho-sdk/types";
|
|
738
|
+
* import {
|
|
739
|
+
* BundlerAction,
|
|
740
|
+
* type BundlerCall,
|
|
741
|
+
* } from "@morpho-org/morpho-sdk/bundler";
|
|
742
|
+
* import type { Address } from "viem";
|
|
743
|
+
*
|
|
744
|
+
* const keyrockUsdcVault =
|
|
745
|
+
* "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145" satisfies Address;
|
|
746
|
+
* const targetAdapterFixture =
|
|
747
|
+
* "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" satisfies Address;
|
|
748
|
+
* const usdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" satisfies Address;
|
|
749
|
+
* const weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" satisfies Address;
|
|
750
|
+
* const ethUsdOracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" satisfies Address;
|
|
751
|
+
* const adaptiveCurveIrm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC" satisfies Address;
|
|
752
|
+
* const targetMarket = {
|
|
753
|
+
* loanToken: usdc,
|
|
754
|
+
* collateralToken: weth,
|
|
755
|
+
* oracle: ethUsdOracle,
|
|
756
|
+
* irm: adaptiveCurveIrm,
|
|
757
|
+
* lltv: 860_000_000_000_000_000n,
|
|
758
|
+
* } satisfies BlueInputMarketParams;
|
|
759
|
+
*
|
|
760
|
+
* const calls: BundlerCall[] = BundlerAction.vaultV2BluePublicAllocatorAllocateFromIdle(
|
|
761
|
+
* ChainId.EthMainnet,
|
|
762
|
+
* keyrockUsdcVault,
|
|
763
|
+
* targetAdapterFixture,
|
|
764
|
+
* targetMarket,
|
|
765
|
+
* 1_000_000n,
|
|
766
|
+
* 1_000_000_000_000_000n,
|
|
767
|
+
* );
|
|
768
|
+
* // Bundler3 resets and approves 1_000 USDC units, then calls `allocateFromIdle` with zero native value.
|
|
769
|
+
* ```
|
|
770
|
+
*/
|
|
771
|
+
function vaultV2BluePublicAllocatorAllocateFromIdle(chainId: number, vault: Address, adapter: Address, market: InputMarketParams, assets: bigint, penalty: bigint, skipRevert?: boolean): BundlerCall[];
|
|
653
772
|
/**
|
|
654
773
|
* Encodes a GeneralAdapter1 native-token wrap call.
|
|
655
774
|
*
|