Skip to content

Smart Contracts

Address: 0x0027Adb36E28fA1C037286Da59BB348fA2B63Bd6

The factory creates and tracks all prediction markets.

Creates a market and places an initial seed bet in a single transaction.

function createMarketAndBet(
string _question,
bytes32 _feedId,
int256 _strikePrice,
uint256 _resolutionTime,
uint256 _bettingCloseTime,
bool _betYes
) external payable returns (address market)
ParameterDescription
_questionHuman-readable market question
_feedIdkeccak256(toUtf8Bytes("BTCUSD")) — get from Feed API
_strikePriceStrike price in 18-decimal fixed point (e.g. 100000 * 1e18)
_bettingCloseTimeUnix timestamp (seconds) when betting closes
_resolutionTimeUnix timestamp (seconds) when market resolves via oracle
_betYestrue = bet Yes, false = bet No
msg.valueQUAI amount for the seed bet (must meet minSeedBet)

Creates a market without a seed bet (owner only in practice).

function createMarket(
string question,
bytes32 feedId,
int256 strikePrice,
uint256 resolutionTime,
uint256 bettingCloseTime
) external returns (address market)
FunctionReturnsDescription
getMarkets()address[]All market addresses
getMarketCount()uint256Number of markets created
markets(i)addressMarket address at index i
isMarket(addr)boolWhether addr is a valid market
minSeedBet()uint256Minimum seed bet in wei
treasuryFeeBps()uint256Treasury fee in basis points
creatorFeeBps()uint256Creator fee in basis points
EventParameters
MarketCreatedmarket (indexed), creator (indexed), question, feedId, strikePrice, resolutionTime, bettingCloseTime

Each market is a separate contract deployed by the factory.

Place a bet on the Yes or No outcome. Send QUAI as msg.value.

function betYes() external payable
function betNo() external payable

Claim winnings after market resolution. Reverts if you have nothing to claim.

function claim() external

Resolve the market using Stork Oracle signed price data. Anyone can call this after resolutionTime. Requires sending the oracle update fee as msg.value.

function resolve(
IStorkOracle.TemporalNumericValueInput[] storkUpdateData
) external payable
FunctionReturnsDescription
question()stringMarket question text
feedId()bytes32Oracle feed identifier
strikePrice()int256Strike price (18-decimal fixed point)
resolutionTime()uint256Unix timestamp for resolution
bettingCloseTime()uint256Unix timestamp when betting closes
status()uint80=Active, 1=Resolved, 2=Cancelled
yesPool()uint256Total QUAI in Yes pool
noPool()uint256Total QUAI in No pool
getUserBets(user)(uint256, uint256)User’s (yesBet, noBet) amounts
calculatePayout(user)uint256User’s payout if they win
estimatePayout(isYes, amount)uint256Estimated payout for a hypothetical bet
getImpliedOdds()(uint256, uint256)(yesProb, noProb) as percentages
isBettingOpen()boolWhether betting is still open
yesWon()boolWhether Yes won (after resolution)
resolvedPrice()int256Actual price at resolution
totalVolume()uint256Total QUAI wagered
creator()addressMarket creator address
hasClaimed(user)boolWhether user has claimed winnings
EventParameters
BetPlaceduser (indexed), isYes, amount, newYesPool, newNoPool
MarketResolvedyesWon, resolvedPrice
WinningsClaimeduser (indexed), payout
MarketCancelled(none)