Components
This page will go over the components of the AMM and how they interact.
Last updated
This page will go over the components of the AMM and how they interact.
Last updated
The Options AMM has four properties:
The AMM will programmatically update the IV to price options more accurately according to market changes.
The AMM allows for single-sided liquidity provision using an exposure position point of view.
If there is no inventory imbalance, canceling trades (not reflecting any arbitrage opportunity) or price changes due to price calculations should not take nor add any value from or to the liquidity providers.
Any gain or loss of the AMM pool should impact the LPs fairly across time.
Disclaimer: with the current UI, users can only provide or remove liquidity equally on both sides
The AMM is structured in 5 components that keep these properties over the lifetime of the pool. Find below a description of those components and their concepts.
The Pool Value Factor short representation is . It aims to express the current pool circumstances in one number as if it was a snapshot. The Pool Value Factor is essential to keep the distribution of impermanent loss or gain correctly among users and the moment they entered the pool.
Consider the case: when a user added liquidity to the pool, the at that moment was 0.9. This number will be stored in the variable (explained below) within the user's struct. By the time the user wishes to remove the funds, the will be compared to the current of the pool, let's say now the factor is at 1. That will represent that the user had an impermanent gain of 11% (). In the Multipliers component (explained below), this will be used to calculate the delivered position for the user to express this given the pool conditions.
In short, we need this number to compare how the pool changed over time. By the moment of withdrawing, we'll compare the pool's factor to the user's factor (got on a snapshot at the moment of entry into the pool) and estimate if that resulted in a gain or loss. The user can experience an impermanent loss or gain depending on the moment they entered and what happened to the pool while they were there. It is important to highlight that even if a pool has an impermanent loss, a user that just joined will not face immediate impermanent loss. Instead, each user will have its own path of impermanent loss or gain calculation in a pool.
The pool's value factor () is always equals to 1 in the opening of the pool, representing the initial balance in the pool. If ,
Actions such as adding liquidity, re-add liquidity, and remove liquidity do not impact the since they impact equally the factors of and . Instead, what impacts this factor is the trades that may happen in the pool.
If ,
The user component (represented in the struct) is updated in two circumstances:
If this is the first time this user adds liquidity or,
If this is not the first time this user adds liquidity.
They are calculated upon the events of adding liquidity, re-adding liquidity, and removing liquidity.
Find below the formulas for the Pool's deamortized balances:
This factor is update whenever there is an event in the pool (add liquidity, re-add liquidity, trade, and remove liquidity).
This variable is just a virtual conception of what it represents. It does not exist like that in the code. Instead, the code checks ERC20 option token addresses the current balance of each token to serve as input for formulations.
The multipliers are factors that the AMM calculates when a user calls the remove liquidity function. They will calculate the "delivered" position in the withdraw, considering the user's initial exposure. They can be understood as:
The multipliers function ensures that the original deposit is considered when calculating the withdrawal amount and that the withdrawal amount should never surpass the pool's total balances. They calculated the equivalent amount of tokens the user should receive to translate the initial exposure to withdrawal position. It is also expected that after all LPs removed the liquidity, the total balances of the pool will be zero. A multiplier could be equal to zero, and in that case, it describes that there is no position for that token on the withdrawal amount.
A user that provides liquidity in either the options tokens or stablecoin has three different properties saved as a struct during the life of the pool:
1. -> Is short for User Balance of Token A. This factor holds the current amount of tokens A the user has provided as liquidity. It is the result of the initial liquidity provision and/or a re-add liquidity event.
2. -> Is short for User Balance of Token B. This factor holds the current amount of tokens B the user has provided as liquidity. It is the result of the initial liquidity provision and/or a re-add liquidity event.
3. -> User Balance Pool Factor is the variable that takes a snapshot of the Pool Factor () by the time the user last added liquidity. This factor will be responsible for making sure the user keeps its initial exposure over time.
In the case of the first liquidity provision, and will be equal to the amount that is being provided as liquidity, and respectively.
In the latter case, where the user is re-adding liquidity, the and will be updated differently. It considers the funds previously added, multiplied by a factor that takes into account both the current Pool Factor ( ) and the User Balance Pool Factor (). This could be understood as if the pool is updating the virtual user balance to the current pool state.
The Deamortized Balance, and , are representations of what the pool owe's to the LPs. One could understand this factor as the virtual debt the pool has with liquidity providers. That could be seen as storing the original deposits provided by the LPs.
By the time the pool is created () , the and will be equal and since:
By the time any other even happen (except trades), by any user, the and will be updated to reflect the amount of original deposits the pool received since the beginning.
The additional amounts of tokens (either, or ) are added to the total and by being divided by the current . By doing so, the pool can take the new deposits to the same level that the previous deposits were, considering the pool's impermanent loss or gain.
The Total Balances is basically the pool balance, and . They are constantly updated and represent the exact and current amount of each token that the pool holds. This factor will be contrasted against the Deamortized Balance, which will guide the calculation for the next component (Multipliers).
→ How much A the users can remove for each A initially deposited
→ How much B the users can remove for each B initially deposited
→ How much B the users can remove for each A initially deposited
→ How much A the users can remove for each B initially deposited