#39271 [SC-Insight] Check `numericAnswer` before external call to check answer is valid or not
Description
Vulnerability Detail
function resolve() external {
bytes32 answer = oracleAdapter.getAnswer(questionId);
uint256[] memory payouts = new uint256[](outcomeCount + 1);
uint256 numericAnswer = uint256(answer);
//@audit - gas: numericAnswer is already typecasted answer. So check numericAnswer first to 0, such that there is no external call required if numericAnswer is 0 as oracle updater going to return false for answer if its uint is zero.
if (oracleAdapter.isInvalid(answer) || numericAnswer == 0) {
// 'Invalid' receives full payout
payouts[outcomeCount] = 1;
} else {
// Each bit (i-th) in numericAnswer indicates if outcome i is 1 or 0
for (uint256 i = 0; i < outcomeCount; i++) {
payouts[i] = (numericAnswer >> i) & 1;
}
}
conditionalTokens.reportPayouts(questionId, payouts);
}Proof of Concept
Proof of Concept
Previous#39243 [SC-Insight] Misleading Comment in merge Function Regarding Token Transfers to wrapped1155FacNext#39487 [SC-Insight] flatCfmImplementation and conditionalScalarMarketImplementation contracts can be
Last updated
Was this helpful?