Butter's fist iteration of Conditional Funding Markets contracts is available at github.com/butterygg/cfm-v1.
The main contract, FlatCFM
represents a CFM with a flat outcomes structure: each outcome represents the condition that a project gets funded. These outcomes are also called decision outcomes.
ConditionalScalarMarket
represents the scalar prediction market which is conditional on the parent outcome being selected. It contains outcomes Short
(also called DOWN), Long
(also called UP) and Invalid
.
The FlatCFMFactory
contract enables the creation of a FlatCFM
and its related ConditionalScalarMarket
. For a given CFM, it helps creating the unique FlatCFM
instance, one ConditionalScalarMarket
instance per decision outcome (not counting for the Invalid outcome), asks the associated oracle questions and prepares the associated conditional tokens.
FlatCFMRealityAdapter
implements an adapter pattern to access RealityETH from our contracts, with a normalized interface.
The system follows these general steps:
The FlatCFMFactory
creates a new FlatCFM
with specified parameters. This enables creation of ConditionalScalarMarket
s for each outcome. This submits the decision question to the oracle via FlatCFMRealityAdapter
and prepares the decision condition through ConditionalTokens
.
The FlatCFMFactory
creates new ConditionalScalarMarket
s for an existing FlatCFM
. This submits the scalar question to the oracle via FlatCFMRealityAdapter
and prepares the scalar conditions through ConditionalTokens
. This relies on a Reality template with a placeholder for the decision outcome name.
Users split their collateral into decision outcome tokens, then split again into scalar outcome tokens. These tokens are ERC20s and can be traded on AMMs.
When the oracle provides an answer to the decision question, the FlatCFM
can be resolved and calculates payouts.
When the oracle provides an answer to the conditional scalar questions (all together), all ConditionalScalarMarket
s can be resolved and calculate payouts.
Users can redeem their positions for payouts.