@azuro-org/toolkit 5.2.0-beta.0 → 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.js
CHANGED
|
@@ -5844,37 +5844,37 @@ const isDevChain = (chainId) => {
|
|
|
5844
5844
|
chainId === baseSepolia.id ||
|
|
5845
5845
|
chainId === bscTestnet.id);
|
|
5846
5846
|
};
|
|
5847
|
-
const getFeedGraphqlEndpoint = (chainId) => (`https://thegraph-1.
|
|
5848
|
-
const getBetsGraphqlEndpoint = (chainId) => (`https://thegraph.
|
|
5847
|
+
const getFeedGraphqlEndpoint = (chainId) => (`https://thegraph-1.chainfeedon.com/subgraphs/name/azuro-protocol/azuro-data-feed-${endpointNameByChainId[chainId]}`);
|
|
5848
|
+
const getBetsGraphqlEndpoint = (chainId) => (`https://thegraph.chainfeedon.com/subgraphs/name/azuro-protocol/azuro-api-${endpointNameByChainId[chainId]}-v3`);
|
|
5849
5849
|
/**
|
|
5850
5850
|
* @deprecated Only for v2 feed
|
|
5851
5851
|
*/
|
|
5852
5852
|
const getLegacyLiveGraphqlEndpoint = (chainId) => {
|
|
5853
5853
|
if (isDevChain(chainId)) {
|
|
5854
|
-
return 'https://thegraph.
|
|
5854
|
+
return 'https://thegraph.chainfeedon.com/subgraphs/name/azuro-protocol/azuro-api-live-data-feed-dev';
|
|
5855
5855
|
}
|
|
5856
5856
|
// if (chainId === polygonAmoy.id) {
|
|
5857
|
-
// return 'https://thegraph.
|
|
5857
|
+
// return 'https://thegraph.chainfeedon.com/subgraphs/name/azuro-protocol/azuro-api-live-data-feed-preprod'
|
|
5858
5858
|
// }
|
|
5859
|
-
return 'https://thegraph.
|
|
5859
|
+
return 'https://thegraph.chainfeedon.com/subgraphs/name/azuro-protocol/azuro-api-live-data-feed';
|
|
5860
5860
|
};
|
|
5861
5861
|
const getSocketEndpoint = (chainId) => {
|
|
5862
5862
|
if (isDevChain(chainId)) {
|
|
5863
|
-
return 'wss://dev-streams.
|
|
5863
|
+
return 'wss://dev-streams.chainfeedon.com/v1/streams';
|
|
5864
5864
|
}
|
|
5865
5865
|
// if (chainId === polygonAmoy.id) {
|
|
5866
5866
|
// return 'wss://preprod-streams.azuro.org/v1/streams'
|
|
5867
5867
|
// }
|
|
5868
|
-
return 'wss://streams.
|
|
5868
|
+
return 'wss://streams.chainfeedon.com/v1/streams';
|
|
5869
5869
|
};
|
|
5870
5870
|
const getApiEndpoint = (chainId) => {
|
|
5871
5871
|
if (isDevChain(chainId)) {
|
|
5872
|
-
return 'https://dev-api.
|
|
5872
|
+
return 'https://dev-api.chainfeedon.com/api/v1/public';
|
|
5873
5873
|
}
|
|
5874
5874
|
// if (chainId === polygonAmoy.id) {
|
|
5875
5875
|
// return 'https://preprod-api.azuro.org/api/v1/public'
|
|
5876
5876
|
// }
|
|
5877
|
-
return 'https://api.
|
|
5877
|
+
return 'https://api.chainfeedon.com/api/v1/public';
|
|
5878
5878
|
};const ODDS_DECIMALS = 12;
|
|
5879
5879
|
const ODDS_COMBO_FEE_MODIFIER = 0.99;
|
|
5880
5880
|
const CLIENT_DATA_TYPES = [
|
|
@@ -8169,7 +8169,24 @@ const getMaxBet = async (props) => {
|
|
|
8169
8169
|
}
|
|
8170
8170
|
const data = await response.json();
|
|
8171
8171
|
return data.response;
|
|
8172
|
-
}
|
|
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) => {
|
|
8173
8190
|
const { chainId, selections, account } = props;
|
|
8174
8191
|
const { api, environment } = chainsData[chainId];
|
|
8175
8192
|
const params = {
|
|
@@ -8194,7 +8211,7 @@ const getMaxBet = async (props) => {
|
|
|
8194
8211
|
return null;
|
|
8195
8212
|
}
|
|
8196
8213
|
if (!response.ok) {
|
|
8197
|
-
throw new Error(`Status ${response.status}: ${response.statusText}`);
|
|
8214
|
+
throw new Error(`API /bet/calculation failed: Status ${response.status}: ${response.statusText}`);
|
|
8198
8215
|
}
|
|
8199
8216
|
const data = await response.json();
|
|
8200
8217
|
return data.response;
|
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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
+
/**
|
|
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
|
+
* */
|
|
17
34
|
export declare const getBetCalculation: (props: GetBetCalculation) => Promise<{
|
|
18
35
|
/** if `minBet` is `undefined`, there is no bottom limit */
|
|
19
36
|
minBet: number | undefined;
|
|
@@ -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>;
|
|
@@ -4,6 +4,6 @@ export declare const getBetsGraphqlEndpoint: (chainId: ChainId) => string;
|
|
|
4
4
|
/**
|
|
5
5
|
* @deprecated Only for v2 feed
|
|
6
6
|
*/
|
|
7
|
-
export declare const getLegacyLiveGraphqlEndpoint: (chainId: ChainId) => "https://thegraph.
|
|
8
|
-
export declare const getSocketEndpoint: (chainId: ChainId) => "wss://dev-streams.
|
|
9
|
-
export declare const getApiEndpoint: (chainId: ChainId) => "https://dev-api.
|
|
7
|
+
export declare const getLegacyLiveGraphqlEndpoint: (chainId: ChainId) => "https://thegraph.chainfeedon.com/subgraphs/name/azuro-protocol/azuro-api-live-data-feed-dev" | "https://thegraph.chainfeedon.com/subgraphs/name/azuro-protocol/azuro-api-live-data-feed";
|
|
8
|
+
export declare const getSocketEndpoint: (chainId: ChainId) => "wss://dev-streams.chainfeedon.com/v1/streams" | "wss://streams.chainfeedon.com/v1/streams";
|
|
9
|
+
export declare const getApiEndpoint: (chainId: ChainId) => "https://dev-api.chainfeedon.com/api/v1/public" | "https://api.chainfeedon.com/api/v1/public";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azuro-org/toolkit",
|
|
3
|
-
"version": "5.2.0-beta.
|
|
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",
|