@sudobility/heavymath_contracts
v0.1.60
Published
Multi-chain prediction market system with UUPS upgradeable contracts, dual-boundary market splits, and a unified TypeScript client for EVM chains and Solana.
Downloads
3,299
Maintainers
Readme
@sudobility/heavymath_contracts
Multi-chain prediction market smart contracts and TypeScript SDK for EVM chains. Features a percentage-based prediction mechanism with dual-boundary market split settlement.
Installation
bun add @sudobility/heavymath_contractsUsage
import { PredictionClient } from '@sudobility/heavymath_contracts';
import { EVMPredictionClient } from '@sudobility/heavymath_contracts/evm';
const client = new EVMPredictionClient({
predictionMarket: '0x...',
stakeToken: '0x...', // USDC address (optional, resolved on-chain)
});
// Place a prediction (auto-approves ERC20)
await client.placePrediction(walletContext, marketId, 60, 1_000_000n);
// Create a market (requires Dealer NFT)
await client.createMarket(walletContext, {
tokenId: 1n,
category: 1n,
subCategory: 2n,
deadline: BigInt(Math.floor(Date.now() / 1000) + 86400),
description: 'Team A wins',
});
// Read market state
const market = await client.getMarket(publicClient, marketId);Smart Contracts
Three UUPS-upgradeable Solidity 0.8.24 contracts:
- PredictionMarket -- core market lifecycle (create, predict, resolve, claim)
- DealerNFT -- ERC721 licensing with category/subcategory permissions
- OracleResolver -- oracle registration and data feeds
How It Works
- Dealers create markets with a deadline
- Users place predictions at a percentage (0-100) with USDC
- At deadline, the market split is calculated across the percentage spectrum
- Winners on the resolved side of the split share the losing side's effective stakes proportionally
- Fees: winner fee (default 1%, max 10%) split between dealer and platform (default 50/50)
Development
bun run compile:evm # Compile Solidity
bun run test:evm # Run Hardhat tests
bun run build # Build all (evm + unified + react-native TS)
bun run lint # ESLint check
bun run typecheck # TypeScript check
bun run deploy:evm:sepolia # Deploy to SepoliaSDK Entry Points
| Import | Description |
| ------------------------------------- | -------------------------- |
| @sudobility/heavymath_contracts | Unified PredictionClient |
| @sudobility/heavymath_contracts/evm | EVMPredictionClient (viem) |
Related Packages
@sudobility/heavymath_types-- shared type definitions@sudobility/heavymath_indexer_client-- indexer API client@sudobility/heavymath_lib-- business logic hooksheavymath_app-- frontend web application
License
BUSL-1.1
