Certora Partners with Morpho to Strengthen Onchain Credit

How formal verification shaped the development of Morpho Midnight’s fixed-rate, fixed-term lending protocol.

Certora has partnered with Morpho to bring formal verification to Morpho Midnight, Morpho’s fixed-rate, fixed-term onchain lending protocol.

For Morpho Midnight, Certora engineers worked alongside Morpho’s protocol team from the earliest stages of development, continuously verifying critical properties as the code evolved. Together, the teams made formal verification an integral part of designing and building the protocol.

Building infrastructure for onchain credit

Morpho builds decentralized, noncustodial lending protocols that provide a foundation for borrowers, lenders, and applications. The protocol supports variable-rate lending through Morpho Blue and fixed-rate, fixed-term lending through Morpho Midnight.

Midnight addresses a practical challenge in onchain lending: borrowers need predictable funding costs, while lenders need flexibility in how they make capital available.

Midnight’s fixed-rate markets let participants agree on pricing for a defined maturity. Lenders can publish offers across multiple markets without locking capital into each one in advance. Funds are sourced when an offer is executed, provided the necessary liquidity is available. For example, a lender can keep assets deployed in Morpho Blue while quoting a fixed-rate offer on Midnight, then move the required funds within the settlement transaction.

Markets can also support different collateral configurations and optional access controls, allowing developers to build products for a broader range of credit needs.

These capabilities depend on precise rules for how positions are created, settled, repaid, and liquidated. Verifying those rules is central to our work together.

How Certora formally verified Morpho Midnight

Morpho Blue and Midnight use immutable core contracts. Once deployed, their core code cannot be changed, making rigorous verification during development particularly important.

For Midnight, Morpho engineers retained ownership of the specifications defining the protocol’s intended behavior, while Certora engineers worked alongside them to verify the implementation.

As the design evolved, this process helped the teams challenge assumptions, refine specifications, and assess whether changes preserved the properties the protocol was intended to uphold. Verification also served as an additional check for bugs throughout development.

Certora’s formal verification of Morpho Midnight covered five areas:

  • Accounting: Keeping credit, debt, and collateral consistent, with transfers and modifications performed by the appropriate parties.
  • Maturity and solvency: Checking liquidation eligibility, incentive bounds, and bad-debt accounting.
  • Offers, fees, and rounding: Verifying limits and accounting behavior across settlements.
  • Permissions: Checking authorization rules and the boundaries of privileged roles.
  • Implementation: Verifying arithmetic, price conversions, and protections against external calls observing inconsistent intermediate states.

Midnight’s whitepaper illustrates why these details matter. A position can become eligible for liquidation because its collateral is insufficient, or because debt remains unpaid after maturity. Those circumstances have different implications for borrowers and lenders, and the protocol defines different incentive behavior for each.

Likewise, an offer may be filled in parts, and settlement can increase or reduce existing credit and debt positions. The accounting must remain consistent across those interactions.

Formal verification gives engineers a systematic way to check specified properties across these behaviors, including combinations of inputs and transaction sequences that individual tests may not exercise.

What the Certora and Morpho partnership means for DeFi developers

For developers building on Morpho, published verification work provides a way to examine which properties have been checked in the infrastructure they depend on. For Morpho’s engineers, explicit specifications provide a foundation for evaluating design decisions and code changes.

The resulting assurance is tied to the properties and assumptions covered by the verification model. It complements the testing, peer review, external security reviews, contests, and bounties that make up Morpho’s broader security approach.

Morpho’s use of Certora extends across multiple components, including Midnight, Morpho Blue, and Vault V2. Its formal verification documentation lists the verified components, tools used, and links to the underlying work.

We are proud to support a team that brings this level of rigor to protocol development. As onchain credit expands, integrating formal verification into the engineering process helps build a stronger foundation for the users, developers, and institutions relying on it.

Q&A with Quentin Garchery of Morpho: Building Midnight with Formal Verification

Quentin Garchery is a Research and Development Engineer at Morpho and a co-author of the Morpho Midnight whitepaper. We asked him about building Midnight with formal verification.

What did your experience building and securing Morpho Blue teach you that shaped the development of Midnight?

First, building Morpho Blue gave us a lot of practical experience: we became better developers, learned more about the ecosystem and its tools, and found ways to work more efficiently as a team.

But beyond that, I think one of the main lessons was to keep things simple. We learned to constantly question our assumptions, our design decisions, and every line of code. Is this really needed? Is it worth the extra complexity? If not, we should remove it. This approach strongly shaped how we built Midnight, pushing us to keep the design as simple as possible.

What was one of the most interesting engineering challenges in building Midnight, and how did working with Certora help your team address it?

Building Midnight took a long time, with many rounds of changes. One of the most interesting challenges was that the requirements and target features changed several times as we refined what we wanted to build. We had to keep revisiting our design choices and updating the code while preserving the protocol's key properties.

Using formal verification with Certora from early in the process helped us with this. When we made changes, it highlighted which rules or invariants were affected and needed to be updated or reconsidered. This helped us better understand the impact of our design decisions as the protocol evolved.

What would it take for formal verification to become a routine part of DeFi development from day one?

I think teams need to be willing to spend more time on formal verification from the start, and recognize the value it brings beyond the verification results themselves.

Thinking about formal verification early can also help shape the design of a protocol. It encourages you to be more precise about the properties you want to guarantee, the assumptions you're making, and the trade-offs you're willing to accept. Writing these properties down forces you to think carefully about what you actually want the protocol to do, and can bring up important questions early in the development process.

STAY INFORMED

Security research, in your inbox.

Incident analysis, formal verification, and new tools from Certora.