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