Rounding Issues In Certain Functions #644
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-34
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2023-09-centrifuge/blob/main/src/InvestmentManager.sol#L370
https://github.com/code-423n4/2023-09-centrifuge/blob/main/src/InvestmentManager.sol#L383
Vulnerability details
Background
Per EIP 4626’s Security Considerations:
Proof of Concept
The current implementation of previewDeposit function will round down the number of shares returned due to this calculation here at function _calculateTrancheTokenAmount
ERC 4626 expects the result returned from previewWithdraw function to be rounded up. However the function _calculateTrancheTokenAmount returns it rounded UP.
Also, the function previewMint has the same problem calling the function _calculateCurrencyAmount
Impact
Other protocols that integrate with Centrifuge's Pools might wrongly assume that the functions handle rounding as per ERC4626 expectation. Thus, it might cause some intergration problem in the future that can lead to wide range of issues for both parties.
Tools Used
VS Code, Manual Review
Recommended Mitigation Steps
Ensure that the rounding of vault’s functions behave as expected. Following are the expected rounding direction for each vault function:
Since the functions: _calculateTrancheTokenAmount and _calculateCurrencyAmount are used in other functions, maybe the way is to create another functions (or a flag) to round up the shares for previewMint and previewWithdraw.
Assessed type
ERC4626
The text was updated successfully, but these errors were encountered: