@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
|
@@ -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
|
|
@@ -52,7 +52,7 @@ export function buildApprovalStep(requirement, { id, chainId, account, denominat
|
|
|
52
52
|
* available and falls back to a direct unlimited approval. Without signature support, always approve.
|
|
53
53
|
*/
|
|
54
54
|
export async function getTokenRequirements(client, params) {
|
|
55
|
-
const { token, spender, amount, owner, chainId,
|
|
55
|
+
const { token, spender, amount, owner, chainId, approvalId } = params;
|
|
56
56
|
// The allowance is trusted as returned by the RPC. See THREAT_MODEL.md, RPC.
|
|
57
57
|
const allowance = await readContract(client, {
|
|
58
58
|
abi: erc20Abi,
|
|
@@ -66,7 +66,7 @@ export async function getTokenRequirements(client, params) {
|
|
|
66
66
|
if (params.supportSignature) {
|
|
67
67
|
const permit = await getTokenPermit(client, {
|
|
68
68
|
...params,
|
|
69
|
-
id: permitId,
|
|
69
|
+
id: params.permitId,
|
|
70
70
|
supportDeployless: params.deployless,
|
|
71
71
|
});
|
|
72
72
|
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;
|
|
@@ -9,9 +9,24 @@ import { validateBlueSupplyPlanAction } from "./blue/supply.js";
|
|
|
9
9
|
import { validateSupplyCollateralPlanAction } from "./blue/supplyCollateral.js";
|
|
10
10
|
import { validateSupplyCollateralBorrowPlanAction } from "./blue/supplyCollateralBorrow.js";
|
|
11
11
|
import { validateBlueWithdrawPlanAction } from "./blue/withdraw.js";
|
|
12
|
+
import { validateBlueWithdrawBuyCallbackPlanAction } from "./blue/withdrawBuyCallback.js";
|
|
12
13
|
import { validateBlueWithdrawCollateralPlanAction } from "./blue/withdrawCollateral.js";
|
|
13
14
|
import { validateDepositPlanAction } from "./deposit.js";
|
|
14
15
|
import { InvalidTransactionPlanError, TransactionPlanSignatureMismatchError, } from "./error.js";
|
|
16
|
+
import { validateSignaturelessMidnightAction } from "./midnight/authorization.js";
|
|
17
|
+
import { validateMidnightCancelOffersPlanAction } from "./midnight/cancelOffers.js";
|
|
18
|
+
import { validateMidnightMakerPublicationPlanAction } from "./midnight/makerPublication.js";
|
|
19
|
+
import { validateMidnightRedeemPlanAction } from "./midnight/redeem.js";
|
|
20
|
+
import { validateMidnightRepayWithdrawCollateralPlanAction } from "./midnight/repayWithdrawCollateral.js";
|
|
21
|
+
import { validateMidnightSupplyCollateralPlanAction } from "./midnight/supplyCollateral.js";
|
|
22
|
+
import { validateMidnightSupplyCollateralBatchPlanAction } from "./midnight/supplyCollateralBatch.js";
|
|
23
|
+
import { validateMidnightSupplyCollateralWithNativePlanAction } from "./midnight/supplyCollateralWithNative.js";
|
|
24
|
+
import { validateMidnightSupplyCollateralTakeBorrowPlanAction } from "./midnight/takeBorrow.js";
|
|
25
|
+
import { validateMidnightTakeLendPlanAction } from "./midnight/takeLend.js";
|
|
26
|
+
import { validateMidnightTakeRepayWithdrawCollateralPlanAction } from "./midnight/takeRepayWithdrawCollateral.js";
|
|
27
|
+
import { validateMidnightSellPlanAction } from "./midnight/validation.js";
|
|
28
|
+
import { validateMidnightWithdrawCollateralPlanAction } from "./midnight/withdrawCollateral.js";
|
|
29
|
+
import { validateMidnightWithdrawCollateralBatchPlanAction } from "./midnight/withdrawCollateralBatch.js";
|
|
15
30
|
import { validatePermitPlanRequest } from "./permit.js";
|
|
16
31
|
import { getPendingSignatureRequests, verifyPlanSignature } from "./plan.js";
|
|
17
32
|
import { validateRedeemPlanAction } from "./redeem.js";
|
|
@@ -33,6 +48,7 @@ const actionValidators = {
|
|
|
33
48
|
blueRepay: validateBlueRepayPlanAction,
|
|
34
49
|
blueWithdraw: validateBlueWithdrawPlanAction,
|
|
35
50
|
blueWithdrawCollateral: validateBlueWithdrawCollateralPlanAction,
|
|
51
|
+
blueWithdrawBuyCallback: validateBlueWithdrawBuyCallbackPlanAction,
|
|
36
52
|
blueRepayWithdrawCollateral: validateRepayWithdrawCollateralPlanAction,
|
|
37
53
|
blueRefinance: validateRefinancePlanAction,
|
|
38
54
|
erc20Approval: validateApprovalPlanAction,
|
|
@@ -42,6 +58,26 @@ const actionValidators = {
|
|
|
42
58
|
vaultV1Redeem: validateRedeemPlanAction,
|
|
43
59
|
vaultV1MigrateToV2: validateMigrateToV2PlanAction,
|
|
44
60
|
morphoAuthorization: validateMorphoAuthorizationPlanAction,
|
|
61
|
+
midnightAuthorization: validateSignaturelessMidnightAction,
|
|
62
|
+
midnightMakeBorrow: validateMidnightMakerPublicationPlanAction,
|
|
63
|
+
midnightMakeLend: validateMidnightMakerPublicationPlanAction,
|
|
64
|
+
midnightMakeRepay: validateMidnightMakerPublicationPlanAction,
|
|
65
|
+
midnightMakeWithdraw: validateMidnightMakerPublicationPlanAction,
|
|
66
|
+
midnightSupplyBlueMakeLend: validateMidnightMakerPublicationPlanAction,
|
|
67
|
+
midnightSupplyCollateralMakeBorrow: validateMidnightMakerPublicationPlanAction,
|
|
68
|
+
midnightTakeBorrow: validateMidnightSellPlanAction,
|
|
69
|
+
midnightSupplyCollateralTakeBorrow: validateMidnightSupplyCollateralTakeBorrowPlanAction,
|
|
70
|
+
midnightTakeLend: validateMidnightTakeLendPlanAction,
|
|
71
|
+
midnightSupplyCollateral: validateMidnightSupplyCollateralPlanAction,
|
|
72
|
+
midnightSupplyCollateralBatch: validateMidnightSupplyCollateralBatchPlanAction,
|
|
73
|
+
midnightSupplyCollateralWithNative: validateMidnightSupplyCollateralWithNativePlanAction,
|
|
74
|
+
midnightWithdrawCollateral: validateMidnightWithdrawCollateralPlanAction,
|
|
75
|
+
midnightWithdrawCollateralBatch: validateMidnightWithdrawCollateralBatchPlanAction,
|
|
76
|
+
midnightRedeem: validateMidnightRedeemPlanAction,
|
|
77
|
+
midnightTakeRepayWithdrawCollateral: validateMidnightTakeRepayWithdrawCollateralPlanAction,
|
|
78
|
+
midnightTakeWithdraw: validateMidnightSellPlanAction,
|
|
79
|
+
midnightRepayWithdrawCollateral: validateMidnightRepayWithdrawCollateralPlanAction,
|
|
80
|
+
midnightCancelOffers: validateMidnightCancelOffersPlanAction,
|
|
45
81
|
vaultV2Deposit: validateDepositPlanAction,
|
|
46
82
|
vaultV2Withdraw: validateWithdrawPlanAction,
|
|
47
83
|
vaultV2ForceRedeem: validateForceRedeemPlanAction,
|
|
@@ -70,8 +106,19 @@ export function serializeTransactionPlan(plan) {
|
|
|
70
106
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
71
107
|
* Restores bigint fields and validates version, action/request shapes, uint256 ranges, unique IDs,
|
|
72
108
|
* references, per-action chain/account and signature-request consistency, including signed requests.
|
|
73
|
-
* Extra keys are allowed.
|
|
74
|
-
*
|
|
109
|
+
* Extra keys are allowed. Midnight maker publications, `midnightSupplyCollateralTakeBorrow`,
|
|
110
|
+
* `midnightTakeRepayWithdrawCollateral` and `midnightSupplyCollateralWithNative` also rerun their
|
|
111
|
+
* builders' static input checks, so a stored recipe that fails those checks throws here. Restore compares the stored market of
|
|
112
|
+
* `midnightSupplyCollateralMakeBorrow`, `midnightSupplyCollateralTakeBorrow` and
|
|
113
|
+
* `midnightTakeRepayWithdrawCollateral` with the registered Midnight deployment, and each maker
|
|
114
|
+
* publication's ratifier with the registry. It does not decode maker offer payloads, so their offer
|
|
115
|
+
* markets are not checked, and other Midnight actions check only the stored market's shape and
|
|
116
|
+
* chain. Restoring `midnightSupplyCollateralWithNative` also looks up the chain's Midnight core,
|
|
117
|
+
* wNative and MidnightBundlesV2 registry entries, so register custom deployments before parsing.
|
|
118
|
+
* Building can still fail: other deployment lookups, such as the Midnight bundle address of other
|
|
119
|
+
* actions, run only in `buildTransactions`. No clock or RPC is used:
|
|
120
|
+
* current expiry, live state and other action-layer business constraints are not checked. Stored
|
|
121
|
+
* signatures are recovered offline.
|
|
75
122
|
* Permits bind owner, token, spender, value, nonce, deadline and chain; Morpho authorizations bind
|
|
76
123
|
* owner, authorized address, nonce, deadline and chain, not operation amounts, markets or referral fees/recipients.
|
|
77
124
|
* Parsing does not prove authenticity or intent for unsigned fields;
|
|
@@ -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;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { UnsupportedTransactionPlanActionError } from "./error.js";
|
|
2
|
+
import { validateSignaturelessMidnightAction } from "./midnight/authorization.js";
|
|
2
3
|
/**
|
|
3
|
-
* @internal Rejects unknown action types
|
|
4
|
+
* @internal Rejects unknown action types, and Midnight steps carrying a signature-request map,
|
|
5
|
+
* before interpreting requests or updates.
|
|
4
6
|
* @param steps - Steps whose action discriminators must be supported.
|
|
5
7
|
* @returns Nothing when every action type is supported.
|
|
6
8
|
* @throws {UnsupportedTransactionPlanActionError} when any step names an unsupported action type.
|
|
9
|
+
* @throws {InvalidTransactionPlanError} when a Midnight step carries `signatureRequestIds`, as restore does.
|
|
7
10
|
*/
|
|
8
11
|
export function validateTransactionPlanActions(steps) {
|
|
9
|
-
for (const step of steps) {
|
|
12
|
+
for (const [index, step] of steps.entries()) {
|
|
10
13
|
const actionType = step.action.type;
|
|
11
|
-
if (actionType !== "
|
|
14
|
+
if (actionType !== "midnightRedeem" &&
|
|
15
|
+
actionType !== "blueRefinance" &&
|
|
12
16
|
actionType !== "erc20Approval" &&
|
|
13
17
|
actionType !== "vaultV1Deposit" &&
|
|
14
18
|
actionType !== "vaultV1MigrateToV2" &&
|
|
@@ -20,8 +24,28 @@ export function validateTransactionPlanActions(steps) {
|
|
|
20
24
|
actionType !== "blueRepay" &&
|
|
21
25
|
actionType !== "blueWithdraw" &&
|
|
22
26
|
actionType !== "blueWithdrawCollateral" &&
|
|
27
|
+
actionType !== "blueWithdrawBuyCallback" &&
|
|
23
28
|
actionType !== "blueRepayWithdrawCollateral" &&
|
|
24
29
|
actionType !== "morphoAuthorization" &&
|
|
30
|
+
actionType !== "midnightAuthorization" &&
|
|
31
|
+
actionType !== "midnightMakeBorrow" &&
|
|
32
|
+
actionType !== "midnightMakeLend" &&
|
|
33
|
+
actionType !== "midnightMakeRepay" &&
|
|
34
|
+
actionType !== "midnightMakeWithdraw" &&
|
|
35
|
+
actionType !== "midnightSupplyBlueMakeLend" &&
|
|
36
|
+
actionType !== "midnightSupplyCollateralMakeBorrow" &&
|
|
37
|
+
actionType !== "midnightTakeBorrow" &&
|
|
38
|
+
actionType !== "midnightSupplyCollateralTakeBorrow" &&
|
|
39
|
+
actionType !== "midnightTakeLend" &&
|
|
40
|
+
actionType !== "midnightTakeRepayWithdrawCollateral" &&
|
|
41
|
+
actionType !== "midnightTakeWithdraw" &&
|
|
42
|
+
actionType !== "midnightRepayWithdrawCollateral" &&
|
|
43
|
+
actionType !== "midnightSupplyCollateral" &&
|
|
44
|
+
actionType !== "midnightSupplyCollateralWithNative" &&
|
|
45
|
+
actionType !== "midnightSupplyCollateralBatch" &&
|
|
46
|
+
actionType !== "midnightWithdrawCollateral" &&
|
|
47
|
+
actionType !== "midnightWithdrawCollateralBatch" &&
|
|
48
|
+
actionType !== "midnightCancelOffers" &&
|
|
25
49
|
actionType !== "vaultV2Deposit" &&
|
|
26
50
|
actionType !== "vaultV2Withdraw" &&
|
|
27
51
|
actionType !== "vaultV2Redeem" &&
|
|
@@ -32,5 +56,9 @@ export function validateTransactionPlanActions(steps) {
|
|
|
32
56
|
actionType !== "vaultV2InKindRedeem") {
|
|
33
57
|
throw new UnsupportedTransactionPlanActionError(actionType);
|
|
34
58
|
}
|
|
59
|
+
if (actionType.startsWith("midnight")) {
|
|
60
|
+
// Every Midnight step is signatureless: build and inspection reject the maps restore rejects.
|
|
61
|
+
validateSignaturelessMidnightAction(step.action, `$.steps[${index}].action`);
|
|
62
|
+
}
|
|
35
63
|
}
|
|
36
64
|
}
|
|
@@ -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;
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import { isAddress, isAddressEqual, maxUint256 } from "viem";
|
|
1
|
+
import { isAddress, isAddressEqual, maxUint128, maxUint256, } from "viem";
|
|
2
2
|
import { InvalidTransactionPlanError } from "./error.js";
|
|
3
|
+
/**
|
|
4
|
+
* @internal Actions whose preparation stores `deadline = BigInt(expiresAt)`, so any other stored
|
|
5
|
+
* deadline would let the bundle execute after the expiry the plan reports.
|
|
6
|
+
*/
|
|
7
|
+
const EXPIRES_AT_DEADLINE_ACTIONS = new Set([
|
|
8
|
+
"midnightTakeLend",
|
|
9
|
+
"midnightTakeBorrow",
|
|
10
|
+
"midnightTakeWithdraw",
|
|
11
|
+
"midnightRepayWithdrawCollateral",
|
|
12
|
+
"midnightMakeBorrow",
|
|
13
|
+
"midnightMakeLend",
|
|
14
|
+
"midnightMakeWithdraw",
|
|
15
|
+
"midnightMakeRepay",
|
|
16
|
+
"midnightSupplyCollateralMakeBorrow",
|
|
17
|
+
"midnightSupplyBlueMakeLend",
|
|
18
|
+
"midnightSupplyCollateralTakeBorrow",
|
|
19
|
+
"midnightTakeRepayWithdrawCollateral",
|
|
20
|
+
"midnightSupplyCollateralWithNative",
|
|
21
|
+
]);
|
|
3
22
|
/** @internal Maximum calldata-origin length in bytes. */
|
|
4
23
|
const MAX_CALLDATA_ORIGIN_BYTES = 1024 * 1024;
|
|
5
24
|
/** @internal Rejects attribution bytes above the preparation and stored-plan limit. */
|
|
@@ -61,6 +80,13 @@ export function validateTransactionPlanHeader(plan) {
|
|
|
61
80
|
reason: "expected a deadline no earlier than expiresAt",
|
|
62
81
|
});
|
|
63
82
|
}
|
|
83
|
+
if (EXPIRES_AT_DEADLINE_ACTIONS.has(step.action.type) &&
|
|
84
|
+
(!("deadline" in inputs) || inputs.deadline !== BigInt(plan.expiresAt))) {
|
|
85
|
+
throw new InvalidTransactionPlanError({
|
|
86
|
+
path: `${path}.action.inputs.deadline`,
|
|
87
|
+
reason: "expected the plan expiresAt",
|
|
88
|
+
});
|
|
89
|
+
}
|
|
64
90
|
}
|
|
65
91
|
const requestIds = new Set();
|
|
66
92
|
for (const [index, request] of plan.signatureRequests.entries()) {
|
|
@@ -102,6 +128,12 @@ export function validatePlanField(value, options) {
|
|
|
102
128
|
valid =
|
|
103
129
|
typeof value === "string" && /^0x(?:[0-9a-fA-F]{2})*$/.test(value);
|
|
104
130
|
break;
|
|
131
|
+
case "bytes32":
|
|
132
|
+
valid = typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value);
|
|
133
|
+
break;
|
|
134
|
+
case "boolean":
|
|
135
|
+
valid = typeof value === "boolean";
|
|
136
|
+
break;
|
|
105
137
|
case "safe integer":
|
|
106
138
|
valid = typeof value === "number" && Number.isSafeInteger(value);
|
|
107
139
|
break;
|
|
@@ -112,8 +144,12 @@ export function validatePlanField(value, options) {
|
|
|
112
144
|
case "bigint":
|
|
113
145
|
valid = typeof value === "bigint";
|
|
114
146
|
break;
|
|
147
|
+
case "uint128 bigint":
|
|
115
148
|
case "uint256 bigint":
|
|
116
|
-
valid =
|
|
149
|
+
valid =
|
|
150
|
+
typeof value === "bigint" &&
|
|
151
|
+
value >= 0n &&
|
|
152
|
+
value <= (type === "uint128 bigint" ? maxUint128 : maxUint256);
|
|
117
153
|
break;
|
|
118
154
|
case "array":
|
|
119
155
|
valid = Array.isArray(value);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Address } from "viem";
|
|
2
|
+
import type { Action } from "./types.js";
|
|
3
|
+
declare const VAULT_PERMIT_ACTION_TYPES: readonly ["vaultV2Deposit", "vaultV1Deposit", "vaultV1Withdraw", "vaultV2Withdraw", "vaultV2Redeem", "vaultV1Redeem", "vaultV2ForceWithdraw", "vaultV1MigrateToV2", "vaultV2InKindRedeem", "vaultV1InKindRedeem"];
|
|
4
|
+
/** @internal Vault actions whose step pulls a token through a bundle and may consume a permit. */
|
|
5
|
+
export type VaultPermitAction = Extract<Action, {
|
|
6
|
+
readonly type: (typeof VAULT_PERMIT_ACTION_TYPES)[number];
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* @internal The bundle, signed token and amounts a vault action's token permit must match.
|
|
10
|
+
* `restore` binds the stored signing payload; `build` is what the bundle pull selects, which differs
|
|
11
|
+
* from `restore` for deposits (`assets` versus `assets ?? nativeAssets`).
|
|
12
|
+
*/
|
|
13
|
+
export interface VaultPermitBinding {
|
|
14
|
+
readonly bundler: "bundles.vaultBundlesV1" | "bundles.vaultExitBundlesV1";
|
|
15
|
+
readonly asset: Address;
|
|
16
|
+
readonly restore: {
|
|
17
|
+
readonly amount: bigint | undefined;
|
|
18
|
+
readonly exact: boolean;
|
|
19
|
+
};
|
|
20
|
+
readonly build: {
|
|
21
|
+
readonly amount: bigint;
|
|
22
|
+
readonly pull: "token" | "shares";
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** @internal Whether the action is one of the vault actions a token permit can fund. */
|
|
26
|
+
export declare function isVaultPermitAction(action: Action): action is VaultPermitAction;
|
|
27
|
+
/** @internal Reads the permit binding from the vault action's stored inputs. */
|
|
28
|
+
export declare function getVaultPermitBinding(action: VaultPermitAction): VaultPermitBinding;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { maxUint256 } from "viem";
|
|
2
|
+
const VAULT_PERMIT_ACTION_TYPES = [
|
|
3
|
+
"vaultV2Deposit",
|
|
4
|
+
"vaultV1Deposit",
|
|
5
|
+
"vaultV1Withdraw",
|
|
6
|
+
"vaultV2Withdraw",
|
|
7
|
+
"vaultV2Redeem",
|
|
8
|
+
"vaultV1Redeem",
|
|
9
|
+
"vaultV2ForceWithdraw",
|
|
10
|
+
"vaultV1MigrateToV2",
|
|
11
|
+
"vaultV2InKindRedeem",
|
|
12
|
+
"vaultV1InKindRedeem",
|
|
13
|
+
];
|
|
14
|
+
/** @internal Whether the action is one of the vault actions a token permit can fund. */
|
|
15
|
+
export function isVaultPermitAction(action) {
|
|
16
|
+
return VAULT_PERMIT_ACTION_TYPES.includes(action.type);
|
|
17
|
+
}
|
|
18
|
+
/** @internal Reads the permit binding from the vault action's stored inputs. */
|
|
19
|
+
export function getVaultPermitBinding(action) {
|
|
20
|
+
switch (action.type) {
|
|
21
|
+
case "vaultV2Deposit":
|
|
22
|
+
case "vaultV1Deposit":
|
|
23
|
+
return {
|
|
24
|
+
bundler: "bundles.vaultBundlesV1",
|
|
25
|
+
asset: action.inputs.asset,
|
|
26
|
+
restore: { amount: action.inputs.assets, exact: true },
|
|
27
|
+
build: {
|
|
28
|
+
amount: action.inputs.assets ?? action.inputs.nativeAssets,
|
|
29
|
+
pull: "token",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
case "vaultV1Withdraw":
|
|
33
|
+
case "vaultV2Withdraw":
|
|
34
|
+
return {
|
|
35
|
+
bundler: "bundles.vaultBundlesV1",
|
|
36
|
+
asset: action.inputs.vault,
|
|
37
|
+
restore: { amount: action.inputs.requiredShareAllowance, exact: false },
|
|
38
|
+
build: { amount: action.inputs.requiredShareAllowance, pull: "shares" },
|
|
39
|
+
};
|
|
40
|
+
case "vaultV2Redeem":
|
|
41
|
+
case "vaultV1Redeem":
|
|
42
|
+
return {
|
|
43
|
+
bundler: "bundles.vaultBundlesV1",
|
|
44
|
+
asset: action.inputs.vault,
|
|
45
|
+
restore: { amount: action.inputs.shares, exact: false },
|
|
46
|
+
build: { amount: action.inputs.shares, pull: "shares" },
|
|
47
|
+
};
|
|
48
|
+
case "vaultV1MigrateToV2":
|
|
49
|
+
return {
|
|
50
|
+
bundler: "bundles.vaultBundlesV1",
|
|
51
|
+
asset: action.inputs.sourceVault,
|
|
52
|
+
restore: { amount: action.inputs.requiredShareAllowance, exact: false },
|
|
53
|
+
build: { amount: action.inputs.requiredShareAllowance, pull: "shares" },
|
|
54
|
+
};
|
|
55
|
+
case "vaultV2ForceWithdraw":
|
|
56
|
+
case "vaultV2InKindRedeem":
|
|
57
|
+
case "vaultV1InKindRedeem":
|
|
58
|
+
return {
|
|
59
|
+
bundler: "bundles.vaultExitBundlesV1",
|
|
60
|
+
asset: action.inputs.vault,
|
|
61
|
+
restore: { amount: maxUint256, exact: true },
|
|
62
|
+
build: { amount: maxUint256, pull: "shares" },
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import { type ActionRequirement } from "../types/index.js";
|
|
3
|
+
import type { SignatureRequest, Step } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* @internal Turns a vault exit's share requirements into approval steps and permit requests.
|
|
6
|
+
* Steps take the ID `${id}:approval` and requests `${id}:tokenPermit`; `signatureRequestIds`
|
|
7
|
+
* names the permit only when one is requested.
|
|
8
|
+
* @throws {UnsupportedRequirementSignatureError} If a requirement is a signature other than a permit.
|
|
9
|
+
*/
|
|
10
|
+
export declare function vaultRequirementSteps(requirements: readonly ActionRequirement[], { id, chainId, account, }: {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly chainId: number;
|
|
13
|
+
readonly account: Address;
|
|
14
|
+
}): {
|
|
15
|
+
readonly approvals: Step[];
|
|
16
|
+
readonly signatureRequests: SignatureRequest[];
|
|
17
|
+
readonly signatureRequestIds: {
|
|
18
|
+
readonly tokenPermit?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|