Skip to Content

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 combo’s total odds — to show what a settled bet is worth, or to rebuild its payout — use calcComboOdds. It applies the same per-leg fee arithmetic, but it also accounts for when the bet was placed: the feed’s fee has a start date, and combos placed before it are priced as the plain product of their legs. calcMinOdds always assumes the fee, which is correct for a bet you are about to place and wrong for an older one.

⚠️

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.00

Leave 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.