First Flight #18: T-Swap

First Flight #18
Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: high
Invalid

Bad Pool tokens to deposit calculation in `getPoolTokensToDepositBasedOnWeth(...)`

Summary

Bad Pool tokens to deposit calculation in getPoolTokensToDepositBasedOnWeth(...) in TSwapPool.

Vulnerability Details

Bad math in getPoolTokensToDepositBasedOnWeth(...), this calculation was explained in the comments of deposit(...), but it's not mathematically correct.
Same issue for LiquidityTokens

Impact

Some of the impact are, DoS with a deposit(...) function reverting, bad amount of pool tokens provided for liquidity.

Tools Used

Manual review

Recommendations

function getPoolTokensToDepositBasedOnWeth(
uint256 wethToDeposit
) public view returns (uint256) {
uint256 poolTokenReserves = i_poolToken.balanceOf(address(this));
uint256 wethReserves = i_wethToken.balanceOf(address(this));
- return (wethToDeposit * poolTokenReserves) / wethReserves;
+ return (wethToDeposit * wethReserves) / (wethReserves + poolTokenReserves) - poolTokenReserves;
}
Updates

Appeal created

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Too generic

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.