@azuro-org/toolkit 4.3.3 → 4.4.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/README.md +4 -4
- package/dist/config.d.ts +38 -0
- package/dist/global.d.ts +15 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +99 -1
- package/dist/utils/createLiveBet.d.ts +23 -0
- package/dist/utils/getLiveBet.d.ts +13 -0
- package/dist/utils/getLiveBetTypedData.d.ts +10 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -12,10 +12,10 @@ npm i --save @azuro-org/toolkit
|
|
|
12
12
|
#### Peer Dependencies
|
|
13
13
|
|
|
14
14
|
```
|
|
15
|
-
@apollo/client@^3.
|
|
16
|
-
@azuro-org/dictionaries@^3.0.
|
|
17
|
-
viem@^2.
|
|
18
|
-
@wagmi/core@^2.
|
|
15
|
+
@apollo/client@^3.11.10
|
|
16
|
+
@azuro-org/dictionaries@^3.0.20
|
|
17
|
+
viem@^2.21.44
|
|
18
|
+
@wagmi/core@^2.14.5
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Package information can be found in our [Doc](https://gem.azuro.org/hub/apps/toolkit/overview)
|
package/dist/config.d.ts
CHANGED
|
@@ -5,6 +5,44 @@ import { type Contracts } from './utils/setupContracts';
|
|
|
5
5
|
export declare const ODDS_DECIMALS = 12;
|
|
6
6
|
export declare const MARGIN_DECIMALS = 12;
|
|
7
7
|
export declare const MIN_LIVE_BET_AMOUNT = 1;
|
|
8
|
+
export declare const LIVE_BET_DATA_TYPES: {
|
|
9
|
+
readonly ClientBetData: readonly [{
|
|
10
|
+
readonly name: "attention";
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
}, {
|
|
13
|
+
readonly name: "affiliate";
|
|
14
|
+
readonly type: "address";
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "core";
|
|
17
|
+
readonly type: "address";
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "amount";
|
|
20
|
+
readonly type: "uint128";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "nonce";
|
|
23
|
+
readonly type: "uint256";
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: "conditionId";
|
|
26
|
+
readonly type: "uint256";
|
|
27
|
+
}, {
|
|
28
|
+
readonly name: "outcomeId";
|
|
29
|
+
readonly type: "uint64";
|
|
30
|
+
}, {
|
|
31
|
+
readonly name: "minOdds";
|
|
32
|
+
readonly type: "uint64";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "expiresAt";
|
|
35
|
+
readonly type: "uint256";
|
|
36
|
+
}, {
|
|
37
|
+
readonly name: "chainId";
|
|
38
|
+
readonly type: "uint256";
|
|
39
|
+
}, {
|
|
40
|
+
readonly name: "relayerFeeAmount";
|
|
41
|
+
readonly type: "uint256";
|
|
42
|
+
}];
|
|
43
|
+
};
|
|
44
|
+
export declare const LIVE_TYPED_DATA_DOMAIN_NAME = "Live Betting";
|
|
45
|
+
export declare const LIVE_TYPED_DATA_DOMAIN_VERSION = "1.0.0";
|
|
8
46
|
export declare const deBridgeUrl = "https://api.dln.trade/v1.0";
|
|
9
47
|
export declare const deBridgeTxUrl = "https://stats-api.dln.trade/api";
|
|
10
48
|
export declare const liveHostAddress = "0x67Fca88E2f5F2C33b86bFa4EccfCb8dCD6a56D17";
|
package/dist/global.d.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
import { type ChainId } from './config';
|
|
1
3
|
export type Selection = {
|
|
2
4
|
outcomeId: string;
|
|
3
5
|
conditionId: string;
|
|
4
6
|
coreAddress: string;
|
|
5
7
|
};
|
|
6
8
|
export type WaveId = number | 'active';
|
|
9
|
+
export type LiveBet = {
|
|
10
|
+
attention: string;
|
|
11
|
+
affiliate: Address;
|
|
12
|
+
core: Address;
|
|
13
|
+
amount: string;
|
|
14
|
+
chainId: ChainId;
|
|
15
|
+
conditionId: string;
|
|
16
|
+
outcomeId: number;
|
|
17
|
+
minOdds: string;
|
|
18
|
+
nonce: string;
|
|
19
|
+
expiresAt: number;
|
|
20
|
+
relayerFeeAmount: string;
|
|
21
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ export { groupByConditionId } from './utils/groupByConditionId';
|
|
|
14
14
|
export { setupContracts, type Contracts } from './utils/setupContracts';
|
|
15
15
|
export { getApiEndpoint, getLiveGraphqlEndpoint, getPrematchGraphqlEndpoint, getSocketEndpoint } from './utils/getEndpoints';
|
|
16
16
|
export { getFreeBets, FreeBetStatus, type FreeBet } from './utils/getFreebets';
|
|
17
|
+
export { getLiveBetTypedData } from './utils/getLiveBetTypedData';
|
|
18
|
+
export { createLiveBet, type CreateLiveBetResponse, LiveBetState } from './utils/createLiveBet';
|
|
19
|
+
export { getLiveBet, type GetLiveBetResponse } from './utils/getLiveBet';
|
|
17
20
|
export { getWaveLevels, WaveLevelName, type WaveLevelData, type WaveLevelsResponse } from './utils/wave/getWaveLevels';
|
|
18
21
|
export { getWaveStats, type WaveStatsResponse } from './utils/wave/getWaveStats';
|
|
19
22
|
export { getWavePeriods, type WavePeriodsResponse } from './utils/wave/getWavePeriods';
|
package/dist/index.js
CHANGED
|
@@ -3932,6 +3932,23 @@ const getApiEndpoint = (chainId) => {
|
|
|
3932
3932
|
};const ODDS_DECIMALS = 12;
|
|
3933
3933
|
const MARGIN_DECIMALS = 12;
|
|
3934
3934
|
const MIN_LIVE_BET_AMOUNT = 1;
|
|
3935
|
+
const LIVE_BET_DATA_TYPES = {
|
|
3936
|
+
ClientBetData: [
|
|
3937
|
+
{ name: 'attention', type: 'string' },
|
|
3938
|
+
{ name: 'affiliate', type: 'address' },
|
|
3939
|
+
{ name: 'core', type: 'address' },
|
|
3940
|
+
{ name: 'amount', type: 'uint128' },
|
|
3941
|
+
{ name: 'nonce', type: 'uint256' },
|
|
3942
|
+
{ name: 'conditionId', type: 'uint256' },
|
|
3943
|
+
{ name: 'outcomeId', type: 'uint64' },
|
|
3944
|
+
{ name: 'minOdds', type: 'uint64' },
|
|
3945
|
+
{ name: 'expiresAt', type: 'uint256' },
|
|
3946
|
+
{ name: 'chainId', type: 'uint256' },
|
|
3947
|
+
{ name: 'relayerFeeAmount', type: 'uint256' },
|
|
3948
|
+
],
|
|
3949
|
+
};
|
|
3950
|
+
const LIVE_TYPED_DATA_DOMAIN_NAME = 'Live Betting';
|
|
3951
|
+
const LIVE_TYPED_DATA_DOMAIN_VERSION = '1.0.0';
|
|
3935
3952
|
const deBridgeUrl = 'https://api.dln.trade/v1.0';
|
|
3936
3953
|
const deBridgeTxUrl = 'https://stats-api.dln.trade/api';
|
|
3937
3954
|
const liveHostAddress = '0x67Fca88E2f5F2C33b86bFa4EccfCb8dCD6a56D17';
|
|
@@ -5596,6 +5613,87 @@ const getFreeBets = async ({ chainId, account, affiliate }) => {
|
|
|
5596
5613
|
}
|
|
5597
5614
|
const data = await response.json();
|
|
5598
5615
|
return data;
|
|
5616
|
+
};const getLiveBetTypedData = ({ account, chainId, bet }) => {
|
|
5617
|
+
if (!liveSupportedChains.includes(chainId)) {
|
|
5618
|
+
throw new Error('provided chainId is not supported for live bet');
|
|
5619
|
+
}
|
|
5620
|
+
const { contracts } = chainsData[chainId];
|
|
5621
|
+
const EIP712Domain = {
|
|
5622
|
+
name: LIVE_TYPED_DATA_DOMAIN_NAME,
|
|
5623
|
+
version: LIVE_TYPED_DATA_DOMAIN_VERSION,
|
|
5624
|
+
chainId,
|
|
5625
|
+
verifyingContract: contracts.liveCore.address,
|
|
5626
|
+
};
|
|
5627
|
+
return {
|
|
5628
|
+
account: account,
|
|
5629
|
+
domain: EIP712Domain,
|
|
5630
|
+
primaryType: 'ClientBetData',
|
|
5631
|
+
types: LIVE_BET_DATA_TYPES,
|
|
5632
|
+
message: {
|
|
5633
|
+
attention: bet.attention,
|
|
5634
|
+
affiliate: bet.affiliate,
|
|
5635
|
+
core: bet.core,
|
|
5636
|
+
amount: BigInt(bet.amount),
|
|
5637
|
+
nonce: BigInt(bet.nonce),
|
|
5638
|
+
conditionId: BigInt(bet.conditionId),
|
|
5639
|
+
outcomeId: BigInt(bet.outcomeId),
|
|
5640
|
+
minOdds: BigInt(bet.minOdds),
|
|
5641
|
+
expiresAt: BigInt(bet.expiresAt),
|
|
5642
|
+
chainId: BigInt(bet.chainId),
|
|
5643
|
+
relayerFeeAmount: BigInt(bet.relayerFeeAmount),
|
|
5644
|
+
},
|
|
5645
|
+
};
|
|
5646
|
+
};var LiveBetState;
|
|
5647
|
+
(function (LiveBetState) {
|
|
5648
|
+
LiveBetState["Created"] = "Created";
|
|
5649
|
+
LiveBetState["Pending"] = "Pending";
|
|
5650
|
+
LiveBetState["Sent"] = "Sent";
|
|
5651
|
+
LiveBetState["Accepted"] = "Accepted";
|
|
5652
|
+
LiveBetState["Rejected"] = "Rejected";
|
|
5653
|
+
})(LiveBetState || (LiveBetState = {}));
|
|
5654
|
+
const createLiveBet = async (props) => {
|
|
5655
|
+
const { chainId, account, bet, signature } = props;
|
|
5656
|
+
if (!liveSupportedChains.includes(chainId)) {
|
|
5657
|
+
throw new Error('provided chainId is not supported for live bet');
|
|
5658
|
+
}
|
|
5659
|
+
const { api, environment } = chainsData[chainId];
|
|
5660
|
+
const order = { bet };
|
|
5661
|
+
const signedBet = {
|
|
5662
|
+
environment,
|
|
5663
|
+
bettor: account.toLowerCase(),
|
|
5664
|
+
data: order,
|
|
5665
|
+
bettorSignature: signature,
|
|
5666
|
+
};
|
|
5667
|
+
const response = await fetch(`${api}/orders`, {
|
|
5668
|
+
method: 'POST',
|
|
5669
|
+
headers: {
|
|
5670
|
+
'Accept': 'application/json',
|
|
5671
|
+
'Content-Type': 'application/json',
|
|
5672
|
+
},
|
|
5673
|
+
body: JSON.stringify(signedBet),
|
|
5674
|
+
});
|
|
5675
|
+
if (response.status === 404) {
|
|
5676
|
+
return null;
|
|
5677
|
+
}
|
|
5678
|
+
if (!response.ok) {
|
|
5679
|
+
throw new Error(`Status ${response.status}: ${response.statusText}`);
|
|
5680
|
+
}
|
|
5681
|
+
const data = await response.json();
|
|
5682
|
+
return data;
|
|
5683
|
+
};const getLiveBet = async ({ chainId, orderId }) => {
|
|
5684
|
+
if (!liveSupportedChains.includes(chainId)) {
|
|
5685
|
+
throw new Error('provided chainId is not supported for live bet');
|
|
5686
|
+
}
|
|
5687
|
+
const { api } = chainsData[chainId];
|
|
5688
|
+
const response = await fetch(`${api}/orders/${orderId}`);
|
|
5689
|
+
if (response.status === 404) {
|
|
5690
|
+
return null;
|
|
5691
|
+
}
|
|
5692
|
+
if (!response.ok) {
|
|
5693
|
+
throw new Error(`Status ${response.status}: ${response.statusText}`);
|
|
5694
|
+
}
|
|
5695
|
+
const data = await response.json();
|
|
5696
|
+
return data;
|
|
5599
5697
|
};var WaveLevelName;
|
|
5600
5698
|
(function (WaveLevelName) {
|
|
5601
5699
|
WaveLevelName["Grey"] = "Grey";
|
|
@@ -5806,4 +5904,4 @@ const getDeBridgeOrder = async (orderId) => {
|
|
|
5806
5904
|
}
|
|
5807
5905
|
const data = await response.json();
|
|
5808
5906
|
return data;
|
|
5809
|
-
};export{BetResult,BetStatus,Bet_OrderBy,BettorFragmentDoc,BettorsDocument,ConditionStatus$1 as ConditionStatus,DeBridgeExternalCallStatus,DeBridgeOrderStatus,Environment,FreeBetStatus,GameBetsDocument,GameDocument,GameStatus,Game_OrderBy$1 as Game_OrderBy,GamesDocument,BetStatus$1 as GraphBetStatus,LiveBetFragmentDoc,LiveBetsDocument,LiveConditionDocument,LiveConditionFragmentDoc,Condition_OrderBy as LiveConditionOrderBy,LiveConditionsDocument,GameStatus$1 as LiveGraphGameStatus,MARGIN_DECIMALS,MIN_LIVE_BET_AMOUNT,MainGameInfoFragmentDoc,NavigationDocument,ODDS_DECIMALS,OrderDirection$1 as OrderDirection,PrematchBetFragmentDoc,PrematchBetsDocument,PrematchConditionDocument,PrematchConditionFragmentDoc,Condition_OrderBy$1 as PrematchConditionOrderBy,PrematchConditionsBatchDocument,PrematchConditionsDocument,GameStatus$2 as PrematchGraphGameStatus,SelectionResult$1 as SelectionResult,SportsDocument,SportsNavigationDocument,WaveLevelName,activateWave,calcLiveOdds,calcMindOdds,calcPrematchOdds,chainsData,chainsDataByEnv,createDeBridgeBet,deBridgeChainIdByOriginalChainId,deBridgeTxUrl,deBridgeUrl,environments,FreeBet as freeBetAbi,getApiEndpoint,getBetStatus,getDeBridgeOrder,getDeBridgeSupportedChains,getDeBridgeSupportedTokens,getFreeBets,getGameStatus,getLiveBetFee,getLiveGraphqlEndpoint,getPrematchBetDataBytes,getPrematchGraphqlEndpoint,getSocketEndpoint,getWaveLeaderBoard,getWaveLevels,getWavePeriods,getWaveStats,groupByConditionId,groupConditionsByMarket,liveCoreAbi,liveHostAddress,liveSupportedChains,lpAbi,prematchComboCoreAbi,prematchCoreAbi,proxyFrontAbi,setupContracts};
|
|
5907
|
+
};export{BetResult,BetStatus,Bet_OrderBy,BettorFragmentDoc,BettorsDocument,ConditionStatus$1 as ConditionStatus,DeBridgeExternalCallStatus,DeBridgeOrderStatus,Environment,FreeBetStatus,GameBetsDocument,GameDocument,GameStatus,Game_OrderBy$1 as Game_OrderBy,GamesDocument,BetStatus$1 as GraphBetStatus,LiveBetFragmentDoc,LiveBetState,LiveBetsDocument,LiveConditionDocument,LiveConditionFragmentDoc,Condition_OrderBy as LiveConditionOrderBy,LiveConditionsDocument,GameStatus$1 as LiveGraphGameStatus,MARGIN_DECIMALS,MIN_LIVE_BET_AMOUNT,MainGameInfoFragmentDoc,NavigationDocument,ODDS_DECIMALS,OrderDirection$1 as OrderDirection,PrematchBetFragmentDoc,PrematchBetsDocument,PrematchConditionDocument,PrematchConditionFragmentDoc,Condition_OrderBy$1 as PrematchConditionOrderBy,PrematchConditionsBatchDocument,PrematchConditionsDocument,GameStatus$2 as PrematchGraphGameStatus,SelectionResult$1 as SelectionResult,SportsDocument,SportsNavigationDocument,WaveLevelName,activateWave,calcLiveOdds,calcMindOdds,calcPrematchOdds,chainsData,chainsDataByEnv,createDeBridgeBet,createLiveBet,deBridgeChainIdByOriginalChainId,deBridgeTxUrl,deBridgeUrl,environments,FreeBet as freeBetAbi,getApiEndpoint,getBetStatus,getDeBridgeOrder,getDeBridgeSupportedChains,getDeBridgeSupportedTokens,getFreeBets,getGameStatus,getLiveBet,getLiveBetFee,getLiveBetTypedData,getLiveGraphqlEndpoint,getPrematchBetDataBytes,getPrematchGraphqlEndpoint,getSocketEndpoint,getWaveLeaderBoard,getWaveLevels,getWavePeriods,getWaveStats,groupByConditionId,groupConditionsByMarket,liveCoreAbi,liveHostAddress,liveSupportedChains,lpAbi,prematchComboCoreAbi,prematchCoreAbi,proxyFrontAbi,setupContracts};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Address, type Hex } from 'viem';
|
|
2
|
+
import { type ChainId } from '../config';
|
|
3
|
+
import { type LiveBet } from '../global';
|
|
4
|
+
export declare enum LiveBetState {
|
|
5
|
+
Created = "Created",
|
|
6
|
+
Pending = "Pending",
|
|
7
|
+
Sent = "Sent",
|
|
8
|
+
Accepted = "Accepted",
|
|
9
|
+
Rejected = "Rejected"
|
|
10
|
+
}
|
|
11
|
+
export type CreateLiveBetResponse = {
|
|
12
|
+
id: string;
|
|
13
|
+
state: LiveBetState;
|
|
14
|
+
errorMessage?: string;
|
|
15
|
+
};
|
|
16
|
+
type Props = {
|
|
17
|
+
chainId: ChainId;
|
|
18
|
+
account: Address;
|
|
19
|
+
bet: LiveBet;
|
|
20
|
+
signature: Hex;
|
|
21
|
+
};
|
|
22
|
+
export declare const createLiveBet: (props: Props) => Promise<CreateLiveBetResponse | null>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ChainId } from '../config';
|
|
2
|
+
import { type CreateLiveBetResponse } from './createLiveBet';
|
|
3
|
+
export type GetLiveBetResponse = {
|
|
4
|
+
txHash: string;
|
|
5
|
+
odds: string;
|
|
6
|
+
betId: string;
|
|
7
|
+
} & CreateLiveBetResponse;
|
|
8
|
+
type Props = {
|
|
9
|
+
chainId: ChainId;
|
|
10
|
+
orderId: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const getLiveBet: ({ chainId, orderId }: Props) => Promise<GetLiveBetResponse | null>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type SignTypedDataParameters, type Address } from 'viem';
|
|
2
|
+
import { type ChainId } from '../config';
|
|
3
|
+
import { type LiveBet } from '../global';
|
|
4
|
+
type Props = {
|
|
5
|
+
chainId: ChainId;
|
|
6
|
+
account: Address;
|
|
7
|
+
bet: LiveBet;
|
|
8
|
+
};
|
|
9
|
+
export declare const getLiveBetTypedData: ({ account, chainId, bet }: Props) => SignTypedDataParameters;
|
|
10
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azuro-org/toolkit",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.1",
|
|
4
4
|
"description": "Set of helpers to work with Azuro protocol",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://github.com/Azuro-protocol/toolkit#readme",
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@apollo/client": "^3.10
|
|
43
|
-
"@azuro-org/dictionaries": "^3.0.
|
|
44
|
-
"viem": "^2.21.
|
|
45
|
-
"@wagmi/core": "^2.
|
|
42
|
+
"@apollo/client": "^3.11.10",
|
|
43
|
+
"@azuro-org/dictionaries": "^3.0.20",
|
|
44
|
+
"viem": "^2.21.44",
|
|
45
|
+
"@wagmi/core": "^2.14.5"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@graphql-codegen/cli": "^4.0.1",
|