# Introduction to Thales Protocol

You've reached the official Thales Protocol documentation.

#### **Thales Protocol** is a suite of smart contracts on the Ethereum Network that provides an easily integratable **Liquidity** and **Automated Market Making** layer for probability based markets (Digital Options, Sports Markets etc.) that are settled by various onchain Oracle Data sources.

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FzRSeikvhpoWVfYGqeEDd%2F1500x500.jfif?alt=media&token=036ef12a-9e6e-40f8-9afa-ce06b11e54a3>" %}

### Purpose of the Thales Protocol

By providing a secure, transparent and decentralized infrastructure for Traders on one side and Liquidity Providers on other side, Thales Protocol revolutionized probability based exclusive-outcome markets on a global scale. It serves as a globally accessible onchain Automated Market Making architecture that allows traders to place positions on Sports, Digital Options etc. against a collateral provided by AMM Liquidity Providers.

### How Thales solved the Market Making problem of exclusive outcome markets

Market Making in units of token prices has always plagued various Prediction Market products on Ethereum Network. Constant Function Market Making incur significant losses in this scenario, due to the fact that the losing side of the market has to go to zero on maturity. A different Market Making approach had to be invented.

<figure><img src="/files/vA1CzPFy15bSIss2iRF4" alt=""><figcaption><p>Insert from Delphi Digital's article on Thales Protocol</p></figcaption></figure>

**Thales Protocol solved this problem by building it's Automated Market Making architecture as such that it provides on-demand liquidity around a fixed oracle-based probability reference point.** This also allows the Thales AMMs to offer on-demand liquidity to multiple markets from a single specialized AMM contract that uses a single counterparty collateral pool. Controlling risk management with a risk cap and skew impact allows the AMM to market make in units of risk rather than token prices. This means that the AMM has theoretically unlimited capital efficiency, so long as the risk exposure of a pool remains within the risk cap.

### Novel onchain solutions bring novel onchain products

Thales Protocols simple yet powerful Smart Contracts allow anyone to participate in various decentralized exotic products as a Trader or as a Liquidity Provider, that leverage the same foundational Thales Protocol collateralization architecture.

<table data-view="cards" data-full-width="true"><thead><tr><th></th><th></th><th></th><th data-hidden data-type="content-ref"></th></tr></thead><tbody><tr><td><span data-gb-custom-inline data-tag="emoji" data-code="26bd">⚽</span> <strong>Thales Sports Markets</strong></td><td> Fully decentralized Sports AMM solution that allows users to place fully collateralized onchain positions and leveraged Parlays on Sports Results, Game Stats, Player Props etc. Users can also deposit funds into the Sports AMM and Parlay AMM Liquidity Pools to provide collateral for traders and gain exposure to the performance of the Sports AMM, effectively becoming <em>The House</em>. Thales Sports Markets settlement data is fully backed by robust Sports Data from Chainlink Oracles.</td><td></td><td></td></tr><tr><td><span data-gb-custom-inline data-tag="emoji" data-code="1f4c8">📈</span> <strong>Thales Digital Options</strong></td><td><code>UP</code> or <code>DOWN</code> tokenized positions on Crypto Strike Prices on specific Strike Dates. Users can choose from a wide variety of Chainlink supported crypto assets and commodities to trade around. Users can also deposit funds into the Thales AMM Liquidity Pool to provide collateral for traders and take exposure to Thales AMM performance. Users can also trade Volatility Digital Options by using Ranged Markets product built on top of the ThalesAMM architecture. It offers <code>IN</code> or <code>OUT</code> tokenized positions on Crypto Price Ranges on Specific Strike Dates.</td><td></td><td></td></tr><tr><td><span data-gb-custom-inline data-tag="emoji" data-code="26a1">⚡</span> <strong>Thales Speed Markets</strong></td><td>Short term intraday positioning on the direction of Crypto Assets from the Current Price, settled at a chosen Strike Time, with a fixed potential profit of 2X for each trade (before fees). By using the Speed Markets AMM, users can take positions as short as 15 minutes or up to a maximum Strike Time of 24 hours. Users can also chain several Speed Markets into one transaction for a potential maximum 47X return.</td><td></td><td></td></tr></tbody></table>

### Integratable on <img src="https://cdn.discordapp.com/emojis/885397024051179520.webp?size=56&#x26;quality=lossless" alt=":optimism:" data-size="line">Optimism, <img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FvHpXOwMBnqanTs43NNPe%2Farbi%20logo2.png?alt=media&#x26;token=6d70d737-674b-4696-98e6-fd08952617a8" alt="" data-size="line"> Arbitrum, <img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2F9ZNFXeYNywvXn4zct7Rg%2Fimage.png?alt=media&#x26;token=cc5f0117-cef8-451d-bf94-751c71c86d56" alt="" data-size="line">Base and <img src="https://cdn.discordapp.com/emojis/963036781878595594.webp?size=56&#x26;quality=lossless" alt=":polygon:" data-size="line">Polygon

&#x20;Anyone can use the Thales APIs to access the pricing data and execute and settle trades that happen on the Thales Protocol smart contracts.


# Foundational Architecture of Thales

How it all came to be

The Thales Protocol was born in 2021 as a permissionless, order book based `peer2peer` Digital Options platform deployed on Ethereum Mainnet and powered by Chainlink price feeds. The original goal of Thales was the ability to support tokenized "all-or-nothing" Digital Options that are determined by the following variables:

* Asset - Choice of asset (price/data feed) around which the Digital Options market is revolving around ( e.g. price of `Bitcoin` )
* Strike Price - Goal price of chosen asset around which market participants choose if the price will be above or below ( e.g. "Will the price of `Bitcoin` be above `$50,000`" )
* Maturity Date - Time and date at which the Strike Price is compared to Current Price and the market is resolved either as UP or DOWN ( e.g. "Will the price of `Bitcoin` be above `$50,000` on `2025/01/01`)

All individual These Markets were (and still are) all dedicated unique smart contracts.  All of them individually support the minting of UP and DOWN ERC20 tokens that represent tokenized exclusive outcomes, in exchange for USD of collateral ( 1 USD deposited into the market by the MM mints 1 `UP` and 1 `DOWN` ERC20 token back to the MM wallet)

Only one of these two types of tokens are able to be redeemed for the entire amount of USD collateral from the market contract after maturity date, depending on if the Chainlink reported price of this market's Asset is UP or DOWN from the Strike Price on the Maturity Date.&#x20;

**This collateral mechanism is the core foundation of the Thales Protocol.**&#x20;

Even though this market design format is ideal for simple derivative markets around the price movement of crypto assets, but this is nowhere near the extent of Thales’ power. Thanks to a network of data authenticators known as Oracles, that publish information to the blockchain, any off-chain event can theoretically form the basis of a Thales Market. This architecture was later expanded to support Sports Games oracle data (pre-game odds and post-game results) to allow Thales to build a permissionless onchain Sports Markets architecture.


# Frequently Asked Questions (FAQ)

Commonly asked questions and answers.

<details>

<summary><strong>What is Thales Protocol?</strong></summary>

Thales Protocol is a suite of smart contracts on the Ethereum Network that provides a Liquidity and Market Making layer for probability based markets settled by various Oracle Data sources (e.g. Digital Options, Sports Markets, Prediction Markets etc).

</details>

<details>

<summary><strong>Does Thales Protocol have a token?</strong></summary>

The [THALES token](https://optimistic.etherscan.io/token/0x217D47011b23BB961eB6D93cA9945B7501a5BB11) is the foundation and the governance token of the Thales Protocol. By staking THALES token, staker is granted Governance Voting Power, THALES Staking Rewards, Gamified Rewards and SafeBox Rewards.

THALES token versions across chains:

* <img src="https://cdn.discordapp.com/emojis/885397024051179520.webp?size=56&#x26;quality=lossless" alt=":optimism:" data-size="line">THALES token on Optimism: [0x217D47011b23BB961eB6D93cA9945B7501a5BB11](https://optimistic.etherscan.io/token/0x217D47011b23BB961eB6D93cA9945B7501a5BB11)
* <img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FvHpXOwMBnqanTs43NNPe%2Farbi%20logo2.png?alt=media&#x26;token=6d70d737-674b-4696-98e6-fd08952617a8" alt="" data-size="line"> THALES token on Arbitrum: [0xe85b662fe97e8562f4099d8a1d5a92d4b453bf30](https://arbiscan.io/address/0xe85b662fe97e8562f4099d8a1d5a92d4b453bf30)
* <img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2F9ZNFXeYNywvXn4zct7Rg%2Fimage.png?alt=media&#x26;token=cc5f0117-cef8-451d-bf94-751c71c86d56" alt="" data-size="line"> THALES token on Base: [0xf34e0cff046e154cafcae502c7541b9e5fd8c249](https://basescan.org/address/0xf34e0cff046e154cafcae502c7541b9e5fd8c249)

[**THALES Token Info**](https://docs.thales.io/thales-token/thales-token-info)

</details>

<details>

<summary>What are the main products of Thales Protocol?</summary>

* 📈 **Onchain Digital Options** - Permissionless architecture for Onchain Digital Options powered by the tokenized Positional Markets collateralization architecture and the ThalesAMM market making based on decentralized Oracle probability pricing.
* **⚽ Onchain Sports markets** - Permissionless architecture for Onchain Sports Markets powered by tokenized Sports Markets and Parlay collateralization architecture and the SportsAMM market making based on decentralized Oracle provided Sports Data for Odds and Results.

</details>

<details>

<summary> On what networks is Thales Protocol deployed?</summary>

Thales Protocol is currently operating on [Optimism](https://www.optimism.io/apps/defi), [Arbitrum](https://arbitrum.io/), [Polygon](https://polygon.technology/) and [Base](https://base.org/) networks.

&#x20;  <img src="https://cdn.discordapp.com/emojis/885397024051179520.webp?size=56&#x26;quality=lossless" alt=":optimism:" data-size="line">      <img src="https://cdn.discordapp.com/emojis/963036781878595594.webp?size=56&#x26;quality=lossless" alt=":polygon:" data-size="line">       ​<img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FvHpXOwMBnqanTs43NNPe%2Farbi%20logo2.png?alt=media&#x26;token=6d70d737-674b-4696-98e6-fd08952617a8" alt="" data-size="line">       ​<img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2F9ZNFXeYNywvXn4zct7Rg%2Fimage.png?alt=media&#x26;token=cc5f0117-cef8-451d-bf94-751c71c86d56" alt="" data-size="line">

</details>

<details>

<summary>Which forms of collateral does Thales Protocol architecture support?</summary>

Thales Protocol contracts currently accept sUSD<img src="https://cdn.discordapp.com/emojis/795704605513220107.webp?size=56&#x26;quality=lossless" alt=":sUSD:" data-size="line">, USDCe<img src="https://cdn.discordapp.com/emojis/795704608332054538.webp?size=56&#x26;quality=lossless" alt=":USDC:" data-size="line">, USDC<img src="https://cdn.discordapp.com/emojis/795704608332054538.webp?size=56&#x26;quality=lossless" alt=":USDC:" data-size="line">, DAI<img src="https://cdn.discordapp.com/emojis/795704607502368808.webp?size=56&#x26;quality=lossless" alt=":DAI:" data-size="line">, USDT<img src="https://cdn.discordapp.com/emojis/795705563727265803.webp?size=56&#x26;quality=lossless" alt=":USDT:" data-size="line">, ETH<img src="/files/o5Avs7pckWmIy0tLcaQY" alt="" data-size="line">, WETH<img src="/files/o5Avs7pckWmIy0tLcaQY" alt="" data-size="line">,ARB<img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FvHpXOwMBnqanTs43NNPe%2Farbi%20logo2.png?alt=media&#x26;token=6d70d737-674b-4696-98e6-fd08952617a8" alt="" data-size="line"> and OP<img src="https://cdn.discordapp.com/emojis/885397024051179520.webp?size=56&#x26;quality=lossless" alt=":optimism:" data-size="line"> for trades execution.&#x20;

These assets are atomically swapped to core collateral and settled within each trade, and those are:

<img src="https://cdn.discordapp.com/emojis/795704605513220107.webp?size=56&#x26;quality=lossless" alt=":sUSD:" data-size="line">sUSD (Synthetix USD) on Optimism

<img src="https://cdn.discordapp.com/emojis/795704608332054538.webp?size=56&#x26;quality=lossless" alt=":USDC:" data-size="line">USDC on Arbitrum, Base and Polygon

</details>

<details>

<summary>Can I integrate Thales contracts and build my own dApp?</summary>

Thales Protocol smart contract provide a Liquidity and Market Making layer for onchain Sports Markets and onchain crypto Digital Options.&#x20;

**Anyone can use the Thales APIs to access the pricing data and execute and settle trades that happen on the Thales Protocol smart contracts.**

To get started integrating **Thales Sports Markets** to you application, use this link:&#x20;

To get started integrating **Thales Digital Options** to your application, use this link:

</details>

<details>

<summary>Are there any examples of dApps that are powered by Thales Protocol smart contracts?</summary>

<img src="/files/15JRy1wCfKuhBElqBA2V" alt="" data-size="original">

[Overtime](https://www.overtimemarkets.xyz/)

* Onchain Sports Markets Automated Market Maker (AMM) interface with integrated Parlay AMM architecture. Built on top of Thales Protocol technology, Overtime offers seamless user experience for all sports enthusiasts while bolstering transparent full collateralization at all times and permissionless security of the Ethereum network.

![](/files/to1Go5lEvFP9lbkJiCNl)

[Thales Markets](https://thalesmarket.io/)

* Onchain Digital Options trading platform that utilizes an Chainlink data feeds, Automated Market Maker, on-demand liquidity and collateralization architecture of the Thales Protocol Smart Contracts to provide it’s users non-custodial, permissionless and simple-to-use derivatives trading.

![](/files/QTOV94mZ8mLbca6x0tGN)

[BookieBot](https://bookiebot.app/)

Telegram Bot application that uses Thales Protocol smart contracts to settle trades

[Spongly](https://spongly.eth.limo/dashboard/)

Spongly is Sports Markets dapp built on top of Thales' SportsAMM and ParlayAMM with a social twist. Take an opportunity to copy trade best sports traders, view individual wallets success rates and have a more detailed overview of all global parlay tickets. Use trading wisdom of the best to your own advantage!

</details>


# The Story of Thales from Miletus

the first known person to exercise an options contract

<figure><img src="/files/xsN5q6jfza1IVaynAlZT" alt=""><figcaption><p>Θαλής</p></figcaption></figure>

The search for alpha is not exclusive to our time. The Ancient Greeks prized creativity and critical thinking just as we do today, but even then few could harness these skills to create tangible gains. The great thinker Thales of Miletus possessed these abilities and used them to demonstrate the everyday value of philosophy while simultaneously profiting from his brilliance.

Born in 640 BC to noble Miletians, Thales was motivated by astronomy, geometry and philosophy much more than the pursuit of wealth. Despite the doubters who mocked his poverty and useless philosophy, Thales wished to spend his time pondering natural phenomena. One day, Thales drew upon his knowledge of the heavens to speculate that the upcoming olive harvest would be particularly bountiful. He believed that the highly desirable commodity could provide him the financial freedom he desired if he had control over the most efficient method of olive oil production, the olive press.

This opportunity provided very little downside and a huge potential for upside. He quickly summoned his meager savings to rent all the presses in the region prior to the harvest season, betting against his fellow citizens who had no interest in bidding up these rights. When harvest season came and every olive farmer needed to produce oil for the hungry markets, Thales made a fortune renting out his presses at favorable terms, becoming the first person to exercise an option contract. He became wealthy but also demonstrated how philosophy could be valuable in practice.&#x20;

As Aristotle once said: “Thales proved that it is easy for philosophers to be rich if they choose, but this is not what they care about”.

<figure><img src="/files/4KVae4Nkx2znlC4eHckT" alt=""><figcaption><p>Do yo usee it now?</p></figcaption></figure>

In an act of tribute, the Thales team has adopted the oil press as the inspiration for our logo. The round stone reflects the shape of the crescent moon while a drip of oil represents the flow of profits available to those clever enough to capture them. Thales provides access to permissionless parimutuel options markets that operate completely on-chain. We believe the future of finance requires this level of transparency, decentralization and censorship resistance and the Thales protocol offers this to any user willing to seize the opportunity.

{% hint style="info" %}
To read more about Thales history and branding, visit this link from our official blog:

[***Thales - Olive oil, a cornered market, and our logo.*** ](https://thalesmarket.medium.com/olive-oil-a-cornered-market-and-our-logo-421be0f2fc93)
{% endhint %}


# For Developers

Build your own app using Thales!

Thales Protocol smart contracts are accessible to anyone permissionlessly. This means that Thales also represents an **Integratable Infrastructure!**  Anyone can build their own application that connects to Thales smart contracts that act as a liquidity, settlement and market making layer for Digital Options or/and Sports Markets, depending on what a third party wants to integrate.

To further enhance and streamline developer experience when integrating, Thales has developed an API for each of the subproducts that reduces the friction even further.&#x20;

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td>Integrate Thales Sports Markets</td><td></td><td></td><td><a href="/pages/BPrgdbi460E7XDTScp2n">/pages/BPrgdbi460E7XDTScp2n</a></td><td><a href="/files/sqk2b23Zm9mfVe6Et8ZH">/files/sqk2b23Zm9mfVe6Et8ZH</a></td></tr><tr><td>Integrate Thales Digital Options</td><td></td><td></td><td><a href="/pages/bYp6fTxVXOD156dNiO0F">/pages/bYp6fTxVXOD156dNiO0F</a></td><td><a href="/files/UEcA35sbZMMDUoa6pT8H">/files/UEcA35sbZMMDUoa6pT8H</a></td></tr><tr><td>Integrate Thales Speed Markets</td><td></td><td></td><td><a href="/pages/eMOfFINCJjFT6dgs7WvW">/pages/eMOfFINCJjFT6dgs7WvW</a></td><td><a href="/files/fu1pJIwR6xWWWzoRL31R">/files/fu1pJIwR6xWWWzoRL31R</a></td></tr></tbody></table>


# Revolutionizing Sports Markets

### Product Market Fit

The world of sports markets is a clear product market fit of a decentralized programmable network with integrated payments, such as the Ethereum Network. This has long been unexplored within the space, mostly due to the difficulty of solving on-chain liquidity and market making for this type of markets. Incrementally solving  a robust collateralization architecture, then an automated market making layer and a publicly available liquidity pool as the foundation, Thales Protocol has effectively solved these core issues and is ready to dominate this massive product market fit. Thales is paving the way for onboarding the next millions of retail users on ethereum, facilitating global liquidity arbitrage between regional sportsbooks and providing a full suite white label solution for any developer wanting to create their own sports markets application.

### Global Use Case

Not only is Thales Protocol making Sports Markets available for everyday users to place their positions without any unfair limits or necessary permissions but it’s also available for institutional entities to execute global arbitrage and offload risk with the same permissionless nature against locally segregated platforms. For the first time ever, there is a secure and open globally accessible platform that any entity from all over the world can use to hedge, offload risk or just tap into the liquidity of. With a permissionless smart-contract based liquidity architecture and automated market making, Thales is connecting the world of sports markets in an unprecedented way.

## Free and Permissionless White Label Solution

With an open API available to any developer, connecting to Thales infrastructure is very simple where the only friction point to any entity can only be the accessibility to crypto assets. If you want to access Thales Sports Markets to build your own Sports Markets application or integrate Thales to your existing application, you can find all the neccesary documentation here: {{{}}}}

&#x20;


# Thales Sports Markets Architecture

Thales Sports Markets architecture supports all your favorite leagues and competitions on a totally transparent and non-custodial manner, making it stand out from the world of centralized sports books.  \
\
Thales developed a process to provide on-chain liquidity and automated market making solutions for binary and ternary exclusive outcomes, all while achieving an **unprecedented level of capital efficiency** with minimal risk of toxic flow.  The only requirements needed for this novel smart contract architecture to operate successfully include on-chain data for pre-event probability of outcomes and post-event results.

Thales Sports Markets use Chainlink infrastructure to provide **robust on-chain data for sports markets** using the implied probability of various pre-game outcomes matched up with post-game results.  Thales' smart contract architecture consumes Chainlink's reliable data feeds to provide anyone with a **globally accessible, permissionless and trustworthy** solution to Sport Market positioning.  \
\
You can find detailed views of individual key smart contracts for Thales Sports Markets infrastructure in the following pages:

* [Game Market Smart Contract](/thales-sports-markets/thales-sports-markets-architecture/game-market-smart-contract)
* [**SportsAMM Smart Contract**](/thales-sports-markets/thales-sports-markets-architecture/sportsamm-smart-contract)
* **Liquidity Provisioning Contract**
* **Parlay Market and AMM Smart Contracts**


# Game Market Smart Contract

The first component that makes Thales Sport Markets possible is the Game Market Smart Contract. This type of smart contract is based on the foundational Thales Positional Market architecture and is similar to an escrow contract.  Each game will have it's own Game Market Smart Contract which will temporarily hold collateral in return for newly minted ERC-20 Outcome Tokens unique to that particular game.  This means that each game will have it's own smart contract, which will then mint a different ERC-20 token for each possible outcome for that game.

The Game Market Smart Contract as well as each ERC-20 Outcome Token available for that game are dependent on the parameters set for that game's league.  Based on the League ID for a particular match, each market can offer HOME WIN, AWAY WIN and DRAW (for sports/events that allow draws) or simply HOME WIN and AWAY WIN.  Other types of markets, such as spreads, can include Outcome Tokens for ABOVE and BELOW. &#x20;

<figure><img src="/files/ntPPMz5yhNkMjvFvKT9Q" alt=""><figcaption><p>You can use Etherscan to see the tokens for each market you've participated in didn't win / haven't exchanged for USD.</p></figcaption></figure>

{% hint style="info" %}
There is only one whitelisted address that is allowed to mint outcome tokens from the Game Market contracts, and that address represents the Sports AMM contract.
{% endhint %}

The depositor receives one of the available Outcome Tokens for each USD deposited into a Game Market Smart Contract.  Since these Outcome Tokens represent all of the possible outcomes for that unique Game Market, only one of the Outcome Tokens for that market will be redeemable for the USD held in the Game Market Smart Contract.  This is determined by Market Resolution data sent to the blockchain via Chainlink data feeds informing the smart contract that certain conditions have been met and which Outcome Tokens are redeemable.&#x20;

Each market will go through the following phases:

* **Market Creation:** The Game Market Contract is created with League ID used to determine which Outcome Tokens can be minted
* **Positioning:** Traders can exchange collateral for Outcome Tokens, with 1 USD purchasing 1 ERC-20 Outcome token
* **Market Resolution:** Winning Traders can exchange Outcome Tokens for the USD held in the Game Market Contract

### Market Creation

A new Game Market Contract is created for each sporting event offered by Overtime.  This happens when a request for new on-chain data is triggered to the Chainlink Node.  The requested on-chain data is stored in a queue and then used to create the individual Game Market Smart Contracts.

Unique game parameters are pulled from the Chainlink data in the following structure:

````
```
struct GameCreate {
bytes32 gameId;
uint256 startTime;
int24 homeOdds;
int24 awayOdds;
int24 drawOdds;
string homeTeam;
string awayTeam;
}
```
````

A Game Market Contract can only be created from the oracle data if the following is true:

* The sporting event has not started yet
* The sporting event is not finished/cancelled
* Odds data is included
* Team names are valid

If these conditions are met then the the **\`RequestGames\`** method in **\`TheRundownConsumerWrapper\`** contract populates the queue with data for new markets.  This contract then calls the **\`CreateMarketForGame\`** method in **\`TheRundownConsumer\`** contract.

**\`TheRundownConsumer\`** contract is whitelisted to use th&#x65;**\`SportPositionalMarketManager\`** contract to finally create the individual Game Market Smart Contract.  This contract is capable of accepting USD as collateral and working with the Sports AMM Smart Contract to mint ERC-20 Outcome Tokens in exchange for this collateral. &#x20;

### Positioning

Once a Game Market Contract has been deployed and minting is live traders can purchase Outcome Tokens.

### Market Resolution

A market contract must be resolved for traders to redeem winning Outcome Tokens for USD.  This can only happen when a sporting event ends and a request is made to the Chainlink Node for the on-chain data required to resolve a Game Market Smart Contract.&#x20;

The data for this request is passed in the following structure:&#x20;

````
```
struct GameResolve {
bytes32 gameId;
uint8 homeScore;
uint8 awayScore;
uint8 statusId;
uint40 lastUpdated;
}
```
````

Once a specific Game Market Smart Contract is resolved on chain by the relevant GameResolve structure, exercising is enabled for that Game Market for all holders of winning ERC-20 Outcome Tokens.&#x20;

Each winning ERC20 Outcome Token can be exercised to redeem one USD from the Game Market Smart Contract. Market contracts are always holding the same amount of USD as there are winning ERC20 Outcome Tokens in circulation.  This architecture ensures that all positions are always fully collateralized at any point in time.&#x20;


# SportsAMM Smart Contract

Automated Market Making contract for Thales Sports Markets

Now that we've learned how Game Market Contracts and Outcome Tokens are created, you may be wondering how these individual market contracts get seeded with collateral to exchange for winning Outcome Tokens once a market is resolved.  This is where the next key contract for Thales Sports Markets architecture, the Sports AMM Smart Contract, comes into play.&#x20;

The Sports AMM Smart Contract is whitelisted to automatically mint Outcome Tokens for individual sports markets by depositing USD collateral from the liquidity pool to individual Game Market Smart Contracts.  This collateral acts as on-demand liquidity for traders minting Outcome Tokens during the positioning phase, with odds data provided by Chainlink to update prices in near real-time.&#x20;

There are two methods that need to get called before the Sports AMM can minted Outcome Tokens.  These include the "**BuyFromAmmQuote"** method and the "**BuyFromAMM"** method.&#x20;

### Get Quote- BuyFromAmmQuote method

When a user wants to acquire a position for a certain game using the SportsAMM, the first step is retrieval of pricing data for that position. This data is seeded to the contract from the Chainlink Odds Data request and it determines the price that the SportsAMM will sell the ERC20 Outcome Tokens for on-demand. When the Odds Data request sends the odds data to the AMM contract, the ERC20 Outcome Tokens can be acquired from the SportsAMM with the "**BuyFromAmmQuote**" read method called by the user. This method requires the following inputs to return a relevant quote:

* **Market (address):** The address of the Game Market Smart Contract that the position is from
* **Position (uint8):** A single digit input in the uint8 format that signals what is the exact position for the game in question
* **Amount (uint256):** The amount of Outcome Tokens requested for that position which is needed to calculate the Skew Impact/Discount for the quote

### BuyFromAMM method

Buy ERC-20 Outcome Tokens

Traders are able to purchase of Outcome Tokens using their wallet to execute the Sports AMM Smart Contract's "**BuyFromAMM**" method.  The inputs required are as follows:

* **Market (address):** Address of the Game Market Smart Contract that the position is from
* **Position (uint8):** A single digit input in the uint8 format that signals what is the exact position for the game in question
* **Amount (uint256):** The amount of Outcome Tokens requested for that position which is needed to calculate the Skew Impact/Discount for the quote
* **ExpectedPayout (uint256):** The amount of collateral that can be claimed for a winning position&#x20;
* **AdditionalSlippage (uint256):** The amount of slippage to include in the transaction as a risk management measure

After the "**BuyFromAMM**" method is executed by the SportsAMM, the **contract executes the following series of actions atomically in a single transaction**:

1. Take the buy-in amount of USD from the user
2. Take the amount of USD required to collateralize a user's requested ERC-20 Outcome Tokens from the Liquidity Pool contract
3. Use the USD taken from the Liquidity Pool to mint an equal amount of every type of ERC-20 Outcome Token that matches the amount requested by the user
4. Sends the minted ERC-20 Outcome Tokens for the specific position/outcome (stored in the position input) and amount (stored in the amount input) to the user
5. Sends a certain percentage of USD from the user's buy-in amount to the SafeBox contract, determined by the "**SafeBoxImpact**" parameter
6. Sends the remaining amount of USD from the user's buy-in amount to the Liquidity Pool contract

## Risk Management

The Sports AMM has certain mechanics implemented that act as risk management tools. These mechanics keep the SportsAMM from offering positions that could expose it to an unacceptable amount of downside risk. &#x20;

These are:

* **Cap Per Market:** A threshold of how much risk the Sports AMM allows itself to take per Game Market, denominated in USD. The "**DefaultCapPerGame**" read method shows the global default for any new game market, while the "**CapPerSport**" method shows the specific risk cap set for an individual sport/league.  "**CapPerMarket**" shows a specific cap set for an individual market.
* **Skew Impact / Discount:** A per-market premium or discount on top of the default pricing provided by Chainlink Odds data, based on the amount of current risk taken on by the Sports AMM.
* **Max/Min Supported Odds:** Determines the maximum and minimum price of any position that the SportsAMM can provide liquidity for.  If the Chainlink Odds data provides odds that are beyond this threshold for a certain game, that game will not have on-demand liquidity from the SportsAMM until they are potentially updated to fall within the required price range.


# ParlayAMM Smart Contract


# Liquidity Providing Smart Contracts


# Singles Market Making

In this page we dive into the details of the Thales Protocol architecture for Sports Markets and how the Thales Sports Markets came to be!

The underlying foundation that makes Thales Sports Markets the worlds first permissionless Sports Markets AMM is the elegant and novel core design of the **Thales Protocol**, on top of which the Sports Markets are built.

By using the Thales AMM architecture and adapting it to mutually exclusive outcomes of ***HOME/AWAY/DRAW, OVER/UNDER, H1/H2 and YES/NO*** that are priced by live on-chain odds feed from Chainlink and also fully collateralized with US&#x44;***,*** Thales Sports Markets are able to provide the **worlds first permissionless, decentralized and fully on-chain Sports Markets AMM!**

**How does the Sports AMM works?**

The [Sports AMM smart contract](https://github.com/thales-markets/contracts/tree/main/contracts/SportMarkets) is a modified version of the [Thales AMM](https://optimistic.etherscan.io/address/0x5ae7454827D83526261F3871C1029792644Ef1B1) that supports the market types with the following outcomes: ***HOME/AWAY/DRAW**, **OVER/UNDER**, **H1/H2** and **YES/NO***

The workflow of the Sports AMM is divided in three parts:

* **Market creation** - Each Sports Market (single market per game) is a dedicated Positional Market smart contract
* **AMM trading** - The Sports AMM contract offers on-demand liquidity of tokenized HOME, AWAY and DRAW positions across all games
* **Market resolution** - The Sports AMM contracts allow traders with winning positional tokens to exchange them for USD

{% hint style="info" %}
Positions on Overtime for **soccer/football matches are only for regular time** (90 minutes + additional time). Playoff or knockout games that are tied at the end of regular time and go to extra time/penalty shoot-out will result in a draw (X).

So if you purchase a HOME position for a soccer/football match that goes to extra time, the winning position for that market is DRAW, even if the HOME team ends up winning the match during extra time.
{% endhint %}

### Market creation

This is the starting phase when markets are created from games offered by the [Chainlink end-point](https://market.link/nodes/TheRundown/integrations). The games are organized in `sportIds` which represent league competitions of given sports, not only the sport in general. The current list of supported  leagues include:

* **NCAA Men's Football** (American football)
* **NFL** (American football)
* **MLB** (Baseball)
* **NBA** (Basketball)
* **NCAA** Men's Basketball
* **NHL** (Hockey)
* **WNBA** (Basketball)
* **MLS** (Soccer)
* **EPL** (Soccer)
* **Ligue** 1 (Soccer)
* **Bundesliga** (Soccer)
* **La Liga** (Soccer)
* **Serie A** (Soccer)
* **UEFA Champions League** (Soccer)
* **Formula 1** (Motorsports)
* **FIFA World Cup** (Soccer)
* **ATP Tennis** (Tennis)
* **CSGO** (eSports)
* **Indian Premier League** (Cricket)
* **EuroLeague** (Basketball)
* **T20 Blast** (Cricket)
* **PGA Tour** (Golf)

Market creation starts by fetching games for each `sportId` each day from the end-point. The fetched games are stored on-chain and then the market's contracts are created from every fetched game. Each game is a dedicated positional market smart contract with two or three available positions depending on the possible outcomes of the sport in question.

{% hint style="info" %}
The Thales Protocol DAO reserves the right to enable trading for various sports one by one as the product matures and becomes more battle tested.
{% endhint %}

### Trading with the Sports AMM

Each Sports Market is open for trading immediately after it is created with the Sports AMM contract offering on-demand liquidity. This liquidity is open for trading up until the moment the game in question starts. At that moment, the AMM stops offering liquidity for that market.

The Sports AMM supports each market by offering the following tokenized ERC20 positions:

* `HOME` and `AWAY` tokens - for two-outcome positional markets (e.g. basketball)
* `HOME`, `AWAY` and `DRAW` tokens - for three-outcome positional markets (e.g. soccer)
* `OVER` and `UNDER` tokens - for positions on if an actual statistic number in the sports game will be higher or lower than the market number (e.g. player props, total points etc.)
* `YES` and `NO` tokens - for positions on special milestone based positional markets within a sports game (e.g. will a basketball player reach a double-double)

Each tokenized position is priced by using the on-chain **Chainlink odds feed** fetched from robust bookmaker APIs. Additionally, there is also a pricing premium on top called **Skew Impact** that serves as an incentive to keep the AMM liquidity balanced between all positions. The Skew Impact makes "overbought" Positional Tokens from a certain market more expensive, keeping the AMM in balance and unexposed to market exposure risk.

Since the odds of a certain result range between 0% and 100%, the Positional Tokens of Sports Markets are priced between 0.00 USD and 1.00 USD by the Sports AMM.&#x20;

{% hint style="info" %}
**Example:** \
Chainlink odds feed reports that the odds of a HOME WIN of a certain game is 30%. This means that the AMM will offer `HOME` ERC-20 tokens for sale priced at \~0.30 USD (depending on Skew Impact which can go to max +5% premium). \
If the end result of the game in question resolves as a HOME WIN, every `HOME` token will be redeemable for 1.00 USD, meaning that everyone who purchased HOME tokens for 0.30 USD in the trading phase earned 0.70 USD of profit per token.
{% endhint %}

Each Sports Market has native liquidity caps (or limits). The AMM will offer on-demand liquidity under the following conditions only:&#x20;

* The Sports AMM's risk is below a currently set threshold in USD. - The AMM can only allow exposure to the market resolution (game result) below the currently set threshold. If the threshold is reached, the AMM stops offering liquidity for that sports market.
* `HOME`, `AWAY` or `DRAW` positions have odds reported between **5% and 95%**. - The AMM does not support liquidity if the position in question is priced **below $0.05 or above $0.95**.

### Skew / Position Bonuses

**Bonuses are added to positions that are underbought**, providing traders with an incentive to take these positions and go against the crowd. If users are piling on the same side of a market (team A) then the other position (Team B) will be awarded a bonus of up to 10%. A 10% bonus on a position with a quote of 0.5 USD will pay out at the rate of a 0.45 USD quote.&#x20;

### Market Resolution

Each market is resolved by Results Data provided by Chainlink Sports Feeds.

#### Possible Sports Markets resolutions include:

* HOME WIN - Each holder of HOME WIN tokens can redeem their tokens for 1.00 USD per token.
* AWAY WIN - Each holder of AWAY WIN tokens can redeem their tokens for 1.00 USD per token.
* DRAW - Each holder of DRAW tokens can redeem their tokens for 1.00 USD per token.
* CANCELLED GAME - Every token is redeemable for the amount per token coinciding with the last reported odds for the game in question.

#### Handicap Market resolutions include:

* H1 WIN- If a Handicap is surpassed by the Favorite, holders of H1 tokens can redeem their tokens for 1.00 USD per token.
* H2 WIN- If a Handicap is not surpassed by the Favorite or the Underdog wins, holders of the H2 token can redeem them for 1.00 USD per token.

#### Total Points Market resolutions includes:

* OVER WIN- If the total points scored in the match is OVER the projected Total points, holders of the OVER token can redeem them for 1.00 USD per token.
* UNDER WIN- If the total points scored in the match is UNDER the projected Total points, holders of the UNDER token can redeem them for 1.00 USD per token.

**REMEMBER! Markets for soccer/football games resolve after regular time**.  If tied at the end of regular time, DRAW is the winning position, even if a team goes on to win in extra time.

{% hint style="info" %}
For additional Technical Details around Sports Markets AMM contracts, visit the following link:&#x20;

<https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-60.md#technical-details>
{% endhint %}


# Parlays Market Making

In this page we dive into the details of the Thales Protocol architecture for Parlays of Thales Sports Markets!

{% hint style="info" %}
Parlays are a common feature in centralized sports markets that allow traders to expand their positions to multiple markets with one potential payout. A parlay combines multiple wagers into one position by rolling over the winnings from each individual wager into the next leg of the wager. Each “leg” or individual position in the parlay must win for the parlay to be deemed a winner.
{% endhint %}

By using the Parlay AMM, users of Thales Sports Markets can string together multiple positions into a one parlay ticket and experience a whole new leveraged dimension for trading sports markets.

### How the ParlayAMM works

When user buys a Parlay Ticket, the ParlayAMM contract locks the full amount of a potential payout taken from the Parlay Liquidity Pool. The contract reads all the latest odds from the SportsAMM but it does not apply any slippage logic of the SportsAMM. Parlay AMM just multiplies the default odds to get the potential payout.

Risk management of the ParlayAMM revolves around having risk caps per unique positions within parlay tickets. This means that the ParlayAMM stores the risk amount of each market within a parlay into a new variable called `RiskPerMarketAndPosition`. Data within the `RiskPerMarketAndPosition` variable is then used to block further parlays that exceed the risk cap defined in the `RiskManager` contract.

### Same Game Parlays

Traders **can combine positions from a single game** with Same Game Parlay positions.  This means you can choose one position that includes outright winner (HOME or AWAY) combined with the Total Points spread (OVER or UNDER total point for both teams for that market).  Same Game Parlay positions include the following:

* **1 and O** (HOME team win and total points OVER the spread)
* **1 and U** (HOME team win and total points UNDER the spread)
* **2 and O** (AWAY team win and total points OVER the spread)
* **2 and U** (AWAY team win and total points UNDER the spread)

Same Game Parlay positions can be purchases as single positions or as part of a parlay.  These positions are currently available for **NBA** (Basketball), **NHL** (Hockey), **MLB** (Baseball) **EuroLeague** (Basketball), **Champions League** (Football/Soccer) and the **English Premier League** (Football/Soccer).

### ParlayAMM Specs and Limits

* Parlays incur a 3% Parlay Fee, plus the normal Safebox Fee of 3%&#x20;
* Buy-in is a **minimum of 3 USD**
* Parlays are limited to **10 positions**&#x20;
* A single parlay can’t have the same team/player/fighter in the same parlay, even with a different date
* Only 1 motorsport market is allowed per a single parlay&#x20;
* Buys only right now
* The minimum price quote is **0.01 (or 100x)** combined quote for each market **Combined Price Quotes for Parlay's**

### Market Cancellation Logic

If a market included in your parlay is cancelled, that market's quote is effectively removed. If you have 4 markets and 1 of them is cancelled, your initial collateral is essentially now applied to 3 markets instead of 4. The calculation for your total parlay’s quote replaces the cancelled market with 1. If you have a parlay with 0.5, 0.3 and 0.6 Implied Odds (0.5 x 0.3 x 0.6 comes to a combined quote of 0.09) and the game with 0.3 Implied Odds is cancelled, the new calculation is 0.5 x 1 x 0.6 (a combined quote of 0.3).


# Onchain Sports Odds

Thales Sports markets are not only bringing the game to the blockchain; it’s doing it with some of the best odds available across all sportsbooks. These odds come from Pinnacle Sportsbook, a highly respected bookmaker with customers in over 100 countries. Data for Tennis is provided by EnetPulse, with instant score updates used to price and resolve Tennis markets.   Golf tournaments are supported by JsonOdds.

### Pinnacle Sportsbook

[Pinnacle Sports](https://www.pinnacle.com/en/) has been around since 1998 and is considered to be one of the most trustworthy sportsbooks on the internet. The level of security they employ is top notch, with the same strong encryption and security standards used by top financial institutions. It is also one of the few sportsbooks to offer odds on eSports.&#x20;

&#x20;                                          ![](https://3906942432-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSlj8vWOOVBuhXhcN6iy%2Fuploads%2FxplWLlbFbMGSYST6T0eY%2Fimage.png?alt=media\&token=8e188b48-1cec-4078-8c04-06d55afe6fd7)

Pinnacle calculates their odds by combining old school methods like “power rankings” with cutting edge data analysis. Pinnacle uses individual player statistics, team schedules and past performance along with the interpretation of trends and other factors when creating these power rankings while also relying on decades of data to arrive at their odds.&#x20;

Pinnacle supplies these odds to [The Rundown's API](https://therundown.io/api) which makes them available to Chainlink and the blockchain.

### EnetPulse

[EnetPulse](https://enetpulse.com/sports-coverage) has provided live data via XML or API data feeds to over 200 international clients for over 20 years.  They offer over 80 different sports, with point-by-point data for ATP Tennis used for Overtime's Tennis markets.

&#x20;                                                ![](https://3906942432-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSlj8vWOOVBuhXhcN6iy%2Fuploads%2FmPtNsxI8Kdz5JRG2tOf7%2Fimage.png?alt=media\&token=08465065-b55d-472c-9dfb-15ab67857e03)

### JsonOdds

[JsonOdds](https://jsonodds.com/) is a simple and modern API for delivering odds for sporting events.  [TIP-150](https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-150.md) made it possible to add data from JsonOdds for professional golf tournaments.

&#x20;                                                              ![](https://3906942432-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSlj8vWOOVBuhXhcN6iy%2Fuploads%2FqckVrVeSNLTH2UnvHce4%2Fimage.png?alt=media\&token=5923186a-9495-4c54-b89f-b8f83cddfaa8)&#x20;

## Odds are used to Price Positions

Thales Sports AMM receives these odds on-chain via Chainlink data feeds and uses them to price their positional tokens for each market. Pricing for a single dollar of potential profit is equivalent to the implied win probability of the position, but as a decimal instead of a percentage. If a Home win has a price of 0.60 per 1 dollar of potential profit, you can infer the implied win probability of that position, based off of the data supplied by Pinnacle, is 60%.


# Sports Markets Liquidity Providing

### Introduction to Sports Markets Liquidity Providing

Thales' design involves a singular counterparty liquidity pool in which anyone in the world with an internet connection can deposit collateral into and become exposed to the performance of the pool. Thales SportsAMM contract uses the liquidity from the pool to collateralize on-demand trades executed on Thales Sports Markets. The performance of the pool is based on the presence of fixed price spreads between exclusive outcomes of sports games.

This singular pool architecture provides liquidity to many dedicated sports game markets with per-game risk management. This means that the global risk of the liquidity pool against the traders is minimized via normal distribution of per-game risk, allowing the pool to have a constant long-term positive performance due to the presence of odds spread. The higher the sample size of global users taking various positions on sports games, the greater the performance of the Thales pools.&#x20;

### Mechanics of Providing Liquidity&#x20;

The deposited USD is used to collateralize the Sports AMM and Parlay AMM on a **weekly round basis**. A single game market can only belong to one round, which is **defined based on the maturity date of the market (game end)**. When a round ends, the AMM's performance from all markets in that round is summed up, and allocated to all liquidity providers proportional to their share of the pool.

* Each LP-ing round lasts **7 days**.
* User can Deposit at any time during any round. **The deposited funds will be utilized as collateral in Sports AMM and Parlay AMM starting with the next round from time of Depositing.**
* The minimum deposit is **100 USD** for the first deposit. Existing depositors are not subject to a minimum amount.
* Deposited funds roll over to next round automatically until a Withdrawal is signaled.
* User can signal a Withdrawal at any time during any round. **Withdrawals are limited to no less than 10% of your total deposit.**
* The funds that are signaled for Withdrawal will be unlocked **at the start of the next round from time of signaling.**&#x20;

{% hint style="danger" %}
If you signal a Withdrawal, **your funds will still be exposed as collateral for the duration of the ongoing round** and will only be removed as collateral when the round ends.
{% endhint %}

{% hint style="warning" %}
**Providing liquidity exposes you to various risks** including potential losses due to users winning in trading as well as smart contract security risks. Please make sure you understand these risks before depositing.
{% endhint %}


# Sports Markets Integration

## Overtime API

In order to ensure easy integration with third party applications, Overtime API is created. API returns all main data available on Overtime. Using Overtime API endpoints someone can get data about:

* Overtime sports
* Overtime collaterals
* Overtime markets
* Overtime market
* User Overtime positions
* User Overtime transactions
* Single quote
* Parlay quote

More details about each API endpoint with request/response examples can be found under [Postman documentation](https://documenter.getpostman.com/view/1435701/2s9XxvUahM).

## Contract integration

Once all data are fetched from API, the next step is integration with Overtime contracts. Depending on whether someone wants to buy a single or a parlay, integration should be done with [Sports AMM Smart Contract](/thales-sports-markets/thales-sports-markets-architecture/sportsamm-smart-contract) or [Parlay AMM Smart Contract](/thales-sports-markets/thales-sports-markets-architecture/parlayamm-smart-contract).

The next sections describe integration with Overtime API and Overtime contracts together with JS code examples.

### Buy a single&#x20;

Let's say someone wants to buy positional tokens on **Chelsea** for the game **Chelsea - Liverpool** with a buy-in amount of **100 sUSD.**

Integration with Overtime API and Sports AMM contract should include the following steps:

1. Get a quote for a single market from Overtime API&#x20;
2. Get a Sports AMM contract address for a specific network from [Thales contracts](https://contracts.thalesmarket.io/)
3. Get a Sports AMM contract ABI from Overtime contract repository [contract repository](https://github.com/thales-markets/contracts/blob/main/scripts/abi/SportsAMM.json)
4. Create Sports AMM contract instance
5. Call `buyFromAmm` method on Sports AMM contract with input parameters fetched from Overtime API in step #1

The JS code snippet below implements these steps:

```javascript
import { ethers } from "ethers";
import w3utils from "web3-utils";
import axios from "axios";
import dotenv from "dotenv";
import sportsAMMContractAbi from "./SportsAMMContractAbi.js"; // SportsAMM contract ABI

dotenv.config();

const API_URL = "https://overtimemarketsv2.xyz"; // base API URL
const NETWORK_ID = 10; // optimism network ID
const NETWORK = "optimism"; // optimism network
const SPORTS_AMM_CONTRACT_ADDRESS =
  "0x170a5714112daEfF20E798B6e92e25B86Ea603C1"; // SportsAMM contract address on optimism
const MARKET_ADDRESS = "0xb157e64720d3ff251023119a5f6557067763b08a"; // address od market Chelsea - Liverpool
const POSITION = 0; // select Chelsea position
const BUY_IN = 100; // 100 sUSD
const SLIPPAGE = 0.02; // slippage 2%

// create instance of Infura provider for optimism network
const provider = new ethers.providers.InfuraProvider(
  { chainId: Number(NETWORK_ID), name: NETWORK },
  process.env.INFURA
);

// create wallet instance for provided private key and provider
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);

// create instance of Sports AMM contract
const sportsAMM = new ethers.Contract(
  SPORTS_AMM_CONTRACT_ADDRESS,
  sportsAMMContractAbi,
  wallet
);

const buyFromAmm = async () => {
  try {
    // get a quote from Overtime API for provided market, position and buy-in amount on optimism network
    const quoteResponse = await axios.get(
      `${API_URL}/overtime/networks/${NETWORK_ID}/markets/${MARKET_ADDRESS}/quote?position=${POSITION}&buyIn=${BUY_IN}`
    );
    const quoteData = quoteResponse.data;
    console.log("Quote data", quoteData);

    // convert payout got from API to BigNumber
    const parsedPayout = ethers.utils.parseEther(quoteData.payout.toString());
    // convert actual buy-in amount got from API to BigNumber
    // actualBuyInCollateralAmount is different from BUY_IN due to the contract architecture having positions amount as input and not buy-in amount
    const parsedActualBuyInCollateralAmount = ethers.utils.parseEther(
      quoteData.actualBuyInCollateralAmount.toString()
    );
    // convert slippage tolerance to BigNumber
    const parsedSlippage = ethers.utils.parseEther(SLIPPAGE.toString());

    // call buyFromAMM method on Sports AMM contract
    const tx = await sportsAMM.buyFromAMM(
      MARKET_ADDRESS,
      POSITION,
      parsedPayout,
      parsedActualBuyInCollateralAmount,
      parsedSlippage,
      {
        type: 2,
        maxPriorityFeePerGas: w3utils.toWei("0.00000000000000001"),
      }
    );
    // wait for the result
    const txResult = await tx.wait();
    console.log(
      `Successfully bought from AMM. Transaction hash: ${txResult.transactionHash}`
    );
  } catch (e) {
    console.log("Failed to buy from AMM", e);
  }
};

buyFromAmm();

```

### Buy a parlay

Let's say someone wants to buy a **4-game parlay** with a buy-in amount of **100 sUSD.**

1. Get a quote for a parlay from Overtime API&#x20;
2. Get a Parlay AMM contract address for a specific network from [Thales contracts](https://contracts.thalesmarket.io/)
3. Get a Parlay AMM contract ABI from Overtime contract repository [contract repository](https://github.com/thales-markets/contracts/blob/main/scripts/abi/ParlayMarketsAMM.json)
4. Create Parlay AMM contract instance
5. Call `buyFromParlay` method on Parlay AMM contract with input parameters fetched from Overtime API in step #1

The JS code snippet below implements these steps:

```javascript
import { ethers } from "ethers";
import w3utils from "web3-utils";
import axios from "axios";
import dotenv from "dotenv";
import parlayAMMContractAbi from "./parlayAMMContractAbi.js"; // ParlayAMM contract ABI

dotenv.config();

const API_URL = "https://overtimemarketsv2.xyz"; // base API URL
const NETWORK_ID = 10; // optimism network ID
const NETWORK = "optimism"; // optimism network
const PARLAY_AMM_CONTRACT_ADDRESS =
  "0x82B3634C0518507D5d817bE6dAb6233ebE4D68D9"; // ParlayAMM contract address on optimism
const MARKETS = [
  "0xb157e64720d3ff251023119a5f6557067763b08a",
  "0xbf1e460b82308cb76d5918377eb03ac7a3c33a43",
  "0xa73553b23799ae0e8743771a79d26cb196eca892",
  "0x91300647b7bc3b698fd2e841d26cdfc61a4145ed",
]; // market addresses
const POSITIONS = [0, 1, 0, 0]; // market positions
const BUY_IN = 100; // 100 sUSD
const SLIPPAGE = 0.02; // slippage 2%
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; // pass as a differentRecipient parameter for the buyFromParlay method

// create instance of Infura provider for optimism network
const provider = new ethers.providers.InfuraProvider(
  { chainId: Number(NETWORK_ID), name: NETWORK },
  process.env.INFURA
);

// create wallet instance for provided private key and provider
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);

// create instance of Parlay AMM contract
const parlayAMM = new ethers.Contract(
  PARLAY_AMM_CONTRACT_ADDRESS,
  parlayAMMContractAbi,
  wallet
);

const buyFromParlay = async () => {
  try {
    // get a quote from Overtime API for provided market addresses, market positions and buy-in amount on optimism network
    const quoteResponse = await axios.get(
      `${API_URL}/overtime/networks/${NETWORK_ID}/parlay/quote?markets=${MARKETS.join(
        ","
      )}&positions=${POSITIONS.join(",")}&buyIn=${BUY_IN}`
    );
    const quoteData = quoteResponse.data;
    console.log("Quote data", quoteData);

    // convert payout got from API to BigNumber
    const parsedPayout = ethers.utils.parseEther(quoteData.payout.toString());
    // convert buy-in amount to BigNumber
    const parsedBuyInAmount = ethers.utils.parseEther(BUY_IN.toString());
    // convert slippage tolerance to BigNumber
    const parsedSlippage = ethers.utils.parseEther(SLIPPAGE.toString());

    // call buyFromParlay method on Parlay AMM contract
    const tx = await parlayAMM.buyFromParlay(
      MARKETS,
      POSITIONS,
      parsedBuyInAmount,
      parsedSlippage,
      parsedPayout,
      ZERO_ADDRESS,
      {
        type: 2,
        maxPriorityFeePerGas: w3utils.toWei("0.00000000000000001"),
      }
    );
    // wait for the result
    const txResult = await tx.wait();
    console.log(
      `Successfully bought from Parlay AMM. Transaction hash: ${txResult.transactionHash}`
    );
  } catch (e) {
    console.log("Failed to buy from Parlay AMM", e);
  }
};

buyFromParlay();
```


# Introduction to Thales Digital Options

Digital Options allow traders to profit from correct predictions on the future price of an asset. They are based on a statement with only two possible outcomes – yes or no – and enable you to speculate on the likelihood of the event occurring before the option expires.

Digital options work by offering two possible outcomes from any given trade: if your prediction is correct, you generate a profit. If you’re incorrect, you lose premium paid. The maximum potential profit or loss are defined before the trade is placed. These maximum amounts depend on factors like the premium you pay, distance to strike price, distance to strike date and the volatility index of the underlying asset.

{% hint style="info" %}
Example of a Digital Option market:\
\
Market: Will the price of <mark style="color:orange;">Bitcoin</mark> be <mark style="color:green;">**UP**</mark> or <mark style="color:red;">**DOWN**</mark> from **$50,000** on January 1st 2025 08:00UTC?

Price per <mark style="color:green;">UP</mark> option: `$0.53` ( Potential profit +88.6%)\
Price per <mark style="color:red;">DOWN</mark> option `$0.47` (Potential profit +112.7%)

* If Bitcoin is ABOVE $50,000 on January 1st 2025 08:00UTC, each <mark style="color:green;">**UP**</mark> option purchased will be worth `$1` from initial `0.53$`, netting +88.6% profit. Every <mark style="color:red;">DOWN</mark> option will be worth `$0`.
* If Bitcoin is ABOVE $50,000 on January 1st 2025 08:00UTC, each <mark style="color:red;">DOWN</mark> option will be worth `$1` from initial `0.47$`, netting +112.7% profit. Every <mark style="color:green;">**UP**</mark> option will be worth `$0`.
  {% endhint %}

Benefits of Digital Options:

* **Easy to understand** and relatable model.
* Limited risk environment with **capped downside** (no risk of liquidation on long calls).
* Near expiry a great amount of **leverage.**
* **Flexibility** to choose Strike Price and Strike Date.
* Potential max losses known before executing the trade, allows for easy risk management.

Thales Digital Options use this concept to provide permissionless, fully collateralized, non-custodial on-chain Digital Options trading experience.&#x20;

Thales provides simple UP/DOWN options as well as IN/OUT price range Digital Options.\
The underlying Thales AMM offers on-demand liquidity for these options by using distance to strike price, distance to strike date and the volatility index variables of each market to algorithmically price the options.&#x20;


# Mechanics of Tokenized Digital Options

Each UP, DOWN, IN or OUT options on Thales are represented by ERC20 tokens:

* **UP** tokens ensure your payout if an outcome resolves **positively**&#x20;
* **DOWN** tokens ensure your payout if an outcome resolves **negatively**
* **IN** tokens ensure your payout if a range market outcome resolves **inside the range**
* **OUT** tokens ensure your payout if a range market outcome resolves **outside the range**

Each specific market on Thales is a dedicated market Smart Contract and is 100% collateralized by USD.  Once this collateral is locked into the market’s smart contract, Positional Tokens are minted and made available for interested traders via the Automated Market Maker (AMM). **Every 1 USD locked into a Market Smart Contract mints 1 of each Positional Tokens (e.g. 1 USD -> 1 UP token + 1 DOWN token).**

See the [Using the Thales AMM](broken://pages/tICTqipiIZSnDHbwRq1h) page for more info.

**Each USD collateralizes one UP token and one DOWN token.** The winning side of the market will have the ability to redeem their Positional Tokens in a 1:1 ratio for the USD collateral added to the pool, while the Positional Tokens of the losing side will become worthless and cannot be redeemed.

{% hint style="info" %}
By holding an <mark style="color:green;">**UP**</mark> ERC20 token from a specific market in your wallet, that token represents a claim for **1$** from that market contract, in case the market resolves as <mark style="color:green;">**UP**</mark> at the Strike Date.

By holding an <mark style="color:red;">**DOWN**</mark> ERC20 token from a specific market in your wallet, that token represents a claim for **1$ f**rom that market contract in case the market resolves as <mark style="color:red;">**DOWN**</mark> at the Strike Date.

**Only one of these two tokens can claim the 1$ on Strike Date, while the other will be deemed worthless.**
{% endhint %}

## Tokenized Ranged Markets

Ranged Markets is a product built on top of the Thales protocol that allows users to participate in markets around the following question:

#### **Will a specific Asset Price be INSIDE or OUTSIDE of the specified Price Range at the specified Maturity Date?**

![](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2Ff0UF902PdXcPoxETuIon%2Franged%20markets.PNG?alt=media\&token=ec9a77d0-e0ba-401c-a7c6-7bc832cf6e54)

Ranged Markets use the same framework as Positional Markets, but they use a **Price Range** instead of a single Strike Price, to resolve the market.&#x20;

Variables that define a Ranged Market:

* **Asset**- The specific asset used to resolve a market based on it's price (e.g. BTC, ETH, etc.).
* **Maturity Date**- The date and time at which the current price of the asset is compared to the market's Price Range to determine if the Ranged Market resolved IN or OUT.
* **Strike Range**- The range between two price points that traders use to position INSIDE or OUTSIDE of for that market.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FxwYUyU5OwIGdc5d0JVOV%2Fimage.png?alt=media&#x26;token=53572b20-1de8-4512-9500-2a4adad8dd5b" alt=""><figcaption><p>Ranged Market example</p></figcaption></figure>

### IN and OUT Tokens

Instead of having a single Strike Price with accompanying UP and DOWN tokens, **Ranged Markets have two Strike Prices that construct a Price Range and are accompanied with IN and OUT ERC20 tokens that represent the two exclusive outcomes of that Ranged Market.**

Ranged Markets use the Thales AMM contract to offer on-demand liquidity for **IN** and **OUT** tokens. It uses the already existing adapted Black Scholes algorithm to calculate the probability between 0% and 100% of a certain Ranged Market finishing INSIDE or OUTSIDE of a specified Price Range at the specified Maturity Date, and then uses that calculated probability to price the IN and OUT tokens.

For example, if the AMM calculates the probability of the specific Ranged Market finishing OUTSIDE of the specified Price Range to be **`25%`**, the AMM will sell the **OUT** tokens representing that position for **`$0.25`**, reflecting the probability percentage. On the other side, the probability that the market will resolve INSIDE the specified Price Range will be equal to **`100% - XX%`,** where XX% represents the probability of the market resolving OUTSIDE. This means that the **IN** token representing that INSIDE position, will be priced by the AMM as **`$1.00 - $0.25 = $0.75`**

If a specific Ranged Market resolves **INSIDE** the specified Price Range at the specified Maturity Date, the **IN** tokens will be **redeemable for USD in a 1:1 ratio** while the OUT tokens will be worthless.&#x20;

If a specific Ranged Market resolves **OUTSIDE** the specified Price Range at the specified Maturity Date, the **OUT** tokens will be **redeemable for USD in a 1:1 ratio** while the IN tokens will be worthless.&#x20;

### Ranged Markets Creation

Thales Ranged Markets use the available Positional Markets to form Price Ranges around their individual Strike Prices. That means that every two Positional Markets with the same Asset and Maturity Date will also create a Ranged Market around their respective individual Strike Prices.&#x20;

The collateralization of Ranged Markets comes from underlying Positional Markets that create the Ranged Market. T**his implies that the volume driven by Ranged Markets will subsequently also drive volume of the underlying Positional Markets that the Ranged Markets are created around.**

{% hint style="info" %}
**The Ranged Markets AMM does not have a dedicated Skew Impact mechanism. They actually inherit the Skew Impact from the underlying Positional Markets that create it.**
{% endhint %}

### Potential Payout Example

For the sake of demonstrating a profitable trade using Ranged Markets, let's take the following Ranged Market:

* **Asset:** BTC
* **Strike Range:** $25,000< --- >$35,000
* **Time until Maturity:** 11 weeks
* **Current BTC Price:** $29,081.47

With these variables, the Thales AMM prices the **IN** and **OUT** tokens of this market at:

**IN = 0.417 USD**

**OUT = 0.720 USD**

{% hint style="warning" %}
Ranged Market Tokens have a slightly higher premium because of the fact they are created by two individual Positional Markets.

Skew Impact of each of the two Positional Market that create a Ranged Market is compounded in the respective Ranged Market they create.
{% endhint %}

Let's say a trader has 1000 USD and wants to acquire a position stating that the price of BTC will remain between $25,000 and $35,000 in 11 weeks from now.&#x20;

This trader then uses the **1000 USD** to purchase exactly **2398 IN tokens** from the Ranged Markets AMM, since the AMM algorithm offers the IN tokens to buyers at 0.417 USD per token.

If in 11 weeks (at the Maturity Date) the price of BTC remains between $25,000 and $35,000, our trader will be able to exercise (redeem) his **IN** tokens (that they acquired for 0.417 USD per token) for 1 USD per IN token. Which means his 2398 IN tokens will be worth exactly 2398 USD, providing them with a **profit of 1398 USD on the initial 1000 USD investment.**

If BTC does not remain between $25,000 and $35,000, the **OUT** tokens (that were priced at 0.720 USD) for this Ranged Markets will be worth 1 USD each, and the **IN** tokens would be worth 0.


# How Thales AMM works

To offer guaranteed liquidity and negate the shortcomings of the Constant Function Market Maker (CFMM) model, Thales has built a completely novel AMM (Automated Market Maker) contract tailored specifically to offer users on-demand liquidity of Positional Tokens from Positional Markets in the trading phase.

**For crypto markets, Thales AMM uses a Black–Scholes pricing algorithm in combination with spread and price impact logic to derive an accurate price for each UP, DOWN, IN and OUT     ERC-20 token which is ultimately based on the odds of success for each outcome.**

{% hint style="info" %}

#### ***Orderbook trading-> Peer versus Peer***

#### ***CFMM trading -> Peer versus Market Maker pool***

#### ***THALES AMM -> Peer versus Market Maker** until someone takes the other side, then it becomes **Peer versus Peer** where the AMM delegates risk to competing peers.*

{% endhint %}

### Thales AMM Mechanism

Thales' AMM uses the [Black–Scholes algorithm](https://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model) to derive a realistic price for each Positional Token available within a Positional Market.&#x20;

The Thales AMM algorithm uses the following data inputs to price Positional Tokens:

* Current Asset Price - Chainlink provided price feeds
* Distance to Strike Price - Current distance to Strike Price precondition set on Market Creation
* Distance to Strike Date - Current distance to Strike Date precondition set on Market Creation
* Implied Market Volatility - Current Implied Volatility of an asset is manually updated for each contract on a daily basis until Chainlink Implied Volatility feeds are available on-chain. BTC and ETH Implied Volatility numbers are derived from Deribit's Orderbook `Ask IV` metrics for the nearest Friday expiries. Any other offering's Implied Volatility is derived by superimposing the Implied Volatility of ETH on a difference of 15 Day Historical Volatility between ETH and the asset in question.

In addition to these inputs, the Thales AMM also uses novel inputs to offset the risk the AMM takes on when offering on-demand liquidity on both ends of a Positional Market. These inputs are:&#x20;

* `min_spread` - Minimum price impact possible on a derived price for a trade using Thales AMM
* `max_spread` - Maximum price impact possible on a derived price for a trade using Thales AMM (in case a trade depletes all liquidity for a certain side of the AMM)

These last two parameters introduce a **Skew** mechanism that serves as an incentive to keep the AMM liquidity balanced between UP and DOWN sides of a market. The Skew makes "overbought" Positional Tokens more expensive than the opposite side of the market, keeping the AMM in balance and unexposed to the risk of a market maturing in an unfavorable direction for the AMM.

Additional safety mechanisms that are introduced are **Cap per Market** and **Price Range Limits.**

* **Risk Cap per Market** is introduced for the first iteration of the AMM to keep the AMM's exposure to individual markets limited. It is denominated in how much USD per market the AMM is risking.
* **Price Range Limits** are set to a range between **0.08 USD <-> 0.95** USD per Positional Token to avoid potential edge cases in large market swings and front-running instances.&#x20;

{% hint style="danger" %}
**Important disclaimer:** AMM trading is disabled 24 hours before a Market matures since the pricing algorithm cannot provide optimal results in such short timeframes up until Market Maturity. This could lead to potential front-running opportunities and edge-case exploits.
{% endhint %}

The Thales AMM uses a single liquidity pool to support multiple individual markets with on-demand liquidity. The risk cap and skew impact allows the AMM to **market-make in units of risk** rather than token prices. This means that the AMM has theoretically **unlimited capital efficiency** so long as the risk exposure of a pool remains within the risk cap.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FmdI8L7q11ZpMmOy5LjHd%2Fskew1.PNG?alt=media&#x26;token=acd1d262-ada8-4ee4-85ff-1cbfaf3bc65a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FnIGhFOlyyRQt7nV9xSqY%2Fskew2.PNG?alt=media&#x26;token=e56de6fb-059e-4437-a657-d335d35c4a3d" alt=""><figcaption></figcaption></figure>

## UNDERSTAND THE RISKS

{% hint style="danger" %}
If your purchased Positional Tokens **do not win** on Market Maturity, **they are deemed worthless** (your losing positions are worth 0)**.**
{% endhint %}

{% hint style="warning" %}
The Thales AMM accepts BUYS and SELLS at all times for individual markets, **with exceptions when certain configurable limits have been reached.**

There might be instances where your Positions you've purchased can’t be sold back to the AMM and **you have to wait for Market Maturity to finalize your positions.**
{% endhint %}

### Thales AMM on-demand liquidity limits:

1. **Odds pricing limit:** The AMM only offers liquidity if the Implied Odds of a position are between 8% and 95%, or in other words if UP and DOWN token prices are between $0.08 and $0.95 (see [TIP-107](https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-107.md) for specifications). If the market movement takes these metrics outside of the specified range, the AMM stops offering liquidity for the respective market.
2. **Time limit:** The AMM only offers liquidity for a specific market until 24 hours before Market Maturity. After the market crosses the 24rth hour before maturity, the AMM stops offering liquidity for that market.
3. **Cap limit:** The AMM only offers liquidity for a limited amount of UP, DOWN, IN and OUT tokens for specific markets based on the amount of risk the AMM takes on from a specific market.

{% hint style="warning" %}
**Exercising your winnings is not influenced by the current AMM liquidity in any way!**
{% endhint %}

### Your winning Positional Tokens will always be redeemable for USD winnings on Market Maturity!


# Digital Options Liquidity Providing

The Thales AMM has proven it's reliability by handling thousands of transactions that have generated millions in volume, so it's finally time to allow users to take part in liquidity provisioning for the Thales AMM. &#x20;

Anyone is able to provide liquidity for the Thales AMM and gain exposure to the AMM's performance. Liquidity Provisioning is available on the **Optimism Network** , **Arbitrum Network** and **Base**  **with sUSD** used as collateral on Optimism, with **USDC.e used on Arbitrum and USDbC on Base.**

You can take part by visiting [**https://thalesmarket.io/liquidity-pool**](<https://thalesmarket.io/liquidity-pool  >)

## How does Providing Liquidity for the Thales AMM work?

Liquidity Provisioning is the process of providing collateral to a protocol that can then use this collateral to execute trades. This is done by acting as a counterparty to traders by providing collateral to back these trades and is then used to payout successful traders.&#x20;

You can see all the details for providing liquidity for the AMM in [TIP-139](https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-139.md).

{% hint style="info" %}
LP deposits count towards your wallet’s gamified THALES staking rewards as protocol generated volume.  Since gamified THALES staking counts volume over a running 4 week timeframe, 100 USD deposited (assuming no change in the AMM’s performance) would equate to 100 USD per week or a total of 400 USD of protocol volume towards gamified staking.
{% endhint %}

#### Deposit and Withdrawal Mechanics

Deposits are entered in 1 week long rounds so Profit and Loss (PnL) can be calculated.  Traders can make a deposit and their collateral will be queued up to enter the upcoming round. Deposits and withdrawals need to be signaled on the UI and will be performed at the start of the next round.&#x20;

When a round ends, the AMM's performance from all markets in that round is summed up, and allocated to all liquidity providers proportional to their share of the pool.&#x20;

* Each LP-ing round lasts **7 days**.
* Users can deposit at any time during any round. The deposited funds will be utilized as collateral in the AMM starting with the next round from time of depositing.
* The minimum deposit is **100 USD.**
* A maximum of **100 users** can enter the pool at one time.
* The maximum amount of USD you can deposit is the number of your **staked THALES divided by 5.**
* Funds roll over to the next round automatically until a withdrawal is signaled.
* User can signal a withdrawal at any time during any round. **Withdrawals are limited to no less than 10% of your total deposit.**
* The funds that are signaled for withdrawal will be unlocked at the start of the next round from time of signaling.&#x20;

{% hint style="danger" %}
**If you signal a withdrawal, your funds will still be exposed as collateral for the duration of the ongoing round and will only be removed as AMM collateral when the round ends.**
{% endhint %}

#### Risks of Providing Liquidity to the Thales AMM

Providing liquidity exposes you to various risks including potential losses due to users winning in trading as well as smart contract security risks. Please make sure you understand these risks before depositing.

Liquidity Provisioning is capped to limit exposure for depositors.  In the event that the AMM performs in an unexpected way these caps limit the potential downside experienced by depositors. &#x20;

Caps are updated via the governance process, where stakers can vote to elect council members every 6 months.  These council members then vote on community submitted TIPs (Thales Improvement Proposals that act as changes to the protocol) and once approved the Protocol DAO can execute these changes.

{% hint style="info" %}
20% of each profitable round will be sent to the contract accruing protocol fees and will be distributed to stakers on each weekly staking claim
{% endhint %}


# Digital Options Integration

## Thales API

In order to ensure easy integration with external partners Thales API is created. API returns all main data available on Thales. Using Thales API endpoints someone can get data about:

* Thales collaterals
* Thales markets
* Thales market
* User Thales positions
* User Thales transactions
* Buy quote
* Sell quote

More details about each API endpoint with request/response examples can be found under [Postman documentation](https://documenter.getpostman.com/view/1435701/2s9YRDzqmS).

## Contract integration

Once all data are fetched from API, the next step is integration with Thales contracts. Depending on whether someone wants to buy a position on Digital Options or Ranged Markets integration should be done with **ThalesAMM** or **RangedAMM** contract.&#x20;

The next sections describe integration with Thales API and Thales contracts together with JS code examples.

### Buy a UP/DOWN position&#x20;

Let's say someone wants to buy **UP** positional tokens on the **BTC** market with a strike price of **35000** on **7th November 2023** with a buy-in amount of **100 sUSD.**

1. Get a buy quote for the market from Thales API&#x20;
2. Get a Thales AMM contract address for a specific network from [Thales contracts](https://contracts.thalesmarket.io/)
3. Get a Thales AMM contract ABI from Thales contract repository [contract repository](https://github.com/thales-markets/contracts/blob/main/scripts/abi/ThalesAMM.json)
4. Create Thales AMM contract instance
5. Call `buyFromAmm` method on Thales AMM contract with input parameters fetched from Thales API in step #1

The JS code snippet below implements these steps:

```javascript
import { ethers } from "ethers";
import w3utils from "web3-utils";
import axios from "axios";
import dotenv from "dotenv";
import ammContractAbi from "./ammContractAbi.js"; // ThalesAMM contract ABI

dotenv.config();

const API_URL = "https://overtimemarketsv2.xyz"; // base API URL
const NETWORK_ID = 10; // optimism network ID
const NETWORK = "optimism"; // optimism network
const AMM_CONTRACT_ADDRESS = "0x278B5A44397c9D8E52743fEdec263c4760dc1A1A"; // ThalesAMM contract address on optimism
const MARKET_ADDRESS = "0x150Faf51367770DEfF9e004773B73A9387d9EB58"; // address of BTC market with strike price 35000 at 2023-11-07
const POSITION = 0; // select UP position
const BUY_IN = 100; // 100 sUSD
const SLIPPAGE = 0.02; // slippage 2%

// create instance of Infura provider for optimism network
const provider = new ethers.providers.InfuraProvider(
  { chainId: Number(NETWORK_ID), name: NETWORK },
  process.env.INFURA
);

// create wallet instance for provided private key and provider
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);

// create instance of Thales AMM contract
const amm = new ethers.Contract(AMM_CONTRACT_ADDRESS, ammContractAbi, wallet);

const buyFromAmm = async () => {
  try {
    // get a buy quote from Thales API for provided market, position and buy-in amount on optimism network
    const quoteResponse = await axios.get(
      `${API_URL}/thales/networks/${NETWORK_ID}/markets/${MARKET_ADDRESS}/buy-quote?position=${POSITION}&buyIn=${BUY_IN}`
    );
    const quoteData = quoteResponse.data;
    console.log("Quote data", quoteData);

    // convert payout got from API to BigNumber
    const parsedPayout = ethers.utils.parseEther(quoteData.payout.toString());
    // convert actual buy-in amount got from API to BigNumber
    // actualBuyInCollateralAmount is different from BUY_IN due to the contract architecture having positions amount as input and not buy-in amount
    const parsedActualBuyInCollateralAmount = ethers.utils.parseEther(
      quoteData.actualBuyInCollateralAmount.toString()
    );
    // convert slippage tolerance to BigNumber
    const parsedSlippage = ethers.utils.parseEther(SLIPPAGE.toString());

    // call buyFromAMM method on Thales AMM contract
    const tx = await amm.buyFromAMM(
      MARKET_ADDRESS,
      POSITION,
      parsedPayout,
      parsedActualBuyInCollateralAmount,
      parsedSlippage,
      {
        type: 2,
        maxPriorityFeePerGas: w3utils.toWei("0.00000000000000001"),
      }
    );
    // wait for the result
    const txResult = await tx.wait();
    console.log(
      `Successfully bought from AMM. Transaction hash: ${txResult.transactionHash}`
    );
  } catch (e) {
    console.log("Failed to buy from AMM", e);
  }
};

buyFromAmm();

```

### Buy a IN/OUT position

Let's say someone wants to buy **IN** positional tokens on the **BTC** market with a range **34000-38000** on **7th November 2023** with a buy-in amount of **100 sUSD.**

Integration with Thales API and Ranged AMM contract should include the following steps:

1. Get a buy quote for the market from Thales API&#x20;
2. Get a Ranged AMM contract address for a specific network from [Thales contracts](https://contracts.thalesmarket.io/)
3. Get a Ranged AMM contract ABI from Thales contract repository [contract repository](https://github.com/thales-markets/contracts/blob/main/scripts/abi/RangedMarketsAMM.json)
4. Create Ranged AMM contract instance
5. Call `buyFromAmm` method on Ranged AMM contract with input parameters fetched from Thales API in step #1

The JS code snippet below implements these steps:

```javascript
import { ethers } from "ethers";
import w3utils from "web3-utils";
import axios from "axios";
import dotenv from "dotenv";
import rangedAmmContractAbi from "./rangedAmmContractAbi.js"; // RangedAMM contract ABI

dotenv.config();

const API_URL = "https://overtimemarketsv2.xyz"; // base API URL
const NETWORK_ID = 10; // optimism network ID
const NETWORK = "optimism"; // optimism network
const RANGED_AMM_CONTRACT_ADDRESS =
  "0x2d356b114cbCA8DEFf2d8783EAc2a5A5324fE1dF"; // RangedAMM contract address on optimism
const MARKET_ADDRESS = "0x5a268e454D7877F73531b54FF81Cd0C329C4b97e"; // address of BTC market with range 34000-38000 at 2023-11-07
const POSITION = 1; // select OUT position
const BUY_IN = 100; // 100 sUSD
const SLIPPAGE = 0.02; // slippage 2%

// create instance of Infura provider for optimism network
const provider = new ethers.providers.InfuraProvider(
  { chainId: Number(NETWORK_ID), name: NETWORK },
  process.env.INFURA
);

// create wallet instance for provided private key and provider
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);

// create instance of Ranged AMM contract
const rangedAMM = new ethers.Contract(
  RANGED_AMM_CONTRACT_ADDRESS,
  rangedAmmContractAbi,
  wallet
);

const buyFromRangedAmm = async () => {
  try {
    // get a buy quote from Thales API for provided market, position and buy-in amount on optimism network
    const quoteResponse = await axios.get(
      `${API_URL}/thales/networks/${NETWORK_ID}/markets/${MARKET_ADDRESS}/buy-quote?position=${POSITION}&buyIn=${BUY_IN}`
    );
    const quoteData = quoteResponse.data;
    console.log("Quote data", quoteData);

    // convert payout got from API to BigNumber
    const parsedPayout = ethers.utils.parseEther(quoteData.payout.toString());
    // convert actual buy-in amount got from API to BigNumber
    // actualBuyInCollateralAmount is different from BUY_IN due to the contract architecture having positions amount as input and not buy-in amount
    const parsedActualBuyInCollateralAmount = ethers.utils.parseEther(
      quoteData.actualBuyInCollateralAmount.toString()
    );
    // convert slippage tolerance to BigNumber
    const parsedSlippage = ethers.utils.parseEther(SLIPPAGE.toString());

    // call buyFromAMM method on Ranged AMM contract
    const tx = await rangedAMM.buyFromAMM(
      MARKET_ADDRESS,
      POSITION,
      parsedPayout,
      parsedActualBuyInCollateralAmount,
      parsedSlippage,
      {
        type: 2,
        maxPriorityFeePerGas: w3utils.toWei("0.00000000000000001"),
      }
    );
    // wait for the result
    const txResult = await tx.wait();
    console.log(
      `Successfully bought from Ranged AMM. Transaction hash: ${txResult.transactionHash}`
    );
  } catch (e) {
    console.log("Failed to buy from Ranged AMM", e);
  }
};

buyFromRangedAmm();
```


# Introduction to Speed Markets

Positional Markets get kicked into overdrive with the **fast-paced excitement of Speed Markets!**  Speed Markets allow users to purchase UP or DOWN positions in **positional markets built on short time frames** and **strike prices based on a snapshot of the current price**.  This new product under the Thales umbrella is the result of [TIP-149](https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-149.md) and the communities' need for speed!

{% hint style="info" %}
Speed Markets are currently available on:

**Optimism, Arbitrum, Polygon, Base and ZkSync**
{% endhint %}

### How Speed Markets work

Typical Positional and Ranged Markets close for positioning when the maturity date/time is less than 24 hours away due to protocol risk management, but some traders couldn't wait on the sidelines for that long.  To satisfy the community Thales developed Speed Markets to **work with nearly instantaneous pricing data**, made possible with the use of [Pyth Benchmarks](https://pyth.network/blog/introducing-the-pyth-benchmarks).&#x20;

Traders choose an asset, direction (UP or DOWN) and strike time for that asset based on the trader's predicted price movement from the asset's current price.  Once a trader submits a transaction to purchase a position, a snapshot of the asset's current price is taken to define the strike price. Because the strike price is always taken from the current price of an asset at the time of a buy, **all positions will have 50:50 implied probabilities**. This means that **a winning trader will see a 2x payout** (minus the quoted LP fee and a fixed 2% Safebox fee) on a single winning position.&#x20;

{% hint style="info" %}
Since every position has equal **50:50 odds** regardless of any variable, there is no need for algorithmic pricing based on Implied Volatility index.  This makes Speed Markets product more immutable, decentralized and lightweight.
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FRaSWWdJwbhQeaoGrW6uG%2F1_yAsLfNWNKfoZSWy2SpSWtg.gif?alt=media&token=56953512-174f-495e-8ff8-1670dae608c4>" %}

Pyth Benchmark on-demand oracles provide historically queryable prices that can be used to validate trades in near real-time, an important factor for risk management of intraday markets such as Speed Markets.  **Every second, Pyth Benchmark price feeds are updated** using source data from reputable third-party data publishers that can be easily verified from the Pythnet blockchain. &#x20;

In the future, Thales plans to further develop this product and to couple it with the [consecutive round format of Thales Royale](https://thalesmarket.medium.com/thales-royale-a-predictions-game-where-the-winner-s-takes-all-a268f9ec6ec8) to facilitate sequential epochs. Once this feature is deployed it will give traders the ability to **compound a winning position into the next epoch(s) automatically.**

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FRaBCHJhdsJqzX3kRoZQm%2Fimage.png?alt=media&token=206b0a2c-1a6e-4139-a871-bc1d1a2d704d>" %}

### Parameters for Speed Markets&#x20;

The parameters for Speed Markets will be maintained via the Governance process. Configuration TIPs for considerations like opening the SpeedMarketAMM up for LPing will need to be submitted by the community and voted in by the Thales Council.  Initial funding will be provided by the TreasuryDAO, but future LPing could take it's place to provide liquidity for Speed Markets. &#x20;

* **Volume generated on Speed Markets will count towards gamified staking rewards**.
* Speed Markets offer a **minimum epoch of 15 minutes**, but the goal is to offer epochs as short at 5 minutes in the future.
* The maximum time to maturity will be 24 hours. &#x20;
* ETH and BTC will be the supported assets, with expansion to more assets planned in the future.
* Speed Markets will include an LP fee that changes depending of a Strike Time and a protocol fee of 2%.

| Strike Time             | LP fee |
| ----------------------- | ------ |
| 10 min - 14 min 59s     | 15%    |
| 15 min - 59 min 59 sec  | 13%    |
| 60 min - 119 min 59 sec | 12%    |
| 120 min - 24 h          | 10%    |

* The minimum buy-in will be 5 USD, with a maximum of 200 USD (but both can be changed).
* The AMM Risk Cap per Asset per Day will begin at 5000 USD.

Positions can be purchased using the several forms of collateral, with the minimum amount of each adjusted to equal 5 USDC.  The following forms of collateral are accepted:

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FBumbqmPN4BNJ9rxleI2T%2Fimage.png?alt=media&token=ad4ff1f7-c68b-46d1-8836-32f8d035318c>" %}

{% hint style="info" %}
Speed Markets on Optimism, Arbitrum and Base also support Multicollateral offramping, meaning you can choose the form of collateral you'd like to receive when claiming a winning position.
{% endhint %}

Eventually, Speed Markets will allow traders to string together several speed markets (like a parlay) for a leveraged payout.  For example, if a trader is able to select the correct direction for 5 epochs in a row, their winnings would approach 32x (2x + 2x + 2x + 2x + 2x) of their initial buy-in.&#x20;

Other features, such as supporting referral bonuses or multi-collateral purchasing can also be added via future TIPs. &#x20;


# Chained Speed Markets

### What are Chained Speed Markets

Chained Speed Markets are the next evolution of classic [Speed Markets](broken://pages/VJlcZffVBcJqE05GLW4e), allowing you to predict multiple sequential price movements in one go for explosive leveraged payouts up to **47x** !

Chained Speed Markets allow you to create a series of **2** to **6 sequential price predictions** with a fixed Strike Time each and with an increasing payout multiplier per each added market. This product has also been voted in by the Thales Governance, under the [TIP-174 Chained Speed Markets](https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-174.md)

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FEFyDaKNJzBcFW9izzw17%2Fimage.png?alt=media&token=06367dc6-fced-4c8c-8c6c-70f594067c6e>" %}

### How Chained Markets work

#### Deposit and Engage

With [Speed Markets](broken://pages/VJlcZffVBcJqE05GLW4e), we allowed the users to bypass the limitations of the classic crypto trading markets. They could now trade short term markets, and not really worry about maturity dates. However, the Speed markets had a different limitation - in one trade, you could at most double your position. In order to accommodate the needs of users looking for a **more leveraged exposure**, we created Chained Speed Markets.

Users can initiate their Chain Speed Markets journey by depositing a modest $5, unlocking a world of strategic trading possibilities. The player then selects the number of rounds, ranging from **2 to 6**, with each round swiftly lasting 10 minutes.

#### Precision

At the deposit stage, traders can show their **strategic thinking and analytical skills**, predicting whether the price of the chosen asset will be above or below its initial value at the **conclusion of each 5 or 10-minute round**. The users are required to submit **all predictions** for the selected rounds at the time of deposit. Once set, these **predictions are immutable and cannot be altered.**

Success in each round means advancement to the next, with the potential for multiplied returns. However, an **incorrect prediction at any stage** results in the loss of the initial $10 deposit. The challenge lies in maintaining accuracy across **all selected rounds.**

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2F1mCPWHn2UWDL4WYS9QLa%2Fimage.png?alt=media&token=514b2b50-f0fe-43ea-942d-8308b05dfacd>" %}

With an increasing multiplier for each correctly predicted round, ranging from 1.7 for  the second round, up to 1.9 for 6 rounds, the excitement intensifies as traders witness their potential returns grow. For instance, a 2-round chained market boasts a thrilling 2.89x payoff if both rounds are picked successfully (up to 47x for 6 rounds )

#### Powered by Pyth Network

Chained Speed Markets leverage the power of [Pyth Benchmark](https://pyth.network/benchmarks) on-demand oracles, offering historically queryable prices that validate trades in **near real-time**. These oracles play a crucial role in risk management for intraday markets like Speed (and Chained) Markets. Pyth Benchmark price feeds are updated every second using source data from reputable third-party publishers, providing **verifiable transparency** through the Pythnet blockchain.

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2Ff2j3Y4HONFAgkdRdB9cG%2F1_nCi0HfWWX9qVBBXLuNRciQ.png?alt=media&token=f1ec173f-0449-4196-9fc9-7427296aac26>" %}

Chained Speed Markets represent a fusion of **speed, strategy, and multiplied** returns, offering traders an exhilarating platform to navigate the dynamic landscape of financial markets.&#x20;

### Chained Markets parameters

The parameters for  **Chained Speed Markets** will be maintained via the Governance process. Configuration TIPs for considerations like opening the **ChainedSpeedMarketAMM** up for LPing will need to be submitted by the community and voted in by the Thales Council.  Initial funding will be provided by the TreasuryDAO, but future LPing could take it's place to provide liquidity for Speed Markets. &#x20;

* **Volume generated on  Chained Speed Markets will count towards gamified staking rewards**.
* Chained Speed Markets currently offer **5 and** **10 minute rounds**, but there might be other options in the future
* **ETH and BTC** will be the supported assets, with expansion to more assets planned in the future.
* Speed Markets will include a **SafeBox** fee of **2%**.
* The number of round can be between **2 and 6**
* The multiplier starts from **2.89x** for two markets, with a max **47x for 6 rounds**
* The minimum buy-in will be **5 USD,** with a maximum of **10 USD** (but both can be changed).
* The AMM Risk Cap per Day will begin at 10.000 USD.

Positions can be purchased using the several forms of collateral, with the minimum amount of each adjusted to equal 5 USDC.  The following forms of collateral are accepted:

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FD9Hoe5Vcu6NiwwiHsijg%2Fimage.png?alt=media&token=808cdde6-b67c-46fb-932b-12976c00c338>" %}

{% hint style="info" %}
Speed Markets on **Optimism**, **Arbitrum** and Base also support **Multicollateral** **offramping**, meaning you can choose the form of collateral you'd like to receive when claiming a winning position.
{% endhint %}


# Speed Markets Integration

## Speed Markets API

In order to ensure easy integration with external partners Speed Markets API is created. API returns all required data to interact with Speed Markets AMM contract. Using Speed Markets API endpoints someone can get data about:

* Buy
* User claimable markets
* Resolve markets (single or multiple markets)
* Resolve market with different collateral (single market)

More details about each API endpoint with request/response examples can be found under [Postman documentation](https://documenter.getpostman.com/view/2415538/2sA358e6Hi#d2c04294-f5d5-4afb-a0c8-a3ceb9f07c59).

## Contract integration

Once all data are fetched from API, the next step is integration with Speed Markets contract. Depending on whether someone wants to buy a position or resolve a market (claim win) integration should be done with Speed Markets AMM contract.

The next sections describe integration with Speed Markets API and Speed Markets contract together with JS code examples.

### Buy a UP/DOWN position

Let's say someone wants to buy **UP** position on the **BTC** market with a current strike price ($ 63,622.56) in **10 minutes** from market creation and with a buy-in amount of **5 sUSD:**

<figure><img src="https://docs.thalesmarket.io/~gitbook/image?url=https:%2F%2F288840232-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FKSZyDhrhMxBqaXew1MHD%252Fuploads%252Ft73JSZxCV7BP6QM2WD3A%252Fbuy.png%3Falt=media%26token=aa214f54-d258-404e-8960-fc847ff0a0aa&#x26;width=768&#x26;dpr=1&#x26;quality=100&#x26;sign=47dd6c40bcd853959b8a5ce41556a5d2bc904668994df42c2d68b65aa97a011a" alt=""><figcaption><p>Buy UP position for 5 sUSD on BTC in 10 min from creation</p></figcaption></figure>

Integration with Speed Markets API and Speed Markets AMM contract should include the following steps:

1. Get a buy parameters for the market from Speed Markets API
2. Get a Speed Markets AMM contract address for a specific network from [Thales contracts](https://contracts.thalesmarket.io/)
3. Get a Speed Markets AMM contract ABI from Speed Markets AMM [contract repository](https://github.com/thales-markets/contracts/blob/main/scripts/abi/SpeedMarketsAMM.json)
4. Create Speed Markets AMM contract instance
5. Call `createNewMarket` or `createNewMarketWithDifferentCollateral` method on  Speed Markets AMM contract with input parameters fetched from Speed Markets API in step #1

The JS code snippet below implements these steps:

```javascript
const ethers = require('ethers');
const fetch = require('node-fetch');
const dotenv = require('dotenv');

// SpeedMarketsAMM contract ABI
const { speedAMMContract } = require('./speedAmmContractAbi.js');

dotenv.config();

const API_URL = 'https://overtimemarketsv2.xyz'; // base API URL
const NETWORK_ID = 10; // optimism network ID
const NETWORK = 'optimism'; // optimism network
// SpeedMarketsAMM contract address on optimism
const AMM_CONTRACT_ADDRESS = '0xE16B8a01490835EC1e76bAbbB3Cadd8921b32001'; 

const ASSET = 'BTC';
const DIRECTION = 'UP';
const COLLATERAL = 'sUSD';
const BUY_IN = 5; // 5 sUSD
const DELTA_TIME = 600; // 10 min

// create instance of Infura provider for optimism network
const provider = new ethers.providers.InfuraProvider(
    { chainId: Number(NETWORK_ID), name: NETWORK },
    process.env.INFURA
);

// create wallet instance for provided private key and provider
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);

// create instance of Speed AMM contract
const speedAmm = new ethers.Contract(AMM_CONTRACT_ADDRESS, speedAMMContract.abi, wallet);

const createNewMarket = async () => {
    try {
        // Get contract method (createNewMarket/createNewMarketWithDifferentCollateral) parameters from Speed Markets API
        // for provided asset, direction, buy-in amount, collateral and delta time on optimism network
        const buyResponse = await fetch(
            `${API_URL}/speed-markets/networks/${NETWORK_ID}/buy/?asset=${ASSET}&direction=${DIRECTION}&buyin=${BUY_IN}&collateral=${COLLATERAL}&deltaTimeSec=${DELTA_TIME}`
        );

        const buyData = await buyResponse.json();
        console.log('Buy data', buyData);

        let tx;
        if (buyData.methodName == 'createNewMarketWithDifferentCollateral') {
            // call createNewMarketWithDifferentCollateral method on Speed Markets AMM contract
            tx = await speedAmm.createNewMarketWithDifferentCollateral(
                buyData.asset,
                buyData.strikeTime,
                buyData.delta,
                buyData.direction,
                buyData.priceUpdateData,
                buyData.collateral,
                buyData.collateralAmount,
                buyData.isEth,
                buyData.referrer,
                buyData.skewImpact,
                {
                    value: buyData.value,
                    type: 2,
                    maxPriorityFeePerGas: 10, // 10 wei
                }
            );
        } else {
            // call createNewMarket method on Speed Markets AMM contract
            tx = await speedAmm.createNewMarket(
                buyData.asset,
                buyData.strikeTime,
                buyData.delta,
                buyData.direction,
                buyData.buyinAmount,
                buyData.priceUpdateData,
                buyData.referrer,
                buyData.skewImpact,
                { value: buyData.value, type: 2, maxPriorityFeePerGas: 10 } // 10 wei
            );
        }

        // wait for the result
        const txResult = await tx.wait();
        console.log(`Successfully bought from Speed AMM. Transaction hash: ${txResult.transactionHash}`);
    } catch (e) {
        console.log('Failed to buy from Speed AMM', e);
    }
};

createNewMarket();
```

### Resolve market(s)

Let's say someone wants to **claim** winnings on two markets (resolve markets) in **sUSD**:

<figure><img src="https://docs.thalesmarket.io/~gitbook/image?url=https:%2F%2F288840232-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FKSZyDhrhMxBqaXew1MHD%252Fuploads%252FI6XsggxzwwH5I9G7k2VP%252Fclaim.png%3Falt=media%26token=39eac6bd-11c2-410a-9a16-b0a6f7edeefa&#x26;width=768&#x26;dpr=1&#x26;quality=100&#x26;sign=4e1abf17ed7dcef7663a592417157b6384158192ec6c7aec204c9d2641f090c5" alt=""><figcaption><p>Resolve (claim) two markets wins</p></figcaption></figure>

Integration with Speed Markets API and Speed Markets AMM contract should include the following steps:

1. Get a resolve parameters for the markets from Speed Markets API
2. Get a Speed Markets AMM contract address for a specific network from [Thales contracts](https://contracts.thalesmarket.io/)
3. Get a Speed Markets AMM contract ABI from Speed Markets AMM [contract repository](https://github.com/thales-markets/contracts/blob/main/scripts/abi/SpeedMarketsAMM.json)
4. Get a user claimable markets from Speed Markets API
5. Create Speed Markets AMM contract instance
6. Call `resolveMarketsBatch` method on  Speed Markets AMM contract with input parameters fetched from Speed Markets API in step #1

The JS code snippet below implements these steps:

```javascript
const ethers = require('ethers');
const fetch = require('node-fetch');
const dotenv = require('dotenv');
// SpeedMarketsAMM contract ABI
const { speedAMMContract } = require('./speedAmmContractAbi.js'); 

dotenv.config();

const API_URL = 'https://overtimemarketsv2.xyz'; // base API URL
const NETWORK_ID = 10; // optimism network ID
const NETWORK = 'optimism'; // optimism network
// SpeedMarketsAMM contract address on optimism
const AMM_CONTRACT_ADDRESS = '0xE16B8a01490835EC1e76bAbbB3Cadd8921b32001'; 

// Speed markets addresses to resolve
const MARKET_1 = '0x5ef786087d122b9056f351Cf3B52E5A7B0d5277D'; 
const MARKET_2 = '0x2542906FE4701A8c930427c2ff6Db1C948B91571';

// create instance of Infura provider for optimism network
const provider = new ethers.providers.InfuraProvider(
    { chainId: Number(NETWORK_ID), name: NETWORK },
    process.env.INFURA
);

// create wallet instance for provided private key and provider
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);

// create instance of Speed AMM contract
const speedAmm = new ethers.Contract(AMM_CONTRACT_ADDRESS, speedAMMContract.abi, wallet);

const resolveMarkets = async () => {
    try {
        // Get contract method (resolveMarketsBatch) parameters from Speed Markets API
        // for provided market address on optimism network
        const resolveResponse = await fetch(
            `${API_URL}/speed-markets/networks/${NETWORK_ID}/resolve?markets[]=${MARKET_1}&markets[]=${MARKET_2}`
        );

        const resolveData = await resolveResponse.json();
        console.log('Resolve data', resolveData);

        // call resolveMarketsBatch method on Speed Markets AMM contract
        const tx = await speedAmm.resolveMarketsBatch(
            resolveData.markets, 
            resolveData.priceUpdateData, 
            {
                value: resolveData.value,
                type: 2,
                maxPriorityFeePerGas: 10, // 10 wei
            }
        );

        // wait for the result
        const txResult = await tx.wait();
        console.log(`Successfully resolved market on Speed AMM. Transaction hash: ${txResult.transactionHash}`);
    } catch (e) {
        console.log('Failed to resolve market on Speed AMM', e);
    }
};

resolveMarkets();
```

### Resolve market with different collateral

If someone wants to **claim** winning in different collateral than default one for a network (resolve market) process is the same as previous one, just using appropriate API and contract method. Corresponding API is "Resolve market with different collateral" and contract method `resolveMarketWithOfframp.` Currently batch is not available for claim with different collateral.


# Speed Markets Trading Guide

How to use the Speed Markets dapp with full Account Abstraction

<figure><img src="/files/d6k2KSHvMYjRS7K3YWhH" alt=""><figcaption></figcaption></figure>

The brand new Speed Markets application offers seamless user experience paired with a lot of fun speculating short term crypto prices!\
\
This guide will help you navigate the dapp.

## Getting Started

To start using the Speed Markets dapp, the first step is to log in.

When visiting the dapp on the link [www.speedmarkets.xyz/speed-markets](https://docs.thales.io/thales-speed-markets/www.speedmarkets.xyz/speed-markets) you will be greeted with the **`Get Started`** menu.&#x20;

<figure><img src="/files/OKzcT7LJs0xECSapShby" alt=""><figcaption><p>Get Started menu</p></figcaption></figure>

The Get Started menu will guide you to onboard the dapp in three steps.

The first step is the `Sign up` step.&#x20;

Click on the `LOGIN` button, tick the Terms of Use checkbox and then click on the login method you want to use.

<figure><img src="/files/mGuxE6X5Frru5M0wH7j0" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
***Social Login*****&#x20;methods (Google, Twitter, Discord, Guthub, Apple etc.) generates a wallet for you via Particle Network, creates you a Smart Accounts and enables for a full Account Abstraction experience.** \
\
C*onnect with Wallet* method onboards you **without** a smart account with regular wallet connection.
{% endhint %}

If you logged in successfully with Social Login, you will unlock step 2 of the Get Started process: the **`Deposit funds`** step.

<figure><img src="/files/sJT2rm7szrCY6qhRxMaE" alt=""><figcaption></figcaption></figure>

Deposit funds in your Speed Markets smart account by sending USDT and/or USDC to the address generated for you. If you don't have USDT or USDC, you can also directly deposit them via Credit Card using the FUND WITH CARD button. [Click here for Deposit Tutorials.](/thales-speed-markets/speed-market-deposit-guides)

## Start Trading

After your Smart Account has funds deposited, you can start using the dapp!\
\
With Paymaster integrated in the backend, you don't have to worry about having an ETH balance for gas fees, so you can immediately start trading with a stablecoin deposit.

On the main dapp trading page, you'll see the price chart with a constantly-updating asset price, based on a data feed from Pyth Oracles. In the other corner of the chart you'll see the liquidity available for the chosen asset. Below the chart are different time frames and a summary of your position once the variables are selected.

<figure><img src="/files/9hQUaUIeDNdW5lMbhdBp" alt=""><figcaption></figcaption></figure>

**To create a position, first choose an asset (BTC or ETH) and a direction.**

This is the direction you think the price will have moved at the end of your selected time frame based on the current price **(at the time the purchase transaction is submitted).**

Next, **choose the position duration**, and then enter the dollar **amount** you'd like to purchase. You can either click on one of the prefilled dollar amount buttons, or enter your own amount in the custom input field.

<figure><img src="/files/8HK3GQVZvgHSwBSe780v" alt=""><figcaption></figcaption></figure>

After building your position with all the parameters above, click on the BUY button to confirm your trade!<br>

<figure><img src="/files/htjWBQEBGJvzwkP6T4mI" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
After confirming your first BUY with a Particle Wallet pop up signature, you also start a **Account Abstraction Session**.

\
After this, all subsequent transactions will require no signature or pop up confirmation. **You just click buttons and its confirmed!**
{% endhint %}

Your open positions will be visible on the bottom of the trading page. If your position is a winning one, you'll see the blue "Claim Win $XX.XX" button next to a winning position. Click on the button to complete the transaction and claim your payout!&#x20;

{% hint style="info" %}
You can also use the **`CLAIM ALL WINS`** button to batch all winning positions at once!
{% endhint %}

<figure><img src="/files/jH6sOiWKHGD51xtO2MUB" alt=""><figcaption></figcaption></figure>


# Speed Market Deposit Guides

Guides on how to deposit funds to your Speed Markets account and start trading!

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td></td><td><a href="/pages/pmRIGHAYZzj37xUcavti">Deposit USDC from Coinbase</a></td><td></td><td><a href="/files/8wlmHoOnyxFBdR8Erqog">/files/8wlmHoOnyxFBdR8Erqog</a></td></tr><tr><td></td><td><a href="/pages/aYKLf9qTQ1O4HPzkhgR2">Deposit from Binance Mobile App</a></td><td></td><td><a href="/files/7nJlWhKmWk6Q425tmG0v">/files/7nJlWhKmWk6Q425tmG0v</a></td></tr><tr><td><p></p><p><a href="/pages/PaGifPUNWxuqCgt5uc1i">Deposit from Binance Website</a></p></td><td></td><td></td><td><a href="/files/p8dWhY2aygU3Hcx6Wjm5">/files/p8dWhY2aygU3Hcx6Wjm5</a></td></tr></tbody></table>

***


# Deposit USDC from Coinbase

## **If you don’t have USDC on Coinbase** <a href="#block-0f9873169aa34fb683817303806dc44b" id="block-0f9873169aa34fb683817303806dc44b"></a>

**Step by step guide how to acquire USDC on Coinbase before depositing to Thales Markets**

1\. Click **‘Buy & Sell’** on the Coinbase homepage.

{% embed url="<https://content.gitbook.com/content/nJyFkobxrWkQl5YVAtfa/blobs/QXGPUG8rpfkcsgLgsJYa/image.png>" %}

2. Click **‘Buy’** then under *Select Asset*, click **USD Coin (USDC).**

{% embed url="<https://content.gitbook.com/content/nJyFkobxrWkQl5YVAtfa/blobs/JPBewJmJZCWsVkDythgk/image.png>" %}

3. **Enter an amount & connect a payment method under ‘*****Pay with’.***

{% embed url="<https://content.gitbook.com/content/nJyFkobxrWkQl5YVAtfa/blobs/wXq7Vh5o7KujLvVUiVgT/image.png>" %}

4. Click **‘Preview Buy’**, review the *Order Preview,* then click **Buy Now.**

{% embed url="<https://content.gitbook.com/content/nJyFkobxrWkQl5YVAtfa/blobs/KKTXjGA2fHjSuiNO6LFl/image.png>" %}

5. You’ll see a “*Your order was submitted”* screen, then will receive a confirmation email when your USDC purchase is successful.

{% embed url="<https://content.gitbook.com/content/nJyFkobxrWkQl5YVAtfa/blobs/exYLci5gRyzhGNr5LgxM/image.png>" %}

## **You have acquired USDC on Coinbase** <a href="#block-3886d7582aa848faa176ee8e9351cc83" id="block-3886d7582aa848faa176ee8e9351cc83"></a>

1. 1\. Click **Send & Receive.**

{% embed url="<https://content.gitbook.com/content/nJyFkobxrWkQl5YVAtfa/blobs/FjTmPWdicDpoTUjwMoNz/image.png>" %}

2. Under *Asset*, select **USD Coin.**

{% embed url="<https://content.gitbook.com/content/nJyFkobxrWkQl5YVAtfa/blobs/hWSwiVVkbIkd8DamZSD0/image.png>" %}

3. **Enter the amount** you wish to deposit to your Speed Markets account.

{% embed url="<https://content.gitbook.com/content/nJyFkobxrWkQl5YVAtfa/blobs/tJu2AJRQwZkKWaBSGrgO/image.png>" %}

4. **Under ‘*****to*****’, enter your Overtime deposit address.** You can find yours on the Speed Markets **Deposit Page**. Then **click ‘*****Continue’***.

5. Under ‘*Network*’, select **the network you want to use Speed Markets on.**

{% hint style="danger" %}
**Make sure you are choosing the network that is the same as the one you chose on the top right corner of the Speed Markets webpage:**

![](/files/XePmePrbpTAkgfRI3LzU)
{% endhint %}

{% embed url="<https://content.gitbook.com/content/nJyFkobxrWkQl5YVAtfa/blobs/5QDQKH8xvjcVheaR9pXR/annotely_image%20(6).png>" fullWidth="false" %}

6. Click **Send Now** and wait for your your deposit to land on Thales Markets Deposit page (usually in a couple minutes).

{% embed url="<https://content.gitbook.com/content/nJyFkobxrWkQl5YVAtfa/blobs/T8wm6xeu8j4Sr0ckLrKg/image.png>" %}

7. **You are now ready to trade on Speed Markets!**&#x20;


# Deposit from Binance Mobile App

Log in to your Binance App and tap **\[Wallets]** - **\[Spot]** - **\[Withdraw]**.

{% embed url="<https://content.gitbook.com/content/nJyFkobxrWkQl5YVAtfa/blobs/HEEZp8qpBX7usjB2odjI/image.png>" %}

2. Choose USDC or USDT (whichever of the two you own in your Binance account). Then, tap **\[Send via Crypto Network]**.

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2F6i6Hkfa6IgJcetiKddMq%2Fannotely_image%20(7).png?alt=media&token=40d699e0-bf05-49ff-afec-3154fcfe145c>" %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FcaHyrrIOZhgsKtVJkFNR%2Fannotely_image%20(8).png?alt=media&token=610081fa-a934-4e3c-8d90-7a0a034d3e3e>" %}

3. In the `Address` input field , paste the destination address copied from your **Speed Markets Deposit page**.
4. &#x20;Select the network

{% hint style="danger" %}
**Make sure you are choosing the network that is the same as the one you chose on the top right corner of the Speed Markets webpage:**

![](/files/XePmePrbpTAkgfRI3LzU)
{% endhint %}

<div><figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2Ft1WBnJbLKcmJTFvO4ptl%2Fviber_image_2023-12-12_13-47-27-762.jpg?alt=media&#x26;token=22d0a9df-1041-4961-bc4a-9a122e502a12" alt=""><figcaption><p>Optimism button</p></figcaption></figure> <figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FMrzk4rqcZHxD7pA4m1SI%2Fviber_image_2023-12-12_13-47-27-782.jpg?alt=media&#x26;token=b01c6c8a-a051-411a-bb1c-446be8a2ff01" alt=""><figcaption><p>Arbitrum button</p></figcaption></figure> <figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FN7OwkoGjEmpDl6ZbN1lt%2Fviber_image_2023-12-12_13-47-27-926.jpg?alt=media&#x26;token=b84dbaf9-0918-485c-a449-6dcca0c98cfd" alt=""><figcaption><p>Polygon button</p></figcaption></figure></div>

5. Enter the withdrawal amount and you will see the corresponding transaction fee and the final amount you will receive. You can also select which wallet to withdraw from by tapping **\[Spot & Funding Wallet].** Tap **\[Withdraw]** to proceed.
6. You will be prompted to confirm the transaction again. Please check carefully before tapping **\[Confirm]**.If you enter the wrong information or select the wrong network when making a transfer, your assets will be permanently lost. **Please make sure the information is correct before you confirm the transaction.**
7. Verify the transaction with your 2FA devices. After confirming the withdrawal request, please wait patiently for the transfer to be processed.


# Deposit from Binance Website

1. Log into your Binance account and click **\[Wallet]** - **\[Overview]**.

{% embed url="<https://public.bnbstatic.com/image/cms/article/body/202303/9723115f02d62c3f91326738626ab848.png>" %}

2. &#x20;Click **\[Withdraw]**.

{% embed url="<https://public.bnbstatic.com/image/cms/article/body/202303/8ce657dc5127d8f89093161e29fec9a5.png>" %}

3. You will be redirected to the withdrawal page. Click **\[Withdraw Crypto]**.

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FOhYrCm5gNWPmxmMD9AwL%2F5e9c45de8803fdcfd5aefdfe4212a7fe.png?alt=media&token=15ab7ade-767e-4fd4-8aa5-663041191c9d>" %}

4. Choose USDC or USDT (whichever of the two you own in your Binance account).

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FpxLymQz92o7Lr7XDeQ3I%2Fannotely_image%20(9).png?alt=media&token=65389c7a-afb0-4aeb-b302-f48b3efd1e7f>" %}

5. Select the network. Depending on the crypto you choose, you will see the corresponding supported networks and network fees for this transaction.&#x20;

{% hint style="danger" %}
**Make sure you are choosing the network that is the same as the one you chose on the top right corner of the Speed Markets webpage:**

![](/files/XePmePrbpTAkgfRI3LzU)
{% endhint %}

{% embed url="<https://content.gitbook.com/content/nJyFkobxrWkQl5YVAtfa/blobs/J3JWmSZpM6Hwcfs43dT7/image.png>" %}

6. In the `Address` input field , paste the destination address copied from your Speed Markets Deposit page.
7. Enter the withdrawal amount. You may choose to use the balance from your Spot or Funding Wallet. You will see the transaction fee and the final amount you will receive. Click **\[Withdraw]** to proceed.
8. You will be prompted to confirm the selected network again. Click **\[Confirm]** if the receiving platform supports the network.
9. Check the withdrawal details carefully. Click **\[Continue]** and verify the transaction with your 2FA devices.
10. Your withdrawal request has been submitted. After confirming your request on Binance, it takes time for the transaction to be confirmed on the blockchain. The [confirmation time](https://academy.binance.com/en/glossary/confirmation-time) varies depending on the blockchain and its network traffic. Please wait patiently for the transfer to be processed.


# THALES Token Info

Most relevant THALES token information compressed into a single page

THALES token is a fixed-supply standard ERC-20 token on the Ethereum network. It is utilized and available on Ethereum Mainnet and main Layer 2 Ethereum Networks: Optimism, Arbitrum and Base.

* [Thales on Optimism](https://optimistic.etherscan.io/token/0x217D47011b23BB961eB6D93cA9945B7501a5BB11)
* [Thales on Arbitrum ](https://arbiscan.io/token/0xe85b662fe97e8562f4099d8a1d5a92d4b453bf30)
* [Thales on Base ](https://basescan.org/token/0xf34e0cff046e154cafcae502c7541b9e5fd8c249)
* [Thales on Mainnet ](https://etherscan.io/token/0x8947da500Eb47F82df21143D0C01A29862a8C3c5)

### THALES token utility <a href="#section1" id="section1"></a>

Main purpose of the THALES token is to act as a Governance Token of the Thales Protocol. Whoever is staking THALES tokens has voting power equal to the amount of tokens they are staking, for the Thales DAO election. Thales DAO elections are used to elect the Thales Council, main governing body of the Thales DAO comprising seven seats chosen by the Thales community. You can learn more about the Thales Governance Structure on this [**Governance Page**](https://thales-io-dapp-git-dev-thales-market.vercel.app/about/governance).&#x20;

Other than granting voting power, THALES token staking makes the user eligible for weekly inflationary THALES token Staking Rewards and pure stablecoin Protocol Rewards.&#x20;

Inflationary Staking Rewards distributed weekly started at 40,000 THALES split pro rata across all stakers on all supported networks, reducing by -0.5% every subsequent week. Synchronization of Staking Rewards across networks is done using Chainlink CCIP, unifying the APY regardless of on what network you stake.&#x20;

Protocol Rewards are awarded to all THALES stakers also on a pro rata basis, equally distributing the Weekly Fee Accrual of the entire Protocol across all stakers. Stakers on Optimism are able to claim Protocol Rewards denominated in sUSD, Arbitrum in USDC and Base also in USDC.

### Where can I acquire the THALES token? <a href="#section1" id="section1"></a>

The THALES token has deep liquidity available on various Decentralized Exchange pairs on Optimism, Arbitrum and Base networks. For best swap execution we suggest using any prominent DEX Aggregator such as [**1inch**](https://app.1inch.io/), [**LlamaSwap**](http://swap.defillama.com/), [**Paraswap**](https://www.paraswap.io/) or [**Matcha**](https://matcha.xyz/). Be careful to double check you are swapping for the official THALES token contracts on supported networks:

* Thales on Optimism: [0x217...5bb11 ](https://optimistic.etherscan.io/token/0x217D47011b23BB961eB6D93cA9945B7501a5BB11)
* Thales on Arbitrum: [0xe85...3bf30 ](https://arbiscan.io/token/0xe85b662fe97e8562f4099d8a1d5a92d4b453bf30)
* Thales on Base: [0xf34...8c249 ](https://basescan.org/token/0xf34e0cff046e154cafcae502c7541b9e5fd8c249)


# THALES Token Distribution

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FxjZy6NC8YobdSCn0Kkdl%2Fimage.png?alt=media&token=e2cc0e60-fd05-496c-b07b-2ee5d0006a46>" %}

THALES is a standard ERC-20 used by the community as the governance token of Thales DAO. Token distribution follows the outline below:

### Distribution Breakdown

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FZvdj2p18fZx6pShRzudp%2Fimage.png?alt=media&token=9f4bf2a0-a5ea-40b5-90dd-5a4525cc09ec>" %}
Pie chart of token distribution
{% endembed %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FjVME2jJB1QWCkUzz9tqC%2Femissions.PNG?alt=media&token=4b1222ac-8674-4495-82c5-b50a25377077>" %}
Unlock schedule
{% endembed %}

**8.75% to SNX stakers**

* 2.25% SNX staking distribution up until implementation of [**TIP-37**](https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-37.md)  - <mark style="color:blue;">**Distribution Completed**</mark>&#x20;
* 4.5% Retroactive distribution for SNX staking (L1 and OP)  - <mark style="color:blue;">**Distribution Completed**</mark>&#x20;
* 2% Airdropped to every SNX staker (L1 and OP) - <mark style="color:blue;">**Distribution Completed**</mark>&#x20;

**18% Thales Core Contributors** - Vesting for 3 years starting Q2 2022

**15% THALES stakers** - Ongoing 3 year long distribution that started Q4 2021 Includes SNX stakers in gamified staking rewards bonus, along with protocol volume bonus

**58.25% Growth Fund:**

* **9% to Strategic Partners** - 2 year long distribution that started Q4 2021&#x20;
* **2% Crowdpooling event on DODO -&#x20;**<mark style="color:blue;">**Distribution Completed**</mark>&#x20;
* **1% Initial DODO LP reward -&#x20;**<mark style="color:blue;">**Distribution Completed**</mark>**&#x20;**&#x20;
* **46.25% to ThalesDAO treasury**&#x20;
  * 18% Distributed to Treasury on TGE to be used as ad-hoc Growth incentives&#x20;
  * 2% sent back to treasury from disengaged Thales Core Contributor ([**TIP-9**](https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-9.md))&#x20;
  * 26.25% reallocated to Treasury from termination of SNX rewards ([**TIP-37**](https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-37.md))

{% hint style="info" %}
You can find a more detailed explanation of THALES tokenomics in this [Medium article](https://thalesmarket.medium.com/thales-tokenomics-v2-0-bd4b59c4e74c).
{% endhint %}


# Staking Guide

The Thales staking contract allow users to lock THALES tokens to receive voting power in the protocol, claim THALES rewards and claim Protocol Rewards in USD stablecoins.

### How THALES staking works

By staking THALES on Optimism, Arbitrum or Base, every week you earn two types of rewards: Staking rewards in THALES tokens and Protocol Rewards in stablecoins. These rewards are synchronized and equal across all supported networks.

Staking Rewards are the main inflationary rewards distributed to all stakers once a week proportional to their Staked Share percentage value and proportional to their % of Total Global Points of Gamified Staking.

Base inflationary rewards are currently `18,183.13` THALES per week for all stakers, and they are decreasing every week.&#x20;

Protocol Rewards are distributed in stablecoins to all THALES stakers from trading activity fees across all Thales Protocol contracts.

### Staking Guide

Visit the STAKING page on Thales.io using this link:

[`thales.io/token/staking?tab=stake-thales`](https://docs.thales.io/thales-token/www.thales.io/token/staking?tab=stake-thales)

Make sure your wallet is connected on the top right corner of the page.

In the STAKE/UNSTAKE box, input the amount of THALES you wish to stake in the input field.

<figure><img src="/files/AqxjKAvAfcLBPhDE0aOW" alt=""><figcaption><p>STAKE box on the STAKING page</p></figcaption></figure>

After you input the amount, click on the `APPROVE THALES` button to approve the staking smart contract to pull your THALES amount.

After confirming the approval transaction, click on the `STAKE` button and confirm the transaction.

Congratulations! You are now successfully staking THALES and are eligible for weekly THALES and USD rewards.

If you ever decide to UNSTAKE your THALES, you can do that on the same box by toggling from `STAKE` to `UNSTAKE`.

### Claiming Rewards Guide

Claiming of weekly THALES staking rewards is done on the REWARDS page.

Navigate to the `REWARDS` page by visiting this link:

[`thales.io/token/staking?tab=rewards`](https://docs.thales.io/thales-token/www.thales.io/token/staking?tab=rewards)

Click on the `CLAIM REWARDS` button and confirm the transaction.

After the transaction is confirmed you have successfully claimed USD rewards to your wallet and the THALES rewards to a 10-week escrow, after which they will be unlocked in the `VESTING` tab.

{% hint style="info" %}
Once THALES staking rewards have been claimed, rewards are then moved to the Escrow contract with 10-week vesting. **The escrowed balance is included in the staked balance for governance voting power and staking rewards.** Escrowed rewards that are redeemed are no longer included in the staked balance unless they are staked through the staking contract.
{% endhint %}

{% hint style="info" %}
Staking rewards are allocated to you once a week, depending on your **`My Staked Share`** percentage value at the time of the weekly snapshot.  You can claim staking rewards weekly.

<mark style="color:red;">**Unclaimed weekly rewards are forfeited!**</mark>
{% endhint %}


# Automate staking with Chainlink Automation

Currently THALES staking rewards need to be claimed manually by users on a weekly basis or the weekly reward is forfeited. The rewards **do not** roll over to next week automatically!&#x20;

With the recent implementation of **`claimOnBehalf`** method in the THALES staking contract, it is finally possible for individual stakers to explore automating their award claiming and thus improve their UX significantly.

This page will guide you through the steps of setting up a Chainlink Automation weekly task for auto-claiming your weekly staking rewards.

## Step 1: Fund your wallet with a few LINK tokens.

{% hint style="warning" %}
Chainlink Automation requires LINK tokens for gas to function.
{% endhint %}

You should have at least **2 LINK** in your wallet that will be used to deposit and fund the task you are creation in one of the the task creation process steps.

## Step 2: Create a new automation task on `automation.chain.link` dapp

Navigate to the Chainlink Automation dapp: <https://automation.chain.link/>

Connect your wallet to the dapp.

**If you want to automate staking on** :red\_circle: **Optimism Network, make sure your wallet and automation dapp is connected to Optimism.**

**If you want to automate staking on** :large\_blue\_diamond: **Arbitrum Network, make sure your wallet and automation dapp is connected to Arbitrum.**\
\
**If you want to automate staking on** :blue\_circle: **Base Network, make sure your wallet and automation dapp is connected to Base Network.**

Click on the `Register new Upkeep` button.&#x20;

Choose `Time Based`.

In `Target contract address` input field, input the following THALES staking contract address for the respective networks:

#### For :red\_circle:Optimism :arrow\_right: 0xC392133eEa695603B51a5d5de73655d571c2CE51:arrow\_left:

#### For :large\_blue\_diamond: Arbitrum :arrow\_right:  `0xD5F18910b75859616E27fc96E37c4874Bdc588bC`:arrow\_left:

#### For :blue\_circle: Base:arrow\_right:  `0xdD462615884E70C80037cCf8Aa0f82cb06056D81`:arrow\_left:

After inputting the contract address, click on **`use custom ABI`** and paste the following ABI:

#### For :red\_circle:Optimism :arrow\_down:

```
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"source","type":"address"}],"name":"AMMVolumeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"srcAccount","type":"address"},{"indexed":false,"internalType":"address","name":"destAccount","type":"address"}],"name":"AccountMerged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"thalesAMM","type":"address"},{"indexed":false,"internalType":"address","name":"thalesRangedAMM","type":"address"},{"indexed":false,"internalType":"address","name":"sportsAMM","type":"address"},{"indexed":false,"internalType":"address","name":"priceFeed","type":"address"},{"indexed":false,"internalType":"address","name":"ThalesStakingRewardsPool","type":"address"},{"indexed":false,"internalType":"address","name":"addressResolver","type":"address"},{"indexed":false,"internalType":"address","name":"stakingThalesBonusRewardsManager","type":"address"}],"name":"AddressesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"canClaimOnBehalf","type":"bool"}],"name":"CanClaimOnBehalfChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"CancelUnstake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"PeriodOfStaking","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastPeriodTimeStamp","type":"uint256"}],"name":"ClosedPeriod","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"destAccount","type":"address"}],"name":"DelegatedVolume","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newEscrow","type":"address"}],"name":"EscrowChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"unclaimedFees","type":"uint256"}],"name":"FeeRewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lastPeriodTimestamp","type":"uint256"}],"name":"LastPeriodTimestampSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_currentPeriodRewards","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_extraRewards","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_revShare","type":"uint256"}],"name":"ReceivedStakingRewardsUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"unclaimedReward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"baseRewards","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"StakedOnBehalf","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"claimEnabled","type":"bool"},{"indexed":false,"internalType":"bool","name":"distributeFeesEnabled","type":"bool"},{"indexed":false,"internalType":"uint256","name":"durationPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"unstakeDurationPeriod","type":"uint256"},{"indexed":false,"internalType":"bool","name":"mergeAccountEnabled","type":"bool"},{"indexed":false,"internalType":"bool","name":"readOnlyMode","type":"bool"},{"indexed":false,"internalType":"bool","name":"sendCCIPMessage","type":"bool"}],"name":"StakingParametersChanged","type":"event"},{"anonymous":false,"inputs":[],"name":"StakingPeriodStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fixedPeriodReward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"periodExtraReward","type":"uint256"},{"indexed":false,"internalType":"bool","name":"extraRewardsActive","type":"bool"}],"name":"StakingRewardsParametersChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"SupportedAMMVaultSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"SupportedSportVaultSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"cooldownTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UnstakeCooldown","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"unstakeAmount","type":"uint256"}],"name":"Unstaked","type":"event"},{"constant":true,"inputs":[],"name":"ThalesStakingRewardsPool","outputs":[{"internalType":"contract IThalesStakingRewardsPool","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"canClaimOnBehalf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"canClosePeriod","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"cancelUnstake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"claimEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"claimReward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"claimRewardOnBehalf","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"closePeriod","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"closingPeriodInProgress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"closingPeriodPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentPeriodFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentPeriodRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"delegateVolume","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"delegatedVolume","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"distributeFeesEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"durationPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"extraRewardsActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"fixedPeriodReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAMMVolume","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAlreadyClaimedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getBaseReward","outputs":[{"internalType":"uint256","name":"_baseRewards","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getContractFeeFunds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getContractRewardFunds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getLastPeriodOfClaimedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getRewardFeesAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getRewardsAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getTotalBonus","outputs":[{"internalType":"uint256","name":"returnValue","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"iEscrowThales","outputs":[{"internalType":"contract IEscrowThales","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"initNonReentrant","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_iEscrowThales","type":"address"},{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"address","name":"_feeToken","type":"address"},{"internalType":"uint256","name":"_durationPeriod","type":"uint256"},{"internalType":"uint256","name":"_unstakeDurationPeriod","type":"uint256"},{"internalType":"address","name":"_ISNXRewards","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastPeriodTimeStamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastUnstakeTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"destAccount","type":"address"}],"name":"mergeAccount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"mergeAccountEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"periodExtraReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"periodsOfStaking","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"priceFeed","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"readOnlyMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"sendRoundClosingMessageCrosschain","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_thalesAMM","type":"address"},{"internalType":"address","name":"_thalesRangedAMM","type":"address"},{"internalType":"address","name":"_sportsAMM","type":"address"},{"internalType":"address","name":"_priceFeed","type":"address"},{"internalType":"address","name":"_thalesStakingRewardsPool","type":"address"},{"internalType":"address","name":"_addressResolver","type":"address"},{"internalType":"address","name":"_stakingThalesBonusRewardsManager","type":"address"}],"name":"setAddresses","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"_canClaimOnBehalf","type":"bool"}],"name":"setCanClaimOnBehalf","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_escrowThalesContract","type":"address"}],"name":"setEscrow","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_lastPeriodTimestamp","type":"uint256"}],"name":"setLastPeriodTimestamp","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"_claimEnabled","type":"bool"},{"internalType":"bool","name":"_distributeFeesEnabled","type":"bool"},{"internalType":"uint256","name":"_durationPeriod","type":"uint256"},{"internalType":"uint256","name":"_unstakeDurationPeriod","type":"uint256"},{"internalType":"bool","name":"_mergeAccountEnabled","type":"bool"},{"internalType":"bool","name":"_readOnlyMode","type":"bool"},{"internalType":"bool","name":"_sendCCIPMessage","type":"bool"}],"name":"setStakingParameters","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_fixedReward","type":"uint256"},{"internalType":"uint256","name":"_extraReward","type":"uint256"},{"internalType":"bool","name":"_extraRewardsActive","type":"bool"}],"name":"setStakingRewardsParameters","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_ammVault","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setSupportedAMMVault","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_sportVault","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setSupportedSportVault","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"sportsAMM","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"stakedBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakerFeesClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakerLifetimeRewardsClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"stakingThalesBonusRewardsManager","outputs":[{"internalType":"contract IStakingThalesBonusRewardsManager","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"stakingToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"startStakingPeriod","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"startTimeStamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"startUnstake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supportedAMMVault","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supportedSportVault","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"thalesAMM","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"thalesRangedAMM","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalEscrowedLastPeriodEnd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalStakedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalStakedLastPeriodEnd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unstake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"unstakeDurationPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"unstaking","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"unstakingAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_currentPeriodRewards","type":"uint256"},{"internalType":"uint256","name":"_extraRewards","type":"uint256"},{"internalType":"uint256","name":"_revShare","type":"uint256"}],"name":"updateStakingRewards","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"updateVolume","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
```

#### For :large\_blue\_diamond: Arbitrum:arrow\_down:

```
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"source","type":"address"}],"name":"AMMVolumeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"srcAccount","type":"address"},{"indexed":false,"internalType":"address","name":"destAccount","type":"address"}],"name":"AccountMerged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"thalesAMM","type":"address"},{"indexed":false,"internalType":"address","name":"thalesRangedAMM","type":"address"},{"indexed":false,"internalType":"address","name":"sportsAMM","type":"address"},{"indexed":false,"internalType":"address","name":"priceFeed","type":"address"},{"indexed":false,"internalType":"address","name":"ThalesStakingRewardsPool","type":"address"},{"indexed":false,"internalType":"address","name":"addressResolver","type":"address"},{"indexed":false,"internalType":"address","name":"stakingThalesBonusRewardsManager","type":"address"}],"name":"AddressesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"canClaimOnBehalf","type":"bool"}],"name":"CanClaimOnBehalfChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"CancelUnstake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"PeriodOfStaking","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastPeriodTimeStamp","type":"uint256"}],"name":"ClosedPeriod","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"destAccount","type":"address"}],"name":"DelegatedVolume","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newEscrow","type":"address"}],"name":"EscrowChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"unclaimedFees","type":"uint256"}],"name":"FeeRewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lastPeriodTimestamp","type":"uint256"}],"name":"LastPeriodTimestampSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_currentPeriodRewards","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_extraRewards","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_revShare","type":"uint256"}],"name":"ReceivedStakingRewardsUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"unclaimedReward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"baseRewards","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"StakedOnBehalf","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"claimEnabled","type":"bool"},{"indexed":false,"internalType":"bool","name":"distributeFeesEnabled","type":"bool"},{"indexed":false,"internalType":"uint256","name":"durationPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"unstakeDurationPeriod","type":"uint256"},{"indexed":false,"internalType":"bool","name":"mergeAccountEnabled","type":"bool"},{"indexed":false,"internalType":"bool","name":"readOnlyMode","type":"bool"},{"indexed":false,"internalType":"bool","name":"sendCCIPMessage","type":"bool"}],"name":"StakingParametersChanged","type":"event"},{"anonymous":false,"inputs":[],"name":"StakingPeriodStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fixedPeriodReward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"periodExtraReward","type":"uint256"},{"indexed":false,"internalType":"bool","name":"extraRewardsActive","type":"bool"}],"name":"StakingRewardsParametersChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"SupportedAMMVaultSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"SupportedSportVaultSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"cooldownTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UnstakeCooldown","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"unstakeAmount","type":"uint256"}],"name":"Unstaked","type":"event"},{"constant":true,"inputs":[],"name":"ThalesStakingRewardsPool","outputs":[{"internalType":"contract IThalesStakingRewardsPool","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"canClaimOnBehalf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"canClosePeriod","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"cancelUnstake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"claimEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"claimReward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"claimRewardOnBehalf","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"closePeriod","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"closingPeriodInProgress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"closingPeriodPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentPeriodFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentPeriodRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"delegateVolume","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"delegatedVolume","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"distributeFeesEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"durationPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"extraRewardsActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"fixedPeriodReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAMMVolume","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAlreadyClaimedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getBaseReward","outputs":[{"internalType":"uint256","name":"_baseRewards","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getContractFeeFunds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getContractRewardFunds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getLastPeriodOfClaimedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getRewardFeesAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getRewardsAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getTotalBonus","outputs":[{"internalType":"uint256","name":"returnValue","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"iEscrowThales","outputs":[{"internalType":"contract IEscrowThales","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"initNonReentrant","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_iEscrowThales","type":"address"},{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"address","name":"_feeToken","type":"address"},{"internalType":"uint256","name":"_durationPeriod","type":"uint256"},{"internalType":"uint256","name":"_unstakeDurationPeriod","type":"uint256"},{"internalType":"address","name":"_ISNXRewards","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastPeriodTimeStamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastUnstakeTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"destAccount","type":"address"}],"name":"mergeAccount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"mergeAccountEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"periodExtraReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"periodsOfStaking","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"priceFeed","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"readOnlyMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"sendRoundClosingMessageCrosschain","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_thalesAMM","type":"address"},{"internalType":"address","name":"_thalesRangedAMM","type":"address"},{"internalType":"address","name":"_sportsAMM","type":"address"},{"internalType":"address","name":"_priceFeed","type":"address"},{"internalType":"address","name":"_thalesStakingRewardsPool","type":"address"},{"internalType":"address","name":"_addressResolver","type":"address"},{"internalType":"address","name":"_stakingThalesBonusRewardsManager","type":"address"}],"name":"setAddresses","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"_canClaimOnBehalf","type":"bool"}],"name":"setCanClaimOnBehalf","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_escrowThalesContract","type":"address"}],"name":"setEscrow","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_lastPeriodTimestamp","type":"uint256"}],"name":"setLastPeriodTimestamp","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"_claimEnabled","type":"bool"},{"internalType":"bool","name":"_distributeFeesEnabled","type":"bool"},{"internalType":"uint256","name":"_durationPeriod","type":"uint256"},{"internalType":"uint256","name":"_unstakeDurationPeriod","type":"uint256"},{"internalType":"bool","name":"_mergeAccountEnabled","type":"bool"},{"internalType":"bool","name":"_readOnlyMode","type":"bool"},{"internalType":"bool","name":"_sendCCIPMessage","type":"bool"}],"name":"setStakingParameters","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_fixedReward","type":"uint256"},{"internalType":"uint256","name":"_extraReward","type":"uint256"},{"internalType":"bool","name":"_extraRewardsActive","type":"bool"}],"name":"setStakingRewardsParameters","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_ammVault","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setSupportedAMMVault","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_sportVault","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setSupportedSportVault","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"sportsAMM","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"stakedBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakerFeesClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakerLifetimeRewardsClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"stakingThalesBonusRewardsManager","outputs":[{"internalType":"contract IStakingThalesBonusRewardsManager","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"stakingToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"startStakingPeriod","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"startTimeStamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"startUnstake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supportedAMMVault","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supportedSportVault","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"thalesAMM","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"thalesRangedAMM","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalEscrowedLastPeriodEnd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalStakedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalStakedLastPeriodEnd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unstake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"unstakeDurationPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"unstaking","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"unstakingAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_currentPeriodRewards","type":"uint256"},{"internalType":"uint256","name":"_extraRewards","type":"uint256"},{"internalType":"uint256","name":"_revShare","type":"uint256"}],"name":"updateStakingRewards","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"updateVolume","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
```

#### For :blue\_circle: Base:arrow\_down:

```
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"source","type":"address"}],"name":"AMMVolumeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"srcAccount","type":"address"},{"indexed":false,"internalType":"address","name":"destAccount","type":"address"}],"name":"AccountMerged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"thalesAMM","type":"address"},{"indexed":false,"internalType":"address","name":"thalesRangedAMM","type":"address"},{"indexed":false,"internalType":"address","name":"sportsAMM","type":"address"},{"indexed":false,"internalType":"address","name":"priceFeed","type":"address"},{"indexed":false,"internalType":"address","name":"ThalesStakingRewardsPool","type":"address"},{"indexed":false,"internalType":"address","name":"addressResolver","type":"address"},{"indexed":false,"internalType":"address","name":"stakingThalesBonusRewardsManager","type":"address"}],"name":"AddressesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"canClaimOnBehalf","type":"bool"}],"name":"CanClaimOnBehalfChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"CancelUnstake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"PeriodOfStaking","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastPeriodTimeStamp","type":"uint256"}],"name":"ClosedPeriod","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"destAccount","type":"address"}],"name":"DelegatedVolume","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newEscrow","type":"address"}],"name":"EscrowChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"unclaimedFees","type":"uint256"}],"name":"FeeRewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lastPeriodTimestamp","type":"uint256"}],"name":"LastPeriodTimestampSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_currentPeriodRewards","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_extraRewards","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_revShare","type":"uint256"}],"name":"ReceivedStakingRewardsUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"unclaimedReward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"baseRewards","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"StakedOnBehalf","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"claimEnabled","type":"bool"},{"indexed":false,"internalType":"bool","name":"distributeFeesEnabled","type":"bool"},{"indexed":false,"internalType":"uint256","name":"durationPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"unstakeDurationPeriod","type":"uint256"},{"indexed":false,"internalType":"bool","name":"mergeAccountEnabled","type":"bool"},{"indexed":false,"internalType":"bool","name":"readOnlyMode","type":"bool"},{"indexed":false,"internalType":"bool","name":"sendCCIPMessage","type":"bool"}],"name":"StakingParametersChanged","type":"event"},{"anonymous":false,"inputs":[],"name":"StakingPeriodStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fixedPeriodReward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"periodExtraReward","type":"uint256"},{"indexed":false,"internalType":"bool","name":"extraRewardsActive","type":"bool"}],"name":"StakingRewardsParametersChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"SupportedAMMVaultSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"SupportedSportVaultSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"cooldownTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UnstakeCooldown","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"unstakeAmount","type":"uint256"}],"name":"Unstaked","type":"event"},{"constant":true,"inputs":[],"name":"ThalesStakingRewardsPool","outputs":[{"internalType":"contract IThalesStakingRewardsPool","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"canClaimOnBehalf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"canClosePeriod","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"cancelUnstake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"claimEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"claimReward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"claimRewardOnBehalf","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"closePeriod","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"closingPeriodInProgress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"closingPeriodPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentPeriodFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentPeriodRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"delegateVolume","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"delegatedVolume","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"distributeFeesEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"durationPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"extraRewardsActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"fixedPeriodReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAMMVolume","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAlreadyClaimedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getBaseReward","outputs":[{"internalType":"uint256","name":"_baseRewards","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getContractFeeFunds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getContractRewardFunds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getLastPeriodOfClaimedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getRewardFeesAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getRewardsAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getTotalBonus","outputs":[{"internalType":"uint256","name":"returnValue","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"iEscrowThales","outputs":[{"internalType":"contract IEscrowThales","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"initNonReentrant","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_iEscrowThales","type":"address"},{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"address","name":"_feeToken","type":"address"},{"internalType":"uint256","name":"_durationPeriod","type":"uint256"},{"internalType":"uint256","name":"_unstakeDurationPeriod","type":"uint256"},{"internalType":"address","name":"_ISNXRewards","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastPeriodTimeStamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastUnstakeTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"destAccount","type":"address"}],"name":"mergeAccount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"mergeAccountEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"periodExtraReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"periodsOfStaking","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"priceFeed","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"readOnlyMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"sendRoundClosingMessageCrosschain","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_thalesAMM","type":"address"},{"internalType":"address","name":"_thalesRangedAMM","type":"address"},{"internalType":"address","name":"_sportsAMM","type":"address"},{"internalType":"address","name":"_priceFeed","type":"address"},{"internalType":"address","name":"_thalesStakingRewardsPool","type":"address"},{"internalType":"address","name":"_addressResolver","type":"address"},{"internalType":"address","name":"_stakingThalesBonusRewardsManager","type":"address"}],"name":"setAddresses","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"_canClaimOnBehalf","type":"bool"}],"name":"setCanClaimOnBehalf","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_escrowThalesContract","type":"address"}],"name":"setEscrow","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_lastPeriodTimestamp","type":"uint256"}],"name":"setLastPeriodTimestamp","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"_claimEnabled","type":"bool"},{"internalType":"bool","name":"_distributeFeesEnabled","type":"bool"},{"internalType":"uint256","name":"_durationPeriod","type":"uint256"},{"internalType":"uint256","name":"_unstakeDurationPeriod","type":"uint256"},{"internalType":"bool","name":"_mergeAccountEnabled","type":"bool"},{"internalType":"bool","name":"_readOnlyMode","type":"bool"},{"internalType":"bool","name":"_sendCCIPMessage","type":"bool"}],"name":"setStakingParameters","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_fixedReward","type":"uint256"},{"internalType":"uint256","name":"_extraReward","type":"uint256"},{"internalType":"bool","name":"_extraRewardsActive","type":"bool"}],"name":"setStakingRewardsParameters","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_ammVault","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setSupportedAMMVault","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_sportVault","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setSupportedSportVault","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"sportsAMM","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"stakedBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakerFeesClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakerLifetimeRewardsClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"stakingThalesBonusRewardsManager","outputs":[{"internalType":"contract IStakingThalesBonusRewardsManager","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"stakingToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"startStakingPeriod","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"startTimeStamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"startUnstake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supportedAMMVault","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supportedSportVault","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"thalesAMM","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"thalesRangedAMM","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalEscrowedLastPeriodEnd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalStakedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalStakedLastPeriodEnd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unstake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"unstakeDurationPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"unstaking","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"unstakingAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_currentPeriodRewards","type":"uint256"},{"internalType":"uint256","name":"_extraRewards","type":"uint256"},{"internalType":"uint256","name":"_revShare","type":"uint256"}],"name":"updateStakingRewards","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"updateVolume","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
```

After inputting the ABI, choose the following function:

**`claimRewardOnBehalf`** \
\
I**nput your wallet address that you use for staking THALES** in the `account`*`address`* input field.

To **Specify your time schedule**, in the `Cron expression` input field, input the following expression:

**`0 9 * * 2`**

{% hint style="info" %}
This Cron expression signals timed execution for the automation job to be every Tuesday at 09:00 UTC.
{% endhint %}

Proceed to the next page, which should look like this:

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2Fy0FZE6DVFjEWeo4ioedj%2Ffinal%20details.PNG?alt=media&token=fc526f5b-1472-4f7f-91b4-ab5a40374c5c>" %}

Scrolling down beneath these details, input your desired `Upkeep name` in the Upkeep details tab.

Input the desired amount of LINK funding for the upkeep in the `Starting balance (LINK)` input field. **The amount should be at least 2 LINK.**

Tick the box which confirms you accept the Terms of Service and click on the **Register Upkeep** button.

Confirm the transaction and **you have successfully automated your weekly THALES staking rewards claims using Chainlink Automation!**

## Step 3: Whitelist your `Upkeep Address` for the `claimOnBehalf` method

This step is important to allow (whiltelist) Chainlink Automation to actually execute the Claim transaction.

1. Go to the Chainlink Automation main page and make sure your wallet is connected to the right network.
2. In **`My Upkeeps`** you should see your newly created upkeep. Click on it to open the  personal dashboard page of your upkeep.
3. After you opened your upkeep page, find your personal **`Upkeep Address`** in the middle section of the page called **`Upkeep`**. **Copy it by clicking on the Copy button.**

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2FrzYy1SaFjFNTnaK7sFNi%2Fannotely_image.png?alt=media&token=f12ae0bc-7b30-41f4-bd13-1debc589a240>" %}

4. Navigate to the THALES token Account Preferences page: <https://www.thales.io/token/staking?tab=acc-preferences>

{% hint style="info" %}
Make sure your wallet used for staking THALES is connected to the thales.io dapp.
{% endhint %}

Click on the **`ENABLE CLAIM ON BEHALF`** button that is located in the bottom left corner of the page.

After the "Claim on behalf" pop-up window opens, in the address input field **make sure to input your copied `Forwarder Address`**.

After inputting the CLA Registry address, click on the **`Enable`** button and confirm the transaction.


# Automate staking with Gelato Functions

Currently THALES staking rewards need to be claimed manually by users on a weekly basis or the weekly reward is forfeited. The rewards **do not** roll over to next week automatically!&#x20;

With the implementation of **`claimOnBehalf`** method in the THALES staking contract, it is finally possible for individual stakers to explore automating their award claiming and thus improve their UX significantly.

This page will guide you through the steps of setting up a Gelato weekly task for auto-claiming your weekly staking rewards.

## Step 1: Sign In and top up your USDC (Polygon) balance for gas

Navigate to the Gelato 1Balance page: <https://app.gelato.network/1balance>

Connect your wallet to the dapp on the top right corner and sign the Sign In message on your wallet.

Make sure you have USDC on Polygon network in your connected wallet. It is important to note that native USDC is needed, the bridged version cannot be used for this.

In the input field of the 1Balance page, input the amount of USDC you wish to be used as a gas tank for your claim transactions.

{% hint style="info" %}
Keep in mind that a claim transaction across supported networks varies between 0.05$ and 0.2$ executed per week.
{% endhint %}

After inputting USDC amount, click on the Deposit button and confirm the transaction.

## Step 2: Create a new task on Gelato functions page

After depositing USDC in the gas tank, navigate to the Gelato Functions page: <https://app.gelato.network/functions>

Click on the **`Create task`** button.

In the create task page, choose the **`Time Interval`** option, put the time frequency as 7 Days, 0 Hours, 0 Minutes and 0 Seconds. Uncheck the Start Immediately button and set the start time at the time you see fit.

In the **`What to trigger`** box, pick **`Transaction`**. In the Network section, pick the network on which you are staking your THALES.&#x20;

<figure><img src="/files/uuQAW6KnZWKXsjUbw6vv" alt="" width="563"><figcaption></figcaption></figure>

In the **`Contract Address`** input field, input the staking contract address of the network in which you are staking your THALES:

* Optimism staking contract:&#x20;
  * <img src="https://cdn.discordapp.com/emojis/885397024051179520.webp?size=56&#x26;quality=lossless" alt=":optimism:" data-size="line">`0xC392133eEa695603B51a5d5de73655d571c2CE51`
* Arbitrum staking contract:
  * <img src="/files/Rjh2jN7sVhzXhN1cSbqv" alt="" data-size="line">`0x160Ca569999601bca06109D42d561D85D6Bb4b57`
* Base staking contract:&#x20;
  * <img src="/files/fwvFadsFdnUNlXYTaQZe" alt="" data-size="line">`0x84aB38e42D8Da33b480762cCa543eEcA6135E040`

<figure><img src="/files/oAD67llDFsYOyA7Gi6Yf" alt=""><figcaption></figcaption></figure>

For the **`Function to be automated`** pick the **`claimRewardOnBehalf`** function.

In the <mark style="color:green;">`address`</mark>` ``account` field, input your address from which you are staking THALES.

As a final step, input how you want to name your task in Task Properties and then click on the **`Create Task`** button and confirm the transaction.

## Step 3: Whitelist your task to claim on your behalf on the Thales.io staking dapp

Open your newly created task page from here: <https://app.gelato.network/functions?type=tasks>

<figure><img src="/files/3rXxG6dehDiz5jRLcweU" alt=""><figcaption></figcaption></figure>

Click on your task and from the task page, copy the **`Dedicated message sender`** address.

Now navigate to thales.io dapp > TOKEN > STAKING > PREFERENCES page using this link: <https://www.thales.io/token/staking?tab=acc-preferences>

Make sure your wallet is connected and connected to the network you are staking your THALES with.

In the third field called `CLAIM ON BEHALF`, input the `Dedicated message sender` address you previously copied from the Gelato task page.

<figure><img src="/files/g89NXhQnUMRiWE6cSCUU" alt=""><figcaption></figcaption></figure>

After inputting the address, click `ENABLE` and confirm the transaction.

CONGRATULATIONS! You have now successfully automated your THALES staking reward claiming.


# Real Yield

All protocol fees accrued by the Thales Protocol smart contracts are distributed to THALES token stakers on a weekly basis

### Introduction to Protocol Rewards

All trades executed on Thales Protocol smart contracts (Sports Markets, Digital Options and Speed Markets) across all supported networks incur a **2% protocol fee**. Additionally, all liquidity providers of AMM contracts have a **20% performance fee on every positive weekly LP round that additionally compliments the fee accrual**.

With the Thales Protocol and its products experiencing maturing growth, the Thales Governance Structure decided that its time to start distributing 100% of all accrued fees to designated funds directly to THALES staking contracts.

**Starting from January 17th 2024, all weekly stablecoin accumulations of trading and LP performance fees are directly distributed to THALES token stakers.** Next to regular staking rewards of THALES tokens claimed by THALES stakers, weekly staking claims now also include stablecoin rewards gathered from global protocol usage.&#x20;

### Chain-agnostic Real Yield using Chainlink CCIP

{% embed url="<https://miro.medium.com/v2/resize:fit:640/format:webp/1*XOEfmUWEn7SVzwrG6oztYA.png>" %}

To make a more fair and efficient staking system that drastically improves User Experience across all supported networks, Thales Protocol additionally leverages Chainlinks Cross-Chain Interoperability Protocol (CCIP) so THALES staking becomes completely chain-agnostic.&#x20;

Using CCIP, regardless of which network you stake your THALES, you always get the same rewards per THALES staked as every staker on any network. This allows for an organic user acquisition for the Thales Protocol across Optimism, Arbitrum and Base where all stakers get an equal treatment. Not only are the THALES token rewards synchronized across networks, but the Protocol Rewards as well. Regardless of which network the fees accrue the most, you as a THALES staker on any supported network will get your fair share of stablecoin rewards as anyone else.

THALES staking continues with the regular snapshot based weekly reward claims, but from now on stakers claim Protocol Rewards in the form of stablecoins next to their regular THALES staking rewards. Protocol Reward claims will be denominated in whatever Thales Protocol uses as base collateral for the network where the claim is taking place:

* Stakers on **Optimism** will claim their Protocol Rewards in [sUSD](https://optimistic.etherscan.io/address/0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9)
* Stakers on **Arbitrum** will claim their Protocol Rewards in [USDC.e](https://arbiscan.io/token/0xff970a61a04b1ca14834a43f5de4533ebddb5cc8)
* Stakers on **Base** will claim their Protocol Rewards in [USDbC](https://basescan.org/token/0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA)


# Thales Governance Structure

Thales is governed by a trio of decentralized autonomous organizations (DAOs) which enable the community to manage the protocol.  Using DAOs as a structure for coordinating a community is one on the main innovations of DeFi.  The Synthetix governance structure is a foundational example of a functioning DAO, and because of this it has served as the inspiration for Thales governance.

Each of the three core DAOs work together to fill different roles within the protocol.  By distributing responsibility to community members who are voted in by their peers, Thales is able to maintain high levels of transparency and accessibility.  This type of representation allows the protocol to retain expert and experienced leadership without sacrificing the ability to react quickly to challenges.

{% hint style="info" %}
You can vote for Council Members from the **Optimism,** **Arbitrum and Base Networks,** with your voting power defined by staked THALES applied to either network.  You must stake THALES to acquire voting power.
{% endhint %}

### **The Thales Council**

In honor of the Seven Sages of Greece, the Thales Council will consist of 7 members elected by  token holders who have staked THALES in return for voting weight.  Each epoch will last 4 months.&#x20;

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2Fc9wlKv2bHdvS02PAbRhz%2F1_xhjewPXQjwrtEv3dhPBByQ.png?alt=media&token=0e6a56dc-73d4-4a82-8784-262abcd06c08>" %}

The duties of the Council Members include reviewing and voting on [Thales Improvement Proposals (TIPs)](broken://pages/WJmQ1tHEZT5hkKGKG5tl) submitted by the community.  TIPs represent potential changes to the core protocol that require strict vetting and must achieve some level of community consensus before reaching the Council.  TIP authors are interviewed by Council Members, who then debate the downfalls and merits of a TIP, before ultimately working with the Protocol DAO to assess any potential technical risks and eventually implement the change to the smart contracts.

To summarize, the community debates and submits proposals and votes on Representatives to review and vote on those proposals.  It's a little like owning stock in a TradFi company, but with more say in the direction of the product and with the unique benefits of using a blockchain; transparent and immutable records, open to everyone equally.&#x20;

### The Protocol DAO

The Protocol DAO is responsible for maintaining the core smart contacts that run the Thales protocol.  They control a multi-sig wallet that is used to initiate upgrades to the code-base and deploy new releases as requested by the Thales Council.  The Protocol DAO also implements successful TIPs and manages the day-to-day operational security necessary for a platform hosting millions of dollars in value. &#x20;

### The Thales DAO

The treasury is maintained by the Thales DAO. This DAO decides how to distribute incentives to the other DAOs in the form of stipends, as well as to community members and contributors for developing the protocol.  They also manage and maintain funds put aside to guarantee the security and health of the platform.

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2Fm57D4AobNsLDOYm2LR6s%2F3f8pnz.png?alt=media&token=6a29677b-a00f-41f0-bfbf-d3c1c05e9ff7>" %}

All three DAOs work together to achieve efficient and distributed community control.  This structure ensures that the users and token holders drive the protocol forward while maintaining the necessary level of decentralization and censorship resistance.


# Thales Improvement Proposals (TIPs)

TIPs are the catalyst for change within the Thales protocol.  These community submitted proposals can be anything from [formalizing the tokenomics of the platform ](https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-4.md)to [adding tradable assets to market feeds.](https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-3.md)  There is no central point of decision-making within the platform; proposals are thought up, discussed and vetted by the community until they reach a state of consensus and agreement that a specific change should move forward.  Only then can a TIP be submitted to the Council for consideration. &#x20;

### Incentivized TIPs

As per [TIP-154](https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-154.md), **submitter are incentivized with 500 USD worth of THALES tokens** for TIPs that pass the Thales Council vote! &#x20;

The creation and submission of TIPs is fairly formal and time consuming and very few TIPs are submitted my community members that are not current or past council members or core contributors.  **We want to see Thales evolve with the input of the entire community,** so now when a TIP is voted in **the author will receive 500 USD worth of THALES** via the Thales Treasury. &#x20;

{% hint style="info" %}
The following parameters must be met for a TIP author to become eligible for the incentive:

* The TIP must pass the voting process, with at least 5 of the 7 council members voting in favor of the TIP, or 7 out of 7 for meta-governance.&#x20;
* TIPs involving trivial parameter changes, such as Buyback & Burn updates, LP ratios and LP incentive amounts will be excluded.
* Core Contributors and Council Members are excluded.
  {% endhint %}

Once a TIP has been voted in with 5/7 (or 7/7 if meta governance) YES votes, the author is eligible for 500 USD worth of THALES distributed via Treasury.

The amount of THALES tokens required to equal 500 USD will be calculated at the time the incentive is sent, and will be based on the current rate obtained by the Treasury from a reputable source. &#x20;

This incentive will be delivered either via Discord Tipbot or by sent directly to an address provided to the Treasury by the author.  If a TIP is created and submitted by multiple authors the incentive amount will be split equally among each author.

### Steps to Create a Successful TIP

1. The community gives birth to an idea, shapes it, molds it, burnishes it in the fires of discussion.
2. Once enough support is evident, an author will use the [TIP Template](https://github.com/thales-markets/thales-improvement-proposals/blob/main/TIPs/TIP-1.md) to craft the proposal in the correct format.
3. TIPs are submitted by forking the [TIP GitHub Repository](https://github.com/thales-markets/thales-improvement-proposals) and adding the new TIP.
4. TIP Editors will reach out to the author and assist them with any edits required to make the TIP meet format and content standards.
5. Core Contributors will assist the TIP author with doing a feasibility study to ensure the TIP could be successful in practice.
6. A TIP is reviewed by the Thales Council and if the proposal is feasible, the Council will interview the author.
7. The Council will vote on the TIP using the [TIP tab](https://thalesmarket.io/governance/thalesgov.eth/) of the governance site. &#x20;
8. If successful, the Council will work with the Protocol DAO to merge the branch and officially deploy the update to the protocol.

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKSZyDhrhMxBqaXew1MHD%2Fuploads%2F3euyOGSNWO3VA1uHoL47%2Ftip%20flow.png?alt=media&token=eefaa1ea-66a0-4f54-acae-f58f78f37fce>" %}


# Smart Contract Audits

* [https://iosiro.com/audits/thales-binary-option-market-smart-contract-audit](<https://iosiro.com/audits/thales-binary-option-market-smart-contract-audit&#xA;https://iosiro.com/audits/thales-airdrop-and-staking-smart-contract-audit&#xA;https://iosiro.com/audits/thales-parlay-market-amm-smart-contract-audit&#xA;&#xA;https://github.com/decurity/audits/blob/master/ThalesMarket/thales-market-speedmarkets-audit-report-1.1.pdf&#xA;&#xA;>)
* [https://iosiro.com/audits/thales-airdrop-and-staking-smart-contract-audit](<https://iosiro.com/audits/thales-binary-option-market-smart-contract-audit&#xA;https://iosiro.com/audits/thales-airdrop-and-staking-smart-contract-audit&#xA;https://iosiro.com/audits/thales-parlay-market-amm-smart-contract-audit&#xA;&#xA;https://github.com/decurity/audits/blob/master/ThalesMarket/thales-market-speedmarkets-audit-report-1.1.pdf&#xA;&#xA;>)
* [https://iosiro.com/audits/thales-parlay-market-amm-smart-contract-audit](<https://iosiro.com/audits/thales-binary-option-market-smart-contract-audit&#xA;https://iosiro.com/audits/thales-airdrop-and-staking-smart-contract-audit&#xA;https://iosiro.com/audits/thales-parlay-market-amm-smart-contract-audit&#xA;&#xA;https://github.com/decurity/audits/blob/master/ThalesMarket/thales-market-speedmarkets-audit-report-1.1.pdf&#xA;&#xA;>)
* [https://github.com/decurity/audits/blob/master/ThalesMarket/thales-market-speedmarkets-audit-report-1.1.pdf\ <br>](<https://iosiro.com/audits/thales-binary-option-market-smart-contract-audit&#xA;https://iosiro.com/audits/thales-airdrop-and-staking-smart-contract-audit&#xA;https://iosiro.com/audits/thales-parlay-market-amm-smart-contract-audit&#xA;&#xA;https://github.com/decurity/audits/blob/master/ThalesMarket/thales-market-speedmarkets-audit-report-1.1.pdf&#xA;&#xA;>)


