@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,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,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isVaultPermitAction = isVaultPermitAction;
|
|
4
|
+
exports.getVaultPermitBinding = getVaultPermitBinding;
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const VAULT_PERMIT_ACTION_TYPES = [
|
|
7
|
+
"vaultV2Deposit",
|
|
8
|
+
"vaultV1Deposit",
|
|
9
|
+
"vaultV1Withdraw",
|
|
10
|
+
"vaultV2Withdraw",
|
|
11
|
+
"vaultV2Redeem",
|
|
12
|
+
"vaultV1Redeem",
|
|
13
|
+
"vaultV2ForceWithdraw",
|
|
14
|
+
"vaultV1MigrateToV2",
|
|
15
|
+
"vaultV2InKindRedeem",
|
|
16
|
+
"vaultV1InKindRedeem",
|
|
17
|
+
];
|
|
18
|
+
/** @internal Whether the action is one of the vault actions a token permit can fund. */
|
|
19
|
+
function isVaultPermitAction(action) {
|
|
20
|
+
return VAULT_PERMIT_ACTION_TYPES.includes(action.type);
|
|
21
|
+
}
|
|
22
|
+
/** @internal Reads the permit binding from the vault action's stored inputs. */
|
|
23
|
+
function getVaultPermitBinding(action) {
|
|
24
|
+
switch (action.type) {
|
|
25
|
+
case "vaultV2Deposit":
|
|
26
|
+
case "vaultV1Deposit":
|
|
27
|
+
return {
|
|
28
|
+
bundler: "bundles.vaultBundlesV1",
|
|
29
|
+
asset: action.inputs.asset,
|
|
30
|
+
restore: { amount: action.inputs.assets, exact: true },
|
|
31
|
+
build: {
|
|
32
|
+
amount: action.inputs.assets ?? action.inputs.nativeAssets,
|
|
33
|
+
pull: "token",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
case "vaultV1Withdraw":
|
|
37
|
+
case "vaultV2Withdraw":
|
|
38
|
+
return {
|
|
39
|
+
bundler: "bundles.vaultBundlesV1",
|
|
40
|
+
asset: action.inputs.vault,
|
|
41
|
+
restore: { amount: action.inputs.requiredShareAllowance, exact: false },
|
|
42
|
+
build: { amount: action.inputs.requiredShareAllowance, pull: "shares" },
|
|
43
|
+
};
|
|
44
|
+
case "vaultV2Redeem":
|
|
45
|
+
case "vaultV1Redeem":
|
|
46
|
+
return {
|
|
47
|
+
bundler: "bundles.vaultBundlesV1",
|
|
48
|
+
asset: action.inputs.vault,
|
|
49
|
+
restore: { amount: action.inputs.shares, exact: false },
|
|
50
|
+
build: { amount: action.inputs.shares, pull: "shares" },
|
|
51
|
+
};
|
|
52
|
+
case "vaultV1MigrateToV2":
|
|
53
|
+
return {
|
|
54
|
+
bundler: "bundles.vaultBundlesV1",
|
|
55
|
+
asset: action.inputs.sourceVault,
|
|
56
|
+
restore: { amount: action.inputs.requiredShareAllowance, exact: false },
|
|
57
|
+
build: { amount: action.inputs.requiredShareAllowance, pull: "shares" },
|
|
58
|
+
};
|
|
59
|
+
case "vaultV2ForceWithdraw":
|
|
60
|
+
case "vaultV2InKindRedeem":
|
|
61
|
+
case "vaultV1InKindRedeem":
|
|
62
|
+
return {
|
|
63
|
+
bundler: "bundles.vaultExitBundlesV1",
|
|
64
|
+
asset: action.inputs.vault,
|
|
65
|
+
restore: { amount: viem_1.maxUint256, exact: true },
|
|
66
|
+
build: { amount: viem_1.maxUint256, pull: "shares" },
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.vaultRequirementSteps = vaultRequirementSteps;
|
|
4
|
+
const index_js_1 = require("../types/index.js");
|
|
5
|
+
const requirements_js_1 = require("./requirements.js");
|
|
6
|
+
/**
|
|
7
|
+
* @internal Turns a vault exit's share requirements into approval steps and permit requests.
|
|
8
|
+
* Steps take the ID `${id}:approval` and requests `${id}:tokenPermit`; `signatureRequestIds`
|
|
9
|
+
* names the permit only when one is requested.
|
|
10
|
+
* @throws {UnsupportedRequirementSignatureError} If a requirement is a signature other than a permit.
|
|
11
|
+
*/
|
|
12
|
+
function vaultRequirementSteps(requirements, { id, chainId, account, }) {
|
|
13
|
+
const approvals = [];
|
|
14
|
+
const signatureRequests = [];
|
|
15
|
+
const tokenPermit = `${id}:tokenPermit`;
|
|
16
|
+
for (const requirement of requirements) {
|
|
17
|
+
if ((0, index_js_1.isRequirementApproval)(requirement)) {
|
|
18
|
+
approvals.push((0, requirements_js_1.buildApprovalStep)(requirement, {
|
|
19
|
+
id: `${id}:approval`,
|
|
20
|
+
chainId,
|
|
21
|
+
account,
|
|
22
|
+
denomination: "shares",
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
else if (requirement.action.type === "permit") {
|
|
26
|
+
signatureRequests.push((0, requirements_js_1.buildPermitSignatureRequest)({ action: requirement.action }, tokenPermit));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new index_js_1.UnsupportedRequirementSignatureError(requirement.action.type);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
approvals,
|
|
34
|
+
signatureRequests,
|
|
35
|
+
signatureRequestIds: signatureRequests.length > 0 ? { tokenPermit } : {},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -47,7 +47,7 @@ export interface VaultV1DepositPlanParams extends DepositPlanParams<AccrualVault
|
|
|
47
47
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
48
48
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
49
49
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
50
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
50
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
51
51
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
52
52
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
53
53
|
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareVaultV1Deposit = prepareVaultV1Deposit;
|
|
4
4
|
exports.buildVaultV1Deposit = buildVaultV1Deposit;
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
7
5
|
const deposit_js_1 = require("../../actions/vaultV1/deposit.js");
|
|
8
6
|
const deposit_js_2 = require("../deposit.js");
|
|
9
7
|
const permit_js_1 = require("../permit.js");
|
|
@@ -25,7 +23,7 @@ const permit_js_1 = require("../permit.js");
|
|
|
25
23
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
26
24
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
27
25
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
28
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
26
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
29
27
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
30
28
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
31
29
|
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
@@ -71,16 +69,7 @@ async function prepareVaultV1Deposit(client, params) {
|
|
|
71
69
|
/** @internal Encodes the deposit from its self-contained inputs and resolved signature requests. */
|
|
72
70
|
function buildVaultV1Deposit(action, requests) {
|
|
73
71
|
const { asset, chainId, account, assets, nativeAssets, ...args } = action.inputs;
|
|
74
|
-
const
|
|
75
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
76
|
-
asset,
|
|
77
|
-
owner: account,
|
|
78
|
-
});
|
|
79
|
-
const requirementSignature = (0, common_js_1.selectBundlesTokenRequirementSignature)(signature ? [signature] : [], {
|
|
80
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1"),
|
|
81
|
-
amount: assets ?? nativeAssets,
|
|
82
|
-
deadline: action.inputs.deadline,
|
|
83
|
-
});
|
|
72
|
+
const requirementSignature = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
84
73
|
return (0, deposit_js_1.vaultV1Deposit)({
|
|
85
74
|
vault: { chainId, address: action.inputs.vault, asset },
|
|
86
75
|
args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AccrualVault, MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { Client } from "viem";
|
|
3
|
+
import type { ReferenceTimestampParams, Transaction, VaultV1InKindRedeemAction } from "../../types/index.js";
|
|
4
4
|
import { type IntentParams } from "../intent.js";
|
|
5
5
|
import type { Action, SignatureRequest, TransactionPlan } from "../types.js";
|
|
6
6
|
/**
|
|
@@ -4,17 +4,15 @@ exports.prepareVaultV1InKindRedeem = prepareVaultV1InKindRedeem;
|
|
|
4
4
|
exports.buildVaultV1InKindRedeem = buildVaultV1InKindRedeem;
|
|
5
5
|
exports.validateInKindRedeemPlanAction = validateInKindRedeemPlanAction;
|
|
6
6
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
7
|
-
const viem_1 = require("viem");
|
|
8
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
9
7
|
const inKindRedeem_js_1 = require("../../actions/vaultV1/inKindRedeem.js");
|
|
10
8
|
const getVaultV1InKindRedeemRequirements_js_1 = require("../../entities/requirements/getVaultV1InKindRedeemRequirements.js");
|
|
11
9
|
const inKindRedeemQuote_js_1 = require("../../entities/vaultV1/inKindRedeemQuote.js");
|
|
12
10
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
13
|
-
const
|
|
11
|
+
const assemble_js_1 = require("../assemble.js");
|
|
14
12
|
const intent_js_1 = require("../intent.js");
|
|
15
13
|
const permit_js_1 = require("../permit.js");
|
|
16
|
-
const requirements_js_1 = require("../requirements.js");
|
|
17
14
|
const validation_js_1 = require("../validation.js");
|
|
15
|
+
const vaultRequirements_js_1 = require("../vaultRequirements.js");
|
|
18
16
|
/**
|
|
19
17
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
20
18
|
* Prepares the stable Vault V1 in-kind exit through VaultExitBundlesV1.
|
|
@@ -103,31 +101,13 @@ async function prepareVaultV1InKindRedeem(client, params) {
|
|
|
103
101
|
now,
|
|
104
102
|
amount: params.assets,
|
|
105
103
|
});
|
|
106
|
-
const approvals =
|
|
107
|
-
|
|
108
|
-
const id = "vaultV1InKindRedeem:tokenPermit";
|
|
109
|
-
for (const requirement of requirements) {
|
|
110
|
-
if ((0, index_js_1.isRequirementApproval)(requirement)) {
|
|
111
|
-
approvals.push((0, requirements_js_1.buildApprovalStep)(requirement, {
|
|
112
|
-
id: "vaultV1InKindRedeem:approval",
|
|
113
|
-
chainId,
|
|
114
|
-
account,
|
|
115
|
-
denomination: "shares",
|
|
116
|
-
}));
|
|
117
|
-
}
|
|
118
|
-
else if (requirement.action.type === "permit") {
|
|
119
|
-
signatureRequests.push((0, requirements_js_1.buildPermitSignatureRequest)({ action: requirement.action }, id));
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
throw new index_js_1.UnsupportedRequirementSignatureError(requirement.action.type);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return (0, morpho_ts_1.deepFreeze)(structuredClone({
|
|
126
|
-
version: 2,
|
|
104
|
+
const { approvals, signatureRequests, signatureRequestIds } = (0, vaultRequirements_js_1.vaultRequirementSteps)(requirements, {
|
|
105
|
+
id: "vaultV1InKindRedeem",
|
|
127
106
|
chainId,
|
|
128
107
|
account,
|
|
129
|
-
|
|
130
|
-
|
|
108
|
+
});
|
|
109
|
+
return (0, assemble_js_1.freezePlan)({
|
|
110
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
131
111
|
steps: [
|
|
132
112
|
...approvals,
|
|
133
113
|
{
|
|
@@ -143,28 +123,17 @@ async function prepareVaultV1InKindRedeem(client, params) {
|
|
|
143
123
|
deadline: inputs.deadline,
|
|
144
124
|
marketParamsList: inputs.marketParamsList,
|
|
145
125
|
},
|
|
146
|
-
signatureRequestIds
|
|
147
|
-
? { tokenPermit: id }
|
|
148
|
-
: {},
|
|
126
|
+
signatureRequestIds,
|
|
149
127
|
},
|
|
150
128
|
},
|
|
151
129
|
],
|
|
152
130
|
signatureRequests,
|
|
153
|
-
})
|
|
131
|
+
}, { detach: true });
|
|
154
132
|
}
|
|
155
133
|
/** @internal Encodes the fixed in-kind exit with its referenced permit. */
|
|
156
134
|
function buildVaultV1InKindRedeem(action, requests) {
|
|
157
135
|
const { chainId, account, vault, assets, ...args } = action.inputs;
|
|
158
|
-
const
|
|
159
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
160
|
-
asset: vault,
|
|
161
|
-
owner: account,
|
|
162
|
-
});
|
|
163
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
164
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultExitBundlesV1"),
|
|
165
|
-
amount: viem_1.maxUint256,
|
|
166
|
-
deadline: action.inputs.deadline,
|
|
167
|
-
});
|
|
136
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
168
137
|
return (0, inKindRedeem_js_1.vaultV1InKindRedeem)({
|
|
169
138
|
vault: { chainId, address: vault },
|
|
170
139
|
args: {
|
|
@@ -47,7 +47,7 @@ export type VaultV1MigrateToV2PlanParams = Omit<IntentParams, "deployless"> & Re
|
|
|
47
47
|
* @param params.supportSignature - Optional unlimited ERC-2612 share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient. Vault V1 shares support ERC-2612; no Permit2 is used.
|
|
48
48
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
49
49
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
50
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
50
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
51
51
|
* @returns A static migration plan with any required source share approval or permit.
|
|
52
52
|
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
53
53
|
* @throws {VaultAssetMismatchError} If the vault assets differ.
|
|
@@ -11,6 +11,7 @@ const migrateToV2_js_1 = require("../../actions/vaultV1/migrateToV2.js");
|
|
|
11
11
|
const migrateToV2Quote_js_1 = require("../../entities/vaultV1/migrateToV2Quote.js");
|
|
12
12
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
13
13
|
const index_js_1 = require("../../types/index.js");
|
|
14
|
+
const assemble_js_1 = require("../assemble.js");
|
|
14
15
|
const error_js_1 = require("../error.js");
|
|
15
16
|
const intent_js_1 = require("../intent.js");
|
|
16
17
|
const permit_js_1 = require("../permit.js");
|
|
@@ -65,7 +66,7 @@ function validateMigrateToV2PlanAction(action, path) {
|
|
|
65
66
|
* @param params.supportSignature - Optional unlimited ERC-2612 share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient. Vault V1 shares support ERC-2612; no Permit2 is used.
|
|
66
67
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
67
68
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
68
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
69
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
69
70
|
* @returns A static migration plan with any required source share approval or permit.
|
|
70
71
|
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
71
72
|
* @throws {VaultAssetMismatchError} If the vault assets differ.
|
|
@@ -162,12 +163,8 @@ async function prepareVaultV1MigrateToV2(client, params) {
|
|
|
162
163
|
supportSignature: intent.supportSignature,
|
|
163
164
|
now,
|
|
164
165
|
});
|
|
165
|
-
return (0,
|
|
166
|
-
|
|
167
|
-
account,
|
|
168
|
-
chainId,
|
|
169
|
-
expiresAt: intent.expiresAt,
|
|
170
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
166
|
+
return (0, assemble_js_1.freezePlan)({
|
|
167
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
171
168
|
steps: [
|
|
172
169
|
...approvals,
|
|
173
170
|
{
|
|
@@ -194,21 +191,12 @@ async function prepareVaultV1MigrateToV2(client, params) {
|
|
|
194
191
|
},
|
|
195
192
|
],
|
|
196
193
|
signatureRequests,
|
|
197
|
-
})
|
|
194
|
+
}, { detach: true });
|
|
198
195
|
}
|
|
199
196
|
/** @internal Maps stored maxSharePrice to the ABI maxSharePriceVaultV2 and encodes the source permit. */
|
|
200
197
|
function buildVaultV1MigrateToV2(action, requests) {
|
|
201
198
|
const { vault: _vault, sourceVault, maxSharePrice, asset, requiredShareAllowance, chainId, account, ...args } = action.inputs;
|
|
202
|
-
const
|
|
203
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
204
|
-
asset: sourceVault,
|
|
205
|
-
owner: account,
|
|
206
|
-
});
|
|
207
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
208
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1"),
|
|
209
|
-
amount: requiredShareAllowance,
|
|
210
|
-
deadline: args.deadline,
|
|
211
|
-
});
|
|
199
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
212
200
|
return (0, migrateToV2_js_1.vaultV1MigrateToV2)({
|
|
213
201
|
vault: { chainId, address: sourceVault, asset },
|
|
214
202
|
args: {
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareVaultV1Redeem = prepareVaultV1Redeem;
|
|
4
4
|
exports.buildVaultV1Redeem = buildVaultV1Redeem;
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
7
5
|
const redeem_js_1 = require("../../actions/vaultV1/redeem.js");
|
|
8
6
|
const permit_js_1 = require("../permit.js");
|
|
9
7
|
const redeem_js_2 = require("../redeem.js");
|
|
@@ -57,16 +55,7 @@ async function prepareVaultV1Redeem(client, params) {
|
|
|
57
55
|
/** @internal Encodes a redemption from fixed inputs and the referenced share permit. */
|
|
58
56
|
function buildVaultV1Redeem(action, requests) {
|
|
59
57
|
const { chainId, account, ...args } = action.inputs;
|
|
60
|
-
const
|
|
61
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
62
|
-
asset: action.inputs.vault,
|
|
63
|
-
owner: account,
|
|
64
|
-
});
|
|
65
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
66
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1"),
|
|
67
|
-
amount: action.inputs.shares,
|
|
68
|
-
deadline: action.inputs.deadline,
|
|
69
|
-
});
|
|
58
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
70
59
|
return (0, redeem_js_1.vaultV1Redeem)({
|
|
71
60
|
vault: { chainId, address: action.inputs.vault },
|
|
72
61
|
args: {
|
|
@@ -36,7 +36,7 @@ export interface VaultV1WithdrawPlanParams extends WithdrawPlanParams<AccrualVau
|
|
|
36
36
|
* @param params.supportSignature - Optional unlimited share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient.
|
|
37
37
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
38
38
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
39
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
39
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
40
40
|
* @returns A plan with the withdrawal step and any required share approval or signature request.
|
|
41
41
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
42
42
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareVaultV1Withdraw = prepareVaultV1Withdraw;
|
|
4
4
|
exports.buildVaultV1Withdraw = buildVaultV1Withdraw;
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
7
5
|
const withdraw_js_1 = require("../../actions/vaultV1/withdraw.js");
|
|
8
6
|
const permit_js_1 = require("../permit.js");
|
|
9
7
|
const withdraw_js_2 = require("../withdraw.js");
|
|
@@ -26,7 +24,7 @@ const withdraw_js_2 = require("../withdraw.js");
|
|
|
26
24
|
* @param params.supportSignature - Optional unlimited share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient.
|
|
27
25
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
28
26
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
29
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
27
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
30
28
|
* @returns A plan with the withdrawal step and any required share approval or signature request.
|
|
31
29
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
32
30
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
@@ -66,16 +64,7 @@ async function prepareVaultV1Withdraw(client, params) {
|
|
|
66
64
|
/** @internal Encodes the withdrawal from its self-contained inputs and resolved signature requests. */
|
|
67
65
|
function buildVaultV1Withdraw(action, requests) {
|
|
68
66
|
const { requiredShareAllowance, chainId, account, assets, ...args } = action.inputs;
|
|
69
|
-
const
|
|
70
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
71
|
-
asset: action.inputs.vault,
|
|
72
|
-
owner: account,
|
|
73
|
-
});
|
|
74
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
75
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1"),
|
|
76
|
-
amount: requiredShareAllowance,
|
|
77
|
-
deadline: action.inputs.deadline,
|
|
78
|
-
});
|
|
67
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
79
68
|
return (0, withdraw_js_1.vaultV1Withdraw)({
|
|
80
69
|
vault: { chainId, address: action.inputs.vault },
|
|
81
70
|
args: {
|
|
@@ -26,7 +26,7 @@ export interface VaultV2DepositPlanParams extends DepositPlanParams<AccrualVault
|
|
|
26
26
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
27
27
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
28
28
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` (device clock when `now` is omitted).
|
|
29
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
29
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
30
30
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
31
31
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
32
32
|
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareVaultV2Deposit = prepareVaultV2Deposit;
|
|
4
4
|
exports.buildVaultV2Deposit = buildVaultV2Deposit;
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
7
5
|
const deposit_js_1 = require("../../actions/vaultV2/deposit.js");
|
|
8
6
|
const deposit_js_2 = require("../deposit.js");
|
|
9
7
|
const permit_js_1 = require("../permit.js");
|
|
@@ -24,7 +22,7 @@ const permit_js_1 = require("../permit.js");
|
|
|
24
22
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
25
23
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
26
24
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` (device clock when `now` is omitted).
|
|
27
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
25
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
28
26
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
29
27
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
30
28
|
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
@@ -64,16 +62,7 @@ async function prepareVaultV2Deposit(client, params) {
|
|
|
64
62
|
/** @internal Encodes the deposit from its self-contained inputs and resolved signature requests. */
|
|
65
63
|
function buildVaultV2Deposit(action, requests) {
|
|
66
64
|
const { asset, chainId, account, assets, nativeAssets, ...args } = action.inputs;
|
|
67
|
-
const
|
|
68
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
69
|
-
asset,
|
|
70
|
-
owner: account,
|
|
71
|
-
});
|
|
72
|
-
const requirementSignature = (0, common_js_1.selectBundlesTokenRequirementSignature)(signature ? [signature] : [], {
|
|
73
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1"),
|
|
74
|
-
amount: assets ?? nativeAssets,
|
|
75
|
-
deadline: action.inputs.deadline,
|
|
76
|
-
});
|
|
65
|
+
const requirementSignature = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
77
66
|
return (0, deposit_js_1.vaultV2Deposit)({
|
|
78
67
|
vault: { chainId, address: action.inputs.vault, asset },
|
|
79
68
|
args: {
|
|
@@ -37,7 +37,7 @@ export interface VaultV2ForceRedeemPlanParams extends Pick<IntentParams, "chainI
|
|
|
37
37
|
* @param params.deallocations - Non-empty, ordered deallocations with positive `assets` in asset base units, including any penalty buffer.
|
|
38
38
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
39
39
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` and is plan metadata only.
|
|
40
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
40
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
41
41
|
* @returns A deep-frozen `TransactionPlan` containing one `vaultV2ForceRedeem` step and no signature requests.
|
|
42
42
|
* @throws {ChainIdMismatchError} If the client targets another chain.
|
|
43
43
|
* @throws {EmptyDeallocationsError} If `deallocations` is empty.
|
|
@@ -7,6 +7,7 @@ const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
|
7
7
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
8
8
|
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
9
9
|
const forceRedeem_js_1 = require("../../actions/vaultV2/forceRedeem.js");
|
|
10
|
+
const assemble_js_1 = require("../assemble.js");
|
|
10
11
|
const intent_js_1 = require("../intent.js");
|
|
11
12
|
const validation_js_1 = require("../validation.js");
|
|
12
13
|
/** @internal Validates the stored force-redeem action's plain input shape. */
|
|
@@ -55,7 +56,7 @@ function validateForceRedeemPlanAction(action, path) {
|
|
|
55
56
|
* @param params.deallocations - Non-empty, ordered deallocations with positive `assets` in asset base units, including any penalty buffer.
|
|
56
57
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
57
58
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` and is plan metadata only.
|
|
58
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
59
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
59
60
|
* @returns A deep-frozen `TransactionPlan` containing one `vaultV2ForceRedeem` step and no signature requests.
|
|
60
61
|
* @throws {ChainIdMismatchError} If the client targets another chain.
|
|
61
62
|
* @throws {EmptyDeallocationsError} If `deallocations` is empty.
|
|
@@ -90,11 +91,7 @@ async function prepareVaultV2ForceRedeem(client, params) {
|
|
|
90
91
|
const now = params.now ?? morpho_ts_1.Time.timestamp();
|
|
91
92
|
const intent = (0, intent_js_1.resolveIntent)(params, now);
|
|
92
93
|
const plan = structuredClone({
|
|
93
|
-
|
|
94
|
-
account: params.account,
|
|
95
|
-
chainId: params.chainId,
|
|
96
|
-
expiresAt: intent.expiresAt,
|
|
97
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
94
|
+
...(0, assemble_js_1.planHeader)({ chainId: params.chainId, account: params.account }, intent),
|
|
98
95
|
steps: [
|
|
99
96
|
{
|
|
100
97
|
id: "vaultV2ForceRedeem",
|
|
@@ -128,7 +125,7 @@ async function prepareVaultV2ForceRedeem(client, params) {
|
|
|
128
125
|
// Validate the cloned inputs with the action encoder before returning a plan.
|
|
129
126
|
buildVaultV2ForceRedeem(plan.steps[0].action);
|
|
130
127
|
await (0, validateClientChainId_js_1.validateClientChainId)(client, params.chainId);
|
|
131
|
-
return (0,
|
|
128
|
+
return (0, assemble_js_1.freezePlan)(plan, { detach: false });
|
|
132
129
|
}
|
|
133
130
|
/** @internal Encodes the fixed multicall through the same action as the forceRedeem handle. */
|
|
134
131
|
function buildVaultV2ForceRedeem(action) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AccrualVaultV2 } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
2
|
+
import type { Address, Client } from "viem";
|
|
3
3
|
import { type ReferenceTimestampParams, type Transaction, type VaultV2ForceWithdrawAction } from "../../types/index.js";
|
|
4
4
|
import { type IntentParams } from "../intent.js";
|
|
5
5
|
import type { Action, SignatureRequest, TransactionPlan } from "../types.js";
|
|
@@ -44,7 +44,7 @@ export interface VaultV2ForceWithdrawPlanParams extends Omit<IntentParams, "depl
|
|
|
44
44
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; insufficient allowance produces an unlimited direct share approval, or an unlimited share permit when `true`.
|
|
45
45
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
46
46
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now` and within the fee-projection horizon; defaults to `now + 2h`.
|
|
47
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
47
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
48
48
|
* @returns A deep-frozen plan containing ordered share approvals, if needed, followed by the forced exit and its concrete permit request, if needed.
|
|
49
49
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
50
50
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|