The createScalarMarket function uses an outcomeSlotCount parameter that defines the number of outcome slots available for a scalar market. This parameter currently only accounts for three possible outcomes: two standard outcomes and one reserved for the INVALID result. However, the scalar market setup also requires an additional slot for the UNRESOLVED_ANSWER outcome. This discrepancy in the slot count may cause unexpected behavior or incorrect outcome handling in the market.
Attachments
Proof of Concept (PoC)
function createScalarMarket(CreateMarketParams calldata params) external returns (address) {
require(params.upperBound > params.lowerBound, "upperBound must be higher than lowerBound");
// values reserved by Reality for INVALID and UNRESOLVED_ANSWER.
require(params.upperBound < type(uint256).max - 2, "upperBound must be less than uint256.max - 2");
require(params.outcomes.length == 2, "Outcomes count must be 2");
string[] memory encodedQuestions = new string[](1);
encodedQuestions[0] = encodeRealityQuestionWithoutOutcomes(params.marketName, params.category, params.lang);
return createMarket(
params,
params.marketName,
InternalMarketConfig({
encodedQuestions: encodedQuestions,
@> outcomeSlotCount: 3, // additional outcome for Invalid Result.
templateId: REALITY_UINT_TEMPLATE
})
);
}
Revised Code
To ensure all possible outcomes are represented correctly, the outcomeSlotCount parameter should be set to four, which includes both the standard outcomes and the two reserved outcomes. It is recommended to review and adjust the outcomeSlotCount parameter accordingly to accurately represent all potential outcomes for the scalar market.
function createScalarMarket(CreateMarketParams calldata params) external returns (address) {
require(params.upperBound > params.lowerBound, "upperBound must be higher than lowerBound");
// values reserved by Reality for INVALID and UNRESOLVED_ANSWER.
require(params.upperBound < type(uint256).max - 2, "upperBound must be less than uint256.max - 2");
require(params.outcomes.length == 2, "Outcomes count must be 2");
string[] memory encodedQuestions = new string[](1);
encodedQuestions[0] = encodeRealityQuestionWithoutOutcomes(params.marketName, params.category, params.lang);
return createMarket(
params,
params.marketName,
InternalMarketConfig({
encodedQuestions: encodedQuestions,
-- outcomeSlotCount: 3, // additional outcome for Invalid Result.
++ outcomeSlotCount: 4, // additional outcomes for Invalid and Unresolved_Answer Result.
templateId: REALITY_UINT_TEMPLATE
})
);
}
Github username: -- Twitter username: -- Submission hash (on-chain): 0xa3d4e5242323ee490da9b267496747be8cba6ec6bc304ffa57160a721a7d3581 Severity: low
Description: Description
The
createScalarMarket
function uses anoutcomeSlotCount
parameter that defines the number of outcome slots available for a scalar market. This parameter currently only accounts for three possible outcomes: two standard outcomes and one reserved for theINVALID
result. However, the scalar market setup also requires an additional slot for theUNRESOLVED_ANSWER
outcome. This discrepancy in the slot count may cause unexpected behavior or incorrect outcome handling in the market.Attachments
outcomeSlotCount
parameter should be set to four, which includes both the standard outcomes and the two reserved outcomes. It is recommended to review and adjust theoutcomeSlotCount
parameter accordingly to accurately represent all potential outcomes for the scalar market.