Single-sided liquidity provision
Quick recap: it is possible to add liquidity on one side of the pool. The pool will track the user's initial exposure, and by the time the user removes liquidity, the withdrawal position will reflect the initial exposure within a new distribution of assets. It means that it is possible (and likely) to withdraw percentages of both assets.
The remove liquidity function allows users to choose what percentage of the amount provided they wish to withdraw at a given instant i . The only user who can remove liquidity is a user who provided liquidity before and still has funds in the pool. r is the proportion of the user's initial deposit that it wishes to withdraw now. Removing "1" corresponds to remove 100% of the funds previously added.
rA​≤1 and rB​≤1
The event of removing liquidity requires the following information:
1. rA​Proportion of initial exposure of token A that wants to withdraw.
2. rB​ Proportion of initial exposure of token B that wants to withdraw.
1. Calculate factors
1.1 Calculate Option Price
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 and its contract implementation, check .
1.2 Calculate the Pool's Value Factor (
Fvi​​)
Fvi​=DBAi−1​​⋅Pi​+DBBi−1​​TBAi−1​​⋅Pi​+TBBi−1​​​
The pool's opening factor works as a factor that will update the pool's amortization as time passes.
1.3 Calculate multipliers
The redemption multipliers are defined as:
mAAi​=DBAi−1​​min(Fvi​⋅DBAi−1​​;TBAi−1​​)​
mBBi​=DBBi−1​​min(Fvi​⋅DBBi−1​​;TBBi−1​​)​
mABi​=DBAi−1​​TBBi−1​​−mBBi​⋅DBBi−1​​​
mBAi​=DBBi−1​​TBAi−1​​−mAAi​⋅DBAi−1​​​
1.4 Calculate withdrawal amount of each token
Ai​=−[mAAi​⋅rA​⋅Fvdu​​UBAu​​​+mBAi​⋅rB​⋅Fvdu​​UBBu​​​]
Bi​=−[mBBi​⋅rB​⋅Fvdu​​UBBu​​​+mABi​⋅rA​⋅Fvdu​​UBAu​​​]
1.5 Update new user balance for each token
After the withdraw, the contract calculates the updated user balance for each token.
UBAu​​=UBAui−1​​​⋅(1−rA​)
UBBu​​=UBBui−1​​​⋅(1−rB​)
1.6 Update new deamortized balance for each token
DBAi​​=DBAi−1​​−rA​⋅Fvdu​​UBAui−1​​​​
DBBi​​=DBBi−1​​−rB​⋅Fvdu​​UBBui−1​​​​
1.7 Update new pool balance for each token
The contract will calculate the new total balance for each token considering the recent withdrawal.
TBAi​​=TBAi−1​​+Ai​
TBBi​​=TBBi−1​​+Bi​