First Flight #18: T-Swap

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

Donate tokens

Summary

Attacker donate tokens to inflate the value of poolToken in the pool, liquidity provider must provide more tokens to get the same LP.

Vulnerability Details

The function that calculate required amount of tokens to deposit does not account for donations, this cause the protocol to ask users to send more tokens to get the same LP tokens amount.

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;
}

Impact

Extra cost for liquidity providers

Tools Used

Unit test

Recommendations

Cache the poolTokens reserve in the contract and update it after deposit.

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Too generic
agent3bood Submitter
about 1 year ago
inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Too generic

Support

FAQs

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