Liquidity Mining: The Physics of Inflation
Why farm tokens tend to zero. The mechanics of MasterChef contracts, Vampire Attacks, and the mercenary capital problem.
🎯 What You'll Learn
- Deconstruct the MasterChef Contract (Minting Logic)
- Analyze the 'Mercenary Capital' feedback loop
- Calculate the Inflationary Decay Rate of a Farm Token
- Trace a Vampire Attack (SushiSwap vs Uniswap)
- Evaluate the 'Real Yield' vs 'Dilution' trade-off
Introduction
Liquidity Mining is not “Free Money”. It is Dilution. When a protocol pays you 100% APY in its own token, it is printing money. If the demand for that token does not grow faster than the printer, the price must collapse mathematically.
This lesson covers the mechanics of this “Rent-a-Liquidity” model and why it creates empires that crumble overnight.
The Feedback Loop
Capital in DeFi has near-zero friction. It moves to the highest yield fast.
The Feedback Loop of Doom:
- Phase 1 (The Pump): High APY attracts TVL. Token price rises due to hype. APY rises further.
- Phase 2 (The Dump): Inflation catches up. Sellers > Buyers. Price drops.
- Phase 3 (The Exodus): APY drops (because token price dropped). TVL leaves. Price crashes to zero.
Typically, a large fraction of liquidity providers are “Mercenaries” who sell the reward token immediately upon receipt (atomic selling).
Deep Dive: The MasterChef Contract
The industry standard for token emissions is the MasterChef.sol contract (pioneered by SushiSwap).
The Logic:
Tokens Per Block are minted and distributed to pools based on Allocation Points.
The Risk:
The MasterChef usually has an Owner. The Owner can change the Mint Rate or Alloc Points instantly.
In many rug pulls, the Owner sets the Mint Rate to a massive value for their own wallet.
Strategy: The Vampire Attack
How do you steal liquidity from a competitor? You offer incentives for the competitor’s LP tokens.
Case Study: SushiSwap (2020)
- Uniswap LPs hold
UNI-LPtokens. - SushiSwap says: “Stake your
UNI-LPtokens in our MasterChef.” - “We will pay you
SUSHItokens.” - Result: SushiSwap drained roughly $1 billion from Uniswap in a matter of days without building a DEX first. They migrated the liquidity.
Code: Calculating Real Yield
Yield comes from two sources: Fees (real) and Emissions (inflationary).
def calculate_real_yield(tvl, trading_volume, emission_rate, token_price):
# 1. Real Yield (Trading Fees)
# 0.3% of volume goes to LPs
daily_fees = trading_volume * 0.003
fee_apy = (daily_fees * 365) / tvl
# 2. Emission Yield (Inflationary)
daily_emission_value = emission_rate * token_price
emission_apy = (daily_emission_value * 365) / tvl
# 3. Net APY
net_apy = fee_apy + emission_apy # Nominal (ignores token dilution)
return {
"nominal_apy": net_apy,
"fee_component": fee_apy,
"dilution_risk": "High" if emission_apy > fee_apy else "Low"
}
Practice Exercises
Exercise 1: The Death Spiral (Beginner)
Scenario: Token Price 5. Task: What happens to the APY? (It halves). What do LPs do? (Leave). What does that do to Price? (Drops more).
Exercise 2: MasterChef Audit (Intermediate)
Task: Read a MasterChef.sol contract. Find the migrator function.
Risk: If migrator is set, the owner can move all staked LP tokens to a different address.
Exercise 3: Real Yield Ratio (Advanced)
Task: Calculate the Fees / Emissions ratio for a protocol.
If Ratio < 1, the protocol is purely subsidized. If Ratio > 1, it covers its yield from actual fees.
Knowledge Check
- What is a MasterChef contract?
- Why do farm tokens tend to zero?
- What is a Vampire Attack?
- Why is “Total Value Locked” (TVL) a vanity metric?
- How can a “Migrator” function be used for a rug pull?
Answers
- The Minting Engine. Smart contract that distributes rewards per block.
- Inflation. Supply increases linearly/exponentially, demand is usually temporary.
- Incentivized Migration. Stealing a competitor’s liquidity by paying rewards for their LP tokens.
- It’s Mercenary. It can leave in one block. A more meaningful metric is “Protocol Revenue”.
- Code is Law. It allows the contract owner to move the underlying assets to a new address.
Summary
- Liquidity Mining: Is marketing. Yield from emissions is dilution.
- MasterChef: Is the central bank. The owner controls the printer.
- Real Yield: Comes from fees. Everything else is debt.
Want to go deeper?
Weekly infrastructure insights for engineers who build trading systems.
Free forever. Unsubscribe anytime.
You're in. Check your inbox.
Questions about this lesson? Working on related infrastructure?
Let's discuss