@azuro-org/sdk
Version:
One-stop solution for building betting dApps on the Azuro Protocol.
44 lines (43 loc) • 1.96 kB
TypeScript
import { OutcomeState } from '@azuro-org/toolkit';
export type UseOutcomeStateProps = {
conditionId: string;
outcomeId: string;
initialState?: OutcomeState;
isInitiallyHidden?: boolean;
initialOdds?: number;
};
/**
* Watch real-time state updates for a single outcome.
* Subscribes to condition updates via websocket and tracks per-outcome state changes
* (Active, Stopped, Canceled, Won, Lost) and visibility.
* Requires `FeedSocketProvider` and `ConditionUpdatesProvider` (both are included in `AzuroSDKProvider`).
*
* This is the outcome-level analog of `useConditionState`: a single condition can hold several outcomes
* that independently become hidden or change state, so each outcome carries its own `state`/`hidden`.
*
* Returns `isLocked` helper to check if the outcome is not Active.
* Returns `isHidden` helper to check if the outcome should be hidden from the market's outcome list.
* Returns the live `odds` and `turnover` for the outcome (from the same `outcomeWatcher` update).
*
* - Docs: https://gem.azuro.org/hub/apps/sdk/watch-hooks/useOutcomeState
*
* @example
* import { useOutcomeState } from '@azuro-org/sdk'
* import { OutcomeState, type MarketOutcome } from '@azuro-org/toolkit'
*
* const { data: state, odds, turnover, isLocked, isHidden, isFetching } = useOutcomeState({
* conditionId: outcome.conditionId,
* outcomeId: outcome.outcomeId,
* initialState: outcome.state, // OutcomeState.Active, OutcomeState.Stopped, etc.
* isInitiallyHidden: outcome.hidden, // boolean, comes from MarketOutcome['hidden']
* initialOdds: outcome.odds, // number, comes from MarketOutcome['odds']
* })
* */
export declare const useOutcomeState: ({ conditionId, outcomeId, initialState, isInitiallyHidden, initialOdds }: UseOutcomeStateProps) => {
state: OutcomeState;
odds: number;
turnover: string;
isHidden: boolean | undefined;
isLocked: boolean;
isFetching: boolean;
};