OilMoneyDocumentation
Start Trading →

Overview

Oil Money is a decentralized binary trading platform built on Solana. Users bet on WTI crude oil price movements in fixed-duration epochs using USDC with 100× leverage.

Each epoch runs for 10 minutes: a 5-minute entry window where users place long or short positions, followed by a 5-minute active period. At entry close, the keeper locks the current WTI price from Pyth Network. At epoch end, the keeper settles using the final price. Winners take from losers proportionally — no order books, no counterparty risk, pure peer-to-peer.

The protocol is fully on-chain via an Anchor program on Solana. A keeper service runs 24/7 managing epoch lifecycle, price feeds, and settlement. Portfolio data is indexed to Supabase for fast queries.

Epoch Lifecycle

Every epoch follows a strict sequence, managed by the keeper service:

1
Create Epoch
The keeper creates a new epoch with start/end timestamps. Entry window opens immediately. Users can begin placing positions.
2
Entry Window (5 min)
Users open positions (long or short) by depositing USDC. They're betting blind — the entry price hasn't been locked yet, preventing front-running.
3
Lock Entry Price
When the entry window closes, the keeper fetches the current WTI/USD price from Pyth Network and locks it on-chain via the lock_entry_price instruction.
4
Active Period (5 min)
The epoch runs. The price chart shows live WTI movement. No new positions can be opened.
5
Settlement
When the epoch ends, the keeper fetches the final price and calls finalize_epoch. The on-chain program computes payouts. Winners can claim immediately.
6
Next Epoch
The keeper immediately creates the next epoch, and the cycle repeats.
Note
If the keeper fails to lock an entry price (network issues, oracle downtime), the epoch is cancelled via cancel_epoch and all users receive full refunds.

Price Oracle (Pyth Network)

Oil Money uses Pyth Network's Hermes oracle service to fetch real-time WTI crude oil spot prices.

Pyth Feed Configuration
Feed:    WTI/USD (Crude Oil Spot)
Feed ID: 925ca92ff005ae943c158e3563f59698...b3e6
Source:  hermes.pyth.network
Format:  u64 with 6 decimal places (USDC precision)

The keeper queries Pyth at two critical moments:

Entry Price Lock
Fetched when the 5-min entry window closes. Becomes the reference price for all positions.
Settlement Price
Fetched when the epoch ends. This is the exit price used to determine winners and losers.
Tip
Prices are stored on-chain as u64 values with 6 decimal places. For example, $68.50 is stored as 68500000.

Settlement Math

The core settlement logic runs on-chain in the Solana program's claim instruction. Here's how payouts are calculated:

1. Fee Deduction

A 5% entry fee is deducted from each position. On the matched portion, this fee goes to the winning side. On the unmatched portion, the fee is refunded.

2. Matched Pool

The matched pool is the minimum of total longs and total shorts after fees. Only the matched portion has PnL exposure.

matched = min(long_net, short_net)

3. Price PnL

The price movement determines the transfer between longs and shorts:

price_change  = (end_price - start_price) / start_price
effective_move = price_change × leverage (100×)

pnl_transfer = matched_pool × effective_move

4. Individual Payout

Each user's payout is their proportional share of their side's final pool, plus any unmatched portion returned at full value.

5. Example

Scenario: $1,000 Long in a pool of $3,000 Longs vs $2,000 Shorts
Fee: $50 (5%) → Net stake: $950
Matched pool (short side net): $1,900
User's share of long side: $950 / $2,850 = 33.3%
If longs win with 0.5% price move (50% effective at 100×):
Long pool receives ~$950 from shorts
User's payout: 33.3% × ($2,850 + $950) ≈ $1,267

Unmatched Liquidity

When longs and shorts aren't equal, some positions are partially or fully "unmatched."

Example: $5,000 Longs vs $3,000 Shorts
Matched: $3,000 (both sides have PnL exposure)
Unmatched: $2,000 of the long side has no opposing bet

How unmatched funds are handled:

The unmatched portion is returned in full at settlement
The 5% fee on the unmatched portion is refunded
No PnL is applied — it's as if that portion never entered the trade
Important
In heavily imbalanced epochs, the dominant side has reduced effective exposure. If you're the only long with $1,000 and shorts total $200, only $200 of your position has leverage exposure.

To improve pool balance and trading experience, a publicly visible market making wallet participates in epochs where one side is severely imbalanced. For example, if longs have $1,000 and shorts only $200, the wallet may add a $300–$500 short position to reduce the unmatched gap.

Note
Market Making Wallet: C6Mt8Yu7dRdEihensd5xa2oroafypiNVhv2fLjLueVg2

This wallet is powered by JUICE protocol infrastructure. Profits from market making are used to buy back and burn tokens, creating deflationary pressure, and to add liquidity. All burns and LP additions are verifiable on-chain.

Program Architecture

The Solana program (Anchor framework) uses Program Derived Addresses (PDAs) for all accounts:

GlobalState["global"]
Stores admin pubkey, current epoch ID, leverage (100×), entry fee (500 bps), entry window duration (300s).
Epoch["epoch", global, epoch_id]
Stores start/end prices, timestamps, total longs/shorts, settled flag, and created_at.
Position["pos", epoch, user]
Stores user pubkey, side (long/short), amount_usdc, claimed flag. One position per user per epoch.
VaultAuth["vault_auth", global]
Authority for the USDC token vault. All deposits go here, all payouts come from here.

Key Instructions

Epoch Management
create_epoch      Create new epoch with timestamps
lock_entry_price  Lock entry price after entry window
finalize_epoch    Settle with end price
cancel_epoch      Cancel broken epoch (full refunds)
User Actions
open_position     Deposit USDC, create position
claim             Claim payout or refund
Admin
update_config     Update leverage, fees, market hours settings

Keeper & Stack

The keeper is a Node.js service that runs 24/7 on Railway, managing the entire epoch lifecycle automatically.

Core Loop (every 10s, 3s when urgent)
1. Fetch GlobalState → get current epoch ID
2. Fetch current epoch account
3. Determine state → take action:
   · No epoch        → create first epoch
   · Epoch settled   → create next epoch
   · Epoch ended     → settle, then create next
   · Entry open      → wait, lock price when window closes
   · Epoch active    → wait for end time

After each settlement, the keeper writes to Supabase for fast portfolio queries: epoch data (prices, totals, timestamps) and position data (wallet, side, amount, claimed status).

Note
All critical operations retry up to 3 times with exponential backoff. If entry price lock fails, the epoch is cancelled and users receive full refunds. The keeper wallet needs approximately 0.5 SOL for transaction fees.

Tech Stack

Frontend
Next.js 14, TypeScript, custom canvas chart, Solana wallet adapter
Smart Contract
Anchor framework on Solana, all settlement math on-chain
Keeper
TypeScript/Node.js on Railway, 24/7 epoch management
Database
Supabase (PostgreSQL) for portfolio and leaderboard data
Oracle
Pyth Network Hermes for WTI/USD real-time price feeds
Token
USDC (SPL Token) for all deposits and payouts, 6 decimal precision

Built on Solana · Powered by Pyth Network · Oil Money © 2026