@azuro-org/toolkit 5.1.8 → 5.2.0-beta.1
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/dist/index.d.ts +1 -0
- package/dist/index.js +50 -3
- package/dist/index.js.map +1 -1
- package/dist/utils/getBetCalculation.d.ts +40 -0
- package/dist/utils/getBetsHistory.d.ts +71 -0
- package/dist/utils/getMaxBet.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { createBet } from './utils/createBet';
|
|
|
17
17
|
export { createComboBet } from './utils/createComboBet';
|
|
18
18
|
export { getBet, type GetBetResponse } from './utils/getBet';
|
|
19
19
|
export { getMaxBet, type GetMaxBetResponse } from './utils/getMaxBet';
|
|
20
|
+
export { getBetCalculation, type GetBetCalculationResponse } from './utils/getBetCalculation';
|
|
20
21
|
export { getWaveLevels, WaveLevelName, type WaveLevelData, type WaveLevelsResponse } from './utils/wave/getWaveLevels';
|
|
21
22
|
export { getWaveStats, type WaveStatsResponse } from './utils/wave/getWaveStats';
|
|
22
23
|
export { getWavePeriods, type WavePeriodsResponse } from './utils/wave/getWavePeriods';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {gnosis,polygon,polygonAmoy,chiliz,spicy,base,baseSepolia,bscTestnet,bsc}from'viem/chains';import gql from'graphql-tag';import {getMarketKey,getMarketName,getMarketDescription,dictionaries,getSelectionName}from'@azuro-org/dictionaries';import {parseUnits,formatUnits}from'viem';var Environment;
|
|
1
|
+
import {gnosis,polygon,polygonAmoy,chiliz,spicy,base,baseSepolia,bscTestnet,bsc}from'viem/chains';import gql from'graphql-tag';import {getMarketKey,getMarketName,getMarketDescription,dictionaries,getSelectionName}from'@azuro-org/dictionaries';import {isAddress,parseUnits,formatUnits}from'viem';var Environment;
|
|
2
2
|
(function (Environment) {
|
|
3
3
|
Environment["GnosisDevXDAI"] = "GnosisDevXDAI";
|
|
4
4
|
Environment["GnosisXDAI"] = "GnosisXDAI";
|
|
@@ -8143,7 +8143,8 @@ const getBetStatus = (props) => {
|
|
|
8143
8143
|
}
|
|
8144
8144
|
const data = await response.json();
|
|
8145
8145
|
return data;
|
|
8146
|
-
}
|
|
8146
|
+
};/** @deprecated use `getBetCalculation` instead */
|
|
8147
|
+
const getMaxBet = async (props) => {
|
|
8147
8148
|
const { chainId, selections } = props;
|
|
8148
8149
|
const { api, environment } = chainsData[chainId];
|
|
8149
8150
|
const response = await fetch(`${api}/bet/calculation`, {
|
|
@@ -8168,6 +8169,52 @@ const getBetStatus = (props) => {
|
|
|
8168
8169
|
}
|
|
8169
8170
|
const data = await response.json();
|
|
8170
8171
|
return data.response;
|
|
8172
|
+
};/**
|
|
8173
|
+
* Calculates the minimum and maximum bet amount for given selections.
|
|
8174
|
+
* User's account is required to provide the **correct** maximum bet amount.
|
|
8175
|
+
* It may be undefined if the user isn't logged in.
|
|
8176
|
+
*
|
|
8177
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/getBetCalculation
|
|
8178
|
+
*
|
|
8179
|
+
* @example
|
|
8180
|
+
* import { getBetCalculation } from '@azuro-org/toolkit'
|
|
8181
|
+
*
|
|
8182
|
+
* const account = userWallet?.address
|
|
8183
|
+
* const selections = [
|
|
8184
|
+
* { conditionId: '1', outcomeId: '1' },
|
|
8185
|
+
* ]
|
|
8186
|
+
*
|
|
8187
|
+
* const { minBet, maxBet } = await getBetCalculation({ selections, account })
|
|
8188
|
+
* */
|
|
8189
|
+
const getBetCalculation = async (props) => {
|
|
8190
|
+
const { chainId, selections, account } = props;
|
|
8191
|
+
const { api, environment } = chainsData[chainId];
|
|
8192
|
+
const params = {
|
|
8193
|
+
bets: selections.map(({ conditionId, outcomeId }) => ({
|
|
8194
|
+
conditionId,
|
|
8195
|
+
outcomeId: +outcomeId,
|
|
8196
|
+
})),
|
|
8197
|
+
environment,
|
|
8198
|
+
};
|
|
8199
|
+
if (account && isAddress(account)) {
|
|
8200
|
+
params.wallet = account;
|
|
8201
|
+
}
|
|
8202
|
+
const response = await fetch(`${api}/bet/calculation_new`, {
|
|
8203
|
+
method: 'POST',
|
|
8204
|
+
headers: {
|
|
8205
|
+
'Accept': 'application/json',
|
|
8206
|
+
'Content-Type': 'application/json',
|
|
8207
|
+
},
|
|
8208
|
+
body: JSON.stringify(params),
|
|
8209
|
+
});
|
|
8210
|
+
if (response.status === 404) {
|
|
8211
|
+
return null;
|
|
8212
|
+
}
|
|
8213
|
+
if (!response.ok) {
|
|
8214
|
+
throw new Error(`API /bet/calculation failed: Status ${response.status}: ${response.statusText}`);
|
|
8215
|
+
}
|
|
8216
|
+
const data = await response.json();
|
|
8217
|
+
return data.response;
|
|
8171
8218
|
};var WaveLevelName;
|
|
8172
8219
|
(function (WaveLevelName) {
|
|
8173
8220
|
WaveLevelName["Grey"] = "Grey";
|
|
@@ -8523,4 +8570,4 @@ const createCashout = async (props) => {
|
|
|
8523
8570
|
publicCustomData: bonus.publicCustomData,
|
|
8524
8571
|
};
|
|
8525
8572
|
});
|
|
8526
|
-
};export{Aggregation_Interval,BET_DATA_TYPES,ConditionStatus as BetConditionStatus,BetFragmentDoc,BetRestrictionType,BetResult,BetState,BetStatus,V3_Bet_OrderBy as Bet_OrderBy,BetsDocument,BettorFragmentDoc,BettorsDocument,BonusStatus,BonusType,CASHOUT_DATA_TYPES,CASHOUT_TYPED_DATA_DOMAIN_NAME,CASHOUT_TYPED_DATA_DOMAIN_VERSION,CLIENT_DATA_TYPES,COMBO_BET_DATA_TYPES,CashoutState,ConditionDocument,ConditionFragmentDoc,ConditionState,Condition_OrderBy,ConditionsBatchDocument,ConditionsDocument,Country_OrderBy,Environment,EventName,EventRestrictionState,Event_OrderBy,FreebetType,GameBetsDocument,GameDocument,GameInfoFragmentDoc,GameState,Game_OrderBy,GamesDocument,BetStatus$1 as GraphBetStatus,League_OrderBy,LegacyBetsDocument,GameStatus as LegacyGameStatus,LegacyLiveBetFragmentDoc,LegacyLiveGamesDocument,LegacyPrematchBetFragmentDoc,Bet_OrderBy as Legacy_Bet_OrderBy,NavigationDocument,ODDS_COMBO_FEE_MODIFIER,ODDS_DECIMALS,OrderDirection,OutcomeResult,Outcome_OrderBy,Participant_OrderBy,V3_SelectionConditionKind as SelectionKind,SelectionResult,SportHub_OrderBy,Sport_OrderBy,SportsDocument,SportsNavigationDocument,TYPED_DATA_DOMAIN_NAME,TYPED_DATA_DOMAIN_VERSION,VirtualCondition_OrderBy,VirtualGame_OrderBy,WaveLevelName,_SubgraphErrorPolicy_,activateWave,azuroBetAbi,baseData,baseSepoliaData,bscData,bscTestnetData,calcMindOdds,cashoutAbi,chainsData,chainsDataByEnv,chilizData,coreAbi,createBet,createCashout,createComboBet,environments,getApiEndpoint,getAvailableFreebets,getBet,getBetFee,getBetStatus,getBetTypedData,getBetsGraphqlEndpoint,getBonuses,getCalculatedCashout,getCashout,getCashoutTypedData,getComboBetTypedData,getFeedGraphqlEndpoint,getIsPendingResolution,getMaxBet,getPrecalculatedCashouts,getProviderFromId,getSocketEndpoint,getWaveLeaderBoard,getWaveLevels,getWavePeriods,getWaveStats,gnosisData,gnosisDevData,groupConditionsByMarket,lpAbi,paymasterAbi,polygonAmoyData,polygonData,relayerAbi,setupContracts,spicyData,vaultAbi};//# sourceMappingURL=index.js.map
|
|
8573
|
+
};export{Aggregation_Interval,BET_DATA_TYPES,ConditionStatus as BetConditionStatus,BetFragmentDoc,BetRestrictionType,BetResult,BetState,BetStatus,V3_Bet_OrderBy as Bet_OrderBy,BetsDocument,BettorFragmentDoc,BettorsDocument,BonusStatus,BonusType,CASHOUT_DATA_TYPES,CASHOUT_TYPED_DATA_DOMAIN_NAME,CASHOUT_TYPED_DATA_DOMAIN_VERSION,CLIENT_DATA_TYPES,COMBO_BET_DATA_TYPES,CashoutState,ConditionDocument,ConditionFragmentDoc,ConditionState,Condition_OrderBy,ConditionsBatchDocument,ConditionsDocument,Country_OrderBy,Environment,EventName,EventRestrictionState,Event_OrderBy,FreebetType,GameBetsDocument,GameDocument,GameInfoFragmentDoc,GameState,Game_OrderBy,GamesDocument,BetStatus$1 as GraphBetStatus,League_OrderBy,LegacyBetsDocument,GameStatus as LegacyGameStatus,LegacyLiveBetFragmentDoc,LegacyLiveGamesDocument,LegacyPrematchBetFragmentDoc,Bet_OrderBy as Legacy_Bet_OrderBy,NavigationDocument,ODDS_COMBO_FEE_MODIFIER,ODDS_DECIMALS,OrderDirection,OutcomeResult,Outcome_OrderBy,Participant_OrderBy,V3_SelectionConditionKind as SelectionKind,SelectionResult,SportHub_OrderBy,Sport_OrderBy,SportsDocument,SportsNavigationDocument,TYPED_DATA_DOMAIN_NAME,TYPED_DATA_DOMAIN_VERSION,VirtualCondition_OrderBy,VirtualGame_OrderBy,WaveLevelName,_SubgraphErrorPolicy_,activateWave,azuroBetAbi,baseData,baseSepoliaData,bscData,bscTestnetData,calcMindOdds,cashoutAbi,chainsData,chainsDataByEnv,chilizData,coreAbi,createBet,createCashout,createComboBet,environments,getApiEndpoint,getAvailableFreebets,getBet,getBetCalculation,getBetFee,getBetStatus,getBetTypedData,getBetsGraphqlEndpoint,getBonuses,getCalculatedCashout,getCashout,getCashoutTypedData,getComboBetTypedData,getFeedGraphqlEndpoint,getIsPendingResolution,getMaxBet,getPrecalculatedCashouts,getProviderFromId,getSocketEndpoint,getWaveLeaderBoard,getWaveLevels,getWavePeriods,getWaveStats,gnosisData,gnosisDevData,groupConditionsByMarket,lpAbi,paymasterAbi,polygonAmoyData,polygonData,relayerAbi,setupContracts,spicyData,vaultAbi};//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
import { type ChainId } from '../config';
|
|
3
|
+
import { type Selection } from '../global';
|
|
4
|
+
export type GetBetCalculationResponse = {
|
|
5
|
+
response: {
|
|
6
|
+
/** if `minBet` is `undefined`, there is no bottom limit */
|
|
7
|
+
minBet: number | undefined;
|
|
8
|
+
maxBet: number;
|
|
9
|
+
maxPayout: `${number}`;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
type GetBetCalculation = {
|
|
13
|
+
chainId: ChainId;
|
|
14
|
+
selections: Selection[];
|
|
15
|
+
account: Address | undefined;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Calculates the minimum and maximum bet amount for given selections.
|
|
19
|
+
* User's account is required to provide the **correct** maximum bet amount.
|
|
20
|
+
* It may be undefined if the user isn't logged in.
|
|
21
|
+
*
|
|
22
|
+
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/getBetCalculation
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* import { getBetCalculation } from '@azuro-org/toolkit'
|
|
26
|
+
*
|
|
27
|
+
* const account = userWallet?.address
|
|
28
|
+
* const selections = [
|
|
29
|
+
* { conditionId: '1', outcomeId: '1' },
|
|
30
|
+
* ]
|
|
31
|
+
*
|
|
32
|
+
* const { minBet, maxBet } = await getBetCalculation({ selections, account })
|
|
33
|
+
* */
|
|
34
|
+
export declare const getBetCalculation: (props: GetBetCalculation) => Promise<{
|
|
35
|
+
/** if `minBet` is `undefined`, there is no bottom limit */
|
|
36
|
+
minBet: number | undefined;
|
|
37
|
+
maxBet: number;
|
|
38
|
+
maxPayout: `${number}`;
|
|
39
|
+
} | null>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem';
|
|
2
|
+
import type { GameState } from '../docs';
|
|
3
|
+
import { type BetState, type CreateBetResponse } from '../global';
|
|
4
|
+
import { type ChainId } from '../config';
|
|
5
|
+
import { type Environment } from '../envs';
|
|
6
|
+
export type Bet = {
|
|
7
|
+
txHash: Hex | null;
|
|
8
|
+
odds: number;
|
|
9
|
+
clearOdds: number;
|
|
10
|
+
betId: number;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
redeemedAt: string | null;
|
|
14
|
+
core: Hex;
|
|
15
|
+
bettor: Address;
|
|
16
|
+
affiliate: Address;
|
|
17
|
+
stake: number;
|
|
18
|
+
maxStake: number;
|
|
19
|
+
environment: Environment;
|
|
20
|
+
} & CreateBetResponse;
|
|
21
|
+
export type GetOrderConditionSpecResponse = {
|
|
22
|
+
conditionId: string;
|
|
23
|
+
outcomeId: number;
|
|
24
|
+
orderId: string;
|
|
25
|
+
gameState: GameState;
|
|
26
|
+
conditionMargin: string;
|
|
27
|
+
selectionMargin: string;
|
|
28
|
+
settledSelectionMargin: string | null;
|
|
29
|
+
result: any;
|
|
30
|
+
};
|
|
31
|
+
export type GetOrderResponse = {
|
|
32
|
+
id: string;
|
|
33
|
+
environment: Environment;
|
|
34
|
+
state: string;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
core: string;
|
|
38
|
+
bettor: string;
|
|
39
|
+
owner: string;
|
|
40
|
+
affiliate: string;
|
|
41
|
+
amount: number;
|
|
42
|
+
payout: number;
|
|
43
|
+
odds: number;
|
|
44
|
+
bonusId: string | null;
|
|
45
|
+
isFreebet: boolean;
|
|
46
|
+
betId: number | null;
|
|
47
|
+
txHash: Hex | null;
|
|
48
|
+
margin: string;
|
|
49
|
+
settledMargin: string | null;
|
|
50
|
+
result: string | null;
|
|
51
|
+
settledAt: Date | null;
|
|
52
|
+
redeemedAt: Date | null;
|
|
53
|
+
error: string | null;
|
|
54
|
+
errorMessage: string | null;
|
|
55
|
+
conditions?: GetOrderConditionSpecResponse[];
|
|
56
|
+
} & CreateBetResponse;
|
|
57
|
+
export type GetBetsHistoryResponse = {
|
|
58
|
+
orders: Bet[];
|
|
59
|
+
};
|
|
60
|
+
export type GetBetsHistoryProps = {
|
|
61
|
+
chainId: ChainId;
|
|
62
|
+
bettor: Address;
|
|
63
|
+
filter?: {
|
|
64
|
+
result?: 'Won' | 'Lost' | 'Canceled';
|
|
65
|
+
state?: BetState | BetState[];
|
|
66
|
+
isRedeemed?: boolean;
|
|
67
|
+
};
|
|
68
|
+
offset?: number;
|
|
69
|
+
limit?: number;
|
|
70
|
+
};
|
|
71
|
+
export declare const getBetsHistory: ({ chainId, bettor, filter, offset, limit }: GetBetsHistoryProps) => Promise<Bet[] | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azuro-org/toolkit",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.0-beta.1",
|
|
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",
|