UNIT LP holders can sandwich leverage traders closing their positions and avoid price impact.
Summary
Liquidity providers can avoid price impact by sandwiching both announce and execute functions from leverage traders to close their positions.
They can write script which does everything for them and avoid the price impact to be bear by the other users.
Vulnerability Detail
The problem is that a large liquidity provider can build a script to front run and then backrun announceLeverageClose(), and also execute the trader close request as keeper.
Front run announceLeverageClose() with announceStableWithdraw()
Back run announceLeverageClose() with _executeStableWithdraw()
Execute _executeLeverageClose() as a keeper
Then deposit again
Impact
LP can avoid paying the trader when he is on profit.
SBSecurity
high
UNIT LP holders can sandwich leverage traders closing their positions and avoid price impact.
Summary
Liquidity providers can avoid price impact by sandwiching both announce and execute functions from leverage traders to close their positions.
They can write script which does everything for them and avoid the price impact to be bear by the other users.
Vulnerability Detail
The problem is that a large liquidity provider can build a script to front run and then backrun
announceLeverageClose()
, and also execute the trader close request as keeper.announceLeverageClose()
withannounceStableWithdraw()
announceLeverageClose()
with_executeStableWithdraw()
_executeLeverageClose()
as a keeperImpact
LP can avoid paying the trader when he is on profit.
Code Snippet
https://github.com/sherlock-audit/2023-12-flatmoney/blob/bba4f077a64f43fbd565f8983388d0e985cb85db/flatcoin-v1/src/DelayedOrder.sol#L317-L368
Tool used
Manual Review
Recommendation
It's hard to give a proper recommendation, maybe lock LPs tokens when there will be a long position close.