Overview

Every request requires specifying the following headers:

  • x-api-key

  • chain-id

Get your API key

The 31Third API is available under https://api.31third.com.

Swagger documentations can be found under:

The following chains are currently supported:

NameId

Ethereum Mainnet

0x1

Polygon Mainnet

0x89

OP Mainnet

0xa

[SOON] Base

0x2105

[SOON] Arbitrum One

0xa4b1

[SOON] Blast

0x13e31

[SOON] BNB Smart Chain

0x38

31Third 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:

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:

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:

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:

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)

Last updated