QuantAMM

QuantAMM
49,600 OP
View results
Submission Details
Severity: low
Invalid

Redundant Storage Operations in afterUpdate Cause Unnecessary Gas Costs

Summary

The `afterUpdate function performs unnecessary delete operations before immediately overwriting storage slots, leading to wasted gas.

Vulnerability Details

In the afterUpdate function, during array reordering:

if (tokenIdIndex != feeDataArrayLength - 1) {
for (uint i = tokenIdIndex + 1; i < feeDataArrayLength; i++) {
delete feeDataArray[i - 1]; // SSTORE operation (~5000 gas)
feeDataArray[i - 1] = feeDataArray[i]; // Another SSTORE operation (~5000 gas)
}
}

Each iteration performs:

  1. A delete operation which costs a full SSTORE (~5000 gas)

  2. Immediately followed by assignment which is another SSTORE (~5000 gas)

Since the slot is immediately overwritten, the delete operation is completely unnecessary. For an array with n elements, this wastes approximately 5000 * (n-1) gas.

Impact

unnecessary gas costs for users transferring NFT positions, particularly with multiple deposits.

Tools Used

Manual Review

Recommendations

if (tokenIdIndex != feeDataArrayLength - 1) {
for (uint i = tokenIdIndex + 1; i < feeDataArrayLength; i++) {
feeDataArray[i - 1] = feeDataArray[i]; // Single SSTORE operation
}
}```
Updates

Lead Judging Commences

n0kto Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!