How onchain liquidity works, and where the money is lost
On one side, whoever deposits their coins into the pool and supplies its liquidity; on the other, whoever swaps and pays a fee on every swap. That fee is the only payment the depositor gets, and it has to be enough to cover the impermanent loss.
How does a pool make a price with no buyers and sellers?
When somebody buys eth, the eth in the pool goes down and the usdc goes up. To keep the product fixed, the price the pool quotes moves by itself: the bigger the order, the worse the price gets as it fills. There’s nobody on the other side, no order book to keep up to date and no bid to wait for. It’s just you and a curve.
In a pool that keeps the product of the two amounts constant, buying eth empties the eth side and fills the usdc side: the point slides along the curve and the price moves. After the price of eth doubles the pool holds 0.707 eth and 2,828 usdc, no longer 1 and 2,000.
Those are the advantages that made AMMs take off: you swap whenever you like, with no counterparty and no waiting. The costs come right after, and there are three of them. Slippage on large orders, which is the price moving while you buy. The sandwich attack, where somebody sees your order before it fills, buys ahead of you and sells right after. And impermanent loss, which hits the people who put money into the pool more than the people who swap, and is the biggest of the three.
Why can providing liquidity pay less than sitting still?
The clearest example is the classic one. You deposit 1 eth when it’s worth $2,000, plus 2,000 usdc, $4,000 in all. If eth doubles to $4,000, someone who just held the coins has $6,000. You, in the pool, have $5,657, because the arbitrage along the way left you with 0.707 eth instead of one. You’re $343 short, 5.7%.
With 1 eth at $2,000 and 2,000 usdc deposited, if eth doubles whoever held the coins still gets $6,000 and whoever put them in the pool gets $5,657. If eth halves, holding still gets $3,000 and the pool $2,828. Either way the difference is 5.7%.
If eth halves to $1,000 instead, someone who just held has $3,000 and you have $2,828: $172 short, 5.7% again. The formula is symmetrical, and that’s the takeaway. What hurts is how far the two prices drift apart, in either direction. The fees you collect are there to cover that gap, and if they don’t, you’ve been working for the pool for free.
When does the loss stop being impermanent?
In practice prices almost never come back to where they started. And you have to stay in the pool long enough for the fees to fill the hole, while volatility keeps widening it. The further the two prices diverge, the bigger the loss, and it grows fast: a doubling costs 5.7%, a tripling 13.4%, a five-fold move 25.5%.
In a 50/50 pool the impermanent loss grows with the distance between the prices of the two coins: 0.6% if one moves a quarter against the other (×1.25), 2.0% at one and a half times (×1.5), 5.7% at a doubling, 13.4% at a tripling, 25.5% at five times.
The calculation to do before depositing is always the same, and it’s a subtraction: what the fees pay minus what the impermanent loss costs. If a pool pays 30% apr in fees and the price divergence costs you 40%, you’re losing money while staring at a green number. Most liquidity providers only look at the first number, because that’s the one printed large in the interface.
What actually reduces impermanent loss?
The four strategies for reducing impermanent loss: stablecoin pools take it close to zero in exchange for lower fees; pools of correlated coins reduce it but stay exposed to the gap between the two; concentrated liquidity raises the fees inside a price band and zeroes them outside it; token emissions make it up only while the issued token holds its value.
The first is pairing coins that don’t diverge. Two stablecoins pegged to the same dollar, like usdc, usdt or dai, almost never move apart, so the impermanent loss stays close to zero. The fees are lower, but the ones you collect you keep. The second is pairing coins that move together, like stETH and eth or wBTC and bitcoin. They’re not the same thing, but they go the same way, and the gap that opens between them is small.
The third is concentrated liquidity, which Uniswap introduced in version three. Instead of spreading your money across every possible price, you put it inside one band. The same capital works much harder as long as the price stays in there, and stops working entirely the moment it leaves. At that point you collect nothing and you’re left holding only the coin that lost. The fourth is having the protocol make up the impermanent loss in its own tokens, which works as long as the token is worth something. If it falls while you pile it up, you’ve swapped a certain loss for a bigger one.
What happens when you borrow against what you hold?
With $10,000 of eth as collateral and a maximum LTV of 75%, the loan reaches $7,500. Liquidation is triggered when the debt reaches 85% of the collateral, which is $8,500: between the most you can borrow and the threshold that liquidates you there are $1,000.
The tricky part is less how much you borrow than where they stop you. Every collateral has a liquidation threshold above the maximum you can borrow, say 85%. If the price of eth falls and your debt ends up worth 85% of the collateral, the protocol sells the collateral to get its money back and keeps a penalty, usually between 5% and 15%. No phone call, no extension. A contract executes, and that’s it.
The trouble is that these sales all arrive together. When the market falls fast, thousands of positions touch the threshold at the same moment, the sold collateral lands on the market, the price falls further, and the fall trips the next threshold. It happened in the March 2020 crash, and again in every one of the sell-offs between 2022 and 2023.
How do you build leverage out of loans, and why does it break?
Starting from $10,000 of eth, each lap lends 75% of what was just deposited: $7,500 on the first lap, $5,625 on the second. The final exposure is about $23,125, which is 2.3 times the starting capital, and with every lap the liquidation threshold comes closer.
While the price rises it’s the best thing in the world: if eth gains 10%, you gain around 30%. When it turns, the same multiplication runs backwards and a 10% fall takes 30% off you. Except the fall has a floor, and the floor is called liquidation. Every lap you did raised your LTV, so the threshold is closer than it was when you started.
It’s leverage under another name, with nobody to ask for an extension. The mechanism itself is neither good nor bad. It multiplies, and it multiplies what you don’t want too. People who use it well know exactly at what price they get liquidated and keep margin aside to stay clear of it. People who use it badly find out the day the market drops ten percent.
What changes between a transparent protocol and one that asks for trust?
The lesson that stuck is that audited code isn’t enough. An audit says an outside firm looked at the code and didn’t find certain errors, and that’s all it says. It doesn’t tell you whether the business model holds up, or who holds the keys. If the protocol is really a company promising a yield, the risk you’re running is the company’s.
four risks, four different placesThe risks that remain after an audit: counterparty risk, which starts with whoever holds the money and shows only when it is late; the bug in the contract, which lives in the code and is public; the manipulated oracle, which comes in through the price the contract reads; the bank run, which starts with a till that doesn’t stretch and shows in the available liquidity.
In the genuinely decentralized protocols, like Aave, Compound or Maker, the risk is still there. It’s a different kind, and at least you can look it in the face: a bug in the contract, a manipulated oracle reporting the wrong price, a pool that runs dry if everyone leaves at once. The code is public and everything happens onchain, so anyone who cares to can measure that risk.
Where does the yield they offer you come from?
A yield can come from the fees paid by people actually using the protocol, which is money that already exists and can be traced onchain, or from new tokens handed out as rewards, which hold up only while somebody is willing to buy them.
You can spot a yield of the first kind by three signs. It sits in a believable range, usually between 5% and 30%. You can follow it onchain back to whoever paid it. And it doesn’t need anyone to keep printing to stay up. GMX passes 30% of its trading fees to stakers. When volume falls the yield falls too, which is uncomfortable but also the sign that it’s real. The GLP pool earns from perpetuals fees and from the net of the traders’ wins and losses, so it pays well but loses when they win. Curve’s stablecoin pools pay little, and they pay every time.
You spot the second kind even faster: three-, four-, five-figure numbers, the yield paid in the protocol’s own token, capital that shows up only for the reward and leaves the next day, no real fee anywhere. Wonderland and the dozens of Olympus copies promised 80,000% a year. That was exactly the mechanism: print, hand out, the recipients sell, the price falls, and to hold the yield up you have to print more. Playing that game is a bet on getting out before everyone else, which has little to do with investing.
Put bluntly: yield farming is a way of making people believe they are earning while they are losing.
How many pieces are you stacking without noticing?
The typical chain: eth deposited with Lido becomes stETH, used as collateral on Aave to borrow usdc, put into a Curve pool, whose token is staked on Convex and in turn used as collateral elsewhere. Every link adds its own risk, whether the contract, the oracle, the liquidity or a slipped peg, and the capital underneath is always the same.
Many people hold a chain like this today without ever having written it out. You deposit eth with Lido and get stETH. You use stETH as collateral on Aave and borrow usdc. You put the usdc into a Curve pool, stake the pool’s token on Convex to boost the reward, and maybe use that as collateral somewhere else too. Six protocols, five different contracts, one pot of capital.
At that point any one of four things can wipe you out, and none of them depends on you: a bug in any of the contracts, an oracle getting stETH’s price wrong or stETH slipping its peg to eth, a pool without enough liquidity to let you out when you need it, and any link in the chain getting drained. Before you ask what the chain pays, ask how many links it has.
What actually happened when Terra went?
The May 2022 contagion in order: UST loses its peg to the dollar and the run for the exit begins; Curve’s 3pool goes out of balance; the protocols that accepted UST as collateral are left with unrecoverable debts; whoever had deposited into Anchor loses the funds; the intermediaries holding UST and LUNA, Celsius and Voyager, go under in the following weeks.
From there the contagion followed the joints one by one. Curve’s 3pool, which held UST, went out of balance and stopped giving a reliable price. The lending protocols that accepted UST as collateral were left with debts nobody would repay. Anyone with money in Anchor, the yield protocol built on top of Terra, watched it vanish. And in the weeks that followed, the intermediaries holding UST and LUNA for their customers, like Celsius and Voyager, went under.
One point giving way spread tens of billions in losses, through protocols that had no bugs and companies that had done nothing illegal that day. That’s why the question “how many links does this chain have” is worth more than any yield on an interface.
Where are the opportunities that are left?
There are three quiet strategies. Putting stablecoins on the biggest protocols pays 3% to 6% with no impermanent loss. Liquid staking, with stETH or rETH, pays the network’s yield, around 3 or 4%, and leaves you holding a receipt you can still trade. In exchange you take on contract risk and the risk of the validator being penalized. The third is delta neutral: you buy spot and sell the same amount on the perpetual, so the price no longer touches you and you collect the funding rate.
In a delta neutral position you buy an amount spot and sell the same amount on the perpetual: the two positions cancel out against the price, and what is left to collect is the funding rate paid between longs and shorts.
Delta neutral is also the best reminder of what this job really is. The two positions cancel out, so the yield comes from the work of keeping them balanced rather than from calling the direction, and that work has to be done every day.
What should you check before you put a dollar in?
The eight minimum checks before depositing: the source of the yield has to be followable onchain; at least two audits with the fixes verified; capital above fifty million with steady volume; at least six months of operation, better still with a downturn come through; a verifiable team and decision process; a standard oracle; a liquidation mechanism with brakes on the cascades; and the exit test at a hundred, a thousand and ten thousand times your own size.
Then: how long it has been around. Six months without an incident is the minimum, and having come through a long downturn is worth far more. Who’s behind it and how decisions get made: a named team helps, but anonymity can hold up too if the protocol is decentralized enough not to depend on them. Which oracle reads the prices, because that’s the attackers’ favorite way in. How liquidation works, if it’s a lending protocol, and whether anything slows a cascade of sales. And finally the simplest test of all, and the most skipped: try getting out. With a hundred thousand, with a million, with ten, and look at what it costs you in slippage before you deposit, not after.
The signals to walk away are just as practical: less than ten million of capital inside, a yield above 50% with no source that explains it, an anonymous team and code that was never audited, a large token unlock on the way, and no real downturn ever survived.
Why do most of the people who try lose?
Onchain finance has come a long way: the big protocols have years of running behind them, security has become a serious trade, and the interfaces are no longer just for programmers. It’s still a place where not knowing costs you right away and costs you a lot, and where nobody calls to warn you.
Put bluntly: decentralized finance is a minefield more than a scam, and most of the mines look like gold. Whoever can’t tell the two apart ends up as the buyer for whoever is selling.
What works is boring and fits in five lines. Learn the mechanisms, pool, loan and liquidation, before you use them. Start with the big protocols and a little capital. Do the real math: real yield minus impermanent loss minus liquidation risk. Don’t put everything in one place. And check your positions often, because a delta neutral that was balanced yesterday might not be today. It’s a job, dressed up as passive income.
the words in this piece · 31
- amm
- the program that holds two coins in its till and works the price out on its own with a formula, instead of matching buyers with sellers.
- apr
- the yearly return without counting the reinvestment of the interest.
- audit
- the examination of the code by an outside firm. it says they found no mistakes, not that there aren’t any.
- book
- the list of buy and sell orders waiting on a market. the thicker it is, the more liquid that market is.
- collateral
- what you leave as security for the loan. if its price falls too far, they sell it to close the debt.
- concentrated liquidity
- liquidity put only inside a chosen price band: it pays more while the price stays in there, and nothing the moment it leaves.
- delta neutral
- a position built so that price movements don’t touch it: what it gains on one side it loses on the other.
- fee
- what you pay to use a protocol. it can go to whoever supplies the service, to whoever holds the token, or to both.
- funding
- the periodic payment between whoever bets on a rise and whoever bets on a fall on a perpetual contract. it exists to keep that contract’s price tied to the spot market.
- funding rate
- the periodic payment between whoever is long and whoever is short, which keeps the perpetual’s price stuck to the spot price.
- impermanent loss
- how much you lose keeping your coins in a pool rather than still in the wallet, when the two prices move apart from each other.
- lending
- borrowing onchain: you leave one coin as collateral and have another lent to you, at a rate that rises and falls with demand.
- liquid staking
- you put the coin into staking and get back a receipt that stands for it and stays tradable.
- liquidation
- the forced sale of the collateral when the debt gets too big against the security behind it.
- liquidity provider
- whoever deposits their own capital in a protocol so that other people can trade, and collects a share of the fees in return. shortened to LP.
- ltv
- how much you have borrowed against what you left as collateral, as a percentage.
- onchain
- happening on the chain, and therefore verifiable by anybody.
- oracle
- the service that brings the market price inside the contract. if it gets the price wrong, everything sitting on top of it gets it wrong.
- order book
- the list of every offer to buy and to sell: the traditional way a price is made.
- perpetual
- the contract that follows a coin’s price without ever expiring: to stay open you pay or collect the funding.
- pool
- the common till the trades happen on: whoever puts their own coins into it takes a slice of the fees.
- real yield
- the yield that comes out of the fees paid by whoever uses the protocol, not out of printing new tokens.
- sandwich attack
- somebody sees your order before it is executed, buys ahead of you and sells again straight afterwards, leaving you a worse price.
- short
- the position that gains when the price falls. you open it by selling something you don’t own.
- slippage
- the difference between the price you expect and the price you actually get. it grows with the size of the order and with the thinness of the book.
- spot
- the market where the asset itself changes hands, delivered on the spot. as opposed to derivatives, where what trades is a contract.
- stablecoin
- a token built to be worth the same as a currency, usually the dollar. what changes is how it manages that: reserves at a bank, collateral onchain, hedges on derivatives.
- staking
- locking tokens up to keep a network or a protocol running, and receiving a yield in return. the tokens stay tied up for a set time.
- token
- the unit a protocol issues. it can serve to vote, to pay, to receive revenue, or to do nothing at all.
- unlock
- the moment when tokens locked up until that day become sellable.
- yield
- what a deployed capital earns, written as a yearly percentage.