Removing Liquidity

In this guide, we will use an example of DotSwap 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
post
/brc20swap/v2/pre_remove_liquid

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
post
/brc20swap/v2/create_remove_liquid_psbt

Example

Remove liquidity

post
Header parameters
AuthorizationstringOptional

token

User-IdstringOptional
Body
order_idstringRequired
psbtstringRequired
checksumstringRequired
Responses
200

Success

application/json
post
/brc20swap/v2/remove_liquid_by_psbt

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
post
/brc20swap/get_liquid_info

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