getTokenAmountFromUsd()
returns (usdAmountInWei * PRECISION) / (uint256(price) * ADDITIONAL_FEED_PRECISION);
. This will revert if the denominator (uint256(price) * ADDITIONAL_FEED_PRECISION)
exceeds type(uint256).max
.
Considering Chainlink TOKEN/USD price feed to have precision of 8 decimals, (uint256(price) * ADDITIONAL_FEED_PRECISION)
will exceed type(uint256).max
if dollar price of TOKEN is more than 115792089237316195423570985008687907853269984665640564039457
and revert.
To reduce such an occurrence, one can return this instead: (usdAmountInWei * PRECISION) / uint256(price) / ADDITIONAL_FEED_PRECISION;
.
Current syntax causes overflow for very large USD price of a token and always reverts, blocking all liquidation attempts.
Manual review
Use syntax: (usdAmountInWei * PRECISION) / uint256(price) / ADDITIONAL_FEED_PRECISION;
.
OR, return 0;
when price
exceeds the threshold.
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.