Skip to Content

useLegacyBets

The useLegacyBets hook is used to fetch pre-match betting history of a specific bettor.

⚠️

The useLegacyBets hook is only for fetching old v2 Azuro Protocol bets if you need to show full betting history.

ℹ️

Hook represents a logic wrapper over TanStack Query’s useInfiniteQuery hook. Explore TanStack Query docs  to understand what data the hook returns.

Usage

import { useLegacyBets } from '@azuro-org/sdk' const { data, hasNextPage, isFetching, fetchNextPage } = useLegacyBets(props) const { pages } = data || {} // render pages <> { pages?.map(({ bets, nextPage }) => { return ( <React.Fragment key={`${nextPage}`}> { bets.map(bet => ( <BetComponent key={`${bet.createdAt}-${bet.tokenId}`} bet={bet} /> )) } </React.Fragment> ) }) } <>
## Props ```ts { filter: { bettor: string // bettor address affiliate?: string // affiliate address type?: BetType // bet type } itemsPerPage?: number orderBy?: Bet_OrderBy // default: Bet_OrderBy.CreatedBlockTimestamp` - orders rows by passed rule orderDir?: OrderDirection // order direction: asc, desc chainId?: ChainId query?: InfiniteQueryParameters<QueryResult> }
type ChainId = | 100 // Gnosis | 137 // Polygon | 80002 // Polygon Amoy | 88888 // Chiliz | 88882 // Chiliz Spicy | 8453 // Base | 84532 // Base Sepolia enum BetType { Unredeemed = 'unredeemed', // ready to redeem bets Accepted = 'accepted', // not resolved bets Settled = 'settled', // resolved bets CashedOut = 'cashedOut', // cashed out bets } type QueryResult = { bets: Bet[], nextPage: number | undefined, }

Return Value

UseInfiniteQueryResult<QueryResult>
import { type UseInfiniteQueryResult } from '@tanstack/react-query' type Selection = { conditionId: string outcomeId: 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 cashout: string | null // cashout 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 isLive: boolean // flag indicates whether the bet is live isCashedOut: boolean // flag indicates whether the bet is cashed out }
Last updated on