Sparkn

CodeFox Inc.
DeFiFoundryProxy
15,000 USDC
View results
Submission Details
Severity: low
Valid

Revert on Zero Value Transfers

Summary

Some tokens (e.g. LEND) revert when transferring a zero value amount. Therefore, if the amount to be transferred is 0, it might cause the transaction to fail.

Vulnerability Details

The _distribute() function is designed to facilitate the fair and proportional distribution of tokens to a group of winners, based on given percentages.

for (uint256 i; i < winnersLength;) {
uint256 amount = totalAmount * percentages[i] / BASIS_POINTS;
erc20.safeTransfer(winners[i], amount);
unchecked {
++i;
}
}

However,some tokens (e.g. LEND) revert when transferring a zero value amount. Therefore, if the amount to be transferred is 0, it might cause the transaction to fail.

Impact

A transaction failure results in the feature being unavailable.

Tools Used

Recommendations

It is recommended to change it to the following code.

for (uint256 i; i < winnersLength;) {
uint256 amount = totalAmount * percentages[i] / BASIS_POINTS;
if (amount != 0)
{
erc20.safeTransfer(winners[i], amount);
}
unchecked {
++i;
}
}

Support

FAQs

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