DeFi lending audit: liquidations, oracles and interest math

A DeFi lending audit checks the three numbers a market depends on: the price of each collateral, the interest each loan accrues, and the health factor that decides when a position can be liquidated. QuillShield audits markets, oracles and liquidation paths as one codebase, then checks each pull request against that audit.

Last updated . 5 minute read. By the QuillShield team.

What goes wrong in lending protocols?

A lending market loses money when someone can borrow or withdraw more than their collateral covers. These are the routes reviewers look at first.

  • Prices that can be moved or misread. A collateral price taken from a thin pool, a stale feed or a feed in the wrong unit lets a borrower take out more than the collateral is worth. Inverse Finance lost $15.6M to a manipulated TWAP in April 2022, as the page on oracle price manipulation explains.
  • A path without the health check. Every function that lowers collateral, adds debt or sends funds out has to end with the same solvency check. Euler's donation function, below, shows how a function added later can miss it.
  • Interest that accrues in the wrong order. The borrow index has to be updated before any action reads or changes a balance, rounding has to favor the market, up on what borrowers owe and down on what lenders are credited, and the rate model has to behave at 100% utilization.
  • Empty or new markets. A market with no supply can have its exchange rate pushed by a donation, with the same mechanics as the ERC-4626 inflation attack.
  • Token callbacks. Lendf.Me lost about $25M in April 2020 when an ERC-777 token's transfer hook let an attacker re-enter a deposit. The reentrancy page covers the pattern.
  • Liquidations that don't pay. If liquidating a small or underwater position costs more than the bonus, nobody liquidates it and the loss stays with lenders.

What has gone wrong before?

Euler Finance shows how one new function can undo the rest. A later improvement proposal, eIP-14, added donateToReserves, which let an account give part of its deposit to the protocol's reserves. The function did not check the health of the account making the donation.

On 13 March 2023 an attacker used it to drain about $197M. Giving collateral away without that check let the attacker put their own account into a state the rest of the protocol did not expect. For a lending team, the rule that follows is short: a health check belongs on every path that changes an account's balance, including the paths added after launch.

How do a full audit and pull request checks fit a lending team?

Scope the markets, the interest rate models, the oracle adapters, the liquidation logic and anything with an admin role, such as the contract that lists new assets. QuillShield reviews them as one codebase, so a price adapter is read with the borrow function that relies on it. As context, add your risk parameters, the feed each asset uses and who can change them.

A lending protocol keeps changing after launch, with new assets, new oracle adapters and new collateral factors. When those changes go through pull requests, each one gets a check against the last full audit. On GitHub, branch protection or rulesets can make the check required, so a new market with a High or Critical finding waits for a fix. A large change, such as a new set of contracts, gets a recommendation for a new full audit.

For a launch with a lot of value behind it, request a manual audit from QuillAudits as well. QuillShield does not replace one.

What does a lending audit cost?

As of November 2026 the pricing page lists 5,000 lines of Solidity at $1,169 and 10,000 lines at $1,899, counted without comments or blank lines, and anything above 40,000 lines is quoted by hand. Pull request checks after the five included ones cost $5 for up to 50 added lines and $0.10 for each line after that. The first-audit guide shows how to get a quote for your own code, and sign-up is free.

What should you check in a lending market?

  • Does every function that removes collateral, adds debt or sends funds out end with the health check?
  • Is interest accrued before each action that reads or changes a balance?
  • Does rounding favor the market, up on debt and down on what lenders are credited?
  • For each asset, which feed sets the price, in which unit, and what happens when it is stale, zero or far off?
  • Can a market be manipulated while it has no supply, and is each new market seeded when it is listed?
  • Is liquidation worth doing at every position size, and what happens to debt that collateral can't cover?
  • Can a token's transfer hook re-enter a market during a deposit, a borrow or a liquidation?
  • Are collateral factors and borrow caps set from the liquidity each asset really has on-chain?

Common questions

Does a fork of an audited lending protocol need its own audit?

Yes. A fork changes assets, oracles, parameters and often code, and each change is outside what the original audit reviewed. Euler's loss came from a function added in a later improvement proposal.

Which parts of a lending protocol need the closest review?

Every path that changes collateral or debt, and every oracle adapter. A missing health check or a misread price lets someone borrow more than their collateral covers.

How much does a lending protocol audit cost with QuillShield?

The price follows the lines of Solidity in scope. On the pricing page, 5,000 lines cost $1,169 and 10,000 lines $1,899 as of November 2026, and above 40,000 lines the price is quoted by hand.

Can QuillShield review a governance proposal?

If the proposal's Solidity is in your repository, its pull request gets a check against the last full audit like any other change. A parameter change made only on-chain, with no code in the repository, is outside what the check sees.

Sources

QuillShield is building the security layer between AI and money, so you can keep shipping between audits.

Sign-up is free, and new accounts get $50 in credit, good for up to half of an order.

  1. 1Sign up and import a repo
  2. 2See the exact price before anything is charged
  3. 3Approve it, and the audit starts