DittoETH

Ditto
DeFiFoundryOracle
55,000 USDC
View results
Submission Details
Severity: low
Invalid

Lack of Zero-Amount Check in increaseCollateral and decreaseCollateral Functions"

Summary

Lack of Zero-Amount Check in increaseCollateral and decreaseCollateral Functions"

Vulnerability Details

The contract fails to verify whether the values in increaseCollateral and decreaseCollateral are non-zero. This oversight could potentially result in unnecessary gas expenditures for null operations.

Impact

The impact of this issue is primarily on efficiency and user experience. If a user accidentally calls the increaseCollateral or decreaseCollateral functions with a zero amount, the transaction will still be processed and gas will be consumed, even though the state of the contract doesn't change. This could lead to unnecessary gas costs for the user.

Tools Used

Manual

Recommendations

To resolve this issue, you should add a require statement at the beginning of the increaseCollateral and decreaseCollateral functions to check if the amount is greater than zero. This will prevent unnecessary gas expenditures for null operations. Here is how you can do it:

function increaseCollateral(address asset, uint8 id, uint88 amount)
external
isNotFrozen(asset)
nonReentrant
onlyValidShortRecord(asset, msg.sender, id)
{
require(amount > 0, "Amount must be greater than zero");
// rest of the code
}
function decreaseCollateral(address asset, uint8 id, uint88 amount)
external
isNotFrozen(asset)
nonReentrant
onlyValidShortRecord(asset, msg.sender, id)
{
require(amount > 0, "Amount must be greater than zero");
// rest of the code
}

This will ensure that the functions will only execute if the amount is greater than zero, thus saving unnecessary gas costs.

Updates

Lead Judging Commences

0xnevi Lead Judge
over 1 year ago
0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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