Skip to content

v8.2.0

Latest

Choose a tag to compare

@on47sky on47sky released this 11 Oct 16:59
· 2 commits to main since this release

The freebet bettor share, bet figures as recorded, and bettor summary totals

Requires @azuro-org/toolkit@^7.2.0.

What's new

  • useBets reads a v3 bet's figures as the bets subgraph records them. The figures are already priced by the
    protocol's rule, and nothing is re-priced on the client.

    • totalOdds is the settled odds once the bet is settled, and the placed odds before that.
    • possibleWin comes from the recorded potential payout.
    • settledPayout is the recorded payout. After redemption that is the amount actually paid, and for a canceled bet,
      whose totalOdds is 1, it is the stake.
    • payout, the claimable amount, is the same figure but only while the bet is redeemable, has won or been canceled,
      and was not cashed out. useRedeemBet sets it to null in the cached list as soon as the redeem is confirmed.
    • A leg's won, lost and canceled flags come from its selection's result alone.
    • The legs of extended conditions, whose ids start with 5 or 6, are named from the titles recorded with the bet
      or from the API, never from @azuro-org/dictionaries.
  • A freebet's money fields are the bettor's share. For a freebet, possibleWin, payout and settledPayout go
    through the toolkit's calcFreebetBettorShare:

    Freebet of 1.00 won at 1.50 payout / settledPayout
    Returnable 0.50
    Not returnable 1.50
    Flag absent 0.50
    Canceled 0

    Real-money bets keep their meaning. Bets from useLegacyBets keep their v2 figures.

  • useBetsSummary returns the exported BetsSummary type, which gains:

    • canceledBetsCount and cashedOutBetsCount;
    • withdrawable, which is toPayout + freebet.toPayout;
    • a freebet block: betsCount, wonBetsCount, lostBetsCount, canceledBetsCount, turnover, inBets,
      toPayout and totalPayout. Its payouts are the bettor's share.
    import { useBetsSummary } from '@azuro-org/sdk'
    
    const { data } = useBetsSummary({ account: '0x...' })
    const { betsCount, toPayout, withdrawable, freebet } = data ?? {}
    
    const hasEverBet = (betsCount ?? 0) + (freebet?.betsCount ?? 0) > 0
    • The top-level figures cover the wallet's own funds; freebets are counted only in freebet.
    • Every figure sums all of the wallet's rows, every pool and affiliate, unless affiliates narrows it.
    • Amounts use the decimals of the summary's chain, including after a chain switch.
  • The summary keeps up with the wallet.

    • Redeem or cash-out through the SDK: the cached summary is patched at once, on the bet's own pool and affiliate
      row, then re-read about 5 s and 15 s later.
      • A real-money redeem lowers toPayout by the payout, or by the stake when the bet was canceled.
      • A freebet redeem lowers freebet.toPayout by the share.
      • A cash-out lowers inBets by the stake, raises cashedOutBetsCount and leaves betsCount as it is.
      • No figure goes below zero.
    • New bet: the summary is re-read about 0, 4, 10 and 25 s after the receipt.
  • useBetsSummaryBySelection values a won freebet at the bettor's share and a lost freebet at 0.

  • useBetsReport inherits the toolkit's report change: the freebet line is the bettor's share, with
    profit = returns.

Changed meaning

  • A freebet's payout and settledPayout are the bettor's share; before, they were the pool's whole payout. If
    your app subtracted a returnable freebet's stake from them itself, remove that step.
  • useBetsSummary betsCount counts bets placed with the wallet's own funds only. A "has this wallet ever bet"
    check should test betsCount + freebet.betsCount.
  • totalOdds carries the subgraph's precision, up to 12 decimals. Format it for display.
  • Extended conditions may start with 6. See isExtendedConditionId in the toolkit's
    v7.2.0 release.

Note

useBetsSummary needs a bets subgraph that serves the new Bettor fields. 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. useBets keeps working on those chains.

Docs:
useBets
useBetsSummary
useBetsReport
Release Notes

Full Changelog: v8.1.0...v8.2.0