Skip to content

Latest commit

 

History

History
45 lines (38 loc) · 1.12 KB

2022.04.14.md

File metadata and controls

45 lines (38 loc) · 1.12 KB

Valorem-options Audit

By: Carter Carlson

Date: March 14, 2022

Findings

High

1. User can excercise option after expiration

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().

Informational

2. Logic within assignExercise() can be incrementally optimized

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.