For the complete documentation index, see llms.txt. This page is also available as Markdown.

Removing Liquidity

In this guide, we will use an example of Nexus process to show how to remove liquidity from a pool, which includes:

  • Removing

    • Pre-remove Request

    • Get Unsigned Remove PSBT

    • Send Signed Remove PSBT

  • Get Estimated Remove Amount

The removing interface for Runes/BRC20/ARC20 is the same, differentiated by coin_type_*.

Pre-remove liquidity

post
Header parameters
AuthorizationstringOptional

token

User-IdstringOptional
Body
tick1stringRequired
tick2stringRequired
coin_type_1stringRequired
coin_type_2stringRequired
percentstringRequired
payer_btc_addrstringRequired
payer_ord_addrstringRequired
payer_pub_keystringRequired
slipperstringRequired
fee_ratestringRequired
Responses
200

Success

application/json
codeintegerRequired
msgstringRequired
req_idstringRequired
post/brc20swap/v2/pre_remove_liquid
POST /brc20swap/v2/pre_remove_liquid HTTP/1.1
Content-Type: application/json
Accept: */*
Content-Length: 196

{
  "tick1": "text",
  "tick2": "text",
  "coin_type_1": "text",
  "coin_type_2": "text",
  "percent": "text",
  "payer_btc_addr": "text",
  "payer_ord_addr": "text",
  "payer_pub_key": "text",
  "slipper": "text",
  "fee_rate": "text"
}
{
  "code": 1,
  "msg": "text",
  "data": {
    "expect_amount1": "text",
    "expect_amount2": "text",
    "expect_transfer_fee": 1,
    "check_sum": "text",
    "tx_size": 1,
    "usr_cnt": 1,
    "vins": [
      "text"
    ]
  },
  "req_id": "text"
}

Example

The returned result should be passed as is to the create_remove_liquid_psbt (the following interface).

Create remove liquidity PSBT

post
Header parameters
AuthorizationstringOptional

token

User-IdstringOptional
Body
tick1stringRequired
tick2stringRequired
coin_type_1stringRequired
coin_type_2stringRequired
percentstringRequired
payer_btc_addrstringRequired
payer_ord_addrstringRequired
payer_pub_keystringRequired
slipperstringRequired
fee_ratestringRequired
expect_amount1stringRequired
expect_amount2stringRequired
expect_transfer_feeintegerRequired
check_sumstringRequired
tx_sizeintegerRequired
usr_cntintegerRequired
vinsstring[]Required
Responses
200

Success

application/json
codeintegerRequired
msgstringRequired
req_idstringRequired
post/brc20swap/v2/create_remove_liquid_psbt
POST /brc20swap/v2/create_remove_liquid_psbt HTTP/1.1
Content-Type: application/json
Accept: */*
Content-Length: 327

{
  "tick1": "text",
  "tick2": "text",
  "coin_type_1": "text",
  "coin_type_2": "text",
  "percent": "text",
  "payer_btc_addr": "text",
  "payer_ord_addr": "text",
  "payer_pub_key": "text",
  "slipper": "text",
  "fee_rate": "text",
  "expect_amount1": "text",
  "expect_amount2": "text",
  "expect_transfer_fee": 1,
  "check_sum": "text",
  "tx_size": 1,
  "usr_cnt": 1,
  "vins": [
    "text"
  ]
}
{
  "code": 1,
  "msg": "text",
  "data": {
    "order_id": "text",
    "psbt": "text",
    "checksum": "text"
  },
  "req_id": "text"
}

Example

Remove liquidity

post
Header parameters
AuthorizationstringOptional

token

User-IdstringOptional
Body
order_idstringRequired
psbtstringRequired
checksumstringRequired
Responses
200

Success

application/json
codeintegerRequired
msgstringRequired
datanullRequired
req_idstringRequired
post/brc20swap/v2/remove_liquid_by_psbt
POST /brc20swap/v2/remove_liquid_by_psbt HTTP/1.1
Content-Type: application/json
Accept: */*
Content-Length: 96

{
  "order_id": "text",
  "psbt": "text",
  "checksum": "text",
  "to_sign_inputs": [
    {
      "index": 1,
      "type": "text"
    }
  ]
}
{
  "code": 1,
  "msg": "text",
  "data": null,
  "req_id": "text"
}

Example

Get liquidity pool info based on removal ratio

post
Header parameters
AuthorizationstringOptional

token

User-IdstringOptional
Body
addressstringRequired
lp_precentintegerRequired

Decimal, Percentage, Integer

from_tickstringRequired

Only BTC for now

to_tickstringRequired
from_coin_typestringRequired
to_coin_typestringRequired
Responses
200

Success

application/json
codeintegerRequired
msgstringRequired
post/brc20swap/get_liquid_info
POST /brc20swap/get_liquid_info HTTP/1.1
Content-Type: application/json
Accept: */*
Content-Length: 115

{
  "address": "text",
  "lp_precent": 1,
  "from_tick": "text",
  "to_tick": "text",
  "from_coin_type": "text",
  "to_coin_type": "text"
}
{
  "code": 1,
  "msg": "text",
  "data": {
    "from_amount": "text",
    "to_amount": "text",
    "mutisign_fee_proportion": "text"
  }
}

Example

Explanation on Fees

The actual amount received by the user will have the key custodial service's fee deducted, which is calculated using the mutisign_fee_proportion field returned by the backend (initially 0.3%, and may adjust in the future if the key custodial service changes).

Fee Calculation

  • Removing BTC-BRC20: Fee = BTC satoshi amount * 0.3%

  • Removing BTC-ARC20: Fee = BTC satoshi amount * 0.3% + ARC20 satoshi amount * 0.3%

  • Removing BRC20-BRC20: Free

Calculation of the Actual Amount Received by the User:

The estimated amount will change in real-time based on the total token amount in the liquidity pool. Your frontend can perform polling requests to obtain the latest estimate.

Last updated