We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loss of funds
EthosBouch::calcFee
Dapper Chartreuse Wolf
High
Calculating Fee as Floor makes huge funds loss for the protocol. EthosVouch::calcFee
Floor
Because if the calculation becomes 1.5 then it will be floor to 1 If we consider this for a lot of calls then it makes a huge impact on the protocol.
1.5
1
Here is the code EthosVouch::calcFee
function calcFee(uint256 total, uint256 feeBasisPoints) internal pure returns (uint256 fee) { /* * Formula derivation: * 1. total = deposit + fee * 2. fee = deposit * (feeBasisPoints/10000) * 3. total = deposit + deposit * (feeBasisPoints/10000) * 4. total = deposit * (1 + feeBasisPoints/10000) * 5. deposit = total / (1 + feeBasisPoints/10000) * 6. fee = total - deposit * 7. fee = total - (total * 10000 / (10000 + feeBasisPoints)) */ return total - (total.mulDiv(BASIS_POINT_SCALE, (BASIS_POINT_SCALE + feeBasisPoints), Math.Rounding.Floor)); <@ }
Make Floor to Ceil
function calcFee(uint256 total, uint256 feeBasisPoints) internal pure returns (uint256 fee) { /* * Formula derivation: * 1. total = deposit + fee * 2. fee = deposit * (feeBasisPoints/10000) * 3. total = deposit + deposit * (feeBasisPoints/10000) * 4. total = deposit * (1 + feeBasisPoints/10000) * 5. deposit = total / (1 + feeBasisPoints/10000) * 6. fee = total - deposit * 7. fee = total - (total * 10000 / (10000 + feeBasisPoints)) */ - return - total - - (total.mulDiv(BASIS_POINT_SCALE, (BASIS_POINT_SCALE + feeBasisPoints), Math.Rounding.Floor)); + return + total - + (total.mulDiv(BASIS_POINT_SCALE, (BASIS_POINT_SCALE + feeBasisPoints), Math.Rounding.Ceil)); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Dapper Chartreuse Wolf
High
There is
loss of funds
inEthosBouch::calcFee
Impact
Calculating Fee as
Floor
makes huge funds loss for the protocol. EthosVouch::calcFeeBecause if the calculation becomes
1.5
then it will be floor to1
If we consider this for a lot of calls then it makes a huge impact on the protocol.
PoC
Here is the code
EthosVouch::calcFee
Mitigation
Make Floor to Ceil
The text was updated successfully, but these errors were encountered: