Skip to content
New issue

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

Expert Iris Stork - there will be rounding error in getCreateAmoint() and getRedeemAmount() #1033

Open
sherlock-admin2 opened this issue Jan 23, 2025 · 0 comments

Comments

@sherlock-admin2
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant