@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
|
@@ -12,10 +12,12 @@ const constant_js_1 = require("../../helpers/constant.js");
|
|
|
12
12
|
const getBlueBundlesV1QuoteTimestamp_js_1 = require("../../helpers/getBlueBundlesV1QuoteTimestamp.js");
|
|
13
13
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
14
14
|
const index_js_1 = require("../../types/index.js");
|
|
15
|
+
const assemble_js_1 = require("../assemble.js");
|
|
15
16
|
const error_js_1 = require("../error.js");
|
|
16
17
|
const validation_js_1 = require("../validation.js");
|
|
17
18
|
const authorization_js_1 = require("./authorization.js");
|
|
18
19
|
const prepare_js_1 = require("./prepare.js");
|
|
20
|
+
const stored_js_1 = require("./stored.js");
|
|
19
21
|
/**
|
|
20
22
|
* Prepares a BlueBundlesV1 collateral withdrawal with direct or inline signed Morpho authorization.
|
|
21
23
|
* Health uses the expiry floored at max(now, lastUpdate), with the entity's LLTV buffer.
|
|
@@ -36,7 +38,7 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
36
38
|
* @param params.supportSignature - Optional Morpho authorization signature preference, defaulting to `false`; otherwise prepares a direct authorization transaction when needed.
|
|
37
39
|
* @param params.now - Optional reference timestamp in Unix seconds, normally the latest block timestamp; defaults to the device clock.
|
|
38
40
|
* @param params.expiresAt - Optional safe-integer Unix expiry later than `now`; defaults to `now + 2h` and governs every deadline.
|
|
39
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended verbatim to
|
|
41
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended verbatim to the action transaction's calldata; approval and authorization steps carry none.
|
|
40
42
|
* @param params.deployless - Optional shared intent field; unused because this operation reads no token metadata or allowances.
|
|
41
43
|
* @returns A deep-frozen, data-only `TransactionPlan` with chain, account, expiry, withdrawal step,
|
|
42
44
|
* and any preceding Morpho authorization step and signature request. The caller signs; the SDK never does.
|
|
@@ -62,7 +64,6 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
62
64
|
* @throws {viem.BaseError} when a contract-code, chain ID, authorization or nonce RPC read fails.
|
|
63
65
|
* @example
|
|
64
66
|
* ```ts
|
|
65
|
-
* import assert from "node:assert/strict";
|
|
66
67
|
* import { markets } from "@morpho-org/morpho-test";
|
|
67
68
|
* import { fetchAccrualPosition } from "@morpho-org/morpho-sdk/blue/fetch";
|
|
68
69
|
* import {
|
|
@@ -77,7 +78,7 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
77
78
|
* if (!ethereum) throw new Error("Install an Ethereum wallet to continue.");
|
|
78
79
|
* const wallet = createWalletClient({ chain: mainnet, transport: custom(ethereum) });
|
|
79
80
|
* const [account] = await wallet.requestAddresses();
|
|
80
|
-
*
|
|
81
|
+
* if (!account) throw new Error("Connect a wallet holding collateral in this market.");
|
|
81
82
|
* const market = markets[mainnet.id].usdc_wbtc;
|
|
82
83
|
* const position = await fetchAccrualPosition(account, market.id, client);
|
|
83
84
|
* const plan = await prepareBlueWithdrawCollateral(client, {
|
|
@@ -98,10 +99,25 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
98
99
|
*/
|
|
99
100
|
async function prepareBlueWithdrawCollateral(client, params) {
|
|
100
101
|
const now = params.now ?? morpho_ts_1.Time.timestamp();
|
|
101
|
-
const { chainId, account, collateralAssets, marketId } = params;
|
|
102
|
-
const { loanToken, collateralToken, oracle, irm, lltv } =
|
|
102
|
+
const { chainId, account, collateralAssets, marketId, marketData, positionData, expiresAt, supportSignature, referralFee, calldataOrigin, deployless, } = params;
|
|
103
|
+
const { loanToken, collateralToken, oracle, irm, lltv } = marketData.market.params;
|
|
103
104
|
const marketParams = { loanToken, collateralToken, oracle, irm, lltv };
|
|
104
|
-
const { intent, steps, signatureRequests, morphoAuthorizationRequestId } = await (0, prepare_js_1.prepareBlue)({
|
|
105
|
+
const { intent, steps, signatureRequests, morphoAuthorizationRequestId } = await (0, prepare_js_1.prepareBlue)({
|
|
106
|
+
client,
|
|
107
|
+
params: {
|
|
108
|
+
chainId,
|
|
109
|
+
account,
|
|
110
|
+
marketId,
|
|
111
|
+
marketData,
|
|
112
|
+
positionData,
|
|
113
|
+
now,
|
|
114
|
+
expiresAt,
|
|
115
|
+
supportSignature,
|
|
116
|
+
referralFee,
|
|
117
|
+
calldataOrigin,
|
|
118
|
+
deployless,
|
|
119
|
+
},
|
|
120
|
+
}, (resolvedIntent) => {
|
|
105
121
|
// Reject invalid fees and deadlines before authorization reads.
|
|
106
122
|
(0, common_js_1.normalizeBundlesCommonParams)(resolvedIntent);
|
|
107
123
|
if (collateralAssets <= 0n) {
|
|
@@ -109,7 +125,7 @@ async function prepareBlueWithdrawCollateral(client, params) {
|
|
|
109
125
|
}
|
|
110
126
|
// Reject amounts outside the ABI range before reading authorization state.
|
|
111
127
|
(0, validate_js_1.validateUint256Field)("collateralAssets", collateralAssets);
|
|
112
|
-
const position =
|
|
128
|
+
const { position } = positionData;
|
|
113
129
|
// Validate health against the same accrual horizon used by the existing handle.
|
|
114
130
|
(0, validate_js_1.validatePositionHealthAfterWithdraw)({
|
|
115
131
|
positionData: position.borrowShares === 0n
|
|
@@ -125,12 +141,8 @@ async function prepareBlueWithdrawCollateral(client, params) {
|
|
|
125
141
|
});
|
|
126
142
|
return { id: "blueWithdrawCollateral", needsAuthorization: true };
|
|
127
143
|
});
|
|
128
|
-
return (0,
|
|
129
|
-
|
|
130
|
-
chainId,
|
|
131
|
-
account,
|
|
132
|
-
expiresAt: intent.expiresAt,
|
|
133
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
144
|
+
return (0, assemble_js_1.freezePlan)({
|
|
145
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
134
146
|
steps: [
|
|
135
147
|
...steps,
|
|
136
148
|
{
|
|
@@ -138,9 +150,9 @@ async function prepareBlueWithdrawCollateral(client, params) {
|
|
|
138
150
|
label: "Withdraw Blue collateral",
|
|
139
151
|
action: {
|
|
140
152
|
type: "blueWithdrawCollateral",
|
|
141
|
-
signatureRequestIds:
|
|
142
|
-
|
|
143
|
-
|
|
153
|
+
signatureRequestIds: (0, stored_js_1.signatureRoles)({
|
|
154
|
+
morphoAuthorization: morphoAuthorizationRequestId,
|
|
155
|
+
}),
|
|
144
156
|
inputs: {
|
|
145
157
|
chainId,
|
|
146
158
|
account,
|
|
@@ -158,7 +170,7 @@ async function prepareBlueWithdrawCollateral(client, params) {
|
|
|
158
170
|
},
|
|
159
171
|
],
|
|
160
172
|
signatureRequests,
|
|
161
|
-
});
|
|
173
|
+
}, { detach: false });
|
|
162
174
|
}
|
|
163
175
|
/** @internal Binds an inline authorization to the collateral withdrawal that consumes it. */
|
|
164
176
|
function validateBlueWithdrawCollateralAuthorizationRequest(request, action) {
|
|
@@ -236,19 +248,8 @@ function validateBlueWithdrawCollateralPlanAction(action, path) {
|
|
|
236
248
|
fields: {
|
|
237
249
|
collateralAssets: "uint256 bigint",
|
|
238
250
|
maxLtv: "uint256 bigint",
|
|
239
|
-
|
|
240
|
-
referralFeePct: "uint256 bigint",
|
|
241
|
-
referralFeeRecipient: "address",
|
|
242
|
-
},
|
|
243
|
-
});
|
|
244
|
-
(0, validation_js_1.validatePlanFields)((0, validation_js_1.getPlanObject)(inputs.marketParams, `${path}.inputs.marketParams`), {
|
|
245
|
-
path: `${path}.inputs.marketParams`,
|
|
246
|
-
fields: {
|
|
247
|
-
loanToken: "address",
|
|
248
|
-
collateralToken: "address",
|
|
249
|
-
oracle: "address",
|
|
250
|
-
irm: "address",
|
|
251
|
-
lltv: "uint256 bigint",
|
|
251
|
+
...stored_js_1.BUNDLES_COMMON_FIELDS,
|
|
252
252
|
},
|
|
253
253
|
});
|
|
254
|
+
(0, stored_js_1.validateStoredBlueMarketParams)(inputs.marketParams, `${path}.inputs.marketParams`);
|
|
254
255
|
}
|
|
@@ -10,6 +10,7 @@ const assertContractCode_js_1 = require("../entities/requirements/assertContract
|
|
|
10
10
|
const index_js_1 = require("../helpers/index.js");
|
|
11
11
|
const validate_js_1 = require("../helpers/validate.js");
|
|
12
12
|
const index_js_2 = require("../types/index.js");
|
|
13
|
+
const assemble_js_1 = require("./assemble.js");
|
|
13
14
|
const error_js_1 = require("./error.js");
|
|
14
15
|
const intent_js_1 = require("./intent.js");
|
|
15
16
|
const requirements_js_1 = require("./requirements.js");
|
|
@@ -99,12 +100,8 @@ async function prepareVaultDeposit(client, params) {
|
|
|
99
100
|
]);
|
|
100
101
|
const approvals = requirements?.approvals ?? [];
|
|
101
102
|
const signatureRequests = requirements?.permit === undefined ? [] : [requirements.permit];
|
|
102
|
-
return (0,
|
|
103
|
-
|
|
104
|
-
account,
|
|
105
|
-
chainId,
|
|
106
|
-
expiresAt: intent.expiresAt,
|
|
107
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
103
|
+
return (0, assemble_js_1.freezePlan)({
|
|
104
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
108
105
|
steps: [
|
|
109
106
|
...approvals,
|
|
110
107
|
{
|
|
@@ -128,5 +125,5 @@ async function prepareVaultDeposit(client, params) {
|
|
|
128
125
|
},
|
|
129
126
|
],
|
|
130
127
|
signatureRequests,
|
|
131
|
-
})
|
|
128
|
+
}, { detach: true });
|
|
132
129
|
}
|
|
@@ -195,3 +195,30 @@ export declare class NonIntegerInputError extends Error {
|
|
|
195
195
|
*/
|
|
196
196
|
constructor(field: string, value: number);
|
|
197
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
200
|
+
* A reduce-only Midnight withdrawal needs more credit units than the position's accrued credit
|
|
201
|
+
* holds, so no quote or market liquidity can reach the target.
|
|
202
|
+
*/
|
|
203
|
+
export declare class MidnightTakeCreditInsufficientError extends Error {
|
|
204
|
+
/** Position credit accrued to the reference timestamp. */
|
|
205
|
+
readonly credit: bigint;
|
|
206
|
+
/** Credit units the target needs. */
|
|
207
|
+
readonly requiredUnits: bigint;
|
|
208
|
+
/**
|
|
209
|
+
* @param params - Accrued credit, the units the target needs and optional underlying error.
|
|
210
|
+
* @param params.credit - Position credit accrued to the reference timestamp.
|
|
211
|
+
* @param params.requiredUnits - Credit units the target needs.
|
|
212
|
+
* @param params.cause - Offer-shortfall error that the credit shortfall replaces.
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* import { MidnightTakeCreditInsufficientError } from "@morpho-org/morpho-sdk";
|
|
216
|
+
* const error = new MidnightTakeCreditInsufficientError({ credit: 40n, requiredUnits: 50n });
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
constructor({ credit, requiredUnits, cause, }: {
|
|
220
|
+
readonly credit: bigint;
|
|
221
|
+
readonly requiredUnits: bigint;
|
|
222
|
+
readonly cause?: unknown;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NonIntegerInputError = exports.InvalidCalldataOriginError = exports.TransactionPlanSignatureMismatchError = exports.IncompleteTransactionPlanError = exports.InvalidTransactionPlanError = exports.UnsupportedTransactionPlanActionError = exports.UnsupportedTransactionPlanVersionError = exports.ZeroAccountError = exports.BlueSnapshotStateMismatchError = exports.BlueSnapshotChainMismatchError = void 0;
|
|
3
|
+
exports.MidnightTakeCreditInsufficientError = exports.NonIntegerInputError = exports.InvalidCalldataOriginError = exports.TransactionPlanSignatureMismatchError = exports.IncompleteTransactionPlanError = exports.InvalidTransactionPlanError = exports.UnsupportedTransactionPlanActionError = exports.UnsupportedTransactionPlanVersionError = exports.ZeroAccountError = exports.BlueSnapshotStateMismatchError = exports.BlueSnapshotChainMismatchError = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
6
6
|
* A caller-provided Blue market or position snapshot was read on a different chain.
|
|
@@ -245,3 +245,32 @@ class NonIntegerInputError extends Error {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
exports.NonIntegerInputError = NonIntegerInputError;
|
|
248
|
+
/**
|
|
249
|
+
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
250
|
+
* A reduce-only Midnight withdrawal needs more credit units than the position's accrued credit
|
|
251
|
+
* holds, so no quote or market liquidity can reach the target.
|
|
252
|
+
*/
|
|
253
|
+
class MidnightTakeCreditInsufficientError extends Error {
|
|
254
|
+
/** Position credit accrued to the reference timestamp. */
|
|
255
|
+
credit;
|
|
256
|
+
/** Credit units the target needs. */
|
|
257
|
+
requiredUnits;
|
|
258
|
+
/**
|
|
259
|
+
* @param params - Accrued credit, the units the target needs and optional underlying error.
|
|
260
|
+
* @param params.credit - Position credit accrued to the reference timestamp.
|
|
261
|
+
* @param params.requiredUnits - Credit units the target needs.
|
|
262
|
+
* @param params.cause - Offer-shortfall error that the credit shortfall replaces.
|
|
263
|
+
* @example
|
|
264
|
+
* ```ts
|
|
265
|
+
* import { MidnightTakeCreditInsufficientError } from "@morpho-org/morpho-sdk";
|
|
266
|
+
* const error = new MidnightTakeCreditInsufficientError({ credit: 40n, requiredUnits: 50n });
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
constructor({ credit, requiredUnits, cause, }) {
|
|
270
|
+
super(`Midnight position credit "${credit}" is below the "${requiredUnits}" units the target needs. Lower the target to at most the position's credit.`, { cause });
|
|
271
|
+
this.credit = credit;
|
|
272
|
+
this.requiredUnits = requiredUnits;
|
|
273
|
+
this.name = "MidnightTakeCreditInsufficientError";
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
exports.MidnightTakeCreditInsufficientError = MidnightTakeCreditInsufficientError;
|
|
@@ -16,10 +16,49 @@ export type { BlueSupplyCollateralBorrowPlanParams } from "./blue/supplyCollater
|
|
|
16
16
|
export { prepareBlueSupplyCollateralBorrow } from "./blue/supplyCollateralBorrow.js";
|
|
17
17
|
export type { BlueWithdrawPlanParams } from "./blue/withdraw.js";
|
|
18
18
|
export { prepareBlueWithdraw } from "./blue/withdraw.js";
|
|
19
|
+
export type { BlueWithdrawBuyCallbackPlanParams } from "./blue/withdrawBuyCallback.js";
|
|
20
|
+
export { prepareBlueWithdrawBuyCallback } from "./blue/withdrawBuyCallback.js";
|
|
19
21
|
export type { BlueWithdrawCollateralPlanParams } from "./blue/withdrawCollateral.js";
|
|
20
22
|
export { prepareBlueWithdrawCollateral } from "./blue/withdrawCollateral.js";
|
|
21
|
-
export { BlueSnapshotChainMismatchError, BlueSnapshotStateMismatchError, IncompleteTransactionPlanError, InvalidCalldataOriginError, InvalidTransactionPlanError, NonIntegerInputError, TransactionPlanSignatureMismatchError, UnsupportedTransactionPlanActionError, UnsupportedTransactionPlanVersionError, ZeroAccountError, } from "./error.js";
|
|
23
|
+
export { BlueSnapshotChainMismatchError, BlueSnapshotStateMismatchError, IncompleteTransactionPlanError, InvalidCalldataOriginError, InvalidTransactionPlanError, MidnightTakeCreditInsufficientError, NonIntegerInputError, TransactionPlanSignatureMismatchError, UnsupportedTransactionPlanActionError, UnsupportedTransactionPlanVersionError, ZeroAccountError, } from "./error.js";
|
|
22
24
|
export type { Funding, IntentParams, ReferralFee, } from "./intent.js";
|
|
25
|
+
export type { MidnightCancelOffersPlanParams } from "./midnight/cancelOffers.js";
|
|
26
|
+
export { prepareMidnightCancelOffers } from "./midnight/cancelOffers.js";
|
|
27
|
+
export type { MidnightMakeBorrowPlanParams } from "./midnight/makeBorrow.js";
|
|
28
|
+
export { prepareMidnightMakeBorrow } from "./midnight/makeBorrow.js";
|
|
29
|
+
export type { MidnightMakeLendPlanParams } from "./midnight/makeLend.js";
|
|
30
|
+
export { prepareMidnightMakeLend } from "./midnight/makeLend.js";
|
|
31
|
+
export type { MidnightMakeRepayPlanParams } from "./midnight/makeRepay.js";
|
|
32
|
+
export { prepareMidnightMakeRepay } from "./midnight/makeRepay.js";
|
|
33
|
+
export type { MidnightMakerPublicationPlanParams } from "./midnight/makerPublication.js";
|
|
34
|
+
export type { MidnightMakeWithdrawPlanParams } from "./midnight/makeWithdraw.js";
|
|
35
|
+
export { prepareMidnightMakeWithdraw } from "./midnight/makeWithdraw.js";
|
|
36
|
+
export type { MidnightRedeemPlanParams } from "./midnight/redeem.js";
|
|
37
|
+
export { prepareMidnightRedeem } from "./midnight/redeem.js";
|
|
38
|
+
export type { MidnightRepayWithdrawCollateralPlanParams } from "./midnight/repayWithdrawCollateral.js";
|
|
39
|
+
export { prepareMidnightRepayWithdrawCollateral } from "./midnight/repayWithdrawCollateral.js";
|
|
40
|
+
export type { MidnightSupplyBlueMakeLendPlanParams } from "./midnight/supplyBlueMakeLend.js";
|
|
41
|
+
export { prepareMidnightSupplyBlueMakeLend } from "./midnight/supplyBlueMakeLend.js";
|
|
42
|
+
export type { MidnightSupplyCollateralPlanParams } from "./midnight/supplyCollateral.js";
|
|
43
|
+
export { prepareMidnightSupplyCollateral } from "./midnight/supplyCollateral.js";
|
|
44
|
+
export type { MidnightSupplyCollateralBatchPlanParams } from "./midnight/supplyCollateralBatch.js";
|
|
45
|
+
export { prepareMidnightSupplyCollateralBatch } from "./midnight/supplyCollateralBatch.js";
|
|
46
|
+
export type { MidnightSupplyCollateralMakeBorrowPlanParams } from "./midnight/supplyCollateralMakeBorrow.js";
|
|
47
|
+
export { prepareMidnightSupplyCollateralMakeBorrow } from "./midnight/supplyCollateralMakeBorrow.js";
|
|
48
|
+
export type { MidnightSupplyCollateralWithNativePlanParams } from "./midnight/supplyCollateralWithNative.js";
|
|
49
|
+
export { prepareMidnightSupplyCollateralWithNative } from "./midnight/supplyCollateralWithNative.js";
|
|
50
|
+
export type { MidnightSupplyCollateralTakeBorrowPlanParams, MidnightTakeBorrowPlanParams, } from "./midnight/takeBorrow.js";
|
|
51
|
+
export { prepareMidnightSupplyCollateralTakeBorrow, prepareMidnightTakeBorrow, } from "./midnight/takeBorrow.js";
|
|
52
|
+
export type { MidnightTakeLendPlanParams } from "./midnight/takeLend.js";
|
|
53
|
+
export { prepareMidnightTakeLend } from "./midnight/takeLend.js";
|
|
54
|
+
export type { MidnightTakeRepayWithdrawCollateralPlanParams } from "./midnight/takeRepayWithdrawCollateral.js";
|
|
55
|
+
export { prepareMidnightTakeRepayWithdrawCollateral } from "./midnight/takeRepayWithdrawCollateral.js";
|
|
56
|
+
export type { MidnightTakeWithdrawPlanParams } from "./midnight/takeWithdraw.js";
|
|
57
|
+
export { prepareMidnightTakeWithdraw } from "./midnight/takeWithdraw.js";
|
|
58
|
+
export type { MidnightWithdrawCollateralPlanParams } from "./midnight/withdrawCollateral.js";
|
|
59
|
+
export { prepareMidnightWithdrawCollateral } from "./midnight/withdrawCollateral.js";
|
|
60
|
+
export type { MidnightWithdrawCollateralBatchPlanParams } from "./midnight/withdrawCollateralBatch.js";
|
|
61
|
+
export { prepareMidnightWithdrawCollateralBatch } from "./midnight/withdrawCollateralBatch.js";
|
|
23
62
|
export { applySignatures, buildTransaction, buildTransactions, getPendingSignatureRequests, } from "./plan.js";
|
|
24
63
|
export { parseTransactionPlan, serializeTransactionPlan } from "./serde.js";
|
|
25
64
|
export type { Action, SignatureRequest, Step, TransactionPlan, } from "./types.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.prepareVaultV1MigrateToV2 = exports.prepareVaultV1InKindRedeem = exports.prepareVaultV1Deposit = exports.serializeTransactionPlan = exports.parseTransactionPlan = exports.getPendingSignatureRequests = exports.buildTransactions = exports.buildTransaction = exports.applySignatures = exports.prepareMidnightWithdrawCollateralBatch = exports.prepareMidnightWithdrawCollateral = exports.prepareMidnightTakeWithdraw = exports.prepareMidnightTakeRepayWithdrawCollateral = exports.prepareMidnightTakeLend = exports.prepareMidnightTakeBorrow = exports.prepareMidnightSupplyCollateralTakeBorrow = exports.prepareMidnightSupplyCollateralWithNative = exports.prepareMidnightSupplyCollateralMakeBorrow = exports.prepareMidnightSupplyCollateralBatch = exports.prepareMidnightSupplyCollateral = exports.prepareMidnightSupplyBlueMakeLend = exports.prepareMidnightRepayWithdrawCollateral = exports.prepareMidnightRedeem = exports.prepareMidnightMakeWithdraw = exports.prepareMidnightMakeRepay = exports.prepareMidnightMakeLend = exports.prepareMidnightMakeBorrow = exports.prepareMidnightCancelOffers = exports.ZeroAccountError = exports.UnsupportedTransactionPlanVersionError = exports.UnsupportedTransactionPlanActionError = exports.TransactionPlanSignatureMismatchError = exports.NonIntegerInputError = exports.MidnightTakeCreditInsufficientError = exports.InvalidTransactionPlanError = exports.InvalidCalldataOriginError = exports.IncompleteTransactionPlanError = exports.BlueSnapshotStateMismatchError = exports.BlueSnapshotChainMismatchError = exports.prepareBlueWithdrawCollateral = exports.prepareBlueWithdrawBuyCallback = exports.prepareBlueWithdraw = exports.prepareBlueSupplyCollateralBorrow = exports.prepareBlueSupplyCollateral = exports.prepareBlueSupply = exports.prepareBlueRepayWithdrawCollateral = exports.prepareBlueRepay = exports.prepareBlueRefinance = exports.validateBlueMarketSnapshot = exports.prepareBlueBorrow = void 0;
|
|
4
|
+
exports.prepareVaultV2Withdraw = exports.prepareVaultV2Redeem = exports.prepareVaultV2InKindRedeem = exports.prepareVaultV2ForceWithdraw = exports.prepareVaultV2ForceRedeem = exports.prepareVaultV2Deposit = exports.prepareVaultV1Withdraw = exports.prepareVaultV1Redeem = void 0;
|
|
4
5
|
var borrow_js_1 = require("./blue/borrow.js");
|
|
5
6
|
Object.defineProperty(exports, "prepareBlueBorrow", { enumerable: true, get: function () { return borrow_js_1.prepareBlueBorrow; } });
|
|
6
7
|
var prepare_js_1 = require("./blue/prepare.js");
|
|
@@ -19,6 +20,8 @@ var supplyCollateralBorrow_js_1 = require("./blue/supplyCollateralBorrow.js");
|
|
|
19
20
|
Object.defineProperty(exports, "prepareBlueSupplyCollateralBorrow", { enumerable: true, get: function () { return supplyCollateralBorrow_js_1.prepareBlueSupplyCollateralBorrow; } });
|
|
20
21
|
var withdraw_js_1 = require("./blue/withdraw.js");
|
|
21
22
|
Object.defineProperty(exports, "prepareBlueWithdraw", { enumerable: true, get: function () { return withdraw_js_1.prepareBlueWithdraw; } });
|
|
23
|
+
var withdrawBuyCallback_js_1 = require("./blue/withdrawBuyCallback.js");
|
|
24
|
+
Object.defineProperty(exports, "prepareBlueWithdrawBuyCallback", { enumerable: true, get: function () { return withdrawBuyCallback_js_1.prepareBlueWithdrawBuyCallback; } });
|
|
22
25
|
var withdrawCollateral_js_1 = require("./blue/withdrawCollateral.js");
|
|
23
26
|
Object.defineProperty(exports, "prepareBlueWithdrawCollateral", { enumerable: true, get: function () { return withdrawCollateral_js_1.prepareBlueWithdrawCollateral; } });
|
|
24
27
|
var error_js_1 = require("./error.js");
|
|
@@ -27,11 +30,49 @@ Object.defineProperty(exports, "BlueSnapshotStateMismatchError", { enumerable: t
|
|
|
27
30
|
Object.defineProperty(exports, "IncompleteTransactionPlanError", { enumerable: true, get: function () { return error_js_1.IncompleteTransactionPlanError; } });
|
|
28
31
|
Object.defineProperty(exports, "InvalidCalldataOriginError", { enumerable: true, get: function () { return error_js_1.InvalidCalldataOriginError; } });
|
|
29
32
|
Object.defineProperty(exports, "InvalidTransactionPlanError", { enumerable: true, get: function () { return error_js_1.InvalidTransactionPlanError; } });
|
|
33
|
+
Object.defineProperty(exports, "MidnightTakeCreditInsufficientError", { enumerable: true, get: function () { return error_js_1.MidnightTakeCreditInsufficientError; } });
|
|
30
34
|
Object.defineProperty(exports, "NonIntegerInputError", { enumerable: true, get: function () { return error_js_1.NonIntegerInputError; } });
|
|
31
35
|
Object.defineProperty(exports, "TransactionPlanSignatureMismatchError", { enumerable: true, get: function () { return error_js_1.TransactionPlanSignatureMismatchError; } });
|
|
32
36
|
Object.defineProperty(exports, "UnsupportedTransactionPlanActionError", { enumerable: true, get: function () { return error_js_1.UnsupportedTransactionPlanActionError; } });
|
|
33
37
|
Object.defineProperty(exports, "UnsupportedTransactionPlanVersionError", { enumerable: true, get: function () { return error_js_1.UnsupportedTransactionPlanVersionError; } });
|
|
34
38
|
Object.defineProperty(exports, "ZeroAccountError", { enumerable: true, get: function () { return error_js_1.ZeroAccountError; } });
|
|
39
|
+
var cancelOffers_js_1 = require("./midnight/cancelOffers.js");
|
|
40
|
+
Object.defineProperty(exports, "prepareMidnightCancelOffers", { enumerable: true, get: function () { return cancelOffers_js_1.prepareMidnightCancelOffers; } });
|
|
41
|
+
var makeBorrow_js_1 = require("./midnight/makeBorrow.js");
|
|
42
|
+
Object.defineProperty(exports, "prepareMidnightMakeBorrow", { enumerable: true, get: function () { return makeBorrow_js_1.prepareMidnightMakeBorrow; } });
|
|
43
|
+
var makeLend_js_1 = require("./midnight/makeLend.js");
|
|
44
|
+
Object.defineProperty(exports, "prepareMidnightMakeLend", { enumerable: true, get: function () { return makeLend_js_1.prepareMidnightMakeLend; } });
|
|
45
|
+
var makeRepay_js_1 = require("./midnight/makeRepay.js");
|
|
46
|
+
Object.defineProperty(exports, "prepareMidnightMakeRepay", { enumerable: true, get: function () { return makeRepay_js_1.prepareMidnightMakeRepay; } });
|
|
47
|
+
var makeWithdraw_js_1 = require("./midnight/makeWithdraw.js");
|
|
48
|
+
Object.defineProperty(exports, "prepareMidnightMakeWithdraw", { enumerable: true, get: function () { return makeWithdraw_js_1.prepareMidnightMakeWithdraw; } });
|
|
49
|
+
var redeem_js_1 = require("./midnight/redeem.js");
|
|
50
|
+
Object.defineProperty(exports, "prepareMidnightRedeem", { enumerable: true, get: function () { return redeem_js_1.prepareMidnightRedeem; } });
|
|
51
|
+
var repayWithdrawCollateral_js_2 = require("./midnight/repayWithdrawCollateral.js");
|
|
52
|
+
Object.defineProperty(exports, "prepareMidnightRepayWithdrawCollateral", { enumerable: true, get: function () { return repayWithdrawCollateral_js_2.prepareMidnightRepayWithdrawCollateral; } });
|
|
53
|
+
var supplyBlueMakeLend_js_1 = require("./midnight/supplyBlueMakeLend.js");
|
|
54
|
+
Object.defineProperty(exports, "prepareMidnightSupplyBlueMakeLend", { enumerable: true, get: function () { return supplyBlueMakeLend_js_1.prepareMidnightSupplyBlueMakeLend; } });
|
|
55
|
+
var supplyCollateral_js_2 = require("./midnight/supplyCollateral.js");
|
|
56
|
+
Object.defineProperty(exports, "prepareMidnightSupplyCollateral", { enumerable: true, get: function () { return supplyCollateral_js_2.prepareMidnightSupplyCollateral; } });
|
|
57
|
+
var supplyCollateralBatch_js_1 = require("./midnight/supplyCollateralBatch.js");
|
|
58
|
+
Object.defineProperty(exports, "prepareMidnightSupplyCollateralBatch", { enumerable: true, get: function () { return supplyCollateralBatch_js_1.prepareMidnightSupplyCollateralBatch; } });
|
|
59
|
+
var supplyCollateralMakeBorrow_js_1 = require("./midnight/supplyCollateralMakeBorrow.js");
|
|
60
|
+
Object.defineProperty(exports, "prepareMidnightSupplyCollateralMakeBorrow", { enumerable: true, get: function () { return supplyCollateralMakeBorrow_js_1.prepareMidnightSupplyCollateralMakeBorrow; } });
|
|
61
|
+
var supplyCollateralWithNative_js_1 = require("./midnight/supplyCollateralWithNative.js");
|
|
62
|
+
Object.defineProperty(exports, "prepareMidnightSupplyCollateralWithNative", { enumerable: true, get: function () { return supplyCollateralWithNative_js_1.prepareMidnightSupplyCollateralWithNative; } });
|
|
63
|
+
var takeBorrow_js_1 = require("./midnight/takeBorrow.js");
|
|
64
|
+
Object.defineProperty(exports, "prepareMidnightSupplyCollateralTakeBorrow", { enumerable: true, get: function () { return takeBorrow_js_1.prepareMidnightSupplyCollateralTakeBorrow; } });
|
|
65
|
+
Object.defineProperty(exports, "prepareMidnightTakeBorrow", { enumerable: true, get: function () { return takeBorrow_js_1.prepareMidnightTakeBorrow; } });
|
|
66
|
+
var takeLend_js_1 = require("./midnight/takeLend.js");
|
|
67
|
+
Object.defineProperty(exports, "prepareMidnightTakeLend", { enumerable: true, get: function () { return takeLend_js_1.prepareMidnightTakeLend; } });
|
|
68
|
+
var takeRepayWithdrawCollateral_js_1 = require("./midnight/takeRepayWithdrawCollateral.js");
|
|
69
|
+
Object.defineProperty(exports, "prepareMidnightTakeRepayWithdrawCollateral", { enumerable: true, get: function () { return takeRepayWithdrawCollateral_js_1.prepareMidnightTakeRepayWithdrawCollateral; } });
|
|
70
|
+
var takeWithdraw_js_1 = require("./midnight/takeWithdraw.js");
|
|
71
|
+
Object.defineProperty(exports, "prepareMidnightTakeWithdraw", { enumerable: true, get: function () { return takeWithdraw_js_1.prepareMidnightTakeWithdraw; } });
|
|
72
|
+
var withdrawCollateral_js_2 = require("./midnight/withdrawCollateral.js");
|
|
73
|
+
Object.defineProperty(exports, "prepareMidnightWithdrawCollateral", { enumerable: true, get: function () { return withdrawCollateral_js_2.prepareMidnightWithdrawCollateral; } });
|
|
74
|
+
var withdrawCollateralBatch_js_1 = require("./midnight/withdrawCollateralBatch.js");
|
|
75
|
+
Object.defineProperty(exports, "prepareMidnightWithdrawCollateralBatch", { enumerable: true, get: function () { return withdrawCollateralBatch_js_1.prepareMidnightWithdrawCollateralBatch; } });
|
|
35
76
|
var plan_js_1 = require("./plan.js");
|
|
36
77
|
Object.defineProperty(exports, "applySignatures", { enumerable: true, get: function () { return plan_js_1.applySignatures; } });
|
|
37
78
|
Object.defineProperty(exports, "buildTransaction", { enumerable: true, get: function () { return plan_js_1.buildTransaction; } });
|
|
@@ -46,8 +87,8 @@ var inKindRedeem_js_1 = require("./vaultv1/inKindRedeem.js");
|
|
|
46
87
|
Object.defineProperty(exports, "prepareVaultV1InKindRedeem", { enumerable: true, get: function () { return inKindRedeem_js_1.prepareVaultV1InKindRedeem; } });
|
|
47
88
|
var migrateToV2_js_1 = require("./vaultv1/migrateToV2.js");
|
|
48
89
|
Object.defineProperty(exports, "prepareVaultV1MigrateToV2", { enumerable: true, get: function () { return migrateToV2_js_1.prepareVaultV1MigrateToV2; } });
|
|
49
|
-
var
|
|
50
|
-
Object.defineProperty(exports, "prepareVaultV1Redeem", { enumerable: true, get: function () { return
|
|
90
|
+
var redeem_js_2 = require("./vaultv1/redeem.js");
|
|
91
|
+
Object.defineProperty(exports, "prepareVaultV1Redeem", { enumerable: true, get: function () { return redeem_js_2.prepareVaultV1Redeem; } });
|
|
51
92
|
var withdraw_js_2 = require("./vaultv1/withdraw.js");
|
|
52
93
|
Object.defineProperty(exports, "prepareVaultV1Withdraw", { enumerable: true, get: function () { return withdraw_js_2.prepareVaultV1Withdraw; } });
|
|
53
94
|
var deposit_js_2 = require("./vaultv2/deposit.js");
|
|
@@ -58,7 +99,7 @@ var forceWithdraw_js_1 = require("./vaultv2/forceWithdraw.js");
|
|
|
58
99
|
Object.defineProperty(exports, "prepareVaultV2ForceWithdraw", { enumerable: true, get: function () { return forceWithdraw_js_1.prepareVaultV2ForceWithdraw; } });
|
|
59
100
|
var inKindRedeem_js_2 = require("./vaultv2/inKindRedeem.js");
|
|
60
101
|
Object.defineProperty(exports, "prepareVaultV2InKindRedeem", { enumerable: true, get: function () { return inKindRedeem_js_2.prepareVaultV2InKindRedeem; } });
|
|
61
|
-
var
|
|
62
|
-
Object.defineProperty(exports, "prepareVaultV2Redeem", { enumerable: true, get: function () { return
|
|
102
|
+
var redeem_js_3 = require("./vaultv2/redeem.js");
|
|
103
|
+
Object.defineProperty(exports, "prepareVaultV2Redeem", { enumerable: true, get: function () { return redeem_js_3.prepareVaultV2Redeem; } });
|
|
63
104
|
var withdraw_js_3 = require("./vaultv2/withdraw.js");
|
|
64
105
|
Object.defineProperty(exports, "prepareVaultV2Withdraw", { enumerable: true, get: function () { return withdraw_js_3.prepareVaultV2Withdraw; } });
|
|
@@ -29,7 +29,7 @@ export interface IntentParams {
|
|
|
29
29
|
readonly supportSignature?: boolean;
|
|
30
30
|
/** Unix seconds. Defaults to two hours from now. */
|
|
31
31
|
readonly expiresAt?: number;
|
|
32
|
-
/** Optional attribution bytes (at most 1 MiB) appended verbatim to
|
|
32
|
+
/** Optional attribution bytes (at most 1 MiB) appended verbatim to the action transaction's calldata; ERC-20 approval, Morpho authorization and Midnight authorization steps carry none. */
|
|
33
33
|
readonly calldataOrigin?: Hex;
|
|
34
34
|
/** Whether token metadata reads for permits may use deployless aggregation. */
|
|
35
35
|
readonly deployless?: boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Address, Client } from "viem";
|
|
2
|
+
import type { Action, Step } from "../types.js";
|
|
3
|
+
type Authorization = Extract<Action, {
|
|
4
|
+
type: "midnightAuthorization";
|
|
5
|
+
}>;
|
|
6
|
+
/** @internal Resolves the ordinary registry bundle grant after the RPC chain has been checked. */
|
|
7
|
+
export declare function prepareMidnightBundleAuthorization(client: Client, inputs: {
|
|
8
|
+
readonly chainId: number;
|
|
9
|
+
readonly account: Address;
|
|
10
|
+
}): Promise<Step<Authorization> | undefined>;
|
|
11
|
+
/** @internal Derives the authorization target from the chain, not from a stored operator. */
|
|
12
|
+
export declare function buildMidnightAuthorization({ inputs }: Authorization): Readonly<import("../../index.js").Transaction<import("../../index.js").MidnightAuthorizationAction>>;
|
|
13
|
+
/** @internal Midnight steps never use signature requests. */
|
|
14
|
+
export declare function validateSignaturelessMidnightAction(action: Record<string, unknown>, path: string): void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepareMidnightBundleAuthorization = prepareMidnightBundleAuthorization;
|
|
4
|
+
exports.buildMidnightAuthorization = buildMidnightAuthorization;
|
|
5
|
+
exports.validateSignaturelessMidnightAction = validateSignaturelessMidnightAction;
|
|
6
|
+
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
7
|
+
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
8
|
+
const actions_1 = require("viem/actions");
|
|
9
|
+
const authorization_js_1 = require("../../actions/midnight/authorization.js");
|
|
10
|
+
const error_js_1 = require("../error.js");
|
|
11
|
+
/** @internal Resolves the ordinary registry bundle grant after the RPC chain has been checked. */
|
|
12
|
+
async function prepareMidnightBundleAuthorization(client, inputs) {
|
|
13
|
+
const { chainId, account } = inputs;
|
|
14
|
+
const isAuthorized = await (0, actions_1.readContract)(client, {
|
|
15
|
+
address: (0, morpho_ts_1.getChainAddress)(chainId, "midnight"),
|
|
16
|
+
abi: midnight_sdk_1.midnightAbi,
|
|
17
|
+
functionName: "isAuthorized",
|
|
18
|
+
args: [account, (0, morpho_ts_1.getChainAddress)(chainId, "midnightBundlesV2")],
|
|
19
|
+
});
|
|
20
|
+
if (isAuthorized) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
id: "midnightAuthorization",
|
|
25
|
+
label: "Authorize Midnight bundle",
|
|
26
|
+
action: { type: "midnightAuthorization", inputs },
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** @internal Derives the authorization target from the chain, not from a stored operator. */
|
|
30
|
+
function buildMidnightAuthorization({ inputs }) {
|
|
31
|
+
return (0, authorization_js_1.midnightSetIsAuthorized)({
|
|
32
|
+
chainId: inputs.chainId,
|
|
33
|
+
onBehalf: inputs.account,
|
|
34
|
+
authorized: (0, morpho_ts_1.getChainAddress)(inputs.chainId, "midnightBundlesV2"),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** @internal Midnight steps never use signature requests. */
|
|
38
|
+
function validateSignaturelessMidnightAction(action, path) {
|
|
39
|
+
if ("signatureRequestIds" in action) {
|
|
40
|
+
throw new error_js_1.InvalidTransactionPlanError({
|
|
41
|
+
path: `${path}.signatureRequestIds`,
|
|
42
|
+
reason: "Midnight steps do not consume signatures",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Client, Hex } from "viem";
|
|
2
|
+
import type { MidnightCancelOffersAction, ReferenceTimestampParams, Transaction } from "../../types/index.js";
|
|
3
|
+
import { type IntentParams } from "../intent.js";
|
|
4
|
+
import type { Action, TransactionPlan } from "../types.js";
|
|
5
|
+
/**
|
|
6
|
+
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
7
|
+
* Offer groups to cancel in full for `account` through a direct Midnight call.
|
|
8
|
+
* No authorization, approval or signature is needed.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import type { MidnightCancelOffersPlanParams } from "@morpho-org/morpho-sdk";
|
|
12
|
+
* import type { Address, Hex } from "viem";
|
|
13
|
+
*
|
|
14
|
+
* declare const maker: Address;
|
|
15
|
+
* declare const group: Hex;
|
|
16
|
+
* const params: MidnightCancelOffersPlanParams = { chainId: 8453, account: maker, groups: [group] };
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export interface MidnightCancelOffersPlanParams extends Pick<IntentParams, "chainId" | "account" | "expiresAt" | "calldataOrigin">, ReferenceTimestampParams {
|
|
20
|
+
/** Nonempty list of distinct 32-byte offer groups, cancelled in list order. */
|
|
21
|
+
readonly groups: readonly Hex[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
25
|
+
* Prepares a full cancellation of `account`'s offer groups as one direct Midnight transaction.
|
|
26
|
+
* One group builds a bare `setConsumed(group, maxUint128, account)`; two or more build one Midnight
|
|
27
|
+
* core `multicall` of those calls, which cancels every group or none. The transaction never targets
|
|
28
|
+
* MidnightBundlesV2, so it builds on every chain with a Midnight deployment. `account`, or an
|
|
29
|
+
* operator it authorized on Midnight, must send it. Validates the groups with the same parse
|
|
30
|
+
* constructor as the entity `cancelOffers`, in the same order. Expiry is plan metadata, not an
|
|
31
|
+
* onchain deadline.
|
|
32
|
+
* @param client - Client used to validate the chain and Midnight core code, not retained by the plan.
|
|
33
|
+
* @param params.chainId - Chain containing the Midnight deployment.
|
|
34
|
+
* @param params.account - Non-zero maker whose groups are cancelled.
|
|
35
|
+
* @param params.groups - Nonempty list of distinct 32-byte offer groups.
|
|
36
|
+
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
37
|
+
* @param params.expiresAt - Expiry in Unix seconds, later than `now`; defaults to `now + 2h`.
|
|
38
|
+
* @param params.calldataOrigin - Optional non-empty hex bytes appended to the built transaction.
|
|
39
|
+
* @returns A deep-frozen plan with one `midnightCancelOffers` step and no signature requests.
|
|
40
|
+
* @throws {InvalidBigIntInputError} when a supplied non-null `now` is not a bigint.
|
|
41
|
+
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
42
|
+
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
43
|
+
* @throws {NonIntegerInputError} when `expiresAt` is not a safe integer.
|
|
44
|
+
* @throws {NonPositiveInputError} when `expiresAt` is not positive.
|
|
45
|
+
* @throws {ExpiredDeadlineError} when `expiresAt` is at or before the reference time.
|
|
46
|
+
* @throws {InvalidCalldataOriginError} when attribution bytes are empty or malformed.
|
|
47
|
+
* @throws {EmptyMidnightGroupCancellationsError} when `groups` is empty.
|
|
48
|
+
* @throws {InvalidMidnightHexInputError} when a group is not 32-byte hex.
|
|
49
|
+
* @throws {DuplicateMidnightGroupCancellationError} when a group appears more than once.
|
|
50
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
51
|
+
* @throws {UnknownAddressError} when the chain has no `midnight` deployment.
|
|
52
|
+
* @throws {ChainIdMismatchError} when the client declares or serves another chain.
|
|
53
|
+
* @throws {MissingContractCodeError} when the registered Midnight core has no deployed code.
|
|
54
|
+
* @throws {viem.BaseError} when the RPC chain ID or bytecode read fails.
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { buildTransactions, prepareMidnightCancelOffers } from "@morpho-org/morpho-sdk";
|
|
58
|
+
* import { createPublicClient, http, type Address, type Hex } from "viem";
|
|
59
|
+
* import { base } from "viem/chains";
|
|
60
|
+
*
|
|
61
|
+
* declare const maker: Address;
|
|
62
|
+
* declare const group: Hex;
|
|
63
|
+
* const client = createPublicClient({ chain: base, transport: http() });
|
|
64
|
+
* const plan = await prepareMidnightCancelOffers(client, {
|
|
65
|
+
* chainId: base.id,
|
|
66
|
+
* account: maker,
|
|
67
|
+
* groups: [group],
|
|
68
|
+
* now: (await client.getBlock()).timestamp,
|
|
69
|
+
* });
|
|
70
|
+
* // One transaction: setConsumed(group, maxUint128, maker) on Midnight.
|
|
71
|
+
* const [tx] = buildTransactions(plan);
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function prepareMidnightCancelOffers(client: Client, params: MidnightCancelOffersPlanParams): Promise<TransactionPlan>;
|
|
75
|
+
/** @internal Validates the stored cancellation's plain input shape. */
|
|
76
|
+
export declare function validateMidnightCancelOffersPlanAction(action: Record<string, unknown>, path: string): void;
|
|
77
|
+
/** @internal Encodes the stored cancellation through the same action as `cancelOffers`. */
|
|
78
|
+
export declare function buildMidnightCancelOffers(action: Extract<Action, {
|
|
79
|
+
type: "midnightCancelOffers";
|
|
80
|
+
}>): Readonly<Transaction<MidnightCancelOffersAction>>;
|