calcMinOdds
Calculates the minimum odds value at which the bet can be placed. If the current odds value is lower than the specified value, the bet cannot be placed and will be rejected by the contract.
This is for placing a bet, not for pricing one that already exists. For a bet that already exists,
read the odds and payout the bets subgraph recorded (settledOdds ?? odds, payout).
calcComboOdds is only the deprecated client-side reproduction
of that pricing. calcMinOdds never looks at when a bet was placed: a number is taken as a single’s odds,
and an array of any length goes through the combo fee rule below, which is right for a combo you are about
to place.
Function renamed in v6.0.0: This function was renamed from calcMindOdds to calcMinOdds (typo fix). The old name was a typo and has been corrected. Please update your imports if migrating from v5.x.
Usage
import { calcMinOdds } from '@azuro-org/toolkit'
const minOdds = calcMinOdds({
odds: 1.17,
slippage: 5, // 5%
})Props
type CalcMinOddsParams = {
odds: number | number[]
slippage?: number
}Return Value
string (.toFixed(ODDS_DECIMALS) called on the number)
Combo odds
Passing an array prices a combo: the feed’s fee is removed from each leg, the legs are multiplied, and the fee is applied once to the product — not compounded per leg.
calcMinOdds({ odds: [ 1.5, 2 ], slippage: 0 }) // 3.05, where the plain product would be 3.00Leave a voided leg out of the array rather than passing 1.0 for it; 1.0 is de-margined to 1.02
and inflates the total. An empty array returns the bare fee (0.99), which is never a valid price for
a bet — calcComboOdds returns 1 in that case instead.