Some positions will get liquidated immediately #1180
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
H-04
primary issue
Highest quality submission among a set of duplicates
selected for report
This submission will be included/highlighted in the audit report
upgraded by judge
Original issue severity upgraded from QA/Gas by judge
Lines of code
https://github.com/code-423n4/2023-04-rubicon/blob/main/contracts/utilities/poolsUtility/Position.sol#L316-L317
Vulnerability details
Description
When opening a position the user makes a deposit and takes a loan against this on the Rubicon compound fork. This loan is taken using max liquidity:
https://github.com/code-423n4/2023-04-rubicon/blob/main/contracts/utilities/poolsUtility/Position.sol#L306-L319
The danger here is that the interest rate for a loan needs to be higher than the interest for the deposit of the collateral. Hence the block after the loan is taken it will be under water.
Impact
Positions opened will in the block after they are created become under water and possible to liquidate.
This only impacts a certain set of leverages (shorts 1x, longs 1.7x and so on) where you loan up to your collateral max, hence medium.
A user will have to know about this behavior in Position and in the same tx (to be safe) increase their margin to not be vulnerable to liquidation.
Proof of Concept
PoC test,
PositionTest.t.sol
:closeFactor
andliquidationIncentive
is the same as compound on mainnet.Added a mint function in the
TokenWithFaucet
:Tools Used
manual audit, forge
Recommended Mitigation Steps
Introduce a safety factor to scale the loans with that the user can provide when opening the position.
The text was updated successfully, but these errors were encountered: