Hook is used for calculate the total odds before placing a bet. This is the odds on which the bet will be made without considering slippage. The total odds depend on the bet amount and the provided selections since each selection may have its individual settings for reinforcement and margin.
Usage
Initialize watcher in the root of your app.
import { useOddsWatcher } from '@azuro-org/sdk'
export function Watchers() {
useOddsWatcher()
return null
}
Provide selections and bet amount for calculating.
import { useCalcOdds } from '@azuro-org/sdk'
const { data, loading, error } = useCalcOdds({
amount: '10',
selections: [
{
conditionId: '486903008559711340',
outcomeId: '29',
},
],
})
const { selectionsOdds, totalOdds } = data
ℹ️
Example of usage: Obtain the total odds for the provided selections.
import { type MarketOutcome, useCalcOdds } from '@azuro-org/sdk'
type TotalOddsProps = {
outcomes: MarketOutcome[]
betAmount: string
}
function TotalOdds(props: TotalOddsProps) {
const { outcomes, betAmount } = props
const { data } = useCalcOdds({
amount: betAmount,
selections: outcomes,
})
const { totalOdds } = data || {}
return (
<span>{totalOdds}</span>
)
}
Props
{
selections: Selection[]
amount?: string
}
type Selection = {
conditionId: string | bigint
outcomeId: string | bigint
}
Return Value
{
loading: boolean
error: Error | null
data: {
selectionsOdds: bigint[] | undefined
totalOdds: bigint | undefined
loading: boolean
error: Error | null
}
}