An additional requirement needs to be added into exercise to ensure protocol works as intended.
Suggestion: add a
require(block.timestamp <= optionRecord.expiryTimestamp)
statement within exercise()
.
The statement:
if (amountWritten <= amount) {
amount -= amountWritten;
claimRecord.amountExercised = amountWritten;
// We pop the end off and overwrite the old slot
} else {
claimRecord.amountExercised = amount;
amount = 0;
}
can be rewritten as:
if (amountWritten < amount) {
amount -= amountWritten;
claimRecord.amountExercised = amountWritten;
// We pop the end off and overwrite the old slot
} else {
claimRecord.amountExercised = amount;
amount = 0;
}
So that when amountWritten == amount
, the amount
is set to 0, eliminating an unnecessary mathematical calculation.
Both of these issues are now resolved and have passing tests cases.