MarketFactory
Market factory is used to create prediction markets of different types.
Market creation logic:
Ask reality questions.
Prepare condition.
Create new erc20 outcome tokens.
Initialize a new market contract.
Variables
CreateMarketParams
Workaround "stack too deep" errors.
InternalMarketConfig
Workaround "stack too deep" errors.
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.
questionTimeout
Reality question timeout.
arbitrator
Arbitrator contract.
realitio
Reality.eth contract.
wrapped1155Factory
Wrapped1155Factory contract.
conditionalTokens
Conditional Tokens contract.
collateralToken
Conditional Tokens collateral token contract.
realityProxy
Oracle contract.
markets
Markets created by this factory.
market
Market contract.
Events
NewMarket
To be emitted when a new market is created.
Parameters
Functions
constructor
Constructor.
createCategoricalMarket
Categorical markets are associated with a Reality question that has only one answer.
Creates a Categorical market.
Parameters
Return Values
Logic
Validate outcomes length (>= 2).
Encode 1 reality question.
Call
createMarket
.
createMultiCategoricalMarket
Multi Categorical markets are associated with a Reality question that has one or more answers.
Creates a Multi Categorical market.
Parameters
Return Values
Logic
Validate outcomes length (>=2).
Encode 1 reality question.
Call
createMarket
.
createScalarMarket
Scalar markets are associated with a Reality question that resolves to a numeric value.
Creates a Scalar market.
Parameters
Return Values
Logic
Validate
upperBound
andlowerBound
.Validate outcomes length (2).
Encode 1 reality question.
Call
createMarket
.
createMultiScalarMarket
Multi Scalar markets are associated with two or more Reality questions, and each one of them resolves to a numeric value.
Creates a Multi Scalar market.
Parameters
Return Values
Logic
Validate outcomes length (>=2).
Encode reality questions, one for each outcome.
Instead of using
params.marketName
, encode a newmarketName
.Call
createMarket
.
createMarket
Creates the Market and deploys the wrapped ERC20 tokens.
Parameters
Return Values
Logic
Ask reality questions.
Prepare condition.
Create new erc20 outcome tokens.
Initialize a new market contract.
createNewMarketParams
Creates the structures needed to initialize the new market.
Parameters
Return Values
encodeRealityQuestionWithOutcomes
Encodes the question, outcomes, category and language following the Reality structure. If any parameter has a special character like quotes, it must be properly escaped.
Parameters
Return Values
encodeRealityQuestionWithoutOutcomes
Encodes the question, category and language following the Reality structure. If any parameter has a special character like quotes, it must be properly escaped.
Parameters
Return Values
askRealityQuestion
Asks a question on reality.
Parameters
Return Values
prepareCondition
Prepares the CTF condition and returns the conditionId.
Parameters
Return Values
Pre-condition
Reality questions asked and return
questionsIds
.questionId
is hashed from all the values thatRealityProxy.resolve()
uses to resolve a market (questionsIds
,outcomes.length
,templateId
,lowerBound
,upperBound
).
Logic
It will check if there is a prepared condition on
ConditionalTokens
, and callconditionalTokens.prepareCondition()
if there isn't any.
deployERC20Positions
Wraps the ERC1155 outcome tokens to ERC20. The INVALID_RESULT outcome is always called SER-INVALID.
Parameters
Return Values
Logic
It will call
wrapped1155Factory.requireWrapped1155
to create an ERC20 token contract for each position. The new tokens addresses and data is saved inMarket
contract.
toString31
Encodes a short string (less than than 31 bytes long) as for storage as expected by Solidity. See https://github.com/gnosis/1155-to-20/pull/4#discussion_r573630922.
Parameters
Return Values
allMarkets
Returns all the markets created by this factory.
Return Values
marketCount
Returns the amount of markets created by this factory.
Return Values
Last updated