SDK
Data Hooks
useBets

Hook is used for fetch bets history for 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 { useBets } from '@azuro-org/data'
 
const { loading, error, data: bets } = useBets(props)
⚠️

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

Props

{
  filter: {
    bettor: string // bettor address
    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
}

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 { BetsDocument, BetsQueryResult, BetsQueryVariables } from '@azuro-org/sdk'
 
const options = {
  // your options
}
 
const { loading, error, data } = useQuery<BetsQueryResult, BetsQueryVariables>(BetsDocument, options)

Return Value

{
  loading: boolean
  error: Error | null
  data: Bet[]
}
type Selection = {
  conditionId: string | bigint
  outcomeId: string | bigint
}
 
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 = {
  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 // 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
}