@morpho-org/morpho-sdk 10.1.0-next.0 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +1 -5
- package/lib/cjs/actions/blue/borrow.d.ts +13 -4
- package/lib/cjs/actions/blue/borrow.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/borrow.internal.js +36 -0
- package/lib/cjs/actions/blue/borrow.js +12 -18
- package/lib/cjs/actions/blue/common.d.ts +53 -28
- package/lib/cjs/actions/blue/common.js +36 -35
- package/lib/cjs/actions/blue/encode.d.ts +23 -0
- package/lib/cjs/actions/blue/encode.js +171 -0
- package/lib/cjs/actions/blue/refinance.d.ts +14 -5
- package/lib/cjs/actions/blue/refinance.internal.d.ts +42 -0
- package/lib/cjs/actions/blue/refinance.internal.js +65 -0
- package/lib/cjs/actions/blue/refinance.js +13 -65
- package/lib/cjs/actions/blue/refinanceValidation.d.ts +6 -6
- package/lib/cjs/actions/blue/refinanceValidation.js +10 -8
- package/lib/cjs/actions/blue/repay.d.ts +5 -4
- package/lib/cjs/actions/blue/repay.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/repay.internal.js +38 -0
- package/lib/cjs/actions/blue/repay.js +5 -19
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +6 -5
- package/lib/cjs/actions/blue/repayWithdrawCollateral.internal.d.ts +61 -0
- package/lib/cjs/actions/blue/repayWithdrawCollateral.internal.js +112 -0
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +6 -118
- package/lib/cjs/actions/blue/signatures.d.ts +30 -0
- package/lib/cjs/actions/blue/signatures.js +90 -0
- package/lib/cjs/actions/blue/supply.d.ts +6 -4
- package/lib/cjs/actions/blue/supply.internal.d.ts +32 -0
- package/lib/cjs/actions/blue/supply.internal.js +101 -0
- package/lib/cjs/actions/blue/supply.js +6 -69
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +5 -4
- package/lib/cjs/actions/blue/supplyCollateral.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/supplyCollateral.internal.js +37 -0
- package/lib/cjs/actions/blue/supplyCollateral.js +5 -19
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +15 -6
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.d.ts +65 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.js +98 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +13 -108
- package/lib/cjs/actions/blue/withdraw.d.ts +15 -6
- package/lib/cjs/actions/blue/withdraw.internal.d.ts +56 -0
- package/lib/cjs/actions/blue/withdraw.internal.js +87 -0
- package/lib/cjs/actions/blue/withdraw.js +13 -80
- package/lib/cjs/actions/blue/withdrawBuyCallback.d.ts +2 -2
- package/lib/cjs/actions/blue/withdrawBuyCallback.internal.d.ts +20 -0
- package/lib/cjs/actions/blue/withdrawBuyCallback.internal.js +58 -0
- package/lib/cjs/actions/blue/withdrawBuyCallback.js +2 -39
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +4 -3
- package/lib/cjs/actions/blue/withdrawCollateral.internal.d.ts +16 -0
- package/lib/cjs/actions/blue/withdrawCollateral.internal.js +39 -0
- package/lib/cjs/actions/blue/withdrawCollateral.js +5 -19
- package/lib/cjs/actions/bundles/common.d.ts +9 -0
- package/lib/cjs/actions/bundles/common.js +18 -6
- package/lib/cjs/actions/bundles/index.d.ts +1 -1
- package/lib/cjs/actions/bundles/index.js +3 -16
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +14 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +59 -60
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +22 -1
- package/lib/cjs/actions/midnight/cancelAndMake.js +46 -87
- package/lib/cjs/actions/midnight/cancelOffers.d.ts +11 -0
- package/lib/cjs/actions/midnight/cancelOffers.js +22 -4
- package/lib/cjs/actions/midnight/encode.d.ts +36 -0
- package/lib/cjs/actions/midnight/encode.js +554 -0
- package/lib/cjs/actions/midnight/index.d.ts +14 -13
- package/lib/cjs/actions/midnight/index.js +29 -13
- package/lib/cjs/actions/midnight/parse.d.ts +35 -0
- package/lib/cjs/actions/midnight/parse.js +73 -0
- package/lib/cjs/actions/midnight/parseCollateralBatch.d.ts +58 -0
- package/lib/cjs/actions/midnight/parseCollateralBatch.js +216 -0
- package/lib/cjs/actions/midnight/redeem.d.ts +16 -3
- package/lib/cjs/actions/midnight/redeem.js +22 -51
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +13 -0
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +42 -67
- package/lib/cjs/actions/midnight/supplyCollateral.d.ts +40 -5
- package/lib/cjs/actions/midnight/supplyCollateral.js +60 -54
- package/lib/cjs/actions/midnight/supplyCollateralBatch.d.ts +3 -3
- package/lib/cjs/actions/midnight/supplyCollateralBatch.js +3 -62
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +24 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +39 -67
- package/lib/cjs/actions/midnight/supplyCollateralWithNative.d.ts +77 -0
- package/lib/cjs/actions/midnight/supplyCollateralWithNative.js +142 -0
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +17 -2
- package/lib/cjs/actions/midnight/takeBorrow.js +25 -56
- package/lib/cjs/actions/midnight/takeLend.d.ts +21 -1
- package/lib/cjs/actions/midnight/takeLend.js +30 -58
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +34 -62
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +17 -2
- package/lib/cjs/actions/midnight/takeWithdraw.js +77 -115
- package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +16 -3
- package/lib/cjs/actions/midnight/withdrawCollateral.js +25 -56
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.d.ts +3 -3
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +3 -71
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +13 -0
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +39 -19
- package/lib/cjs/actions/requirements/blue/index.d.ts +1 -1
- package/lib/cjs/actions/requirements/blue/index.js +3 -15
- package/lib/cjs/actions/requirements/chainCheck.d.ts +5 -0
- package/lib/cjs/actions/requirements/chainCheck.js +10 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +40 -27
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +11 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +36 -17
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +14 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +44 -9
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +10 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +61 -24
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +10 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +25 -4
- package/lib/cjs/actions/requirements/encode/index.d.ts +5 -5
- package/lib/cjs/actions/requirements/encode/index.js +11 -19
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +26 -11
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +40 -12
- package/lib/cjs/actions/requirements/index.d.ts +1 -1
- package/lib/cjs/actions/requirements/index.js +3 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +11 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +34 -19
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +26 -12
- package/lib/cjs/actions/requirements/midnight/index.d.ts +2 -2
- package/lib/cjs/actions/requirements/midnight/index.js +5 -16
- package/lib/cjs/actions/vaultV1/deposit.d.ts +23 -1
- package/lib/cjs/actions/vaultV1/deposit.js +48 -11
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +18 -1
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +36 -16
- package/lib/cjs/actions/vaultV1/index.d.ts +5 -5
- package/lib/cjs/actions/vaultV1/index.js +11 -19
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +24 -2
- package/lib/cjs/actions/vaultV1/migrateToV2.js +51 -12
- package/lib/cjs/actions/vaultV1/redeem.d.ts +22 -2
- package/lib/cjs/actions/vaultV1/redeem.js +30 -8
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +21 -1
- package/lib/cjs/actions/vaultV1/withdraw.js +30 -8
- package/lib/cjs/actions/vaultV2/deposit.d.ts +23 -1
- package/lib/cjs/actions/vaultV2/deposit.js +48 -11
- package/lib/cjs/actions/vaultV2/forceRedeem.d.ts +20 -2
- package/lib/cjs/actions/vaultV2/forceRedeem.js +39 -8
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +25 -2
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +38 -15
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +18 -1
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +35 -15
- package/lib/cjs/actions/vaultV2/index.d.ts +6 -6
- package/lib/cjs/actions/vaultV2/index.js +13 -20
- package/lib/cjs/actions/vaultV2/redeem.d.ts +22 -2
- package/lib/cjs/actions/vaultV2/redeem.js +30 -8
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +21 -1
- package/lib/cjs/actions/vaultV2/withdraw.js +30 -8
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +1 -5
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +1 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +1 -2
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +2 -0
- package/lib/cjs/entities/blue/blue.d.ts +118 -28
- package/lib/cjs/entities/blue/blue.js +503 -416
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/midnight.d.ts +117 -41
- package/lib/cjs/entities/midnight/midnight.js +472 -843
- package/lib/cjs/entities/midnight/parse.d.ts +74 -0
- package/lib/cjs/entities/midnight/parse.js +336 -0
- package/lib/cjs/entities/midnight/prepare.d.ts +47 -0
- package/lib/cjs/entities/midnight/prepare.js +293 -0
- package/lib/cjs/entities/midnight/publication.d.ts +7 -3
- package/lib/cjs/entities/midnight/publication.js +10 -7
- package/lib/cjs/entities/midnight/types.d.ts +7 -0
- package/lib/cjs/entities/requirements/assertContractCode.d.ts +10 -5
- package/lib/cjs/entities/requirements/assertContractCode.js +24 -15
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +15 -0
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +59 -51
- package/lib/cjs/entities/requirements/getErc2612Permit.d.ts +7 -3
- package/lib/cjs/entities/requirements/getErc2612Permit.js +20 -4
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +15 -0
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +24 -7
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +14 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +27 -7
- package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.js +4 -3
- package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.js +4 -3
- package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.js +4 -3
- package/lib/cjs/entities/requirements/index.d.ts +2 -2
- package/lib/cjs/entities/requirements/index.js +5 -16
- package/lib/cjs/entities/requirements/validateNativeRequirements.d.ts +21 -0
- package/lib/cjs/entities/requirements/validateNativeRequirements.js +37 -0
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.d.ts +2 -2
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.js +1 -7
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +5 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +29 -46
- package/lib/cjs/entities/vaultV1/vaultV1.js +234 -159
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.d.ts +4 -0
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.js +9 -4
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.d.ts +2 -2
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.js +1 -7
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +40 -92
- package/lib/cjs/entities/vaultV2/vaultV2.js +230 -188
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +13 -5
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +21 -27
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +5 -7
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- package/lib/cjs/helpers/constant.d.ts +2 -0
- package/lib/cjs/helpers/constant.js +3 -1
- package/lib/cjs/helpers/deadShares.js +0 -3
- package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
- package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.js +18 -0
- package/lib/cjs/helpers/index.d.ts +1 -1
- package/lib/cjs/helpers/index.js +2 -1
- package/lib/cjs/helpers/parse.d.ts +33 -0
- package/lib/cjs/helpers/parse.js +71 -0
- package/lib/cjs/helpers/parseMidnight.d.ts +48 -0
- package/lib/cjs/helpers/parseMidnight.js +95 -0
- package/lib/cjs/helpers/parseMidnightMaker.d.ts +44 -0
- package/lib/cjs/helpers/parseMidnightMaker.js +154 -0
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +4 -5
- package/lib/cjs/helpers/quoteBlueRepay.d.ts +7 -3
- package/lib/cjs/helpers/quoteBlueRepay.js +20 -7
- package/lib/cjs/helpers/reallocationPenalty.d.ts +10 -0
- package/lib/cjs/helpers/reallocationPenalty.js +32 -0
- package/lib/cjs/helpers/referralFee.d.ts +2 -1
- package/lib/cjs/helpers/referralFee.js +5 -1
- package/lib/cjs/helpers/validate.d.ts +34 -6
- package/lib/cjs/helpers/validate.js +52 -9
- package/lib/cjs/helpers/validateMidnightBounds.d.ts +1 -2
- package/lib/cjs/helpers/validateMidnightBounds.js +1 -2
- package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.d.ts +8 -0
- package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.js +4 -4
- package/lib/cjs/helpers/validateMidnightPublication.d.ts +17 -1
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +1 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +4 -5
- package/lib/cjs/transactionPlan/blue/borrow.d.ts +11 -5
- package/lib/cjs/transactionPlan/blue/borrow.js +26 -8
- package/lib/cjs/transactionPlan/blue/refinance.d.ts +9 -2
- package/lib/cjs/transactionPlan/blue/refinance.js +36 -11
- package/lib/cjs/transactionPlan/blue/repay.d.ts +1 -2
- package/lib/cjs/transactionPlan/blue/repay.js +3 -3
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +35 -7
- package/lib/cjs/transactionPlan/blue/supply.d.ts +1 -2
- package/lib/cjs/transactionPlan/blue/supply.js +1 -2
- package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +2 -3
- package/lib/cjs/transactionPlan/blue/supplyCollateral.js +2 -3
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +25 -8
- package/lib/cjs/transactionPlan/blue/withdraw.d.ts +17 -7
- package/lib/cjs/transactionPlan/blue/withdraw.js +28 -9
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +17 -9
- package/lib/cjs/transactionPlan/deposit.js +4 -0
- package/lib/cjs/transactionPlan/intent.d.ts +1 -1
- package/lib/cjs/transactionPlan/intent.js +4 -2
- package/lib/cjs/transactionPlan/plan.d.ts +8 -4
- package/lib/cjs/transactionPlan/plan.js +8 -4
- package/lib/cjs/transactionPlan/types.d.ts +6 -0
- package/lib/cjs/transactionPlan/validation.d.ts +1 -1
- package/lib/cjs/transactionPlan/validation.js +3 -0
- package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +5 -5
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +5 -5
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +7 -3
- package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +1 -2
- package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -2
- package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -3
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +3 -3
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +3 -3
- package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -3
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -3
- package/lib/cjs/types/action.d.ts +13 -2
- package/lib/cjs/types/error.d.ts +27 -8
- package/lib/cjs/types/error.js +42 -12
- package/lib/cjs/types/sharedLiquidity.d.ts +7 -2
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +2 -4
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/blue/borrow.d.ts +13 -4
- package/lib/esm/actions/blue/borrow.internal.d.ts +13 -0
- package/lib/esm/actions/blue/borrow.internal.js +31 -0
- package/lib/esm/actions/blue/borrow.js +12 -18
- package/lib/esm/actions/blue/common.d.ts +53 -28
- package/lib/esm/actions/blue/common.js +36 -34
- package/lib/esm/actions/blue/encode.d.ts +23 -0
- package/lib/esm/actions/blue/encode.js +164 -0
- package/lib/esm/actions/blue/refinance.d.ts +14 -5
- package/lib/esm/actions/blue/refinance.internal.d.ts +42 -0
- package/lib/esm/actions/blue/refinance.internal.js +59 -0
- package/lib/esm/actions/blue/refinance.js +13 -65
- package/lib/esm/actions/blue/refinanceValidation.d.ts +6 -6
- package/lib/esm/actions/blue/refinanceValidation.js +11 -9
- package/lib/esm/actions/blue/repay.d.ts +5 -4
- package/lib/esm/actions/blue/repay.internal.d.ts +13 -0
- package/lib/esm/actions/blue/repay.internal.js +33 -0
- package/lib/esm/actions/blue/repay.js +5 -19
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +6 -5
- package/lib/esm/actions/blue/repayWithdrawCollateral.internal.d.ts +61 -0
- package/lib/esm/actions/blue/repayWithdrawCollateral.internal.js +104 -0
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +6 -118
- package/lib/esm/actions/blue/signatures.d.ts +30 -0
- package/lib/esm/actions/blue/signatures.js +82 -0
- package/lib/esm/actions/blue/supply.d.ts +6 -4
- package/lib/esm/actions/blue/supply.internal.d.ts +32 -0
- package/lib/esm/actions/blue/supply.internal.js +95 -0
- package/lib/esm/actions/blue/supply.js +6 -69
- package/lib/esm/actions/blue/supplyCollateral.d.ts +5 -4
- package/lib/esm/actions/blue/supplyCollateral.internal.d.ts +13 -0
- package/lib/esm/actions/blue/supplyCollateral.internal.js +32 -0
- package/lib/esm/actions/blue/supplyCollateral.js +5 -19
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +15 -6
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.d.ts +65 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.js +91 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +13 -108
- package/lib/esm/actions/blue/withdraw.d.ts +15 -6
- package/lib/esm/actions/blue/withdraw.internal.d.ts +56 -0
- package/lib/esm/actions/blue/withdraw.internal.js +80 -0
- package/lib/esm/actions/blue/withdraw.js +13 -80
- package/lib/esm/actions/blue/withdrawBuyCallback.d.ts +2 -2
- package/lib/esm/actions/blue/withdrawBuyCallback.internal.d.ts +20 -0
- package/lib/esm/actions/blue/withdrawBuyCallback.internal.js +53 -0
- package/lib/esm/actions/blue/withdrawBuyCallback.js +2 -39
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +4 -3
- package/lib/esm/actions/blue/withdrawCollateral.internal.d.ts +16 -0
- package/lib/esm/actions/blue/withdrawCollateral.internal.js +34 -0
- package/lib/esm/actions/blue/withdrawCollateral.js +5 -19
- package/lib/esm/actions/bundles/common.d.ts +9 -0
- package/lib/esm/actions/bundles/common.js +15 -4
- package/lib/esm/actions/bundles/index.d.ts +1 -1
- package/lib/esm/actions/bundles/index.js +1 -1
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +14 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +58 -61
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +22 -1
- package/lib/esm/actions/midnight/cancelAndMake.js +43 -85
- package/lib/esm/actions/midnight/cancelOffers.d.ts +11 -0
- package/lib/esm/actions/midnight/cancelOffers.js +18 -2
- package/lib/esm/actions/midnight/encode.d.ts +36 -0
- package/lib/esm/actions/midnight/encode.js +539 -0
- package/lib/esm/actions/midnight/index.d.ts +14 -13
- package/lib/esm/actions/midnight/index.js +14 -13
- package/lib/esm/actions/midnight/parse.d.ts +35 -0
- package/lib/esm/actions/midnight/parse.js +68 -0
- package/lib/esm/actions/midnight/parseCollateralBatch.d.ts +58 -0
- package/lib/esm/actions/midnight/parseCollateralBatch.js +209 -0
- package/lib/esm/actions/midnight/redeem.d.ts +16 -3
- package/lib/esm/actions/midnight/redeem.js +20 -50
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +13 -0
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +38 -64
- package/lib/esm/actions/midnight/supplyCollateral.d.ts +40 -5
- package/lib/esm/actions/midnight/supplyCollateral.js +57 -53
- package/lib/esm/actions/midnight/supplyCollateralBatch.d.ts +3 -3
- package/lib/esm/actions/midnight/supplyCollateralBatch.js +3 -62
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +24 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +34 -63
- package/lib/esm/actions/midnight/supplyCollateralWithNative.d.ts +77 -0
- package/lib/esm/actions/midnight/supplyCollateralWithNative.js +137 -0
- package/lib/esm/actions/midnight/takeBorrow.d.ts +17 -2
- package/lib/esm/actions/midnight/takeBorrow.js +21 -53
- package/lib/esm/actions/midnight/takeLend.d.ts +21 -1
- package/lib/esm/actions/midnight/takeLend.js +27 -56
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +31 -60
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +17 -2
- package/lib/esm/actions/midnight/takeWithdraw.js +76 -115
- package/lib/esm/actions/midnight/withdrawCollateral.d.ts +16 -3
- package/lib/esm/actions/midnight/withdrawCollateral.js +23 -55
- package/lib/esm/actions/midnight/withdrawCollateralBatch.d.ts +3 -3
- package/lib/esm/actions/midnight/withdrawCollateralBatch.js +3 -71
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +13 -0
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +36 -18
- package/lib/esm/actions/requirements/blue/index.d.ts +1 -1
- package/lib/esm/actions/requirements/blue/index.js +1 -1
- package/lib/esm/actions/requirements/chainCheck.d.ts +5 -0
- package/lib/esm/actions/requirements/chainCheck.js +6 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +36 -25
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +11 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +33 -16
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +14 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +41 -8
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +10 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +59 -24
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +10 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +21 -2
- package/lib/esm/actions/requirements/encode/index.d.ts +5 -5
- package/lib/esm/actions/requirements/encode/index.js +5 -5
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +26 -11
- package/lib/esm/actions/requirements/getRequirementsApproval.js +38 -12
- package/lib/esm/actions/requirements/index.d.ts +1 -1
- package/lib/esm/actions/requirements/index.js +1 -1
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +11 -0
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +31 -18
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -0
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +22 -10
- package/lib/esm/actions/requirements/midnight/index.d.ts +2 -2
- package/lib/esm/actions/requirements/midnight/index.js +2 -2
- package/lib/esm/actions/vaultV1/deposit.d.ts +23 -1
- package/lib/esm/actions/vaultV1/deposit.js +45 -10
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +18 -1
- package/lib/esm/actions/vaultV1/inKindRedeem.js +33 -15
- package/lib/esm/actions/vaultV1/index.d.ts +5 -5
- package/lib/esm/actions/vaultV1/index.js +5 -5
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +24 -2
- package/lib/esm/actions/vaultV1/migrateToV2.js +49 -12
- package/lib/esm/actions/vaultV1/redeem.d.ts +22 -2
- package/lib/esm/actions/vaultV1/redeem.js +28 -8
- package/lib/esm/actions/vaultV1/withdraw.d.ts +21 -1
- package/lib/esm/actions/vaultV1/withdraw.js +28 -8
- package/lib/esm/actions/vaultV2/deposit.d.ts +23 -1
- package/lib/esm/actions/vaultV2/deposit.js +45 -10
- package/lib/esm/actions/vaultV2/forceRedeem.d.ts +20 -2
- package/lib/esm/actions/vaultV2/forceRedeem.js +35 -6
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +25 -2
- package/lib/esm/actions/vaultV2/forceWithdraw.js +35 -14
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +18 -1
- package/lib/esm/actions/vaultV2/inKindRedeem.js +32 -14
- package/lib/esm/actions/vaultV2/index.d.ts +6 -6
- package/lib/esm/actions/vaultV2/index.js +6 -6
- package/lib/esm/actions/vaultV2/redeem.d.ts +22 -2
- package/lib/esm/actions/vaultV2/redeem.js +28 -8
- package/lib/esm/actions/vaultV2/withdraw.d.ts +21 -1
- package/lib/esm/actions/vaultV2/withdraw.js +28 -8
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +118 -28
- package/lib/esm/entities/blue/blue.js +485 -398
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +117 -41
- package/lib/esm/entities/midnight/midnight.js +455 -826
- package/lib/esm/entities/midnight/parse.d.ts +74 -0
- package/lib/esm/entities/midnight/parse.js +320 -0
- package/lib/esm/entities/midnight/prepare.d.ts +47 -0
- package/lib/esm/entities/midnight/prepare.js +282 -0
- package/lib/esm/entities/midnight/publication.d.ts +7 -3
- package/lib/esm/entities/midnight/publication.js +7 -3
- package/lib/esm/entities/midnight/types.d.ts +7 -0
- package/lib/esm/entities/requirements/assertContractCode.d.ts +10 -5
- package/lib/esm/entities/requirements/assertContractCode.js +24 -15
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +15 -0
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +53 -47
- package/lib/esm/entities/requirements/getErc2612Permit.d.ts +7 -3
- package/lib/esm/entities/requirements/getErc2612Permit.js +19 -4
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +15 -0
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +20 -5
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +14 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +23 -5
- package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.js +4 -3
- package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.js +4 -3
- package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.js +4 -3
- package/lib/esm/entities/requirements/index.d.ts +2 -2
- package/lib/esm/entities/requirements/index.js +2 -2
- package/lib/esm/entities/requirements/validateNativeRequirements.d.ts +21 -0
- package/lib/esm/entities/requirements/validateNativeRequirements.js +33 -0
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.d.ts +2 -2
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.js +1 -7
- package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
- package/lib/esm/entities/vaultV1/migrateToV2Quote.js +5 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +29 -46
- package/lib/esm/entities/vaultV1/vaultV1.js +214 -139
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.d.ts +4 -0
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.js +10 -5
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.d.ts +2 -2
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.js +1 -7
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +40 -92
- package/lib/esm/entities/vaultV2/vaultV2.js +214 -172
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +13 -5
- package/lib/esm/entities/vaultV2BlueReallocationData.js +19 -25
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/constant.d.ts +2 -0
- package/lib/esm/helpers/constant.js +2 -0
- package/lib/esm/helpers/deadShares.js +1 -4
- package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
- package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.js +15 -0
- package/lib/esm/helpers/index.d.ts +1 -1
- package/lib/esm/helpers/index.js +1 -1
- package/lib/esm/helpers/parse.d.ts +33 -0
- package/lib/esm/helpers/parse.js +61 -0
- package/lib/esm/helpers/parseMidnight.d.ts +48 -0
- package/lib/esm/helpers/parseMidnight.js +80 -0
- package/lib/esm/helpers/parseMidnightMaker.d.ts +44 -0
- package/lib/esm/helpers/parseMidnightMaker.js +147 -0
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +4 -5
- package/lib/esm/helpers/quoteBlueRepay.d.ts +7 -3
- package/lib/esm/helpers/quoteBlueRepay.js +21 -8
- package/lib/esm/helpers/reallocationPenalty.d.ts +10 -0
- package/lib/esm/helpers/reallocationPenalty.js +28 -0
- package/lib/esm/helpers/referralFee.d.ts +2 -1
- package/lib/esm/helpers/referralFee.js +5 -1
- package/lib/esm/helpers/validate.d.ts +34 -6
- package/lib/esm/helpers/validate.js +52 -11
- package/lib/esm/helpers/validateMidnightBounds.d.ts +1 -2
- package/lib/esm/helpers/validateMidnightBounds.js +1 -2
- package/lib/esm/helpers/validateMidnightCancelAndMakePublication.d.ts +8 -0
- package/lib/esm/helpers/validateMidnightCancelAndMakePublication.js +2 -2
- package/lib/esm/helpers/validateMidnightPublication.d.ts +17 -1
- package/lib/esm/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
- package/lib/esm/helpers/validateMidnightTakeFeasibility.js +1 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/midnight/errors.d.ts +1 -2
- package/lib/esm/midnight/errors.js +1 -2
- package/lib/esm/transactionPlan/blue/borrow.d.ts +11 -5
- package/lib/esm/transactionPlan/blue/borrow.js +27 -9
- package/lib/esm/transactionPlan/blue/refinance.d.ts +9 -2
- package/lib/esm/transactionPlan/blue/refinance.js +37 -12
- package/lib/esm/transactionPlan/blue/repay.d.ts +1 -2
- package/lib/esm/transactionPlan/blue/repay.js +4 -4
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +36 -8
- package/lib/esm/transactionPlan/blue/supply.d.ts +1 -2
- package/lib/esm/transactionPlan/blue/supply.js +1 -2
- package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +2 -3
- package/lib/esm/transactionPlan/blue/supplyCollateral.js +2 -3
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +25 -8
- package/lib/esm/transactionPlan/blue/withdraw.d.ts +17 -7
- package/lib/esm/transactionPlan/blue/withdraw.js +28 -9
- package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
- package/lib/esm/transactionPlan/blue/withdrawCollateral.js +17 -9
- package/lib/esm/transactionPlan/deposit.js +5 -1
- package/lib/esm/transactionPlan/intent.d.ts +1 -1
- package/lib/esm/transactionPlan/intent.js +4 -2
- package/lib/esm/transactionPlan/plan.d.ts +8 -4
- package/lib/esm/transactionPlan/plan.js +8 -4
- package/lib/esm/transactionPlan/types.d.ts +6 -0
- package/lib/esm/transactionPlan/validation.d.ts +1 -1
- package/lib/esm/transactionPlan/validation.js +3 -0
- package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +5 -5
- package/lib/esm/transactionPlan/vaultv1/deposit.js +5 -5
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +8 -4
- package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +1 -2
- package/lib/esm/transactionPlan/vaultv1/redeem.js +1 -2
- package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv1/withdraw.js +2 -3
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -3
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +3 -3
- package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv2/redeem.js +2 -3
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +2 -3
- package/lib/esm/types/action.d.ts +13 -2
- package/lib/esm/types/error.d.ts +27 -8
- package/lib/esm/types/error.js +38 -10
- package/lib/esm/types/sharedLiquidity.d.ts +7 -2
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +7 -7
|
@@ -25,12 +25,13 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
25
25
|
* @param params.account - Non-zero account whose supply position is withdrawn and which sends every plan transaction.
|
|
26
26
|
* @param params.marketId - Market ID matching the caller-fetched snapshot and its market tuple.
|
|
27
27
|
* @param params.marketData.chainId - Chain on which the market snapshot was fetched; must equal `chainId`.
|
|
28
|
-
* @param params.marketData.market - Caller-fetched `Market` snapshot
|
|
28
|
+
* @param params.marketData.market - Caller-fetched `Market` snapshot used to fix the market tuple; never stored in the plan.
|
|
29
29
|
* @param params.positionData.chainId - Position snapshot's chain; must match `chainId`.
|
|
30
|
-
* @param params.positionData.position - Caller-fetched `AccrualPosition` belonging to `account` and `marketId`; validates the withdrawal against supplied assets or shares.
|
|
30
|
+
* @param params.positionData.position - Caller-fetched `AccrualPosition` belonging to `account` and `marketId`; validates the withdrawal against supplied assets or shares and quotes share-mode penalty coverage.
|
|
31
31
|
* @param params.assets - Exact positive gross loan assets withdrawn in base units; exclusive with `shares`.
|
|
32
32
|
* @param params.shares - Exact positive supply shares burned; exclusive with `assets`, with no full-close sentinel or minimum-proceeds guarantee.
|
|
33
33
|
* @param params.reallocations - Optional ordered Vault V2 BluePublicAllocator inputs; defaults to an empty list. Penalties reduce withdrawal proceeds.
|
|
34
|
+
* @param params.maxPenalty - Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost.
|
|
34
35
|
* @param params.reallocations[].vault - Vault whose liquidity the allocator moves.
|
|
35
36
|
* @param params.reallocations[].from.type - Source discriminator: `market` or `idle`.
|
|
36
37
|
* @param params.reallocations[].from.adapter - Source adapter, required only for a `market` source.
|
|
@@ -42,7 +43,7 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
42
43
|
* @param params.reallocations[].to.adapter - Target adapter supplying the enclosing withdrawal market.
|
|
43
44
|
* @param params.reallocations[].assets - Positive reallocated assets in loan-token base units, bounded by uint128.
|
|
44
45
|
* @param params.reallocations[].penalty - Vault-configured WAD-scaled penalty, bounded by uint64 and applied with upward rounding per allocation.
|
|
45
|
-
* @param params.referralFee.bps - Optional integer referral fee in basis points of gross proceeds after allocator penalties; defaults to zero and must be
|
|
46
|
+
* @param params.referralFee.bps - Optional integer referral fee in basis points of gross proceeds after allocator penalties; defaults to zero and must be at most 1,000.
|
|
46
47
|
* @param params.referralFee.recipient - Optional fee recipient; required and non-zero when `referralFee.bps` is positive.
|
|
47
48
|
* @param params.supportSignature - Optional Morpho authorization signature preference; defaults to `false`, selecting a direct authorization transaction when needed. Neither mode requests a token allowance or Permit2 signature.
|
|
48
49
|
* @param params.now - Optional reference timestamp in seconds, normally the latest block timestamp; defaults to the device clock.
|
|
@@ -50,6 +51,7 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
50
51
|
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to every built transaction; omitted by default.
|
|
51
52
|
* @param params.deployless - Optional shared intent field; unused because withdrawal reads no token metadata.
|
|
52
53
|
* @returns A deep-frozen, data-only `{ version, chainId, account, expiresAt, steps, signatureRequests, calldataOrigin? }` plan with a withdrawal step. Direct Morpho authorization is a preceding step; signed authorization is consumed inline by the withdrawal. Attach signatures before building.
|
|
54
|
+
* @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
|
|
53
55
|
* @throws {ChainIdMismatchError} when the client declares or its transport serves another chain.
|
|
54
56
|
* @throws {UnsupportedChainIdError} when `chainId` is absent from the registry.
|
|
55
57
|
* @throws {UnknownAddressError} when Blue or BlueBundlesV1 is not registered on `chainId`.
|
|
@@ -60,8 +62,9 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
60
62
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
61
63
|
* @throws {NonPositiveInputError} when expiry, the selected withdrawal amount, or a reallocation amount is not positive.
|
|
62
64
|
* @throws {ExpiredDeadlineError} when `expiresAt` is at or before `now`.
|
|
63
|
-
* @throws {NegativeInputError} when the referral fee, a withdrawal amount, or a reallocation penalty is negative.
|
|
64
|
-
* @throws {InputExceedsMaxError} when referral basis points exceed
|
|
65
|
+
* @throws {NegativeInputError} when the referral fee, a withdrawal amount, maxPenalty, or a reallocation penalty is negative.
|
|
66
|
+
* @throws {InputExceedsMaxError} when referral basis points exceed 1,000, an encoded amount or penalty exceeds its ABI bound, or aggregate allocator penalties exceed withdrawn assets (the snapshot's downward-rounded asset quote in shares mode).
|
|
67
|
+
* Also thrown when maxPenalty exceeds WAD or a penalty exceeds maxPenalty (zero by default).
|
|
65
68
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
66
69
|
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not an object or has a legacy Vault V1 shape.
|
|
67
70
|
* @throws {InvalidReallocationAddressError} when a reallocation vault or adapter address is malformed.
|
|
@@ -69,7 +72,6 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
69
72
|
* @throws {InconsistentReallocationPenaltyError} when allocations from one vault specify different penalties.
|
|
70
73
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a reallocation source is the withdrawal market.
|
|
71
74
|
* @throws {MutuallyExclusiveWithdrawAmountsError} when both withdrawal modes are nonzero.
|
|
72
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000.
|
|
73
75
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no non-zero recipient.
|
|
74
76
|
* @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
|
|
75
77
|
* @throws {MissingAccrualPositionError} when the required position snapshot is missing.
|
|
@@ -103,6 +105,7 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
103
105
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
104
106
|
*/
|
|
105
107
|
async function prepareBlueWithdraw(client, params) {
|
|
108
|
+
const { maxPenalty } = params;
|
|
106
109
|
await (0, validateClientChainId_js_1.validateClientChainId)(client, params.chainId);
|
|
107
110
|
const { positionData: snapshot } = params;
|
|
108
111
|
if (snapshot == null) {
|
|
@@ -123,6 +126,7 @@ async function prepareBlueWithdraw(client, params) {
|
|
|
123
126
|
withdrawAssets: "assets" in params ? (params.assets ?? 0n) : 0n,
|
|
124
127
|
withdrawShares: "shares" in params ? (params.shares ?? 0n) : 0n,
|
|
125
128
|
reallocations: params.reallocations ?? [],
|
|
129
|
+
...(maxPenalty !== undefined && { maxPenalty }),
|
|
126
130
|
deadline: intent.deadline,
|
|
127
131
|
referralFeePct: intent.referralFeePct,
|
|
128
132
|
referralFeeRecipient: intent.referralFeeRecipient ?? viem_1.zeroAddress,
|
|
@@ -135,7 +139,7 @@ async function prepareBlueWithdraw(client, params) {
|
|
|
135
139
|
});
|
|
136
140
|
const max = inputs.withdrawAssets > 0n
|
|
137
141
|
? inputs.withdrawAssets
|
|
138
|
-
:
|
|
142
|
+
: snapshot.position.market.toSupplyAssets(inputs.withdrawShares, "Down");
|
|
139
143
|
const penalty = (0, common_js_1.getBlueBundlesV1PenaltyAssets)(inputs.reallocations);
|
|
140
144
|
if (penalty > max) {
|
|
141
145
|
throw new index_js_1.InputExceedsMaxError({
|
|
@@ -208,7 +212,13 @@ function validateBlueWithdrawAuthorizationRequest(request, action) {
|
|
|
208
212
|
deadline: action.inputs.deadline,
|
|
209
213
|
});
|
|
210
214
|
}
|
|
211
|
-
/**
|
|
215
|
+
/**
|
|
216
|
+
* @internal Encodes the self-contained withdrawal recipe and its inline authorization, if requested.
|
|
217
|
+
* @param action - Withdrawal recipe with optional WAD-scaled maxPenalty in [0, WAD], defaulting to zero.
|
|
218
|
+
* @param requests - Available authorization signatures.
|
|
219
|
+
* @throws {NegativeInputError} when maxPenalty is negative.
|
|
220
|
+
* @throws {InputExceedsMaxError} when maxPenalty exceeds WAD or a penalty exceeds maxPenalty (zero by default).
|
|
221
|
+
*/
|
|
212
222
|
function buildBlueWithdraw(action, requests = []) {
|
|
213
223
|
const { chainId, account, marketParams, authorizationNonce: _authorizationNonce, ...args } = action.inputs;
|
|
214
224
|
let authorizationSignature;
|
|
@@ -242,7 +252,10 @@ function buildBlueWithdraw(action, requests = []) {
|
|
|
242
252
|
}
|
|
243
253
|
const targetMarketParams = new blue_sdk_1.MarketParams(marketParams);
|
|
244
254
|
// Reject malformed entries with typed errors before reading their source fields.
|
|
245
|
-
(0, validate_js_1.validateVaultV2BlueReallocations)(args.reallocations,
|
|
255
|
+
(0, validate_js_1.validateVaultV2BlueReallocations)(args.reallocations, {
|
|
256
|
+
targetMarketId: targetMarketParams.id,
|
|
257
|
+
maxPenalty: args.maxPenalty,
|
|
258
|
+
});
|
|
246
259
|
const reallocations = args.reallocations.map((entry) => ({
|
|
247
260
|
...entry,
|
|
248
261
|
from: entry.from.type === "market"
|
|
@@ -265,6 +278,12 @@ function buildBlueWithdraw(action, requests = []) {
|
|
|
265
278
|
/** @internal Validates stored withdrawal scalars and allocator input shapes. */
|
|
266
279
|
function validateBlueWithdrawPlanAction(action, path) {
|
|
267
280
|
const inputs = (0, validation_js_1.getPlanObject)(action.inputs, `${path}.inputs`);
|
|
281
|
+
if (inputs.maxPenalty !== undefined) {
|
|
282
|
+
(0, validation_js_1.validatePlanField)(inputs.maxPenalty, {
|
|
283
|
+
path: `${path}.inputs.maxPenalty`,
|
|
284
|
+
type: "uint256 bigint",
|
|
285
|
+
});
|
|
286
|
+
}
|
|
268
287
|
const roles = (0, validation_js_1.getPlanObject)(action.signatureRequestIds, `${path}.signatureRequestIds`);
|
|
269
288
|
if (roles.morphoAuthorization !== undefined) {
|
|
270
289
|
(0, validation_js_1.validatePlanField)(roles.morphoAuthorization, {
|
|
@@ -30,7 +30,8 @@ export interface BlueWithdrawCollateralPlanParams extends IntentParams, Referenc
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Prepares a BlueBundlesV1 collateral withdrawal with direct or inline signed Morpho authorization.
|
|
33
|
-
* Health
|
|
33
|
+
* Health uses the expiry floored at max(now, lastUpdate), with the entity's LLTV buffer.
|
|
34
|
+
* Expiries more than 365 days out retain the legacy +2h projection for unlimited sentinels.
|
|
34
35
|
* No token allowance or Permit2 prerequisite is read or produced.
|
|
35
36
|
* @param client - Viem client used for registered contract-code and Morpho authorization reads.
|
|
36
37
|
* @param params - Intent and matching market and account position snapshots.
|
|
@@ -40,9 +41,9 @@ export interface BlueWithdrawCollateralPlanParams extends IntentParams, Referenc
|
|
|
40
41
|
* @param params.marketData.chainId - Chain from which the market snapshot was fetched; must equal `chainId`.
|
|
41
42
|
* @param params.marketData.market - Caller-fetched `Market` providing the market tuple and LLTV.
|
|
42
43
|
* @param params.positionData.chainId - Chain from which the position snapshot was fetched; must equal `chainId`.
|
|
43
|
-
* @param params.positionData.position - Caller-fetched `AccrualPosition` for `account` and `marketId`, used for the
|
|
44
|
+
* @param params.positionData.position - Caller-fetched `AccrualPosition` for `account` and `marketId`, used for the deadline-accrued health check.
|
|
44
45
|
* @param params.collateralAssets - Positive collateral withdrawal in token base units, not exceeding the position's collateral.
|
|
45
|
-
* @param params.referralFee.bps - Optional integer referral fee in basis points; defaults to zero and must be
|
|
46
|
+
* @param params.referralFee.bps - Optional integer referral fee in basis points; defaults to zero and must be at most 1,000.
|
|
46
47
|
* @param params.referralFee.recipient - Non-zero fee recipient required when the optional fee is positive.
|
|
47
48
|
* @param params.supportSignature - Optional Morpho authorization signature preference, defaulting to `false`; otherwise prepares a direct authorization transaction when needed.
|
|
48
49
|
* @param params.now - Optional reference timestamp in Unix seconds, normally the latest block timestamp; defaults to the device clock.
|
|
@@ -59,9 +60,8 @@ export interface BlueWithdrawCollateralPlanParams extends IntentParams, Referenc
|
|
|
59
60
|
* @throws {NonPositiveInputError} when `expiresAt` or `collateralAssets` is not positive.
|
|
60
61
|
* @throws {ExpiredDeadlineError} when `expiresAt` is at or before `now`.
|
|
61
62
|
* @throws {NegativeInputError} when `referralFee.bps` is negative.
|
|
62
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
63
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000 or `collateralAssets` exceeds uint256.
|
|
63
64
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
64
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000.
|
|
65
65
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no non-zero recipient.
|
|
66
66
|
* @throws {UnsupportedMarketIrmError} when projecting an indebted position requires an unsupported IRM without rate data.
|
|
67
67
|
* @throws {WithdrawExceedsCollateralError} when `collateralAssets` exceeds the position's collateral.
|
|
@@ -9,6 +9,7 @@ const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
|
9
9
|
const withdrawCollateral_js_1 = require("../../actions/blue/withdrawCollateral.js");
|
|
10
10
|
const common_js_1 = require("../../actions/bundles/common.js");
|
|
11
11
|
const constant_js_1 = require("../../helpers/constant.js");
|
|
12
|
+
const getBlueBundlesV1QuoteTimestamp_js_1 = require("../../helpers/getBlueBundlesV1QuoteTimestamp.js");
|
|
12
13
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
13
14
|
const index_js_1 = require("../../types/index.js");
|
|
14
15
|
const error_js_1 = require("../error.js");
|
|
@@ -17,7 +18,8 @@ const authorization_js_1 = require("./authorization.js");
|
|
|
17
18
|
const prepare_js_1 = require("./prepare.js");
|
|
18
19
|
/**
|
|
19
20
|
* Prepares a BlueBundlesV1 collateral withdrawal with direct or inline signed Morpho authorization.
|
|
20
|
-
* Health
|
|
21
|
+
* Health uses the expiry floored at max(now, lastUpdate), with the entity's LLTV buffer.
|
|
22
|
+
* Expiries more than 365 days out retain the legacy +2h projection for unlimited sentinels.
|
|
21
23
|
* No token allowance or Permit2 prerequisite is read or produced.
|
|
22
24
|
* @param client - Viem client used for registered contract-code and Morpho authorization reads.
|
|
23
25
|
* @param params - Intent and matching market and account position snapshots.
|
|
@@ -27,9 +29,9 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
27
29
|
* @param params.marketData.chainId - Chain from which the market snapshot was fetched; must equal `chainId`.
|
|
28
30
|
* @param params.marketData.market - Caller-fetched `Market` providing the market tuple and LLTV.
|
|
29
31
|
* @param params.positionData.chainId - Chain from which the position snapshot was fetched; must equal `chainId`.
|
|
30
|
-
* @param params.positionData.position - Caller-fetched `AccrualPosition` for `account` and `marketId`, used for the
|
|
32
|
+
* @param params.positionData.position - Caller-fetched `AccrualPosition` for `account` and `marketId`, used for the deadline-accrued health check.
|
|
31
33
|
* @param params.collateralAssets - Positive collateral withdrawal in token base units, not exceeding the position's collateral.
|
|
32
|
-
* @param params.referralFee.bps - Optional integer referral fee in basis points; defaults to zero and must be
|
|
34
|
+
* @param params.referralFee.bps - Optional integer referral fee in basis points; defaults to zero and must be at most 1,000.
|
|
33
35
|
* @param params.referralFee.recipient - Non-zero fee recipient required when the optional fee is positive.
|
|
34
36
|
* @param params.supportSignature - Optional Morpho authorization signature preference, defaulting to `false`; otherwise prepares a direct authorization transaction when needed.
|
|
35
37
|
* @param params.now - Optional reference timestamp in Unix seconds, normally the latest block timestamp; defaults to the device clock.
|
|
@@ -46,9 +48,8 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
46
48
|
* @throws {NonPositiveInputError} when `expiresAt` or `collateralAssets` is not positive.
|
|
47
49
|
* @throws {ExpiredDeadlineError} when `expiresAt` is at or before `now`.
|
|
48
50
|
* @throws {NegativeInputError} when `referralFee.bps` is negative.
|
|
49
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
51
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000 or `collateralAssets` exceeds uint256.
|
|
50
52
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
51
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000.
|
|
52
53
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no non-zero recipient.
|
|
53
54
|
* @throws {UnsupportedMarketIrmError} when projecting an indebted position requires an unsupported IRM without rate data.
|
|
54
55
|
* @throws {WithdrawExceedsCollateralError} when `collateralAssets` exceeds the position's collateral.
|
|
@@ -113,8 +114,11 @@ async function prepareBlueWithdrawCollateral(client, params) {
|
|
|
113
114
|
(0, validate_js_1.validatePositionHealthAfterWithdraw)({
|
|
114
115
|
positionData: position.borrowShares === 0n
|
|
115
116
|
? new blue_sdk_1.AccrualPosition(position, position.market)
|
|
116
|
-
: position.accrueInterest(
|
|
117
|
-
|
|
117
|
+
: position.accrueInterest((0, getBlueBundlesV1QuoteTimestamp_js_1.getBlueBundlesV1QuoteTimestamp)({
|
|
118
|
+
lastUpdate: position.market.lastUpdate,
|
|
119
|
+
now,
|
|
120
|
+
deadline: resolvedIntent.deadline,
|
|
121
|
+
})),
|
|
118
122
|
withdrawAmount: collateralAssets,
|
|
119
123
|
lltv,
|
|
120
124
|
marketId,
|
|
@@ -170,7 +174,7 @@ function validateBlueWithdrawCollateralAuthorizationRequest(request, action) {
|
|
|
170
174
|
}
|
|
171
175
|
/** @internal Encodes the self-contained collateral withdrawal recipe. */
|
|
172
176
|
function buildBlueWithdrawCollateral(action, requests) {
|
|
173
|
-
const { chainId, account, marketParams,
|
|
177
|
+
const { chainId, account, marketParams, collateralAssets, maxLtv, deadline, referralFeePct, referralFeeRecipient, } = action.inputs;
|
|
174
178
|
const id = action.signatureRequestIds.morphoAuthorization;
|
|
175
179
|
const request = id === undefined
|
|
176
180
|
? undefined
|
|
@@ -185,7 +189,11 @@ function buildBlueWithdrawCollateral(action, requests) {
|
|
|
185
189
|
return (0, withdrawCollateral_js_1.blueWithdrawCollateral)({
|
|
186
190
|
market: { chainId, marketParams: new blue_sdk_1.MarketParams(marketParams) },
|
|
187
191
|
args: {
|
|
188
|
-
|
|
192
|
+
collateralAssets,
|
|
193
|
+
maxLtv,
|
|
194
|
+
deadline,
|
|
195
|
+
referralFeePct,
|
|
196
|
+
referralFeeRecipient,
|
|
189
197
|
userAddress: account,
|
|
190
198
|
authorizationSignature: request?.kind === "morphoAuthorization" &&
|
|
191
199
|
request.signature !== undefined
|
|
@@ -36,6 +36,8 @@ function validateDepositPlanAction(action, path) {
|
|
|
36
36
|
function resolveDepositInputs(params, now) {
|
|
37
37
|
const { vault, chainId, assets } = params;
|
|
38
38
|
const intent = (0, intent_js_1.resolveIntent)(params, now);
|
|
39
|
+
// Bound forward accrual for both vault deposit plan kinds.
|
|
40
|
+
(0, validate_js_1.validateVaultDepositDeadline)(intent.deadline, { now, field: "expiresAt" });
|
|
39
41
|
const slippageTolerance = params.slippageTolerance ?? blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE;
|
|
40
42
|
(0, validate_js_1.validateSlippageTolerance)(slippageTolerance);
|
|
41
43
|
const native = (params.funding ?? { type: "erc20" }).type === "native";
|
|
@@ -68,6 +70,8 @@ async function prepareVaultDeposit(client, params) {
|
|
|
68
70
|
const { chainId, account, assets } = params;
|
|
69
71
|
const vault = params.vault.address;
|
|
70
72
|
const now = params.now ?? morpho_ts_1.Time.timestamp();
|
|
73
|
+
// Reject a non-bigint clock before deriving the default expiry.
|
|
74
|
+
(0, validate_js_1.validateReferenceTime)(now);
|
|
71
75
|
const { intent, native, common, asset, maxSharePrice } = resolveDepositInputs(params, now);
|
|
72
76
|
const spender = (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1");
|
|
73
77
|
const tokenPermitRequestId = `${params.type}:tokenPermit`;
|
|
@@ -10,7 +10,7 @@ export type Funding = {
|
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
13
|
-
* Referral fee in basis points of the gross amount, paid to `recipient`.
|
|
13
|
+
* Referral fee in basis points of the gross amount, paid to `recipient`. At most 1,000 bps (10%).
|
|
14
14
|
*/
|
|
15
15
|
export interface ReferralFee {
|
|
16
16
|
readonly bps: number;
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.resolveIntent = resolveIntent;
|
|
4
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
5
|
const viem_1 = require("viem");
|
|
6
|
+
const constant_js_1 = require("../helpers/constant.js");
|
|
6
7
|
const index_js_1 = require("../types/index.js");
|
|
7
8
|
const error_js_1 = require("./error.js");
|
|
8
9
|
const validation_js_1 = require("./validation.js");
|
|
9
10
|
const BASIS_POINTS = 10000n;
|
|
10
11
|
const WAD_PER_BASIS_POINT = morpho_ts_1.MathLib.WAD / BASIS_POINTS;
|
|
12
|
+
const MAX_REFERRAL_FEE_BPS = constant_js_1.MIDNIGHT_MAX_REFERRAL_FEE_PCT / WAD_PER_BASIS_POINT;
|
|
11
13
|
function toSafeInteger(field, value) {
|
|
12
14
|
if (!Number.isSafeInteger(value)) {
|
|
13
15
|
throw new error_js_1.NonIntegerInputError(field, value);
|
|
@@ -37,11 +39,11 @@ function resolveIntent(params, now) {
|
|
|
37
39
|
if (bps < 0n) {
|
|
38
40
|
throw new index_js_1.NegativeInputError("referralFee.bps", bps);
|
|
39
41
|
}
|
|
40
|
-
if (bps >
|
|
42
|
+
if (bps > MAX_REFERRAL_FEE_BPS) {
|
|
41
43
|
throw new index_js_1.InputExceedsMaxError({
|
|
42
44
|
field: "referralFee.bps",
|
|
43
45
|
value: bps,
|
|
44
|
-
max:
|
|
46
|
+
max: MAX_REFERRAL_FEE_BPS,
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
const { calldataOrigin } = params;
|
|
@@ -70,6 +70,7 @@ export declare function getPendingSignatureRequests(plan: TransactionPlan): read
|
|
|
70
70
|
* @param step - Recipe to encode; missing signatures on unrelated supported steps do not block it.
|
|
71
71
|
* @returns A frozen `{ to, data, value, action }`, ready to simulate or submit. `data` ends with the plan's `calldataOrigin` when one was set.
|
|
72
72
|
* @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent.
|
|
73
|
+
* @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
|
|
73
74
|
* @throws {InvalidSignatureError} If a stored signature has high s, cannot recover a public key or does not match the request owner.
|
|
74
75
|
* @throws {UnsupportedTransactionPlanVersionError} If the plan version is unsupported.
|
|
75
76
|
* @throws {UnsupportedTransactionPlanActionError} If any plan step or the selected step names an unsupported action type.
|
|
@@ -83,13 +84,14 @@ export declare function getPendingSignatureRequests(plan: TransactionPlan): read
|
|
|
83
84
|
* @throws {EmptyDeallocationsError} If a force-redeem step has no deallocations.
|
|
84
85
|
* @throws {EmptyMarketParamsListError} If a Vault V1 in-kind redemption step has no markets.
|
|
85
86
|
* @throws {ReferralFeePctExceededError} If the action's referral fee is at least WAD.
|
|
87
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
86
88
|
* @throws {ReferralFeeRecipientMissingError} If a positive referral fee has no nonzero recipient.
|
|
87
89
|
* @throws {IncompleteTransactionPlanError} If a referenced signature request or its signature is missing.
|
|
88
90
|
* @throws {TransactionPlanSignatureMismatchError} If a referenced request disagrees with the step's action or its encoding arguments.
|
|
89
91
|
* @throws {BundlesPermitMismatchError} If a stored signature cannot be parsed or a signed permit's encoding arguments do not match the step.
|
|
90
92
|
* @throws {MarketIdMismatchError} If a Blue market ID differs from its parameter tuple.
|
|
91
|
-
* @throws {NegativeInputError} If a Blue amount, native value, LTV bound or referral fee is negative.
|
|
92
|
-
* @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, or withdrawal-only funding is nonzero.
|
|
93
|
+
* @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative.
|
|
94
|
+
* @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), or withdrawal-only funding is nonzero.
|
|
93
95
|
* @throws {MutuallyExclusiveRepayAmountsError} If a Blue repayment specifies both nonzero assets and shares.
|
|
94
96
|
* @throws {MaxRepayAssetsBelowRepayAssetsError} If exact-asset funding cannot cover repayment plus referral fees.
|
|
95
97
|
* @throws {NativeFundingAmountMismatchError} If Blue native funding does not equal the full repayment cap.
|
|
@@ -120,6 +122,7 @@ export declare function buildTransaction(plan: TransactionPlan, step: Step): Rea
|
|
|
120
122
|
* @param plan - Plan whose referenced signature requests all carry a signature.
|
|
121
123
|
* @returns Frozen SDK transactions in step order; discriminate on `action.type` for per-step handling.
|
|
122
124
|
* @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent.
|
|
125
|
+
* @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
|
|
123
126
|
* @throws {InvalidSignatureError} If a stored signature has high s, cannot recover a public key or does not match the request owner.
|
|
124
127
|
* @throws {UnsupportedTransactionPlanVersionError} If the plan version is unsupported, including empty plans.
|
|
125
128
|
* @throws {UnsupportedTransactionPlanActionError} If any plan step names an unsupported action type, before reading requests.
|
|
@@ -133,13 +136,14 @@ export declare function buildTransaction(plan: TransactionPlan, step: Step): Rea
|
|
|
133
136
|
* @throws {EmptyDeallocationsError} If a force-redeem step has no deallocations.
|
|
134
137
|
* @throws {EmptyMarketParamsListError} If a Vault V1 in-kind redemption step has no markets.
|
|
135
138
|
* @throws {ReferralFeePctExceededError} If an action's referral fee is at least WAD.
|
|
139
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
136
140
|
* @throws {ReferralFeeRecipientMissingError} If a positive referral fee has no nonzero recipient.
|
|
137
141
|
* @throws {IncompleteTransactionPlanError} If any step references a signature request or signature that is missing.
|
|
138
142
|
* @throws {TransactionPlanSignatureMismatchError} If a referenced request disagrees with its action or encoding arguments.
|
|
139
143
|
* @throws {BundlesPermitMismatchError} If a stored signature cannot be parsed or a signed permit's encoding arguments do not match the step.
|
|
140
144
|
* @throws {MarketIdMismatchError} If a Blue market ID differs from its parameter tuple.
|
|
141
|
-
* @throws {NegativeInputError} If a Blue amount, native value, LTV bound or referral fee is negative.
|
|
142
|
-
* @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, or withdrawal-only funding is nonzero.
|
|
145
|
+
* @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative.
|
|
146
|
+
* @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), or withdrawal-only funding is nonzero.
|
|
143
147
|
* @throws {MutuallyExclusiveRepayAmountsError} If a Blue repayment specifies both nonzero assets and shares.
|
|
144
148
|
* @throws {MaxRepayAssetsBelowRepayAssetsError} If exact-asset funding cannot cover repayment plus referral fees.
|
|
145
149
|
* @throws {NativeFundingAmountMismatchError} If Blue native funding does not equal the full repayment cap.
|
|
@@ -371,6 +371,7 @@ function encodeStep(action, requests) {
|
|
|
371
371
|
* @param step - Recipe to encode; missing signatures on unrelated supported steps do not block it.
|
|
372
372
|
* @returns A frozen `{ to, data, value, action }`, ready to simulate or submit. `data` ends with the plan's `calldataOrigin` when one was set.
|
|
373
373
|
* @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent.
|
|
374
|
+
* @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
|
|
374
375
|
* @throws {InvalidSignatureError} If a stored signature has high s, cannot recover a public key or does not match the request owner.
|
|
375
376
|
* @throws {UnsupportedTransactionPlanVersionError} If the plan version is unsupported.
|
|
376
377
|
* @throws {UnsupportedTransactionPlanActionError} If any plan step or the selected step names an unsupported action type.
|
|
@@ -384,13 +385,14 @@ function encodeStep(action, requests) {
|
|
|
384
385
|
* @throws {EmptyDeallocationsError} If a force-redeem step has no deallocations.
|
|
385
386
|
* @throws {EmptyMarketParamsListError} If a Vault V1 in-kind redemption step has no markets.
|
|
386
387
|
* @throws {ReferralFeePctExceededError} If the action's referral fee is at least WAD.
|
|
388
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
387
389
|
* @throws {ReferralFeeRecipientMissingError} If a positive referral fee has no nonzero recipient.
|
|
388
390
|
* @throws {IncompleteTransactionPlanError} If a referenced signature request or its signature is missing.
|
|
389
391
|
* @throws {TransactionPlanSignatureMismatchError} If a referenced request disagrees with the step's action or its encoding arguments.
|
|
390
392
|
* @throws {BundlesPermitMismatchError} If a stored signature cannot be parsed or a signed permit's encoding arguments do not match the step.
|
|
391
393
|
* @throws {MarketIdMismatchError} If a Blue market ID differs from its parameter tuple.
|
|
392
|
-
* @throws {NegativeInputError} If a Blue amount, native value, LTV bound or referral fee is negative.
|
|
393
|
-
* @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, or withdrawal-only funding is nonzero.
|
|
394
|
+
* @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative.
|
|
395
|
+
* @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), or withdrawal-only funding is nonzero.
|
|
394
396
|
* @throws {MutuallyExclusiveRepayAmountsError} If a Blue repayment specifies both nonzero assets and shares.
|
|
395
397
|
* @throws {MaxRepayAssetsBelowRepayAssetsError} If exact-asset funding cannot cover repayment plus referral fees.
|
|
396
398
|
* @throws {NativeFundingAmountMismatchError} If Blue native funding does not equal the full repayment cap.
|
|
@@ -467,6 +469,7 @@ function buildTransaction(plan, step) {
|
|
|
467
469
|
* @param plan - Plan whose referenced signature requests all carry a signature.
|
|
468
470
|
* @returns Frozen SDK transactions in step order; discriminate on `action.type` for per-step handling.
|
|
469
471
|
* @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent.
|
|
472
|
+
* @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
|
|
470
473
|
* @throws {InvalidSignatureError} If a stored signature has high s, cannot recover a public key or does not match the request owner.
|
|
471
474
|
* @throws {UnsupportedTransactionPlanVersionError} If the plan version is unsupported, including empty plans.
|
|
472
475
|
* @throws {UnsupportedTransactionPlanActionError} If any plan step names an unsupported action type, before reading requests.
|
|
@@ -480,13 +483,14 @@ function buildTransaction(plan, step) {
|
|
|
480
483
|
* @throws {EmptyDeallocationsError} If a force-redeem step has no deallocations.
|
|
481
484
|
* @throws {EmptyMarketParamsListError} If a Vault V1 in-kind redemption step has no markets.
|
|
482
485
|
* @throws {ReferralFeePctExceededError} If an action's referral fee is at least WAD.
|
|
486
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
483
487
|
* @throws {ReferralFeeRecipientMissingError} If a positive referral fee has no nonzero recipient.
|
|
484
488
|
* @throws {IncompleteTransactionPlanError} If any step references a signature request or signature that is missing.
|
|
485
489
|
* @throws {TransactionPlanSignatureMismatchError} If a referenced request disagrees with its action or encoding arguments.
|
|
486
490
|
* @throws {BundlesPermitMismatchError} If a stored signature cannot be parsed or a signed permit's encoding arguments do not match the step.
|
|
487
491
|
* @throws {MarketIdMismatchError} If a Blue market ID differs from its parameter tuple.
|
|
488
|
-
* @throws {NegativeInputError} If a Blue amount, native value, LTV bound or referral fee is negative.
|
|
489
|
-
* @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, or withdrawal-only funding is nonzero.
|
|
492
|
+
* @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative.
|
|
493
|
+
* @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), or withdrawal-only funding is nonzero.
|
|
490
494
|
* @throws {MutuallyExclusiveRepayAmountsError} If a Blue repayment specifies both nonzero assets and shares.
|
|
491
495
|
* @throws {MaxRepayAssetsBelowRepayAssetsError} If exact-asset funding cannot cover repayment plus referral fees.
|
|
492
496
|
* @throws {NativeFundingAmountMismatchError} If Blue native funding does not equal the full repayment cap.
|
|
@@ -87,6 +87,8 @@ export type Action = {
|
|
|
87
87
|
readonly marketParams: MarketParams;
|
|
88
88
|
readonly borrowAssets: bigint;
|
|
89
89
|
readonly maxLtv: bigint;
|
|
90
|
+
/** Maximum WAD-scaled penalty rate per reallocation, defaulting to zero; it does not bound total proceeds lost. */
|
|
91
|
+
readonly maxPenalty?: bigint;
|
|
90
92
|
readonly reallocations: readonly VaultV2BlueReallocation[];
|
|
91
93
|
readonly deadline: bigint;
|
|
92
94
|
readonly referralFeePct: bigint;
|
|
@@ -123,6 +125,8 @@ export type Action = {
|
|
|
123
125
|
readonly marketParams: Pick<MarketParams, "loanToken" | "collateralToken" | "oracle" | "irm" | "lltv">;
|
|
124
126
|
readonly withdrawAssets: bigint;
|
|
125
127
|
readonly withdrawShares: bigint;
|
|
128
|
+
/** Maximum WAD-scaled penalty rate per reallocation, defaulting to zero; it does not bound total proceeds lost. */
|
|
129
|
+
readonly maxPenalty?: bigint;
|
|
126
130
|
readonly reallocations: readonly VaultV2BlueReallocation[];
|
|
127
131
|
readonly deadline: bigint;
|
|
128
132
|
readonly referralFeePct: bigint;
|
|
@@ -264,6 +268,8 @@ export type Action = {
|
|
|
264
268
|
readonly sourceMarketParams: Readonly<MarketParams>;
|
|
265
269
|
readonly destinationMarketParams: Readonly<MarketParams>;
|
|
266
270
|
readonly maxLtv: bigint;
|
|
271
|
+
/** Maximum WAD-scaled penalty rate per reallocation, defaulting to zero; it does not bound the total penalty added to destination debt. */
|
|
272
|
+
readonly maxPenalty?: bigint;
|
|
267
273
|
readonly deadline: bigint;
|
|
268
274
|
readonly referralFeePct: bigint;
|
|
269
275
|
readonly referralFeeRecipient: Address;
|
|
@@ -7,7 +7,7 @@ export declare function validateTransactionPlanHeader(plan: TransactionPlan): vo
|
|
|
7
7
|
/** @internal Compares an untrusted address without throwing on malformed input. */
|
|
8
8
|
export declare function matchesAddress(value: unknown, expected: Address): boolean;
|
|
9
9
|
/** @internal Scalar and collection shapes used by stored plan fields. */
|
|
10
|
-
type PlanFieldType = "string" | "address" | "hex" | "safe integer" | "positive safe integer" | "uint256 bigint" | "array";
|
|
10
|
+
type PlanFieldType = "string" | "address" | "hex" | "safe integer" | "positive safe integer" | "bigint" | "uint256 bigint" | "array";
|
|
11
11
|
/** @internal Validates one restored field without coercing it. */
|
|
12
12
|
export declare function validatePlanField(value: unknown, options: {
|
|
13
13
|
readonly path: string;
|
|
@@ -118,6 +118,9 @@ function validatePlanField(value, options) {
|
|
|
118
118
|
valid =
|
|
119
119
|
typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
120
120
|
break;
|
|
121
|
+
case "bigint":
|
|
122
|
+
valid = typeof value === "bigint";
|
|
123
|
+
break;
|
|
121
124
|
case "uint256 bigint":
|
|
122
125
|
valid = typeof value === "bigint" && value >= 0n && value <= viem_1.maxUint256;
|
|
123
126
|
break;
|
|
@@ -32,8 +32,8 @@ export interface VaultV1DepositPlanParams extends DepositPlanParams<AccrualVault
|
|
|
32
32
|
/**
|
|
33
33
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
34
34
|
* Prepares a Vault V1 (MetaMorpho) deposit plan through VaultBundlesV1 from caller intent and a
|
|
35
|
-
* vault snapshot, reading the token prerequisites directly. The
|
|
36
|
-
*
|
|
35
|
+
* vault snapshot, reading the token prerequisites directly. The quote is fixed on the
|
|
36
|
+
* deposit step at preparation, so the returned plan is static:
|
|
37
37
|
* only signatures are added before building.
|
|
38
38
|
* @param client - Viem client for `params.chainId`, used for allowance and permit metadata reads only.
|
|
39
39
|
* @param params.vault - Caller-fetched AccrualVault snapshot used for the quote; its address identifies the vault.
|
|
@@ -41,7 +41,7 @@ export interface VaultV1DepositPlanParams extends DepositPlanParams<AccrualVault
|
|
|
41
41
|
* @param params.account - Non-zero account funding, signing and sending the deposit.
|
|
42
42
|
* @param params.assets - Positive gross deposit in asset base units, before referral fees.
|
|
43
43
|
* @param params.funding.type - Optional funding source: `"erc20"` (default) or `"native"`; native funding requires the vault asset to be wNative.
|
|
44
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be
|
|
44
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be at most 1,000.
|
|
45
45
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
46
46
|
* @param params.slippageTolerance - Optional WAD-scaled tolerance for the share-price bound; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
|
|
47
47
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
@@ -50,16 +50,16 @@ export interface VaultV1DepositPlanParams extends DepositPlanParams<AccrualVault
|
|
|
50
50
|
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
|
|
51
51
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
52
52
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
53
|
+
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
53
54
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
54
55
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
55
56
|
* @throws {NonPositiveInputError} when `expiresAt`, `assets`, net assets or previewed shares are not positive.
|
|
56
57
|
* @throws {ExpiredDeadlineError} when `expiresAt` is not in the future.
|
|
57
58
|
* @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
|
|
58
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
59
|
+
* @throws {InputExceedsMaxError} when `expiresAt` exceeds seven days after `now`, `referralFee.bps` exceeds 1,000 or `assets` exceeds uint256.
|
|
59
60
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
|
|
60
61
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
61
62
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
62
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
63
63
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
64
64
|
* @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a vault whose asset is not wNative.
|
|
65
65
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
@@ -10,8 +10,8 @@ const permit_js_1 = require("../permit.js");
|
|
|
10
10
|
/**
|
|
11
11
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
12
12
|
* Prepares a Vault V1 (MetaMorpho) deposit plan through VaultBundlesV1 from caller intent and a
|
|
13
|
-
* vault snapshot, reading the token prerequisites directly. The
|
|
14
|
-
*
|
|
13
|
+
* vault snapshot, reading the token prerequisites directly. The quote is fixed on the
|
|
14
|
+
* deposit step at preparation, so the returned plan is static:
|
|
15
15
|
* only signatures are added before building.
|
|
16
16
|
* @param client - Viem client for `params.chainId`, used for allowance and permit metadata reads only.
|
|
17
17
|
* @param params.vault - Caller-fetched AccrualVault snapshot used for the quote; its address identifies the vault.
|
|
@@ -19,7 +19,7 @@ const permit_js_1 = require("../permit.js");
|
|
|
19
19
|
* @param params.account - Non-zero account funding, signing and sending the deposit.
|
|
20
20
|
* @param params.assets - Positive gross deposit in asset base units, before referral fees.
|
|
21
21
|
* @param params.funding.type - Optional funding source: `"erc20"` (default) or `"native"`; native funding requires the vault asset to be wNative.
|
|
22
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be
|
|
22
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be at most 1,000.
|
|
23
23
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
24
24
|
* @param params.slippageTolerance - Optional WAD-scaled tolerance for the share-price bound; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
|
|
25
25
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
@@ -28,16 +28,16 @@ const permit_js_1 = require("../permit.js");
|
|
|
28
28
|
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
|
|
29
29
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
30
30
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
31
|
+
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
31
32
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
32
33
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
33
34
|
* @throws {NonPositiveInputError} when `expiresAt`, `assets`, net assets or previewed shares are not positive.
|
|
34
35
|
* @throws {ExpiredDeadlineError} when `expiresAt` is not in the future.
|
|
35
36
|
* @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
|
|
36
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
37
|
+
* @throws {InputExceedsMaxError} when `expiresAt` exceeds seven days after `now`, `referralFee.bps` exceeds 1,000 or `assets` exceeds uint256.
|
|
37
38
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
|
|
38
39
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
39
40
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
40
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
41
41
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
42
42
|
* @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a vault whose asset is not wNative.
|
|
43
43
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
@@ -41,7 +41,7 @@ export type VaultV1MigrateToV2PlanParams = Omit<IntentParams, "deployless"> & Re
|
|
|
41
41
|
* @param params.account - Non-zero account approving or permitting shares and sending the migration.
|
|
42
42
|
* @param params.assets - Positive gross migration in asset base units, before referral fees; mutually exclusive with `shares`.
|
|
43
43
|
* @param params.shares - Positive source share amount to migrate; mutually exclusive with `assets`.
|
|
44
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be
|
|
44
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be at most 1,000.
|
|
45
45
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
46
46
|
* @param params.slippageTolerance - Optional WAD-scaled tolerance for the destination price and source share allowance quotes; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
|
|
47
47
|
* @param params.supportSignature - Optional unlimited ERC-2612 share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient. Vault V1 shares support ERC-2612; no Permit2 is used.
|
|
@@ -49,6 +49,7 @@ export type VaultV1MigrateToV2PlanParams = Omit<IntentParams, "deployless"> & Re
|
|
|
49
49
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
50
50
|
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
|
|
51
51
|
* @returns A static migration plan with any required source share approval or permit.
|
|
52
|
+
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
52
53
|
* @throws {VaultAssetMismatchError} If the vault assets differ.
|
|
53
54
|
* @throws {SameVaultMigrationError} If source and target are identical.
|
|
54
55
|
* @throws {AmountAndSharesExclusiveError} If both or neither amount is supplied.
|
|
@@ -56,11 +57,10 @@ export type VaultV1MigrateToV2PlanParams = Omit<IntentParams, "deployless"> & Re
|
|
|
56
57
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
57
58
|
* @throws {NonPositiveInputError} when `expiresAt`, the selected amount, net migrated assets or previewed shares are not positive.
|
|
58
59
|
* @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
|
|
59
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
60
|
+
* @throws {InputExceedsMaxError} when `expiresAt` exceeds seven days after `now`, `referralFee.bps` exceeds 1,000 or the selected amount exceeds uint256.
|
|
60
61
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
|
|
61
62
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
62
63
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
63
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
64
64
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
65
65
|
* @throws {ExpiredDeadlineError} If the expiry is not in the future.
|
|
66
66
|
* @throws {ChainIdMismatchError} If the client targets another chain.
|
|
@@ -59,7 +59,7 @@ function validateMigrateToV2PlanAction(action, path) {
|
|
|
59
59
|
* @param params.account - Non-zero account approving or permitting shares and sending the migration.
|
|
60
60
|
* @param params.assets - Positive gross migration in asset base units, before referral fees; mutually exclusive with `shares`.
|
|
61
61
|
* @param params.shares - Positive source share amount to migrate; mutually exclusive with `assets`.
|
|
62
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be
|
|
62
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be at most 1,000.
|
|
63
63
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
64
64
|
* @param params.slippageTolerance - Optional WAD-scaled tolerance for the destination price and source share allowance quotes; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
|
|
65
65
|
* @param params.supportSignature - Optional unlimited ERC-2612 share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient. Vault V1 shares support ERC-2612; no Permit2 is used.
|
|
@@ -67,6 +67,7 @@ function validateMigrateToV2PlanAction(action, path) {
|
|
|
67
67
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
68
68
|
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
|
|
69
69
|
* @returns A static migration plan with any required source share approval or permit.
|
|
70
|
+
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
70
71
|
* @throws {VaultAssetMismatchError} If the vault assets differ.
|
|
71
72
|
* @throws {SameVaultMigrationError} If source and target are identical.
|
|
72
73
|
* @throws {AmountAndSharesExclusiveError} If both or neither amount is supplied.
|
|
@@ -74,11 +75,10 @@ function validateMigrateToV2PlanAction(action, path) {
|
|
|
74
75
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
75
76
|
* @throws {NonPositiveInputError} when `expiresAt`, the selected amount, net migrated assets or previewed shares are not positive.
|
|
76
77
|
* @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
|
|
77
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
78
|
+
* @throws {InputExceedsMaxError} when `expiresAt` exceeds seven days after `now`, `referralFee.bps` exceeds 1,000 or the selected amount exceeds uint256.
|
|
78
79
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
|
|
79
80
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
80
81
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
81
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
82
82
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
83
83
|
* @throws {ExpiredDeadlineError} If the expiry is not in the future.
|
|
84
84
|
* @throws {ChainIdMismatchError} If the client targets another chain.
|
|
@@ -109,7 +109,11 @@ function validateMigrateToV2PlanAction(action, path) {
|
|
|
109
109
|
async function prepareVaultV1MigrateToV2(client, params) {
|
|
110
110
|
const { sourceVault, targetVault, chainId, account } = params;
|
|
111
111
|
const now = params.now ?? morpho_ts_1.Time.timestamp();
|
|
112
|
+
// Reject a non-bigint clock before deriving the default expiry.
|
|
113
|
+
(0, validate_js_1.validateReferenceTime)(now);
|
|
112
114
|
const intent = (0, intent_js_1.resolveIntent)(params, now);
|
|
115
|
+
// Report the plan's public expiry field before computing the shared quote.
|
|
116
|
+
(0, validate_js_1.validateVaultDepositDeadline)(intent.deadline, { now, field: "expiresAt" });
|
|
113
117
|
const slippageTolerance = params.slippageTolerance ?? blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE;
|
|
114
118
|
(0, validate_js_1.validateSlippageTolerance)(slippageTolerance);
|
|
115
119
|
if (!(0, viem_1.isAddressEqual)(sourceVault.asset, targetVault.asset)) {
|
|
@@ -37,10 +37,9 @@ export interface VaultV1RedeemPlanParams extends RedeemPlanParams {
|
|
|
37
37
|
* @throws {NonPositiveInputError} when `expiresAt` or `shares` is not positive.
|
|
38
38
|
* @throws {ExpiredDeadlineError} when `expiresAt` is not in the future.
|
|
39
39
|
* @throws {NegativeInputError} when `referralFee.bps` is negative.
|
|
40
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
40
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000 or `shares` exceeds uint256.
|
|
41
41
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
42
42
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
43
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
44
43
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
45
44
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
46
45
|
* @throws {MissingContractCodeError} when VaultBundlesV1 is absent.
|