Submitted by Picodes
https://github.com/code-423n4/2022-06-yieldy/blob/524f3b83522125fb7d4677fa7a7e5ba5a2c0fe67/src/contracts/LiquidityReserve.sol#L126
https://github.com/code-423n4/2022-06-yieldy/blob/524f3b83522125fb7d4677fa7a7e5ba5a2c0fe67/src/contracts/LiquidityReserve.sol#L176
https://github.com/code-423n4/2022-06-yieldy/blob/524f3b83522125fb7d4677fa7a7e5ba5a2c0fe67/src/contracts/LiquidityReserve.sol#L206
Using sandwich attacks and JIT (Just-in-time liquidity), the yield of LiquidityReserve could be extracted for liquidity providers.
The yield of LiquidityReserve is distributed when a user calls instantUnstakeReserve() in Staking. Then, in instantUnstake, totalLockedValue increases with the fee paid by the user withdrawing. The fee is shared between all liquidity providers as they all see the value of their shares increase.
Therefore, an attacker could do the following sandwich attack when spotting a call to instantUnstakeReserve().
The problem here is that you can instantly add and remove liquidity without penalty, and that the yield is instantly distributed.
To mitigate this, you can
0xean (Yieldy) disagreed with severity and commented:
Picodes (warden) commented:
0xean (Yieldy) commented:
Picodes (warden) commented:
moose-code (judge) commented:
