In ChainlinkUtil
, when the getPrice
function is called to query the provided Chainlink Price Feed for the margin collateral oracle price, there is no explicit check for the price being equal to zero. Consequently, getPrice
can return 0
.
The problem arises when deductAccountMargin
is called. This function calls marginCollateralConfiguration.getPrice()
to obtain the collateral's USD price, which is saved in ctx.marginCollateralPriceUsdX18
. This value is then passed to withdrawMarginUsd
. Within withdrawMarginUsd
, a division occurs: UD60x18 requiredMarginInCollateralX18 = amountUsdX18.div(ctx.marginCollateralPriceUsdX18);
. This can lead to a division by zero error.
A division by zero error will occur, which, in newer versions of Solidity, will cause the transaction to revert. This can lead to a temporary DoS for the liquidateAccounts
and fillMarketOrder
functions.
Do note that if (answer <= minAnswer || answer >= maxAnswer) {
check doesn't stop the price from returning 0
because minAnswer is int192
datatype and can save negative values, so for fixing this issue add a check in getPrice
to handle the case where answer
is equal to zero. This early return with a proper error will prevent the division by zero case.
In ChainlinkUtil
:
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.