The extra tokens given to users as an incentive in the TSwapPool::_swap function disrupt the protocol's invariant of x * y = k, leading to a risk of protocol funds being drained over time.
The TSwapPool protocol adheres to a strict invariant x * y = k, where:
x: The balance of the pool token
y: The balance of WETH
k: The constant product of the two balances
This invariant ensures that the product of the balances of pool tokens and WETH remains constant after each swap. However, in the _swap function, users receive extra tokens after every swap_count reaches SWAP_COUNT_MAX. This breaks the invariant, allowing users to drain the protocol funds by repeatedly swapping and collecting the extra tokens.
A malicious user can exploit this mechanism by performing a large number of swaps to continuously collect the extra incentive tokens, potentially draining the protocol's funds.
Manual code review
The simplest solution is to remove the extra incentive mechanism entirely. This will ensure that the protocol maintains its invariant without any additional complexities.
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.