Database Schema Documentation

This page documents the SPMC database schema, including all tables, columns, relationships, and constraints.

67
Tables
23
Relationships
3
Migrations

Entity Relationship Diagram

This diagram shows the relationships between database tables. Click and drag to pan, use mouse wheel to zoom.

erDiagram %% Schema: kalshimarkets kalshimarkets_raw_markets { market_id VARCHAR(255) PK,NOT NULL event_ticker VARCHAR(255) NOT NULL title TEXT NOT NULL description TEXT category VARCHAR(255) subcategory VARCHAR(255) status VARCHAR(50) NOT NULL open_time TIMESTAMP NOT NULL close_time TIMESTAMP NOT NULL settlement_time TIMESTAMP settlement_value NUMERIC(20, 8) yes_bid NUMERIC(20, 8) yes_ask NUMERIC(20, 8) no_bid NUMERIC(20, 8) no_ask NUMERIC(20, 8) volume NUMERIC open_interest NUMERIC liquidity NUMERIC last_trade_price NUMERIC(20, 8) last_trade_time TIMESTAMP rules_primary TEXT rules_secondary TEXT is_primary_market BOOLEAN raw_metadata JSON created_at TIMESTAMP updated_at TIMESTAMP last_checked TIMESTAMP } %% Schema: limitlessctfexchange limitlessctfexchange_fee_charged { id VARCHAR PK,NOT NULL receiver TEXT NOT NULL token_id NUMERIC NOT NULL amount NUMERIC NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_hot_block { height INTEGER PK,NOT NULL hash TEXT NOT NULL } limitlessctfexchange_hot_change_log { block_height INTEGER PK,NOT NULL index INTEGER PK,NOT NULL change JSONB NOT NULL } limitlessctfexchange_migrations { id INTEGER PK,NOT NULL timestamp INTEGER NOT NULL name VARCHAR NOT NULL } limitlessctfexchange_new_admin { id VARCHAR PK,NOT NULL new_admin_address TEXT NOT NULL admin TEXT NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_new_operator { id VARCHAR PK,NOT NULL new_operator_address TEXT NOT NULL admin TEXT NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_order { id VARCHAR PK,NOT NULL salt NUMERIC NOT NULL maker TEXT NOT NULL signer TEXT NOT NULL taker TEXT NOT NULL token_id NUMERIC NOT NULL maker_amount NUMERIC NOT NULL taker_amount NUMERIC NOT NULL expiration NUMERIC NOT NULL nonce NUMERIC NOT NULL fee_rate_bps NUMERIC NOT NULL side INTEGER NOT NULL signature_type INTEGER NOT NULL signature TEXT NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL status_id VARCHAR } limitlessctfexchange_order_cancelled { id VARCHAR PK,NOT NULL order_hash TEXT NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_order_filled { id VARCHAR PK,NOT NULL order_hash TEXT NOT NULL maker TEXT NOT NULL taker TEXT NOT NULL maker_asset_id NUMERIC NOT NULL taker_asset_id NUMERIC NOT NULL maker_amount_filled NUMERIC NOT NULL taker_amount_filled NUMERIC NOT NULL fee NUMERIC NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_order_status { id VARCHAR PK,NOT NULL is_filled_or_cancelled BOOLEAN NOT NULL remaining NUMERIC NOT NULL last_updated TIMESTAMP NOT NULL block INTEGER NOT NULL } limitlessctfexchange_orders_matched { id VARCHAR PK,NOT NULL taker_order_hash TEXT NOT NULL taker_order_maker TEXT NOT NULL maker_asset_id NUMERIC NOT NULL taker_asset_id NUMERIC NOT NULL maker_amount_filled NUMERIC NOT NULL taker_amount_filled NUMERIC NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_proxy_factory_updated { id VARCHAR PK,NOT NULL old_proxy_factory TEXT NOT NULL new_proxy_factory TEXT NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_removed_admin { id VARCHAR PK,NOT NULL removed_admin TEXT NOT NULL admin TEXT NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_removed_operator { id VARCHAR PK,NOT NULL removed_operator TEXT NOT NULL admin TEXT NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_safe_factory_updated { id VARCHAR PK,NOT NULL old_safe_factory TEXT NOT NULL new_safe_factory TEXT NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_status { id INTEGER PK,NOT NULL height INTEGER NOT NULL hash TEXT nonce INTEGER } limitlessctfexchange_token_registered { id VARCHAR PK,NOT NULL token0 NUMERIC NOT NULL token1 NUMERIC NOT NULL condition_id TEXT NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_token_registry { id VARCHAR PK,NOT NULL complement NUMERIC NOT NULL condition_id TEXT NOT NULL last_updated TIMESTAMP NOT NULL block INTEGER NOT NULL } limitlessctfexchange_trading_paused { id VARCHAR PK,NOT NULL pauser TEXT NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_trading_unpaused { id VARCHAR PK,NOT NULL pauser TEXT NOT NULL timestamp TIMESTAMP NOT NULL block INTEGER NOT NULL tx_hash TEXT NOT NULL } limitlessctfexchange_user_state { id VARCHAR PK,NOT NULL is_admin BOOLEAN NOT NULL is_operator BOOLEAN NOT NULL nonce NUMERIC NOT NULL proxy_wallet_address TEXT safe_address TEXT last_updated TIMESTAMP NOT NULL block INTEGER NOT NULL } %% Schema: migration_system migration_system_migration_history { id INTEGER PK,NOT NULL version VARCHAR(50) UNIQUE,NOT NULL description TEXT sql_hash VARCHAR(64) NOT NULL deployed_at TIMESTAMP deployed_by VARCHAR(100) status VARCHAR(20) rollback_sql TEXT } %% Schema: pmf pmf_authors { id UUID PK,NOT NULL "Unique identifier (UUID primary key)" privy_user_id VARCHAR(255) UNIQUE,NOT NULL "Privy user ID from authentication token" wallet_address VARCHAR(255) UNIQUE,NOT NULL "Unique blockchain wallet address for the author" email VARCHAR(255) UNIQUE,NOT NULL "Email address from Privy linked accounts" twitter VARCHAR(255) "Twitter handle (optional)" telegram VARCHAR(255) "Telegram username (optional)" is_active BOOLEAN NOT NULL "Whether author is approved/active (admin-controlled, default false for applications)" created_at TIMESTAMP NOT NULL "Timestamp when author record was created" updated_at TIMESTAMP NOT NULL "Timestamp when author record was last updated (auto-updated via trigger)" } pmf_group_nav_hourly { group_id UUID PK,FK,NOT NULL "Foreign key to market_groups" ts TIMESTAMP PK,NOT NULL "Snapshot timestamp, truncated to hour boundary" nav NUMERIC(12, 2) NOT NULL "Total portfolio value in base currency" nav_normalized NUMERIC(10, 6) NOT NULL "Normalized NAV (1.0 at inception)" cash_value NUMERIC(12, 2) NOT NULL "Uninvested cash portion" invested_value NUMERIC(12, 2) NOT NULL "Market value of all positions" invested_ratio NUMERIC(5, 4) NOT NULL "Percentage invested (0.0 to 1.0)" base_currency TEXT NOT NULL "Currency unit for NAV calculations" nav_metadata JSONB NOT NULL "Additional metadata (quality indicators, errors, etc.)" } pmf_portfolio_rebalances { id UUID PK,NOT NULL "Unique identifier for the rebalance event" group_id UUID FK,NOT NULL "Foreign key to market_groups (portfolio)" rebalance_timestamp TIMESTAMP NOT NULL "When the rebalance occurred" portfolio_value_before NUMERIC(12, 2) NOT NULL "Total portfolio value before rebalancing" portfolio_value_after NUMERIC(12, 2) NOT NULL "Total portfolio value after rebalancing (should be same)" allocations JSONB NOT NULL "JSON array of allocations with percentages, amounts, and shares calculated" rebalance_type VARCHAR(50) "Type of rebalance: manual (user), automatic (scheduled), initial (first allocation)" triggered_by VARCHAR(255) "User ID or system identifier that triggered the rebalance" notes TEXT "Optional notes about the rebalance" created_at TIMESTAMP NOT NULL updated_at TIMESTAMP NOT NULL } %% Schema: polymarket polymarket_raw_markets { condition_id VARCHAR(255) PK,NOT NULL question_id VARCHAR(255) NOT NULL question TEXT NOT NULL description TEXT category VARCHAR(255) end_date_iso TIMESTAMP game_start_time TIMESTAMP market_slug VARCHAR(255) active BOOLEAN closed BOOLEAN seconds_delay NUMERIC icon TEXT fpmm VARCHAR(255) minimum_order_size NUMERIC(20, 8) minimum_tick_size NUMERIC(20, 8) min_incentive_size NUMERIC(20, 8) max_incentive_spread NUMERIC(20, 8) best_bid_price NUMERIC(20, 8) best_bid_size NUMERIC(20, 8) best_ask_price NUMERIC(20, 8) best_ask_size NUMERIC(20, 8) midpoint_price NUMERIC(20, 8) spread NUMERIC(20, 8) volume NUMERIC(20, 8) liquidity NUMERIC(20, 8) token_yes_id VARCHAR(255) token_yes_outcome TEXT token_no_id VARCHAR(255) token_no_outcome TEXT raw_metadata JSON created_at TIMESTAMP updated_at TIMESTAMP last_checked TIMESTAMP } polymarket_transformed_markets { market_id VARCHAR(255) PK,NOT NULL question TEXT NOT NULL description TEXT category VARCHAR(255) status VARCHAR(50) end_date TIMESTAMP volume NUMERIC(20, 8) liquidity NUMERIC(20, 8) best_buy_price NUMERIC(20, 8) best_buy_size NUMERIC(20, 8) best_sell_price NUMERIC(20, 8) best_sell_size NUMERIC(20, 8) midpoint NUMERIC(20, 8) spread NUMERIC(20, 8) is_active BOOLEAN created_at TIMESTAMP updated_at TIMESTAMP last_checked TIMESTAMP } %% Schema: public public_grouped_markets { id VARCHAR(255) PK,NOT NULL title TEXT NOT NULL final_end_date TIMESTAMP NOT NULL created_at TIMESTAMP NOT NULL updated_at TIMESTAMP NOT NULL market_ids JSONB NOT NULL platforms JSONB NOT NULL metrics JSONB NOT NULL } public_kalshi_markets { market_id VARCHAR(255) PK,NOT NULL event_ticker VARCHAR(255) NOT NULL title TEXT NOT NULL description TEXT status VARCHAR(50) NOT NULL expiration_date TIMESTAMP category VARCHAR(255) subcategory VARCHAR(255) volume NUMERIC open_interest NUMERIC volume_24h NUMERIC total_trades INTEGER last_trade_time TIMESTAMP best_bid_price NUMERIC(20, 8) best_bid_size NUMERIC(20, 8) best_ask_price NUMERIC(20, 8) best_ask_size NUMERIC(20, 8) last_trade_price NUMERIC(20, 8) adjusted_midpoint NUMERIC(20, 8) created_at TIMESTAMP NOT NULL updated_at TIMESTAMP NOT NULL last_checked TIMESTAMP NOT NULL group_id VARCHAR(255) FK group_similarity NUMERIC(20, 8) } public_market_group_items { id UUID PK,NOT NULL group_id UUID NOT NULL market_id VARCHAR NOT NULL market_type VARCHAR NOT NULL created_at TIMESTAMP } public_polymarket_markets { market_id VARCHAR(255) PK,NOT NULL question TEXT NOT NULL description TEXT category VARCHAR(255) end_date TIMESTAMP status VARCHAR(50) volume NUMERIC(20, 8) liquidity NUMERIC(20, 8) is_active BOOLEAN group_id VARCHAR(255) FK group_similarity NUMERIC(20, 8) yes_token_id VARCHAR(255) yes_best_buy_price NUMERIC(20, 8) yes_best_buy_size NUMERIC(20, 8) yes_best_sell_price NUMERIC(20, 8) yes_best_sell_size NUMERIC(20, 8) yes_midpoint NUMERIC(20, 8) yes_spread NUMERIC(20, 8) no_token_id VARCHAR(255) no_best_buy_price NUMERIC(20, 8) no_best_buy_size NUMERIC(20, 8) no_best_sell_price NUMERIC(20, 8) no_best_sell_size NUMERIC(20, 8) no_midpoint NUMERIC(20, 8) no_spread NUMERIC(20, 8) created_at TIMESTAMP updated_at TIMESTAMP last_checked TIMESTAMP } public_schema_migrations { version TEXT PK,NOT NULL applied_at TIMESTAMP NOT NULL checksum TEXT NOT NULL execution_time_ms INTEGER status TEXT } %% Schema: trading trading_opportunities { id UUID PK,NOT NULL group_id UUID FK,NOT NULL timestamp TIMESTAMP NOT NULL apy NUMERIC(10, 2) NOT NULL "Annualized percentage yield = (spread / days_to_close) * 365" spread NUMERIC(10, 4) NOT NULL "Profit margin after all fees (1 - total_cost)" days_to_close INTEGER NOT NULL kalshi_yes_price NUMERIC(10, 4) kalshi_no_price NUMERIC(10, 4) poly_yes_price NUMERIC(10, 4) poly_no_price NUMERIC(10, 4) limitless_yes_price NUMERIC(10, 4) limitless_no_price NUMERIC(10, 4) yes_platform TEXT "Platform to buy YES on for this opportunity" no_platform TEXT "Platform to buy NO on for this opportunity" total_cost NUMERIC(10, 4) "Total cost including all fees and gas" traded BOOLEAN "Whether a position was opened for this opportunity" trade_reason TEXT position_id UUID FK market_title TEXT created_at TIMESTAMP yes_orderbook_liquidity NUMERIC(20, 2) "Total YES liquidity available in orderbook ($)" no_orderbook_liquidity NUMERIC(20, 2) "Total NO liquidity available in orderbook ($)" executable_size NUMERIC(20, 2) "Maximum size that can be executed given orderbook depth" yes_best_ask NUMERIC(10, 6) "Best ask price for YES at opportunity detection" no_best_ask NUMERIC(10, 6) "Best ask price for NO at opportunity detection" yes_ask_depth INTEGER "Number of ask levels in YES orderbook" no_ask_depth INTEGER "Number of ask levels in NO orderbook" orderbook_freshness_seconds INTEGER "Age of orderbook data in seconds" execution_method TEXT "Whether opportunity was calculated from market prices or orderbook" } trading_orderbook_snapshots { id UUID PK,NOT NULL group_id UUID FK,NOT NULL timestamp TIMESTAMP NOT NULL kalshi_yes_liquidity NUMERIC(20, 2) kalshi_no_liquidity NUMERIC(20, 2) kalshi_spread NUMERIC(10, 6) kalshi_mid_price NUMERIC(10, 6) kalshi_bid_levels INTEGER kalshi_ask_levels INTEGER polymarket_yes_liquidity NUMERIC(20, 2) polymarket_no_liquidity NUMERIC(20, 2) polymarket_spread NUMERIC(10, 6) polymarket_mid_price NUMERIC(10, 6) polymarket_bid_levels INTEGER polymarket_ask_levels INTEGER limitless_yes_liquidity NUMERIC(20, 2) limitless_no_liquidity NUMERIC(20, 2) limitless_spread NUMERIC(10, 6) limitless_mid_price NUMERIC(10, 6) limitless_bid_levels INTEGER limitless_ask_levels INTEGER max_executable_arbitrage NUMERIC(20, 2) "Maximum arbitrage size given orderbook constraints" best_yes_platform TEXT best_no_platform TEXT arbitrage_spread NUMERIC(10, 4) arbitrage_apy NUMERIC(10, 2) created_at TIMESTAMP } trading_positions { id UUID PK,NOT NULL session_id UUID FK opportunity_id UUID strategy_name TEXT NOT NULL is_simulation BOOLEAN NOT NULL created_at TIMESTAMP NOT NULL yes_market_id UUID yes_platform TEXT NOT NULL yes_target_price NUMERIC(20, 8) yes_executed_price NUMERIC(20, 8) yes_execution_time TIMESTAMP yes_size NUMERIC(20, 8) yes_fees NUMERIC(20, 8) yes_slippage NUMERIC(20, 8) no_market_id UUID no_platform TEXT NOT NULL no_target_price NUMERIC(20, 8) no_executed_price NUMERIC(20, 8) no_execution_time TIMESTAMP no_size NUMERIC(20, 8) no_fees NUMERIC(20, 8) no_slippage NUMERIC(20, 8) status TEXT NOT NULL total_invested NUMERIC(20, 8) max_risk NUMERIC(20, 8) exit_time TIMESTAMP exit_reason TEXT market_resolution TEXT gross_pnl NUMERIC(20, 8) total_fees_paid NUMERIC(20, 8) net_pnl NUMERIC(20, 8) execution_latency_ms INTEGER failure_reason TEXT metadata JSONB group_id UUID FK "Link to the verified market group being traded" entry_apy NUMERIC(10, 2) "APY at time of trade entry (%)" entry_spread NUMERIC(10, 4) "Price spread at entry (decimal)" days_to_resolution INTEGER "Days until market resolution at entry" yes_levels_consumed INTEGER "Number of orderbook levels consumed for YES execution" no_levels_consumed INTEGER "Number of orderbook levels consumed for NO execution" yes_avg_execution_price NUMERIC(10, 6) "Volume-weighted average price for YES execution from orderbook" no_avg_execution_price NUMERIC(10, 6) "Volume-weighted average price for NO execution from orderbook" max_available_liquidity NUMERIC(20, 2) "Maximum executable size based on orderbook liquidity at entry" liquidity_constrained_by TEXT "Which side limited the trade size (yes/no/both/none)" price_impact_pct NUMERIC(10, 4) "Price impact from walking the orderbook (%)" orderbook_timestamp TIMESTAMP "Timestamp of orderbook data used for execution" } trading_sessions { id UUID PK,NOT NULL name TEXT NOT NULL mode TEXT NOT NULL started_at TIMESTAMP NOT NULL ended_at TIMESTAMP total_positions INTEGER total_pnl NUMERIC(20, 8) status TEXT NOT NULL metadata JSONB } %% Schema: unified unified_archived_markets { id UUID PK,NOT NULL "UUID primary key" platform TEXT NOT NULL "Trading platform: kalshi, polymarket, or limitless" platform_market_id TEXT NOT NULL "Platform-specific unique identifier" title TEXT NOT NULL "Market question/title as displayed" description TEXT "Detailed market description" category TEXT "Market category" subcategory TEXT "Market subcategory" status TEXT NOT NULL "Market status: open, closed, resolved" is_active BOOLEAN "Whether market is currently tradeable" created_at TIMESTAMP "When we first saw this market" updated_at TIMESTAMP "Last update timestamp" last_checked TIMESTAMP "Last API check timestamp" market_open_time TIMESTAMP market_close_time TIMESTAMP "When market closes for trading" resolution_time TIMESTAMP "When market resolves" last_trade_time TIMESTAMP volume_24h NUMERIC(20, 8) "Trading volume in last 24 hours" total_volume NUMERIC(20, 8) "Total historical volume" contract_volume NUMERIC(20, 8) liquidity NUMERIC(20, 8) "Available liquidity" open_interest NUMERIC(20, 8) "Open interest value" total_trades INTEGER unique_traders INTEGER best_bid_price NUMERIC(20, 8) best_bid_size NUMERIC(20, 8) best_ask_price NUMERIC(20, 8) best_ask_size NUMERIC(20, 8) last_trade_price NUMERIC(20, 8) "Last traded price" midpoint_price NUMERIC(20, 8) "Midpoint between bid and ask" spread NUMERIC(20, 8) "Bid-ask spread" adjusted_midpoint NUMERIC(20, 8) yes_token_id TEXT yes_best_buy_price NUMERIC(20, 8) "Best bid for YES token" yes_best_buy_size NUMERIC(20, 8) yes_best_sell_price NUMERIC(20, 8) "Best ask for YES token" yes_best_sell_size NUMERIC(20, 8) yes_midpoint NUMERIC(20, 8) yes_spread NUMERIC(20, 8) no_token_id TEXT no_best_buy_price NUMERIC(20, 8) "Best bid for NO token" no_best_buy_size NUMERIC(20, 8) no_best_sell_price NUMERIC(20, 8) "Best ask for NO token" no_best_sell_size NUMERIC(20, 8) no_midpoint NUMERIC(20, 8) no_spread NUMERIC(20, 8) event_ticker TEXT market_slug TEXT limitless_id INTEGER max_spread NUMERIC(20, 8) min_size NUMERIC(20, 8) collateral_token_symbol TEXT collateral_token_address TEXT collateral_token_decimals INTEGER categories ARRAY group_id UUID group_similarity NUMERIC(20, 8) platform_metadata JSONB last_realtime_update TIMESTAMP "Timestamp of last real-time WebSocket update" last_api_update TIMESTAMP "Timestamp of last API polling update" data_confidence_score NUMERIC(3, 2) data_freshness_score NUMERIC(3, 2) data_completeness_score NUMERIC(3, 2) platform_reliability_score NUMERIC(3, 2) overall_quality_score NUMERIC(3, 2) last_quality_check TIMESTAMP quality_check_count INTEGER normalized_title TEXT similarity_hash TEXT cross_platform_group_id UUID fee_percentage NUMERIC(5, 4) fee_function_type VARCHAR(50) yes_price NUMERIC(10, 6) no_price NUMERIC(10, 6) price_confidence NUMERIC(3, 2) derived_event_id TEXT title_embedding NULL description_embedding NULL } unified_batch_operations { id UUID PK,NOT NULL platform TEXT NOT NULL operation_type TEXT NOT NULL started_at TIMESTAMP completed_at TIMESTAMP duration_seconds INTEGER "Automatically calculated duration in seconds" total_items INTEGER successful_items INTEGER failed_items INTEGER retried_items INTEGER success_rate NUMERIC(5, 4) "Automatically calculated success rate (0-1)" batch_metadata JSONB performance_stats JSONB error_summary JSONB parent_batch_id UUID FK status TEXT } unified_builder_orders { id UUID PK,NOT NULL "Unique identifier for the order record" token_id TEXT NOT NULL "Polymarket token ID for the market outcome" side TEXT NOT NULL "Order side: BUY or SELL" order_volume NUMERIC(20, 8) NOT NULL "Order volume in USDC (up to 8 decimal places)" price NUMERIC(20, 8) "Limit order price between 0.01 and 0.99 (optional, null for market orders)" group_id UUID FK "Reference to market group (optional, preserved even if group is deleted)" writer_id UUID FK "Reference to author/writer (optional, preserved even if author is deleted)" request_path TEXT NOT NULL "HTTP request path from the original order request" request_method TEXT NOT NULL "HTTP request method from the original order request (typically POST)" created_at TIMESTAMP NOT NULL "Timestamp when the order was signed and recorded" } unified_dead_letter_queue { id UUID PK,NOT NULL message_type TEXT NOT NULL "Type of message (market_update, websocket_event, api_call)" payload JSONB NOT NULL "Original message payload as JSON" platform TEXT NOT NULL "Platform that generated the message" market_id TEXT "Market ID if applicable" original_timestamp TIMESTAMP NOT NULL failure_reason TEXT NOT NULL "Reason for message failure" retry_count INTEGER NOT NULL "Number of retry attempts made" max_retries INTEGER NOT NULL "Maximum retry attempts allowed" status TEXT NOT NULL "Current message status" created_at TIMESTAMP NOT NULL updated_at TIMESTAMP NOT NULL next_retry_at TIMESTAMP "When to retry the message next" resolved_at TIMESTAMP "When the message was successfully resolved" metadata JSONB "Additional metadata as JSON" } unified_embedding_queue { id UUID PK,NOT NULL entity_type TEXT NOT NULL entity_id UUID NOT NULL text_content TEXT NOT NULL embedding_type TEXT NOT NULL status TEXT created_at TIMESTAMP processed_at TIMESTAMP error_message TEXT retry_count INTEGER } unified_event_series { event_id UUID PK,FK,NOT NULL series_id UUID PK,FK,NOT NULL position INTEGER created_at TIMESTAMP } unified_events { id UUID PK,NOT NULL title TEXT NOT NULL normalized_title TEXT description TEXT category TEXT subcategory TEXT start_date TIMESTAMP end_date TIMESTAMP resolution_date TIMESTAMP status TEXT NOT NULL is_active BOOLEAN total_markets INTEGER active_markets INTEGER resolved_markets INTEGER total_volume NUMERIC(20, 8) platforms ARRAY platform_count INTEGER kalshi_event_id TEXT UNIQUE kalshi_event_ticker TEXT polymarket_event_id TEXT UNIQUE polymarket_event_slug TEXT limitless_event_id TEXT similarity_hash TEXT UNIQUE title_embedding NULL tags ARRAY platform_metadata JSONB created_at TIMESTAMP updated_at TIMESTAMP last_synced TIMESTAMP } unified_fund_prices_daily { id UUID PK,NOT NULL group_id UUID FK,NOT NULL "Reference to the market group (fund) this price belongs to" price_date DATE NOT NULL "Date for this price snapshot (date only, no time component)" price NUMERIC(10, 6) NOT NULL "Weighted average price of all markets in the fund (0.0 to 1.0), accounting for position types" market_count INTEGER NOT NULL "Total number of markets included in the computation" polymarket_count INTEGER NOT NULL "Number of Polymarket markets included (subset of market_count)" total_weight NUMERIC(12, 4) NOT NULL "Sum of all market weights used in the computation" data_completeness NUMERIC(5, 2) "Percentage of markets that had price data available (0-100)" avg_price_age_hours INTEGER "Average age in hours of the constituent market prices used" computation_method VARCHAR(50) NOT NULL "How this price was computed: batch (scheduled job) or on_demand (API request)" computed_at TIMESTAMP NOT NULL "Timestamp when this price was computed" computation_duration_ms INTEGER "Time taken to compute this price in milliseconds" metadata JSONB NOT NULL "Additional context as JSON (e.g., markets skipped, errors encountered, data sources)" created_at TIMESTAMP NOT NULL "Timestamp when this record was first created" updated_at TIMESTAMP NOT NULL "Timestamp when this record was last updated" } unified_group_market_relationships { id UUID PK,NOT NULL group_id UUID FK,NOT NULL market_id UUID NOT NULL weight NUMERIC(10, 4) position_type VARCHAR(20) metadata JSONB added_at TIMESTAMP updated_at TIMESTAMP } unified_group_membership_history { id UUID PK,NOT NULL group_id UUID FK,NOT NULL market_id UUID NOT NULL "Market UUID - no FK constraint to preserve history even if market is deleted" action VARCHAR(20) NOT NULL "Type of change: added (new market), removed (deleted market), weight_changed (existing market weight updated)" timestamp TIMESTAMP NOT NULL "When the change occurred (defaults to NOW but can be backdated for imports)" weight NUMERIC(10, 4) "Weight after the change (NULL for removed markets)" position_type VARCHAR(20) changed_by VARCHAR(100) metadata JSONB NOT NULL "Additional context as JSON. For resolution events, includes: { "settlement_value": 100.50, -- Total value received (shares × price) "settlement_price": 1.0, -- Resolution price (0.0, 0.5, or 1.0) "resolution_outcome": "YES", -- YES, NO, or INVALID "resolution_time": "2024-12-09T15:00:00Z", "position_details": { "shares": 100.0, -- Number of shares held "entry_price": 0.75, -- Average entry price "exit_price": 1.0, -- Resolution price (adjusted for position_type) "position_type": "long", -- long or short "cost_basis": 75.0 -- Total cost (shares × entry_price) }, "profit_loss": 25.0, -- settlement_value - cost_basis "profit_loss_percent": 33.33, -- (profit_loss / cost_basis) × 100 "holding_period_days": 14, -- Days from first entry to resolution "platform_market_id": "0xabc123", -- Platform-specific ID "market_title": "Will MongoDB beat earnings?", "platform": "polymarket", -- polymarket or kalshi "source": "automatic_cleanup", -- Always automatic for resolutions "cleanup_job_id": "uuid", -- ID of cleanup job that processed this "processed_at": "2024-12-10T03:00:00Z" }" created_at TIMESTAMP NOT NULL } unified_group_templates { id UUID PK,NOT NULL name VARCHAR(100) UNIQUE,NOT NULL description TEXT group_type VARCHAR(10) NOT NULL template_config JSONB NOT NULL is_active BOOLEAN created_at TIMESTAMP updated_at TIMESTAMP version INTEGER author VARCHAR(100) tags ARRAY usage_count INTEGER last_used_at TIMESTAMP validation_rules JSONB required_permissions ARRAY validation_status VARCHAR(20) } unified_grouping_log { id INTEGER PK,NOT NULL group_id UUID action VARCHAR(20) "Type of action: created, verified, rejected, expired" actor VARCHAR(50) "System or username who performed the action" details TEXT created_at TIMESTAMP } unified_market_events_recent { id BIGINT PK,NOT NULL platform TEXT NOT NULL platform_market_id TEXT NOT NULL event_type TEXT NOT NULL trade_price NUMERIC(10, 6) trade_size NUMERIC(20, 8) trade_side TEXT old_status TEXT new_status TEXT status_reason TEXT event_data JSONB occurred_at TIMESTAMP websocket_session_id TEXT created_at TIMESTAMP } unified_market_group_members { id UUID PK,NOT NULL group_id UUID FK,NOT NULL market_id UUID NOT NULL similarity_score NUMERIC(5, 4) is_representative BOOLEAN added_at TIMESTAMP } unified_market_group_verification_log { id UUID PK,NOT NULL group_id UUID FK,NOT NULL action TEXT NOT NULL previous_state JSONB new_state JSONB verified_by TEXT NOT NULL created_at TIMESTAMP } unified_market_groups { id UUID PK,NOT NULL title TEXT NOT NULL description TEXT status TEXT similarity_threshold NUMERIC(3, 2) created_at TIMESTAMP updated_at TIMESTAMP title_embedding NULL description_embedding NULL platform_count INTEGER market_count INTEGER total_volume NUMERIC(15, 2) total_liquidity NUMERIC(15, 2) consensus_price NUMERIC(10, 6) price_variance NUMERIC(10, 6) human_verified BOOLEAN "When true, this group is tradeable. human_verified = tradeable in our simplified system." verified_at TIMESTAMP verified_by TEXT "Username/ID of admin who verified this group" verification_notes TEXT "Admin notes about the verification decision" is_valid_group BOOLEAN "Admin determination: NULL=not reviewed, TRUE=correctly grouped, FALSE=incorrectly grouped" confidence NUMERIC(3, 2) "Automated confidence score (0.00-1.00) for group quality" grouping_method VARCHAR(50) "Algorithm used to create group (e.g., multi_stage_v2)" rejection_count INTEGER "Number of times this group has been rejected in verification" is_system_generated BOOLEAN is_template BOOLEAN template_name VARCHAR(100) metadata JSONB "Type-specific configuration including agent_deployment: { "agent_deployment": { "agent_id": "uuid", "wallet_address": "0x...", "telegram_bot_id": "123456789:ABC...", "telegram_chat_id": "987654321", "deployment_status": "pending|deploying|deployed|waiting_wallet|ready|failed", "tee_endpoint": "https://...", "deployed_at": "2025-01-15T10:30:00Z", "wallet_retrieved_at": "2025-01-15T10:31:00Z", "whitelisted_at": "2025-01-15T10:32:00Z", "trading_config": { "max_position_size": 100, "min_confidence_threshold": 0.7, "unsupervised_mode": false }, "error_message": "optional error details if deployment fails" } }" display_settings JSONB group_type VARCHAR(10) source_template_id UUID FK template_version INTEGER auto_update_from_template BOOLEAN max_spread NUMERIC(5, 4) has_arbitrage_opportunity BOOLEAN max_arbitrage_profit NUMERIC(10, 4) last_arbitrage_check TIMESTAMP final_resolution_time TIMESTAMP manager VARCHAR(255) "Name or identifier of the group manager/creator" logo_url TEXT "URL to the group logo or branding image" is_paper_trading BOOLEAN NOT NULL "Flag indicating if this is a simulated (paper trading) portfolio vs real money portfolio" initial_capital NUMERIC(12, 2) "Starting capital for paper trading portfolios (default $100)" current_cash NUMERIC(12, 2) "Current unallocated cash in the portfolio" paper_trading_config JSONB "Configuration for paper trading simulations (fee settings, etc.)" track_nav BOOLEAN NOT NULL "Enable hourly NAV computation for this group" base_currency TEXT NOT NULL "Currency for NAV calculations (USDC, USD, etc.)" } unified_market_history { timestamp TIMESTAMP PK,NOT NULL market_id UUID PK,NOT NULL platform TEXT NOT NULL yes_price NUMERIC(5, 4) no_price NUMERIC(5, 4) volume NUMERIC(15, 2) liquidity NUMERIC(15, 2) } unified_market_history_2025_09 { timestamp TIMESTAMP PK,NOT NULL market_id UUID PK,NOT NULL platform TEXT NOT NULL yes_price NUMERIC(5, 4) no_price NUMERIC(5, 4) volume NUMERIC(15, 2) liquidity NUMERIC(15, 2) } unified_market_history_2025_10 { timestamp TIMESTAMP PK,NOT NULL market_id UUID PK,NOT NULL platform TEXT NOT NULL yes_price NUMERIC(5, 4) no_price NUMERIC(5, 4) volume NUMERIC(15, 2) liquidity NUMERIC(15, 2) } unified_market_history_2025_11 { timestamp TIMESTAMP PK,NOT NULL market_id UUID PK,NOT NULL platform TEXT NOT NULL yes_price NUMERIC(5, 4) no_price NUMERIC(5, 4) volume NUMERIC(15, 2) liquidity NUMERIC(15, 2) } unified_market_prices_current { platform TEXT PK,NOT NULL platform_market_id TEXT PK,NOT NULL best_bid_price NUMERIC(10, 6) best_ask_price NUMERIC(10, 6) last_trade_price NUMERIC(10, 6) volume_24h NUMERIC(20, 8) volume_total NUMERIC(20, 8) liquidity_depth NUMERIC(20, 8) spread NUMERIC(10, 6) mid_price NUMERIC(10, 6) price_change_24h NUMERIC(10, 6) price_change_pct_24h NUMERIC(10, 4) high_24h NUMERIC(10, 6) low_24h NUMERIC(10, 6) market_status TEXT resolution_value NUMERIC(10, 6) resolved_at TIMESTAMP last_ticker_update TIMESTAMP last_trade_update TIMESTAMP last_orderbook_update TIMESTAMP updated_at TIMESTAMP update_count BIGINT websocket_session_id TEXT } unified_market_similarity_cache { id UUID PK,NOT NULL market_a_id UUID NOT NULL market_b_id UUID NOT NULL similarity_score NUMERIC(5, 4) NOT NULL similarity_method VARCHAR(50) NOT NULL calculated_at TIMESTAMP } unified_markets { id UUID PK,NOT NULL platform TEXT NOT NULL platform_market_id TEXT NOT NULL title TEXT description TEXT status TEXT category TEXT market_type TEXT market_open_time TIMESTAMP market_close_time TIMESTAMP settlement_time TIMESTAMP settlement_value NUMERIC yes_price NUMERIC no_price NUMERIC yes_bid NUMERIC yes_ask NUMERIC no_bid NUMERIC no_ask NUMERIC best_bid_price NUMERIC best_ask_price NUMERIC best_bid_size NUMERIC best_ask_size NUMERIC last_trade_price NUMERIC last_trade_time TIMESTAMP total_volume NUMERIC volume_24h NUMERIC open_interest NUMERIC liquidity NUMERIC implied_probability NUMERIC url TEXT rules TEXT metadata JSONB created_at TIMESTAMP updated_at TIMESTAMP is_active BOOLEAN PK,NOT NULL event_ticker TEXT subcategory TEXT rules_primary TEXT rules_secondary TEXT expected_settlement_time TIMESTAMP settlement_source TEXT settlement_description TEXT tags ARRAY image_url TEXT platform_created_at TIMESTAMP platform_updated_at TIMESTAMP market_slug TEXT yes_token_id TEXT no_token_id TEXT midpoint_price NUMERIC spread NUMERIC volume_yes NUMERIC volume_no NUMERIC liquidity_yes NUMERIC liquidity_no NUMERIC trade_count INTEGER trader_count INTEGER minimum_order_size NUMERIC minimum_tick_size NUMERIC data_source TEXT is_test_market BOOLEAN raw_data JSONB market_group_id UUID group_confidence_score NUMERIC group_method TEXT title_embedding NULL description_embedding NULL combined_embedding NULL data_quality_score NUMERIC has_sufficient_volume BOOLEAN has_recent_activity BOOLEAN has_stable_prices BOOLEAN has_trading_bonus BOOLEAN bonus_amount NUMERIC bonus_currency TEXT expiry_date TIMESTAMP event_id UUID contract_volume NUMERIC yes_best_buy_size NUMERIC no_best_buy_size NUMERIC yes_best_sell_size NUMERIC no_best_sell_size NUMERIC total_trades INTEGER unique_traders INTEGER } unified_markets_active { id UUID PK,NOT NULL platform TEXT NOT NULL platform_market_id TEXT NOT NULL title TEXT description TEXT status TEXT category TEXT market_type TEXT market_open_time TIMESTAMP market_close_time TIMESTAMP settlement_time TIMESTAMP settlement_value NUMERIC yes_price NUMERIC no_price NUMERIC yes_bid NUMERIC yes_ask NUMERIC no_bid NUMERIC no_ask NUMERIC best_bid_price NUMERIC best_ask_price NUMERIC best_bid_size NUMERIC best_ask_size NUMERIC last_trade_price NUMERIC last_trade_time TIMESTAMP total_volume NUMERIC volume_24h NUMERIC open_interest NUMERIC liquidity NUMERIC implied_probability NUMERIC url TEXT rules TEXT metadata JSONB created_at TIMESTAMP updated_at TIMESTAMP is_active BOOLEAN PK,NOT NULL event_ticker TEXT subcategory TEXT rules_primary TEXT rules_secondary TEXT expected_settlement_time TIMESTAMP settlement_source TEXT settlement_description TEXT tags ARRAY image_url TEXT platform_created_at TIMESTAMP platform_updated_at TIMESTAMP market_slug TEXT yes_token_id TEXT no_token_id TEXT midpoint_price NUMERIC spread NUMERIC volume_yes NUMERIC volume_no NUMERIC liquidity_yes NUMERIC liquidity_no NUMERIC trade_count INTEGER trader_count INTEGER minimum_order_size NUMERIC minimum_tick_size NUMERIC data_source TEXT is_test_market BOOLEAN raw_data JSONB market_group_id UUID group_confidence_score NUMERIC group_method TEXT title_embedding NULL description_embedding NULL combined_embedding NULL data_quality_score NUMERIC has_sufficient_volume BOOLEAN has_recent_activity BOOLEAN has_stable_prices BOOLEAN has_trading_bonus BOOLEAN bonus_amount NUMERIC bonus_currency TEXT expiry_date TIMESTAMP event_id UUID contract_volume NUMERIC yes_best_buy_size NUMERIC no_best_buy_size NUMERIC yes_best_sell_size NUMERIC no_best_sell_size NUMERIC total_trades INTEGER unique_traders INTEGER } unified_markets_inactive { id UUID PK,NOT NULL platform TEXT NOT NULL platform_market_id TEXT NOT NULL title TEXT description TEXT status TEXT category TEXT market_type TEXT market_open_time TIMESTAMP market_close_time TIMESTAMP settlement_time TIMESTAMP settlement_value NUMERIC yes_price NUMERIC no_price NUMERIC yes_bid NUMERIC yes_ask NUMERIC no_bid NUMERIC no_ask NUMERIC best_bid_price NUMERIC best_ask_price NUMERIC best_bid_size NUMERIC best_ask_size NUMERIC last_trade_price NUMERIC last_trade_time TIMESTAMP total_volume NUMERIC volume_24h NUMERIC open_interest NUMERIC liquidity NUMERIC implied_probability NUMERIC url TEXT rules TEXT metadata JSONB created_at TIMESTAMP updated_at TIMESTAMP is_active BOOLEAN PK,NOT NULL event_ticker TEXT subcategory TEXT rules_primary TEXT rules_secondary TEXT expected_settlement_time TIMESTAMP settlement_source TEXT settlement_description TEXT tags ARRAY image_url TEXT platform_created_at TIMESTAMP platform_updated_at TIMESTAMP market_slug TEXT yes_token_id TEXT no_token_id TEXT midpoint_price NUMERIC spread NUMERIC volume_yes NUMERIC volume_no NUMERIC liquidity_yes NUMERIC liquidity_no NUMERIC trade_count INTEGER trader_count INTEGER minimum_order_size NUMERIC minimum_tick_size NUMERIC data_source TEXT is_test_market BOOLEAN raw_data JSONB market_group_id UUID group_confidence_score NUMERIC group_method TEXT title_embedding NULL description_embedding NULL combined_embedding NULL data_quality_score NUMERIC has_sufficient_volume BOOLEAN has_recent_activity BOOLEAN has_stable_prices BOOLEAN has_trading_bonus BOOLEAN bonus_amount NUMERIC bonus_currency TEXT expiry_date TIMESTAMP event_id UUID contract_volume NUMERIC yes_best_buy_size NUMERIC no_best_buy_size NUMERIC yes_best_sell_size NUMERIC no_best_sell_size NUMERIC total_trades INTEGER unique_traders INTEGER } unified_order_book_current { id INTEGER PK,NOT NULL "Auto-incrementing primary key" platform TEXT NOT NULL "Trading platform: polymarket, kalshi, or limitless" market_id TEXT NOT NULL "Platform-specific market identifier (e.g., Polymarket condition_id)" token_type TEXT NOT NULL "Binary outcome token: YES (buy outcome) or NO (sell outcome)" bids JSONB NOT NULL "Array of bid levels [{price, size},...] sorted by price DESC. Price in [0,1], size in base units." asks JSONB NOT NULL "Array of ask levels [{price, size},...] sorted by price ASC. Price in [0,1], size in base units." best_bid_price NUMERIC(10, 6) "Highest bid price (top of book). Null if no bids." best_bid_size NUMERIC(20, 8) "Size available at best bid price" best_ask_price NUMERIC(10, 6) "Lowest ask price (top of book). Null if no asks." best_ask_size NUMERIC(20, 8) "Size available at best ask price" spread NUMERIC(10, 6) "Computed: ask - bid. Indicates market liquidity (smaller = more liquid)" mid_price NUMERIC(10, 6) "Computed: (bid + ask) / 2. Fair value estimate." sequence_number BIGINT "Platform sequence number for detecting gaps/replays" exchange_timestamp TIMESTAMP "When the exchange generated this orderbook state" received_at TIMESTAMP "When our system first received this update" updated_at TIMESTAMP "Last modification time (auto-updated by trigger)" } unified_raw_events { id UUID PK,NOT NULL "Auto-incrementing primary key" platform TEXT NOT NULL "Source platform" event_type TEXT NOT NULL "Type of event received" market_id TEXT NOT NULL "Platform market identifier" event_data JSONB NOT NULL "Complete event payload (JSONB)" blockchain_data JSONB ingested_at TIMESTAMP "When event was received" processed_at TIMESTAMP "When event was processed" processing_status TEXT "Processing status" retry_count INTEGER "Number of retry attempts" error_message TEXT "Error details if failed" api_endpoint TEXT "API endpoint called" http_method TEXT "HTTP method used (GET, POST, etc.)" response_time_ms INTEGER "API response time in ms" response_status_code INTEGER "HTTP status code" rate_limit_remaining INTEGER "Number of requests remaining in rate limit window" rate_limit_reset_at TIMESTAMP "When rate limit window resets" data_freshness_seconds INTEGER "Age of data in seconds when received" api_version TEXT "API version used" request_headers JSONB "HTTP request headers" response_headers JSONB "HTTP response headers" pagination_cursor TEXT "Cursor for paginated requests" batch_size INTEGER "Number of items in batch request" is_incremental_update BOOLEAN "True if this is an incremental update" parent_request_id UUID "Parent request ID for related requests" batch_operation_id UUID FK batch_sequence_number INTEGER batch_context JSONB is_realtime BOOLEAN "Whether from WebSocket/realtime" websocket_session_id TEXT "Session ID for WebSocket connection that generated this event" } unified_schema_migrations { version TEXT PK,NOT NULL description TEXT applied_at TIMESTAMP } unified_series { id UUID PK,NOT NULL title TEXT NOT NULL normalized_title TEXT description TEXT category TEXT series_type TEXT frequency TEXT status TEXT NOT NULL is_active BOOLEAN total_events INTEGER total_markets INTEGER active_markets INTEGER total_volume NUMERIC(20, 8) platforms ARRAY platform_count INTEGER kalshi_series_id TEXT UNIQUE kalshi_series_ticker TEXT polymarket_series_id TEXT UNIQUE polymarket_series_slug TEXT limitless_series_id TEXT similarity_hash TEXT UNIQUE tags ARRAY platform_metadata JSONB created_at TIMESTAMP updated_at TIMESTAMP last_synced TIMESTAMP } unified_template_instantiations { id UUID PK,NOT NULL template_id UUID FK,NOT NULL group_id UUID FK,NOT NULL instantiated_at TIMESTAMP instantiated_by VARCHAR(100) instantiation_config JSONB } %% Relationships pmf_group_nav_hourly ||--|| unified_market_groups : "group_id -> id" pmf_portfolio_rebalances }o--|| unified_market_groups : "group_id -> id" public_kalshi_markets }o--|| public_grouped_markets : "group_id -> id" public_polymarket_markets }o--|| public_grouped_markets : "group_id -> id" trading_opportunities }o--|| unified_market_groups : "group_id -> id" trading_opportunities }o--|| trading_positions : "position_id -> id" trading_orderbook_snapshots }o--|| unified_market_groups : "group_id -> id" trading_positions }o--|| unified_market_groups : "group_id -> id" trading_positions }o--|| trading_sessions : "session_id -> id" unified_batch_operations }o--|| unified_batch_operations : "parent_batch_id -> id" unified_builder_orders }o--|| unified_market_groups : "group_id -> id" unified_builder_orders }o--|| pmf_authors : "writer_id -> id" unified_event_series ||--|| unified_events : "event_id -> id" unified_event_series ||--|| unified_series : "series_id -> id" unified_fund_prices_daily ||--|| unified_market_groups : "group_id -> id" unified_group_market_relationships ||--|| unified_market_groups : "group_id -> id" unified_group_membership_history }o--|| unified_market_groups : "group_id -> id" unified_market_group_members ||--|| unified_market_groups : "group_id -> id" unified_market_group_verification_log }o--|| unified_market_groups : "group_id -> id" unified_market_groups }o--|| unified_group_templates : "source_template_id -> id" unified_raw_events }o--|| unified_batch_operations : "batch_operation_id -> id" unified_template_instantiations ||--|| unified_market_groups : "group_id -> id" unified_template_instantiations ||--|| unified_group_templates : "template_id -> id"

Database Tables

unified.archived_markets

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid() UUID primary key
platform TEXT No Trading platform: kalshi, polymarket, or limitless
platform_market_id TEXT No Platform-specific unique identifier
title TEXT No Market question/title as displayed
description TEXT Yes Detailed market description
category TEXT Yes Market category
subcategory TEXT Yes Market subcategory
status TEXT No Market status: open, closed, resolved
is_active BOOLEAN Yes true Whether market is currently tradeable
created_at TIMESTAMP Yes now() When we first saw this market
updated_at TIMESTAMP Yes now() Last update timestamp
last_checked TIMESTAMP Yes now() Last API check timestamp
market_open_time TIMESTAMP Yes
market_close_time TIMESTAMP Yes When market closes for trading
resolution_time TIMESTAMP Yes When market resolves
last_trade_time TIMESTAMP Yes
volume_24h NUMERIC(20, 8) Yes 0 Trading volume in last 24 hours
total_volume NUMERIC(20, 8) Yes 0 Total historical volume
contract_volume NUMERIC(20, 8) Yes 0
liquidity NUMERIC(20, 8) Yes 0 Available liquidity
open_interest NUMERIC(20, 8) Yes 0 Open interest value
total_trades INTEGER Yes 0
unique_traders INTEGER Yes 0
best_bid_price NUMERIC(20, 8) Yes
best_bid_size NUMERIC(20, 8) Yes
best_ask_price NUMERIC(20, 8) Yes
best_ask_size NUMERIC(20, 8) Yes
last_trade_price NUMERIC(20, 8) Yes Last traded price
midpoint_price NUMERIC(20, 8) Yes Midpoint between bid and ask
spread NUMERIC(20, 8) Yes Bid-ask spread
adjusted_midpoint NUMERIC(20, 8) Yes
yes_token_id TEXT Yes
yes_best_buy_price NUMERIC(20, 8) Yes Best bid for YES token
yes_best_buy_size NUMERIC(20, 8) Yes
yes_best_sell_price NUMERIC(20, 8) Yes Best ask for YES token
yes_best_sell_size NUMERIC(20, 8) Yes
yes_midpoint NUMERIC(20, 8) Yes
yes_spread NUMERIC(20, 8) Yes
no_token_id TEXT Yes
no_best_buy_price NUMERIC(20, 8) Yes Best bid for NO token
no_best_buy_size NUMERIC(20, 8) Yes
no_best_sell_price NUMERIC(20, 8) Yes Best ask for NO token
no_best_sell_size NUMERIC(20, 8) Yes
no_midpoint NUMERIC(20, 8) Yes
no_spread NUMERIC(20, 8) Yes
event_ticker TEXT Yes
market_slug TEXT Yes
limitless_id INTEGER Yes
max_spread NUMERIC(20, 8) Yes
min_size NUMERIC(20, 8) Yes
collateral_token_symbol TEXT Yes
collateral_token_address TEXT Yes
collateral_token_decimals INTEGER Yes
categories ARRAY Yes
group_id UUID Yes
group_similarity NUMERIC(20, 8) Yes
platform_metadata JSONB Yes
last_realtime_update TIMESTAMP Yes Timestamp of last real-time WebSocket update
last_api_update TIMESTAMP Yes Timestamp of last API polling update
data_confidence_score NUMERIC(3, 2) Yes
data_freshness_score NUMERIC(3, 2) Yes
data_completeness_score NUMERIC(3, 2) Yes
platform_reliability_score NUMERIC(3, 2) Yes
overall_quality_score NUMERIC(3, 2) Yes
last_quality_check TIMESTAMP Yes now()
quality_check_count INTEGER Yes 0
normalized_title TEXT Yes
similarity_hash TEXT Yes
cross_platform_group_id UUID Yes
fee_percentage NUMERIC(5, 4) Yes
fee_function_type VARCHAR(50) Yes
yes_price NUMERIC(10, 6) Yes
no_price NUMERIC(10, 6) Yes
price_confidence NUMERIC(3, 2) Yes
derived_event_id TEXT Yes
title_embedding NULL Yes
description_embedding NULL Yes

Indexes

Name Columns Type
archived_markets_category_idx category Index
archived_markets_coalesce_idx None Index
archived_markets_cross_platform_group_id_idx cross_platform_group_id Index
archived_markets_cross_platform_group_id_is_active_market_c_idx cross_platform_group_id, is_active, market_close_time Index
archived_markets_cross_platform_group_id_yes_price_no_price_idx cross_platform_group_id, yes_price, no_price Index
archived_markets_data_confidence_score_idx data_confidence_score Index
archived_markets_event_ticker_idx event_ticker Index
archived_markets_group_id_idx group_id Index
archived_markets_group_id_is_active_idx group_id, is_active Index
archived_markets_is_active_idx is_active Index
archived_markets_is_active_platform_id_idx is_active, platform, id Index
archived_markets_last_api_update_idx last_api_update Index
archived_markets_last_checked_idx last_checked Index
archived_markets_last_quality_check_idx last_quality_check Index
archived_markets_last_realtime_update_idx last_realtime_update Index
archived_markets_market_close_time_idx market_close_time Index
archived_markets_market_close_time_idx1 market_close_time Index
archived_markets_market_slug_idx market_slug Index
archived_markets_no_token_id_idx no_token_id Index
archived_markets_normalized_title_idx normalized_title Index
archived_markets_overall_quality_score_idx overall_quality_score Index
archived_markets_overall_quality_score_updated_at_idx overall_quality_score, updated_at Index
archived_markets_platform_fee_percentage_idx platform, fee_percentage Index
archived_markets_platform_idx platform Index
archived_markets_platform_idx1 platform Index
archived_markets_platform_is_active_idx platform, is_active Index
archived_markets_platform_is_active_status_idx platform, is_active, status Index
archived_markets_platform_last_realtime_update_idx platform, last_realtime_update Index
archived_markets_platform_last_realtime_update_last_api_up_idx1 platform, last_realtime_update, last_api_update Index
archived_markets_platform_last_realtime_update_last_api_upd_idx platform, last_realtime_update, last_api_update Index
archived_markets_platform_market_id_idx platform_market_id Index
archived_markets_platform_metadata_idx platform_metadata Index
archived_markets_platform_overall_quality_score_is_active_idx platform, overall_quality_score, is_active Index
archived_markets_platform_platform_market_id_key platform, platform_market_id Unique
archived_markets_similarity_hash_idx similarity_hash Index
archived_markets_status_idx status Index
archived_markets_to_tsvector_idx None Index
archived_markets_to_tsvector_idx1 None Index
archived_markets_to_tsvector_idx2 None Index
archived_markets_total_volume_idx total_volume Index
archived_markets_updated_at_idx updated_at Index
archived_markets_yes_token_id_idx yes_token_id Index

Constraints

Name Type Columns Definition
archived_markets_pkey primary_key id
archived_markets_platform_platform_market_id_key unique platform, platform_market_id
markets_adjusted_midpoint_check check
markets_best_ask_price_check check
markets_best_ask_size_check check
markets_best_bid_price_check check
markets_best_bid_size_check check
markets_check check
markets_check1 check
markets_check2 check
markets_contract_volume_check check
markets_data_completeness_score_check check
markets_data_confidence_score_check check
markets_data_freshness_score_check check
markets_group_similarity_check check
markets_last_trade_price_check check
markets_liquidity_check check
markets_max_spread_check check
markets_midpoint_price_check check
markets_min_size_check check
markets_no_best_buy_price_check check
markets_no_best_buy_size_check check
markets_no_best_sell_price_check check
markets_no_best_sell_size_check check
markets_no_midpoint_check check
markets_no_spread_check check
markets_open_interest_check check
markets_overall_quality_score_check check
markets_platform_check check
markets_platform_reliability_score_check check
markets_quality_check_count_check check
markets_spread_check check
markets_total_trades_check check
markets_total_volume_check check
markets_unique_traders_check check
markets_volume_24h_check check
markets_yes_best_buy_price_check check
markets_yes_best_buy_size_check check
markets_yes_best_sell_price_check check
markets_yes_best_sell_size_check check
markets_yes_midpoint_check check
markets_yes_spread_check check

pmf.authors

Writers and managers who create and manage prediction market funds

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid() Unique identifier (UUID primary key)
privy_user_id VARCHAR(255) No Privy user ID from authentication token
wallet_address VARCHAR(255) No Unique blockchain wallet address for the author
email VARCHAR(255) No Email address from Privy linked accounts
twitter VARCHAR(255) Yes Twitter handle (optional)
telegram VARCHAR(255) Yes Telegram username (optional)
is_active BOOLEAN No false Whether author is approved/active (admin-controlled, default false for applications)
created_at TIMESTAMP No now() Timestamp when author record was created
updated_at TIMESTAMP No now() Timestamp when author record was last updated (auto-updated via trigger)

Indexes

Name Columns Type
authors_email_key email Unique
authors_privy_user_id_key privy_user_id Unique
authors_wallet_address_key wallet_address Unique
idx_authors_created_at created_at Index
idx_authors_email email Index
idx_authors_is_active is_active Index
idx_authors_privy_user_id privy_user_id Index
idx_authors_wallet_address wallet_address Index

Constraints

Name Type Columns Definition
authors_pkey primary_key id
authors_email_key unique email
authors_privy_user_id_key unique privy_user_id
authors_wallet_address_key unique wallet_address

Relationships

unified.batch_operations

Tracking for bulk data operations

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
platform TEXT No
operation_type TEXT No
started_at TIMESTAMP Yes now()
completed_at TIMESTAMP Yes
duration_seconds INTEGER Yes Automatically calculated duration in seconds
total_items INTEGER Yes 0
successful_items INTEGER Yes 0
failed_items INTEGER Yes 0
retried_items INTEGER Yes 0
success_rate NUMERIC(5, 4) Yes Automatically calculated success rate (0-1)
batch_metadata JSONB Yes
performance_stats JSONB Yes
error_summary JSONB Yes
parent_batch_id FK UUID Yes
References: unified.batch_operations(id)
status TEXT Yes 'running'::text

Indexes

Name Columns Type
idx_batch_operations_duration duration_seconds Index
idx_batch_operations_operation_type operation_type Index
idx_batch_operations_parent_batch parent_batch_id Index
idx_batch_operations_platform platform Index
idx_batch_operations_platform_status platform, status Index
idx_batch_operations_started_at started_at Index
idx_batch_operations_status status Index

Constraints

Name Type Columns Definition
batch_operations_pkey primary_key id
batch_operations_parent_batch_id_fkey foreign_key parent_batch_id
batch_operations_check check
batch_operations_check1 check
batch_operations_check2 check
batch_operations_failed_items_check check
batch_operations_operation_type_check check
batch_operations_platform_check check
batch_operations_retried_items_check check
batch_operations_status_check check
batch_operations_successful_items_check check
batch_operations_total_items_check check

Relationships

unified.builder_orders

Records order metadata from builder signing server for analytics and tracking

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid() Unique identifier for the order record
token_id TEXT No Polymarket token ID for the market outcome
side TEXT No Order side: BUY or SELL
order_volume NUMERIC(20, 8) No Order volume in USDC (up to 8 decimal places)
price NUMERIC(20, 8) Yes Limit order price between 0.01 and 0.99 (optional, null for market orders)
group_id FK UUID Yes Reference to market group (optional, preserved even if group is deleted)
References: unified.market_groups(id)
writer_id FK UUID Yes Reference to author/writer (optional, preserved even if author is deleted)
References: pmf.authors(id)
request_path TEXT No HTTP request path from the original order request
request_method TEXT No HTTP request method from the original order request (typically POST)
created_at TIMESTAMP No now() Timestamp when the order was signed and recorded

Indexes

Name Columns Type
idx_builder_orders_created_at created_at Index
idx_builder_orders_group_created group_id, created_at Index
idx_builder_orders_group_id group_id Index
idx_builder_orders_token_id token_id Index
idx_builder_orders_writer_id writer_id Index

Constraints

Name Type Columns Definition
builder_orders_pkey primary_key id
builder_orders_group_id_fkey foreign_key group_id
builder_orders_writer_id_fkey foreign_key writer_id
builder_orders_order_volume_check check
builder_orders_price_check check
builder_orders_request_path_check check
builder_orders_side_check check
builder_orders_token_id_check check

Relationships

unified.dead_letter_queue

Failed events for retry and debugging

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
message_type TEXT No Type of message (market_update, websocket_event, api_call)
payload JSONB No Original message payload as JSON
platform TEXT No Platform that generated the message
market_id TEXT Yes Market ID if applicable
original_timestamp TIMESTAMP No
failure_reason TEXT No Reason for message failure
retry_count INTEGER No 0 Number of retry attempts made
max_retries INTEGER No 3 Maximum retry attempts allowed
status TEXT No 'pending'::text Current message status
created_at TIMESTAMP No now()
updated_at TIMESTAMP No now()
next_retry_at TIMESTAMP Yes When to retry the message next
resolved_at TIMESTAMP Yes When the message was successfully resolved
metadata JSONB Yes '{}'::jsonb Additional metadata as JSON

Indexes

Name Columns Type
idx_dead_letter_queue_created_at created_at Index
idx_dead_letter_queue_market_id market_id Index
idx_dead_letter_queue_message_type message_type Index
idx_dead_letter_queue_next_retry next_retry_at Index
idx_dead_letter_queue_platform platform Index
idx_dead_letter_queue_status status Index

Constraints

Name Type Columns Definition
dead_letter_queue_pkey primary_key id
chk_dead_letter_queue_platform check
chk_dead_letter_queue_retry_count check
chk_dead_letter_queue_status check

unified.embedding_queue

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
entity_type TEXT No
entity_id UUID No
text_content TEXT No
embedding_type TEXT No
status TEXT Yes 'pending'::text
created_at TIMESTAMP Yes now()
processed_at TIMESTAMP Yes
error_message TEXT Yes
retry_count INTEGER Yes 0

Indexes

Name Columns Type
idx_embedding_queue_entity entity_type, entity_id Index
idx_embedding_queue_status status Index

Constraints

Name Type Columns Definition
embedding_queue_pkey primary_key id
embedding_queue_embedding_type_check check
embedding_queue_entity_type_check check
embedding_queue_status_check check

unified.event_series

Columns

Name Type Nullable Default Description
event_id PK FK UUID No
References: unified.events(id)
series_id PK FK UUID No
References: unified.series(id)
position INTEGER Yes
created_at TIMESTAMP Yes now()

Indexes

Name Columns Type
idx_event_series_event event_id Index
idx_event_series_position series_id, position Index
idx_event_series_series series_id Index

Constraints

Name Type Columns Definition
event_series_pkey primary_key event_id, series_id
event_series_event_id_fkey foreign_key event_id
event_series_series_id_fkey foreign_key series_id

Relationships

unified.events

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
title TEXT No
normalized_title TEXT Yes
description TEXT Yes
category TEXT Yes
subcategory TEXT Yes
start_date TIMESTAMP Yes
end_date TIMESTAMP Yes
resolution_date TIMESTAMP Yes
status TEXT No 'active'::text
is_active BOOLEAN Yes true
total_markets INTEGER Yes 0
active_markets INTEGER Yes 0
resolved_markets INTEGER Yes 0
total_volume NUMERIC(20, 8) Yes 0
platforms ARRAY Yes '{}'::text[]
platform_count INTEGER Yes 0
kalshi_event_id TEXT Yes
kalshi_event_ticker TEXT Yes
polymarket_event_id TEXT Yes
polymarket_event_slug TEXT Yes
limitless_event_id TEXT Yes
similarity_hash TEXT Yes
title_embedding NULL Yes
tags ARRAY Yes
platform_metadata JSONB Yes '{}'::jsonb
created_at TIMESTAMP Yes now()
updated_at TIMESTAMP Yes now()
last_synced TIMESTAMP Yes now()

Indexes

Name Columns Type
events_unique_hash similarity_hash Unique
events_unique_kalshi_id kalshi_event_id Unique
events_unique_polymarket_id polymarket_event_id Unique
idx_events_active is_active Index
idx_events_category category, subcategory Index
idx_events_dates start_date, end_date Index
idx_events_embedding title_embedding Index
idx_events_kalshi_id kalshi_event_id Index
idx_events_normalized_title normalized_title Index
idx_events_platforms platforms Index
idx_events_polymarket_id polymarket_event_id Index
idx_events_similarity_hash similarity_hash Index
idx_events_status status Index
idx_events_tags tags Index

Constraints

Name Type Columns Definition
events_pkey primary_key id
events_unique_hash unique similarity_hash
events_unique_kalshi_id unique kalshi_event_id
events_unique_polymarket_id unique polymarket_event_id
events_dates_check check
events_market_counts_check check
events_status_check check

Relationships

limitlessctfexchange.fee_charged

Columns

Name Type Nullable Default Description
id PK VARCHAR No
receiver TEXT No
token_id NUMERIC No
amount NUMERIC No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
fee_charged_pkey primary_key id

unified.fund_prices_daily

Precomputed daily fund prices for fast time series queries and paper trading simulations

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
group_id FK UUID No Reference to the market group (fund) this price belongs to
References: unified.market_groups(id)
price_date DATE No Date for this price snapshot (date only, no time component)
price NUMERIC(10, 6) No Weighted average price of all markets in the fund (0.0 to 1.0), accounting for position types
market_count INTEGER No Total number of markets included in the computation
polymarket_count INTEGER No Number of Polymarket markets included (subset of market_count)
total_weight NUMERIC(12, 4) No Sum of all market weights used in the computation
data_completeness NUMERIC(5, 2) Yes Percentage of markets that had price data available (0-100)
avg_price_age_hours INTEGER Yes Average age in hours of the constituent market prices used
computation_method VARCHAR(50) No 'batch'::character varying How this price was computed: batch (scheduled job) or on_demand (API request)
computed_at TIMESTAMP No now() Timestamp when this price was computed
computation_duration_ms INTEGER Yes Time taken to compute this price in milliseconds
metadata JSONB No '{}'::jsonb Additional context as JSON (e.g., markets skipped, errors encountered, data sources)
created_at TIMESTAMP No now() Timestamp when this record was first created
updated_at TIMESTAMP No now() Timestamp when this record was last updated

Indexes

Name Columns Type
idx_fund_prices_computed_at computed_at Index
idx_fund_prices_date price_date Index
idx_fund_prices_group_date group_id, price_date Index
idx_fund_prices_method computation_method Index
unique_group_date group_id, price_date Unique

Constraints

Name Type Columns Definition
fund_prices_daily_pkey primary_key id
fund_prices_daily_group_id_fkey foreign_key group_id
unique_group_date unique group_id, price_date
fund_prices_daily_avg_price_age_hours_check check
fund_prices_daily_computation_duration_ms_check check
fund_prices_daily_data_completeness_check check
fund_prices_daily_market_count_check check
fund_prices_daily_polymarket_count_check check
fund_prices_daily_price_check check
fund_prices_daily_total_weight_check check
valid_polymarket_count check

Relationships

unified.group_market_relationships

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
group_id FK UUID No
References: unified.market_groups(id)
market_id UUID No
weight NUMERIC(10, 4) Yes 1.0
position_type VARCHAR(20) Yes
metadata JSONB Yes '{}'::jsonb
added_at TIMESTAMP Yes now()
updated_at TIMESTAMP Yes now()

Indexes

Name Columns Type
idx_gmr_group_id group_id Index
idx_gmr_group_market group_id, market_id Index
idx_gmr_market_id market_id Index
unique_group_market group_id, market_id Unique

Constraints

Name Type Columns Definition
group_market_relationships_pkey primary_key id
group_market_relationships_group_id_fkey foreign_key group_id
unique_group_market unique group_id, market_id
group_market_relationships_position_type_check check
group_market_relationships_weight_check check
valid_weight check

Relationships

unified.group_membership_history

Audit log of all changes to group membership (add/remove markets, weight changes)

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
group_id FK UUID No
References: unified.market_groups(id)
market_id UUID No Market UUID - no FK constraint to preserve history even if market is deleted
action VARCHAR(20) No Type of change: added (new market), removed (deleted market), weight_changed (existing market weight updated)
timestamp TIMESTAMP No now() When the change occurred (defaults to NOW but can be backdated for imports)
weight NUMERIC(10, 4) Yes Weight after the change (NULL for removed markets)
position_type VARCHAR(20) Yes
changed_by VARCHAR(100) Yes
metadata JSONB No '{}'::jsonb Additional context as JSON. For resolution events, includes: { "settlement_value": 100.50, -- Total value received (shares × price) "settlement_price": 1.0, -- Resolution price (0.0, 0.5, or 1.0) "resolution_outcome": "YES", -- YES, NO, or INVALID "resolution_time": "2024-12-09T15:00:00Z", "position_details": { "shares": 100.0, -- Number of shares held "entry_price": 0.75, -- Average entry price "exit_price": 1.0, -- Resolution price (adjusted for position_type) "position_type": "long", -- long or short "cost_basis": 75.0 -- Total cost (shares × entry_price) }, "profit_loss": 25.0, -- settlement_value - cost_basis "profit_loss_percent": 33.33, -- (profit_loss / cost_basis) × 100 "holding_period_days": 14, -- Days from first entry to resolution "platform_market_id": "0xabc123", -- Platform-specific ID "market_title": "Will MongoDB beat earnings?", "platform": "polymarket", -- polymarket or kalshi "source": "automatic_cleanup", -- Always automatic for resolutions "cleanup_job_id": "uuid", -- ID of cleanup job that processed this "processed_at": "2024-12-10T03:00:00Z" }
created_at TIMESTAMP No now()

Indexes

Name Columns Type
idx_gmh_action action Index
idx_gmh_action_timestamp action, timestamp Index
idx_gmh_group_timestamp group_id, timestamp Index
idx_gmh_market_resolved market_id, timestamp Index
idx_gmh_market_timestamp market_id, timestamp Index
idx_gmh_resolved_actions group_id, timestamp Index
idx_gmh_timestamp timestamp Index

Constraints

Name Type Columns Definition
group_membership_history_pkey primary_key id
group_membership_history_group_id_fkey foreign_key group_id
group_membership_history_action_check check
group_membership_history_position_type_check check

Relationships

pmf.group_nav_hourly

Hourly NAV snapshots for market groups

Columns

Name Type Nullable Default Description
group_id PK FK UUID No Foreign key to market_groups
References: unified.market_groups(id)
ts PK TIMESTAMP No Snapshot timestamp, truncated to hour boundary
nav NUMERIC(12, 2) No Total portfolio value in base currency
nav_normalized NUMERIC(10, 6) No Normalized NAV (1.0 at inception)
cash_value NUMERIC(12, 2) No Uninvested cash portion
invested_value NUMERIC(12, 2) No Market value of all positions
invested_ratio NUMERIC(5, 4) No Percentage invested (0.0 to 1.0)
base_currency TEXT No 'USDC'::text Currency unit for NAV calculations
nav_metadata JSONB No '{}'::jsonb Additional metadata (quality indicators, errors, etc.)

Indexes

Name Columns Type
idx_nav_hourly_group_ts group_id, ts Index
idx_nav_hourly_ts ts Index

Constraints

Name Type Columns Definition
group_nav_hourly_pkey primary_key group_id, ts
group_nav_hourly_group_id_fkey foreign_key group_id
chk_cash_value_non_negative check
chk_invested_ratio_range check
chk_invested_value_non_negative check
chk_nav_normalized_positive check
chk_nav_positive check

Relationships

unified.group_templates

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
name VARCHAR(100) No
description TEXT Yes
group_type VARCHAR(10) No
template_config JSONB No
is_active BOOLEAN Yes true
created_at TIMESTAMP Yes now()
updated_at TIMESTAMP Yes now()
version INTEGER Yes 1
author VARCHAR(100) Yes
tags ARRAY Yes
usage_count INTEGER Yes 0
last_used_at TIMESTAMP Yes
validation_rules JSONB Yes '{}'::jsonb
required_permissions ARRAY Yes
validation_status VARCHAR(20) Yes 'pending'::character varying

Indexes

Name Columns Type
group_templates_name_key name Unique
idx_group_templates_active is_active Index
idx_group_templates_type group_type Index

Constraints

Name Type Columns Definition
group_templates_pkey primary_key id
group_templates_name_key unique name

Relationships

public.grouped_markets

Columns

Name Type Nullable Default Description
id PK VARCHAR(255) No
title TEXT No
final_end_date TIMESTAMP No
created_at TIMESTAMP No '2025-07-06 21:57:45.966909+00'::timestamp with time zone
updated_at TIMESTAMP No '2025-07-06 21:57:45.966909+00'::timestamp with time zone
market_ids JSONB No '{}'::jsonb
platforms JSONB No '{}'::jsonb
metrics JSONB No '{}'::jsonb

Constraints

Name Type Columns Definition
grouped_markets_pkey primary_key id

Relationships

unified.grouping_log

Audit log for all grouping actions (creation, verification, rejection)

Columns

Name Type Nullable Default Description
id PK INTEGER No nextval('unified.grouping_log_id_seq'::regclass)
group_id UUID Yes
action VARCHAR(20) Yes Type of action: created, verified, rejected, expired
actor VARCHAR(50) Yes System or username who performed the action
details TEXT Yes
created_at TIMESTAMP Yes now()

Indexes

Name Columns Type
idx_grouping_log_action action Index
idx_grouping_log_created_at created_at Index
idx_grouping_log_group_id group_id Index

Constraints

Name Type Columns Definition
grouping_log_pkey primary_key id

limitlessctfexchange.hot_block

Columns

Name Type Nullable Default Description
height PK INTEGER No nextval('limitlessctfexchange.hot_block_height_seq'::regclass)
hash TEXT No

Constraints

Name Type Columns Definition
hot_block_pkey primary_key height

limitlessctfexchange.hot_change_log

Columns

Name Type Nullable Default Description
block_height PK INTEGER No
index PK INTEGER No
change JSONB No

Constraints

Name Type Columns Definition
hot_change_log_pkey primary_key block_height, index

public.kalshi_markets

Columns

Name Type Nullable Default Description
market_id PK VARCHAR(255) No
event_ticker VARCHAR(255) No
title TEXT No
description TEXT Yes
status VARCHAR(50) No
expiration_date TIMESTAMP Yes
category VARCHAR(255) Yes
subcategory VARCHAR(255) Yes
volume NUMERIC Yes
open_interest NUMERIC Yes
volume_24h NUMERIC Yes
total_trades INTEGER Yes
last_trade_time TIMESTAMP Yes
best_bid_price NUMERIC(20, 8) Yes
best_bid_size NUMERIC(20, 8) Yes
best_ask_price NUMERIC(20, 8) Yes
best_ask_size NUMERIC(20, 8) Yes
last_trade_price NUMERIC(20, 8) Yes
adjusted_midpoint NUMERIC(20, 8) Yes
created_at TIMESTAMP No '2025-07-06 21:57:45.966909+00'::timestamp with time zone
updated_at TIMESTAMP No '2025-07-06 21:57:45.966909+00'::timestamp with time zone
last_checked TIMESTAMP No '2025-07-06 21:57:45.966909+00'::timestamp with time zone
group_id FK VARCHAR(255) Yes
References: public.grouped_markets(id)
group_similarity NUMERIC(20, 8) Yes

Indexes

Name Columns Type
idx_kalshi_markets_event_ticker event_ticker Index
idx_kalshi_markets_expiration expiration_date Index
idx_kalshi_markets_group_id group_id Index
idx_kalshi_markets_last_checked last_checked Index
idx_kalshi_markets_status status Index

Constraints

Name Type Columns Definition
kalshi_markets_pkey primary_key market_id
kalshi_markets_group_id_fkey foreign_key group_id

Relationships

unified.market_events_recent

HOT TABLE: Recent trades and lifecycle events. Circular buffer keeping last 100 events per market. Auto-cleaned after 1 hour. Use for recent activity feeds and trade history.

Columns

Name Type Nullable Default Description
id PK BIGINT No nextval('unified.market_events_recent_id_seq'::regclass)
platform TEXT No
platform_market_id TEXT No
event_type TEXT No
trade_price NUMERIC(10, 6) Yes
trade_size NUMERIC(20, 8) Yes
trade_side TEXT Yes
old_status TEXT Yes
new_status TEXT Yes
status_reason TEXT Yes
event_data JSONB Yes
occurred_at TIMESTAMP Yes now()
websocket_session_id TEXT Yes
created_at TIMESTAMP Yes now()

Indexes

Name Columns Type
idx_events_recent_created created_at Index
idx_events_recent_market platform, platform_market_id, occurred_at Index
idx_events_recent_trades platform_market_id, trade_price, occurred_at Index
idx_events_recent_type event_type, occurred_at Index

Constraints

Name Type Columns Definition
market_events_recent_pkey primary_key id

public.market_group_items

Columns

Name Type Nullable Default Description
id PK UUID No
group_id UUID No
market_id VARCHAR No
market_type VARCHAR No
created_at TIMESTAMP Yes

Constraints

Name Type Columns Definition
market_group_items_pkey primary_key id

unified.market_group_members

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
group_id FK UUID No
References: unified.market_groups(id)
market_id UUID No
similarity_score NUMERIC(5, 4) Yes 1.0
is_representative BOOLEAN Yes false
added_at TIMESTAMP Yes now()

Indexes

Name Columns Type
idx_market_group_members_group_id group_id Index
idx_market_group_members_group_market group_id, market_id Index
idx_market_group_members_market_id market_id Index
market_group_members_group_id_market_id_key group_id, market_id Unique

Constraints

Name Type Columns Definition
market_group_members_pkey primary_key id
market_group_members_group_id_fkey foreign_key group_id
market_group_members_group_id_market_id_key unique group_id, market_id

Relationships

unified.market_group_verification_log

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
group_id FK UUID No
References: unified.market_groups(id)
action TEXT No
previous_state JSONB Yes
new_state JSONB Yes
verified_by TEXT No
created_at TIMESTAMP Yes now()

Indexes

Name Columns Type
idx_verification_log_group_id group_id Index

Constraints

Name Type Columns Definition
market_group_verification_log_pkey primary_key id
market_group_verification_log_group_id_fkey foreign_key group_id

Relationships

unified.market_groups

Cross-platform market correlations for arbitrage detection

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
title TEXT No
description TEXT Yes
status TEXT Yes 'active'::text
similarity_threshold NUMERIC(3, 2) Yes 0.4
created_at TIMESTAMP Yes now()
updated_at TIMESTAMP Yes now()
title_embedding NULL Yes
description_embedding NULL Yes
platform_count INTEGER Yes 0
market_count INTEGER Yes 0
total_volume NUMERIC(15, 2) Yes 0
total_liquidity NUMERIC(15, 2) Yes 0
consensus_price NUMERIC(10, 6) Yes
price_variance NUMERIC(10, 6) Yes
human_verified BOOLEAN Yes false When true, this group is tradeable. human_verified = tradeable in our simplified system.
verified_at TIMESTAMP Yes
verified_by TEXT Yes Username/ID of admin who verified this group
verification_notes TEXT Yes Admin notes about the verification decision
is_valid_group BOOLEAN Yes Admin determination: NULL=not reviewed, TRUE=correctly grouped, FALSE=incorrectly grouped
confidence NUMERIC(3, 2) Yes 0.00 Automated confidence score (0.00-1.00) for group quality
grouping_method VARCHAR(50) Yes 'manual'::character varying Algorithm used to create group (e.g., multi_stage_v2)
rejection_count INTEGER Yes 0 Number of times this group has been rejected in verification
is_system_generated BOOLEAN Yes false
is_template BOOLEAN Yes false
template_name VARCHAR(100) Yes
metadata JSONB Yes '{}'::jsonb Type-specific configuration including agent_deployment: { "agent_deployment": { "agent_id": "uuid", "wallet_address": "0x...", "telegram_bot_id": "123456789:ABC...", "telegram_chat_id": "987654321", "deployment_status": "pending|deploying|deployed|waiting_wallet|ready|failed", "tee_endpoint": "https://...", "deployed_at": "2025-01-15T10:30:00Z", "wallet_retrieved_at": "2025-01-15T10:31:00Z", "whitelisted_at": "2025-01-15T10:32:00Z", "trading_config": { "max_position_size": 100, "min_confidence_threshold": 0.7, "unsupervised_mode": false }, "error_message": "optional error details if deployment fails" } }
display_settings JSONB Yes '{}'::jsonb
group_type VARCHAR(10) Yes 'same_event'::unified.group_type
source_template_id FK UUID Yes
References: unified.group_templates(id)
template_version INTEGER Yes
auto_update_from_template BOOLEAN Yes false
max_spread NUMERIC(5, 4) Yes
has_arbitrage_opportunity BOOLEAN Yes false
max_arbitrage_profit NUMERIC(10, 4) Yes
last_arbitrage_check TIMESTAMP Yes
final_resolution_time TIMESTAMP Yes
manager VARCHAR(255) Yes Name or identifier of the group manager/creator
logo_url TEXT Yes URL to the group logo or branding image
is_paper_trading BOOLEAN No false Flag indicating if this is a simulated (paper trading) portfolio vs real money portfolio
initial_capital NUMERIC(12, 2) Yes 100.00 Starting capital for paper trading portfolios (default $100)
current_cash NUMERIC(12, 2) Yes 100.00 Current unallocated cash in the portfolio
paper_trading_config JSONB Yes '{}'::jsonb Configuration for paper trading simulations (fee settings, etc.)
track_nav BOOLEAN No false Enable hourly NAV computation for this group
base_currency TEXT No 'USDC'::text Currency for NAV calculations (USDC, USD, etc.)

Indexes

Name Columns Type
idx_market_groups_active_id_title id, title, status, updated_at Index
idx_market_groups_admin_verified human_verified, is_valid_group Index
idx_market_groups_agent_deployment None Index
idx_market_groups_agent_wallet None Index
idx_market_groups_confidence confidence Index
idx_market_groups_human_verified human_verified Index
idx_market_groups_manager manager Index
idx_market_groups_status status Index
idx_market_groups_status_updated_at status, updated_at Index
idx_market_groups_system_generated is_system_generated Index
idx_market_groups_template is_template Index
idx_market_groups_type group_type Index
idx_market_groups_updated_at updated_at Index

Constraints

Name Type Columns Definition
market_groups_pkey primary_key id
market_groups_source_template_id_fkey foreign_key source_template_id
market_groups_rejection_count_check check
market_groups_status_check check

Relationships

unified.market_history

Partitioned table for historical market price data

Columns

Name Type Nullable Default Description
timestamp PK TIMESTAMP No
market_id PK UUID No
platform TEXT No
yes_price NUMERIC(5, 4) Yes
no_price NUMERIC(5, 4) Yes
volume NUMERIC(15, 2) Yes
liquidity NUMERIC(15, 2) Yes

Constraints

Name Type Columns Definition
market_history_pkey primary_key market_id, timestamp

unified.market_history_2025_09

Columns

Name Type Nullable Default Description
timestamp PK TIMESTAMP No
market_id PK UUID No
platform TEXT No
yes_price NUMERIC(5, 4) Yes
no_price NUMERIC(5, 4) Yes
volume NUMERIC(15, 2) Yes
liquidity NUMERIC(15, 2) Yes

Indexes

Name Columns Type
idx_market_history_2025_09_market_id market_id Index

Constraints

Name Type Columns Definition
market_history_2025_09_pkey primary_key market_id, timestamp

unified.market_history_2025_10

Columns

Name Type Nullable Default Description
timestamp PK TIMESTAMP No
market_id PK UUID No
platform TEXT No
yes_price NUMERIC(5, 4) Yes
no_price NUMERIC(5, 4) Yes
volume NUMERIC(15, 2) Yes
liquidity NUMERIC(15, 2) Yes

Indexes

Name Columns Type
idx_market_history_2025_10_market_id market_id Index

Constraints

Name Type Columns Definition
market_history_2025_10_pkey primary_key market_id, timestamp

unified.market_history_2025_11

Columns

Name Type Nullable Default Description
timestamp PK TIMESTAMP No
market_id PK UUID No
platform TEXT No
yes_price NUMERIC(5, 4) Yes
no_price NUMERIC(5, 4) Yes
volume NUMERIC(15, 2) Yes
liquidity NUMERIC(15, 2) Yes

Constraints

Name Type Columns Definition
market_history_2025_11_pkey primary_key market_id, timestamp

unified.market_prices_current

HOT TABLE: Latest price and volume data for each market. Updated on every ticker/price WebSocket event. One row per market, constantly UPSERTed. Use for real-time price queries and monitoring.

Columns

Name Type Nullable Default Description
platform PK TEXT No
platform_market_id PK TEXT No
best_bid_price NUMERIC(10, 6) Yes
best_ask_price NUMERIC(10, 6) Yes
last_trade_price NUMERIC(10, 6) Yes
volume_24h NUMERIC(20, 8) Yes
volume_total NUMERIC(20, 8) Yes
liquidity_depth NUMERIC(20, 8) Yes
spread NUMERIC(10, 6) Yes
mid_price NUMERIC(10, 6) Yes
price_change_24h NUMERIC(10, 6) Yes
price_change_pct_24h NUMERIC(10, 4) Yes
high_24h NUMERIC(10, 6) Yes
low_24h NUMERIC(10, 6) Yes
market_status TEXT Yes
resolution_value NUMERIC(10, 6) Yes
resolved_at TIMESTAMP Yes
last_ticker_update TIMESTAMP Yes
last_trade_update TIMESTAMP Yes
last_orderbook_update TIMESTAMP Yes
updated_at TIMESTAMP Yes now()
update_count BIGINT Yes 0
websocket_session_id TEXT Yes

Indexes

Name Columns Type
idx_market_prices_current_updated updated_at Index
idx_prices_current_status market_status Index
idx_prices_current_updated updated_at Index
idx_prices_current_volume volume_24h Index

Constraints

Name Type Columns Definition
market_prices_current_pkey primary_key platform, platform_market_id

unified.market_similarity_cache

Cached similarity calculations for performance

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
market_a_id UUID No
market_b_id UUID No
similarity_score NUMERIC(5, 4) No
similarity_method VARCHAR(50) No
calculated_at TIMESTAMP Yes now()

Indexes

Name Columns Type
idx_similarity_cache_method similarity_method Index
idx_similarity_cache_score similarity_score Index
market_similarity_cache_market_a_id_market_b_id_similarity__key market_a_id, market_b_id, similarity_method Unique

Constraints

Name Type Columns Definition
market_similarity_cache_pkey primary_key id
market_similarity_cache_market_a_id_market_b_id_similarity__key unique market_a_id, market_b_id, similarity_method

unified.markets

Columns

Name Type Nullable Default Description
id PK UUID No
platform TEXT No
platform_market_id TEXT No
title TEXT Yes
description TEXT Yes
status TEXT Yes
category TEXT Yes
market_type TEXT Yes
market_open_time TIMESTAMP Yes
market_close_time TIMESTAMP Yes
settlement_time TIMESTAMP Yes
settlement_value NUMERIC Yes
yes_price NUMERIC Yes
no_price NUMERIC Yes
yes_bid NUMERIC Yes
yes_ask NUMERIC Yes
no_bid NUMERIC Yes
no_ask NUMERIC Yes
best_bid_price NUMERIC Yes
best_ask_price NUMERIC Yes
best_bid_size NUMERIC Yes
best_ask_size NUMERIC Yes
last_trade_price NUMERIC Yes
last_trade_time TIMESTAMP Yes
total_volume NUMERIC Yes
volume_24h NUMERIC Yes
open_interest NUMERIC Yes
liquidity NUMERIC Yes
implied_probability NUMERIC Yes
url TEXT Yes
rules TEXT Yes
metadata JSONB Yes
created_at TIMESTAMP Yes now()
updated_at TIMESTAMP Yes now()
is_active PK BOOLEAN No true
event_ticker TEXT Yes
subcategory TEXT Yes
rules_primary TEXT Yes
rules_secondary TEXT Yes
expected_settlement_time TIMESTAMP Yes
settlement_source TEXT Yes
settlement_description TEXT Yes
tags ARRAY Yes
image_url TEXT Yes
platform_created_at TIMESTAMP Yes
platform_updated_at TIMESTAMP Yes
market_slug TEXT Yes
yes_token_id TEXT Yes
no_token_id TEXT Yes
midpoint_price NUMERIC Yes
spread NUMERIC Yes
volume_yes NUMERIC Yes
volume_no NUMERIC Yes
liquidity_yes NUMERIC Yes
liquidity_no NUMERIC Yes
trade_count INTEGER Yes
trader_count INTEGER Yes
minimum_order_size NUMERIC Yes
minimum_tick_size NUMERIC Yes
data_source TEXT Yes
is_test_market BOOLEAN Yes false
raw_data JSONB Yes
market_group_id UUID Yes
group_confidence_score NUMERIC Yes
group_method TEXT Yes
title_embedding NULL Yes
description_embedding NULL Yes
combined_embedding NULL Yes
data_quality_score NUMERIC Yes
has_sufficient_volume BOOLEAN Yes
has_recent_activity BOOLEAN Yes
has_stable_prices BOOLEAN Yes
has_trading_bonus BOOLEAN Yes
bonus_amount NUMERIC Yes
bonus_currency TEXT Yes
expiry_date TIMESTAMP Yes
event_id UUID Yes
contract_volume NUMERIC Yes 0
yes_best_buy_size NUMERIC Yes 0
no_best_buy_size NUMERIC Yes 0
yes_best_sell_size NUMERIC Yes 0
no_best_sell_size NUMERIC Yes 0
total_trades INTEGER Yes 0
unique_traders INTEGER Yes 0

Indexes

Name Columns Type
idx_markets_is_active is_active Index
idx_markets_platform platform Index
idx_markets_platform_market_id platform, platform_market_id, is_active Unique
idx_markets_updated_at updated_at Index

Constraints

Name Type Columns Definition
markets_pkey primary_key id, is_active

unified.markets_active

Columns

Name Type Nullable Default Description
id PK UUID No
platform TEXT No
platform_market_id TEXT No
title TEXT Yes
description TEXT Yes
status TEXT Yes
category TEXT Yes
market_type TEXT Yes
market_open_time TIMESTAMP Yes
market_close_time TIMESTAMP Yes
settlement_time TIMESTAMP Yes
settlement_value NUMERIC Yes
yes_price NUMERIC Yes
no_price NUMERIC Yes
yes_bid NUMERIC Yes
yes_ask NUMERIC Yes
no_bid NUMERIC Yes
no_ask NUMERIC Yes
best_bid_price NUMERIC Yes
best_ask_price NUMERIC Yes
best_bid_size NUMERIC Yes
best_ask_size NUMERIC Yes
last_trade_price NUMERIC Yes
last_trade_time TIMESTAMP Yes
total_volume NUMERIC Yes
volume_24h NUMERIC Yes
open_interest NUMERIC Yes
liquidity NUMERIC Yes
implied_probability NUMERIC Yes
url TEXT Yes
rules TEXT Yes
metadata JSONB Yes
created_at TIMESTAMP Yes now()
updated_at TIMESTAMP Yes now()
is_active PK BOOLEAN No true
event_ticker TEXT Yes
subcategory TEXT Yes
rules_primary TEXT Yes
rules_secondary TEXT Yes
expected_settlement_time TIMESTAMP Yes
settlement_source TEXT Yes
settlement_description TEXT Yes
tags ARRAY Yes
image_url TEXT Yes
platform_created_at TIMESTAMP Yes
platform_updated_at TIMESTAMP Yes
market_slug TEXT Yes
yes_token_id TEXT Yes
no_token_id TEXT Yes
midpoint_price NUMERIC Yes
spread NUMERIC Yes
volume_yes NUMERIC Yes
volume_no NUMERIC Yes
liquidity_yes NUMERIC Yes
liquidity_no NUMERIC Yes
trade_count INTEGER Yes
trader_count INTEGER Yes
minimum_order_size NUMERIC Yes
minimum_tick_size NUMERIC Yes
data_source TEXT Yes
is_test_market BOOLEAN Yes false
raw_data JSONB Yes
market_group_id UUID Yes
group_confidence_score NUMERIC Yes
group_method TEXT Yes
title_embedding NULL Yes
description_embedding NULL Yes
combined_embedding NULL Yes
data_quality_score NUMERIC Yes
has_sufficient_volume BOOLEAN Yes
has_recent_activity BOOLEAN Yes
has_stable_prices BOOLEAN Yes
has_trading_bonus BOOLEAN Yes
bonus_amount NUMERIC Yes
bonus_currency TEXT Yes
expiry_date TIMESTAMP Yes
event_id UUID Yes
contract_volume NUMERIC Yes 0
yes_best_buy_size NUMERIC Yes 0
no_best_buy_size NUMERIC Yes 0
yes_best_sell_size NUMERIC Yes 0
no_best_sell_size NUMERIC Yes 0
total_trades INTEGER Yes 0
unique_traders INTEGER Yes 0

Indexes

Name Columns Type
markets_active_is_active_idx is_active Index
markets_active_platform_idx platform Index
markets_active_platform_platform_market_id_is_active_idx platform, platform_market_id, is_active Unique
markets_active_updated_at_idx updated_at Index

Constraints

Name Type Columns Definition
markets_active_pkey primary_key id, is_active

unified.markets_inactive

Columns

Name Type Nullable Default Description
id PK UUID No
platform TEXT No
platform_market_id TEXT No
title TEXT Yes
description TEXT Yes
status TEXT Yes
category TEXT Yes
market_type TEXT Yes
market_open_time TIMESTAMP Yes
market_close_time TIMESTAMP Yes
settlement_time TIMESTAMP Yes
settlement_value NUMERIC Yes
yes_price NUMERIC Yes
no_price NUMERIC Yes
yes_bid NUMERIC Yes
yes_ask NUMERIC Yes
no_bid NUMERIC Yes
no_ask NUMERIC Yes
best_bid_price NUMERIC Yes
best_ask_price NUMERIC Yes
best_bid_size NUMERIC Yes
best_ask_size NUMERIC Yes
last_trade_price NUMERIC Yes
last_trade_time TIMESTAMP Yes
total_volume NUMERIC Yes
volume_24h NUMERIC Yes
open_interest NUMERIC Yes
liquidity NUMERIC Yes
implied_probability NUMERIC Yes
url TEXT Yes
rules TEXT Yes
metadata JSONB Yes
created_at TIMESTAMP Yes now()
updated_at TIMESTAMP Yes now()
is_active PK BOOLEAN No true
event_ticker TEXT Yes
subcategory TEXT Yes
rules_primary TEXT Yes
rules_secondary TEXT Yes
expected_settlement_time TIMESTAMP Yes
settlement_source TEXT Yes
settlement_description TEXT Yes
tags ARRAY Yes
image_url TEXT Yes
platform_created_at TIMESTAMP Yes
platform_updated_at TIMESTAMP Yes
market_slug TEXT Yes
yes_token_id TEXT Yes
no_token_id TEXT Yes
midpoint_price NUMERIC Yes
spread NUMERIC Yes
volume_yes NUMERIC Yes
volume_no NUMERIC Yes
liquidity_yes NUMERIC Yes
liquidity_no NUMERIC Yes
trade_count INTEGER Yes
trader_count INTEGER Yes
minimum_order_size NUMERIC Yes
minimum_tick_size NUMERIC Yes
data_source TEXT Yes
is_test_market BOOLEAN Yes false
raw_data JSONB Yes
market_group_id UUID Yes
group_confidence_score NUMERIC Yes
group_method TEXT Yes
title_embedding NULL Yes
description_embedding NULL Yes
combined_embedding NULL Yes
data_quality_score NUMERIC Yes
has_sufficient_volume BOOLEAN Yes
has_recent_activity BOOLEAN Yes
has_stable_prices BOOLEAN Yes
has_trading_bonus BOOLEAN Yes
bonus_amount NUMERIC Yes
bonus_currency TEXT Yes
expiry_date TIMESTAMP Yes
event_id UUID Yes
contract_volume NUMERIC Yes 0
yes_best_buy_size NUMERIC Yes 0
no_best_buy_size NUMERIC Yes 0
yes_best_sell_size NUMERIC Yes 0
no_best_sell_size NUMERIC Yes 0
total_trades INTEGER Yes 0
unique_traders INTEGER Yes 0

Indexes

Name Columns Type
markets_inactive_is_active_idx is_active Index
markets_inactive_platform_idx platform Index
markets_inactive_platform_platform_market_id_is_active_idx platform, platform_market_id, is_active Unique
markets_inactive_updated_at_idx updated_at Index

Constraints

Name Type Columns Definition
markets_inactive_pkey primary_key id, is_active

migration_system.migration_history

Columns

Name Type Nullable Default Description
id PK INTEGER No nextval('migration_system.migration_history_id_seq'::regclass)
version VARCHAR(50) No
description TEXT Yes
sql_hash VARCHAR(64) No
deployed_at TIMESTAMP Yes now()
deployed_by VARCHAR(100) Yes
status VARCHAR(20) Yes 'success'::character varying
rollback_sql TEXT Yes

Indexes

Name Columns Type
migration_history_version_key version Unique

Constraints

Name Type Columns Definition
migration_history_pkey primary_key id
migration_history_version_key unique version

limitlessctfexchange.migrations

Columns

Name Type Nullable Default Description
id PK INTEGER No nextval('limitlessctfexchange.migrations_id_seq'::regclass)
timestamp INTEGER No
name VARCHAR No

Constraints

Name Type Columns Definition
migrations_pkey primary_key id

limitlessctfexchange.new_admin

Columns

Name Type Nullable Default Description
id PK VARCHAR No
new_admin_address TEXT No
admin TEXT No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
new_admin_pkey primary_key id

limitlessctfexchange.new_operator

Columns

Name Type Nullable Default Description
id PK VARCHAR No
new_operator_address TEXT No
admin TEXT No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
new_operator_pkey primary_key id

trading.opportunities

Log of all detected arbitrage opportunities and APY calculations

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
group_id FK UUID No
References: unified.market_groups(id)
timestamp TIMESTAMP No now()
apy NUMERIC(10, 2) No Annualized percentage yield = (spread / days_to_close) * 365
spread NUMERIC(10, 4) No Profit margin after all fees (1 - total_cost)
days_to_close INTEGER No
kalshi_yes_price NUMERIC(10, 4) Yes
kalshi_no_price NUMERIC(10, 4) Yes
poly_yes_price NUMERIC(10, 4) Yes
poly_no_price NUMERIC(10, 4) Yes
limitless_yes_price NUMERIC(10, 4) Yes
limitless_no_price NUMERIC(10, 4) Yes
yes_platform TEXT Yes Platform to buy YES on for this opportunity
no_platform TEXT Yes Platform to buy NO on for this opportunity
total_cost NUMERIC(10, 4) Yes Total cost including all fees and gas
traded BOOLEAN Yes false Whether a position was opened for this opportunity
trade_reason TEXT Yes
position_id FK UUID Yes
References: trading.positions(id)
market_title TEXT Yes
created_at TIMESTAMP Yes now()
yes_orderbook_liquidity NUMERIC(20, 2) Yes Total YES liquidity available in orderbook ($)
no_orderbook_liquidity NUMERIC(20, 2) Yes Total NO liquidity available in orderbook ($)
executable_size NUMERIC(20, 2) Yes Maximum size that can be executed given orderbook depth
yes_best_ask NUMERIC(10, 6) Yes Best ask price for YES at opportunity detection
no_best_ask NUMERIC(10, 6) Yes Best ask price for NO at opportunity detection
yes_ask_depth INTEGER Yes Number of ask levels in YES orderbook
no_ask_depth INTEGER Yes Number of ask levels in NO orderbook
orderbook_freshness_seconds INTEGER Yes Age of orderbook data in seconds
execution_method TEXT Yes 'market_price'::text Whether opportunity was calculated from market prices or orderbook

Indexes

Name Columns Type
idx_opportunities_apy apy Index
idx_opportunities_group_id group_id Index
idx_opportunities_timestamp timestamp Index
idx_opportunities_traded traded Index

Constraints

Name Type Columns Definition
opportunities_pkey primary_key id
opportunities_group_id_fkey foreign_key group_id
opportunities_position_id_fkey foreign_key position_id
opportunities_execution_method_check check

Relationships

limitlessctfexchange.order

Columns

Name Type Nullable Default Description
id PK VARCHAR No
salt NUMERIC No
maker TEXT No
signer TEXT No
taker TEXT No
token_id NUMERIC No
maker_amount NUMERIC No
taker_amount NUMERIC No
expiration NUMERIC No
nonce NUMERIC No
fee_rate_bps NUMERIC No
side INTEGER No
signature_type INTEGER No
signature TEXT No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No
status_id VARCHAR Yes

Constraints

Name Type Columns Definition
order_pkey primary_key id

unified.order_book_current

Real-time orderbook snapshot for each market/token. Stores full depth (bids/asks arrays) from WebSocket feeds. One row per market/token combination, updated on each orderbook event.

Columns

Name Type Nullable Default Description
id PK INTEGER No nextval('unified.order_book_current_id_seq'::regclass) Auto-incrementing primary key
platform TEXT No Trading platform: polymarket, kalshi, or limitless
market_id TEXT No Platform-specific market identifier (e.g., Polymarket condition_id)
token_type TEXT No Binary outcome token: YES (buy outcome) or NO (sell outcome)
bids JSONB No '[]'::jsonb Array of bid levels [{price, size},...] sorted by price DESC. Price in [0,1], size in base units.
asks JSONB No '[]'::jsonb Array of ask levels [{price, size},...] sorted by price ASC. Price in [0,1], size in base units.
best_bid_price NUMERIC(10, 6) Yes Highest bid price (top of book). Null if no bids.
best_bid_size NUMERIC(20, 8) Yes Size available at best bid price
best_ask_price NUMERIC(10, 6) Yes Lowest ask price (top of book). Null if no asks.
best_ask_size NUMERIC(20, 8) Yes Size available at best ask price
spread NUMERIC(10, 6) Yes Computed: ask - bid. Indicates market liquidity (smaller = more liquid)
mid_price NUMERIC(10, 6) Yes Computed: (bid + ask) / 2. Fair value estimate.
sequence_number BIGINT Yes Platform sequence number for detecting gaps/replays
exchange_timestamp TIMESTAMP Yes When the exchange generated this orderbook state
received_at TIMESTAMP Yes now() When our system first received this update
updated_at TIMESTAMP Yes now() Last modification time (auto-updated by trigger)

Indexes

Name Columns Type
idx_orderbook_current_best_prices best_bid_price, best_ask_price Index
idx_orderbook_current_platform_market platform, market_id Index
idx_orderbook_current_updated updated_at Index
uq_orderbook_current platform, market_id, token_type Unique

Constraints

Name Type Columns Definition
order_book_current_pkey primary_key id
uq_orderbook_current unique platform, market_id, token_type
order_book_current_token_type_check check

limitlessctfexchange.order_cancelled

Columns

Name Type Nullable Default Description
id PK VARCHAR No
order_hash TEXT No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
order_cancelled_pkey primary_key id

limitlessctfexchange.order_filled

Columns

Name Type Nullable Default Description
id PK VARCHAR No
order_hash TEXT No
maker TEXT No
taker TEXT No
maker_asset_id NUMERIC No
taker_asset_id NUMERIC No
maker_amount_filled NUMERIC No
taker_amount_filled NUMERIC No
fee NUMERIC No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
order_filled_pkey primary_key id

limitlessctfexchange.order_status

Columns

Name Type Nullable Default Description
id PK VARCHAR No
is_filled_or_cancelled BOOLEAN No
remaining NUMERIC No
last_updated TIMESTAMP No
block INTEGER No

Constraints

Name Type Columns Definition
order_status_pkey primary_key id

trading.orderbook_snapshots

Historical snapshots of orderbook liquidity and arbitrage opportunities

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
group_id FK UUID No
References: unified.market_groups(id)
timestamp TIMESTAMP No now()
kalshi_yes_liquidity NUMERIC(20, 2) Yes
kalshi_no_liquidity NUMERIC(20, 2) Yes
kalshi_spread NUMERIC(10, 6) Yes
kalshi_mid_price NUMERIC(10, 6) Yes
kalshi_bid_levels INTEGER Yes
kalshi_ask_levels INTEGER Yes
polymarket_yes_liquidity NUMERIC(20, 2) Yes
polymarket_no_liquidity NUMERIC(20, 2) Yes
polymarket_spread NUMERIC(10, 6) Yes
polymarket_mid_price NUMERIC(10, 6) Yes
polymarket_bid_levels INTEGER Yes
polymarket_ask_levels INTEGER Yes
limitless_yes_liquidity NUMERIC(20, 2) Yes
limitless_no_liquidity NUMERIC(20, 2) Yes
limitless_spread NUMERIC(10, 6) Yes
limitless_mid_price NUMERIC(10, 6) Yes
limitless_bid_levels INTEGER Yes
limitless_ask_levels INTEGER Yes
max_executable_arbitrage NUMERIC(20, 2) Yes Maximum arbitrage size given orderbook constraints
best_yes_platform TEXT Yes
best_no_platform TEXT Yes
arbitrage_spread NUMERIC(10, 4) Yes
arbitrage_apy NUMERIC(10, 2) Yes
created_at TIMESTAMP Yes now()

Indexes

Name Columns Type
idx_orderbook_snapshots_arbitrage arbitrage_apy Index
idx_orderbook_snapshots_group_id group_id Index
idx_orderbook_snapshots_timestamp timestamp Index

Constraints

Name Type Columns Definition
orderbook_snapshots_pkey primary_key id
orderbook_snapshots_group_id_fkey foreign_key group_id

Relationships

limitlessctfexchange.orders_matched

Columns

Name Type Nullable Default Description
id PK VARCHAR No
taker_order_hash TEXT No
taker_order_maker TEXT No
maker_asset_id NUMERIC No
taker_asset_id NUMERIC No
maker_amount_filled NUMERIC No
taker_amount_filled NUMERIC No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
orders_matched_pkey primary_key id

public.polymarket_markets

Columns

Name Type Nullable Default Description
market_id PK VARCHAR(255) No
question TEXT No
description TEXT Yes
category VARCHAR(255) Yes
end_date TIMESTAMP Yes
status VARCHAR(50) Yes
volume NUMERIC(20, 8) Yes
liquidity NUMERIC(20, 8) Yes
is_active BOOLEAN Yes
group_id FK VARCHAR(255) Yes
References: public.grouped_markets(id)
group_similarity NUMERIC(20, 8) Yes
yes_token_id VARCHAR(255) Yes
yes_best_buy_price NUMERIC(20, 8) Yes
yes_best_buy_size NUMERIC(20, 8) Yes
yes_best_sell_price NUMERIC(20, 8) Yes
yes_best_sell_size NUMERIC(20, 8) Yes
yes_midpoint NUMERIC(20, 8) Yes
yes_spread NUMERIC(20, 8) Yes
no_token_id VARCHAR(255) Yes
no_best_buy_price NUMERIC(20, 8) Yes
no_best_buy_size NUMERIC(20, 8) Yes
no_best_sell_price NUMERIC(20, 8) Yes
no_best_sell_size NUMERIC(20, 8) Yes
no_midpoint NUMERIC(20, 8) Yes
no_spread NUMERIC(20, 8) Yes
created_at TIMESTAMP Yes '2025-07-06 21:57:45.966909+00'::timestamp with time zone
updated_at TIMESTAMP Yes '2025-07-06 21:57:45.966909+00'::timestamp with time zone
last_checked TIMESTAMP Yes '2025-07-06 21:57:45.966909+00'::timestamp with time zone

Constraints

Name Type Columns Definition
polymarket_markets_pkey primary_key market_id
polymarket_markets_group_id_fkey foreign_key group_id

Relationships

pmf.portfolio_rebalances

Tracks portfolio rebalancing events with detailed allocation snapshots

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid() Unique identifier for the rebalance event
group_id FK UUID No Foreign key to market_groups (portfolio)
References: unified.market_groups(id)
rebalance_timestamp TIMESTAMP No now() When the rebalance occurred
portfolio_value_before NUMERIC(12, 2) No Total portfolio value before rebalancing
portfolio_value_after NUMERIC(12, 2) No Total portfolio value after rebalancing (should be same)
allocations JSONB No JSON array of allocations with percentages, amounts, and shares calculated
rebalance_type VARCHAR(50) Yes 'manual'::character varying Type of rebalance: manual (user), automatic (scheduled), initial (first allocation)
triggered_by VARCHAR(255) Yes User ID or system identifier that triggered the rebalance
notes TEXT Yes Optional notes about the rebalance
created_at TIMESTAMP No now()
updated_at TIMESTAMP No now()

Indexes

Name Columns Type
idx_rebalances_group_id group_id Index
idx_rebalances_group_timestamp group_id, rebalance_timestamp Index
idx_rebalances_timestamp rebalance_timestamp Index
idx_rebalances_type rebalance_type Index

Constraints

Name Type Columns Definition
portfolio_rebalances_pkey primary_key id
portfolio_rebalances_group_id_fkey foreign_key group_id

Relationships

trading.positions

Tracks individual arbitrage positions from entry to exit

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
session_id FK UUID Yes
References: trading.sessions(id)
opportunity_id UUID Yes
strategy_name TEXT No
is_simulation BOOLEAN No true
created_at TIMESTAMP No now()
yes_market_id UUID Yes
yes_platform TEXT No
yes_target_price NUMERIC(20, 8) Yes
yes_executed_price NUMERIC(20, 8) Yes
yes_execution_time TIMESTAMP Yes
yes_size NUMERIC(20, 8) Yes 1.0
yes_fees NUMERIC(20, 8) Yes 0
yes_slippage NUMERIC(20, 8) Yes
no_market_id UUID Yes
no_platform TEXT No
no_target_price NUMERIC(20, 8) Yes
no_executed_price NUMERIC(20, 8) Yes
no_execution_time TIMESTAMP Yes
no_size NUMERIC(20, 8) Yes 1.0
no_fees NUMERIC(20, 8) Yes 0
no_slippage NUMERIC(20, 8) Yes
status TEXT No 'pending'::text
total_invested NUMERIC(20, 8) Yes
max_risk NUMERIC(20, 8) Yes
exit_time TIMESTAMP Yes
exit_reason TEXT Yes
market_resolution TEXT Yes
gross_pnl NUMERIC(20, 8) Yes
total_fees_paid NUMERIC(20, 8) Yes
net_pnl NUMERIC(20, 8) Yes
execution_latency_ms INTEGER Yes
failure_reason TEXT Yes
metadata JSONB Yes '{}'::jsonb
group_id FK UUID Yes Link to the verified market group being traded
References: unified.market_groups(id)
entry_apy NUMERIC(10, 2) Yes APY at time of trade entry (%)
entry_spread NUMERIC(10, 4) Yes Price spread at entry (decimal)
days_to_resolution INTEGER Yes Days until market resolution at entry
yes_levels_consumed INTEGER Yes Number of orderbook levels consumed for YES execution
no_levels_consumed INTEGER Yes Number of orderbook levels consumed for NO execution
yes_avg_execution_price NUMERIC(10, 6) Yes Volume-weighted average price for YES execution from orderbook
no_avg_execution_price NUMERIC(10, 6) Yes Volume-weighted average price for NO execution from orderbook
max_available_liquidity NUMERIC(20, 2) Yes Maximum executable size based on orderbook liquidity at entry
liquidity_constrained_by TEXT Yes Which side limited the trade size (yes/no/both/none)
price_impact_pct NUMERIC(10, 4) Yes Price impact from walking the orderbook (%)
orderbook_timestamp TIMESTAMP Yes Timestamp of orderbook data used for execution

Indexes

Name Columns Type
idx_positions_created_at created_at Index
idx_positions_open status Index
idx_positions_opportunity_id opportunity_id Index
idx_positions_session_id session_id Index
idx_positions_status status Index
idx_positions_strategy strategy_name Index

Constraints

Name Type Columns Definition
positions_pkey primary_key id
positions_group_id_fkey foreign_key group_id
positions_session_id_fkey foreign_key session_id
positions_exit_reason_check check
positions_liquidity_constrained_by_check check
positions_market_resolution_check check
positions_status_check check

Relationships

limitlessctfexchange.proxy_factory_updated

Columns

Name Type Nullable Default Description
id PK VARCHAR No
old_proxy_factory TEXT No
new_proxy_factory TEXT No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
proxy_factory_updated_pkey primary_key id

unified.raw_events

DEPRECATED: Do not use in production. Replaced by specialized hot tables for better performance. Only use for debugging with sampling enabled.

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid() Auto-incrementing primary key
platform TEXT No Source platform
event_type TEXT No Type of event received
market_id TEXT No Platform market identifier
event_data JSONB No Complete event payload (JSONB)
blockchain_data JSONB Yes
ingested_at TIMESTAMP Yes now() When event was received
processed_at TIMESTAMP Yes When event was processed
processing_status TEXT Yes 'pending'::text Processing status
retry_count INTEGER Yes 0 Number of retry attempts
error_message TEXT Yes Error details if failed
api_endpoint TEXT Yes API endpoint called
http_method TEXT Yes 'GET'::text HTTP method used (GET, POST, etc.)
response_time_ms INTEGER Yes API response time in ms
response_status_code INTEGER Yes HTTP status code
rate_limit_remaining INTEGER Yes Number of requests remaining in rate limit window
rate_limit_reset_at TIMESTAMP Yes When rate limit window resets
data_freshness_seconds INTEGER Yes Age of data in seconds when received
api_version TEXT Yes API version used
request_headers JSONB Yes HTTP request headers
response_headers JSONB Yes HTTP response headers
pagination_cursor TEXT Yes Cursor for paginated requests
batch_size INTEGER Yes Number of items in batch request
is_incremental_update BOOLEAN Yes false True if this is an incremental update
parent_request_id UUID Yes Parent request ID for related requests
batch_operation_id FK UUID Yes
References: unified.batch_operations(id)
batch_sequence_number INTEGER Yes
batch_context JSONB Yes
is_realtime BOOLEAN Yes false Whether from WebSocket/realtime
websocket_session_id TEXT Yes Session ID for WebSocket connection that generated this event

Indexes

Name Columns Type
idx_raw_events_api_endpoint api_endpoint Index
idx_raw_events_batch_operation batch_operation_id Index
idx_raw_events_batch_sequence batch_operation_id, batch_sequence_number Index
idx_raw_events_event_type event_type Index
idx_raw_events_failed_retry_optimization processing_status, retry_count, ingested_at Index
idx_raw_events_incremental is_incremental_update Index
idx_raw_events_ingested_at ingested_at Index
idx_raw_events_market_id market_id Index
idx_raw_events_parent_request parent_request_id Index
idx_raw_events_pending platform, ingested_at Index
idx_raw_events_platform platform Index
idx_raw_events_platform_endpoint platform, api_endpoint Index
idx_raw_events_platform_status platform, processing_status Index
idx_raw_events_processing_status processing_status Index
idx_raw_events_realtime is_realtime, platform, ingested_at Index
idx_raw_events_response_status response_status_code Index
idx_raw_events_response_time response_time_ms Index
idx_raw_events_status_code response_status_code Index
idx_raw_events_status_time processing_status, ingested_at Index
idx_raw_events_websocket_session websocket_session_id Index

Constraints

Name Type Columns Definition
raw_events_pkey primary_key id
raw_events_batch_operation_id_fkey foreign_key batch_operation_id
check_batch_size_positive check
check_realtime_session_consistency check
check_response_time_positive check
check_valid_status_code check
raw_events_batch_sequence_number_check check
raw_events_event_type_check check
raw_events_platform_check check
raw_events_processing_status_check check
raw_events_retry_count_check check

Relationships

kalshimarkets.raw_markets

Columns

Name Type Nullable Default Description
market_id PK VARCHAR(255) No
event_ticker VARCHAR(255) No
title TEXT No
description TEXT Yes
category VARCHAR(255) Yes
subcategory VARCHAR(255) Yes
status VARCHAR(50) No
open_time TIMESTAMP No
close_time TIMESTAMP No
settlement_time TIMESTAMP Yes
settlement_value NUMERIC(20, 8) Yes
yes_bid NUMERIC(20, 8) Yes
yes_ask NUMERIC(20, 8) Yes
no_bid NUMERIC(20, 8) Yes
no_ask NUMERIC(20, 8) Yes
volume NUMERIC Yes
open_interest NUMERIC Yes
liquidity NUMERIC Yes
last_trade_price NUMERIC(20, 8) Yes
last_trade_time TIMESTAMP Yes
rules_primary TEXT Yes
rules_secondary TEXT Yes
is_primary_market BOOLEAN Yes
raw_metadata JSON Yes
created_at TIMESTAMP Yes '2025-07-06 21:57:45.966909+00'::timestamp with time zone
updated_at TIMESTAMP Yes '2025-07-06 21:57:45.966909+00'::timestamp with time zone
last_checked TIMESTAMP Yes '2025-07-06 21:57:45.966909+00'::timestamp with time zone

Constraints

Name Type Columns Definition
raw_markets_pkey primary_key market_id

polymarket.raw_markets

Columns

Name Type Nullable Default Description
condition_id PK VARCHAR(255) No
question_id VARCHAR(255) No
question TEXT No
description TEXT Yes
category VARCHAR(255) Yes
end_date_iso TIMESTAMP Yes
game_start_time TIMESTAMP Yes
market_slug VARCHAR(255) Yes
active BOOLEAN Yes
closed BOOLEAN Yes
seconds_delay NUMERIC Yes
icon TEXT Yes
fpmm VARCHAR(255) Yes
minimum_order_size NUMERIC(20, 8) Yes
minimum_tick_size NUMERIC(20, 8) Yes
min_incentive_size NUMERIC(20, 8) Yes
max_incentive_spread NUMERIC(20, 8) Yes
best_bid_price NUMERIC(20, 8) Yes
best_bid_size NUMERIC(20, 8) Yes
best_ask_price NUMERIC(20, 8) Yes
best_ask_size NUMERIC(20, 8) Yes
midpoint_price NUMERIC(20, 8) Yes
spread NUMERIC(20, 8) Yes
volume NUMERIC(20, 8) Yes
liquidity NUMERIC(20, 8) Yes
token_yes_id VARCHAR(255) Yes
token_yes_outcome TEXT Yes
token_no_id VARCHAR(255) Yes
token_no_outcome TEXT Yes
raw_metadata JSON Yes
created_at TIMESTAMP Yes '2025-07-06 21:57:45.966909+00'::timestamp with time zone
updated_at TIMESTAMP Yes '2025-07-06 21:57:45.966909+00'::timestamp with time zone
last_checked TIMESTAMP Yes '2025-07-06 21:57:45.966909+00'::timestamp with time zone

Constraints

Name Type Columns Definition
raw_markets_pkey primary_key condition_id

limitlessctfexchange.removed_admin

Columns

Name Type Nullable Default Description
id PK VARCHAR No
removed_admin TEXT No
admin TEXT No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
removed_admin_pkey primary_key id

limitlessctfexchange.removed_operator

Columns

Name Type Nullable Default Description
id PK VARCHAR No
removed_operator TEXT No
admin TEXT No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
removed_operator_pkey primary_key id

limitlessctfexchange.safe_factory_updated

Columns

Name Type Nullable Default Description
id PK VARCHAR No
old_safe_factory TEXT No
new_safe_factory TEXT No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
safe_factory_updated_pkey primary_key id

public.schema_migrations

Columns

Name Type Nullable Default Description
version PK TEXT No
applied_at TIMESTAMP No now()
checksum TEXT No
execution_time_ms INTEGER Yes
status TEXT Yes 'completed'::text

Indexes

Name Columns Type
idx_schema_migrations_applied_at applied_at Index
idx_schema_migrations_status status Index

Constraints

Name Type Columns Definition
schema_migrations_pkey primary_key version

unified.schema_migrations

Columns

Name Type Nullable Default Description
version PK TEXT No
description TEXT Yes
applied_at TIMESTAMP Yes now()

Constraints

Name Type Columns Definition
schema_migrations_pkey primary_key version

unified.series

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
title TEXT No
normalized_title TEXT Yes
description TEXT Yes
category TEXT Yes
series_type TEXT Yes
frequency TEXT Yes
status TEXT No 'active'::text
is_active BOOLEAN Yes true
total_events INTEGER Yes 0
total_markets INTEGER Yes 0
active_markets INTEGER Yes 0
total_volume NUMERIC(20, 8) Yes 0
platforms ARRAY Yes '{}'::text[]
platform_count INTEGER Yes 0
kalshi_series_id TEXT Yes
kalshi_series_ticker TEXT Yes
polymarket_series_id TEXT Yes
polymarket_series_slug TEXT Yes
limitless_series_id TEXT Yes
similarity_hash TEXT Yes
tags ARRAY Yes
platform_metadata JSONB Yes '{}'::jsonb
created_at TIMESTAMP Yes now()
updated_at TIMESTAMP Yes now()
last_synced TIMESTAMP Yes now()

Indexes

Name Columns Type
idx_series_active is_active Index
idx_series_category category Index
idx_series_kalshi_id kalshi_series_id Index
idx_series_normalized_title normalized_title Index
idx_series_platforms platforms Index
idx_series_polymarket_id polymarket_series_id Index
idx_series_similarity_hash similarity_hash Index
idx_series_status status Index
idx_series_tags tags Index
idx_series_type series_type Index
series_unique_hash similarity_hash Unique
series_unique_kalshi_id kalshi_series_id Unique
series_unique_polymarket_id polymarket_series_id Unique

Constraints

Name Type Columns Definition
series_pkey primary_key id
series_unique_hash unique similarity_hash
series_unique_kalshi_id unique kalshi_series_id
series_unique_polymarket_id unique polymarket_series_id
series_counts_check check
series_status_check check
series_type_check check

Relationships

trading.sessions

Groups related trades for analysis and risk management

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
name TEXT No
mode TEXT No
started_at TIMESTAMP No now()
ended_at TIMESTAMP Yes
total_positions INTEGER Yes 0
total_pnl NUMERIC(20, 8) Yes 0
status TEXT No 'active'::text
metadata JSONB Yes '{}'::jsonb

Indexes

Name Columns Type
idx_sessions_started_at started_at Index
idx_sessions_status status Index

Constraints

Name Type Columns Definition
sessions_pkey primary_key id
sessions_mode_check check
sessions_status_check check

Relationships

limitlessctfexchange.status

Columns

Name Type Nullable Default Description
id PK INTEGER No nextval('limitlessctfexchange.status_id_seq'::regclass)
height INTEGER No
hash TEXT Yes
nonce INTEGER Yes

Constraints

Name Type Columns Definition
status_pkey primary_key id

unified.template_instantiations

Columns

Name Type Nullable Default Description
id PK UUID No gen_random_uuid()
template_id FK UUID No
References: unified.group_templates(id)
group_id FK UUID No
References: unified.market_groups(id)
instantiated_at TIMESTAMP Yes now()
instantiated_by VARCHAR(100) Yes
instantiation_config JSONB Yes '{}'::jsonb

Indexes

Name Columns Type
unique_template_group template_id, group_id Unique

Constraints

Name Type Columns Definition
template_instantiations_pkey primary_key id
template_instantiations_group_id_fkey foreign_key group_id
template_instantiations_template_id_fkey foreign_key template_id
unique_template_group unique template_id, group_id

Relationships

limitlessctfexchange.token_registered

Columns

Name Type Nullable Default Description
id PK VARCHAR No
token0 NUMERIC No
token1 NUMERIC No
condition_id TEXT No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
token_registered_pkey primary_key id

limitlessctfexchange.token_registry

Columns

Name Type Nullable Default Description
id PK VARCHAR No
complement NUMERIC No
condition_id TEXT No
last_updated TIMESTAMP No
block INTEGER No

Constraints

Name Type Columns Definition
token_registry_pkey primary_key id

limitlessctfexchange.trading_paused

Columns

Name Type Nullable Default Description
id PK VARCHAR No
pauser TEXT No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
trading_paused_pkey primary_key id

limitlessctfexchange.trading_unpaused

Columns

Name Type Nullable Default Description
id PK VARCHAR No
pauser TEXT No
timestamp TIMESTAMP No
block INTEGER No
tx_hash TEXT No

Constraints

Name Type Columns Definition
trading_unpaused_pkey primary_key id

polymarket.transformed_markets

Columns

Name Type Nullable Default Description
market_id PK VARCHAR(255) No
question TEXT No
description TEXT Yes
category VARCHAR(255) Yes
status VARCHAR(50) Yes
end_date TIMESTAMP Yes
volume NUMERIC(20, 8) Yes
liquidity NUMERIC(20, 8) Yes
best_buy_price NUMERIC(20, 8) Yes
best_buy_size NUMERIC(20, 8) Yes
best_sell_price NUMERIC(20, 8) Yes
best_sell_size NUMERIC(20, 8) Yes
midpoint NUMERIC(20, 8) Yes
spread NUMERIC(20, 8) Yes
is_active BOOLEAN Yes
created_at TIMESTAMP Yes '2025-07-06 21:57:45.966909+00'::timestamp with time zone
updated_at TIMESTAMP Yes '2025-07-06 21:57:45.966909+00'::timestamp with time zone
last_checked TIMESTAMP Yes '2025-07-06 21:57:45.966909+00'::timestamp with time zone

Constraints

Name Type Columns Definition
transformed_markets_pkey primary_key market_id

limitlessctfexchange.user_state

Columns

Name Type Nullable Default Description
id PK VARCHAR No
is_admin BOOLEAN No
is_operator BOOLEAN No
nonce NUMERIC No
proxy_wallet_address TEXT Yes
safe_address TEXT Yes
last_updated TIMESTAMP No
block INTEGER No

Constraints

Name Type Columns Definition
user_state_pkey primary_key id

Database Migrations

This section lists all database migrations that have been applied to the schema.

000_baseline_schema.sql
Baseline Schema
001_20251216_add_orderbook_snapshot_event_type.sql
20251216 Add Orderbook Snapshot Event Type
002_20251217_add_builder_orders_table.sql
20251217 Add Builder Orders Table