Swiv is a privacy-preserving, precision-based prediction market built on Solana using Anchor and MagicBlock Private Ephemeral Rollups. Unlike binary prediction markets (Yes/No), Swiv allows users to submit continuous numerical predictions (e.g. price levels, values, metrics), producing richer and more accurate market signals.
The protocol separates private execution from public settlement:
- Sensitive user actions happen inside a private ephemeral rollup
- Only finalized, aggregated results are committed to Solana L1
https://github.com/swiv-labs/Frontend
https://github.com/swiv-labs/Backend
https://youtu.be/IB5Ptia9SeI?si=g1wYQDfLLjf_di2s
-
Written in Rust (Anchor framework)
-
Deployed on Solana
-
Manages:
- Pool lifecycle
- PDA ownership
- Vault accounting
- Reward distribution
- Protocol fees
-
Enabled via
#[ephemeral] -
Handles:
- Private bet placement
- Private prediction updates
- Weight calculations
-
Prevents:
- Front-running
- Wallet tracking
- Strategy leakage
-
Final states are flushed back to Solana via:
- Pool undelegation
- Bet undelegation
-
Enables permissionless reward claiming
initialize_protocol(protocol_fee_bps)-
Creates the global protocol config
-
Sets:
- Admin authority
- Treasury wallet
- Protocol fee (basis points)
-
Executed once
create_pool(
pool_id,
name,
metadata,
start_time,
end_time,
max_accuracy_buffer,
conviction_bonus_bps
)Each pool defines:
- A prediction window (
start_time → end_time) - A numerical outcome range
- Accuracy tolerance (
max_accuracy_buffer) - Conviction incentives
The pool PDA:
- Owns a token vault
- Tracks total stake, weights, and resolution state
delegate_pool(pool_id)-
Transfers pool PDA authority to MagicBlock TEE
-
From this point:
- Pool state becomes privately mutable
- No public on-chain writes for user actions
This step is required before resolution.
init_bet(amount, request_id)- Creates a bet PDA
- Locks user stake into pool vault
- Stores encrypted metadata in the rollup
place_bet(prediction, request_id)
update_bet(new_prediction)- Prediction value remains private
- Users may update predictions before pool expiry
- Update count affects conviction bonus
resolve_pool(final_outcome)- Called inside MagicBlock TEE
- Marks pool as resolved
- Stores the final numerical outcome
- Enables weight computation
No user data is revealed on-chain at this stage.
batch_calculate_weights()- Admin passes all bet PDAs as remaining accounts
- Each bet weight is calculated privately
- Results are written into bet accounts
This avoids per-user transactions and preserves privacy.
Swiv’s reward system is stake-weighted and accuracy-driven.
calculate_accuracy_score(prediction, result, buffer)- Measures closeness to final outcome
- Linear decay inside buffer
- Outside buffer → score = 0
Formula:
accuracy = 1 - (|prediction - result| / buffer)
Scaled by MATH_PRECISION = 1_000_000
calculate_time_bonus(start, end, entry_time)- Rewards earlier participation
- Longer commitment → higher multiplier
Earlier bets receive higher influence.
calculate_conviction_bonus(update_count)- No updates → higher conviction bonus
- Multiple updates → neutral weight
Encourages confidence, not constant adjustment.
weight =
stake
× accuracy
× time_bonus
× convictionScaled down by precision constants:
final_weight = raw_product / P³This produces a fair, manipulation-resistant influence score.
finalize_weights()Requirements:
- Pool must be resolved
- Weights must not be finalized already
Actions:
- Deduct protocol fee
- Lock distributable vault balance
- Emit final settlement event
Once called:
- Pool becomes immutable
- Claiming is enabled
batch_undelegate_bets()
undelegate_pool()- Writes finalized bet + pool data to Solana
- Ends private execution phase
claim_reward()-
Permissionless
-
Based on:
user_weight / total_pool_weight -
Transfers tokens directly from pool vault
No admin trust required.
emergency_refund()- Used if pool cannot be resolved
- Returns stakes proportionally
- Prevents fund lockups
- Privacy: Predictions never hit public mempool
- Fairness: No front-running or copy trading
- Precision: Not limited to binary outcomes
- Verifiability: Final state is fully on-chain
- Scalability: Batch operations reduce gas costs
Swiv introduces a new category of prediction markets by combining:
- Precision-based numerical forecasting
- Private ephemeral execution
- Trustless on-chain settlement
By leveraging MagicBlock Private Ephemeral Rollups and Solana’s PDA model, Swiv delivers privacy without sacrificing decentralization or verifiability.