The GlobalConfigurationBranch
includes a function call to ERC20(collateralType).decimals()
, which assumes that the decimals
function is implemented for all ERC20 tokens (referred to as collateral types in this context). However, the decimals
function is optional in the ERC20 standard, potentially causing the configureMarginCollateral
function to revert when interacting with tokens that do not implement this function.
While most ERC20 assets implement the decimals
function, it is not mandated by the ERC20 standard. Consequently, a small subset of ERC20 tokens is incompatible with the current implementation, leading to potential transaction failures and an inability to support these tokens.
If the collateral type does not implement the decimals
function, the function will catch this failure and revert with an InvalidMarginCollateralConfiguration
error. This prevents the function from configuring such tokens as margin collateral.
Only tokens that implement the decimals
function can be used as collateral. This limits the contract's flexibility and compatibility with the full spectrum of ERC20 tokens.
To support all ERC20 collateral types, consider one of the following approaches:
Optional decimals
query with fallback:
First, attempt to call the decimals
function.
If the call fails, allow the user to provide the decimals value as an input argument.
Require decimals
as an input argument:
Modify the function to always require the decimals value to be supplied as an argument.
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.