In this series of semi-technical posts we will attempt to describe the thought that went behind the DAO product design and our option Automated market makers (AMMs). Our goal is two-fold: We will attempt to formalize the key economical assumptions behind AMMs and derive from them a consistant mathematical framework as we believe that is has not been entirely done in the current litterature. We will use this mathematical framework to carefully explain and justify the choices we made for our platform.
I hope to make those writings as accessible as possible but knowledge in calculus will probably help the understanding.
At this point we plan to make a series of four posts:
- The first spot will be attempt to provide a different view of spot AMMs
- The second post will use this work to propose a design for single option AMMs
- The third post shall study possible designs for multi-options AMMs
- Finally, the last post will explain the problems that arise with those multi-options AMMs and propose some potential solutions.
As announced above, in this first post I will focus only on the classical spot price AMMs such as the one proposed on the Uniswap v2 or Sushiswap platform. Formally, we consider a pool where two type of tokens get pooled, a numeraire token A and an asset token B. Traders can exchange token A for token B with the AMM following a specific set of rules and liquidity providers (LPs) can add or removes both token according to another set of rules.
With this in mind, let us ask ourself what is absolutely necessary to require from a pool AMM for it to have a chance to work. We propose the two following properties as base points for our construction:
Property 1: An AMM should never leak money , that is it should be impossible for an external actor to perform a sequence of actions such that If an AMM is in state A with token A and token B, no sequence of actions taken by external actors should put the AMM in state B with token A and token B and such that and .
Property 2: The behavior of an AMM should be scale free. This means that the price at which the AMM is selling/buying token should only depend on variables which are independent by scale.
The first property is probably the most fundamental one. Indeed there is no point in putting your money in a pool if there a mean for external actors to arbitrage you. The second property is more debatable but is in some sense extremely natural as we expect the behavior of an AMM to be independent on the unit of account and we consider. Armed with those two properties let us now ask ourselves what an AMM consists in.
We propose to reduce an AMM to two price functions and which represents the price at which the LPs are willing to sell token A and token B at a given state. Following Property 2 we get that hose functions should only depend on the ratio of each token rather than the nominal amount of token and as such we can write them as the ask price and the bid price where is the ratio of token A to token B.
Another way to phrase this is to consider thats LPs see the ratio of tokens in the pool as an input for the respective demand of token A and token B in the market and adjust their price accordingly.
Let us now derive some useful consequences of this representation.
When the pool is selling , and the number of tokens in the pool follows: . Conversely when the pool is buying , and the number of tokens in the pool follows: . Let us know play around with those equations a little bit. It is not too hard to see that on can rewrite the first equation as:
We integrate the relation above to where C(r) is an antiderivative of .
Enough with the technicalities, let us now unpack what we have written there.
- An AMM strategy is entirely determined by two ask and bid functions and , which encodes the price at which pool participants buy and sell at a given ratio. Moreover in order for the Property 1 to holds, we must have that there exist no interval of r on which
- Those two functions determine two invariant curves and for buys and sells respectively.
Provided that we allow the bid and ask function to be dependent on time all the common AMM fit in this framework.
- Uniswap without fees uses
- Uniswap with fee k base points uses and
- Synthetix models uses $p_A(r)=Cst
The rule for LPs add and removal are straightforward: It is extremely natural to assume that a LP adding tokens in a pool according to the current composition of this pool, let’s call it a fair add, shall receive a proportion of lp tokens equal to the proportion of tokens he added. From there, any add can be expressed as the composition of a token A buy and fair add or token B buy and fair add. If we consider that remove is the inverse of add, this completely specifies the add and removal rules.
This is it for a simple mathematical description of what we believes consists in an AMM. In the next post will explore how one could decide to extend description in order to sell on option.