This repository has been archived by the owner on Nov 19, 2023. It is now read-only.
xiaoming90 - Secondary debt dust balances are not truncated #210
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
medium
Secondary debt dust balances are not truncated
Summary
Dust balances in primary debt are truncated toward zero. However, this truncation was not performed against secondary debts.
Vulnerability Detail
https://github.com/sherlock-audit/2023-03-notional-0xleastwood/blob/main/contracts-v2/contracts/internal/vaults/VaultAccount.sol#L231
vaultState.totalDebtUnderlying
is primarily used to track the total debt of primary currency. Within theupdateAccountDebt
function, any dust balance in thevaultState.totalDebtUnderlying
is truncated towards zero at the end of the function as shown above.https://github.com/sherlock-audit/2023-03-notional-0xleastwood/blob/main/contracts-v2/contracts/internal/vaults/VaultSecondaryBorrow.sol#L304
However, this approach was not consistently applied when handling dust balance in secondary debt within the
_updateTotalSecondaryDebt
function. Within the_updateTotalSecondaryDebt
function, the dust balance in secondary debts is not truncated.Impact
The inconsistency in handling dust balances in primary and secondary debt could potentially lead to discrepancies in debt accounting within the protocol, accumulation of dust, and result in unforeseen consequences.
Code Snippet
https://github.com/sherlock-audit/2023-03-notional-0xleastwood/blob/main/contracts-v2/contracts/internal/vaults/VaultSecondaryBorrow.sol#L304
Tool used
Manual Review
Recommendation
Consider truncating dust balance in secondary debt within the
_updateTotalSecondaryDebt
function similar to what has been done for primary debt.The text was updated successfully, but these errors were encountered: