Withdraw
Same process as unmint, but considering 100% of the funds and after exercise window.
Withdraw
The event of withdrawing funds from expired options doesn't require any parameters. It will unlock 100% of the seller's funds, which may be composed of a combination of strike assets and the underlying asset, depending on how many options were exercised.
There is no race condition on withdrawing funds. That means that it does not matter the order/moment you withdraw. The assets will be distributed evenly and proportionally between the owners.
The withdrawal function will perform the following actions after expiration.
1) Consult Balances
1.1) Consult Current StrikeReservesn
This step will fit its purpose better in a put option where the collateral is in strike asset.
This balance should reflect the new current StrikeReserves, considering the interest that accrued in the meanwhile.
1.2) Consult Current UnderlyingReservesn
UnderlyingReservesn is a variable where we store the total amount of underlying assets currently locked in the protocol. This function has a precise fit with call options since, in call options, the underlying asset is the asset locked as collateral.
2.1) Calculate StrikeToSend
This step calculates the amount of strike asset an owner needs to receive for this withdrawal process.
StrikeToSend=TotalSharesi−1OwnerSharest⋅StrikeReservesn
2.2) Calculate UnderlyingToSend
This step calculates the amount of underlying asset an owner needs to receive to complete the withdrawal.
UnderlyingToSend=TotalSharesi−1OwnerSharest⋅UnderlyingReservesn
3) Updates
3.1) Update TotalSharesi
TotalSharesi is the sum of all the owner's shares.
TotalSharesi=TotalSharesi−1−OwnerSharest
Notice that the negative sign here is different from the pure mint function since it removed funds and, therefore, removed the weighted impact.
3.2) Update OwnerSharest
This factor updates the current total amount of owner shares. This factor will store that the funds were withdrawn from the contract by setting it to zero.
OwnerSharest=0
3.3) Update strikeReservesi
Using StrikeReservesn (accrued with interest from the last period), we'll deduct the amount of StrikeToSendused while minting this option.
StrikeReservesi=StrikeReservesn−StrikeToSend
This session described mathematically how the contract logic works. It is not needed to update the total ERC20 balances at the code level since tokens transfer to or from the contract is automatically updated with the ERC20 implementation.
3.4) Update UnderlyingReservesi
Using UnderlyingReservesn (accrued with interest from the last period), we'll deduct the amount of UnderlyingToSend used while minting this option.
UnderlyingReservesi=UnderlyingReservesn−UnderlyingToSend
This session described mathematically how the contract logic works. It is not needed to update the total ERC20 balances at the code level since tokens transfer to or from the contract is automatically updated with the ERC20 implementation.
Withdraw options ✅
Last updated