Mint
The event of minting an option requires the following initial information:
1. Option Amount
2. Owner
After the information was supplied to the contract, the mint function will perform the following activities:
1) Required Collateral Amount
Calculate the number of assets the user has to send to the contract to lock as collateral. 
If this is a put option:
AmountToTransfer=OptionsAmount⋅StrikePrice 
If this is a call option:
AmountToTransfer=OptionsAmount⋅UnderlyingAsset 
2) Consult Balances
2.1) Consult Current 
StrikeReservesn
StrikeReservesn is a variable where we store the current amount of the strike asset. If the strike asset is an interest-bearing token, it is expected that StrikeReservesn will have accrued some interest since the last period. We are calling balanceOf() from ERC20 strike asset to check option contract strike asset balance.
StrikeReservesn=StrikeReservesi−1+aTokensYield
2.2) Consult Current 
UnderlyingReservesn
UnderlyingReservesnis 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. We are calling balanceOf() from ERC20 an underlying asset to check option contract strike asset balance.
3) Calculate 
OwnerSharesi
OwnerSharesi is a variable that stores the shares of the user based on the current option contract situation. 
If i=0,OwnerSharesi=AmountToTransfer 
If i=0,we identify the following cases:
If this is a put option:
OwnerSharesi=StrikeReservesn+(UnderlyingReservesi⋅StrikePrice)AmountToTransfer⋅TotalSharesi−1 
If this is a call option:
OwnerSharesi=UnderlyingReservesi+StrikePriceStrikeReservesiAmountToTransfer⋅TotalSharesi−1
4) Updates
4.1) Update  
TotalSharesi
TotalShares is the sum of all the owner's individual factor of OwnerShares.
TotalSharesi=TotalSharesi−1+OwnerSharesi 
4.2) Update 
UserMintedOptionsi 
Update the current number of outstanding options minted by the same user on the same option series.
UserMintedOptions=UserMintedOptionsi−1+OptionsAmount 
4.3) Update 
OwnerSharesi
This factor updates the current owner shares. Important: If the user had previously minted options, those would be accounted for as one factor.
OwnerSharest=OwnerSharesi−1+OwnerSharesi 
4.4) Update 
StrikeReservesi
UsingStrikeReservesn (accrued with interest from the last period) we'll add the AmountToTransfer to transfer used while minting this option.
StrikeReservesi=StrikeReservesn+AmountToTransfer