# BRC20

When selecting the token pair and clicking to add liquidity, if it is a BRC20 token, you need to first request the pre-add/create interface.

## POST /brc20swap/v2/pre\_add\_liquid

> Pre-add liquidity

```json
{"openapi":"3.0.1","info":{"title":"Backend API","version":"1.0.0"},"servers":[{"url":"https://api-testnet4.dotswap.app","description":"Swap test"},{"url":"https://api.dotswap.app","description":"Swap official"}],"security":[],"paths":{"/brc20swap/v2/pre_add_liquid":{"post":{"summary":"Pre-add liquidity","deprecated":false,"description":"","tags":[],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"tick1":{"type":"string","title":"Coin name"},"tick2":{"type":"string"},"amount_1":{"type":"string","title":"Injection amount"},"amount_2":{"type":"string"},"tick_1_inscription_ids":{"type":"array","items":{"type":"string"},"title":"Inscription ID","description":"Used when recharging BRC20"},"tick_2_inscription_ids":{"type":"array","items":{"type":"string"}},"payer_ord_addr":{"type":"string","title":"Address"},"payer_btc_addr":{"type":"string"},"payer_pub_key":{"type":"string"},"fee_rate":{"type":"string","title":"Fee rate"},"slipper":{"type":"string","title":"Slippage"}},"required":["tick1","tick2","amount_1","amount_2","slipper","tick_1_inscription_ids","tick_2_inscription_ids","payer_ord_addr","fee_rate","payer_btc_addr","payer_pub_key"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer","additionalProperties":false},"msg":{"type":"string","additionalProperties":false},"data":{"type":"object","properties":{"tx_size":{"type":"integer","title":"Tx size","additionalProperties":false},"ins_contain_sats":{"type":"integer","title":"The sum of satoshis in the input inscriptions","additionalProperties":false},"vins":{"type":"array","items":{"type":"string","additionalProperties":false}},"usr_cnt":{"type":"integer","additionalProperties":false},"net_fee":{"type":"integer","title":"Network fee","additionalProperties":false},"check_sum":{"type":"string","title":"Checksum","additionalProperties":false}},"required":["net_fee","check_sum","tx_size","usr_cnt","vins"]},"req_id":{"type":"string","additionalProperties":false}},"required":["code","msg","data","req_id"]}}},"headers":{}}}}}}}
```

## Important Notes

{% hint style="info" %}

1. The result returned from this interface should be passed as is to the `create_add_liquid_psbt` interface.
2. Since liquidity is added based on a ratio and BRC20 needs to be inscribed first, creating BRC20-BRC20 token pair pools is not supported.
3. For the `tick_1_inscription_ids` and `tick_2_inscription_ids` parameters:

   * If `coin_type_1` is BRC20, put the BRC20 inscription ID in the `tick_1_inscription_ids` array and leave `tick_2_inscription_ids` empty.
   * If `coin_type_2` is BRC20, put the BRC20 inscription ID in the `tick_2_inscription_ids` array and leave `tick_1_inscription_ids` empty.

   *For the same token pair, BRC20-BTC and BTC-BRC20, the same pool is created or added to (e.g., ordi-BTC, BTC-ordi), just using different fields for the parameters.*

```
```

{% endhint %}

## POST /brc20swap/v2/create\_add\_liquid\_psbt

> Build the PSBT for adding BRC20 liquidity

```json
{"openapi":"3.0.1","info":{"title":"Backend API","version":"1.0.0"},"servers":[{"url":"https://api-testnet4.dotswap.app","description":"Swap test"},{"url":"https://api.dotswap.app","description":"Swap official"}],"security":[],"paths":{"/brc20swap/v2/create_add_liquid_psbt":{"post":{"summary":"Build the PSBT for adding BRC20 liquidity","deprecated":false,"description":"","tags":[],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"tick1":{"type":"string"},"tick2":{"type":"string"},"amount_1":{"type":"string"},"amount_2":{"type":"string"},"slipper":{"type":"string"},"tick_1_inscription_ids":{"type":"array","items":{"type":"string"}},"tick_2_inscription_ids":{"type":"array","items":{"type":"string"}},"payer_ord_addr":{"type":"string"},"fee_rate":{"type":"string"},"payer_btc_addr":{"type":"string"},"payer_pub_key":{"type":"string"},"check_sum":{"type":"string"},"vins":{"type":"array","items":{"type":"string"}}},"required":["tick1","tick2","amount_1","amount_2","slipper","tick_1_inscription_ids","tick_2_inscription_ids","payer_ord_addr","fee_rate","payer_btc_addr","payer_pub_key","check_sum","vins"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer"},"msg":{"type":"string"},"data":{"type":"object","properties":{"psbt":{"type":"string","title":"PSBT base64"},"ToSignInputs":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"type":{"type":"string"}},"required":["index","type"]}},"check_sum":{"type":"string"},"tx_size":{"type":"integer"},"usr_cnt":{"type":"integer"},"vins":{"type":"array","items":{"type":"string"}}},"required":["ToSignInputs","psbt","check_sum","tx_size","usr_cnt","vins"]},"req_id":{"type":"string"}},"required":["code","msg","data","req_id"]}}},"headers":{}}}}}}}
```

## Important Notes:

{% hint style="info" %}

1. Upon successful pre-add/create request, obtain the unsigned PSBT. Some of the request parameters will be from the pre-add/create request's return result.
2. Use the same address for both `payer_ord_addr` and `payer_btc_addr`.
   {% endhint %}

## POST /brc20swap/v2/add\_liquid\_by\_psbt

> Add liquidity

```json
{"openapi":"3.0.1","info":{"title":"Backend API","version":"1.0.0"},"servers":[{"url":"https://api-testnet4.dotswap.app","description":"Swap test"},{"url":"https://api.dotswap.app","description":"Swap official"}],"security":[],"paths":{"/brc20swap/v2/add_liquid_by_psbt":{"post":{"summary":"Add liquidity","deprecated":false,"description":"","tags":[],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"psbt":{"type":"string","title":"PSBT base64"},"tick1":{"type":"string"},"tick2":{"type":"string"},"amount_1":{"type":"string"},"amount_2":{"type":"string"},"slipper":{"type":"string"},"payer_ord_addr":{"type":"string"},"fee_rate":{"type":"string"},"payer_btc_addr":{"type":"string"},"payer_pub_key":{"type":"string"},"check_sum":{"type":"string"},"chl":{"type":"string"},"coin_type_1":{"type":"string"},"coin_type_2":{"type":"string"},"token":{"type":"string"}},"required":["tick1","coin_type_1","amount_1","tick2","coin_type_2","amount_2","fee_rate","slipper","token","payer_ord_addr","payer_btc_addr","payer_pub_key","psbt"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer"},"msg":{"type":"string"},"data":{"type":"object","properties":{"order_id":{"type":"string","title":"Order number"}},"required":["order_id"]},"req_id":{"type":"string"}},"required":["code","msg","data","req_id"]}}},"headers":{}}}}}}}
```

Finally, send the signed PSBT. If the response indicates success, the liquidity has been added/created successfully.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.on.nexus/dotswap/developers/l1-swap-and-liquidity-apis/liquidity-management/brc20.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
