Open sherlock-admin opened 1 year ago
Valid, medium severity looks good
@0xleastwood + @xiaoming9090 : Understood from the team that the truncation of dust is no longer necessary. Thus, they have been removed from the codebase. Update made in PR https://github.com/notional-finance/contracts-v2/pull/137
Sherlock note: Classifying this as 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.