Here maxSwapAmount is based solely on the initialLiquidity of the pool, but the liqudity of the pool will vary after each swap.
It means that maxSwapAmount should also vary accordingly to the liquidity available in the pool at the time of the swap.
With this code we have some issues :
1. If LPs add liquidity after launch
initialLiquidity is too low
maxSwapAmount is artificially low
=> excessive penalties
2. If liquidity is removed
initialLiquidity is too high
maxSwapAmount becomes overly permissive
=> limits can be bypassed
=> potential exploitation during phase 1 / 2
3. If the first swap happens before all intended liquidity is in place
This is the most critical case:
--> a bot triggers a micro-swap, initialLiquidity is locked in at a very low value.
All subsequent phases are permanently broken.
Likelihood: High
Impact: High
Foundry Test :
Use currentLiquidity instead of initialLiquidity :
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.
The contest is complete and the rewards are being distributed.