@morpho-org/morpho-sdk 6.0.0-next.2 → 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 +83 -29
- package/README.md +9 -7
- package/lib/cjs/abis.d.ts +3 -2844
- package/lib/cjs/abis.js +1 -1951
- 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 +1 -9
- 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 +2 -2
- 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 +6 -2
- package/lib/cjs/actions/bundles/common.js +23 -5
- 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 +6 -8
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +11 -16
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
- 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 +5 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +6 -11
- 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 -5
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +10 -7
- 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 +1 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +3 -3
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +6 -5
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +10 -7
- package/lib/cjs/augment.d.ts +0 -1
- package/lib/cjs/augment.js +0 -1
- package/lib/cjs/blue/abis.d.ts +1 -5
- package/lib/cjs/blue/abis.js +1 -7
- package/lib/cjs/blue/entities.d.ts +2 -8
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/fetch.d.ts +1 -3
- package/lib/cjs/blue/fetch.js +1 -3
- 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 +30 -265
- package/lib/cjs/entities/blue/blue.js +1 -205
- package/lib/cjs/entities/index.d.ts +3 -66
- package/lib/cjs/entities/index.js +1 -21
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +9 -2
- package/lib/cjs/entities/vaultV1/vaultV1.js +12 -7
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +22 -9
- package/lib/cjs/entities/vaultV2/vaultV2.js +28 -15
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +4 -21
- package/lib/cjs/errors.d.ts +2 -46
- package/lib/cjs/errors.js +1 -46
- package/lib/cjs/fetch.d.ts +1 -17
- package/lib/cjs/fetch.js +1 -17
- package/lib/cjs/helpers/constant.d.ts +0 -2
- package/lib/cjs/helpers/constant.js +0 -2
- package/lib/cjs/helpers/index.d.ts +2 -3
- package/lib/cjs/helpers/index.js +1 -9
- package/lib/cjs/helpers/slippage.d.ts +1 -103
- package/lib/cjs/helpers/slippage.js +0 -150
- package/lib/cjs/helpers/utilization.d.ts +12 -10
- package/lib/cjs/helpers/utilization.js +27 -12
- package/lib/cjs/helpers/validate.d.ts +1 -24
- package/lib/cjs/helpers/validate.js +2 -49
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +1 -3
- package/lib/cjs/types/action.d.ts +17 -65
- package/lib/cjs/types/action.js +11 -4
- package/lib/cjs/types/error.d.ts +50 -381
- package/lib/cjs/types/error.js +64 -395
- package/lib/cjs/types/sharedLiquidity.d.ts +1 -117
- package/lib/cjs/types.d.ts +2 -18
- package/lib/cjs/utils.d.ts +6 -35
- package/lib/cjs/utils.js +2 -36
- package/lib/esm/abis.d.ts +3 -2844
- package/lib/esm/abis.js +3 -1950
- 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 +1 -9
- 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 +2 -2
- 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 +6 -2
- package/lib/esm/actions/bundles/common.js +24 -6
- 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 +6 -8
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +12 -17
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
- 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 +5 -5
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +6 -11
- 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 -5
- package/lib/esm/actions/vaultV1/inKindRedeem.js +10 -7
- 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 +1 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -3
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +6 -5
- package/lib/esm/actions/vaultV2/inKindRedeem.js +10 -7
- package/lib/esm/augment.d.ts +0 -1
- package/lib/esm/augment.js +0 -1
- package/lib/esm/blue/abis.d.ts +1 -5
- package/lib/esm/blue/abis.js +1 -5
- package/lib/esm/blue/entities.d.ts +2 -8
- package/lib/esm/blue/entities.js +1 -3
- package/lib/esm/blue/fetch.d.ts +1 -3
- package/lib/esm/blue/fetch.js +1 -3
- 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 +30 -265
- package/lib/esm/entities/blue/blue.js +4 -208
- package/lib/esm/entities/index.d.ts +3 -66
- package/lib/esm/entities/index.js +1 -18
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +9 -2
- package/lib/esm/entities/vaultV1/vaultV1.js +15 -10
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +22 -9
- package/lib/esm/entities/vaultV2/vaultV2.js +32 -19
- package/lib/esm/entities/vaultV2BlueReallocationData.js +2 -19
- package/lib/esm/errors.d.ts +2 -46
- package/lib/esm/errors.js +2 -46
- package/lib/esm/fetch.d.ts +1 -17
- package/lib/esm/fetch.js +1 -17
- package/lib/esm/helpers/constant.d.ts +0 -2
- package/lib/esm/helpers/constant.js +0 -2
- package/lib/esm/helpers/index.d.ts +2 -3
- package/lib/esm/helpers/index.js +2 -3
- package/lib/esm/helpers/slippage.d.ts +1 -103
- package/lib/esm/helpers/slippage.js +1 -147
- package/lib/esm/helpers/utilization.d.ts +12 -10
- package/lib/esm/helpers/utilization.js +26 -11
- package/lib/esm/helpers/validate.d.ts +1 -24
- package/lib/esm/helpers/validate.js +2 -48
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +1 -3
- package/lib/esm/types/action.d.ts +17 -65
- package/lib/esm/types/action.js +12 -5
- package/lib/esm/types/error.d.ts +50 -381
- package/lib/esm/types/error.js +58 -377
- package/lib/esm/types/sharedLiquidity.d.ts +1 -117
- package/lib/esm/types.d.ts +2 -18
- package/lib/esm/utils.d.ts +6 -35
- package/lib/esm/utils.js +5 -34
- package/package.json +5 -13
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -88
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -152
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -53
- 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 -50
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -45
- 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 -11
- 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 -332
- package/lib/cjs/entities/vaultV1ReallocationData.js +0 -557
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +0 -80
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +0 -245
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -84
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -148
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -49
- 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 -50
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -41
- 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 -11
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +0 -7
- 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 -332
- package/lib/esm/entities/vaultV1ReallocationData.js +0 -559
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +0 -80
- package/lib/esm/helpers/computeVaultV1Reallocations.js +0 -241
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { AccrualVaultV2MorphoMarketV1AdapterV2, DEFAULT_SLIPPAGE_TOLERANCE,
|
|
1
|
+
import { AccrualVaultV2MorphoMarketV1AdapterV2, DEFAULT_SLIPPAGE_TOLERANCE, MarketUtils, MathLib, } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { erc2612Abi, fetchAccrualVaultV2 } from "@morpho-org/blue-sdk-viem";
|
|
3
|
-
import { getChainAddress, Time } from "@morpho-org/morpho-ts";
|
|
3
|
+
import { _try, getChainAddress, Time } from "@morpho-org/morpho-ts";
|
|
4
4
|
import { erc20Abi, isAddressEqual, maxUint256 } from "viem";
|
|
5
5
|
import { multicall } from "viem/actions";
|
|
6
6
|
import { getBundlesReferralFeeAssets, normalizeBundlesCommonParams, resolveBundlesFunding, selectBundlesSharesPermitSignature, selectBundlesSharesRequirementSignature, selectBundlesTokenRequirementSignature, } from "../../actions/bundles/common.js";
|
|
7
7
|
import { encodeErc20Approval, encodeVaultSharesPermit, vaultV2Deposit, vaultV2ForceRedeem, vaultV2ForceWithdraw, vaultV2InKindRedeem, vaultV2Redeem, vaultV2Withdraw, } from "../../actions/index.js";
|
|
8
|
-
import { computeMinForceWithdrawSharePrice, computeVaultMaxShareAllowance, computeVaultMaxSharePrice, computeVaultV2ForceWithdrawFeeSharesMinted, computeVaultV2ForceWithdrawMinSharesBurnt, computeVaultV2ForceWithdrawPlan, computeVaultV2ForceWithdrawSharesBurnt, resolveVaultV2ForceWithdrawEligibility, validateChainId, validateSlippageTolerance, } from "../../helpers/index.js";
|
|
8
|
+
import { computeMinForceWithdrawSharePrice, computeVaultMaxShareAllowance, computeVaultMaxSharePrice, computeVaultV2ForceWithdrawFeeSharesMinted, computeVaultV2ForceWithdrawMinSharesBurnt, computeVaultV2ForceWithdrawPlan, computeVaultV2ForceWithdrawSharesBurnt, MAX_SLIPPAGE_TOLERANCE, resolveVaultV2ForceWithdrawEligibility, validateChainId, validateSlippageTolerance, } from "../../helpers/index.js";
|
|
9
9
|
import { validateDeadline, validateNativeVaultAsset, validateReferralFee, validateUint256Field, } from "../../helpers/validate.js";
|
|
10
|
-
import { AdapterNotPartOfVaultError, ChainIdMismatchError, EmptyMarketParamsListError, ExpiredDeadlineError, InKindRedeemCoverageError, InKindRedeemZeroDeallocationError, InputExceedsMaxError, InsufficientBlueBalanceForInKindRedeemError, isRequirementSignature, NonPositiveInputError,
|
|
10
|
+
import { AdapterNotPartOfVaultError, ChainIdMismatchError, EmptyMarketParamsListError, ExpiredDeadlineError, InKindRedeemCoverageError, InKindRedeemZeroDeallocationError, InputExceedsMaxError, InsufficientBlueBalanceForInKindRedeemError, isRequirementSignature, NonPositiveInputError, VaultAddressMismatchError, VaultV2ForceWithdrawCoverageError, VaultV2ForceWithdrawFeeSharesExceedBurnError, VaultV2ForceWithdrawSharePriceBelowFloorError, VaultV2ForceWithdrawZeroSharePriceError, VaultV2ForceWithdrawZeroWithdrawalError, VaultV2SingleAdapterRequiredError, VaultV2UndecodableLiquidityDataError, VaultV2UnsupportedExitAdapterError, VaultV2UnsupportedLiquidityAdapterError, } from "../../types/index.js";
|
|
11
11
|
import { getVaultBundlesSharesRequirements } from "../requirements/getVaultBundlesSharesRequirements.js";
|
|
12
12
|
import { getBundlesTokenRequirements } from "../requirements/index.js";
|
|
13
13
|
// Maximum accepted deadline horizon; the on-chain management fee is capped at 5%/yr so the
|
|
@@ -30,7 +30,6 @@ export class MorphoVaultV2 {
|
|
|
30
30
|
}
|
|
31
31
|
return fetchAccrualVaultV2(this.vault, this.client.viemClient, {
|
|
32
32
|
...parameters,
|
|
33
|
-
chainId: this.chainId,
|
|
34
33
|
deployless: this.client.options.supportDeployless,
|
|
35
34
|
});
|
|
36
35
|
}
|
|
@@ -366,8 +365,7 @@ export class MorphoVaultV2 {
|
|
|
366
365
|
remaining -= chunk;
|
|
367
366
|
}
|
|
368
367
|
const vaultExitBundlesV1 = getChainAddress(this.chainId, "bundles.vaultExitBundlesV1");
|
|
369
|
-
const
|
|
370
|
-
const blue = addresses.blue ?? addresses.morpho;
|
|
368
|
+
const blue = getChainAddress(this.chainId, "blue");
|
|
371
369
|
return {
|
|
372
370
|
getRequirements: async () => {
|
|
373
371
|
const requirementsTimestamp = Time.timestamp();
|
|
@@ -410,9 +408,14 @@ export class MorphoVaultV2 {
|
|
|
410
408
|
required: peak,
|
|
411
409
|
});
|
|
412
410
|
}
|
|
413
|
-
|
|
411
|
+
// In-kind withdrawals carry no onchain share cap, so the allowance itself is the cap. A
|
|
412
|
+
// larger leftover allowance would let a share-price loss burn past `requiredShareAllowance`.
|
|
413
|
+
if (allowance === requiredShareAllowance)
|
|
414
414
|
return [];
|
|
415
|
-
|
|
415
|
+
// A lowering permit can be skipped after its nonce is consumed, so oversized allowances
|
|
416
|
+
// must be reset with an onchain approval.
|
|
417
|
+
if (allowance < requiredShareAllowance &&
|
|
418
|
+
this.client.options.supportSignature) {
|
|
416
419
|
return [
|
|
417
420
|
encodeVaultSharesPermit({
|
|
418
421
|
vault: vaultData,
|
|
@@ -436,8 +439,10 @@ export class MorphoVaultV2 {
|
|
|
436
439
|
];
|
|
437
440
|
},
|
|
438
441
|
buildTx: (signatures) => {
|
|
439
|
-
const
|
|
440
|
-
|
|
442
|
+
const permit = selectBundlesSharesPermitSignature(signatures, {
|
|
443
|
+
spender: vaultExitBundlesV1,
|
|
444
|
+
amount: requiredShareAllowance,
|
|
445
|
+
deadline,
|
|
441
446
|
});
|
|
442
447
|
return vaultV2InKindRedeem({
|
|
443
448
|
vault: { chainId: this.chainId, address: this.vault },
|
|
@@ -577,6 +582,21 @@ export class MorphoVaultV2 {
|
|
|
577
582
|
}
|
|
578
583
|
// sharesBurntNow ≥ minSharesBurntNow ≥ minSharesBurntProjected > feeSharesProjected ≥ feeSharesNow
|
|
579
584
|
const netSharesBurntNow = sharesBurntNow - feeSharesNow;
|
|
585
|
+
if (minSharePriceE27Override != null) {
|
|
586
|
+
// The maximum-slippage threshold only bounds the override; unlike the transaction floor it
|
|
587
|
+
// may round to zero, in which case every positive override is acceptable.
|
|
588
|
+
const minAllowedSharePriceE27 = _try(() => computeMinForceWithdrawSharePrice({
|
|
589
|
+
withdrawnAssets: plan.withdrawnAssets,
|
|
590
|
+
sharesBurnt: netSharesBurntNow,
|
|
591
|
+
slippageTolerance: MAX_SLIPPAGE_TOLERANCE,
|
|
592
|
+
}), VaultV2ForceWithdrawZeroSharePriceError) ?? 1n;
|
|
593
|
+
if (minSharePriceE27Override < minAllowedSharePriceE27) {
|
|
594
|
+
throw new VaultV2ForceWithdrawSharePriceBelowFloorError({
|
|
595
|
+
minSharePriceE27: minSharePriceE27Override,
|
|
596
|
+
floorE27: minAllowedSharePriceE27,
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
}
|
|
580
600
|
const minSharePriceE27 = minSharePriceE27Override ??
|
|
581
601
|
computeMinForceWithdrawSharePrice({
|
|
582
602
|
withdrawnAssets: plan.withdrawnAssets,
|
|
@@ -587,17 +607,10 @@ export class MorphoVaultV2 {
|
|
|
587
607
|
// lowering a lower bound weakens it, so any vault whose share price grew past that would be left
|
|
588
608
|
// with no real protection. Its two sibling `computeMin*SharePrice` helpers cap nothing either —
|
|
589
609
|
// only the `computeMax*` ones do, where capping relaxes an upper bound and is safe.
|
|
590
|
-
//
|
|
591
|
-
// It still has to fit the ABI slot though. Defense-in-depth rather than a reachable input error:
|
|
592
|
-
// with `exitAssets` bounded above, the derived floor only exceeds `uint256` on a vault whose
|
|
593
|
-
// share price passed ~1e50 assets/share, which no fixture here can construct.
|
|
594
610
|
validateUint256Field("minSharePriceE27", minSharePriceE27);
|
|
595
611
|
// VaultExitBundlesV1's burn bound includes fee shares minted by the first withdrawal. Add the
|
|
596
612
|
// projected fee shares to the price-floor ceiling so the approval covers that mint.
|
|
597
|
-
// Saturated at `maxUint256
|
|
598
|
-
// approval encoder clamps what it emits — so an uncapped requirement would sit permanently above
|
|
599
|
-
// any allowance the user can actually grant and `getRequirements()` would return the same
|
|
600
|
-
// approval forever. No account can hold or burn more shares than that anyway.
|
|
613
|
+
// Saturated at `maxUint256` as an ABI-slot guard for an otherwise valid extreme share burn.
|
|
601
614
|
const requiredShareAllowance = MathLib.min(MathLib.mulDivUp(exitAssets, MathLib.RAY, minSharePriceE27) +
|
|
602
615
|
feeSharesProjected, maxUint256);
|
|
603
616
|
const vaultExitBundlesV1 = getChainAddress(this.chainId, "bundles.vaultExitBundlesV1");
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, Market, MarketUtils, MathLib, UnsupportedVaultV2AdapterError, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { _try, bigIntComparator } from "@morpho-org/morpho-ts";
|
|
3
3
|
import { isAddressEqual } from "viem";
|
|
4
|
-
import { DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION,
|
|
4
|
+
import { DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, MAX_REALLOCATION_PENALTY, } from "../helpers/constant.js";
|
|
5
|
+
import { resolveMaxWithdrawalUtilization } from "../helpers/utilization.js";
|
|
5
6
|
import { InputExceedsMaxError, InsufficientSharedLiquidityError, NegativeInputError, NonPositiveInputError, ReallocationAdapterSupplySharesUnderflowError, ReallocationAllocationUnderflowError, ReallocationWithdrawExceedsMarketSupplyError, UnknownReallocationActiveAdaptersError, UnknownReallocationAdapterError, UnknownReallocationAllocationError, UnknownReallocationMarketError, UnknownReallocationMarketPublicAllocatorConfigError, UnknownReallocationPublicAllocatorConfigError, UnknownReallocationVaultError, } from "../types/index.js";
|
|
6
7
|
const MAX_SHARED_CAP_SEARCH_STEPS = 1024n;
|
|
7
8
|
/** Creates isolated transaction-scoped state for one simulation. @internal */
|
|
@@ -41,18 +42,6 @@ const getAdapterIds = (cache, adapter, market) => {
|
|
|
41
42
|
cache.set(key, ids);
|
|
42
43
|
return ids;
|
|
43
44
|
};
|
|
44
|
-
const resolveMaxWithdrawalUtilization = (value) => {
|
|
45
|
-
const utilization = value ?? DEFAULT_WITHDRAWAL_TARGET_UTILIZATION;
|
|
46
|
-
if (utilization < 0n)
|
|
47
|
-
throw new NegativeInputError("maxWithdrawalUtilization", utilization);
|
|
48
|
-
if (utilization > MathLib.WAD)
|
|
49
|
-
throw new InputExceedsMaxError({
|
|
50
|
-
field: "maxWithdrawalUtilization",
|
|
51
|
-
value: utilization,
|
|
52
|
-
max: MathLib.WAD,
|
|
53
|
-
});
|
|
54
|
-
return utilization;
|
|
55
|
-
};
|
|
56
45
|
const resolveMaxPenalty = (value) => {
|
|
57
46
|
const penalty = value ?? DEFAULT_MAX_REALLOCATION_PENALTY;
|
|
58
47
|
if (penalty < 0n)
|
|
@@ -72,16 +61,10 @@ const cloneAccrualVault = (vault, markets) => new AccrualVault({
|
|
|
72
61
|
pendingTimelock: { ...vault.pendingTimelock },
|
|
73
62
|
pendingGuardian: { ...vault.pendingGuardian },
|
|
74
63
|
supplyQueue: [...vault.supplyQueue],
|
|
75
|
-
publicAllocatorConfig: vault.publicAllocatorConfig == null
|
|
76
|
-
? undefined
|
|
77
|
-
: { ...vault.publicAllocatorConfig },
|
|
78
64
|
}, [...vault.allocations.values()].map(({ config, position }) => ({
|
|
79
65
|
config: {
|
|
80
66
|
...config,
|
|
81
67
|
pendingCap: { ...config.pendingCap },
|
|
82
|
-
publicAllocatorConfig: config.publicAllocatorConfig == null
|
|
83
|
-
? undefined
|
|
84
|
-
: { ...config.publicAllocatorConfig },
|
|
85
68
|
},
|
|
86
69
|
position: clonePosition(position, markets),
|
|
87
70
|
})));
|
package/lib/esm/errors.d.ts
CHANGED
|
@@ -1,49 +1,5 @@
|
|
|
1
|
-
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError,
|
|
2
|
-
/** @deprecated Use InvalidBlueMarketParamsError or the raw protocol subpath. */
|
|
3
|
-
InvalidMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError,
|
|
4
|
-
/** @deprecated Use UnknownBlueDataError or the raw protocol subpath. */
|
|
5
|
-
UnknownDataError, UnknownFactory as UnknownBlueFactory,
|
|
6
|
-
/** @deprecated Use UnknownBlueFactory or the raw protocol subpath. */
|
|
7
|
-
UnknownFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError,
|
|
8
|
-
/** @deprecated Use UnknownBlueMarketParamsError or the raw protocol subpath. */
|
|
9
|
-
UnknownMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory,
|
|
10
|
-
/** @deprecated Use UnknownBlueOfFactory or the raw protocol subpath. */
|
|
11
|
-
UnknownOfFactory, UnknownTokenError as UnknownBlueTokenError,
|
|
12
|
-
/** @deprecated Use UnknownBlueTokenError or the raw protocol subpath. */
|
|
13
|
-
UnknownTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError,
|
|
14
|
-
/** @deprecated Use UnknownBlueTokenPriceError or the raw protocol subpath. */
|
|
15
|
-
UnknownTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError,
|
|
16
|
-
/** @deprecated Use UnknownBlueVaultConfigError or the raw protocol subpath. */
|
|
17
|
-
UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError, UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError,
|
|
18
|
-
/** @deprecated Use UnsupportedBluePreLiquidationParamsError or the raw protocol subpath. */
|
|
19
|
-
UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError,
|
|
20
|
-
/** @deprecated Use UnsupportedBlueVaultV2AdapterError or the raw protocol subpath. */
|
|
21
|
-
UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
1
|
+
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError, UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
22
2
|
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
23
|
-
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError,
|
|
24
|
-
/** @deprecated Use InvalidMidnightOfferGroupError or the raw protocol subpath. */
|
|
25
|
-
InvalidOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError,
|
|
26
|
-
/** @deprecated Use InvalidMidnightOfferParameterError or the raw protocol subpath. */
|
|
27
|
-
InvalidOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError,
|
|
28
|
-
/** @deprecated Use InvalidMidnightPositionAccrualStateError or the raw protocol subpath. */
|
|
29
|
-
InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError,
|
|
30
|
-
/** @deprecated Use InvalidMidnightPositionAccrualTimestampError or the raw protocol subpath. */
|
|
31
|
-
InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError,
|
|
32
|
-
/** @deprecated Use InvalidMidnightPositionLossFactorError or the raw protocol subpath. */
|
|
33
|
-
InvalidPositionLossFactorError, InvalidTickSpacingError as InvalidMidnightTickSpacingError,
|
|
34
|
-
/** @deprecated Use InvalidMidnightTickSpacingError or the raw protocol subpath. */
|
|
35
|
-
InvalidTickSpacingError, InvalidTreeError as InvalidMidnightTreeError,
|
|
36
|
-
/** @deprecated Use InvalidMidnightTreeError or the raw protocol subpath. */
|
|
37
|
-
InvalidTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError,
|
|
38
|
-
/** @deprecated Use InvalidMidnightTreeHeightError or the raw protocol subpath. */
|
|
39
|
-
InvalidTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError,
|
|
40
|
-
/** @deprecated Use MidnightPriceGreaterThanOneError or the raw protocol subpath. */
|
|
41
|
-
PriceGreaterThanOneError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError,
|
|
42
|
-
/** @deprecated Use MidnightSettlementFeeExceedsPriceError or the raw protocol subpath. */
|
|
43
|
-
SettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError,
|
|
44
|
-
/** @deprecated Use MidnightTickOutOfRangeError or the raw protocol subpath. */
|
|
45
|
-
TickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError,
|
|
46
|
-
/** @deprecated Use UnknownMidnightCollateralIndexError or the raw protocol subpath. */
|
|
47
|
-
UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
3
|
+
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
48
4
|
export type { ErrorClass } from "@morpho-org/morpho-ts";
|
|
49
5
|
export { _try, DivisionByZeroError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|
package/lib/esm/errors.js
CHANGED
|
@@ -1,48 +1,4 @@
|
|
|
1
|
-
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError,
|
|
2
|
-
/** @deprecated Use InvalidBlueMarketParamsError or the raw protocol subpath. */
|
|
3
|
-
InvalidMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError,
|
|
4
|
-
/** @deprecated Use UnknownBlueDataError or the raw protocol subpath. */
|
|
5
|
-
UnknownDataError, UnknownFactory as UnknownBlueFactory,
|
|
6
|
-
/** @deprecated Use UnknownBlueFactory or the raw protocol subpath. */
|
|
7
|
-
UnknownFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError,
|
|
8
|
-
/** @deprecated Use UnknownBlueMarketParamsError or the raw protocol subpath. */
|
|
9
|
-
UnknownMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory,
|
|
10
|
-
/** @deprecated Use UnknownBlueOfFactory or the raw protocol subpath. */
|
|
11
|
-
UnknownOfFactory, UnknownTokenError as UnknownBlueTokenError,
|
|
12
|
-
/** @deprecated Use UnknownBlueTokenError or the raw protocol subpath. */
|
|
13
|
-
UnknownTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError,
|
|
14
|
-
/** @deprecated Use UnknownBlueTokenPriceError or the raw protocol subpath. */
|
|
15
|
-
UnknownTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError,
|
|
16
|
-
/** @deprecated Use UnknownBlueVaultConfigError or the raw protocol subpath. */
|
|
17
|
-
UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError, UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError,
|
|
18
|
-
/** @deprecated Use UnsupportedBluePreLiquidationParamsError or the raw protocol subpath. */
|
|
19
|
-
UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError,
|
|
20
|
-
/** @deprecated Use UnsupportedBlueVaultV2AdapterError or the raw protocol subpath. */
|
|
21
|
-
UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
1
|
+
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError, UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
22
2
|
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
23
|
-
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError,
|
|
24
|
-
/** @deprecated Use InvalidMidnightOfferGroupError or the raw protocol subpath. */
|
|
25
|
-
InvalidOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError,
|
|
26
|
-
/** @deprecated Use InvalidMidnightOfferParameterError or the raw protocol subpath. */
|
|
27
|
-
InvalidOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError,
|
|
28
|
-
/** @deprecated Use InvalidMidnightPositionAccrualStateError or the raw protocol subpath. */
|
|
29
|
-
InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError,
|
|
30
|
-
/** @deprecated Use InvalidMidnightPositionAccrualTimestampError or the raw protocol subpath. */
|
|
31
|
-
InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError,
|
|
32
|
-
/** @deprecated Use InvalidMidnightPositionLossFactorError or the raw protocol subpath. */
|
|
33
|
-
InvalidPositionLossFactorError, InvalidTickSpacingError as InvalidMidnightTickSpacingError,
|
|
34
|
-
/** @deprecated Use InvalidMidnightTickSpacingError or the raw protocol subpath. */
|
|
35
|
-
InvalidTickSpacingError, InvalidTreeError as InvalidMidnightTreeError,
|
|
36
|
-
/** @deprecated Use InvalidMidnightTreeError or the raw protocol subpath. */
|
|
37
|
-
InvalidTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError,
|
|
38
|
-
/** @deprecated Use InvalidMidnightTreeHeightError or the raw protocol subpath. */
|
|
39
|
-
InvalidTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError,
|
|
40
|
-
/** @deprecated Use MidnightPriceGreaterThanOneError or the raw protocol subpath. */
|
|
41
|
-
PriceGreaterThanOneError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError,
|
|
42
|
-
/** @deprecated Use MidnightSettlementFeeExceedsPriceError or the raw protocol subpath. */
|
|
43
|
-
SettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError,
|
|
44
|
-
/** @deprecated Use MidnightTickOutOfRangeError or the raw protocol subpath. */
|
|
45
|
-
TickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError,
|
|
46
|
-
/** @deprecated Use UnknownMidnightCollateralIndexError or the raw protocol subpath. */
|
|
47
|
-
UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
3
|
+
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
48
4
|
export { _try, DivisionByZeroError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|
package/lib/esm/fetch.d.ts
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
export { fetchAccrualPosition as fetchBlueAccrualPosition,
|
|
2
|
-
/** @deprecated Use `fetchBlueAccrualPosition` or the raw `/blue/fetch` subpath. */
|
|
3
|
-
fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket,
|
|
4
|
-
/** @deprecated Use `fetchBlueMarket` or the raw `/blue/fetch` subpath. */
|
|
5
|
-
fetchMarket, fetchMarketParams as fetchBlueMarketParams,
|
|
6
|
-
/** @deprecated Use `fetchBlueMarketParams` or the raw `/blue/fetch` subpath. */
|
|
7
|
-
fetchMarketParams, fetchPosition as fetchBluePosition,
|
|
8
|
-
/** @deprecated Use `fetchBluePosition` or the raw `/blue/fetch` subpath. */
|
|
9
|
-
fetchPosition, fetchPreLiquidationParams as fetchBluePreLiquidationParams,
|
|
10
|
-
/** @deprecated Use `fetchBluePreLiquidationParams` or the raw `/blue/fetch` subpath. */
|
|
11
|
-
fetchPreLiquidationParams, fetchPreLiquidationPosition as fetchBluePreLiquidationPosition,
|
|
12
|
-
/** @deprecated Use `fetchBluePreLiquidationPosition` or the raw `/blue/fetch` subpath. */
|
|
13
|
-
fetchPreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser,
|
|
14
|
-
/** @deprecated Use `fetchBlueUser` or the raw `/blue/fetch` subpath. */
|
|
15
|
-
fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig,
|
|
16
|
-
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `fetchVaultV2BlueMarketPublicAllocatorConfig`. */
|
|
17
|
-
fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
1
|
+
export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition, fetchPreLiquidationParams as fetchBluePreLiquidationParams, fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
18
2
|
export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
|
package/lib/esm/fetch.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
export { fetchAccrualPosition as fetchBlueAccrualPosition,
|
|
2
|
-
/** @deprecated Use `fetchBlueAccrualPosition` or the raw `/blue/fetch` subpath. */
|
|
3
|
-
fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket,
|
|
4
|
-
/** @deprecated Use `fetchBlueMarket` or the raw `/blue/fetch` subpath. */
|
|
5
|
-
fetchMarket, fetchMarketParams as fetchBlueMarketParams,
|
|
6
|
-
/** @deprecated Use `fetchBlueMarketParams` or the raw `/blue/fetch` subpath. */
|
|
7
|
-
fetchMarketParams, fetchPosition as fetchBluePosition,
|
|
8
|
-
/** @deprecated Use `fetchBluePosition` or the raw `/blue/fetch` subpath. */
|
|
9
|
-
fetchPosition, fetchPreLiquidationParams as fetchBluePreLiquidationParams,
|
|
10
|
-
/** @deprecated Use `fetchBluePreLiquidationParams` or the raw `/blue/fetch` subpath. */
|
|
11
|
-
fetchPreLiquidationParams, fetchPreLiquidationPosition as fetchBluePreLiquidationPosition,
|
|
12
|
-
/** @deprecated Use `fetchBluePreLiquidationPosition` or the raw `/blue/fetch` subpath. */
|
|
13
|
-
fetchPreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser,
|
|
14
|
-
/** @deprecated Use `fetchBlueUser` or the raw `/blue/fetch` subpath. */
|
|
15
|
-
fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig,
|
|
16
|
-
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `fetchVaultV2BlueMarketPublicAllocatorConfig`. */
|
|
17
|
-
fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
1
|
+
export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition, fetchPreLiquidationParams as fetchBluePreLiquidationParams, fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
18
2
|
export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
|
|
@@ -17,8 +17,6 @@ export declare const DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = 900000000000000000n
|
|
|
17
17
|
/**
|
|
18
18
|
* The default target utilization above which shared liquidity reallocations are
|
|
19
19
|
* triggered (and the level the target market is brought back to), scaled by WAD.
|
|
20
|
-
* Still overridable through the deprecated `supplyTargetUtilization` /
|
|
21
|
-
* `defaultSupplyTargetUtilization` options until the next major.
|
|
22
20
|
*/
|
|
23
21
|
export declare const DEFAULT_SUPPLY_TARGET_UTILIZATION = 900000000000000000n;
|
|
24
22
|
/**
|
|
@@ -18,8 +18,6 @@ export const DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = 900000000000000000n;
|
|
|
18
18
|
/**
|
|
19
19
|
* The default target utilization above which shared liquidity reallocations are
|
|
20
20
|
* triggered (and the level the target market is brought back to), scaled by WAD.
|
|
21
|
-
* Still overridable through the deprecated `supplyTargetUtilization` /
|
|
22
|
-
* `defaultSupplyTargetUtilization` options until the next major.
|
|
23
21
|
*/
|
|
24
22
|
export const DEFAULT_SUPPLY_TARGET_UTILIZATION = 900000000000000000n;
|
|
25
23
|
/**
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
export { computeReallocations, computeVaultV1Reallocations, } from "./computeVaultV1Reallocations.js";
|
|
2
1
|
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 "./constant.js";
|
|
3
2
|
export { addTransactionMetadata } from "./metadata.js";
|
|
4
3
|
export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./previewVaultV2ForceWithdraw.js";
|
|
5
4
|
export { type PreviewVaultV2InKindRedeemParams, previewVaultV2InKindRedeem, type VaultV2InKindRedeemMarketPreview, } from "./previewVaultV2InKindRedeem.js";
|
|
6
5
|
export { grossFromNetAssets } from "./referralFee.js";
|
|
7
6
|
export { signAndVerifyTypedData } from "./signAndVerifyTypedData.js";
|
|
8
|
-
export {
|
|
9
|
-
export { validateAccrualPosition, validateChainId, validateMidnightMarketChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw,
|
|
7
|
+
export { computeMinForceWithdrawSharePrice, computeVaultMaxShareAllowance, computeVaultMaxSharePrice, } from "./slippage.js";
|
|
8
|
+
export { validateAccrualPosition, validateChainId, validateMidnightMarketChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, validateWithdrawAmount, validateWithdrawShares, } from "./validate.js";
|
|
10
9
|
export { validateOfferSides } from "./validateOfferSides.js";
|
|
11
10
|
export { type RequirementSpenderKey, validateRequirementSpender, } from "./validateRequirementSpender.js";
|
|
12
11
|
export { computeVaultV2ForceWithdrawFeeSharesMinted, computeVaultV2ForceWithdrawMinSharesBurnt, computeVaultV2ForceWithdrawPlan, computeVaultV2ForceWithdrawSharesBurnt, resolveVaultV2ForceWithdrawEligibility, type VaultV2ForceWithdrawEligibility, type VaultV2ForceWithdrawPlan, } from "./vaultV2ForceWithdrawPlan.js";
|
package/lib/esm/helpers/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
export { computeReallocations, computeVaultV1Reallocations, } from "./computeVaultV1Reallocations.js";
|
|
2
1
|
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 "./constant.js";
|
|
3
2
|
export { addTransactionMetadata } from "./metadata.js";
|
|
4
3
|
export { previewVaultV2ForceWithdraw, } from "./previewVaultV2ForceWithdraw.js";
|
|
5
4
|
export { previewVaultV2InKindRedeem, } from "./previewVaultV2InKindRedeem.js";
|
|
6
5
|
export { grossFromNetAssets } from "./referralFee.js";
|
|
7
6
|
export { signAndVerifyTypedData } from "./signAndVerifyTypedData.js";
|
|
8
|
-
export {
|
|
9
|
-
export { validateAccrualPosition, validateChainId, validateMidnightMarketChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw,
|
|
7
|
+
export { computeMinForceWithdrawSharePrice, computeVaultMaxShareAllowance, computeVaultMaxSharePrice, } from "./slippage.js";
|
|
8
|
+
export { validateAccrualPosition, validateChainId, validateMidnightMarketChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, validateWithdrawAmount, validateWithdrawShares, } from "./validate.js";
|
|
10
9
|
export { validateOfferSides } from "./validateOfferSides.js";
|
|
11
10
|
export { validateRequirementSpender, } from "./validateRequirementSpender.js";
|
|
12
11
|
export { computeVaultV2ForceWithdrawFeeSharesMinted, computeVaultV2ForceWithdrawMinSharesBurnt, computeVaultV2ForceWithdrawPlan, computeVaultV2ForceWithdrawSharesBurnt, resolveVaultV2ForceWithdrawEligibility, } from "./vaultV2ForceWithdrawPlan.js";
|
|
@@ -1,72 +1,4 @@
|
|
|
1
|
-
import { type AccrualVault, AccrualVaultV2
|
|
2
|
-
/**
|
|
3
|
-
* Computes the minimum borrow share price (in RAY, 1e27) for slippage protection.
|
|
4
|
-
*
|
|
5
|
-
* Mirrors the on-chain check in GeneralAdapter1's `morphoBorrow`:
|
|
6
|
-
* ```solidity
|
|
7
|
-
* require(borrowedAssets.rDivDown(borrowedShares) >= minSharePriceE27)
|
|
8
|
-
* ```
|
|
9
|
-
*
|
|
10
|
-
* @param params - Computation parameters.
|
|
11
|
-
* @param params.borrowAmount - The amount of assets to borrow.
|
|
12
|
-
* @param params.market - The market to compute the minimum borrow share price for.
|
|
13
|
-
* @param params.slippageTolerance - Slippage tolerance in WAD (e.g. 0.003e18 = 0.3%).
|
|
14
|
-
* @returns minSharePriceE27 in RAY scale (1e27).
|
|
15
|
-
*/
|
|
16
|
-
export declare function computeMinBorrowSharePrice(params: {
|
|
17
|
-
borrowAmount: bigint;
|
|
18
|
-
market: Market;
|
|
19
|
-
slippageTolerance: bigint;
|
|
20
|
-
}): bigint;
|
|
21
|
-
/**
|
|
22
|
-
* Computes the maximum repay share price (in RAY, 1e27) for slippage protection.
|
|
23
|
-
*
|
|
24
|
-
* Supports both repay-by-assets and repay-by-shares paths:
|
|
25
|
-
* - By assets: derives expected shares from the repay amount via `toBorrowShares("Down")`.
|
|
26
|
-
* - By shares: derives expected assets from the shares via `toBorrowAssets("Up")`.
|
|
27
|
-
*
|
|
28
|
-
* Direction is opposite of borrow's `minSharePrice`:
|
|
29
|
-
* - Borrow uses `(WAD - slippage)` → lower bound (protects borrower from getting fewer assets per share).
|
|
30
|
-
* - Repay uses `(WAD + slippage)` → upper bound (protects repayer from paying too many assets per share).
|
|
31
|
-
*
|
|
32
|
-
* Capped at {@link MAX_ABSOLUTE_SHARE_PRICE} to prevent absurd values.
|
|
33
|
-
*
|
|
34
|
-
* @param params - Computation parameters.
|
|
35
|
-
* @param params.repayAssets - The amount of assets to repay (0n when repaying by shares).
|
|
36
|
-
* @param params.repayShares - The amount of shares to repay (0n when repaying by assets).
|
|
37
|
-
* @param params.market - The market to compute the maximum repay share price for.
|
|
38
|
-
* @param params.slippageTolerance - Slippage tolerance in WAD (e.g. 0.003e18 = 0.3%).
|
|
39
|
-
* @returns maxSharePriceE27 in RAY scale (1e27).
|
|
40
|
-
*/
|
|
41
|
-
export declare function computeMaxRepaySharePrice(params: {
|
|
42
|
-
repayAssets: bigint;
|
|
43
|
-
repayShares: bigint;
|
|
44
|
-
market: Market;
|
|
45
|
-
slippageTolerance: bigint;
|
|
46
|
-
}): bigint;
|
|
47
|
-
/**
|
|
48
|
-
* Computes the maximum supply share price (in RAY, 1e27) for slippage protection.
|
|
49
|
-
*
|
|
50
|
-
* Mirrors the on-chain check in GeneralAdapter1's `morphoSupply`:
|
|
51
|
-
* ```solidity
|
|
52
|
-
* require(suppliedAssets.rDivUp(suppliedShares) <= maxSharePriceE27)
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* Caps at {@link MAX_ABSOLUTE_SHARE_PRICE} to prevent absurd values on extreme markets.
|
|
56
|
-
*
|
|
57
|
-
* @param params - Computation parameters.
|
|
58
|
-
* @param params.supplyAssets - The amount of loan assets to supply.
|
|
59
|
-
* @param params.market - The market to compute the maximum supply share price for.
|
|
60
|
-
* @param params.slippageTolerance - Slippage tolerance in WAD (e.g. `0.003e18` = 0.3%).
|
|
61
|
-
* @returns `maxSharePriceE27` in RAY scale (1e27).
|
|
62
|
-
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance >= WAD`.
|
|
63
|
-
* @throws {ShareDivideByZeroError} when expected shares round down to zero.
|
|
64
|
-
*/
|
|
65
|
-
export declare function computeMaxSupplySharePrice(params: {
|
|
66
|
-
supplyAssets: bigint;
|
|
67
|
-
market: Market;
|
|
68
|
-
slippageTolerance: bigint;
|
|
69
|
-
}): bigint;
|
|
1
|
+
import { type AccrualVault, AccrualVaultV2 } from "@morpho-org/blue-sdk";
|
|
70
2
|
/**
|
|
71
3
|
* Computes the minimum Vault V2 force-withdraw share price (in RAY, 1e27) for slippage protection.
|
|
72
4
|
*
|
|
@@ -113,40 +45,6 @@ export declare function computeMinForceWithdrawSharePrice(params: {
|
|
|
113
45
|
readonly sharesBurnt: bigint;
|
|
114
46
|
readonly slippageTolerance: bigint;
|
|
115
47
|
}): bigint;
|
|
116
|
-
/**
|
|
117
|
-
* Computes the minimum withdraw share price (in RAY, 1e27) for slippage protection.
|
|
118
|
-
*
|
|
119
|
-
* Mirrors the on-chain check in GeneralAdapter1's `morphoWithdraw`:
|
|
120
|
-
* ```solidity
|
|
121
|
-
* require(withdrawnAssets.rDivDown(withdrawnShares) >= minSharePriceE27)
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* Supports both assets and shares modes:
|
|
125
|
-
* - By assets: derives expected shares via `toSupplyShares("Up")` (upper bound, protects the
|
|
126
|
-
* withdrawer against over-burning shares).
|
|
127
|
-
* - By shares: derives expected assets via `toSupplyAssets("Down")` (lower bound, the on-chain
|
|
128
|
-
* amount paid out).
|
|
129
|
-
*
|
|
130
|
-
* Direction is opposite of supply's `maxSharePrice`:
|
|
131
|
-
* - Supply uses `(WAD + slippage)` → upper bound (anti-inflation).
|
|
132
|
-
* - Withdraw uses `(WAD − slippage)` → lower bound (protects withdrawer from receiving too few
|
|
133
|
-
* assets per share burned).
|
|
134
|
-
*
|
|
135
|
-
* @param params - Computation parameters.
|
|
136
|
-
* @param params.withdrawAssets - The amount of assets to withdraw (`0n` when withdrawing by shares).
|
|
137
|
-
* @param params.withdrawShares - The amount of shares to withdraw (`0n` when withdrawing by assets).
|
|
138
|
-
* @param params.market - The market to compute the minimum withdraw share price for.
|
|
139
|
-
* @param params.slippageTolerance - Slippage tolerance in WAD (e.g. `0.003e18` = 0.3%).
|
|
140
|
-
* @returns `minSharePriceE27` in RAY scale (1e27).
|
|
141
|
-
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance >= WAD`.
|
|
142
|
-
* @throws {ShareDivideByZeroError} when expected shares round down to zero.
|
|
143
|
-
*/
|
|
144
|
-
export declare function computeMinWithdrawSharePrice(params: {
|
|
145
|
-
withdrawAssets: bigint;
|
|
146
|
-
withdrawShares: bigint;
|
|
147
|
-
market: Market;
|
|
148
|
-
slippageTolerance: bigint;
|
|
149
|
-
}): bigint;
|
|
150
48
|
/**
|
|
151
49
|
* Computes the RAY-scaled maximum share price for a VaultBundlesV1 deposit leg.
|
|
152
50
|
*
|