Skip to content

feat: adds the prediction-market-bets and prediction-market-payouts file#4

Open
Airstarr wants to merge 2 commits intomainfrom
contract-again
Open

feat: adds the prediction-market-bets and prediction-market-payouts file#4
Airstarr wants to merge 2 commits intomainfrom
contract-again

Conversation

@Airstarr
Copy link
Copy Markdown
Owner

Prediction Market Smart Contracts

These smart contracts facilitate the creation, management, and payout of prediction markets using the Clarity language. They are split into two main contracts:

  1. Prediction Market Payout Management Contract
  2. Prediction Market Betting Contract

1. Prediction Market Payout Management Contract

Overview

This contract is designed to manage payouts for prediction markets. It handles the resolution of markets, calculation of winnings, and distribution of funds to participants. It also supports fee collection and withdrawal of accumulated fees by the contract owner.

Features

  • Market Resolution: Only the contract owner can resolve a market, specifying the winning option and total pool.
  • Payout Claims: Users can claim their winnings based on their bets and the resolved results of the market.
  • Fee Management: Automatically deducts a fee (0.5%) from user winnings and tracks total fees collected.
  • Balance Management: Users can withdraw their balances, and the contract owner can withdraw accumulated fees.

Functions

  • Public Functions:

    • resolve-market: Resolve a market by specifying the winning option and total pool.
    • claim-payout: Claim winnings for a resolved market if the user bet on the winning option.
    • withdraw-balance: Withdraw funds from the user's balance.
    • withdraw-fees: Withdraw accumulated fees as the contract owner.
  • Read-Only Functions:

    • get-market-payout: Retrieve payout details for a specific market.
    • get-user-bet: Retrieve a user's bet for a specific market.
    • get-user-balance: Check the balance of a specific user.
    • get-total-fees: Get the total fees collected by the contract.

Data Structures

  • Maps:
    • market-payouts: Tracks resolved market details including total pool, winning option, and resolution status.
    • user-bets: Tracks user bets for each market, including bet amount, chosen option, and claim status.
    • user-balances: Tracks user balances.
  • Data Variables:
    • total-fees: Tracks total fees collected by the contract.

2. Prediction Market Betting Contract

Overview

This contract facilitates the creation and participation in prediction markets. Users can create markets, place bets on outcomes, and resolve markets. The contract also manages user balances for deposits and withdrawals.

Features

  • Market Creation: Allows users to create prediction markets with custom descriptions and options.
  • Betting: Users can place bets on specific options within open markets.
  • Market Resolution: Market creators can resolve their markets by specifying the winning option.
  • Winnings Claim: Users can claim their winnings based on the resolved results of the market.
  • Fund Management: Users can deposit funds into the contract for betting and withdraw unused funds.

Functions

  • Public Functions:

    • create-market: Create a new prediction market with a description and list of options.
    • place-bet: Place a bet on a specific option in an open market.
    • resolve-market: Resolve a market by specifying the winning option.
    • claim-winnings: Claim winnings for a resolved market if the user bet on the winning option.
    • deposit-funds: Deposit funds into the contract for betting.
    • withdraw-funds: Withdraw unused funds from the user's balance.
  • Read-Only Functions:

    • get-market: Retrieve details of a specific market.
    • get-bet: Retrieve a specific user's bet in a market.
    • get-balance: Check the balance of a specific user.

Data Structures

  • Maps:
    • markets: Tracks market details including creator, description, options, total pool, and resolution status.
    • bets: Tracks user bets for each market, including bet amount and chosen option.
    • user-balances: Tracks user balances for deposits and winnings.
  • Data Variables:
    • total-bets: Tracks the total number of markets created.

How They Work Together

  1. The Prediction Market Betting Contract is used to create markets, allow users to place bets, and manage the resolution of markets.
  2. The Prediction Market Payout Management Contract is responsible for calculating and distributing winnings, managing fees, and facilitating balance withdrawals.

These contracts work in tandem to provide a seamless experience for creating, participating in, and managing prediction markets.


Usage Instructions

  1. Deploy both contracts to the blockchain.
  2. Use the Prediction Market Betting Contract to create markets and allow users to place bets.
  3. Once a market is resolved in the betting contract, manage payouts using the Prediction Market Payout Management Contract.
  4. Users can interact with both contracts to place bets, claim winnings, and manage their balances.

Notes

  • These contracts assume the contract owner is responsible for market resolution and fee withdrawal.
  • Fee parameters, market details, and payout calculations can be adjusted as needed to suit specific use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant