Closed c4-bot-9 closed 4 months ago
submission explains about the issue due to which user is unable to withdraw complete balance. All steps are pretty well explained.
Please have a second look. Thanks
Hey @Tri-pathi, thanks for contributing to the PJQA process! This represents a validation repository finding and as such was not evaluated by me directly.
The _amount
argument of the removeAsset
function is in the collateral denomination. As such, the burn amount will be less than the original balance the user acquired when depositing, while the withdrawal will be the full amount.
@alex-ppg
As such, the burn amount will be less than the original balance the user acquired when depositing, while the withdrawal will be the full amount.
Yes, it will withdraw the amount
completely, but the user will be unable to exit completely from Predy. A complete exit means the total bond tokens of the user should be zero in the protocol, but with the current implementation, it is not possible. Every user will have some dust bond tokens remaining.
Hey @Tri-pathi, thank you for your feedback. I do not foresee any high-risk or medium-risk impact arising from having dust of the Predy tokens in one's account. As such, this cannot constitute an HM vulnerability and would be at-best a QA issue. Based on this fact, the submission will remain in the validation repository and no further feedback is expected.
Lines of code
https://github.com/code-423n4/2024-05-predy/blob/main/src/PredyPool.sol#L237
Vulnerability details
Summary
The
PredyPool:withdraw()
function is used to withdraw either thequoteToken
or thebaseToken
from the lending pool. However, due to a rounding issue, lenders are unable to completely exit the poolImpact
Lenders are unable to exit completely from the PredyPool
Proof of Concept
https://github.com/code-423n4/2024-05-predy/blob/main/src/PredyPool.sol#L222 Lender supply the tokens via supply method and get equivalent bond shares which represent their actual balance in the predypool.
Alice is a lender and supplies amount tokens to the
PredyPool
Alice will receive
(amount * 1e18) / (tokenState.assetScaler)
bond tokens in return, referred to asaliceTotalBondShares
The
tokenState.assetScaler
increases after every deposit, withdrawal, and trade. Hence, at any time, the maximum amount of assets a lender can withdraw can be viewed bygetAvailableCollateralValue()
At any time, Alice should be able to withdraw
(total Alice's bond tokens * tokenState.assetScaler) / 1e18
. So, Alice calls thewithdraw
function to withdraw the above amount.predypool.withdraw()
calls removeAsset to compute balances and Alice's total balance.