⚙️Thales 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.

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 Tokenized Positional Markets or Tokenized Ranged Markets integration should be done with ThalesAMM or RangedAMM contract.

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

Buy a UP/DOWN position

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:

Buy UP tokens for 100 sUSD on BTC-35000@2023-11-07

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

  1. Get a buy quote for the market from Thales API

  2. Get a Thales AMM contract address for a specific network from Thales contracts

  3. Get a Thales AMM contract ABI from Thales contract repository contract repository

  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:

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:

Buy IN tokens for 100 sUSD on BTC-34000-38000@2023-11-07

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

  1. Get a buy quote for the market from Thales API

  2. Get a Ranged AMM contract address for a specific network from Thales contracts

  3. Get a Ranged AMM contract ABI from Thales contract repository contract repository

  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:

Last updated

Was this helpful?