In this article, we outline two key use cases for Replicating Market Makers (RMMs) and introduce a method for recovering a trading function based on a desired liquidity distribution. We then show how this is utilized by Primitive Portfolio for passive portfolio management for onchain institutions. The conclusion is that in addition to the usual RMMs portfolio capabilities, bets on price action can be implemented and managed passively through Portfolio, instead of depending on active management.
Liquidity Allocation
While there is a large body of research around the connection between CFMMs and the portfolio value of their LPTs, there is significantly less written on the connection with the liquidity distribution. This has limited the use of CFMMs to being predominantly about achieving a specific portfolio value (with the exception of Uniswap V3). Primitive believes that they can be used as building blocks for much more.
In this section, I will define a notion of liquidity that allows us to allocate to CFMMs based on our desired distribution. This functionality allows us to passively implement an expectation on price action and earn fee income accordingly, with minimal need for manual re-balance events requiring action costing additional fees. This functionality I refer to as dynamic allocation. I will only consider the two asset case for this section, however the same logic applies to assets.
If our goal is only to consider potential for fee income rather than portfolio value function (PVF), the definition of liquidity we need is the depth of the CFMM. This can be defined multiple ways but ultimately lead to the same outcome: a connection between depth and the CFMM trading function.
Defining Liquidity in Terms of Depth
The simplest definition would be defining depth in terms of the swap quantity required to push the price of the pool up . Thus for , we can always determine a due to the convexity of . Assuming this is a smooth CFMM, (not descretely defined), this would mean we can define our depth as
Note this measures based off the output quantity rather than the input quantity, however a change of variables can reframe the problem from input quantity. This definition is a measure of trade size required to move the price upwards by . We can recover the reserve by integrating:
where .
Recovering the Portfolio Value Function
We can now apply Lemma 1 from the LVR paper, which states that . Thus to recover a PFV, we need to integrate one more time:
Given what we've learned from the Replicating Market Makers paper, we can perform a change of variables , and recover the trading function through fenchel conjugacy: .
Note for this definition of liquidity to work, we need to ensure that our depth is integrable over . Basically this says if we want to boast a liquidity distribution of where is the time elapsed since entry, we require finite total liquidity.
Your Liquidity is Your Gamma
There are a few key insights that help support our understanding of what this definition means. Firstly, it treats depth as a mass distribution, where total mass accumulated between two prices is the swap quantity required to move through the range. Additionally, due to the connection between depth and PVF, we can see that:
Since gamma is always negative for a CFMM, this says that your liquidity depth is precisely the magnitude of gamma of your portfolio. It should be noted that this definition defines depth from a starting price of upwards, rather than depth in both directions from the market price . While both are valid definitions, this one is easier to recover a CFMM from and serves the purpose of spot allocation just as well.
Routing Implications
Lastly, by defining the connection between trade depth and price, we can route through multiple CFMMs efficiently using their depth functions. This allows a simple solution to CFMM routing that requires minimal computation, which allows us to pool liquidity between multiple CFMMs.
Other Definitions
As mentioned at the start of the section, there are multiple ways to define liquidity, all of which are a change of variables away from each other. A more intuitive definition from an allocation perspective would be using the swap in value! Since the swap-in asset is the numeraire as we increase price, we simply need to change variables to the swap-in quantity. So:
where is determined from the trading function. This definition is less clean to work with mathematically because of the fact that our depth is no longer our gamma. Regardless, these definitions allow us to allocate liquidity to curves that express exactly the liquidity distribution we desire, earning fees proportionally to their depth.
Portfolio Construction
The perhaps more obvious use case of RMMs would be in replicating specific portfolios passively. RMMs are able to replicate any positive, concave, monotonically increasing portfolio value function directly. These portfolios are represented directly as tokens known as LPTs. While this is already a rich set of portfolios, we can go a step further by utilizing lending/borrowing markets, opening up even more potential portfolios.
Due to the concave nature of LPTs, they function as great mechanism for leverage. Shorting LPTs will result in a convex portfolio, as shown in A Note On Borrowing Constant Function Market Maker Shares. As an example of how this can be used, turn to RMM-01, our first implementation of a Black-Scholes Covered Call RMM.
A covered call is traditionally a collateralized short call. This implies that simply shorting a covered call should achieve you a long option, either call or put depending on how its shorted. This is exactly what we see as well when the RMM-01 LPT is shorted. As shown here, an RMM-01 LPT with perfect replication has a payoff of
for and . If we short an LPT with respect to the asset, we see a portfolio of:
This is precisely the payoff of a Black-Scholes call option, a.k.a. an example of a convex portfolio. Similarly if we had shorted with respect to assets, we would hold a put option.
What this tells us is we can achieve any non-negative, monotonically increasing function regardless of convexity or concavity simply by allowing a mechanism to short LPTs. It shold be noted that bounded LPT payoffs such as with RMM-01 are much cleaner to do this as we dont require a liquidation engine, however, unbounded LPT payoffs would require liquidations to short.
This again, however, isn't the end of the story. What if the portfolio you're looking to replicate isn't path independent (i.e. every change of price matters rather than simply the end state)? What if we want to replicate volatility derivatives rather than price derivatives? This is also possible when we start to consider the portfolio of an arbitrageur.
As described in Replicating Monotonic Payoffs Without Oracles, we can recover the payoff of the arbitraguer's position as after time :
This may look a little confusing at first glance as it is Ito calculus, however, what is really being said here is that we have a two legs: one path-independent fixed leg based on the LPT value, and a volatility-based floating leg that inflates in value the more volatile price action is. This floating leg allows us to break free from the monotonic nature of LPT payoffs and be able to use CFMM to do volatility contracts. A perfect example of this is the Variance Swap contract as described in the monotone paper.
Suppose we have a CFMM with the logarithmic payoff:
Note, as , we require unbounded capital to support this range of prices, however, for our purposes this is not a problem. We are simply using this payoff to illustrate a point. Assuming Geometric Brownian Motion, we achieve an arbitraguer value of:
The expactation value of this is which is precisely that of a variance swap under GBM.
In summary, we can use CFMMs to achieve many different portfolios and derivatives. Allowing the construction of any monotonically increasing non-negative payoffs, regardless of convexity, as well as a large set of volatility contracts by considering the arbitrageur earnings.
There is however a catch for those payoffs replicated directly as LPTs. They suffer from a loss known as loss-versus-rebalancing (LVR). This is a frictional loss incurred by LPs due to their pacificity and reliance on arbitrage for price updates. It's a loss that results from an informational disadvantage that LPs take on by only recieving price updates through.
It should be noted that this loss only negatively affects the LP's portfolio. When we are shorting LPTs, we are in turn also short this loss, so in a sense, LPT shorts benefit from LVR. Additionally, any position structured around arbitrageur earning is directly earning LVR by the nature of arbitrage. I will circle back to this in a later post and explain why LVR is even less of a concern for RMMs specifically when we consider certain constraints of decentralized portfolio management.
Portfolio Management
Portfolio by Primitive aims to utilize both these use cases of RMM in conjunction with the new Financial Virtual Machine (FVM) introduced in our yellow paper. RMMs provides an approach to constructing a diverse set of potential portfolios while boasting the ability to express complex positions in time in one action. This provides us the perfect vehicle to address the following two major needs and constraints of onchain organizations.
First, onchain organizations have diverse needs for their assets. While individual investors only seek to maximize returns, organizations tend have unique needs based on the structure they represent. These needs can be anything from managing treasury risk, generating positive returns, to managing native token liquidity. All of these needs require a diverse set of tool so that we can properly manage risks and allocations.
Additionally, DAOs with treasuries, a common type of onchain organization, make treasury allocation decisions based on a proposal/voting system. Depending on the implementation and voting structure, this can be a very slow and long process. As a result, certain mechanisms that require frequent re-balances such as Uniswap V3 become unviable for these DAOs to use directly without a vault implementation. In a sense, it is beneficial to DAOs to reduce the quantity of allocation actions as much as possible. This constraint also applies to a lot of other organizations as well just due to the cost of transacting on Ethereum.
The diversity of positions and allocation capabilities made available by RMMs and Portfolio allows fine tuned control over the greeks of the net portfolio, effectively allowing you to manage risk as best as possible at any given moment. And due to RMMs being equipped to change over time, we can manage risk over time without needing additional actions on behalf of the organizations. Portfolio implements RMMs in an opinionated way to deliver the best solution to the problems explained above. The capabilities and impact of Portfolio go far beyond just this and need consideration of the FVM as well to really get the full picture. To further support our understanding of the impact, we will explore the ramifications of the combination of FVM and RMM in a later post.
Appendix: Relevant CFMM Equations
CFMMs facilitate trades using a set of pool reserves , and a trading function which defines which trades are accepted. If a trader wants to tender a basket , they will recieve if
where is the fee regime on the CFMM. This function follows a lot of specific properties, but for now we'll focus on two key ones to understanding where RMMs comes into play. The trading function both implies a price based solely on the pool reserves:
and it implies a specific portfolio value for its LPs:
The above equation shows us that recovering the portfolio value function from the trading function is much more straight forward than the inverse operation. This is where RMMs comes in. Introduced in this paper, RMMs allows us to recover a trading function from a desired portfolio value function.