Prediction
Prediction runs parimutuel yes or no markets in HYPE. Its owner, the wallet that deployed it, writes each question and states the outcome after the market closes. A stated outcome takes effect one hour later, and a market whose outcome is never stated refunds everyone after seven days. The owner has no path to the pots beyond stating the outcome and the fee set at deploy.
#Parameters
| Field in the Builder | Constructor argument | Default | Notes |
|---|---|---|---|
| Owner fee in basis points | feeBps_ |
100 (1%) | At most 300 (3%), and taken only from the losing side. |
| (none) | owner_ |
your wallet | Writes markets and states outcomes. Fixed forever. |
#A market's life
- Create.
create(question, closes), owner only. The question is 1 to 200 bytes;closesis a time after now and at most 90 days ahead. On the page, the owner types the question and the hours until it closes. - Bet.
bet(id, side)with HYPE as the value,truefor yes andfalsefor no. Anyone, any number of times, on either side, until the market closes. - Propose. After the close,
propose(id, outcome), owner only, once. The market's status becomes Proposed and it becomes final one hour later (TIMELOCK). - Finalize. After that hour, anyone calls
finalize(id). The fee is sent to the owner. - Claim. Each winner calls
claim(id)once.
If no outcome has been proposed seven days after the close (RESOLVE_WINDOW), anyone can call refund(id). The market then returns every stake through claim. Until someone calls refund, the owner can still propose.
#The payout
With pot = yesPot + noPot and winners the pot on the winning side:
fee = (pot - winners) × feeBps / 10,000, taken from the losing side only;- a winner receives
stake on the winning side × (pot - fee) / winners; - if nobody bet on the winning side, there is no fee and everyone gets their stakes back;
- after a refund, everyone gets their stakes back.
A wallet that bet on both sides is paid on its winning-side stake only.
#What the owner decides
The owner states the outcome. The one-hour timelock makes the stated outcome visible to everyone before it is final, but the contract has no dispute step: once proposed, an outcome cannot be changed by anyone, the owner included. Play on markets whose owner you trust to report the truth. The owner cannot move a pot, cancel bets or change the fee.
#The page
The app page shows the terms of the market above everything else, then each market with its pots, its status (Open, Outcome proposed, Final, Refunding) and your position. The owner sees a form to create markets and, after a close, Outcome: Yes and Outcome: No. After the timelock anyone sees Make final; after seven days with no outcome anyone sees Open refunds.
#Functions
| Function | Who may call | What it does |
|---|---|---|
create(string, uint64) |
Owner | Opens a market. |
bet(uint256, bool) payable |
Anyone | Adds to a side's pot. |
propose(uint256, bool) |
Owner | States the outcome, final one hour later. |
finalize(uint256) |
Anyone | Makes a proposed outcome final and pays the fee. |
refund(uint256) |
Anyone | Opens refunds seven days after an unresolved close. |
claim(uint256) |
Anyone with a stake | Pays winnings or refunds, once. |
market(uint256), marketCount(), stakesOf(uint256, address, uint256), claimed(uint256, address) |
Read | Markets and positions. |
Events: Created, Bet, Proposed, Finalized, Claimed, Refunded. Errors include NotOwner, BadMarket, Closed, NotClosed, NotProposed, TooEarly, NotFinal, AlreadyClaimed, NothingToClaim, Stale, BadFee.
Demiurge