Developer Hub
🔮 For applications
SDK
Data Hooks
useLiveBets

This hook is used to fetch live betting history of a specific bettor.

Hook represents a logic wrapper over standard Apollo's useQuery hook. Explore Apollo's docs (opens in a new tab) to understand what data the hooks return.

Usage

import { useLiveBets } from '@azuro-org/sdk'
 
const { loading, error, bets } = useLiveBets(props)
⚠️

The hook won't be called while bettor value is nullish.

Props

{
  filter: {
    bettor: string // bettor address
    affiliate?: string // affiliate address
    type?: BetType // bet type
    limit?: number // limit the number of rows returned from a query
    offset?: number // omit a specified number of rows before the beginning of the result set
  }
  orderBy?: Bet_OrderBy // default: Bet_OrderBy.CreatedBlockTimestamp` - orders rows by passed rule
  orderDir?: OrderDirection // order direction: asc, desc
}
enum BetType {
  Unredeemed = 'unredeemed', // ready to redeem bets
  Accepted = 'accepted', // not resolved bets
  Settled = 'settled', // resolved bets
}

Custom query options

To accommodate additional arguments within your GraphQL query, the optimal approach is to create a custom hook. This can be achieved by leveraging the fundamental Apollo useQuery hook as your starting point.

import { useQuery } from '@apollo/client'
import { LiveBetsDocument, LiveBetsQueryResult, LiveBetsQueryVariables, useApolloClients } from '@azuro-org/sdk'
 
const { prematchClient } = useApolloClients()
 
const options = {
  // your options
  client: prematchClient
}
 
const { loading, error, data } = useQuery<LiveBetsQueryResult, LiveBetsQueryVariables>(LiveBetsDocument, options)

Return Value

{
  loading: boolean
  error: Error | null
  bets: Bet[]
}
type Selection = {
  conditionId: string
  outcomeId: string
  coreAddress: string
}
 
type BetOutcome = {
  selectionName: string
  odds: number
  marketName: string
  game: GameQuery['games'][0] // game on which the bet is placed
  isWin: boolean | null
  isLose: boolean | null
  isCanceled: boolean
} & Selection
 
type Bet = {
  affiliate: string // affiliate address
  tokenId: string // id of the bet's NFT
  freebetId?: string | null // id of the freebet's NFT
  freebetContractAddress?: Address // freebet contract address
  totalOdds: number // total odds of the bet
  coreAddress: Address // core contract address
  lpAddress: Address // lp contract address
  outcomes: BetOutcome[] // bet's outcomes list
  txHash: string // bet's transaction hash
  status: BetStatus // subgraph bet status
  amount: string // bet's amount in USDT
  possibleWin: number // possible win amount in USDT
  payout: number | null // actual payout amount in USDT
  createdAt: number // created date
  isWin: boolean // flag indicates the bet's win
  isLose: boolean // flag indicates the bet's lose
  isRedeemable: boolean // flag indicates the possibility of redeeming the bet
  isRedeemed: boolean // flag indicates whether the bet has been redeemed
  isCanceled: boolean // flag indicates whether the bet has been canceled
}