A boat in a container shipyard

Tech Talks: Calculating Accurate DeFi Yields

Clipper’s updated Polygon data dashboard now displays the net yield that Liquidity Providers are earning! Here's how it works.

Written by

Abe Othman

Published on

January 27, 2022

Skip the empty chatter with Tech Talks, an ongoing crypto series that covers specific technical challenges and the Shipyard developer team’s solutions. In short, Tech Talks is written for (and by) galaxy brains who love digging into the details.

We recently deployed an update to Clipper’s Polygon data dashboard that, for the first time, displays the net yield that Liquidity Providers (LPs) are earning for their deposit of assets. There is so much confusion about the returns from providing liquidity that we wanted to clearly explain how we compute our net yield figure.

Here is a screenshot of Clippers Data Page:

LP Gain and Loss

Clipper runs using an automated market maker embedded in a smart contract. Liquidity providers deposit their assets, and then the smart contract performs swaps with traders using that pool of assets. This setup is common to automated market maker smart contracts, like Uniswap, Sushiswap, Curve, etc.

It is typical to describe automated market makers as charging “fees”. This is something I regularly did in my own research into automated market making. However, unless there is a transfer of tokens that goes into a separate lockbox that LPs get a claim to, then the market maker should not be regarded as charging fees on behalf of their LPs. To our knowledge, very few automated market makers have a fee structure for LPs because the additional token transfer is too expensive. You will see that Clipper’s Polygon data dashboard has removed any reference to fees.

If there are no fees, then how do LPs make any profits? The answer is that the LPs profit when the swaps that are being done with the smart contract are tilted in their favor: when the output tokens a trader extracts are worth less than the input tokens a trader deposits. Although the market maker’s edge on any individual swap is likely to be small, the amount of assets in the pool can accrete significantly over thousands of trades.

Loss is generated whenever a trade is made at a price that retroactively appears to have been a bad value for the market maker. (A loss is “impermanent” if it could be reverted by future price changes - often wishful thinking!)

Observe that loss is a function of future prices, which are arbitrary and unpredictable. That means LPs of any market maker using their liquidity can suffer loss. As I pointed out in my PhD thesis on automated market making, the only market maker that can operate without loss is one that never trades!


Basis and Tokens

A liquidity pool - which is what an LP owns a fractional share of - is a collection of assets whose value changes over time in response to two factors, both of which can generate loss or profit:

  • Changes in the market prices of crypto assets (e.g., in the USD price of ETH).
  • Changes in pool composition because of the swaps, deposits, and withdrawals that the automated market maker mediates.

Our yield calculation needs to take into account deposits and withdrawals of LP capital, meaning that we cannot just compute changes in pool value directly. But when an LP makes a deposit in a pool, they get a certain amount of fungible ERC20 pool tokens, representing fractional ownership of the pool. These pool tokens give us a way to normalize out deposits and withdrawals by calculating pool value per token. Given a set of external market prices, we can then calculate the value per token for our pool by taking the value of the assets at those external market prices and dividing that value by the number of tokens in the pool. Then, to express yield, we look at changes in the value per token over time.

There are two reasonable interpretations of what to use for the external market price vector when examining the asset pool over time, and they lead to two different “bases” for yield computation.

The first interpretation looks at value-per-token at historical market prices (i.e., at the USD market prices as they were at each block). We call this a “USD basis” since it reflects the returns of an LP that thinks of their deposit and return in USD. It is highly sensitive to external market prices of crypto assets.

The second interpretation measures the value-per-token at current market prices. We call this a “crypto basis” since it holds external market prices constant. As a result, it is generally much less volatile than USD basis measurements.

Note that crypto basis and USD basis calculations for value-per-token converge at the current block, where historical market prices are the current market prices.


Displaying Yield: the Financial Markets Analogue

In financial markets, the flow of dividends from e.g., a money market fund has standard reporting, called the “30 day SEC yield”, which annualizes out the yield over the last 30 days. When you go to Clipper’s Polygon dashboard, this is the default display: annualized yield from the last 30 days. 

We call this dashboard figure “net yield” to emphasize that we are taking into account loss. Although Clipper’s Polygon numbers are positive right now, there’s nothing stopping them from going negative if external market prices change significantly.

On the whole, Clipper supports transparent and open communication with asset holders about the value of providing liquidity to automated market makers. We believe that our standard of Net Yield on USD and Crypto basis should be how these values are communicated and compared across markets.

Written by

Abe Othman

Published on

January 27, 2022

March 29, 2024

What are stablecoins used for?, Clipper expands to Base, the latest AdmiralDAO proposals, and more.

February 28, 2024

A positive omen for DeFi derivatives, Clipper's new facelift, the latest AdmiralDAO proposals, and more.

Keep up with DeFi by subscribing to Shipyard’s industry newsletter

We’ll send you the latest news about DEXs, stats on our products, interesting articles, and CEO Mark Lurie’s thoughts on it all.

Thank you! Your submission has been received!
Oops! Something went wrong. :-( Please try again.