@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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AbiEncodingBytesSizeMismatchError, BaseError, IntegerOutOfRangeError, InvalidHexValueError, isHex, maxUint256, } from "viem";
|
|
2
|
+
import { MidnightCalldataEncodingError } from "../types/index.js";
|
|
3
|
+
import { validateMidnightAddress } from "./validateMidnightAccount.js";
|
|
4
|
+
const OFFER_ADDRESS_FIELDS = [
|
|
5
|
+
"maker",
|
|
6
|
+
"callback",
|
|
7
|
+
"receiverIfMakerIsSeller",
|
|
8
|
+
"ratifier",
|
|
9
|
+
];
|
|
10
|
+
const OFFER_UINT256_FIELDS = [
|
|
11
|
+
"start",
|
|
12
|
+
"expiry",
|
|
13
|
+
"tick",
|
|
14
|
+
"continuousFeeCap",
|
|
15
|
+
];
|
|
16
|
+
const OFFER_CAP_FIELDS = ["maxUnits", "maxAssets"];
|
|
17
|
+
const BYTES32_PATTERN = /^0x[0-9a-fA-F]{64}$/;
|
|
18
|
+
const validateUint256 = (field, value) => {
|
|
19
|
+
if (typeof value !== "bigint") {
|
|
20
|
+
throw new MidnightCalldataEncodingError(field, new BaseError(`Invalid bigint value: "${String(value)}".`));
|
|
21
|
+
}
|
|
22
|
+
if (value < 0n || value > maxUint256) {
|
|
23
|
+
throw new MidnightCalldataEncodingError(field, new IntegerOutOfRangeError({
|
|
24
|
+
max: `${maxUint256}n`,
|
|
25
|
+
min: "0n",
|
|
26
|
+
signed: false,
|
|
27
|
+
size: 32,
|
|
28
|
+
value: `${value}n`,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const validateBytes = (field, value) => {
|
|
33
|
+
if (!isHex(value) || value.length % 2 !== 0) {
|
|
34
|
+
throw new MidnightCalldataEncodingError(field, new InvalidHexValueError(value));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Parses the fields of each taken offer fill that `MidnightBundlesV2` ABI-encodes and that the
|
|
39
|
+
* side, market and cap guards do not already check, so a malformed offer is rejected before any
|
|
40
|
+
* read or encoding.
|
|
41
|
+
*
|
|
42
|
+
* Integer and address bounds are the ABI's: `start`, `expiry`, `tick`, `continuousFeeCap` and
|
|
43
|
+
* the fill's `units` are `uint256` bigints; the `maxUnits` and `maxAssets` caps are bigints whose
|
|
44
|
+
* `uint128` bounds the action parser checks; `maker`, `callback`, `receiverIfMakerIsSeller` and
|
|
45
|
+
* `ratifier` are addresses (checksummed when mixed-case); `group` is exactly 32 bytes of `0x` hex;
|
|
46
|
+
* `reduceOnly` is a boolean. `callbackData` and `ratifierData` must be even-length `0x` hex.
|
|
47
|
+
*
|
|
48
|
+
* @param takeableOffers - Offers selected for a Midnight take.
|
|
49
|
+
* @returns Nothing when every offer field can be encoded.
|
|
50
|
+
* @throws {MidnightCalldataEncodingError} when a field is malformed; `input` is its path, such as
|
|
51
|
+
* `"takeableOffers[0].offer.maker"`.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export const validateMidnightTakeableOfferFields = (takeableOffers) => {
|
|
55
|
+
for (const [index, { units, offer, ratifierData },] of takeableOffers.entries()) {
|
|
56
|
+
const path = `takeableOffers[${index}]`;
|
|
57
|
+
for (const field of OFFER_ADDRESS_FIELDS) {
|
|
58
|
+
validateMidnightAddress(`${path}.offer.${field}`, offer[field]);
|
|
59
|
+
}
|
|
60
|
+
for (const field of OFFER_UINT256_FIELDS) {
|
|
61
|
+
validateUint256(`${path}.offer.${field}`, offer[field]);
|
|
62
|
+
}
|
|
63
|
+
for (const field of OFFER_CAP_FIELDS) {
|
|
64
|
+
validateUint256(`${path}.offer.${field}`, offer[field]);
|
|
65
|
+
}
|
|
66
|
+
if (typeof offer.group !== "string" || !BYTES32_PATTERN.test(offer.group)) {
|
|
67
|
+
throw new MidnightCalldataEncodingError(`${path}.offer.group`, isHex(offer.group, { strict: true })
|
|
68
|
+
? new AbiEncodingBytesSizeMismatchError({
|
|
69
|
+
expectedSize: 32,
|
|
70
|
+
value: offer.group,
|
|
71
|
+
})
|
|
72
|
+
: new InvalidHexValueError(offer.group));
|
|
73
|
+
}
|
|
74
|
+
validateBytes(`${path}.offer.callbackData`, offer.callbackData);
|
|
75
|
+
if (typeof offer.reduceOnly !== "boolean") {
|
|
76
|
+
throw new MidnightCalldataEncodingError(`${path}.offer.reduceOnly`, new BaseError(`Invalid boolean value: "${offer.reduceOnly}".`));
|
|
77
|
+
}
|
|
78
|
+
validateBytes(`${path}.ratifierData`, ratifierData);
|
|
79
|
+
validateUint256(`${path}.units`, units);
|
|
80
|
+
}
|
|
81
|
+
};
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from "./client/index.js";
|
|
|
4
4
|
export type { SupplyCollateralWithNativeParams } from "./entities/midnight/types.js";
|
|
5
5
|
export * from "./entities/requirements/index.js";
|
|
6
6
|
export * from "./helpers/index.js";
|
|
7
|
-
export type { Action, BlueBorrowPlanParams, BlueMarketSnapshot, BluePositionSnapshot, BlueRefinancePlanParams, BlueRepayPlanParams, BlueRepayWithdrawCollateralPlanParams, BlueSupplyCollateralBorrowPlanParams, BlueSupplyCollateralPlanParams, BlueSupplyPlanParams, BlueWithdrawCollateralPlanParams, BlueWithdrawPlanParams, Funding, IntentParams, ReferralFee, SignatureRequest, Step, TransactionPlan, VaultV1DepositPlanParams, VaultV1InKindRedeemPlanParams, VaultV1MigrateToV2PlanParams, VaultV1RedeemPlanParams, VaultV1WithdrawPlanParams, VaultV2DepositPlanParams, VaultV2ForceRedeemPlanParams, VaultV2ForceWithdrawPlanParams, VaultV2InKindRedeemPlanParams, VaultV2RedeemPlanParams, VaultV2WithdrawPlanParams, } from "./transactionPlan/index.js";
|
|
8
|
-
export { applySignatures, BlueSnapshotChainMismatchError, BlueSnapshotStateMismatchError, buildTransaction, buildTransactions, getPendingSignatureRequests, IncompleteTransactionPlanError, InvalidCalldataOriginError, InvalidTransactionPlanError, NonIntegerInputError, parseTransactionPlan, prepareBlueBorrow, prepareBlueRefinance, prepareBlueRepay, prepareBlueRepayWithdrawCollateral, prepareBlueSupply, prepareBlueSupplyCollateral, prepareBlueSupplyCollateralBorrow, prepareBlueWithdraw, prepareBlueWithdrawCollateral, prepareVaultV1Deposit, prepareVaultV1InKindRedeem, prepareVaultV1MigrateToV2, prepareVaultV1Redeem, prepareVaultV1Withdraw, prepareVaultV2Deposit, prepareVaultV2ForceRedeem, prepareVaultV2ForceWithdraw, prepareVaultV2InKindRedeem, prepareVaultV2Redeem, prepareVaultV2Withdraw, serializeTransactionPlan, TransactionPlanSignatureMismatchError, UnsupportedTransactionPlanActionError, UnsupportedTransactionPlanVersionError, validateBlueMarketSnapshot, ZeroAccountError, } from "./transactionPlan/index.js";
|
|
7
|
+
export type { Action, BlueBorrowPlanParams, BlueMarketSnapshot, BluePositionSnapshot, BlueRefinancePlanParams, BlueRepayPlanParams, BlueRepayWithdrawCollateralPlanParams, BlueSupplyCollateralBorrowPlanParams, BlueSupplyCollateralPlanParams, BlueSupplyPlanParams, BlueWithdrawBuyCallbackPlanParams, BlueWithdrawCollateralPlanParams, BlueWithdrawPlanParams, Funding, IntentParams, MidnightCancelOffersPlanParams, MidnightMakeBorrowPlanParams, MidnightMakeLendPlanParams, MidnightMakeRepayPlanParams, MidnightMakerPublicationPlanParams, MidnightMakeWithdrawPlanParams, MidnightRedeemPlanParams, MidnightRepayWithdrawCollateralPlanParams, MidnightSupplyBlueMakeLendPlanParams, MidnightSupplyCollateralBatchPlanParams, MidnightSupplyCollateralMakeBorrowPlanParams, MidnightSupplyCollateralPlanParams, MidnightSupplyCollateralTakeBorrowPlanParams, MidnightSupplyCollateralWithNativePlanParams, MidnightTakeBorrowPlanParams, MidnightTakeLendPlanParams, MidnightTakeRepayWithdrawCollateralPlanParams, MidnightTakeWithdrawPlanParams, MidnightWithdrawCollateralBatchPlanParams, MidnightWithdrawCollateralPlanParams, ReferralFee, SignatureRequest, Step, TransactionPlan, VaultV1DepositPlanParams, VaultV1InKindRedeemPlanParams, VaultV1MigrateToV2PlanParams, VaultV1RedeemPlanParams, VaultV1WithdrawPlanParams, VaultV2DepositPlanParams, VaultV2ForceRedeemPlanParams, VaultV2ForceWithdrawPlanParams, VaultV2InKindRedeemPlanParams, VaultV2RedeemPlanParams, VaultV2WithdrawPlanParams, } from "./transactionPlan/index.js";
|
|
8
|
+
export { applySignatures, BlueSnapshotChainMismatchError, BlueSnapshotStateMismatchError, buildTransaction, buildTransactions, getPendingSignatureRequests, IncompleteTransactionPlanError, InvalidCalldataOriginError, InvalidTransactionPlanError, MidnightTakeCreditInsufficientError, NonIntegerInputError, parseTransactionPlan, prepareBlueBorrow, prepareBlueRefinance, prepareBlueRepay, prepareBlueRepayWithdrawCollateral, prepareBlueSupply, prepareBlueSupplyCollateral, prepareBlueSupplyCollateralBorrow, prepareBlueWithdraw, prepareBlueWithdrawBuyCallback, prepareBlueWithdrawCollateral, prepareMidnightCancelOffers, prepareMidnightMakeBorrow, prepareMidnightMakeLend, prepareMidnightMakeRepay, prepareMidnightMakeWithdraw, prepareMidnightRedeem, prepareMidnightRepayWithdrawCollateral, prepareMidnightSupplyBlueMakeLend, prepareMidnightSupplyCollateral, prepareMidnightSupplyCollateralBatch, prepareMidnightSupplyCollateralMakeBorrow, prepareMidnightSupplyCollateralTakeBorrow, prepareMidnightSupplyCollateralWithNative, prepareMidnightTakeBorrow, prepareMidnightTakeLend, prepareMidnightTakeRepayWithdrawCollateral, prepareMidnightTakeWithdraw, prepareMidnightWithdrawCollateral, prepareMidnightWithdrawCollateralBatch, prepareVaultV1Deposit, prepareVaultV1InKindRedeem, prepareVaultV1MigrateToV2, prepareVaultV1Redeem, prepareVaultV1Withdraw, prepareVaultV2Deposit, prepareVaultV2ForceRedeem, prepareVaultV2ForceWithdraw, prepareVaultV2InKindRedeem, prepareVaultV2Redeem, prepareVaultV2Withdraw, serializeTransactionPlan, TransactionPlanSignatureMismatchError, UnsupportedTransactionPlanActionError, UnsupportedTransactionPlanVersionError, validateBlueMarketSnapshot, ZeroAccountError, } from "./transactionPlan/index.js";
|
|
9
9
|
export * from "./types/index.js";
|
|
10
10
|
export { version } from "./version.js";
|
package/lib/esm/index.js
CHANGED
|
@@ -3,6 +3,6 @@ export { validateClientChainId } from "./actions/requirements/validateClientChai
|
|
|
3
3
|
export * from "./client/index.js";
|
|
4
4
|
export * from "./entities/requirements/index.js";
|
|
5
5
|
export * from "./helpers/index.js";
|
|
6
|
-
export { applySignatures, BlueSnapshotChainMismatchError, BlueSnapshotStateMismatchError, buildTransaction, buildTransactions, getPendingSignatureRequests, IncompleteTransactionPlanError, InvalidCalldataOriginError, InvalidTransactionPlanError, NonIntegerInputError, parseTransactionPlan, prepareBlueBorrow, prepareBlueRefinance, prepareBlueRepay, prepareBlueRepayWithdrawCollateral, prepareBlueSupply, prepareBlueSupplyCollateral, prepareBlueSupplyCollateralBorrow, prepareBlueWithdraw, prepareBlueWithdrawCollateral, prepareVaultV1Deposit, prepareVaultV1InKindRedeem, prepareVaultV1MigrateToV2, prepareVaultV1Redeem, prepareVaultV1Withdraw, prepareVaultV2Deposit, prepareVaultV2ForceRedeem, prepareVaultV2ForceWithdraw, prepareVaultV2InKindRedeem, prepareVaultV2Redeem, prepareVaultV2Withdraw, serializeTransactionPlan, TransactionPlanSignatureMismatchError, UnsupportedTransactionPlanActionError, UnsupportedTransactionPlanVersionError, validateBlueMarketSnapshot, ZeroAccountError, } from "./transactionPlan/index.js";
|
|
6
|
+
export { applySignatures, BlueSnapshotChainMismatchError, BlueSnapshotStateMismatchError, buildTransaction, buildTransactions, getPendingSignatureRequests, IncompleteTransactionPlanError, InvalidCalldataOriginError, InvalidTransactionPlanError, MidnightTakeCreditInsufficientError, NonIntegerInputError, parseTransactionPlan, prepareBlueBorrow, prepareBlueRefinance, prepareBlueRepay, prepareBlueRepayWithdrawCollateral, prepareBlueSupply, prepareBlueSupplyCollateral, prepareBlueSupplyCollateralBorrow, prepareBlueWithdraw, prepareBlueWithdrawBuyCallback, prepareBlueWithdrawCollateral, prepareMidnightCancelOffers, prepareMidnightMakeBorrow, prepareMidnightMakeLend, prepareMidnightMakeRepay, prepareMidnightMakeWithdraw, prepareMidnightRedeem, prepareMidnightRepayWithdrawCollateral, prepareMidnightSupplyBlueMakeLend, prepareMidnightSupplyCollateral, prepareMidnightSupplyCollateralBatch, prepareMidnightSupplyCollateralMakeBorrow, prepareMidnightSupplyCollateralTakeBorrow, prepareMidnightSupplyCollateralWithNative, prepareMidnightTakeBorrow, prepareMidnightTakeLend, prepareMidnightTakeRepayWithdrawCollateral, prepareMidnightTakeWithdraw, prepareMidnightWithdrawCollateral, prepareMidnightWithdrawCollateralBatch, prepareVaultV1Deposit, prepareVaultV1InKindRedeem, prepareVaultV1MigrateToV2, prepareVaultV1Redeem, prepareVaultV1Withdraw, prepareVaultV2Deposit, prepareVaultV2ForceRedeem, prepareVaultV2ForceWithdraw, prepareVaultV2InKindRedeem, prepareVaultV2Redeem, prepareVaultV2Withdraw, serializeTransactionPlan, TransactionPlanSignatureMismatchError, UnsupportedTransactionPlanActionError, UnsupportedTransactionPlanVersionError, validateBlueMarketSnapshot, ZeroAccountError, } from "./transactionPlan/index.js";
|
|
7
7
|
export * from "./types/index.js";
|
|
8
8
|
export { version } from "./version.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { ChainIdMismatchError, InvalidEcrecoverSignatureError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError,
|
|
1
|
+
export { ChainIdMismatchError, InvalidEcrecoverSignatureError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
2
|
+
export { InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, } from "@morpho-org/morpho-ts";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { ChainIdMismatchError, InvalidEcrecoverSignatureError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError,
|
|
1
|
+
export { ChainIdMismatchError, InvalidEcrecoverSignatureError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
2
|
+
export { InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, } from "@morpho-org/morpho-ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { EcrecoverRatifier,
|
|
2
2
|
/** @deprecated Use EcrecoverRatifier with a tagged tree. */
|
|
3
|
-
EcrecoverRatifierUtils, eip712Digest, GroupUtils, MarketUtils, OfferChainUtils, OfferUtils, Payload, PositionUtils, PriceRatifierV1,
|
|
3
|
+
EcrecoverRatifierUtils, eip712Digest, GroupUtils, getBlueBuyCallbackAddress, MarketUtils, OfferChainUtils, OfferUtils, Payload, PositionUtils, PriceRatifierV1,
|
|
4
4
|
/** @deprecated Use PriceRatifierV1. */
|
|
5
5
|
PriceRatifierV1Utils, RateRatifierV1,
|
|
6
6
|
/** @deprecated Use RateRatifierV1. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { EcrecoverRatifier,
|
|
2
2
|
/** @deprecated Use EcrecoverRatifier with a tagged tree. */
|
|
3
|
-
EcrecoverRatifierUtils, eip712Digest, GroupUtils, MarketUtils, OfferChainUtils, OfferUtils, Payload, PositionUtils, PriceRatifierV1,
|
|
3
|
+
EcrecoverRatifierUtils, eip712Digest, GroupUtils, getBlueBuyCallbackAddress, MarketUtils, OfferChainUtils, OfferUtils, Payload, PositionUtils, PriceRatifierV1,
|
|
4
4
|
/** @deprecated Use PriceRatifierV1. */
|
|
5
5
|
PriceRatifierV1Utils, RateRatifierV1,
|
|
6
6
|
/** @deprecated Use RateRatifierV1. */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { Intent } from "./intent.js";
|
|
3
|
+
import type { TransactionPlan } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* @internal The stored plan header: version, chain, account, expiry, and the calldata origin when
|
|
6
|
+
* the intent has one.
|
|
7
|
+
*/
|
|
8
|
+
export declare function planHeader({ chainId, account }: {
|
|
9
|
+
readonly chainId: number;
|
|
10
|
+
readonly account: Address;
|
|
11
|
+
}, { expiresAt, calldataOrigin }: Pick<Intent, "expiresAt" | "calldataOrigin">): {
|
|
12
|
+
readonly version: 2;
|
|
13
|
+
readonly chainId: number;
|
|
14
|
+
readonly account: `0x${string}`;
|
|
15
|
+
readonly expiresAt: number;
|
|
16
|
+
readonly calldataOrigin?: `0x${string}` | undefined;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @internal Deeply freezes a prepared plan. `detach` copies it first, so no object the caller
|
|
20
|
+
* passed in is frozen or shared with the plan.
|
|
21
|
+
*/
|
|
22
|
+
export declare function freezePlan(plan: TransactionPlan, { detach }: {
|
|
23
|
+
readonly detach: boolean;
|
|
24
|
+
}): TransactionPlan;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { deepFreeze } from "@morpho-org/morpho-ts";
|
|
2
|
+
/**
|
|
3
|
+
* @internal The stored plan header: version, chain, account, expiry, and the calldata origin when
|
|
4
|
+
* the intent has one.
|
|
5
|
+
*/
|
|
6
|
+
export function planHeader({ chainId, account }, { expiresAt, calldataOrigin }) {
|
|
7
|
+
return {
|
|
8
|
+
version: 2,
|
|
9
|
+
chainId,
|
|
10
|
+
account,
|
|
11
|
+
expiresAt,
|
|
12
|
+
...(calldataOrigin && { calldataOrigin }),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @internal Deeply freezes a prepared plan. `detach` copies it first, so no object the caller
|
|
17
|
+
* passed in is frozen or shared with the plan.
|
|
18
|
+
*/
|
|
19
|
+
export function freezePlan(plan, { detach }) {
|
|
20
|
+
return deepFreeze(detach ? structuredClone(plan) : plan);
|
|
21
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MathLib, Time } from "@morpho-org/morpho-ts";
|
|
2
2
|
import { blueBorrow } from "../../actions/blue/borrow.js";
|
|
3
3
|
import { normalizeBundlesCommonParams } from "../../actions/bundles/common.js";
|
|
4
4
|
import { getBlueBundlesV1QuoteTimestamp } from "../../helpers/getBlueBundlesV1QuoteTimestamp.js";
|
|
5
5
|
import { DEFAULT_LLTV_BUFFER } from "../../helpers/index.js";
|
|
6
6
|
import { validatePositionHealth } from "../../helpers/validate.js";
|
|
7
|
+
import { freezePlan, planHeader } from "../assemble.js";
|
|
7
8
|
import { IncompleteTransactionPlanError, InvalidTransactionPlanError, } from "../error.js";
|
|
8
9
|
import { getPlanObject, validatePlanField, validatePlanFields, } from "../validation.js";
|
|
9
10
|
import { prepareBlue, } from "./prepare.js";
|
|
11
|
+
import { BUNDLES_COMMON_FIELDS, signatureRoles, validateStoredBlueMarket, validateStoredReallocations, } from "./stored.js";
|
|
10
12
|
/**
|
|
11
13
|
* Prepares a BlueBundlesV1 borrow against existing collateral. No token allowance is needed.
|
|
12
14
|
* Health uses the expiry, floored at max(now, lastUpdate), like the entity handle.
|
|
@@ -118,12 +120,8 @@ export async function prepareBlueBorrow(client, { chainId, account, marketId, ma
|
|
|
118
120
|
reason: "expected prepared borrow inputs",
|
|
119
121
|
});
|
|
120
122
|
}
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
account: inputs.account,
|
|
124
|
-
chainId: inputs.chainId,
|
|
125
|
-
expiresAt: intent.expiresAt,
|
|
126
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
123
|
+
return freezePlan({
|
|
124
|
+
...planHeader({ chainId: inputs.chainId, account: inputs.account }, intent),
|
|
127
125
|
steps: [
|
|
128
126
|
...steps,
|
|
129
127
|
{
|
|
@@ -135,14 +133,14 @@ export async function prepareBlueBorrow(client, { chainId, account, marketId, ma
|
|
|
135
133
|
...inputs,
|
|
136
134
|
authorizationNonce: signatureRequests.find((request) => request.id === morphoAuthorizationRequestId)?.args.nonce ?? 0n,
|
|
137
135
|
},
|
|
138
|
-
signatureRequestIds:
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
signatureRequestIds: signatureRoles({
|
|
137
|
+
morphoAuthorization: morphoAuthorizationRequestId,
|
|
138
|
+
}),
|
|
141
139
|
},
|
|
142
140
|
},
|
|
143
141
|
],
|
|
144
142
|
signatureRequests,
|
|
145
|
-
})
|
|
143
|
+
}, { detach: true });
|
|
146
144
|
}
|
|
147
145
|
/** @internal Encodes a prepared borrow without state reads or signing. */
|
|
148
146
|
export function buildBlueBorrow(action, requests) {
|
|
@@ -185,26 +183,6 @@ export function buildBlueBorrow(action, requests) {
|
|
|
185
183
|
},
|
|
186
184
|
});
|
|
187
185
|
}
|
|
188
|
-
function validateMarket(value, path) {
|
|
189
|
-
const market = getPlanObject(value, path);
|
|
190
|
-
validatePlanFields(market, {
|
|
191
|
-
path,
|
|
192
|
-
fields: {
|
|
193
|
-
id: "hex",
|
|
194
|
-
loanToken: "address",
|
|
195
|
-
collateralToken: "address",
|
|
196
|
-
oracle: "address",
|
|
197
|
-
irm: "address",
|
|
198
|
-
lltv: "uint256 bigint",
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
|
-
if (typeof market.id !== "string" || market.id.length !== 66) {
|
|
202
|
-
throw new InvalidTransactionPlanError({
|
|
203
|
-
path: `${path}.id`,
|
|
204
|
-
reason: "expected a 32-byte market ID",
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
186
|
/** @internal Validates the stored borrow recipe, including each allocator input. */
|
|
209
187
|
export function validateBorrowPlanAction(action, path) {
|
|
210
188
|
const inputs = getPlanObject(action.inputs, `${path}.inputs`);
|
|
@@ -215,47 +193,19 @@ export function validateBorrowPlanAction(action, path) {
|
|
|
215
193
|
borrowAssets: "uint256 bigint",
|
|
216
194
|
authorizationNonce: "uint256 bigint",
|
|
217
195
|
maxLtv: "uint256 bigint",
|
|
218
|
-
|
|
219
|
-
referralFeePct: "uint256 bigint",
|
|
220
|
-
referralFeeRecipient: "address",
|
|
196
|
+
...BUNDLES_COMMON_FIELDS,
|
|
221
197
|
reallocations: "array",
|
|
222
198
|
},
|
|
223
199
|
});
|
|
224
|
-
|
|
200
|
+
validateStoredBlueMarket(inputs.marketParams, `${path}.inputs.marketParams`);
|
|
225
201
|
if (inputs.maxPenalty !== undefined) {
|
|
226
202
|
validatePlanField(inputs.maxPenalty, {
|
|
227
203
|
path: `${path}.inputs.maxPenalty`,
|
|
228
204
|
type: "uint256 bigint",
|
|
229
205
|
});
|
|
230
206
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
path: entryPath,
|
|
236
|
-
fields: {
|
|
237
|
-
vault: "address",
|
|
238
|
-
assets: "uint256 bigint",
|
|
239
|
-
penalty: "uint256 bigint",
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
validatePlanFields(getPlanObject(entry.to, `${entryPath}.to`), {
|
|
243
|
-
path: `${entryPath}.to`,
|
|
244
|
-
fields: { adapter: "address" },
|
|
245
|
-
});
|
|
246
|
-
const from = getPlanObject(entry.from, `${entryPath}.from`);
|
|
247
|
-
if (from.type !== "market" && from.type !== "idle") {
|
|
248
|
-
throw new InvalidTransactionPlanError({
|
|
249
|
-
path: `${entryPath}.from.type`,
|
|
250
|
-
reason: "expected market or idle",
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
if (from.type === "market") {
|
|
254
|
-
validatePlanFields(from, {
|
|
255
|
-
path: `${entryPath}.from`,
|
|
256
|
-
fields: { adapter: "address" },
|
|
257
|
-
});
|
|
258
|
-
validateMarket(from.marketParams, `${entryPath}.from.marketParams`);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
207
|
+
validateStoredReallocations(inputs.reallocations, {
|
|
208
|
+
path: `${path}.inputs.reallocations`,
|
|
209
|
+
marketParams: validateStoredBlueMarket,
|
|
210
|
+
});
|
|
261
211
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { MathLib, } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
2
|
+
import { Time } from "@morpho-org/morpho-ts";
|
|
3
3
|
import { parseBlueAllocations, parseBlueBundlesV1Common, } from "../../actions/blue/common.js";
|
|
4
4
|
import { blueRefinance } from "../../actions/blue/refinance.js";
|
|
5
5
|
import { validateBlueRefinanceQuote, validateBlueRefinanceSource, } from "../../actions/blue/refinanceValidation.js";
|
|
6
6
|
import { DEFAULT_LLTV_BUFFER } from "../../helpers/index.js";
|
|
7
7
|
import { parseBlueMarket } from "../../helpers/parse.js";
|
|
8
|
+
import { freezePlan, planHeader } from "../assemble.js";
|
|
8
9
|
import { IncompleteTransactionPlanError, InvalidTransactionPlanError, } from "../error.js";
|
|
9
10
|
import { getPlanObject, validatePlanField, validatePlanFields, } from "../validation.js";
|
|
10
11
|
import { prepareBlue, } from "./prepare.js";
|
|
11
12
|
import { validateBlueRefinanceDestination } from "./refinanceValidation.js";
|
|
13
|
+
import { BUNDLES_COMMON_FIELDS, signatureRoles } from "./stored.js";
|
|
12
14
|
/**
|
|
13
15
|
* Prepares a full Blue borrow-position migration. Fetch both market and position snapshots at the
|
|
14
16
|
* same block and pass that block's timestamp as `now`. Penalties and fees increase destination debt;
|
|
@@ -152,20 +154,18 @@ export async function prepareBlueRefinance(client, params) {
|
|
|
152
154
|
...(maxPenalty !== undefined && { maxPenalty }),
|
|
153
155
|
...(request && { authorizationNonce: request.args.nonce }),
|
|
154
156
|
},
|
|
155
|
-
signatureRequestIds:
|
|
157
|
+
signatureRequestIds: signatureRoles({
|
|
158
|
+
morphoAuthorization: request?.id,
|
|
159
|
+
}),
|
|
156
160
|
};
|
|
157
|
-
return
|
|
158
|
-
|
|
159
|
-
account,
|
|
160
|
-
chainId,
|
|
161
|
-
expiresAt: intent.expiresAt,
|
|
162
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
161
|
+
return freezePlan({
|
|
162
|
+
...planHeader({ chainId, account }, intent),
|
|
163
163
|
steps: [
|
|
164
164
|
...steps,
|
|
165
165
|
{ id, label: "Refinance Blue borrow position", action },
|
|
166
166
|
],
|
|
167
167
|
signatureRequests,
|
|
168
|
-
})
|
|
168
|
+
}, { detach: true });
|
|
169
169
|
}
|
|
170
170
|
function validatePlanMarketParams(value, path) {
|
|
171
171
|
const params = getPlanObject(value, path);
|
|
@@ -241,9 +241,7 @@ export function validateRefinancePlanAction(action, path) {
|
|
|
241
241
|
path: `${path}.inputs`,
|
|
242
242
|
fields: {
|
|
243
243
|
maxLtv: "uint256 bigint",
|
|
244
|
-
|
|
245
|
-
referralFeePct: "uint256 bigint",
|
|
246
|
-
referralFeeRecipient: "address",
|
|
244
|
+
...BUNDLES_COMMON_FIELDS,
|
|
247
245
|
reallocations: "array",
|
|
248
246
|
},
|
|
249
247
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AccrualPosition, MarketParams, } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
2
|
+
import { Time } from "@morpho-org/morpho-ts";
|
|
3
3
|
import { maxUint256 } from "viem";
|
|
4
4
|
import { getBlueBundlesV1ReferralFeeAssets } from "../../actions/blue/common.js";
|
|
5
5
|
import { blueRepay } from "../../actions/blue/repay.js";
|
|
@@ -8,10 +8,12 @@ import { parseNativeFunding } from "../../helpers/parse.js";
|
|
|
8
8
|
import { quoteBlueRepayFunding } from "../../helpers/quoteBlueRepay.js";
|
|
9
9
|
import { validateReferralFee } from "../../helpers/validate.js";
|
|
10
10
|
import { NonPositiveInputError } from "../../types/index.js";
|
|
11
|
+
import { freezePlan, planHeader } from "../assemble.js";
|
|
11
12
|
import { InvalidTransactionPlanError, TransactionPlanSignatureMismatchError, } from "../error.js";
|
|
12
13
|
import { getVaultPermit, validateTokenPermitRequest } from "../permit.js";
|
|
13
14
|
import { getPlanObject, validatePlanFields } from "../validation.js";
|
|
14
15
|
import { prepareBlue, } from "./prepare.js";
|
|
16
|
+
import { BUNDLES_COMMON_FIELDS, signatureRoles, validateStoredBlueMarketParams, } from "./stored.js";
|
|
15
17
|
/**
|
|
16
18
|
* Prepares an asset, share, or full Blue repayment through BlueBundlesV1, never Permit2.
|
|
17
19
|
* Share quotes accrue the supplied position to expiry, at most two hours from the reference time.
|
|
@@ -133,12 +135,8 @@ export async function prepareBlueRepay(client, { chainId, account, marketId, mar
|
|
|
133
135
|
reason: "expected resolved repayment inputs",
|
|
134
136
|
});
|
|
135
137
|
}
|
|
136
|
-
return
|
|
137
|
-
|
|
138
|
-
chainId: params.chainId,
|
|
139
|
-
account: params.account,
|
|
140
|
-
expiresAt: resolvedIntent.expiresAt,
|
|
141
|
-
calldataOrigin: resolvedIntent.calldataOrigin,
|
|
138
|
+
return freezePlan({
|
|
139
|
+
...planHeader({ chainId: params.chainId, account: params.account }, resolvedIntent),
|
|
142
140
|
steps: [
|
|
143
141
|
...steps,
|
|
144
142
|
{
|
|
@@ -147,14 +145,14 @@ export async function prepareBlueRepay(client, { chainId, account, marketId, mar
|
|
|
147
145
|
action: {
|
|
148
146
|
type: "blueRepay",
|
|
149
147
|
inputs,
|
|
150
|
-
signatureRequestIds:
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
signatureRequestIds: signatureRoles({
|
|
149
|
+
tokenPermit: signatureRequests[0]?.id,
|
|
150
|
+
}),
|
|
153
151
|
},
|
|
154
152
|
},
|
|
155
153
|
],
|
|
156
154
|
signatureRequests,
|
|
157
|
-
})
|
|
155
|
+
}, { detach: true });
|
|
158
156
|
}
|
|
159
157
|
/** @internal Checks a repayment permit against the fixed token pull. */
|
|
160
158
|
export function validateBlueRepayPermit(request, action) {
|
|
@@ -197,9 +195,7 @@ export function validateBlueRepayPlanAction(action, path) {
|
|
|
197
195
|
repayAssets: "uint256 bigint",
|
|
198
196
|
repayShares: "uint256 bigint",
|
|
199
197
|
maxRepayAssets: "uint256 bigint",
|
|
200
|
-
|
|
201
|
-
referralFeePct: "uint256 bigint",
|
|
202
|
-
referralFeeRecipient: "address",
|
|
198
|
+
...BUNDLES_COMMON_FIELDS,
|
|
203
199
|
},
|
|
204
200
|
});
|
|
205
201
|
if (inputs.nativeAssets !== undefined) {
|
|
@@ -208,16 +204,6 @@ export function validateBlueRepayPlanAction(action, path) {
|
|
|
208
204
|
fields: { nativeAssets: "uint256 bigint" },
|
|
209
205
|
});
|
|
210
206
|
}
|
|
211
|
-
|
|
212
|
-
validatePlanFields(market, {
|
|
213
|
-
path: `${path}.inputs.marketParams`,
|
|
214
|
-
fields: {
|
|
215
|
-
loanToken: "address",
|
|
216
|
-
collateralToken: "address",
|
|
217
|
-
oracle: "address",
|
|
218
|
-
irm: "address",
|
|
219
|
-
lltv: "uint256 bigint",
|
|
220
|
-
},
|
|
221
|
-
});
|
|
207
|
+
validateStoredBlueMarketParams(inputs.marketParams, `${path}.inputs.marketParams`);
|
|
222
208
|
getPlanObject(action.signatureRequestIds, `${path}.signatureRequestIds`);
|
|
223
209
|
}
|