@morpho-org/morpho-sdk 10.1.0-next.0 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +1 -5
- package/lib/cjs/actions/blue/borrow.d.ts +13 -4
- package/lib/cjs/actions/blue/borrow.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/borrow.internal.js +36 -0
- package/lib/cjs/actions/blue/borrow.js +12 -18
- package/lib/cjs/actions/blue/common.d.ts +53 -28
- package/lib/cjs/actions/blue/common.js +36 -35
- package/lib/cjs/actions/blue/encode.d.ts +23 -0
- package/lib/cjs/actions/blue/encode.js +171 -0
- package/lib/cjs/actions/blue/refinance.d.ts +14 -5
- package/lib/cjs/actions/blue/refinance.internal.d.ts +42 -0
- package/lib/cjs/actions/blue/refinance.internal.js +65 -0
- package/lib/cjs/actions/blue/refinance.js +13 -65
- package/lib/cjs/actions/blue/refinanceValidation.d.ts +6 -6
- package/lib/cjs/actions/blue/refinanceValidation.js +10 -8
- package/lib/cjs/actions/blue/repay.d.ts +5 -4
- package/lib/cjs/actions/blue/repay.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/repay.internal.js +38 -0
- package/lib/cjs/actions/blue/repay.js +5 -19
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +6 -5
- package/lib/cjs/actions/blue/repayWithdrawCollateral.internal.d.ts +61 -0
- package/lib/cjs/actions/blue/repayWithdrawCollateral.internal.js +112 -0
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +6 -118
- package/lib/cjs/actions/blue/signatures.d.ts +30 -0
- package/lib/cjs/actions/blue/signatures.js +90 -0
- package/lib/cjs/actions/blue/supply.d.ts +6 -4
- package/lib/cjs/actions/blue/supply.internal.d.ts +32 -0
- package/lib/cjs/actions/blue/supply.internal.js +101 -0
- package/lib/cjs/actions/blue/supply.js +6 -69
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +5 -4
- package/lib/cjs/actions/blue/supplyCollateral.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/supplyCollateral.internal.js +37 -0
- package/lib/cjs/actions/blue/supplyCollateral.js +5 -19
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +15 -6
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.d.ts +65 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.js +98 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +13 -108
- package/lib/cjs/actions/blue/withdraw.d.ts +15 -6
- package/lib/cjs/actions/blue/withdraw.internal.d.ts +56 -0
- package/lib/cjs/actions/blue/withdraw.internal.js +87 -0
- package/lib/cjs/actions/blue/withdraw.js +13 -80
- package/lib/cjs/actions/blue/withdrawBuyCallback.d.ts +2 -2
- package/lib/cjs/actions/blue/withdrawBuyCallback.internal.d.ts +20 -0
- package/lib/cjs/actions/blue/withdrawBuyCallback.internal.js +58 -0
- package/lib/cjs/actions/blue/withdrawBuyCallback.js +2 -39
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +4 -3
- package/lib/cjs/actions/blue/withdrawCollateral.internal.d.ts +16 -0
- package/lib/cjs/actions/blue/withdrawCollateral.internal.js +39 -0
- package/lib/cjs/actions/blue/withdrawCollateral.js +5 -19
- package/lib/cjs/actions/bundles/common.d.ts +9 -0
- package/lib/cjs/actions/bundles/common.js +18 -6
- package/lib/cjs/actions/bundles/index.d.ts +1 -1
- package/lib/cjs/actions/bundles/index.js +3 -16
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +14 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +59 -60
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +22 -1
- package/lib/cjs/actions/midnight/cancelAndMake.js +46 -87
- package/lib/cjs/actions/midnight/cancelOffers.d.ts +11 -0
- package/lib/cjs/actions/midnight/cancelOffers.js +22 -4
- package/lib/cjs/actions/midnight/encode.d.ts +36 -0
- package/lib/cjs/actions/midnight/encode.js +554 -0
- package/lib/cjs/actions/midnight/index.d.ts +14 -13
- package/lib/cjs/actions/midnight/index.js +29 -13
- package/lib/cjs/actions/midnight/parse.d.ts +35 -0
- package/lib/cjs/actions/midnight/parse.js +73 -0
- package/lib/cjs/actions/midnight/parseCollateralBatch.d.ts +58 -0
- package/lib/cjs/actions/midnight/parseCollateralBatch.js +216 -0
- package/lib/cjs/actions/midnight/redeem.d.ts +16 -3
- package/lib/cjs/actions/midnight/redeem.js +22 -51
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +13 -0
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +42 -67
- package/lib/cjs/actions/midnight/supplyCollateral.d.ts +40 -5
- package/lib/cjs/actions/midnight/supplyCollateral.js +60 -54
- package/lib/cjs/actions/midnight/supplyCollateralBatch.d.ts +3 -3
- package/lib/cjs/actions/midnight/supplyCollateralBatch.js +3 -62
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +24 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +39 -67
- package/lib/cjs/actions/midnight/supplyCollateralWithNative.d.ts +77 -0
- package/lib/cjs/actions/midnight/supplyCollateralWithNative.js +142 -0
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +17 -2
- package/lib/cjs/actions/midnight/takeBorrow.js +25 -56
- package/lib/cjs/actions/midnight/takeLend.d.ts +21 -1
- package/lib/cjs/actions/midnight/takeLend.js +30 -58
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +34 -62
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +17 -2
- package/lib/cjs/actions/midnight/takeWithdraw.js +77 -115
- package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +16 -3
- package/lib/cjs/actions/midnight/withdrawCollateral.js +25 -56
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.d.ts +3 -3
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +3 -71
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +13 -0
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +39 -19
- package/lib/cjs/actions/requirements/blue/index.d.ts +1 -1
- package/lib/cjs/actions/requirements/blue/index.js +3 -15
- package/lib/cjs/actions/requirements/chainCheck.d.ts +5 -0
- package/lib/cjs/actions/requirements/chainCheck.js +10 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +40 -27
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +11 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +36 -17
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +14 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +44 -9
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +10 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +61 -24
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +10 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +25 -4
- package/lib/cjs/actions/requirements/encode/index.d.ts +5 -5
- package/lib/cjs/actions/requirements/encode/index.js +11 -19
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +26 -11
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +40 -12
- package/lib/cjs/actions/requirements/index.d.ts +1 -1
- package/lib/cjs/actions/requirements/index.js +3 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +11 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +34 -19
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +26 -12
- package/lib/cjs/actions/requirements/midnight/index.d.ts +2 -2
- package/lib/cjs/actions/requirements/midnight/index.js +5 -16
- package/lib/cjs/actions/vaultV1/deposit.d.ts +23 -1
- package/lib/cjs/actions/vaultV1/deposit.js +48 -11
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +18 -1
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +36 -16
- package/lib/cjs/actions/vaultV1/index.d.ts +5 -5
- package/lib/cjs/actions/vaultV1/index.js +11 -19
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +24 -2
- package/lib/cjs/actions/vaultV1/migrateToV2.js +51 -12
- package/lib/cjs/actions/vaultV1/redeem.d.ts +22 -2
- package/lib/cjs/actions/vaultV1/redeem.js +30 -8
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +21 -1
- package/lib/cjs/actions/vaultV1/withdraw.js +30 -8
- package/lib/cjs/actions/vaultV2/deposit.d.ts +23 -1
- package/lib/cjs/actions/vaultV2/deposit.js +48 -11
- package/lib/cjs/actions/vaultV2/forceRedeem.d.ts +20 -2
- package/lib/cjs/actions/vaultV2/forceRedeem.js +39 -8
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +25 -2
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +38 -15
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +18 -1
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +35 -15
- package/lib/cjs/actions/vaultV2/index.d.ts +6 -6
- package/lib/cjs/actions/vaultV2/index.js +13 -20
- package/lib/cjs/actions/vaultV2/redeem.d.ts +22 -2
- package/lib/cjs/actions/vaultV2/redeem.js +30 -8
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +21 -1
- package/lib/cjs/actions/vaultV2/withdraw.js +30 -8
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +1 -5
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +1 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +1 -2
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +2 -0
- package/lib/cjs/entities/blue/blue.d.ts +118 -28
- package/lib/cjs/entities/blue/blue.js +503 -416
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/midnight.d.ts +117 -41
- package/lib/cjs/entities/midnight/midnight.js +472 -843
- package/lib/cjs/entities/midnight/parse.d.ts +74 -0
- package/lib/cjs/entities/midnight/parse.js +336 -0
- package/lib/cjs/entities/midnight/prepare.d.ts +47 -0
- package/lib/cjs/entities/midnight/prepare.js +293 -0
- package/lib/cjs/entities/midnight/publication.d.ts +7 -3
- package/lib/cjs/entities/midnight/publication.js +10 -7
- package/lib/cjs/entities/midnight/types.d.ts +7 -0
- package/lib/cjs/entities/requirements/assertContractCode.d.ts +10 -5
- package/lib/cjs/entities/requirements/assertContractCode.js +24 -15
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +15 -0
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +59 -51
- package/lib/cjs/entities/requirements/getErc2612Permit.d.ts +7 -3
- package/lib/cjs/entities/requirements/getErc2612Permit.js +20 -4
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +15 -0
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +24 -7
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +14 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +27 -7
- package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.js +4 -3
- package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.js +4 -3
- package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.js +4 -3
- package/lib/cjs/entities/requirements/index.d.ts +2 -2
- package/lib/cjs/entities/requirements/index.js +5 -16
- package/lib/cjs/entities/requirements/validateNativeRequirements.d.ts +21 -0
- package/lib/cjs/entities/requirements/validateNativeRequirements.js +37 -0
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.d.ts +2 -2
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.js +1 -7
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +5 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +29 -46
- package/lib/cjs/entities/vaultV1/vaultV1.js +234 -159
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.d.ts +4 -0
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.js +9 -4
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.d.ts +2 -2
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.js +1 -7
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +40 -92
- package/lib/cjs/entities/vaultV2/vaultV2.js +230 -188
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +13 -5
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +21 -27
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +5 -7
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- package/lib/cjs/helpers/constant.d.ts +2 -0
- package/lib/cjs/helpers/constant.js +3 -1
- package/lib/cjs/helpers/deadShares.js +0 -3
- package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
- package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.js +18 -0
- package/lib/cjs/helpers/index.d.ts +1 -1
- package/lib/cjs/helpers/index.js +2 -1
- package/lib/cjs/helpers/parse.d.ts +33 -0
- package/lib/cjs/helpers/parse.js +71 -0
- package/lib/cjs/helpers/parseMidnight.d.ts +48 -0
- package/lib/cjs/helpers/parseMidnight.js +95 -0
- package/lib/cjs/helpers/parseMidnightMaker.d.ts +44 -0
- package/lib/cjs/helpers/parseMidnightMaker.js +154 -0
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +4 -5
- package/lib/cjs/helpers/quoteBlueRepay.d.ts +7 -3
- package/lib/cjs/helpers/quoteBlueRepay.js +20 -7
- package/lib/cjs/helpers/reallocationPenalty.d.ts +10 -0
- package/lib/cjs/helpers/reallocationPenalty.js +32 -0
- package/lib/cjs/helpers/referralFee.d.ts +2 -1
- package/lib/cjs/helpers/referralFee.js +5 -1
- package/lib/cjs/helpers/validate.d.ts +34 -6
- package/lib/cjs/helpers/validate.js +52 -9
- package/lib/cjs/helpers/validateMidnightBounds.d.ts +1 -2
- package/lib/cjs/helpers/validateMidnightBounds.js +1 -2
- package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.d.ts +8 -0
- package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.js +4 -4
- package/lib/cjs/helpers/validateMidnightPublication.d.ts +17 -1
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +1 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +4 -5
- package/lib/cjs/transactionPlan/blue/borrow.d.ts +11 -5
- package/lib/cjs/transactionPlan/blue/borrow.js +26 -8
- package/lib/cjs/transactionPlan/blue/refinance.d.ts +9 -2
- package/lib/cjs/transactionPlan/blue/refinance.js +36 -11
- package/lib/cjs/transactionPlan/blue/repay.d.ts +1 -2
- package/lib/cjs/transactionPlan/blue/repay.js +3 -3
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +35 -7
- package/lib/cjs/transactionPlan/blue/supply.d.ts +1 -2
- package/lib/cjs/transactionPlan/blue/supply.js +1 -2
- package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +2 -3
- package/lib/cjs/transactionPlan/blue/supplyCollateral.js +2 -3
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +25 -8
- package/lib/cjs/transactionPlan/blue/withdraw.d.ts +17 -7
- package/lib/cjs/transactionPlan/blue/withdraw.js +28 -9
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +17 -9
- package/lib/cjs/transactionPlan/deposit.js +4 -0
- package/lib/cjs/transactionPlan/intent.d.ts +1 -1
- package/lib/cjs/transactionPlan/intent.js +4 -2
- package/lib/cjs/transactionPlan/plan.d.ts +8 -4
- package/lib/cjs/transactionPlan/plan.js +8 -4
- package/lib/cjs/transactionPlan/types.d.ts +6 -0
- package/lib/cjs/transactionPlan/validation.d.ts +1 -1
- package/lib/cjs/transactionPlan/validation.js +3 -0
- package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +5 -5
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +5 -5
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +7 -3
- package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +1 -2
- package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -2
- package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -3
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +3 -3
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +3 -3
- package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -3
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -3
- package/lib/cjs/types/action.d.ts +13 -2
- package/lib/cjs/types/error.d.ts +27 -8
- package/lib/cjs/types/error.js +42 -12
- package/lib/cjs/types/sharedLiquidity.d.ts +7 -2
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +2 -4
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/blue/borrow.d.ts +13 -4
- package/lib/esm/actions/blue/borrow.internal.d.ts +13 -0
- package/lib/esm/actions/blue/borrow.internal.js +31 -0
- package/lib/esm/actions/blue/borrow.js +12 -18
- package/lib/esm/actions/blue/common.d.ts +53 -28
- package/lib/esm/actions/blue/common.js +36 -34
- package/lib/esm/actions/blue/encode.d.ts +23 -0
- package/lib/esm/actions/blue/encode.js +164 -0
- package/lib/esm/actions/blue/refinance.d.ts +14 -5
- package/lib/esm/actions/blue/refinance.internal.d.ts +42 -0
- package/lib/esm/actions/blue/refinance.internal.js +59 -0
- package/lib/esm/actions/blue/refinance.js +13 -65
- package/lib/esm/actions/blue/refinanceValidation.d.ts +6 -6
- package/lib/esm/actions/blue/refinanceValidation.js +11 -9
- package/lib/esm/actions/blue/repay.d.ts +5 -4
- package/lib/esm/actions/blue/repay.internal.d.ts +13 -0
- package/lib/esm/actions/blue/repay.internal.js +33 -0
- package/lib/esm/actions/blue/repay.js +5 -19
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +6 -5
- package/lib/esm/actions/blue/repayWithdrawCollateral.internal.d.ts +61 -0
- package/lib/esm/actions/blue/repayWithdrawCollateral.internal.js +104 -0
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +6 -118
- package/lib/esm/actions/blue/signatures.d.ts +30 -0
- package/lib/esm/actions/blue/signatures.js +82 -0
- package/lib/esm/actions/blue/supply.d.ts +6 -4
- package/lib/esm/actions/blue/supply.internal.d.ts +32 -0
- package/lib/esm/actions/blue/supply.internal.js +95 -0
- package/lib/esm/actions/blue/supply.js +6 -69
- package/lib/esm/actions/blue/supplyCollateral.d.ts +5 -4
- package/lib/esm/actions/blue/supplyCollateral.internal.d.ts +13 -0
- package/lib/esm/actions/blue/supplyCollateral.internal.js +32 -0
- package/lib/esm/actions/blue/supplyCollateral.js +5 -19
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +15 -6
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.d.ts +65 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.js +91 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +13 -108
- package/lib/esm/actions/blue/withdraw.d.ts +15 -6
- package/lib/esm/actions/blue/withdraw.internal.d.ts +56 -0
- package/lib/esm/actions/blue/withdraw.internal.js +80 -0
- package/lib/esm/actions/blue/withdraw.js +13 -80
- package/lib/esm/actions/blue/withdrawBuyCallback.d.ts +2 -2
- package/lib/esm/actions/blue/withdrawBuyCallback.internal.d.ts +20 -0
- package/lib/esm/actions/blue/withdrawBuyCallback.internal.js +53 -0
- package/lib/esm/actions/blue/withdrawBuyCallback.js +2 -39
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +4 -3
- package/lib/esm/actions/blue/withdrawCollateral.internal.d.ts +16 -0
- package/lib/esm/actions/blue/withdrawCollateral.internal.js +34 -0
- package/lib/esm/actions/blue/withdrawCollateral.js +5 -19
- package/lib/esm/actions/bundles/common.d.ts +9 -0
- package/lib/esm/actions/bundles/common.js +15 -4
- package/lib/esm/actions/bundles/index.d.ts +1 -1
- package/lib/esm/actions/bundles/index.js +1 -1
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +14 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +58 -61
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +22 -1
- package/lib/esm/actions/midnight/cancelAndMake.js +43 -85
- package/lib/esm/actions/midnight/cancelOffers.d.ts +11 -0
- package/lib/esm/actions/midnight/cancelOffers.js +18 -2
- package/lib/esm/actions/midnight/encode.d.ts +36 -0
- package/lib/esm/actions/midnight/encode.js +539 -0
- package/lib/esm/actions/midnight/index.d.ts +14 -13
- package/lib/esm/actions/midnight/index.js +14 -13
- package/lib/esm/actions/midnight/parse.d.ts +35 -0
- package/lib/esm/actions/midnight/parse.js +68 -0
- package/lib/esm/actions/midnight/parseCollateralBatch.d.ts +58 -0
- package/lib/esm/actions/midnight/parseCollateralBatch.js +209 -0
- package/lib/esm/actions/midnight/redeem.d.ts +16 -3
- package/lib/esm/actions/midnight/redeem.js +20 -50
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +13 -0
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +38 -64
- package/lib/esm/actions/midnight/supplyCollateral.d.ts +40 -5
- package/lib/esm/actions/midnight/supplyCollateral.js +57 -53
- package/lib/esm/actions/midnight/supplyCollateralBatch.d.ts +3 -3
- package/lib/esm/actions/midnight/supplyCollateralBatch.js +3 -62
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +24 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +34 -63
- package/lib/esm/actions/midnight/supplyCollateralWithNative.d.ts +77 -0
- package/lib/esm/actions/midnight/supplyCollateralWithNative.js +137 -0
- package/lib/esm/actions/midnight/takeBorrow.d.ts +17 -2
- package/lib/esm/actions/midnight/takeBorrow.js +21 -53
- package/lib/esm/actions/midnight/takeLend.d.ts +21 -1
- package/lib/esm/actions/midnight/takeLend.js +27 -56
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +31 -60
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +17 -2
- package/lib/esm/actions/midnight/takeWithdraw.js +76 -115
- package/lib/esm/actions/midnight/withdrawCollateral.d.ts +16 -3
- package/lib/esm/actions/midnight/withdrawCollateral.js +23 -55
- package/lib/esm/actions/midnight/withdrawCollateralBatch.d.ts +3 -3
- package/lib/esm/actions/midnight/withdrawCollateralBatch.js +3 -71
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +13 -0
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +36 -18
- package/lib/esm/actions/requirements/blue/index.d.ts +1 -1
- package/lib/esm/actions/requirements/blue/index.js +1 -1
- package/lib/esm/actions/requirements/chainCheck.d.ts +5 -0
- package/lib/esm/actions/requirements/chainCheck.js +6 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +36 -25
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +11 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +33 -16
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +14 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +41 -8
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +10 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +59 -24
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +10 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +21 -2
- package/lib/esm/actions/requirements/encode/index.d.ts +5 -5
- package/lib/esm/actions/requirements/encode/index.js +5 -5
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +26 -11
- package/lib/esm/actions/requirements/getRequirementsApproval.js +38 -12
- package/lib/esm/actions/requirements/index.d.ts +1 -1
- package/lib/esm/actions/requirements/index.js +1 -1
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +11 -0
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +31 -18
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -0
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +22 -10
- package/lib/esm/actions/requirements/midnight/index.d.ts +2 -2
- package/lib/esm/actions/requirements/midnight/index.js +2 -2
- package/lib/esm/actions/vaultV1/deposit.d.ts +23 -1
- package/lib/esm/actions/vaultV1/deposit.js +45 -10
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +18 -1
- package/lib/esm/actions/vaultV1/inKindRedeem.js +33 -15
- package/lib/esm/actions/vaultV1/index.d.ts +5 -5
- package/lib/esm/actions/vaultV1/index.js +5 -5
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +24 -2
- package/lib/esm/actions/vaultV1/migrateToV2.js +49 -12
- package/lib/esm/actions/vaultV1/redeem.d.ts +22 -2
- package/lib/esm/actions/vaultV1/redeem.js +28 -8
- package/lib/esm/actions/vaultV1/withdraw.d.ts +21 -1
- package/lib/esm/actions/vaultV1/withdraw.js +28 -8
- package/lib/esm/actions/vaultV2/deposit.d.ts +23 -1
- package/lib/esm/actions/vaultV2/deposit.js +45 -10
- package/lib/esm/actions/vaultV2/forceRedeem.d.ts +20 -2
- package/lib/esm/actions/vaultV2/forceRedeem.js +35 -6
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +25 -2
- package/lib/esm/actions/vaultV2/forceWithdraw.js +35 -14
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +18 -1
- package/lib/esm/actions/vaultV2/inKindRedeem.js +32 -14
- package/lib/esm/actions/vaultV2/index.d.ts +6 -6
- package/lib/esm/actions/vaultV2/index.js +6 -6
- package/lib/esm/actions/vaultV2/redeem.d.ts +22 -2
- package/lib/esm/actions/vaultV2/redeem.js +28 -8
- package/lib/esm/actions/vaultV2/withdraw.d.ts +21 -1
- package/lib/esm/actions/vaultV2/withdraw.js +28 -8
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +118 -28
- package/lib/esm/entities/blue/blue.js +485 -398
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +117 -41
- package/lib/esm/entities/midnight/midnight.js +455 -826
- package/lib/esm/entities/midnight/parse.d.ts +74 -0
- package/lib/esm/entities/midnight/parse.js +320 -0
- package/lib/esm/entities/midnight/prepare.d.ts +47 -0
- package/lib/esm/entities/midnight/prepare.js +282 -0
- package/lib/esm/entities/midnight/publication.d.ts +7 -3
- package/lib/esm/entities/midnight/publication.js +7 -3
- package/lib/esm/entities/midnight/types.d.ts +7 -0
- package/lib/esm/entities/requirements/assertContractCode.d.ts +10 -5
- package/lib/esm/entities/requirements/assertContractCode.js +24 -15
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +15 -0
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +53 -47
- package/lib/esm/entities/requirements/getErc2612Permit.d.ts +7 -3
- package/lib/esm/entities/requirements/getErc2612Permit.js +19 -4
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +15 -0
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +20 -5
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +14 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +23 -5
- package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.js +4 -3
- package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.js +4 -3
- package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.js +4 -3
- package/lib/esm/entities/requirements/index.d.ts +2 -2
- package/lib/esm/entities/requirements/index.js +2 -2
- package/lib/esm/entities/requirements/validateNativeRequirements.d.ts +21 -0
- package/lib/esm/entities/requirements/validateNativeRequirements.js +33 -0
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.d.ts +2 -2
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.js +1 -7
- package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
- package/lib/esm/entities/vaultV1/migrateToV2Quote.js +5 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +29 -46
- package/lib/esm/entities/vaultV1/vaultV1.js +214 -139
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.d.ts +4 -0
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.js +10 -5
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.d.ts +2 -2
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.js +1 -7
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +40 -92
- package/lib/esm/entities/vaultV2/vaultV2.js +214 -172
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +13 -5
- package/lib/esm/entities/vaultV2BlueReallocationData.js +19 -25
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/constant.d.ts +2 -0
- package/lib/esm/helpers/constant.js +2 -0
- package/lib/esm/helpers/deadShares.js +1 -4
- package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
- package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.js +15 -0
- package/lib/esm/helpers/index.d.ts +1 -1
- package/lib/esm/helpers/index.js +1 -1
- package/lib/esm/helpers/parse.d.ts +33 -0
- package/lib/esm/helpers/parse.js +61 -0
- package/lib/esm/helpers/parseMidnight.d.ts +48 -0
- package/lib/esm/helpers/parseMidnight.js +80 -0
- package/lib/esm/helpers/parseMidnightMaker.d.ts +44 -0
- package/lib/esm/helpers/parseMidnightMaker.js +147 -0
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +4 -5
- package/lib/esm/helpers/quoteBlueRepay.d.ts +7 -3
- package/lib/esm/helpers/quoteBlueRepay.js +21 -8
- package/lib/esm/helpers/reallocationPenalty.d.ts +10 -0
- package/lib/esm/helpers/reallocationPenalty.js +28 -0
- package/lib/esm/helpers/referralFee.d.ts +2 -1
- package/lib/esm/helpers/referralFee.js +5 -1
- package/lib/esm/helpers/validate.d.ts +34 -6
- package/lib/esm/helpers/validate.js +52 -11
- package/lib/esm/helpers/validateMidnightBounds.d.ts +1 -2
- package/lib/esm/helpers/validateMidnightBounds.js +1 -2
- package/lib/esm/helpers/validateMidnightCancelAndMakePublication.d.ts +8 -0
- package/lib/esm/helpers/validateMidnightCancelAndMakePublication.js +2 -2
- package/lib/esm/helpers/validateMidnightPublication.d.ts +17 -1
- package/lib/esm/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
- package/lib/esm/helpers/validateMidnightTakeFeasibility.js +1 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/midnight/errors.d.ts +1 -2
- package/lib/esm/midnight/errors.js +1 -2
- package/lib/esm/transactionPlan/blue/borrow.d.ts +11 -5
- package/lib/esm/transactionPlan/blue/borrow.js +27 -9
- package/lib/esm/transactionPlan/blue/refinance.d.ts +9 -2
- package/lib/esm/transactionPlan/blue/refinance.js +37 -12
- package/lib/esm/transactionPlan/blue/repay.d.ts +1 -2
- package/lib/esm/transactionPlan/blue/repay.js +4 -4
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +36 -8
- package/lib/esm/transactionPlan/blue/supply.d.ts +1 -2
- package/lib/esm/transactionPlan/blue/supply.js +1 -2
- package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +2 -3
- package/lib/esm/transactionPlan/blue/supplyCollateral.js +2 -3
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +25 -8
- package/lib/esm/transactionPlan/blue/withdraw.d.ts +17 -7
- package/lib/esm/transactionPlan/blue/withdraw.js +28 -9
- package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
- package/lib/esm/transactionPlan/blue/withdrawCollateral.js +17 -9
- package/lib/esm/transactionPlan/deposit.js +5 -1
- package/lib/esm/transactionPlan/intent.d.ts +1 -1
- package/lib/esm/transactionPlan/intent.js +4 -2
- package/lib/esm/transactionPlan/plan.d.ts +8 -4
- package/lib/esm/transactionPlan/plan.js +8 -4
- package/lib/esm/transactionPlan/types.d.ts +6 -0
- package/lib/esm/transactionPlan/validation.d.ts +1 -1
- package/lib/esm/transactionPlan/validation.js +3 -0
- package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +5 -5
- package/lib/esm/transactionPlan/vaultv1/deposit.js +5 -5
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +8 -4
- package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +1 -2
- package/lib/esm/transactionPlan/vaultv1/redeem.js +1 -2
- package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv1/withdraw.js +2 -3
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -3
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +3 -3
- package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv2/redeem.js +2 -3
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +2 -3
- package/lib/esm/types/action.d.ts +13 -2
- package/lib/esm/types/error.d.ts +27 -8
- package/lib/esm/types/error.js +38 -10
- package/lib/esm/types/sharedLiquidity.d.ts +7 -2
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +7 -7
|
@@ -2,30 +2,27 @@ import { DEFAULT_SLIPPAGE_TOLERANCE, MarketParams, } from "@morpho-org/blue-sdk"
|
|
|
2
2
|
import { fetchAccrualVaultV2 } from "@morpho-org/blue-sdk-viem";
|
|
3
3
|
import { getChainAddress, Time, } from "@morpho-org/morpho-ts";
|
|
4
4
|
import { isAddressEqual } from "viem";
|
|
5
|
-
import { getBundlesReferralFeeAssets, normalizeBundlesCommonParams, resolveBundlesFunding, selectBundlesSharesPermitSignature, selectBundlesTokenRequirementSignature, } from "../../actions/bundles/common.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { getBundlesReferralFeeAssets, normalizeBundlesCommonParams as parseBundlesCommon, resolveBundlesFunding, selectBundlesSharesPermitSignature, selectBundlesTokenRequirementSignature, } from "../../actions/bundles/common.js";
|
|
6
|
+
import { createChainCheck, } from "../../actions/requirements/chainCheck.js";
|
|
7
|
+
import { buildVaultV2Deposit, } from "../../actions/vaultV2/deposit.js";
|
|
8
|
+
import { buildVaultV2ForceRedeem, parseVaultV2ForceRedeem, } from "../../actions/vaultV2/forceRedeem.js";
|
|
9
|
+
import { buildVaultV2ForceWithdraw, } from "../../actions/vaultV2/forceWithdraw.js";
|
|
10
|
+
import { buildVaultV2InKindRedeem, } from "../../actions/vaultV2/inKindRedeem.js";
|
|
11
|
+
import { buildVaultV2Redeem, } from "../../actions/vaultV2/redeem.js";
|
|
12
|
+
import { buildVaultV2Withdraw, } from "../../actions/vaultV2/withdraw.js";
|
|
8
13
|
import { computeVaultMaxShareAllowance, computeVaultMaxSharePrice, validateChainId, validateSlippageTolerance, } from "../../helpers/index.js";
|
|
9
14
|
import { resolveTransactionMetadata } from "../../helpers/metadata.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
15
|
+
import { parseUint256 } from "../../helpers/parse.js";
|
|
16
|
+
import { validateNativeVaultAsset, validateReferenceTime, validateVaultDepositDeadline, } from "../../helpers/validate.js";
|
|
17
|
+
import { ExpiredDeadlineError, NonPositiveInputError, VaultAddressMismatchError, } from "../../types/index.js";
|
|
12
18
|
import { assertRegistryTargetsHaveCode } from "../requirements/assertContractCode.js";
|
|
13
|
-
import {
|
|
19
|
+
import { getParsedBundlesTokenRequirements, parseGetBundlesTokenRequirements, } from "../requirements/getBundlesTokenRequirements.js";
|
|
20
|
+
import { getParsedVaultBundlesSharesRequirements, parseVaultBundlesSharesRequirements, } from "../requirements/getVaultBundlesSharesRequirements.js";
|
|
14
21
|
import { getVaultV2ForceWithdrawRequirements } from "../requirements/getVaultV2ForceWithdrawRequirements.js";
|
|
15
22
|
import { getVaultV2InKindRedeemRequirements } from "../requirements/getVaultV2InKindRedeemRequirements.js";
|
|
16
|
-
import {
|
|
23
|
+
import { validateNativeRequirements } from "../requirements/validateNativeRequirements.js";
|
|
17
24
|
import { computeVaultV2ForceWithdrawQuote } from "./forceWithdrawQuote.js";
|
|
18
25
|
import { computeVaultV2InKindRedeemQuote } from "./inKindRedeemQuote.js";
|
|
19
|
-
/**
|
|
20
|
-
* Midnight adapters revert vault-initiated `allocate` (`SelfAllocationOnly`), so a vault routing
|
|
21
|
-
* liquidity through one accepts no deposit. Exits are served from idle assets plus what the adapter's
|
|
22
|
-
* `withdrawToVault` path can withdraw from the liquidity market.
|
|
23
|
-
*/
|
|
24
|
-
const isMidnightLiquidityAdapter = (vaultData) => vaultData.accrualLiquidityAdapter?.type === "VaultV2MidnightAdapter";
|
|
25
|
-
/** Idle assets plus what the Midnight liquidity adapter can withdraw to the vault onchain. */
|
|
26
|
-
const midnightWithdrawLiquidity = (vaultData) => vaultData.assetBalance +
|
|
27
|
-
(vaultData.accrualLiquidityAdapter?.maxWithdraw(vaultData.liquidityData)
|
|
28
|
-
.value ?? 0n);
|
|
29
26
|
/** Binds a viem client to a Vault V2 vault's action builders. */
|
|
30
27
|
export class MorphoVaultV2 {
|
|
31
28
|
client;
|
|
@@ -38,7 +35,10 @@ export class MorphoVaultV2 {
|
|
|
38
35
|
this.chainId = chainId;
|
|
39
36
|
}
|
|
40
37
|
async getData(parameters) {
|
|
41
|
-
|
|
38
|
+
return this.getDataWithChainCheck(createChainCheck(this.client.viemClient, this.chainId), parameters);
|
|
39
|
+
}
|
|
40
|
+
async getDataWithChainCheck(chainCheck, parameters) {
|
|
41
|
+
await chainCheck();
|
|
42
42
|
return fetchAccrualVaultV2(this.vault, this.client.viemClient, {
|
|
43
43
|
...parameters,
|
|
44
44
|
deployless: this.client.options.supportDeployless,
|
|
@@ -52,16 +52,19 @@ export class MorphoVaultV2 {
|
|
|
52
52
|
*
|
|
53
53
|
* @param roles - Registry labels to resolve and check.
|
|
54
54
|
*/
|
|
55
|
-
async assertWriteTargets(roles) {
|
|
55
|
+
async assertWriteTargets(roles, chainCheck) {
|
|
56
56
|
const targets = [];
|
|
57
57
|
for (const role of roles) {
|
|
58
58
|
const address = getChainAddress(this.chainId, role);
|
|
59
59
|
targets.push({ role, address });
|
|
60
60
|
}
|
|
61
|
-
await assertRegistryTargetsHaveCode(this.client.viemClient, this.chainId, targets);
|
|
61
|
+
await assertRegistryTargetsHaveCode(this.client.viemClient, this.chainId, targets, chainCheck);
|
|
62
62
|
}
|
|
63
63
|
/** {@inheritDoc VaultV2Actions.deposit} */
|
|
64
64
|
deposit(params) {
|
|
65
|
+
return this.buildDeposit(this.parseDeposit(params));
|
|
66
|
+
}
|
|
67
|
+
parseDeposit(params) {
|
|
65
68
|
const suppliedNow = params.now;
|
|
66
69
|
const metadata = resolveTransactionMetadata(this.client.options.metadata, suppliedNow);
|
|
67
70
|
const { userAddress, vaultData } = params;
|
|
@@ -71,30 +74,26 @@ export class MorphoVaultV2 {
|
|
|
71
74
|
throw new VaultAddressMismatchError(this.vault, vaultData.address);
|
|
72
75
|
}
|
|
73
76
|
const createdAt = suppliedNow ?? Time.timestamp();
|
|
77
|
+
// Reject a non-bigint clock before deriving the default deadline.
|
|
78
|
+
validateReferenceTime(createdAt);
|
|
74
79
|
const deadline = params.deadline ?? createdAt + Time.s.from.h(2n);
|
|
75
80
|
if (deadline <= createdAt) {
|
|
76
81
|
throw new ExpiredDeadlineError(deadline, createdAt);
|
|
77
82
|
}
|
|
78
|
-
const common =
|
|
83
|
+
const common = parseBundlesCommon({
|
|
79
84
|
deadline,
|
|
80
85
|
referralFeePct: params.referralFeePct,
|
|
81
86
|
referralFeeRecipient: params.referralFeeRecipient,
|
|
82
87
|
});
|
|
83
88
|
const funding = resolveBundlesFunding(params);
|
|
84
|
-
// Reject
|
|
85
|
-
|
|
89
|
+
// Reject invalid funding before preparing a lazy handle.
|
|
90
|
+
parseUint256(funding.value > 0n ? "nativeAmount" : "amount", funding.assets);
|
|
86
91
|
if (funding.value > 0n) {
|
|
87
|
-
// The native path must target the chain's registered wrapped-native asset.
|
|
88
92
|
validateNativeVaultAsset(this.chainId, vaultAsset);
|
|
89
93
|
}
|
|
90
|
-
if (isMidnightLiquidityAdapter(vaultData)) {
|
|
91
|
-
throw new InputExceedsMaxError({
|
|
92
|
-
field: funding.value > 0n ? "nativeAmount" : "amount",
|
|
93
|
-
value: funding.assets,
|
|
94
|
-
max: 0n,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
94
|
const referralFeeAssets = getBundlesReferralFeeAssets(funding.assets, common.referralFeePct);
|
|
95
|
+
// Bound forward accrual before deriving the deposit price protection.
|
|
96
|
+
validateVaultDepositDeadline(deadline, { now: createdAt });
|
|
98
97
|
const maxSharePrice = computeVaultMaxSharePrice({
|
|
99
98
|
vaultData,
|
|
100
99
|
deadline,
|
|
@@ -102,35 +101,69 @@ export class MorphoVaultV2 {
|
|
|
102
101
|
slippageTolerance: params.slippageTolerance ?? DEFAULT_SLIPPAGE_TOLERANCE,
|
|
103
102
|
});
|
|
104
103
|
const spender = getChainAddress(this.chainId, "bundles.vaultBundlesV1");
|
|
104
|
+
if (maxSharePrice <= 0n) {
|
|
105
|
+
throw new NonPositiveInputError("maxSharePrice", maxSharePrice);
|
|
106
|
+
}
|
|
107
|
+
// Computed bounds also have to fit uint256.
|
|
108
|
+
parseUint256("maxSharePrice", maxSharePrice);
|
|
109
|
+
const parsed = {
|
|
110
|
+
vault: { chainId: this.chainId, address: this.vault, asset: vaultAsset },
|
|
111
|
+
userAddress,
|
|
112
|
+
funding,
|
|
113
|
+
maxSharePrice,
|
|
114
|
+
common,
|
|
115
|
+
metadata,
|
|
116
|
+
};
|
|
117
|
+
return {
|
|
118
|
+
suppliedNow,
|
|
119
|
+
parsed,
|
|
120
|
+
spender,
|
|
121
|
+
vaultAsset,
|
|
122
|
+
userAddress,
|
|
123
|
+
funding,
|
|
124
|
+
deadline,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
buildDeposit(input) {
|
|
128
|
+
const { parsed, spender, vaultAsset, userAddress, funding, deadline } = input;
|
|
105
129
|
let pendingRequirements;
|
|
106
130
|
return Object.freeze({
|
|
107
131
|
getRequirements: async (requirementOptions) => {
|
|
108
|
-
const now = suppliedNow ?? Time.timestamp();
|
|
132
|
+
const now = input.suppliedNow ?? Time.timestamp();
|
|
109
133
|
if (deadline <= now) {
|
|
110
134
|
throw new ExpiredDeadlineError(deadline, now);
|
|
111
135
|
}
|
|
136
|
+
const chainCheck = createChainCheck(this.client.viemClient, this.chainId);
|
|
137
|
+
if (funding.value > 0n) {
|
|
138
|
+
// Native funding skips the token resolver's chain validation.
|
|
139
|
+
await validateNativeRequirements(this.client.viemClient, {
|
|
140
|
+
chainId: this.chainId,
|
|
141
|
+
chainCheck,
|
|
142
|
+
assertWriteTargets: () => this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck),
|
|
143
|
+
});
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
await this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck);
|
|
147
|
+
const tokenInput = parseGetBundlesTokenRequirements(this.client.viemClient, {
|
|
148
|
+
token: vaultAsset,
|
|
149
|
+
spender,
|
|
150
|
+
amount: funding.assets,
|
|
151
|
+
owner: userAddress,
|
|
152
|
+
chainId: this.chainId,
|
|
153
|
+
deadline,
|
|
154
|
+
supportSignature: this.client.options.supportSignature,
|
|
155
|
+
supportDeployless: this.client.options.supportDeployless,
|
|
156
|
+
useSimplePermit: requirementOptions?.useSimplePermit,
|
|
157
|
+
now,
|
|
158
|
+
});
|
|
159
|
+
// Check each non-no-op invocation before sharing an in-flight state read.
|
|
160
|
+
if (tokenInput.amount > 0n) {
|
|
161
|
+
await chainCheck();
|
|
162
|
+
}
|
|
112
163
|
if (pendingRequirements != null) {
|
|
113
164
|
return await pendingRequirements;
|
|
114
165
|
}
|
|
115
|
-
|
|
116
|
-
// allowance/nonce reads.
|
|
117
|
-
const pending = (async () => {
|
|
118
|
-
await this.assertWriteTargets(["bundles.vaultBundlesV1"]);
|
|
119
|
-
return funding.value > 0n
|
|
120
|
-
? []
|
|
121
|
-
: getBundlesTokenRequirements(this.client.viemClient, {
|
|
122
|
-
token: vaultAsset,
|
|
123
|
-
spender,
|
|
124
|
-
amount: funding.assets,
|
|
125
|
-
owner: userAddress,
|
|
126
|
-
chainId: this.chainId,
|
|
127
|
-
deadline,
|
|
128
|
-
supportSignature: this.client.options.supportSignature,
|
|
129
|
-
supportDeployless: this.client.options.supportDeployless,
|
|
130
|
-
useSimplePermit: requirementOptions?.useSimplePermit,
|
|
131
|
-
now,
|
|
132
|
-
});
|
|
133
|
-
})();
|
|
166
|
+
const pending = getParsedBundlesTokenRequirements({ viemClient: this.client.viemClient, chainCheck }, tokenInput);
|
|
134
167
|
pendingRequirements = pending;
|
|
135
168
|
try {
|
|
136
169
|
return await pending;
|
|
@@ -145,29 +178,14 @@ export class MorphoVaultV2 {
|
|
|
145
178
|
buildTx: (signatures) => {
|
|
146
179
|
// The pure deposit action rejects a token signature supplied alongside native funding.
|
|
147
180
|
const requirementSignature = selectBundlesTokenRequirementSignature(signatures, { spender, amount: funding.assets, deadline });
|
|
148
|
-
return
|
|
149
|
-
vault: {
|
|
150
|
-
chainId: this.chainId,
|
|
151
|
-
address: this.vault,
|
|
152
|
-
asset: vaultAsset,
|
|
153
|
-
},
|
|
154
|
-
args: {
|
|
155
|
-
...(funding.value > 0n
|
|
156
|
-
? { nativeAmount: funding.assets }
|
|
157
|
-
: { amount: funding.assets }),
|
|
158
|
-
maxSharePrice,
|
|
159
|
-
userAddress,
|
|
160
|
-
requirementSignature,
|
|
161
|
-
referralFeePct: common.referralFeePct,
|
|
162
|
-
referralFeeRecipient: common.referralFeeRecipient,
|
|
163
|
-
deadline,
|
|
164
|
-
},
|
|
165
|
-
metadata,
|
|
166
|
-
});
|
|
181
|
+
return buildVaultV2Deposit(parsed, { requirementSignature });
|
|
167
182
|
},
|
|
168
183
|
});
|
|
169
184
|
}
|
|
170
185
|
withdraw(params) {
|
|
186
|
+
return this.buildWithdraw(this.parseWithdraw(params));
|
|
187
|
+
}
|
|
188
|
+
parseWithdraw(params) {
|
|
171
189
|
const suppliedNow = params.now;
|
|
172
190
|
const metadata = resolveTransactionMetadata(this.client.options.metadata, suppliedNow);
|
|
173
191
|
const { amount, userAddress, vaultData } = params;
|
|
@@ -179,21 +197,13 @@ export class MorphoVaultV2 {
|
|
|
179
197
|
throw new NonPositiveInputError("amount", amount);
|
|
180
198
|
}
|
|
181
199
|
// Reject values outside the ABI range before resolving any requirements.
|
|
182
|
-
|
|
183
|
-
if (isMidnightLiquidityAdapter(vaultData) &&
|
|
184
|
-
amount > midnightWithdrawLiquidity(vaultData)) {
|
|
185
|
-
throw new InputExceedsMaxError({
|
|
186
|
-
field: "amount",
|
|
187
|
-
value: amount,
|
|
188
|
-
max: midnightWithdrawLiquidity(vaultData),
|
|
189
|
-
});
|
|
190
|
-
}
|
|
200
|
+
const parsedAmount = parseUint256("amount", amount);
|
|
191
201
|
const createdAt = suppliedNow ?? Time.timestamp();
|
|
192
202
|
const deadline = params.deadline ?? createdAt + Time.s.from.h(2n);
|
|
193
203
|
if (deadline <= createdAt) {
|
|
194
204
|
throw new ExpiredDeadlineError(deadline, createdAt);
|
|
195
205
|
}
|
|
196
|
-
const common =
|
|
206
|
+
const common = parseBundlesCommon({
|
|
197
207
|
deadline,
|
|
198
208
|
referralFeePct: params.referralFeePct,
|
|
199
209
|
referralFeeRecipient: params.referralFeeRecipient,
|
|
@@ -208,15 +218,34 @@ export class MorphoVaultV2 {
|
|
|
208
218
|
assets: amount,
|
|
209
219
|
slippageTolerance,
|
|
210
220
|
});
|
|
221
|
+
const parsed = {
|
|
222
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
223
|
+
args: { amount: parsedAmount, userAddress, ...common },
|
|
224
|
+
common,
|
|
225
|
+
metadata,
|
|
226
|
+
};
|
|
227
|
+
return {
|
|
228
|
+
suppliedNow,
|
|
229
|
+
parsed,
|
|
230
|
+
spender,
|
|
231
|
+
vaultData,
|
|
232
|
+
userAddress,
|
|
233
|
+
requiredShareAllowance,
|
|
234
|
+
deadline,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
buildWithdraw(input) {
|
|
238
|
+
const { parsed, spender, vaultData, userAddress, requiredShareAllowance, deadline, } = input;
|
|
211
239
|
return Object.freeze({
|
|
212
240
|
getRequirements: async () => {
|
|
213
|
-
const now = suppliedNow ?? Time.timestamp();
|
|
241
|
+
const now = input.suppliedNow ?? Time.timestamp();
|
|
214
242
|
if (deadline <= now) {
|
|
215
243
|
throw new ExpiredDeadlineError(deadline, now);
|
|
216
244
|
}
|
|
217
|
-
|
|
245
|
+
const chainCheck = createChainCheck(this.client.viemClient, this.chainId);
|
|
246
|
+
await this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck);
|
|
218
247
|
// Re-read the live share allowance on every call instead of caching the resolved requirements.
|
|
219
|
-
return
|
|
248
|
+
return getParsedVaultBundlesSharesRequirements({ viemClient: this.client.viemClient, chainCheck }, parseVaultBundlesSharesRequirements(this.client.viemClient, {
|
|
220
249
|
vaultData,
|
|
221
250
|
version: "vaultV2",
|
|
222
251
|
owner: userAddress,
|
|
@@ -225,7 +254,7 @@ export class MorphoVaultV2 {
|
|
|
225
254
|
deadline,
|
|
226
255
|
supportSignature: this.client.options.supportSignature,
|
|
227
256
|
now,
|
|
228
|
-
});
|
|
257
|
+
}));
|
|
229
258
|
},
|
|
230
259
|
buildTx: (signatures) => {
|
|
231
260
|
const permit = selectBundlesSharesPermitSignature(signatures, {
|
|
@@ -233,23 +262,15 @@ export class MorphoVaultV2 {
|
|
|
233
262
|
amount: requiredShareAllowance,
|
|
234
263
|
deadline,
|
|
235
264
|
});
|
|
236
|
-
return
|
|
237
|
-
vault: { chainId: this.chainId, address: this.vault },
|
|
238
|
-
args: {
|
|
239
|
-
amount,
|
|
240
|
-
userAddress,
|
|
241
|
-
requirementSignature: permit,
|
|
242
|
-
referralFeePct: common.referralFeePct,
|
|
243
|
-
referralFeeRecipient: common.referralFeeRecipient,
|
|
244
|
-
deadline,
|
|
245
|
-
},
|
|
246
|
-
metadata,
|
|
247
|
-
});
|
|
265
|
+
return buildVaultV2Withdraw(parsed, { requirementSignature: permit });
|
|
248
266
|
},
|
|
249
267
|
});
|
|
250
268
|
}
|
|
251
269
|
/** {@inheritDoc VaultV2Actions.redeem} */
|
|
252
270
|
redeem(params) {
|
|
271
|
+
return this.buildRedeem(this.parseRedeem(params));
|
|
272
|
+
}
|
|
273
|
+
parseRedeem(params) {
|
|
253
274
|
const suppliedNow = params.now;
|
|
254
275
|
const metadata = resolveTransactionMetadata(this.client.options.metadata, suppliedNow);
|
|
255
276
|
validateChainId(this.client.viemClient.chain?.id, this.chainId);
|
|
@@ -262,34 +283,32 @@ export class MorphoVaultV2 {
|
|
|
262
283
|
if (deadline <= createdAt) {
|
|
263
284
|
throw new ExpiredDeadlineError(deadline, createdAt);
|
|
264
285
|
}
|
|
265
|
-
const common =
|
|
286
|
+
const common = parseBundlesCommon({
|
|
266
287
|
deadline,
|
|
267
288
|
referralFeePct: params.referralFeePct,
|
|
268
289
|
referralFeeRecipient: params.referralFeeRecipient,
|
|
269
290
|
});
|
|
270
291
|
const spender = getChainAddress(this.chainId, "bundles.vaultBundlesV1");
|
|
292
|
+
const parsed = {
|
|
293
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
294
|
+
args: { shares: parseUint256("shares", shares), userAddress, ...common },
|
|
295
|
+
common,
|
|
296
|
+
metadata,
|
|
297
|
+
};
|
|
298
|
+
return { suppliedNow, parsed, spender, shares, userAddress, deadline };
|
|
299
|
+
}
|
|
300
|
+
buildRedeem(input) {
|
|
301
|
+
const { parsed, spender, shares, userAddress, deadline } = input;
|
|
271
302
|
return Object.freeze({
|
|
272
303
|
getRequirements: async () => {
|
|
273
|
-
const now = suppliedNow ?? Time.timestamp();
|
|
304
|
+
const now = input.suppliedNow ?? Time.timestamp();
|
|
274
305
|
if (deadline <= now) {
|
|
275
306
|
throw new ExpiredDeadlineError(deadline, now);
|
|
276
307
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const { vault: accrued } = vaultData.accrueInterest(now);
|
|
282
|
-
const liquidity = midnightWithdrawLiquidity(accrued);
|
|
283
|
-
if (accrued.toAssets(shares) > liquidity) {
|
|
284
|
-
throw new InputExceedsMaxError({
|
|
285
|
-
field: "shares",
|
|
286
|
-
value: shares,
|
|
287
|
-
max: accrued.toShares(liquidity),
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return getVaultBundlesSharesRequirements(this.client.viemClient, {
|
|
292
|
-
vaultData,
|
|
308
|
+
const chainCheck = createChainCheck(this.client.viemClient, this.chainId);
|
|
309
|
+
await this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck);
|
|
310
|
+
return getParsedVaultBundlesSharesRequirements({ viemClient: this.client.viemClient, chainCheck }, parseVaultBundlesSharesRequirements(this.client.viemClient, {
|
|
311
|
+
vaultData: await this.getDataWithChainCheck(chainCheck),
|
|
293
312
|
version: "vaultV2",
|
|
294
313
|
owner: userAddress,
|
|
295
314
|
chainId: this.chainId,
|
|
@@ -297,7 +316,7 @@ export class MorphoVaultV2 {
|
|
|
297
316
|
deadline,
|
|
298
317
|
supportSignature: this.client.options.supportSignature,
|
|
299
318
|
now,
|
|
300
|
-
});
|
|
319
|
+
}));
|
|
301
320
|
},
|
|
302
321
|
buildTx: (signatures) => {
|
|
303
322
|
const permit = selectBundlesSharesPermitSignature(signatures, {
|
|
@@ -305,26 +324,16 @@ export class MorphoVaultV2 {
|
|
|
305
324
|
amount: shares,
|
|
306
325
|
deadline,
|
|
307
326
|
});
|
|
308
|
-
return
|
|
309
|
-
vault: { chainId: this.chainId, address: this.vault },
|
|
310
|
-
args: {
|
|
311
|
-
shares,
|
|
312
|
-
userAddress,
|
|
313
|
-
requirementSignature: permit,
|
|
314
|
-
referralFeePct: common.referralFeePct,
|
|
315
|
-
referralFeeRecipient: common.referralFeeRecipient,
|
|
316
|
-
deadline,
|
|
317
|
-
},
|
|
318
|
-
metadata,
|
|
319
|
-
});
|
|
327
|
+
return buildVaultV2Redeem(parsed, { requirementSignature: permit });
|
|
320
328
|
},
|
|
321
329
|
});
|
|
322
330
|
}
|
|
323
331
|
/** {@inheritDoc VaultV2Actions.inKindRedeem} */
|
|
324
332
|
inKindRedeem(params) {
|
|
325
|
-
|
|
333
|
+
return this.buildInKindRedeem(this.parseInKindRedeem(params));
|
|
334
|
+
}
|
|
335
|
+
parseInKindRedeem({ now: suppliedNow, amount, marketParamsList, vaultData, userAddress, adapter: adapterOverride, deadline: deadlineOverride, }) {
|
|
326
336
|
const metadata = resolveTransactionMetadata(this.client.options.metadata, suppliedNow);
|
|
327
|
-
const { amount, marketParamsList, vaultData, userAddress, adapter: adapterOverride, deadline: deadlineOverride, } = params;
|
|
328
337
|
validateChainId(this.client.viemClient.chain?.id, this.chainId);
|
|
329
338
|
if (!isAddressEqual(vaultData.address, this.vault)) {
|
|
330
339
|
throw new VaultAddressMismatchError(this.vault, vaultData.address);
|
|
@@ -333,12 +342,36 @@ export class MorphoVaultV2 {
|
|
|
333
342
|
amount,
|
|
334
343
|
marketParamsList,
|
|
335
344
|
vaultData,
|
|
336
|
-
deadline: deadlineOverride,
|
|
337
345
|
adapter: adapterOverride,
|
|
346
|
+
deadline: deadlineOverride,
|
|
338
347
|
now: suppliedNow ?? Time.timestamp(),
|
|
339
348
|
vault: this.vault,
|
|
340
349
|
});
|
|
341
350
|
const vaultExitBundlesV1 = getChainAddress(this.chainId, "bundles.vaultExitBundlesV1");
|
|
351
|
+
const parsed = {
|
|
352
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
353
|
+
args: {
|
|
354
|
+
adapter,
|
|
355
|
+
amount,
|
|
356
|
+
marketParamsList: marketParamsListSnapshot,
|
|
357
|
+
userAddress,
|
|
358
|
+
deadline,
|
|
359
|
+
},
|
|
360
|
+
metadata,
|
|
361
|
+
};
|
|
362
|
+
return {
|
|
363
|
+
suppliedNow,
|
|
364
|
+
parsed,
|
|
365
|
+
deadline,
|
|
366
|
+
userAddress,
|
|
367
|
+
vaultData,
|
|
368
|
+
vaultExitBundlesV1,
|
|
369
|
+
peak,
|
|
370
|
+
requiredShareAllowance,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
buildInKindRedeem(input) {
|
|
374
|
+
const { parsed, deadline, userAddress, vaultData, vaultExitBundlesV1, peak, requiredShareAllowance, } = input;
|
|
342
375
|
return {
|
|
343
376
|
getRequirements: () => getVaultV2InKindRedeemRequirements(this.client.viemClient, {
|
|
344
377
|
vaultData,
|
|
@@ -349,7 +382,7 @@ export class MorphoVaultV2 {
|
|
|
349
382
|
requiredShareAllowance,
|
|
350
383
|
supportSignature: this.client.options.supportSignature,
|
|
351
384
|
peak,
|
|
352
|
-
now: suppliedNow,
|
|
385
|
+
now: input.suppliedNow,
|
|
353
386
|
}),
|
|
354
387
|
buildTx: (signatures) => {
|
|
355
388
|
const permit = selectBundlesSharesPermitSignature(signatures, {
|
|
@@ -357,31 +390,23 @@ export class MorphoVaultV2 {
|
|
|
357
390
|
amount: requiredShareAllowance,
|
|
358
391
|
deadline,
|
|
359
392
|
});
|
|
360
|
-
return
|
|
361
|
-
|
|
362
|
-
args: {
|
|
363
|
-
adapter,
|
|
364
|
-
amount,
|
|
365
|
-
marketParamsList: marketParamsListSnapshot,
|
|
366
|
-
userAddress,
|
|
367
|
-
deadline,
|
|
368
|
-
requirementSignature: permit,
|
|
369
|
-
},
|
|
370
|
-
metadata,
|
|
393
|
+
return buildVaultV2InKindRedeem(parsed, {
|
|
394
|
+
requirementSignature: permit,
|
|
371
395
|
});
|
|
372
396
|
},
|
|
373
397
|
};
|
|
374
398
|
}
|
|
375
399
|
/** {@inheritDoc VaultV2Actions.forceWithdraw} */
|
|
376
400
|
forceWithdraw(params) {
|
|
377
|
-
|
|
401
|
+
return this.buildForceWithdraw(this.parseForceWithdraw(params));
|
|
402
|
+
}
|
|
403
|
+
parseForceWithdraw({ now: suppliedNow, exitAssets, vaultData, userAddress, adapter: adapterOverride, deadline: deadlineOverride, slippageTolerance = DEFAULT_SLIPPAGE_TOLERANCE, minSharePriceE27: minSharePriceE27Override, referralFeePct = 0n, referralFeeRecipient, }) {
|
|
378
404
|
const metadata = resolveTransactionMetadata(this.client.options.metadata, suppliedNow);
|
|
379
|
-
const { exitAssets, vaultData, userAddress, adapter: adapterOverride, deadline: deadlineOverride, slippageTolerance = DEFAULT_SLIPPAGE_TOLERANCE, minSharePriceE27: minSharePriceE27Override, referralFeePct = 0n, referralFeeRecipient, } = params;
|
|
380
405
|
validateChainId(this.client.viemClient.chain?.id, this.chainId);
|
|
381
406
|
if (!isAddressEqual(vaultData.address, this.vault)) {
|
|
382
407
|
throw new VaultAddressMismatchError(this.vault, vaultData.address);
|
|
383
408
|
}
|
|
384
|
-
const { deadline, adapter, minSharePriceE27, requiredShareAllowance } = computeVaultV2ForceWithdrawQuote({
|
|
409
|
+
const { deadline, adapter, minSharePriceE27, requiredShareAllowance, referral, } = computeVaultV2ForceWithdrawQuote({
|
|
385
410
|
exitAssets,
|
|
386
411
|
vaultData,
|
|
387
412
|
userAddress,
|
|
@@ -395,6 +420,30 @@ export class MorphoVaultV2 {
|
|
|
395
420
|
vault: this.vault,
|
|
396
421
|
});
|
|
397
422
|
const vaultExitBundlesV1 = getChainAddress(this.chainId, "bundles.vaultExitBundlesV1");
|
|
423
|
+
const parsed = {
|
|
424
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
425
|
+
args: {
|
|
426
|
+
adapter,
|
|
427
|
+
exitAssets,
|
|
428
|
+
minSharePriceE27,
|
|
429
|
+
userAddress,
|
|
430
|
+
deadline,
|
|
431
|
+
},
|
|
432
|
+
referral,
|
|
433
|
+
metadata,
|
|
434
|
+
};
|
|
435
|
+
return {
|
|
436
|
+
suppliedNow,
|
|
437
|
+
parsed,
|
|
438
|
+
deadline,
|
|
439
|
+
userAddress,
|
|
440
|
+
vaultData,
|
|
441
|
+
vaultExitBundlesV1,
|
|
442
|
+
requiredShareAllowance,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
buildForceWithdraw(input) {
|
|
446
|
+
const { parsed, deadline, userAddress, vaultData, vaultExitBundlesV1, requiredShareAllowance, } = input;
|
|
398
447
|
return {
|
|
399
448
|
getRequirements: () => getVaultV2ForceWithdrawRequirements(this.client.viemClient, {
|
|
400
449
|
vaultData,
|
|
@@ -404,7 +453,7 @@ export class MorphoVaultV2 {
|
|
|
404
453
|
deadline,
|
|
405
454
|
requiredShareAllowance,
|
|
406
455
|
supportSignature: this.client.options.supportSignature,
|
|
407
|
-
now: suppliedNow,
|
|
456
|
+
now: input.suppliedNow,
|
|
408
457
|
}),
|
|
409
458
|
buildTx: (signatures) => {
|
|
410
459
|
const permit = selectBundlesSharesPermitSignature(signatures, {
|
|
@@ -412,26 +461,17 @@ export class MorphoVaultV2 {
|
|
|
412
461
|
amount: requiredShareAllowance,
|
|
413
462
|
deadline,
|
|
414
463
|
});
|
|
415
|
-
return
|
|
416
|
-
|
|
417
|
-
args: {
|
|
418
|
-
adapter,
|
|
419
|
-
exitAssets,
|
|
420
|
-
minSharePriceE27,
|
|
421
|
-
userAddress,
|
|
422
|
-
deadline,
|
|
423
|
-
referralFeePct,
|
|
424
|
-
referralFeeRecipient,
|
|
425
|
-
requirementSignature: permit,
|
|
426
|
-
},
|
|
427
|
-
metadata,
|
|
464
|
+
return buildVaultV2ForceWithdraw(parsed, {
|
|
465
|
+
requirementSignature: permit,
|
|
428
466
|
});
|
|
429
467
|
},
|
|
430
468
|
};
|
|
431
469
|
}
|
|
432
470
|
forceRedeem(params) {
|
|
433
|
-
|
|
434
|
-
|
|
471
|
+
return this.buildForceRedeem(this.parseForceRedeem(params));
|
|
472
|
+
}
|
|
473
|
+
parseForceRedeem({ now: suppliedNow, deallocations, redeem, userAddress, }) {
|
|
474
|
+
const metadata = resolveTransactionMetadata(this.client.options.metadata, suppliedNow);
|
|
435
475
|
validateChainId(this.client.viemClient.chain?.id, this.chainId);
|
|
436
476
|
const shares = redeem.shares;
|
|
437
477
|
const deallocationsSnapshot = deallocations.map(({ adapter, marketParams, amount }) => ({
|
|
@@ -439,16 +479,18 @@ export class MorphoVaultV2 {
|
|
|
439
479
|
amount,
|
|
440
480
|
...(marketParams && { marketParams: new MarketParams(marketParams) }),
|
|
441
481
|
}));
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
482
|
+
const parsed = parseVaultV2ForceRedeem({
|
|
483
|
+
vault: { address: this.vault },
|
|
484
|
+
args: {
|
|
485
|
+
deallocations: deallocationsSnapshot,
|
|
486
|
+
redeem: { shares, recipient: userAddress },
|
|
487
|
+
onBehalf: userAddress,
|
|
488
|
+
},
|
|
489
|
+
metadata,
|
|
490
|
+
});
|
|
491
|
+
return parsed;
|
|
492
|
+
}
|
|
493
|
+
buildForceRedeem(parsed) {
|
|
494
|
+
return { buildTx: () => buildVaultV2ForceRedeem(parsed) };
|
|
453
495
|
}
|
|
454
496
|
}
|