Precision handling and division by zero in BaseLSTAdapter.sol
Summary
There are issues related to precision handling and division by zero, which could lead to unexpected behavior or errors in the BaseLSTAdapter.sol
Vulnerability Detail
Precision and Division by Zero: Division operations without checks for division by zero. This could lead to a revert if totalAssets() or BUFFER_PERCENTAGE_PRECISION returns zero. Additionally, precision loss may occur due to integer division in Solidity, which could affect the accuracy of calculations like targetBufferEth.
Precision in Calculating targetBufferEth: The calculation of targetBufferEth involves division, which could lead to precision loss. This is particularly concerning because the calculation is critical for managing the buffer's size, which directly affects the system's behavior.
Impact
If division by zero occurs, the contract could revert unexpectedly. This could disrupt operations and potentially lead to loss of funds.
Precision loss in calculating targetBufferEth could result in the buffer not being managed accurately. This could affect the contract's ability to maintain the desired buffer size, potentially leading to suboptimal performance or even financial losses.
Implement checks to ensure that totalAssets() and BUFFER_PERCENTAGE_PRECISION are never zero before performing the division. Use a conditional statement to check for zero values before the division operation.
Manage the values used in the calculation of targetBufferEth to avoid extreme values that could lead to imprecise results. This could involve ensuring that totalAssets(), assets, and targetBufferPercentage are within expected ranges.
Rhaydden
medium
Precision handling and division by zero in BaseLSTAdapter.sol
Summary
There are issues related to precision handling and division by zero, which could lead to unexpected behavior or errors in the BaseLSTAdapter.sol
Vulnerability Detail
totalAssets()
orBUFFER_PERCENTAGE_PRECISION
returns zero. Additionally, precision loss may occur due to integer division in Solidity, which could affect the accuracy of calculations liketargetBufferEth
.targetBufferEth
: The calculation oftargetBufferEth
involves division, which could lead to precision loss. This is particularly concerning because the calculation is critical for managing the buffer's size, which directly affects the system's behavior.Impact
targetBufferEth
could result in the buffer not being managed accurately. This could affect the contract's ability to maintain the desired buffer size, potentially leading to suboptimal performance or even financial losses.Code Snippet
https://github.com/sherlock-audit/2024-01-napier/blob/main/napier-v1/src/adapters/BaseLSTAdapter.sol#L100
Tool used
Manual Review
Recommendation