Developer Hub
🔮 For applications
SDK
cashout
usePrecalculatedCashouts

This hook retrieves a list of approximate precalculated cashouts for a specific bettor and is intended for use in the client's bets view.

ℹ️

You can find more information Here.

Usage

import { usePrecalculatedCashouts } from '@azuro-org/sdk'
 
 
const { status, outcomes, possibleWin, tokenId } = bet // bet from subgraph
const { cashouts, totalMultiplier, isCashoutAvailable, isFetching } = usePrecalculatedCashouts({
  tokenId,
  selections: outcomes,
  graphBetStatus: status,
})
 
const cashoutAmount = possibleWin * +totalMultiplier
ℹ️

You can find a usage example in our demo (opens in a new tab).

Props

  selections: Selection[] // user's bet selections
  graphBetStatus: GraphBetStatus
  enabled?: boolean
type Selection = {
  tokenId: string
  conditionId: string
  outcomeId: string
  coreAddress: string
}

Return Value

{
  cashouts: Record<string, GetPrecalculatedCashouts>
  totalMultiplier: number // total multiplier for cashout
  isCashoutAvailable: boolean // Indicates whether cashout is available for the provided condition
  isFetching: boolean
}
type GetPrecalculatedCashouts = {
  conditionId: string
  available: boolean
  outcomes: {
    outcomeId: number
    multiplier: string
  }[]
}[] | null