unisat-dev-docs

BRC20 Swap API

BRC20 Swap API provides a set of interfaces for BRC20 Swap and PizzaSwap services. It allows users to interact with the BRC20 Swap ecosystem, including balance checks, pool information, liquidity management, and token transfers.

👉 View Swagger UI


đź“‘ Table of Contents

Route Summary
GET /v1/brc20-swap/config Swap’s global configuration information.
GET /v1/brc20-swap/balance Gets the balance for the specified address and tick.
GET /v1/brc20-swap/pool_info Get Pool information based on trade pair.
GET /v1/brc20-swap/select Select the tick information that you can use based on the address.
GET /v1/brc20-swap/pre_deploy_pool Prepare deploy pool operation
POST /v1/brc20-swap/deploy_pool Deploy the pool operation.
GET /v1/brc20-swap/pre_add_liq Prepare add liquidity operation
POST /v1/brc20-swap/add_liq Add the liquidity operation
GET /v1/brc20-swap/pre_remove_liq Prepare remove liquidity operation
POST /v1/brc20-swap/remove_liq Remove the liquidity operation
GET /v1/brc20-swap/pre_send Prepare send operation
POST /v1/brc20-swap/pre_batch_send Prepare batch send operation
GET /v1/brc20-swap/pre_swap Prepare swap operation
POST /v1/brc20-swap/send The send operation.
POST /v1/brc20-swap/batch_send The batch send operation.
POST /v1/brc20-swap/swap The swap operation.
GET /v1/brc20-swap/pool_list Gets the pool list information.
GET /v1/brc20-swap/my_pool_list Gets the user’s pool list information.
GET /v1/brc20-swap/my_pool Gets the user pool information for the specified pair.
GET /v1/brc20-swap/overview An overview of swap information
GET /v1/brc20-swap/gas_history Gets the gas consumption records for a user aggregation operation.
GET /v1/brc20-swap/send_history Gets the history of send transaction.
GET /v1/brc20-swap/liq_history Gets the history of a pair addition pool.
GET /v1/brc20-swap/swap_history Gets the history of swap.
GET /v1/brc20-swap/rollup_history Get chain history of rollup inscription.
GET /v1/brc20-swap/deposit_list Gets the deposit list for a user.
GET /v1/brc20-swap/create_deposit Create a deposit psbt to be signed by the user.
POST /v1/brc20-swap/confirm_deposit User signature deposit psbt, submit confirmation.
GET /v1/brc20-swap/system_status Gets the current system state.
GET /v1/brc20-swap/withdraw_history Gets the user withdrawal history.
GET /v1/brc20-swap/create_retry_withdraw Retry create a withdraw psbt to be signed by the user.
POST /v1/brc20-swap/confirm_retry_withdraw User signature withdraw psbt, submit confirmation.
GET /v1/brc20-swap/create_withdraw Create a withdraw psbt to be signed by the user.
POST /v1/brc20-swap/confirm_withdraw User signature withdraw psbt, submit confirmation.
GET /v1/brc20-swap/withdraw_process Gets the withdrawal progress for the specified ID.

brc20-swap

Swap’s global configuration information.

Method: GET
Path: /v1/brc20-swap/config
Swagger Link: View in Swagger UI

Description

This interface provides the global configuration information for the BRC20 Swap service. It includes details such as the module ID, service gas tick, and pending deposit confirmation numbers.

Response (200)


Gets the balance for the specified address and tick.

Method: GET
Path: /v1/brc20-swap/balance
Swagger Link: View in Swagger UI

Description

This interface retrieves the balance for a specific address and tick in the BRC20 Swap service. It returns the confirmed module balance, swap balance, pending swap balance, and pending available balance.

Parameters

Response (200)


Get Pool information based on trade pair.

Method: GET
Path: /v1/brc20-swap/pool_info
Swagger Link: View in Swagger UI

Description

This interface retrieves the pool information for a specific trade pair in the BRC20 Swap service. It includes details such as whether the pool exists, if liquidity has been added, tick prices, LP quantity, TVL, volume, and rewards.

Parameters

Response (200)


Select the tick information that you can use based on the address.

Method: GET
Path: /v1/brc20-swap/select
Swagger Link: View in Swagger UI

Description

This interface retrieves the tick information that can be used for swapping based on the provided address. It returns the tick, decimal, BRC20 balance, and swap balance for each available tick.

Parameters

Response (200)


Prepare deploy pool operation

Method: GET
Path: /v1/brc20-swap/pre_deploy_pool
Swagger Link: View in Swagger UI

Description

This interface pre-loads the /deploy_pool operation, providing the signature content, gas, and byte information required for deploying a pool in the BRC20 Swap service.

Parameters

Response (200)


Deploy the pool operation.

Method: POST
Path: /v1/brc20-swap/deploy_pool
Swagger Link: View in Swagger UI

Description

This interface deploys a pool in the BRC20 Swap service. It requires the address, tick0, tick1, timestamp, fee tick, and user signatures to complete the operation.

Response (200)


Prepare add liquidity operation

Method: GET
Path: /v1/brc20-swap/pre_add_liq
Swagger Link: View in Swagger UI

Description

This interface pre-loads the /add_liq operation, providing the signature content, gas, and byte information required for adding liquidity in the BRC20 Swap service.

Parameters

Response (200)


Add the liquidity operation

Method: POST
Path: /v1/brc20-swap/add_liq
Swagger Link: View in Swagger UI

Description

This interface adds liquidity to a pool in the BRC20 Swap service. It requires the address, tick0, tick1, amounts, LP, slippage, timestamp, fee tick, and user signatures to complete the operation.

Response (200)


Prepare remove liquidity operation

Method: GET
Path: /v1/brc20-swap/pre_remove_liq
Swagger Link: View in Swagger UI

Description

This interface pre-loads the /remove_liq operation, providing the signature content, gas, and byte information required for removing liquidity in the BRC20 Swap service.

Parameters

Response (200)


Remove the liquidity operation

Method: POST
Path: /v1/brc20-swap/remove_liq
Swagger Link: View in Swagger UI

Description

This interface removes liquidity from a pool in the BRC20 Swap service. It requires the address, tick0, tick1, amounts, LP, slippage, timestamp, fee tick, and user signatures to complete the operation.

Response (200)


Prepare send operation

Method: GET
Path: /v1/brc20-swap/pre_send
Swagger Link: View in Swagger UI

Description

This interface pre-loads the /send operation, providing the signature content, gas, and byte information required for sending a tick in the BRC20 Swap service.

Parameters

Response (200)


Prepare batch send operation

Method: POST
Path: /v1/brc20-swap/pre_batch_send
Swagger Link: View in Swagger UI

Description

This interface pre-loads the /batch_send operation, providing the signature content, gas, and byte information required for sending multiple ticks in the BRC20 Swap service.

Response (200)


Prepare swap operation

Method: GET
Path: /v1/brc20-swap/pre_swap
Swagger Link: View in Swagger UI

Description

This interface pre-loads the /swap operation, providing the signature content, gas, and byte information required for swapping ticks in the BRC20 Swap service.

Parameters

Response (200)


The send operation.

Method: POST
Path: /v1/brc20-swap/send
Swagger Link: View in Swagger UI

Description

This interface sends a tick in the BRC20 Swap service. It requires the address, tick, amount, receiver, timestamp, fee tick, and user signatures to complete the operation.

Response (200)


The batch send operation.

Method: POST
Path: /v1/brc20-swap/batch_send
Swagger Link: View in Swagger UI

Description

This interface sends multiple ticks in the BRC20 Swap service. It requires the address, tick, amount, receivers, timestamp, fee tick, and user signatures to complete the operation.

Response (200)


The swap operation.

Method: POST
Path: /v1/brc20-swap/swap
Swagger Link: View in Swagger UI

Description

This interface swaps ticks in the BRC20 Swap service. It requires the address, input tick, output tick, input amount, output amount, slippage, exact type, timestamp, fee tick, and user signatures to complete the operation.

Response (200)


Gets the pool list information.

Method: GET
Path: /v1/brc20-swap/pool_list
Swagger Link: View in Swagger UI

Description

This interface retrieves the pool list information in the BRC20 Swap service. It supports filtering by address, tick, and fuzzy matching, and allows pagination through start and limit parameters.

Parameters

Response (200)


Gets the user’s pool list information.

Method: GET
Path: /v1/brc20-swap/my_pool_list
Swagger Link: View in Swagger UI

Description

This interface retrieves the user’s pool list information in the BRC20 Swap service. It supports filtering by address, tick, and pagination through start and limit parameters.

Parameters

Response (200)


Gets the user pool information for the specified pair.

Method: GET
Path: /v1/brc20-swap/my_pool
Swagger Link: View in Swagger UI

Description

This interface retrieves the user pool information for a specific pair in the BRC20 Swap service. It requires the address, tick0, and tick1 parameters to identify the pool.

Parameters

Response (200)


An overview of swap information

Method: GET
Path: /v1/brc20-swap/overview
Swagger Link: View in Swagger UI

Description

This interface provides an overview of the swap information in the BRC20 Swap service, including total liquidity, 7-day volume, 24-hour volume, number of transactions, and number of pairs.

Response (200)


Gets the gas consumption records for a user aggregation operation.

Method: GET
Path: /v1/brc20-swap/gas_history
Swagger Link: View in Swagger UI

Description

This interface retrieves the gas consumption records for a user aggregation operation in the BRC20 Swap service. It supports filtering by address and pagination through start and limit parameters.

Parameters

Response (200)


Gets the history of send transaction.

Method: GET
Path: /v1/brc20-swap/send_history
Swagger Link: View in Swagger UI

Description

This interface retrieves the history of send transactions in the BRC20 Swap service. It supports filtering by address, tick, and pagination through start and limit parameters.

Parameters

Response (200)


Gets the history of a pair addition pool.

Method: GET
Path: /v1/brc20-swap/liq_history
Swagger Link: View in Swagger UI

Description

This interface retrieves the history of pair addition pools in the BRC20 Swap service. It supports filtering by address, tick, type (add or remove), and pagination through start and limit parameters.

Parameters

Response (200)


Gets the history of swap.

Method: GET
Path: /v1/brc20-swap/swap_history
Swagger Link: View in Swagger UI

Description

This interface retrieves the history of swap transactions in the BRC20 Swap service. It supports filtering by address, tick, and pagination through start and limit parameters.

Parameters

Response (200)


Get chain history of rollup inscription.

Method: GET
Path: /v1/brc20-swap/rollup_history
Swagger Link: View in Swagger UI

Description

This interface retrieves the chain history of rollup inscriptions in the BRC20 Swap service. It supports filtering by inscription ID and pagination through start and limit parameters.

Parameters

Response (200)


Gets the deposit list for a user.

Method: GET
Path: /v1/brc20-swap/deposit_list
Swagger Link: View in Swagger UI

Description

This interface retrieves the deposit list for a user in the BRC20 Swap service. It supports filtering by address, tick, and pagination through start and limit parameters.

Parameters

Response (200)


Create a deposit psbt to be signed by the user.

Method: GET
Path: /v1/brc20-swap/create_deposit
Swagger Link: View in Swagger UI

Description

This interface creates a deposit PSBT to be signed by the user in the BRC20 Swap service. It requires the inscription ID, public key, and address parameters to generate the PSBT.

Parameters

Response (200)


User signature deposit psbt, submit confirmation.

Method: POST
Path: /v1/brc20-swap/confirm_deposit
Swagger Link: View in Swagger UI

Description

This interface allows the user to sign the deposit PSBT and submit the confirmation in the BRC20 Swap service. It requires the PSBT and inscription ID to complete the operation.

Response (200)


Gets the current system state.

Method: GET
Path: /v1/brc20-swap/system_status
Swagger Link: View in Swagger UI

Description

This interface retrieves the current system state of the BRC20 Swap service, including whether rollup inscription committing is enabled.

Response (200)


Gets the user withdrawal history.

Method: GET
Path: /v1/brc20-swap/withdraw_history
Swagger Link: View in Swagger UI

Description

This interface retrieves the user withdrawal history in the BRC20 Swap service. It supports filtering by address, pagination through start and limit parameters, and an optional tick parameter.

Parameters

Response (200)


Retry create a withdraw psbt to be signed by the user.

Method: GET
Path: /v1/brc20-swap/create_retry_withdraw
Swagger Link: View in Swagger UI

Description

This interface retries to create a withdrawal PSBT to be signed by the user in the BRC20 Swap service. It requires the withdrawal order ID, public key, and address parameters to generate the PSBT.

Parameters

Response (200)


User signature withdraw psbt, submit confirmation.

Method: POST
Path: /v1/brc20-swap/confirm_retry_withdraw
Swagger Link: View in Swagger UI

Description

This interface allows the user to sign the retry withdrawal PSBT and submit the confirmation in the BRC20 Swap service. It requires the withdrawal order ID, payment PSBT, and approve PSBT to complete the operation.

Response (200)


Create a withdraw psbt to be signed by the user.

Method: GET
Path: /v1/brc20-swap/create_withdraw
Swagger Link: View in Swagger UI

Description

This interface creates a withdrawal PSBT to be signed by the user in the BRC20 Swap service. It requires the public key, address, tick, amount, timestamp, and fee tick parameters to generate the PSBT.

Parameters

Response (200)


User signature withdraw psbt, submit confirmation.

Method: POST
Path: /v1/brc20-swap/confirm_withdraw
Swagger Link: View in Swagger UI

Description

This interface allows the user to sign the withdrawal PSBT and submit the confirmation in the BRC20 Swap service. It requires the withdrawal order ID, payment PSBT, approve PSBT, fee tick, and optional fee amount to complete the operation.

Response (200)


Gets the withdrawal progress for the specified ID.

Method: GET
Path: /v1/brc20-swap/withdraw_process
Swagger Link: View in Swagger UI

Description

This interface retrieves the withdrawal progress for a specific ID in the BRC20 Swap service. It requires the ID parameter to identify the withdrawal order.

Parameters

Response (200)