Create a market
To create a market, the user calls one of the market creation functions inside the MarketFactory contract. The steps to create a prediction market are quite similar among different market types.
For example, the following function may be used to create a categorical market:
function createCategoricalMarket(CreateMarketParams calldata params) external returns (address)Parameter: the function call requires a CreateMarketParams struct
struct CreateMarketParams {
string marketName; // Used only in categorical, multi categorical, and scalar markets. In multi scalar markets, the market name is formed using questionStart + outcomeType + questionEnd.
string[] outcomes; // The market outcomes, doesn't include the INVALID_RESULT outcome
string questionStart; // Used to build the Reality question on multi scalar markets
string questionEnd; // Used to build the Reality question on multi scalar markets
string outcomeType; // Used to build the Reality question on multi scalar markets
uint256 parentOutcome; // conditional outcome to use (optional)
address parentMarket; // conditional market to use (optional)
string category; // Reality question category
string lang; // Reality question language
uint256 lowerBound; // Lower bound, only used for scalar markets
uint256 upperBound; // Upper bound, only user for scalar markets
uint256 minBond; // Min bond to use on Reality
uint32 openingTime; // Reality question opening time
string[] tokenNames; // Name of the ERC20 tokens associated to each outcome
}If the function succeeds, the newly created market address will be stored in a state variable:
while the actual market information will be stored in a separate Market contract:
and an event will be emitted:
When creating a market, the contract will also:
Setup one or multiple Reality questions. A market may contain one or multiple questions waiting to be resolved by an oracle. Reality is chosen for this task.
Prepare a Condition. Each market corresponds to a
conditionId. ThisconditionIdwill be used in theConditionalTokenscontract to resolve the market.
ERC20 Position Tokens Creation. For each possible outcome (including an "Invalid" outcome), the contract creates a wrapped ERC20 token representing this position using
Wrapped1155Factory. The tokens addresses and data will be saved in theMarketcontract.
Last updated