RealityProxy
Contract used as a Reality Oracle. Is called to resolve a market based on the answer provided.
Variables
conditionalTokens
Conditional Tokens contract.
realitio
Reality.eth contract.
INVALID_RESULT
INVALID_RESULT reserved value.
REALITY_UINT_TEMPLATE
Template for scalar and multi scalar markets.
REALITY_SINGLE_SELECT_TEMPLATE
Template for categorical markets.
REALITY_MULTI_SELECT_TEMPLATE
Template for multi categorical markets.
Functions
constructor
Constructor.
Parameters
Name | Type | Description |
---|---|---|
_conditionalTokens | contract IConditionalTokens | Conditional Tokens contract address. |
_realitio | contract IRealityETH_v3_0 | Reality.eth contract address. |
resolve
Resolves the specified market.
Parameters
Name | Type | Description |
---|---|---|
market | contract Market | Market to resolve. UNTRUSTED. |
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
questionId
fromquestionsIds
,outcomes.length
,templateId
,lowerBound
,upperBound
.Call one of the 4 internal resolution functions corresponding to 4 market types, passing
questionId
,questionsIds
, as well asnumOutcomes
orlow
,high
depending on the market type.
resolveCategoricalMarket
Resolves to invalid if the answer is invalid or the result is greater than the amount of outcomes.
Parameters
Name | Type | Description |
---|---|---|
questionId | bytes32 | Conditional Tokens questionId. |
questionsIds | bytes32[] | Reality questions ids. |
numOutcomes | uint256 | The number of outcomes, excluding the INVALID_RESULT outcome. |
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
questionId
to theConditionalTokens
contract.
resolveMultiCategoricalMarket
Resolves to invalid if the answer is invalid or all the results are zero.
Parameters
Name | Type | Description |
---|---|---|
questionId | bytes32 | Conditional Tokens questionId. |
questionsIds | bytes32[] | Reality questions ids. |
numOutcomes | uint256 | The number of outcomes, excluding the INVALID_RESULT outcome. |
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
questionId
to theConditionalTokens
contract.
resolveScalarMarket
Resolves to invalid if the answer is invalid.
Parameters
Name | Type | Description |
---|---|---|
questionId | bytes32 | Conditional Tokens questionId. |
questionsIds | bytes32[] | Reality questions ids. |
low | uint256 | Lower bound. |
high | uint256 | Upper bound. |
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
lowerBound
andupperBound
, calculates proportional payouts for the first two outcomes based on the answer's position within the range.
Reports the final payouts of the
questionId
to theConditionalTokens
contract.
resolveMultiScalarMarket
If any individual result is invalid then the corresponding payout element is set to 0. If all the elements of the payout vector are 0 or all are invalid, the market resolves to invalid.
Parameters
Name | Type | Description |
---|---|---|
questionId | bytes32 | Conditional Tokens questionId. |
questionsIds | bytes32[] | Reality questions ids. |
numOutcomes | uint256 | The number of outcomes, excluding the INVALID_RESULT outcome. |
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
questionId
to theConditionalTokens
contract.
Last updated