DeFiFoundrySolidity
16,653 OP
View results
Submission Details
Severity: low
Invalid

Potential Issue with Token Decimals Leading to Miscalculations

Description

The contract assumes that the asset and underlying tokens have 18 decimals (as is standard for alETH and WETH). However, if the tokens were to have different decimal places, calculations involving amounts and balances might lead to incorrect results.

Impact

  • Miscalculations: Differences in token decimals can cause miscalculations in swaps, deposits, and withdrawals, leading to potential financial discrepancies.

  • Compatibility Issues: If the contract is reused or modified to interact with tokens having different decimals, it may not function correctly.

Recommendation

  • Validate Token Decimals: Add checks to ensure that the tokens have expected decimal places, or adjust calculations to account for varying decimals.

    uint8 constant EXPECTED_DECIMALS = 18;
    constructor(
    address _asset,
    address _transmuter,
    string memory _name
    ) BaseStrategy(_asset, _name) {
    // ...
    require(asset.decimals() == EXPECTED_DECIMALS, "Unexpected asset decimals");
    require(underlying.decimals() == EXPECTED_DECIMALS, "Unexpected underlying decimals");
    // ...
    }
Updates

Appeal created

inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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