@azuro-org/sdk
Version:
One-stop solution for building betting dApps on the Azuro Protocol.
40 lines (39 loc) • 1.61 kB
TypeScript
import { type Selection, type ChainId } from '@azuro-org/toolkit';
import { type UseQueryResult } from '@tanstack/react-query';
import { type QueryParameter, type Bet } from '../../global';
export type PrecalculatedCashout = {
isAvailable: boolean;
odds: string;
} & Selection;
export type PrecalculatedCashoutsQueryData = {
margin: string;
minMargin: string;
cashouts: Record<string, PrecalculatedCashout>;
} | undefined;
export type UsePrecalculatedCashoutsProps = {
bet: Pick<Bet, 'tokenId' | 'amount' | 'outcomes' | 'status' | 'totalOdds' | 'freebetId'>;
chainId?: ChainId;
query?: QueryParameter<PrecalculatedCashoutsQueryData>;
};
export type UsePrecalculatedCashouts = (props: UsePrecalculatedCashoutsProps) => UseQueryResult<{
isAvailable: boolean;
cashoutAmount: number | undefined;
}>;
/**
* Get precalculated cashout data for a bet including availability and cashout amount.
* Automatically refetches every 60 seconds to keep data up to date.
*
* Only works for accepted bets without freebet and from the same provider.
* Calculates cashout amount based on current odds and margin.
*
* - Docs: https://gem.azuro.org/hub/apps/sdk/cashout/usePrecalculatedCashouts
*
* @example
* import { usePrecalculatedCashouts } from '@azuro-org/sdk'
*
* const { data, isFetching } = usePrecalculatedCashouts({
* bet: { tokenId: '123', amount: '100', outcomes: [...], status: 'Accepted', totalOdds: 2.5, freebetId: null },
* })
* const { isAvailable, cashoutAmount } = data || {}
* */
export declare const usePrecalculatedCashouts: UsePrecalculatedCashouts;