Wrong calculation in LendingPool::borrow
function leads to users being able to borrow 20% more value in reserve assets than their nft collateral value. This makes the user insolvent, giving the protocol bad debt while the user goes away with his 20% profit.
In LendingPool::initiateLiquidation
function we check to se if a users healthFactor is below liquidationThreshold. We do this by calling the calculateHealthFactor
function of the user. This function gets the users debt and 80% of their collateral value to be collateralThreshold
used in Health factor calculations:
If userDebt
in this function is more than 80% of their collateral, this function will return less than 1e18 meaning their position is liquidatable in the LendingPool::initializeLiquidation
function:
This is all good, however in the LendingPool::borrow
function users can borrow themself in debt beyond liquidatable all the way to insolvent! This is possible due to a miscalculation in the borrow function. What we should be doing in the borrow function is the same as in the initiateLiquidation function: scale down collateralValue to 80% and make sure debt is lower than that. Instead we do the opposite. We make sure 100% of the collateralValue is more than a 80% scaled down user debt:
Due to this miscalculation in the if logic. Users can borrow a maximum of 20% above their collateralValue
. Meaning they have gone past liquidatable, all the way to insolvent. Giving the protocol bad debt. The function then proceeds to mint the user the debt tokens and transfer the borrowed assets to the user.
raacNFT owners can borrow 20% more value than their collateral value giving the protocol bad debt.
Lets say the user raacNFT is worth 100 USD.
The user calls the LendingPool::depositNFT
Then the user call LendingPool::borrow
with amount
== 119.
The function then gives him 119 reserve assets.
He or someone else starts LendingPool::initiateLiquidation
He gets liquidated, loosing his 100 USD worth of raacNFT
he is left with 119 reserve asset. Which leaves him in a profit of 19 USD.
change this line in LendingPool::borrow
to make sure users cant borrow themself into liquidation
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.