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 StrikeReservesnStrikeReserves_n

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 StrikeReservesStrikeReserves, considering the interest that accrued in the meanwhile.

1.2) Consult Current UnderlyingReservesnUnderlyingReserves_n

UnderlyingReservesnUnderlyingReserves_n 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 StrikeToSendStrikeToSend

This step calculates the amount of strike asset an owner needs to receive for this withdrawal process.

StrikeToSend=OwnerSharestStrikeReservesnTotalSharesi1\displaystyle StrikeToSend=\frac{OwnerShares_t\cdot StrikeReserves_n}{TotalShares_{i-1}}

2.2) Calculate UnderlyingToSendUnderlyingToSend

This step calculates the amount of underlying asset an owner needs to receive to complete the withdrawal.

UnderlyingToSend=OwnerSharestUnderlyingReservesnTotalSharesi1\displaystyle UnderlyingToSend=\frac{OwnerShares_t\cdot UnderlyingReserves_n}{TotalShares_{i-1}}

3) Updates

3.1) Update TotalSharesiTotalShares_i

TotalSharesiTotalShares_i is the sum of all the owner's shares.

TotalSharesi=TotalSharesi1OwnerSharestTotalShares_i = TotalShares_{i-1} -OwnerShares_t

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 OwnerSharestOwnerShares_t

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=0OwnerShares_t=0

3.3) Update strikeReservesistrikeReserves_i

Using StrikeReservesnStrikeReserves_n (accrued with interest from the last period), we'll deduct the amount of StrikeToSendStrikeToSendused while minting this option.

StrikeReservesi=StrikeReservesnStrikeToSendStrikeReserves_i=StrikeReserves_n-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 UnderlyingReservesiUnderlyingReserves_i

Using UnderlyingReservesnUnderlyingReserves_n (accrued with interest from the last period), we'll deduct the amount of UnderlyingToSendUnderlyingToSend used while minting this option.

UnderlyingReservesi=UnderlyingReservesnUnderlyingToSendUnderlyingReserves_i=UnderlyingReserves_n-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