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