Book a free call

DeFi Yield Farming: How It Works and What It Costs

Yield farming pays you for putting crypto into a DeFi protocol as trading liquidity or a loan. Learn where the yield comes from, the main strategies and the risks.

Hertiv engineering teamReviewed by a senior engineer
6 min read
DeFi Yield Farming: How It Works and What It Costs
On this page

Short answer

DeFi yield farming means depositing crypto into a decentralised finance protocol to earn a return, usually trading fees, interest or extra tokens. You supply liquidity to a trading pool or lend assets to borrowers, and the protocol pays you for the use of your funds. The return is real, but so are the risks: token prices move, smart contracts have bugs, and yields can fall fast.

What is DeFi yield farming?

DeFi yield farming is the practice of depositing crypto into a decentralised finance protocol to earn a return, usually in the form of trading fees, interest or extra tokens. Instead of holding an asset and waiting for its price to rise, you put it to work in a protocol that needs it.

The most common setup is a liquidity pool. A trading pair, such as two tokens, sits in a pool that traders swap against. Liquidity providers deposit both tokens, and each trade pays a small fee that is shared between them in proportion to their share of the pool.

Strategy How it pays Main risk
Liquidity pools Trading fees Impermanent loss
Lending markets Borrower interest Borrower default
Staking Network rewards Token price fall
Auto-compounding vaults Reinvested rewards Smart contract bug
Token rewards Extra protocol tokens Reward token falls

Farming is not the same as staking a single token for network security, though the two are often mixed up. Farming usually means moving funds between pools and strategies to chase the best return, which is also where the extra risk comes from.

Where does the yield actually come from?

The yield in yield farming comes from three places, and knowing which one pays you matters more than the headline rate. Trading fees come from people swapping in a pool. Interest comes from borrowers who pay to use your assets. Token rewards come from the protocol itself, which issues new tokens to attract deposits.

Fees and interest are the durable sources. They exist because someone pays for a service: a trader pays to swap, a borrower pays to borrow. Token rewards are the fragile source, because they depend on the protocol choosing to issue tokens, and on those tokens holding value.

A pool that pays mostly in token rewards can look generous while the rewards lose value faster than they arrive. Check the split before you deposit: a return built on fees is steadier than one built on a token that the protocol prints. What is DeFi explains the protocols these returns come from.

The main yield farming strategies

The main yield farming strategies are liquidity pools, lending markets, staking and auto-compounding vaults, and each one trades a different risk for a different return. Most farmers use more than one, but each position should be judged on its own.

Liquidity pools pay trading fees and sometimes extra tokens. The risk is impermanent loss: if one token in the pair moves far from the other, your share is worth less than simply holding both tokens would have been. Stable pairs, such as two stablecoins, have little impermanent loss but pay lower fees.

Lending markets pay interest from borrowers, with collateral that can be sold if a loan goes bad. Staking pays network rewards for locking tokens that secure a chain. Auto-compounding vaults take your rewards, sell them and reinvest, which saves gas and time but adds another contract to trust. DeFi development teams build these vaults as part of larger products.

What are the risks of yield farming?

The risks of yield farming are impermanent loss, smart contract bugs, token price falls and protocol failure, and they stack. A position can lose value from a price move and a bug at the same time, so the headline yield is only half the picture.

Impermanent loss hits liquidity pools when the two tokens in a pair move apart. Smart contract bugs hit any protocol, including audited ones, because an audit is a review, not a guarantee. A reward token can fall faster than it is earned, which turns a high headline rate into a loss. And a protocol can fail outright, through a hack, a governance decision or a market event.

The practical defence is size and spread. Keep each position small enough that its failure does not matter much, spread across more than one protocol, and treat any return that looks far above the rest of the market as a warning sign. Smart contract audit work reduces, but never removes, the contract risk.

Example: a small liquidity pool position

Example (hypothetical): you deposit 1,000 of token A and 1,000 of token B into a trading pool, a total of 2,000. The pool holds 20,000 in total, so your share is 10%. Over one month, traders pay 200 in fees into the pool, and the protocol adds 300 in reward tokens.

Your share of the fees is 10% of 200, which is 20. Your share of the rewards is 10% of 300, which is 30. Together that is 50 on a 2,000 deposit, or 2.5% for the month, before any price moves.

Now suppose token B falls by 20% during that month. Your 1,000 of token B is worth 800, and the pool rebalances your share, so the position is worth less than 2,050 even after the 50 of yield. The arithmetic is simple: a 2.5% yield does not cover a 20% price fall. That is why farmers watch the tokens in the pair as closely as the rate.

How to start yield farming safely

You start yield farming safely by keeping the first position small, choosing a protocol with a public audit and a track record, and writing down what would make you leave before you deposit.

  1. Pick a well-known protocol with a public audit and a history of handling incidents openly.
  2. Start with a stable pair or a lending position, where the risks are easier to see than in a volatile pool.
  3. Deposit an amount you could lose without changing your plans, and keep it there for a full month.
  4. Track the split between fees, interest and token rewards, and check the reward token's price weekly.
  5. Set an exit rule in advance, such as leaving if the reward token falls by half or if the protocol is exploited.
  6. Withdraw a test amount first, so you know the exit path works before you need it.

Keep records of every deposit and withdrawal, including gas costs, so you can see the real return. Crypto wallet development matters here too, since the wallet that holds your funds is part of the security picture.

What are the common mistakes?

The most common yield farming mistakes are chasing the highest headline rate, ignoring the reward token's price, and putting too much into one protocol.

  • Chasing the highest rate. A pool paying far more than the rest of the market is usually paying in a token that is falling, or taking a risk others will not.
  • Ignoring impermanent loss. A volatile pair can lose more to price moves than it earns in fees.
  • Trusting an audit as a guarantee. Audits catch some bugs, not all of them, and they do not cover economic risks.
  • One protocol, one position. A single failure should not wipe out the whole farming budget.
  • Forgetting gas and tax. Frequent moves cost gas, and every reward may be taxable where you live.

Key takeaways

  • Yield farming pays fees, interest or extra tokens for putting crypto to work in a protocol
  • Fees and interest are steadier than token rewards, which depend on the reward token holding value
  • Impermanent loss can wipe out the yield in a volatile pair
  • Keep each position small, spread across protocols, and set an exit rule before depositing
  • An audit reduces smart contract risk but never removes it

Frequently asked questions

Is yield farming the same as staking?

No, though they overlap. Staking usually means locking a token to secure a network and earning rewards for it. Yield farming is broader: it covers liquidity pools, lending and vaults, and it often means moving funds between strategies to chase the best return.

How much can you earn from yield farming?

Returns vary widely and change fast, from a few percent a year on stable pairs to very high headline rates on new pools. The high rates usually come with high risk, often paid in a token that is falling. Check the split between fees, interest and rewards before judging a rate.

What is impermanent loss?

Impermanent loss is the loss a liquidity provider takes when the two tokens in a pair move apart in price. Your share of the pool ends up worth less than simply holding both tokens would have been. It is called impermanent because the loss shrinks if the prices move back together.

Can you lose money yield farming?

Yes. Token prices can fall, reward tokens can lose value, smart contracts can be exploited, and a protocol can fail. A position can lose more from a price move than it earns in yield, which is why position size and exit rules matter more than the headline rate.

Do I need a lot of money to start yield farming?

No, but gas costs matter. On some chains, moving funds in and out of a pool costs enough that a small position loses money on fees alone. Start small on a low-fee chain or a layer-2 network, and count gas in the return before scaling up.

Is yield farming legal?

It depends on where you live and what you farm. Some places treat farming rewards as income, and some protocols are restricted in certain places. Check the tax and regulatory rules that apply to you, and keep records of deposits, rewards and withdrawals.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: blockchain systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a DeFi product and want the yield mechanics right? Talk to Hertiv.

A senior engineer replies within one business day. Or see our DeFi Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call