Liquidity Mining: The Physics of Inflation
Why Farm Tokens always go 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
📚 Prerequisites
Before this lesson, you should understand:
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 explores the physics of this “Rent-a-Liquidity” model and why it creates fleeting empires that crumble overnight.
The Physics: Mercenary Capital
Capital in DeFi is a superfluid. It has Zero Friction. It moves to the highest yield instantly.
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 0.
Physics: This is an unstable equilibrium. Typically, 95% of liquidity providers are “Mercenaries” who will sell the reward token immediately (Atomic Selling).
Deep Dive: The MasterChef Contract
The industry standard for printing tokens is the MasterChef.sol contract (pioneered by SushiSwap).
The Logic:
Tokens Per Block are minted and distributed to pools based on Allocation Points.
The Danger:
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 Infinity for their own wallet.
Strategy: The Vampire Attack
How do you steal liquidity? Physics: 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 $1 Billion from Uniswap in days without building a DEX first. They “Vampired” the liquidity.
Code: Calculating Real Yield
Yield comes from two sources: Fees (Real) and Emissions (Fake).
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. Fake Yield (Emissions)
daily_emission_value = emission_rate * token_price
emission_apy = (daily_emission_value * 365) / tvl
# 3. Inflation Adjustment
# If you hold the reward token, you are being diluted by emissions
net_apy = fee_apy + emission_apy # Nominal
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 steal all staked LP tokens legally.
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 is profitable.
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 1 block. Meaningful metric is “Protocol Revenue”.
- Code is Law. It allows the contract owner to move the underlying assets to a new address (the attacker’s wallet).
Summary
- Mining: Is Marketing.
- Yield: Is often Dilution.
- MasterChef: Is the Central Bank.
Questions about this lesson? Working on related infrastructure?
Let's discuss