You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there will be rounding error in getCreateAmoint() and getRedeemAmount()
Description
Here the main issue is division is done before multiplication.The value of ethPrice includes oracleDecimals decimal places. To calculate the create amount,it needs to be converted to a base unit by division. This conversion is done when calculating the tvl, which may lead to a loss of precision in subsequent calculations. One possibility is that the calculation result of creationRate is zero, resulting in a division-by-zero error when calculating the create amount.
The function getRedeemAmount has similar precision-loss issues as the function getCreateAmount when calculating the redeem amount, manifested as itpotentially returning zero. One is because converting ethPrice to base units is completed when calculating the tvl, and the other is because PRECISION is multiplied after division when calculating the redeemRate.
Precision loss could render the redeem amount zero, potentially causing transaction failures and diminishing user value.
Mitigation
To mitigate precision loss, prioritize multiplication before division. Additionally, implement ethPrice conversion directly within create and redeem amount calculation processes.
The text was updated successfully, but these errors were encountered:
Expert Iris Stork
High
there will be rounding error in getCreateAmoint() and getRedeemAmount()
Description
Here the main issue is division is done before multiplication.The value of ethPrice includes oracleDecimals decimal places. To calculate the create amount,it needs to be converted to a base unit by division. This conversion is done when calculating the tvl, which may lead to a loss of precision in subsequent calculations. One possibility is that the calculation result of creationRate is zero, resulting in a division-by-zero error when calculating the create amount.
https://github.com/sherlock-audit/2024-12-plaza-finance/blob/14a962c52a8f4731bbe4655a2f6d0d85e144c7c2/plaza-evm/src/Pool.sol#L318C3-L344C4
The function getRedeemAmount has similar precision-loss issues as the function getCreateAmount when calculating the redeem amount, manifested as itpotentially returning zero. One is because converting ethPrice to base units is completed when calculating the tvl, and the other is because PRECISION is multiplied after division when calculating the redeemRate.
https://github.com/sherlock-audit/2024-12-plaza-finance/blob/14a962c52a8f4731bbe4655a2f6d0d85e144c7c2/plaza-evm/src/Pool.sol#L514
Impact
Precision loss could render the redeem amount zero, potentially causing transaction failures and diminishing user value.
Mitigation
To mitigate precision loss, prioritize multiplication before division. Additionally, implement ethPrice conversion directly within create and redeem amount calculation processes.
The text was updated successfully, but these errors were encountered: