@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
|
@@ -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 } 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;
|
|
@@ -75,25 +78,17 @@ export class MorphoVaultV2 {
|
|
|
75
78
|
if (deadline <= createdAt) {
|
|
76
79
|
throw new ExpiredDeadlineError(deadline, createdAt);
|
|
77
80
|
}
|
|
78
|
-
const common =
|
|
81
|
+
const common = parseBundlesCommon({
|
|
79
82
|
deadline,
|
|
80
83
|
referralFeePct: params.referralFeePct,
|
|
81
84
|
referralFeeRecipient: params.referralFeeRecipient,
|
|
82
85
|
});
|
|
83
86
|
const funding = resolveBundlesFunding(params);
|
|
84
|
-
// Reject
|
|
85
|
-
|
|
87
|
+
// Reject invalid funding before preparing a lazy handle.
|
|
88
|
+
parseUint256(funding.value > 0n ? "nativeAmount" : "amount", funding.assets);
|
|
86
89
|
if (funding.value > 0n) {
|
|
87
|
-
// The native path must target the chain's registered wrapped-native asset.
|
|
88
90
|
validateNativeVaultAsset(this.chainId, vaultAsset);
|
|
89
91
|
}
|
|
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
92
|
const referralFeeAssets = getBundlesReferralFeeAssets(funding.assets, common.referralFeePct);
|
|
98
93
|
const maxSharePrice = computeVaultMaxSharePrice({
|
|
99
94
|
vaultData,
|
|
@@ -102,35 +97,69 @@ export class MorphoVaultV2 {
|
|
|
102
97
|
slippageTolerance: params.slippageTolerance ?? DEFAULT_SLIPPAGE_TOLERANCE,
|
|
103
98
|
});
|
|
104
99
|
const spender = getChainAddress(this.chainId, "bundles.vaultBundlesV1");
|
|
100
|
+
if (maxSharePrice <= 0n) {
|
|
101
|
+
throw new NonPositiveInputError("maxSharePrice", maxSharePrice);
|
|
102
|
+
}
|
|
103
|
+
// Computed bounds also have to fit uint256.
|
|
104
|
+
parseUint256("maxSharePrice", maxSharePrice);
|
|
105
|
+
const parsed = {
|
|
106
|
+
vault: { chainId: this.chainId, address: this.vault, asset: vaultAsset },
|
|
107
|
+
userAddress,
|
|
108
|
+
funding,
|
|
109
|
+
maxSharePrice,
|
|
110
|
+
common,
|
|
111
|
+
metadata,
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
suppliedNow,
|
|
115
|
+
parsed,
|
|
116
|
+
spender,
|
|
117
|
+
vaultAsset,
|
|
118
|
+
userAddress,
|
|
119
|
+
funding,
|
|
120
|
+
deadline,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
buildDeposit(input) {
|
|
124
|
+
const { parsed, spender, vaultAsset, userAddress, funding, deadline } = input;
|
|
105
125
|
let pendingRequirements;
|
|
106
126
|
return Object.freeze({
|
|
107
127
|
getRequirements: async (requirementOptions) => {
|
|
108
|
-
const now = suppliedNow ?? Time.timestamp();
|
|
128
|
+
const now = input.suppliedNow ?? Time.timestamp();
|
|
109
129
|
if (deadline <= now) {
|
|
110
130
|
throw new ExpiredDeadlineError(deadline, now);
|
|
111
131
|
}
|
|
132
|
+
const chainCheck = createChainCheck(this.client.viemClient, this.chainId);
|
|
133
|
+
if (funding.value > 0n) {
|
|
134
|
+
// Native funding skips the token resolver's chain validation.
|
|
135
|
+
await validateNativeRequirements(this.client.viemClient, {
|
|
136
|
+
chainId: this.chainId,
|
|
137
|
+
chainCheck,
|
|
138
|
+
assertWriteTargets: () => this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck),
|
|
139
|
+
});
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
await this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck);
|
|
143
|
+
const tokenInput = parseGetBundlesTokenRequirements(this.client.viemClient, {
|
|
144
|
+
token: vaultAsset,
|
|
145
|
+
spender,
|
|
146
|
+
amount: funding.assets,
|
|
147
|
+
owner: userAddress,
|
|
148
|
+
chainId: this.chainId,
|
|
149
|
+
deadline,
|
|
150
|
+
supportSignature: this.client.options.supportSignature,
|
|
151
|
+
supportDeployless: this.client.options.supportDeployless,
|
|
152
|
+
useSimplePermit: requirementOptions?.useSimplePermit,
|
|
153
|
+
now,
|
|
154
|
+
});
|
|
155
|
+
// Check each non-no-op invocation before sharing an in-flight state read.
|
|
156
|
+
if (tokenInput.amount > 0n) {
|
|
157
|
+
await chainCheck();
|
|
158
|
+
}
|
|
112
159
|
if (pendingRequirements != null) {
|
|
113
160
|
return await pendingRequirements;
|
|
114
161
|
}
|
|
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
|
-
})();
|
|
162
|
+
const pending = getParsedBundlesTokenRequirements({ viemClient: this.client.viemClient, chainCheck }, tokenInput);
|
|
134
163
|
pendingRequirements = pending;
|
|
135
164
|
try {
|
|
136
165
|
return await pending;
|
|
@@ -145,29 +174,14 @@ export class MorphoVaultV2 {
|
|
|
145
174
|
buildTx: (signatures) => {
|
|
146
175
|
// The pure deposit action rejects a token signature supplied alongside native funding.
|
|
147
176
|
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
|
-
});
|
|
177
|
+
return buildVaultV2Deposit(parsed, { requirementSignature });
|
|
167
178
|
},
|
|
168
179
|
});
|
|
169
180
|
}
|
|
170
181
|
withdraw(params) {
|
|
182
|
+
return this.buildWithdraw(this.parseWithdraw(params));
|
|
183
|
+
}
|
|
184
|
+
parseWithdraw(params) {
|
|
171
185
|
const suppliedNow = params.now;
|
|
172
186
|
const metadata = resolveTransactionMetadata(this.client.options.metadata, suppliedNow);
|
|
173
187
|
const { amount, userAddress, vaultData } = params;
|
|
@@ -179,21 +193,13 @@ export class MorphoVaultV2 {
|
|
|
179
193
|
throw new NonPositiveInputError("amount", amount);
|
|
180
194
|
}
|
|
181
195
|
// 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
|
-
}
|
|
196
|
+
const parsedAmount = parseUint256("amount", amount);
|
|
191
197
|
const createdAt = suppliedNow ?? Time.timestamp();
|
|
192
198
|
const deadline = params.deadline ?? createdAt + Time.s.from.h(2n);
|
|
193
199
|
if (deadline <= createdAt) {
|
|
194
200
|
throw new ExpiredDeadlineError(deadline, createdAt);
|
|
195
201
|
}
|
|
196
|
-
const common =
|
|
202
|
+
const common = parseBundlesCommon({
|
|
197
203
|
deadline,
|
|
198
204
|
referralFeePct: params.referralFeePct,
|
|
199
205
|
referralFeeRecipient: params.referralFeeRecipient,
|
|
@@ -208,15 +214,34 @@ export class MorphoVaultV2 {
|
|
|
208
214
|
assets: amount,
|
|
209
215
|
slippageTolerance,
|
|
210
216
|
});
|
|
217
|
+
const parsed = {
|
|
218
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
219
|
+
args: { amount: parsedAmount, userAddress, ...common },
|
|
220
|
+
common,
|
|
221
|
+
metadata,
|
|
222
|
+
};
|
|
223
|
+
return {
|
|
224
|
+
suppliedNow,
|
|
225
|
+
parsed,
|
|
226
|
+
spender,
|
|
227
|
+
vaultData,
|
|
228
|
+
userAddress,
|
|
229
|
+
requiredShareAllowance,
|
|
230
|
+
deadline,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
buildWithdraw(input) {
|
|
234
|
+
const { parsed, spender, vaultData, userAddress, requiredShareAllowance, deadline, } = input;
|
|
211
235
|
return Object.freeze({
|
|
212
236
|
getRequirements: async () => {
|
|
213
|
-
const now = suppliedNow ?? Time.timestamp();
|
|
237
|
+
const now = input.suppliedNow ?? Time.timestamp();
|
|
214
238
|
if (deadline <= now) {
|
|
215
239
|
throw new ExpiredDeadlineError(deadline, now);
|
|
216
240
|
}
|
|
217
|
-
|
|
241
|
+
const chainCheck = createChainCheck(this.client.viemClient, this.chainId);
|
|
242
|
+
await this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck);
|
|
218
243
|
// Re-read the live share allowance on every call instead of caching the resolved requirements.
|
|
219
|
-
return
|
|
244
|
+
return getParsedVaultBundlesSharesRequirements({ viemClient: this.client.viemClient, chainCheck }, parseVaultBundlesSharesRequirements(this.client.viemClient, {
|
|
220
245
|
vaultData,
|
|
221
246
|
version: "vaultV2",
|
|
222
247
|
owner: userAddress,
|
|
@@ -225,7 +250,7 @@ export class MorphoVaultV2 {
|
|
|
225
250
|
deadline,
|
|
226
251
|
supportSignature: this.client.options.supportSignature,
|
|
227
252
|
now,
|
|
228
|
-
});
|
|
253
|
+
}));
|
|
229
254
|
},
|
|
230
255
|
buildTx: (signatures) => {
|
|
231
256
|
const permit = selectBundlesSharesPermitSignature(signatures, {
|
|
@@ -233,23 +258,15 @@ export class MorphoVaultV2 {
|
|
|
233
258
|
amount: requiredShareAllowance,
|
|
234
259
|
deadline,
|
|
235
260
|
});
|
|
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
|
-
});
|
|
261
|
+
return buildVaultV2Withdraw(parsed, { requirementSignature: permit });
|
|
248
262
|
},
|
|
249
263
|
});
|
|
250
264
|
}
|
|
251
265
|
/** {@inheritDoc VaultV2Actions.redeem} */
|
|
252
266
|
redeem(params) {
|
|
267
|
+
return this.buildRedeem(this.parseRedeem(params));
|
|
268
|
+
}
|
|
269
|
+
parseRedeem(params) {
|
|
253
270
|
const suppliedNow = params.now;
|
|
254
271
|
const metadata = resolveTransactionMetadata(this.client.options.metadata, suppliedNow);
|
|
255
272
|
validateChainId(this.client.viemClient.chain?.id, this.chainId);
|
|
@@ -262,34 +279,32 @@ export class MorphoVaultV2 {
|
|
|
262
279
|
if (deadline <= createdAt) {
|
|
263
280
|
throw new ExpiredDeadlineError(deadline, createdAt);
|
|
264
281
|
}
|
|
265
|
-
const common =
|
|
282
|
+
const common = parseBundlesCommon({
|
|
266
283
|
deadline,
|
|
267
284
|
referralFeePct: params.referralFeePct,
|
|
268
285
|
referralFeeRecipient: params.referralFeeRecipient,
|
|
269
286
|
});
|
|
270
287
|
const spender = getChainAddress(this.chainId, "bundles.vaultBundlesV1");
|
|
288
|
+
const parsed = {
|
|
289
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
290
|
+
args: { shares: parseUint256("shares", shares), userAddress, ...common },
|
|
291
|
+
common,
|
|
292
|
+
metadata,
|
|
293
|
+
};
|
|
294
|
+
return { suppliedNow, parsed, spender, shares, userAddress, deadline };
|
|
295
|
+
}
|
|
296
|
+
buildRedeem(input) {
|
|
297
|
+
const { parsed, spender, shares, userAddress, deadline } = input;
|
|
271
298
|
return Object.freeze({
|
|
272
299
|
getRequirements: async () => {
|
|
273
|
-
const now = suppliedNow ?? Time.timestamp();
|
|
300
|
+
const now = input.suppliedNow ?? Time.timestamp();
|
|
274
301
|
if (deadline <= now) {
|
|
275
302
|
throw new ExpiredDeadlineError(deadline, now);
|
|
276
303
|
}
|
|
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,
|
|
304
|
+
const chainCheck = createChainCheck(this.client.viemClient, this.chainId);
|
|
305
|
+
await this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck);
|
|
306
|
+
return getParsedVaultBundlesSharesRequirements({ viemClient: this.client.viemClient, chainCheck }, parseVaultBundlesSharesRequirements(this.client.viemClient, {
|
|
307
|
+
vaultData: await this.getDataWithChainCheck(chainCheck),
|
|
293
308
|
version: "vaultV2",
|
|
294
309
|
owner: userAddress,
|
|
295
310
|
chainId: this.chainId,
|
|
@@ -297,7 +312,7 @@ export class MorphoVaultV2 {
|
|
|
297
312
|
deadline,
|
|
298
313
|
supportSignature: this.client.options.supportSignature,
|
|
299
314
|
now,
|
|
300
|
-
});
|
|
315
|
+
}));
|
|
301
316
|
},
|
|
302
317
|
buildTx: (signatures) => {
|
|
303
318
|
const permit = selectBundlesSharesPermitSignature(signatures, {
|
|
@@ -305,26 +320,16 @@ export class MorphoVaultV2 {
|
|
|
305
320
|
amount: shares,
|
|
306
321
|
deadline,
|
|
307
322
|
});
|
|
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
|
-
});
|
|
323
|
+
return buildVaultV2Redeem(parsed, { requirementSignature: permit });
|
|
320
324
|
},
|
|
321
325
|
});
|
|
322
326
|
}
|
|
323
327
|
/** {@inheritDoc VaultV2Actions.inKindRedeem} */
|
|
324
328
|
inKindRedeem(params) {
|
|
325
|
-
|
|
329
|
+
return this.buildInKindRedeem(this.parseInKindRedeem(params));
|
|
330
|
+
}
|
|
331
|
+
parseInKindRedeem({ now: suppliedNow, amount, marketParamsList, vaultData, userAddress, adapter: adapterOverride, deadline: deadlineOverride, }) {
|
|
326
332
|
const metadata = resolveTransactionMetadata(this.client.options.metadata, suppliedNow);
|
|
327
|
-
const { amount, marketParamsList, vaultData, userAddress, adapter: adapterOverride, deadline: deadlineOverride, } = params;
|
|
328
333
|
validateChainId(this.client.viemClient.chain?.id, this.chainId);
|
|
329
334
|
if (!isAddressEqual(vaultData.address, this.vault)) {
|
|
330
335
|
throw new VaultAddressMismatchError(this.vault, vaultData.address);
|
|
@@ -333,12 +338,36 @@ export class MorphoVaultV2 {
|
|
|
333
338
|
amount,
|
|
334
339
|
marketParamsList,
|
|
335
340
|
vaultData,
|
|
336
|
-
deadline: deadlineOverride,
|
|
337
341
|
adapter: adapterOverride,
|
|
342
|
+
deadline: deadlineOverride,
|
|
338
343
|
now: suppliedNow ?? Time.timestamp(),
|
|
339
344
|
vault: this.vault,
|
|
340
345
|
});
|
|
341
346
|
const vaultExitBundlesV1 = getChainAddress(this.chainId, "bundles.vaultExitBundlesV1");
|
|
347
|
+
const parsed = {
|
|
348
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
349
|
+
args: {
|
|
350
|
+
adapter,
|
|
351
|
+
amount,
|
|
352
|
+
marketParamsList: marketParamsListSnapshot,
|
|
353
|
+
userAddress,
|
|
354
|
+
deadline,
|
|
355
|
+
},
|
|
356
|
+
metadata,
|
|
357
|
+
};
|
|
358
|
+
return {
|
|
359
|
+
suppliedNow,
|
|
360
|
+
parsed,
|
|
361
|
+
deadline,
|
|
362
|
+
userAddress,
|
|
363
|
+
vaultData,
|
|
364
|
+
vaultExitBundlesV1,
|
|
365
|
+
peak,
|
|
366
|
+
requiredShareAllowance,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
buildInKindRedeem(input) {
|
|
370
|
+
const { parsed, deadline, userAddress, vaultData, vaultExitBundlesV1, peak, requiredShareAllowance, } = input;
|
|
342
371
|
return {
|
|
343
372
|
getRequirements: () => getVaultV2InKindRedeemRequirements(this.client.viemClient, {
|
|
344
373
|
vaultData,
|
|
@@ -349,7 +378,7 @@ export class MorphoVaultV2 {
|
|
|
349
378
|
requiredShareAllowance,
|
|
350
379
|
supportSignature: this.client.options.supportSignature,
|
|
351
380
|
peak,
|
|
352
|
-
now: suppliedNow,
|
|
381
|
+
now: input.suppliedNow,
|
|
353
382
|
}),
|
|
354
383
|
buildTx: (signatures) => {
|
|
355
384
|
const permit = selectBundlesSharesPermitSignature(signatures, {
|
|
@@ -357,31 +386,23 @@ export class MorphoVaultV2 {
|
|
|
357
386
|
amount: requiredShareAllowance,
|
|
358
387
|
deadline,
|
|
359
388
|
});
|
|
360
|
-
return
|
|
361
|
-
|
|
362
|
-
args: {
|
|
363
|
-
adapter,
|
|
364
|
-
amount,
|
|
365
|
-
marketParamsList: marketParamsListSnapshot,
|
|
366
|
-
userAddress,
|
|
367
|
-
deadline,
|
|
368
|
-
requirementSignature: permit,
|
|
369
|
-
},
|
|
370
|
-
metadata,
|
|
389
|
+
return buildVaultV2InKindRedeem(parsed, {
|
|
390
|
+
requirementSignature: permit,
|
|
371
391
|
});
|
|
372
392
|
},
|
|
373
393
|
};
|
|
374
394
|
}
|
|
375
395
|
/** {@inheritDoc VaultV2Actions.forceWithdraw} */
|
|
376
396
|
forceWithdraw(params) {
|
|
377
|
-
|
|
397
|
+
return this.buildForceWithdraw(this.parseForceWithdraw(params));
|
|
398
|
+
}
|
|
399
|
+
parseForceWithdraw({ now: suppliedNow, exitAssets, vaultData, userAddress, adapter: adapterOverride, deadline: deadlineOverride, slippageTolerance = DEFAULT_SLIPPAGE_TOLERANCE, minSharePriceE27: minSharePriceE27Override, referralFeePct = 0n, referralFeeRecipient, }) {
|
|
378
400
|
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
401
|
validateChainId(this.client.viemClient.chain?.id, this.chainId);
|
|
381
402
|
if (!isAddressEqual(vaultData.address, this.vault)) {
|
|
382
403
|
throw new VaultAddressMismatchError(this.vault, vaultData.address);
|
|
383
404
|
}
|
|
384
|
-
const { deadline, adapter, minSharePriceE27, requiredShareAllowance } = computeVaultV2ForceWithdrawQuote({
|
|
405
|
+
const { deadline, adapter, minSharePriceE27, requiredShareAllowance, referral, } = computeVaultV2ForceWithdrawQuote({
|
|
385
406
|
exitAssets,
|
|
386
407
|
vaultData,
|
|
387
408
|
userAddress,
|
|
@@ -395,6 +416,30 @@ export class MorphoVaultV2 {
|
|
|
395
416
|
vault: this.vault,
|
|
396
417
|
});
|
|
397
418
|
const vaultExitBundlesV1 = getChainAddress(this.chainId, "bundles.vaultExitBundlesV1");
|
|
419
|
+
const parsed = {
|
|
420
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
421
|
+
args: {
|
|
422
|
+
adapter,
|
|
423
|
+
exitAssets,
|
|
424
|
+
minSharePriceE27,
|
|
425
|
+
userAddress,
|
|
426
|
+
deadline,
|
|
427
|
+
},
|
|
428
|
+
referral,
|
|
429
|
+
metadata,
|
|
430
|
+
};
|
|
431
|
+
return {
|
|
432
|
+
suppliedNow,
|
|
433
|
+
parsed,
|
|
434
|
+
deadline,
|
|
435
|
+
userAddress,
|
|
436
|
+
vaultData,
|
|
437
|
+
vaultExitBundlesV1,
|
|
438
|
+
requiredShareAllowance,
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
buildForceWithdraw(input) {
|
|
442
|
+
const { parsed, deadline, userAddress, vaultData, vaultExitBundlesV1, requiredShareAllowance, } = input;
|
|
398
443
|
return {
|
|
399
444
|
getRequirements: () => getVaultV2ForceWithdrawRequirements(this.client.viemClient, {
|
|
400
445
|
vaultData,
|
|
@@ -404,7 +449,7 @@ export class MorphoVaultV2 {
|
|
|
404
449
|
deadline,
|
|
405
450
|
requiredShareAllowance,
|
|
406
451
|
supportSignature: this.client.options.supportSignature,
|
|
407
|
-
now: suppliedNow,
|
|
452
|
+
now: input.suppliedNow,
|
|
408
453
|
}),
|
|
409
454
|
buildTx: (signatures) => {
|
|
410
455
|
const permit = selectBundlesSharesPermitSignature(signatures, {
|
|
@@ -412,26 +457,17 @@ export class MorphoVaultV2 {
|
|
|
412
457
|
amount: requiredShareAllowance,
|
|
413
458
|
deadline,
|
|
414
459
|
});
|
|
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,
|
|
460
|
+
return buildVaultV2ForceWithdraw(parsed, {
|
|
461
|
+
requirementSignature: permit,
|
|
428
462
|
});
|
|
429
463
|
},
|
|
430
464
|
};
|
|
431
465
|
}
|
|
432
466
|
forceRedeem(params) {
|
|
433
|
-
|
|
434
|
-
|
|
467
|
+
return this.buildForceRedeem(this.parseForceRedeem(params));
|
|
468
|
+
}
|
|
469
|
+
parseForceRedeem({ now: suppliedNow, deallocations, redeem, userAddress, }) {
|
|
470
|
+
const metadata = resolveTransactionMetadata(this.client.options.metadata, suppliedNow);
|
|
435
471
|
validateChainId(this.client.viemClient.chain?.id, this.chainId);
|
|
436
472
|
const shares = redeem.shares;
|
|
437
473
|
const deallocationsSnapshot = deallocations.map(({ adapter, marketParams, amount }) => ({
|
|
@@ -439,16 +475,18 @@ export class MorphoVaultV2 {
|
|
|
439
475
|
amount,
|
|
440
476
|
...(marketParams && { marketParams: new MarketParams(marketParams) }),
|
|
441
477
|
}));
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
478
|
+
const parsed = parseVaultV2ForceRedeem({
|
|
479
|
+
vault: { address: this.vault },
|
|
480
|
+
args: {
|
|
481
|
+
deallocations: deallocationsSnapshot,
|
|
482
|
+
redeem: { shares, recipient: userAddress },
|
|
483
|
+
onBehalf: userAddress,
|
|
484
|
+
},
|
|
485
|
+
metadata,
|
|
486
|
+
});
|
|
487
|
+
return parsed;
|
|
488
|
+
}
|
|
489
|
+
buildForceRedeem(parsed) {
|
|
490
|
+
return { buildTx: () => buildVaultV2ForceRedeem(parsed) };
|
|
453
491
|
}
|
|
454
492
|
}
|
|
@@ -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";
|
|
@@ -92,9 +92,6 @@ const cloneAccrualVault = (vault, markets) => new AccrualVault({
|
|
|
92
92
|
position: clonePosition(position, markets),
|
|
93
93
|
})));
|
|
94
94
|
const cloneAdapter = (adapter, markets) => {
|
|
95
|
-
if (adapter.type === "VaultV2MidnightAdapter") {
|
|
96
|
-
return adapter;
|
|
97
|
-
}
|
|
98
95
|
const base = {
|
|
99
96
|
address: adapter.address,
|
|
100
97
|
parentVault: adapter.parentVault,
|
|
@@ -146,8 +143,7 @@ const cloneVault = (vault, { markets, adapterKeysToClone, }) => {
|
|
|
146
143
|
/**
|
|
147
144
|
* Immutable-by-convention state container for Vault V2 BluePublicAllocator simulations.
|
|
148
145
|
*
|
|
149
|
-
* Constructor inputs are cloned
|
|
150
|
-
* shared by reference. Every simulated reallocation returns a new
|
|
146
|
+
* Constructor inputs are cloned. Every simulated reallocation returns a new
|
|
151
147
|
* instance. Planning keeps the transaction-scoped `firstTotalAssets`
|
|
152
148
|
* denominator outside the durable snapshot while applying reallocations in
|
|
153
149
|
* contract order. Penalty donations update simulated vault accounting but are
|
|
@@ -278,7 +274,7 @@ export class VaultV2BlueReallocationData {
|
|
|
278
274
|
/**
|
|
279
275
|
* Clones the complete simulation snapshot.
|
|
280
276
|
*
|
|
281
|
-
* @returns A deep clone of this simulation state
|
|
277
|
+
* @returns A deep clone of this simulation state.
|
|
282
278
|
* @example
|
|
283
279
|
* ```ts
|
|
284
280
|
* import { markets } from "@morpho-org/morpho-test";
|