RMM Primer - A friendly guide for Primitive and AMMs

Introduction

Primitive Replicating Market Maker ("RMM") is a supply source for tokens and option derivatives*. Existing as a free, unchangeable, and unowned protocol, RMM is the purest form of decentralized infrastructure.

Anyone has the freedom to provide capital to the RMM pools and earn fees, providing a service of filling the other side of token trades, and eventually option trades. There are no gatekeepers, no pausing (i.e. circuit breakers), and markets run 24/7.

By the end of this primer, you will have a better understanding of using the protocol to hedge risk or take advantage of time-based strategies as a market participant. There are concrete example scenarios to help you grasp the different nuances present in the protocol.

Read more to learn about the primitive behind the magic.

*Replicated option derivative payoffs, not option contracts. "In layman’s terms, replication is four fives for a twenty: they behave exactly the same (they’re each worth twenty dollars), but they look completely different (one is four pieces of paper, the other is one piece of paper)". There are no promises the payoffs will be received.

Decentralized Exchanges are Liquidity Sources

This primer assumes a basic knowledge about decentralized exchanges, token trading, and popular protocols like Uniswap, Curve, and Balancer. Token trading is the most fundamental backbone to decentralized finance - enabling more markets like lending and derivatives.

Dex Volume 2019 - 2022

Without knowing anything about these protocols in the chart, it goes far to know that the majority of them rely on the same "idea", and together they make up almost all of the token trading activity on Ethereum.

This section is a brief overview on how these dexes work and how they can be used for token and option trading.

How to Make a Decentralized Exchange

Trading curves of different protocols

Different AMMs
Different AMMs

Constant Function Market Maker ("CFMM") based decentralized exchanges (e.g. Uniswap, Curve, Balancer) facilitate the lion's share of on-chain token trading volumes. The success of CFMMs as spot markets can be attributed to several crucial properties that they all share: ability to support any token pairs, high degree of capital efficiency, predictable behavior, and a relatively straightforward user experience. At a high level, CFMMs facilitate trades between two counterparties, "traders" (users that swap one token for another) and "liquidity providers" (users that make their tokens available for trades to earn fees).

Constant Function Market Maker Trading

Trading in a Primitive RMM Pool

RMM pools with different IV
RMM pools with different IV

Buyers

Traders are users that own one token (e.g. ETH) and demand another (e.g. USDC). Traders swap assets on a CFMM by sending transactions specifying some amount of tokens for other tokens, less a small fee. The average price a trader pays is dependent on both the ratio and amount of tokens in the pool prior to the swap (e.g. 100ETH/100,000USDC), the trade size (smaller swaps beget a better average price), and the trading function (we'll get to this later).

Suppliers

On the other side of this trade are the liquidity providers. Liquidity providers add two tokens to a liquidity pool contract. This liquidity contract accepts transactions swapping from token A to token B and token B to token A. Whenever traders execute swaps from either direction, liquidity providers collect fees proportionally based on their provided tokens compared to the total tokens in the pool.

Market Making

From a high level, tokens are made available by market participants to be the other side of trades for users who want to swap their tokens. The tokens available are implictly priced by a rule, called the trading function, which comes from basic math. This technology works exceptionally well on networks like Ethereum because it automates the process of supplying tokens to the other side of trades; a reason they are often called Automated Market Makers ("AMMs").

How to Earn a Return using CFMMs

Payoff of Liquidity in CFMMs

Payoff Comparison
Payoff Comparison

Liquidity Providers

In this section we will dig a bit deeper into what it means to provide liquidity to a CFMM, as well as how/when you might want to do so.

Price of the Asset over time

The final payoff of a liquidity position on a CFMM is determined by the trading function and the asset's price path. Price path is taking into account the prices that the asset has reached over a time period. There are unique price paths along which providing liquidity to a CFMM can be advantageous or disadvantageous. Say, for example, your portfolio (a liquidity position) has 1 ETH and 0 USDC. If the price of ETH doubles, your portfolio value will also double.

Impermanent, or Divergence, Loss

In the case of the ETH 2x price path, if you had provided liquidity to a CFMM that demands an equal weighted (50% ETH, 50% USDC) portfolio, you would have suffered what's known colloquially as "Impermanent Loss" (opportunity cost) by not capturing the full increase in ETH's price because the portfolio was not 100% exposed to it. This phenomenon occurs because as the price of one asset in a CFMM pool increases, LPs are effectively buying the cheaper asset (in this case USDC) on the way up. You would've profited in the end, but you would've missed out on that sweet sweet 2x.

Status Quo Strategy

So when does providing liquidity to a CFMM work to your advantage? The strategy name for adding liquidity to a CFMM which maintains a constant portfolio weight of an amount of assets is "mean reversion". A mean reversion strategy wants the prices of the token pair in a liquidity pool to be correlated in the medium run. In the ETH 2x case described earlier, in order to obtain the optimal terminal payoff the price of ETH would have to drop 50% to that at which you had initially added liquidity (hence the name, impermanent loss).

In summary

Providing liquidity to a CFMM creates a portfolio that is implicitly long a mean reversion strategy where price variation works in your favor so long as the prices of the assets revert to that which it was originally.

Options

What is a call option?

Long Call Option

Long Call Payoff
Long Call Payoff

Buying Calls

Before getting back to CFMMs, let's walk through a brief primer on call options. A call option gives the right to purchase an asset for a pre-determined price up until an expiration date. These properties of an agreed upon price and expiration date give the call option itself its own value, beyond the underlying asset. To own a call option in traditional markets, it is purchased from another party on an options exchange.

Short Call Option + Asset - Covered Call

Covered Call Payoff
Covered Call Payoff

Supplying Calls

The party selling (shorting) a call option is liable to sell their assets if the option buyer chooses to exercise, (buy the asset for the strike price). In traditional exchanges, most of these assets do not need to be put up as collateral because the terms of the option contract are legally enforceable. However, in DeFi, there is no way to enforce the delivery of the underlying assets, unless they are already deposited. It's for this reason that call options in DeFi are collateralized, and this combined position of selling a call option + depositing the collateral is a covered call option.

Covered Call Options and CFMMs

Earlier in this article we discussed how CFMM liquidity maps onto a unique payoff structure (mean reversion). Likewise, covered call options offer their own distinct payoff structure.

Covered call strategies and mean reversion are similar in that they both offer what's called a "concave payoff". To summarize, a concave payoff is a payoff that has a discrete central barrier at which returns are maximized (see above graph).

In the case of a call option, that barrier is located at the strike price (K). That is to say, the max payoff for a party selling a call option is obtained if the price of the underlying is equal to exactly K at expiry. Similarly, the max payoff of a CFMM liquidity provider is obtained if the price of the underlying token reverts to its initial price.

The important difference between these two strategies is rooted in the fact that covered calls allow you to take a directional view on future price. Choosing a strike price greater than the market price of an asset implies a directionally bullish opinion on the asset price.

RMM is a Covered Call CFMM

The Curve

RMM
RMM

RMM curves value pool assets based on price, volatility, and time. It is these properties which make RMM a new primitive.

The Payoff

Payoff of RMM
Payoff of RMM

Change in Implied Volatility - All else constant

RMM Parameters - IV
RMM Parameters - IV

Price of swapping on different IV Curves

RMM curves with different implied volatilities will have different costs when swapping. Trading in a higher IV curve will lead to a higher price of the asset being purchased, while trading in a lower IV curve is the opposite. This will affect the external arbitrageurs who only rebalance pools when it is profitable to do so - there must be a larger profit opportunity in higher IV pools to warrant a rebalance. This has the consequence of affecting the fees that will be generating, as less rebalancing means less fees.

Change in Time until Expiry - All else constant

RMM Parameters - Maturity
RMM Parameters - Maturity

Price of swapping as pool gets closer to expiry

If only time changed, the curve also experiences "Liquidity Compression" until trades can be executed at a fixed cost equal to the strike price. This compression is sometimes described as "concentration around the strike price", as the price of the asset is constant and equal to the strike price as expiration.

RMM Curve Changes over Time

RMM Parameters - Maturity
RMM Parameters - Maturity

Time until expiry affects expected fees

The distance between the curves with a lot of time until expiry and zero time until expiry is equal to the total fees expected to be earned by the liquidity provider. This does depend on the implied volatility and swap fee of the curve, as these parameters impact the probability of capturing the expected fees.

RMM Liquidity

Primitive RMMs benefit from the same properties present in other CFMMs, but with the distinct advantage of being able to express more nuanced opinions about future price.

Example #1
Example #1

These are some of the additonal benefits you can see from using RMM in lieu of other CFMMs:

  1. Liquidity providers choose the point at which impermanent loss begins (K).
  2. Liquidity providers can directly bet on volatility (σ), earning more or less fees depending on the accuracy of the bet.
  3. Liquidity providers earn theta over time, i.e. fees generated as pools get closer to expiration (τ).

Choose a price strategy

With RMM you're not limited to mean reversion strategies. Instead, you can deploy a position that expresses a directional view on the future price of a token. Doing so requires thoughtful strike price (K) and expiry (τ) selection. For example, if the price of ETH is 3000 USDC, but you believe that one month from now that price will be 4000 USDC, you can express that view by providing liquidity to an RMM that expires in one month (τ = 1 month) with a strike price of 4000 USDC/ETH (K = 4000 USDC). This position has the highest expected return if the price of ETH reaches a terminal value of 4000 USDC at expiry. The caveat to this is that if you're incorrect about the price path, for example if ETH goes to 2000 USDC in that same timespan, you are exposed to greater impermanent loss and will likely make less fees relative to a comparable xy=k position (how about hedging with another RMM?).

Choose a volatility strategy

How about that volatility (σ) thing? In general, a volatility near the market IV (just check the chain) for a given pair should serve as a good proxy for volatility selection. Volatility in an RMM prescribes the degree of liquidity concentration around the strike price. If the strike price of the curve is set to 4000 USDC, a 100% position will have less concentrated liquidity at 4000 USDC versus a 90% one. That means the 100% position would likely earn less fees than the 90% one, should the terminal price at expiry land at 4000 USDC. The tradeoff here comes in the form of greater impermanent loss for lower volatility positions.

RMM Liquidity Tokens

Every liquidity token minted from depositing into a CFMM has a payoff. For RMM, the liquidity token payoff is a covered call.

The method to convert this payoff into the trading function is explained in the Replicating Market Makers paper. Primitive's RMM protocol is an implementation of this.

Ways to use

Provide Liquidity

  • Each RMM is a two token pool which accepts deposits and mints RMM liquidity tokens. These liquidity tokens are a new DeFi primitive designed to replicate the payoff of a covered call by capturing theta decay through trading fees.

Swap

  • Every pool is composed of two tokens which can be exchanged for one another at any time up until the expiration date of the pool. Trading fees are earned by the liquidity providers on a continuous pro-rata basis and are re-invested into the pool.

DeFi Protocols

  • The RMM liquidity tokens are instantly redeemable at any time for their underlying assets. This makes it a highly composable instrument that can be used as a collateral asset for borrowing. Adoption for CFMM LP tokens has grown immensely in 2021, which are now supported across some of the top protocols like Tribe and Aave.

As a Market Making Vault

  • Liquidity in RMMs must be rebalanced based on time, volatility, and price. Along with that, the pool's trading fee is also a parameter than can be chosen by a pool creator. Vault strategies can be built around time preferences or volatility preferences, giving end users easy access to a huge source of sustainable yield: theta.

As a Structured Product Vault

  • Structured products maintain a portfolio of assets or derivatives which follow a strategy on behalf of depositors. RMM liquidity tokens can be used as a tool to hedge out risk (e.g. underlying asset price risk) or tap into specific exposures, like theta.

As a Large Yield Optimizing Vault

  • One of the hurdles for yield optimizing vaults is as they scale into TVL of $ billions, there are not many sources which can sustain strong returns. The theta from options comes with risk, but it also is sourced directly from the volatility of the underlying asset. Vaults which utilize option strategies can earn outsized yields in high volatility environments.

Comparisons

Comparison Table of Payoffs
Comparison Table of Payoffs

Compared to Uniswap xy=k curve:

  • Impermanent loss only occurs after the strike price, making liquidity provision directional.
  • RMM curves concentrate liquidity over time vs. Uniswap V3's fixed concentrated liquidity.
  • Trading fees are designed to be dependent on time and volatility, while Uniswap's fees are dependent on volatility.

Compared to Covered Call Options in DeFi:

  • No reliance on oracles reduces risk and easily supports long-tail assets.
  • No need for a direct counter-party to generate theta/fees.
  • Instantly redeemable for underlying and quote asset vs. covered calls which is a position that needs to be closed in an exchange.
  • Highly composable and a better collateral asset because of redeemability.

Liquidity Provision in Practice

Covered calls are inherently directional bets which are best to take advantage of in high volatility environments. It is ideal to provide liquidity when the underlying asset's volatility is high, and the expected price of the asset will not exceed the strike price by expiration.

Choosing your strategy

RMM Curve Parameters
RMM Curve Parameters

Each RMM Pool is a "theta curve" with the following set of parameters:

  • Strike price: Each liquidity token is composed of strike price amount of quote tokens if the price of the underlying asset is greater than this strike price. When the pool expires, the underlying asset can be bought or sold for this strike price amount. This will incentivize the re-balancing of the pool such that the each liquidity pool token is worth strike price of the quote asset.
  • Implied Volatility: The expected volatility of the underlying asset over the time period until the expiration date. Higher implied volatility will make trades have higher price impact (cost), and lower implied volatility will make trades have lower price impact. If realized volatility of the asset is less than the chosen implied volatility, there is a lower chance that liquidity providers get their expected theta (trading fees).
  • Maturity: The expiration date at which no more trading in the pool can occur, and thus no more trading fees can be generated. Liquidity providers can withdraw their liquidity at any time, before or after.
  • Gamma: Used to compute the trading fee of the pool. For example, if a pool's trading fee is 1%, its gamma will be 99%. Each swap must pay the trading fee to the liquidity providers, which gets automatically re-invested into the pool.

Example #1 - Choosing a Far Strike Price

On January 10, 2022, Alice notices the volatility of YFI has increased sharply since announcing their new tokenomics plan. The coin trades at $32,000 right now, and Alice believes it won't exceed $100,000 by March. Alice also believes it can double in value to $64,000 by then. She wants to take advantage of the volatility and price movement, so she provides liquidity to an RMM that expires March 11, 2022, with a strike price of $100,000 and implied volatility of 150%.

The amount of value in stable units (e.g. $) of liquidity that Alice must provide is calculated using the Portfolio Value formula:

Depositing Tokens

To summarize the initial position on January 10:

  • Current Price: $32,000
  • Strike Price: $100,000
  • Maturity: March 11, 2022
  • Time until expiry: ~3 Months
  • Implied Volatility: 150%
  • Value of Alice's deposit V(S) in $: (0.8737 + $2909) = $30,868
  • Value of Alice's deposit V(S) in YFI: (0.8737 + $2909/$32000) = 0.964

Derived information:

  • Call price with those parameters is C: ~$1,132

Notice how the value of the covered call is just the current price less the premium. E.g. S - C = V(S), $32,000 - $1,132 = $30,868.

Capital Efficiency

Therefore, liquidity is being efficiently used to "back" these tokens that have the payoff of a covered call. When compared to covered calls issued on other option protocols, full collateralization is required, sometimes even locked, to mint the call tokens. Going further, these LP tokens are instantly redeemable for their underlying assets at any time, which makes it a strong collateral asset. Using the LP token as a collateral asset to leverage a position is capital efficiency increase that RMM is capable of supporting - but that is left to a future primer.

On or After Expiration

Let's say assumptions proved right for Alice, and three months later YFI is trading at $77,000 with implied volatility over the period being effectively realized. The most important assumption here is the choice of implied volatility (IV). If the realized volatility of the underlying asset diverges from the choice of IV, its possible the replication is not as precise. In that scenario, Alice would have been better off moving their liquidity a lower IV curve. But, because RV was close to IV, the replication was very precise and Alice got the expected payoff. This is a critical choice that is being made when liquidity is provided.

Exiting Position at Expiry

The pool has eclipsed its expiration timestamp, and Alice decides to exit her position. Assuming the pool had sufficient liquidity to attract traders and arbitrageurs, the trading fees and final swaps should cause the pool to be 100% composed of YFI.

This is because the underlying assets in an expired RMM pool can be bought or sold for the strike price. This will incentivize traders/arbitrageurs to purchase all the underlying assets from the pool if the price of asset (e.g. on another dex) is more than the strike price. In the opposite scenario, traders/arbitrageurs will sell as much underlying assets to the pool until the pool only has underlying assets in the if there exists a reference price of the asset that is less than the strike price.

Withdrawing Tokens

March 11, 2022: Alice removes liquidity when YFI is $77,000 and realized volatility over that period was 155%.

  • YFI Price: $77,000 (~2.4x increase).
  • Realized volatility >= Implied volatility, therefore high probability that the LP token in practice has this payoff.
  • Liquidity token composition: 0.00% in $, 100.00% in YFI
  • Value of Alice's deposit V(S) in $: $77,000 (~2.5x increase, $77,000 / $30,868).
  • Value of Alice's deposit V(S) in YFI: 1 (+3.73% increase in YFI, 1 / 0.964 ).

Alice took the risk of redeeming $100,000 if YFI's price was above that by expiration date. In exchange, she is rewarded with the 3.73% gain in YFI. This extra return denominated in the asset also led to an overall higher return when denominated in a stable coin. Notice that YFI's price increased by 240% and Alice's position increased by 250%, 10% more.

Example #2

Alice loves using RMMs, she made a strong risk-adjusted return and felt confident in the security of the protocol.

She continues to believe that in 3 months YFI will not be above $100,000, so she decides to enter in a new position.

Depositing Tokens

March 20, 2022: Alice provides liquidity when YFI is $80,000

  • Current Price: $80,000
  • Strike Price: $100,000
  • Maturity: June 21, 2022
  • Time until expiry: ~3 Months
  • Implied Volatility: 150%
  • Value of Alice's deposit V(S) in $: (0.469 YFI + $25062) = $62,582
  • Value of Alice's deposit V(S) in YFI: (0.469 + $25062/$80000) = 0.782

Derived information:

  • Call price with those parameters is C: ~$17,418

On or After Expiration

Unfortunately, this time Alice was wrong. Its June 21, 2022 and YFI is trading at $135,000. What happened to her deposit?

Withdrawing Tokens

June 21, 2022: Alice removes liquidity when YFI is $135,000 and the realized volatility over that period was around 150%.

  • YFI Price: $135,000 (~1.6875x increase).
  • RV >= IV, high chance replication success if sufficient liquidity in pool during lifetime.
  • Liquidity token composition: 100.00% in $, 0.00% in YFI
  • Value of Alice's deposit V(S) in $: $100,000 (~1.5979x in $, $100,000 / $62,582).
  • Value of Alice's deposit V(S) in YFI: 0.7407 (-5.3% decrease in YFI, 0.7407 / 0.782).

While Alice did get a good return in $, if she wanted to earn a return denominated in YFI she would have been better off to hold all of her deposit in YFI. The actual price of YFI was more than the strike price of the pool, $35,000 more, which incentivized arbitrageurs to buy all the YFI from the pool at a price of $100,000. The pool is then 100% composed of $, which liquidity providers like Alice eventually withdraw.

So, what was the tradeoff that Alice took?

  • Trading lower probability of potential gains (YFI price increase above $100k) for higher probability of profits (trading fees).

In the opposite scenario, If YFI's price was below $100,000 at the maturity:

  • Alice withdraws 1 YFI, earning a 28% (!!!!) return on YFI. Note: High return because of IV parameter curve being high, and realized volatility was close to it.

And what was the belief/purpose of providing liquidity to RMM?

  • Not confident in YFI being above $100,000 in 3 months.
  • Wanted to capture trading fees, i.e. theta decay, generated from YFI's volatility.
  • Wanted to earn a return denominated in YFI.

RMM Strategies

Choose Impermanent Loss Price Point

In short term bearish environments, like a prospective FOMC meeting, prices are dampened and volatility is heightened. This is an optimal time period to take advantage of RMM. By providing liquidity, the exposure to the underlying asset will be maintained assuming the strike price is high enough, and higher volatility will warrant higher fees (if the liquidity is there).

In comparison to a CFMM like Uniswap, any price change in the underlying asset which does not revert to the initial entry price will miss out on potential gains (opportunity cost) from the asset, while RMM pools will only miss gains on the asset if the pool expires "in the money"; when the market price of the asset is above the strike price of the pool.

On the other hand, this opportunity cost in Uniswap would be in the LPs benefit in the scenario the underlying price fell off a cliff. In that scenario, the RMM LPs will be left holding 100% the underlying asset, which could potentially go to zero.

This directionality is not available in any AMM curves because those curves are not aware of time or strike prices.

Hedge Options with RMM

Hedging options is called a dynamic hedge because it is a position which counters another position's greek exposures. Greeks are planned to be explained in a future option primer, but for now they can be thought of as symbols to represent the change in the option's value depending on price, volatility, or time. For example, if an option changes value because of time (theta), the dynamic hedge will also change by the same magnitude from the same change in time.

An option's value is derived in part from the underlying asset's price. The greek symbol delta is used as a quantitative metric for how much value the option's value changes when the underlying asset's price changes. Going further, the greek symbol gamma is the metric for how much the delta changes when the underlying asset price changes. Gamma exists for options because if the underlying asset price gets closer or further away from the strike price, there is more/less probability the asset price will be above the strike. If the option is not above the strike by its maturity date, then it's worthless. Therefore, delta is sometimes used as a proxy for the probability of being in the money. Gamma is one of the primary reasons options are such a popular instrument, because purchasing gamma (buying the call option) is cheaper (but has the same returns) as purchasing delta (buying the asset).

Call options have a positive gamma, which means a hedge cannot only be in the underlying asset (which has no gamma), it must be a negative gamma position. Uniswap liquidity tokens have negative gamma, but it's not a straightforward hedge for a call option because it does not match its gamma.

RMM liquidity tokens replicate a covered call payoff, which means its close to a perfect hedge (almost) for calls. Along with that, it's negative gamma so it can be used to hedge other gamma positive positions.

Why hedge a call option with a short call option? A rough example of an opportunity is if call options on another protocol are underpriced, they can be purchased and then hedged with an RMM liquidity position, capturing the difference in premiums.

RMM Risks

While these are the expected results of providing liquidity to RMM, its entirely possible that no fees are generated at all. However, in that case it would mean the pool's liquidity is not rebalanced. This might end up in the LP's favor anyway. For example, if no trading occurred in the pool Alice deposited to, and thus no fees were generated, the initial deposit would be the same. At that point, she'd be withdrawing some YFI along with the $, rather than only $.

A no trading fees scenario occur for several reasons:

  • Realized volatility is lower than the curve's implied volatility, increasing the arbitrage profit window and reducing the amount of trading fees generated.
  • Liquidity in Alice's pool is too small for many trades to happen.
  • Liquidity in Alice's pool does not create enough profitable opportunities for arbitrageurs to trade the pool.
  • The pool is not known well/integrated into a dex aggregator/known by arbitrageurs/searchers.

Oracle Risks

None.

Smart Contract Risks

Have the smart contracts for RMM been audited?

Yes. RMM protocol contracts have been audited by five security firms, making it one of the most audited set of smart contracts in DeFi (if not the most):

  • Trail of Bits - 8 weeks
  • ChainSecurity - 8 weeks
  • ABDK - 4 weeks
  • Dedaub - 4 weeks
  • Sherlock - continuous

While these audits give high confidence in the protocol's security, the smart contracts still have the possibility of containing bugs. Along with the audits, Primitive has a $1,000,000 bug bounty on Immunefi, and $10,000,000 of coverage by Sherlock.

Conclusion

Primitive RMM is a highly composable primitive for DeFi that will bring more liquidity to on-chain options. Liquidity tokens can be used as a collateral asset in lending and derivative protocols, increasing the capital efficiency and usage of the underlying tokens.

RMM protocol fixes the poor liquidity environment for on-chain options and it's going live in a couple of weeks. You in?

Resources

Visit the website here: primitive.finance

Follow Primitive on twitter.

Frequently answered questions: FAQ.

Community Discord: Discord.

Subscribe to Primitive
Receive the latest updates directly to your inbox.
Verification
This entry has been permanently stored onchain and signed by its creator.