Toolkit v7.2 & SDK v8.2: Freebet Share and Recorded Bet Figures
Every figure that values a freebet now shows what the bettor receives: the bettor’s share of the payout, by the freebet contract’s rule. Bet figures are read as the bets subgraph records them, already priced by the protocol’s rule, with no client-side re-pricing. useBetsSummary also gains freebet totals and a withdrawable figure.
No compile-time migration, but some figures change meaning. Both releases are minors: nothing is removed and no type is narrowed. SDK 8.2.0 depends on @azuro-org/toolkit ^7.2.0. Check the places where your app reads these figures or recognises an extended condition:
- Freebet
payoutandsettledPayoutonuseBetsare the bettor’s share. Before SDK v8.2.0 they were the pool’s whole payout.possibleWinfollows the same rule: a freebet with no returnable flag is valued as returnable, and a canceled freebet reports 0. A returnable freebet of 1.00 won at 1.50 reads 0.50, wherepayoutandsettledPayoutread 1.50 before. If your app subtracted a returnable freebet’s stake from these figures itself, remove that step. - The freebet line of the bets report (
useBetsReport/getBetsReport):returnsis the sum of the bettor’s shares andprofitequalsreturns. Before,returnssummed the pool’s whole payout andprofitwasreturns - turnover. useBetsSummarybetsCountcounts bets placed with the wallet’s own funds only. Freebets are counted infreebet.betsCount. A “has this wallet ever bet” check should testbetsCount + freebet.betsCount.totalOddsonuseBetscarries the precision the subgraph records it at, up to 12 decimals. Format it for display rather than printing the raw number.- Extended conditions may start with
6. The first digit of a condition id is its type, and ids starting with5or6are both the extended type,5on older conditions. If your app testsconditionId[0] === '5', switch toisExtendedConditionId, or it will name a condition starting with6from@azuro-org/dictionaries, which does not have it. useBetsSummaryneeds a bets subgraph that serves the newBettorfields. They are served on Polygon, Base, Polygon Amoy and Base Sepolia. On Gnosis, Chiliz, Chiliz Spicy, BSC and BSC Testnet the query fails until the subgraph there is updated, so the hook returns an error.useBetskeeps working on those chains and reads bet figures as recorded, with no client rebuild.
What’s New
Toolkit v7.2.0
calcFreebetBettorShare- new. Returns the share of a freebet’s payout that the bettor receives. TakesCalcFreebetBettorShareParams(payout,amount,isAmountReturnable).getBetsReportandcalcBetsReportread every bet’s recorded payout with no combo rebuild, read a leg’s void from its selection result alone, and value the freebet line at the bettor’s share withprofit = returns.BetsReportEntry.isFreebetAmountReturnableis new and optional.BetsReportEntry.createdAtandBetsReportSelection.oddsare now optional, deprecated and ignored, so entries built by older callers still type-check.BetsReportEntry.isRedeemedstays required but is deprecated and ignored: a redeemed bet’srawPayoutis already the amount actually paid.SINGLE_MARGIN_REMOVED_AT- new constant.calcComboOddsprices a single leg created at or after it at its quoted odds.- Deprecated, still exported and still working:
calcComboOddsandMARGIN_APPLIED_AT(read a bet’sodds/settledOddsandpotentialPayout/payout, orrawPotentialPayout/rawPayout, instead of re-pricing its legs), andisSelectionCanceled(readselection.result === SelectionResult.Canceled). - Fragment additions, none removed:
BetFragmentgainsrawAmount,rawPotentialPayout,rawPayoutandcore.liquidityPool.tokenDecimals;BettorFragmentgains the affiliate, the counts and the freebet totals;BetReportFragmentgainsisFreebetAmountReturnable; the v3 bets ofGameBetsQuerygainisFreebetandisFreebetAmountReturnable. SelectionResultnow includesCanceled.isExtendedConditionId- new. Tells whether a condition is extended from the first digit of its id:5or6.groupConditionsByMarketandgetPredefinedCombouse it, so a condition starting with either digit takes the extended path: named by its API titles, never by@azuro-org/dictionaries.
SDK v8.2.0
useBetsreadstotalOdds,possibleWin,payoutandsettledPayoutas recorded. A freebet’s money fields are the bettor’s share, and a leg’s won, lost and canceled flags come from its selection result alone. Bets fromuseLegacyBetskeep the v2 figures.useRedeemBetalso sets a redeemed bet’spayouttonullin the cacheduseBetslist as soon as the transaction is confirmed, alongsideisRedeemedandisRedeemable, instead of keeping it until the next read.useBetsSummaryreturns the exportedBetsSummarytype with the newcanceledBetsCount,cashedOutBetsCount,withdrawableandfreebetblock. It sums every pool and affiliate row of the wallet and formats with the decimals of its chain (chainId, or the app’s current chain), also after a chain switch.- Redeem and cash-out patch the summary at once, on the bet’s own pool and affiliate row, and re-read it about 5 s and 15 s later. A cash-out no longer lowers
betsCount. A new bet re-reads the summary about 0, 4, 10 and 25 s after the receipt. useBetsReportinherits the toolkit report change.useBetsSummaryBySelectionvalues a won freebet at the bettor’s share and a lost freebet at 0.useBetsnames the legs of extended conditions, starting with5or6, from the titles recorded with the bet or, failing those, from the API, never from@azuro-org/dictionaries.
A freebet pays the bettor a share of its payout
The liquidity pool pays a freebet’s whole payout to the freebet contract, which splits it between the bettor and the freebet fund:
- Payout no greater than the stake: the bettor receives nothing and all of it goes back to the fund. A lost freebet pays 0, and a canceled one pays back exactly its stake.
- The freebet’s amount is returnable: the stake goes back to the fund and the bettor receives
payout - stake. - Otherwise (the flag is exactly
false): the bettor receives the whole payout.
A freebet whose flag is absent (null or undefined) is valued as returnable. That is the smaller of the two shares, so the app never shows more than the bettor receives.
For a freebet of 1.00 won at 1.50, the pool pays 1.50:
| Freebet | Bettor receives |
|---|---|
| Returnable | 0.50 |
| Not returnable | 1.50 |
| Flag absent | 0.50 |
| Canceled | 0 |
import { parseUnits } from 'viem'
import { calcFreebetBettorShare } from '@azuro-org/toolkit'
// a returnable freebet of 1 USDT that won at 1.5: the pool pays 1.5, the bettor receives 0.5
const share = calcFreebetBettorShare({
payout: parseUnits('1.5', 6), // the bet's payout as the pool records it, token base units
amount: parseUnits('1', 6), // the freebet's stake, token base units
isAmountReturnable: true, // null or undefined counts as returnable
})The math is plain bigint over base units, nothing is rounded.
Bet figures as recorded
useBets no longer re-prices anything on the client. Per state:
- Pending:
totalOddsis the odds the bet was placed at,possibleWinis the recorded potential payout,payoutandsettledPayoutarenull. - Won:
totalOddsis the settled odds,payoutis the recorded payout while the bet is redeemable,settledPayoutis the recorded payout and survives redemption. - Lost:
payoutisnull,settledPayoutis0, andpossibleWinkeeps the win that was missed. - Canceled:
totalOddsis1, andpossibleWin,settledPayoutand, while redeemable,payoutare the stake, or0for a freebet. - Cashed out:
payoutisnull. Readcashoutfor what the cash-out paid.
For a freebet each of these money figures is the bettor’s share. A combo is no longer re-priced on the client, and calcComboOdds is deprecated.
The bettor summary
import { useBetsSummary } from '@azuro-org/sdk'
const { data } = useBetsSummary({ account: '0x...' })
const { betsCount, toPayout, withdrawable, freebet } = data ?? {}
// freebet.betsCount, freebet.turnover, freebet.inBets, freebet.toPayout, freebet.totalPayout
const hasEverBet = (betsCount ?? 0) + (freebet?.betsCount ?? 0) > 0withdrawable is what the wallet can redeem now: toPayout plus freebet.toPayout. A won real-money bet waiting for redemption with 2.00 and a won returnable freebet of 1.00 at 1.50 give toPayout 2.00, freebet.toPayout 0.50 and withdrawable 2.50.
- The top-level figures cover the wallet’s own funds, and freebets are counted only in
freebet. Its payouts are the bettor’s share. - A redeem or cash-out made through the SDK updates the summary at once and confirms it from the subgraph about 5 s and 15 s later.
- A new bet appears in the summary without a reload, once the subgraph has recorded it.
See the full documentation.