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