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.

Pre-add liquidity

post
Body
tick1stringRequired
tick2stringRequired
amount_1stringRequired
amount_2stringRequired
tick_1_inscription_idsstring[]Required

Used when recharging BRC20

tick_2_inscription_idsstring[]Required
payer_ord_addrstringRequired
payer_btc_addrstringRequired
payer_pub_keystringRequired
fee_ratestringRequired
slipperstringRequired
Responses
200Success
application/json
post
POST /brc20swap/v2/pre_add_liquid HTTP/1.1
Host: test-api-proxy.ddpurse.com
Content-Type: application/json
Accept: */*
Content-Length: 364

{
  "tick1": "sint amet aliquip reprehenderit",
  "tick2": "sint et",
  "coin_type_1": "nostrud",
  "coin_type_2": "nisi",
  "amount_1": "86",
  "amount_2": "44",
  "tick_1_inscription_ids": [
    "32",
    "44",
    "21",
    "11",
    "55"
  ],
  "tick_2_inscription_ids": [
    "17",
    "55",
    "23",
    "74",
    "41"
  ],
  "payer_ord_addr": "dolor in id",
  "fee_rate": "cillum aute",
  "payer_btc_addr": "irure sit culpa ea sed",
  "payer_pub_key": "minim"
}
{
  "code": 1,
  "msg": "text",
  "data": {
    "tx_size": 1,
    "ins_contain_sats": 1,
    "vins": [
      "text"
    ],
    "usr_cnt": 1,
    "net_fee": 1,
    "check_sum": "text"
  },
  "req_id": "text"
}

Important Notes

  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.

Build the PSBT for adding BRC20 liquidity

post
Body
tick1stringRequired
tick2stringRequired
amount_1stringRequired
amount_2stringRequired
slipperstringRequired
tick_1_inscription_idsstring[]Required
tick_2_inscription_idsstring[]Required
payer_ord_addrstringRequired
fee_ratestringRequired
payer_btc_addrstringRequired
payer_pub_keystringRequired
check_sumstringRequired
vinsstring[]Required
Responses
200Success
application/json
post
POST /brc20swap/v2/create_add_liquid_psbt HTTP/1.1
Host: test-api-proxy.ddpurse.com
Content-Type: application/json
Accept: */*
Content-Length: 276

{
  "tick1": "text",
  "tick2": "text",
  "amount_1": "text",
  "amount_2": "text",
  "slipper": "text",
  "tick_1_inscription_ids": [
    "text"
  ],
  "tick_2_inscription_ids": [
    "text"
  ],
  "payer_ord_addr": "text",
  "fee_rate": "text",
  "payer_btc_addr": "text",
  "payer_pub_key": "text",
  "check_sum": "text",
  "vins": [
    "text"
  ]
}
{
  "code": 1,
  "msg": "text",
  "data": {
    "psbt": "text",
    "ToSignInputs": [
      {
        "index": 1,
        "type": "text"
      }
    ],
    "check_sum": "text",
    "tx_size": 1,
    "usr_cnt": 1,
    "vins": [
      "text"
    ]
  },
  "req_id": "text"
}

Important Notes:

  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.

Add liquidity

post
Body
psbtstringRequired
tick1stringRequired
tick2stringRequired
amount_1stringRequired
amount_2stringRequired
slipperstringRequired
payer_ord_addrstringRequired
fee_ratestringRequired
payer_btc_addrstringRequired
payer_pub_keystringRequired
check_sumstringOptional
chlstringOptional
coin_type_1stringRequired
coin_type_2stringRequired
tokenstringRequired
Responses
200Success
application/json
post
POST /brc20swap/v2/add_liquid_by_psbt HTTP/1.1
Host: test-api-proxy.ddpurse.com
Content-Type: application/json
Accept: */*
Content-Length: 1928

{
  "tick1": "SHE•SHE•SHE•SHE•SHE",
  "coin_type_1": "runes",
  "amount_1": "1000",
  "tick2": "BTC",
  "coin_type_2": "btc",
  "amount_2": "1000",
  "fee_rate": "2",
  "slipper": "12",
  "token": "ee1f8f9acc00000:0",
  "payer_ord_addr": "tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e",
  "payer_btc_addr": "tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e",
  "payer_pub_key": "02d3ac7452920b1cc4653516dd4f4381a2df0a8c0aac6e3446e633a73ea63eee81:02d3ac7452920b1cc4653516dd4f4381a2df0a8c0aac6e3446e633a73ea63eee81",
  "psbt": "70736274ff0100fd88010200000002fc20c54d42ccd93abc7c4d1f15c988d940b635d62222e230246bacc0239f73ef0800000000fffffffffc20c54d42ccd93abc7c4d1f15c988d940b635d62222e230246bacc0239f73ef0000000000ffffffff094a01000000000000160014464ef3759fcfb1eb3d76f3319ef58ec20301c6584a01000000000000160014018960754f34943aa8ffa8cccdc56e1a875fa1274a01000000000000160014018960754f34943aa8ffa8cccdc56e1a875fa1274a01000000000000160014018960754f34943aa8ffa8cccdc56e1a875fa1274a01000000000000160014018960754f34943aa8ffa8cccdc56e1a875fa1274a01000000000000160014018960754f34943aa8ffa8cccdc56e1a875fa12700000000000000001f6a5d1c00b29a040dc801010000c801020000c801030000c801040000c80105e8030000000000002200206a72120e03ad7415a95610879860d1be85e0301cf84369a228a2bb313e46fdf3dc16000000000000160014464ef3759fcfb1eb3d76f3319ef58ec20301c658000000000001011fb324000000000000160014464ef3759fcfb1eb3d76f3319ef58ec20301c65801086c02483045022100bf5297dd65decb812cff9d20f3ea912f40e63f23159f4a86ddf7b5e644e5cfb102201474cb363601e373459d89ea12534c8aacb730d9ca43b0a703667b789e313b94012102d3ac7452920b1cc4653516dd4f4381a2df0a8c0aac6e3446e633a73ea63eee810001011f4a01000000000000160014464ef3759fcfb1eb3d76f3319ef58ec20301c65801086b0247304402206a76f519f02f52f16ccd71f6d94f7dd8a639a82609aadc9845f301004300cbe302203d244b00effd66f7c081a2510a1a79ab8efdc6b8463fc97f2997e692f2aeef75012102d3ac7452920b1cc4653516dd4f4381a2df0a8c0aac6e3446e633a73ea63eee8100000000000000000000",
  "check_sum": "74F36E9221834B276DBE1DFFD6AAA054"
}
{
  "code": 0,
  "msg": "",
  "data": {
    "order_id": "liquid_1072411956272431104"
  },
  "req_id": "1887758755461242880"
}

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

Last updated