#886b12f8a2 Thanks @Foulks-Plb! - Fix assets-mode repay reverting on quiet markets. MorphoBlue.repay and
MorphoBlue.repayWithdrawCollateral now derive maxSharePrice from the
2h-forward-accrued market in both repay modes, not just shares mode.
Previously the assets path computed the slippage bound from the un-accrued
positionData.market snapshot (as of the market's on-chain lastUpdate),
while on-chain morphoRepay accrues interest lastUpdate → execution before
enforcing the bound. On a market that hasn't accrued recently, the accrued
borrow share price rose past the default 0.03% slippageTolerance ceiling and
the bundle reverted — e.g. at ~8% APR, 0.03% is only ~1.3 days of accrual, so a
quiet market reverted systematically. Direct core repay (no bundler, no
bound) was unaffected, which is why the fallback path succeeded while
app.morpho.org did not.
#875e3bcaf5 Thanks @Rubilmax! - Consolidate Vault, Blue, and Midnight scalar input validation into two protocol-agnostic errors: NegativeInputError for inputs that must be non-negative and NonPositiveInputError for inputs that must be positive. Both errors expose the invalid field and value as readonly properties.
This replaces the operation-specific scalar-bound error implementations with deprecated aliases to the two canonical classes, preserving imports and instanceof checks during the deprecation window:
NonPositiveAssetAmountError, NonPositiveSharesAmountError, NonPositiveMaxSharePriceError, ZeroDepositAmountError, NonPositiveBorrowAmountError, ZeroCollateralAmountError, NonPositiveReallocationAmountError, NonPositiveRepayAmountError, NonPositiveRepayMaxSharePriceError, NonPositiveWithdrawCollateralAmountError, ZeroSupplyAmountError, and NonPositiveWithdrawAmountError alias NonPositiveInputError.
NegativeSlippageToleranceError, NegativeNativeAmountError, NegativeReallocationFeeError, , , , , , , and alias .
v@morpho-org/test-v2.8.3Patch
2.8.3
Patch Changes
#815e7578c3 Thanks @Rubilmax! - Add first-iteration Midnight action flows under client.morpho.midnight(chainId), expose Midnight SDK API helpers through morpho-sdk/midnight-api and shared ABI/constant/error/utility entrypoints, and expose pure Midnight transaction builders for the markets-app taker, maker, redeem, repay/withdraw, and cancel flows.
The Midnight entity returns lazy action outputs with getRequirements() and synchronous buildTx(...) methods, matching the existing morpho-sdk action pattern while accepting fixed-rate API quote takeable offers directly. UI labels, rate display logic, and offer-chain presentation stay on the integrator side.
Midnight market transaction builders are synchronous and consume caller-provided marketData state, while redeem consumes a single caller-provided positionData snapshot that includes its hydrated market. Maker-offer action builders consume caller-provided offersData from getOffersData(...), which creates the tree from the same entries accepted by Tree.create(...) and runs mempool validation. getMarketData(...), getPositionData(...), and getOffersData(...) remain async helpers so integrators can prepare state once, compose UI/validation around it, and then build transactions without hidden reads. Callers can pin several reads to one externally fetched block by forwarding its through the fetch parameters.
v@morpho-org/morpho-sdk-v5.3.0Patch
5.3.0
Minor Changes
#815e7578c3 Thanks @Rubilmax! - Add first-iteration Midnight action flows under client.morpho.midnight(chainId), expose Midnight SDK API helpers through morpho-sdk/midnight-api and shared ABI/constant/error/utility entrypoints, and expose pure Midnight transaction builders for the markets-app taker, maker, redeem, repay/withdraw, and cancel flows.
The Midnight entity returns lazy action outputs with getRequirements() and synchronous buildTx(...) methods, matching the existing morpho-sdk action pattern while accepting fixed-rate API quote takeable offers directly. UI labels, rate display logic, and offer-chain presentation stay on the integrator side.
Midnight market transaction builders are synchronous and consume caller-provided marketData state, while redeem consumes a single caller-provided positionData snapshot that includes its hydrated market. Maker-offer action builders consume caller-provided offersData from getOffersData(...), which creates the tree from the same entries accepted by Tree.create(...) and runs mempool validation. getMarketData(...), getPositionData(...), and getOffersData(...) remain async helpers so integrators can prepare state once, compose UI/validation around it, and then build transactions without hidden reads. Callers can pin several reads to one externally fetched block by forwarding its through the fetch parameters.
v@morpho-org/midnight-sdk-v1.2.0Patch
1.2.0
Minor Changes
#815e7578c3 Thanks @Rubilmax! - Add OfferChainUtils.buildLendFixedRateOfferChain, buildBorrowFixedRateOfferChain, and getMaxFixedRateOfferChainEndTimestamp so the markets app can build adjacent, grouped offers that keep a maker's displayed fixed rate stable across a long selected window.
Expose a Midnight accrued position's currently withdrawable credit capacity.
Align Midnight positions with Blue's model: base positions require user and marketId, while accrued positions accept user plus a hydrated market and derive the market id. Retain both identifiers across local accrual so downstream transaction flows can bind snapshots to the correct account and market.
This position input change intentionally ships in a minor release rather than forcing a major release because @morpho-org/midnight-sdk is still young and its public model is being stabilized around secure, owner-bound action flows.
Move the position model and utilities into a dedicated position module matching Blue's source layout while preserving the package's root exports.
Accept a single Midnight offer or group anywhere tree-shaped input is supported, including Tree.from, ratifier helpers, and mempool validation.
NonPositiveMinBorrowSharePriceError
NegativeSupplyAmountError
NegativeSupplyMaxSharePriceError
NegativeWithdrawMinSharePriceError
NegativeMinSharePriceError
NegativeBorrowSharesError
NegativeMaxRepaySharePriceError
NegativeInputError
The previously deprecated NonPositiveTransferAmountError and NativeAmountExceedsTransferAmountError exports are removed. The unreleased Midnight-specific scalar errors are superseded directly by the canonical errors.
Compatibility warning (acknowledged): this minor release intentionally changes the constructor signatures, constructor identity, and name property observed through the deprecated aliases. Negative values previously matched by a legacy NonPositive*Error may now match NegativeInputError instead. It also removes the two previously deprecated exports named above. These compatibility risks are explicitly accepted for this release despite their normally breaking nature.
Consumers should replace handlers for these classes with the shared input error matching the documented constraint of each field.
State-independent validation is now repeated at both public boundaries: Blue entities and pure actions reject the same malformed scalar modes and reallocations, while Midnight entities and pure actions reject the same malformed amounts, market chains, collateral indexes, and empty offer submissions.
Patch maintained direct dependents so their published releases resolve and are validated against this @morpho-org/morpho-sdk minor. The existing ^5.0.0 peer range in @morpho-org/liquidity-sdk-viem already accepts the new v5 minor and does not require widening.
Domain-specific errors for conflicting modes, mismatched data, exceeded balances, unsupported native assets, and unsafe positions remain unchanged.
Midnight Bundles token pulls use approval-based execution in this first iteration: getRequirements() returns ERC20 approval calls, and encoded bundle calls pass PermitKind.None. ERC2612 token permits, Permit2 SignatureTransfer token pulls, unit-target take helpers, exposed taker reduceOnly, referral fee controls, max-continuous-fee controls, and generic collateral withdrawal lists are left to follow-up work.
Allow fork tests to select Anvil's Osaka hardfork so deployed Midnight bytecode using the CLZ opcode can be exercised end to end.
Borrow-side flows are explicit: takeBorrow and makeBorrow borrow without supplying collateral, while supplyCollateralTakeBorrow and supplyCollateralMakeBorrow perform collateral-supply plus borrow flows. Public maker flows are exposed through async entity methods such as makeLend, makeBorrow, and supplyCollateralMakeBorrow; they accept raw offer or group inputs, prepare and validate offersData internally, then return lazy requirement and transaction handles. Maker submit metadata exposes all submitted group ids, and the ratifier helpers enforce that the submitted tree uses one ratifier.
Named take transaction builders validate that their takeable offers match the expected maker side, and named maker entity flows validate that prepared maker trees match the expected maker side. Borrow takes require a positive maxUnits, repayment-withdrawal flows reject unknown collateral indexes before exposing requirements, and partial group cancellation rejects amounts outside the onchain offer-cap range. getOffersData(...) stays side-agnostic so callers can prepare any valid tree.
Validation runs before requirements are exposed: takeable offers must match the requested flow, redemption cannot exceed position credit, approval amounts and operators are checked before allowance short-circuits, and market inputs must belong to the selected Midnight deployment. Maker preparation also preserves caller-owned offer group arrays.
Bind security-sensitive flow artifacts to their preparation context: Ecrecover submissions use the canonical payload retained for the signed tree instead of trusting payload bytes supplied to buildTx, typed-data signing rejects wallets on another chain, and redemption accepts only owner-bound position snapshots for the requested account.
blockNumber
Midnight Bundles token pulls use approval-based execution in this first iteration: getRequirements() returns ERC20 approval calls, and encoded bundle calls pass PermitKind.None. ERC2612 token permits, Permit2 SignatureTransfer token pulls, unit-target take helpers, exposed taker reduceOnly, referral fee controls, max-continuous-fee controls, and generic collateral withdrawal lists are left to follow-up work.
Allow fork tests to select Anvil's Osaka hardfork so deployed Midnight bytecode using the CLZ opcode can be exercised end to end.
Borrow-side flows are explicit: takeBorrow and makeBorrow borrow without supplying collateral, while supplyCollateralTakeBorrow and supplyCollateralMakeBorrow perform collateral-supply plus borrow flows. Public maker flows are exposed through async entity methods such as makeLend, makeBorrow, and supplyCollateralMakeBorrow; they accept raw offer or group inputs, prepare and validate offersData internally, then return lazy requirement and transaction handles. Maker submit metadata exposes all submitted group ids, and the ratifier helpers enforce that the submitted tree uses one ratifier.
Named take transaction builders validate that their takeable offers match the expected maker side, and named maker entity flows validate that prepared maker trees match the expected maker side. Borrow takes require a positive maxUnits, repayment-withdrawal flows reject unknown collateral indexes before exposing requirements, and partial group cancellation rejects amounts outside the onchain offer-cap range. getOffersData(...) stays side-agnostic so callers can prepare any valid tree.
Validation runs before requirements are exposed: takeable offers must match the requested flow, redemption cannot exceed position credit, approval amounts and operators are checked before allowance short-circuits, and market inputs must belong to the selected Midnight deployment. Maker preparation also preserves caller-owned offer group arrays.
Bind security-sensitive flow artifacts to their preparation context: Ecrecover submissions use the canonical payload retained for the signed tree instead of trusting payload bytes supplied to buildTx, typed-data signing rejects wallets on another chain, and redemption accepts only owner-bound position snapshots for the requested account.
#875e3bcaf5 Thanks @Rubilmax! - Consolidate Vault, Blue, and Midnight scalar input validation into two protocol-agnostic errors: NegativeInputError for inputs that must be non-negative and NonPositiveInputError for inputs that must be positive. Both errors expose the invalid field and value as readonly properties.
This replaces the operation-specific scalar-bound error implementations with deprecated aliases to the two canonical classes, preserving imports and instanceof checks during the deprecation window:
NonPositiveAssetAmountError, NonPositiveSharesAmountError, NonPositiveMaxSharePriceError, ZeroDepositAmountError, NonPositiveBorrowAmountError, ZeroCollateralAmountError, NonPositiveReallocationAmountError, NonPositiveRepayAmountError, NonPositiveRepayMaxSharePriceError, NonPositiveWithdrawCollateralAmountError, ZeroSupplyAmountError, and NonPositiveWithdrawAmountError alias NonPositiveInputError.
NegativeSlippageToleranceError, NegativeNativeAmountError, NegativeReallocationFeeError, NonPositiveMinBorrowSharePriceError, NegativeSupplyAmountError, NegativeSupplyMaxSharePriceError, NegativeWithdrawMinSharePriceError, NegativeMinSharePriceError, NegativeBorrowSharesError, and NegativeMaxRepaySharePriceError alias NegativeInputError.
The previously deprecated NonPositiveTransferAmountError and NativeAmountExceedsTransferAmountError exports are removed. The unreleased Midnight-specific scalar errors are superseded directly by the canonical errors.
Compatibility warning (acknowledged): this minor release intentionally changes the constructor signatures, constructor identity, and name property observed through the deprecated aliases. Negative values previously matched by a legacy NonPositive*Error may now match NegativeInputError instead. It also removes the two previously deprecated exports named above. These compatibility risks are explicitly accepted for this release despite their normally breaking nature.
Consumers should replace handlers for these classes with the shared input error matching the documented constraint of each field.
State-independent validation is now repeated at both public boundaries: Blue entities and pure actions reject the same malformed scalar modes and reallocations, while Midnight entities and pure actions reject the same malformed amounts, market chains, collateral indexes, and empty offer submissions.
Patch maintained direct dependents so their published releases resolve and are validated against this @morpho-org/morpho-sdk minor. The existing ^5.0.0 peer range in @morpho-org/liquidity-sdk-viem already accepts the new v5 minor and does not require widening.
Domain-specific errors for conflicting modes, mismatched data, exceeded balances, unsupported native assets, and unsafe positions remain unchanged.