This repository has been archived by the owner on Nov 19, 2023. It is now read-only.
xiaoming90 - Vault account might not be able to exit after liquidation #192
Labels
Medium
A valid Medium severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
xiaoming90
high
Vault account might not be able to exit after liquidation
Summary
The vault exit might fail after a liquidation event, leading to users being unable to main their positions.
Vulnerability Detail
Assume that a large portion of the vault account gets liquidated which results in a large amount of cash deposited into the vault account's cash balance. In addition, interest will also start accruing within the vault account's cash balance.
Let$x$ be the
primaryCash
of a vault account after a liquidation event and interest accrual.The owner of the vault account decided to exit the vault by calling$x$ .
exitVault
. Within theexitVault
function, thevaultAccount.tempCashBalance
will be set toNext, the$-y$ ($x + (-y) \Rightarrow x - y$ . If $x > y$ , then the new
lendToExitVault
function is called. Assume that the cost in prime cash terms to lend an offsetting fCash position isprimeCashCostToLend
). TheupdateAccountDebt
function will be called, and thevaultAccount.tempCashBalance
will be updated tovaultAccount.tempCashBalance
will be more than zero.Subsequently, the
redeemWithDebtRepayment
function will be called. However, sincevaultAccount.tempCashBalance
is larger than zero, the transaction will revert, and the owner cannot exit the vault.https://github.com/sherlock-audit/2023-03-notional/blob/main/contracts-v2/contracts/internal/vaults/VaultConfiguration.sol#L429
Impact
The owner of the vault account would not be able to exit the vault to main their position. As such, their assets are stuck within the protocol.
Code Snippet
https://github.com/sherlock-audit/2023-03-notional/blob/main/contracts-v2/contracts/internal/vaults/VaultConfiguration.sol#L429
Tool used
Manual Review
Recommendation
Consider refunding the excess positive
vaultAccount.tempCashBalance
to the users so thatvaultAccount.tempCashBalance
will be cleared (set to zero) before calling theredeemWithDebtRepayment
function.The text was updated successfully, but these errors were encountered: