Submitted by cccz, also found by sinarette.
All leveraged positions are opened by simple recursive borrowing loop (supply collateral  borrow  swap  repeat).
The issue here is that the last borrowed asset will not be collateralized.
Consider the WBTC collateralization rate is 0.7.
Alice uses 1e8 WBTC and 1.7x leverage to long WBTC
In _borrowLoop, 1e8 WBTC is collateralized and borrowed to USDC, and 0.7e8 WBTC is purchased using USDC, and the 0.7e8 WBTC is uncollateralized. At this point, the users collateral is 1e8 WBTC and the borrowed USDC is worth 0.7e8 WBTC. If the price of WBTC drops slightly, the user will be liquidated.
The POC below indicates the purchased WBTC is not collateralized:
https://github.com/code-423n4/2023-04-rubicon/blob/511636d889742296a54392875a35e4c0c4727bb7/contracts/utilities/poolsUtility/Position.sol#L251-L269 https://github.com/code-423n4/2023-04-rubicon/blob/511636d889742296a54392875a35e4c0c4727bb7/contracts/utilities/poolsUtility/Position.sol#L183-L192
Hardhat
When the loop in openPosition ends, collateralize the remaining assets in the contract.
daoio (Rubicon) confirmed
