31Third.
  • 👋Introduction
    • About 31Third
    • Use cases
    • 0x Labs Collaboration
    • Architecture
    • Team
  • 🤝31Third API
    • Overview
    • Healthcheck
    • Assets
      • Wallet
      • Enzyme
    • Swap
      • Get started
      • price
      • quote
    • Basket Trade (m:n swap)
      • async
      • Wallet
      • Enzyme
      • SetProtocol
    • Refresh Quotes
    • RFQ
  • ⛓️Protocol
    • Overview
    • Contracts
      • BatchTrade
      • Owner Privilege
    • Prohibition
    • Audit
    • Statistics
      • Gas cost analysis
    • Fees
  • 📚Resources
    • FAQ
    • Start trading
    • Discord
    • Twitter
Powered by GitBook
On this page
  • 31Third Basket Trade API flow
  • Step 1: Assets
  • Step 2: Settings
  • Step 3: Configure rebalancing
  • Step 4: Calculate rebalancing
  • Step 5: Show rebalancing
  • Step 6: Refresh Quotes
  • Step 7: Sign and execute
  1. 31Third API

Overview

PreviousTeamNextHealthcheck

Last updated 22 days ago

Every request requires specifying the following headers:

  • x-api-key

  • chain-id

The 31Third API is available under .

Swagger documentations can be found under:

  • General:

  • Enzyme:

The following chains are currently supported:

Name
Id

Ethereum Mainnet

0x1

Polygon Mainnet

0x89

OP Mainnet

0xa

[SOON] Base

0x2105

Arbitrum One

0xa4b1

[SOON] Blast

0x13e31

BNB Smart Chain

0x38

31Third Basket Trade API flow

The API flow for integrators looks as follows. All the steps are described in more details below.

Please note that the endpoints used in the picture are for basic wallet rebalancings, however similar endpoints exist for Enzyme vaults as well.

Step 1: Assets

You can either use your own or some external service to load token/asset data or use 31Third's asset endpoints. If you use some external source keep in mind that what don't support all existing tokens, so a rebalancing calculation might fail.

More details on assets:

  • Wallet

  • Enzyme

Step 2: Settings

(COMING SOON)

31Third supports multiple liquidity sources. The available sources can be fetched and then be used to configure the rebalancing calculation.

More details on settings:

  • COMING SOON

Step 3: Configure rebalancing

This can either be done by a user via an UI or through a script.

Step 4: Calculate rebalancing

Calculate the rebalancing with the 31Third API. It's possible to calculate rebalancings for wallets or protocol contracts (e.g. Enzyme vaults).

More details on rebalancings:

  • Wallet

  • Enzyme

Step 4.1: async

The calculation of rebalancings might take some seconds depending on how many assets are involved. Therefore all rebalancing endpoints have the option to calculate them async, show the progress to the user and then receive the rebalancing when the calculation is done.

More details on async:

  • async

Step 5: Show rebalancing

Show rebalancing with details to the user. Or if you use a script maybe do some checks or analysis on top.

Step 6: Refresh Quotes

After you calculated a rebalancing it might be that you have to refresh quotes. For example if you have a user interface and user don't directly execute received rebalancings.

More details on refreshing quotes:

  • Refresh Quotes

Step 7: Sign and execute

Users can now sign and execute the rebalancing on-chain. The following 3 params may be used for that:

txHandler

the contract address where the the data should be sent to

txData

the calldata to send to the contract

txValue

the native currency value sent with the tx (optional)

🤝
Get your API key
https://api.31third.com
https://api.31third.com/0.1/api
https://api.31third.com/0.1/api/enzyme
31Third API flow