Missing Slippage Protection in the Supply Function #223
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-95
grade-c
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
🤖_135_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2024-05-predy/blob/main/src/PredyPool.sol#L222
Vulnerability details
Impact
The current supply function is susceptible to slippage issues. Slippage occurs when there is a difference between the expected price of a trade and the actual price at which the trade is executed. In the context of the supply function, slippage can lead to users receiving fewer bond tokens than anticipated when supplying either the quote or base tokens. This discrepancy can arise due to fluctuations in the market at the time of the transaction.
Proof of Concept
Consider a scenario where a user intends to supply a large amount of the quote token to the pool. Due to the size of the transaction, the supply might affect the pool's balance and, consequently, the interest rates and the bond token minting rate. If the transaction executes without slippage protection, the user might receive fewer bond tokens than expected.
For instance:
Alice supplies 1000 quote tokens.
Expected bond tokens: 950.
Actual Transaction without Slippage Protection:
Market conditions or pool liquidity changes during the transaction.
Alice receives only 900 bond tokens instead of 950.
The user faces an unexpected loss of 50 bond tokens due to slippage.
Tools Used
Manual Review
Recommended Mitigation Steps
Incorporate a mechanism to handle slippage tolerance. This can be achieved by allowing users to specify a minimum acceptable amount of bond tokens they are willing to receive from the transaction, and a deadline.
Assessed type
Context
The text was updated successfully, but these errors were encountered: