Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
CleanBread committed Nov 8, 2024
2 parents ef9bf29 + 732b80f commit 5ae9078
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 10 deletions.
3 changes: 3 additions & 0 deletions pages/hub/apps/guides/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"type": "separator"
},
"custom-markets": {
"title": "Custom markets"
},
"political-markets": {
"title": "How to add political / social markets"
},
"social-login": {
Expand Down
30 changes: 21 additions & 9 deletions pages/hub/apps/guides/custom-markets.mdx
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
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.
Apart from the predominant sports markets, Azuro now allows to integrate custom markets.

<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.
If you use our [SDK](/hub/apps/sdk/overview), no additional changes are needed; just ensure you are using version `5.2.8` 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
New `unique` hub has been created it works same as others `sports` and `esports` hubs.

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
```graphql {5, 12, 14}
query games {
games(
where: {
sport_: {
sporthub: "unique"
}
}
) {
id
title
conditions {
title # it's custom market's name
outcomes {
title # it's selection's name
}
}
}
}
```
Expand Down
67 changes: 67 additions & 0 deletions pages/hub/apps/guides/political-markets.mdx
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 })
})
})
```
3 changes: 3 additions & 0 deletions pages/hub/apps/toolkit/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ import {
MARGIN_DECIMALS, // marginality decimals
ODDS_DECIMALS, // odds decimals
MIN_LIVE_BET_AMOUNT, // min amount for live bet
LIVE_BET_DATA_TYPES, // data types for sign typed data
LIVE_TYPED_DATA_DOMAIN_NAME, // typed data domain name
LIVE_TYPED_DATA_DOMAIN_VERSION, // typed data domain version

deBridgeUrl, // deBridge api endpoint for creating order
deBridgeTxUrl, // deBridge tx api endpoint for checking order status
Expand Down
5 changes: 4 additions & 1 deletion pages/hub/apps/toolkit/utils/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"getLiveBetFee": "getLiveBetFee",
"getPrematchBetDataBytes": "getPrematchBetDataBytes",
"groupConditionsByMarket": "groupConditionsByMarket",
"getFreeBets": "getFreeBets"
"getFreeBets": "getFreeBets",
"getLiveBetTypedData": "getLiveBetTypedData",
"createLiveBet": "createLiveBet",
"getLiveBet": "getLiveBet"
}
60 changes: 60 additions & 0 deletions pages/hub/apps/toolkit/utils/createLiveBet.mdx
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'
}
```
48 changes: 48 additions & 0 deletions pages/hub/apps/toolkit/utils/getLiveBet.mdx
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'
}
```
46 changes: 46 additions & 0 deletions pages/hub/apps/toolkit/utils/getLiveBetTypedData.mdx
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`

0 comments on commit 5ae9078

Please sign in to comment.