@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
|
@@ -6,6 +6,7 @@ const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
|
6
6
|
const common_js_1 = require("../actions/bundles/common.js");
|
|
7
7
|
const validate_js_1 = require("../helpers/validate.js");
|
|
8
8
|
const index_js_1 = require("../types/index.js");
|
|
9
|
+
const assemble_js_1 = require("./assemble.js");
|
|
9
10
|
const intent_js_1 = require("./intent.js");
|
|
10
11
|
const shareSpending_js_1 = require("./shareSpending.js");
|
|
11
12
|
const validation_js_1 = require("./validation.js");
|
|
@@ -30,12 +31,8 @@ async function prepareVaultRedeem(client, params) {
|
|
|
30
31
|
supportSignature: intent.supportSignature,
|
|
31
32
|
now,
|
|
32
33
|
});
|
|
33
|
-
return (0,
|
|
34
|
-
|
|
35
|
-
account,
|
|
36
|
-
chainId,
|
|
37
|
-
expiresAt: intent.expiresAt,
|
|
38
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
34
|
+
return (0, assemble_js_1.freezePlan)({
|
|
35
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
39
36
|
steps: [
|
|
40
37
|
...approvals,
|
|
41
38
|
{
|
|
@@ -51,7 +48,7 @@ async function prepareVaultRedeem(client, params) {
|
|
|
51
48
|
},
|
|
52
49
|
],
|
|
53
50
|
signatureRequests,
|
|
54
|
-
})
|
|
51
|
+
}, { detach: true });
|
|
55
52
|
}
|
|
56
53
|
/** @internal Validates stored V1 and V2 exact-share redemption inputs. */
|
|
57
54
|
function validateRedeemPlanAction(action, path) {
|
|
@@ -25,19 +25,22 @@ export declare function buildApprovalStep(requirement: Readonly<Transaction<ERC2
|
|
|
25
25
|
}): Step<Extract<Action, {
|
|
26
26
|
type: "erc20Approval";
|
|
27
27
|
}>>;
|
|
28
|
-
|
|
28
|
+
type TokenRequirementsParams = {
|
|
29
29
|
readonly token: Address;
|
|
30
30
|
readonly spender: Address;
|
|
31
31
|
readonly amount: bigint;
|
|
32
32
|
readonly owner: Address;
|
|
33
33
|
readonly chainId: number;
|
|
34
|
+
readonly approvalId: (index: number) => string;
|
|
35
|
+
} & ({
|
|
36
|
+
readonly supportSignature?: false;
|
|
37
|
+
} | {
|
|
38
|
+
readonly supportSignature: boolean;
|
|
34
39
|
readonly deadline: bigint;
|
|
35
40
|
readonly now: bigint;
|
|
36
|
-
readonly supportSignature: boolean;
|
|
37
41
|
readonly deployless: boolean | undefined;
|
|
38
42
|
readonly permitId: string;
|
|
39
|
-
|
|
40
|
-
}
|
|
43
|
+
});
|
|
41
44
|
/**
|
|
42
45
|
* @internal Resolves the token prerequisite of a bundles pull without Permit2. A sufficient
|
|
43
46
|
* direct allowance yields nothing. Otherwise signature support prefers an ERC-2612 permit when
|
|
@@ -57,7 +57,7 @@ function buildApprovalStep(requirement, { id, chainId, account, denomination, })
|
|
|
57
57
|
* available and falls back to a direct unlimited approval. Without signature support, always approve.
|
|
58
58
|
*/
|
|
59
59
|
async function getTokenRequirements(client, params) {
|
|
60
|
-
const { token, spender, amount, owner, chainId,
|
|
60
|
+
const { token, spender, amount, owner, chainId, approvalId } = params;
|
|
61
61
|
// The allowance is trusted as returned by the RPC. See THREAT_MODEL.md, RPC.
|
|
62
62
|
const allowance = await (0, actions_1.readContract)(client, {
|
|
63
63
|
abi: viem_1.erc20Abi,
|
|
@@ -71,7 +71,7 @@ async function getTokenRequirements(client, params) {
|
|
|
71
71
|
if (params.supportSignature) {
|
|
72
72
|
const permit = await (0, getTokenPermit_js_1.getTokenPermit)(client, {
|
|
73
73
|
...params,
|
|
74
|
-
id: permitId,
|
|
74
|
+
id: params.permitId,
|
|
75
75
|
supportDeployless: params.deployless,
|
|
76
76
|
});
|
|
77
77
|
if (permit !== undefined) {
|
|
@@ -15,8 +15,19 @@ export declare function serializeTransactionPlan(plan: TransactionPlan): string;
|
|
|
15
15
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
16
16
|
* Restores bigint fields and validates version, action/request shapes, uint256 ranges, unique IDs,
|
|
17
17
|
* references, per-action chain/account and signature-request consistency, including signed requests.
|
|
18
|
-
* Extra keys are allowed.
|
|
19
|
-
*
|
|
18
|
+
* Extra keys are allowed. Midnight maker publications, `midnightSupplyCollateralTakeBorrow`,
|
|
19
|
+
* `midnightTakeRepayWithdrawCollateral` and `midnightSupplyCollateralWithNative` also rerun their
|
|
20
|
+
* builders' static input checks, so a stored recipe that fails those checks throws here. Restore compares the stored market of
|
|
21
|
+
* `midnightSupplyCollateralMakeBorrow`, `midnightSupplyCollateralTakeBorrow` and
|
|
22
|
+
* `midnightTakeRepayWithdrawCollateral` with the registered Midnight deployment, and each maker
|
|
23
|
+
* publication's ratifier with the registry. It does not decode maker offer payloads, so their offer
|
|
24
|
+
* markets are not checked, and other Midnight actions check only the stored market's shape and
|
|
25
|
+
* chain. Restoring `midnightSupplyCollateralWithNative` also looks up the chain's Midnight core,
|
|
26
|
+
* wNative and MidnightBundlesV2 registry entries, so register custom deployments before parsing.
|
|
27
|
+
* Building can still fail: other deployment lookups, such as the Midnight bundle address of other
|
|
28
|
+
* actions, run only in `buildTransactions`. No clock or RPC is used:
|
|
29
|
+
* current expiry, live state and other action-layer business constraints are not checked. Stored
|
|
30
|
+
* signatures are recovered offline.
|
|
20
31
|
* Permits bind owner, token, spender, value, nonce, deadline and chain; Morpho authorizations bind
|
|
21
32
|
* owner, authorized address, nonce, deadline and chain, not operation amounts, markets or referral fees/recipients.
|
|
22
33
|
* Parsing does not prove authenticity or intent for unsigned fields;
|
|
@@ -13,14 +13,29 @@ const supply_js_1 = require("./blue/supply.js");
|
|
|
13
13
|
const supplyCollateral_js_1 = require("./blue/supplyCollateral.js");
|
|
14
14
|
const supplyCollateralBorrow_js_1 = require("./blue/supplyCollateralBorrow.js");
|
|
15
15
|
const withdraw_js_1 = require("./blue/withdraw.js");
|
|
16
|
+
const withdrawBuyCallback_js_1 = require("./blue/withdrawBuyCallback.js");
|
|
16
17
|
const withdrawCollateral_js_1 = require("./blue/withdrawCollateral.js");
|
|
17
18
|
const deposit_js_1 = require("./deposit.js");
|
|
18
19
|
const error_js_2 = require("./error.js");
|
|
20
|
+
const authorization_js_2 = require("./midnight/authorization.js");
|
|
21
|
+
const cancelOffers_js_1 = require("./midnight/cancelOffers.js");
|
|
22
|
+
const makerPublication_js_1 = require("./midnight/makerPublication.js");
|
|
23
|
+
const redeem_js_1 = require("./midnight/redeem.js");
|
|
24
|
+
const repayWithdrawCollateral_js_2 = require("./midnight/repayWithdrawCollateral.js");
|
|
25
|
+
const supplyCollateral_js_2 = require("./midnight/supplyCollateral.js");
|
|
26
|
+
const supplyCollateralBatch_js_1 = require("./midnight/supplyCollateralBatch.js");
|
|
27
|
+
const supplyCollateralWithNative_js_1 = require("./midnight/supplyCollateralWithNative.js");
|
|
28
|
+
const takeBorrow_js_1 = require("./midnight/takeBorrow.js");
|
|
29
|
+
const takeLend_js_1 = require("./midnight/takeLend.js");
|
|
30
|
+
const takeRepayWithdrawCollateral_js_1 = require("./midnight/takeRepayWithdrawCollateral.js");
|
|
31
|
+
const validation_js_1 = require("./midnight/validation.js");
|
|
32
|
+
const withdrawCollateral_js_2 = require("./midnight/withdrawCollateral.js");
|
|
33
|
+
const withdrawCollateralBatch_js_1 = require("./midnight/withdrawCollateralBatch.js");
|
|
19
34
|
const permit_js_1 = require("./permit.js");
|
|
20
35
|
const plan_js_1 = require("./plan.js");
|
|
21
|
-
const
|
|
36
|
+
const redeem_js_2 = require("./redeem.js");
|
|
22
37
|
const validateActions_js_1 = require("./validateActions.js");
|
|
23
|
-
const
|
|
38
|
+
const validation_js_2 = require("./validation.js");
|
|
24
39
|
const inKindRedeem_js_1 = require("./vaultv1/inKindRedeem.js");
|
|
25
40
|
const migrateToV2_js_1 = require("./vaultv1/migrateToV2.js");
|
|
26
41
|
const forceRedeem_js_1 = require("./vaultv2/forceRedeem.js");
|
|
@@ -37,15 +52,36 @@ const actionValidators = {
|
|
|
37
52
|
blueRepay: repay_js_1.validateBlueRepayPlanAction,
|
|
38
53
|
blueWithdraw: withdraw_js_1.validateBlueWithdrawPlanAction,
|
|
39
54
|
blueWithdrawCollateral: withdrawCollateral_js_1.validateBlueWithdrawCollateralPlanAction,
|
|
55
|
+
blueWithdrawBuyCallback: withdrawBuyCallback_js_1.validateBlueWithdrawBuyCallbackPlanAction,
|
|
40
56
|
blueRepayWithdrawCollateral: repayWithdrawCollateral_js_1.validateRepayWithdrawCollateralPlanAction,
|
|
41
57
|
blueRefinance: refinance_js_1.validateRefinancePlanAction,
|
|
42
58
|
erc20Approval: approval_js_1.validateApprovalPlanAction,
|
|
43
|
-
vaultV2Redeem:
|
|
59
|
+
vaultV2Redeem: redeem_js_2.validateRedeemPlanAction,
|
|
44
60
|
vaultV2ForceWithdraw: forceWithdraw_js_1.validateForceWithdrawPlanAction,
|
|
45
61
|
vaultV1Deposit: deposit_js_1.validateDepositPlanAction,
|
|
46
|
-
vaultV1Redeem:
|
|
62
|
+
vaultV1Redeem: redeem_js_2.validateRedeemPlanAction,
|
|
47
63
|
vaultV1MigrateToV2: migrateToV2_js_1.validateMigrateToV2PlanAction,
|
|
48
64
|
morphoAuthorization: authorization_js_1.validateMorphoAuthorizationPlanAction,
|
|
65
|
+
midnightAuthorization: authorization_js_2.validateSignaturelessMidnightAction,
|
|
66
|
+
midnightMakeBorrow: makerPublication_js_1.validateMidnightMakerPublicationPlanAction,
|
|
67
|
+
midnightMakeLend: makerPublication_js_1.validateMidnightMakerPublicationPlanAction,
|
|
68
|
+
midnightMakeRepay: makerPublication_js_1.validateMidnightMakerPublicationPlanAction,
|
|
69
|
+
midnightMakeWithdraw: makerPublication_js_1.validateMidnightMakerPublicationPlanAction,
|
|
70
|
+
midnightSupplyBlueMakeLend: makerPublication_js_1.validateMidnightMakerPublicationPlanAction,
|
|
71
|
+
midnightSupplyCollateralMakeBorrow: makerPublication_js_1.validateMidnightMakerPublicationPlanAction,
|
|
72
|
+
midnightTakeBorrow: validation_js_1.validateMidnightSellPlanAction,
|
|
73
|
+
midnightSupplyCollateralTakeBorrow: takeBorrow_js_1.validateMidnightSupplyCollateralTakeBorrowPlanAction,
|
|
74
|
+
midnightTakeLend: takeLend_js_1.validateMidnightTakeLendPlanAction,
|
|
75
|
+
midnightSupplyCollateral: supplyCollateral_js_2.validateMidnightSupplyCollateralPlanAction,
|
|
76
|
+
midnightSupplyCollateralBatch: supplyCollateralBatch_js_1.validateMidnightSupplyCollateralBatchPlanAction,
|
|
77
|
+
midnightSupplyCollateralWithNative: supplyCollateralWithNative_js_1.validateMidnightSupplyCollateralWithNativePlanAction,
|
|
78
|
+
midnightWithdrawCollateral: withdrawCollateral_js_2.validateMidnightWithdrawCollateralPlanAction,
|
|
79
|
+
midnightWithdrawCollateralBatch: withdrawCollateralBatch_js_1.validateMidnightWithdrawCollateralBatchPlanAction,
|
|
80
|
+
midnightRedeem: redeem_js_1.validateMidnightRedeemPlanAction,
|
|
81
|
+
midnightTakeRepayWithdrawCollateral: takeRepayWithdrawCollateral_js_1.validateMidnightTakeRepayWithdrawCollateralPlanAction,
|
|
82
|
+
midnightTakeWithdraw: validation_js_1.validateMidnightSellPlanAction,
|
|
83
|
+
midnightRepayWithdrawCollateral: repayWithdrawCollateral_js_2.validateMidnightRepayWithdrawCollateralPlanAction,
|
|
84
|
+
midnightCancelOffers: cancelOffers_js_1.validateMidnightCancelOffersPlanAction,
|
|
49
85
|
vaultV2Deposit: deposit_js_1.validateDepositPlanAction,
|
|
50
86
|
vaultV2Withdraw: withdraw_js_2.validateWithdrawPlanAction,
|
|
51
87
|
vaultV2ForceRedeem: forceRedeem_js_1.validateForceRedeemPlanAction,
|
|
@@ -74,8 +110,19 @@ function serializeTransactionPlan(plan) {
|
|
|
74
110
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
75
111
|
* Restores bigint fields and validates version, action/request shapes, uint256 ranges, unique IDs,
|
|
76
112
|
* references, per-action chain/account and signature-request consistency, including signed requests.
|
|
77
|
-
* Extra keys are allowed.
|
|
78
|
-
*
|
|
113
|
+
* Extra keys are allowed. Midnight maker publications, `midnightSupplyCollateralTakeBorrow`,
|
|
114
|
+
* `midnightTakeRepayWithdrawCollateral` and `midnightSupplyCollateralWithNative` also rerun their
|
|
115
|
+
* builders' static input checks, so a stored recipe that fails those checks throws here. Restore compares the stored market of
|
|
116
|
+
* `midnightSupplyCollateralMakeBorrow`, `midnightSupplyCollateralTakeBorrow` and
|
|
117
|
+
* `midnightTakeRepayWithdrawCollateral` with the registered Midnight deployment, and each maker
|
|
118
|
+
* publication's ratifier with the registry. It does not decode maker offer payloads, so their offer
|
|
119
|
+
* markets are not checked, and other Midnight actions check only the stored market's shape and
|
|
120
|
+
* chain. Restoring `midnightSupplyCollateralWithNative` also looks up the chain's Midnight core,
|
|
121
|
+
* wNative and MidnightBundlesV2 registry entries, so register custom deployments before parsing.
|
|
122
|
+
* Building can still fail: other deployment lookups, such as the Midnight bundle address of other
|
|
123
|
+
* actions, run only in `buildTransactions`. No clock or RPC is used:
|
|
124
|
+
* current expiry, live state and other action-layer business constraints are not checked. Stored
|
|
125
|
+
* signatures are recovered offline.
|
|
79
126
|
* Permits bind owner, token, spender, value, nonce, deadline and chain; Morpho authorizations bind
|
|
80
127
|
* owner, authorized address, nonce, deadline and chain, not operation amounts, markets or referral fees/recipients.
|
|
81
128
|
* Parsing does not prove authenticity or intent for unsigned fields;
|
|
@@ -109,10 +156,10 @@ function parseTransactionPlan(json) {
|
|
|
109
156
|
cause,
|
|
110
157
|
});
|
|
111
158
|
}
|
|
112
|
-
const plan = (0,
|
|
113
|
-
(0,
|
|
159
|
+
const plan = (0, validation_js_2.getPlanObject)(restored, "$");
|
|
160
|
+
(0, validation_js_2.validatePlanField)(plan.version, { path: "$.version", type: "safe integer" });
|
|
114
161
|
(0, version_js_1.validateTransactionPlanVersion)(plan.version);
|
|
115
|
-
(0,
|
|
162
|
+
(0, validation_js_2.validatePlanFields)(plan, {
|
|
116
163
|
path: "$",
|
|
117
164
|
fields: {
|
|
118
165
|
chainId: "positive safe integer",
|
|
@@ -126,13 +173,13 @@ function parseTransactionPlan(json) {
|
|
|
126
173
|
const requests = plan.signatureRequests;
|
|
127
174
|
for (const [index, value] of steps.entries()) {
|
|
128
175
|
const path = `$.steps[${index}]`;
|
|
129
|
-
const step = (0,
|
|
130
|
-
(0,
|
|
176
|
+
const step = (0, validation_js_2.getPlanObject)(value, path);
|
|
177
|
+
(0, validation_js_2.validatePlanFields)(step, {
|
|
131
178
|
path,
|
|
132
179
|
fields: { id: "string", label: "string" },
|
|
133
180
|
});
|
|
134
|
-
const action = (0,
|
|
135
|
-
(0,
|
|
181
|
+
const action = (0, validation_js_2.getPlanObject)(step.action, `${path}.action`);
|
|
182
|
+
(0, validation_js_2.validatePlanField)(action.type, {
|
|
136
183
|
path: `${path}.action.type`,
|
|
137
184
|
type: "string",
|
|
138
185
|
});
|
|
@@ -141,9 +188,9 @@ function parseTransactionPlan(json) {
|
|
|
141
188
|
(0, validateActions_js_1.validateTransactionPlanActions)(steps);
|
|
142
189
|
for (const [index, step] of steps.entries()) {
|
|
143
190
|
const path = `$.steps[${index}].action`;
|
|
144
|
-
const action = (0,
|
|
145
|
-
const inputs = (0,
|
|
146
|
-
(0,
|
|
191
|
+
const action = (0, validation_js_2.getPlanObject)(step.action, path);
|
|
192
|
+
const inputs = (0, validation_js_2.getPlanObject)(action.inputs, `${path}.inputs`);
|
|
193
|
+
(0, validation_js_2.validatePlanFields)(inputs, {
|
|
147
194
|
path: `${path}.inputs`,
|
|
148
195
|
fields: { chainId: "positive safe integer", account: "address" },
|
|
149
196
|
});
|
|
@@ -152,8 +199,8 @@ function parseTransactionPlan(json) {
|
|
|
152
199
|
const requestIds = new Set();
|
|
153
200
|
for (const [index, value] of requests.entries()) {
|
|
154
201
|
const path = `$.signatureRequests[${index}]`;
|
|
155
|
-
const request = (0,
|
|
156
|
-
(0,
|
|
202
|
+
const request = (0, validation_js_2.getPlanObject)(value, path);
|
|
203
|
+
(0, validation_js_2.validatePlanFields)(request, {
|
|
157
204
|
path,
|
|
158
205
|
fields: { id: "string", kind: "string" },
|
|
159
206
|
});
|
|
@@ -165,9 +212,9 @@ function parseTransactionPlan(json) {
|
|
|
165
212
|
continue;
|
|
166
213
|
}
|
|
167
214
|
const path = `$.steps[${index}].action.signatureRequestIds`;
|
|
168
|
-
const ids = (0,
|
|
215
|
+
const ids = (0, validation_js_2.getPlanObject)(step.action.signatureRequestIds, path);
|
|
169
216
|
for (const [role, id] of Object.entries(ids)) {
|
|
170
|
-
(0,
|
|
217
|
+
(0, validation_js_2.validatePlanField)(id, { path: `${path}.${role}`, type: "string" });
|
|
171
218
|
if (!requestIds.has(id)) {
|
|
172
219
|
throw new error_js_2.InvalidTransactionPlanError({
|
|
173
220
|
path: `${path}.${role}`,
|
|
@@ -178,7 +225,7 @@ function parseTransactionPlan(json) {
|
|
|
178
225
|
}
|
|
179
226
|
const result = restored;
|
|
180
227
|
// Apply the same context and deadline rules as direct builders.
|
|
181
|
-
(0,
|
|
228
|
+
(0, validation_js_2.validateTransactionPlanHeader)(result);
|
|
182
229
|
try {
|
|
183
230
|
// Check references and request/action consistency, including restored signatures.
|
|
184
231
|
(0, plan_js_1.getPendingSignatureRequests)(result);
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import type { InputMarketParams, MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
+
import type { MarketUtils } from "@morpho-org/midnight-sdk";
|
|
2
3
|
import type { Address, Hex } from "viem";
|
|
3
4
|
import type { BlueRepayParams } from "../actions/blue/repay.js";
|
|
4
5
|
import type { BlueRepayWithdrawCollateralParams } from "../actions/blue/repayWithdrawCollateral.js";
|
|
5
6
|
import type { BlueSupplyCollateralBorrowParams } from "../actions/blue/supplyCollateralBorrow.js";
|
|
7
|
+
import type { MidnightRepayWithdrawCollateralParams } from "../actions/midnight/repayWithdrawCollateral.js";
|
|
8
|
+
import type { MidnightTakeBorrowParams } from "../actions/midnight/takeBorrow.js";
|
|
9
|
+
import type { MidnightTakeLendParams } from "../actions/midnight/takeLend.js";
|
|
10
|
+
import type { MidnightTakeRepayWithdrawCollateralParams } from "../actions/midnight/takeRepayWithdrawCollateral.js";
|
|
11
|
+
import type { MidnightTakeableOffer } from "../actions/midnight/types.js";
|
|
12
|
+
import type { BlueReallocationInput } from "../helpers/validate.js";
|
|
13
|
+
import type { MidnightBlueSupply, MidnightCollateralTransfer } from "../types/action.js";
|
|
6
14
|
import type { AuthorizationSignatureArgs, PermitAction, RequirementTypedData, VaultV1MigrateToV2AmountArgs, VaultV2BlueReallocation } from "../types/index.js";
|
|
15
|
+
import type { MidnightCancelAndMakeParams } from "../types/midnightCancelAndMake.js";
|
|
7
16
|
interface ActionInputs {
|
|
8
17
|
readonly chainId: number;
|
|
9
18
|
readonly account: Address;
|
|
@@ -25,6 +34,18 @@ type VaultSignatureRequestIds = {
|
|
|
25
34
|
/** Token permit consumed by the action; omitted when no permit is needed. */
|
|
26
35
|
readonly tokenPermit?: string;
|
|
27
36
|
};
|
|
37
|
+
type MidnightSellInputs = ActionInputs & Omit<MidnightTakeBorrowParams, "chainId" | "market" | "metadata" | "referralFeePct" | "referralFeeRecipient"> & {
|
|
38
|
+
readonly market: MidnightTakeableOffer["offer"]["market"];
|
|
39
|
+
readonly referralFeePct: bigint;
|
|
40
|
+
readonly referralFeeRecipient: Address;
|
|
41
|
+
};
|
|
42
|
+
type MidnightMakerPublicationInputs = ActionInputs & Pick<MidnightCancelAndMakeParams, "cancellations" | "deadline"> & {
|
|
43
|
+
readonly ratifierType: "priceV1" | "rateV1";
|
|
44
|
+
readonly ratifier: Address;
|
|
45
|
+
readonly root: Hex;
|
|
46
|
+
readonly groups: readonly Hex[];
|
|
47
|
+
readonly payload: Hex;
|
|
48
|
+
};
|
|
28
49
|
/**
|
|
29
50
|
* Recipes supported by TransactionPlan.
|
|
30
51
|
* Snapshot-derived values such as the asset and the quote are fixed on `inputs` at preparation;
|
|
@@ -33,6 +54,119 @@ type VaultSignatureRequestIds = {
|
|
|
33
54
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
34
55
|
*/
|
|
35
56
|
export type Action = {
|
|
57
|
+
readonly type: "midnightMakeBorrow";
|
|
58
|
+
readonly inputs: MidnightMakerPublicationInputs;
|
|
59
|
+
} | {
|
|
60
|
+
readonly type: "midnightMakeLend";
|
|
61
|
+
readonly inputs: MidnightMakerPublicationInputs;
|
|
62
|
+
} | {
|
|
63
|
+
readonly type: "midnightMakeRepay";
|
|
64
|
+
readonly inputs: MidnightMakerPublicationInputs;
|
|
65
|
+
} | {
|
|
66
|
+
readonly type: "midnightMakeWithdraw";
|
|
67
|
+
readonly inputs: MidnightMakerPublicationInputs;
|
|
68
|
+
} | {
|
|
69
|
+
readonly type: "midnightSupplyBlueMakeLend";
|
|
70
|
+
readonly inputs: MidnightMakerPublicationInputs & {
|
|
71
|
+
readonly blueSupply: MidnightBlueSupply;
|
|
72
|
+
/** Native ETH in wei, passed as transaction value. */
|
|
73
|
+
readonly nativeAssets?: bigint;
|
|
74
|
+
};
|
|
75
|
+
} | {
|
|
76
|
+
readonly type: "midnightSupplyCollateralMakeBorrow";
|
|
77
|
+
readonly inputs: MidnightMakerPublicationInputs & {
|
|
78
|
+
readonly collateral: {
|
|
79
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
80
|
+
readonly supplies: readonly MidnightCollateralTransfer[];
|
|
81
|
+
};
|
|
82
|
+
/** Native ETH in wei, passed as transaction value. */
|
|
83
|
+
readonly nativeAssets?: bigint;
|
|
84
|
+
};
|
|
85
|
+
} | {
|
|
86
|
+
readonly type: "midnightRepayWithdrawCollateral";
|
|
87
|
+
readonly inputs: ActionInputs & Omit<MidnightRepayWithdrawCollateralParams, "chainId" | "market" | "metadata" | "nativeAmount"> & {
|
|
88
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
89
|
+
/** Native ETH in wei, passed as transaction value. Omitted or zero means no ETH funding. */
|
|
90
|
+
readonly nativeAssets?: bigint;
|
|
91
|
+
};
|
|
92
|
+
} | {
|
|
93
|
+
readonly type: "midnightTakeBorrow";
|
|
94
|
+
readonly inputs: MidnightSellInputs;
|
|
95
|
+
} | {
|
|
96
|
+
readonly type: "midnightTakeRepayWithdrawCollateral";
|
|
97
|
+
readonly inputs: ActionInputs & Omit<MidnightTakeRepayWithdrawCollateralParams, "chainId" | "market" | "metadata" | "nativeAmount" | "referralFeePct" | "referralFeeRecipient"> & {
|
|
98
|
+
readonly market: MidnightTakeableOffer["offer"]["market"];
|
|
99
|
+
readonly nativeAssets?: bigint;
|
|
100
|
+
readonly referralFeePct: bigint;
|
|
101
|
+
readonly referralFeeRecipient: Address;
|
|
102
|
+
};
|
|
103
|
+
} | {
|
|
104
|
+
readonly type: "midnightSupplyCollateralTakeBorrow";
|
|
105
|
+
readonly inputs: MidnightSellInputs & {
|
|
106
|
+
readonly collateralSupplies: readonly MidnightCollateralTransfer[];
|
|
107
|
+
/** Native ETH in wei, passed as transaction value. */
|
|
108
|
+
readonly nativeAssets?: bigint;
|
|
109
|
+
};
|
|
110
|
+
} | {
|
|
111
|
+
readonly type: "midnightTakeWithdraw";
|
|
112
|
+
readonly inputs: MidnightSellInputs;
|
|
113
|
+
} | {
|
|
114
|
+
readonly type: "midnightTakeLend";
|
|
115
|
+
readonly inputs: ActionInputs & Omit<MidnightTakeLendParams, "chainId" | "market" | "metadata" | "nativeAmount" | "referralFeePct" | "referralFeeRecipient"> & {
|
|
116
|
+
readonly market: MidnightTakeableOffer["offer"]["market"];
|
|
117
|
+
readonly nativeAssets?: bigint;
|
|
118
|
+
readonly referralFeePct: bigint;
|
|
119
|
+
readonly referralFeeRecipient: Address;
|
|
120
|
+
};
|
|
121
|
+
} | {
|
|
122
|
+
readonly type: "midnightAuthorization";
|
|
123
|
+
readonly inputs: ActionInputs;
|
|
124
|
+
} | {
|
|
125
|
+
readonly type: "midnightSupplyCollateral";
|
|
126
|
+
readonly inputs: ActionInputs & {
|
|
127
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
128
|
+
readonly collateralIndex: bigint;
|
|
129
|
+
readonly collateralAssets: bigint;
|
|
130
|
+
};
|
|
131
|
+
} | {
|
|
132
|
+
readonly type: "midnightWithdrawCollateral";
|
|
133
|
+
readonly inputs: ActionInputs & {
|
|
134
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
135
|
+
readonly collateralIndex: bigint;
|
|
136
|
+
readonly assets: bigint;
|
|
137
|
+
readonly receiver: Address;
|
|
138
|
+
};
|
|
139
|
+
} | {
|
|
140
|
+
readonly type: "midnightWithdrawCollateralBatch";
|
|
141
|
+
readonly inputs: ActionInputs & {
|
|
142
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
143
|
+
readonly collateralWithdrawals: readonly MidnightCollateralTransfer[];
|
|
144
|
+
readonly receiver: Address;
|
|
145
|
+
};
|
|
146
|
+
} | {
|
|
147
|
+
readonly type: "midnightSupplyCollateralBatch";
|
|
148
|
+
readonly inputs: ActionInputs & {
|
|
149
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
150
|
+
readonly collateralSupplies: readonly MidnightCollateralTransfer[];
|
|
151
|
+
};
|
|
152
|
+
} | {
|
|
153
|
+
readonly type: "midnightSupplyCollateralWithNative";
|
|
154
|
+
readonly inputs: ActionInputs & {
|
|
155
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
156
|
+
readonly collateralIndex: bigint;
|
|
157
|
+
readonly collateralAssets: bigint;
|
|
158
|
+
/** Native ETH in wei, passed as transaction value. */
|
|
159
|
+
readonly nativeAssets: bigint;
|
|
160
|
+
readonly deadline: bigint;
|
|
161
|
+
};
|
|
162
|
+
} | {
|
|
163
|
+
readonly type: "midnightRedeem";
|
|
164
|
+
readonly inputs: ActionInputs & {
|
|
165
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
166
|
+
readonly units: bigint;
|
|
167
|
+
readonly receiver: Address;
|
|
168
|
+
};
|
|
169
|
+
} | {
|
|
36
170
|
readonly type: "vaultV2ForceRedeem";
|
|
37
171
|
readonly inputs: ActionInputs & {
|
|
38
172
|
readonly vault: Address;
|
|
@@ -122,12 +256,12 @@ export type Action = {
|
|
|
122
256
|
} | {
|
|
123
257
|
readonly type: "blueWithdraw";
|
|
124
258
|
readonly inputs: ActionInputs & {
|
|
125
|
-
readonly marketParams:
|
|
259
|
+
readonly marketParams: Readonly<InputMarketParams>;
|
|
126
260
|
readonly withdrawAssets: bigint;
|
|
127
261
|
readonly withdrawShares: bigint;
|
|
128
262
|
/** Maximum WAD-scaled penalty rate per reallocation, defaulting to zero; it does not bound total proceeds lost. */
|
|
129
263
|
readonly maxPenalty?: bigint;
|
|
130
|
-
readonly reallocations: readonly
|
|
264
|
+
readonly reallocations: readonly BlueReallocationInput[];
|
|
131
265
|
readonly deadline: bigint;
|
|
132
266
|
readonly referralFeePct: bigint;
|
|
133
267
|
readonly referralFeeRecipient: Address;
|
|
@@ -151,6 +285,15 @@ export type Action = {
|
|
|
151
285
|
readonly referralFeePct: bigint;
|
|
152
286
|
readonly referralFeeRecipient: Address;
|
|
153
287
|
};
|
|
288
|
+
} | {
|
|
289
|
+
readonly type: "blueWithdrawBuyCallback";
|
|
290
|
+
readonly inputs: ActionInputs & {
|
|
291
|
+
readonly marketParams: Readonly<InputMarketParams>;
|
|
292
|
+
/** BlueBuyCallback whose supply position is withdrawn to `account`, its owner. */
|
|
293
|
+
readonly callbackAddress: Address;
|
|
294
|
+
/** Every supply share the callback held in the prepared snapshot. */
|
|
295
|
+
readonly shares: bigint;
|
|
296
|
+
};
|
|
154
297
|
} | {
|
|
155
298
|
readonly type: "blueRepayWithdrawCollateral";
|
|
156
299
|
readonly inputs: ActionInputs & Omit<BlueRepayWithdrawCollateralParams["args"], "userAddress" | "requirementSignature" | "authorizationSignature" | "nativeAmount"> & {
|
|
@@ -283,6 +426,11 @@ export type Action = {
|
|
|
283
426
|
} | {
|
|
284
427
|
readonly type: "morphoAuthorization";
|
|
285
428
|
readonly inputs: ActionInputs;
|
|
429
|
+
} | {
|
|
430
|
+
readonly type: "midnightCancelOffers";
|
|
431
|
+
readonly inputs: ActionInputs & {
|
|
432
|
+
readonly groups: readonly Hex[];
|
|
433
|
+
};
|
|
286
434
|
};
|
|
287
435
|
/**
|
|
288
436
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
@@ -323,7 +471,7 @@ export interface TransactionPlan {
|
|
|
323
471
|
readonly account: Address;
|
|
324
472
|
/** Unix seconds. One expiry governs every step deadline and signature deadline. */
|
|
325
473
|
readonly expiresAt: number;
|
|
326
|
-
/** Appended verbatim to
|
|
474
|
+
/** Appended verbatim to the action transaction's calldata; ERC-20 approval, Morpho authorization and Midnight authorization steps carry none. */
|
|
327
475
|
readonly calldataOrigin?: Hex;
|
|
328
476
|
readonly steps: readonly Step[];
|
|
329
477
|
readonly signatureRequests: readonly SignatureRequest[];
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Step } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* @internal Rejects unknown action types
|
|
3
|
+
* @internal Rejects unknown action types, and Midnight steps carrying a signature-request map,
|
|
4
|
+
* before interpreting requests or updates.
|
|
4
5
|
* @param steps - Steps whose action discriminators must be supported.
|
|
5
6
|
* @returns Nothing when every action type is supported.
|
|
6
7
|
* @throws {UnsupportedTransactionPlanActionError} when any step names an unsupported action type.
|
|
8
|
+
* @throws {InvalidTransactionPlanError} when a Midnight step carries `signatureRequestIds`, as restore does.
|
|
7
9
|
*/
|
|
8
10
|
export declare function validateTransactionPlanActions(steps: readonly Step[]): void;
|
|
@@ -2,16 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateTransactionPlanActions = validateTransactionPlanActions;
|
|
4
4
|
const error_js_1 = require("./error.js");
|
|
5
|
+
const authorization_js_1 = require("./midnight/authorization.js");
|
|
5
6
|
/**
|
|
6
|
-
* @internal Rejects unknown action types
|
|
7
|
+
* @internal Rejects unknown action types, and Midnight steps carrying a signature-request map,
|
|
8
|
+
* before interpreting requests or updates.
|
|
7
9
|
* @param steps - Steps whose action discriminators must be supported.
|
|
8
10
|
* @returns Nothing when every action type is supported.
|
|
9
11
|
* @throws {UnsupportedTransactionPlanActionError} when any step names an unsupported action type.
|
|
12
|
+
* @throws {InvalidTransactionPlanError} when a Midnight step carries `signatureRequestIds`, as restore does.
|
|
10
13
|
*/
|
|
11
14
|
function validateTransactionPlanActions(steps) {
|
|
12
|
-
for (const step of steps) {
|
|
15
|
+
for (const [index, step] of steps.entries()) {
|
|
13
16
|
const actionType = step.action.type;
|
|
14
|
-
if (actionType !== "
|
|
17
|
+
if (actionType !== "midnightRedeem" &&
|
|
18
|
+
actionType !== "blueRefinance" &&
|
|
15
19
|
actionType !== "erc20Approval" &&
|
|
16
20
|
actionType !== "vaultV1Deposit" &&
|
|
17
21
|
actionType !== "vaultV1MigrateToV2" &&
|
|
@@ -23,8 +27,28 @@ function validateTransactionPlanActions(steps) {
|
|
|
23
27
|
actionType !== "blueRepay" &&
|
|
24
28
|
actionType !== "blueWithdraw" &&
|
|
25
29
|
actionType !== "blueWithdrawCollateral" &&
|
|
30
|
+
actionType !== "blueWithdrawBuyCallback" &&
|
|
26
31
|
actionType !== "blueRepayWithdrawCollateral" &&
|
|
27
32
|
actionType !== "morphoAuthorization" &&
|
|
33
|
+
actionType !== "midnightAuthorization" &&
|
|
34
|
+
actionType !== "midnightMakeBorrow" &&
|
|
35
|
+
actionType !== "midnightMakeLend" &&
|
|
36
|
+
actionType !== "midnightMakeRepay" &&
|
|
37
|
+
actionType !== "midnightMakeWithdraw" &&
|
|
38
|
+
actionType !== "midnightSupplyBlueMakeLend" &&
|
|
39
|
+
actionType !== "midnightSupplyCollateralMakeBorrow" &&
|
|
40
|
+
actionType !== "midnightTakeBorrow" &&
|
|
41
|
+
actionType !== "midnightSupplyCollateralTakeBorrow" &&
|
|
42
|
+
actionType !== "midnightTakeLend" &&
|
|
43
|
+
actionType !== "midnightTakeRepayWithdrawCollateral" &&
|
|
44
|
+
actionType !== "midnightTakeWithdraw" &&
|
|
45
|
+
actionType !== "midnightRepayWithdrawCollateral" &&
|
|
46
|
+
actionType !== "midnightSupplyCollateral" &&
|
|
47
|
+
actionType !== "midnightSupplyCollateralWithNative" &&
|
|
48
|
+
actionType !== "midnightSupplyCollateralBatch" &&
|
|
49
|
+
actionType !== "midnightWithdrawCollateral" &&
|
|
50
|
+
actionType !== "midnightWithdrawCollateralBatch" &&
|
|
51
|
+
actionType !== "midnightCancelOffers" &&
|
|
28
52
|
actionType !== "vaultV2Deposit" &&
|
|
29
53
|
actionType !== "vaultV2Withdraw" &&
|
|
30
54
|
actionType !== "vaultV2Redeem" &&
|
|
@@ -35,5 +59,9 @@ function validateTransactionPlanActions(steps) {
|
|
|
35
59
|
actionType !== "vaultV2InKindRedeem") {
|
|
36
60
|
throw new error_js_1.UnsupportedTransactionPlanActionError(actionType);
|
|
37
61
|
}
|
|
62
|
+
if (actionType.startsWith("midnight")) {
|
|
63
|
+
// Every Midnight step is signatureless: build and inspection reject the maps restore rejects.
|
|
64
|
+
(0, authorization_js_1.validateSignaturelessMidnightAction)(step.action, `$.steps[${index}].action`);
|
|
65
|
+
}
|
|
38
66
|
}
|
|
39
67
|
}
|
|
@@ -7,7 +7,7 @@ export declare function validateTransactionPlanHeader(plan: TransactionPlan): vo
|
|
|
7
7
|
/** @internal Compares an untrusted address without throwing on malformed input. */
|
|
8
8
|
export declare function matchesAddress(value: unknown, expected: Address): boolean;
|
|
9
9
|
/** @internal Scalar and collection shapes used by stored plan fields. */
|
|
10
|
-
type PlanFieldType = "string" | "address" | "hex" | "safe integer" | "positive safe integer" | "bigint" | "uint256 bigint" | "array";
|
|
10
|
+
type PlanFieldType = "string" | "address" | "hex" | "bytes32" | "boolean" | "safe integer" | "positive safe integer" | "bigint" | "uint128 bigint" | "uint256 bigint" | "array";
|
|
11
11
|
/** @internal Validates one restored field without coercing it. */
|
|
12
12
|
export declare function validatePlanField(value: unknown, options: {
|
|
13
13
|
readonly path: string;
|
|
@@ -9,6 +9,25 @@ exports.validatePlanFields = validatePlanFields;
|
|
|
9
9
|
exports.validateVaultPlanAction = validateVaultPlanAction;
|
|
10
10
|
const viem_1 = require("viem");
|
|
11
11
|
const error_js_1 = require("./error.js");
|
|
12
|
+
/**
|
|
13
|
+
* @internal Actions whose preparation stores `deadline = BigInt(expiresAt)`, so any other stored
|
|
14
|
+
* deadline would let the bundle execute after the expiry the plan reports.
|
|
15
|
+
*/
|
|
16
|
+
const EXPIRES_AT_DEADLINE_ACTIONS = new Set([
|
|
17
|
+
"midnightTakeLend",
|
|
18
|
+
"midnightTakeBorrow",
|
|
19
|
+
"midnightTakeWithdraw",
|
|
20
|
+
"midnightRepayWithdrawCollateral",
|
|
21
|
+
"midnightMakeBorrow",
|
|
22
|
+
"midnightMakeLend",
|
|
23
|
+
"midnightMakeWithdraw",
|
|
24
|
+
"midnightMakeRepay",
|
|
25
|
+
"midnightSupplyCollateralMakeBorrow",
|
|
26
|
+
"midnightSupplyBlueMakeLend",
|
|
27
|
+
"midnightSupplyCollateralTakeBorrow",
|
|
28
|
+
"midnightTakeRepayWithdrawCollateral",
|
|
29
|
+
"midnightSupplyCollateralWithNative",
|
|
30
|
+
]);
|
|
12
31
|
/** @internal Maximum calldata-origin length in bytes. */
|
|
13
32
|
const MAX_CALLDATA_ORIGIN_BYTES = 1024 * 1024;
|
|
14
33
|
/** @internal Rejects attribution bytes above the preparation and stored-plan limit. */
|
|
@@ -70,6 +89,13 @@ function validateTransactionPlanHeader(plan) {
|
|
|
70
89
|
reason: "expected a deadline no earlier than expiresAt",
|
|
71
90
|
});
|
|
72
91
|
}
|
|
92
|
+
if (EXPIRES_AT_DEADLINE_ACTIONS.has(step.action.type) &&
|
|
93
|
+
(!("deadline" in inputs) || inputs.deadline !== BigInt(plan.expiresAt))) {
|
|
94
|
+
throw new error_js_1.InvalidTransactionPlanError({
|
|
95
|
+
path: `${path}.action.inputs.deadline`,
|
|
96
|
+
reason: "expected the plan expiresAt",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
73
99
|
}
|
|
74
100
|
const requestIds = new Set();
|
|
75
101
|
for (const [index, request] of plan.signatureRequests.entries()) {
|
|
@@ -111,6 +137,12 @@ function validatePlanField(value, options) {
|
|
|
111
137
|
valid =
|
|
112
138
|
typeof value === "string" && /^0x(?:[0-9a-fA-F]{2})*$/.test(value);
|
|
113
139
|
break;
|
|
140
|
+
case "bytes32":
|
|
141
|
+
valid = typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value);
|
|
142
|
+
break;
|
|
143
|
+
case "boolean":
|
|
144
|
+
valid = typeof value === "boolean";
|
|
145
|
+
break;
|
|
114
146
|
case "safe integer":
|
|
115
147
|
valid = typeof value === "number" && Number.isSafeInteger(value);
|
|
116
148
|
break;
|
|
@@ -121,8 +153,12 @@ function validatePlanField(value, options) {
|
|
|
121
153
|
case "bigint":
|
|
122
154
|
valid = typeof value === "bigint";
|
|
123
155
|
break;
|
|
156
|
+
case "uint128 bigint":
|
|
124
157
|
case "uint256 bigint":
|
|
125
|
-
valid =
|
|
158
|
+
valid =
|
|
159
|
+
typeof value === "bigint" &&
|
|
160
|
+
value >= 0n &&
|
|
161
|
+
value <= (type === "uint128 bigint" ? viem_1.maxUint128 : viem_1.maxUint256);
|
|
126
162
|
break;
|
|
127
163
|
case "array":
|
|
128
164
|
valid = Array.isArray(value);
|