Exercise
Options buyers can exercise their right during the window of expiration.

Exercise

The event of exercising an option requires the following initial information: 1. Amount To Exercise 2. Owner
After the information was supplied, the exercise function will perform the following activities:
This function can only be called duringexerciseWindowperiod, depending on the exercise type.
For European: after trade window and before expiration. For American: anytime before expiration.

1) Consult Current
StrikeReservesnStrikeReserves_n

This balance should reflect the new current strikeReserves, considering the interest that accrued in the meanwhile. We are calling balanceOf()from ERC20 strike asset to check option contract strike asset balance.

2) Calculate
StrikeToSendStrikeToSend

This step calculates how many strike assets the user will receive in a put option after it requested the exercise.
StrikeToSend=ExerciseAmountStrikePriceStrikeToSend=ExerciseAmount\cdot StrikePrice

3) Calculate
UnderlyingToReceiveUnderlyingToReceive

This step calculates the amount a user should receive in underlying assets after the exercise was requested in the case of a call option.
UnderlyingToReceive=ExerciseAmountUnderlyingToReceive=ExerciseAmount

4) Updates

4.1) Update
StrikeReservesiStrikeReserves_i

Using the current
StrikeReservesStrikeReserves
(accrued with interest from the last period), we'll deduct the amount
StrikeToSendStrikeToSend
used while minting this option.

StrikeReservesi=StrikeReservesnStrikeToSendStrikeReserves_i=StrikeReserves_n-StrikeToSend

4.2) Update
underlyingReservesiunderlyingReserves_i

Using the current
UnderlyingReservesUnderlyingReserves
(accrued with interest from the last period), we'll add the amount of underlying to transfer used while minting this option. Also, now with the expiration, one can either receive tokens or send tokens. In the case of a put option, this balance should increase if the options were exercised. That means an option buyer chose to exercise options.
UnderlyingReservesi=UnderlyingReservesn+UnderlyingToReceiveUnderlyingReserves_i=UnderlyingReserves_n+UnderlyingToReceive

5) Burn options

Burn exercised options.
Burn=ExerciseAmountBurn = ExerciseAmount
Note that exercise functions do not impact the
TotalSharesTotalShares
or any
OwnerSharesOwnerShares
.
Exercise options ✅