The decimals()
function is not a part of the ERC-20 standard, and was added later as an optional extension. As such, some valid ERC20 tokens do not support this interface, so it is unsafe to blindly cast all tokens to this interface, and then call this function.
The ERC-20 standard does not mandate the implementation of symbol() and decimals() functions. If a collateral token does not support these functions, any attempt to retrieve this data in _registerCollateralToken
will fail, leading to a contract revert.
The function relies on IERC20Metadata to fetch symbol()
and decimals()
assuming all tokens comply with this extended interface.
A revert due to missing functions could prevent certain ERC-20 tokens from being registered, limiting the system’s flexibility.
This could introduce compatibility issues particularly with tokens that adhere strictly to ERC-20 but do not implement IERC20Metadata.
Fallback Mechanism
Implement a try-catch block or alternative method to handle cases where symbol() or decimals() are missing.
Default to predefined values or allow manual input when the functions are absent.
Pre-validation Before Registration
Verify if a token implements IERC20Metadata before calling its methods.
Use supportsInterface() or a similar method to check for compliance.
Whitelist Approach
Allow only collateral tokens known to have symbol() and decimals(), maintaining a registry of verified tokens.
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.