Repository navigation
@azuro-org/toolkit v7.2.0
The freebet bettor share, recorded payouts in the bets report, and extended conditions starting with 6
What's new
-
New
calcFreebetBettorSharereturns what a freebet pays the bettor, in token base units. The liquidity pool
pays a freebet's whole payout to the freebet contract, which splits it between the bettor and the freebet fund:import { parseUnits } from 'viem' import { calcFreebetBettorShare } from '@azuro-org/toolkit' // a returnable freebet of 1 USDT won at 1.5: the pool pays 1.5, the bettor receives 0.5 const share = calcFreebetBettorShare({ payout: parseUnits('1.5', 6), amount: parseUnits('1', 6), isAmountReturnable: true, })
- A payout no greater than the stake returns
0n; a lost freebet pays 0 and a canceled one exactly its stake. - A returnable freebet returns
payout - amount. - Otherwise, when the flag is exactly
false, it returns the wholepayout. - A
nullor absent flag counts as returnable. That is the smaller share, so an app never shows more than the
bettor receives. - It is plain
bigintmath, so nothing is rounded. The params type isCalcFreebetBettorShareParams.
- A payout no greater than the stake returns
-
The bets report reads recorded payouts (
getBetsReport/calcBetsReport).- A won or lost bet returns the payout the bets subgraph recorded (
rawPayout). That is already priced by the
protocol's rule and is the amount actually paid once the bet is redeemed. A combo is no longer re-priced from its
leg odds. - A leg is void when its selection's result is
Canceled. - The freebet line values each freebet at the bettor's share.
returnsis the sum of the shares, andprofitequals
returns, because the bettor staked nothing of their own. A canceled freebet adds its stake torefundedand
nothing toreturns.
- A won or lost bet returns the payout the bets subgraph recorded (
-
BetsReportEntry:- It gains
isFreebetAmountReturnable?: boolean | null, whichgetBetsReportfills; absent means returnable. createdAtandBetsReportSelection.oddsare optional, deprecated and ignored.isRedeemedis deprecated and ignored, and its type is unchanged.
Entries built by older callers still type-check.
- It gains
-
New
isExtendedConditionId(conditionId)tells whether a condition is extended from the first digit of its id:
5or6. An extended condition is named from the titles the API sends with it, never from
@azuro-org/dictionaries.groupConditionsByMarketandgetPredefinedCombonow use it, so a condition starting
with6takes the extended path as one starting with5does.import { isExtendedConditionId } from '@azuro-org/toolkit' isExtendedConditionId('6001000000000000000000000000001') // true isExtendedConditionId('1001000000000000000000000000001') // false
-
calcComboOddssingle-leg boundary. The new constantSINGLE_MARGIN_REMOVED_ATmarks the moment a single-leg
bet stopped carrying the combo pricing rule. A single-leg list created at or after it prices at that leg's quoted
odds. Two or more legs keep the combo rule. -
Deprecated, still exported and still working:
calcComboOddsandMARGIN_APPLIED_AT: read a bet'sodds/settledOddsandpotentialPayout/payout(or
rawPotentialPayout/rawPayout) instead of re-pricing its legs on the client.isSelectionCanceled: readselection.result === SelectionResult.Canceled.
calcMinOdds, which prices new bets, is unchanged. -
GraphQL fragments. Fields are only added; none is removed.
Bet:rawAmount,rawPotentialPayout,rawPayoutandcore.liquidityPool.tokenDecimals.BetReport:isFreebetAmountReturnable.Bettor:affiliate;canceledBetsCountandcashedOutBetsCount;freebetBetsCount,freebetWonBetsCount,freebetLostBetsCountandfreebetCanceledBetsCount;rawFreebetTurnover,rawFreebetInBets,rawFreebetToPayoutandrawFreebetTotalPayout.
- The v3 bets of
GameBets:isFreebetandisFreebetAmountReturnable.
-
SelectionResultnow hasCancelednext toWonandLost. An exhaustiveswitchover it needs the new
case.
Changed meaning
- The report's freebet
returnsandprofitare the bettor's share. Before,returnssummed the pool's whole
payout, andprofitwasreturns - turnover. - Extended conditions may start with
6. Replace anyconditionId[0] === '5'test withisExtendedConditionId.
Otherwise a condition starting with6is looked up in@azuro-org/dictionaries, which does not have it.
Docs:
getBetsReport
calcComboOdds
isExtendedConditionId
release notes
Full Changelog: v7.1.0...v7.2.0