import { AthleteProps, TeamProps } from "./contests.types"; /** * Market definition * * Defines a tradeable betting market with its configuration and options */ export interface MarketProps { /** Unique market identifier */ market_id: string; /** Type of event this market applies to */ event_type: 'tournament'|'team'|'match'; /** Market level/scope */ level: 'event' | 'exotic' | 'athlete' | 'team' | 'h2h'; /** Human-readable market description */ description: string; /** Market type category */ type: 'Spread' | 'Winner' | 'Total' | 'Stat'; /** Trading side configuration */ trade_side: string; /** Game length this market covers */ length: 'half' | 'inning' | 'full_game'; /** Statistic being tracked (points, rebounds, yards, etc.) */ stat: string; /** Whether market is actively trading */ status: 'active' | 'inactive'; /** Optional external market mappings for odds providers */ external_mapping?:ExternalMarketMapProps[]; /** Available sides/options for this market */ side_options: MarketSideOptionProps[]; /** Optional variable value for configurable markets */ length_variable?:number; /** Maximum order size allowed */ max_order?:number; /** Whether probability display should be locked */ lock_probability?:boolean; /** Market grouping category for UI organization */ market_group: 'main'|'team_stat'|'player_stat'|'team_total'|'player_total'|'other'; /** Optional custom label for the stat */ stat_label?:string; /** Whether to use custom description instead of generated */ description_override?:boolean; /** Whether this is a suggested/featured market */ suggested?:boolean; /** When the market resolver runs (live, post-game, etc.) */ resolver_timing?:string; /** Optional supported player positions for this market */ supported_positions?:string[]; /** Whether variable selection is required */ var_1_required?:boolean; /** Whether to show side option selector */ show_side_option?:boolean; /** Market resolver identifier */ resolver?:string; /** Timestamp when market was created */ create_datetime: any; /** Timestamp of last update */ last_update_datetime: any; } /** * Market side option * * Defines a selectable side/outcome within a market */ export interface MarketSideOptionProps { /** Side identifier (over/under, home/away, yes/no, etc.) */ side: string; /** Display label for this side */ label: string; /** Source of the ID for this side */ id_source: 'athlete' | 'team' | 'side' | 'exotic'; /** Parseable title template for generating market names */ parseable_title: string; } /** * External market mapping * * Maps internal markets to external odds provider markets */ export interface ExternalMarketMapProps { /** External provider name */ external_source: 'sportradar'|'bet_scope'; /** External market type identifier */ external_type: string; /** External market ID */ external_id: string; /** League ID for this mapping */ league_id:string; /** Whether this mapping applies to live markets */ live:boolean; /** Whether this mapping applies to pre-event markets */ pre_event:boolean; /** Whether this mapping is active */ active:boolean; } /** * Market liquidity data * * Real-time market depth and available liquidity for trading */ export interface MarketLiquidityProps { /** League ID */ league_id:string; /** Array of contests with their markets and liquidity */ contests: { /** Contest type (event, tournament, match) */ contest_type:string; /** Contest ID */ contest_id:string; /** Contest display title */ contest_title:string; /** Unique contest hash */ contest_hash:string; /** When the contest is scheduled */ scheduled_datetime:string; /** League image URL */ league_image?: string; /** Indicates whether participants are teams or athletes */ participant_type?: 'athlete' | 'team'; /** Teams/participants in the contest */ teams: { /** Optional side (home/away) */ side?:string; /** Team ID */ team_id: string; /** Optional team logo URL */ image_url?:string; /** Team name */ name: string; }[]; /** Athletes in the contest (for athlete-type matches) */ athletes?: { /** Optional side (home/away) */ side?:string; /** Athlete ID */ athlete_id: string; /** Optional athlete image URL */ image_url?:string; /** Athlete name */ name: string; }[]; /** Available markets for this contest */ markets: { /** Market ID */ market_id:string; /** Market description */ market_description:string; /** Whether a variable is required */ variable_required:boolean; /** Available variable options (spreads, totals, etc.) */ variable_options: number[]; /** The variable flagged show:true from best available (the primary line to display) */ show_variable?: number; /** Market level */ level:'contest'|'athlete'|'team'; /** Type of side options */ side_type:'team'|'athlete'|'side'|'exotic'; /** Whether this is a spread market */ is_spread_market:boolean; /** Whether multiple participants can be selected */ multiple_participants:boolean; /** Total available liquidity */ liquidity:number; /** Total trading volume */ volume:number; /** Whether market is active */ active:boolean; /** Unique market hash */ market_hash: string; /** Side options with parseable title templates */ side_options?: MarketSideOptionProps[]; /** Available side type options */ side_type_options: { /** Available athletes */ athletes: { athlete_id:string, name:string, position:string, image:string }[]; /** Available teams */ teams: { team_id:string, name:string, image:string }[]; }; /** Market sides with liquidity data */ sides: { /** Side identifier */ side:string; /** Side type */ side_type: 'athlete'|'team'|'side'; /** Unique market side hash */ market_side_hash: string; /** Available liquidity for each order context */ liquidities: { /** Unique order context hash */ order_context_hash:string; /** Variable value (spread, total, etc.) */ variable:number; /** Market title */ title:string; /** Side type */ side_type:string; /** Side ID */ side_id:string; /** Current market price (0-100) */ price:number; /** Available liquidity amount */ available:number; /** Order ID from best available */ order_id?: string; /** Last trade on this order context */ last_trade?:{ trade_id:string, amount:number, cumulative_amt:number, price:number, create_datetime:any }; }[]; }[]; }[]; }[]; } /** * Player portfolio * * Complete portfolio of all player positions, orders, and trading activity */ export interface PortfolioProps { /** Player ID */ player_id:string; /** Portfolio holdings mapped by order context hash */ portfolio: { /** Order context hash as key */ [key:string] : { /** Market title */ title: string; /** Total amount in resting buy orders */ resting_buys: number; /** Average price of resting buy orders */ resting_buy_price:number; /** Potential winnings from resting buys */ resting_buys_potential_winnings:number; /** Total amount in resting sell orders */ resting_sells: number; /** Expected cash from resting sells */ resting_expected_cash:number; /** Average price of resting sell orders */ resting_sell_price:number; /** Potential winnings from resting sells */ resting_sells_potential_winnings:number; /** Active buy orders */ resting_buy_orders: { order_id:string, initial_amt:number, open_amt:number, price:number, order_type:'market'|'limit'|'h2h', collar_pct:number, called_amt:number, expire_datetime:any, challenger?:string }[]; /** Active sell orders */ resting_sell_orders: { order_id:string, open_amt:number, selling_position_id:string, order_type: 'market'|'limit', price:number, collar_pct: number, cash_rcvd:number, expire_datetime:any }[]; /** Closed/cancelled buy orders */ closed_buy_orders: { order_id:string, status: 'cancelled'|'closed', order_type:'market'|'limit'|'h2h', collar_pct:number, price:number, initial_amt:number, called_amt:number, returned_amt:number, challenger?:string }[]; /** Total stake owned on this context */ position: number; /** Original total investment (sum of original_stake across positions) */ invested: number; /** Number of contracts owned */ contracts:number; /** Potential winnings from current positions */ potential_winnings:number; /** Actual winnings received */ winnings: number; /** Net winnings after commission */ net_winnings: number; /** Result indicator — only present when context is finalized */ result_ind?: 'win' | 'lose' | 'draw'; /** Average position price */ position_price:number; /** Cash received from selling positions */ cash_from_sales:number; /** Cash tied up in unsettled sales */ delayed_cash:number; /** Individual positions owned */ positions: { position_id:string, order_id:string, original_position:number, position:number, price:number, potential_winnings:number, challenger?:string }[]; /** Full parlay object — only present on parlay entries (keyed by "parlay:{parlay_id}") */ parlay?: ParlayProps; /** Player's parlay positions — only present on parlay entries */ parlay_positions?: ParlayPositionProps[]; /** Parlay leg entries — only present on parlay entries, keyed by order_context_hash */ legs?: { [key:string]: PortfolioProps['portfolio'][string]; }; }; }; } /** * Commission rebate configuration * * Defines a commission rebate program for a player tier */ export interface CommissionRebateProps { /** Unique commission rebate ID */ commission_rebate_id: string; /** Whether this rebate is active */ status: 'active'|'inactive'; /** Rebate calculation frequency */ frequency: 'month'; /** Player tier this rebate applies to */ player_tier: 'freemium' | 'premium'; /** Maximum rebate amount per period */ rebate_cap: number; /** Timestamp when created */ create_datetime:any; /** Timestamp of last update */ last_update_datetime:any; } /** * Player commission rebate * * Individual rebate record for a player for a specific period */ export interface PlayerCommissionRebateProps { /** Unique player commission rebate ID */ player_commission_rebate_id:string; /** Player ID */ player_id:string; /** Commission rebate configuration ID */ commission_rebate_id:string; /** * Current rebate status * - collectable: Rebate calculated and ready to collect * - collected: Rebate has been collected and closed * - inprogress: Rebate month still active, not yet calculated * - expired: Rebate expired uncollected */ status: 'collectable' | 'collected' | 'inprogress' | 'expired'; /** Total commission paid during the rebate period */ commission_paid: number; /** Rebate amount to be paid back */ rebate_amt: number; /** Month this rebate covers */ rebate_month:any; /** Estimated community savings from no-vig trading */ community_saved:number; /** Rebate cap amount for this player's tier */ rebate_cap: number; /** When the rebate expires */ expire_datetime: any; /** Timestamp when created */ create_datetime: any; /** Timestamp of last update */ last_update_datetime:any; } export interface OrderContextProps { /** Status of the order action */ placement_status:'success'|'failed'; message:string, /** If failed to place, error message to explain the issue */ error?:string, /** Order Details */ order_context?:{ /** Order Ids of new or updated orders */ order_ids:string[], /** Position Ids of new or updated positions */ position_ids:string[], /** Title of the order */ title:string, /** Price of order */ price:number, /** Amount of order */ amount:number, /** Market Identifier hash for the order */ order_context_hash:string, /** Status of the order */ status:'approved'|'cancelled'|'closed' } } /** * Position * * Represents a filled position from a matched order */ export interface PositionProps { /** Unique position identifier */ position_id: string; /** Order that created this position */ order_id: string; /** Amount staked */ stake: number; /** Winnings if position wins */ winnings: number; /** Net winnings after commission */ net_winnings: number; /** Potential winnings */ potential_winnings: number; /** Amount currently in a sale order */ in_sale_order: number; /** Delayed cash awaiting result */ delayed_cash: number; /** Cash received from sales */ cash_rcvd: number; /** Routing premium charged */ routing_premium?: number; /** Original stake when created */ original_stake: number; /** American odds */ odds: number; /** Result indicator */ result_ind?: 'win' | 'lose' | 'draw'; /** Implied probability */ probability: number; /** Associated parlay ID */ parlay_id?: string; /** Position status */ status: 'inprogress' | 'closed'; /** Legacy ID */ legacy_id?: string; /** Resolution datetime */ resolution_datetime?: any; /** Purchased grade */ purchased_grade?: number; /** Commission charged */ commission: number; /** Hedged positions */ hedged_positions?: HedgedPositionProps[]; /** Created timestamp */ create_datetime?: any; /** Last update timestamp */ last_update_datetime?: any; } /** * Hedged position */ export interface HedgedPositionProps { hedge_id: string; hedged_amt: number; player_id: string; event_id: string; event_type: string; market_id: string; var_1: number; stake_reduction: number; } /** * Order * * Represents a buy or sell order in the marketplace */ export interface OrderProps { /** Unique order identifier */ order_id: string; /** Player who created the order */ player_id: string; /** Order type */ order_type: 'market' | 'limit' | 'h2h'; /** Collar percentage for market orders */ collar_pct: number; /** Side of the order */ side: string; /** Side identifier */ side_id: string; /** Side type */ side_type: 'athlete' | 'team' | 'side'; /** Whether order is reversed */ reversed?: boolean; /** Campaign ID */ campaign_id?: string; /** Draft liquidity */ draft_liquidity?: number; /** Fund ID */ fund_id?: string; /** Reference order ID */ reference_order_id?: string; /** Legacy BE type */ be_type?: 'market' | 'prop' | 'ind'; /** Buy or sell */ buy_sell_ind: 'buy' | 'sell'; /** Amount still available to match */ open_amt: number; /** Amount already fulfilled */ called_amt: number; /** Potential winnings */ potential_winnings: number; /** Market ID */ market_id: string; /** Market details */ market?: MarketProps; /** Order title */ title: string; /** Working percentage */ working_pct?: number; /** Fulfill action */ fulfill_action?: 'replenish' | 'drain'; /** Event ID */ event_id: string; /** Event type */ event_type: 'team' | 'tournament' | 'match'; /** Position IDs created from trades */ position_ids: string[]; /** Expiration datetime */ expire_datetime: any; /** Created datetime */ create_datetime?: any; /** Last update datetime */ last_update_datetime?: any; /** American odds */ odds: number; /** Implied probability */ probability: number; /** Variable value */ var_1: number; /** League ID */ league_id?: string; /** Whether using promo balance */ promo_balance?: boolean; /** Whether promoted */ promoted?: boolean; /** Rejection count */ rejections: number; /** Location coordinates */ location?: any; /** Region */ region?: string; /** Market type */ market_type: 'FREE' | 'FOR_MONEY'; /** Available for parlays */ available_for_parlays: boolean; /** Order status */ status: 'cancelled' | 'approved' | 'closed' | 'pending'; /** Cancel type */ cancel_type?: 'expired' | 'manual' | 'closed'; /** Resolution status */ resolution_status: 'inprogress' | 'closed'; /** Whether live */ live?: boolean; /** Whether H2H */ h2h?: boolean; /** H2H ID */ h2h_id?: string; /** H2H user */ h2h_user?: any; /** Parlay ID */ parlay_id?: string; /** Event details */ event?: any; /** Selling position ID */ selling_position_id?: string; /** Whether result was viewed */ result_viewed?: boolean; /** Commission percentage */ commission_pct: number; /** Positions from this order */ positions: PositionProps[]; /** Payment for order flow */ pfof?: boolean; /** Influencer ID */ influencer_id?: string; /** Influencer details */ influencer?: any; /** Influence type */ influence_type?: 'copy' | 'fade'; /** Tip type */ tip_type?: 'win' | 'all'; /** Tip percentage */ tip_pct?: number; /** Whether tip processed */ tip_processed?: boolean; /** Legacy ID */ legacy_id?: string; /** Grade */ grade?: number; /** Last grade datetime */ last_grade_datetime?: any; /** No bet indicator */ no_bet?: boolean; /** No bet reason */ no_bet_reason?: string; /** Router data */ router_data?: { routing_margin: number; liquidity_hash: string; liquidity_id: string; }; } /** * Parlay * * Represents a multi-leg parlay bet */ export interface ParlayProps { /** Unique parlay identifier */ parlay_id: string; /** Player who created the parlay */ player_id: string; /** Parlay name */ name: string; /** Whether to show to user */ show_me?: boolean; /** Number of legs */ legs: number; /** American odds */ odds: number; /** Offer side */ offer_side: 'maker' | 'taker'; /** Winning side */ winning_side?: 'maker' | 'taker'; /** Grade */ grade?: number; /** Whether promotional */ promo?: boolean; /** Implied probability */ probability: number; /** Parlay status */ status: 'approved' | 'cancelled' | 'closed'; /** Expiration datetime */ expire_datetime: any; /** Cancel type */ cancel_type?: 'expired' | 'manual'; /** Resolution status */ resolution_status: 'inprogress' | 'closed'; /** Region */ region: string; /** Market type */ market_type: 'FOR_MONEY' | 'FREE'; /** Location */ location: { latitude: number; longitude: number }; /** No bet indicator */ no_bet?: boolean; /** No bet reason */ no_bet_reason?: string; /** Offer amount */ offer_amt: number; /** Open amount */ open_amt: number; /** Potential winnings */ potential_winnings: number; /** Called amount */ called_amt: number; /** Commission percentage */ commission_pct: number; /** Created datetime */ create_datetime: any; /** Last update datetime */ last_update_datetime: any; } /** * Parlay position * * Represents a player's position in a parlay */ export interface ParlayPositionProps { /** Unique parlay position identifier */ parlay_position_id: string; /** Parlay ID */ parlay_id: string; /** Player ID */ player_id: string; /** Side */ side: 'maker' | 'taker'; /** Status */ status: 'inprogress' | 'closed'; /** Stake amount */ stake: number; /** American odds */ odds: number; /** Result indicator */ result_ind?: 'win' | 'lose' | 'draw'; /** Implied probability */ probability: number; /** Commission percentage */ commission_pct: number; /** Initial probability */ initial_probability: number; /** Refunded amount */ refunded: number; /** Commission charged */ commission: number; /** Net winnings */ net_winnings: number; /** Potential winnings */ potential_winnings: number; /** Winnings */ winnings: number; /** Resolution datetime */ resolution_datetime?: any; /** Created datetime */ create_datetime: any; /** Last update datetime */ last_update_datetime: any; } /** * Poll response * * Represents a user's response to a poll/flash market */ export interface PollResponseProps { /** Unique poll response identifier */ poll_response_id: string; /** Poll ID */ poll_id: string; /** Selected option ID */ poll_option_id?: string; /** Input value for input-type polls */ input_value?: string; /** Phone number */ phone?: string; /** Email */ email?: string; /** Device ID */ device_id?: string; /** Parimutuel odds */ parimutuel_odds?: number; /** Stake amount */ stake: number | string; /** Market type */ market_type: 'FREE' | 'FOR_MONEY'; /** Result indicator */ result_ind?: 'win' | 'lose' | 'draw'; /** Winnings */ winnings: number; /** Whether timed out */ timed_out?: boolean; /** Player ID */ player_id: string; /** Status */ status: string; /** Response body */ response_body: any; /** Created datetime */ create_datetime: any; /** Last update datetime */ last_update_datetime: any; }