@azuro-org/toolkit 5.0.0-beta.10 → 5.0.0-beta.11
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 +44 -36
- package/dist/utils/cashout/createCashout.d.ts +1 -2
- package/dist/utils/cashout/getCalculatedCashout.d.ts +1 -2
- package/dist/utils/cashout/getCashoutTypedData.d.ts +1 -2
- package/dist/utils/cashout/getPrecalculatedCashouts.d.ts +5 -3
- package/dist/utils/getEndpoints.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4829,8 +4829,18 @@ const isDev = (chainId) => {
|
|
|
4829
4829
|
chainId === spicy.id ||
|
|
4830
4830
|
chainId === baseSepolia.id);
|
|
4831
4831
|
};
|
|
4832
|
-
const getFeedGraphqlEndpoint = (chainId) =>
|
|
4833
|
-
|
|
4832
|
+
const getFeedGraphqlEndpoint = (chainId) => {
|
|
4833
|
+
if (isDev(chainId)) {
|
|
4834
|
+
return (`https://thegraph.onchainfeed.org/subgraphs/name/azuro-protocol/azuro-data-feed-${endpointNameByChainId[chainId]}`);
|
|
4835
|
+
}
|
|
4836
|
+
return (`https://thegraph-1.onchainfeed.org/subgraphs/name/azuro-protocol/azuro-data-feed-${endpointNameByChainId[chainId]}`);
|
|
4837
|
+
};
|
|
4838
|
+
const getBetsGraphqlEndpoint = (chainId) => {
|
|
4839
|
+
if (isDev(chainId)) {
|
|
4840
|
+
return (`https://thegraph.azuro.org/subgraphs/name/azuro-protocol/azuro-api-${endpointNameByChainId[chainId]}-v3`);
|
|
4841
|
+
}
|
|
4842
|
+
return (`https://thegraph-0.onchainfeed.org/subgraphs/name/azuro-protocol/azuro-api-${endpointNameByChainId[chainId]}-v3`);
|
|
4843
|
+
};
|
|
4834
4844
|
/**
|
|
4835
4845
|
* @deprecated Only for v2 feed
|
|
4836
4846
|
*/
|
|
@@ -4859,7 +4869,7 @@ const getApiEndpoint = (chainId) => {
|
|
|
4859
4869
|
// if (chainId === polygonAmoy.id) {
|
|
4860
4870
|
// return 'https://preprod-api.azuro.org/api/v1/public'
|
|
4861
4871
|
// }
|
|
4862
|
-
return 'https://api.
|
|
4872
|
+
return 'https://api.onchainfeed.org/api/v1/public';
|
|
4863
4873
|
};const ODDS_DECIMALS = 12;
|
|
4864
4874
|
const MIN_BET_AMOUNT = 1;
|
|
4865
4875
|
const CLIENT_DATA_TYPES = [
|
|
@@ -4929,11 +4939,11 @@ const gnosisData = {
|
|
|
4929
4939
|
api: getApiEndpoint(gnosis.id),
|
|
4930
4940
|
environment: environments[gnosis.id],
|
|
4931
4941
|
contracts: setupContracts({
|
|
4932
|
-
lp: '
|
|
4933
|
-
core: '
|
|
4934
|
-
relayer: '
|
|
4935
|
-
azuroBet: '
|
|
4936
|
-
cashout: '
|
|
4942
|
+
lp: '0xeb7cDA87D00d677A6Dc73EB569723b0fA51D97E7',
|
|
4943
|
+
core: '0x0e00E6ffcb5E207B800eec9e02999D1Fd9e448f2',
|
|
4944
|
+
relayer: '0x40eb85018fA18dDd10a433C8c40ca8D6744d8B32',
|
|
4945
|
+
azuroBet: '0xd7cd9342A14962C2dCB14569CB6fcA2759999089',
|
|
4946
|
+
cashout: '0x25de227af58188e656524d1C32cCf7C078cdC891',
|
|
4937
4947
|
}),
|
|
4938
4948
|
betToken: {
|
|
4939
4949
|
address: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d',
|
|
@@ -4975,11 +4985,11 @@ const polygonData = {
|
|
|
4975
4985
|
api: getApiEndpoint(polygon.id),
|
|
4976
4986
|
environment: environments[polygon.id],
|
|
4977
4987
|
contracts: setupContracts({
|
|
4978
|
-
lp: '
|
|
4979
|
-
core: '
|
|
4980
|
-
relayer: '
|
|
4981
|
-
azuroBet: '
|
|
4982
|
-
cashout: '
|
|
4988
|
+
lp: '0x0FA7FB5407eA971694652E6E16C12A52625DE1b8',
|
|
4989
|
+
core: '0xF9548Be470A4e130c90ceA8b179FCD66D2972AC7',
|
|
4990
|
+
relayer: '0x8dA05c0021e6b35865FDC959c54dCeF3A4AbBa9d',
|
|
4991
|
+
azuroBet: '0x7A1c3FEf712753374C4DCe34254B96faF2B7265B',
|
|
4992
|
+
cashout: '0x4a2BB4211cCF9b9eA6eF01D0a61448154ED19095',
|
|
4983
4993
|
}),
|
|
4984
4994
|
betToken: {
|
|
4985
4995
|
address: '0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
|
|
@@ -5044,14 +5054,14 @@ const chilizData = {
|
|
|
5044
5054
|
api: getApiEndpoint(chiliz.id),
|
|
5045
5055
|
environment: environments[chiliz.id],
|
|
5046
5056
|
contracts: setupContracts({
|
|
5047
|
-
lp: '
|
|
5048
|
-
core: '
|
|
5049
|
-
relayer: '
|
|
5050
|
-
azuroBet: '
|
|
5051
|
-
cashout: '
|
|
5057
|
+
lp: '0xEf6b12580301b04CD2551182C88623524B6e47b8',
|
|
5058
|
+
core: '0xa5061617Ee6565CF48d7f0FEF06910b9fb9dE2b0',
|
|
5059
|
+
relayer: '0x81F72B93ABaf061535aaF5D831F05e0CC4084b32',
|
|
5060
|
+
azuroBet: '0x3777B4F27F4B36f14454dbB1f79278bcba694B52',
|
|
5061
|
+
cashout: '0x3995eebB51793Ee353162E7400DB455B17dE3692',
|
|
5052
5062
|
}),
|
|
5053
5063
|
betToken: {
|
|
5054
|
-
address: '
|
|
5064
|
+
address: '0x677F7e16C7Dd57be1D4C8aD1244883214953DC47',
|
|
5055
5065
|
symbol: 'WCHZ',
|
|
5056
5066
|
decimals: 18,
|
|
5057
5067
|
},
|
|
@@ -5113,11 +5123,11 @@ const baseData = {
|
|
|
5113
5123
|
api: getApiEndpoint(base.id),
|
|
5114
5124
|
environment: environments[base.id],
|
|
5115
5125
|
contracts: setupContracts({
|
|
5116
|
-
lp: '
|
|
5117
|
-
core: '
|
|
5118
|
-
relayer: '
|
|
5119
|
-
azuroBet: '
|
|
5120
|
-
cashout: '
|
|
5126
|
+
lp: '0x1eD7368bc515E928A4007cEa61FB8a6F8863Af87',
|
|
5127
|
+
core: '0xF40cF1dD7d16C098cff5F8B5650A8FaEf1F4640d',
|
|
5128
|
+
relayer: '0xD2D508d66dB4fCE4B384e4C3EA2fa53BA43e73b5',
|
|
5129
|
+
azuroBet: '0xF328404Dbc8c997d12dC55a1A179AF7F8cb7df90',
|
|
5130
|
+
cashout: '0x6EDff24761F4473611B45BDAe4a779ff31af14Be',
|
|
5121
5131
|
}),
|
|
5122
5132
|
betToken: {
|
|
5123
5133
|
address: '0x4200000000000000000000000000000000000006',
|
|
@@ -7131,7 +7141,7 @@ const getWaveLevels = async ({ waveId, chainId } = { waveId: 'active', chainId:
|
|
|
7131
7141
|
if (!contracts.cashout?.address) {
|
|
7132
7142
|
throw new Error('provided chainId is not supported for cashout');
|
|
7133
7143
|
}
|
|
7134
|
-
const response = await fetch(`${api}/cashout/get-
|
|
7144
|
+
const response = await fetch(`${api}/cashout/get-available`, {
|
|
7135
7145
|
method: 'POST',
|
|
7136
7146
|
headers: {
|
|
7137
7147
|
'Accept': 'application/json',
|
|
@@ -7147,10 +7157,10 @@ const getWaveLevels = async ({ waveId, chainId } = { waveId: 'active', chainId:
|
|
|
7147
7157
|
if (!response.ok) {
|
|
7148
7158
|
throw new Error(`Status ${response.status}: ${response.statusText}`);
|
|
7149
7159
|
}
|
|
7150
|
-
const
|
|
7151
|
-
return
|
|
7160
|
+
const data = await response.json();
|
|
7161
|
+
return data;
|
|
7152
7162
|
};const getCalculatedCashout = async (props) => {
|
|
7153
|
-
const { chainId, account, graphBetId
|
|
7163
|
+
const { chainId, account, graphBetId } = props;
|
|
7154
7164
|
const { api, environment, contracts } = chainsData[chainId];
|
|
7155
7165
|
if (!contracts.cashout?.address) {
|
|
7156
7166
|
throw new Error('provided chainId is not supported for cashout');
|
|
@@ -7165,7 +7175,6 @@ const getWaveLevels = async ({ waveId, chainId } = { waveId: 'active', chainId:
|
|
|
7165
7175
|
environment,
|
|
7166
7176
|
owner: account,
|
|
7167
7177
|
betId: graphBetId,
|
|
7168
|
-
isLive,
|
|
7169
7178
|
}),
|
|
7170
7179
|
});
|
|
7171
7180
|
if (response.status === 404) {
|
|
@@ -7174,15 +7183,14 @@ const getWaveLevels = async ({ waveId, chainId } = { waveId: 'active', chainId:
|
|
|
7174
7183
|
if (!response.ok) {
|
|
7175
7184
|
throw new Error(`Status ${response.status}: ${response.statusText}`);
|
|
7176
7185
|
}
|
|
7177
|
-
const {
|
|
7186
|
+
const { owner, betId, ...rest } = await response.json();
|
|
7178
7187
|
return {
|
|
7179
|
-
multiplier: cashoutOdds,
|
|
7180
7188
|
account: owner,
|
|
7181
7189
|
tokenId: betId,
|
|
7182
7190
|
...rest,
|
|
7183
7191
|
};
|
|
7184
7192
|
};const getCashoutTypedData = (props) => {
|
|
7185
|
-
const { account, chainId, attention, tokenId,
|
|
7193
|
+
const { account, chainId, attention, tokenId, cashoutOdds, expiredAt } = props;
|
|
7186
7194
|
const { contracts } = chainsData[chainId];
|
|
7187
7195
|
if (!contracts.cashout?.address) {
|
|
7188
7196
|
throw new Error('provided chainId is not supported for cashout');
|
|
@@ -7204,8 +7212,8 @@ const getWaveLevels = async ({ waveId, chainId } = { waveId: 'active', chainId:
|
|
|
7204
7212
|
items: [
|
|
7205
7213
|
{
|
|
7206
7214
|
betId: BigInt(tokenId),
|
|
7207
|
-
bettingContract:
|
|
7208
|
-
minOdds: typeof
|
|
7215
|
+
bettingContract: contracts.core.address,
|
|
7216
|
+
minOdds: typeof cashoutOdds === 'string' ? (parseUnits(cashoutOdds, ODDS_DECIMALS)) : cashoutOdds,
|
|
7209
7217
|
},
|
|
7210
7218
|
],
|
|
7211
7219
|
expiresAt: BigInt(expiredAt),
|
|
@@ -7219,7 +7227,7 @@ const getWaveLevels = async ({ waveId, chainId } = { waveId: 'active', chainId:
|
|
|
7219
7227
|
CashoutState["Open"] = "OPEN";
|
|
7220
7228
|
})(CashoutState || (CashoutState = {}));
|
|
7221
7229
|
const createCashout = async (props) => {
|
|
7222
|
-
const { chainId, calculationId,
|
|
7230
|
+
const { chainId, calculationId, attention, signature } = props;
|
|
7223
7231
|
const { api, contracts } = chainsData[chainId];
|
|
7224
7232
|
if (!contracts.cashout?.address) {
|
|
7225
7233
|
throw new Error('provided chainId is not supported for cashout');
|
|
@@ -7228,7 +7236,7 @@ const createCashout = async (props) => {
|
|
|
7228
7236
|
calculationId,
|
|
7229
7237
|
signature: {
|
|
7230
7238
|
verifyingContract: contracts.cashout.address,
|
|
7231
|
-
bettingContract:
|
|
7239
|
+
bettingContract: contracts.core.address,
|
|
7232
7240
|
attention,
|
|
7233
7241
|
chainId,
|
|
7234
7242
|
ownerSignature: signature,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Hex
|
|
1
|
+
import { type Hex } from 'viem';
|
|
2
2
|
import { type ChainId } from '../../config';
|
|
3
3
|
export declare enum CashoutState {
|
|
4
4
|
Processing = "PROCESSING",
|
|
@@ -14,7 +14,6 @@ export type CreateCashoutResponse = {
|
|
|
14
14
|
type Props = {
|
|
15
15
|
chainId: ChainId;
|
|
16
16
|
calculationId: string;
|
|
17
|
-
betCoreAddress: Address | string;
|
|
18
17
|
attention: string;
|
|
19
18
|
signature: Hex;
|
|
20
19
|
};
|
|
@@ -7,7 +7,7 @@ export type GetCalculatedCashout = {
|
|
|
7
7
|
environment: Environment;
|
|
8
8
|
tokenId: string;
|
|
9
9
|
cashoutAmount: string;
|
|
10
|
-
|
|
10
|
+
cashoutOdds: string;
|
|
11
11
|
expiredAt: number;
|
|
12
12
|
approveExpiredAt: number;
|
|
13
13
|
isLive: boolean;
|
|
@@ -16,7 +16,6 @@ type Props = {
|
|
|
16
16
|
chainId: ChainId;
|
|
17
17
|
account: Address;
|
|
18
18
|
graphBetId: string;
|
|
19
|
-
isLive: boolean;
|
|
20
19
|
};
|
|
21
20
|
export declare const getCalculatedCashout: (props: Props) => Promise<GetCalculatedCashout>;
|
|
22
21
|
export {};
|
|
@@ -5,8 +5,7 @@ type Props = {
|
|
|
5
5
|
account: Address;
|
|
6
6
|
attention: string;
|
|
7
7
|
tokenId: string | bigint;
|
|
8
|
-
|
|
9
|
-
multiplier: string | bigint;
|
|
8
|
+
cashoutOdds: string | bigint;
|
|
10
9
|
expiredAt: number;
|
|
11
10
|
};
|
|
12
11
|
export declare const getCashoutTypedData: (props: Props) => SignTypedDataParameters<typeof CASHOUT_DATA_TYPES>;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { type ChainId } from '../../config';
|
|
2
2
|
type GetPrecalculatedCashoutsResponse = {
|
|
3
|
-
|
|
3
|
+
margin: string;
|
|
4
|
+
marginMin: string;
|
|
5
|
+
availables: {
|
|
4
6
|
conditionId: string;
|
|
5
7
|
available: boolean;
|
|
6
8
|
outcomes: {
|
|
7
9
|
outcomeId: number;
|
|
8
|
-
|
|
10
|
+
price: string;
|
|
9
11
|
}[];
|
|
10
12
|
}[];
|
|
11
13
|
};
|
|
12
|
-
export type GetPrecalculatedCashouts = GetPrecalculatedCashoutsResponse
|
|
14
|
+
export type GetPrecalculatedCashouts = GetPrecalculatedCashoutsResponse | null;
|
|
13
15
|
type Props = {
|
|
14
16
|
chainId: ChainId;
|
|
15
17
|
conditionIds: string[];
|
|
@@ -6,4 +6,4 @@ export declare const getBetsGraphqlEndpoint: (chainId: ChainId) => string;
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const getLegacyLiveGraphqlEndpoint: (chainId: ChainId) => "https://thegraph.azuro.org/subgraphs/name/azuro-protocol/azuro-api-live-data-feed-dev" | "https://thegraph.azuro.org/subgraphs/name/azuro-protocol/azuro-api-live-data-feed";
|
|
8
8
|
export declare const getSocketEndpoint: (chainId: ChainId) => "wss://dev-streams.onchainfeed.org/v1/streams" | "wss://streams.onchainfeed.org/v1/streams";
|
|
9
|
-
export declare const getApiEndpoint: (chainId: ChainId) => "https://dev-api.onchainfeed.org/api/v1/public" | "https://api.
|
|
9
|
+
export declare const getApiEndpoint: (chainId: ChainId) => "https://dev-api.onchainfeed.org/api/v1/public" | "https://api.onchainfeed.org/api/v1/public";
|