FutarchyFactory
Futarchy factory is used to create price-based futarchy markets.
Market creation logic:
Ask reality questions.
Prepare condition.
Create new erc20 outcome tokens.
Initialize a new market contract.
Variables
CreateProposalParams
REALITY_SINGLE_SELECT_TEMPLATE
Template for 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.
proposals
Proposals created by this factory.
proposal
Proposal contract.
Events
NewProposal
To be emitted when a new proposal is created.
Parameters
proposal
address
The new proposal address.
marketName
string
The name of the market.
conditionId
bytes32
Conditional Tokens conditionId.
questionId
bytes32
Conditional Tokens questionId.
Functions
constructor
Constructor.
_proposal
address
Address of the proposal contract that is going to be used for each new deployment.
_arbitrator
address
Address of the arbitrator that is going to resolve Realitio disputes.
_realitio
contract IRealityETH_v3_0
Address of the Realitio implementation.
_wrapped1155Factory
contract IWrapped1155Factory
Address of the Wrapped1155Factory implementation.
_conditionalTokens
contract IConditionalTokens
Address of the ConditionalTokens implementation.
_realityProxy
contract RealityProxy
Address of the RealityProxy implementation.
_questionTimeout
uint32
Reality question timeout.
createProposal
Creates a price-based futarchy market and deploys the wrapped ERC20 tokens.
Parameters
params
struct FutarchyFactory.CreateProposalParams
CreateProposalParams instance.
Return Values
[0]
address
The new proposal address.
Logic
Ask reality questions.
Prepare condition.
Create new erc20 outcome tokens.
Initialize a new proposal contract.
createNewProposalParams
Creates the structures needed to initialize the new proposal.
Parameters
params
struct FutarchyFactory.CreateProposalParams
CreateProposalParams instance.
tokenNames
string[] memory
Array with the names of the outcome tokens.
Return Values
[0]
struct FutarchyProposal.FutarchyProposalParams
FutarchyProposal.FutarchyProposalParam instance.
getOutcomesAndTokens
Creates the outcomes and token names.
Parameters
collateralToken1
IERC20
The token collateral.
collateralToken2
IERC20
The currency collateral.
Return Values
[0]
string[]
The outcomes names.
[1]
string[]
The wrapped ERC20 names.
encodeRealityQuestion
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
question
string
The question text.
category
string
The question category.
lang
string
The question language.
Return Values
[0]
string
The encoded question.
askRealityQuestion
Asks a question on reality.
Parameters
encodedQuestion
string
The encoded question containing the Reality parameters.
templateId
uint256
The Reality template id.
openingTime
uint32
The question opening time.
minBond
uint256
The question min bond.
Return Values
[0]
bytes32
The question id
prepareCondition
Prepares the CTF condition and returns the conditionId.
Parameters
questionId
bytes32
An identifier for the question to be answered by the oracle.
outcomeSlotCount
uint256
The number of outcome slots which must be used for this condition. Must not exceed 256.
Return Values
[0]
bytes32
Condition ID.
Pre-condition
Reality question asked and return
questionsId
.
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.
Parameters
collateralToken1
ERC20
The token collateral.
collateralToken2
ERC20
The currency collateral.
parentCollectionId
bytes32
The parentCollectionId.
conditionId
bytes32
The conditionId.
tokenNames
string[]
The name of each outcome token.
Return Values
wrapped1155
contract IERC20[]
Array of outcome tokens wrapped to ERC20.
data
bytes[]
Array of token data used to create each ERC20.
Logic
It will call
wrapped1155Factory.requireWrapped1155
to create an ERC20 token contract for each position. The new tokens addresses and data are saved inProposal
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
value
string
String to encode
Return Values
encodedString
bytes32
The encoded string.
allMarkets
Returns all the proposals created by this factory.
Return Values
[0]
address[]
The addresses of the proposals.
marketsCount
Returns the amount of proposals created by this factory.
Return Values
[0]
uint256
The amount of proposals.
Last updated