[go: up one dir, main page]

Tuesday, November 01, 2022

How to Eliminate Impermanent Loss

    

 

Impermanent loss (IL) is like an exogenous tax on the suppliers in automated market makers (AMMs). While liquidity providers (LPs) can hedge their IL, this tactic merely reduces its variance. Worst of all, it exceeds the fee revenue in most AMMs, which is not a long-run equilibrium. Fortunately, there is a straightforward way to significantly reduce the IL while maintaining the autonomy of these algorithmic trading contracts. A contract with the functionality described below is on the Goerli testnet and can be accessed here (its verified code is revealed here). I gave away my previous musing on extending Uniswap’s AMM to handle perps and stablecoins, but this one is copyrighted and has a patent pending.1

The key to removing IL is having the liquidity providers (LPs) dominate price-discovery trades on their pools. In practice, an AMM’s arbitrageurs are not the LPs, and we commonly model the IL assuming the LP passively leaves his position alone or hedges on Binance. However, if the LP collective drives the net price changes on their pools, its net position is unaffected, as the change in the LP position mirrors the price-setting trades. If the LP's net position does not change, it avoids adverse selection, and its IL is zero.

The simplest case

Consider a constant product AMM where Bob is the only LP and its only trader.2 I will use the leveraged AMM I described earlier here. In this AMM, traders and LPs can leverage their positions, and when they do so, the borrowed tokens are debited from their ETH or USD accounts. This nets an LP's pool positions with subsequent trades, generating a cross-margining effect. Further, this lowers the operational risk created by having to transact on different platforms, often off the Ethereum main chain.

Assume LP Bob is levered at 20:1, so the pool tokens implied by Uniswap v2 math are 20 times greater than his actual token amounts invested. While this approach generates an unrestricted range, leverage enables it to be as capital efficient as a Uniswap v3 restricted range pool; 20:1 leverage is about what one gets with a v3 range with price bounds +/- 10% from the current price. For example, Bob adds 1.0 ETH to become an LP in this LAMM, and the current ETH price is 1296 USD. There is 20x leverage for LPs, so his pool ETH is 20.3

With 20x LP leverage, this implies liquidity of 720 via

  • poolETH = liquidity /sqrt(price)
  • sqrt(1296)= 36
  • poolETH = 20
  • liquidity = 20*36 = 720
Given this liquidity, we calculate the pool USD
  • PoolUSD = liquidity * sqrt(price) = 720 * 36 = 25,920
With poolUSD of 25,920 and 20x leverage, he will need to deposit 1,296 in USD.His trading accounts will reflect his initial ETH and USD deposits and the borrowed amounts in his pool positions.
  • Initial trade account ETH = ETH deposit – poolETHborrowed = 1 – 20 = – 19
  • trade account USD = USD deposit – poolUSDborrowed = 1,296 – 25,920 = – 24,624
LP Bob’s net ETH position is 1.0, his initial ETH deposit. This is the sum of his pool ETH and trade account ETH. His liquidity number and the square root of price imply his pool positions, so these change as the AMM’s price changes. Bob’s subsequent trades are credited and debited in his trade accounts.
  • pool ETH = liquidity/sqrt(price)
  • trade account ETH = initial ETH deposit – initial poolETH + subsequent trades
  • pool USD = liquidity*sqrt(price)
  • trade account USD = initial USD deposit – initial poolUSD + subsequent trades
  • Net tokens = pool tokens + trade account tokens
In Figure 1 below, all price movements are caused by Bob's trades that are added to his trade account, where his ETH purchases reduce his ETH debt. These increases are precisely offset by declines in the contract's pool ETH position, which in this case means Bob's pool ETH position, leaving Bob’s net ETH position unchanged. With his net ETH and USD positions unchanged, his IL is zero. Intuitively this should make sense because he cannot lose money trading with himself, regardless of the algorithm.
Figure 1

Arbitrage Trading and Price Discovery

Price discovery happens on the cheapest and lowest latency exchanges. If you know the price of ETH is going up, your best strategy for capturing this price movement would be to buy on a low-latency exchange first and then send an order to a blockchain AMM. Sending trades to a blockchain AMM and a centralized exchange simultaneously would generate the same result, as the blockchain trade would appear at least ten seconds after your Binance trade went through. It would make no sense to send a large buy on the blockchain first and then send a large buy order to Binance after it gets processed because that would only allow others to front-run your second trade.

Many people think that since there is so much volume on Uniswap, it is likely that ETH price discovery is happening on these blockchain AMMs. If Uniswap had comparable latency, this would make sense, but the latency difference is 100-fold at minimum. If we remember that way back in 2009, firms spent $300 million building a more direct cable from Chicago to New York to save four milliseconds; even the centralized blockchains like Solana are orders of magnitude slower than standard centralized exchanges. 

Ultimately, this is an empirical issue. Figure 2 below shows that 80% of the time, Uniswap prices are within Gemini prices by 0.1%. More importantly, for my argument, we see that when the Uniswap price diverges from the Gemini price, the Uniswap price moves towards the Gemini price and not vice versa.

Figure 2

Uniswap 0.05% ETH/USDC Pool

Gemini/Pool premium vs. Future Gemini & Pool Price Changes

Data from the second quarter of 2022. I took the Gemini minute-downsampled prices, paired them with the next Uniswap price, and then looked at the price 3 minutes later.


To give LPs an arbitrage-trader advantage, we let LPs trade for free on the contract, while everyone else would have to pay a fee, such as 0.2%. Traders paying the fee need the AMM's price to deviate by 0.2% from the 'true price' to consider an arbitrage trade, while the LP is incented to arbitrage trade well below that level (above unlisted costs like those from gas). If LPs traded each time the Binance/Gemini price deviated by 0.2% from the AMM, the non-LP traders would never see an arbitrage opportunity and be relegated to liquidity trading.4

An efficient exchange needs arbitrage traders setting prices. The LP should not pay arbitrageurs anything in AMMs because price discovery for latent exchanges is not subtle: arb the AMM with Binance/Gemini prices. Non-LP arbitrage profits add a significant cost to an essential party in the exchange, a cost that must eventually get charged to liquidity traders in a sustainable AMM. When the arbitrageur and arbitragee are the same entity, this eliminates a significant deadweight cost, which is always a good thing.

A simple fee exemption would be sufficient to make this work if there was only one LP, but with multiple LPs, we need more rules to prevent some LPs from dominating arbitrage trading.

Consider the case where Bob and Alice are LPs. In figure 3 below, Bob has twice the liquidity as Alice, and Bob trades twice as much as Alice, and the result is that both end up with the same net ETH at the new price. There will be slight IL because Bob's USD change is not exactly twice that of Alice, but this is generally insignificant (or at least second-order).5 

Figure 3

LPs Bob and Alice trade proportional to their liquidity

Data to the right are units of ETH


In contrast, in Figure 4 below, only one LP trades, resulting in significant net ETH position changes for both LPs. While some LPs would be averse to generating a change in their net ETH position, some would appreciate the profit as worth the risk. Without some sort of restriction, LPs with superior blockchain connectivity would dominate arbitrage trading, leaving those without bleeding-edge access susceptible to the standard IL.

Figure 4

Only One LP Trades Alice Trades

We need to add conditions to prevent low-latency LPs from dominating arbitrage. A simple rule based on the LP’s current net ETH position compared to their initial net ETH position can do this because when LPs trade proportional to their liquidity, their net ETH position is constant. Therefore the LPs can buy for free only if their net ETH position is less than 100% of their initial ETH position and can sell for free only if they have more than 100% of their initial net ETH position. This incents LPs to arbitrage price changes only when it reduces their IL, so aggressive LPs will get a ‘time out’ when they trade too much.

An LP’s net ETH position relative to her initial net ETH reflects her relative arbitrage trading, assuming she does not add or subtract ETH exogenously. To make the LP’s net ETH position reflect their relative trading, we need to restrict LPs from depositing or withdrawing ETH from their accounts while they provide liquidity, as otherwise, their net ETH position would not reflect their relative trading.

Managing LP Liquidity

In a standard constant product AMM, when the price moves the pool amounts of one of the tokens decrease. In an AMM with 20:1 leverage, the LPs would generate negative net token positions when prices move by about 10%. While traders could supply sufficient tokens for trading in the short run for this AMM to continue operating, it is not an equilibrium for a sustainable pool.

To mitigate this risk, the liquidators can remove an LP’s liquidity when they have a negative net position in either ETH or USD. This constraint will bind well before the LP becomes insolvent.6 An LP liquidation is comparatively benign in that it merely removes liquidity and nets the pool tokens with the ex-LP's trade account debts, so no trades are dumped onto this market.

An LP arbitraging the pool would not need to get tokens elsewhere and deposit them into the pool to avoid liquidation. If the LPs were not arbitraging the pool, they would be forced to wrangle up tokens to deposit into the pool, which requires more capital, trading expense, and operational risk. This wrangling is avoided when they can trade on the same contract where they provide liquidity. Ideally, the LPs trade proportionate to their liquidity and never need to rebalance their pool using outside tokens.

A hack to this system would be for a 'just in time' liquidity provision and trade. Carlos could add liquidity, make a trade, then remove liquidity, all in one block. Such transactions are parasitic and need to be discouraged. Therefore we penalize LPs who remove liquidity within a week, so anyone just wishing to trade will find the tactic of 'add liquidity/trade/remove liquidity' unattractive.7

Liquidity trader Imbalances

If the LPs generate 100% of the net trades needed to move the AMM price, the non-LP trades must be zero-sum. If there is a temporary excess demand in one direction, the LPs can handle this in two ways.

First, they can arbitrage the price premium generated by the excess net liquidity trading and accept the resulting net ETH position change. For example, excess non-LP buys push the AMM price above its true price, and an LP can sell on the AMM, generating an arbitrage profit. The downside is the LP now has a net short position relative to her initial net ETH position, which may generate an unacceptable risk.

Alternatively, the LPs can do nothing. Non-LP demand pushing the AMM price to a premium over its true price will cause the LPs to become short ETH relative to their initial ETH position, but being short an overpriced asset is not a bad situation. On average, at some point, non-LPs will arbitrage the AMM price, pushing it down, and restoring the LP position to its initial neutral condition. If, for some reason, users prefer to buy ETH with leverage on this AMM, generating a persistent price premium on the AMM, that is not so much a problem as an equilibrium. This is purely an empirical issue but easily soluble.

Active LPs

This strategy is subtly different than hedging one’s LP position. In classical option hedging, it is assumed the hedger is a price taker, and such hedging reduces risk but does not change the expected loss for a position with negative convexity. In contrast, if the hedger effectively sets the price as an informed trader, they eliminate this convexity cost. The LP fee advantage combined with the latency of blockchain AMMs allows the LPs to trade like market wizards.

If LPs are expected to arbitrage their pools, this implies access to arbitrage bots that monitor centralized exchanges and the blockchain. The LP’s informational advantage only exists within the price-premium window of the fee amount, which requires an algorithm, APIs, and web3 capabilities. They need the ability to react to 0.2% price deviations at all hours of the day. The high latency of the blockchain works to the AMM’s benefit here, as it makes it possible for an LP arb-bot to implement a simple algorithm based on centralized exchange prices.

While such a setup is straightforward, many LPs will need assistance. One solution is that someone can provide a contract that acts as a vault and manages an arbitrage bot for that vault. The capital supplier and vault owner can then split fee revenue in some mutually agreeable way. Alternatively, the contract can allow LPs to designate other accounts to make arbitrage trades on their account but not withdraw or do anything else. This would allow an LP to hire arb-bots that can seamlessly add their account to an algorithm, tapping the various LPs depending on their individual net ETH position. The arb-bot would need a fee, but as there are economies of scale in creating and running such a program, it would generate mutual gains from trade.

It should be no surprise that active traders can game passive LPs in an AMM. Over the past century, the riskless real interest rate has been less than 1%. It is not an equilibrium for passive investors to make 5%+ without risk or effort, and many pools advertise 10% or even 100% returns for passive LPs. If investors want such returns, they will either have to create an arb-bot or find an arb-bot partner, and to expect otherwise is fanciful. Over time, those with the better arb-bots will dominate. Market making has never been only about providing capital. In centralized limit order books, the market makers always post two-sided markets—a bid and ask—which are adjusted continuously. These are highly competitive markets, and every competitive market requires a significant investment of capital and time, as well as a little alpha.

The inherent latency advantage will make AMMs derivative markets for the foreseeable future. When secure L2 solutions come around with latency comparable to centralized exchanges, traditional centralized limit order books can be used.

Example Spreadsheet

The spreadsheet below shows how a sequence of random prices affects three AMM participants' net ETH position and demand functions. There are two LPs and one non-LP. In each period, the true price changes randomly via a random walk. The LPs then generate their desired ETH trades based on the current price on the AMM, the true price, and their current net ETH position relative to their original net ETH position. The non-LP trades randomly or targets the price if the AMM deviates from the true price by more than the fee.

You can see how the mechanism works if you play around with it. I find such simple models helpful for my intuition.

Summary:

The essential rules for an IL-free AMM are as follows. They apply to a leveraged AMM so that the contract can monitor the LP’s net ETH position, given that the LP has both pool positions implied by his liquidity and a trade account reflecting trades against the aggregate pool. The trade account for an LP starts as a negative number, reflecting the ETH borrowed to go into the pool; however, the initial net position for an LP is positive.

  • Standard accounts pay a fee to trade
  • LP accounts qualify for a discounted fee if a trade moves the account's net ETH position towards its net ETH position at the time of initiating a liquidity position.
    • LP’s currentNetETH < LP’s initialNetETH, buy only for zero fee
    • LP’s currentNetETH < LP’s initialNetETH, sell only for zero fee
  • Restrictions
    • LPs cannot add or withdraw tokens from their accounts while providing liquidity.
    • Withdrawals less than several days after initiating liquidity position pay a fee on pool USD removed

Appendix

Impermanent Loss Significance

IL is a significant problem for AMMs, but it is commonly ignored for two reasons. First, it is not a direct cost in that it is reflected in receiving back more of the less valuable token and less of the more valuable token. A pool with initial token amounts of ETH(0) and USD(0) will change over time to ETH(t) and USD(t). The mathematics of AMMs imply ETH(t) and USD(t) are functions of the price such that if the price of ETH rises, the LP will have less ETH and more USD, and the inverse (see more on this here).

IL(t) = p(t)*(ETH(t) – ETH(0)) + (USD(t) – USD(0))

More importantly, the main reason an LP position value changes comes from the variation in the token price unrelated to IL. Note that the IL formula above highlights it is just capturing the adverse selection of an LP’s pool positions, not the total pnl. If the token quantities are constant, the IL is zero, but the position value will change dramatically due to the change in the ETH price.

Figure 5 below shows the relative magnitudes of the total change in value for an LP vs. the IL for an unrestricted (i.e., v2) ETH/USDC pool. It is common to ignore second-order costs like these.

Figure 5

While the IL expense is relatively small, it is still significant. This is more conspicuous in the concentrated liquidity ranges offered in Uniswap v3 because a 10%+/- range uses only 5% of the capital in v2, which implies the IL becomes 20 times more prominent relative to the base price pnl changes.

If you do not calculate the loss, it is easy to ignore, and AMM promoters are not inclined to mention costs if they are not forced to.  For example, a Bankless newsletter listed the top yield-farming opportunities but did not mention IL. Ribbon presents its option writing pools by listing the option premium as if it were a dividend. Uniswap’s pool portal conspicuously presents the fee revenue but nothing about the IL.  When people do not mention a cost, it is no surprise they underprice it.

The major Uniswap pools generate ILs greater than their fee revenue, a net loss. This is easy to measure. Fee income is simple: fee times the volume traded. The IL payoff is very similar to a short straddle, which has negative convexity in that the second derivative of the LP position is negative. Specifically, we call this second derivative gamma, which for an LP position is defined as

Options theory tells us that the convexity cost is the price variance divided by two times gamma. This cost over time is called theta, which represents the expected option decay needed to offset the option seller’s gamma.

Applying this formula to Uniswap pools reveals a consistent negative pnl for LPs in that their fee income does not outweigh their convexity costs. The chart at the top of this post shows the average daily liquidity and volume for the popular ETH/USDC Uniswap v3 pool. Note it is generating a slight positive pnl this month because ETH volatility has been lower than average (data are through October 9).

A persistent systemic option underpricing has happened before. Convertible bonds are standard corporate bonds with an option, usually an out-of-the-money call with a long maturity. Before around 2005, it was common for these bonds to price their option below the price of explicit stand-alone options on stocks. These underpriced options allowed hedge funds focused on convertible bonds to generate significant Sharpe ratios for decades.

The driver of this underpricing was caused by a lack of transparency and bad incentives. The option value was rarely estimated independently, but the option value allowed the bond to have a lower explicit interest rate. If the company's stock price fell, the option expired worthless. In that scenario, the company was clearly better off for having sold the worthless options, and management would highlight the money they saved by issuing convertible bonds. If the company's stock price rose so that the option was in the money, shareholders were sufficiently distracted by their above-average returns that they did not criticize management.

Eventually, investment banks made it easier to isolate the options component of these bonds, and the options were priced efficiently via arbitrage. A simple convertible bond hedge fund strategy no longer generates a 1.5+ Sharpe ratio. We should expect something similar in AMMs. Currently, LPs are selling underpriced options, which creates an opportunity for those who can offer that same revenue for that service at a lower cost.

AMM Volume Not What it Appears

The net loss to LPs leads one to suspect that the impressive AMM volume is not a sign of a vibrant trading tool as it is a mechanism for savvy investors to fleece LPs who ignore their IL. As an analogy, consider the Defi exchange dYdX, which recorded a huge volume in late 2021. This was mainly driven by people taking advantage of their rewards program. Activity on their exchange was rewarded with tokens worth more than the fees generated, creating an arbitrage opportunity for throwing in some ETH and trading back and forth. Once the rewards system stopped, volume on the dYdX platform declined by over 95%.

Some believe fees from arbitrage traders generate net revenue, but this is wrong because arbitrage is purely voluntary, and they only do it to make positive profits. The arbitrageur profits are just the other side of IL. Thus the relative volume differential between the ETH/USD pools with different fees is proportional to the fee difference: six times the fee generates one-sixth the volume. The marginal trader seems to be the pool arbitrageurs, who need to make a profit to cover costs outside the pool, such as fees on centralized exchanges and capital costs (significant because they cannot be netted).

1

I do not yet have a master plan for applying this, so contact me for suggestions. I think it would form the foundation for a decentralized perp and stablecoin contract without frictions created by unnecessary governance tokens or funding rates.

2

I will ignore LP fee revenue in this explanation because I merely want to focus on the IL, and fees complicate the examples while providing no additional insight. I will also assume a simple ETH/USD pool, though it generalizes to any pair of tokens.

3

LP leverage is not as dangerous as trader leverage. A trader leveraging 20x would be wiped out when the price moves 5%, while for an LP, it would take a 50%+ move if the LP did not trade.

4

If LPs monopolize arbitrage trading on the AMM, everyone else who trades there would be 'liquidity' traders. These traders just want to alter their crypto exposure for myriad reasons unrelated to its current price premium to centralized exchanges (eg, need cash for a vacation or a long-term investment decision). These uninformed traders are also called 'noise' traders because 'white noise' refers to a mean zero random variable.

5

Even if the LPs trade strictly proportional amounts of ETH, that will not necessarily imply their USDC changes will also be strictly proportional. The USDC amounts exchanged as a price move depends on whether the LP traded early in the sequence or later.  As a practical matter, however, the resulting IL volatility is negligible: an order of magnitude lower and mean-zero (opposed to strictly negative).

6

There are edge cases where an LP can become insolvent while never having a negative token balance, basically, terrible directional trading. However, it’s highly improbable.

7

The minimum time is not obvious—a day, a week—but the key is making it more attractive to put on a position directly instead of doing so disguised as an LP. 

An Alternative Capital Efficient AMM

 Uniswap v3 introduced restricted ranges to address automated market maker capital efficiency. An alternative way to economize capital would give liquidity providers leverage. I will refer to this as a leveraged v2 contract or LAMM (Leveraged Automated Market Maker).

I made a prototype that works on Rinkeby here (you can see the contract code here).

Adding leverage to an AMM has several benefits in addition to capital efficiency. For example, given the ability to extend leverage to LPs,  extending leverage to traders is straightforward. This means a leveraged swap contract can allow traders to short and leverage long, previously only available in perpetual swap (‘perp’) markets. This perp market would have the added benefit of not requiring an oracle because the price is set by arbitrage, in that an underpriced token can be bought on the LAMM and then sold on another exchange at a higher price. This avoids the ridiculous funding rate premium mechanism, which is simply a conspiracy by insiders to milk extra revenue out of users (to see why it does and cannot ‘arbitrage’ the perp price see here).

There are several other significant advantages to using a leveraged AMM compared to restricted ranges. For example, with leverage account insolvency is possible, there needs to be a reserve or insurance fund within the contract to prevent contract insolvency. In corporate financial theory, equity is often thought of as the residual tranche, the part of the capital structure that takes the first loss and that part that takes any extra revenue. Equity holders have rights and responsibilities, so they are correctly incented to make the contract work well; equity receives revenue for an essential continual service. In contrast, adding a fee to Uniswap going to their equity holders is simply a payment for branding, which seems quaint in the domain of open contracts.

Preliminaries

The canonical AMM is based on two formulas. First, the price is represented by the ratio of the tokens in the pool. For example, with 1500 USD stablecoins and 1 ETH, the price would be 1500, which is common sense.

Secondly, for an existing pool, a trade with ETH going in and USD going out is subject to the following rule: the product of both tokens must be maintained at its existing level, a constant.

While this model works, unrestricted ranges are capital inefficient. For example, if you wanted sufficient liquidity so that a $10K order would move the price of a token priced at $1500 by 0.1%, you need $40 million in ETH and USDC in the pool. This is insanely inefficient for stablecoins, where 99.999% of the time, prices are locked at parity.

In May 2021, Uniswap released v3, allowing users to provide restricted or concentrated ranges. I describe the mathematics of v3 in this post here. With v3, you use the same foundational equations above but have to adjust individual LP USD and ETH pool quantities to reflect their particular ranges and also track the vector of total liquidity provided across all possible prices.

One can see the capital efficiency by noting how much capital is required to provide the same amount of liquidity for various ranges. Below we see how much capital is needed as a percent of the unrestricted range (i.e., v2) for range sizes.

Figure 1

Relative Capital For Symmetric Restricted Ranges of Various Sizes

Same liquidity

* e.g., a 10% spread for a token priced at 100 would have bounds at 90 and 111 (i.e., 100/0.9)

As shown above, a stablecoin pair where an LP offers liquidity between 99.9 and 100.1 can provide 0.05% of the capital for the same amount of ‘liquidity.’ This v3 pool would be 2000x more capital efficient than v2.

For pairs with risky tokens, like ETH/USDC, a range covering 15% up or down corresponds to about a week’s volatility. An LP receives fees only while the current price is within its range, defined as an ‘active’ range. If one wanted to be 95% sure their range would be active after a week of neglect, a token like ETH with an annual volatility of 90% needs a 30% range, which requires only 15% of the capital of a v2 range.

While the market price can breach all restricted ranges, such a case generates no risk to users; the pool would merely become irrelevant. There would be no trades so that the LPs would generate no trading fees, but neither LPs nor traders would have credit risk. A pool where all the LP ranges were inactive would be like if there were a venue where one could buy Bitcoin for $100k; no one would use it. In v3, the total absence of active ranges is rare because other LPs arise to capture fee revenue; the first to provide liquidity with a dynamic range would get 100% of fee revenue.

Alternative

Uniswap’s concentrated range is not the only way to economize on LP capital. Indeed, as a v3-style approach capital efficiency is absent off the blockchain, it is not the simplest way to leverage capital. While admirably clever, it is a product of path dependence, aiming to maintain the standard functionality of v2 by adding several parameters. Leverage, or its converse margin, is the common traditional finance method. Remember that leverage and margin are just two sides of the same coin, in that maximum leverage of 8 implies a 12.5% required margin.

Consider the case where Alice provides liquidity for a range covering the current price by +/- 10% with the same liquidity as an unrestricted pool (hereafter, ‘v2’). Below the v2 case is presented as a special case of v3 where the range is infinite (zero to infinity). The capital needed for the v3 range is about 5% of that required for a v2 pool, consistent with Figure 1 above.

Figure 2

Alice’s v3 LP vs. a v2 LP with the Same Liquidity

We can replicate the v3 capital savings via leverage, which implies giving the LP an asset and liability. Assume Bob provides 1.32 ETH and 1987 USDC in a leveraged v2 pool, the same token amounts Alice provided in her v3 pool. Here Bob would need to borrow ‘25.82 - 1.32’ (24.49) ETH, and also 36,742 USD. Instead of Alice’s extra account parameters pLow and pHigh, Bob has the additional account parameters corresponding to the ETH and USDC he borrowed to establish his v2 range. For Alice in her v3 range, and Bob in his levered v2 range, their account parameters look like this:

Figure 3

Bob borrows 24.49 ETH so that in addition to his initial ETH deposit, he has the right amount of ETH in the pool (and the same for USDC). This is reflected as a debit in his account labeled ‘vETH.’ Initially, his borrowing does not affect his account’s market value; it creates a symmetric asset and liability that cancels out. Bob’s net or ‘real’ ETH is 1.32, just like for Alice.

They have identical net amounts of ETH and USDC in their accounts, supporting the exact same amount of liquidity. As the price changes, this implies changes to their pool amounts, which in both cases are fictive numbers representing the implied amounts for a v2 pool. The pool amounts are levered LP Bob’s assets. As long as the price is within Alice’s range, Alice and Bob will have identical LP account values and thus also PnLs. This implies their impermanent loss (IL) will also be identical.

Figure 4

The difference between the PnL and the IL is the effect of the initial 1.32 ETH invested. Given their initial investment of $3975, Alice and Bob have an identical account value at the inception ETH price of $1500. The approaches generate identical PnLs across Alice’s v3 price range.

Over a broader price range, however, these approaches differ significantly. This is because Alice’s portfolio positions are static outside her price bounds. Bob’s levered position, however, changes continuously so that his account value becomes negative when prices move significantly up or down. [This all ignores fee revenue to make the presentation simpler.]

Figure 5

While Bob’s levered position is riskier over the infinite price range, the difference between Alice and Bob is slight over a broad price range from $1000 to $2000. Indeed, as noted for Figure 5 above, their PnLs are identical when the price is within Alice’s range of $1350 to $1667.

Bob’s potential for a negative account value, insolvency, implies a liquidation method is needed to protect the levered pool because if one party has a negative account value, not all accounts will be able to retrieve their full account values. Insolvency without any insurance fund would generate a run as those with assets in the pool would want to withdraw early enough to get their total account value; with an insurance fund, the equity owners would suffer a loss.

In the above example, we have 20x leverage given to LP Bob in that his pool ETH and USDC are about 20 times his initial ‘real’ ETH and USDC deposits. Leverage applied to an LP is very different than giving that to a trader. LP Bob’s account becomes insolvent at price moves of -50% and +95%, while a trader with 20x leverage would lose all of his money with a mere 5% price move. As the daily volatility of ETH is 5%, the protocol has adequate time to anticipate and rectify potential insolvencies before they are realized.

As a practical matter, however, a LAMM will be more concerned with LP token deficits rather than insolvency. As Bob matched Alice’s 10% range with his initial token allocation, a +10% price move would exhaust his ETH, and a -10% move would drain his USDC. At the price point of $1350 in Figure 6 below, Bob has zero net USDC, just like Alice.

Figure 6

While Bob has no more USDC to give out when the price of ETH falls to $1350, the value of his account is $3674, a loss of only $301, or 7.5%. Thus, well before the price moves that would render a LAMM LP insolvent, the protocol needs a mechanism for either motivating Bob to add tokens or incenting new LPs to add tokens so that swaps can resume.

A price where the LPs have net nonpositive USDC, such as $1350 in this example, implies no swaps can occur below this price. As with v3, this is not a danger to anyone, just a lost opportunity. Unlike the v3 case, new LPs will not get all the fees if they rectify this situation but instead share this fee revenue pro-rata with the existing LPs. This weakens the incentive for providing essential additional liquidity in the LAMM without some extra mechanism.

As a practical matter, there will be several, if not hundreds, of LPs, each with different starting price points and so each with different net token amounts. One LP with a net negative USDC would probably not mean the LPs as a whole have a net negative USDC balance. It is not essential to immediately liquidate an LP with a negative net token position, as the contract will still probably have positive net amounts of both tokens. This implies the rule for liquidation need not assume a single LP’s net token deficit implies a complete token deficit. For example, Bob could be liquidated when his net USDC fell below -1000, as opposed to 0.

Remember that in v3, the pool can also run out of a token if the price exceeds all LP ranges; historically, this has not been a significant problem. As the LAMM has weaker incentives for adding liquidity when the pool is out of a token, the key is creating incentives so this situation would be as rare as we see with v3 pools. This is a problem with several solutions.

Mechanisms for Incenting LPs to Maintain Positive Token Positions

An LP liquidation would be seamless in that no large trade is needed. An LP liquidation simply takes the ‘pool’ ETH and USDC implied by his liquidity given the current contract price, adds it to his vETH and vUSDC accounts, and zeros out his LP liquidity. The LP is left with an account with a positive value but deficient in one of the tokens. The contract could require the LP to have non-negative ETH and USDC balances before withdrawing his tokens. In the example below, the price has fallen to $1300, giving Bob a deficit of 686.83 USDC. Bob would be incentivized to deposit an additional 686.83 USDC in the contract, allowing him to withdraw his 3.24 ETH (worth $4,212). Once removed, the situation would be like when a v3 pool has no active ranges: no risk for anyone, just an opportunity for new LPs.

Figure 7

One solution would allow new LPs to remove deficient LPs when adding liquidity simultaneously. For example, a new LP could specify an existing LP deficient in one of the tokens at the time of adding liquidity. The contract would check to validate the LP was in default, then liquidate the LP while adding the new LP (here, default is triggered by a minimum net token balance, as opposed to the usual market value vs. required margin). This would give the new LP a greater incentive to rectify the problem, as it would make the situation identical to v3, where new LPs are incented by the lure of 100% of fee revenue.

Alternatively, one could emphasize the cost of the deficient LPs by giving keepers an incentive fee to liquidate LPs who are deficient in one token. This would be like the above condition, but with a different agent policing the contract for deficient LPs and a more prominent cost applied to these defaulting LPs. One could add that a liquidator must also rectify the liquidated LPs deficient token balance (which would require giving the liquidator an equal value of the defaulting LP’s surplus token).

Another solution would apply a funding rate based on the total LP’s net ETH and USDC. This would be a profoundly different application of the funding rate commonly used in perps, where the perp price is compared to an external spot price. One could use various functions, but the gist would be that the cost applied to deficient LPs would increase exponentially as the contract’s net ETH or USDC approached zero, giving LPs an incentive to add the deficient token.

Leveraged Traders: Perps

The leveraged LP has pool tokens implied by his liquidity and a corresponding debt reflecting his leverage so that his real or net ETH balance is the sum of these two accounts.1 If we treat his vETH account not merely as a debt but as a general trade account that can be negative or positive, traders could get leverage in the exact same way. The liquidation and accounting mechanisms would already be in place.

For example, trader Bob could deposit $750 USDC into the contract, generating the following account profile on contract.

Figure 8

Assume Bob then sells 1.0 ETH. Assuming no fees or price impact and a margin requirement of 20% (i.e., 5x leverage max), this would generate the following account data.

Figure 9

Alternatively, trader Alice could deposit $375 worth of ETH

Figure 10

If she shorted 1.375 ETH, her account would look identical to Bob’s in figure 9.

Or consider the case where a trader deposits 1 ETH and goes long 2 ETH, shown in Figure 11 below. His account would look like this:

Figure 11

One need only monitor whether the trader’s account market value exceeds his required margin, regardless of whether they are long or short. As long as traders cannot withdraw more than their required margin, and there is a mechanism and incentive for liquidators to liquidate defaulting accounts when they violate their required margin, the contract is safe.

Leveraged trading would allow the contract to function in a limited sense until some LP rectified the pool USDC deficit by depositing USDC. That is, while the contract has no USDC, traders cannot sell ETH for USDC as a swap, but those with collateral could sell ETH on the contract, generating a credit to their USD balance. A liquidation rule or funding rate approach will incentivize the existing LPs to shore up their balances soon, at which time the trader could withdraw their USD credit as USDC.

No Oracle-based Funding Rate

By having both Uniswap and perp functionality, the contract price would be set by arbitrage, not a funding rate linked to an oracle. This would eliminate several problems in perp protocols. Oracles needed for standard perp funding rate calculations can be hacked and censored. More importantly, the funding rate mechanism used to link perp prices with spot prices is a farce in that it is profoundly different than the funding rates applied in traditional swap markets or the basis in futures markets.

The Funding Rate Farce

In prime broker swap accounts, the funding rate is completely independent of the price; the assets in these accounts trade on spot markets as if they were not in swap accounts (you cannot tell which trades on the NYSE were made from swap accounts). Swap funding rates change slowly like general interest rates, are known ex-ante, and only apply to overnight positions. There is no reason to apply intraday funding rates because it is a pointless extension, as the magnitudes are too small to incent behavior meaningfully.

In futures markets, the difference between the futures and spot price is called the basis. It converges to zero at maturity, and as the futures moves toward the spot price over time, its change acts as a funding rate. This basis, however, is orders of magnitude greater than the usual 0.03% price premiums in perp markets. This larger basis allows for real arbitrage because it covers transaction costs and can be locked in. In contrast, in perp markets, the perp premium at the time of trade means almost nothing, as the funding rate is a function of the average perp premium over a position’s duration, not its value at the time the trade was initiated. 

A perp price is set by a Schelling point, in that the most obvious target is the spot price, and the funding rate is just there to make traders feel comfortable that it is not merely a Schelling point. The fact that there is a vague relation to an equilibrating mechanism seemed a necessary and sufficient condition for perp markets when users had only one coin in the protocol, as was the case with BitMex in 2016. However, when trading ETH for USDC, this mechanism is an anachronism: let real arbitrage set the price.

The perp premium funding rate mechanism is incoherent and used to fleece traders whenever they are drunk with house money. If the market has just gone up, many ETH holders are sitting on big gains, so they do not mind paying an extra 5% for a month (aka only 0.018% every 8 hours). If your perp protocol has a funding rate based on its perp price premium to the spot, your perp protocol managers are either ignorant or evil.

StableCoin

An ETH-USDC contract with perp and Uniswap functionality naturally produce a stablecoin. Consider a user who deposits 0.375 ETH, where the ETH price is $2000. Her account value and required margin would look as follows:

Figure 12

Assume the trader goes long 0.625 ETH using leverage. Her account value would look like this:

Figure 13

As she is long $2000 worth of ETH, she needs 20% of that value in her account to satisfy her margin requirement.

Now consider Bob, who deposits 1 ETH in the contract. His initial account value would look like this:

Figure 14

He also has a $400 required margin, but as his position is not leveraged, it is never a concern. This is because if the value of ETH goes down, so does his margin requirement, and vice versa.

Bob can turn this into a MakerDao-like CDP position by withdrawing a new stablecoin, vUSD. Such a coin would be worth USDC within the contract, both adding to a user’s USD account when deposited, subtracting from the USD when negative. Yet the stablecoin would help economize on the contract’s USDC. By giving users cheaper fees when withdrawing a new vUSD stablecoin instead of USDC, a user would be incentivized to withdraw vUSD instead of USDC. The ultimate fungibility of USDC into vUSD on the contract would set the value of vUSD at parity with USDC as long as the contract is solvent. A withdrawal of $1250 vUSD would leave Bob’s account looking like Figure 15 below:

Figure 15

Bob’s account is exactly the same as Alice’s, though they arrived via different trades. A MakerDao CDP that generates a stablecoin is identical to a levered long position collateralized by ETH. A LAMM with swap and perp functionality makes stablecoins the way a donut maker makes donut holes, it’s an unavoidable complementary product. Just as it would be inefficient to produce donut holes but not donuts, it would be inefficient to produce stablecoins without a perp contract.

The benefit of this approach is that it creates stablecoins more efficiently because, unlike MakerDao, it does not rely on auctions or oracles. Auctions can be gamed, as when MakerDao sold $8MM worth of ETH in March 2020 for zero USD. In a LAMM, a defaulter’s net ETH position is straightforward to close on the contract. Relying on oracles is also problematic, as these can be hacked or censored.

In the long run, one could have several independent contracts, each with its own stablecoin. For example, a vUSD2 for a WBTC-USDC contract and a vUSD3 for a UNI-USDC contract. These other stablecoins would be supported solely by their specific LAMM contract, independent. Eventually, if one of these stablecoins became popular and used like USDC for transacting with several other contracts or products, it could act as if it were USDC. Like the creation of fiat money or valuation in new tokens, use eventually implies real value even if no ‘real’ assets are backing the token. Eliminating centralized stablecoins such as USDC from the blockchain is essential for long-run security. The creation of efficient decentralized stablecoin mechanisms is essential for that objective.

In summary

  • Leveraged AMMs can economize on capital like restricted ranges
    • LAMMs naturally extend to provide perps and stablecoins
  • Current Perp Markets are Censorable and Gamed
    • Perps on low-latency platforms are effectively centralized
    • The BitMex-style funding rate equilibrating mechanism is a farce; it does not and cannot equilibrate the perp market
      • funding rates are manipulated to benefit insiders
      • see my prior post for an explanation
    • A LAMM generates perps supported by real arbitrage
  • Existing Stablecoins Not Sustainable
    • Most centralized, fine for now, but not a long-run solution
    • Decentralized stablecoins have regulatory attack surfaces
      • Identifiable persons with control over choke points
      • Oracles like Chainlink are censorable
    • Governance tokens have weak revenue endgames
      • incentive to embrace regulations when token growth stops
    • A LAMM generates stablecoins without centralized attack surfaces

Concentrated liquidity in AMMs is a great innovation but ultimately ephemeral because it is inefficient. If there are ways to generate the same leverage but with more functionality, those will be adopted. There are many overvalued Ethereum tokens, and it would be nice to be able to short these on-chain, not just sell them. It would be nice to be able to short BTC or ETH, or take a position on BTC/ETH on-chain. None of this is feasible with only Uniswap pool functionality.

Shorting would benefit the Ethereum ecosystem because Ponzi tokens are a systemic threat in that they are common and run by stupid or evil people taking advantage of new crypto investors. These crap-coins sully the reputation of everything on the blockchain. It is much harder for insiders to maintain the value of a Ponzi token when people can short.

Yield farming highlights how inefficient many liquidity positions are because if collateral can be used elsewhere, that implies it is not used efficiently. If we ignore transaction and information costs, using LP tokens as collateral on other platforms is efficient; in practice, these costs are significant. For example, if you could use your house down payment to collateralize a car loan, your car lender would be better off requiring less collateral in cash. This is because lenders specialize in certain assets and are not efficient at monitoring the value of every asset one could apply collateral to and then making transactions in these other markets. A car seller would prefer you take out an additional home equity loan and give them the cash as collateral for a car loan, allowing the car seller to avoid building the infrastructure to monitor and potentially seize a person’s house.

This post is already too long for most readers, so I will not outline the best part of this approach, which is how it facilitates a mechanism to eliminate impermanent loss. Maybe later.

1

LP(i) net ETH = vETH + liquidity(i)/sqrt(price); net USD = vUSD + liquidity(i)*sqrt(price)