A DeFi development company designs, writes and secures smart contracts that hold and move users' money without an operator in the middle. This guide explains what such a project contains, where DeFi protocols fail, how to judge a development firm and what drives cost, so a founder can scope the work before hiring.
DeFi code is public, the money in it is real and most mistakes cannot be reversed. For that reason, economic design and security take more of the budget than features do.
What counts as a DeFi protocol
A DeFi protocol is a set of contracts that performs a financial function under rules enforced on-chain. Typical functions are swapping assets, lending them, issuing a stablecoin against collateral, pooling yield and settling derivatives. Three properties separate a DeFi protocol from a fintech app that uses a blockchain:
- Self-custody: users keep assets in their own wallets or in contracts whose withdrawal rules no single admin can override, though in some protocols public governance can change those rules after a time delay.
- Composability: other contracts can call yours without permission. A lending market can accept your liquidity token as collateral, and an aggregator can route trades through your pool. When one protocol fails, every protocol that holds its tokens or reads its prices can lose money.
- Transparency: state and code are public, so anyone can check reserves and attackers can study the contracts too.
A design that needs an admin who can freeze balances, reverse transactions or set prices is a custodial product that uses a blockchain, and it carries different legal duties.
The core DeFi primitives
Most DeFi products are one primitive or a mix of a few. The primitive tells the development team which reference designs to study and which attacks to expect.
| Primitive | Core mechanism | Reference designs | Typical failure |
|---|---|---|---|
| Automated market maker (AMM) | A pool prices assets by a curve, such as x·y=k | Uniswap v2, v3 and v4, Curve, Balancer | The pool price is used as an oracle and gets manipulated. Liquidity providers suffer impermanent loss. |
| Lending market | Over-collateralized loans, rates set by utilization, liquidations | Aave, Compound, Morpho | Bad debt from oracle errors or illiquid collateral |
| Collateralized stablecoin | Users lock collateral and mint a stable asset | Sky (formerly MakerDAO), Liquity | The peg breaks when collateral falls faster than liquidations clear. |
| Yield vault | Pools deposits, runs a strategy and issues shares | Yearn, ERC-4626 vaults | Share-price manipulation and strategy losses |
| Staking and liquid staking | Locks tokens for rewards and issues a receipt token | Lido, Rocket Pool | Reward accounting bugs, slashing and receipt-token de-pegs |
| Derivatives | Perpetuals, options and synthetics settled on-chain | GMX, dYdX, Synthetix | Oracle delay arbitrage and funding imbalance |
Each primitive has its own guide on this site: the decentralized exchange development guide covers swaps, the lending and borrowing platform guide covers credit markets and the DeFi yield farming guide covers incentive programs.
Other products combine these primitives: on-chain insurance, synthetic assets, tokenized real-world assets, crowdfunding contracts and managed vaults. Each combined product carries the risks of its primitives, and insurance and tokenized assets also add legal risks such as licensing and securities rules.
A worked example: constant-product pricing
An AMM pool holds x of token A and y of token B, and it keeps x·y = k after every trade, before fees. A trader who sells dx of A with fee f receives dy = y·dx(1−f) / (x + dx(1−f)). A larger trade relative to the pool gets a worse price.
That formula explains three design needs. Users set a minimum output to limit slippage. Large swaps need protection from sandwich attacks, in which a bot trades just before and just after the swap and profits from the price move. A pool's spot price is unsafe as an oracle, because a flash loan can move it for one block.
Architecture of a DeFi product
The contracts are the core, but a usable product has seven layers, and the budget must cover all of them, not only the Solidity work.
- Core contracts hold the accounting and the invariants: who owns what, how balances change and which conditions must always hold. Keep this layer small, and keep it immutable where possible.
- Periphery contracts are routers, helpers and adapters that make the core easier to use. A team can replace them without moving user funds.
- Oracles bring in outside prices, usually from Chainlink, Pyth, RedStone or a time-weighted average price (TWAP) from a deep on-chain pool. Each oracle can fail. A feed can stop updating, and many feeds update only when the price moves by a set percentage, so small moves do not appear. On rollups, the sequencer can also go down.
- Governance and admin decide who can change parameters, upgrade code or pause the system. A common setup is a multisig behind a timelock, plus a guardian that can pause but cannot move funds.
- Keepers and bots send the transactions for liquidations, harvests and rebalances. Incentives should pay third parties to do this work, and the protocol team runs backup bots.
- Indexing and APIs turn contract events into positions, histories and APYs that the front end can query.
- The front end handles wallet connection, transaction building, simulation and risk disclosures, and its hosting must prevent a silent swap of the code. In February 2025, attackers took about $1.4 billion from the Bybit exchange after they altered the Safe wallet interface its signers used.
Choosing a chain
A chain's existing liquidity and users matter more than its speed. A lending market on a chain without deep stablecoin liquidity has little to lend.
- Ethereum mainnet has the deepest liquidity and the most tested tools, but gas makes small positions too expensive there.
- Ethereum rollups such as Arbitrum, Base and Optimism offer EVM compatibility with low fees. Oracle logic must handle sequencer downtime, and bridged assets differ from native ones.
- BNB Smart Chain and other EVM chains offer cheap transactions and many retail users, but they have fewer validators, so a small group could halt or censor them.
- Solana programs are written in Rust, and each transaction lists every account it touches, so Solidity contracts do not port to Solana. Sui and Aptos use the Move language. The multichain development guide covers products that span several ecosystems.
Where DeFi protocols break
Most losses come from a short list of causes, and a design review checks each one in turn.
Price oracle manipulation
Some contracts read a price that one transaction can move. An attacker borrows a large sum with a flash loan, pushes the price, borrows against the inflated value and repays the loan. Cream Finance in 2021 and Mango Markets in 2022 lost large sums this way. Defenses are manipulation-resistant oracles, sanity bounds on prices and caps on how much one asset can back.
Reentrancy and call order
A contract that sends tokens before it updates its own state lets the recipient call back in. The fix is the checks-effects-interactions pattern plus reentrancy guards. Read-only reentrancy is a related bug: another protocol reads your contract's state in the middle of an update and gets a wrong value. In July 2023, a bug in the Vyper compiler broke reentrancy locks in several Curve pools, so the compiler is part of the attack surface.
Math, rounding and overflow bugs
Share-based systems such as vaults and lending pools must round in one direction. If rounding favors the user, an attacker repeats tiny operations until the rounding error adds up, so contracts should round against the user. A new vault should also mint a few shares to an address nobody controls, so the share price cannot be inflated while the vault is empty.
Two 2025 exploits came from this class of bug. In May 2025, an attacker drained about $223 million from Cetus, a DEX on Sui, through a code path that a math library's overflow check did not cover. In November 2025, Balancer v2 pools lost about $128 million across several chains after an attacker amplified a rounding error with many small swaps in one transaction. Rekt's Balancer analysis describes the mechanics.
Governance capture
In 2022, an attacker flash-borrowed enough Beanstalk governance tokens to pass a malicious proposal in one transaction and took about $181 million. Governance contracts should snapshot voting power before a proposal and run execution through a timelock.
Admin key compromise
Many large losses came from stolen keys or tricked signers, not from contract bugs. Teams use hardware-backed multisigs, separate roles and tight limits on what each key can do.
The DeFi development process
- Mechanism design: write an economic model that says who supplies capital, who pays whom, what happens in a 50% price crash and what happens if nobody liquidates. Simulate that model, even in a spreadsheet.
- Specification: a plain-language spec and a list of invariants, such as "total shares map to total assets".
- Implementation: Foundry or Hardhat, OpenZeppelin libraries for standard parts and as little custom code as possible. Forks of proven designs reduce risk, but check the license. Uniswap v4 core and Aave v3 use the Business Source License 1.1, which limits commercial reuse.
- Testing: unit tests, fuzz tests, invariant tests and fork tests against mainnet state with real tokens and oracles. Static analysis tools such as Slither catch common issues at low cost.
- Audit and fixes: one or more independent audits, often with a public audit contest. The plan includes time to fix findings and get a re-review.
- Guarded launch: deposit caps, a short asset list and cautious parameters, with limits raised as the system runs without incident.
- Operations: monitoring, keepers, parameter governance, incident response and a new audit for every upgrade.
What a DeFi development company delivers
A full-scope DeFi development company covers the seven steps above. In practice, scopes differ, and the contract should list each item:
| Deliverable | What to expect |
|---|---|
| Mechanism design | A written model of the economics with stress scenarios. Some firms expect the client to bring this model. |
| Smart contracts | Source code, deployment scripts and an invariant list, in a repository you own |
| Test suite | Unit, fuzz, invariant and fork tests, with a coverage report |
| Front end and indexer | Wallet connection, transaction simulation and a subgraph or custom indexer |
| Audit coordination | Preparation for an independent auditor and fixes for the findings. The auditor should be a separate firm. |
| Launch and operations | Deployment, multisig setup, monitoring, keepers and an incident plan |
How to evaluate a DeFi development company
- Deployed code: ask for contract addresses of past work and the audit reports for them. Block explorers show how long the contracts have run and how much value they held.
- Losses: ask whether any contract the firm wrote has lost funds, and read the post-mortem.
- Audit independence: the firm that writes the code should not be the only firm that audits it.
- Key custody: admin keys and upgrade rights belong to your multisig, never to the developer.
- Code ownership and licenses: the contract assigns the code to you and lists every forked component with its license.
- Fixed-price offers for new mechanisms: a fixed price for an untested design often means the firm plans to fork existing code. Ask which code the offer reuses.
- Security claims: treat a promise of a hack-proof protocol as a warning sign, since audited protocols such as Balancer v2 have still been exploited.
Cost and timeline drivers
No single price fits "a DeFi platform", because cost depends on how much of the design is new. The figures below are estimates based on team size and an assumed hourly rate, not quotes.
A fork of an established AMM with a custom front end and small changes needs two smart contract engineers, one front-end engineer and a part-time product lead for about 8 to 12 weeks. For a cost figure, count that team as four full-time people for 12 weeks, which is about 1,900 hours. At an average rate of $100 to $180 per hour, the fork costs roughly $190,000 to $350,000 before audits. A new lending or derivatives protocol often needs four to eight engineers for six months or more before the audit.
| Driver | Lowers cost | Raises cost |
|---|---|---|
| Novelty | Fork of audited code with parameter changes | New mechanism with no reference implementation |
| Contract size | A few hundred lines of custom logic | Thousands of lines across many interacting contracts |
| Assets supported | Two or three major tokens | Long-tail tokens with thin liquidity and unusual behavior |
| Chains | One EVM chain | Several chains, cross-chain messaging and non-EVM targets |
| Audits | One firm and a small scope | Several firms plus contests. Audit fees grow with code size. |
| Compliance | Permissionless protocol with no front-end gating | KYC, geofencing, licensed entities and regulated assets |
When not to build a new protocol
A new protocol is a poor fit when the only yield comes from the project's own token emissions, when the budget cannot cover an audit, or when users would get more from existing liquidity. Many products are front ends, aggregators or vault strategies on top of established protocols. The DeFi application development guide covers that integration route.
Frequently asked questions
What does a DeFi development company do?
A DeFi development company designs the protocol's economics, writes and tests the smart contracts, builds the front end and indexer, prepares the code for an independent audit and helps with launch. Scopes differ, so the contract should list each deliverable.
Which programming language is used for DeFi development?
Solidity is the main language on Ethereum and other EVM chains, and some protocols such as Curve use Vyper. Solana programs are written in Rust, usually with Anchor. Aptos and Sui use Move. Off-chain code is usually TypeScript, Go or Rust.
Can I fork Uniswap or Aave?
Forking audited code is safer than writing new code, but check the license first. Uniswap v4 core and Aave v3 use the Business Source License 1.1, which limits commercial use. A fork gets none of the original's liquidity, and every change needs a new review.
How long does a DeFi protocol take to build?
A lightly changed fork can reach production in two to three months: about 8 to 12 weeks of building, with a short audit of the changed code at the end. A new protocol often takes six to twelve months from design to guarded launch. Audits and fixes take a large share of that time.
Is an audit enough to make a protocol safe?
No. An audit is a review with a fixed time limit, and it can miss bugs. Teams add invariant tests, a bug bounty, deposit caps at launch, monitoring and a pause function. Balancer v2 had several audits before the 2025 exploit.