DeFi Best Practices for Teams That Run a Product
Running a DeFi product well means audited contracts, guarded keys, honest price feeds and limits that hold when the market moves.
On this page
Short answer
Running a DeFi product well means keeping users' funds safe while the market moves, the contracts stay live, and the team keeps shipping. The practices below cover the parts that cause real losses: contract bugs, key handling, price feeds, liquidity, upgrades and monitoring. They apply whether you run a lending pool, a swap or a yield product.
What does running a DeFi product well mean?
Running a DeFi product well means keeping users' funds safe while the market moves, the contracts stay live, and the team keeps shipping. It is not a one-off launch task: the same product that passed an audit can fail a year later because a key was lost, a price feed went stale, or a dependency changed.
The work falls into a few areas, and each needs an owner:
| Area | What good looks like |
|---|---|
| Contracts | Audited, tested, and upgradeable only by agreement |
| Keys | Held in multisig, with a tested recovery plan |
| Price feeds | From a reliable oracle, with a fallback and a staleness check |
| Liquidity | Deep enough for normal trades, with clear limits |
| Monitoring | Alerts on large moves, failed feeds and unusual withdrawals |
If you are still building, how to implement DeFi covers the build steps in order. This article covers what to do once the product is live and holding real funds.
How do you keep the smart contracts safe?
You keep smart contracts safe by treating the audit as the start, not the end. An independent audit before launch is the baseline, and every change after launch needs the same care: a code review, tests on a copy of the live state, and a second look at any function that moves funds.
Write the contracts so that a bug cannot drain the whole pool. Use withdrawal limits, caps on how much can move in one transaction, and a pause function that a named group can trigger. A pause does not fix a bug, but it buys hours while the team works out what happened.
Test the failure cases, not just the happy path. What happens when the oracle returns a stale price, when a token transfer fails, when a user sends an unexpected token, or when two transactions arrive in the same block? The answers to those questions are where most losses come from, so write them down as tests and run them on every change.
How do you handle keys and treasuries?
You handle keys and treasuries by making sure no single person can move funds alone. Admin keys should sit behind a multisig that needs several named people to approve a transaction, and the signers should be spread across people and devices, not all in one office or one laptop.
Keep the treasury separate from the operating funds. The money users deposit should sit in the product's contracts, and the team's own funds should sit in a separate wallet with its own rules. Mixing the two makes accounting hard and tempts shortcuts when cash is tight.
Write down the recovery plan and test it once a year. If a signer loses a key or leaves the team, the others need to know how to replace them without stopping the product. A multisig with a signer who cannot be reached is a lock on your own funds, and it happens more often than teams expect.
How do you manage oracle and price-feed risk?
You manage oracle risk by never trusting a single price source for a decision that moves money. Use a reliable oracle as the main feed, check it against a second source, and refuse to act when the two disagree by more than a set amount. A stale or manipulated price is one of the most common ways DeFi products lose money.
Check the age of every price before you use it. A feed that stopped updating an hour ago is not a price, it is a guess, and liquidations or swaps based on it will be wrong. Build the staleness check into the contract, not just the dashboard, so the product stops rather than trades on old data.
Set a circuit breaker for extreme moves. If a price jumps far beyond what the market could do in a few minutes, pause the affected function and let a human look. A short pause costs little; a liquidation cascade based on a bad price can cost the whole pool. For the background on what DeFi is, what is DeFi explains the model these feeds serve.
How do you protect users from bad trades?
You protect users from bad trades by showing them the true cost before they confirm, and by limiting how much a single trade can move the price. Slippage settings, minimum amounts received, and clear warnings on thin pools are the basics, and they should be on by default rather than hidden in settings.
Watch the pool depth. A pool with little liquidity moves a lot on a normal trade, so users get a worse price than the screen shows. Publish the pool depth, warn when a trade is large relative to the pool, and route large trades through deeper venues when you can. A user who loses money to slippage rarely comes back.
Be honest about the risks in plain language. Users should know that a pool can lose value, that a token can fall, and that a smart contract can have a bug, before they deposit. A product that hides those risks in small print loses trust faster than one that states them clearly. For wallet safety on the user side, best DeFi wallets covers what users should look for.
How do you monitor and upgrade safely?
You monitor a DeFi product by watching the numbers that signal trouble before users notice: total value locked, large withdrawals, failed transactions, oracle staleness and the gap between your price and the wider market. Alerts should go to a named person, not a shared inbox nobody reads.
Upgrade in stages, and keep the old version working until the new one proves itself. Test every upgrade on a copy of the live state, including a rollback, and agree the change with the multisig signers before it goes live. An upgrade that changes how funds move needs the same care as the first launch.
Keep an incident plan written down. It should say who decides to pause the product, who talks to users, and how funds are returned if something goes wrong. The first incident is the wrong time to write it, and a team that has rehearsed the plan reacts in minutes instead of hours.
Example: a small lending pool team
Example (hypothetical): a small team runs a lending pool. A user borrows $10,000 against $12,500 of collateral, which is a loan-to-value ratio of 80%, the pool's maximum. The pool's rule is that a loan is liquidated when the ratio rises above 85%.
One morning the collateral falls by 10%, from $12,500 to $11,250. The ratio becomes $10,000 divided by $11,250, which is about 88.9%, above the 85% limit, so the loan is liquidated. The pool sells enough collateral to repay the loan and returns the rest to the borrower. The arithmetic is 10,000 divided by 12,500 equals 0.8, and 10,000 divided by 11,250 equals about 0.889.
The liquidation works because the oracle price was fresh and the pool had a clear rule. The team later adds a second price source and a check that pauses liquidations when the two sources disagree by more than 2%. That check costs nothing on a normal day, and it stops the pool from liquidating loans on a bad price feed.
What are the common mistakes?
The most common mistakes in DeFi products come from trusting one component too much, and from shipping fast without a way to stop.
- One price source. A single oracle is a single point of failure for every decision that uses price.
- Admin keys held by one person. A lost key or a compromised laptop can move all the funds.
- No pause function. A bug found on a Friday evening cannot be stopped until Monday.
- Untested upgrades. A change that works in development breaks the live pool.
- Hidden risks. Users who discover the risks after depositing do not deposit again.
- No incident plan. The first incident becomes a scramble instead of a rehearsed response.
If you are planning the wallet side of the product, how to develop a DeFi wallet covers the build. Once the product holds real funds, the practices in this article are what keep it safe.
Key takeaways
- Running DeFi well is daily work: contracts, keys, price feeds, liquidity and monitoring
- Never trust a single price source for a decision that moves money
- Admin keys belong behind a multisig, with a tested recovery plan
- Caps, pauses and circuit breakers buy time when something goes wrong
- Write the incident plan down before the first incident, and rehearse it
Frequently asked questions
What is the biggest risk in running a DeFi product?
The biggest risks are a contract bug, a bad price feed and a lost or stolen admin key. Each can drain funds on its own, and each is preventable: audits and caps for contracts, multiple price sources with staleness checks for feeds, and multisig with a recovery plan for keys.
Do I need an audit before launch?
Yes. An independent audit of the contracts that hold user funds is the baseline before launch, and every change after launch needs review and testing too. An audit does not prove a contract is safe, but launching without one asks users to trust code nobody independent has read.
How many price sources should I use?
At least two, with a rule for what happens when they disagree. Use a reliable oracle as the main feed and check it against a second source, and pause the affected function when the gap is larger than a set amount. Also check the age of every price before you use it.
What is a multisig, and why does it matter?
A multisig is a wallet that needs several named people to approve a transaction before it happens. It matters because no single person, key or laptop can move funds alone. Spread the signers across people and devices, and test the recovery plan once a year.
How do I know if my pool has enough liquidity?
Watch the pool depth against the size of normal trades. If a typical trade moves the price by more than a small amount, the pool is thin for that trade size. Publish the depth, warn users on large trades, and route large trades through deeper venues when you can.
What should I do first if something goes wrong?
Follow the incident plan: pause the affected function, check the price feeds and the contract state, and tell users what happened and what you are doing. A short pause costs little, while trading on while a bug or a bad feed is live can cost the whole pool.