Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: medium
Valid

Treasury.sol => Incorrect _totalValue Calculation Due to Token Decimal Mismatch in Treasury

Summary

The Treasury contract's _totalValue aggregates token values without accounting for different token decimals, leading to incorrect total value calculations and potential economic issues.

Vulnerability Details

The Treasury contract maintains a _totalValue variable that tracks the total value of all tokens held. However, it naively adds token amounts without normalizing for decimal differences:

function deposit(address token, uint256 amount) external override nonReentrant {
if (token == address(0)) revert InvalidAddress();
if (amount == 0) revert InvalidAmount();
IERC20(token).transferFrom(msg.sender, address(this), amount);
_balances[token] += amount;
_totalValue += amount; // Direct addition without decimal normalization
emit Deposited(token, amount);
}

Example scenario:

  1. Deposit 1 WBTC (8 decimals) = 100,000,000 (1e8)

  2. Deposit 1 USDC (6 decimals) = 1,000,000 (1e6)

  3. _totalValue = 101,000,000

This is incorrect because:

  • 1 WBTC = 100,000,000 (1e8)

  • 1 USDC = 1,000,000 (1e6)

  • The values are added directly without considering their different decimal bases

  • Results in meaningless total that doesn't represent actual value

Impact

  1. Incorrect Total Value Reporting: The getTotalValue() function returns inaccurate aggregated values

  2. Skewed Protocol Metrics: Any protocol decisions or calculations based on _totalValue will be incorrect

  3. Economic Implications: If protocol uses _totalValue for:

    • Fee calculations

    • Risk assessments

    • Protocol health metrics

    • Treasury-based decisions
      All would be based on incorrect data

Severity: MEDIUM

  • Doesn't lead to direct fund loss

  • But affects protocol metrics and decision-making

  • Could indirectly impact economic decisions

Tools Used

Manual Review

Recommendations

Track values separately:

mapping(address => uint256) private _tokenValues;
mapping(address => uint8) private _tokenDecimals;
  1. Consider adding:

    • Decimal tracking for each token

    • Value normalization functions

    • Clear documentation about value representations

    • Separate getters for normalized and raw values

Updates

Lead Judging Commences

inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Treasury::deposit increments _totalValue regardless of the token, be it malicious, different decimals, FoT etc.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.