Skip to main content

Smart Contracts

The protocol consists of two smart contracts deployed on Base, with mainnet deployment planned post-audit.

Contract Overview

ContractFunction
HunchTokenERC-20 token ($HUNCH) - betting currency, rewards, governance
HunchManagerBetting pools, odds tracking, payout settlement

HunchToken

Standard ERC-20 token with additional capabilities for the prediction market ecosystem.

Features

Mintable

Authorized addresses can mint for rewards and signup bonuses

Burnable

Potential deflationary mechanics

Operator Pattern

Gasless transfers during betting

Role-Based Access

Separate permissions for different operations

Key Functions

// Mint tokens to an address (owner/minter only)
function mint(address to, uint256 amount) external;

// Standard ERC-20 balance check
function balanceOf(address account) external view returns (uint256);

// Standard ERC-20 transfer
function transfer(address to, uint256 amount) external returns (bool);

HunchManager

Core betting logic and market settlement contract.

Key Functions

// Place a bet on a market
function placeBet(
    bytes32 marketId,    // Polymarket condition ID (hashed)
    bool isYes,          // true for YES, false for NO
    uint256 amount,      // Bet amount in wei
    uint256 odds         // Current odds at time of bet
) external;

// Settle a market with final outcome (settler only)
function resolveMarket(bytes32 marketId, bool outcome) external;

// Process payout for a single bet
function settleBet(uint256 betId) external;

// Preview potential payout
function calculatePayout(uint256 amount, uint256 odds) 
    external view returns (uint256);

Payout Calculation

The share-based payout model:
User bets $10 on YES at 65% odds:

Shares purchased: 10 / 0.65 = 15.38 shares
If YES wins: Payout = 15.38 tokens
Platform fee (1.5%): 0.23 tokens
Net payout: 15.15 tokens
Profit: 5.15 tokens

If NO wins: User loses $10 bet

Security Design

OpenZeppelin

Battle-tested, audited base contracts

Role-Based Access

Separate permissions for minting, settling, operations

Non-Custodial

Users maintain control via smart accounts

Reentrancy Guards

Protection on all state-changing functions

Fee Caps

Platform fee hard-capped at 10% maximum

Upgradeable

Proxy pattern allows bug fixes without migration

Deployment Status

Contracts are deployed on Base Sepolia testnet and verified on BaseScan for inspection.

Mainnet Roadmap

TimelineMilestone
Q2 2026Complete internal security review
Q2 2026Third-party audit (targeting Trail of Bits or OpenZeppelin)
Q3 2026Mainnet deployment with limited beta
Q3 2026Full public launch