@morpho-org/morpho-sdk 9.8.0 → 10.0.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/MIGRATION-v9-to-v10.md +114 -0
- package/README.md +109 -13
- package/lib/cjs/actions/blue/common.js +4 -2
- package/lib/cjs/actions/blue/withdrawBuyCallback.js +2 -1
- package/lib/cjs/actions/bundles/common.js +20 -14
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +3 -4
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +3 -2
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +2 -1
- package/lib/cjs/actions/midnight/cancelAndMake.js +2 -1
- package/lib/cjs/actions/midnight/cancelOffers.d.ts +54 -0
- package/lib/cjs/actions/midnight/cancelOffers.js +108 -0
- package/lib/cjs/actions/midnight/index.d.ts +1 -0
- package/lib/cjs/actions/midnight/index.js +1 -0
- package/lib/cjs/actions/midnight/supplyCollateralBatch.js +4 -2
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +1 -1
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +3 -2
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +1 -1
- package/lib/cjs/actions/midnight/takeBorrow.js +3 -2
- package/lib/cjs/actions/midnight/takeLend.d.ts +1 -1
- package/lib/cjs/actions/midnight/takeLend.js +3 -2
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +3 -2
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +1 -1
- package/lib/cjs/actions/midnight/takeWithdraw.js +3 -2
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +4 -2
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -4
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -1
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +4 -6
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +3 -3
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +3 -3
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +5 -13
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +3 -5
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +26 -23
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +2 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +2 -1
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +6 -3
- package/lib/cjs/actions/vaultV1/migrateToV2.js +1 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +4 -2
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +4 -2
- package/lib/cjs/entities/blue/blue.d.ts +34 -28
- package/lib/cjs/entities/blue/blue.js +107 -77
- package/lib/cjs/entities/midnight/deadline.d.ts +2 -2
- package/lib/cjs/entities/midnight/deadline.js +4 -3
- package/lib/cjs/entities/midnight/midnight.d.ts +49 -51
- package/lib/cjs/entities/midnight/midnight.js +158 -138
- package/lib/cjs/entities/midnight/publication.d.ts +2 -0
- package/lib/cjs/entities/midnight/publication.js +193 -138
- package/lib/cjs/entities/midnight/types.d.ts +4 -4
- package/lib/cjs/entities/requirements/assertContractCode.js +4 -2
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +3 -5
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +24 -28
- package/lib/cjs/entities/requirements/getErc2612Permit.js +10 -5
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -4
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
- package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.d.ts +21 -0
- package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.js +111 -0
- package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.d.ts +20 -0
- package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.js +76 -0
- package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.d.ts +21 -0
- package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.js +93 -0
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.d.ts +25 -0
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.js +85 -0
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +20 -0
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +37 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +12 -12
- package/lib/cjs/entities/vaultV1/vaultV1.js +90 -194
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.d.ts +25 -0
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.js +189 -0
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.d.ts +28 -0
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.js +110 -0
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +16 -16
- package/lib/cjs/entities/vaultV2/vaultV2.js +94 -385
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +14 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +1599 -883
- package/lib/cjs/errors.d.ts +1 -1
- package/lib/cjs/errors.js +2 -1
- package/lib/cjs/helpers/deadShares.js +83 -47
- package/lib/cjs/helpers/encodeMidnightCalldata.js +4 -2
- package/lib/cjs/helpers/metadata.d.ts +14 -2
- package/lib/cjs/helpers/metadata.js +49 -8
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +44 -27
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +11 -2
- package/lib/cjs/helpers/utilization.js +10 -5
- package/lib/cjs/helpers/validate.js +88 -67
- package/lib/cjs/helpers/validateMidnightBounds.js +2 -1
- package/lib/cjs/helpers/validateMidnightCollateralBatch.js +2 -1
- package/lib/cjs/helpers/validateMidnightPublication.js +4 -2
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +177 -104
- package/lib/cjs/helpers/validatePositiveInput.js +2 -1
- package/lib/cjs/helpers/validateTakeableOffers.js +2 -1
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +40 -22
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js +10 -1
- package/lib/cjs/transactionPlan/approval.js +12 -1
- package/lib/cjs/transactionPlan/deposit.d.ts +22 -0
- package/lib/cjs/transactionPlan/deposit.js +139 -0
- package/lib/cjs/transactionPlan/error.d.ts +10 -8
- package/lib/cjs/transactionPlan/error.js +10 -8
- package/lib/cjs/transactionPlan/getTokenPermit.js +2 -1
- package/lib/cjs/transactionPlan/index.d.ts +18 -0
- package/lib/cjs/transactionPlan/index.js +23 -5
- package/lib/cjs/transactionPlan/intent.d.ts +3 -3
- package/lib/cjs/transactionPlan/intent.js +14 -7
- package/lib/cjs/transactionPlan/permit.d.ts +1 -1
- package/lib/cjs/transactionPlan/permit.js +86 -20
- package/lib/cjs/transactionPlan/plan.d.ts +16 -6
- package/lib/cjs/transactionPlan/plan.js +77 -24
- package/lib/cjs/transactionPlan/redeem.d.ts +18 -0
- package/lib/cjs/transactionPlan/redeem.js +63 -0
- package/lib/cjs/transactionPlan/requirements.d.ts +4 -3
- package/lib/cjs/transactionPlan/requirements.js +12 -6
- package/lib/cjs/transactionPlan/serde.d.ts +2 -2
- package/lib/cjs/transactionPlan/serde.js +45 -19
- package/lib/cjs/transactionPlan/shareSpending.d.ts +18 -0
- package/lib/cjs/transactionPlan/shareSpending.js +50 -0
- package/lib/cjs/transactionPlan/types.d.ts +117 -11
- package/lib/cjs/transactionPlan/validateActions.js +11 -1
- package/lib/cjs/transactionPlan/validation.js +6 -3
- package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +93 -0
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +94 -0
- package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.d.ts +96 -0
- package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.js +203 -0
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +94 -0
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +217 -0
- package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +69 -0
- package/lib/cjs/transactionPlan/vaultv1/redeem.js +78 -0
- package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +77 -0
- package/lib/cjs/transactionPlan/vaultv1/withdraw.js +88 -0
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +18 -33
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +19 -143
- package/lib/cjs/transactionPlan/vaultv2/forceRedeem.d.ts +74 -0
- package/lib/cjs/transactionPlan/vaultv2/forceRedeem.js +155 -0
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +98 -0
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +206 -0
- package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.d.ts +113 -0
- package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.js +206 -0
- package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +84 -0
- package/lib/cjs/transactionPlan/vaultv2/redeem.js +86 -0
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +18 -29
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +21 -126
- package/lib/cjs/transactionPlan/version.js +2 -1
- package/lib/cjs/transactionPlan/withdraw.d.ts +18 -0
- package/lib/cjs/transactionPlan/withdraw.js +94 -0
- package/lib/cjs/types/action.d.ts +26 -2
- package/lib/cjs/types/action.js +17 -9
- package/lib/cjs/types/error.d.ts +8 -1
- package/lib/cjs/types/error.js +21 -6
- package/lib/cjs/types/metadata.d.ts +12 -2
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/actions/blue/common.js +4 -2
- package/lib/esm/actions/blue/withdrawBuyCallback.js +2 -1
- package/lib/esm/actions/bundles/common.js +20 -14
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +3 -4
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +3 -2
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +2 -1
- package/lib/esm/actions/midnight/cancelAndMake.js +2 -1
- package/lib/esm/actions/midnight/cancelOffers.d.ts +54 -0
- package/lib/esm/actions/midnight/cancelOffers.js +104 -0
- package/lib/esm/actions/midnight/index.d.ts +1 -0
- package/lib/esm/actions/midnight/index.js +1 -0
- package/lib/esm/actions/midnight/supplyCollateralBatch.js +4 -2
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +1 -1
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +3 -2
- package/lib/esm/actions/midnight/takeBorrow.d.ts +1 -1
- package/lib/esm/actions/midnight/takeBorrow.js +3 -2
- package/lib/esm/actions/midnight/takeLend.d.ts +1 -1
- package/lib/esm/actions/midnight/takeLend.js +3 -2
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +3 -2
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +1 -1
- package/lib/esm/actions/midnight/takeWithdraw.js +3 -2
- package/lib/esm/actions/midnight/withdrawCollateralBatch.js +4 -2
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -4
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -1
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +4 -6
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +3 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -6
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +3 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -6
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +7 -15
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +3 -5
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +26 -23
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +2 -1
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +2 -1
- package/lib/esm/actions/vaultV1/inKindRedeem.js +6 -3
- package/lib/esm/actions/vaultV1/migrateToV2.js +1 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +4 -2
- package/lib/esm/actions/vaultV2/inKindRedeem.js +4 -2
- package/lib/esm/entities/blue/blue.d.ts +34 -28
- package/lib/esm/entities/blue/blue.js +107 -77
- package/lib/esm/entities/midnight/deadline.d.ts +2 -2
- package/lib/esm/entities/midnight/deadline.js +4 -3
- package/lib/esm/entities/midnight/midnight.d.ts +49 -51
- package/lib/esm/entities/midnight/midnight.js +159 -139
- package/lib/esm/entities/midnight/publication.d.ts +2 -0
- package/lib/esm/entities/midnight/publication.js +193 -138
- package/lib/esm/entities/midnight/types.d.ts +4 -4
- package/lib/esm/entities/requirements/assertContractCode.js +4 -2
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +3 -5
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +25 -29
- package/lib/esm/entities/requirements/getErc2612Permit.js +10 -5
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -4
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
- package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.d.ts +21 -0
- package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.js +108 -0
- package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.d.ts +20 -0
- package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.js +73 -0
- package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.d.ts +21 -0
- package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.js +90 -0
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.d.ts +25 -0
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.js +82 -0
- package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +20 -0
- package/lib/esm/entities/vaultV1/migrateToV2Quote.js +34 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +12 -12
- package/lib/esm/entities/vaultV1/vaultV1.js +96 -200
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.d.ts +25 -0
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.js +186 -0
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.d.ts +28 -0
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.js +107 -0
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +16 -16
- package/lib/esm/entities/vaultV2/vaultV2.js +102 -393
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +14 -0
- package/lib/esm/entities/vaultV2BlueReallocationData.js +1599 -883
- package/lib/esm/errors.d.ts +1 -1
- package/lib/esm/errors.js +1 -1
- package/lib/esm/helpers/deadShares.js +83 -47
- package/lib/esm/helpers/encodeMidnightCalldata.js +4 -2
- package/lib/esm/helpers/metadata.d.ts +14 -2
- package/lib/esm/helpers/metadata.js +48 -8
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +44 -27
- package/lib/esm/helpers/previewVaultV2InKindRedeem.js +11 -2
- package/lib/esm/helpers/utilization.js +10 -5
- package/lib/esm/helpers/validate.js +88 -67
- package/lib/esm/helpers/validateMidnightBounds.js +2 -1
- package/lib/esm/helpers/validateMidnightCollateralBatch.js +2 -1
- package/lib/esm/helpers/validateMidnightPublication.js +4 -2
- package/lib/esm/helpers/validateMidnightTakeFeasibility.js +176 -103
- package/lib/esm/helpers/validatePositiveInput.js +2 -1
- package/lib/esm/helpers/validateTakeableOffers.js +2 -1
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +40 -22
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +1 -1
- package/lib/esm/transactionPlan/approval.js +13 -2
- package/lib/esm/transactionPlan/deposit.d.ts +22 -0
- package/lib/esm/transactionPlan/deposit.js +135 -0
- package/lib/esm/transactionPlan/error.d.ts +10 -8
- package/lib/esm/transactionPlan/error.js +10 -8
- package/lib/esm/transactionPlan/getTokenPermit.js +2 -1
- package/lib/esm/transactionPlan/index.d.ts +18 -0
- package/lib/esm/transactionPlan/index.js +9 -0
- package/lib/esm/transactionPlan/intent.d.ts +3 -3
- package/lib/esm/transactionPlan/intent.js +14 -7
- package/lib/esm/transactionPlan/permit.d.ts +1 -1
- package/lib/esm/transactionPlan/permit.js +86 -20
- package/lib/esm/transactionPlan/plan.d.ts +16 -6
- package/lib/esm/transactionPlan/plan.js +73 -20
- package/lib/esm/transactionPlan/redeem.d.ts +18 -0
- package/lib/esm/transactionPlan/redeem.js +59 -0
- package/lib/esm/transactionPlan/requirements.d.ts +4 -3
- package/lib/esm/transactionPlan/requirements.js +12 -6
- package/lib/esm/transactionPlan/serde.d.ts +2 -2
- package/lib/esm/transactionPlan/serde.js +45 -19
- package/lib/esm/transactionPlan/shareSpending.d.ts +18 -0
- package/lib/esm/transactionPlan/shareSpending.js +47 -0
- package/lib/esm/transactionPlan/types.d.ts +117 -11
- package/lib/esm/transactionPlan/validateActions.js +11 -1
- package/lib/esm/transactionPlan/validation.js +6 -3
- package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +93 -0
- package/lib/esm/transactionPlan/vaultv1/deposit.js +90 -0
- package/lib/esm/transactionPlan/vaultv1/inKindRedeem.d.ts +96 -0
- package/lib/esm/transactionPlan/vaultv1/inKindRedeem.js +198 -0
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +94 -0
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +212 -0
- package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +69 -0
- package/lib/esm/transactionPlan/vaultv1/redeem.js +74 -0
- package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +77 -0
- package/lib/esm/transactionPlan/vaultv1/withdraw.js +84 -0
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +18 -33
- package/lib/esm/transactionPlan/vaultv2/deposit.js +21 -144
- package/lib/esm/transactionPlan/vaultv2/forceRedeem.d.ts +74 -0
- package/lib/esm/transactionPlan/vaultv2/forceRedeem.js +150 -0
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +98 -0
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +201 -0
- package/lib/esm/transactionPlan/vaultv2/inKindRedeem.d.ts +113 -0
- package/lib/esm/transactionPlan/vaultv2/inKindRedeem.js +201 -0
- package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +84 -0
- package/lib/esm/transactionPlan/vaultv2/redeem.js +82 -0
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +18 -29
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +23 -127
- package/lib/esm/transactionPlan/version.js +2 -1
- package/lib/esm/transactionPlan/withdraw.d.ts +18 -0
- package/lib/esm/transactionPlan/withdraw.js +90 -0
- package/lib/esm/types/action.d.ts +26 -2
- package/lib/esm/types/action.js +17 -9
- package/lib/esm/types/error.d.ts +8 -1
- package/lib/esm/types/error.js +21 -6
- package/lib/esm/types/metadata.d.ts +12 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +15 -14
|
@@ -11,6 +11,7 @@ const common_js_1 = require("../../actions/blue/common.js");
|
|
|
11
11
|
const index_js_1 = require("../../actions/index.js");
|
|
12
12
|
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
13
13
|
const index_js_2 = require("../../helpers/index.js");
|
|
14
|
+
const metadata_js_1 = require("../../helpers/metadata.js");
|
|
14
15
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
15
16
|
const index_js_3 = require("../../types/index.js");
|
|
16
17
|
const assertContractCode_js_1 = require("../requirements/assertContractCode.js");
|
|
@@ -41,9 +42,9 @@ class MorphoBlue {
|
|
|
41
42
|
throw new index_js_3.ExpiredDeadlineError(deadline, now);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
validateWriteCommon(params) {
|
|
45
|
+
validateWriteCommon(params, now) {
|
|
45
46
|
(0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
|
|
46
|
-
this.validateDeadline(params.deadline);
|
|
47
|
+
this.validateDeadline(params.deadline, now);
|
|
47
48
|
// Resolve at handle creation so unsupported deployments fail before any RPC prerequisite work.
|
|
48
49
|
(0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.blueBundlesV1");
|
|
49
50
|
// Validate the referral inputs eagerly; the normalized result is intentionally discarded here
|
|
@@ -75,8 +76,43 @@ class MorphoBlue {
|
|
|
75
76
|
getMaxLtv(marketParams = this.marketParams) {
|
|
76
77
|
return blue_sdk_1.MathLib.zeroFloorSub(marketParams.lltv, index_js_2.DEFAULT_LLTV_BUFFER);
|
|
77
78
|
}
|
|
78
|
-
getBlueBundlesV1QuoteTimestamp(lastUpdate) {
|
|
79
|
-
return blue_sdk_1.MathLib.max(
|
|
79
|
+
getBlueBundlesV1QuoteTimestamp(lastUpdate, now = morpho_ts_1.Time.timestamp()) {
|
|
80
|
+
return blue_sdk_1.MathLib.max(now, lastUpdate) + morpho_ts_1.Time.s.from.h(2n);
|
|
81
|
+
}
|
|
82
|
+
quoteRepay({ positionData, repayAssets, repayShares, deadline, now, }) {
|
|
83
|
+
const saturatedRepay = repayShares === viem_1.maxUint256;
|
|
84
|
+
const simulatedRepayShares = saturatedRepay
|
|
85
|
+
? positionData.borrowShares
|
|
86
|
+
: repayShares;
|
|
87
|
+
if (repayAssets > 0n) {
|
|
88
|
+
(0, index_js_2.validateRepayAmount)({
|
|
89
|
+
positionData,
|
|
90
|
+
repayAssets,
|
|
91
|
+
marketId: this.marketParams.id,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else if (repayShares > 0n && !saturatedRepay) {
|
|
95
|
+
(0, index_js_2.validateRepayShares)({
|
|
96
|
+
positionData,
|
|
97
|
+
repayShares,
|
|
98
|
+
marketId: this.marketParams.id,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const quoteHorizon = this.getBlueBundlesV1QuoteTimestamp(positionData.market.lastUpdate, now);
|
|
102
|
+
if (repayShares > 0n && deadline > quoteHorizon) {
|
|
103
|
+
throw new index_js_3.InputExceedsMaxError({
|
|
104
|
+
field: "deadline",
|
|
105
|
+
value: deadline,
|
|
106
|
+
max: quoteHorizon,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const accrualTimestamp = repayShares > 0n ? deadline : quoteHorizon;
|
|
110
|
+
const accruedPosition = positionData.accrueInterest(accrualTimestamp);
|
|
111
|
+
let expectedRepayAssets = repayAssets;
|
|
112
|
+
if (repayAssets <= 0n && repayShares > 0n) {
|
|
113
|
+
expectedRepayAssets = accruedPosition.market.toBorrowAssets(simulatedRepayShares, "Up");
|
|
114
|
+
}
|
|
115
|
+
return { simulatedRepayShares, accruedPosition, expectedRepayAssets };
|
|
80
116
|
}
|
|
81
117
|
async getTokenRequirements(params) {
|
|
82
118
|
this.validateDeadline(params.deadline, params.now);
|
|
@@ -121,10 +157,14 @@ class MorphoBlue {
|
|
|
121
157
|
});
|
|
122
158
|
}
|
|
123
159
|
supply(params) {
|
|
160
|
+
const suppliedNow = params.now;
|
|
161
|
+
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, suppliedNow);
|
|
124
162
|
const { userAddress, assets, nativeAmount, deadline, referralFeePct, referralFeeRecipient, } = params;
|
|
125
|
-
|
|
126
|
-
|
|
163
|
+
const createdAt = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
164
|
+
this.validateWriteCommon(params, createdAt);
|
|
165
|
+
if (assets <= 0n) {
|
|
127
166
|
throw new index_js_3.NonPositiveInputError("assets", assets);
|
|
167
|
+
}
|
|
128
168
|
const nativeValue = (0, common_js_1.validateBlueBundlesV1NativeFunding)({
|
|
129
169
|
chainId: this.chainId,
|
|
130
170
|
token: this.marketParams.loanToken,
|
|
@@ -138,11 +178,12 @@ class MorphoBlue {
|
|
|
138
178
|
}
|
|
139
179
|
return {
|
|
140
180
|
getRequirements: (requirementsParams) => {
|
|
141
|
-
const now = morpho_ts_1.Time.timestamp();
|
|
181
|
+
const now = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
142
182
|
this.validateDeadline(deadline, now);
|
|
143
183
|
return this.assertWriteTargets().then(() => {
|
|
144
|
-
if (nativeValue > 0n)
|
|
184
|
+
if (nativeValue > 0n) {
|
|
145
185
|
return [];
|
|
186
|
+
}
|
|
146
187
|
return this.getTokenRequirements({
|
|
147
188
|
token: this.marketParams.loanToken,
|
|
148
189
|
amount: assets,
|
|
@@ -168,21 +209,26 @@ class MorphoBlue {
|
|
|
168
209
|
referralFeeRecipient,
|
|
169
210
|
requirementSignature: token,
|
|
170
211
|
},
|
|
171
|
-
metadata
|
|
212
|
+
metadata,
|
|
172
213
|
});
|
|
173
214
|
},
|
|
174
215
|
};
|
|
175
216
|
}
|
|
176
217
|
/** {@inheritDoc BlueActions.withdraw} */
|
|
177
218
|
withdraw(params) {
|
|
219
|
+
const suppliedNow = params.now;
|
|
220
|
+
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, suppliedNow);
|
|
178
221
|
const { userAddress, positionData, deadline, referralFeePct, referralFeeRecipient, } = params;
|
|
179
|
-
|
|
222
|
+
const createdAt = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
223
|
+
this.validateWriteCommon(params, createdAt);
|
|
180
224
|
const assets = ("assets" in params ? params.assets : undefined) ?? 0n;
|
|
181
225
|
const shares = ("shares" in params ? params.shares : undefined) ?? 0n;
|
|
182
|
-
if (assets < 0n)
|
|
226
|
+
if (assets < 0n) {
|
|
183
227
|
throw new index_js_3.NegativeInputError("assets", assets);
|
|
184
|
-
|
|
228
|
+
}
|
|
229
|
+
if (shares < 0n) {
|
|
185
230
|
throw new index_js_3.NegativeInputError("shares", shares);
|
|
231
|
+
}
|
|
186
232
|
if (assets > 0n && shares > 0n) {
|
|
187
233
|
throw new index_js_3.MutuallyExclusiveWithdrawAmountsError(this.marketParams.id);
|
|
188
234
|
}
|
|
@@ -197,20 +243,13 @@ class MorphoBlue {
|
|
|
197
243
|
expectedMarketId: this.marketParams.id,
|
|
198
244
|
expectedUser: userAddress,
|
|
199
245
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
(0, index_js_2.validateWithdrawAmount)({
|
|
209
|
-
positionData,
|
|
210
|
-
withdrawAssets: assets,
|
|
211
|
-
marketId: this.marketParams.id,
|
|
212
|
-
});
|
|
213
|
-
}
|
|
246
|
+
const validateWithdrawal = shares > 0n ? index_js_2.validateWithdrawShares : index_js_2.validateWithdrawAmount;
|
|
247
|
+
validateWithdrawal({
|
|
248
|
+
positionData,
|
|
249
|
+
withdrawShares: shares,
|
|
250
|
+
withdrawAssets: assets,
|
|
251
|
+
marketId: this.marketParams.id,
|
|
252
|
+
});
|
|
214
253
|
const reallocations = [...(params.reallocations ?? [])];
|
|
215
254
|
// Validate the exact PublicAllocations mapping before requirement reads.
|
|
216
255
|
const publicAllocations = (0, common_js_1.getBlueBundlesV1PublicAllocations)(reallocations, this.marketParams);
|
|
@@ -225,7 +264,7 @@ class MorphoBlue {
|
|
|
225
264
|
}
|
|
226
265
|
return {
|
|
227
266
|
getRequirements: async () => {
|
|
228
|
-
const now = morpho_ts_1.Time.timestamp();
|
|
267
|
+
const now = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
229
268
|
this.validateDeadline(deadline, now);
|
|
230
269
|
await this.assertWriteTargets();
|
|
231
270
|
return this.getAuthorizationRequirements({
|
|
@@ -250,13 +289,14 @@ class MorphoBlue {
|
|
|
250
289
|
referralFeeRecipient,
|
|
251
290
|
authorizationSignature: authorization,
|
|
252
291
|
},
|
|
253
|
-
metadata
|
|
292
|
+
metadata,
|
|
254
293
|
});
|
|
255
294
|
},
|
|
256
295
|
};
|
|
257
296
|
}
|
|
258
297
|
/** {@inheritDoc BlueActions.withdrawBuyCallback} */
|
|
259
298
|
withdrawBuyCallback(params) {
|
|
299
|
+
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, params.now);
|
|
260
300
|
const { userAddress, callbackAddress, positionData } = params;
|
|
261
301
|
(0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
|
|
262
302
|
if (positionData == null) {
|
|
@@ -288,7 +328,7 @@ class MorphoBlue {
|
|
|
288
328
|
const tx = (0, index_js_1.blueWithdrawBuyCallback)({
|
|
289
329
|
market: { chainId: this.chainId, marketParams: this.marketParams },
|
|
290
330
|
args: { callbackAddress, userAddress, shares },
|
|
291
|
-
metadata
|
|
331
|
+
metadata,
|
|
292
332
|
});
|
|
293
333
|
return {
|
|
294
334
|
getRequirements: async () => {
|
|
@@ -341,8 +381,10 @@ class MorphoBlue {
|
|
|
341
381
|
}
|
|
342
382
|
/** {@inheritDoc BlueActions.supplyCollateral} */
|
|
343
383
|
supplyCollateral(params) {
|
|
384
|
+
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, params.now);
|
|
344
385
|
const { userAddress, collateralAssets, nativeAmount, deadline, referralFeePct, referralFeeRecipient, } = params;
|
|
345
386
|
const combinedAction = this.supplyCollateralBorrow({
|
|
387
|
+
now: params.now,
|
|
346
388
|
userAddress,
|
|
347
389
|
collateralAssets,
|
|
348
390
|
borrowAssets: 0n,
|
|
@@ -368,16 +410,18 @@ class MorphoBlue {
|
|
|
368
410
|
referralFeeRecipient,
|
|
369
411
|
requirementSignature: token,
|
|
370
412
|
},
|
|
371
|
-
metadata
|
|
413
|
+
metadata,
|
|
372
414
|
});
|
|
373
415
|
},
|
|
374
416
|
};
|
|
375
417
|
}
|
|
376
418
|
/** {@inheritDoc BlueActions.borrow} */
|
|
377
419
|
borrow(params) {
|
|
420
|
+
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, params.now);
|
|
378
421
|
const { userAddress, borrowAssets, positionData, reallocations, deadline, referralFeePct, referralFeeRecipient, } = params;
|
|
379
422
|
const normalizedReallocations = [...(reallocations ?? [])];
|
|
380
423
|
const combinedAction = this.supplyCollateralBorrow({
|
|
424
|
+
now: params.now,
|
|
381
425
|
userAddress,
|
|
382
426
|
collateralAssets: 0n,
|
|
383
427
|
borrowAssets,
|
|
@@ -403,13 +447,14 @@ class MorphoBlue {
|
|
|
403
447
|
referralFeeRecipient,
|
|
404
448
|
authorizationSignature: authorization,
|
|
405
449
|
},
|
|
406
|
-
metadata
|
|
450
|
+
metadata,
|
|
407
451
|
});
|
|
408
452
|
},
|
|
409
453
|
};
|
|
410
454
|
}
|
|
411
455
|
/** {@inheritDoc BlueActions.repay} */
|
|
412
456
|
repay(params) {
|
|
457
|
+
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, params.now);
|
|
413
458
|
const combinedAction = this.repayWithdrawCollateral({
|
|
414
459
|
...params,
|
|
415
460
|
collateralAssets: 0n,
|
|
@@ -435,15 +480,17 @@ class MorphoBlue {
|
|
|
435
480
|
referralFeeRecipient,
|
|
436
481
|
requirementSignature: token,
|
|
437
482
|
},
|
|
438
|
-
metadata
|
|
483
|
+
metadata,
|
|
439
484
|
});
|
|
440
485
|
},
|
|
441
486
|
};
|
|
442
487
|
}
|
|
443
488
|
/** {@inheritDoc BlueActions.withdrawCollateral} */
|
|
444
489
|
withdrawCollateral(params) {
|
|
490
|
+
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, params.now);
|
|
445
491
|
const { userAddress, positionData, collateralAssets, deadline, referralFeePct, referralFeeRecipient, } = params;
|
|
446
492
|
const combinedAction = this.repayWithdrawCollateral({
|
|
493
|
+
now: params.now,
|
|
447
494
|
userAddress,
|
|
448
495
|
positionData,
|
|
449
496
|
repayAssets: 0n,
|
|
@@ -469,15 +516,18 @@ class MorphoBlue {
|
|
|
469
516
|
referralFeeRecipient: combinedArgs.referralFeeRecipient,
|
|
470
517
|
authorizationSignature: authorization,
|
|
471
518
|
},
|
|
472
|
-
metadata
|
|
519
|
+
metadata,
|
|
473
520
|
});
|
|
474
521
|
},
|
|
475
522
|
};
|
|
476
523
|
}
|
|
477
524
|
/** {@inheritDoc BlueActions.repayWithdrawCollateral} */
|
|
478
525
|
repayWithdrawCollateral(params) {
|
|
526
|
+
const suppliedNow = params.now;
|
|
527
|
+
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, suppliedNow);
|
|
479
528
|
const { userAddress, positionData, collateralAssets, nativeAmount, deadline, referralFeeRecipient, } = params;
|
|
480
|
-
|
|
529
|
+
const createdAt = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
530
|
+
this.validateWriteCommon(params, createdAt);
|
|
481
531
|
// `validateWriteCommon` returns void, so default an omitted `referralFeePct` to `0n`
|
|
482
532
|
// here, matching the pure action's normalization.
|
|
483
533
|
const referralFeePct = params.referralFeePct ?? 0n;
|
|
@@ -507,39 +557,13 @@ class MorphoBlue {
|
|
|
507
557
|
expectedMarketId: this.marketParams.id,
|
|
508
558
|
expectedUser: userAddress,
|
|
509
559
|
});
|
|
510
|
-
const
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
repayAssets,
|
|
518
|
-
marketId: this.marketParams.id,
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
else if (repayShares > 0n && !saturatedRepay) {
|
|
522
|
-
(0, index_js_2.validateRepayShares)({
|
|
523
|
-
positionData,
|
|
524
|
-
repayShares,
|
|
525
|
-
marketId: this.marketParams.id,
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
const quoteHorizon = this.getBlueBundlesV1QuoteTimestamp(positionData.market.lastUpdate);
|
|
529
|
-
if (repayShares > 0n && deadline > quoteHorizon) {
|
|
530
|
-
throw new index_js_3.InputExceedsMaxError({
|
|
531
|
-
field: "deadline",
|
|
532
|
-
value: deadline,
|
|
533
|
-
max: quoteHorizon,
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
const accrualTimestamp = repayShares > 0n ? deadline : quoteHorizon;
|
|
537
|
-
const accruedPosition = positionData.accrueInterest(accrualTimestamp);
|
|
538
|
-
const expectedRepayAssets = repayAssets > 0n
|
|
539
|
-
? repayAssets
|
|
540
|
-
: hasRepay
|
|
541
|
-
? accruedPosition.market.toBorrowAssets(simulatedRepayShares, "Up")
|
|
542
|
-
: 0n;
|
|
560
|
+
const { simulatedRepayShares, accruedPosition, expectedRepayAssets } = this.quoteRepay({
|
|
561
|
+
positionData,
|
|
562
|
+
repayAssets,
|
|
563
|
+
repayShares,
|
|
564
|
+
deadline,
|
|
565
|
+
now: createdAt,
|
|
566
|
+
});
|
|
543
567
|
const referralFeeAssets = (0, common_js_1.getBlueBundlesV1ReferralFeeAssets)(expectedRepayAssets, referralFeePct);
|
|
544
568
|
const maxRepayAssets = expectedRepayAssets + referralFeeAssets;
|
|
545
569
|
const nativeValue = (0, common_js_1.validateBlueBundlesV1NativeFunding)({
|
|
@@ -561,7 +585,7 @@ class MorphoBlue {
|
|
|
561
585
|
}
|
|
562
586
|
return {
|
|
563
587
|
getRequirements: async (requirementsParams) => {
|
|
564
|
-
const now = morpho_ts_1.Time.timestamp();
|
|
588
|
+
const now = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
565
589
|
this.validateDeadline(deadline, now);
|
|
566
590
|
await this.assertWriteTargets();
|
|
567
591
|
const [tokenRequirements, authorizationRequirements] = await Promise.all([
|
|
@@ -612,15 +636,18 @@ class MorphoBlue {
|
|
|
612
636
|
requirementSignature: token,
|
|
613
637
|
authorizationSignature: authorization,
|
|
614
638
|
},
|
|
615
|
-
metadata
|
|
639
|
+
metadata,
|
|
616
640
|
});
|
|
617
641
|
},
|
|
618
642
|
};
|
|
619
643
|
}
|
|
620
644
|
/** {@inheritDoc BlueActions.supplyCollateralBorrow} */
|
|
621
645
|
supplyCollateralBorrow(params) {
|
|
646
|
+
const suppliedNow = params.now;
|
|
647
|
+
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, suppliedNow);
|
|
622
648
|
const { userAddress, collateralAssets, borrowAssets, positionData, nativeAmount, deadline, referralFeePct, referralFeeRecipient, } = params;
|
|
623
|
-
|
|
649
|
+
const createdAt = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
650
|
+
this.validateWriteCommon(params, createdAt);
|
|
624
651
|
if (collateralAssets < 0n) {
|
|
625
652
|
throw new index_js_3.NegativeInputError("collateralAssets", collateralAssets);
|
|
626
653
|
}
|
|
@@ -654,7 +681,7 @@ class MorphoBlue {
|
|
|
654
681
|
expectedUser: userAddress,
|
|
655
682
|
});
|
|
656
683
|
(0, index_js_2.validatePositionHealth)({
|
|
657
|
-
positionData: positionData.accrueInterest(this.getBlueBundlesV1QuoteTimestamp(positionData.market.lastUpdate)),
|
|
684
|
+
positionData: positionData.accrueInterest(this.getBlueBundlesV1QuoteTimestamp(positionData.market.lastUpdate, createdAt)),
|
|
658
685
|
additionalCollateral: collateralAssets,
|
|
659
686
|
borrowAmount: borrowAssets,
|
|
660
687
|
marketId: this.marketParams.id,
|
|
@@ -669,7 +696,7 @@ class MorphoBlue {
|
|
|
669
696
|
});
|
|
670
697
|
return {
|
|
671
698
|
getRequirements: async (requirementsParams) => {
|
|
672
|
-
const now = morpho_ts_1.Time.timestamp();
|
|
699
|
+
const now = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
673
700
|
this.validateDeadline(deadline, now);
|
|
674
701
|
await this.assertWriteTargets();
|
|
675
702
|
const [tokenRequirements, authorizationRequirements] = await Promise.all([
|
|
@@ -713,15 +740,18 @@ class MorphoBlue {
|
|
|
713
740
|
requirementSignature: token,
|
|
714
741
|
authorizationSignature: authorization,
|
|
715
742
|
},
|
|
716
|
-
metadata
|
|
743
|
+
metadata,
|
|
717
744
|
});
|
|
718
745
|
},
|
|
719
746
|
};
|
|
720
747
|
}
|
|
721
748
|
/** {@inheritDoc BlueActions.refinance} */
|
|
722
749
|
refinance(params) {
|
|
750
|
+
const suppliedNow = params.now;
|
|
751
|
+
const metadata = (0, metadata_js_1.resolveTransactionMetadata)(this.client.options.metadata, suppliedNow);
|
|
723
752
|
const { userAddress, positionData, destination, deadline, referralFeeRecipient, } = params;
|
|
724
|
-
|
|
753
|
+
const createdAt = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
754
|
+
this.validateWriteCommon(params, createdAt);
|
|
725
755
|
(0, validate_js_1.validateMarketParamsId)(destination.marketParams);
|
|
726
756
|
// `validateWriteCommon` returns void, so default an omitted `referralFeePct` to `0n`
|
|
727
757
|
// here, matching the pure action's normalization.
|
|
@@ -755,7 +785,7 @@ class MorphoBlue {
|
|
|
755
785
|
const reallocations = [...(params.reallocations ?? [])];
|
|
756
786
|
const publicAllocations = (0, common_js_1.getBlueBundlesV1PublicAllocations)(reallocations, destination.marketParams);
|
|
757
787
|
const penaltyAssets = (0, common_js_1.getBlueBundlesV1PenaltyAssets)(publicAllocations);
|
|
758
|
-
const accrualTimestamp = this.getBlueBundlesV1QuoteTimestamp(blue_sdk_1.MathLib.max(positionData.market.lastUpdate, destination.positionData.market.lastUpdate));
|
|
788
|
+
const accrualTimestamp = this.getBlueBundlesV1QuoteTimestamp(blue_sdk_1.MathLib.max(positionData.market.lastUpdate, destination.positionData.market.lastUpdate), createdAt);
|
|
759
789
|
const accruedSourcePosition = positionData.accrueInterest(accrualTimestamp);
|
|
760
790
|
const accruedDestinationPosition = destination.positionData.accrueInterest(accrualTimestamp);
|
|
761
791
|
const referralFeeAssets = (0, common_js_1.getBlueBundlesV1ReferralFeeAssets)(accruedSourcePosition.borrowAssets, referralFeePct);
|
|
@@ -768,7 +798,7 @@ class MorphoBlue {
|
|
|
768
798
|
});
|
|
769
799
|
return {
|
|
770
800
|
getRequirements: async () => {
|
|
771
|
-
const now = morpho_ts_1.Time.timestamp();
|
|
801
|
+
const now = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
772
802
|
this.validateDeadline(deadline, now);
|
|
773
803
|
await this.assertWriteTargets();
|
|
774
804
|
return this.getAuthorizationRequirements({
|
|
@@ -796,7 +826,7 @@ class MorphoBlue {
|
|
|
796
826
|
referralFeeRecipient,
|
|
797
827
|
authorizationSignature: authorization,
|
|
798
828
|
},
|
|
799
|
-
metadata
|
|
829
|
+
metadata,
|
|
800
830
|
});
|
|
801
831
|
},
|
|
802
832
|
};
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Midnight bundles revert with `DeadlinePassed()` once the deadline has passed, so a deadline at
|
|
5
5
|
* or before `now` builds a transaction that cannot succeed. `maxUint256` still means
|
|
6
|
-
* "no expiry". The check uses the
|
|
6
|
+
* "no expiry". The check uses the supplied reference timestamp, falling back to the device clock. Transaction
|
|
7
7
|
* builders stay clock-free and only check the deadline's `uint256` shape.
|
|
8
8
|
*
|
|
9
9
|
* @param deadline - Bundle execution deadline timestamp, in seconds.
|
|
10
|
-
* @param now -
|
|
10
|
+
* @param now - Timestamp in seconds used to validate the deadline; defaults to `Time.timestamp()`.
|
|
11
11
|
* @returns Nothing when `deadline` is after `now`.
|
|
12
12
|
* @throws {ExpiredDeadlineError} when `deadline` is at or before `now`.
|
|
13
13
|
* @internal
|
|
@@ -8,17 +8,18 @@ const index_js_1 = require("../../types/index.js");
|
|
|
8
8
|
*
|
|
9
9
|
* Midnight bundles revert with `DeadlinePassed()` once the deadline has passed, so a deadline at
|
|
10
10
|
* or before `now` builds a transaction that cannot succeed. `maxUint256` still means
|
|
11
|
-
* "no expiry". The check uses the
|
|
11
|
+
* "no expiry". The check uses the supplied reference timestamp, falling back to the device clock. Transaction
|
|
12
12
|
* builders stay clock-free and only check the deadline's `uint256` shape.
|
|
13
13
|
*
|
|
14
14
|
* @param deadline - Bundle execution deadline timestamp, in seconds.
|
|
15
|
-
* @param now -
|
|
15
|
+
* @param now - Timestamp in seconds used to validate the deadline; defaults to `Time.timestamp()`.
|
|
16
16
|
* @returns Nothing when `deadline` is after `now`.
|
|
17
17
|
* @throws {ExpiredDeadlineError} when `deadline` is at or before `now`.
|
|
18
18
|
* @internal
|
|
19
19
|
*/
|
|
20
20
|
const validateMidnightDeadline = (deadline, now = morpho_ts_1.Time.timestamp()) => {
|
|
21
|
-
if (deadline <= now)
|
|
21
|
+
if (deadline <= now) {
|
|
22
22
|
throw new index_js_1.ExpiredDeadlineError(deadline, now);
|
|
23
|
+
}
|
|
23
24
|
};
|
|
24
25
|
exports.validateMidnightDeadline = validateMidnightDeadline;
|