getPriceOfOneWethInPoolTokens
is supposed to return the price of 1 WETH in terms of pool tokens, and TSwapPool::getPriceOfOnePoolTokenInWeth
is supposed to return the price of 1 pool token in terms of WETH. However, the return values are incorrect. Both functions return the amount of output tokens, which is not the same as the price of 1 output token in input tokens. (Consider this: as compared to a fee-less protocol, if there are fees, the amount of output tokens should be lower, while the price should be not lower but higher.)
Proof of concept: consider the following scenario:
A user has 1 WETH, and wants to swap it for pool tokens.
The user calls getPriceOfOneWethInPoolTokens
and sees an incorrect price that is the inverse of the actual price.
User finds the price appealing and swaps his WETH.
User ends up with a lot less pool tokens than he expected.
Proof of code: Insert this piece of code to TSwapPool.t.sol
(note that it demonstrates a different scenario than the one written under "Proof of Concept"):
User will think that the WETH / pool token is cheaper that it actually is, and they might make their trading decisions based on this incorrect price information. E.g. they might think the price of their token is falling, might panic and sell their tokens to avoid further losses by calling sellPoolTokens()
.
Manual review, Foundry.
Perform the following changes:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.