@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
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { AccrualPosition, Market } from "@morpho-org/midnight-sdk";
|
|
2
|
+
import { type Address, type Hex } from "viem";
|
|
3
|
+
import { parseMidnightCancelOffers } from "../../actions/midnight/cancelOffers.js";
|
|
4
|
+
import { type ParsedMidnightSupplyCollateralBatchPreparation, type ParsedMidnightWithdrawCollateralBatchPreparation } from "../../actions/midnight/parseCollateralBatch.js";
|
|
5
|
+
import { type ParsedMidnightRedeem } from "../../actions/midnight/redeem.js";
|
|
6
|
+
import { parseMidnightRepayWithdrawCollateral } from "../../actions/midnight/repayWithdrawCollateral.js";
|
|
7
|
+
import { parseMidnightSupplyCollateralPreparation } from "../../actions/midnight/supplyCollateral.js";
|
|
8
|
+
import { parseMidnightSupplyCollateralTakeBorrow } from "../../actions/midnight/supplyCollateralTakeBorrow.js";
|
|
9
|
+
import { parseMidnightTakeBorrow } from "../../actions/midnight/takeBorrow.js";
|
|
10
|
+
import { parseMidnightTakeLend } from "../../actions/midnight/takeLend.js";
|
|
11
|
+
import { parseMidnightTakeRepayWithdrawCollateral } from "../../actions/midnight/takeRepayWithdrawCollateral.js";
|
|
12
|
+
import { parseMidnightTakeWithdraw } from "../../actions/midnight/takeWithdraw.js";
|
|
13
|
+
import { type ParsedMidnightWithdrawCollateral } from "../../actions/midnight/withdrawCollateral.js";
|
|
14
|
+
import type { MorphoClientType } from "../../types/client.js";
|
|
15
|
+
import type { RedeemParams, RepayWithdrawCollateralParams, SupplyCollateralBatchParams, SupplyCollateralParams, SupplyCollateralTakeBorrowParams, TakeBorrowParams, TakeLendParams, TakeRepayWithdrawCollateralParams, TakeWithdrawParams, WithdrawCollateralBatchParams, WithdrawCollateralParams } from "./types.js";
|
|
16
|
+
/** Checks entity snapshot bindings without depending on the entity layer. @internal */
|
|
17
|
+
export { validateMidnightPositionBinding as validatePositionBinding } from "../../helpers/parseMidnight.js";
|
|
18
|
+
type Context = {
|
|
19
|
+
readonly client: MorphoClientType;
|
|
20
|
+
readonly chainId: number;
|
|
21
|
+
};
|
|
22
|
+
type ParsedTakeLendParams = {
|
|
23
|
+
readonly now?: bigint;
|
|
24
|
+
} & ReturnType<typeof parseMidnightTakeLend> & Pick<TakeLendParams, "accountAddress" | "marketData">;
|
|
25
|
+
type ParsedTakeBorrowParams = {
|
|
26
|
+
readonly now?: bigint;
|
|
27
|
+
} & ReturnType<typeof parseMidnightTakeBorrow> & Pick<TakeBorrowParams, "accountAddress" | "marketData" | "positionData" | "collateralPrices">;
|
|
28
|
+
type ParsedTakeWithdrawParams = {
|
|
29
|
+
readonly now?: bigint;
|
|
30
|
+
} & ReturnType<typeof parseMidnightTakeWithdraw> & Pick<TakeWithdrawParams, "accountAddress" | "marketData">;
|
|
31
|
+
type ParsedSupplyCollateralTakeBorrowParams = {
|
|
32
|
+
readonly now?: bigint;
|
|
33
|
+
} & ReturnType<typeof parseMidnightSupplyCollateralTakeBorrow> & Pick<SupplyCollateralTakeBorrowParams, "accountAddress" | "marketData" | "positionData" | "collateralPrices">;
|
|
34
|
+
type ParsedTakeRepayWithdrawCollateralParams = {
|
|
35
|
+
readonly now?: bigint;
|
|
36
|
+
} & ReturnType<typeof parseMidnightTakeRepayWithdrawCollateral> & Pick<TakeRepayWithdrawCollateralParams, "accountAddress" | "marketData" | "positionData" | "collateralPrices">;
|
|
37
|
+
type ParsedRepayWithdrawCollateralParams = {
|
|
38
|
+
readonly now?: bigint;
|
|
39
|
+
} & ReturnType<typeof parseMidnightRepayWithdrawCollateral> & Pick<RepayWithdrawCollateralParams, "accountAddress" | "marketData" | "positionData" | "collateralPrices">;
|
|
40
|
+
type ParsedCancelOffersParams = ReturnType<typeof parseMidnightCancelOffers>;
|
|
41
|
+
/** Owns complete entity lend params; reuses the standalone static constructor. @internal */
|
|
42
|
+
export declare const parseTakeLendParams: (params: TakeLendParams, { client, chainId }: Context) => ParsedTakeLendParams;
|
|
43
|
+
/** Owns complete entity borrow params, including receiver defaults. @internal */
|
|
44
|
+
export declare const parseTakeBorrowParams: (params: TakeBorrowParams, { client, chainId }: Context) => ParsedTakeBorrowParams;
|
|
45
|
+
/** Owns complete entity credit-exit params. @internal */
|
|
46
|
+
export declare const parseTakeWithdrawParams: (params: TakeWithdrawParams, { client, chainId }: Context) => ParsedTakeWithdrawParams;
|
|
47
|
+
/** Owns complete entity collateral-funded borrow params. @internal */
|
|
48
|
+
export declare const parseSupplyCollateralTakeBorrowParams: (params: SupplyCollateralTakeBorrowParams, { client, chainId }: Context) => ParsedSupplyCollateralTakeBorrowParams;
|
|
49
|
+
/** Owns complete entity taker repayment params and withdrawal defaults. @internal */
|
|
50
|
+
export declare const parseTakeRepayWithdrawCollateralParams: (params: TakeRepayWithdrawCollateralParams, { client, chainId }: Context) => ParsedTakeRepayWithdrawCollateralParams;
|
|
51
|
+
/** Owns complete entity direct repayment params without re-entering a public builder. @internal */
|
|
52
|
+
export declare const parseRepayWithdrawCollateralParams: (params: RepayWithdrawCollateralParams, { client, chainId }: Context) => ParsedRepayWithdrawCollateralParams;
|
|
53
|
+
/** Owns supply amount, reserve and collateral; preserves the lazy zero-owner error. @internal */
|
|
54
|
+
export declare const parseSupplyCollateralParams: (params: SupplyCollateralParams, { client, chainId }: Context) => ReturnType<typeof parseMidnightSupplyCollateralPreparation>;
|
|
55
|
+
/** Owns complete entity supply batch inputs and lazy construction failures. @internal */
|
|
56
|
+
export declare const parseSupplyCollateralBatchParams: (params: SupplyCollateralBatchParams, { client, chainId }: Context) => ParsedMidnightSupplyCollateralBatchPreparation;
|
|
57
|
+
/** Owns withdrawal batch binding, index-before-amount resolution and complete action inputs. @internal */
|
|
58
|
+
export declare const parseWithdrawCollateralBatchParams: (params: WithdrawCollateralBatchParams, { client, chainId }: Context) => ParsedMidnightWithdrawCollateralBatchPreparation;
|
|
59
|
+
/** Owns max-amount resolution, owner, market, collateral and receiver constraints. @internal */
|
|
60
|
+
export declare const parseWithdrawCollateralParams: (params: WithdrawCollateralParams, { client, chainId }: Context) => ParsedMidnightWithdrawCollateral & {
|
|
61
|
+
readonly accountAddress: Address;
|
|
62
|
+
readonly marketData: Market;
|
|
63
|
+
readonly positionData: AccrualPosition;
|
|
64
|
+
readonly collateralPrices: WithdrawCollateralParams["collateralPrices"];
|
|
65
|
+
readonly available: bigint;
|
|
66
|
+
};
|
|
67
|
+
/** Owns redemption defaults and snapshot-dependent amount constraints in their existing order. @internal */
|
|
68
|
+
export declare const parseRedeemParams: (params: RedeemParams, { client, chainId }: Context) => ParsedMidnightRedeem;
|
|
69
|
+
/** Owns the complete cancellation intent, including its distinct account error. @internal */
|
|
70
|
+
export declare const parseCancelOffersParams: (params: {
|
|
71
|
+
readonly accountAddress: Address;
|
|
72
|
+
readonly groups: readonly Hex[];
|
|
73
|
+
readonly now?: bigint;
|
|
74
|
+
}, { client, chainId }: Context) => ParsedCancelOffersParams;
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { MathLib } from "@morpho-org/blue-sdk";
|
|
2
|
+
import { Time } from "@morpho-org/morpho-ts";
|
|
3
|
+
import { isAddress, isAddressEqual, maxUint256, zeroAddress, } from "viem";
|
|
4
|
+
import { parseMidnightCancelOffers } from "../../actions/midnight/cancelOffers.js";
|
|
5
|
+
import { parseMidnightSupplyCollateralBatchPreparation, parseMidnightWithdrawCollateralBatchPreparation, } from "../../actions/midnight/parseCollateralBatch.js";
|
|
6
|
+
import { parseMidnightRedeem, } from "../../actions/midnight/redeem.js";
|
|
7
|
+
import { parseMidnightRepayWithdrawCollateral } from "../../actions/midnight/repayWithdrawCollateral.js";
|
|
8
|
+
import { parseMidnightSupplyCollateralPreparation } from "../../actions/midnight/supplyCollateral.js";
|
|
9
|
+
import { parseMidnightSupplyCollateralTakeBorrow } from "../../actions/midnight/supplyCollateralTakeBorrow.js";
|
|
10
|
+
import { parseMidnightTakeBorrow } from "../../actions/midnight/takeBorrow.js";
|
|
11
|
+
import { parseMidnightTakeLend } from "../../actions/midnight/takeLend.js";
|
|
12
|
+
import { parseMidnightTakeRepayWithdrawCollateral } from "../../actions/midnight/takeRepayWithdrawCollateral.js";
|
|
13
|
+
import { parseMidnightTakeWithdraw } from "../../actions/midnight/takeWithdraw.js";
|
|
14
|
+
import { parseMidnightWithdrawCollateral, } from "../../actions/midnight/withdrawCollateral.js";
|
|
15
|
+
import { MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS } from "../../helpers/constant.js";
|
|
16
|
+
import { validateChainId } from "../../helpers/index.js";
|
|
17
|
+
import { resolveTransactionMetadata } from "../../helpers/metadata.js";
|
|
18
|
+
import { parseMidnightAccount, parseMidnightAddress, parseMidnightCollateral, parseMidnightMarket, parseMidnightPositiveAmount, validateMidnightPositionBinding as validatePositionBinding, } from "../../helpers/parseMidnight.js";
|
|
19
|
+
import { validateMidnightAddress } from "../../helpers/validateMidnightAccount.js";
|
|
20
|
+
import { AccrualPositionUserMismatchError, InsufficientMidnightWithdrawableLiquidityError, MidnightInvalidAccountAddressError, MidnightRedeemExceedsCreditError, MidnightTakeDeadlineTooFarError, MissingAccrualPositionError, NoMidnightCreditToRedeemError, } from "../../types/index.js";
|
|
21
|
+
import { validateMidnightDeadline } from "./deadline.js";
|
|
22
|
+
/** Checks entity snapshot bindings without depending on the entity layer. @internal */
|
|
23
|
+
export { validateMidnightPositionBinding as validatePositionBinding } from "../../helpers/parseMidnight.js";
|
|
24
|
+
const validateTakeDeadlineWindow = (deadline, now = Time.timestamp()) => {
|
|
25
|
+
// Freshness is checked at this invocation, not certified by the static action contract.
|
|
26
|
+
validateMidnightDeadline(deadline, now);
|
|
27
|
+
const maxDeadline = now + MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS;
|
|
28
|
+
if (deadline > maxDeadline) {
|
|
29
|
+
throw new MidnightTakeDeadlineTooFarError({ deadline, maxDeadline });
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
/** Owns complete entity lend params; reuses the standalone static constructor. @internal */
|
|
33
|
+
export const parseTakeLendParams = (params, { client, chainId }) => {
|
|
34
|
+
const metadata = resolveTransactionMetadata(client.options.metadata, params.now);
|
|
35
|
+
validateChainId(client.viemClient.chain?.id, chainId);
|
|
36
|
+
const accountAddress = parseMidnightAccount("accountAddress", params.accountAddress);
|
|
37
|
+
validateTakeDeadlineWindow(params.deadline, params.now);
|
|
38
|
+
const action = parseMidnightTakeLend({
|
|
39
|
+
chainId,
|
|
40
|
+
market: params.marketData.params,
|
|
41
|
+
target: params.target,
|
|
42
|
+
takeableOffers: params.takeableOffers,
|
|
43
|
+
deadline: params.deadline,
|
|
44
|
+
maxContinuousFee: params.maxContinuousFee,
|
|
45
|
+
nativeAmount: params.nativeAmount,
|
|
46
|
+
referralFeePct: params.referralFeePct,
|
|
47
|
+
referralFeeRecipient: params.referralFeeRecipient,
|
|
48
|
+
metadata,
|
|
49
|
+
});
|
|
50
|
+
return Object.freeze({
|
|
51
|
+
...action,
|
|
52
|
+
now: params.now,
|
|
53
|
+
accountAddress,
|
|
54
|
+
marketData: params.marketData,
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
/** Owns complete entity borrow params, including receiver defaults. @internal */
|
|
58
|
+
export const parseTakeBorrowParams = (params, { client, chainId }) => {
|
|
59
|
+
const metadata = resolveTransactionMetadata(client.options.metadata, params.now);
|
|
60
|
+
validateChainId(client.viemClient.chain?.id, chainId);
|
|
61
|
+
const accountAddress = parseMidnightAccount("accountAddress", params.accountAddress);
|
|
62
|
+
validateTakeDeadlineWindow(params.deadline, params.now);
|
|
63
|
+
const action = parseMidnightTakeBorrow({
|
|
64
|
+
chainId,
|
|
65
|
+
market: params.marketData.params,
|
|
66
|
+
target: params.target,
|
|
67
|
+
takeableOffers: params.takeableOffers,
|
|
68
|
+
deadline: params.deadline,
|
|
69
|
+
receiver: params.receiver ?? accountAddress,
|
|
70
|
+
referralFeePct: params.referralFeePct,
|
|
71
|
+
referralFeeRecipient: params.referralFeeRecipient,
|
|
72
|
+
metadata,
|
|
73
|
+
});
|
|
74
|
+
return Object.freeze({
|
|
75
|
+
...action,
|
|
76
|
+
now: params.now,
|
|
77
|
+
accountAddress,
|
|
78
|
+
marketData: params.marketData,
|
|
79
|
+
positionData: params.positionData,
|
|
80
|
+
collateralPrices: params.collateralPrices,
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
/** Owns complete entity credit-exit params. @internal */
|
|
84
|
+
export const parseTakeWithdrawParams = (params, { client, chainId }) => {
|
|
85
|
+
const metadata = resolveTransactionMetadata(client.options.metadata, params.now);
|
|
86
|
+
validateChainId(client.viemClient.chain?.id, chainId);
|
|
87
|
+
const accountAddress = parseMidnightAccount("accountAddress", params.accountAddress);
|
|
88
|
+
validateTakeDeadlineWindow(params.deadline, params.now);
|
|
89
|
+
const action = parseMidnightTakeWithdraw({
|
|
90
|
+
chainId,
|
|
91
|
+
market: params.marketData.params,
|
|
92
|
+
target: params.target,
|
|
93
|
+
takeableOffers: params.takeableOffers,
|
|
94
|
+
deadline: params.deadline,
|
|
95
|
+
receiver: params.receiver ?? accountAddress,
|
|
96
|
+
referralFeePct: params.referralFeePct,
|
|
97
|
+
referralFeeRecipient: params.referralFeeRecipient,
|
|
98
|
+
metadata,
|
|
99
|
+
});
|
|
100
|
+
return Object.freeze({
|
|
101
|
+
...action,
|
|
102
|
+
now: params.now,
|
|
103
|
+
accountAddress,
|
|
104
|
+
marketData: params.marketData,
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
/** Owns complete entity collateral-funded borrow params. @internal */
|
|
108
|
+
export const parseSupplyCollateralTakeBorrowParams = (params, { client, chainId }) => {
|
|
109
|
+
const metadata = resolveTransactionMetadata(client.options.metadata, params.now);
|
|
110
|
+
validateChainId(client.viemClient.chain?.id, chainId);
|
|
111
|
+
const accountAddress = parseMidnightAccount("accountAddress", params.accountAddress);
|
|
112
|
+
validateTakeDeadlineWindow(params.deadline, params.now);
|
|
113
|
+
const action = parseMidnightSupplyCollateralTakeBorrow({
|
|
114
|
+
chainId,
|
|
115
|
+
market: params.marketData.params,
|
|
116
|
+
target: params.target,
|
|
117
|
+
takeableOffers: params.takeableOffers,
|
|
118
|
+
deadline: params.deadline,
|
|
119
|
+
receiver: params.receiver ?? accountAddress,
|
|
120
|
+
collateralSupplies: params.collateralSupplies,
|
|
121
|
+
nativeAmount: params.nativeAmount,
|
|
122
|
+
referralFeePct: params.referralFeePct,
|
|
123
|
+
referralFeeRecipient: params.referralFeeRecipient,
|
|
124
|
+
metadata,
|
|
125
|
+
});
|
|
126
|
+
return Object.freeze({
|
|
127
|
+
...action,
|
|
128
|
+
now: params.now,
|
|
129
|
+
accountAddress,
|
|
130
|
+
marketData: params.marketData,
|
|
131
|
+
positionData: params.positionData,
|
|
132
|
+
collateralPrices: params.collateralPrices,
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
/** Owns complete entity taker repayment params and withdrawal defaults. @internal */
|
|
136
|
+
export const parseTakeRepayWithdrawCollateralParams = (params, { client, chainId }) => {
|
|
137
|
+
const metadata = resolveTransactionMetadata(client.options.metadata, params.now);
|
|
138
|
+
validateChainId(client.viemClient.chain?.id, chainId);
|
|
139
|
+
const accountAddress = parseMidnightAccount("accountAddress", params.accountAddress);
|
|
140
|
+
validateTakeDeadlineWindow(params.deadline, params.now);
|
|
141
|
+
const action = parseMidnightTakeRepayWithdrawCollateral({
|
|
142
|
+
chainId,
|
|
143
|
+
market: params.marketData.params,
|
|
144
|
+
target: params.target,
|
|
145
|
+
takeableOffers: params.takeableOffers,
|
|
146
|
+
deadline: params.deadline,
|
|
147
|
+
maxContinuousFee: params.maxContinuousFee,
|
|
148
|
+
repayEnabled: params.repayEnabled,
|
|
149
|
+
nativeAmount: params.nativeAmount,
|
|
150
|
+
collateralWithdrawals: params.collateralWithdrawals ?? [],
|
|
151
|
+
collateralReceiver: params.collateralReceiver ?? accountAddress,
|
|
152
|
+
referralFeePct: params.referralFeePct,
|
|
153
|
+
referralFeeRecipient: params.referralFeeRecipient,
|
|
154
|
+
metadata,
|
|
155
|
+
});
|
|
156
|
+
return Object.freeze({
|
|
157
|
+
...action,
|
|
158
|
+
now: params.now,
|
|
159
|
+
accountAddress,
|
|
160
|
+
marketData: params.marketData,
|
|
161
|
+
positionData: params.positionData,
|
|
162
|
+
collateralPrices: params.collateralPrices,
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
/** Owns complete entity direct repayment params without re-entering a public builder. @internal */
|
|
166
|
+
export const parseRepayWithdrawCollateralParams = (params, { client, chainId }) => {
|
|
167
|
+
const metadata = resolveTransactionMetadata(client.options.metadata, params.now);
|
|
168
|
+
validateChainId(client.viemClient.chain?.id, chainId);
|
|
169
|
+
const accountAddress = parseMidnightAccount("accountAddress", params.accountAddress);
|
|
170
|
+
// Preserve account, local deadline, then standalone static guard precedence.
|
|
171
|
+
validateMidnightDeadline(params.deadline, params.now);
|
|
172
|
+
const action = parseMidnightRepayWithdrawCollateral({
|
|
173
|
+
chainId,
|
|
174
|
+
market: params.marketData.params,
|
|
175
|
+
repay: params.repay,
|
|
176
|
+
deadline: params.deadline,
|
|
177
|
+
nativeAmount: params.nativeAmount,
|
|
178
|
+
collateralWithdrawals: params.collateralWithdrawals ?? [],
|
|
179
|
+
collateralReceiver: params.collateralReceiver ?? accountAddress,
|
|
180
|
+
metadata,
|
|
181
|
+
});
|
|
182
|
+
return Object.freeze({
|
|
183
|
+
...action,
|
|
184
|
+
now: params.now,
|
|
185
|
+
accountAddress,
|
|
186
|
+
marketData: params.marketData,
|
|
187
|
+
positionData: params.positionData,
|
|
188
|
+
collateralPrices: params.collateralPrices,
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
/** Owns supply amount, reserve and collateral; preserves the lazy zero-owner error. @internal */
|
|
192
|
+
export const parseSupplyCollateralParams = (params, { client, chainId }) => {
|
|
193
|
+
const metadata = resolveTransactionMetadata(client.options.metadata, params.now);
|
|
194
|
+
validateChainId(client.viemClient.chain?.id, chainId);
|
|
195
|
+
return parseMidnightSupplyCollateralPreparation({
|
|
196
|
+
chainId,
|
|
197
|
+
market: params.marketData,
|
|
198
|
+
accountAddress: params.accountAddress,
|
|
199
|
+
collateralAssets: params.collateralAssets,
|
|
200
|
+
reservedCollateralAssets: params.reservedCollateralAssets,
|
|
201
|
+
collateralIndex: params.collateralIndex,
|
|
202
|
+
metadata,
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
/** Owns complete entity supply batch inputs and lazy construction failures. @internal */
|
|
206
|
+
export const parseSupplyCollateralBatchParams = (params, { client, chainId }) => {
|
|
207
|
+
const metadata = resolveTransactionMetadata(client.options.metadata, params.now);
|
|
208
|
+
validateChainId(client.viemClient.chain?.id, chainId);
|
|
209
|
+
return parseMidnightSupplyCollateralBatchPreparation({
|
|
210
|
+
chainId,
|
|
211
|
+
market: params.marketData,
|
|
212
|
+
accountAddress: params.accountAddress,
|
|
213
|
+
collateralSupplies: params.collateralSupplies,
|
|
214
|
+
metadata,
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
/** Owns withdrawal batch binding, index-before-amount resolution and complete action inputs. @internal */
|
|
218
|
+
export const parseWithdrawCollateralBatchParams = (params, { client, chainId }) => {
|
|
219
|
+
const metadata = resolveTransactionMetadata(client.options.metadata, params.now);
|
|
220
|
+
validateChainId(client.viemClient.chain?.id, chainId);
|
|
221
|
+
return parseMidnightWithdrawCollateralBatchPreparation({
|
|
222
|
+
...params,
|
|
223
|
+
chainId,
|
|
224
|
+
metadata,
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
/** Owns max-amount resolution, owner, market, collateral and receiver constraints. @internal */
|
|
228
|
+
export const parseWithdrawCollateralParams = (params, { client, chainId }) => {
|
|
229
|
+
const metadata = resolveTransactionMetadata(client.options.metadata, params.now);
|
|
230
|
+
validateChainId(client.viemClient.chain?.id, chainId);
|
|
231
|
+
const onBehalf = parseMidnightAccount("accountAddress", params.accountAddress);
|
|
232
|
+
const market = parseMidnightMarket(params.marketData, chainId);
|
|
233
|
+
// Position binding precedes collateral lookup at this boundary.
|
|
234
|
+
validatePositionBinding(params);
|
|
235
|
+
const collateral = parseMidnightCollateral(market, params.collateralIndex ?? 0n);
|
|
236
|
+
const available = params.positionData.collateral[Number(collateral.index)] ?? 0n;
|
|
237
|
+
const action = parseMidnightWithdrawCollateral({
|
|
238
|
+
chainId,
|
|
239
|
+
market: market.struct,
|
|
240
|
+
assets: params.assets === maxUint256 ? available : params.assets,
|
|
241
|
+
onBehalf,
|
|
242
|
+
receiver: params.receiver ?? onBehalf,
|
|
243
|
+
collateralIndex: collateral.index,
|
|
244
|
+
metadata,
|
|
245
|
+
});
|
|
246
|
+
return Object.freeze({
|
|
247
|
+
...action,
|
|
248
|
+
now: params.now,
|
|
249
|
+
available,
|
|
250
|
+
accountAddress: onBehalf,
|
|
251
|
+
marketData: params.marketData,
|
|
252
|
+
positionData: params.positionData,
|
|
253
|
+
collateralPrices: params.collateralPrices,
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
/** Owns redemption defaults and snapshot-dependent amount constraints in their existing order. @internal */
|
|
257
|
+
export const parseRedeemParams = (params, { client, chainId }) => {
|
|
258
|
+
const metadata = resolveTransactionMetadata(client.options.metadata, params.now);
|
|
259
|
+
validateChainId(client.viemClient.chain?.id, chainId);
|
|
260
|
+
const address = parseMidnightAddress("accountAddress", params.accountAddress);
|
|
261
|
+
if (!params.positionData) {
|
|
262
|
+
throw new MissingAccrualPositionError();
|
|
263
|
+
}
|
|
264
|
+
if (params.positionData.user != null) {
|
|
265
|
+
validateMidnightAddress("positionData.user", params.positionData.user);
|
|
266
|
+
}
|
|
267
|
+
if (params.positionData.user == null ||
|
|
268
|
+
!isAddressEqual(params.positionData.user, address)) {
|
|
269
|
+
throw new AccrualPositionUserMismatchError(params.positionData.user ?? "unbound", address);
|
|
270
|
+
}
|
|
271
|
+
const marketData = params.positionData.market;
|
|
272
|
+
// Reject market/deployment errors before snapshot accrual and amount checks.
|
|
273
|
+
const market = parseMidnightMarket(marketData, chainId);
|
|
274
|
+
const accrued = params.positionData.accrueInterest(MathLib.max(params.now ?? Time.timestamp(), params.positionData.lastAccrual));
|
|
275
|
+
const units = params.units ?? accrued.faceValue;
|
|
276
|
+
if (params.units === undefined && units <= 0n) {
|
|
277
|
+
throw new NoMidnightCreditToRedeemError(marketData.id);
|
|
278
|
+
}
|
|
279
|
+
// Bound the resolved amount before checking credit and liquidity.
|
|
280
|
+
parseMidnightPositiveAmount("units", units);
|
|
281
|
+
if (accrued.credit < units) {
|
|
282
|
+
throw new MidnightRedeemExceedsCreditError({
|
|
283
|
+
market: marketData.id,
|
|
284
|
+
units,
|
|
285
|
+
credit: accrued.credit,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
if (marketData.withdrawable < units) {
|
|
289
|
+
throw new InsufficientMidnightWithdrawableLiquidityError({
|
|
290
|
+
market: marketData.id,
|
|
291
|
+
units,
|
|
292
|
+
withdrawable: marketData.withdrawable,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
// The owning action constructor mints the complete contract only after snapshot checks.
|
|
296
|
+
return parseMidnightRedeem({
|
|
297
|
+
chainId,
|
|
298
|
+
market: market.struct,
|
|
299
|
+
units,
|
|
300
|
+
onBehalf: address,
|
|
301
|
+
receiver: params.receiver ?? address,
|
|
302
|
+
metadata,
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
/** Owns the complete cancellation intent, including its distinct account error. @internal */
|
|
306
|
+
export const parseCancelOffersParams = (params, { client, chainId }) => {
|
|
307
|
+
const metadata = resolveTransactionMetadata(client.options.metadata, params.now);
|
|
308
|
+
validateChainId(client.viemClient.chain?.id, chainId);
|
|
309
|
+
const { accountAddress } = params;
|
|
310
|
+
if (!isAddress(accountAddress) ||
|
|
311
|
+
isAddressEqual(accountAddress, zeroAddress)) {
|
|
312
|
+
throw new MidnightInvalidAccountAddressError(accountAddress);
|
|
313
|
+
}
|
|
314
|
+
return parseMidnightCancelOffers({
|
|
315
|
+
chainId,
|
|
316
|
+
groups: params.groups,
|
|
317
|
+
onBehalf: accountAddress,
|
|
318
|
+
metadata,
|
|
319
|
+
});
|
|
320
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import { parseMidnightCancelAndMake } from "../../actions/midnight/cancelAndMake.js";
|
|
3
|
+
import { type ChainCheck } from "../../actions/requirements/chainCheck.js";
|
|
4
|
+
import type { MorphoClientType } from "../../types/client.js";
|
|
5
|
+
import type { GetOffersDataParams, MakeLendParams, MakeOffersParams, OffersData, SupplyBlueMakeLendParams, SupplyCollateralMakeBorrowParams } from "./types.js";
|
|
6
|
+
type Context = {
|
|
7
|
+
readonly client: MorphoClientType;
|
|
8
|
+
readonly chainId: number;
|
|
9
|
+
};
|
|
10
|
+
declare const offersParams: unique symbol;
|
|
11
|
+
declare const preparedMake: unique symbol;
|
|
12
|
+
interface PreparedMakeParams<Operation extends string> {
|
|
13
|
+
readonly action: ReturnType<typeof parseMidnightCancelAndMake>;
|
|
14
|
+
readonly data: OffersData;
|
|
15
|
+
readonly [preparedMake]: Operation;
|
|
16
|
+
}
|
|
17
|
+
type Funding = {
|
|
18
|
+
readonly loanToken: Address;
|
|
19
|
+
readonly approvalAmount: bigint;
|
|
20
|
+
};
|
|
21
|
+
/** Validates the complete raw publication request before state reads. @internal */
|
|
22
|
+
export declare const parseGetOffersDataParams: (params: GetOffersDataParams, { client, chainId }: Context) => Readonly<{
|
|
23
|
+
tree: import("@morpho-org/midnight-sdk").Tree<"priceV1"> | import("@morpho-org/midnight-sdk").Tree<"rateV1">;
|
|
24
|
+
accountAddress: `0x${string}`;
|
|
25
|
+
ratifier: `0x${string}`;
|
|
26
|
+
ratifierType: "priceV1" | "rateV1";
|
|
27
|
+
validation: false | import("./types.js").OfferValidationParams | undefined;
|
|
28
|
+
[offersParams]: true;
|
|
29
|
+
}>;
|
|
30
|
+
/** Reads publication state only from the complete constructed request. @internal */
|
|
31
|
+
export declare const getOffersDataInternal: (params: ReturnType<typeof parseGetOffersDataParams>, { client, chainId, marketCreationTime, chainCheck, }: Context & {
|
|
32
|
+
readonly marketCreationTime?: "expiry" | "now";
|
|
33
|
+
readonly chainCheck?: ChainCheck;
|
|
34
|
+
}) => Promise<OffersData>;
|
|
35
|
+
/** Constructs the complete lend publication and requirement inputs from raw params. @internal */
|
|
36
|
+
export declare const parseMakeLendParams: (params: MakeLendParams, context: Context) => Promise<PreparedMakeParams<"makeLend"> & Funding>;
|
|
37
|
+
/** Constructs the complete reduce-only repayment publication from raw params. @internal */
|
|
38
|
+
export declare const parseMakeRepayParams: (params: MakeLendParams, context: Context) => Promise<PreparedMakeParams<"makeRepay"> & Funding>;
|
|
39
|
+
/** Constructs the complete borrow publication from raw params. @internal */
|
|
40
|
+
export declare const parseMakeBorrowParams: (params: MakeOffersParams, context: Context) => Promise<PreparedMakeParams<"makeBorrow">>;
|
|
41
|
+
/** Constructs the complete reduce-only credit-exit publication from raw params. @internal */
|
|
42
|
+
export declare const parseMakeWithdrawParams: (params: MakeOffersParams, context: Context) => Promise<PreparedMakeParams<"makeWithdraw">>;
|
|
43
|
+
/** Constructs a complete Blue-funded publication while preserving its RPC/error order. @internal */
|
|
44
|
+
export declare const parseSupplyBlueMakeLendParams: (params: SupplyBlueMakeLendParams, context: Context) => Promise<PreparedMakeParams<"supplyBlueMakeLend"> & Funding>;
|
|
45
|
+
/** Constructs the complete collateral-funded borrow publication from its raw request. @internal */
|
|
46
|
+
export declare const parseSupplyCollateralMakeBorrowParams: (params: SupplyCollateralMakeBorrowParams, context: Context) => Promise<PreparedMakeParams<"supplyCollateralMakeBorrow">>;
|
|
47
|
+
export {};
|