sherlock-audit / 2024-05-napier-update-judging

8 stars 7 forks source link

Wrong percentage calculation #95

Closed sherlock-admin3 closed 5 months ago

sherlock-admin3 commented 5 months ago

Wrong percentage calculation

Low/Info issue submitted by NoOne

Summary

In Solidity would not directly compile because Solidity does not recognize 0.1 or 0.01 as a valid number for computation in its native types. Solidity does not support real numbers or floating-point arithmetic directly.

Vulnerability Detail

In Solidity, when assigning such values to state variables or manipulating them in smart contracts, ensure you handle these scaled integers consistently across all calculations to avoid precision errors or overflow/underflow bugs.

Impact

Code Snippet

function __BaseLSTAdapter_init

BaseLSTVault.sol

BaseLSTVault.sol

Tool used

Manual Review

Recommendation

use this $.targetBufferPercentage = 10**17 for $.targetBufferPercentage

use this targetBufferPercentage = 10**17 for targetBufferPercentage

and this MIN_BUFFER_PERCENTAGE = 1e16 for MIN_BUFFER_PERCENTAGE