Add Liquidity
The event of adding liquidity requires the following information from the user:
1. Adu​ Amount of token A to be added
2. Bdu​ Amount of token B to be added
3. Owner
After the information was supplied, the add liquidity
function will perform the following activities:
1. Calculate factors
1.1 Calculate Option Price
This happens if iî€ =0. If i=0 , it is not required to calculate the option price in the very first liquidity provision in a pool.
For simplicity, let's acknowledge that the option price is a function that required a MarketData and an internal vector (IV) as input.
Pi​=fp​(IVi−1​,MarketDatai​)
For more details about the pricing formula or its contract implementation for pricing the options, check .
1.2 Calculate the Pool's Value Factor (
Fvi​​)
If i=0 , Fvi​​=1
If iî€ =0 , Fvi​​=DBAi−1​​⋅Pi​+DBBi−1​​TBAi−1​​⋅Pi​+TBBi−1​​​
Since this is the first liquidity provision of the pool, this is i=0 and therefore, Fvi​​=1.
2. Updates
2.1 Update Deamortized Balance of the pool for each token
By the time the pool is created (i=0) , the DBAi​​and DBBi​​ will be equal to the Adu​ and Bdu​ since:
Fvi​​=1
DBAi−1​​=0
DBBi−1​​=0
DBAi​​=DBAi−1​​+Fvi​​Adu​​
DBBi​​=DBBi−1​​+Fvi​​Bdu​​
2.2 Update the User Balances for each token and the Pool Factor previously calculated
Updating this factor is essential, especially when there is a re-add liquidity
event.
UBAu​​=Adu​
UBBu​​=Bdu​
The UBfu​​ works as if it was a snapshot of the pool's factor at the moment of this user's deposit. This factor will be updated in the case of re-add liquidity
by the user.
UBFu​​=Fvdu​
2.3 Update Total Balance of the pool for each token
TBAi​​=TBAi−1​​+Adu​
TBBi​​=TBBi−1​​+Bdu​