Sparkn

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

Hardcoded commission fees prevent owner from changing fees in the future

Summary

This audit report provides an assessment of the contract containing the hardcoded commission fees.The hardcoded variable can cause issue if owner wants to change commission fees .

Vulnerability Details

The contract contains the following line of code with the hardcoded variable:
uint256 private constant COMMISSION_FEE = 500; // this can be changed in the future.
In a situation where owner wants to update the commission fees, he would not be able to do so.

Impact

The presence of the hardcoded commission fee can lead to no option for the owner to change fees as intended .This can result to an inhability to update fees in a situation where it's needed.

Tools Used

Manual review, VsCode, Remix

Recommendations

it is recommended to implement a more dynamic approach for setting the commission fee. Instead of hardcoding it.
the contract should allow the commission fee to be set during deployment or provide a mechanism for the contract owner to update the commission fee post-deployment;
Option1: Setup the commission fee via the constructor upon deployment:

contract Test {
uint256 public fee;
constructor(uint256 _fee) {
require(_fee > 0, "Invalid fee");
fee = _fee;
}
}

Option2: create a function to update fees when needed by owner

uint256 public fee;
function updateFee(uint256 _newFee) external {
require(_newFee >0, "Invalid fee");
fee = _newFee;
}

Support

FAQs

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