Skip to content

prodeapp/prodeapp-contracts

Repository files navigation

ProdeApp Contracts

Descentralized pool betting platform using Realitio secured by Kleros as oracle.

Overview

The contracts in this repo are meant to allow permissionless creation and management of betting markets. The typical setup for a market would be a set of questions related to the outcome of the matches of a tournament (or part of it).

Users who want to participate in a market will have to:

  • Pay a fixed price for each bet.
  • Place a bet. A bet consists of all the predictions for the set of questions that compose the Market (for example: team A wins game 1, team C wins game 2, team Z wins the final, etc.).
  • Bets should only be submitted prior to the beginning of the matches.

Once all the matches results are known and resolved in Realitio, a users ranking has to be created and the rewards are then distributed according to the ranking.

Each bet is a tradeable NFT. Along the course of a tournament or of a given match, the expected value of a set of predictions, i.e. the expected ranking position a bet will achieve, will vary. Bets being tradeable allow users to speculate and make a profit if their bet starts having a good prospect during the course of a tournament.

Techincal details

The gas consumption of the contracts is high. v1 is going to be deployed on the Gnosis Chain. For this reason, intensive gas functions are acceptable as long as they fit in a block.

Gas optimization, among other things, are going to be considered for v2, which is going to be deployed on a rollup.

Market creation

Each Market is created from the MarketFactory. To create a new Market instance, the following information is needed:

  • The market info, containing the name and symbol of the market.
  • All the questions (template ID, string and the opening timestamp) that make up de market. The questions will be created in Realitio v3 at the moment of initialization of the contract. The results, i.e. the answers to the questions, should be unknown during the betting period (< closingTime).
  • closingTime: timestamp at which no more bets are allow.
  • price: how much each bet costs.
  • The managementFee (in basis points) and the manager. The creator of the Market must set the address of the manager, which will receive a percentage (managementFee) of the pool as reward. In addition, the managementFee might be used to reward front-end providers on calling placeBet() and to reward the manager thourgh royalties.
  • The Realitio question timeout, which specifies how much time should pass for a new answer to be considered final.
  • The Realitio question minBond, which specifies the minimum bond require to answer each question.
  • prizeWeights: an array containing the distribution of rewards in basis points. It is expected to be filled in descending order, but not enforced.

Betting period

Once the market has been created, anyone can place a bet by paying the given price and submitting their predictions. Duplicate bets are allowed.

For each correct prediction, a point is earned. Predicting that a question will result Invalid is allowed and will add up to the score if correct. However, questions answered too soon are not considered final by the Market contract. The final score of a bet is equal to the sum of correct answers.

An ERC721 token is minted on making a bet. The manager of the bet could receive royalties equal to the managementFee.

Bets can be submitted until the closingTime is reached.

Waiting for results

After the betting period is over, the contract enters a stalled period that ends when all Realitio questions become final. When they do, the management reward is transferred to the manager and the ranking creation period begins.

Ranking creation period

Due to gas restrictions, it's not viable nor efficient to calculate the scores of all the bets and arrange the entire ranking based on them. For this reason, the score of each bet has to be registered manually by calling registerPoints. Bets not registered will not be rewarded even if their score is higher than the current top bets.

Bets with 0 points cannot be registered in the ranking and therefore are not elegible for prizes.

Prizes period

After the ranking creation period is over (1 week), winners can claim their reward. Winners are not the original creators of the bet but the owners of the bet NFT at the moment the reward is claimed.

When 2 or more bets share the same score, prizes are split between them so that:

  • Bets with the same score must receive the same reward.
  • Bets with higher scores should receive a greater reward than bets with lower scores (according to prizeWeights).

If a ranking position eligible for a prize is not filled, the vacant prize is distributed equally among the rest of the winners.

In the unexpected case in which no bet got more than 0 points or the ranking was not registered, all players can claim a reimbursement. Note that the reimbursement doesn't cover 100% of the price, since the managemente fee was already discounted. The NFT is burnt. In this rare case, players should evaluate if they value more the reimbursement or the NFT.

Funding a pool

Anyone can provide extra funding for the market until the ranking creation period starts. Beware that the funds will be lost if no bet is submitted during the betting period.

Further considerations

The type of betting markets supported by these contracts are fun and make the most sense when the prediction space is big. In such cases, the chances of becoming a winner are small, but the reward is big. Take this into consideration when creating a new market.

About

Smart Contracts for the Prode protocol

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •