Skip to content
Private, independent platform.Private, independent platform: free for clients, funded by a commission paid by vendors.Funding
smart-contract.com

Guides

DeFi audit: risks, method and cost of a protocol review

DeFi audit guide: why DeFi protocols carry more risk, what a DeFi smart contract audit covers, Solidity specifics, timeline, indicative cost and re-audit.

Updated September 26, 20269 min readBy the smart-contract.com team

A DeFi audit is an independent security review of the smart contracts behind a decentralized finance protocol (exchange, lending market, vault, staking or derivatives), focused on how funds can be stolen, locked or mispriced through the code and through its economic design. It goes further than a standard token audit because DeFi contracts hold pooled user funds, depend on external prices and interact with other protocols.

This guide explains why DeFi carries more risk, what a DeFi smart contract audit covers, what changes between a Solidity audit and a Rust or Move audit, how the review is organized, what it costs in the site's public model and what to do after the report.

Why DeFi is higher risk

DeFi protocols concentrate value and logic in contracts that anyone can call, at any time, with any amount the market allows. A flaw that would be minor in a simple token can drain a pool in a single transaction. The main sources of risk are:

  • Pooled funds. Deposits from many users sit in the same contracts, so one flaw exposes everyone.
  • Composability. Your protocol calls other protocols and is called by them. Their behavior, upgrades and failures become part of your risk.
  • Oracles. Prices decide how much users can borrow, what they receive in a swap and when positions are liquidated. Stale, missing or manipulated prices break those decisions. See oracle manipulation.
  • Price manipulation and flash loans. An attacker can borrow very large amounts within one transaction, move a price, exploit the protocol and repay the loan. See flash loan.
  • Liquidations. Liquidation logic must work under extreme conditions: fast price moves, congested networks, dust positions and incentives that are neither too low nor too generous.
  • Economic design. Interest rate models, fee curves, rewards and incentives can be correct as code and still be exploitable as economics.
  • Governance. Voting power that can be borrowed or bought for a short time, or proposals executed without delay, can turn governance into an attack path.
  • Upgradeability and admin keys. Whoever controls upgrades, pauses or parameters controls the protocol. Key management, a multisig and a timelock are part of the security model.

The guide to common smart contract vulnerabilities describes many of these patterns in more detail.

What a DeFi audit covers

A DeFi audit combines a line-by-line code review with an analysis of the protocol as a financial system. A complete engagement usually includes four layers:

  1. Manual review. Access control, flows of funds, accounting of shares and debts, rounding, edge cases, external calls, upgrade paths and admin functions. This is where most serious findings come from.
  2. Invariants. The auditor and your team agree on properties that must always hold, such as "the sum of user balances never exceeds the assets held" or "a healthy position cannot be liquidated". See invariant in the glossary.
  3. Fuzzing and invariant testing. Tools generate large numbers of random transaction sequences and check that the invariants survive. Formal verification can be added for critical components when the auditor offers it.
  4. Economic review. Scenarios with manipulated prices, flash loans, extreme volatility, low liquidity and adversarial users, to test whether incentives and parameters hold up.

The deliverable is a report with findings ranked by severity, each with an explanation, a proof of concept where relevant and a recommended fix, followed by a re-audit of the fixes.

Solidity audit specifics vs Rust and Move

Most DeFi protocols run on EVM chains and are written in Solidity, but the review changes with the language. The public model reflects this with a language factor: Solidity 1.0, Move 1.25, Rust (Solana), Cairo and other languages 1.3.

LanguageTypical points of attention in a DeFi review
Solidity (EVM)Reentrancy, token quirks (fees on transfer, rebasing, unusual decimals), approvals, proxy storage layout, unchecked arithmetic, rounding direction, external calls to untrusted contracts
Rust (Solana)Account validation, signer and owner checks, program-derived addresses, cross-program invocations, account reallocation and closing
Move (Sui, Aptos)Resource and object ownership, capabilities and who holds them, module upgrade policies, shared object access

Solidity benefits from the most mature tooling and the largest pool of reviewers, which is why it is the baseline in the model. For other languages, check that the auditor has published reports on your ecosystem: experience with one language does not transfer automatically to another.

Method and timeline

A DeFi audit follows the same steps as any smart contract audit, with more time spent on design and scenarios.

  1. Scoping. You share the repository, a commit hash, the list of contracts in scope, documentation and tests. The auditor estimates effort and proposes dates.
  2. Kick-off. Your team walks the auditors through the design, the roles, the economic assumptions and the known limitations.
  3. Review. Manual review, tooling, invariants and economic scenarios, with questions to your team along the way.
  4. Report. Findings ranked by severity, with fixes recommended.
  5. Fixes and re-audit. Your developers fix the issues and the auditor verifies each fix on a new commit.

In the model, a 1,500 nSLOC Solidity DeFi protocol takes about 6 auditor-days with an independent auditor and about 8.5 auditor-days, or 2 weeks, with an established firm. A 5,000 nSLOC protocol takes about 3 weeks with 2 auditors at an established firm. Add time for your team to fix the findings and for the re-audit. The guide on how to prepare for a smart contract audit helps you shorten each step.

What a DeFi audit costs

In the public indicative model, the DeFi project type carries a factor of 1.35, compared with 1.0 for staking and 0.7 for a token: for the same size of code, a DeFi protocol takes about a third more auditor-days than a staking contract. The ranges below assume standard urgency, partial tests and documentation, and no extra risk factor unless stated.

CaseIndependent auditorsEstablished audit firms
DeFi protocol, 1,500 nSLOC, Solidity4,800 to 8,400 EUR15,000 to 30,000 EUR
Same, with external integrations and upgradeable contracts5,600 to 9,800 EUR18,000 to 35,000 EUR
Same size, Rust (Solana)6,400 to 11,000 EUR20,000 to 39,000 EUR
DeFi protocol, 5,000 nSLOC, Solidity16,000 to 27,000 EUR49,000 to 95,000 EUR

Custom math (pricing curves, interest models, fixed-point arithmetic) adds 20% of effort in the model, and each of external integrations and upgradeability adds 10%. Good tests and documentation reduce effort by 10%; none increase it by 20%. Starting within two weeks costs x1.25, within a week x1.5.

These are orders of magnitude, not quotes. Enter your own figures in the audit cost calculator, and read the guide on smart contract audit cost for every parameter.

Re-audit and after the audit

The re-audit is the auditor's verification of your fixes, priced at about 20% of the first audit in the model. For the 1,500 nSLOC Solidity case above, audit and re-audit together come to about 5,800 to 10,000 EUR with an independent auditor, or 18,000 to 36,000 EUR with an established firm. Without a re-audit, the report describes code you no longer deploy.

After deployment, an audit report ages with every change. Plan for:

  • Monitoring: alerts on unusual flows, price deviations, large withdrawals and admin actions.
  • A bug bounty: a public reward for researchers who report flaws responsibly.
  • Pause and response: a tested way to pause sensitive functions, held by a multisig, and a written plan for who does what during an incident.
  • New audits for significant upgrades, new modules or new chains.

Choosing DeFi auditors and staying independent

Choose auditors on DeFi experience you can verify, not on the total price alone. Compare quotes on the same basis:

  • Published reports on protocols similar to yours (AMM, lending, vaults, derivatives) and on your language and chain.
  • Effort: auditor-days and number of reviewers. A price far below the others usually means fewer days.
  • Method: manual review, invariants, fuzzing, economic review, formal verification where relevant.
  • Re-audit: included or not, and within what time limit.
  • Independence: no role in writing the code.

On smart-contract.com, independence is enforced in the database: a company holding a development engagement on your project can never be invited to its audit, and an audit firm engaged on a project cannot then develop it. The guide on developer and auditor independence explains why. You can browse audit firms in the directory, read the smart contract audit service page, or start with DeFi development if the contracts are not written yet. For protocols that will hold significant funds, several complementary reviews are common practice.

Key takeaways

  • A DeFi audit reviews both the code and the economic design of a protocol that holds pooled user funds.
  • Oracles, flash loans, liquidations, governance, upgradeability and admin keys are the main DeFi-specific risks.
  • A complete engagement combines manual review, invariants, fuzzing and economic scenarios, then a re-audit.
  • In the site's model, DeFi carries a 1.35 factor: a 1,500 nSLOC Solidity protocol costs about 4,800 to 8,400 EUR with an independent auditor and 15,000 to 30,000 EUR with an established firm.
  • Budget the re-audit (about 20%), then monitoring, a bug bounty and a tested pause procedure.

Frequently asked questions

How much does a DeFi audit cost?

In the site's public indicative model, a 1,500 nSLOC Solidity DeFi protocol costs about 4,800 to 8,400 EUR with an independent auditor and 15,000 to 30,000 EUR with an established firm, at standard urgency with partial tests. A 5,000 nSLOC protocol costs about 16,000 to 27,000 EUR and 49,000 to 95,000 EUR respectively. The audit cost calculator gives a range for your own code.

Why is a DeFi audit more expensive than a token audit?

DeFi code holds pooled funds, relies on oracles, interacts with other protocols and implements economic logic such as interest rates, fees and liquidations. Auditors must review the code and test the design against manipulation scenarios. The model reflects this with a project type factor of 1.35 for DeFi, against 0.7 for a token and 1.0 for staking.

Is a Solidity audit different from a Rust or Move audit?

The method is the same, but the points of attention differ. Solidity reviews focus on reentrancy, token quirks, proxies and rounding; Rust on Solana on account validation and signer checks; Move on object ownership and capabilities. Tooling and reviewers are most abundant for Solidity, so the model applies a factor of 1.25 for Move and 1.3 for Rust.

Does a DeFi audit protect against economic attacks?

Only if the scope includes an economic review. Ask the auditor explicitly whether they will test price manipulation, flash loan scenarios, liquidation behavior and incentive design, and how. Even then, an audit reduces risk without removing it: parameters change, markets move and integrated protocols evolve, so monitoring and a bug bounty remain necessary.

When should I book a DeFi audit?

Book it several weeks before the planned audit start, once the code can be frozen, tested and documented. A start within two weeks costs x1.25 in the model, and within a week x1.5. Plan time after the report for fixes and the re-audit, and do not launch on mainnet before the fixes are verified.

Ready to have your protocol reviewed? Describe it once and receive comparable quotes from up to 6 vetted, independent auditors, free for clients and without commitment until you choose.

Describe your project once. Compare with confidence.

Get comparable quotes from vetted developers, then secure your code with an independent auditor.

Get quotes

Free for clients. No commitment.