@azuro-org/toolkit 4.3.2 → 4.4.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/dist/config.d.ts +38 -0
- package/dist/global.d.ts +15 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +102 -3
- 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 +1 -1
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';
|
|
@@ -5296,8 +5313,9 @@ const calcPrematchOdds = async (props) => {
|
|
|
5296
5313
|
contracts,
|
|
5297
5314
|
});
|
|
5298
5315
|
odds = selections.reduce((acc, { conditionId, outcomeId }, index) => {
|
|
5316
|
+
const key = `${conditionId}-${outcomeId}`;
|
|
5299
5317
|
const result = response[index]?.result;
|
|
5300
|
-
acc[
|
|
5318
|
+
acc[key] = formatToFixed(formatUnits(typeof result === 'bigint' ? result : 0n, ODDS_DECIMALS), 5);
|
|
5301
5319
|
return acc;
|
|
5302
5320
|
}, {});
|
|
5303
5321
|
}
|
|
@@ -5321,7 +5339,7 @@ const calcPrematchOdds = async (props) => {
|
|
|
5321
5339
|
});
|
|
5322
5340
|
return selections.reduce((acc, { conditionId, outcomeId }, index) => {
|
|
5323
5341
|
const key = `${conditionId}-${outcomeId}`;
|
|
5324
|
-
acc[key] = formatToFixed(formatUnits(conditionOdds[index], ODDS_DECIMALS),
|
|
5342
|
+
acc[key] = formatToFixed(formatUnits(conditionOdds[index], ODDS_DECIMALS), 5);
|
|
5325
5343
|
return acc;
|
|
5326
5344
|
}, {});
|
|
5327
5345
|
}
|
|
@@ -5595,6 +5613,87 @@ const getFreeBets = async ({ chainId, account, affiliate }) => {
|
|
|
5595
5613
|
}
|
|
5596
5614
|
const data = await response.json();
|
|
5597
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;
|
|
5598
5697
|
};var WaveLevelName;
|
|
5599
5698
|
(function (WaveLevelName) {
|
|
5600
5699
|
WaveLevelName["Grey"] = "Grey";
|
|
@@ -5805,4 +5904,4 @@ const getDeBridgeOrder = async (orderId) => {
|
|
|
5805
5904
|
}
|
|
5806
5905
|
const data = await response.json();
|
|
5807
5906
|
return data;
|
|
5808
|
-
};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 {};
|