Description
This should be its own contract, even though the additional code is pretty negligible. We want to keep gas costs down on clone deployments of Option.sol.
Make a new contract EuropeanOption.sol
.
Add a modifier inExpiryWindow
which checks a time window beyond the expiration date.
Only allow exercises to happen within this expiry window.
Make the expiry window a constant. (3 days?).
European options only allow exercises on the date of expiry... but in the blockchain sense, this could make problems since gas could be higher/lower than normal. A time window that is not too long but not too short would improve any keepers who might be automatically exercising options.
This also leads into getting automatic expiry to work... which would require cash settlement.
Cash settlement simply means that for every $1 in the money of the option contract, that amount is the profit delivered to option holders.
To check if an option is in the money, this requires an oracle.
Add a state variable for the oracle address. If an option expires, and it's in the money, allow the long option tokens holders to claim the in the money profits, and the short option token holders to take the loss, on a proportionally distributed basis.
BUT, the problem comes to how its settled. If this is an ETH option, and the profit is $10, then we need DAI paid out to the option holders, not eth... This means the contract would need a collateral of dai, not eth... but this makes more problems. How much Dai must go into upfront? What if eth skyrockets and we dont have enough dai collateral to pay the setttlement value? Well, to avoid this smart contract from handling this (another contract will handle this), just settle the amount in ETH terms.
For example, if 1 ETH is $1000, and the cash settled profit is $100, then the smart contract would retain 0.1 ETH for long option token holders ($100 at expiry), and 0.9 ETH for short option token holders.