The DebtToken::totalSupply
function incorrectly scales the total supply using a division (rayDiv) instead of a multiplication (rayMul) by the normalized debt. This results in an underestimation of the total debt supply, which in turn can lead to inaccurate accounting in the lending pool reserve and potential downstream complications.
The current implementation is:
Since the user's balance function scales the stored value by multiplying with the normalized debt, the totalSupply
should also use a multiplication (rayMul) on the stored scaled total to yield the correct underlying debt amount. Using rayDiv underestimates the debt supply.
Proof of Concept
In DebtToken.test.js
, add or refer to the following test case:
Inaccurate Debt Accounting: The total supply is underestimated, which can lead to an incorrect value for total usage in the reserve struct.
Downstream Miscalculations: Since the total supply is used in risk and liquidation calculations, this error might lead to improper collateralization assessments or liquidation events.
Manual Code Review
Unit Testing with Hardhat/Foundry
Modify the total supply calculation to use multiplication (rayMul) with the normalized debt. Below is the suggested patch:
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.