@morpho-org/morpho-sdk 10.1.0-next.0 → 10.1.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 +6 -2
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +1 -5
- package/lib/cjs/actions/blue/borrow.d.ts +2 -1
- package/lib/cjs/actions/blue/borrow.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/borrow.internal.js +35 -0
- package/lib/cjs/actions/blue/borrow.js +4 -16
- package/lib/cjs/actions/blue/common.d.ts +50 -28
- package/lib/cjs/actions/blue/common.js +21 -34
- package/lib/cjs/actions/blue/encode.d.ts +23 -0
- package/lib/cjs/actions/blue/encode.js +171 -0
- package/lib/cjs/actions/blue/refinance.d.ts +3 -2
- package/lib/cjs/actions/blue/refinance.internal.d.ts +42 -0
- package/lib/cjs/actions/blue/refinance.internal.js +62 -0
- package/lib/cjs/actions/blue/refinance.js +5 -63
- package/lib/cjs/actions/blue/refinanceValidation.d.ts +4 -5
- package/lib/cjs/actions/blue/refinanceValidation.js +1 -3
- package/lib/cjs/actions/blue/repay.d.ts +1 -1
- package/lib/cjs/actions/blue/repay.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/repay.internal.js +38 -0
- package/lib/cjs/actions/blue/repay.js +2 -17
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +2 -2
- package/lib/cjs/actions/blue/repayWithdrawCollateral.internal.d.ts +61 -0
- package/lib/cjs/actions/blue/repayWithdrawCollateral.internal.js +112 -0
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +3 -116
- package/lib/cjs/actions/blue/signatures.d.ts +30 -0
- package/lib/cjs/actions/blue/signatures.js +90 -0
- package/lib/cjs/actions/blue/supply.d.ts +1 -1
- package/lib/cjs/actions/blue/supply.internal.d.ts +32 -0
- package/lib/cjs/actions/blue/supply.internal.js +101 -0
- package/lib/cjs/actions/blue/supply.js +2 -67
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +1 -1
- package/lib/cjs/actions/blue/supplyCollateral.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/supplyCollateral.internal.js +37 -0
- package/lib/cjs/actions/blue/supplyCollateral.js +2 -17
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +4 -3
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.d.ts +63 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.js +94 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +5 -106
- package/lib/cjs/actions/blue/withdraw.d.ts +4 -3
- package/lib/cjs/actions/blue/withdraw.internal.d.ts +56 -0
- package/lib/cjs/actions/blue/withdraw.internal.js +84 -0
- package/lib/cjs/actions/blue/withdraw.js +5 -78
- package/lib/cjs/actions/blue/withdrawBuyCallback.d.ts +2 -2
- package/lib/cjs/actions/blue/withdrawBuyCallback.internal.d.ts +20 -0
- package/lib/cjs/actions/blue/withdrawBuyCallback.internal.js +58 -0
- package/lib/cjs/actions/blue/withdrawBuyCallback.js +2 -39
- package/lib/cjs/actions/blue/withdrawCollateral.internal.d.ts +16 -0
- package/lib/cjs/actions/blue/withdrawCollateral.internal.js +39 -0
- package/lib/cjs/actions/blue/withdrawCollateral.js +2 -17
- package/lib/cjs/actions/bundles/common.d.ts +9 -0
- package/lib/cjs/actions/bundles/common.js +18 -6
- package/lib/cjs/actions/bundles/index.d.ts +1 -1
- package/lib/cjs/actions/bundles/index.js +3 -16
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +14 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +59 -60
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +22 -1
- package/lib/cjs/actions/midnight/cancelAndMake.js +46 -87
- package/lib/cjs/actions/midnight/cancelOffers.d.ts +11 -0
- package/lib/cjs/actions/midnight/cancelOffers.js +22 -4
- package/lib/cjs/actions/midnight/encode.d.ts +36 -0
- package/lib/cjs/actions/midnight/encode.js +554 -0
- package/lib/cjs/actions/midnight/index.d.ts +14 -13
- package/lib/cjs/actions/midnight/index.js +29 -13
- package/lib/cjs/actions/midnight/parse.d.ts +35 -0
- package/lib/cjs/actions/midnight/parse.js +73 -0
- package/lib/cjs/actions/midnight/parseCollateralBatch.d.ts +58 -0
- package/lib/cjs/actions/midnight/parseCollateralBatch.js +216 -0
- package/lib/cjs/actions/midnight/redeem.d.ts +16 -3
- package/lib/cjs/actions/midnight/redeem.js +22 -51
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +13 -0
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +42 -67
- package/lib/cjs/actions/midnight/supplyCollateral.d.ts +40 -5
- package/lib/cjs/actions/midnight/supplyCollateral.js +60 -54
- package/lib/cjs/actions/midnight/supplyCollateralBatch.d.ts +3 -3
- package/lib/cjs/actions/midnight/supplyCollateralBatch.js +3 -62
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +24 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +39 -66
- package/lib/cjs/actions/midnight/supplyCollateralWithNative.d.ts +77 -0
- package/lib/cjs/actions/midnight/supplyCollateralWithNative.js +142 -0
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +17 -2
- package/lib/cjs/actions/midnight/takeBorrow.js +25 -55
- package/lib/cjs/actions/midnight/takeLend.d.ts +21 -1
- package/lib/cjs/actions/midnight/takeLend.js +30 -57
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +34 -61
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +17 -2
- package/lib/cjs/actions/midnight/takeWithdraw.js +78 -115
- package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +16 -3
- package/lib/cjs/actions/midnight/withdrawCollateral.js +25 -56
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.d.ts +3 -3
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +3 -71
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +13 -0
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +39 -19
- package/lib/cjs/actions/requirements/blue/index.d.ts +1 -1
- package/lib/cjs/actions/requirements/blue/index.js +3 -15
- package/lib/cjs/actions/requirements/chainCheck.d.ts +5 -0
- package/lib/cjs/actions/requirements/chainCheck.js +10 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +40 -27
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +11 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +36 -17
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +14 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +44 -9
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +10 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +61 -24
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +10 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +25 -4
- package/lib/cjs/actions/requirements/encode/index.d.ts +5 -5
- package/lib/cjs/actions/requirements/encode/index.js +11 -19
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +26 -11
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +40 -12
- package/lib/cjs/actions/requirements/index.d.ts +1 -1
- package/lib/cjs/actions/requirements/index.js +3 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +11 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +34 -19
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +26 -12
- package/lib/cjs/actions/requirements/midnight/index.d.ts +2 -2
- package/lib/cjs/actions/requirements/midnight/index.js +5 -16
- package/lib/cjs/actions/vaultV1/deposit.d.ts +21 -0
- package/lib/cjs/actions/vaultV1/deposit.js +46 -10
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +18 -1
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +36 -16
- package/lib/cjs/actions/vaultV1/index.d.ts +5 -5
- package/lib/cjs/actions/vaultV1/index.js +11 -19
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +21 -0
- package/lib/cjs/actions/vaultV1/migrateToV2.js +49 -11
- package/lib/cjs/actions/vaultV1/redeem.d.ts +19 -0
- package/lib/cjs/actions/vaultV1/redeem.js +28 -7
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +19 -0
- package/lib/cjs/actions/vaultV1/withdraw.js +28 -7
- package/lib/cjs/actions/vaultV2/deposit.d.ts +21 -0
- package/lib/cjs/actions/vaultV2/deposit.js +46 -10
- package/lib/cjs/actions/vaultV2/forceRedeem.d.ts +20 -2
- package/lib/cjs/actions/vaultV2/forceRedeem.js +39 -8
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +23 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +36 -14
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +18 -1
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +35 -15
- package/lib/cjs/actions/vaultV2/index.d.ts +6 -6
- package/lib/cjs/actions/vaultV2/index.js +13 -20
- package/lib/cjs/actions/vaultV2/redeem.d.ts +19 -0
- package/lib/cjs/actions/vaultV2/redeem.js +28 -7
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +19 -0
- package/lib/cjs/actions/vaultV2/withdraw.js +28 -7
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +1 -5
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +1 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +1 -2
- package/lib/cjs/entities/blue/blue.d.ts +35 -8
- package/lib/cjs/entities/blue/blue.js +467 -406
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/midnight.d.ts +117 -41
- package/lib/cjs/entities/midnight/midnight.js +472 -843
- package/lib/cjs/entities/midnight/parse.d.ts +74 -0
- package/lib/cjs/entities/midnight/parse.js +336 -0
- package/lib/cjs/entities/midnight/prepare.d.ts +47 -0
- package/lib/cjs/entities/midnight/prepare.js +293 -0
- package/lib/cjs/entities/midnight/publication.d.ts +7 -3
- package/lib/cjs/entities/midnight/publication.js +10 -7
- package/lib/cjs/entities/midnight/types.d.ts +7 -0
- package/lib/cjs/entities/requirements/assertContractCode.d.ts +10 -5
- package/lib/cjs/entities/requirements/assertContractCode.js +24 -15
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +15 -0
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +59 -51
- package/lib/cjs/entities/requirements/getErc2612Permit.d.ts +7 -3
- package/lib/cjs/entities/requirements/getErc2612Permit.js +20 -4
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +15 -0
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +24 -7
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +14 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +27 -7
- package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.js +4 -3
- package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.js +4 -3
- package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.js +4 -3
- package/lib/cjs/entities/requirements/index.d.ts +2 -2
- package/lib/cjs/entities/requirements/index.js +5 -16
- package/lib/cjs/entities/requirements/validateNativeRequirements.d.ts +21 -0
- package/lib/cjs/entities/requirements/validateNativeRequirements.js +37 -0
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.d.ts +2 -2
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.js +1 -7
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +17 -40
- package/lib/cjs/entities/vaultV1/vaultV1.js +228 -159
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.d.ts +4 -0
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.js +9 -4
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.d.ts +2 -2
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.js +1 -7
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +29 -86
- package/lib/cjs/entities/vaultV2/vaultV2.js +226 -188
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +2 -3
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +2 -6
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +5 -7
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- package/lib/cjs/helpers/deadShares.js +0 -3
- package/lib/cjs/helpers/parse.d.ts +33 -0
- package/lib/cjs/helpers/parse.js +71 -0
- package/lib/cjs/helpers/parseMidnight.d.ts +48 -0
- package/lib/cjs/helpers/parseMidnight.js +95 -0
- package/lib/cjs/helpers/parseMidnightMaker.d.ts +44 -0
- package/lib/cjs/helpers/parseMidnightMaker.js +154 -0
- package/lib/cjs/helpers/validate.d.ts +3 -2
- package/lib/cjs/helpers/validate.js +4 -0
- package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.d.ts +8 -0
- package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.js +4 -4
- package/lib/cjs/helpers/validateMidnightPublication.d.ts +17 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +4 -5
- package/lib/cjs/transactionPlan/blue/refinance.js +17 -9
- package/lib/cjs/transactionPlan/blue/repay.js +2 -1
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +23 -4
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +2 -2
- package/lib/cjs/transactionPlan/blue/withdraw.d.ts +2 -2
- package/lib/cjs/transactionPlan/blue/withdraw.js +3 -3
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +6 -2
- package/lib/cjs/transactionPlan/validation.d.ts +1 -1
- package/lib/cjs/transactionPlan/validation.js +3 -0
- package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +2 -2
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +2 -2
- package/lib/cjs/types/action.d.ts +13 -2
- package/lib/cjs/types/error.d.ts +20 -2
- package/lib/cjs/types/error.js +32 -3
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +2 -4
- 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/borrow.d.ts +2 -1
- package/lib/esm/actions/blue/borrow.internal.d.ts +13 -0
- package/lib/esm/actions/blue/borrow.internal.js +30 -0
- package/lib/esm/actions/blue/borrow.js +4 -16
- package/lib/esm/actions/blue/common.d.ts +50 -28
- package/lib/esm/actions/blue/common.js +21 -33
- package/lib/esm/actions/blue/encode.d.ts +23 -0
- package/lib/esm/actions/blue/encode.js +164 -0
- package/lib/esm/actions/blue/refinance.d.ts +3 -2
- package/lib/esm/actions/blue/refinance.internal.d.ts +42 -0
- package/lib/esm/actions/blue/refinance.internal.js +56 -0
- package/lib/esm/actions/blue/refinance.js +5 -63
- package/lib/esm/actions/blue/refinanceValidation.d.ts +4 -5
- package/lib/esm/actions/blue/refinanceValidation.js +2 -4
- package/lib/esm/actions/blue/repay.d.ts +1 -1
- package/lib/esm/actions/blue/repay.internal.d.ts +13 -0
- package/lib/esm/actions/blue/repay.internal.js +33 -0
- package/lib/esm/actions/blue/repay.js +2 -17
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +2 -2
- package/lib/esm/actions/blue/repayWithdrawCollateral.internal.d.ts +61 -0
- package/lib/esm/actions/blue/repayWithdrawCollateral.internal.js +104 -0
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +3 -116
- package/lib/esm/actions/blue/signatures.d.ts +30 -0
- package/lib/esm/actions/blue/signatures.js +82 -0
- package/lib/esm/actions/blue/supply.d.ts +1 -1
- package/lib/esm/actions/blue/supply.internal.d.ts +32 -0
- package/lib/esm/actions/blue/supply.internal.js +95 -0
- package/lib/esm/actions/blue/supply.js +2 -67
- package/lib/esm/actions/blue/supplyCollateral.d.ts +1 -1
- package/lib/esm/actions/blue/supplyCollateral.internal.d.ts +13 -0
- package/lib/esm/actions/blue/supplyCollateral.internal.js +32 -0
- package/lib/esm/actions/blue/supplyCollateral.js +2 -17
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +4 -3
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.d.ts +63 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.js +87 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +5 -106
- package/lib/esm/actions/blue/withdraw.d.ts +4 -3
- package/lib/esm/actions/blue/withdraw.internal.d.ts +56 -0
- package/lib/esm/actions/blue/withdraw.internal.js +77 -0
- package/lib/esm/actions/blue/withdraw.js +5 -78
- package/lib/esm/actions/blue/withdrawBuyCallback.d.ts +2 -2
- package/lib/esm/actions/blue/withdrawBuyCallback.internal.d.ts +20 -0
- package/lib/esm/actions/blue/withdrawBuyCallback.internal.js +53 -0
- package/lib/esm/actions/blue/withdrawBuyCallback.js +2 -39
- package/lib/esm/actions/blue/withdrawCollateral.internal.d.ts +16 -0
- package/lib/esm/actions/blue/withdrawCollateral.internal.js +34 -0
- package/lib/esm/actions/blue/withdrawCollateral.js +2 -17
- package/lib/esm/actions/bundles/common.d.ts +9 -0
- package/lib/esm/actions/bundles/common.js +15 -4
- package/lib/esm/actions/bundles/index.d.ts +1 -1
- package/lib/esm/actions/bundles/index.js +1 -1
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +14 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +58 -61
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +22 -1
- package/lib/esm/actions/midnight/cancelAndMake.js +43 -85
- package/lib/esm/actions/midnight/cancelOffers.d.ts +11 -0
- package/lib/esm/actions/midnight/cancelOffers.js +18 -2
- package/lib/esm/actions/midnight/encode.d.ts +36 -0
- package/lib/esm/actions/midnight/encode.js +539 -0
- package/lib/esm/actions/midnight/index.d.ts +14 -13
- package/lib/esm/actions/midnight/index.js +14 -13
- package/lib/esm/actions/midnight/parse.d.ts +35 -0
- package/lib/esm/actions/midnight/parse.js +68 -0
- package/lib/esm/actions/midnight/parseCollateralBatch.d.ts +58 -0
- package/lib/esm/actions/midnight/parseCollateralBatch.js +209 -0
- package/lib/esm/actions/midnight/redeem.d.ts +16 -3
- package/lib/esm/actions/midnight/redeem.js +20 -50
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +13 -0
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +38 -64
- package/lib/esm/actions/midnight/supplyCollateral.d.ts +40 -5
- package/lib/esm/actions/midnight/supplyCollateral.js +57 -53
- package/lib/esm/actions/midnight/supplyCollateralBatch.d.ts +3 -3
- package/lib/esm/actions/midnight/supplyCollateralBatch.js +3 -62
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +24 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +33 -61
- package/lib/esm/actions/midnight/supplyCollateralWithNative.d.ts +77 -0
- package/lib/esm/actions/midnight/supplyCollateralWithNative.js +137 -0
- package/lib/esm/actions/midnight/takeBorrow.d.ts +17 -2
- package/lib/esm/actions/midnight/takeBorrow.js +20 -51
- package/lib/esm/actions/midnight/takeLend.d.ts +21 -1
- package/lib/esm/actions/midnight/takeLend.js +26 -54
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +30 -58
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +17 -2
- package/lib/esm/actions/midnight/takeWithdraw.js +76 -114
- package/lib/esm/actions/midnight/withdrawCollateral.d.ts +16 -3
- package/lib/esm/actions/midnight/withdrawCollateral.js +23 -55
- package/lib/esm/actions/midnight/withdrawCollateralBatch.d.ts +3 -3
- package/lib/esm/actions/midnight/withdrawCollateralBatch.js +3 -71
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +13 -0
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +36 -18
- package/lib/esm/actions/requirements/blue/index.d.ts +1 -1
- package/lib/esm/actions/requirements/blue/index.js +1 -1
- package/lib/esm/actions/requirements/chainCheck.d.ts +5 -0
- package/lib/esm/actions/requirements/chainCheck.js +6 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +36 -25
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +11 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +33 -16
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +14 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +41 -8
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +10 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +59 -24
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +10 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +21 -2
- package/lib/esm/actions/requirements/encode/index.d.ts +5 -5
- package/lib/esm/actions/requirements/encode/index.js +5 -5
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +26 -11
- package/lib/esm/actions/requirements/getRequirementsApproval.js +38 -12
- package/lib/esm/actions/requirements/index.d.ts +1 -1
- package/lib/esm/actions/requirements/index.js +1 -1
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +11 -0
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +31 -18
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -0
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +22 -10
- package/lib/esm/actions/requirements/midnight/index.d.ts +2 -2
- package/lib/esm/actions/requirements/midnight/index.js +2 -2
- package/lib/esm/actions/vaultV1/deposit.d.ts +21 -0
- package/lib/esm/actions/vaultV1/deposit.js +43 -9
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +18 -1
- package/lib/esm/actions/vaultV1/inKindRedeem.js +33 -15
- package/lib/esm/actions/vaultV1/index.d.ts +5 -5
- package/lib/esm/actions/vaultV1/index.js +5 -5
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +21 -0
- package/lib/esm/actions/vaultV1/migrateToV2.js +47 -11
- package/lib/esm/actions/vaultV1/redeem.d.ts +19 -0
- package/lib/esm/actions/vaultV1/redeem.js +26 -7
- package/lib/esm/actions/vaultV1/withdraw.d.ts +19 -0
- package/lib/esm/actions/vaultV1/withdraw.js +26 -7
- package/lib/esm/actions/vaultV2/deposit.d.ts +21 -0
- package/lib/esm/actions/vaultV2/deposit.js +43 -9
- package/lib/esm/actions/vaultV2/forceRedeem.d.ts +20 -2
- package/lib/esm/actions/vaultV2/forceRedeem.js +35 -6
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +23 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +33 -13
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +18 -1
- package/lib/esm/actions/vaultV2/inKindRedeem.js +32 -14
- package/lib/esm/actions/vaultV2/index.d.ts +6 -6
- package/lib/esm/actions/vaultV2/index.js +6 -6
- package/lib/esm/actions/vaultV2/redeem.d.ts +19 -0
- package/lib/esm/actions/vaultV2/redeem.js +26 -7
- package/lib/esm/actions/vaultV2/withdraw.d.ts +19 -0
- package/lib/esm/actions/vaultV2/withdraw.js +26 -7
- 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/blue/blue.d.ts +35 -8
- package/lib/esm/entities/blue/blue.js +449 -388
- 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 +117 -41
- package/lib/esm/entities/midnight/midnight.js +455 -826
- package/lib/esm/entities/midnight/parse.d.ts +74 -0
- package/lib/esm/entities/midnight/parse.js +320 -0
- package/lib/esm/entities/midnight/prepare.d.ts +47 -0
- package/lib/esm/entities/midnight/prepare.js +282 -0
- package/lib/esm/entities/midnight/publication.d.ts +7 -3
- package/lib/esm/entities/midnight/publication.js +7 -3
- package/lib/esm/entities/midnight/types.d.ts +7 -0
- package/lib/esm/entities/requirements/assertContractCode.d.ts +10 -5
- package/lib/esm/entities/requirements/assertContractCode.js +24 -15
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +15 -0
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +53 -47
- package/lib/esm/entities/requirements/getErc2612Permit.d.ts +7 -3
- package/lib/esm/entities/requirements/getErc2612Permit.js +19 -4
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +15 -0
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +20 -5
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +14 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +23 -5
- package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.js +4 -3
- package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.js +4 -3
- package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.js +4 -3
- package/lib/esm/entities/requirements/index.d.ts +2 -2
- package/lib/esm/entities/requirements/index.js +2 -2
- package/lib/esm/entities/requirements/validateNativeRequirements.d.ts +21 -0
- package/lib/esm/entities/requirements/validateNativeRequirements.js +33 -0
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.d.ts +2 -2
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.js +1 -7
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +17 -40
- package/lib/esm/entities/vaultV1/vaultV1.js +208 -139
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.d.ts +4 -0
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.js +10 -5
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.d.ts +2 -2
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.js +1 -7
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +29 -86
- package/lib/esm/entities/vaultV2/vaultV2.js +210 -172
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +2 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.js +2 -6
- 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/deadShares.js +1 -4
- package/lib/esm/helpers/parse.d.ts +33 -0
- package/lib/esm/helpers/parse.js +61 -0
- package/lib/esm/helpers/parseMidnight.d.ts +48 -0
- package/lib/esm/helpers/parseMidnight.js +80 -0
- package/lib/esm/helpers/parseMidnightMaker.d.ts +44 -0
- package/lib/esm/helpers/parseMidnightMaker.js +147 -0
- package/lib/esm/helpers/validate.d.ts +3 -2
- package/lib/esm/helpers/validate.js +5 -1
- package/lib/esm/helpers/validateMidnightCancelAndMakePublication.d.ts +8 -0
- package/lib/esm/helpers/validateMidnightCancelAndMakePublication.js +2 -2
- package/lib/esm/helpers/validateMidnightPublication.d.ts +17 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/midnight/errors.d.ts +1 -2
- package/lib/esm/midnight/errors.js +1 -2
- package/lib/esm/transactionPlan/blue/refinance.js +18 -10
- package/lib/esm/transactionPlan/blue/repay.js +3 -2
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +24 -5
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +2 -2
- package/lib/esm/transactionPlan/blue/withdraw.d.ts +2 -2
- package/lib/esm/transactionPlan/blue/withdraw.js +3 -3
- package/lib/esm/transactionPlan/blue/withdrawCollateral.js +6 -2
- package/lib/esm/transactionPlan/validation.d.ts +1 -1
- package/lib/esm/transactionPlan/validation.js +3 -0
- package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +2 -2
- package/lib/esm/transactionPlan/vaultv1/deposit.js +2 -2
- package/lib/esm/types/action.d.ts +13 -2
- package/lib/esm/types/error.d.ts +20 -2
- package/lib/esm/types/error.js +27 -0
- 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
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { encodeParsedErc20Permit, parseErc20Permit, } from "../../actions/requirements/encode/encodeErc20Permit.js";
|
|
2
2
|
import { readErc2612Permit } from "../../reads/readErc2612Permit.js";
|
|
3
|
-
/**
|
|
4
|
-
export
|
|
3
|
+
/** Uses the enclosing token resolver's complete checked input, not scalar witnesses. @internal */
|
|
4
|
+
export const getBundlesErc2612Permit = ({ viemClient, chainCheck, }, params) => resolveErc2612Permit(viemClient, {
|
|
5
|
+
...params,
|
|
6
|
+
encodePermit: (nonce) => encodeParsedErc20Permit({ viemClient, chainCheck }, parseErc20Permit(viemClient, {
|
|
7
|
+
token: params.token,
|
|
8
|
+
owner: params.owner,
|
|
9
|
+
spender: params.spender,
|
|
10
|
+
amount: params.amount,
|
|
11
|
+
chainId: params.chainId,
|
|
12
|
+
nonce,
|
|
13
|
+
deadline: params.deadline,
|
|
14
|
+
now: params.now,
|
|
15
|
+
supportDeployless: params.supportDeployless,
|
|
16
|
+
})),
|
|
17
|
+
});
|
|
18
|
+
/** Preserves the shared nonce/domain fallback and transport-error behavior. */
|
|
19
|
+
function resolveErc2612Permit(viemClient, params) {
|
|
5
20
|
return readErc2612Permit(viemClient, {
|
|
6
21
|
token: params.token,
|
|
7
22
|
owner: params.owner,
|
|
8
23
|
resolve: async (nonce) => {
|
|
9
|
-
const result = await
|
|
24
|
+
const result = await params.encodePermit(nonce);
|
|
10
25
|
return { domain: result.action.typedData.domain, result };
|
|
11
26
|
},
|
|
12
27
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Address, type Client } from "viem";
|
|
2
|
+
import { type ChainCheck } from "../../actions/requirements/chainCheck.js";
|
|
2
3
|
/**
|
|
3
4
|
* Parameters for {@link getUnusedPermit2Nonce}.
|
|
4
5
|
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
@@ -11,6 +12,14 @@ export interface GetUnusedPermit2NonceParams {
|
|
|
11
12
|
/** Lowest nonce to consider; defaults to 0. */
|
|
12
13
|
readonly startNonce?: bigint;
|
|
13
14
|
}
|
|
15
|
+
declare const unusedPermit2NonceInput: unique symbol;
|
|
16
|
+
/** Complete checked legacy nonce lookup invocation. @internal */
|
|
17
|
+
export type UnusedPermit2NonceInput = Readonly<GetUnusedPermit2NonceParams> & {
|
|
18
|
+
readonly startNonce: bigint;
|
|
19
|
+
readonly [unusedPermit2NonceInput]: true;
|
|
20
|
+
};
|
|
21
|
+
/** Owns the complete lookup's chain declaration, bounds and default start nonce. @internal */
|
|
22
|
+
export declare const parseUnusedPermit2Nonce: (viemClient: Client, params: GetUnusedPermit2NonceParams) => UnusedPermit2NonceInput;
|
|
14
23
|
/**
|
|
15
24
|
* Finds the lowest unused Permit2 unordered nonce for legacy SignatureTransfer integrations.
|
|
16
25
|
*
|
|
@@ -50,3 +59,9 @@ export interface GetUnusedPermit2NonceParams {
|
|
|
50
59
|
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
51
60
|
*/
|
|
52
61
|
export declare const getUnusedPermit2Nonce: (viemClient: Client, params: GetUnusedPermit2NonceParams) => Promise<bigint>;
|
|
62
|
+
/** Scans from the complete checked lookup, preserving registry and RPC ordering. @internal */
|
|
63
|
+
export declare const getParsedUnusedPermit2Nonce: ({ viemClient, chainCheck: providedChainCheck, }: {
|
|
64
|
+
readonly viemClient: Client;
|
|
65
|
+
readonly chainCheck?: ChainCheck;
|
|
66
|
+
}, params: UnusedPermit2NonceInput) => Promise<bigint>;
|
|
67
|
+
export {};
|
|
@@ -2,10 +2,22 @@ import { permit2Abi } from "@morpho-org/blue-sdk-viem";
|
|
|
2
2
|
import { getChainAddress } from "@morpho-org/morpho-ts";
|
|
3
3
|
import { maxUint256 } from "viem";
|
|
4
4
|
import { readContract } from "viem/actions";
|
|
5
|
-
import {
|
|
5
|
+
import { createChainCheck, } from "../../actions/requirements/chainCheck.js";
|
|
6
6
|
import { validateChainId } from "../../helpers/index.js";
|
|
7
7
|
import { validateUint256Field } from "../../helpers/validate.js";
|
|
8
8
|
import { NoUnusedPermit2NonceError } from "../../types/index.js";
|
|
9
|
+
/** Owns the complete lookup's chain declaration, bounds and default start nonce. @internal */
|
|
10
|
+
export const parseUnusedPermit2Nonce = (viemClient, params) => {
|
|
11
|
+
const input = {
|
|
12
|
+
owner: params.owner,
|
|
13
|
+
chainId: params.chainId,
|
|
14
|
+
startNonce: params.startNonce,
|
|
15
|
+
};
|
|
16
|
+
validateChainId(viemClient.chain?.id, input.chainId);
|
|
17
|
+
const startNonce = input.startNonce ?? 0n;
|
|
18
|
+
validateUint256Field("startNonce", startNonce);
|
|
19
|
+
return { ...input, startNonce };
|
|
20
|
+
};
|
|
9
21
|
/** Highest Permit2 nonce-bitmap word index; each word covers 256 unordered nonces. */
|
|
10
22
|
const MAX_PERMIT2_NONCE_WORD = maxUint256 >> 8n;
|
|
11
23
|
/**
|
|
@@ -47,10 +59,13 @@ const MAX_PERMIT2_NONCE_WORD = maxUint256 >> 8n;
|
|
|
47
59
|
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
48
60
|
*/
|
|
49
61
|
export const getUnusedPermit2Nonce = async (viemClient, params) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
return getParsedUnusedPermit2Nonce({ viemClient }, parseUnusedPermit2Nonce(viemClient, params));
|
|
63
|
+
};
|
|
64
|
+
/** Scans from the complete checked lookup, preserving registry and RPC ordering. @internal */
|
|
65
|
+
export const getParsedUnusedPermit2Nonce = async ({ viemClient, chainCheck: providedChainCheck, }, params) => {
|
|
66
|
+
const chainCheck = providedChainCheck ?? createChainCheck(viemClient, params.chainId);
|
|
67
|
+
const { startNonce } = params;
|
|
68
|
+
await chainCheck();
|
|
54
69
|
const permit2 = getChainAddress(params.chainId, "permit2");
|
|
55
70
|
const startWord = startNonce >> 8n;
|
|
56
71
|
for (let word = startWord; word <= MAX_PERMIT2_NONCE_WORD; word++) {
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { Token } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { Address, Client } from "viem";
|
|
3
|
+
import { type ChainCheck } from "../../actions/requirements/chainCheck.js";
|
|
3
4
|
import { type ERC20ApprovalAction, type PermitRequirementSignature, type ReferenceTimestampParams, type Requirement, type Transaction } from "../../types/index.js";
|
|
5
|
+
declare const vaultBundlesSharesRequirementsInput: unique symbol;
|
|
6
|
+
/** Complete checked vault-share resolver invocation. @internal */
|
|
7
|
+
export type VaultBundlesSharesRequirementsInput = Readonly<Parameters<typeof getVaultBundlesSharesRequirements>[1]> & {
|
|
8
|
+
readonly [vaultBundlesSharesRequirementsInput]: true;
|
|
9
|
+
};
|
|
10
|
+
/** Owns declared-chain and deadline checks before state is read. @internal */
|
|
11
|
+
export declare const parseVaultBundlesSharesRequirements: (viemClient: Client, params: Parameters<typeof getVaultBundlesSharesRequirements>[1]) => VaultBundlesSharesRequirementsInput;
|
|
4
12
|
/**
|
|
5
13
|
* Resolves the vault-share approval or ERC-2612 requirement for a VaultBundlesV1 exit.
|
|
6
14
|
*
|
|
@@ -29,3 +37,9 @@ export declare const getVaultBundlesSharesRequirements: (viemClient: Client, par
|
|
|
29
37
|
readonly deadline: bigint;
|
|
30
38
|
readonly supportSignature: boolean;
|
|
31
39
|
} & ReferenceTimestampParams) => Promise<readonly (Readonly<Transaction<ERC20ApprovalAction>> | Requirement<PermitRequirementSignature>)[]>;
|
|
40
|
+
/** Consumes the complete invocation without repeating static validation. @internal */
|
|
41
|
+
export declare const getParsedVaultBundlesSharesRequirements: ({ viemClient, chainCheck: providedChainCheck, }: {
|
|
42
|
+
readonly viemClient: Client;
|
|
43
|
+
readonly chainCheck?: ChainCheck;
|
|
44
|
+
}, params: VaultBundlesSharesRequirementsInput) => ReturnType<typeof getVaultBundlesSharesRequirements>;
|
|
45
|
+
export {};
|
|
@@ -3,10 +3,26 @@ import { getChainAddress, Time } from "@morpho-org/morpho-ts";
|
|
|
3
3
|
import { erc20Abi, maxUint256 } from "viem";
|
|
4
4
|
import { readContract } from "viem/actions";
|
|
5
5
|
import { encodeErc20Approval, encodeVaultSharesPermit, } from "../../actions/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { createChainCheck, } from "../../actions/requirements/chainCheck.js";
|
|
7
7
|
import { validateChainId } from "../../helpers/index.js";
|
|
8
8
|
import { validateDeadline } from "../../helpers/validate.js";
|
|
9
9
|
import { ExpiredDeadlineError, } from "../../types/index.js";
|
|
10
|
+
/** Owns declared-chain and deadline checks before state is read. @internal */
|
|
11
|
+
export const parseVaultBundlesSharesRequirements = (viemClient, params) => {
|
|
12
|
+
const input = {
|
|
13
|
+
vaultData: params.vaultData,
|
|
14
|
+
version: params.version,
|
|
15
|
+
owner: params.owner,
|
|
16
|
+
chainId: params.chainId,
|
|
17
|
+
requiredShareAllowance: params.requiredShareAllowance,
|
|
18
|
+
deadline: params.deadline,
|
|
19
|
+
supportSignature: params.supportSignature,
|
|
20
|
+
now: params.now,
|
|
21
|
+
};
|
|
22
|
+
validateChainId(viemClient.chain?.id, input.chainId);
|
|
23
|
+
validateDeadline(input.deadline);
|
|
24
|
+
return { ...input };
|
|
25
|
+
};
|
|
10
26
|
/**
|
|
11
27
|
* Resolves the vault-share approval or ERC-2612 requirement for a VaultBundlesV1 exit.
|
|
12
28
|
*
|
|
@@ -27,14 +43,16 @@ import { ExpiredDeadlineError, } from "../../types/index.js";
|
|
|
27
43
|
* @throws {viem.BaseError} when an allowance, permit nonce, or `eth_chainId` read fails.
|
|
28
44
|
*/
|
|
29
45
|
export const getVaultBundlesSharesRequirements = async (viemClient, params) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
return getParsedVaultBundlesSharesRequirements({ viemClient }, parseVaultBundlesSharesRequirements(viemClient, params));
|
|
47
|
+
};
|
|
48
|
+
/** Consumes the complete invocation without repeating static validation. @internal */
|
|
49
|
+
export const getParsedVaultBundlesSharesRequirements = async ({ viemClient, chainCheck: providedChainCheck, }, params) => {
|
|
50
|
+
const chainCheck = providedChainCheck ?? createChainCheck(viemClient, params.chainId);
|
|
33
51
|
const now = params.now ?? Time.timestamp();
|
|
34
52
|
if (params.deadline <= now) {
|
|
35
53
|
throw new ExpiredDeadlineError(params.deadline, now);
|
|
36
54
|
}
|
|
37
|
-
await
|
|
55
|
+
await chainCheck();
|
|
38
56
|
const spender = getChainAddress(params.chainId, "bundles.vaultBundlesV1");
|
|
39
57
|
// The allowance is trusted as returned by the RPC. See THREAT_MODEL.md, RPC.
|
|
40
58
|
const allowance = await readContract(viemClient, {
|
|
@@ -3,7 +3,7 @@ import { getChainAddress, Time } from "@morpho-org/morpho-ts";
|
|
|
3
3
|
import { erc20Abi, isAddressEqual, maxUint256 } from "viem";
|
|
4
4
|
import { readContract } from "viem/actions";
|
|
5
5
|
import { encodeErc20Approval, encodeVaultSharesPermit, } from "../../actions/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { createChainCheck } from "../../actions/requirements/chainCheck.js";
|
|
7
7
|
import { ExpiredDeadlineError, InsufficientBlueBalanceForInKindRedeemError, VaultIsBlueFeeRecipientError, VaultMorphoMismatchError, } from "../../types/index.js";
|
|
8
8
|
import { assertRegistryTargetsHaveCode } from "./assertContractCode.js";
|
|
9
9
|
/**
|
|
@@ -21,14 +21,15 @@ export async function getVaultV1InKindRedeemRequirements(client, params) {
|
|
|
21
21
|
if (deadline <= requirementsTimestamp) {
|
|
22
22
|
throw new ExpiredDeadlineError(deadline, requirementsTimestamp);
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
const chainCheck = createChainCheck(client, chainId);
|
|
25
|
+
await chainCheck();
|
|
25
26
|
await assertRegistryTargetsHaveCode(client, chainId, [
|
|
26
27
|
{
|
|
27
28
|
role: "bundles.vaultExitBundlesV1",
|
|
28
29
|
address: getChainAddress(chainId, "bundles.vaultExitBundlesV1"),
|
|
29
30
|
},
|
|
30
31
|
{ role: "blue", address: getChainAddress(chainId, "blue") },
|
|
31
|
-
]);
|
|
32
|
+
], chainCheck);
|
|
32
33
|
const [allowance, nonce, blueBalance, morpho, blueFeeRecipient] = await Promise.all([
|
|
33
34
|
readContract(client, {
|
|
34
35
|
address: vault,
|
|
@@ -3,7 +3,7 @@ import { getChainAddress, Time } from "@morpho-org/morpho-ts";
|
|
|
3
3
|
import { erc20Abi, maxUint256 } from "viem";
|
|
4
4
|
import { readContract } from "viem/actions";
|
|
5
5
|
import { encodeErc20Approval, encodeVaultSharesPermit, } from "../../actions/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { createChainCheck } from "../../actions/requirements/chainCheck.js";
|
|
7
7
|
import { ExpiredDeadlineError, } from "../../types/index.js";
|
|
8
8
|
import { assertRegistryTargetsHaveCode } from "./assertContractCode.js";
|
|
9
9
|
/**
|
|
@@ -20,13 +20,14 @@ export async function getVaultV2ForceWithdrawRequirements(client, params) {
|
|
|
20
20
|
if (deadline <= requirementsTimestamp) {
|
|
21
21
|
throw new ExpiredDeadlineError(deadline, requirementsTimestamp);
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
const chainCheck = createChainCheck(client, chainId);
|
|
24
|
+
await chainCheck();
|
|
24
25
|
await assertRegistryTargetsHaveCode(client, chainId, [
|
|
25
26
|
{
|
|
26
27
|
role: "bundles.vaultExitBundlesV1",
|
|
27
28
|
address: getChainAddress(chainId, "bundles.vaultExitBundlesV1"),
|
|
28
29
|
},
|
|
29
|
-
]);
|
|
30
|
+
], chainCheck);
|
|
30
31
|
// Vault gates are intentionally left to the final transaction: the receive-assets gate may
|
|
31
32
|
// inspect VaultExitBundlesV1's transient `initiator`, and a send-shares gate is arbitrary
|
|
32
33
|
// external code re-evaluated after each intermediate penalty burn, so neither is
|
|
@@ -3,7 +3,7 @@ import { getChainAddress, Time } from "@morpho-org/morpho-ts";
|
|
|
3
3
|
import { erc20Abi, maxUint256 } from "viem";
|
|
4
4
|
import { readContract } from "viem/actions";
|
|
5
5
|
import { encodeErc20Approval, encodeVaultSharesPermit, } from "../../actions/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { createChainCheck } from "../../actions/requirements/chainCheck.js";
|
|
7
7
|
import { ExpiredDeadlineError, InsufficientBlueBalanceForInKindRedeemError, } from "../../types/index.js";
|
|
8
8
|
import { assertRegistryTargetsHaveCode } from "./assertContractCode.js";
|
|
9
9
|
/**
|
|
@@ -21,14 +21,15 @@ export async function getVaultV2InKindRedeemRequirements(client, params) {
|
|
|
21
21
|
if (deadline <= requirementsTimestamp) {
|
|
22
22
|
throw new ExpiredDeadlineError(deadline, requirementsTimestamp);
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
const chainCheck = createChainCheck(client, chainId);
|
|
25
|
+
await chainCheck();
|
|
25
26
|
await assertRegistryTargetsHaveCode(client, chainId, [
|
|
26
27
|
{
|
|
27
28
|
role: "bundles.vaultExitBundlesV1",
|
|
28
29
|
address: getChainAddress(chainId, "bundles.vaultExitBundlesV1"),
|
|
29
30
|
},
|
|
30
31
|
{ role: "blue", address: getChainAddress(chainId, "blue") },
|
|
31
|
-
]);
|
|
32
|
+
], chainCheck);
|
|
32
33
|
// Vault gates are intentionally left to the final transaction. A receive gate may inspect
|
|
33
34
|
// VaultExitBundlesV1's transient `initiator`, which is populated only during the actual
|
|
34
35
|
// periphery call. A send-share gate is arbitrary external code and is evaluated repeatedly
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { type GetBundlesTokenRequirementsParams, getBundlesTokenRequirements, } from "./getBundlesTokenRequirements.js";
|
|
2
|
+
export { type GetUnusedPermit2NonceParams, getUnusedPermit2Nonce, } from "./getUnusedPermit2Nonce.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { getBundlesTokenRequirements, } from "./getBundlesTokenRequirements.js";
|
|
2
|
+
export { getUnusedPermit2Nonce, } from "./getUnusedPermit2Nonce.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Client } from "viem";
|
|
2
|
+
import type { ChainCheck } from "../../actions/requirements/chainCheck.js";
|
|
3
|
+
/**
|
|
4
|
+
* Checks native-funded write targets and the served chain concurrently.
|
|
5
|
+
*
|
|
6
|
+
* @param client - Connected viem client.
|
|
7
|
+
* @param params - Validation parameters.
|
|
8
|
+
* @param params.chainId - Expected chain ID.
|
|
9
|
+
* @param params.chainCheck - Optional invocation-local chain validation shared with target checks.
|
|
10
|
+
* @param params.assertWriteTargets - Contract-code validation for the selected flow.
|
|
11
|
+
* @returns Resolves when both validations succeed.
|
|
12
|
+
* @throws {ChainIdMismatchError} when the declared or served chain differs.
|
|
13
|
+
* @throws {MissingContractCodeError} when a write target has no code on the expected chain.
|
|
14
|
+
* @throws {viem.BaseError} when a validation RPC request fails.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare const validateNativeRequirements: (client: Client, { chainId, assertWriteTargets, chainCheck, }: {
|
|
18
|
+
readonly chainId: number;
|
|
19
|
+
readonly assertWriteTargets: () => Promise<void>;
|
|
20
|
+
readonly chainCheck?: ChainCheck;
|
|
21
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { validateClientChainId } from "../../actions/requirements/validateClientChainId.js";
|
|
2
|
+
import { ChainIdMismatchError } from "../../types/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Checks native-funded write targets and the served chain concurrently.
|
|
5
|
+
*
|
|
6
|
+
* @param client - Connected viem client.
|
|
7
|
+
* @param params - Validation parameters.
|
|
8
|
+
* @param params.chainId - Expected chain ID.
|
|
9
|
+
* @param params.chainCheck - Optional invocation-local chain validation shared with target checks.
|
|
10
|
+
* @param params.assertWriteTargets - Contract-code validation for the selected flow.
|
|
11
|
+
* @returns Resolves when both validations succeed.
|
|
12
|
+
* @throws {ChainIdMismatchError} when the declared or served chain differs.
|
|
13
|
+
* @throws {MissingContractCodeError} when a write target has no code on the expected chain.
|
|
14
|
+
* @throws {viem.BaseError} when a validation RPC request fails.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export const validateNativeRequirements = async (client, { chainId, assertWriteTargets, chainCheck = () => validateClientChainId(client, chainId), }) => {
|
|
18
|
+
const [chain, targets] = await Promise.allSettled([
|
|
19
|
+
chainCheck(),
|
|
20
|
+
assertWriteTargets(),
|
|
21
|
+
]);
|
|
22
|
+
// A served-chain mismatch explains a target failure; other chain errors must not hide it.
|
|
23
|
+
if (chain.status === "rejected" &&
|
|
24
|
+
chain.reason instanceof ChainIdMismatchError) {
|
|
25
|
+
throw chain.reason;
|
|
26
|
+
}
|
|
27
|
+
if (targets.status === "rejected") {
|
|
28
|
+
throw targets.reason;
|
|
29
|
+
}
|
|
30
|
+
if (chain.status === "rejected") {
|
|
31
|
+
throw chain.reason;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -13,13 +13,13 @@ export declare function computeVaultV1InKindRedeemQuote({ amount, marketParamsLi
|
|
|
13
13
|
readonly chainId: number;
|
|
14
14
|
}): {
|
|
15
15
|
deadline: bigint;
|
|
16
|
-
marketParamsListSnapshot: {
|
|
16
|
+
marketParamsListSnapshot: readonly Readonly<{
|
|
17
17
|
loanToken: `0x${string}`;
|
|
18
18
|
collateralToken: `0x${string}`;
|
|
19
19
|
oracle: `0x${string}`;
|
|
20
20
|
irm: `0x${string}`;
|
|
21
21
|
lltv: bigint;
|
|
22
|
-
}[];
|
|
22
|
+
}>[];
|
|
23
23
|
requiredShareAllowance: bigint;
|
|
24
24
|
vaultExitBundlesV1: `0x${string}`;
|
|
25
25
|
};
|
|
@@ -15,13 +15,7 @@ export function computeVaultV1InKindRedeemQuote({ amount, marketParamsList, vaul
|
|
|
15
15
|
if (marketParamsList.length === 0) {
|
|
16
16
|
throw new EmptyMarketParamsListError();
|
|
17
17
|
}
|
|
18
|
-
const marketParamsListSnapshot = marketParamsList.map(({ loanToken, collateralToken, oracle, irm, lltv }) => ({
|
|
19
|
-
loanToken,
|
|
20
|
-
collateralToken,
|
|
21
|
-
oracle,
|
|
22
|
-
irm,
|
|
23
|
-
lltv,
|
|
24
|
-
}));
|
|
18
|
+
const marketParamsListSnapshot = Object.freeze(marketParamsList.map(({ loanToken, collateralToken, oracle, irm, lltv }) => Object.freeze({ loanToken, collateralToken, oracle, irm, lltv })));
|
|
25
19
|
const deadline = deadlineOverride ?? now + Time.s.from.h(2n);
|
|
26
20
|
// Reject the same bounds the action enforces, before `getRequirements()` can walk the caller
|
|
27
21
|
// through a vault-share approval or an EIP-712 permit for a deadline `buildTx()` cannot encode.
|
|
@@ -470,6 +470,7 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
|
|
|
470
470
|
private readonly chainId;
|
|
471
471
|
constructor(client: MorphoClientType, vault: Address, chainId: number);
|
|
472
472
|
getData(parameters?: FetchParameters): Promise<AccrualVault>;
|
|
473
|
+
private getDataWithChainCheck;
|
|
473
474
|
/**
|
|
474
475
|
* Asserts that every registry contract this flow's transaction targets or names as
|
|
475
476
|
* spender/authorized operator holds code, with one `eth_getCode` per distinct address
|
|
@@ -480,59 +481,35 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
|
|
|
480
481
|
*/
|
|
481
482
|
private assertWriteTargets;
|
|
482
483
|
/** {@inheritDoc VaultV1Actions.deposit} */
|
|
483
|
-
deposit(params: {
|
|
484
|
-
readonly userAddress: Address;
|
|
485
|
-
readonly vaultData: AccrualVault;
|
|
486
|
-
readonly slippageTolerance?: bigint;
|
|
487
|
-
readonly referralFeePct?: bigint;
|
|
488
|
-
readonly referralFeeRecipient?: Address;
|
|
489
|
-
readonly deadline?: bigint;
|
|
490
|
-
} & ReferenceTimestampParams & BundlesFundingArgs): Readonly<{
|
|
484
|
+
deposit(params: Parameters<VaultV1Actions["deposit"]>[0]): Readonly<{
|
|
491
485
|
getRequirements: (requirementOptions?: BundlesTokenRequirementsOptions) => Promise<readonly ActionRequirement[]>;
|
|
492
486
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../types/action.js").Transaction<VaultV1DepositAction>>;
|
|
493
487
|
}>;
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
readonly slippageTolerance?: bigint;
|
|
499
|
-
readonly referralFeePct?: bigint;
|
|
500
|
-
readonly referralFeeRecipient?: Address;
|
|
501
|
-
readonly deadline?: bigint;
|
|
502
|
-
} & ReferenceTimestampParams): Readonly<{
|
|
488
|
+
/** Owns the complete raw deposit boundary, including snapshot-derived price protection. */
|
|
489
|
+
private parseDeposit;
|
|
490
|
+
private buildDeposit;
|
|
491
|
+
withdraw(params: Parameters<VaultV1Actions["withdraw"]>[0]): Readonly<{
|
|
503
492
|
getRequirements: () => Promise<readonly (Readonly<import("../../types/action.js").Transaction<import("../../types/action.js").ERC20ApprovalAction>> | import("../../types/action.js").Requirement<import("../../types/action.js").Erc2612RequirementSignature, undefined>)[]>;
|
|
504
493
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../types/action.js").Transaction<VaultV1WithdrawAction>>;
|
|
505
494
|
}>;
|
|
495
|
+
private parseWithdraw;
|
|
496
|
+
private buildWithdraw;
|
|
506
497
|
/** {@inheritDoc VaultV1Actions.redeem} */
|
|
507
|
-
redeem(params: {
|
|
508
|
-
readonly shares: bigint;
|
|
509
|
-
readonly userAddress: Address;
|
|
510
|
-
readonly referralFeePct?: bigint;
|
|
511
|
-
readonly referralFeeRecipient?: Address;
|
|
512
|
-
readonly deadline?: bigint;
|
|
513
|
-
} & ReferenceTimestampParams): Readonly<{
|
|
498
|
+
redeem(params: Parameters<VaultV1Actions["redeem"]>[0]): Readonly<{
|
|
514
499
|
getRequirements: () => Promise<readonly (Readonly<import("../../types/action.js").Transaction<import("../../types/action.js").ERC20ApprovalAction>> | import("../../types/action.js").Requirement<import("../../types/action.js").Erc2612RequirementSignature, undefined>)[]>;
|
|
515
500
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../types/action.js").Transaction<VaultV1RedeemAction>>;
|
|
516
501
|
}>;
|
|
502
|
+
private parseRedeem;
|
|
503
|
+
private buildRedeem;
|
|
517
504
|
/** {@inheritDoc VaultV1Actions.inKindRedeem} */
|
|
518
|
-
inKindRedeem(params:
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
readonly vaultData: AccrualVault;
|
|
522
|
-
readonly userAddress: Address;
|
|
523
|
-
readonly deadline?: bigint;
|
|
524
|
-
} & ReferenceTimestampParams): ActionOutput<VaultV1InKindRedeemAction, readonly RequirementSignature[], undefined>;
|
|
505
|
+
inKindRedeem(params: Parameters<VaultV1Actions["inKindRedeem"]>[0]): ActionOutput<VaultV1InKindRedeemAction, readonly RequirementSignature[], undefined>;
|
|
506
|
+
private parseInKindRedeem;
|
|
507
|
+
private buildInKindRedeem;
|
|
525
508
|
/** {@inheritDoc VaultV1Actions.migrateToV2} */
|
|
526
|
-
migrateToV2(params: {
|
|
527
|
-
readonly userAddress: Address;
|
|
528
|
-
readonly sourceVault: AccrualVault;
|
|
529
|
-
readonly targetVault: AccrualVaultV2;
|
|
530
|
-
readonly slippageTolerance?: bigint;
|
|
531
|
-
readonly referralFeePct?: bigint;
|
|
532
|
-
readonly referralFeeRecipient?: Address;
|
|
533
|
-
readonly deadline?: bigint;
|
|
534
|
-
} & ReferenceTimestampParams & VaultV1MigrateToV2AmountArgs): Readonly<{
|
|
509
|
+
migrateToV2(params: Parameters<VaultV1Actions["migrateToV2"]>[0]): Readonly<{
|
|
535
510
|
getRequirements: () => Promise<readonly (Readonly<import("../../types/action.js").Transaction<import("../../types/action.js").ERC20ApprovalAction>> | import("../../types/action.js").Requirement<import("../../types/action.js").Erc2612RequirementSignature, undefined>)[]>;
|
|
536
511
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../types/action.js").Transaction<VaultV1MigrateToV2Action>>;
|
|
537
512
|
}>;
|
|
513
|
+
private parseMigrateToV2;
|
|
514
|
+
private buildMigrateToV2;
|
|
538
515
|
}
|