Unmint

Unminting an option is similar to the withdraw function, check below the major differences.

Unmint

The unmint function is a function to assist options sellers that decide to leave the position before expiration.

To do so, the option seller has to buy the equivalent amount of options in the secondary market (in the options AMM) and use them together with the address that it holds (owner) the position to unmint.

‌Note that this leaves the seller on the option price exposure because it can happen that when they decide to leave the position, the options in the market are above the premium they received. "Buying back" the options at a higher price to leave a position can incur a loss.

Unmint function is very similar to the withdraw function. The differences are:

  • Withdraw function can only happen after expiration.

  • The withdraw function only allows users to withdraw 100% off the funds.

  • In European options, unmint will never result in removing two assets (strike asset and underlying asset). Instead, unmint will only return the funds that were previously provided as collateral since options weren't exercised yet.

  • The withdraw function can return a combination of assets (underlying and strike asset) since a few buyers may exercise the options during the expiration window.

The event of unminting options requires the following information: 1. Amount of options to unmint 2. Owner

After the information was supplied to the contract, the unmint function will perform the following activities:

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 strikeReserves, considering the interest that could accrue in the meanwhile. We are calling balanceOf()from ERC20 strike asset to check option contract strike asset balance.

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 the underlying asset is the asset locked as collateral in call options. We callbalanceOf()from an ERC20 underlying asset to check the option contract's strike asset balance.

2) Calculate factors

2.1) Calculate OwnerShareswOwnerShares_w

This step calculates the proportional shares the user will unmint from its current position, considering his contract shares.

OwnerSharesw=AmountOfOptionsToWithdrawOwnerSharesi1UserMintedOptions\displaystyle OwnerShares_w=\frac{AmountOfOptionsToWithdraw\cdot OwnerShares_{i-1}}{UserMintedOptions}

2.2) Calculate StikeToSendStikeToSend

This step is most fit with put options since the collateral in put options is in strike asset.

This step calculates the number of strike assets a user would need to receive for this unminting process.

StrikeToSend=OwnerShareswStrikeReservesnTotalSharesi1\displaystyle StrikeToSend=\frac{OwnerShares_w\cdot StrikeReserves_n}{TotalShares_{i-1}}

2.3) Calculate UnderlyingToSendUnderlyingToSend

This step is most fit with call options since the collateral in calls is in the underlying asset.

3) Updates

3.1) Update TotalSharesiTotalShares_i

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

TotalSharesi=TotalSharesi1OwnerShareswTotalShares_i = TotalShares_{i-1} -OwnerShares_w

Notice the negative sign here is different from the pure mint function since it removed funds and, therefore, should reduce the number of shares.

3.2) Update OwnerSharesiOwnerShares_i

This factor updates the current total amount of user shares.

OwnerSharesi=OwnerSharesi1OwnerShareswOwnerShares_i=OwnerShares_{i-1}-OwnerShares_w

3.3) UpdatestrikeReservesnstrikeReserves_n

They are used in the case of a put option.

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

StrikeReservesi=StrikeReservesi1StrikeToSendStrikeReserves_i=StrikeReserves_{i-1} - 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

They are used in the case of a call option.

Using the current 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.

4) Burn options

After the unmint function is processed, the options tokens will be burned.

Unminting options ✅

Last updated