@azuro-org/toolkit 5.2.0-beta.1 → 6.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/docs/bets/fragments/legacyLiveBet.d.ts +1 -0
- package/dist/docs/bets/fragments/legacyPrematchBet.d.ts +1 -0
- package/dist/docs/bets/legacyBets.d.ts +2 -0
- package/dist/docs/index.d.ts +0 -13
- package/dist/global.d.ts +33 -3
- package/dist/helpers/normalizeTimestampToMs.d.ts +9 -0
- package/dist/helpers/serializeApiParams.d.ts +4 -0
- package/dist/index.d.ts +27 -18
- package/dist/index.js +942 -605
- package/dist/index.js.map +1 -1
- package/dist/utils/bet/createBet.d.ts +39 -0
- package/dist/utils/bet/createComboBet.d.ts +44 -0
- package/dist/utils/bet/getBet.d.ts +28 -0
- package/dist/utils/{getBetCalculation.d.ts → bet/getBetCalculation.d.ts} +10 -15
- package/dist/utils/bet/getBetFee.d.ts +32 -0
- package/dist/utils/bet/getBetStatus.d.ts +43 -0
- package/dist/utils/bet/getBetTypedData.d.ts +38 -0
- package/dist/utils/bet/getBetsByBettor.d.ts +44 -0
- package/dist/utils/bet/getComboBetTypedData.d.ts +42 -0
- package/dist/utils/bet/types.d.ts +128 -0
- package/dist/utils/bonus/getAvailableFreebets.d.ts +26 -3
- package/dist/utils/bonus/getBonuses.d.ts +23 -3
- package/dist/utils/calcMinOdds.d.ts +20 -0
- package/dist/utils/cashout/createCashout.d.ts +26 -3
- package/dist/utils/cashout/getCalculatedCashout.d.ts +29 -4
- package/dist/utils/cashout/getCashout.d.ts +22 -3
- package/dist/utils/cashout/getCashoutTypedData.d.ts +30 -3
- package/dist/utils/cashout/getPrecalculatedCashouts.d.ts +31 -3
- package/dist/utils/feed/getConditionsByGameIds.d.ts +52 -0
- package/dist/utils/feed/getConditionsState.d.ts +34 -0
- package/dist/utils/feed/getGamesByFilters.d.ts +35 -0
- package/dist/utils/feed/getGamesByIds.d.ts +26 -0
- package/dist/utils/feed/getNavigation.d.ts +58 -0
- package/dist/utils/feed/getSports.d.ts +57 -0
- package/dist/utils/feed/searchGames.d.ts +29 -0
- package/dist/utils/feed/types.d.ts +46 -0
- package/dist/utils/getEndpoints.d.ts +1 -0
- package/dist/utils/getIsPendingResolution.d.ts +17 -4
- package/dist/utils/getProviderFromId.d.ts +12 -0
- package/dist/utils/groupConditionsByMarket.d.ts +22 -4
- package/package.json +1 -1
- package/dist/docs/bets/bets.d.ts +0 -67
- package/dist/docs/bets/fragments/bet.d.ts +0 -57
- package/dist/utils/calcMindOdds.d.ts +0 -6
- package/dist/utils/createBet.d.ts +0 -17
- package/dist/utils/createComboBet.d.ts +0 -17
- package/dist/utils/getBet.d.ts +0 -23
- package/dist/utils/getBetFee.d.ts +0 -14
- package/dist/utils/getBetStatus.d.ts +0 -19
- package/dist/utils/getBetTypedData.d.ts +0 -16
- package/dist/utils/getBetsHistory.d.ts +0 -71
- package/dist/utils/getComboBetTypedData.d.ts +0 -16
- package/dist/utils/getMaxBet.d.ts +0 -18
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Address } from 'viem';
|
|
2
2
|
import { type Environment } from '../../envs';
|
|
3
3
|
import { type ChainId } from '../../config';
|
|
4
|
-
export type
|
|
4
|
+
export type GetCalculatedCashoutResult = {
|
|
5
5
|
calculationId: string;
|
|
6
6
|
account: string;
|
|
7
7
|
environment: Environment;
|
|
@@ -12,10 +12,35 @@ export type GetCalculatedCashout = {
|
|
|
12
12
|
approveExpiredAt: number;
|
|
13
13
|
isLive: boolean;
|
|
14
14
|
} | null;
|
|
15
|
-
|
|
15
|
+
/** @deprecated use GetCalculatedCashoutResult instead */
|
|
16
|
+
export type GetCalculatedCashout = GetCalculatedCashoutResult;
|
|
17
|
+
export type GetCalculatedCashoutParams = {
|
|
16
18
|
chainId: ChainId;
|
|
17
19
|
account: Address;
|
|
18
20
|
graphBetId: string;
|
|
19
21
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves the calculated cashout information for a specific bet, including the cashout amount and odds.
|
|
24
|
+
* Returns null if no cashout calculation is available for the bet.
|
|
25
|
+
*
|
|
26
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/cashout/getCalculatedCashout
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* import { getCalculatedCashout } from '@azuro-org/toolkit'
|
|
30
|
+
*
|
|
31
|
+
* const chainId = 100
|
|
32
|
+
* const account = '0x123...'
|
|
33
|
+
* const graphBetId = '456'
|
|
34
|
+
*
|
|
35
|
+
* const cashout = await getCalculatedCashout({
|
|
36
|
+
* chainId,
|
|
37
|
+
* account,
|
|
38
|
+
* graphBetId,
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* if (cashout) {
|
|
42
|
+
* console.log(`Cashout amount: ${cashout.cashoutAmount}`)
|
|
43
|
+
* console.log(`Cashout odds: ${cashout.cashoutOdds}`)
|
|
44
|
+
* }
|
|
45
|
+
* */
|
|
46
|
+
export declare const getCalculatedCashout: (props: GetCalculatedCashoutParams) => Promise<GetCalculatedCashoutResult>;
|
|
@@ -3,9 +3,28 @@ import { type CreateCashoutResponse } from './createCashout';
|
|
|
3
3
|
export type GetCashoutResponse = {
|
|
4
4
|
txHash: string;
|
|
5
5
|
} & CreateCashoutResponse;
|
|
6
|
-
type
|
|
6
|
+
export type GetCashoutResult = GetCashoutResponse | null;
|
|
7
|
+
export type GetCashoutParams = {
|
|
7
8
|
chainId: ChainId;
|
|
8
9
|
orderId: string;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves the status and details of a cashout order by its order ID.
|
|
13
|
+
* Returns null if the cashout order is not found.
|
|
14
|
+
*
|
|
15
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/cashout/getCashout
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* import { getCashout } from '@azuro-org/toolkit'
|
|
19
|
+
*
|
|
20
|
+
* const chainId = 100
|
|
21
|
+
* const orderId = 'abc123'
|
|
22
|
+
*
|
|
23
|
+
* const cashout = await getCashout({ chainId, orderId })
|
|
24
|
+
*
|
|
25
|
+
* if (cashout) {
|
|
26
|
+
* console.log(`State: ${cashout.state}`)
|
|
27
|
+
* console.log(`Transaction hash: ${cashout.txHash}`)
|
|
28
|
+
* }
|
|
29
|
+
* */
|
|
30
|
+
export declare const getCashout: ({ chainId, orderId }: GetCashoutParams) => Promise<GetCashoutResult>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SignTypedDataParameters, type Address } from 'viem';
|
|
2
2
|
import { type ChainId, CASHOUT_DATA_TYPES } from '../../config';
|
|
3
|
-
type
|
|
3
|
+
export type GetCashoutTypedDataParams = {
|
|
4
4
|
chainId: ChainId;
|
|
5
5
|
account: Address;
|
|
6
6
|
attention: string;
|
|
@@ -8,5 +8,32 @@ type Props = {
|
|
|
8
8
|
cashoutOdds: string | bigint;
|
|
9
9
|
expiredAt: number;
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Generates EIP-712 typed data for signing a cashout order.
|
|
13
|
+
* This typed data must be signed by the user before submitting the cashout.
|
|
14
|
+
*
|
|
15
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/cashout/getCashoutTypedData
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* import { getCashoutTypedData } from '@azuro-org/toolkit'
|
|
19
|
+
* import { signTypedData } from 'viem/accounts'
|
|
20
|
+
*
|
|
21
|
+
* const chainId = 100
|
|
22
|
+
* const account = '0x123...'
|
|
23
|
+
* const tokenId = '456'
|
|
24
|
+
* const cashoutOdds = '1.85'
|
|
25
|
+
* const expiredAt = Math.floor(Date.now() / 1000) + 3600
|
|
26
|
+
* const attention = 'By signing this transaction, I agree to cash out on Azuro'
|
|
27
|
+
*
|
|
28
|
+
* const typedData = getCashoutTypedData({
|
|
29
|
+
* chainId,
|
|
30
|
+
* account,
|
|
31
|
+
* attention,
|
|
32
|
+
* tokenId,
|
|
33
|
+
* cashoutOdds,
|
|
34
|
+
* expiredAt,
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* const signature = await signTypedData(typedData)
|
|
38
|
+
* */
|
|
39
|
+
export declare const getCashoutTypedData: (props: GetCashoutTypedDataParams) => SignTypedDataParameters<typeof CASHOUT_DATA_TYPES>;
|
|
@@ -11,10 +11,38 @@ type GetPrecalculatedCashoutsResponse = {
|
|
|
11
11
|
}[];
|
|
12
12
|
}[];
|
|
13
13
|
};
|
|
14
|
-
export type
|
|
15
|
-
|
|
14
|
+
export type GetPrecalculatedCashoutsResult = GetPrecalculatedCashoutsResponse | null;
|
|
15
|
+
/** @deprecated use GetPrecalculatedCashoutsResult instead */
|
|
16
|
+
export type GetPrecalculatedCashouts = GetPrecalculatedCashoutsResult;
|
|
17
|
+
export type GetPrecalculatedCashoutsParams = {
|
|
16
18
|
chainId: ChainId;
|
|
17
19
|
conditionIds: string[];
|
|
18
20
|
};
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves precalculated cashout availability and prices for specified conditions.
|
|
23
|
+
* Returns margin information and outcome prices for each available condition.
|
|
24
|
+
*
|
|
25
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/cashout/getPrecalculatedCashouts
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* import { getPrecalculatedCashouts } from '@azuro-org/toolkit'
|
|
29
|
+
*
|
|
30
|
+
* const chainId = 100
|
|
31
|
+
* const conditionIds = ['123', '456', '789']
|
|
32
|
+
*
|
|
33
|
+
* const cashouts = await getPrecalculatedCashouts({
|
|
34
|
+
* chainId,
|
|
35
|
+
* conditionIds,
|
|
36
|
+
* })
|
|
37
|
+
*
|
|
38
|
+
* if (cashouts) {
|
|
39
|
+
* cashouts.availables.forEach(({ conditionId, available, outcomes }) => {
|
|
40
|
+
* console.log(`Condition ${conditionId} available: ${available}`)
|
|
41
|
+
* outcomes.forEach(({ outcomeId, price }) => {
|
|
42
|
+
* console.log(` Outcome ${outcomeId}: ${price}`)
|
|
43
|
+
* })
|
|
44
|
+
* })
|
|
45
|
+
* }
|
|
46
|
+
* */
|
|
47
|
+
export declare const getPrecalculatedCashouts: (props: GetPrecalculatedCashoutsParams) => Promise<GetPrecalculatedCashoutsResult>;
|
|
20
48
|
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ConditionState } from '../../global';
|
|
2
|
+
import type { ChainId } from '../../config';
|
|
3
|
+
export type GetConditionsByGameIdsParams = {
|
|
4
|
+
chainId: ChainId;
|
|
5
|
+
gameIds?: string | string[];
|
|
6
|
+
states?: ConditionState | ConditionState[];
|
|
7
|
+
outcomeIds?: string | string[];
|
|
8
|
+
maxMargin?: number | string;
|
|
9
|
+
orderBy?: string;
|
|
10
|
+
orderDir?: 'asc' | 'desc';
|
|
11
|
+
};
|
|
12
|
+
export type ConditionDetailedData = {
|
|
13
|
+
id: string;
|
|
14
|
+
conditionId: string;
|
|
15
|
+
state: ConditionState;
|
|
16
|
+
title: string | null;
|
|
17
|
+
isExpressForbidden: boolean;
|
|
18
|
+
isPrematchEnabled: boolean;
|
|
19
|
+
isLiveEnabled: boolean;
|
|
20
|
+
margin: string;
|
|
21
|
+
outcomes: {
|
|
22
|
+
title: string | null;
|
|
23
|
+
outcomeId: string;
|
|
24
|
+
odds: string;
|
|
25
|
+
}[];
|
|
26
|
+
game: {
|
|
27
|
+
gameId: string;
|
|
28
|
+
sport: {
|
|
29
|
+
sportId: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
wonOutcomeIds: string[];
|
|
33
|
+
};
|
|
34
|
+
export type GetConditionsByGameIdsResponse = {
|
|
35
|
+
conditions: ConditionDetailedData[];
|
|
36
|
+
};
|
|
37
|
+
export type GetConditionsByGameIdsResponseResult = GetConditionsByGameIdsResponse['conditions'];
|
|
38
|
+
/**
|
|
39
|
+
* Fetches detailed conditions data for a given list of game IDs.
|
|
40
|
+
* Returns comprehensive condition information including outcomes, odds, and game relationships.
|
|
41
|
+
*
|
|
42
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/feed/getConditionsByGameIds
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* import { getConditionsByGameIds } from '@azuro-org/toolkit'
|
|
46
|
+
*
|
|
47
|
+
* const conditions = await getConditionsByGameIds({
|
|
48
|
+
* chainId: 137,
|
|
49
|
+
* gameIds: ['1006000000000077484167'],
|
|
50
|
+
* })
|
|
51
|
+
* */
|
|
52
|
+
export declare const getConditionsByGameIds: (props: GetConditionsByGameIdsParams) => Promise<GetConditionsByGameIdsResponseResult>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ConditionState } from '../../global';
|
|
2
|
+
import type { ChainId } from '../../config';
|
|
3
|
+
export type GetConditionsStateParams = {
|
|
4
|
+
chainId: ChainId;
|
|
5
|
+
conditionIds: string[];
|
|
6
|
+
};
|
|
7
|
+
export type ConditionStateData = {
|
|
8
|
+
conditionId: string;
|
|
9
|
+
state: ConditionState;
|
|
10
|
+
outcomes: {
|
|
11
|
+
id: string;
|
|
12
|
+
outcomeId: string;
|
|
13
|
+
odds: string;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
type ConditionsStateResponse = {
|
|
17
|
+
conditions: ConditionStateData[];
|
|
18
|
+
};
|
|
19
|
+
export type GetConditionsStateResult = ConditionsStateResponse['conditions'];
|
|
20
|
+
/**
|
|
21
|
+
* Fetches up-to-date condition states and outcome odds for a list of conditions.
|
|
22
|
+
*
|
|
23
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/feed/getConditionsState
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* import { getConditionsState } from '@azuro-org/toolkit'
|
|
27
|
+
*
|
|
28
|
+
* const conditions = await getConditionsState({
|
|
29
|
+
* chainId: 137,
|
|
30
|
+
* conditionIds: ['300610060000000000635055340000000000000000387193'],
|
|
31
|
+
* })
|
|
32
|
+
* */
|
|
33
|
+
export declare const getConditionsState: (props: GetConditionsStateParams) => Promise<GetConditionsStateResult>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { GameState, ConditionState } from '../../global';
|
|
2
|
+
import type { ChainId } from '../../config';
|
|
3
|
+
import type { SportHubSlug, GameOrderBy, PaginatedGamesResponse } from './types';
|
|
4
|
+
export type GetGamesByFiltersParams = {
|
|
5
|
+
chainId: ChainId;
|
|
6
|
+
state?: GameState.Live | GameState.Prematch;
|
|
7
|
+
sportIds?: string | number | (string | number)[];
|
|
8
|
+
leagueSlugs?: string | string[];
|
|
9
|
+
sportHub?: SportHubSlug;
|
|
10
|
+
conditionsState?: ConditionState | ConditionState[];
|
|
11
|
+
orderBy?: GameOrderBy;
|
|
12
|
+
orderDir?: 'asc' | 'desc';
|
|
13
|
+
/** 1-based, default: 1 */
|
|
14
|
+
page?: number;
|
|
15
|
+
/** 1-based, default: 10 */
|
|
16
|
+
perPage?: number;
|
|
17
|
+
};
|
|
18
|
+
export type GetGamesByFiltersResult = PaginatedGamesResponse;
|
|
19
|
+
/**
|
|
20
|
+
* Fetches games by applying various filters such as sport, league, or game state.
|
|
21
|
+
* Returns paginated results ideal for building sport/country/league listing pages.
|
|
22
|
+
*
|
|
23
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/feed/getGamesByFilters
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* import { GameState, getGamesByFilters } from '@azuro-org/toolkit'
|
|
27
|
+
*
|
|
28
|
+
* const games = await getGamesByFilters({
|
|
29
|
+
* chainId: 137,
|
|
30
|
+
* state: GameState.Prematch,
|
|
31
|
+
* page: 2,
|
|
32
|
+
* perPage: 50,
|
|
33
|
+
* })
|
|
34
|
+
* */
|
|
35
|
+
export declare const getGamesByFilters: (props: GetGamesByFiltersParams) => Promise<GetGamesByFiltersResult>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ChainId } from '../../config';
|
|
2
|
+
import type { GameData } from './types';
|
|
3
|
+
export type GetGamesByIdsParams = {
|
|
4
|
+
chainId: ChainId;
|
|
5
|
+
gameIds: string[];
|
|
6
|
+
};
|
|
7
|
+
type GetGamesByIdsResponse = GameData[];
|
|
8
|
+
export type GetGamesByIdsResult = GetGamesByIdsResponse;
|
|
9
|
+
/**
|
|
10
|
+
* Fetches game data for a specific list of game IDs.
|
|
11
|
+
* Returns detailed information for each requested game including participants, timing, and league data.
|
|
12
|
+
*
|
|
13
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/feed/getGamesByIds
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* import { getGamesByIds } from '@azuro-org/toolkit'
|
|
17
|
+
*
|
|
18
|
+
* const games = await getGamesByIds({
|
|
19
|
+
* chainId: 137,
|
|
20
|
+
* gameIds: ['1006000000000080373237'],
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* const gameData = games[0]
|
|
24
|
+
* */
|
|
25
|
+
export declare const getGamesByIds: (props: GetGamesByIdsParams) => Promise<GetGamesByIdsResult>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ChainId } from '../../config';
|
|
2
|
+
import type { SportHubSlug } from './types';
|
|
3
|
+
export type GetNavigationParams = {
|
|
4
|
+
chainId: ChainId;
|
|
5
|
+
sportHub?: SportHubSlug;
|
|
6
|
+
sportIds?: string | number | (string | number)[];
|
|
7
|
+
};
|
|
8
|
+
export type NavigationSportData = {
|
|
9
|
+
id: number;
|
|
10
|
+
slug: string;
|
|
11
|
+
name: string;
|
|
12
|
+
sportId: string;
|
|
13
|
+
sporthub: {
|
|
14
|
+
id: SportHubSlug;
|
|
15
|
+
slug: SportHubSlug;
|
|
16
|
+
};
|
|
17
|
+
activeGamesCount: number;
|
|
18
|
+
activeLiveGamesCount: number;
|
|
19
|
+
activePrematchGamesCount: number;
|
|
20
|
+
countries: {
|
|
21
|
+
id: string;
|
|
22
|
+
slug: string;
|
|
23
|
+
name: string;
|
|
24
|
+
turnover: string;
|
|
25
|
+
activeGamesCount: number;
|
|
26
|
+
activeLiveGamesCount: number;
|
|
27
|
+
activePrematchGamesCount: number;
|
|
28
|
+
leagues: {
|
|
29
|
+
id: string;
|
|
30
|
+
slug: string;
|
|
31
|
+
name: string;
|
|
32
|
+
turnover: string;
|
|
33
|
+
activeGamesCount: number;
|
|
34
|
+
activeLiveGamesCount: number;
|
|
35
|
+
activePrematchGamesCount: number;
|
|
36
|
+
}[];
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
type GetNavigationResponse = {
|
|
40
|
+
sports: NavigationSportData[];
|
|
41
|
+
};
|
|
42
|
+
export type GetNavigationResult = GetNavigationResponse['sports'];
|
|
43
|
+
/**
|
|
44
|
+
* Fetches navigation structure with sports, countries, and leagues hierarchy.
|
|
45
|
+
* Returns active game counts at each level for building navigation menus.
|
|
46
|
+
*
|
|
47
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/feed/getNavigation
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* import { getNavigation } from '@azuro-org/toolkit'
|
|
51
|
+
*
|
|
52
|
+
* const sports = await getNavigation({
|
|
53
|
+
* chainId: 137,
|
|
54
|
+
* sportHub: 'sports',
|
|
55
|
+
* })
|
|
56
|
+
* */
|
|
57
|
+
export declare const getNavigation: (props: GetNavigationParams) => Promise<GetNavigationResult>;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { GameState } from '../../global';
|
|
2
|
+
import type { ChainId } from '../../config';
|
|
3
|
+
import type { GameData, SportHubSlug } from './types';
|
|
4
|
+
export type GetSportsParams = {
|
|
5
|
+
chainId: ChainId;
|
|
6
|
+
states?: GameState[];
|
|
7
|
+
/** 1-based, default: 1 */
|
|
8
|
+
page?: number;
|
|
9
|
+
/** default: 100 */
|
|
10
|
+
perPage?: number;
|
|
11
|
+
sportIds?: (string | number)[];
|
|
12
|
+
sportHub?: SportHubSlug;
|
|
13
|
+
countrySlug?: string;
|
|
14
|
+
leagueSlug?: string;
|
|
15
|
+
orderBy?: 'turnover' | 'startsAt';
|
|
16
|
+
orderDir?: 'asc' | 'desc';
|
|
17
|
+
};
|
|
18
|
+
export type SportData = {
|
|
19
|
+
id: number;
|
|
20
|
+
slug: string;
|
|
21
|
+
name: string;
|
|
22
|
+
sportId: string;
|
|
23
|
+
turnover: string;
|
|
24
|
+
countries: {
|
|
25
|
+
slug: string;
|
|
26
|
+
name: string;
|
|
27
|
+
turnover: string;
|
|
28
|
+
leagues: {
|
|
29
|
+
slug: string;
|
|
30
|
+
name: string;
|
|
31
|
+
turnover: string;
|
|
32
|
+
games: GameData[];
|
|
33
|
+
}[];
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
36
|
+
type GetSportsResponse = {
|
|
37
|
+
sports: SportData[];
|
|
38
|
+
};
|
|
39
|
+
export type GetSportsResult = GetSportsResponse['sports'];
|
|
40
|
+
/**
|
|
41
|
+
* Fetches a complete sports hierarchy including countries, leagues, and games.
|
|
42
|
+
* Returns nested structure with all games organized by sport, country, and league.
|
|
43
|
+
*
|
|
44
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/feed/getSports
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* import { GameState, getSports } from '@azuro-org/toolkit'
|
|
48
|
+
*
|
|
49
|
+
* const sports = await getSports({
|
|
50
|
+
* chainId: 137,
|
|
51
|
+
* states: [GameState.Prematch, GameState.Live],
|
|
52
|
+
* page: 1,
|
|
53
|
+
* perPage: 50,
|
|
54
|
+
* })
|
|
55
|
+
* */
|
|
56
|
+
export declare const getSports: (props: GetSportsParams) => Promise<GetSportsResult>;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ChainId } from '../../config';
|
|
2
|
+
import type { PaginatedGamesResponse } from './types';
|
|
3
|
+
export type SearchGamesParams = {
|
|
4
|
+
chainId: ChainId;
|
|
5
|
+
/** minimum 3 characters long */
|
|
6
|
+
query: string;
|
|
7
|
+
/** 1-based, default: 1 */
|
|
8
|
+
page?: number;
|
|
9
|
+
/** 1-based, default: 10 */
|
|
10
|
+
perPage?: number;
|
|
11
|
+
};
|
|
12
|
+
export type SearchGamesResult = PaginatedGamesResponse;
|
|
13
|
+
/**
|
|
14
|
+
* Searches for games by text query across game titles, leagues, and countries.
|
|
15
|
+
* Minimum query length is 3 characters. Returns paginated results.
|
|
16
|
+
*
|
|
17
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/feed/searchGames
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* import { searchGames } from '@azuro-org/toolkit'
|
|
21
|
+
*
|
|
22
|
+
* const { games } = await searchGames({
|
|
23
|
+
* chainId: 137,
|
|
24
|
+
* query: 'Manchester',
|
|
25
|
+
* page: 1,
|
|
26
|
+
* perPage: 10,
|
|
27
|
+
* })
|
|
28
|
+
* */
|
|
29
|
+
export declare const searchGames: (props: SearchGamesParams) => Promise<SearchGamesResult>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { GameState } from '../../global';
|
|
2
|
+
export declare enum GameOrderBy {
|
|
3
|
+
StartsAt = "startsAt",
|
|
4
|
+
Turnover = "turnover"
|
|
5
|
+
}
|
|
6
|
+
export type GameParticipant = {
|
|
7
|
+
image: string | null | undefined;
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
10
|
+
export type SportHubSlug = string;
|
|
11
|
+
export type GameData = {
|
|
12
|
+
id: string;
|
|
13
|
+
gameId: string;
|
|
14
|
+
slug: string;
|
|
15
|
+
title: string;
|
|
16
|
+
startsAt: string;
|
|
17
|
+
state: GameState;
|
|
18
|
+
turnover: string;
|
|
19
|
+
sport: {
|
|
20
|
+
sportId: string;
|
|
21
|
+
slug: string;
|
|
22
|
+
name: string;
|
|
23
|
+
sporthub: {
|
|
24
|
+
id: SportHubSlug;
|
|
25
|
+
slug: SportHubSlug;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
league: {
|
|
29
|
+
id?: string;
|
|
30
|
+
slug: string;
|
|
31
|
+
name: string;
|
|
32
|
+
};
|
|
33
|
+
country: {
|
|
34
|
+
id?: string;
|
|
35
|
+
slug: string;
|
|
36
|
+
name: string;
|
|
37
|
+
};
|
|
38
|
+
participants: GameParticipant[];
|
|
39
|
+
};
|
|
40
|
+
export type PaginatedGamesResponse = {
|
|
41
|
+
games: GameData[];
|
|
42
|
+
page: number;
|
|
43
|
+
perPage: number;
|
|
44
|
+
total: number;
|
|
45
|
+
totalPages: number;
|
|
46
|
+
};
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
import { GameState } from '../
|
|
2
|
-
type
|
|
1
|
+
import { GameState } from '../global';
|
|
2
|
+
export type GetIsPendingResolutionParams = {
|
|
3
3
|
state: GameState;
|
|
4
4
|
startsAt: string;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Determines if a game is pending resolution after completion.
|
|
8
|
+
* Returns true if the game is in Live state but has exceeded the expected resolution window (100 minutes after start).
|
|
9
|
+
*
|
|
10
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/getIsPendingResolution
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { getIsPendingResolution, GameState } from '@azuro-org/toolkit'
|
|
14
|
+
*
|
|
15
|
+
* const isPending = getIsPendingResolution({
|
|
16
|
+
* state: GameState.Live,
|
|
17
|
+
* startsAt: '1640000000'
|
|
18
|
+
* })
|
|
19
|
+
* */
|
|
20
|
+
export declare const getIsPendingResolution: ({ state, startsAt }: GetIsPendingResolutionParams) => boolean;
|
|
@@ -1 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the provider ID from a condition ID string.
|
|
3
|
+
* The provider ID is encoded in characters 2-4 of the condition ID.
|
|
4
|
+
*
|
|
5
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/getProviderFromId
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import { getProviderFromId } from '@azuro-org/toolkit'
|
|
9
|
+
*
|
|
10
|
+
* const providerId = getProviderFromId('C001234567890')
|
|
11
|
+
* console.log(providerId) // 001
|
|
12
|
+
* */
|
|
1
13
|
export declare const getProviderFromId: (id: string) => number;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConditionState } from '../
|
|
3
|
-
import type { Selection } from '../global';
|
|
1
|
+
import type { ConditionDetailedData } from './feed/getConditionsByGameIds';
|
|
2
|
+
import { ConditionState, type Selection } from '../global';
|
|
4
3
|
export type MarketOutcome = {
|
|
5
4
|
selectionName: string;
|
|
6
5
|
odds: number;
|
|
@@ -23,5 +22,24 @@ type Condition = {
|
|
|
23
22
|
};
|
|
24
23
|
export type Market = TMarket<Condition[]>;
|
|
25
24
|
export type GameMarkets = Market[];
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Groups game conditions by their market types and sorts them according to sport-specific ordering.
|
|
27
|
+
* It processes outcomes to include selection names, handles duplicate conditions, and organizes data for display.
|
|
28
|
+
*
|
|
29
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/groupConditionsByMarket
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* import { groupConditionsByMarket } from '@azuro-org/toolkit'
|
|
33
|
+
*
|
|
34
|
+
* const conditions = await getConditionsByGameIds({ gameIds: ['123'] })
|
|
35
|
+
* const markets = groupConditionsByMarket(conditions)
|
|
36
|
+
*
|
|
37
|
+
* markets.forEach(market => {
|
|
38
|
+
* console.log(market.name) // e.g., "Match Winner", "Total Goals"
|
|
39
|
+
* market.conditions.forEach(condition => {
|
|
40
|
+
* console.log(condition.outcomes) // outcomes with odds and selection names
|
|
41
|
+
* })
|
|
42
|
+
* })
|
|
43
|
+
* */
|
|
44
|
+
export declare const groupConditionsByMarket: (conditions: ConditionDetailedData[]) => GameMarkets;
|
|
27
45
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azuro-org/toolkit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-beta.0",
|
|
4
4
|
"description": "This framework-agnostic package provides essential utilities for building applications on the Azuro Protocol.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/dist/docs/bets/bets.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as Types from './types';
|
|
2
|
-
export type BetsQueryVariables = Types.Exact<{
|
|
3
|
-
first?: Types.InputMaybe<Types.Scalars['Int']['input']>;
|
|
4
|
-
skip?: Types.InputMaybe<Types.Scalars['Int']['input']>;
|
|
5
|
-
where: Types.V3_Bet_Filter;
|
|
6
|
-
orderBy?: Types.InputMaybe<Types.V3_Bet_OrderBy>;
|
|
7
|
-
orderDirection?: Types.InputMaybe<Types.OrderDirection>;
|
|
8
|
-
}>;
|
|
9
|
-
export type BetsQuery = {
|
|
10
|
-
__typename?: 'Query';
|
|
11
|
-
v3Bets: Array<{
|
|
12
|
-
__typename?: 'V3_Bet';
|
|
13
|
-
id: string;
|
|
14
|
-
actor: string;
|
|
15
|
-
amount: string;
|
|
16
|
-
status: Types.BetStatus;
|
|
17
|
-
potentialPayout: string;
|
|
18
|
-
payout?: string | null;
|
|
19
|
-
result?: Types.BetResult | null;
|
|
20
|
-
odds: string;
|
|
21
|
-
settledOdds?: string | null;
|
|
22
|
-
redeemedTxHash?: string | null;
|
|
23
|
-
affiliate: string;
|
|
24
|
-
isRedeemed: boolean;
|
|
25
|
-
isRedeemable: boolean;
|
|
26
|
-
isCashedOut: boolean;
|
|
27
|
-
freebetId?: string | null;
|
|
28
|
-
isFreebetAmountReturnable?: boolean | null;
|
|
29
|
-
paymasterContractAddress?: string | null;
|
|
30
|
-
tokenId: string;
|
|
31
|
-
createdAt: string;
|
|
32
|
-
resolvedAt?: string | null;
|
|
33
|
-
txHash: string;
|
|
34
|
-
core: {
|
|
35
|
-
__typename?: 'CoreContract';
|
|
36
|
-
address: string;
|
|
37
|
-
liquidityPool: {
|
|
38
|
-
__typename?: 'LiquidityPoolContract';
|
|
39
|
-
address: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
selections: Array<{
|
|
43
|
-
__typename?: 'V3_Selection';
|
|
44
|
-
odds: string;
|
|
45
|
-
result?: Types.SelectionResult | null;
|
|
46
|
-
conditionKind: Types.V3_SelectionConditionKind;
|
|
47
|
-
outcome: {
|
|
48
|
-
__typename?: 'V3_Outcome';
|
|
49
|
-
outcomeId: string;
|
|
50
|
-
title?: string | null;
|
|
51
|
-
condition: {
|
|
52
|
-
__typename?: 'V3_Condition';
|
|
53
|
-
conditionId: string;
|
|
54
|
-
title?: string | null;
|
|
55
|
-
status: Types.ConditionStatus;
|
|
56
|
-
gameId: string;
|
|
57
|
-
wonOutcomeIds?: Array<string> | null;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
}>;
|
|
61
|
-
cashout?: {
|
|
62
|
-
__typename?: 'Cashout';
|
|
63
|
-
payout: string;
|
|
64
|
-
} | null;
|
|
65
|
-
}>;
|
|
66
|
-
};
|
|
67
|
-
export declare const BetsDocument: import("graphql/language/ast").DocumentNode;
|