Skip to content

Commit

Permalink
Merge pull request #65 from Azuro-protocol/dev
Browse files Browse the repository at this point in the history
Merge dev branch
  • Loading branch information
alvik48 authored Nov 20, 2023
2 parents 5f603da + 6e1a5fb commit 056d1b1
Show file tree
Hide file tree
Showing 28 changed files with 243 additions and 28 deletions.
18 changes: 18 additions & 0 deletions components/ContractsAddresses/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ type ContractName =
| 'betToken'
| 'access'
| 'azuroBet'
| 'hostCore'
| 'clientCore'
| 'relayer'

const config: Record<ContractName, { title: string, link?: string }> = {
factory: {
Expand Down Expand Up @@ -45,6 +48,18 @@ const config: Record<ContractName, { title: string, link?: string }> = {
title: 'AzuroBet',
link: '/contracts/azuro-bet',
},
hostCore: {
title: 'HostCore',
link: '/contracts/live-host-core',
},
clientCore: {
title: 'ClientCore',
link: '/contracts/live-client-core',
},
relayer: {
title: 'Relayer',
link: '/contracts/live-relayer',
},
}

const rows: ContractName[] = [
Expand All @@ -56,6 +71,9 @@ const rows: ContractName[] = [
'betToken',
'access',
'azuroBet',
'hostCore',
'clientCore',
'relayer'
]

type ContractsTableProps = {
Expand Down
4 changes: 4 additions & 0 deletions pages/concepts/glossary.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ A sports betting market is a specific category of bet on a certain fixture or ev

The ratio of winnings to the stake and bettor also get his wager returned. So wagering 1 at 1:5 pays out 6 (5 + 1).

### Order

The request to place a bet, signed by user's wallet .

### Outcome (Selection)

The simplest type of bet in a betting app’s office, the winning of which is determined by the result of a sporting
Expand Down
8 changes: 7 additions & 1 deletion pages/contracts/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@
},
"free-bet": "FreeBet",
"safe-oracle": "SafeOracle",
"access": "Access"
"access": "Access",
"---4": {
"type": "separator"
},
"live-host-core": "Live: HostCore",
"live-client-core": "Live: ClientCore",
"live-relayer": "Live: Relayer"
}
7 changes: 5 additions & 2 deletions pages/contracts/deployment-addresses.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Tab, Tabs } from 'nextra-theme-docs'
import { ContractsAddresses } from 'components'


# Deployment Addresses

### Beacons
Expand Down Expand Up @@ -123,6 +121,9 @@ import { ContractsAddresses } from 'components'
proxyFront: '0x135a1256a8b48643DD0823fE189ADD1c2a012DBa',
betToken: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d',
azuroBet: '0xE818aA9A648189aC509D2730fe6824a9D13a8ec7',
hostCore: '0x2276b77B2C6ea24e1677F40A821D07907f5Dbba0',
clientCore: '0xFc4910f0E7523063f3640e249Fc0f25542b76899',
relayer: '0x3B0213eB35735A8E2b19F13C5Ec0a65a8226D5B2',
},
},
{
Expand All @@ -134,6 +135,8 @@ import { ContractsAddresses } from 'components'
proxyFront: '0xa43328ABd99ae605A87661E7fC84a0e509DE6BD0',
betToken: '0xe656De3EC9eFf1B851e0b39AFFaa1478353885a4',
azuroBet: '0x3C37477122187B511E04F4Bc0F00872F7f5EC2Db',
clientCore: '0xC1e90cB3232157874394d9a9EE878c2be5233B2e',
relayer: '0x1e15376522EfcbfD5032A6497a111495CE49c2FA',
},
},
{
Expand Down
7 changes: 7 additions & 0 deletions pages/contracts/live-client-core.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Callout } from 'components'

# ClientCore (Live betting)

<Callout type="warning">
The page is under construction
</Callout>
7 changes: 7 additions & 0 deletions pages/contracts/live-host-core.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Callout } from 'components'

# HostCore (Live betting)

<Callout type="warning">
The page is under construction
</Callout>
7 changes: 7 additions & 0 deletions pages/contracts/live-relayer.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Callout } from 'components'

# Relayer (Live betting)

<Callout type="warning">
The page is under construction
</Callout>
2 changes: 1 addition & 1 deletion pages/contracts/proxy-front.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

ProxyFront is a proxy contract designed to facilitate interaction with a Liquidity Pool contract. The contract provides functions for making bets and withdrawing payouts in batches.

Right now it provides 2 methods for [batch redeem](/guides/redeem-bets#batch-redeem) and [batch betting](guides/place-a-bet#place-a-batch-of-single-bets).
Right now it provides 2 methods for [batch redeem](/guides/prematch/redeem-bets#batch-redeem) and [batch betting](guides/place-a-bet#place-a-batch-of-single-bets).

### Reference

Expand Down
17 changes: 6 additions & 11 deletions pages/guides/_meta.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
{
"get-games": "Get Games",
"markets-and-outcomes": "Prepare Game Markets",
"get-odds-values": "Get Odds Values",
"real-time-odds-updates": "Real-time Odds Updates",
"place-a-bet": "Place a Bet",
"get-bets-history": "Get Bets History",
"redeem-bets": "Redeem Bets",
"handle-contract-errors": "Handle Contract Errors",
"affiliate-ggr": "Get bets made on specific Front(Affiliate)",
"azuro-score": "Azuro Score leaderboard",
"prematch": "Prematch",
"live": "Live betting",
"freebets": "Freebets",
"---": {
"type": "separator"
},
"freebets": "Freebets"
"handle-contract-errors": "Handle Contract Errors",
"affiliate-ggr": "Get bets made on specific Front(Affiliate)",
"azuro-score": "Azuro Score leaderboard"
}
4 changes: 2 additions & 2 deletions pages/guides/freebets/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Let's consider the life cycle of a free bet, omitting technical details:
_How-to in [Distribution guide](/guides/freebets/distribute-freebets) section._
2. The user accesses your application's UI, sees a notification that a freebet is available to them until a certain date.
_How-to in [Use freebets](/guides/freebets/use-freebets) section._
3. The user places a bet using the provided freebet*. _(How-to in [Place a bet](/guides/place-a-bet#place-a-freebet) section)_
3. The user places a bet using the provided freebet*. _(How-to in [Place a bet](/guides/prematch/place-a-bet#place-a-freebet) section)_
4. After the event is resolved:
* If the bet wins, when the user claims their winnings (_how-to in [Redeem bets](/guides/redeem-bets#freebet-redeem) section_), they receive a profit from the win (payout - freebet amount),
* If the bet wins, when the user claims their winnings (_how-to in [Redeem bets](/guides/prematch/redeem-bets#freebet-redeem) section_), they receive a profit from the win (payout - freebet amount),
and the amount of the issued freebet is returned to the freebet contract balance.
* If the bet loses, the freebet amount contributes to the revenue of the LP with your affiliate address.

Expand Down
5 changes: 2 additions & 3 deletions pages/guides/freebets/use-freebets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Api returns all available to claim freebets for specified bettor (status: `New`

### Use freebet to place a bet

If you're not familiar with generic logic around placing a bet, please read [Guides section](/guides/place-a-bet) first.
If you're not familiar with generic logic around placing a bet, please read [Guides section](/guides/prematch/place-a-bet) first.

<Callout type="warning">
To apply freebet, `outcome.rawMinOdds` should be greater than `freebet.minOdds`. The bet should be single - freebets aren't applicable to combo bets.
Expand Down Expand Up @@ -174,5 +174,4 @@ const tx = await freebetContract.connect(signer).withdrawPayout(bet.freebet.free
```

All details about bet history and base logic of redeem, please read in Guides section:
[Bet history](/guides/get-bets-history) & [Redeem Bets](/guides/redeem-bets)

[Bet history](/guides/prematch/get-bets-history) & [Redeem Bets](/guides/prematch/redeem-bets)
5 changes: 5 additions & 0 deletions pages/guides/live/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"overview": "Overview",
"data-retrieval": "Data retrieval",
"place-a-bet": "Place a bet"
}
86 changes: 86 additions & 0 deletions pages/guides/live/data-retrieval.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { Callout } from 'components';

# Live data retrieval

All the live games and markets data is stored in the [`HostCore`](/contracts/live-host-core) smart contract in the `HostChain` (currently is a Gnosis chain)
and can be retrieved via a [`LiveDataFeed`](/subgraph/overview#live-endpoints) subgraph.

Data structure is almost the same as the one in the main Subgraph for prematch core contracts.

<Callout type="info">
Key differences in the entities structure comparing to prematch subgraphs:

- Removed all entities and events related to bets (bets, freebets, expresses) and contracts (cores, liquidity pools).
- Removed `selection` entity and its relations.
- Entity `condition` doesn't have an `isExpressForbidden` field.
- Event `GameShifted` changed to `GameUpdated` (triggers by changing game status and/or start time).
- Event `ConditionShifted` completely removed.
</Callout>

Typical data feed lifecycle:

1. `Game` appears in the `LiveDataFeed` subgraph in the `Created` state. It means that the game is in live state.
2. `Conditions` start to appear in this game (usually they start to appear almost when the game starts and finish appearing in 5-10 minutes).
3. During the game each `Condition` can change its state between `Paused` and `Created`. Also condition's odds can be changed.
4. `Game` finishes and its status changes to `Finished`.
5. After some period `Conditions` start to finalize their status to `Resolved`/`Canceled`.
6. After all `Conditions` are resolved, the game change its status to `Resolved`.

## How to display live games and markets

Here we'll describe the logic of displaying live games and their markets.
Supposed that you already have a frontend with setup prematch games.

### Load live games

When game goes live, it saves its id (so the same game in prematch and live subgraphs have the same `gameId` value),
but it's stored in another smart contract, and you should load its info from another subgraph called [`LiveDataFeed`](/subgraph/overview#live-endpoints).

We recommend you to call a snapshot of live games almost the same way you did it for prematch games (see [Get Games](/guides/prematch/get-games) section), but you need to filter them by `Created` status:

```ts
useQuery(QUERY, {
variables: {
where: {
status: 'Created',
hasActiveConditions: true, // Avoid this parameter if you want to get the game with no available markets
},
},
})
```

<Callout type="warning">
While most of the games that we provide in prematch will go live, we don't guarantee it for each particular game.
Consider this when planning your UX.
</Callout>

<Callout type="feature">
If you want to effectively update your games list without querying big snapshots each time, you need to listen to the following events in the `LiveDataFeed` subgraph: `NewGame`, `GameUpdated`, `GameCanceled`.
For each new event you can get its `gameId` field and retrieve an actual game's info.
</Callout>

### Load markets

For each live game you can request its markets (called `conditions`) the same way you do this for prematch games (see [Prepare game markets](/guides/prematch/markets-and-outcomes) section).

<Callout type="warning">
Take into consideration that markets appear after the game created in the `HostCore` smart contract.
It means that this is a normal situation if a game doesn't have any live markets for a while.
You should continue to request game markets all the time and be ready to add a new ones until the game is finished.
</Callout>

### Get realtime markets updates

As for prematch games, live game's markets are constantly updated:

- Market can be stopped and unstopped.
- Outcomes odds can be changed.

For market stop/unstop action you need to listen to new `ConditionStopped` events in `LiveDataFeed` subgraph and then request the actual condition's state.

For odds changes you need to listen to our `HostCore` smart contract event `OddsChanged` (the same way as described in [Real-time Odds Updates](/guides/prematch/real-time-odds-updates) section for prematch, just use the `HostCore` contract).

### Finish a game

When game finishes, its status changes on `Finished` until it has unsettled markets.
When all markets are settled, its status changes on `Resolved`.
13 changes: 13 additions & 0 deletions pages/guides/live/overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Live betting overview

Live betting, also known as in-play betting, allows users to place bets on sport events as they are happening.
Unlike traditional betting, which is done before an event starts, live betting offers dynamic odds that change as the game progresses.

In Azuro we are providing a live betting in the most user-friendly way to make it fast and convenient.
It means that the user needs only to approve a spending limit of the betting token (only once) for our `Relayer` smart contract,
and then he can place his bets just by signing messages in his EVM wallet.

Technically, in Azuro, live betting feature is split by two major parts:

- [Data feed](/guides/live/data-retrieval).
- [Bets management](/guides/live/place-a-bet).
7 changes: 7 additions & 0 deletions pages/guides/live/place-a-bet.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Callout } from 'components'

# Place a bet

<Callout type="warning">
The page is under construction
</Callout>
9 changes: 9 additions & 0 deletions pages/guides/prematch/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"get-games": "Get Games",
"markets-and-outcomes": "Prepare Game Markets",
"get-odds-values": "Get Odds Values",
"real-time-odds-updates": "Real-time Odds Updates",
"place-a-bet": "Place a Bet",
"get-bets-history": "Get Bets History",
"redeem-bets": "Redeem Bets"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ sendTransaction(txDto)
To send a batch of single bets you should use [ProxyFront](/contracts/proxy-front) contract.

<Callout type="info">
Note that data structure differs from the structure of [placing single bet on LP contract](/guides/place-a-bet#place-a-single-bet).
Note that data structure differs from the structure of [placing single bet on LP contract](/guides/prematch/place-a-bet#place-a-single-bet).
</Callout>

<Tabs items={[ 'Ethers', 'Wagmi' ]}>
Expand Down Expand Up @@ -420,7 +420,7 @@ It's important to ensure that the user has sufficient funds in their account bef
gracefully if the bet cannot be placed due to insufficient funds or other reasons.

Keeping the odds updated is essential for providing the best user experience to your customers. By
[subscribing to odds updates](/guides/real-time-odds-updates), you can keep the odds values up-to-date in real-time,
[subscribing to odds updates](/guides/prematch/real-time-odds-updates), you can keep the odds values up-to-date in real-time,
which can help reduce the risk of user frustration or missed betting opportunities. Alternatively, you can
[fetch the odds values](/guides/get-odds-values) before a user submits a bet to ensure that the odds values are current
[fetch the odds values](/guides/prematch/get-odds-values) before a user submits a bet to ensure that the odds values are current
at the time of the bet placement.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ eventEmitter.subscribe('ConditionStopped', (event) => {
You don't need to subscribe to express core contract. It calls `OddsChanged` event on core contract with every combo bet.
</Callout>

The information on how to fetch odds values can be found in ["Get Odds Values"](/apis/subgraph/guides/get-odds-values)
The information on how to fetch odds values can be found in ["Get Odds Values"](/guides/prematch/get-odds-values)
section.


Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Card } from 'components'
<Card
title="Integrate with Azuro"
text="Learn how to integrate with Azuro by building a dApp through guided examples"
to="/guides/get-games"
to="/guides/prematch/get-games"
/>
<Card
title="The Azuro smart contracts"
Expand Down
40 changes: 40 additions & 0 deletions pages/releases/9-live-betting-in-testnet.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 11/20 Live betting in Polygon Mumbai testnet

## Introduction

The Azuro Protocol team is excited to announce the launch of most anticipated feature -
**live betting** in Polygon Mumbai testnet for all Azuro Protocol frontend operators.
In this update, we introduce the concept of live betting,
guides for markets data retrieval and gasless betting using Azuro Live Betting API.

[Contracts](/contracts/live-host-core) / [Subgraph](/subgraph/overview#live-endpoints) / [Guides](/guides/live/overview)

## Smart contracts

We have added new smart contracts for live betting:

- [`HostCore`](/contracts/live-host-core) in Gnosis chain for games and markets storing.
- [`LiveCore`](/contracts/live-client-core) in Polygon Mumbai chain for bets storing.
- [`Relayer`](/contracts/live-relayer) in Polygon Mumbai chain for processing a new bets.

## Subgraph

We have added new [Subgraphs](/subgraph/overview#live-endpoints) for indexing of new smart contracts:

- `HostCore` subgraph for indexing of `HostCore` contract in the Host chain.
- `LiveCore` subgraphs for indexing of `LiveCore` contracts in the Client chains.

## Azuro Live Betting API

We have added a new API for bets registering and processing. This API allows to place an [`order`](/concepts/glossary#order) (signed bet request) and track its status.

- `POST /orders` endpoint for adding a new order.
- `GET /orders/:id` for retrieving an order actual state.

## Conclusion

With implementing of Live betting feature we're expecting a significant increase in betting turnover and an interest in Web3 betting at all.

We've tried to make a technical implementation of the feature as easy as possible.

If you have any questions or need further assistance, please don't hesitate to reach out to the Azuro Protocol team.
3 changes: 3 additions & 0 deletions pages/releases/_meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"9-live-betting-in-testnet": {
"title": "11/20 Live betting in Polygon Mumbai testnet"
},
"8-sdk": {
"title": "11/13 SDK"
},
Expand Down
Loading

0 comments on commit 056d1b1

Please sign in to comment.