-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
252 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Callout } from 'components' | ||
|
||
Apart from the predominant sports markets, Azuro now allows to integrate political and social markets, starting with the "2024 Presidential Election USA" market. | ||
|
||
<Callout type="info"> | ||
If you use our [SDK](/hub/apps/sdk/overview), no additional changes are needed; just ensure you are using version 5.1.0 or above. | ||
</Callout> | ||
|
||
The steps to get custom (i.e. markets other than sport markets) are the same as for sports markets, but there is a slight difference in how the names of markets and selections are generated. | ||
|
||
### GraphQL | ||
For sports markets, you use the [@azuro-org/dictionaries](https://www.npmjs.com/package/@azuro-org/dictionaries) library to gain names for markets and selections, but for custom markets, you need to use the `title` field from the `Condition` and `Outcome` entities: | ||
|
||
```graphql {2, 5} | ||
fragment PrematchCondition on Condition { | ||
title # it's custom market's name | ||
# your condition fields | ||
outcomes { | ||
title # it's selection's name | ||
# your outcome fields | ||
} | ||
} | ||
``` | ||
|
||
Same for prematch bets: | ||
|
||
```graphql {4, 6} | ||
fragment PrematchBet on Bet { | ||
selections { | ||
outcome { | ||
title # it's selection's name | ||
condition { | ||
title # it's custom market's name | ||
} | ||
} | ||
} | ||
} | ||
|
||
``` | ||
|
||
- `title` field in `Condition` entity is custom market's name | ||
- `title` field in `Outcome` entity is selection's name in custom market | ||
|
||
<Callout type="info"> | ||
For sports markets this fields will be `null`. | ||
</Callout> | ||
|
||
### Title field usage | ||
Make sure you use the `title` field in your market generating function. | ||
|
||
```ts {10, 13} | ||
import { getMarketName, getSelectionName } from '@azuro-org/dictionaries' | ||
|
||
conditions.forEach((condition) => { | ||
const customMarketName = condition.title | ||
|
||
condition.outcomes.forEach((outcome) => { | ||
const customSelectionName = outcome.title | ||
|
||
// If customMarketName has a value, then use it as marketName; otherwise, use the getMarketName function. | ||
const marketName = customMarketName || getMarketName({ outcomeId: outcome.outcomeId }) | ||
|
||
// If customSelectionName has a value, then use it as selectionName; otherwise, use the getSelectionName function. | ||
const selectionName = customSelectionName || getSelectionName({ outcomeId: outcome.outcomeId, withPoint: true }) | ||
}) | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Sends live bet order. | ||
|
||
#### Usage | ||
|
||
```ts | ||
import { createLiveBet } from '@azuro-org/toolkit' | ||
|
||
|
||
const createdOrder = await createLiveBet({ | ||
account: account.address, | ||
chainId: appChain.id, | ||
bet: liveBet, | ||
signature, | ||
}) | ||
``` | ||
|
||
#### Props | ||
|
||
```ts | ||
{ | ||
chainId: ChainId // liveSupportedChains | ||
account: Address | ||
bet: LiveBet | ||
signature: Hex // signed typed data | ||
} | ||
``` | ||
|
||
```ts | ||
type LiveBet = { | ||
attention: string | ||
affiliate: Address | ||
core: Address | ||
amount: string | ||
chainId: ChainId | ||
conditionId: string | ||
outcomeId: number | ||
minOdds: string | ||
nonce: string | ||
expiresAt: number | ||
relayerFeeAmount: string | ||
} | ||
``` | ||
#### Return Value | ||
```ts | ||
type CreateLiveBetResponse = { | ||
id: string | ||
state: LiveBetState | ||
errorMessage?: string | ||
} | ||
|
||
enum LiveBetState { | ||
Created = 'Created', | ||
Pending = 'Pending', | ||
Sent = 'Sent', | ||
Accepted = 'Accepted', | ||
Rejected = 'Rejected' | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Returns live bet order. | ||
|
||
#### Usage | ||
|
||
```ts | ||
import { getLiveBet } from '@azuro-org/toolkit' | ||
|
||
|
||
const order = await getLiveBet({ | ||
chainId: appChain.id, | ||
orderId, | ||
}) | ||
``` | ||
|
||
#### Props | ||
|
||
```ts | ||
{ | ||
chainId: ChainId // liveSupportedChains | ||
orderId: string | ||
} | ||
``` | ||
|
||
#### Return Value | ||
|
||
```ts | ||
export type GetLiveBetResponse = { | ||
txHash: string | ||
odds: string | ||
betId: string | ||
} & CreateLiveBetResponse | ||
``` | ||
```ts | ||
type CreateLiveBetResponse = { | ||
id: string | ||
state: LiveBetState | ||
errorMessage?: string | ||
} | ||
|
||
enum LiveBetState { | ||
Created = 'Created', | ||
Pending = 'Pending', | ||
Sent = 'Sent', | ||
Accepted = 'Accepted', | ||
Rejected = 'Rejected' | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Returns a typed data for live bet sign. | ||
|
||
#### Usage | ||
|
||
```ts | ||
import { getLiveBetTypedData } from '@azuro-org/toolkit' | ||
|
||
|
||
const typedData = getLiveBetTypedData({ | ||
account: account.address, | ||
chainId: appChain.id, | ||
bet: liveBet, | ||
}) | ||
|
||
const signature = await walletClient.data.signTypedData(typedData) | ||
``` | ||
|
||
#### Props | ||
|
||
```ts | ||
{ | ||
chainId: ChainId // liveSupportedChains | ||
account: Address | ||
bet: LiveBet | ||
} | ||
``` | ||
|
||
```ts | ||
type LiveBet = { | ||
attention: string | ||
affiliate: Address | ||
core: Address | ||
amount: string | ||
chainId: ChainId | ||
conditionId: string | ||
outcomeId: number | ||
minOdds: string | ||
nonce: string | ||
expiresAt: number | ||
relayerFeeAmount: string | ||
} | ||
``` | ||
#### Return Value | ||
`SignTypedDataParameters` |