"Risk free long" attack
Attack
Attacker opens 2 positions (lets assume that 1ETH = 2500USDC)
[Position #1: Long USDC->ETH]: 1000 USDX x5 = 5K USDC -> 2 ETH
[Position #2: Long ETH -> USDC]: 0.4ETH x5 = 2 ETH -> 5000 USDC
Each position has 1.16 heath factor.
Then attacker waits when hf of one position will be ~ 1, and take N
fastCheckOperatins
with minimal allowed (which means decrease in collateral).Then attacker liquidates his account during the same transaction (cause account's and liquidation is more profitable than closing at the case).
Protection
This attack could beneficial only if attarcker could take money from pool, and this amount could be >> gas consumed. To be protected from Gearbox side, at first let's compute maximum possible drop between full health factor check:
The edge case is where , and user has already asset convert to underlying (because all other assets has lower ). Protocol has constraint for for underlying asset
On the other side, the liquidator pays, and we want to construct constraint for drop_max:
so, if we construct limit as:
it will be stronger, because:
So, to make fast check safe, Gearbox has contraint: