@morpho-org/morpho-sdk 10.3.1 → 10.5.0-next.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 +169 -5
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +5 -1
- package/lib/cjs/actions/blue/common.js +12 -3
- package/lib/cjs/actions/midnight/redeem.d.ts +20 -3
- package/lib/cjs/actions/midnight/redeem.js +58 -1
- package/lib/cjs/actions/midnight/supplyCollateralWithNative.d.ts +24 -1
- package/lib/cjs/actions/midnight/supplyCollateralWithNative.js +41 -0
- package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +16 -2
- package/lib/cjs/actions/midnight/withdrawCollateral.js +26 -1
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +5 -1
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +3 -1
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +5 -1
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +3 -1
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +2 -1
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +3 -1
- package/lib/cjs/entities/midnight/midnight.d.ts +100 -103
- package/lib/cjs/entities/midnight/midnight.js +99 -99
- package/lib/cjs/entities/vaultV1/vaultV1.js +0 -1
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +34 -8
- package/lib/cjs/entities/vaultV2/vaultV2.js +39 -2
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -2
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +6 -2
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +7 -5
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +3 -1
- package/lib/cjs/helpers/callback.d.ts +3 -2
- package/lib/cjs/helpers/callback.js +4 -20
- package/lib/cjs/helpers/computeMidnightPostWithdrawalCollateral.d.ts +17 -0
- package/lib/cjs/helpers/computeMidnightPostWithdrawalCollateral.js +30 -0
- package/lib/cjs/helpers/deadShares.js +3 -0
- package/lib/cjs/helpers/parseMidnightMaker.d.ts +21 -0
- package/lib/cjs/helpers/parseMidnightMaker.js +41 -1
- package/lib/cjs/helpers/validate.d.ts +60 -2
- package/lib/cjs/helpers/validate.js +87 -1
- package/lib/cjs/helpers/validateMidnightPublication.d.ts +10 -0
- package/lib/cjs/helpers/validateMidnightPublication.js +18 -1
- package/lib/cjs/helpers/validateMidnightTakeableOfferFields.d.ts +28 -0
- package/lib/cjs/helpers/validateMidnightTakeableOfferFields.js +85 -0
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js +23 -1
- package/lib/cjs/midnight/errors.d.ts +2 -1
- package/lib/cjs/midnight/errors.js +5 -4
- package/lib/cjs/midnight/utils.d.ts +1 -1
- package/lib/cjs/midnight/utils.js +2 -1
- package/lib/cjs/transactionPlan/assemble.d.ts +24 -0
- package/lib/cjs/transactionPlan/assemble.js +25 -0
- package/lib/cjs/transactionPlan/blue/borrow.js +14 -64
- package/lib/cjs/transactionPlan/blue/refinance.js +9 -11
- package/lib/cjs/transactionPlan/blue/repay.js +10 -24
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +49 -45
- package/lib/cjs/transactionPlan/blue/stored.d.ts +26 -0
- package/lib/cjs/transactionPlan/blue/stored.js +87 -0
- package/lib/cjs/transactionPlan/blue/supply.js +7 -22
- package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +1 -1
- package/lib/cjs/transactionPlan/blue/supplyCollateral.js +10 -15
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +14 -64
- package/lib/cjs/transactionPlan/blue/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/blue/withdraw.js +67 -79
- package/lib/cjs/transactionPlan/blue/withdrawBuyCallback.d.ts +101 -0
- package/lib/cjs/transactionPlan/blue/withdrawBuyCallback.js +264 -0
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +2 -3
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +31 -30
- package/lib/cjs/transactionPlan/deposit.js +4 -7
- package/lib/cjs/transactionPlan/error.d.ts +27 -0
- package/lib/cjs/transactionPlan/error.js +30 -1
- package/lib/cjs/transactionPlan/index.d.ts +40 -1
- package/lib/cjs/transactionPlan/index.js +46 -5
- package/lib/cjs/transactionPlan/intent.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/authorization.d.ts +15 -0
- package/lib/cjs/transactionPlan/midnight/authorization.js +45 -0
- package/lib/cjs/transactionPlan/midnight/cancelOffers.d.ts +80 -0
- package/lib/cjs/transactionPlan/midnight/cancelOffers.js +125 -0
- package/lib/cjs/transactionPlan/midnight/makeBorrow.d.ts +104 -0
- package/lib/cjs/transactionPlan/midnight/makeBorrow.js +126 -0
- package/lib/cjs/transactionPlan/midnight/makeLend.d.ts +140 -0
- package/lib/cjs/transactionPlan/midnight/makeLend.js +176 -0
- package/lib/cjs/transactionPlan/midnight/makeRepay.d.ts +118 -0
- package/lib/cjs/transactionPlan/midnight/makeRepay.js +118 -0
- package/lib/cjs/transactionPlan/midnight/makeWithdraw.d.ts +104 -0
- package/lib/cjs/transactionPlan/midnight/makeWithdraw.js +126 -0
- package/lib/cjs/transactionPlan/midnight/makerPublication.d.ts +55 -0
- package/lib/cjs/transactionPlan/midnight/makerPublication.js +315 -0
- package/lib/cjs/transactionPlan/midnight/market.d.ts +49 -0
- package/lib/cjs/transactionPlan/midnight/market.js +120 -0
- package/lib/cjs/transactionPlan/midnight/prepare.d.ts +244 -0
- package/lib/cjs/transactionPlan/midnight/prepare.js +547 -0
- package/lib/cjs/transactionPlan/midnight/publicationState.d.ts +24 -0
- package/lib/cjs/transactionPlan/midnight/publicationState.js +50 -0
- package/lib/cjs/transactionPlan/midnight/redeem.d.ts +102 -0
- package/lib/cjs/transactionPlan/midnight/redeem.js +170 -0
- package/lib/cjs/transactionPlan/midnight/reduceOnlySellFeasibility.d.ts +25 -0
- package/lib/cjs/transactionPlan/midnight/reduceOnlySellFeasibility.js +51 -0
- package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.d.ts +162 -0
- package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.js +328 -0
- package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.d.ts +155 -0
- package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.js +199 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateral.d.ts +96 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateral.js +190 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.d.ts +112 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.js +221 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +129 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.js +179 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.d.ts +115 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.js +259 -0
- package/lib/cjs/transactionPlan/midnight/takeBorrow.d.ts +304 -0
- package/lib/cjs/transactionPlan/midnight/takeBorrow.js +545 -0
- package/lib/cjs/transactionPlan/midnight/takeLend.d.ts +99 -0
- package/lib/cjs/transactionPlan/midnight/takeLend.js +263 -0
- package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +175 -0
- package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.js +440 -0
- package/lib/cjs/transactionPlan/midnight/takeWithdraw.d.ts +139 -0
- package/lib/cjs/transactionPlan/midnight/takeWithdraw.js +240 -0
- package/lib/cjs/transactionPlan/midnight/validation.d.ts +22 -0
- package/lib/cjs/transactionPlan/midnight/validation.js +158 -0
- package/lib/cjs/transactionPlan/midnight/withdrawCollateral.d.ts +130 -0
- package/lib/cjs/transactionPlan/midnight/withdrawCollateral.js +228 -0
- package/lib/cjs/transactionPlan/midnight/withdrawCollateralBatch.d.ts +142 -0
- package/lib/cjs/transactionPlan/midnight/withdrawCollateralBatch.js +232 -0
- package/lib/cjs/transactionPlan/permit.d.ts +15 -2
- package/lib/cjs/transactionPlan/permit.js +26 -68
- package/lib/cjs/transactionPlan/plan.d.ts +99 -15
- package/lib/cjs/transactionPlan/plan.js +159 -31
- package/lib/cjs/transactionPlan/redeem.js +4 -7
- package/lib/cjs/transactionPlan/requirements.d.ts +7 -4
- package/lib/cjs/transactionPlan/requirements.js +2 -2
- package/lib/cjs/transactionPlan/serde.d.ts +13 -2
- package/lib/cjs/transactionPlan/serde.js +68 -21
- package/lib/cjs/transactionPlan/types.d.ts +151 -3
- package/lib/cjs/transactionPlan/validateActions.d.ts +3 -1
- package/lib/cjs/transactionPlan/validateActions.js +31 -3
- package/lib/cjs/transactionPlan/validation.d.ts +1 -1
- package/lib/cjs/transactionPlan/validation.js +37 -1
- package/lib/cjs/transactionPlan/vaultBinding.d.ts +29 -0
- package/lib/cjs/transactionPlan/vaultBinding.js +69 -0
- package/lib/cjs/transactionPlan/vaultRequirements.d.ts +20 -0
- package/lib/cjs/transactionPlan/vaultRequirements.js +37 -0
- package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +2 -13
- package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.d.ts +2 -2
- package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.js +10 -41
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +6 -18
- package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -12
- package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -13
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +2 -13
- package/lib/cjs/transactionPlan/vaultv2/forceRedeem.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv2/forceRedeem.js +4 -7
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +2 -2
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +12 -42
- package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.d.ts +2 -2
- package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.js +10 -41
- package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -13
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -13
- package/lib/cjs/transactionPlan/withdraw.js +4 -7
- package/lib/cjs/types/error.d.ts +4 -1
- package/lib/cjs/types/error.js +5 -2
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +4 -2
- 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/common.js +13 -4
- package/lib/esm/actions/midnight/redeem.d.ts +20 -3
- package/lib/esm/actions/midnight/redeem.js +56 -0
- package/lib/esm/actions/midnight/supplyCollateralWithNative.d.ts +24 -1
- package/lib/esm/actions/midnight/supplyCollateralWithNative.js +40 -0
- package/lib/esm/actions/midnight/withdrawCollateral.d.ts +16 -2
- package/lib/esm/actions/midnight/withdrawCollateral.js +25 -1
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +100 -103
- package/lib/esm/entities/midnight/midnight.js +99 -99
- package/lib/esm/entities/vaultV1/vaultV1.js +0 -1
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +34 -8
- package/lib/esm/entities/vaultV2/vaultV2.js +40 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -2
- package/lib/esm/entities/vaultV2BlueReallocationData.js +6 -2
- 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/callback.d.ts +3 -2
- package/lib/esm/helpers/callback.js +5 -21
- package/lib/esm/helpers/computeMidnightPostWithdrawalCollateral.d.ts +17 -0
- package/lib/esm/helpers/computeMidnightPostWithdrawalCollateral.js +27 -0
- package/lib/esm/helpers/deadShares.js +4 -1
- package/lib/esm/helpers/parseMidnightMaker.d.ts +21 -0
- package/lib/esm/helpers/parseMidnightMaker.js +40 -1
- package/lib/esm/helpers/validate.d.ts +60 -2
- package/lib/esm/helpers/validate.js +84 -1
- package/lib/esm/helpers/validateMidnightPublication.d.ts +10 -0
- package/lib/esm/helpers/validateMidnightPublication.js +16 -0
- package/lib/esm/helpers/validateMidnightTakeableOfferFields.d.ts +28 -0
- package/lib/esm/helpers/validateMidnightTakeableOfferFields.js +81 -0
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +1 -1
- package/lib/esm/midnight/errors.d.ts +2 -1
- package/lib/esm/midnight/errors.js +2 -1
- package/lib/esm/midnight/utils.d.ts +1 -1
- package/lib/esm/midnight/utils.js +1 -1
- package/lib/esm/transactionPlan/assemble.d.ts +24 -0
- package/lib/esm/transactionPlan/assemble.js +21 -0
- package/lib/esm/transactionPlan/blue/borrow.js +15 -65
- package/lib/esm/transactionPlan/blue/refinance.js +10 -12
- package/lib/esm/transactionPlan/blue/repay.js +11 -25
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +50 -46
- package/lib/esm/transactionPlan/blue/stored.d.ts +26 -0
- package/lib/esm/transactionPlan/blue/stored.js +80 -0
- package/lib/esm/transactionPlan/blue/supply.js +7 -22
- package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +1 -1
- package/lib/esm/transactionPlan/blue/supplyCollateral.js +10 -15
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +15 -65
- package/lib/esm/transactionPlan/blue/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/blue/withdraw.js +70 -82
- package/lib/esm/transactionPlan/blue/withdrawBuyCallback.d.ts +101 -0
- package/lib/esm/transactionPlan/blue/withdrawBuyCallback.js +259 -0
- package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +2 -3
- package/lib/esm/transactionPlan/blue/withdrawCollateral.js +32 -31
- package/lib/esm/transactionPlan/deposit.js +5 -8
- package/lib/esm/transactionPlan/error.d.ts +27 -0
- package/lib/esm/transactionPlan/error.js +28 -0
- package/lib/esm/transactionPlan/index.d.ts +40 -1
- package/lib/esm/transactionPlan/index.js +20 -1
- package/lib/esm/transactionPlan/intent.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/authorization.d.ts +15 -0
- package/lib/esm/transactionPlan/midnight/authorization.js +40 -0
- package/lib/esm/transactionPlan/midnight/cancelOffers.d.ts +80 -0
- package/lib/esm/transactionPlan/midnight/cancelOffers.js +120 -0
- package/lib/esm/transactionPlan/midnight/makeBorrow.d.ts +104 -0
- package/lib/esm/transactionPlan/midnight/makeBorrow.js +123 -0
- package/lib/esm/transactionPlan/midnight/makeLend.d.ts +140 -0
- package/lib/esm/transactionPlan/midnight/makeLend.js +172 -0
- package/lib/esm/transactionPlan/midnight/makeRepay.d.ts +118 -0
- package/lib/esm/transactionPlan/midnight/makeRepay.js +115 -0
- package/lib/esm/transactionPlan/midnight/makeWithdraw.d.ts +104 -0
- package/lib/esm/transactionPlan/midnight/makeWithdraw.js +123 -0
- package/lib/esm/transactionPlan/midnight/makerPublication.d.ts +55 -0
- package/lib/esm/transactionPlan/midnight/makerPublication.js +310 -0
- package/lib/esm/transactionPlan/midnight/market.d.ts +49 -0
- package/lib/esm/transactionPlan/midnight/market.js +112 -0
- package/lib/esm/transactionPlan/midnight/prepare.d.ts +244 -0
- package/lib/esm/transactionPlan/midnight/prepare.js +536 -0
- package/lib/esm/transactionPlan/midnight/publicationState.d.ts +24 -0
- package/lib/esm/transactionPlan/midnight/publicationState.js +47 -0
- package/lib/esm/transactionPlan/midnight/redeem.d.ts +102 -0
- package/lib/esm/transactionPlan/midnight/redeem.js +165 -0
- package/lib/esm/transactionPlan/midnight/reduceOnlySellFeasibility.d.ts +25 -0
- package/lib/esm/transactionPlan/midnight/reduceOnlySellFeasibility.js +47 -0
- package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.d.ts +162 -0
- package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.js +323 -0
- package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.d.ts +155 -0
- package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.js +196 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateral.d.ts +96 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateral.js +185 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.d.ts +112 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.js +216 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +129 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.js +176 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.d.ts +115 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.js +254 -0
- package/lib/esm/transactionPlan/midnight/takeBorrow.d.ts +304 -0
- package/lib/esm/transactionPlan/midnight/takeBorrow.js +539 -0
- package/lib/esm/transactionPlan/midnight/takeLend.d.ts +99 -0
- package/lib/esm/transactionPlan/midnight/takeLend.js +258 -0
- package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +175 -0
- package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.js +435 -0
- package/lib/esm/transactionPlan/midnight/takeWithdraw.d.ts +139 -0
- package/lib/esm/transactionPlan/midnight/takeWithdraw.js +236 -0
- package/lib/esm/transactionPlan/midnight/validation.d.ts +22 -0
- package/lib/esm/transactionPlan/midnight/validation.js +151 -0
- package/lib/esm/transactionPlan/midnight/withdrawCollateral.d.ts +130 -0
- package/lib/esm/transactionPlan/midnight/withdrawCollateral.js +223 -0
- package/lib/esm/transactionPlan/midnight/withdrawCollateralBatch.d.ts +142 -0
- package/lib/esm/transactionPlan/midnight/withdrawCollateralBatch.js +227 -0
- package/lib/esm/transactionPlan/permit.d.ts +15 -2
- package/lib/esm/transactionPlan/permit.js +25 -68
- package/lib/esm/transactionPlan/plan.d.ts +99 -15
- package/lib/esm/transactionPlan/plan.js +154 -27
- package/lib/esm/transactionPlan/redeem.js +5 -8
- package/lib/esm/transactionPlan/requirements.d.ts +7 -4
- package/lib/esm/transactionPlan/requirements.js +2 -2
- package/lib/esm/transactionPlan/serde.d.ts +13 -2
- package/lib/esm/transactionPlan/serde.js +49 -2
- package/lib/esm/transactionPlan/types.d.ts +151 -3
- package/lib/esm/transactionPlan/validateActions.d.ts +3 -1
- package/lib/esm/transactionPlan/validateActions.js +31 -3
- package/lib/esm/transactionPlan/validation.d.ts +1 -1
- package/lib/esm/transactionPlan/validation.js +38 -2
- package/lib/esm/transactionPlan/vaultBinding.d.ts +29 -0
- package/lib/esm/transactionPlan/vaultBinding.js +65 -0
- package/lib/esm/transactionPlan/vaultRequirements.d.ts +20 -0
- package/lib/esm/transactionPlan/vaultRequirements.js +34 -0
- package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv1/deposit.js +3 -14
- package/lib/esm/transactionPlan/vaultv1/inKindRedeem.d.ts +2 -2
- package/lib/esm/transactionPlan/vaultv1/inKindRedeem.js +12 -43
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +9 -21
- package/lib/esm/transactionPlan/vaultv1/redeem.js +2 -13
- package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv1/withdraw.js +3 -14
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -14
- package/lib/esm/transactionPlan/vaultv2/forceRedeem.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv2/forceRedeem.js +5 -8
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +2 -2
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +15 -45
- package/lib/esm/transactionPlan/vaultv2/inKindRedeem.d.ts +2 -2
- package/lib/esm/transactionPlan/vaultv2/inKindRedeem.js +12 -43
- package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv2/redeem.js +3 -14
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +3 -14
- package/lib/esm/transactionPlan/withdraw.js +5 -8
- package/lib/esm/types/error.d.ts +4 -1
- package/lib/esm/types/error.js +5 -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
|
@@ -4,18 +4,17 @@ exports.prepareVaultV2ForceWithdraw = prepareVaultV2ForceWithdraw;
|
|
|
4
4
|
exports.buildVaultV2ForceWithdraw = buildVaultV2ForceWithdraw;
|
|
5
5
|
exports.validateForceWithdrawPlanAction = validateForceWithdrawPlanAction;
|
|
6
6
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
7
|
-
const viem_1 = require("viem");
|
|
8
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
9
7
|
const forceWithdraw_js_1 = require("../../actions/vaultV2/forceWithdraw.js");
|
|
10
8
|
const getVaultV2ForceWithdrawRequirements_js_1 = require("../../entities/requirements/getVaultV2ForceWithdrawRequirements.js");
|
|
11
9
|
const forceWithdrawQuote_js_1 = require("../../entities/vaultV2/forceWithdrawQuote.js");
|
|
12
10
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
13
11
|
const index_js_1 = require("../../types/index.js");
|
|
12
|
+
const assemble_js_1 = require("../assemble.js");
|
|
14
13
|
const error_js_1 = require("../error.js");
|
|
15
14
|
const intent_js_1 = require("../intent.js");
|
|
16
15
|
const permit_js_1 = require("../permit.js");
|
|
17
|
-
const requirements_js_1 = require("../requirements.js");
|
|
18
16
|
const validation_js_1 = require("../validation.js");
|
|
17
|
+
const vaultRequirements_js_1 = require("../vaultRequirements.js");
|
|
19
18
|
/**
|
|
20
19
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
21
20
|
* Prepares a static forced-exit plan using shared snapshot quoting and requirement helpers.
|
|
@@ -34,7 +33,7 @@ const validation_js_1 = require("../validation.js");
|
|
|
34
33
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; insufficient allowance produces an unlimited direct share approval, or an unlimited share permit when `true`.
|
|
35
34
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
36
35
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now` and within the fee-projection horizon; defaults to `now + 2h`.
|
|
37
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
36
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
38
37
|
* @returns A deep-frozen plan containing ordered share approvals, if needed, followed by the forced exit and its concrete permit request, if needed.
|
|
39
38
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
40
39
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
@@ -119,31 +118,13 @@ async function prepareVaultV2ForceWithdraw(client, params) {
|
|
|
119
118
|
supportSignature: intent.supportSignature,
|
|
120
119
|
now,
|
|
121
120
|
});
|
|
122
|
-
const approvals =
|
|
123
|
-
|
|
124
|
-
const tokenPermitRequestId = "vaultV2ForceWithdraw:tokenPermit";
|
|
125
|
-
for (const requirement of requirements) {
|
|
126
|
-
if ((0, index_js_1.isRequirementApproval)(requirement)) {
|
|
127
|
-
approvals.push((0, requirements_js_1.buildApprovalStep)(requirement, {
|
|
128
|
-
id: "vaultV2ForceWithdraw:approval",
|
|
129
|
-
chainId,
|
|
130
|
-
account,
|
|
131
|
-
denomination: "shares",
|
|
132
|
-
}));
|
|
133
|
-
}
|
|
134
|
-
else if (requirement.action.type === "permit") {
|
|
135
|
-
signatureRequests.push((0, requirements_js_1.buildPermitSignatureRequest)({ action: requirement.action }, tokenPermitRequestId));
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
throw new index_js_1.UnsupportedRequirementSignatureError(requirement.action.type);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return (0, morpho_ts_1.deepFreeze)(structuredClone({
|
|
142
|
-
version: 2,
|
|
143
|
-
account,
|
|
121
|
+
const { approvals, signatureRequests, signatureRequestIds } = (0, vaultRequirements_js_1.vaultRequirementSteps)(requirements, {
|
|
122
|
+
id: "vaultV2ForceWithdraw",
|
|
144
123
|
chainId,
|
|
145
|
-
|
|
146
|
-
|
|
124
|
+
account,
|
|
125
|
+
});
|
|
126
|
+
return (0, assemble_js_1.freezePlan)({
|
|
127
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
147
128
|
steps: [
|
|
148
129
|
...approvals,
|
|
149
130
|
{
|
|
@@ -152,14 +133,12 @@ async function prepareVaultV2ForceWithdraw(client, params) {
|
|
|
152
133
|
action: {
|
|
153
134
|
type: "vaultV2ForceWithdraw",
|
|
154
135
|
inputs: { ...inputs, assets, chainId, account },
|
|
155
|
-
signatureRequestIds
|
|
156
|
-
? { tokenPermit: tokenPermitRequestId }
|
|
157
|
-
: {},
|
|
136
|
+
signatureRequestIds,
|
|
158
137
|
},
|
|
159
138
|
},
|
|
160
139
|
],
|
|
161
140
|
signatureRequests,
|
|
162
|
-
})
|
|
141
|
+
}, { detach: true });
|
|
163
142
|
}
|
|
164
143
|
/** @internal Encodes the forced exit from fixed inputs and its referenced vault-share permit. */
|
|
165
144
|
function buildVaultV2ForceWithdraw(action, requests) {
|
|
@@ -167,16 +146,7 @@ function buildVaultV2ForceWithdraw(action, requests) {
|
|
|
167
146
|
if (args.minSharePriceE27 <= 0n) {
|
|
168
147
|
throw new index_js_1.NonPositiveInputError("minSharePriceE27", args.minSharePriceE27);
|
|
169
148
|
}
|
|
170
|
-
const
|
|
171
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
172
|
-
asset: action.inputs.vault,
|
|
173
|
-
owner: account,
|
|
174
|
-
});
|
|
175
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
176
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultExitBundlesV1"),
|
|
177
|
-
amount: viem_1.maxUint256,
|
|
178
|
-
deadline: action.inputs.deadline,
|
|
179
|
-
});
|
|
149
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
180
150
|
return (0, forceWithdraw_js_1.vaultV2ForceWithdraw)({
|
|
181
151
|
vault: { chainId, address: action.inputs.vault },
|
|
182
152
|
args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AccrualVaultV2, MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { Address, Client } from "viem";
|
|
3
|
+
import type { ReferenceTimestampParams, Transaction, VaultV2InKindRedeemAction } from "../../types/index.js";
|
|
4
4
|
import { type IntentParams } from "../intent.js";
|
|
5
5
|
import type { Action, SignatureRequest, TransactionPlan } from "../types.js";
|
|
6
6
|
/**
|
|
@@ -4,17 +4,15 @@ exports.prepareVaultV2InKindRedeem = prepareVaultV2InKindRedeem;
|
|
|
4
4
|
exports.buildVaultV2InKindRedeem = buildVaultV2InKindRedeem;
|
|
5
5
|
exports.validateInKindRedeemPlanAction = validateInKindRedeemPlanAction;
|
|
6
6
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
7
|
-
const viem_1 = require("viem");
|
|
8
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
9
7
|
const inKindRedeem_js_1 = require("../../actions/vaultV2/inKindRedeem.js");
|
|
10
8
|
const getVaultV2InKindRedeemRequirements_js_1 = require("../../entities/requirements/getVaultV2InKindRedeemRequirements.js");
|
|
11
9
|
const inKindRedeemQuote_js_1 = require("../../entities/vaultV2/inKindRedeemQuote.js");
|
|
12
10
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
13
|
-
const
|
|
11
|
+
const assemble_js_1 = require("../assemble.js");
|
|
14
12
|
const intent_js_1 = require("../intent.js");
|
|
15
13
|
const permit_js_1 = require("../permit.js");
|
|
16
|
-
const requirements_js_1 = require("../requirements.js");
|
|
17
14
|
const validation_js_1 = require("../validation.js");
|
|
15
|
+
const vaultRequirements_js_1 = require("../vaultRequirements.js");
|
|
18
16
|
/**
|
|
19
17
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
20
18
|
* Prepares the existing Vault V2 in-kind exit through VaultExitBundlesV1. Preparation validates
|
|
@@ -112,31 +110,13 @@ async function prepareVaultV2InKindRedeem(client, params) {
|
|
|
112
110
|
peak: quote.peak,
|
|
113
111
|
now,
|
|
114
112
|
});
|
|
115
|
-
const approvals =
|
|
116
|
-
|
|
117
|
-
const tokenPermit = "vaultV2InKindRedeem:tokenPermit";
|
|
118
|
-
for (const requirement of requirements) {
|
|
119
|
-
if ((0, index_js_1.isRequirementApproval)(requirement)) {
|
|
120
|
-
approvals.push((0, requirements_js_1.buildApprovalStep)(requirement, {
|
|
121
|
-
id: "vaultV2InKindRedeem:approval",
|
|
122
|
-
chainId,
|
|
123
|
-
account,
|
|
124
|
-
denomination: "shares",
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
127
|
-
else if (requirement.action.type === "permit") {
|
|
128
|
-
signatureRequests.push((0, requirements_js_1.buildPermitSignatureRequest)({ action: requirement.action }, tokenPermit));
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
throw new index_js_1.UnsupportedRequirementSignatureError(requirement.action.type);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return (0, morpho_ts_1.deepFreeze)(structuredClone({
|
|
135
|
-
version: 2,
|
|
113
|
+
const { approvals, signatureRequests, signatureRequestIds } = (0, vaultRequirements_js_1.vaultRequirementSteps)(requirements, {
|
|
114
|
+
id: "vaultV2InKindRedeem",
|
|
136
115
|
chainId,
|
|
137
116
|
account,
|
|
138
|
-
|
|
139
|
-
|
|
117
|
+
});
|
|
118
|
+
return (0, assemble_js_1.freezePlan)({
|
|
119
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
140
120
|
steps: [
|
|
141
121
|
...approvals,
|
|
142
122
|
{
|
|
@@ -145,28 +125,17 @@ async function prepareVaultV2InKindRedeem(client, params) {
|
|
|
145
125
|
action: {
|
|
146
126
|
type: "vaultV2InKindRedeem",
|
|
147
127
|
inputs: { ...inputs, assets, chainId, account },
|
|
148
|
-
signatureRequestIds
|
|
149
|
-
? { tokenPermit }
|
|
150
|
-
: {},
|
|
128
|
+
signatureRequestIds,
|
|
151
129
|
},
|
|
152
130
|
},
|
|
153
131
|
],
|
|
154
132
|
signatureRequests,
|
|
155
|
-
})
|
|
133
|
+
}, { detach: true });
|
|
156
134
|
}
|
|
157
135
|
/** @internal Encodes only the saved inputs and referenced unlimited share permit. */
|
|
158
136
|
function buildVaultV2InKindRedeem(action, requests) {
|
|
159
137
|
const { chainId, account, assets, ...args } = action.inputs;
|
|
160
|
-
const
|
|
161
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
162
|
-
asset: args.vault,
|
|
163
|
-
owner: account,
|
|
164
|
-
});
|
|
165
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
166
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultExitBundlesV1"),
|
|
167
|
-
amount: viem_1.maxUint256,
|
|
168
|
-
deadline: args.deadline,
|
|
169
|
-
});
|
|
138
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
170
139
|
return (0, inKindRedeem_js_1.vaultV2InKindRedeem)({
|
|
171
140
|
vault: { chainId, address: args.vault },
|
|
172
141
|
args: {
|
|
@@ -40,7 +40,7 @@ export interface VaultV2RedeemPlanParams extends RedeemPlanParams {
|
|
|
40
40
|
* @param params.supportSignature - Optional ERC-2612 share-permit preference; defaults to `false` for direct approval.
|
|
41
41
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
42
42
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` (device clock when `now` is omitted).
|
|
43
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
43
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
44
44
|
* @returns A deep-frozen, serializable `TransactionPlan` with version, chain, account, expiry,
|
|
45
45
|
* ordered approval/redeem steps and signature requests. Any required share approval or permit is unlimited.
|
|
46
46
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareVaultV2Redeem = prepareVaultV2Redeem;
|
|
4
4
|
exports.buildVaultV2Redeem = buildVaultV2Redeem;
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
7
5
|
const redeem_js_1 = require("../../actions/vaultV2/redeem.js");
|
|
8
6
|
const permit_js_1 = require("../permit.js");
|
|
9
7
|
const redeem_js_2 = require("../redeem.js");
|
|
@@ -21,7 +19,7 @@ const redeem_js_2 = require("../redeem.js");
|
|
|
21
19
|
* @param params.supportSignature - Optional ERC-2612 share-permit preference; defaults to `false` for direct approval.
|
|
22
20
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
23
21
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` (device clock when `now` is omitted).
|
|
24
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
22
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
25
23
|
* @returns A deep-frozen, serializable `TransactionPlan` with version, chain, account, expiry,
|
|
26
24
|
* ordered approval/redeem steps and signature requests. Any required share approval or permit is unlimited.
|
|
27
25
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
@@ -64,16 +62,7 @@ async function prepareVaultV2Redeem(client, params) {
|
|
|
64
62
|
/** @internal Encodes a redemption from its fixed inputs and referenced share permit. */
|
|
65
63
|
function buildVaultV2Redeem(action, requests) {
|
|
66
64
|
const { chainId, account, vault, shares, ...common } = action.inputs;
|
|
67
|
-
const
|
|
68
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
69
|
-
asset: vault,
|
|
70
|
-
owner: account,
|
|
71
|
-
});
|
|
72
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
73
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1"),
|
|
74
|
-
amount: shares,
|
|
75
|
-
deadline: action.inputs.deadline,
|
|
76
|
-
});
|
|
65
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
77
66
|
return (0, redeem_js_1.vaultV2Redeem)({
|
|
78
67
|
vault: { chainId, address: vault },
|
|
79
68
|
args: {
|
|
@@ -28,7 +28,7 @@ export interface VaultV2WithdrawPlanParams extends WithdrawPlanParams<AccrualVau
|
|
|
28
28
|
* @param params.supportSignature - Optional unlimited share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient.
|
|
29
29
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
30
30
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` (device clock when `now` is omitted).
|
|
31
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
31
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
32
32
|
* @returns A plan with the withdrawal step and any required share approval or signature request.
|
|
33
33
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
34
34
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareVaultV2Withdraw = prepareVaultV2Withdraw;
|
|
4
4
|
exports.buildVaultV2Withdraw = buildVaultV2Withdraw;
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
7
5
|
const withdraw_js_1 = require("../../actions/vaultV2/withdraw.js");
|
|
8
6
|
const permit_js_1 = require("../permit.js");
|
|
9
7
|
const withdraw_js_2 = require("../withdraw.js");
|
|
@@ -26,7 +24,7 @@ const withdraw_js_2 = require("../withdraw.js");
|
|
|
26
24
|
* @param params.supportSignature - Optional unlimited share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient.
|
|
27
25
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
28
26
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` (device clock when `now` is omitted).
|
|
29
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
27
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
30
28
|
* @returns A plan with the withdrawal step and any required share approval or signature request.
|
|
31
29
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
32
30
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
@@ -63,16 +61,7 @@ async function prepareVaultV2Withdraw(client, params) {
|
|
|
63
61
|
/** @internal Encodes the withdrawal from its self-contained inputs and resolved signature requests. */
|
|
64
62
|
function buildVaultV2Withdraw(action, requests) {
|
|
65
63
|
const { requiredShareAllowance, chainId, account, assets, ...args } = action.inputs;
|
|
66
|
-
const
|
|
67
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
68
|
-
asset: action.inputs.vault,
|
|
69
|
-
owner: account,
|
|
70
|
-
});
|
|
71
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
72
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1"),
|
|
73
|
-
amount: requiredShareAllowance,
|
|
74
|
-
deadline: action.inputs.deadline,
|
|
75
|
-
});
|
|
64
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
76
65
|
return (0, withdraw_js_1.vaultV2Withdraw)({
|
|
77
66
|
vault: { chainId, address: action.inputs.vault },
|
|
78
67
|
args: {
|
|
@@ -8,6 +8,7 @@ const common_js_1 = require("../actions/bundles/common.js");
|
|
|
8
8
|
const index_js_1 = require("../helpers/index.js");
|
|
9
9
|
const validate_js_1 = require("../helpers/validate.js");
|
|
10
10
|
const index_js_2 = require("../types/index.js");
|
|
11
|
+
const assemble_js_1 = require("./assemble.js");
|
|
11
12
|
const intent_js_1 = require("./intent.js");
|
|
12
13
|
const shareSpending_js_1 = require("./shareSpending.js");
|
|
13
14
|
const validation_js_1 = require("./validation.js");
|
|
@@ -62,12 +63,8 @@ async function prepareVaultWithdraw(client, params) {
|
|
|
62
63
|
supportSignature: intent.supportSignature,
|
|
63
64
|
now,
|
|
64
65
|
});
|
|
65
|
-
return (0,
|
|
66
|
-
|
|
67
|
-
account,
|
|
68
|
-
chainId,
|
|
69
|
-
expiresAt: intent.expiresAt,
|
|
70
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
66
|
+
return (0, assemble_js_1.freezePlan)({
|
|
67
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
71
68
|
steps: [
|
|
72
69
|
...approvals,
|
|
73
70
|
{
|
|
@@ -90,5 +87,5 @@ async function prepareVaultWithdraw(client, params) {
|
|
|
90
87
|
},
|
|
91
88
|
],
|
|
92
89
|
signatureRequests,
|
|
93
|
-
})
|
|
90
|
+
}, { detach: true });
|
|
94
91
|
}
|
package/lib/cjs/types/error.d.ts
CHANGED
|
@@ -840,7 +840,8 @@ export declare class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
|
840
840
|
* ```
|
|
841
841
|
*/
|
|
842
842
|
export declare class InvalidVaultV2BlueReallocationShapeError extends Error {
|
|
843
|
-
|
|
843
|
+
/** @param options - Optional underlying failure, kept as `cause`. */
|
|
844
|
+
constructor(options?: ErrorOptions);
|
|
844
845
|
}
|
|
845
846
|
/**
|
|
846
847
|
* Thrown when a Blue Public Allocator reallocation contains a malformed vault
|
|
@@ -1683,6 +1684,8 @@ export declare class MidnightCalldataEncodingError extends Error {
|
|
|
1683
1684
|
* pulled with native funding, or the token checked by
|
|
1684
1685
|
* `getMidnightApprovalRequirements`). `"blueMarket"` reports the Blue market encoding in
|
|
1685
1686
|
* `supplyBlueMakeLend`: a malformed address or an out-of-range `lltv`.
|
|
1687
|
+
* TransactionPlan take preparers report a malformed taken offer field by its path, such as
|
|
1688
|
+
* `"takeableOffers[i].offer.maker"` or `"takeableOffers[i].units"`.
|
|
1686
1689
|
* @param cause - viem encoding error.
|
|
1687
1690
|
*/
|
|
1688
1691
|
constructor(input: string, cause: BaseError);
|
package/lib/cjs/types/error.js
CHANGED
|
@@ -1113,8 +1113,9 @@ exports.ReallocationWithdrawalOnTargetMarketError = ReallocationWithdrawalOnTarg
|
|
|
1113
1113
|
* ```
|
|
1114
1114
|
*/
|
|
1115
1115
|
class InvalidVaultV2BlueReallocationShapeError extends Error {
|
|
1116
|
-
|
|
1117
|
-
|
|
1116
|
+
/** @param options - Optional underlying failure, kept as `cause`. */
|
|
1117
|
+
constructor(options) {
|
|
1118
|
+
super("Reallocation entry is not a valid Vault V2 reallocation. High-level Blue writes accept only VaultV2BlueReallocation entries (e.g. from getVaultV2BlueReallocations()). Use morpho-sdk v5 if Vault V1 reallocations are required.", options);
|
|
1118
1119
|
this.name = "InvalidVaultV2BlueReallocationShapeError";
|
|
1119
1120
|
}
|
|
1120
1121
|
}
|
|
@@ -2172,6 +2173,8 @@ class MidnightCalldataEncodingError extends Error {
|
|
|
2172
2173
|
* pulled with native funding, or the token checked by
|
|
2173
2174
|
* `getMidnightApprovalRequirements`). `"blueMarket"` reports the Blue market encoding in
|
|
2174
2175
|
* `supplyBlueMakeLend`: a malformed address or an out-of-range `lltv`.
|
|
2176
|
+
* TransactionPlan take preparers report a malformed taken offer field by its path, such as
|
|
2177
|
+
* `"takeableOffers[i].offer.maker"` or `"takeableOffers[i].units"`.
|
|
2175
2178
|
* @param cause - viem encoding error.
|
|
2176
2179
|
*/
|
|
2177
2180
|
constructor(input, cause) {
|
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { AdaptiveCurveIrmLib as BlueAdaptiveCurveIrmLib, CapacityLimitReason,
|
|
|
3
3
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
4
|
defaultPreLiquidationParamsRegistry as blueDefaultPreLiquidationParamsRegistry,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
|
-
getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
6
|
+
getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2MidnightAdapterUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
7
7
|
export { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData as getBlueAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, MetaMorphoAction as BlueMetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
|
8
8
|
export { EcrecoverRatifier as MidnightEcrecoverRatifier,
|
|
9
9
|
/** @deprecated Use MidnightEcrecoverRatifier with a tagged tree. */
|
|
@@ -17,7 +17,7 @@ RatifierUtils as MidnightRatifierUtils, SetterRatifier as MidnightSetterRatifier
|
|
|
17
17
|
/** @deprecated Use MidnightSetterRatifier with a tagged tree. */
|
|
18
18
|
SetterRatifierUtils as MidnightSetterRatifierUtils, TakeAmountsLib as MidnightTakeAmountsLib, TickLib as MidnightTickLib, TreeUtils as MidnightTreeUtils, } from "@morpho-org/midnight-sdk";
|
|
19
19
|
export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, } from "@morpho-org/morpho-ts";
|
|
20
|
-
export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
|
|
20
|
+
export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, MidnightPositionLib, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
|
|
21
21
|
export { validateClientChainId } from "./actions/requirements/validateClientChainId.js";
|
|
22
22
|
export { addTransactionMetadata } from "./helpers/metadata.js";
|
|
23
23
|
export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./helpers/previewVaultV2ForceWithdraw.js";
|
package/lib/cjs/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinForceWithdrawSharePrice = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.validateClientChainId = exports.values = exports.transformValue = exports.Time = exports.retryPromiseLinearBackoff = exports.mergeEntries = exports.keys = exports.isNotUndefined = exports.isNotNull = exports.isDefined = exports.hasValue = exports.getValue = exports.getSubdomainBaseUrl = exports.getLastDefined = exports.getLast = exports.fromEntries = exports.filterDefined = exports.entries = exports.deepFreeze = void 0;
|
|
3
|
+
exports.createGetValue = exports.bigIntComparator = exports.MidnightTreeUtils = exports.MidnightTickLib = exports.MidnightTakeAmountsLib = exports.MidnightSetterRatifierUtils = exports.MidnightSetterRatifier = exports.MidnightRatifierUtils = exports.MidnightRatifier = exports.MidnightRateRatifierV1Utils = exports.MidnightRateRatifierV1 = exports.MidnightPriceRatifierV1Utils = exports.MidnightPriceRatifierV1 = exports.MidnightPositionUtils = exports.MidnightPayload = exports.MidnightOfferUtils = exports.MidnightOfferChainUtils = exports.MidnightMarketUtils = exports.MidnightGroupUtils = exports.eip712Digest = exports.MidnightEcrecoverRatifierUtils = exports.MidnightEcrecoverRatifier = exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.BlueMetaMorphoAction = exports.isUndecodableResultError = exports.isTransportError = exports.isContractRevertError = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getBlueAuthorizationTypedData = exports.decodeBytes32String = exports.catchRevertOnly = exports.VaultV2Utils = exports.VaultV2MidnightAdapterUtils = exports.VaultV2BluePublicAllocatorConfigUtils = exports.VaultV2BlueMarketPublicAllocatorConfigUtils = exports.VaultUtils = exports.BlueSharesMath = exports.MathLib = exports.BlueMarketUtils = exports.getBlueDefaultPreLiquidationParams = exports.blueDefaultPreLiquidationParamsRegistry = exports.CapacityLimitReason = exports.BlueAdaptiveCurveIrmLib = void 0;
|
|
4
|
+
exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinForceWithdrawSharePrice = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.validateClientChainId = exports.values = exports.transformValue = exports.Time = exports.retryPromiseLinearBackoff = exports.mergeEntries = exports.MidnightPositionLib = exports.keys = exports.isNotUndefined = exports.isNotNull = exports.isDefined = exports.hasValue = exports.getValue = exports.getSubdomainBaseUrl = exports.getLastDefined = exports.getLast = exports.fromEntries = exports.filterDefined = exports.entries = exports.deepFreeze = exports.createHasValue = void 0;
|
|
5
5
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
6
|
Object.defineProperty(exports, "BlueAdaptiveCurveIrmLib", { enumerable: true, get: function () { return blue_sdk_1.AdaptiveCurveIrmLib; } });
|
|
7
7
|
Object.defineProperty(exports, "CapacityLimitReason", { enumerable: true, get: function () { return blue_sdk_1.CapacityLimitReason; } });
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "BlueSharesMath", { enumerable: true, get: functi
|
|
|
15
15
|
Object.defineProperty(exports, "VaultUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultUtils; } });
|
|
16
16
|
Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfigUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfigUtils; } });
|
|
17
17
|
Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfigUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfigUtils; } });
|
|
18
|
+
Object.defineProperty(exports, "VaultV2MidnightAdapterUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MidnightAdapterUtils; } });
|
|
18
19
|
Object.defineProperty(exports, "VaultV2Utils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Utils; } });
|
|
19
20
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
20
21
|
Object.defineProperty(exports, "catchRevertOnly", { enumerable: true, get: function () { return blue_sdk_viem_1.catchRevertOnly; } });
|
|
@@ -76,6 +77,7 @@ Object.defineProperty(exports, "isDefined", { enumerable: true, get: function ()
|
|
|
76
77
|
Object.defineProperty(exports, "isNotNull", { enumerable: true, get: function () { return morpho_ts_1.isNotNull; } });
|
|
77
78
|
Object.defineProperty(exports, "isNotUndefined", { enumerable: true, get: function () { return morpho_ts_1.isNotUndefined; } });
|
|
78
79
|
Object.defineProperty(exports, "keys", { enumerable: true, get: function () { return morpho_ts_1.keys; } });
|
|
80
|
+
Object.defineProperty(exports, "MidnightPositionLib", { enumerable: true, get: function () { return morpho_ts_1.MidnightPositionLib; } });
|
|
79
81
|
Object.defineProperty(exports, "mergeEntries", { enumerable: true, get: function () { return morpho_ts_1.mergeEntries; } });
|
|
80
82
|
Object.defineProperty(exports, "retryPromiseLinearBackoff", { enumerable: true, get: function () { return morpho_ts_1.retryPromiseLinearBackoff; } });
|
|
81
83
|
Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return morpho_ts_1.Time; } });
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Installed @morpho-org/morpho-sdk package version. */
|
|
2
|
-
export declare const version = "10.
|
|
2
|
+
export declare const version = "10.5.0-next.0";
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/abis.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare const bundlesPermitParameters: {
|
|
|
33
33
|
}];
|
|
34
34
|
};
|
|
35
35
|
export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
|
|
36
|
-
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
36
|
+
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
37
37
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
38
38
|
preLiquidationAbi as bluePreLiquidationAbi,
|
|
39
39
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
package/lib/esm/abis.js
CHANGED
|
@@ -19,7 +19,7 @@ export const bundlesPermitParameters = {
|
|
|
19
19
|
],
|
|
20
20
|
};
|
|
21
21
|
export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
|
|
22
|
-
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
22
|
+
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
23
23
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
24
24
|
preLiquidationAbi as bluePreLiquidationAbi,
|
|
25
25
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MarketUtils, MathLib, VaultV2BluePublicAllocatorConfigUtils, } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
|
|
3
3
|
import { isAddressEqual, zeroAddress, zeroHash, } from "viem";
|
|
4
4
|
import { addTransactionMetadata } from "../../helpers/index.js";
|
|
@@ -103,9 +103,18 @@ export const parseBlueAllocations = (reallocations, { marketParams: targetMarket
|
|
|
103
103
|
targetMarketId: targetMarketParams.id,
|
|
104
104
|
maxPenalty,
|
|
105
105
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
const idle = {
|
|
107
|
+
loanToken: targetMarketParams.loanToken,
|
|
108
|
+
collateralToken: zeroAddress,
|
|
109
|
+
oracle: zeroAddress,
|
|
110
|
+
irm: zeroAddress,
|
|
111
|
+
lltv: 0n,
|
|
112
|
+
};
|
|
113
|
+
const idleMarketParams = parseBlueMarket({
|
|
114
|
+
...idle,
|
|
115
|
+
id: MarketUtils.getMarketId(idle),
|
|
116
|
+
liquidationIncentiveFactor: MarketUtils.getLiquidationIncentiveFactor(idle),
|
|
117
|
+
});
|
|
109
118
|
const publicAllocations = snapshots.map((reallocation) => {
|
|
110
119
|
if (reallocation.from.type === "market" &&
|
|
111
120
|
!isAddressEqual(reallocation.from.marketParams.loanToken, targetMarketParams.loanToken)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { MarketInput } from "@morpho-org/midnight-sdk";
|
|
2
|
-
import type
|
|
1
|
+
import type { AccrualPosition, MarketInput } from "@morpho-org/midnight-sdk";
|
|
2
|
+
import { type Address } from "viem";
|
|
3
3
|
import { type MidnightMarket } from "../../helpers/parseMidnight.js";
|
|
4
|
-
import type
|
|
4
|
+
import { type Metadata, type MidnightRedeemAction, type Transaction } from "../../types/index.js";
|
|
5
5
|
/** Parameters for encoding a direct Midnight credit redemption. */
|
|
6
6
|
export interface MidnightRedeemParams {
|
|
7
7
|
readonly chainId: number;
|
|
@@ -63,4 +63,21 @@ export interface ParsedMidnightRedeem extends Omit<MidnightRedeemParams, "market
|
|
|
63
63
|
}
|
|
64
64
|
/** Parses static redeem constraints using the existing error order. @internal */
|
|
65
65
|
export declare const parseMidnightRedeem: (params: MidnightRedeemParams) => ParsedMidnightRedeem;
|
|
66
|
+
/** Owner-bound position snapshot and optional amounts for a redemption. @internal */
|
|
67
|
+
export interface MidnightRedeemPreparationParams {
|
|
68
|
+
readonly chainId: number;
|
|
69
|
+
readonly accountAddress: Address;
|
|
70
|
+
readonly positionData: AccrualPosition;
|
|
71
|
+
readonly units?: bigint;
|
|
72
|
+
readonly receiver?: Address;
|
|
73
|
+
readonly now: bigint;
|
|
74
|
+
readonly metadata?: Metadata;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Owns redemption defaults and snapshot-dependent amount constraints in the same order as the
|
|
78
|
+
* entity `redeem`, then mints the complete redeem contract. Used by TransactionPlan preparation;
|
|
79
|
+
* the entity keeps its own copy of these checks.
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
export declare const parseMidnightRedeemPreparation: (params: MidnightRedeemPreparationParams) => ParsedMidnightRedeem;
|
|
66
83
|
export {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { MathLib } from "@morpho-org/blue-sdk";
|
|
1
2
|
import { deepFreeze } from "@morpho-org/morpho-ts";
|
|
3
|
+
import { isAddressEqual } from "viem";
|
|
2
4
|
import { parseMidnightAddress, parseMidnightMarket, parseMidnightOwner, parseMidnightPositiveAmount, } from "../../helpers/parseMidnight.js";
|
|
5
|
+
import { validateMidnightAddress } from "../../helpers/validateMidnightAccount.js";
|
|
3
6
|
import { validateMidnightReceiver } from "../../helpers/validateMidnightReceiver.js";
|
|
7
|
+
import { AccrualPositionUserMismatchError, InsufficientMidnightWithdrawableLiquidityError, MidnightRedeemExceedsCreditError, MissingAccrualPositionError, NoMidnightCreditToRedeemError, } from "../../types/index.js";
|
|
4
8
|
import { encodeMidnightRedeem } from "./encode.js";
|
|
5
9
|
import { snapshotMidnightMetadata } from "./parse.js";
|
|
6
10
|
/**
|
|
@@ -70,3 +74,55 @@ export const parseMidnightRedeem = (params) => {
|
|
|
70
74
|
[parsedRedeem]: true,
|
|
71
75
|
});
|
|
72
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Owns redemption defaults and snapshot-dependent amount constraints in the same order as the
|
|
79
|
+
* entity `redeem`, then mints the complete redeem contract. Used by TransactionPlan preparation;
|
|
80
|
+
* the entity keeps its own copy of these checks.
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
export const parseMidnightRedeemPreparation = (params) => {
|
|
84
|
+
const address = parseMidnightAddress("accountAddress", params.accountAddress);
|
|
85
|
+
if (!params.positionData) {
|
|
86
|
+
throw new MissingAccrualPositionError();
|
|
87
|
+
}
|
|
88
|
+
if (params.positionData.user != null) {
|
|
89
|
+
validateMidnightAddress("positionData.user", params.positionData.user);
|
|
90
|
+
}
|
|
91
|
+
if (params.positionData.user == null ||
|
|
92
|
+
!isAddressEqual(params.positionData.user, address)) {
|
|
93
|
+
throw new AccrualPositionUserMismatchError(params.positionData.user ?? "unbound", address);
|
|
94
|
+
}
|
|
95
|
+
const marketData = params.positionData.market;
|
|
96
|
+
// Reject market/deployment errors before snapshot accrual and amount checks.
|
|
97
|
+
const market = parseMidnightMarket(marketData, params.chainId);
|
|
98
|
+
const accrued = params.positionData.accrueInterest(MathLib.max(params.now, params.positionData.lastAccrual));
|
|
99
|
+
const units = params.units ?? accrued.faceValue;
|
|
100
|
+
if (params.units === undefined && units <= 0n) {
|
|
101
|
+
throw new NoMidnightCreditToRedeemError(marketData.id);
|
|
102
|
+
}
|
|
103
|
+
// Bound the resolved amount before checking credit and liquidity.
|
|
104
|
+
parseMidnightPositiveAmount("units", units);
|
|
105
|
+
if (accrued.credit < units) {
|
|
106
|
+
throw new MidnightRedeemExceedsCreditError({
|
|
107
|
+
market: marketData.id,
|
|
108
|
+
units,
|
|
109
|
+
credit: accrued.credit,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (marketData.withdrawable < units) {
|
|
113
|
+
throw new InsufficientMidnightWithdrawableLiquidityError({
|
|
114
|
+
market: marketData.id,
|
|
115
|
+
units,
|
|
116
|
+
withdrawable: marketData.withdrawable,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
// The owning action constructor mints the complete contract only after snapshot checks.
|
|
120
|
+
return parseMidnightRedeem({
|
|
121
|
+
chainId: params.chainId,
|
|
122
|
+
market: market.struct,
|
|
123
|
+
units,
|
|
124
|
+
onBehalf: address,
|
|
125
|
+
receiver: params.receiver ?? address,
|
|
126
|
+
metadata: params.metadata,
|
|
127
|
+
});
|
|
128
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type MarketInput } from "@morpho-org/midnight-sdk";
|
|
1
|
+
import { type MarketInput, MarketUtils } from "@morpho-org/midnight-sdk";
|
|
2
2
|
import { type Address } from "viem";
|
|
3
|
+
import { encodeMidnightMarketId } from "../../helpers/encodeMidnightCalldata.js";
|
|
3
4
|
import { type Metadata, type MidnightSupplyCollateralWithNativeAction, type Transaction } from "../../types/index.js";
|
|
4
5
|
/** Parameters for encoding a Midnight collateral supply. */
|
|
5
6
|
export interface MidnightSupplyCollateralWithNativeParams {
|
|
@@ -75,3 +76,25 @@ export declare function prepareMidnightSupplyCollateralWithNative(params: Midnig
|
|
|
75
76
|
token: `0x${string}`;
|
|
76
77
|
tx: Transaction<MidnightSupplyCollateralWithNativeAction>;
|
|
77
78
|
};
|
|
79
|
+
/** Owned native collateral supply inputs, checked in the encoder's order. @internal */
|
|
80
|
+
export interface ParsedMidnightSupplyCollateralWithNative {
|
|
81
|
+
readonly chainId: number;
|
|
82
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
83
|
+
readonly marketId: ReturnType<typeof encodeMidnightMarketId>;
|
|
84
|
+
readonly collateralIndex: bigint;
|
|
85
|
+
readonly assets: bigint;
|
|
86
|
+
/** wNative collateral pulled from the sender. */
|
|
87
|
+
readonly token: Address;
|
|
88
|
+
readonly accountAddress: Address;
|
|
89
|
+
/** Native funding sent as transaction value. */
|
|
90
|
+
readonly value: bigint;
|
|
91
|
+
readonly wrappedNative: Address;
|
|
92
|
+
readonly deadline: bigint;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Parses a native collateral supply with the same checks, in the same order, as
|
|
96
|
+
* `midnightSupplyCollateralWithNative`, without encoding the bundle call. Resolving
|
|
97
|
+
* MidnightBundlesV2 is left to the caller. `assetsField` names the amount in its errors, so a
|
|
98
|
+
* caller can report its own parameter name. @internal
|
|
99
|
+
*/
|
|
100
|
+
export declare function parseMidnightSupplyCollateralWithNative(params: Omit<MidnightSupplyCollateralWithNativeParams, "metadata">, assetsField?: "assets" | "collateralAssets"): ParsedMidnightSupplyCollateralWithNative;
|