@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
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./authorization.js"), exports);
|
|
18
18
|
__exportStar(require("./cancelAndMake.js"), exports);
|
|
19
|
+
__exportStar(require("./cancelOffers.js"), exports);
|
|
19
20
|
__exportStar(require("./redeem.js"), exports);
|
|
20
21
|
__exportStar(require("./repayWithdrawCollateral.js"), exports);
|
|
21
22
|
__exportStar(require("./supplyCollateral.js"), exports);
|
|
@@ -49,8 +49,9 @@ const midnightSupplyCollateralBatch = (params) => {
|
|
|
49
49
|
// Direct batches require one entry per index rather than summing duplicates.
|
|
50
50
|
(0, validateMidnightCollateralBatch_js_1.validateMidnightCollateralBatch)(params.collateralSupplies, new index_js_2.EmptyMidnightCollateralSuppliesError());
|
|
51
51
|
const calls = params.collateralSupplies.map(({ collateralIndex, assets }) => {
|
|
52
|
-
if (assets <= 0n)
|
|
52
|
+
if (assets <= 0n) {
|
|
53
53
|
throw new index_js_2.NonPositiveInputError("assets", assets);
|
|
54
|
+
}
|
|
54
55
|
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("assets", assets);
|
|
55
56
|
// Reject indexes not configured on the market.
|
|
56
57
|
midnight_sdk_1.MarketUtils.getCollateralByIndex(params.market, collateralIndex);
|
|
@@ -74,8 +75,9 @@ const midnightSupplyCollateralBatch = (params) => {
|
|
|
74
75
|
args: [calls],
|
|
75
76
|
}),
|
|
76
77
|
};
|
|
77
|
-
if (params.metadata)
|
|
78
|
+
if (params.metadata) {
|
|
78
79
|
tx = (0, index_js_1.addTransactionMetadata)(tx, params.metadata);
|
|
80
|
+
}
|
|
79
81
|
return (0, morpho_ts_1.deepFreeze)({
|
|
80
82
|
...tx,
|
|
81
83
|
action: {
|
|
@@ -86,7 +86,7 @@ export interface MidnightSupplyCollateralTakeBorrowParams extends MidnightTakeBo
|
|
|
86
86
|
* receiver: borrower,
|
|
87
87
|
* collateralSupplies: [{ collateralIndex: 0n, assets: 2_000_000n }],
|
|
88
88
|
* takeableOffers: quote.data.takeableOffers,
|
|
89
|
-
* deadline:
|
|
89
|
+
* deadline: (await client.getBlock()).timestamp + 600n,
|
|
90
90
|
* });
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
@@ -90,7 +90,7 @@ const index_js_2 = require("../../types/index.js");
|
|
|
90
90
|
* receiver: borrower,
|
|
91
91
|
* collateralSupplies: [{ collateralIndex: 0n, assets: 2_000_000n }],
|
|
92
92
|
* takeableOffers: quote.data.takeableOffers,
|
|
93
|
-
* deadline:
|
|
93
|
+
* deadline: (await client.getBlock()).timestamp + 600n,
|
|
94
94
|
* });
|
|
95
95
|
* ```
|
|
96
96
|
*/
|
|
@@ -150,8 +150,9 @@ const midnightSupplyCollateralTakeBorrow = (params) => {
|
|
|
150
150
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
151
151
|
}
|
|
152
152
|
(0, validate_js_1.validateDeadline)(params.deadline);
|
|
153
|
-
if (params.referralFeeRecipient !== undefined)
|
|
153
|
+
if (params.referralFeeRecipient !== undefined) {
|
|
154
154
|
(0, validateMidnightAccount_js_1.validateMidnightAddress)("referralFeeRecipient", params.referralFeeRecipient);
|
|
155
|
+
}
|
|
155
156
|
const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(params);
|
|
156
157
|
(0, validateMidnightBounds_js_1.validateMidnightReferralFeeCap)(referralFeePct);
|
|
157
158
|
(0, validateMidnightTakeFeasibility_js_1.validateMidnightSellTargetBounds)({ target, referralFeePct });
|
|
@@ -77,7 +77,7 @@ export interface MidnightTakeBorrowParams extends MidnightReferralFeeParams {
|
|
|
77
77
|
* target: { type: "assets", assets: 1_000_000n, maxUnits: 1_100_000n },
|
|
78
78
|
* receiver: borrower,
|
|
79
79
|
* takeableOffers: quote.data.takeableOffers,
|
|
80
|
-
* deadline:
|
|
80
|
+
* deadline: (await client.getBlock()).timestamp + 600n,
|
|
81
81
|
* });
|
|
82
82
|
* ```
|
|
83
83
|
*/
|
|
@@ -77,7 +77,7 @@ const index_js_2 = require("../../types/index.js");
|
|
|
77
77
|
* target: { type: "assets", assets: 1_000_000n, maxUnits: 1_100_000n },
|
|
78
78
|
* receiver: borrower,
|
|
79
79
|
* takeableOffers: quote.data.takeableOffers,
|
|
80
|
-
* deadline:
|
|
80
|
+
* deadline: (await client.getBlock()).timestamp + 600n,
|
|
81
81
|
* });
|
|
82
82
|
* ```
|
|
83
83
|
*/
|
|
@@ -128,8 +128,9 @@ const midnightTakeBorrow = (params) => {
|
|
|
128
128
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
129
129
|
}
|
|
130
130
|
(0, validate_js_1.validateDeadline)(params.deadline);
|
|
131
|
-
if (params.referralFeeRecipient !== undefined)
|
|
131
|
+
if (params.referralFeeRecipient !== undefined) {
|
|
132
132
|
(0, validateMidnightAccount_js_1.validateMidnightAddress)("referralFeeRecipient", params.referralFeeRecipient);
|
|
133
|
+
}
|
|
133
134
|
const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(params);
|
|
134
135
|
(0, validateMidnightBounds_js_1.validateMidnightReferralFeeCap)(referralFeePct);
|
|
135
136
|
(0, validateMidnightTakeFeasibility_js_1.validateMidnightSellTargetBounds)({ target, referralFeePct });
|
|
@@ -81,7 +81,7 @@ export interface MidnightTakeLendParams extends MidnightReferralFeeParams {
|
|
|
81
81
|
* target: { type: "assets", assets: 1_000_000n, minUnits: 900_000n },
|
|
82
82
|
* takeableOffers: quote.data.takeableOffers,
|
|
83
83
|
* maxContinuousFee: maxUint256,
|
|
84
|
-
* deadline:
|
|
84
|
+
* deadline: (await client.getBlock()).timestamp + 600n,
|
|
85
85
|
* });
|
|
86
86
|
* ```
|
|
87
87
|
*/
|
|
@@ -74,7 +74,7 @@ const index_js_2 = require("../../types/index.js");
|
|
|
74
74
|
* target: { type: "assets", assets: 1_000_000n, minUnits: 900_000n },
|
|
75
75
|
* takeableOffers: quote.data.takeableOffers,
|
|
76
76
|
* maxContinuousFee: maxUint256,
|
|
77
|
-
* deadline:
|
|
77
|
+
* deadline: (await client.getBlock()).timestamp + 600n,
|
|
78
78
|
* });
|
|
79
79
|
* ```
|
|
80
80
|
*/
|
|
@@ -119,8 +119,9 @@ const midnightTakeLend = (params) => {
|
|
|
119
119
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
120
120
|
}
|
|
121
121
|
(0, validate_js_1.validateDeadline)(params.deadline);
|
|
122
|
-
if (params.referralFeeRecipient !== undefined)
|
|
122
|
+
if (params.referralFeeRecipient !== undefined) {
|
|
123
123
|
(0, validateMidnightAccount_js_1.validateMidnightAddress)("referralFeeRecipient", params.referralFeeRecipient);
|
|
124
|
+
}
|
|
124
125
|
const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(params);
|
|
125
126
|
(0, validateMidnightBounds_js_1.validateMidnightReferralFeeCap)(referralFeePct);
|
|
126
127
|
if (referralFeePct > 0n) {
|
|
@@ -107,7 +107,7 @@ export interface MidnightTakeRepayWithdrawCollateralParams extends MidnightRefer
|
|
|
107
107
|
* collateralWithdrawals: [{ collateralIndex: 0n, assets: maxUint256 }],
|
|
108
108
|
* collateralReceiver: borrower,
|
|
109
109
|
* maxContinuousFee: maxUint256,
|
|
110
|
-
* deadline:
|
|
110
|
+
* deadline: (await client.getBlock()).timestamp + 600n,
|
|
111
111
|
* });
|
|
112
112
|
* ```
|
|
113
113
|
*/
|
|
@@ -93,7 +93,7 @@ const index_js_2 = require("../../types/index.js");
|
|
|
93
93
|
* collateralWithdrawals: [{ collateralIndex: 0n, assets: maxUint256 }],
|
|
94
94
|
* collateralReceiver: borrower,
|
|
95
95
|
* maxContinuousFee: maxUint256,
|
|
96
|
-
* deadline:
|
|
96
|
+
* deadline: (await client.getBlock()).timestamp + 600n,
|
|
97
97
|
* });
|
|
98
98
|
* ```
|
|
99
99
|
*/
|
|
@@ -154,8 +154,9 @@ const midnightTakeRepayWithdrawCollateral = (params) => {
|
|
|
154
154
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
155
155
|
}
|
|
156
156
|
(0, validate_js_1.validateDeadline)(params.deadline);
|
|
157
|
-
if (params.referralFeeRecipient !== undefined)
|
|
157
|
+
if (params.referralFeeRecipient !== undefined) {
|
|
158
158
|
(0, validateMidnightAccount_js_1.validateMidnightAddress)("referralFeeRecipient", params.referralFeeRecipient);
|
|
159
|
+
}
|
|
159
160
|
const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(params);
|
|
160
161
|
(0, validateMidnightBounds_js_1.validateMidnightReferralFeeCap)(referralFeePct);
|
|
161
162
|
if (referralFeePct > 0n) {
|
|
@@ -73,7 +73,7 @@ export interface MidnightTakeWithdrawParams extends MidnightReferralFeeParams {
|
|
|
73
73
|
* target: { type: "units", units: credit, minSellerAssets: 990_000n },
|
|
74
74
|
* receiver: lender,
|
|
75
75
|
* takeableOffers: quote.data.takeableOffers,
|
|
76
|
-
* deadline:
|
|
76
|
+
* deadline: (await client.getBlock()).timestamp + 600n,
|
|
77
77
|
* });
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
@@ -63,8 +63,9 @@ const validateParams = (params) => {
|
|
|
63
63
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
64
64
|
}
|
|
65
65
|
(0, validate_js_1.validateDeadline)(params.deadline);
|
|
66
|
-
if (params.referralFeeRecipient !== undefined)
|
|
66
|
+
if (params.referralFeeRecipient !== undefined) {
|
|
67
67
|
(0, validateMidnightAccount_js_1.validateMidnightAddress)("referralFeeRecipient", params.referralFeeRecipient);
|
|
68
|
+
}
|
|
68
69
|
const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(params);
|
|
69
70
|
(0, validateMidnightBounds_js_1.validateMidnightReferralFeeCap)(referralFeePct);
|
|
70
71
|
(0, validateMidnightTakeFeasibility_js_1.validateMidnightSellTargetBounds)({ target, referralFeePct });
|
|
@@ -137,7 +138,7 @@ const validateParams = (params) => {
|
|
|
137
138
|
* target: { type: "units", units: credit, minSellerAssets: 990_000n },
|
|
138
139
|
* receiver: lender,
|
|
139
140
|
* takeableOffers: quote.data.takeableOffers,
|
|
140
|
-
* deadline:
|
|
141
|
+
* deadline: (await client.getBlock()).timestamp + 600n,
|
|
141
142
|
* });
|
|
142
143
|
* ```
|
|
143
144
|
*/
|
|
@@ -60,8 +60,9 @@ const midnightWithdrawCollateralBatch = (params) => {
|
|
|
60
60
|
// Direct batches require one entry per index rather than summing duplicates.
|
|
61
61
|
(0, validateMidnightCollateralBatch_js_1.validateMidnightCollateralBatch)(params.collateralWithdrawals, new index_js_2.EmptyMidnightCollateralWithdrawalsError());
|
|
62
62
|
const calls = params.collateralWithdrawals.map(({ collateralIndex, assets }) => {
|
|
63
|
-
if (assets <= 0n)
|
|
63
|
+
if (assets <= 0n) {
|
|
64
64
|
throw new index_js_2.NonPositiveInputError("assets", assets);
|
|
65
|
+
}
|
|
65
66
|
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("assets", assets);
|
|
66
67
|
// Reject indexes not configured on the market.
|
|
67
68
|
midnight_sdk_1.MarketUtils.getCollateralByIndex(params.market, collateralIndex);
|
|
@@ -86,8 +87,9 @@ const midnightWithdrawCollateralBatch = (params) => {
|
|
|
86
87
|
args: [calls],
|
|
87
88
|
}),
|
|
88
89
|
};
|
|
89
|
-
if (params.metadata)
|
|
90
|
+
if (params.metadata) {
|
|
90
91
|
tx = (0, index_js_1.addTransactionMetadata)(tx, params.metadata);
|
|
92
|
+
}
|
|
91
93
|
return (0, morpho_ts_1.deepFreeze)({
|
|
92
94
|
...tx,
|
|
93
95
|
action: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Client } from "viem";
|
|
2
2
|
import { type Address } from "viem";
|
|
3
|
-
import { type AuthorizationRequirementSignature, type BlueAuthorizationAction, type Requirement, type Transaction } from "../../../types/index.js";
|
|
3
|
+
import { type AuthorizationRequirementSignature, type BlueAuthorizationAction, type ReferenceTimestampParams, type Requirement, type Transaction } from "../../../types/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Resolves whether a supported operator needs Blue authorization for the given user, and returns
|
|
6
6
|
* the requirement to satisfy it when it does.
|
|
@@ -18,7 +18,7 @@ import { type AuthorizationRequirementSignature, type BlueAuthorizationAction, t
|
|
|
18
18
|
* @param params.authorized - Operator to authorize. Defaults to the chain's registered
|
|
19
19
|
* BlueBundlesV1 deployment and must match it.
|
|
20
20
|
* @param params.deadline - Optional signature deadline forwarded to the authorization encoder.
|
|
21
|
-
* @param params.now -
|
|
21
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
22
22
|
* @param params.supportSignature - When `true`, return a signable `Requirement` instead of a
|
|
23
23
|
* transaction so the destination route can consume the signed authorization.
|
|
24
24
|
* @returns A deep-frozen `Transaction<BlueAuthorizationAction>`, a signable authorization
|
|
@@ -63,5 +63,4 @@ export declare const getBlueAuthorizationRequirement: (params: {
|
|
|
63
63
|
readonly supportSignature?: boolean;
|
|
64
64
|
readonly authorized?: Address;
|
|
65
65
|
readonly deadline?: bigint;
|
|
66
|
-
|
|
67
|
-
}) => Promise<Readonly<Transaction<BlueAuthorizationAction>> | Requirement<AuthorizationRequirementSignature> | null>;
|
|
66
|
+
} & ReferenceTimestampParams) => Promise<Readonly<Transaction<BlueAuthorizationAction>> | Requirement<AuthorizationRequirementSignature> | null>;
|
|
@@ -26,7 +26,7 @@ const validateClientChainId_js_1 = require("../validateClientChainId.js");
|
|
|
26
26
|
* @param params.authorized - Operator to authorize. Defaults to the chain's registered
|
|
27
27
|
* BlueBundlesV1 deployment and must match it.
|
|
28
28
|
* @param params.deadline - Optional signature deadline forwarded to the authorization encoder.
|
|
29
|
-
* @param params.now -
|
|
29
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
30
30
|
* @param params.supportSignature - When `true`, return a signable `Requirement` instead of a
|
|
31
31
|
* transaction so the destination route can consume the signed authorization.
|
|
32
32
|
* @returns A deep-frozen `Transaction<BlueAuthorizationAction>`, a signable authorization
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Address } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { type Client } from "viem";
|
|
3
|
-
import { type AuthorizationRequirementSignature, type Requirement } from "../../../types/index.js";
|
|
3
|
+
import { type AuthorizationRequirementSignature, type ReferenceTimestampParams, type Requirement } from "../../../types/index.js";
|
|
4
4
|
/** Parameters for {@link encodeBlueSignatureAuthorization}. */
|
|
5
|
-
interface EncodeBlueSignatureAuthorizationParams {
|
|
5
|
+
interface EncodeBlueSignatureAuthorizationParams extends ReferenceTimestampParams {
|
|
6
6
|
/** Account granting the authorization and signing it (the Morpho `authorizer`). */
|
|
7
7
|
owner: Address;
|
|
8
8
|
/** BlueBundlesV1 operator to authorize on Morpho; must be the chain's registered deployment. */
|
|
@@ -15,8 +15,6 @@ interface EncodeBlueSignatureAuthorizationParams {
|
|
|
15
15
|
isAuthorized?: boolean;
|
|
16
16
|
/** Signature deadline in seconds. Defaults to two hours from now. */
|
|
17
17
|
deadline?: bigint;
|
|
18
|
-
/** Timestamp the deadline is validated against; defaults to the current time. */
|
|
19
|
-
now?: bigint;
|
|
20
18
|
}
|
|
21
19
|
/**
|
|
22
20
|
* Builds a Morpho authorization `Requirement` that, once signed, lets BlueBundlesV1 operate on
|
|
@@ -26,7 +24,7 @@ interface EncodeBlueSignatureAuthorizationParams {
|
|
|
26
24
|
* typed data, verifies it against the connected account, and returns a deep-frozen
|
|
27
25
|
* `RequirementSignature` the selected transaction route consumes. The requirement's
|
|
28
26
|
* `action.typedData` holds that EIP-712 payload so it can be inspected or displayed before signing.
|
|
29
|
-
* Deadline defaults to two hours from `
|
|
27
|
+
* Deadline defaults to two hours from `params.now` (the deprecated fallback uses the device clock).
|
|
30
28
|
* The operator pin applies to grants and revocations alike: revoking a previously registered
|
|
31
29
|
* operator is outside this helper's scope.
|
|
32
30
|
*
|
|
@@ -40,7 +38,7 @@ interface EncodeBlueSignatureAuthorizationParams {
|
|
|
40
38
|
* @param params.nonce - The owner's current Morpho authorization nonce.
|
|
41
39
|
* @param params.isAuthorized - Grant (`true`, default) or revoke (`false`).
|
|
42
40
|
* @param params.deadline - Optional signature deadline in seconds.
|
|
43
|
-
* @param params.now -
|
|
41
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
44
42
|
* @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
|
|
45
43
|
* `sign(client, userAddress)` produces the deep-frozen signature.
|
|
46
44
|
* @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
|
|
@@ -15,7 +15,7 @@ const index_js_1 = require("../../../types/index.js");
|
|
|
15
15
|
* typed data, verifies it against the connected account, and returns a deep-frozen
|
|
16
16
|
* `RequirementSignature` the selected transaction route consumes. The requirement's
|
|
17
17
|
* `action.typedData` holds that EIP-712 payload so it can be inspected or displayed before signing.
|
|
18
|
-
* Deadline defaults to two hours from `
|
|
18
|
+
* Deadline defaults to two hours from `params.now` (the deprecated fallback uses the device clock).
|
|
19
19
|
* The operator pin applies to grants and revocations alike: revoking a previously registered
|
|
20
20
|
* operator is outside this helper's scope.
|
|
21
21
|
*
|
|
@@ -29,7 +29,7 @@ const index_js_1 = require("../../../types/index.js");
|
|
|
29
29
|
* @param params.nonce - The owner's current Morpho authorization nonce.
|
|
30
30
|
* @param params.isAuthorized - Grant (`true`, default) or revoke (`false`).
|
|
31
31
|
* @param params.deadline - Optional signature deadline in seconds.
|
|
32
|
-
* @param params.now -
|
|
32
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
33
33
|
* @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
|
|
34
34
|
* `sign(client, userAddress)` produces the deep-frozen signature.
|
|
35
35
|
* @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
|
|
@@ -87,7 +87,7 @@ const encodeBlueSignatureAuthorization = async (viemClient, params) => {
|
|
|
87
87
|
throw new index_js_1.ExpiredDeadlineError(params.deadline, timestamp);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
const deadline = params.deadline ?? morpho_ts_1.Time.timestamp() + morpho_ts_1.Time.s.from.h(2n);
|
|
90
|
+
const deadline = params.deadline ?? (params.now ?? morpho_ts_1.Time.timestamp()) + morpho_ts_1.Time.s.from.h(2n);
|
|
91
91
|
const typedData = (0, morpho_ts_1.deepFreeze)((0, blue_sdk_viem_1.getAuthorizationTypedData)({ authorizer: owner, authorized, isAuthorized, nonce, deadline }, chainId));
|
|
92
92
|
const action = {
|
|
93
93
|
type: "authorization",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Address } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { Client } from "viem";
|
|
3
|
-
import { type Erc2612RequirementSignature, type Requirement } from "../../../types/index.js";
|
|
3
|
+
import { type Erc2612RequirementSignature, type ReferenceTimestampParams, type Requirement } from "../../../types/index.js";
|
|
4
4
|
/** Parameters for {@link encodeErc20Permit}. */
|
|
5
|
-
interface EncodeErc20PermitParams {
|
|
5
|
+
interface EncodeErc20PermitParams extends ReferenceTimestampParams {
|
|
6
6
|
token: Address;
|
|
7
7
|
/** Account that owns the tokens and signs the permit. */
|
|
8
8
|
owner: Address;
|
|
@@ -12,8 +12,6 @@ interface EncodeErc20PermitParams {
|
|
|
12
12
|
nonce: bigint;
|
|
13
13
|
supportDeployless?: boolean;
|
|
14
14
|
deadline?: bigint;
|
|
15
|
-
/** Timestamp the deadline is validated against; defaults to the current time. */
|
|
16
|
-
now?: bigint;
|
|
17
15
|
}
|
|
18
16
|
/**
|
|
19
17
|
* Builds an EIP-2612 permit `Requirement` that, once signed, lets a supported SDK spender pull
|
|
@@ -23,7 +21,7 @@ interface EncodeErc20PermitParams {
|
|
|
23
21
|
* signature, verifies it against the connected account, and returns a `RequirementSignature`
|
|
24
22
|
* the selected transaction route can consume. The requirement's `action.typedData` holds that
|
|
25
23
|
* EIP-712 payload so it can be inspected or displayed before signing. Deadline defaults to two
|
|
26
|
-
* hours from `
|
|
24
|
+
* hours from `params.now` (the deprecated fallback uses the device clock).
|
|
27
25
|
*
|
|
28
26
|
* @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
|
|
29
27
|
* @param params - Permit encoding parameters.
|
|
@@ -36,7 +34,7 @@ interface EncodeErc20PermitParams {
|
|
|
36
34
|
* @param params.nonce - The owner's current EIP-2612 nonce on `token`.
|
|
37
35
|
* @param params.supportDeployless - Whether `fetchToken` should use deployless multicall.
|
|
38
36
|
* @param params.deadline - Signature expiration timestamp. Defaults to two hours from now.
|
|
39
|
-
* @param params.now -
|
|
37
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
40
38
|
* @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
|
|
41
39
|
* `sign(client, userAddress)` produces the deep-frozen signature.
|
|
42
40
|
* @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`, or when the RPC
|
|
@@ -16,7 +16,7 @@ const validateClientChainId_js_1 = require("../validateClientChainId.js");
|
|
|
16
16
|
* signature, verifies it against the connected account, and returns a `RequirementSignature`
|
|
17
17
|
* the selected transaction route can consume. The requirement's `action.typedData` holds that
|
|
18
18
|
* EIP-712 payload so it can be inspected or displayed before signing. Deadline defaults to two
|
|
19
|
-
* hours from `
|
|
19
|
+
* hours from `params.now` (the deprecated fallback uses the device clock).
|
|
20
20
|
*
|
|
21
21
|
* @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
|
|
22
22
|
* @param params - Permit encoding parameters.
|
|
@@ -29,7 +29,7 @@ const validateClientChainId_js_1 = require("../validateClientChainId.js");
|
|
|
29
29
|
* @param params.nonce - The owner's current EIP-2612 nonce on `token`.
|
|
30
30
|
* @param params.supportDeployless - Whether `fetchToken` should use deployless multicall.
|
|
31
31
|
* @param params.deadline - Signature expiration timestamp. Defaults to two hours from now.
|
|
32
|
-
* @param params.now -
|
|
32
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
33
33
|
* @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
|
|
34
34
|
* `sign(client, userAddress)` produces the deep-frozen signature.
|
|
35
35
|
* @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`, or when the RPC
|
|
@@ -96,7 +96,7 @@ const encodeErc20Permit = async (viemClient, params) => {
|
|
|
96
96
|
throw new index_js_1.ExpiredDeadlineError(params.deadline, timestamp);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
const deadline = params.deadline ?? morpho_ts_1.Time.timestamp() + morpho_ts_1.Time.s.from.h(2n);
|
|
99
|
+
const deadline = params.deadline ?? (params.now ?? morpho_ts_1.Time.timestamp()) + morpho_ts_1.Time.s.from.h(2n);
|
|
100
100
|
await (0, validateClientChainId_js_1.validateClientChainId)(viemClient, chainId);
|
|
101
101
|
const tokenData = await (0, blue_sdk_viem_1.fetchToken)(token, viemClient, {
|
|
102
102
|
deployless: supportDeployless,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Address } from "@morpho-org/blue-sdk";
|
|
2
|
-
import { type Permit2SignatureTransferRequirementSignature, type Requirement } from "../../../types/index.js";
|
|
2
|
+
import { type Permit2SignatureTransferRequirementSignature, type ReferenceTimestampParams, type Requirement } from "../../../types/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Parameters for {@link encodeErc20Permit2SignatureTransfer}.
|
|
5
5
|
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
6
6
|
*/
|
|
7
|
-
export interface EncodeErc20Permit2SignatureTransferParams {
|
|
7
|
+
export interface EncodeErc20Permit2SignatureTransferParams extends ReferenceTimestampParams {
|
|
8
8
|
/** ERC-20 token pulled through Permit2. */
|
|
9
9
|
readonly token: Address;
|
|
10
10
|
/** Registered fixed bundles deployment receiving permission to pull the token. */
|
|
@@ -17,8 +17,6 @@ export interface EncodeErc20Permit2SignatureTransferParams {
|
|
|
17
17
|
readonly nonce: bigint;
|
|
18
18
|
/** Signature expiration timestamp in seconds. */
|
|
19
19
|
readonly deadline: bigint;
|
|
20
|
-
/** Timestamp the deadline is validated against; defaults to the current time. */
|
|
21
|
-
readonly now?: bigint;
|
|
22
20
|
}
|
|
23
21
|
/**
|
|
24
22
|
* Builds a Permit2 SignatureTransfer requirement for a direct fixed-bundles token pull.
|
|
@@ -34,7 +32,7 @@ export interface EncodeErc20Permit2SignatureTransferParams {
|
|
|
34
32
|
* @param params.chainId - Target chain id.
|
|
35
33
|
* @param params.nonce - Unused Permit2 unordered nonce.
|
|
36
34
|
* @param params.deadline - Signature expiration timestamp in seconds.
|
|
37
|
-
* @param params.now -
|
|
35
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
38
36
|
* @returns A requirement whose `action.typedData` is the EIP-712 payload and whose
|
|
39
37
|
* `sign(client, userAddress)` returns a deep-frozen signature result.
|
|
40
38
|
* @throws {NegativeInputError} when `amount` or `nonce` is negative.
|
|
@@ -62,7 +60,8 @@ export interface EncodeErc20Permit2SignatureTransferParams {
|
|
|
62
60
|
* amount: 1_000_000n,
|
|
63
61
|
* chainId: mainnet.id,
|
|
64
62
|
* nonce: 0n,
|
|
65
|
-
*
|
|
63
|
+
* now: (await client.getBlock()).timestamp,
|
|
64
|
+
* deadline: (await client.getBlock()).timestamp + 3_600n,
|
|
66
65
|
* });
|
|
67
66
|
* // requirement satisfies Requirement<Permit2SignatureTransferRequirementSignature>
|
|
68
67
|
* ```
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.encodeErc20Permit2SignatureTransfer = void 0;
|
|
4
4
|
const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const viem_1 = require("viem");
|
|
7
6
|
const signAndVerifyTypedData_js_1 = require("../../../helpers/signAndVerifyTypedData.js");
|
|
8
7
|
const validate_js_1 = require("../../../helpers/validate.js");
|
|
9
8
|
const validateRequirementSpender_js_1 = require("../../../helpers/validateRequirementSpender.js");
|
|
@@ -22,7 +21,7 @@ const index_js_1 = require("../../../types/index.js");
|
|
|
22
21
|
* @param params.chainId - Target chain id.
|
|
23
22
|
* @param params.nonce - Unused Permit2 unordered nonce.
|
|
24
23
|
* @param params.deadline - Signature expiration timestamp in seconds.
|
|
25
|
-
* @param params.now -
|
|
24
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
26
25
|
* @returns A requirement whose `action.typedData` is the EIP-712 payload and whose
|
|
27
26
|
* `sign(client, userAddress)` returns a deep-frozen signature result.
|
|
28
27
|
* @throws {NegativeInputError} when `amount` or `nonce` is negative.
|
|
@@ -50,7 +49,8 @@ const index_js_1 = require("../../../types/index.js");
|
|
|
50
49
|
* amount: 1_000_000n,
|
|
51
50
|
* chainId: mainnet.id,
|
|
52
51
|
* nonce: 0n,
|
|
53
|
-
*
|
|
52
|
+
* now: (await client.getBlock()).timestamp,
|
|
53
|
+
* deadline: (await client.getBlock()).timestamp + 3_600n,
|
|
54
54
|
* });
|
|
55
55
|
* // requirement satisfies Requirement<Permit2SignatureTransferRequirementSignature>
|
|
56
56
|
* ```
|
|
@@ -64,16 +64,8 @@ const encodeErc20Permit2SignatureTransfer = (params) => {
|
|
|
64
64
|
// this public encoder must reject the same out-of-range inputs itself.
|
|
65
65
|
(0, validate_js_1.validateUint256Field)("amount", amount);
|
|
66
66
|
(0, validate_js_1.validateUint256Field)("nonce", nonce);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
if (deadline > viem_1.maxUint256) {
|
|
71
|
-
throw new index_js_1.InputExceedsMaxError({
|
|
72
|
-
field: "deadline",
|
|
73
|
-
value: deadline,
|
|
74
|
-
max: viem_1.maxUint256,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
67
|
+
// Reject deadlines outside the positive uint256 range before signing.
|
|
68
|
+
(0, validate_js_1.validateDeadline)(deadline);
|
|
77
69
|
// Reject an already-expired deadline before signing so a direct caller is never walked through a
|
|
78
70
|
// wallet EIP-712 prompt for a SignatureTransfer that Permit2 would revert with `SignatureExpired`.
|
|
79
71
|
// The sibling encodeErc20Permit and the token-requirement resolver enforce the same guard.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Address, Token } from "@morpho-org/blue-sdk";
|
|
2
|
-
import { type PermitRequirementSignature, type Requirement } from "../../../types/index.js";
|
|
2
|
+
import { type PermitRequirementSignature, type ReferenceTimestampParams, type Requirement } from "../../../types/index.js";
|
|
3
3
|
/** Parameters for {@link encodeVaultSharesPermit}. */
|
|
4
|
-
export interface EncodeVaultSharesPermitParams {
|
|
4
|
+
export interface EncodeVaultSharesPermitParams extends ReferenceTimestampParams {
|
|
5
5
|
/** Vault share token, including V1 permit-domain metadata when available. */
|
|
6
6
|
readonly vault: Token;
|
|
7
7
|
/** Vault generation, which selects the standard V1 or two-field V2 domain. */
|
|
@@ -16,8 +16,6 @@ export interface EncodeVaultSharesPermitParams {
|
|
|
16
16
|
readonly nonce: bigint;
|
|
17
17
|
/** Shared permit and bundle deadline. */
|
|
18
18
|
readonly deadline: bigint;
|
|
19
|
-
/** Timestamp the deadline is validated against; defaults to the current time. */
|
|
20
|
-
readonly now?: bigint;
|
|
21
19
|
}
|
|
22
20
|
/**
|
|
23
21
|
* Builds an unlimited ERC-2612 shares-permit requirement used by a vault exit.
|
|
@@ -33,7 +31,7 @@ export interface EncodeVaultSharesPermitParams {
|
|
|
33
31
|
* @param params.chainId - Chain on which the vault and spender are deployed.
|
|
34
32
|
* @param params.nonce - Current vault permit nonce for the owner.
|
|
35
33
|
* @param params.deadline - Shared permit and bundle deadline.
|
|
36
|
-
* @param params.now -
|
|
34
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
37
35
|
* @returns A requirement whose `action.typedData` is the EIP-712 payload and whose `sign()` result
|
|
38
36
|
* can be embedded in fixed vault-bundles calldata.
|
|
39
37
|
* @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
|
|
@@ -23,7 +23,7 @@ const index_js_1 = require("../../../types/index.js");
|
|
|
23
23
|
* @param params.chainId - Chain on which the vault and spender are deployed.
|
|
24
24
|
* @param params.nonce - Current vault permit nonce for the owner.
|
|
25
25
|
* @param params.deadline - Shared permit and bundle deadline.
|
|
26
|
-
* @param params.now -
|
|
26
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
27
27
|
* @returns A requirement whose `action.typedData` is the EIP-712 payload and whose `sign()` result
|
|
28
28
|
* can be embedded in fixed vault-bundles calldata.
|
|
29
29
|
* @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
|
|
@@ -62,31 +62,34 @@ const index_js_1 = require("../../../types/index.js");
|
|
|
62
62
|
const encodeVaultSharesPermit = (params) => {
|
|
63
63
|
const { vault: inputVault, version, spender, owner, chainId, nonce, deadline, } = params;
|
|
64
64
|
const inputDomain = inputVault.eip5267Domain;
|
|
65
|
+
let eip5267Domain;
|
|
66
|
+
if (version === "vaultV2") {
|
|
67
|
+
eip5267Domain = new blue_sdk_1.Eip5267Domain({
|
|
68
|
+
// Only the bitmap-selected fields enter Vault V2's domain separator.
|
|
69
|
+
fields: "0x0c",
|
|
70
|
+
name: "",
|
|
71
|
+
version: "",
|
|
72
|
+
chainId: BigInt(chainId),
|
|
73
|
+
verifyingContract: inputVault.address,
|
|
74
|
+
salt: viem_1.zeroHash,
|
|
75
|
+
extensions: [],
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else if (inputDomain != null) {
|
|
79
|
+
eip5267Domain = new blue_sdk_1.Eip5267Domain({
|
|
80
|
+
fields: inputDomain.fields,
|
|
81
|
+
name: inputDomain.name,
|
|
82
|
+
version: inputDomain.version,
|
|
83
|
+
chainId: inputDomain.chainId,
|
|
84
|
+
verifyingContract: inputDomain.verifyingContract,
|
|
85
|
+
salt: inputDomain.salt,
|
|
86
|
+
extensions: [...inputDomain.extensions],
|
|
87
|
+
});
|
|
88
|
+
}
|
|
65
89
|
const vault = new blue_sdk_1.Token({
|
|
66
90
|
address: inputVault.address,
|
|
67
91
|
name: inputVault.name,
|
|
68
|
-
eip5267Domain
|
|
69
|
-
? new blue_sdk_1.Eip5267Domain({
|
|
70
|
-
// Only the bitmap-selected fields enter Vault V2's domain separator.
|
|
71
|
-
fields: "0x0c",
|
|
72
|
-
name: "",
|
|
73
|
-
version: "",
|
|
74
|
-
chainId: BigInt(chainId),
|
|
75
|
-
verifyingContract: inputVault.address,
|
|
76
|
-
salt: viem_1.zeroHash,
|
|
77
|
-
extensions: [],
|
|
78
|
-
})
|
|
79
|
-
: inputDomain == null
|
|
80
|
-
? undefined
|
|
81
|
-
: new blue_sdk_1.Eip5267Domain({
|
|
82
|
-
fields: inputDomain.fields,
|
|
83
|
-
name: inputDomain.name,
|
|
84
|
-
version: inputDomain.version,
|
|
85
|
-
chainId: inputDomain.chainId,
|
|
86
|
-
verifyingContract: inputDomain.verifyingContract,
|
|
87
|
-
salt: inputDomain.salt,
|
|
88
|
-
extensions: [...inputDomain.extensions],
|
|
89
|
-
}),
|
|
92
|
+
eip5267Domain,
|
|
90
93
|
});
|
|
91
94
|
// Bind the permit to one of the registered fixed vault bundles deployments.
|
|
92
95
|
(0, validateRequirementSpender_js_1.validateRequirementSpender)({
|
|
@@ -72,8 +72,9 @@ const getMidnightApprovalRequirements = async (params) => {
|
|
|
72
72
|
spender: params.spender,
|
|
73
73
|
allowed: ["midnight", "midnightBundlesV2"],
|
|
74
74
|
});
|
|
75
|
-
if (params.amount === 0n)
|
|
75
|
+
if (params.amount === 0n) {
|
|
76
76
|
return [];
|
|
77
|
+
}
|
|
77
78
|
await (0, validateClientChainId_js_1.validateClientChainId)(params.viemClient, params.chainId);
|
|
78
79
|
const allowance = await (0, actions_1.readContract)(params.viemClient, {
|
|
79
80
|
address: params.token,
|
|
@@ -68,8 +68,9 @@ const getMidnightAuthorizationRequirement = async (params) => {
|
|
|
68
68
|
functionName: "isAuthorized",
|
|
69
69
|
args: [params.owner, params.authorized],
|
|
70
70
|
});
|
|
71
|
-
if (isAuthorized)
|
|
71
|
+
if (isAuthorized) {
|
|
72
72
|
return null;
|
|
73
|
+
}
|
|
73
74
|
return (0, morpho_ts_1.deepFreeze)({
|
|
74
75
|
to: midnight,
|
|
75
76
|
value: 0n,
|
|
@@ -47,11 +47,13 @@ const common_js_1 = require("../bundles/common.js");
|
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
49
|
const vaultV1InKindRedeem = ({ vault, args, metadata, }) => {
|
|
50
|
-
if (args.amount <= 0n)
|
|
50
|
+
if (args.amount <= 0n) {
|
|
51
51
|
throw new index_js_2.NonPositiveInputError("amount", args.amount);
|
|
52
|
+
}
|
|
52
53
|
(0, validate_js_1.validateDeadline)(args.deadline);
|
|
53
|
-
if (args.marketParamsList.length === 0)
|
|
54
|
+
if (args.marketParamsList.length === 0) {
|
|
54
55
|
throw new index_js_2.EmptyMarketParamsListError();
|
|
56
|
+
}
|
|
55
57
|
const to = (0, morpho_ts_1.getChainAddress)(vault.chainId, "bundles.vaultExitBundlesV1");
|
|
56
58
|
const marketParamsList = args.marketParamsList.map((marketParams) => ({
|
|
57
59
|
loanToken: marketParams.loanToken,
|
|
@@ -82,8 +84,9 @@ const vaultV1InKindRedeem = ({ vault, args, metadata, }) => {
|
|
|
82
84
|
],
|
|
83
85
|
}),
|
|
84
86
|
};
|
|
85
|
-
if (metadata)
|
|
87
|
+
if (metadata) {
|
|
86
88
|
tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
|
|
89
|
+
}
|
|
87
90
|
return (0, morpho_ts_1.deepFreeze)({
|
|
88
91
|
...tx,
|
|
89
92
|
action: {
|
|
@@ -90,7 +90,7 @@ const vaultV1MigrateToV2 = (params) => {
|
|
|
90
90
|
throw new index_js_1.AmountAndSharesExclusiveError();
|
|
91
91
|
}
|
|
92
92
|
const selectedAmount = assets ?? shares ?? 0n;
|
|
93
|
-
const amountField = assets
|
|
93
|
+
const amountField = assets == null ? "shares" : "assets";
|
|
94
94
|
// Validation only; rejects non-positive migration amounts.
|
|
95
95
|
(0, validatePositiveInput_js_1.validatePositiveInput)(amountField, selectedAmount);
|
|
96
96
|
// Validation only; rejects non-positive share-price bounds.
|