Developer Hub
🔮 For applications
Toolkit
Utils
calcLiveOdds

Calculates the live odds value for specific outcome at which the bet can be placed on. If the current odds value is lower than the specified value, the bet cannot be placed and will be rejected by the contract.

Usage

import { calcLiveOdds } from '@azuro-org/toolkit'
 
const liveOdds = calcLiveOdds({
  selection,
  betAmount,
  oddsData,
})

Props

{
  selection: Selection
  oddsData: OddsData
  betAmount?: string
}
type Selection = {
  conditionId: string
  outcomeId: string
  coreAddress: string
}
 
type SocketData = {
  conditionId: string
  margin: number // marginality
  reinforcement: number
  winningOutcomesCount: number
  outcomes: Record<string, { // key is outcomeId
    odds: number // current odds
    clearOdds: number // current odds without marginality
  }>
}

Return Value

number