In TswapPool::_swap
the extra tokens given to users after every swapCount
breaks the protocol invariant of x * y = k
The protocol follows a strict invariant of x * y = k
, where
x
: The balance of the pool token in the pool
y
: The balance of WETH in the pool
k
: The constant product of the 2 balances
This means that whenever the balances change in the protocol, the ratio between the two amounts should remain constant, hence the k
. However, this is broken due to the extra incentive (a full extra token after every 10 swaps) in the _swap
function, meaning that over time the protocol funds would be drained.
The following block of code is responsible for the issue.
A user swaps 10 times and collects the extra incentive of 1 token (1_000_000_000_000_000_000
)
The usercontinues to swap until all the protocol funds are drained.
Consider the following proof of code:
A user could maliciously drain the protocol of funds by doing a lot of swaps and collecting the extra incentive (a full extra token after every 10 swaps) given out by the protocol.
More simply put, the core invariant of the protocol is broken.
Manual review, Foundry.
Remove the extra incentive mechanism. If you want to keep this nonetheless, you should account for the change in the x * y = k
invariant. Alternatively, you could set aside tokens the same way you did with fees.
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.