Variables
conditionalTokens
realitio
INVALID_RESULT
REALITY_UINT_TEMPLATE
REALITY_SINGLE_SELECT_TEMPLATE
REALITY_MULTI_SELECT_TEMPLATE
Functions
constructor
resolve
Pre-condition
This market reality questions must be finalized. If there is a reopened question, that question need to be finalized instead.
Logic
- From the provided market contract, hash back the original
questionIdfromquestionsIds,outcomes.length,templateId,lowerBound,upperBound. - Call one of the 4 internal resolution functions corresponding to 4 market types, passing
questionId,questionsIds, as well asnumOutcomesorlow,highdepending on the market type.
resolveCategoricalMarket
Pre-condition
This market reality questions must be finalized. If there is a reopened question, that question need to be finalized instead.
Logic
- Get reality final answer by calling
realitio.resultForOnceSettled()for the first question inquestionsIds. - Create a payouts array defaulting to 0s. Its length is
numOutcomes+1(last index is for INVALID outcome). - Calculates the payout for each outcome based on the answer. A payout which index matches the answer will be set to 1. If the answer is INVALID_RESULT or larger than or equal to the number of outcomes, sets the payout of the last index to 1.
- Reports the final payouts of the
questionIdto theConditionalTokenscontract.
resolveMultiCategoricalMarket
Pre-condition
This market reality questions must be finalized. If there is a reopened question, that question need to be finalized instead.
Logic
- Get reality final answer by calling
realitio.resultForOnceSettled()for the first question inquestionsIds. - Create a payouts array defaulting to 0s. Its length is
numOutcomes+1(last index is for INVALID outcome). - Calculates payouts based on a binary representation of the answer. If the answer is INVALID_RESULT, sets the payout of the last index to 1. Otherwise, it processes each bit of the answer:
- For each outcome, sets the payout to 1 if the corresponding bit in the answer is set, otherwise 0.
- Tracks if all outcomes have zero payouts.
- If all outcomes have zero payouts after processing, sets the payout of the last index to 1.
- Reports the final payouts of the
questionIdto theConditionalTokenscontract.
resolveScalarMarket
Pre-condition
This market reality questions must be finalized. If there is a reopened question, that question need to be finalized instead.
Logic
- Get reality final answer by calling
realitio.resultForOnceSettled()for the first question inquestionsIds. - Create a payouts array defaulting to 0s. Its length is 3 (last index is for INVALID outcome).
- Calculates the payout for each outcome based on the answer:
- If the answer is INVALID_RESULT, sets the payout for the third outcome to 1.
- If the answer is less than or equal to
lowerBound, sets the payout for the first outcome to 1. If the answer is greater than or equal toupperBound, sets the payout for the second outcome to 1. - For answers between
lowerBoundandupperBound, calculates proportional payouts for the first two outcomes based on the answer’s position within the range.
- Reports the final payouts of the
questionIdto theConditionalTokenscontract.
resolveMultiScalarMarket
Pre-condition
This market reality questions must be finalized. If there is one or more reopened questions, those questions need to be finalized instead.
Logic
- Get reality final answers by calling
realitio.resultForOnceSettled()for each question inquestionsIds. - Create a payouts array defaulting to 0s. Its length is
numOutcomes+1(last index is for INVALID outcome). - For each answer + index:
- If the answer is INVALID_RESULT, sets the payout at that index to 0.
- If the answer exceeds the maximum payout, caps it at the maximum, otherwise sets the payout at that index to answer.
- Tracks if all outcomes have zero payouts.
- If all outcomes have zero payouts after processing, sets the payout of the last index to 1.
- Reports the final payouts of the
questionIdto theConditionalTokenscontract.