@morpho-org/morpho-sdk 6.0.0-next.1 → 6.0.0-next.3
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/MIGRATION-v5-to-v6.md +199 -34
- package/README.md +23 -15
- package/lib/cjs/abis.d.ts +3 -2829
- package/lib/cjs/abis.js +1 -1938
- package/lib/cjs/actions/blue/borrow.d.ts +3 -2
- package/lib/cjs/actions/blue/borrow.js +3 -2
- package/lib/cjs/actions/blue/common.js +6 -35
- package/lib/cjs/actions/blue/refinance.d.ts +2 -2
- package/lib/cjs/actions/blue/refinance.js +2 -2
- package/lib/cjs/actions/blue/repay.d.ts +1 -1
- package/lib/cjs/actions/blue/repay.js +1 -1
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +2 -2
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -2
- package/lib/cjs/actions/blue/supply.d.ts +2 -2
- package/lib/cjs/actions/blue/supply.js +4 -9
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +2 -2
- package/lib/cjs/actions/blue/supplyCollateral.js +2 -2
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -2
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +3 -2
- package/lib/cjs/actions/blue/withdraw.d.ts +3 -3
- package/lib/cjs/actions/blue/withdraw.js +3 -3
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +2 -2
- package/lib/cjs/actions/blue/withdrawCollateral.js +2 -2
- package/lib/cjs/actions/bundles/common.d.ts +38 -4
- package/lib/cjs/actions/bundles/common.js +91 -35
- package/lib/cjs/actions/index.d.ts +0 -1
- package/lib/cjs/actions/index.js +0 -1
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +9 -8
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +17 -26
- package/lib/cjs/actions/requirements/blue/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/blue/index.js +0 -1
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +20 -14
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +24 -25
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +4 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +21 -12
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +39 -38
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +4 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +14 -9
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +9 -6
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +22 -17
- package/lib/cjs/actions/requirements/encode/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/encode/index.js +0 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +5 -6
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -6
- package/lib/cjs/actions/requirements/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/index.js +0 -1
- package/lib/cjs/actions/vaultV1/deposit.d.ts +1 -2
- package/lib/cjs/actions/vaultV1/deposit.js +1 -2
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +6 -4
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +12 -8
- package/lib/cjs/actions/vaultV2/deposit.d.ts +1 -2
- package/lib/cjs/actions/vaultV2/deposit.js +1 -2
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +58 -39
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +87 -60
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +6 -4
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +12 -8
- package/lib/cjs/augment.d.ts +0 -1
- package/lib/cjs/augment.js +0 -1
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +1 -5
- package/lib/cjs/blue/entities.d.ts +2 -2
- package/lib/cjs/blue/entities.js +1 -2
- package/lib/cjs/blue/errors.d.ts +1 -1
- package/lib/cjs/blue/errors.js +2 -1
- package/lib/cjs/blue/fetch.d.ts +1 -1
- package/lib/cjs/blue/fetch.js +1 -2
- package/lib/cjs/blue/types.d.ts +2 -4
- package/lib/cjs/blue/utils.d.ts +1 -3
- package/lib/cjs/blue/utils.js +1 -3
- package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
- package/lib/cjs/client/morphoViemExtension.js +1 -1
- package/lib/cjs/constants.d.ts +3 -37
- package/lib/cjs/constants.js +1 -39
- package/lib/cjs/entities/blue/blue.d.ts +38 -264
- package/lib/cjs/entities/blue/blue.js +2 -203
- package/lib/cjs/entities/index.d.ts +3 -60
- package/lib/cjs/entities/index.js +1 -20
- package/lib/cjs/entities/midnight/midnight.js +20 -24
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +7 -6
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +19 -14
- package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +3 -3
- package/lib/cjs/entities/requirements/index.d.ts +1 -0
- package/lib/cjs/entities/requirements/index.js +1 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +18 -6
- package/lib/cjs/entities/vaultV1/vaultV1.js +25 -8
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +154 -35
- package/lib/cjs/entities/vaultV2/vaultV2.js +249 -23
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +8 -1
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +50 -34
- package/lib/cjs/errors.d.ts +2 -46
- package/lib/cjs/errors.js +2 -46
- package/lib/cjs/fetch.d.ts +1 -15
- package/lib/cjs/fetch.js +1 -16
- package/lib/cjs/helpers/constant.d.ts +0 -2
- package/lib/cjs/helpers/constant.js +0 -2
- package/lib/cjs/helpers/index.d.ts +4 -3
- package/lib/cjs/helpers/index.js +10 -9
- package/lib/cjs/helpers/metadata.d.ts +3 -5
- package/lib/cjs/helpers/metadata.js +4 -6
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +164 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +2 -0
- package/lib/cjs/helpers/slippage.d.ts +34 -90
- package/lib/cjs/helpers/slippage.js +52 -137
- package/lib/cjs/helpers/utilization.d.ts +12 -10
- package/lib/cjs/helpers/utilization.js +27 -12
- package/lib/cjs/helpers/validate.d.ts +66 -32
- package/lib/cjs/helpers/validate.js +84 -57
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +1 -3
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +369 -0
- package/lib/cjs/types/action.d.ts +102 -68
- package/lib/cjs/types/action.js +11 -4
- package/lib/cjs/types/error.d.ts +332 -385
- package/lib/cjs/types/error.js +369 -412
- package/lib/cjs/types/sharedLiquidity.d.ts +1 -117
- package/lib/cjs/types.d.ts +2 -18
- package/lib/cjs/utils.d.ts +8 -35
- package/lib/cjs/utils.js +11 -36
- package/lib/esm/abis.d.ts +3 -2829
- package/lib/esm/abis.js +3 -1935
- package/lib/esm/actions/blue/borrow.d.ts +3 -2
- package/lib/esm/actions/blue/borrow.js +3 -2
- package/lib/esm/actions/blue/common.js +8 -37
- package/lib/esm/actions/blue/refinance.d.ts +2 -2
- package/lib/esm/actions/blue/refinance.js +2 -2
- package/lib/esm/actions/blue/repay.d.ts +1 -1
- package/lib/esm/actions/blue/repay.js +1 -1
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +2 -2
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +2 -2
- package/lib/esm/actions/blue/supply.d.ts +2 -2
- package/lib/esm/actions/blue/supply.js +6 -11
- package/lib/esm/actions/blue/supplyCollateral.d.ts +2 -2
- package/lib/esm/actions/blue/supplyCollateral.js +2 -2
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -2
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +3 -2
- package/lib/esm/actions/blue/withdraw.d.ts +3 -3
- package/lib/esm/actions/blue/withdraw.js +3 -3
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +2 -2
- package/lib/esm/actions/blue/withdrawCollateral.js +2 -2
- package/lib/esm/actions/bundles/common.d.ts +38 -4
- package/lib/esm/actions/bundles/common.js +91 -36
- package/lib/esm/actions/index.d.ts +0 -1
- package/lib/esm/actions/index.js +0 -1
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +9 -8
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +20 -29
- package/lib/esm/actions/requirements/blue/index.d.ts +0 -1
- package/lib/esm/actions/requirements/blue/index.js +0 -1
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +20 -14
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +25 -26
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +4 -5
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +21 -12
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +40 -39
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +4 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +14 -9
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +9 -6
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +22 -17
- package/lib/esm/actions/requirements/encode/index.d.ts +0 -1
- package/lib/esm/actions/requirements/encode/index.js +0 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +5 -6
- package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -6
- package/lib/esm/actions/requirements/index.d.ts +0 -1
- package/lib/esm/actions/requirements/index.js +0 -1
- package/lib/esm/actions/vaultV1/deposit.d.ts +1 -2
- package/lib/esm/actions/vaultV1/deposit.js +1 -2
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +6 -4
- package/lib/esm/actions/vaultV1/inKindRedeem.js +12 -8
- package/lib/esm/actions/vaultV2/deposit.d.ts +1 -2
- package/lib/esm/actions/vaultV2/deposit.js +1 -2
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +58 -39
- package/lib/esm/actions/vaultV2/forceWithdraw.js +89 -62
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +6 -4
- package/lib/esm/actions/vaultV2/inKindRedeem.js +12 -8
- package/lib/esm/augment.d.ts +0 -1
- package/lib/esm/augment.js +0 -1
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +2 -2
- package/lib/esm/blue/entities.js +1 -1
- package/lib/esm/blue/errors.d.ts +1 -1
- package/lib/esm/blue/errors.js +1 -1
- package/lib/esm/blue/fetch.d.ts +1 -1
- package/lib/esm/blue/fetch.js +1 -1
- package/lib/esm/blue/types.d.ts +2 -4
- package/lib/esm/blue/utils.d.ts +1 -3
- package/lib/esm/blue/utils.js +1 -3
- package/lib/esm/client/morphoViemExtension.d.ts +1 -1
- package/lib/esm/client/morphoViemExtension.js +1 -1
- package/lib/esm/constants.d.ts +3 -37
- package/lib/esm/constants.js +3 -37
- package/lib/esm/entities/blue/blue.d.ts +38 -264
- package/lib/esm/entities/blue/blue.js +5 -206
- package/lib/esm/entities/index.d.ts +3 -60
- package/lib/esm/entities/index.js +1 -16
- package/lib/esm/entities/midnight/midnight.js +20 -24
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +7 -6
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +20 -15
- package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +3 -3
- package/lib/esm/entities/requirements/index.d.ts +1 -0
- package/lib/esm/entities/requirements/index.js +1 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +18 -6
- package/lib/esm/entities/vaultV1/vaultV1.js +29 -12
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +154 -35
- package/lib/esm/entities/vaultV2/vaultV2.js +256 -30
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +8 -1
- package/lib/esm/entities/vaultV2BlueReallocationData.js +48 -32
- package/lib/esm/errors.d.ts +2 -46
- package/lib/esm/errors.js +2 -46
- package/lib/esm/fetch.d.ts +1 -15
- package/lib/esm/fetch.js +1 -15
- package/lib/esm/helpers/constant.d.ts +0 -2
- package/lib/esm/helpers/constant.js +0 -2
- package/lib/esm/helpers/index.d.ts +4 -3
- package/lib/esm/helpers/index.js +4 -3
- package/lib/esm/helpers/metadata.d.ts +3 -5
- package/lib/esm/helpers/metadata.js +4 -6
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +161 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.js +2 -0
- package/lib/esm/helpers/slippage.d.ts +34 -90
- package/lib/esm/helpers/slippage.js +52 -134
- package/lib/esm/helpers/utilization.d.ts +12 -10
- package/lib/esm/helpers/utilization.js +26 -11
- package/lib/esm/helpers/validate.d.ts +66 -32
- package/lib/esm/helpers/validate.js +83 -57
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +1 -3
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +362 -0
- package/lib/esm/types/action.d.ts +102 -68
- package/lib/esm/types/action.js +12 -5
- package/lib/esm/types/error.d.ts +332 -385
- package/lib/esm/types/error.js +355 -392
- package/lib/esm/types/sharedLiquidity.d.ts +1 -117
- package/lib/esm/types.d.ts +2 -18
- package/lib/esm/utils.d.ts +8 -35
- package/lib/esm/utils.js +7 -34
- package/package.json +7 -15
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -42
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -83
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -151
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -37
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -50
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -74
- package/lib/cjs/actions/requirements/generalAdapter/index.d.ts +0 -3
- package/lib/cjs/actions/requirements/generalAdapter/index.js +0 -19
- package/lib/cjs/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
- package/lib/cjs/actions/signatures/getBlueAuthorizationAction.js +0 -48
- package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +0 -58
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +0 -119
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -44
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -43
- package/lib/cjs/actions/signatures/index.d.ts +0 -3
- package/lib/cjs/actions/signatures/index.js +0 -19
- package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -8
- package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.js +0 -8
- package/lib/cjs/bundler/actions.d.ts +0 -797
- package/lib/cjs/bundler/actions.js +0 -1371
- package/lib/cjs/bundler/index.d.ts +0 -2
- package/lib/cjs/bundler/index.js +0 -18
- package/lib/cjs/bundler/types.d.ts +0 -235
- package/lib/cjs/bundler/types.js +0 -2
- package/lib/cjs/entities/vaultV1ReallocationData.d.ts +0 -326
- package/lib/cjs/entities/vaultV1ReallocationData.js +0 -542
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +0 -78
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +0 -243
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -42
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -79
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -147
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -37
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -46
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -70
- package/lib/esm/actions/requirements/generalAdapter/index.d.ts +0 -3
- package/lib/esm/actions/requirements/generalAdapter/index.js +0 -3
- package/lib/esm/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
- package/lib/esm/actions/signatures/getBlueAuthorizationAction.js +0 -44
- package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +0 -58
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +0 -115
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -44
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -39
- package/lib/esm/actions/signatures/index.d.ts +0 -3
- package/lib/esm/actions/signatures/index.js +0 -3
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -8
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +0 -5
- package/lib/esm/bundler/actions.d.ts +0 -797
- package/lib/esm/bundler/actions.js +0 -1368
- package/lib/esm/bundler/index.d.ts +0 -2
- package/lib/esm/bundler/index.js +0 -2
- package/lib/esm/bundler/types.d.ts +0 -235
- package/lib/esm/bundler/types.js +0 -1
- package/lib/esm/entities/vaultV1ReallocationData.d.ts +0 -326
- package/lib/esm/entities/vaultV1ReallocationData.js +0 -544
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +0 -78
- package/lib/esm/helpers/computeVaultV1Reallocations.js +0 -239
- /package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.d.ts +0 -0
- /package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.d.ts +0 -0
package/lib/esm/bundler/index.js
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import type { InputMarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import type { Address, Hex } from "viem";
|
|
3
|
-
/**
|
|
4
|
-
* Morpho authorization payload signed by a user for Bundler3-mediated Morpho
|
|
5
|
-
* Blue execution.
|
|
6
|
-
*/
|
|
7
|
-
export interface Authorization {
|
|
8
|
-
/** Address granting or revoking authorization. */
|
|
9
|
-
readonly authorizer: Address;
|
|
10
|
-
/** Address receiving authorization. */
|
|
11
|
-
readonly authorized: Address;
|
|
12
|
-
/** Whether authorization is granted (`true`) or revoked (`false`). */
|
|
13
|
-
readonly isAuthorized: boolean;
|
|
14
|
-
/** Morpho authorization nonce consumed by the signature. */
|
|
15
|
-
readonly nonce: bigint;
|
|
16
|
-
/** Signature deadline timestamp in seconds. */
|
|
17
|
-
readonly deadline: bigint;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Public allocator withdrawal input used by a `reallocateTo` Bundler3 action.
|
|
21
|
-
*
|
|
22
|
-
* @deprecated Vault V1 PublicAllocator composition will be removed in the next major. Use Vault V2
|
|
23
|
-
* BluePublicAllocator actions.
|
|
24
|
-
*/
|
|
25
|
-
export interface InputReallocation {
|
|
26
|
-
/** Market to withdraw liquidity from. */
|
|
27
|
-
readonly marketParams: InputMarketParams;
|
|
28
|
-
/** Amount of loan assets to withdraw from the market. */
|
|
29
|
-
readonly amount: bigint;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Permit2 single-permit token allowance details.
|
|
33
|
-
*/
|
|
34
|
-
export interface Permit2PermitSingleDetails {
|
|
35
|
-
/** ERC20 token approved through Permit2. */
|
|
36
|
-
readonly token: Address;
|
|
37
|
-
/** Allowance amount approved through Permit2. */
|
|
38
|
-
readonly amount: bigint;
|
|
39
|
-
/** Permit2 allowance expiration timestamp in seconds. */
|
|
40
|
-
readonly expiration: number;
|
|
41
|
-
/** Permit2 nonce consumed by the signature. */
|
|
42
|
-
readonly nonce: number;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Permit2 single-permit payload signed by the token owner.
|
|
46
|
-
*/
|
|
47
|
-
export interface Permit2PermitSingle {
|
|
48
|
-
/** Token, amount, expiration, and nonce being approved. */
|
|
49
|
-
readonly details: Permit2PermitSingleDetails;
|
|
50
|
-
/** Deadline timestamp for consuming the Permit2 signature. */
|
|
51
|
-
readonly sigDeadline: bigint;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Argument tuples for Bundler3 actions supported by `morpho-sdk`.
|
|
55
|
-
*/
|
|
56
|
-
export interface ActionArgs {
|
|
57
|
-
/** Native-token transfer from `owner` to `recipient` for `amount`; `skipRevert` controls Bundler3 revert handling. */
|
|
58
|
-
readonly nativeTransfer: [
|
|
59
|
-
owner: Address,
|
|
60
|
-
recipient: Address,
|
|
61
|
-
amount: bigint,
|
|
62
|
-
skipRevert?: boolean
|
|
63
|
-
];
|
|
64
|
-
/** ERC20 transfer from `adapter` to `recipient` for `amount` of `asset`; `skipRevert` controls Bundler3 revert handling. */
|
|
65
|
-
readonly erc20Transfer: [
|
|
66
|
-
asset: Address,
|
|
67
|
-
recipient: Address,
|
|
68
|
-
amount: bigint,
|
|
69
|
-
adapter: Address,
|
|
70
|
-
skipRevert?: boolean
|
|
71
|
-
];
|
|
72
|
-
/** GeneralAdapter1 ERC20 `transferFrom` of `asset` and `amount` to `recipient`; `skipRevert` controls Bundler3 revert handling. */
|
|
73
|
-
readonly erc20TransferFrom: [
|
|
74
|
-
asset: Address,
|
|
75
|
-
amount: bigint,
|
|
76
|
-
recipient: Address,
|
|
77
|
-
skipRevert?: boolean
|
|
78
|
-
];
|
|
79
|
-
/** ERC-2612 permit from `owner` for `asset`, `amount`, `deadline`, and `signature`; `skipRevert` controls Bundler3 revert handling. */
|
|
80
|
-
readonly permit: [
|
|
81
|
-
owner: Address,
|
|
82
|
-
asset: Address,
|
|
83
|
-
amount: bigint,
|
|
84
|
-
deadline: bigint,
|
|
85
|
-
signature: Hex | null,
|
|
86
|
-
skipRevert?: boolean
|
|
87
|
-
];
|
|
88
|
-
/** Permit2 approval from `owner` for `permitSingle` and `signature`; `skipRevert` controls Bundler3 revert handling. */
|
|
89
|
-
readonly approve2: [
|
|
90
|
-
owner: Address,
|
|
91
|
-
permitSingle: Permit2PermitSingle,
|
|
92
|
-
signature: Hex | null,
|
|
93
|
-
skipRevert?: boolean
|
|
94
|
-
];
|
|
95
|
-
/** GeneralAdapter1 Permit2 transfer of `asset` and `amount` to `recipient`; `skipRevert` controls Bundler3 revert handling. */
|
|
96
|
-
readonly transferFrom2: [
|
|
97
|
-
asset: Address,
|
|
98
|
-
amount: bigint,
|
|
99
|
-
recipient: Address,
|
|
100
|
-
skipRevert?: boolean
|
|
101
|
-
];
|
|
102
|
-
/** ERC4626 deposit into `erc4626` for `assets`, `maxSharePrice`, and `receiver`; `skipRevert` controls Bundler3 revert handling. */
|
|
103
|
-
readonly erc4626Deposit: [
|
|
104
|
-
erc4626: Address,
|
|
105
|
-
assets: bigint,
|
|
106
|
-
maxSharePrice: bigint,
|
|
107
|
-
receiver: Address,
|
|
108
|
-
skipRevert?: boolean
|
|
109
|
-
];
|
|
110
|
-
/** ERC4626 redeem from `erc4626` for `shares`, `minSharePrice`, `receiver`, and `owner`; `skipRevert` controls Bundler3 revert handling. */
|
|
111
|
-
readonly erc4626Redeem: [
|
|
112
|
-
erc4626: Address,
|
|
113
|
-
shares: bigint,
|
|
114
|
-
minSharePrice: bigint,
|
|
115
|
-
receiver: Address,
|
|
116
|
-
owner: Address,
|
|
117
|
-
skipRevert?: boolean
|
|
118
|
-
];
|
|
119
|
-
/** Morpho Blue `setAuthorizationWithSig` call submitting a signed `authorization` and its `signature`; `skipRevert` controls Bundler3 revert handling. */
|
|
120
|
-
readonly morphoSetAuthorizationWithSig: [
|
|
121
|
-
authorization: Authorization,
|
|
122
|
-
signature: Hex | null,
|
|
123
|
-
skipRevert?: boolean
|
|
124
|
-
];
|
|
125
|
-
/** Morpho Blue supply-collateral call for `market`, `assets`, `onBehalf`, and callback actions; `skipRevert` controls Bundler3 revert handling. */
|
|
126
|
-
readonly morphoSupplyCollateral: [
|
|
127
|
-
market: InputMarketParams,
|
|
128
|
-
assets: bigint,
|
|
129
|
-
onBehalf: Address,
|
|
130
|
-
onMorphoSupplyCollateral: Action[],
|
|
131
|
-
skipRevert?: boolean
|
|
132
|
-
];
|
|
133
|
-
/** Morpho Blue supply call for `market`, `assets` or `shares`, `slippageAmount`, `onBehalf`, and callback actions; `skipRevert` controls Bundler3 revert handling. */
|
|
134
|
-
readonly morphoSupply: [
|
|
135
|
-
market: InputMarketParams,
|
|
136
|
-
assets: bigint,
|
|
137
|
-
shares: bigint,
|
|
138
|
-
slippageAmount: bigint,
|
|
139
|
-
onBehalf: Address,
|
|
140
|
-
onMorphoSupply: Action[],
|
|
141
|
-
skipRevert?: boolean
|
|
142
|
-
];
|
|
143
|
-
/** Morpho Blue borrow call for `market`, `assets` or `shares`, `minSharePrice`, and `receiver`; `skipRevert` controls Bundler3 revert handling. */
|
|
144
|
-
readonly morphoBorrow: [
|
|
145
|
-
market: InputMarketParams,
|
|
146
|
-
assets: bigint,
|
|
147
|
-
shares: bigint,
|
|
148
|
-
minSharePrice: bigint,
|
|
149
|
-
receiver: Address,
|
|
150
|
-
skipRevert?: boolean
|
|
151
|
-
];
|
|
152
|
-
/** Morpho Blue repay call for `market`, `assets` or `shares`, `maxSharePrice`, `onBehalf`, and callback actions; `skipRevert` controls Bundler3 revert handling. */
|
|
153
|
-
readonly morphoRepay: [
|
|
154
|
-
market: InputMarketParams,
|
|
155
|
-
assets: bigint,
|
|
156
|
-
shares: bigint,
|
|
157
|
-
maxSharePrice: bigint,
|
|
158
|
-
onBehalf: Address,
|
|
159
|
-
onMorphoRepay: Action[],
|
|
160
|
-
skipRevert?: boolean
|
|
161
|
-
];
|
|
162
|
-
/** Morpho Blue withdraw call for `market`, `assets` or `shares`, `slippageAmount`, and `receiver`; `skipRevert` controls Bundler3 revert handling. */
|
|
163
|
-
readonly morphoWithdraw: [
|
|
164
|
-
market: InputMarketParams,
|
|
165
|
-
assets: bigint,
|
|
166
|
-
shares: bigint,
|
|
167
|
-
slippageAmount: bigint,
|
|
168
|
-
receiver: Address,
|
|
169
|
-
skipRevert?: boolean
|
|
170
|
-
];
|
|
171
|
-
/** Morpho Blue withdraw-collateral call for `market`, `assets`, and `receiver`; `skipRevert` controls Bundler3 revert handling. */
|
|
172
|
-
readonly morphoWithdrawCollateral: [
|
|
173
|
-
market: InputMarketParams,
|
|
174
|
-
assets: bigint,
|
|
175
|
-
receiver: Address,
|
|
176
|
-
skipRevert?: boolean
|
|
177
|
-
];
|
|
178
|
-
/**
|
|
179
|
-
* PublicAllocator reallocation to `supplyMarket` from `vault` withdrawals while paying `fee`;
|
|
180
|
-
* `skipRevert` controls Bundler3 revert handling.
|
|
181
|
-
*
|
|
182
|
-
* @deprecated Vault V1 PublicAllocator composition will be removed in the next major. Use Vault V2
|
|
183
|
-
* BluePublicAllocator actions.
|
|
184
|
-
*/
|
|
185
|
-
readonly reallocateTo: [
|
|
186
|
-
vault: Address,
|
|
187
|
-
fee: bigint,
|
|
188
|
-
withdrawals: InputReallocation[],
|
|
189
|
-
supplyMarket: InputMarketParams,
|
|
190
|
-
skipRevert?: boolean
|
|
191
|
-
];
|
|
192
|
-
/** Vault V2 Blue Public Allocator market-to-market reallocation with a WAD-scaled penalty. */
|
|
193
|
-
readonly vaultV2BluePublicAllocatorReallocate: [
|
|
194
|
-
vault: Address,
|
|
195
|
-
deallocateAdapter: Address,
|
|
196
|
-
deallocateMarket: InputMarketParams,
|
|
197
|
-
allocateAdapter: Address,
|
|
198
|
-
allocateMarket: InputMarketParams,
|
|
199
|
-
assets: bigint,
|
|
200
|
-
penalty: bigint,
|
|
201
|
-
skipRevert?: boolean
|
|
202
|
-
];
|
|
203
|
-
/** Vault V2 Blue Public Allocator idle-to-market allocation with a WAD-scaled penalty. */
|
|
204
|
-
readonly vaultV2BluePublicAllocatorAllocateFromIdle: [
|
|
205
|
-
vault: Address,
|
|
206
|
-
adapter: Address,
|
|
207
|
-
market: InputMarketParams,
|
|
208
|
-
assets: bigint,
|
|
209
|
-
penalty: bigint,
|
|
210
|
-
skipRevert?: boolean
|
|
211
|
-
];
|
|
212
|
-
/** GeneralAdapter1 native wrap of `amount` to `recipient`; `skipRevert` controls Bundler3 revert handling. */
|
|
213
|
-
readonly wrapNative: [
|
|
214
|
-
amount: bigint,
|
|
215
|
-
recipient: Address,
|
|
216
|
-
skipRevert?: boolean
|
|
217
|
-
];
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Supported Bundler3 action discriminator.
|
|
221
|
-
*/
|
|
222
|
-
export type ActionType = keyof ActionArgs;
|
|
223
|
-
/**
|
|
224
|
-
* Supported Bundler3 action object map keyed by action discriminator.
|
|
225
|
-
*/
|
|
226
|
-
export type Actions = {
|
|
227
|
-
readonly [T in ActionType]: {
|
|
228
|
-
readonly type: T;
|
|
229
|
-
readonly args: ActionArgs[T];
|
|
230
|
-
};
|
|
231
|
-
};
|
|
232
|
-
/**
|
|
233
|
-
* Discriminated union of Bundler3 actions supported by `morpho-sdk`.
|
|
234
|
-
*/
|
|
235
|
-
export type Action = Actions[ActionType];
|
package/lib/esm/bundler/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
import { AccrualPosition, Market, type MarketId, Position, Vault, VaultMarketConfig } from "@morpho-org/blue-sdk";
|
|
2
|
-
import type { Address } from "viem";
|
|
3
|
-
import type { PublicAllocatorOptions, PublicReallocation, ReallocationComputeOptions } from "../types/index.js";
|
|
4
|
-
/**
|
|
5
|
-
* Input state required to construct {@link VaultV1ReallocationData}.
|
|
6
|
-
*
|
|
7
|
-
* @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
|
|
8
|
-
* `InputVaultV2BlueReallocationData`.
|
|
9
|
-
*/
|
|
10
|
-
export interface InputVaultV1ReallocationData {
|
|
11
|
-
/** Chain id associated with the fetched state. */
|
|
12
|
-
readonly chainId: number;
|
|
13
|
-
/** Markets indexed by market id. */
|
|
14
|
-
readonly markets?: Readonly<Record<MarketId, Market | undefined>>;
|
|
15
|
-
/** Vaults indexed by vault address. */
|
|
16
|
-
readonly vaults?: Readonly<Record<Address, Vault | undefined>>;
|
|
17
|
-
/** Positions indexed by user or vault address, then by market id. */
|
|
18
|
-
readonly positions?: Readonly<Record<Address, Readonly<Record<MarketId, Position | undefined>>>>;
|
|
19
|
-
/** Vault market configs indexed by vault address, then by market id. */
|
|
20
|
-
readonly vaultMarketConfigs?: Readonly<Record<Address, Readonly<Record<MarketId, VaultMarketConfig | undefined>>>>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Deprecated input name for Vault V1 reallocation data.
|
|
24
|
-
*
|
|
25
|
-
* @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
|
|
26
|
-
* `InputVaultV2BlueReallocationData`.
|
|
27
|
-
*/
|
|
28
|
-
export type InputReallocationData = InputVaultV1ReallocationData;
|
|
29
|
-
/**
|
|
30
|
-
* Narrow state container for computing public allocator reallocations.
|
|
31
|
-
*
|
|
32
|
-
* @remarks
|
|
33
|
-
* The class owns only the market, vault, position, vault-market-config,
|
|
34
|
-
* and chain data needed by the shared-liquidity algorithm. Constructor inputs
|
|
35
|
-
* are cloned, and simulation steps return cloned `VaultV1ReallocationData` instances
|
|
36
|
-
* so fetched caller inputs are not mutated.
|
|
37
|
-
*
|
|
38
|
-
* Public records are exposed for inspection and snapshotting only. Treat
|
|
39
|
-
* `markets`, `vaults`, `positions`, and `vaultMarketConfigs` as a read
|
|
40
|
-
* contract keyed by market id or address; use the getters for typed absence
|
|
41
|
-
* errors and use simulation methods to produce updated state.
|
|
42
|
-
*
|
|
43
|
-
* @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
|
|
44
|
-
* `VaultV2BlueReallocationData`.
|
|
45
|
-
*/
|
|
46
|
-
export declare class VaultV1ReallocationData implements InputVaultV1ReallocationData {
|
|
47
|
-
/** Chain id associated with the fetched reallocation data. */
|
|
48
|
-
readonly chainId: number;
|
|
49
|
-
/** Markets indexed by market id. */
|
|
50
|
-
readonly markets: Record<MarketId, Market | undefined>;
|
|
51
|
-
/** Vaults indexed by vault address. */
|
|
52
|
-
readonly vaults: Record<Address, Vault | undefined>;
|
|
53
|
-
/** Positions indexed by user or vault address, then by market id. */
|
|
54
|
-
readonly positions: Record<Address, Record<MarketId, Position | undefined>>;
|
|
55
|
-
/** Vault market configs indexed by vault address, then by market id. */
|
|
56
|
-
readonly vaultMarketConfigs: Record<Address, Record<MarketId, VaultMarketConfig | undefined>>;
|
|
57
|
-
/**
|
|
58
|
-
* Creates a cloned reallocation state from fetched market, vault, position,
|
|
59
|
-
* and vault-market-config data.
|
|
60
|
-
*
|
|
61
|
-
* @param input - Reallocation input data fetched at a consistent chain state.
|
|
62
|
-
*/
|
|
63
|
-
constructor(input: InputVaultV1ReallocationData);
|
|
64
|
-
/**
|
|
65
|
-
* Creates a deep clone of this reallocation state.
|
|
66
|
-
*
|
|
67
|
-
* @returns A new `VaultV1ReallocationData` instance with cloned entity objects.
|
|
68
|
-
*/
|
|
69
|
-
clone(): VaultV1ReallocationData;
|
|
70
|
-
private forkAliasedState;
|
|
71
|
-
/**
|
|
72
|
-
* Gets a market by id.
|
|
73
|
-
*
|
|
74
|
-
* @param marketId - Market id to read.
|
|
75
|
-
* @returns The cloned market data.
|
|
76
|
-
* @throws {@link UnknownReallocationMarketError} when the market is absent.
|
|
77
|
-
*/
|
|
78
|
-
getMarket(marketId: MarketId): Market;
|
|
79
|
-
/**
|
|
80
|
-
* Gets a vault by address.
|
|
81
|
-
*
|
|
82
|
-
* @param vault - Vault address to read.
|
|
83
|
-
* @returns The cloned vault data.
|
|
84
|
-
* @throws {@link UnknownReallocationVaultError} when the vault is absent.
|
|
85
|
-
*/
|
|
86
|
-
getVault(vault: Address): Vault;
|
|
87
|
-
/**
|
|
88
|
-
* Gets a raw market position.
|
|
89
|
-
*
|
|
90
|
-
* @param user - Position owner address, usually a MetaMorpho vault.
|
|
91
|
-
* @param marketId - Market id for the position.
|
|
92
|
-
* @returns The cloned position data.
|
|
93
|
-
* @throws {@link UnknownReallocationPositionError} when the position is absent.
|
|
94
|
-
*/
|
|
95
|
-
getPosition(user: Address, marketId: MarketId): Position;
|
|
96
|
-
/**
|
|
97
|
-
* Gets a position wrapped with its market accrual helpers.
|
|
98
|
-
*
|
|
99
|
-
* @param user - Position owner address, usually a MetaMorpho vault.
|
|
100
|
-
* @param marketId - Market id for the position.
|
|
101
|
-
* @returns Accrual-aware position data.
|
|
102
|
-
* @throws {@link UnknownReallocationPositionError} when the position is absent.
|
|
103
|
-
* @throws {@link UnknownReallocationMarketError} when the market is absent.
|
|
104
|
-
*/
|
|
105
|
-
getAccrualPosition(user: Address, marketId: MarketId): AccrualPosition;
|
|
106
|
-
/**
|
|
107
|
-
* Gets a vault-market config.
|
|
108
|
-
*
|
|
109
|
-
* @param vault - Vault address.
|
|
110
|
-
* @param marketId - Market id configured by the vault.
|
|
111
|
-
* @returns The cloned vault-market config.
|
|
112
|
-
* @throws {@link UnknownReallocationVaultMarketConfigError} when the config is absent.
|
|
113
|
-
*/
|
|
114
|
-
getVaultMarketConfig(vault: Address, marketId: MarketId): VaultMarketConfig;
|
|
115
|
-
/**
|
|
116
|
-
* Calculates public reallocations that can supply liquidity to `marketId`.
|
|
117
|
-
*
|
|
118
|
-
* @remarks
|
|
119
|
-
* The algorithm repeatedly chooses the single largest currently available
|
|
120
|
-
* source-market withdrawal across reallocatable vaults, applies that
|
|
121
|
-
* withdrawal to a cloned state, and repeats until no valid withdrawal remains.
|
|
122
|
-
*
|
|
123
|
-
* Pass `options.timestamp` to evaluate market interest and pending public
|
|
124
|
-
* allocator caps at the same block as the fetched reallocation data.
|
|
125
|
-
* This method does not add an implicit delay margin before measuring
|
|
126
|
-
* target-market vault headroom. If a transaction may land later than the
|
|
127
|
-
* fetched block, pass a future `timestamp` or reserve your own headroom so
|
|
128
|
-
* interest accrued before inclusion does not make `reallocateTo` exceed the
|
|
129
|
-
* target market cap.
|
|
130
|
-
* Returned `data` normalizes `vault.publicAllocatorConfig.accruedFee` to the
|
|
131
|
-
* on-chain `reallocateTo` fee semantics: one fee charge per vault with at
|
|
132
|
-
* least one computed withdrawal.
|
|
133
|
-
*
|
|
134
|
-
* @param marketId - Target market to supply with shared liquidity.
|
|
135
|
-
* @param options - Optional allocator discovery options.
|
|
136
|
-
* @returns Computed source-market withdrawals and the post-reallocation state.
|
|
137
|
-
* @throws {@link UnknownReallocationMarketError} when the target market is absent.
|
|
138
|
-
* @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
|
|
139
|
-
* `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
|
|
140
|
-
* @example
|
|
141
|
-
* ```ts
|
|
142
|
-
* import { createPublicClient, http } from "viem";
|
|
143
|
-
* import { mainnet } from "viem/chains";
|
|
144
|
-
* import { markets, vaults } from "@morpho-org/morpho-test";
|
|
145
|
-
* import {
|
|
146
|
-
* morphoViemExtension,
|
|
147
|
-
* type PublicReallocation,
|
|
148
|
-
* } from "@morpho-org/morpho-sdk";
|
|
149
|
-
* import type { VaultV1ReallocationData } from "@morpho-org/morpho-sdk/entities";
|
|
150
|
-
*
|
|
151
|
-
* const client = createPublicClient({
|
|
152
|
-
* chain: mainnet,
|
|
153
|
-
* transport: http(),
|
|
154
|
-
* }).extend(morphoViemExtension());
|
|
155
|
-
*
|
|
156
|
-
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
157
|
-
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
158
|
-
* const block = await client.getBlock();
|
|
159
|
-
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
160
|
-
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
161
|
-
* block: { number: block.number, timestamp: block.timestamp },
|
|
162
|
-
* });
|
|
163
|
-
*
|
|
164
|
-
* const result: {
|
|
165
|
-
* withdrawals: readonly PublicReallocation[];
|
|
166
|
-
* data: VaultV1ReallocationData;
|
|
167
|
-
* } = reallocationData.computeVaultV1Reallocations(marketParams.id, {
|
|
168
|
-
* timestamp: block.timestamp,
|
|
169
|
-
* });
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
computeVaultV1Reallocations(marketId: MarketId, options?: PublicAllocatorOptions): {
|
|
173
|
-
readonly withdrawals: readonly PublicReallocation[];
|
|
174
|
-
data: VaultV1ReallocationData;
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* Calculates Vault V1 public reallocations that can supply liquidity to `marketId`.
|
|
178
|
-
*
|
|
179
|
-
* @param marketId - Target market to supply with shared liquidity.
|
|
180
|
-
* @param options - Optional allocator discovery options.
|
|
181
|
-
* @returns Computed source-market withdrawals and the post-reallocation state.
|
|
182
|
-
* @throws {@link UnknownReallocationMarketError} when the target market is absent.
|
|
183
|
-
* @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
|
|
184
|
-
* `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
|
|
185
|
-
*/
|
|
186
|
-
getMarketPublicReallocations(marketId: MarketId, options?: PublicAllocatorOptions): {
|
|
187
|
-
readonly withdrawals: readonly PublicReallocation[];
|
|
188
|
-
data: VaultV1ReallocationData;
|
|
189
|
-
};
|
|
190
|
-
/**
|
|
191
|
-
* Sums the public-allocator liquidity reallocatable into `marketId` from
|
|
192
|
-
* sibling markets.
|
|
193
|
-
*
|
|
194
|
-
* Read-only metric — never throws on insufficiency (returns `0n`). Bounded by
|
|
195
|
-
* each source market's withdrawal utilization cap and the target market's
|
|
196
|
-
* vault supply-cap headroom. Pass `options.defaultMaxWithdrawalUtilization` to
|
|
197
|
-
* widen the source ceiling (e.g. `MathLib.WAD` for the full drain).
|
|
198
|
-
*
|
|
199
|
-
* @param marketId - Target market that would receive the liquidity.
|
|
200
|
-
* @param options - Optional allocator discovery options.
|
|
201
|
-
* @returns Total reallocatable assets in loan-token units; `0n` when none is available.
|
|
202
|
-
* @throws {@link UnknownReallocationMarketError} when the target market is absent.
|
|
203
|
-
* @deprecated Vault V1 shared-liquidity metrics will be removed in the next major. Use
|
|
204
|
-
* `VaultV2BlueReallocationData.getPublicReallocationLiquidity`.
|
|
205
|
-
* @example
|
|
206
|
-
* ```ts
|
|
207
|
-
* import { createPublicClient, http } from "viem";
|
|
208
|
-
* import { mainnet } from "viem/chains";
|
|
209
|
-
* import { markets, vaults } from "@morpho-org/morpho-test";
|
|
210
|
-
* import { morphoViemExtension } from "@morpho-org/morpho-sdk";
|
|
211
|
-
*
|
|
212
|
-
* const client = createPublicClient({
|
|
213
|
-
* chain: mainnet,
|
|
214
|
-
* transport: http(),
|
|
215
|
-
* }).extend(morphoViemExtension());
|
|
216
|
-
*
|
|
217
|
-
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
218
|
-
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
219
|
-
* const block = await client.getBlock();
|
|
220
|
-
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
221
|
-
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
222
|
-
* block: { number: block.number, timestamp: block.timestamp },
|
|
223
|
-
* });
|
|
224
|
-
*
|
|
225
|
-
* const liquidity: bigint = reallocationData.getPublicReallocationLiquidity(
|
|
226
|
-
* marketParams.id,
|
|
227
|
-
* { timestamp: block.timestamp },
|
|
228
|
-
* );
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
getPublicReallocationLiquidity(marketId: MarketId, options?: PublicAllocatorOptions): bigint;
|
|
232
|
-
/**
|
|
233
|
-
* Computes the liquidity available to bring `marketId` to `utilization`,
|
|
234
|
-
* counting the public-allocator liquidity reallocatable into it.
|
|
235
|
-
*
|
|
236
|
-
* Returns the max borrow `x` keeping post-borrow utilization
|
|
237
|
-
* `(borrow + x) / (supply + L) ≤ utilization`, where `L` is the
|
|
238
|
-
* reallocatable liquidity added to the market's supply — equivalently
|
|
239
|
-
* `getBorrowToUtilization({ supply + L, borrow }, utilization)`. Below
|
|
240
|
-
* `utilization` this is the market's own borrow headroom plus `utilization · L`;
|
|
241
|
-
* reallocated supply also raises the supply denominator, so only that scaled
|
|
242
|
-
* share backs further borrow.
|
|
243
|
-
*
|
|
244
|
-
* Read-only metric — never throws on insufficiency:
|
|
245
|
-
* - returns only the market's own borrow headroom when
|
|
246
|
-
* `supplyTargetUtilization > utilization` (reallocation would not
|
|
247
|
-
* trigger at that utilization);
|
|
248
|
-
* - returns `0n` when the market is already at or above `utilization` and `L`
|
|
249
|
-
* is too small to bring it back under.
|
|
250
|
-
*
|
|
251
|
-
* @param marketId - Target market to borrow from.
|
|
252
|
-
* @param utilization - Utilization to bring the market to, scaled by WAD. Defaults to {@link DEFAULT_SUPPLY_TARGET_UTILIZATION}.
|
|
253
|
-
* @param options - Optional reallocation options (supply target utilization trigger, timestamp, withdrawal caps).
|
|
254
|
-
* @returns Available liquidity to the given utilization in loan-token units; `0n` when none is available.
|
|
255
|
-
* @throws {@link UnknownReallocationMarketError} when the target market is absent.
|
|
256
|
-
* @deprecated Vault V1 shared-liquidity metrics will be removed in the next major. Use
|
|
257
|
-
* `VaultV2BlueReallocationData.getAvailableLiquidityToUtilization`.
|
|
258
|
-
* @example
|
|
259
|
-
* ```ts
|
|
260
|
-
* import { createPublicClient, http, parseEther } from "viem";
|
|
261
|
-
* import { mainnet } from "viem/chains";
|
|
262
|
-
* import { markets, vaults } from "@morpho-org/morpho-test";
|
|
263
|
-
* import { morphoViemExtension } from "@morpho-org/morpho-sdk";
|
|
264
|
-
*
|
|
265
|
-
* const client = createPublicClient({
|
|
266
|
-
* chain: mainnet,
|
|
267
|
-
* transport: http(),
|
|
268
|
-
* }).extend(morphoViemExtension());
|
|
269
|
-
*
|
|
270
|
-
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
271
|
-
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
272
|
-
* const block = await client.getBlock();
|
|
273
|
-
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
274
|
-
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
275
|
-
* block: { number: block.number, timestamp: block.timestamp },
|
|
276
|
-
* });
|
|
277
|
-
*
|
|
278
|
-
* // Max borrow keeping utilization at or below 90%, counting shared liquidity.
|
|
279
|
-
* const available: bigint =
|
|
280
|
-
* reallocationData.getAvailableLiquidityToUtilization(
|
|
281
|
-
* marketParams.id,
|
|
282
|
-
* parseEther("0.9"),
|
|
283
|
-
* { timestamp: block.timestamp },
|
|
284
|
-
* );
|
|
285
|
-
* ```
|
|
286
|
-
*/
|
|
287
|
-
getAvailableLiquidityToUtilization(marketId: MarketId, utilization?: bigint, options?: ReallocationComputeOptions): bigint;
|
|
288
|
-
/**
|
|
289
|
-
* Gets the largest currently valid source-market withdrawal for a vault.
|
|
290
|
-
*
|
|
291
|
-
* @param params - Candidate vault, target market, prior withdrawals, and allocator limits.
|
|
292
|
-
* @returns The largest withdrawal candidate, or `undefined` if required data is missing.
|
|
293
|
-
*
|
|
294
|
-
* @internal
|
|
295
|
-
*/
|
|
296
|
-
private getLargestVaultWithdrawal;
|
|
297
|
-
/**
|
|
298
|
-
* Applies one public allocator withdrawal and corresponding target-market supply.
|
|
299
|
-
*
|
|
300
|
-
* @param vault - Vault performing the public reallocation.
|
|
301
|
-
* @param supplyMarketId - Target market that receives the withdrawn assets.
|
|
302
|
-
* @param withdrawal - Source market id and asset amount to withdraw.
|
|
303
|
-
* @param timestamp - Timestamp used to accrue source and target positions.
|
|
304
|
-
* @returns A cloned state after applying the simulated reallocation.
|
|
305
|
-
* @throws {@link MissingPublicAllocatorConfigError} when the vault allocator config is absent.
|
|
306
|
-
* @throws {@link UnknownReallocationVaultMarketConfigError} when source or target allocator limits are absent.
|
|
307
|
-
*
|
|
308
|
-
* @internal
|
|
309
|
-
*/
|
|
310
|
-
protected applyPublicReallocation({ vault, supplyMarketId, withdrawal, timestamp, }: {
|
|
311
|
-
readonly vault: Address;
|
|
312
|
-
readonly supplyMarketId: MarketId;
|
|
313
|
-
readonly withdrawal: {
|
|
314
|
-
readonly id: MarketId;
|
|
315
|
-
readonly assets: bigint;
|
|
316
|
-
};
|
|
317
|
-
readonly timestamp: bigint;
|
|
318
|
-
}): VaultV1ReallocationData;
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Deprecated class name for Vault V1 reallocation data.
|
|
322
|
-
*
|
|
323
|
-
* @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
|
|
324
|
-
* `VaultV2BlueReallocationData`.
|
|
325
|
-
*/
|
|
326
|
-
export { VaultV1ReallocationData as ReallocationData };
|