Developer Hub
🔮 For applications
Toolkit
Utils
getBetStatus

Returns detailed bet status based on bet's status derived from the subgraph, alongside the result and associated games within the bet.

This helper extends the BetStatus from the subgraph. However, it's noticeable that there might not be sufficient statuses to create a detailed UI representation of the bet state. For instance, there might be ambiguity in understanding what occurred with the bet between the 'Accepted' and 'Resolved' statuses.

enum GraphBetStatus {
  Accepted = 'Accepted', // bet was accepted
  Resolved = 'Resolved', // bet was resolved
  Canceled = 'Canceled' // bet was canceled
}

Thus, we've introduced additional statuses:

enum BetStatus {
  Accepted, // same as GraphBetStatus.Accepted
  Live, // if at least one game in live
  PendingResolution, // if at least one game has PendingResolution status in bet
  Resolved, // same as GraphBetStatus.Resolved
  Canceled, // same as GraphBetStatus.Canceled
}

Usage

import { type Bet } from '@azuro-org/sdk'
import { getBetStatus, BetStatus } from '@azuro-org/toolkit'
 
const { outcomes, status, coreAddress } = bet as Bet // bet's data from `usePrematchBets` or `useLiveBets`
const liveCoreAddress = '0xsdf123...'
 
const betStatus = getBetStatus({
  graphStatus: status,
  games: outcomes.map(({ game }) => game),
  isLiveBet: coreAddress.toLowerCase() === liveCoreAddress.toLowerCase(),
})

Props

{
  graphStatus: BetStatus // bet's status from subgraph
  games: GameQuery['games'][]
  isLiveBet: boolean
}

Return Value

enum BetStatus {
  Accepted,
  Live,
  PendingResolution,
  Canceled,
  Resolved,
}