Invariance break for the calculation of ∆y
.
The documentation specifies that the following invariance must be met: ∆y = (αγ/1+αγ) * y
.
However, when calculating values using the function TSwapPool::getOutputAmountBasedOnInput
there are cases in which it breaks.
The swapping does not follow the invariance in the documentation which leads to taking fee that is not as the documentation specifies.
This means that the token pool balance is not as expected and does follow the documentation invariance with fees.
Manual Review
Add the following test case to TSwapPool.t.sol
:
Run the command: forge test --mt testInvarianceBreak -vvvvv
Check that the expected deltaY does not equal to the actual one. For this example the output will be:
Rewrite the calculation of the methods TSwapPool::getOutputAmountBasedOnInput
and TSwapPool::getInputAmountBasedOnOutput
is a way that follows the invariances with fees specified in the documentation:
∆x = (β/(1-β)) * (1/γ) * x
∆y = (αγ/1+αγ) * y
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.