@azuro-org/sdk
Version:
One-stop solution for building betting dApps on the Azuro Protocol.
40 lines (39 loc) • 1.48 kB
TypeScript
import { type ChainId, Legacy_Bet_OrderBy, OrderDirection } from '@azuro-org/toolkit';
import { type InfiniteData, type UseInfiniteQueryResult } from '@tanstack/react-query';
import { type Address } from 'viem';
import { type Bet, BetType, type InfiniteQueryParameters } from '../../global';
type UseLegacyBetsResult = {
bets: Bet[];
nextPage: number | undefined;
};
export type UseLegacyBetsProps = {
filter: {
bettor: Address;
affiliate?: string;
type?: BetType;
};
itemsPerPage?: number;
orderBy?: Legacy_Bet_OrderBy;
orderDir?: OrderDirection;
chainId?: ChainId;
query?: InfiniteQueryParameters<UseLegacyBetsResult>;
};
export type UseLegacyBets = (props: UseLegacyBetsProps) => UseInfiniteQueryResult<InfiniteData<UseLegacyBetsResult>>;
/**
* Fetches betting history from legacy Azuro contracts (v2) with infinite scroll pagination.
* Supports filtering by bet type (Unredeemed, Accepted, Settled, CashedOut).
*
* Use this hook for historical bets placed on legacy contracts. For current bets, use `useBets` instead.
*
* - Docs: https://gem.azuro.org/hub/apps/sdk/data-hooks/useLegacyBets
*
* @example
* import { useLegacyBets } from '@azuro-org/sdk'
*
* const { data, isFetching, hasNextPage, fetchNextPage } = useLegacyBets({
* filter: { bettor: '0x...' },
* })
* const allBets = data?.pages.flatMap(page => page.bets) || []
* */
export declare const useLegacyBets: UseLegacyBets;
export {};