πŸ› οΈHODLMM API Documentation

This page provides endpoints and sample code for integrating with HODLMM.

API Usage and Documents

The BitFlow HODLMM API can be accessed via the below endpoints. Please reach out to the team for an API key.

const BFF_API_URL = 'https://bff.bitflowapis.finance/api';
const BFF_API_KEY = '<bitflow-assigned-api-key>';

fetch(url, {
  method: 'GET', // or 'POST'
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': BFF_API_KEY,
    // 'X-Allow-Fallback': false - disables on-chain fallback
  },
})
circle-info

Note: API keys will not be required during BETA

On-chain fallback

The BitFlow HODLMM API uses on-chain data as a fallback when database data becomes stale.

You can disable this behavior by setting:

X-Allow-Fallback: false

When disabled, the API will not query on-chain data and may return database stale data.

Strict vs Simple Mode

Strict mode is ideal for those looking to execute precise liquidity operations. These transactions can be broadcast in Deny mode and use exact bin IDs. If on-chain state changes in a way that affects your quoted bins/amounts, the transaction will revert (for example: if you’re trying to add to the active bin and it shifts by 1 before execution).

Simple mode is ideal for those looking to add liquidity with more flexibility and fewer failed transactions. These transactions can be broadcast in Allow mode and use offsets from the active bin ID rather than absolute bin IDs. Transactions are more likely to confirm even when on-chain state changes, since the liquidity operation is applied relative to the current active bin at the time of execution.

Adding Liquidity

1

Getting Pool Bins

Before adding liquidity, you need to get the pool's bins. You can do this via the following endpoint:

  • /quotes/v1/bins/{pool_id}: Returns all bins for a pool

This endpoint is a GET request.

circle-exclamation

On-chain fallback

2

Getting User Position Bins

After getting pool bins, you need to get the user's position bins. You can do this via the following endpoint:

  • /app/v1/users/{user_address}/positions/{pool_id}/bins: Returns position bins for a user for a pool

This endpoint is a GET request.

circle-exclamation

On-chain fallback

3

Preparing Bins for Add Liquidity

After getting pool bins and user positions, you need to prepare the bins with the amounts you want to add to each bin.

Read more about the different modes here.

4

Executing Add Liquidity

After preparing the bins to add, you can execute the add by calling the liquidity router contract with the necessary parameters.

Read more about the different modes here.


Withdrawing Liquidity

1

Getting User Position Bins

Before withdrawing liquidity, you need to get the user's position bins. You can do this via the following endpoint:

  • /app/v1/users/{user_address}/positions/{pool_id}/bins: Returns position bins for a user for a pool

This endpoint is a GET request.

circle-exclamation

On-chain fallback

2

Preparing Bins for Withdraw Liquidity

After getting user positions, you need to prepare the bins with the percentage you want to withdraw from each bin.

Read more about the different modes here.

3

Executing Withdraw Liquidity

After preparing the bins to withdraw, you can execute the withdrawal by calling the liquidity router contract with the necessary parameters.

Read more about the different modes here.


Moving Liquidity

1

Getting Pool Bins

Before moving liquidity, you need to get the pool's bins. You can do this via the following endpoint:

  • /quotes/v1/bins/{pool_id}: Returns all bins for a pool

This endpoint is a GET request.

circle-exclamation

On-chain fallback

2

Getting User Position Bins

After getting pool bins, you need to get the user's position bins. You can do this via the following endpoint:

  • /app/v1/users/{user_address}/positions/{pool_id}/bins: Returns position bins for a user for a pool

This endpoint is a GET request.

circle-exclamation

On-chain fallback

3

Preparing Bins for Move Liquidity

After getting pool bins and user positions, you need to prepare the bins you want to move liquidity from, to, and the amount of liquidity to move.

Read more about the different modes here.

4

Executing Move Liquidity

After preparing the bins to move, you can execute the move by calling the liquidity router contract with the necessary parameters.

Read more about the different modes here.


Swapping Tokens

1

Getting a Quote

Before executing a swap, you need to get a quote. You can do this via the following endpoints:

  • /quotes/v1/quote: Returns the best route

  • /quotes/v1/quote/multi: Returns all routes

These endpoints are POST requests and the request body is the same for both.

2

Getting Swap Parameters

After getting a quote, you need to generate the swap parameters. You can do this via the following endpoint:

  • /quotes/v1/swap: Returns the swap parameters for a route

This endpoint is a POST request.

3

Executing a Swap

After getting the swap parameters, you can execute the swap by calling the swap router contract with the necessary parameters.


Getting Data

Getting Available Tokens

You can get all available tokens via the following endpoint:

  • /quotes/v1/tokens: Returns all available tokens

This endpoint is a GET request.

Getting Available Pools

You can get all available pools via the following endpoint:

  • /quotes/v1/pools: Returns all available pools

This endpoint is a GET request.

Getting Available Pairs

You can get all available trading pairs via the following endpoint:

  • /quotes/v1/pairs: Returns all available trading pairs

This endpoint is a GET request.

Getting Pool Data

You can get Quote Engine data for a pool via the following endpoint:

  • quotes/v1/pools/{pool_id}: Returns Quote Engine data for a pool

This endpoint is a GET request.

Getting Pool Data (with tokens data)

You can get all data for a pool via the following endpoint:

  • app/v1/pools/{pool_id}: Returns all data for a pool

This endpoint is a GET request.

circle-exclamation

On-chain fallback

Getting Pool Bins

You can get all bins for a pool via the following endpoint:

  • /quotes/v1/bins/{pool_id}: Returns all bins for a pool

This endpoint is a GET request.

circle-exclamation

On-chain fallback

Getting Pool Bin Price History

You can get the bin price history for a pool via the following endpoint:

  • /app/v1/pools/{pool_id}/bin-price-history: Returns bin price history for a pool

This endpoint is a GET request.

Getting User Position for a Pool

You can get the position for a user for a pool via the following endpoint:

  • /app/v1/users/{user_address}/liquidity/{pool_id}: Returns position for a user for a pool

This endpoint is a GET request.

circle-exclamation

On-chain fallback

Getting User Position Bins for a Pool

You can get the position bins for a user for a pool via the following endpoint:

  • /app/v1/users/{user_address}/positions/{pool_id}/bins: Returns position bins for a user for a pool

This endpoint is a GET request.

circle-exclamation

On-chain fallback

Last updated