@morpho-org/morpho-sdk 10.0.2 → 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/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/entities/blue/blue.d.ts +35 -8
- package/lib/cjs/entities/blue/blue.js +467 -406
- 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 +21 -52
- package/lib/cjs/entities/vaultV2/vaultV2.js +226 -150
- 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/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/version.d.ts +1 -1
- package/lib/cjs/version.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/entities/blue/blue.d.ts +35 -8
- package/lib/esm/entities/blue/blue.js +449 -388
- 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 +21 -52
- package/lib/esm/entities/vaultV2/vaultV2.js +209 -133
- 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/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/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +3 -3
|
@@ -6,17 +6,24 @@ const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
|
6
6
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
7
7
|
const viem_1 = require("viem");
|
|
8
8
|
const common_js_1 = require("../../actions/bundles/common.js");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
9
|
+
const chainCheck_js_1 = require("../../actions/requirements/chainCheck.js");
|
|
10
|
+
const deposit_js_1 = require("../../actions/vaultV2/deposit.js");
|
|
11
|
+
const forceRedeem_js_1 = require("../../actions/vaultV2/forceRedeem.js");
|
|
12
|
+
const forceWithdraw_js_1 = require("../../actions/vaultV2/forceWithdraw.js");
|
|
13
|
+
const inKindRedeem_js_1 = require("../../actions/vaultV2/inKindRedeem.js");
|
|
14
|
+
const redeem_js_1 = require("../../actions/vaultV2/redeem.js");
|
|
15
|
+
const withdraw_js_1 = require("../../actions/vaultV2/withdraw.js");
|
|
16
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
12
17
|
const metadata_js_1 = require("../../helpers/metadata.js");
|
|
18
|
+
const parse_js_1 = require("../../helpers/parse.js");
|
|
13
19
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
14
|
-
const
|
|
20
|
+
const index_js_2 = require("../../types/index.js");
|
|
15
21
|
const assertContractCode_js_1 = require("../requirements/assertContractCode.js");
|
|
22
|
+
const getBundlesTokenRequirements_js_1 = require("../requirements/getBundlesTokenRequirements.js");
|
|
16
23
|
const getVaultBundlesSharesRequirements_js_1 = require("../requirements/getVaultBundlesSharesRequirements.js");
|
|
17
24
|
const getVaultV2ForceWithdrawRequirements_js_1 = require("../requirements/getVaultV2ForceWithdrawRequirements.js");
|
|
18
25
|
const getVaultV2InKindRedeemRequirements_js_1 = require("../requirements/getVaultV2InKindRedeemRequirements.js");
|
|
19
|
-
const
|
|
26
|
+
const validateNativeRequirements_js_1 = require("../requirements/validateNativeRequirements.js");
|
|
20
27
|
const forceWithdrawQuote_js_1 = require("./forceWithdrawQuote.js");
|
|
21
28
|
const inKindRedeemQuote_js_1 = require("./inKindRedeemQuote.js");
|
|
22
29
|
/** Binds a viem client to a Vault V2 vault's action builders. */
|
|
@@ -31,7 +38,10 @@ class MorphoVaultV2 {
|
|
|
31
38
|
this.chainId = chainId;
|
|
32
39
|
}
|
|
33
40
|
async getData(parameters) {
|
|
34
|
-
|
|
41
|
+
return this.getDataWithChainCheck((0, chainCheck_js_1.createChainCheck)(this.client.viemClient, this.chainId), parameters);
|
|
42
|
+
}
|
|
43
|
+
async getDataWithChainCheck(chainCheck, parameters) {
|
|
44
|
+
await chainCheck();
|
|
35
45
|
return (0, blue_sdk_viem_1.fetchAccrualVaultV2)(this.vault, this.client.viemClient, {
|
|
36
46
|
...parameters,
|
|
37
47
|
deployless: this.client.options.supportDeployless,
|
|
@@ -45,28 +55,31 @@ class MorphoVaultV2 {
|
|
|
45
55
|
*
|
|
46
56
|
* @param roles - Registry labels to resolve and check.
|
|
47
57
|
*/
|
|
48
|
-
async assertWriteTargets(roles) {
|
|
58
|
+
async assertWriteTargets(roles, chainCheck) {
|
|
49
59
|
const targets = [];
|
|
50
60
|
for (const role of roles) {
|
|
51
61
|
const address = (0, morpho_ts_1.getChainAddress)(this.chainId, role);
|
|
52
62
|
targets.push({ role, address });
|
|
53
63
|
}
|
|
54
|
-
await (0, assertContractCode_js_1.assertRegistryTargetsHaveCode)(this.client.viemClient, this.chainId, targets);
|
|
64
|
+
await (0, assertContractCode_js_1.assertRegistryTargetsHaveCode)(this.client.viemClient, this.chainId, targets, chainCheck);
|
|
55
65
|
}
|
|
56
66
|
/** {@inheritDoc VaultV2Actions.deposit} */
|
|
57
67
|
deposit(params) {
|
|
68
|
+
return this.buildDeposit(this.parseDeposit(params));
|
|
69
|
+
}
|
|
70
|
+
parseDeposit(params) {
|
|
58
71
|
const suppliedNow = params.now;
|
|
59
72
|
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, suppliedNow);
|
|
60
73
|
const { userAddress, vaultData } = params;
|
|
61
74
|
const { asset: vaultAsset } = vaultData;
|
|
62
|
-
(0,
|
|
75
|
+
(0, index_js_1.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
|
|
63
76
|
if (!(0, viem_1.isAddressEqual)(vaultData.address, this.vault)) {
|
|
64
|
-
throw new
|
|
77
|
+
throw new index_js_2.VaultAddressMismatchError(this.vault, vaultData.address);
|
|
65
78
|
}
|
|
66
79
|
const createdAt = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
67
80
|
const deadline = params.deadline ?? createdAt + morpho_ts_1.Time.s.from.h(2n);
|
|
68
81
|
if (deadline <= createdAt) {
|
|
69
|
-
throw new
|
|
82
|
+
throw new index_js_2.ExpiredDeadlineError(deadline, createdAt);
|
|
70
83
|
}
|
|
71
84
|
const common = (0, common_js_1.normalizeBundlesCommonParams)({
|
|
72
85
|
deadline,
|
|
@@ -74,49 +87,82 @@ class MorphoVaultV2 {
|
|
|
74
87
|
referralFeeRecipient: params.referralFeeRecipient,
|
|
75
88
|
});
|
|
76
89
|
const funding = (0, common_js_1.resolveBundlesFunding)(params);
|
|
77
|
-
// Reject
|
|
78
|
-
(0,
|
|
90
|
+
// Reject invalid funding before preparing a lazy handle.
|
|
91
|
+
(0, parse_js_1.parseUint256)(funding.value > 0n ? "nativeAmount" : "amount", funding.assets);
|
|
79
92
|
if (funding.value > 0n) {
|
|
80
|
-
// The native path must target the chain's registered wrapped-native asset.
|
|
81
93
|
(0, validate_js_1.validateNativeVaultAsset)(this.chainId, vaultAsset);
|
|
82
94
|
}
|
|
83
95
|
const referralFeeAssets = (0, common_js_1.getBundlesReferralFeeAssets)(funding.assets, common.referralFeePct);
|
|
84
|
-
const maxSharePrice = (0,
|
|
96
|
+
const maxSharePrice = (0, index_js_1.computeVaultMaxSharePrice)({
|
|
85
97
|
vaultData,
|
|
86
98
|
deadline,
|
|
87
99
|
assets: funding.assets - referralFeeAssets,
|
|
88
100
|
slippageTolerance: params.slippageTolerance ?? blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE,
|
|
89
101
|
});
|
|
90
102
|
const spender = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultBundlesV1");
|
|
103
|
+
if (maxSharePrice <= 0n) {
|
|
104
|
+
throw new index_js_2.NonPositiveInputError("maxSharePrice", maxSharePrice);
|
|
105
|
+
}
|
|
106
|
+
// Computed bounds also have to fit uint256.
|
|
107
|
+
(0, parse_js_1.parseUint256)("maxSharePrice", maxSharePrice);
|
|
108
|
+
const parsed = {
|
|
109
|
+
vault: { chainId: this.chainId, address: this.vault, asset: vaultAsset },
|
|
110
|
+
userAddress,
|
|
111
|
+
funding,
|
|
112
|
+
maxSharePrice,
|
|
113
|
+
common,
|
|
114
|
+
metadata,
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
suppliedNow,
|
|
118
|
+
parsed,
|
|
119
|
+
spender,
|
|
120
|
+
vaultAsset,
|
|
121
|
+
userAddress,
|
|
122
|
+
funding,
|
|
123
|
+
deadline,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
buildDeposit(input) {
|
|
127
|
+
const { parsed, spender, vaultAsset, userAddress, funding, deadline } = input;
|
|
91
128
|
let pendingRequirements;
|
|
92
129
|
return Object.freeze({
|
|
93
130
|
getRequirements: async (requirementOptions) => {
|
|
94
|
-
const now = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
131
|
+
const now = input.suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
95
132
|
if (deadline <= now) {
|
|
96
|
-
throw new
|
|
133
|
+
throw new index_js_2.ExpiredDeadlineError(deadline, now);
|
|
134
|
+
}
|
|
135
|
+
const chainCheck = (0, chainCheck_js_1.createChainCheck)(this.client.viemClient, this.chainId);
|
|
136
|
+
if (funding.value > 0n) {
|
|
137
|
+
// Native funding skips the token resolver's chain validation.
|
|
138
|
+
await (0, validateNativeRequirements_js_1.validateNativeRequirements)(this.client.viemClient, {
|
|
139
|
+
chainId: this.chainId,
|
|
140
|
+
chainCheck,
|
|
141
|
+
assertWriteTargets: () => this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck),
|
|
142
|
+
});
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
await this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck);
|
|
146
|
+
const tokenInput = (0, getBundlesTokenRequirements_js_1.parseGetBundlesTokenRequirements)(this.client.viemClient, {
|
|
147
|
+
token: vaultAsset,
|
|
148
|
+
spender,
|
|
149
|
+
amount: funding.assets,
|
|
150
|
+
owner: userAddress,
|
|
151
|
+
chainId: this.chainId,
|
|
152
|
+
deadline,
|
|
153
|
+
supportSignature: this.client.options.supportSignature,
|
|
154
|
+
supportDeployless: this.client.options.supportDeployless,
|
|
155
|
+
useSimplePermit: requirementOptions?.useSimplePermit,
|
|
156
|
+
now,
|
|
157
|
+
});
|
|
158
|
+
// Check each non-no-op invocation before sharing an in-flight state read.
|
|
159
|
+
if (tokenInput.amount > 0n) {
|
|
160
|
+
await chainCheck();
|
|
97
161
|
}
|
|
98
162
|
if (pendingRequirements != null) {
|
|
99
163
|
return await pendingRequirements;
|
|
100
164
|
}
|
|
101
|
-
|
|
102
|
-
// allowance/nonce reads.
|
|
103
|
-
const pending = (async () => {
|
|
104
|
-
await this.assertWriteTargets(["bundles.vaultBundlesV1"]);
|
|
105
|
-
return funding.value > 0n
|
|
106
|
-
? []
|
|
107
|
-
: (0, index_js_4.getBundlesTokenRequirements)(this.client.viemClient, {
|
|
108
|
-
token: vaultAsset,
|
|
109
|
-
spender,
|
|
110
|
-
amount: funding.assets,
|
|
111
|
-
owner: userAddress,
|
|
112
|
-
chainId: this.chainId,
|
|
113
|
-
deadline,
|
|
114
|
-
supportSignature: this.client.options.supportSignature,
|
|
115
|
-
supportDeployless: this.client.options.supportDeployless,
|
|
116
|
-
useSimplePermit: requirementOptions?.useSimplePermit,
|
|
117
|
-
now,
|
|
118
|
-
});
|
|
119
|
-
})();
|
|
165
|
+
const pending = (0, getBundlesTokenRequirements_js_1.getParsedBundlesTokenRequirements)({ viemClient: this.client.viemClient, chainCheck }, tokenInput);
|
|
120
166
|
pendingRequirements = pending;
|
|
121
167
|
try {
|
|
122
168
|
return await pending;
|
|
@@ -131,45 +177,30 @@ class MorphoVaultV2 {
|
|
|
131
177
|
buildTx: (signatures) => {
|
|
132
178
|
// The pure deposit action rejects a token signature supplied alongside native funding.
|
|
133
179
|
const requirementSignature = (0, common_js_1.selectBundlesTokenRequirementSignature)(signatures, { spender, amount: funding.assets, deadline });
|
|
134
|
-
return (0,
|
|
135
|
-
vault: {
|
|
136
|
-
chainId: this.chainId,
|
|
137
|
-
address: this.vault,
|
|
138
|
-
asset: vaultAsset,
|
|
139
|
-
},
|
|
140
|
-
args: {
|
|
141
|
-
...(funding.value > 0n
|
|
142
|
-
? { nativeAmount: funding.assets }
|
|
143
|
-
: { amount: funding.assets }),
|
|
144
|
-
maxSharePrice,
|
|
145
|
-
userAddress,
|
|
146
|
-
requirementSignature,
|
|
147
|
-
referralFeePct: common.referralFeePct,
|
|
148
|
-
referralFeeRecipient: common.referralFeeRecipient,
|
|
149
|
-
deadline,
|
|
150
|
-
},
|
|
151
|
-
metadata,
|
|
152
|
-
});
|
|
180
|
+
return (0, deposit_js_1.buildVaultV2Deposit)(parsed, { requirementSignature });
|
|
153
181
|
},
|
|
154
182
|
});
|
|
155
183
|
}
|
|
156
184
|
withdraw(params) {
|
|
185
|
+
return this.buildWithdraw(this.parseWithdraw(params));
|
|
186
|
+
}
|
|
187
|
+
parseWithdraw(params) {
|
|
157
188
|
const suppliedNow = params.now;
|
|
158
189
|
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, suppliedNow);
|
|
159
190
|
const { amount, userAddress, vaultData } = params;
|
|
160
|
-
(0,
|
|
191
|
+
(0, index_js_1.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
|
|
161
192
|
if (!(0, viem_1.isAddressEqual)(vaultData.address, this.vault)) {
|
|
162
|
-
throw new
|
|
193
|
+
throw new index_js_2.VaultAddressMismatchError(this.vault, vaultData.address);
|
|
163
194
|
}
|
|
164
195
|
if (amount <= 0n) {
|
|
165
|
-
throw new
|
|
196
|
+
throw new index_js_2.NonPositiveInputError("amount", amount);
|
|
166
197
|
}
|
|
167
198
|
// Reject values outside the ABI range before resolving any requirements.
|
|
168
|
-
(0,
|
|
199
|
+
const parsedAmount = (0, parse_js_1.parseUint256)("amount", amount);
|
|
169
200
|
const createdAt = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
170
201
|
const deadline = params.deadline ?? createdAt + morpho_ts_1.Time.s.from.h(2n);
|
|
171
202
|
if (deadline <= createdAt) {
|
|
172
|
-
throw new
|
|
203
|
+
throw new index_js_2.ExpiredDeadlineError(deadline, createdAt);
|
|
173
204
|
}
|
|
174
205
|
const common = (0, common_js_1.normalizeBundlesCommonParams)({
|
|
175
206
|
deadline,
|
|
@@ -177,24 +208,43 @@ class MorphoVaultV2 {
|
|
|
177
208
|
referralFeeRecipient: params.referralFeeRecipient,
|
|
178
209
|
});
|
|
179
210
|
const slippageTolerance = params.slippageTolerance ?? blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE;
|
|
180
|
-
(0,
|
|
211
|
+
(0, index_js_1.validateSlippageTolerance)(slippageTolerance);
|
|
181
212
|
// Resolve the spender eagerly so an unregistered VaultBundlesV1 fails at handle creation.
|
|
182
213
|
const spender = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultBundlesV1");
|
|
183
|
-
const requiredShareAllowance = (0,
|
|
214
|
+
const requiredShareAllowance = (0, index_js_1.computeVaultMaxShareAllowance)({
|
|
184
215
|
vaultData,
|
|
185
216
|
deadline,
|
|
186
217
|
assets: amount,
|
|
187
218
|
slippageTolerance,
|
|
188
219
|
});
|
|
220
|
+
const parsed = {
|
|
221
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
222
|
+
args: { amount: parsedAmount, userAddress, ...common },
|
|
223
|
+
common,
|
|
224
|
+
metadata,
|
|
225
|
+
};
|
|
226
|
+
return {
|
|
227
|
+
suppliedNow,
|
|
228
|
+
parsed,
|
|
229
|
+
spender,
|
|
230
|
+
vaultData,
|
|
231
|
+
userAddress,
|
|
232
|
+
requiredShareAllowance,
|
|
233
|
+
deadline,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
buildWithdraw(input) {
|
|
237
|
+
const { parsed, spender, vaultData, userAddress, requiredShareAllowance, deadline, } = input;
|
|
189
238
|
return Object.freeze({
|
|
190
239
|
getRequirements: async () => {
|
|
191
|
-
const now = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
240
|
+
const now = input.suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
192
241
|
if (deadline <= now) {
|
|
193
|
-
throw new
|
|
242
|
+
throw new index_js_2.ExpiredDeadlineError(deadline, now);
|
|
194
243
|
}
|
|
195
|
-
|
|
244
|
+
const chainCheck = (0, chainCheck_js_1.createChainCheck)(this.client.viemClient, this.chainId);
|
|
245
|
+
await this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck);
|
|
196
246
|
// Re-read the live share allowance on every call instead of caching the resolved requirements.
|
|
197
|
-
return (0, getVaultBundlesSharesRequirements_js_1.
|
|
247
|
+
return (0, getVaultBundlesSharesRequirements_js_1.getParsedVaultBundlesSharesRequirements)({ viemClient: this.client.viemClient, chainCheck }, (0, getVaultBundlesSharesRequirements_js_1.parseVaultBundlesSharesRequirements)(this.client.viemClient, {
|
|
198
248
|
vaultData,
|
|
199
249
|
version: "vaultV2",
|
|
200
250
|
owner: userAddress,
|
|
@@ -203,7 +253,7 @@ class MorphoVaultV2 {
|
|
|
203
253
|
deadline,
|
|
204
254
|
supportSignature: this.client.options.supportSignature,
|
|
205
255
|
now,
|
|
206
|
-
});
|
|
256
|
+
}));
|
|
207
257
|
},
|
|
208
258
|
buildTx: (signatures) => {
|
|
209
259
|
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signatures, {
|
|
@@ -211,34 +261,26 @@ class MorphoVaultV2 {
|
|
|
211
261
|
amount: requiredShareAllowance,
|
|
212
262
|
deadline,
|
|
213
263
|
});
|
|
214
|
-
return (0,
|
|
215
|
-
vault: { chainId: this.chainId, address: this.vault },
|
|
216
|
-
args: {
|
|
217
|
-
amount,
|
|
218
|
-
userAddress,
|
|
219
|
-
requirementSignature: permit,
|
|
220
|
-
referralFeePct: common.referralFeePct,
|
|
221
|
-
referralFeeRecipient: common.referralFeeRecipient,
|
|
222
|
-
deadline,
|
|
223
|
-
},
|
|
224
|
-
metadata,
|
|
225
|
-
});
|
|
264
|
+
return (0, withdraw_js_1.buildVaultV2Withdraw)(parsed, { requirementSignature: permit });
|
|
226
265
|
},
|
|
227
266
|
});
|
|
228
267
|
}
|
|
229
268
|
/** {@inheritDoc VaultV2Actions.redeem} */
|
|
230
269
|
redeem(params) {
|
|
270
|
+
return this.buildRedeem(this.parseRedeem(params));
|
|
271
|
+
}
|
|
272
|
+
parseRedeem(params) {
|
|
231
273
|
const suppliedNow = params.now;
|
|
232
274
|
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, suppliedNow);
|
|
233
|
-
(0,
|
|
275
|
+
(0, index_js_1.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
|
|
234
276
|
const { shares, userAddress } = params;
|
|
235
277
|
if (shares <= 0n) {
|
|
236
|
-
throw new
|
|
278
|
+
throw new index_js_2.NonPositiveInputError("shares", shares);
|
|
237
279
|
}
|
|
238
280
|
const createdAt = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
239
281
|
const deadline = params.deadline ?? createdAt + morpho_ts_1.Time.s.from.h(2n);
|
|
240
282
|
if (deadline <= createdAt) {
|
|
241
|
-
throw new
|
|
283
|
+
throw new index_js_2.ExpiredDeadlineError(deadline, createdAt);
|
|
242
284
|
}
|
|
243
285
|
const common = (0, common_js_1.normalizeBundlesCommonParams)({
|
|
244
286
|
deadline,
|
|
@@ -246,15 +288,26 @@ class MorphoVaultV2 {
|
|
|
246
288
|
referralFeeRecipient: params.referralFeeRecipient,
|
|
247
289
|
});
|
|
248
290
|
const spender = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultBundlesV1");
|
|
291
|
+
const parsed = {
|
|
292
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
293
|
+
args: { shares: (0, parse_js_1.parseUint256)("shares", shares), userAddress, ...common },
|
|
294
|
+
common,
|
|
295
|
+
metadata,
|
|
296
|
+
};
|
|
297
|
+
return { suppliedNow, parsed, spender, shares, userAddress, deadline };
|
|
298
|
+
}
|
|
299
|
+
buildRedeem(input) {
|
|
300
|
+
const { parsed, spender, shares, userAddress, deadline } = input;
|
|
249
301
|
return Object.freeze({
|
|
250
302
|
getRequirements: async () => {
|
|
251
|
-
const now = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
303
|
+
const now = input.suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
252
304
|
if (deadline <= now) {
|
|
253
|
-
throw new
|
|
305
|
+
throw new index_js_2.ExpiredDeadlineError(deadline, now);
|
|
254
306
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
307
|
+
const chainCheck = (0, chainCheck_js_1.createChainCheck)(this.client.viemClient, this.chainId);
|
|
308
|
+
await this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck);
|
|
309
|
+
return (0, getVaultBundlesSharesRequirements_js_1.getParsedVaultBundlesSharesRequirements)({ viemClient: this.client.viemClient, chainCheck }, (0, getVaultBundlesSharesRequirements_js_1.parseVaultBundlesSharesRequirements)(this.client.viemClient, {
|
|
310
|
+
vaultData: await this.getDataWithChainCheck(chainCheck),
|
|
258
311
|
version: "vaultV2",
|
|
259
312
|
owner: userAddress,
|
|
260
313
|
chainId: this.chainId,
|
|
@@ -262,7 +315,7 @@ class MorphoVaultV2 {
|
|
|
262
315
|
deadline,
|
|
263
316
|
supportSignature: this.client.options.supportSignature,
|
|
264
317
|
now,
|
|
265
|
-
});
|
|
318
|
+
}));
|
|
266
319
|
},
|
|
267
320
|
buildTx: (signatures) => {
|
|
268
321
|
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signatures, {
|
|
@@ -270,40 +323,54 @@ class MorphoVaultV2 {
|
|
|
270
323
|
amount: shares,
|
|
271
324
|
deadline,
|
|
272
325
|
});
|
|
273
|
-
return (0,
|
|
274
|
-
vault: { chainId: this.chainId, address: this.vault },
|
|
275
|
-
args: {
|
|
276
|
-
shares,
|
|
277
|
-
userAddress,
|
|
278
|
-
requirementSignature: permit,
|
|
279
|
-
referralFeePct: common.referralFeePct,
|
|
280
|
-
referralFeeRecipient: common.referralFeeRecipient,
|
|
281
|
-
deadline,
|
|
282
|
-
},
|
|
283
|
-
metadata,
|
|
284
|
-
});
|
|
326
|
+
return (0, redeem_js_1.buildVaultV2Redeem)(parsed, { requirementSignature: permit });
|
|
285
327
|
},
|
|
286
328
|
});
|
|
287
329
|
}
|
|
288
330
|
/** {@inheritDoc VaultV2Actions.inKindRedeem} */
|
|
289
331
|
inKindRedeem(params) {
|
|
290
|
-
|
|
332
|
+
return this.buildInKindRedeem(this.parseInKindRedeem(params));
|
|
333
|
+
}
|
|
334
|
+
parseInKindRedeem({ now: suppliedNow, amount, marketParamsList, vaultData, userAddress, adapter: adapterOverride, deadline: deadlineOverride, }) {
|
|
291
335
|
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, suppliedNow);
|
|
292
|
-
|
|
293
|
-
(0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
|
|
336
|
+
(0, index_js_1.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
|
|
294
337
|
if (!(0, viem_1.isAddressEqual)(vaultData.address, this.vault)) {
|
|
295
|
-
throw new
|
|
338
|
+
throw new index_js_2.VaultAddressMismatchError(this.vault, vaultData.address);
|
|
296
339
|
}
|
|
297
340
|
const { deadline, adapter, marketParamsListSnapshot, requiredShareAllowance, peak, } = (0, inKindRedeemQuote_js_1.computeVaultV2InKindRedeemQuote)({
|
|
298
341
|
amount,
|
|
299
342
|
marketParamsList,
|
|
300
343
|
vaultData,
|
|
301
|
-
deadline: deadlineOverride,
|
|
302
344
|
adapter: adapterOverride,
|
|
345
|
+
deadline: deadlineOverride,
|
|
303
346
|
now: suppliedNow ?? morpho_ts_1.Time.timestamp(),
|
|
304
347
|
vault: this.vault,
|
|
305
348
|
});
|
|
306
349
|
const vaultExitBundlesV1 = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultExitBundlesV1");
|
|
350
|
+
const parsed = {
|
|
351
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
352
|
+
args: {
|
|
353
|
+
adapter,
|
|
354
|
+
amount,
|
|
355
|
+
marketParamsList: marketParamsListSnapshot,
|
|
356
|
+
userAddress,
|
|
357
|
+
deadline,
|
|
358
|
+
},
|
|
359
|
+
metadata,
|
|
360
|
+
};
|
|
361
|
+
return {
|
|
362
|
+
suppliedNow,
|
|
363
|
+
parsed,
|
|
364
|
+
deadline,
|
|
365
|
+
userAddress,
|
|
366
|
+
vaultData,
|
|
367
|
+
vaultExitBundlesV1,
|
|
368
|
+
peak,
|
|
369
|
+
requiredShareAllowance,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
buildInKindRedeem(input) {
|
|
373
|
+
const { parsed, deadline, userAddress, vaultData, vaultExitBundlesV1, peak, requiredShareAllowance, } = input;
|
|
307
374
|
return {
|
|
308
375
|
getRequirements: () => (0, getVaultV2InKindRedeemRequirements_js_1.getVaultV2InKindRedeemRequirements)(this.client.viemClient, {
|
|
309
376
|
vaultData,
|
|
@@ -314,7 +381,7 @@ class MorphoVaultV2 {
|
|
|
314
381
|
requiredShareAllowance,
|
|
315
382
|
supportSignature: this.client.options.supportSignature,
|
|
316
383
|
peak,
|
|
317
|
-
now: suppliedNow,
|
|
384
|
+
now: input.suppliedNow,
|
|
318
385
|
}),
|
|
319
386
|
buildTx: (signatures) => {
|
|
320
387
|
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signatures, {
|
|
@@ -322,31 +389,23 @@ class MorphoVaultV2 {
|
|
|
322
389
|
amount: requiredShareAllowance,
|
|
323
390
|
deadline,
|
|
324
391
|
});
|
|
325
|
-
return (0,
|
|
326
|
-
|
|
327
|
-
args: {
|
|
328
|
-
adapter,
|
|
329
|
-
amount,
|
|
330
|
-
marketParamsList: marketParamsListSnapshot,
|
|
331
|
-
userAddress,
|
|
332
|
-
deadline,
|
|
333
|
-
requirementSignature: permit,
|
|
334
|
-
},
|
|
335
|
-
metadata,
|
|
392
|
+
return (0, inKindRedeem_js_1.buildVaultV2InKindRedeem)(parsed, {
|
|
393
|
+
requirementSignature: permit,
|
|
336
394
|
});
|
|
337
395
|
},
|
|
338
396
|
};
|
|
339
397
|
}
|
|
340
398
|
/** {@inheritDoc VaultV2Actions.forceWithdraw} */
|
|
341
399
|
forceWithdraw(params) {
|
|
342
|
-
|
|
400
|
+
return this.buildForceWithdraw(this.parseForceWithdraw(params));
|
|
401
|
+
}
|
|
402
|
+
parseForceWithdraw({ now: suppliedNow, exitAssets, vaultData, userAddress, adapter: adapterOverride, deadline: deadlineOverride, slippageTolerance = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, minSharePriceE27: minSharePriceE27Override, referralFeePct = 0n, referralFeeRecipient, }) {
|
|
343
403
|
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, suppliedNow);
|
|
344
|
-
|
|
345
|
-
(0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
|
|
404
|
+
(0, index_js_1.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
|
|
346
405
|
if (!(0, viem_1.isAddressEqual)(vaultData.address, this.vault)) {
|
|
347
|
-
throw new
|
|
406
|
+
throw new index_js_2.VaultAddressMismatchError(this.vault, vaultData.address);
|
|
348
407
|
}
|
|
349
|
-
const { deadline, adapter, minSharePriceE27, requiredShareAllowance } = (0, forceWithdrawQuote_js_1.computeVaultV2ForceWithdrawQuote)({
|
|
408
|
+
const { deadline, adapter, minSharePriceE27, requiredShareAllowance, referral, } = (0, forceWithdrawQuote_js_1.computeVaultV2ForceWithdrawQuote)({
|
|
350
409
|
exitAssets,
|
|
351
410
|
vaultData,
|
|
352
411
|
userAddress,
|
|
@@ -360,6 +419,30 @@ class MorphoVaultV2 {
|
|
|
360
419
|
vault: this.vault,
|
|
361
420
|
});
|
|
362
421
|
const vaultExitBundlesV1 = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultExitBundlesV1");
|
|
422
|
+
const parsed = {
|
|
423
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
424
|
+
args: {
|
|
425
|
+
adapter,
|
|
426
|
+
exitAssets,
|
|
427
|
+
minSharePriceE27,
|
|
428
|
+
userAddress,
|
|
429
|
+
deadline,
|
|
430
|
+
},
|
|
431
|
+
referral,
|
|
432
|
+
metadata,
|
|
433
|
+
};
|
|
434
|
+
return {
|
|
435
|
+
suppliedNow,
|
|
436
|
+
parsed,
|
|
437
|
+
deadline,
|
|
438
|
+
userAddress,
|
|
439
|
+
vaultData,
|
|
440
|
+
vaultExitBundlesV1,
|
|
441
|
+
requiredShareAllowance,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
buildForceWithdraw(input) {
|
|
445
|
+
const { parsed, deadline, userAddress, vaultData, vaultExitBundlesV1, requiredShareAllowance, } = input;
|
|
363
446
|
return {
|
|
364
447
|
getRequirements: () => (0, getVaultV2ForceWithdrawRequirements_js_1.getVaultV2ForceWithdrawRequirements)(this.client.viemClient, {
|
|
365
448
|
vaultData,
|
|
@@ -369,7 +452,7 @@ class MorphoVaultV2 {
|
|
|
369
452
|
deadline,
|
|
370
453
|
requiredShareAllowance,
|
|
371
454
|
supportSignature: this.client.options.supportSignature,
|
|
372
|
-
now: suppliedNow,
|
|
455
|
+
now: input.suppliedNow,
|
|
373
456
|
}),
|
|
374
457
|
buildTx: (signatures) => {
|
|
375
458
|
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signatures, {
|
|
@@ -377,44 +460,37 @@ class MorphoVaultV2 {
|
|
|
377
460
|
amount: requiredShareAllowance,
|
|
378
461
|
deadline,
|
|
379
462
|
});
|
|
380
|
-
return (0,
|
|
381
|
-
|
|
382
|
-
args: {
|
|
383
|
-
adapter,
|
|
384
|
-
exitAssets,
|
|
385
|
-
minSharePriceE27,
|
|
386
|
-
userAddress,
|
|
387
|
-
deadline,
|
|
388
|
-
referralFeePct,
|
|
389
|
-
referralFeeRecipient,
|
|
390
|
-
requirementSignature: permit,
|
|
391
|
-
},
|
|
392
|
-
metadata,
|
|
463
|
+
return (0, forceWithdraw_js_1.buildVaultV2ForceWithdraw)(parsed, {
|
|
464
|
+
requirementSignature: permit,
|
|
393
465
|
});
|
|
394
466
|
},
|
|
395
467
|
};
|
|
396
468
|
}
|
|
397
469
|
forceRedeem(params) {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
470
|
+
return this.buildForceRedeem(this.parseForceRedeem(params));
|
|
471
|
+
}
|
|
472
|
+
parseForceRedeem({ now: suppliedNow, deallocations, redeem, userAddress, }) {
|
|
473
|
+
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, suppliedNow);
|
|
474
|
+
(0, index_js_1.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
|
|
401
475
|
const shares = redeem.shares;
|
|
402
476
|
const deallocationsSnapshot = deallocations.map(({ adapter, marketParams, amount }) => ({
|
|
403
477
|
adapter,
|
|
404
478
|
amount,
|
|
405
479
|
...(marketParams && { marketParams: new blue_sdk_1.MarketParams(marketParams) }),
|
|
406
480
|
}));
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
481
|
+
const parsed = (0, forceRedeem_js_1.parseVaultV2ForceRedeem)({
|
|
482
|
+
vault: { address: this.vault },
|
|
483
|
+
args: {
|
|
484
|
+
deallocations: deallocationsSnapshot,
|
|
485
|
+
redeem: { shares, recipient: userAddress },
|
|
486
|
+
onBehalf: userAddress,
|
|
487
|
+
},
|
|
488
|
+
metadata,
|
|
489
|
+
});
|
|
490
|
+
return parsed;
|
|
491
|
+
}
|
|
492
|
+
buildForceRedeem(parsed) {
|
|
493
|
+
return { buildTx: () => (0, forceRedeem_js_1.buildVaultV2ForceRedeem)(parsed) };
|
|
418
494
|
}
|
|
419
495
|
}
|
|
420
496
|
exports.MorphoVaultV2 = MorphoVaultV2;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
+
import { type Address } from "viem";
|
|
3
|
+
declare const blueMarket: unique symbol;
|
|
4
|
+
/** An owned, immutable market tuple with its validated identifier. @internal */
|
|
5
|
+
export interface BlueMarket extends Readonly<Pick<MarketParams, "loanToken" | "collateralToken" | "oracle" | "irm" | "lltv" | "id">> {
|
|
6
|
+
readonly [blueMarket]: true;
|
|
7
|
+
}
|
|
8
|
+
/** Validates and owns a frozen plain snapshot of the market tuple and identifier. @internal */
|
|
9
|
+
export declare const parseBlueMarket: (value: MarketParams) => BlueMarket;
|
|
10
|
+
/** Parses an unsigned ABI amount without changing validator error semantics. @internal */
|
|
11
|
+
export declare const parseUint256: (field: string, value: bigint) => bigint;
|
|
12
|
+
/** Parses a positive ABI deadline; expiry belongs to the entity. @internal */
|
|
13
|
+
export declare const parseDeadline: (value: bigint) => bigint;
|
|
14
|
+
/** Parses the referral pair using the existing fixed-bundle normalizer. @internal */
|
|
15
|
+
export declare const parseReferralFee: (params: {
|
|
16
|
+
readonly referralFeePct?: bigint;
|
|
17
|
+
readonly referralFeeRecipient?: Address;
|
|
18
|
+
}) => {
|
|
19
|
+
readonly referralFeePct: bigint;
|
|
20
|
+
readonly referralFeeRecipient: Address;
|
|
21
|
+
};
|
|
22
|
+
/** Parses exclusive native funding; signature exclusivity is checked at encoding. @internal */
|
|
23
|
+
export declare const parseNativeFunding: (params: {
|
|
24
|
+
readonly chainId: number;
|
|
25
|
+
readonly token: Address;
|
|
26
|
+
readonly fundedAmount: bigint;
|
|
27
|
+
readonly nativeAmount?: bigint;
|
|
28
|
+
}) => bigint;
|
|
29
|
+
/** Parses the lower amount bound independently of ABI encoding limits. @internal */
|
|
30
|
+
export declare const parseNonnegative: (field: string, value: bigint) => bigint;
|
|
31
|
+
/** Completes a nonnegative amount with its ABI upper bound. @internal */
|
|
32
|
+
export declare const parseUint256Max: (field: string, value: bigint) => bigint;
|
|
33
|
+
export {};
|