@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
package/lib/cjs/errors.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightRatifierV1AddressError = exports.InvalidMidnightRateRatifierV1TimeError = exports.InvalidMidnightRateRatifierV1TickError = exports.InvalidMidnightRateRatifierV1RateError = exports.
|
|
4
|
-
exports.RetryStoppedError = exports.RetriesExhaustedError = exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.MissingLocalePartError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightRatifierV1TakerNotAllowedError = exports.MidnightRateRatifierV1BoundOverflowError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError =
|
|
3
|
+
exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightRatifierV1AddressError = exports.InvalidMidnightRateRatifierV1TimeError = exports.InvalidMidnightRateRatifierV1TickError = exports.InvalidMidnightRateRatifierV1RateError = exports.InvalidMidnightOfferParameterError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.InvalidMidnightEcrecoverSignatureError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.UnresolvedBlockNumberError = exports.UnnamedAbiOutputsError = exports.UnknownAbiFunctionError = exports.Permit2ExpirationOutOfRangeError = exports.NonTupleReturnValueError = exports.MissingPermitDomainNameError = exports.BlueMarketParamsIdMismatchError = exports.MalformedTokenMetadataError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownBlueVaultConfigError = exports.UnknownBlueTokenPriceError = exports.UnknownBlueTokenError = exports.UnknownBlueOfFactory = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownBlueFactory = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidBlueVaultV2MidnightAdapterMarketsError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
|
|
4
|
+
exports.RetryStoppedError = exports.RetriesExhaustedError = exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.MissingLocalePartError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightRatifierV1TakerNotAllowedError = exports.MidnightRateRatifierV1BoundOverflowError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = void 0;
|
|
5
5
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
6
|
Object.defineProperty(exports, "BlueErrors", { enumerable: true, get: function () { return blue_sdk_1.BlueErrors; } });
|
|
7
7
|
Object.defineProperty(exports, "IncompleteChainRegistryError", { enumerable: true, get: function () { return blue_sdk_1.IncompleteChainRegistryError; } });
|
|
8
8
|
Object.defineProperty(exports, "InvalidBlueMarketParamsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidMarketParamsError; } });
|
|
9
|
+
Object.defineProperty(exports, "InvalidBlueVaultV2MidnightAdapterMarketsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidVaultV2MidnightAdapterMarketsError; } });
|
|
9
10
|
Object.defineProperty(exports, "UnknownAddressError", { enumerable: true, get: function () { return blue_sdk_1.UnknownAddressError; } });
|
|
10
11
|
Object.defineProperty(exports, "UnknownBlueDataError", { enumerable: true, get: function () { return blue_sdk_1.UnknownDataError; } });
|
|
11
12
|
Object.defineProperty(exports, "UnknownBlueFactory", { enumerable: true, get: function () { return blue_sdk_1.UnknownFactory; } });
|
|
@@ -34,6 +35,7 @@ Object.defineProperty(exports, "NonTupleReturnValueError", { enumerable: true, g
|
|
|
34
35
|
Object.defineProperty(exports, "Permit2ExpirationOutOfRangeError", { enumerable: true, get: function () { return blue_sdk_viem_1.Permit2ExpirationOutOfRangeError; } });
|
|
35
36
|
Object.defineProperty(exports, "UnknownAbiFunctionError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnknownAbiFunctionError; } });
|
|
36
37
|
Object.defineProperty(exports, "UnnamedAbiOutputsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnnamedAbiOutputsError; } });
|
|
38
|
+
Object.defineProperty(exports, "UnresolvedBlockNumberError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnresolvedBlockNumberError; } });
|
|
37
39
|
Object.defineProperty(exports, "UnsupportedPermitDomainExtensionsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnsupportedPermitDomainExtensionsError; } });
|
|
38
40
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
39
41
|
Object.defineProperty(exports, "MidnightChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
|
|
@@ -44,9 +46,6 @@ Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerabl
|
|
|
44
46
|
Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
|
|
45
47
|
Object.defineProperty(exports, "InvalidMidnightOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
|
|
46
48
|
Object.defineProperty(exports, "InvalidMidnightOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
|
|
47
|
-
Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
|
|
48
|
-
Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
|
|
49
|
-
Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
|
|
50
49
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
|
|
51
50
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
|
|
52
51
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
|
|
@@ -69,6 +68,9 @@ Object.defineProperty(exports, "_try", { enumerable: true, get: function () { re
|
|
|
69
68
|
Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return morpho_ts_1.DivisionByZeroError; } });
|
|
70
69
|
Object.defineProperty(exports, "InvalidAddressError", { enumerable: true, get: function () { return morpho_ts_1.InvalidAddressError; } });
|
|
71
70
|
Object.defineProperty(exports, "InvalidBitLengthError", { enumerable: true, get: function () { return morpho_ts_1.InvalidBitLengthError; } });
|
|
71
|
+
Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
|
|
72
|
+
Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
|
|
73
|
+
Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
|
|
72
74
|
Object.defineProperty(exports, "MissingLocalePartError", { enumerable: true, get: function () { return morpho_ts_1.MissingLocalePartError; } });
|
|
73
75
|
Object.defineProperty(exports, "NegativeValueError", { enumerable: true, get: function () { return morpho_ts_1.NegativeValueError; } });
|
|
74
76
|
Object.defineProperty(exports, "RegistryValueAlreadyRegisteredError", { enumerable: true, get: function () { return morpho_ts_1.RegistryValueAlreadyRegisteredError; } });
|
package/lib/cjs/fetch.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
|
|
1
|
+
export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MidnightAdapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
fetchPreLiquidationParams as fetchBluePreLiquidationParams,
|
|
4
4
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
-
fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
+
fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MidnightAdapter, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
6
6
|
export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
|
package/lib/cjs/fetch.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchMidnightRatifierInfo = exports.fetchMidnightPosition = exports.fetchMidnightMarketParams = exports.fetchMidnightMarket = exports.fetchMidnightAccrualPosition = exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.fetchVaultV2BluePublicAllocatorData = exports.fetchVaultV2BluePublicAllocatorConfig = exports.fetchVaultV2BlueMarketPublicAllocatorConfig = exports.fetchVaultV2Adapter = exports.fetchVaultV2 = exports.fetchVaultUser = exports.fetchVaultMarketConfig = exports.fetchVaultMarketAllocation = exports.fetchVaultConfig = exports.fetchVault = exports.fetchBlueUser = exports.fetchToken = exports.fetchBluePreLiquidationPosition = exports.fetchBluePreLiquidationParams = exports.fetchBluePosition = exports.fetchBlueMarketParams = exports.fetchBlueMarket = exports.fetchHolding = exports.fetchAccrualVaultV2MorphoVaultV1Adapter = exports.fetchAccrualVaultV2MorphoMarketV1AdapterV2 = exports.fetchAccrualVaultV2MorphoMarketV1Adapter = exports.fetchAccrualVaultV2Adapter = exports.fetchAccrualVaultV2 = exports.fetchAccrualVault = exports.fetchBlueAccrualPosition = void 0;
|
|
3
|
+
exports.fetchMidnightRatifierInfo = exports.fetchMidnightPosition = exports.fetchMidnightMarketParams = exports.fetchMidnightMarket = exports.fetchMidnightAccrualPosition = exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.fetchVaultV2MidnightAdapter = exports.fetchVaultV2BluePublicAllocatorData = exports.fetchVaultV2BluePublicAllocatorConfig = exports.fetchVaultV2BlueMarketPublicAllocatorConfig = exports.fetchVaultV2Adapter = exports.fetchVaultV2 = exports.fetchVaultUser = exports.fetchVaultMarketConfig = exports.fetchVaultMarketAllocation = exports.fetchVaultConfig = exports.fetchVault = exports.fetchBlueUser = exports.fetchToken = exports.fetchBluePreLiquidationPosition = exports.fetchBluePreLiquidationParams = exports.fetchBluePosition = exports.fetchBlueMarketParams = exports.fetchBlueMarket = exports.fetchHolding = exports.fetchAccrualVaultV2MorphoVaultV1Adapter = exports.fetchAccrualVaultV2MorphoMarketV1AdapterV2 = exports.fetchAccrualVaultV2MorphoMarketV1Adapter = exports.fetchAccrualVaultV2MidnightAdapter = exports.fetchAccrualVaultV2Adapter = exports.fetchAccrualVaultV2 = exports.fetchAccrualVault = exports.fetchBlueAccrualPosition = void 0;
|
|
4
4
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
5
5
|
Object.defineProperty(exports, "fetchBlueAccrualPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualPosition; } });
|
|
6
6
|
Object.defineProperty(exports, "fetchAccrualVault", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVault; } });
|
|
7
7
|
Object.defineProperty(exports, "fetchAccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2; } });
|
|
8
8
|
Object.defineProperty(exports, "fetchAccrualVaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2Adapter; } });
|
|
9
|
+
Object.defineProperty(exports, "fetchAccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MidnightAdapter; } });
|
|
9
10
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1Adapter; } });
|
|
10
11
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1AdapterV2; } });
|
|
11
12
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -29,6 +30,7 @@ Object.defineProperty(exports, "fetchVaultV2Adapter", { enumerable: true, get: f
|
|
|
29
30
|
Object.defineProperty(exports, "fetchVaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BlueMarketPublicAllocatorConfig; } });
|
|
30
31
|
Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorConfig; } });
|
|
31
32
|
Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorData", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorData; } });
|
|
33
|
+
Object.defineProperty(exports, "fetchVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MidnightAdapter; } });
|
|
32
34
|
Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1Adapter; } });
|
|
33
35
|
Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1AdapterV2; } });
|
|
34
36
|
Object.defineProperty(exports, "fetchVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -4,7 +4,8 @@ import { type Address, type Hex } from "viem";
|
|
|
4
4
|
* Computes the CREATE2 address of `owner`'s `BlueBuyCallback` for `salt`, as deployed or
|
|
5
5
|
* returned by the chain's `midnightBlueBuyCallbackFactory.createBlueBuyCallback(owner, salt)`.
|
|
6
6
|
*
|
|
7
|
-
* Use it to fill each offer's `callback` before calling `supplyBlueMakeLend`.
|
|
7
|
+
* Use it to fill each offer's `callback` before calling `supplyBlueMakeLend`. It is the
|
|
8
|
+
* Midnight-qualified name of midnight-sdk's `getBlueBuyCallbackAddress`.
|
|
8
9
|
*
|
|
9
10
|
* @param params.chainId - Chain whose `midnightBlueBuyCallbackFactory`, `midnight` and `blue` are used.
|
|
10
11
|
* @param params.owner - Callback owner, the maker.
|
|
@@ -28,7 +29,7 @@ import { type Address, type Hex } from "viem";
|
|
|
28
29
|
* // `callbackFor(maker)` returns the maker's BlueBuyCallback address, deployed or not.
|
|
29
30
|
* ```
|
|
30
31
|
*/
|
|
31
|
-
export declare const getMidnightBlueBuyCallbackAddress: (
|
|
32
|
+
export declare const getMidnightBlueBuyCallbackAddress: (params: {
|
|
32
33
|
readonly chainId: number;
|
|
33
34
|
readonly owner: Address;
|
|
34
35
|
readonly salt: Hex;
|
|
@@ -2,18 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getMidnightBlueBuyCallbackData = exports.getMidnightBlueBuyCallbackAddress = void 0;
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
|
-
const
|
|
5
|
+
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
6
6
|
const viem_1 = require("viem");
|
|
7
|
-
/**
|
|
8
|
-
* `BlueBuyCallback` creation bytecode from `morpho-org/midnight` commit
|
|
9
|
-
* `4603969e`, embedded in every `midnightBlueBuyCallbackFactory` of the address registry.
|
|
10
|
-
*/
|
|
11
|
-
const blueBuyCallbackBytecode = "0x60e0806040523461012657606081611611803803809161001f828561012a565b8339810103126101265761003281610161565b9061004b604061004460208401610161565b9201610161565b908260805260a0528060c05260018060a01b031690813b15610126576040516207767560ed1b81526001600160a01b03909116600482015260016024820152905f908290604490829084905af1801561011b5761010b575b60405161149b9081610176823960805181818160b4015281816102fc0152818161078201528181610dfd0152611004015260a0518181816102210152610dc3015260c051818181610103015281816102650152818161067c015281816108660152610f5e0152f35b5f6101159161012a565b5f6100a3565b6040513d5f823e3d90fd5b5f80fd5b601f909101601f19168101906001600160401b0382119082101761014d57604052565b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b03821682036101265756fe6080806040526004361015610012575f80fd5b5f905f3560e01c908163117803e314610fe7575080631c0bb54d14610d585780631e686318146107ef5780638069218f1461043d578063affed0e014610420578063bc25cf7714610289578063c011ff6414610245578063dc400c12146102015763eecea00014610081575f80fd5b346101a15760403660031901126101a15761009a61107c565b9060243591821515908184036101fd576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633036101ee576040516332f256cf60e11b81523060048201526001600160a01b038281166024830152939485947f000000000000000000000000000000000000000000000000000000000000000016939091602081604481885afa9081156101e35786916101b4575b5015150361014a57505050f35b823b156101af576040516207767560ed1b81526001600160a01b03929092166004830152151560248201529082908290604490829084905af180156101a4576101905750f35b8161019a91611044565b6101a15780f35b80fd5b6040513d84823e3d90fd5b505050fd5b6101d6915060203d6020116101dc575b6101ce8183611044565b810190611358565b5f61013d565b503d6101c4565b6040513d88823e3d90fd5b6330cd747160e01b8352600483fd5b8280fd5b50346101a157806003193601126101a15760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b50346101a157806003193601126101a15760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b50346101a15760203660031901126101a1576102a361107c565b6040516370a0823160e01b81523060048201526001600160a01b03821691602082602481865afa9182156104155784926103dd575b50803b156103ce5760405163a9059cbb60e01b602082019081526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001660248301526044820184905285928392909190839061034881606481015b03601f198101835282611044565b51925af1610354611370565b90156103c65780519081159182156103ac575b50501561039d576040519081527f2ae72b44f59d038340fca5739135a1d51fc5ab720bb02d983e4c5ff4119ca7b860203392a380f35b630bc11c3f60e21b8352600483fd5b6103bf9250602080918301019101611358565b5f80610367565b602081519101fd5b633c11a9c560e21b8452600484fd5b9091506020813d60201161040d575b816103f960209383611044565b810103126104095751905f6102d8565b5f80fd5b3d91506103ec565b6040513d86823e3d90fd5b50346101a157806003193601126101a15760209054604051908152f35b503461040957366003190161010081126104095760a0136104095760405161046481611028565b61046c61107c565b8152602435906001600160a01b038216820361040957602081019182526044359182151583036104095760408201928352606082019160643583526084356080820190808252606060a3193601126104095742116107e05783515f54905f1982146107cc57600182015f55036107bd5760405160208101917f81d0284fb0e2cde18d0553b06189d6f7613c96a01bb5b5e7828eade6a0dcac9183526001600160a01b0384511660408301526001600160a01b038551166060830152865115156080830152855160a08301525160c082015260c0815261054c60e082611044565b51902060405160208101907f47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218825246604082015230606082015260608152610595608082611044565b5190209060405190602082019261190160f01b845260228301526042820152604281526105c3606282611044565b51902060a4359060ff82168092036104095760805f916020936040519182528482015260c435604082015260e435606082015282805260015afa1561073b576001600160a01b035f511680151591826107a9575b5081610776575b5015610767576106af91516040519081527fbae999fc435f6200224444d8535f1936f9abd69060fcaec680f690f1810ae36a60203392a280516040516332f256cf60e11b81523060048201526001600160a01b0391821660248201527f0000000000000000000000000000000000000000000000000000000000000000909116939092602090849081906044820190565b0381875afa92831561073b575f93610746575b5051151580921515036106d3578380f35b516001600160a01b031690823b15610409576040516207767560ed1b81526001600160a01b0392909216600483015215156024820152905f908290604490829084905af1801561073b57610728575b80808380f35b61073491505f90611044565b5f5f610722565b6040513d5f823e3d90fd5b61076091935060203d6020116101dc576101ce8183611044565b915f6106c2565b638baa579f60e01b5f5260045ffd5b90506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016145f61061e565b516001600160a01b0316811491505f610617565b633ab3447f60e11b5f5260045ffd5b634e487b7160e01b5f52601160045260245ffd5b630f05f5bf60e01b5f5260045ffd5b346104095760803660031901126104095760243567ffffffffffffffff8111610409576108209036906004016110a6565b50610829611066565b5060643567ffffffffffffffff81116104095761084d61085c91369060040161122a565b60208082518301019101611284565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169060a0812060405190632e3071cd60e11b8252600482015260c081602481865afa90811561073b575f91610ca8575b50608081016108ce6001600160801b038251164261134b565b9081151580610c92575b80610c7c575b610a82575b50506001600160801b03815116906001600160801b03604081602084015116920151169060a08420604051906349e2903160e11b82526004820152306024820152606081604481895afa90811561073b575f916109f9575b505160018401928385116107cc57620f424083018093116107cc576109766001600160a01b039361097160209661097c956113cc565b611470565b9461134b565b935116936024604051809681936370a0823160e01b835260048301525afa91821561073b575f926109c4575b6020935081811090821802186040519181811090821802188152f35b91506020833d6020116109f1575b816109df60209383611044565b810103126104095760209251916109a8565b3d91506109d2565b90506060813d606011610a7a575b81610a1460609383611044565b8101031261040957604051906060820182811067ffffffffffffffff821117610a6657610a5b91604091825280518452610a5060208201611337565b602085015201611337565b60408201528661093b565b634e487b7160e01b5f52604160045260245ffd5b3d9150610a07565b6060840151604051638c00bf6b60e01b8152906001600160a01b0316610aab60048301876112e6565b6001600160801b0385511660a483015260208501936001600160801b0385511660c48401526001600160801b0360408701948186511660e48601528160608901511661010486015251166101248401526020836101648160a08a01956001600160801b038751166101448301525afa92831561073b575f93610c46575b50610b8b6001600160801b0393610b85610b4f670de0b6b3a76400009487895116936113cc565b610b80671bc16d674ec80000610b6583806113cc565b046729a2241af62c0000610b7984836113cc565b04926113bf565b6113bf565b906113cc565b049282610ba3610b9a866113df565b8284511661139f565b16905281610bbc610bb3856113df565b8288511661139f565b16855251169081610bce575b506108e3565b670de0b6b3a764000091610be1916113cc565b04610bf6816001600160801b0385511661134b565b6001600160801b0383511691620f424083018093116107cc57600182018092116107cc57610c36610c3b926109716001600160801b0395610b9a946113cc565b6113df565b169052838080610bc8565b92506020833d602011610c74575b81610c6160209383611044565b8101031261040957915191610b8b610b28565b3d9150610c54565b506001600160a01b0360608501511615156108de565b506001600160801b0360408401511615156108d8565b905060c0813d60c011610d50575b81610cc360c09383611044565b81010312610409576040519060c0820182811067ffffffffffffffff821117610a6657610d459160a091604052610cf981611337565b8452610d0760208201611337565b6020850152610d1860408201611337565b6040850152610d2960608201611337565b6060850152610d3a60808201611337565b608085015201611337565b60a0820152836108b5565b3d9150610cb6565b346104095760e03660031901126104095760243567ffffffffffffffff811161040957610d899036906004016110a6565b60443560a435916001600160a01b0383168093036104095760c43567ffffffffffffffff811161040957610dc190369060040161122a565b7f0000000000000000000000000000000000000000000000000000000000000000936001600160a01b0385163303610fd8576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001603610fc95780602080610e3593518301019101611284565b60406001600160a01b038251169201916001600160a01b0383511603610fba5782610f17575b505160405163095ea7b360e01b602082019081526001600160a01b03948516602483015260448201939093525f938493921691908390610e9e816064810161033a565b51925af1610eaa611370565b90156103c6578051908115918215610efd575b505015610eee5760206040517f7f87788ea698181ea4d28d1576d0ba4fc92c0dbe5bf75b43692af2ce91dbaea28152f35b631f55ddd960e21b5f5260045ffd5b610f109250602080918301019101611358565b8180610ebd565b604051635c2bea4960e01b815290610f339060048301906112e6565b8260a48201525f60c48201523060e482015230610104820152604081610124815f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165af1801561073b5715610e5b57604090819392933d8311610fb3575b610fa48183611044565b81010312610409579083610e5b565b503d610f9a565b63effb039160e01b5f5260045ffd5b631ec6e83760e21b5f5260045ffd5b631e6a35c760e01b5f5260045ffd5b34610409575f366003190112610409576020906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b60a0810190811067ffffffffffffffff821117610a6657604052565b90601f8019910116810190811067ffffffffffffffff821117610a6657604052565b604435906001600160a01b038216820361040957565b600435906001600160a01b038216820361040957565b35906001600160a01b038216820361040957565b919091610100818403126104095760405190610100820182811067ffffffffffffffff821117610a66576040528193813583526110e560208301611092565b60208401526110f660408301611092565b6040840152606082013567ffffffffffffffff811161040957820181601f820112156104095780359067ffffffffffffffff8211610a66576040519261114260208460051b0185611044565b82845260208085019360071b8301019181831161040957602001925b8284106111a6575050505060e080926111a19260608601526080810135608086015260a081013560a086015261119660c08201611092565b60c086015201611092565b910152565b6080848303126104095760405190608082019082821067ffffffffffffffff831117610a66576080926020926040526111de87611092565b81528287013583820152604087013560408201526111fe60608801611092565b606082015281520193019261115e565b67ffffffffffffffff8111610a6657601f01601f191660200190565b81601f82011215610409578035906112418261120e565b9261124f6040519485611044565b8284526020838301011161040957815f926020809301838601378301015290565b51906001600160a01b038216820361040957565b908160a09103126104095760806040519161129e83611028565b6112a781611270565b83526112b560208201611270565b60208401526112c660408201611270565b60408401526112d760608201611270565b60608401520151608082015290565b608080916001600160a01b0381511684526001600160a01b0360208201511660208501526001600160a01b0360408201511660408501526001600160a01b0360608201511660608501520151910152565b51906001600160801b038216820361040957565b919082039182116107cc57565b90816020910312610409575180151581036104095790565b3d1561139a573d906113818261120e565b9161138f6040519384611044565b82523d5f602084013e565b606090565b906001600160801b03809116911601906001600160801b0382116107cc57565b919082018092116107cc57565b818102929181159184041417156107cc57565b6040516113ed604082611044565b6014815260208101907f6d61782075696e7431323820657863656564656400000000000000000000000082526001600160801b0383116114355750506001600160801b031690565b60449060405192839162461bcd60e51b8352602060048401525180918160248501528484015e5f828201840152601f01601f19168101030190fd5b811561147a570490565b634e487b7160e01b5f52601260045260245ffdfea164736f6c6343000822000a";
|
|
12
7
|
/**
|
|
13
8
|
* Computes the CREATE2 address of `owner`'s `BlueBuyCallback` for `salt`, as deployed or
|
|
14
9
|
* returned by the chain's `midnightBlueBuyCallbackFactory.createBlueBuyCallback(owner, salt)`.
|
|
15
10
|
*
|
|
16
|
-
* Use it to fill each offer's `callback` before calling `supplyBlueMakeLend`.
|
|
11
|
+
* Use it to fill each offer's `callback` before calling `supplyBlueMakeLend`. It is the
|
|
12
|
+
* Midnight-qualified name of midnight-sdk's `getBlueBuyCallbackAddress`.
|
|
17
13
|
*
|
|
18
14
|
* @param params.chainId - Chain whose `midnightBlueBuyCallbackFactory`, `midnight` and `blue` are used.
|
|
19
15
|
* @param params.owner - Callback owner, the maker.
|
|
@@ -37,19 +33,7 @@ const blueBuyCallbackBytecode = "0x60e080604052346101265760608161161180380380916
|
|
|
37
33
|
* // `callbackFor(maker)` returns the maker's BlueBuyCallback address, deployed or not.
|
|
38
34
|
* ```
|
|
39
35
|
*/
|
|
40
|
-
const getMidnightBlueBuyCallbackAddress = (
|
|
41
|
-
opcode: "CREATE2",
|
|
42
|
-
from: (0, morpho_ts_1.getChainAddress)(chainId, "midnightBlueBuyCallbackFactory"),
|
|
43
|
-
salt,
|
|
44
|
-
bytecode: (0, viem_1.concatHex)([
|
|
45
|
-
blueBuyCallbackBytecode,
|
|
46
|
-
(0, viem_1.encodeAbiParameters)([{ type: "address" }, { type: "address" }, { type: "address" }], [
|
|
47
|
-
owner,
|
|
48
|
-
(0, morpho_ts_1.getChainAddress)(chainId, "midnight"),
|
|
49
|
-
(0, morpho_ts_1.getChainAddress)(chainId, "blue"),
|
|
50
|
-
]),
|
|
51
|
-
]),
|
|
52
|
-
});
|
|
36
|
+
const getMidnightBlueBuyCallbackAddress = (params) => (0, midnight_sdk_1.getBlueBuyCallbackAddress)(params);
|
|
53
37
|
exports.getMidnightBlueBuyCallbackAddress = getMidnightBlueBuyCallbackAddress;
|
|
54
38
|
/**
|
|
55
39
|
* Returns the `callbackData` every `supplyBlueMakeLend` offer must carry: `abi.encode(blueMarket)`.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IMarketParams, Market } from "@morpho-org/midnight-sdk";
|
|
2
|
+
import type { MidnightCollateralTransfer } from "../types/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* @internal Applies Midnight bundle withdrawals to a collateral snapshot in order. Callers parse the
|
|
5
|
+
* withdrawals first, so every `collateralIndex` is configured on `market`.
|
|
6
|
+
* A maxUint256 withdrawal uses the balance left at its index by earlier withdrawals.
|
|
7
|
+
* @throws {WithdrawExceedsCollateralError} If a withdrawal exceeds the remaining balance.
|
|
8
|
+
*/
|
|
9
|
+
export declare function computeMidnightPostWithdrawalCollateral({ market, marketId, collateral, withdrawals, }: {
|
|
10
|
+
readonly market: IMarketParams;
|
|
11
|
+
readonly marketId: Market["id"];
|
|
12
|
+
readonly collateral: readonly bigint[];
|
|
13
|
+
readonly withdrawals: readonly MidnightCollateralTransfer[];
|
|
14
|
+
}): {
|
|
15
|
+
postCollateral: bigint[];
|
|
16
|
+
withdrawAmount: bigint;
|
|
17
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeMidnightPostWithdrawalCollateral = computeMidnightPostWithdrawalCollateral;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const error_js_1 = require("../types/error.js");
|
|
6
|
+
/**
|
|
7
|
+
* @internal Applies Midnight bundle withdrawals to a collateral snapshot in order. Callers parse the
|
|
8
|
+
* withdrawals first, so every `collateralIndex` is configured on `market`.
|
|
9
|
+
* A maxUint256 withdrawal uses the balance left at its index by earlier withdrawals.
|
|
10
|
+
* @throws {WithdrawExceedsCollateralError} If a withdrawal exceeds the remaining balance.
|
|
11
|
+
*/
|
|
12
|
+
function computeMidnightPostWithdrawalCollateral({ market, marketId, collateral, withdrawals, }) {
|
|
13
|
+
const postCollateral = Array.from({ length: market.collateralParams.length }, (_, index) => collateral[index] ?? 0n);
|
|
14
|
+
let withdrawAmount = 0n;
|
|
15
|
+
for (const { collateralIndex, assets } of withdrawals) {
|
|
16
|
+
const index = Number(collateralIndex);
|
|
17
|
+
const available = postCollateral[index] ?? 0n;
|
|
18
|
+
const amount = assets === viem_1.maxUint256 ? available : assets;
|
|
19
|
+
if (amount > available) {
|
|
20
|
+
throw new error_js_1.WithdrawExceedsCollateralError({
|
|
21
|
+
withdrawAmount: amount,
|
|
22
|
+
available,
|
|
23
|
+
market: marketId,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
postCollateral[index] = available - amount;
|
|
27
|
+
withdrawAmount += amount;
|
|
28
|
+
}
|
|
29
|
+
return { postCollateral, withdrawAmount };
|
|
30
|
+
}
|
|
@@ -193,6 +193,9 @@ function getDeadSharesAbsoluteCap(id, { absoluteCaps, entity, adapter, }) {
|
|
|
193
193
|
}
|
|
194
194
|
/** Checks the currently allocated positions of one supported adapter. @internal */
|
|
195
195
|
function assertAdapterDeadShares(adapter, { absoluteCaps, entity, }) {
|
|
196
|
+
if (adapter instanceof blue_sdk_1.AccrualVaultV2MidnightAdapter) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
196
199
|
if (adapter instanceof blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter) {
|
|
197
200
|
const id = blue_sdk_1.VaultV2MorphoVaultV1Adapter.adapterCapId(adapter.address);
|
|
198
201
|
if (getDeadSharesAbsoluteCap(id, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Tree, type TreeCreateRequest } from "@morpho-org/midnight-sdk";
|
|
2
2
|
import { type Address, type Hex } from "viem";
|
|
3
|
+
import type { MidnightCancelAndMakeParams } from "../types/midnightCancelAndMake.js";
|
|
3
4
|
/** Preserves maker and sell-receiver errors before the upstream tree constructor. @internal */
|
|
4
5
|
export declare const parseMidnightMakerTree: (params: {
|
|
5
6
|
readonly offers: Extract<TreeCreateRequest, {
|
|
@@ -42,3 +43,23 @@ export declare const parseMidnightMakerFundingBinding: (params: {
|
|
|
42
43
|
}) => {
|
|
43
44
|
loanToken: `0x${string}`;
|
|
44
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Rejects malformed cancellations before any maker-state read, with the bundle parser's checks
|
|
48
|
+
* and order: group hex, then each ceiling's type, bounds and duplicate, then overlap with the new
|
|
49
|
+
* tree. Used by TransactionPlan maker constructors; entity flows run these checks in the bundle
|
|
50
|
+
* parser.
|
|
51
|
+
*
|
|
52
|
+
* @param params.cancellations - Groups to cancel with their consumption ceilings.
|
|
53
|
+
* @param params.tree - Parsed offer tree whose groups the bundle publishes.
|
|
54
|
+
* @throws {InvalidMidnightHexInputError} when a cancellation group is not 32-byte hex.
|
|
55
|
+
* @throws {InvalidBigIntInputError} when a `maxConsumed` ceiling is not a bigint.
|
|
56
|
+
* @throws {NegativeInputError} when a `maxConsumed` ceiling is negative.
|
|
57
|
+
* @throws {InputExceedsMaxError} when a `maxConsumed` ceiling exceeds uint128.
|
|
58
|
+
* @throws {DuplicateMidnightGroupCancellationError} when a group is cancelled more than once.
|
|
59
|
+
* @throws {MidnightReplacementGroupCancelledError} when a cancelled group is in the new tree.
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
export declare const validateMidnightMakerCancellations: (params: {
|
|
63
|
+
readonly cancellations: MidnightCancelAndMakeParams["cancellations"];
|
|
64
|
+
readonly tree: ReturnType<typeof parseMidnightMakerTree>;
|
|
65
|
+
}) => void;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseMidnightMakerFundingBinding = exports.parseMidnightMakerBinding = exports.parseMidnightMakerIntent = exports.parseMidnightMakerTree = void 0;
|
|
3
|
+
exports.validateMidnightMakerCancellations = exports.parseMidnightMakerFundingBinding = exports.parseMidnightMakerBinding = exports.parseMidnightMakerIntent = exports.parseMidnightMakerTree = void 0;
|
|
4
4
|
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
6
|
const viem_1 = require("viem");
|
|
7
7
|
const index_js_1 = require("../types/index.js");
|
|
8
8
|
const encodeMidnightCalldata_js_1 = require("./encodeMidnightCalldata.js");
|
|
9
|
+
const validateMidnightBounds_js_1 = require("./validateMidnightBounds.js");
|
|
10
|
+
const validateMidnightPublication_js_1 = require("./validateMidnightPublication.js");
|
|
9
11
|
const validateOfferSides_js_1 = require("./validateOfferSides.js");
|
|
10
12
|
/** Preserves maker and sell-receiver errors before the upstream tree constructor. @internal */
|
|
11
13
|
const parseMidnightMakerTree = (params) => {
|
|
@@ -152,3 +154,41 @@ const parseMidnightMakerFundingBinding = (params) => {
|
|
|
152
154
|
return { loanToken: params.loanToken };
|
|
153
155
|
};
|
|
154
156
|
exports.parseMidnightMakerFundingBinding = parseMidnightMakerFundingBinding;
|
|
157
|
+
/**
|
|
158
|
+
* Rejects malformed cancellations before any maker-state read, with the bundle parser's checks
|
|
159
|
+
* and order: group hex, then each ceiling's type, bounds and duplicate, then overlap with the new
|
|
160
|
+
* tree. Used by TransactionPlan maker constructors; entity flows run these checks in the bundle
|
|
161
|
+
* parser.
|
|
162
|
+
*
|
|
163
|
+
* @param params.cancellations - Groups to cancel with their consumption ceilings.
|
|
164
|
+
* @param params.tree - Parsed offer tree whose groups the bundle publishes.
|
|
165
|
+
* @throws {InvalidMidnightHexInputError} when a cancellation group is not 32-byte hex.
|
|
166
|
+
* @throws {InvalidBigIntInputError} when a `maxConsumed` ceiling is not a bigint.
|
|
167
|
+
* @throws {NegativeInputError} when a `maxConsumed` ceiling is negative.
|
|
168
|
+
* @throws {InputExceedsMaxError} when a `maxConsumed` ceiling exceeds uint128.
|
|
169
|
+
* @throws {DuplicateMidnightGroupCancellationError} when a group is cancelled more than once.
|
|
170
|
+
* @throws {MidnightReplacementGroupCancelledError} when a cancelled group is in the new tree.
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
const validateMidnightMakerCancellations = (params) => {
|
|
174
|
+
const { cancellations, tree } = params;
|
|
175
|
+
(0, validateMidnightPublication_js_1.validateMidnightCancellationGroups)(cancellations);
|
|
176
|
+
const cancelledGroups = new Set();
|
|
177
|
+
for (const [index, { group, maxConsumed }] of cancellations.entries()) {
|
|
178
|
+
if (typeof maxConsumed !== "bigint") {
|
|
179
|
+
throw new index_js_1.InvalidBigIntInputError(`cancellations[${index}].maxConsumed`, maxConsumed);
|
|
180
|
+
}
|
|
181
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)(`cancellations[${index}].maxConsumed`, maxConsumed);
|
|
182
|
+
const key = group.toLowerCase();
|
|
183
|
+
if (cancelledGroups.has(key)) {
|
|
184
|
+
throw new index_js_1.DuplicateMidnightGroupCancellationError({ index, group });
|
|
185
|
+
}
|
|
186
|
+
cancelledGroups.add(key);
|
|
187
|
+
}
|
|
188
|
+
for (const { group } of tree.offers) {
|
|
189
|
+
if (cancelledGroups.has(group.toLowerCase())) {
|
|
190
|
+
throw new index_js_1.MidnightReplacementGroupCancelledError({ group });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
exports.validateMidnightMakerCancellations = validateMidnightMakerCancellations;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AccrualPosition, type InputMarketParams, type MarketId, type MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { type Market as MidnightMarket, type MarketInput as MidnightMarketInput } from "@morpho-org/midnight-sdk";
|
|
3
3
|
import { type Address } from "viem";
|
|
4
|
-
import { type VaultV2BlueReallocation } from "../types/index.js";
|
|
4
|
+
import { type MidnightCollateralTransfer, type MidnightRepay, type VaultV2BlueReallocation } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Rejects a reference time that is not a bigint, so a serialized timestamp fails with a typed
|
|
7
7
|
* error before any deadline arithmetic.
|
|
@@ -223,6 +223,54 @@ export declare const getMidnightMaxSafeDebt: (params: {
|
|
|
223
223
|
readonly collateral: readonly bigint[];
|
|
224
224
|
readonly collateralPrices: readonly bigint[];
|
|
225
225
|
}) => bigint;
|
|
226
|
+
/**
|
|
227
|
+
* @internal Rejects a Midnight borrow whose post-borrow debt exceeds the collateral's capacity at
|
|
228
|
+
* LLTV minus `DEFAULT_LLTV_BUFFER`, with the same check and error as the entity borrow flows.
|
|
229
|
+
* Used by TransactionPlan preparers; the entity keeps its inline check.
|
|
230
|
+
*/
|
|
231
|
+
export declare const validateMidnightBorrowHealth: (params: {
|
|
232
|
+
readonly market: MidnightMarket;
|
|
233
|
+
readonly collateral: readonly bigint[];
|
|
234
|
+
readonly collateralPrices: readonly bigint[];
|
|
235
|
+
readonly debt: bigint;
|
|
236
|
+
readonly borrowUnits: bigint;
|
|
237
|
+
}) => void;
|
|
238
|
+
/**
|
|
239
|
+
* @internal Rejects a Midnight collateral withdrawal whose post-operation debt exceeds the remaining
|
|
240
|
+
* collateral's capacity at LLTV minus `DEFAULT_LLTV_BUFFER`, with the same check and error as the
|
|
241
|
+
* entity withdraw and repay-withdraw flows. Used by TransactionPlan preparers; the entity keeps its
|
|
242
|
+
* inline checks.
|
|
243
|
+
*/
|
|
244
|
+
export declare const validateMidnightWithdrawHealth: (params: {
|
|
245
|
+
readonly market: MidnightMarket;
|
|
246
|
+
readonly collateral: readonly bigint[];
|
|
247
|
+
readonly collateralPrices: readonly bigint[];
|
|
248
|
+
readonly debt: bigint;
|
|
249
|
+
readonly withdrawAmount: bigint;
|
|
250
|
+
}) => void;
|
|
251
|
+
/**
|
|
252
|
+
* @internal Checks a direct Midnight repayment and collateral withdrawal against the position
|
|
253
|
+
* snapshot, in order: each withdrawal against the remaining collateral, an exact repayment against
|
|
254
|
+
* the debt, a full repayment cap against the debt, then the remaining debt against the remaining
|
|
255
|
+
* collateral's buffered capacity when collateral is withdrawn. Matches the entity
|
|
256
|
+
* `repayWithdrawCollateral` checks; used by TransactionPlan preparers, while the entity keeps its
|
|
257
|
+
* inline checks. Callers parse the withdrawals first.
|
|
258
|
+
* @throws {WithdrawExceedsCollateralError} If a withdrawal exceeds the remaining collateral.
|
|
259
|
+
* @throws {MidnightRepayExceedsDebtError} If an exact repayment exceeds the debt.
|
|
260
|
+
* @throws {MidnightTakeTargetUnreachableError} If a full repayment cap is below the debt.
|
|
261
|
+
* @throws {MissingMarketPriceError} If remaining collateral has no price for the health check.
|
|
262
|
+
* @throws {WithdrawMakesPositionUnhealthyError} If the remaining debt exceeds buffered capacity.
|
|
263
|
+
*/
|
|
264
|
+
export declare const validateMidnightRepayWithdrawCollateralPosition: (params: {
|
|
265
|
+
readonly marketData: MidnightMarket;
|
|
266
|
+
readonly positionData: {
|
|
267
|
+
readonly collateral: readonly bigint[];
|
|
268
|
+
readonly debt: bigint;
|
|
269
|
+
};
|
|
270
|
+
readonly collateralPrices: readonly bigint[];
|
|
271
|
+
readonly repay: MidnightRepay;
|
|
272
|
+
readonly collateralWithdrawals: readonly MidnightCollateralTransfer[];
|
|
273
|
+
}) => void;
|
|
226
274
|
/**
|
|
227
275
|
* Validates that the resulting position stays within the safe LTV threshold
|
|
228
276
|
* (LLTV minus buffer) after supplying additional collateral and borrowing.
|
|
@@ -449,8 +497,18 @@ export declare const validateRepayShares: (params: {
|
|
|
449
497
|
repayShares: bigint;
|
|
450
498
|
marketId: MarketId;
|
|
451
499
|
}) => void;
|
|
500
|
+
/** Plain allocation fields shared by reallocation validation and stored withdrawal plans. @internal */
|
|
501
|
+
export type BlueReallocationInput = Omit<VaultV2BlueReallocation, "from"> & {
|
|
502
|
+
readonly from: {
|
|
503
|
+
readonly type: "market";
|
|
504
|
+
readonly adapter: Address;
|
|
505
|
+
readonly marketParams: Readonly<InputMarketParams>;
|
|
506
|
+
} | Extract<VaultV2BlueReallocation["from"], {
|
|
507
|
+
type: "idle";
|
|
508
|
+
}>;
|
|
509
|
+
};
|
|
452
510
|
/** @internal */
|
|
453
|
-
export declare const validateVaultV2BlueReallocations: (reallocations: Iterable<
|
|
511
|
+
export declare const validateVaultV2BlueReallocations: (reallocations: Iterable<BlueReallocationInput>, { targetMarketId, maxPenalty, }: {
|
|
454
512
|
readonly targetMarketId: MarketId;
|
|
455
513
|
readonly maxPenalty?: bigint;
|
|
456
514
|
}) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateSlippageTolerance = exports.validateVaultV2BlueReallocations = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validateNativeVaultAsset = exports.validateMidnightNativeAmount = exports.validateNativeAsset = exports.validateChainId = exports.validatePositionHealth = exports.getMidnightMaxSafeDebt = exports.validateAccrualPosition = exports.validateMidnightMarketChainId = exports.validateReferralFee = exports.validateDeadline = exports.validateMarketParamsId = exports.validateUint256Field = void 0;
|
|
3
|
+
exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateSlippageTolerance = exports.validateVaultV2BlueReallocations = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validateNativeVaultAsset = exports.validateMidnightNativeAmount = exports.validateNativeAsset = exports.validateChainId = exports.validatePositionHealth = exports.validateMidnightRepayWithdrawCollateralPosition = exports.validateMidnightWithdrawHealth = exports.validateMidnightBorrowHealth = exports.getMidnightMaxSafeDebt = exports.validateAccrualPosition = exports.validateMidnightMarketChainId = exports.validateReferralFee = exports.validateDeadline = exports.validateMarketParamsId = exports.validateUint256Field = void 0;
|
|
4
4
|
exports.validateReferenceTime = validateReferenceTime;
|
|
5
5
|
exports.validateVaultDepositDeadline = validateVaultDepositDeadline;
|
|
6
6
|
exports.validateUserAddress = validateUserAddress;
|
|
@@ -9,6 +9,7 @@ const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
|
9
9
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
10
10
|
const viem_1 = require("viem");
|
|
11
11
|
const index_js_1 = require("../types/index.js");
|
|
12
|
+
const computeMidnightPostWithdrawalCollateral_js_1 = require("./computeMidnightPostWithdrawalCollateral.js");
|
|
12
13
|
const constant_js_1 = require("./constant.js");
|
|
13
14
|
const reallocationPenalty_js_1 = require("./reallocationPenalty.js");
|
|
14
15
|
const validateMidnightAccount_js_1 = require("./validateMidnightAccount.js");
|
|
@@ -320,6 +321,91 @@ const getMidnightMaxSafeDebt = (params) => {
|
|
|
320
321
|
return maxSafeDebt;
|
|
321
322
|
};
|
|
322
323
|
exports.getMidnightMaxSafeDebt = getMidnightMaxSafeDebt;
|
|
324
|
+
/**
|
|
325
|
+
* @internal Rejects a Midnight borrow whose post-borrow debt exceeds the collateral's capacity at
|
|
326
|
+
* LLTV minus `DEFAULT_LLTV_BUFFER`, with the same check and error as the entity borrow flows.
|
|
327
|
+
* Used by TransactionPlan preparers; the entity keeps its inline check.
|
|
328
|
+
*/
|
|
329
|
+
const validateMidnightBorrowHealth = (params) => {
|
|
330
|
+
const postDebt = params.debt + params.borrowUnits;
|
|
331
|
+
if (postDebt <= 0n) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const maxSafeDebt = (0, exports.getMidnightMaxSafeDebt)(params);
|
|
335
|
+
if (postDebt > maxSafeDebt) {
|
|
336
|
+
throw new index_js_1.BorrowExceedsSafeLtvError(params.borrowUnits, blue_sdk_1.MathLib.zeroFloorSub(maxSafeDebt, params.debt));
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
exports.validateMidnightBorrowHealth = validateMidnightBorrowHealth;
|
|
340
|
+
/**
|
|
341
|
+
* @internal Rejects a Midnight collateral withdrawal whose post-operation debt exceeds the remaining
|
|
342
|
+
* collateral's capacity at LLTV minus `DEFAULT_LLTV_BUFFER`, with the same check and error as the
|
|
343
|
+
* entity withdraw and repay-withdraw flows. Used by TransactionPlan preparers; the entity keeps its
|
|
344
|
+
* inline checks.
|
|
345
|
+
*/
|
|
346
|
+
const validateMidnightWithdrawHealth = (params) => {
|
|
347
|
+
if (params.debt <= 0n) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const maxSafeDebt = (0, exports.getMidnightMaxSafeDebt)(params);
|
|
351
|
+
if (params.debt > maxSafeDebt) {
|
|
352
|
+
throw new index_js_1.WithdrawMakesPositionUnhealthyError({
|
|
353
|
+
withdrawAmount: params.withdrawAmount,
|
|
354
|
+
borrowAssets: params.debt,
|
|
355
|
+
maxSafeBorrow: maxSafeDebt,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
exports.validateMidnightWithdrawHealth = validateMidnightWithdrawHealth;
|
|
360
|
+
/**
|
|
361
|
+
* @internal Checks a direct Midnight repayment and collateral withdrawal against the position
|
|
362
|
+
* snapshot, in order: each withdrawal against the remaining collateral, an exact repayment against
|
|
363
|
+
* the debt, a full repayment cap against the debt, then the remaining debt against the remaining
|
|
364
|
+
* collateral's buffered capacity when collateral is withdrawn. Matches the entity
|
|
365
|
+
* `repayWithdrawCollateral` checks; used by TransactionPlan preparers, while the entity keeps its
|
|
366
|
+
* inline checks. Callers parse the withdrawals first.
|
|
367
|
+
* @throws {WithdrawExceedsCollateralError} If a withdrawal exceeds the remaining collateral.
|
|
368
|
+
* @throws {MidnightRepayExceedsDebtError} If an exact repayment exceeds the debt.
|
|
369
|
+
* @throws {MidnightTakeTargetUnreachableError} If a full repayment cap is below the debt.
|
|
370
|
+
* @throws {MissingMarketPriceError} If remaining collateral has no price for the health check.
|
|
371
|
+
* @throws {WithdrawMakesPositionUnhealthyError} If the remaining debt exceeds buffered capacity.
|
|
372
|
+
*/
|
|
373
|
+
const validateMidnightRepayWithdrawCollateralPosition = (params) => {
|
|
374
|
+
const { marketData, positionData, repay, collateralWithdrawals } = params;
|
|
375
|
+
const { debt } = positionData;
|
|
376
|
+
const { postCollateral, withdrawAmount } = (0, computeMidnightPostWithdrawalCollateral_js_1.computeMidnightPostWithdrawalCollateral)({
|
|
377
|
+
market: marketData.params,
|
|
378
|
+
marketId: marketData.id,
|
|
379
|
+
collateral: positionData.collateral,
|
|
380
|
+
withdrawals: collateralWithdrawals,
|
|
381
|
+
});
|
|
382
|
+
// The bundle must fill the whole assets target and the direct repay is capped at the debt, so a repay above it reverts `OutOfOffers()`.
|
|
383
|
+
if (repay.type === "assets" && repay.assets > debt) {
|
|
384
|
+
throw new index_js_1.MidnightRepayExceedsDebtError({
|
|
385
|
+
field: "repay.assets",
|
|
386
|
+
value: repay.assets,
|
|
387
|
+
debt,
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
if (repay.type === "full" && repay.maxBuyerAssets < debt) {
|
|
391
|
+
throw new index_js_1.MidnightTakeTargetUnreachableError({
|
|
392
|
+
field: "repay.maxBuyerAssets",
|
|
393
|
+
value: repay.maxBuyerAssets,
|
|
394
|
+
limit: debt,
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
if (collateralWithdrawals.length === 0) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
(0, exports.validateMidnightWithdrawHealth)({
|
|
401
|
+
market: marketData,
|
|
402
|
+
collateral: postCollateral,
|
|
403
|
+
collateralPrices: params.collateralPrices,
|
|
404
|
+
debt: repay.type === "assets" && debt > repay.assets ? debt - repay.assets : 0n,
|
|
405
|
+
withdrawAmount,
|
|
406
|
+
});
|
|
407
|
+
};
|
|
408
|
+
exports.validateMidnightRepayWithdrawCollateralPosition = validateMidnightRepayWithdrawCollateralPosition;
|
|
323
409
|
/**
|
|
324
410
|
* Validates that the resulting position stays within the safe LTV threshold
|
|
325
411
|
* (LLTV minus buffer) after supplying additional collateral and borrowing.
|
|
@@ -37,3 +37,13 @@ export declare const validateMidnightPublication: (params: MidnightCancelAndMake
|
|
|
37
37
|
* @throws {InvalidMidnightHexInputError} when `value` is not exactly 32 bytes of hex.
|
|
38
38
|
*/
|
|
39
39
|
export declare const validateMidnightBytes32: (field: string, value: Hex) => void;
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
* Validates every cancelled group as 32-byte hex, in input order, with the same checks and error
|
|
43
|
+
* labels as {@link validateMidnightPublication}. Used by TransactionPlan maker constructors before
|
|
44
|
+
* any state read; entity flows keep the check inside the bundle parser.
|
|
45
|
+
*
|
|
46
|
+
* @param cancellations - Groups to cancel with their consumption ceilings.
|
|
47
|
+
* @throws {InvalidMidnightHexInputError} when a cancellation group is not 32-byte hex.
|
|
48
|
+
*/
|
|
49
|
+
export declare const validateMidnightCancellationGroups: (cancellations: MidnightCancelAndMakeParams["cancellations"]) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateMidnightBytes32 = exports.validateMidnightPublication = exports.snapshotMidnightCancelAndMakeParams = void 0;
|
|
3
|
+
exports.validateMidnightCancellationGroups = exports.validateMidnightBytes32 = exports.validateMidnightPublication = exports.snapshotMidnightCancelAndMakeParams = void 0;
|
|
4
4
|
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
5
|
const viem_1 = require("viem");
|
|
6
6
|
const index_js_1 = require("../types/index.js");
|
|
@@ -155,3 +155,20 @@ const validateHexInput = (value, field, size) => {
|
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
};
|
|
158
|
+
/**
|
|
159
|
+
* @internal
|
|
160
|
+
* Validates every cancelled group as 32-byte hex, in input order, with the same checks and error
|
|
161
|
+
* labels as {@link validateMidnightPublication}. Used by TransactionPlan maker constructors before
|
|
162
|
+
* any state read; entity flows keep the check inside the bundle parser.
|
|
163
|
+
*
|
|
164
|
+
* @param cancellations - Groups to cancel with their consumption ceilings.
|
|
165
|
+
* @throws {InvalidMidnightHexInputError} when a cancellation group is not 32-byte hex.
|
|
166
|
+
*/
|
|
167
|
+
const validateMidnightCancellationGroups = (cancellations) => {
|
|
168
|
+
for (const [index, { group }] of cancellations.entries()) {
|
|
169
|
+
validateHexInput(group, `cancellations[${index}].group`, {
|
|
170
|
+
exactBytes: 32,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
exports.validateMidnightCancellationGroups = validateMidnightCancellationGroups;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { OfferStruct } from "@morpho-org/midnight-sdk";
|
|
2
|
+
import { type Hex } from "viem";
|
|
3
|
+
declare const OFFER_ADDRESS_FIELDS: readonly ["maker", "callback", "receiverIfMakerIsSeller", "ratifier"];
|
|
4
|
+
declare const OFFER_UINT256_FIELDS: readonly ["start", "expiry", "tick", "continuousFeeCap"];
|
|
5
|
+
declare const OFFER_CAP_FIELDS: readonly ["maxUnits", "maxAssets"];
|
|
6
|
+
/**
|
|
7
|
+
* Parses the fields of each taken offer fill that `MidnightBundlesV2` ABI-encodes and that the
|
|
8
|
+
* side, market and cap guards do not already check, so a malformed offer is rejected before any
|
|
9
|
+
* read or encoding.
|
|
10
|
+
*
|
|
11
|
+
* Integer and address bounds are the ABI's: `start`, `expiry`, `tick`, `continuousFeeCap` and
|
|
12
|
+
* the fill's `units` are `uint256` bigints; the `maxUnits` and `maxAssets` caps are bigints whose
|
|
13
|
+
* `uint128` bounds the action parser checks; `maker`, `callback`, `receiverIfMakerIsSeller` and
|
|
14
|
+
* `ratifier` are addresses (checksummed when mixed-case); `group` is exactly 32 bytes of `0x` hex;
|
|
15
|
+
* `reduceOnly` is a boolean. `callbackData` and `ratifierData` must be even-length `0x` hex.
|
|
16
|
+
*
|
|
17
|
+
* @param takeableOffers - Offers selected for a Midnight take.
|
|
18
|
+
* @returns Nothing when every offer field can be encoded.
|
|
19
|
+
* @throws {MidnightCalldataEncodingError} when a field is malformed; `input` is its path, such as
|
|
20
|
+
* `"takeableOffers[0].offer.maker"`.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare const validateMidnightTakeableOfferFields: (takeableOffers: readonly {
|
|
24
|
+
readonly units: bigint;
|
|
25
|
+
readonly offer: Pick<OfferStruct, (typeof OFFER_ADDRESS_FIELDS)[number] | (typeof OFFER_UINT256_FIELDS)[number] | (typeof OFFER_CAP_FIELDS)[number] | "group" | "callbackData" | "reduceOnly">;
|
|
26
|
+
readonly ratifierData: Hex;
|
|
27
|
+
}[]) => void;
|
|
28
|
+
export {};
|