The Treasury.sol contract documentation states that it supports multi-token deposits. Given this claim, the contract is expected to work seamlessly with various ERC-20 tokens. However, an issue has been identified:
The _totalValue variable is updated incorrectly without considering token decimals, leading to inaccurate treasury value calculations.
_totalValue Calculation Due to Token Decimal DifferencesThe contract updates _totalValue as _totalValue += amount;, but it does so without considering that different tokens have different decimals. For example:
USDC and USDT use 6 decimals (1 USDC = 1 * 10^6 in raw units).
DAI and ETH-based tokens use 18 decimals (1 DAI = 1 * 10^18).
Summing these raw values directly leads to inaccurate treasury value calculations.
Misleading Treasury Value: The contract may overestimate or underestimate its total value, leading to incorrect financial decision-making.
Incorrect Treasury Valuation: Governance or fund allocation decisions could be made based on incorrect data, affecting protocol sustainability.
Risk of Incorrect Balance Accounting: The contract might reflect a deposit that never actually occurred, leading to misreported treasury holdings.
Manual Code Review
Normalize _totalValue Based on Token Decimals
Introduce a mapping decimals to store the decimal count of each token.
Convert all values to a standard 18-decimal format before updating _totalValue.
Example fix:
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.