RUNES

dotswap V3 Transaction request flow

dotswap V3 Swap interface

aggregate and calculate Swap quotes

post
Header parameters
AuthorizationstringRequired
User-IdstringRequired
User-AgentstringRequiredExample: Apifox/1.0.0 (https://apifox.com)
Content-TypestringRequiredExample: application/json
Body
fee_rateintegerRequired

with a minimum of 1, used to filter pools with no available UTXOs.

Responses
200Success
application/json
post
POST /dotswap/api/swap/quote HTTP/1.1
Host: test-api-proxy.ddpurse.com
Authorization: text
User-Id: text
User-Agent: text
Content-Type: application/json
Accept: */*
Content-Length: 2

{}
200Success
{
  "code": 1,
  "msg": "text",
  "data": {
    "quote_id": "text",
    "from_amount": "text",
    "to_amount": "text",
    "swap_method": "text",
    "pool_infos": [
      {
        "service_fee": 1,
        "name": "text",
        "third_party_id": 1,
        "third_party_address": "text",
        "pool_id": 1,
        "third_pool_id": 1,
        "pool_url": "text",
        "icon": "text",
        "from_tick": {
          "coin_type": "text",
          "tick": "text",
          "token_id": "text"
        },
        "to_tick": {
          "coin_type": "text",
          "tick": "text",
          "token_id": "text"
        },
        "from_tick_address": "text",
        "to_tick_address": "text",
        "from_balance": "text",
        "to_balance": "text",
        "from_margin": "text",
        "to_margin": "text",
        "from_to_fee_ratio": "text",
        "to_from_fee_ratio": "text",
        "dex_margin_percent": "text",
        "pool_type": "text",
        "sqrt_price": "text",
        "liquidity": null,
        "ServiceFeeRatio": 1,
        "deltaAmount": "text"
      }
    ]
  },
  "req_id": "text"
}

Use this interface to obtain the available swap amount.

For example, if you want to check how much YKO•KKK•KKK•KKK•KKK you can get for 0.1 BTC, then set from_token to btc and to_token to runes. Input the value of from_token.amount, and the interface will return to_amount, which represents the amount of YKO•KKK•KKK•KKK•KKK.

Please save the quote_id field from the current interface for use in subsequent requests.

Aggregate and create Swap PSBT

post
Header parameters
AuthorizationstringRequired
User-IdstringRequired
User-AgentstringRequiredExample: Apifox/1.0.0 (https://apifox.com)
Content-TypestringRequiredExample: application/json
Body
quote_idstringRequired

obtained from the calculation interface

fee_rateintegerRequired

with a minimum of 1, used for transaction construction.

btc_addressstringRequired
ord_addressstringRequired
pubkeystringRequired
slippageintegerRequired
use_bitcoin_channelbooleanRequired
inscriptionstring[]Required

required only for BRC20.

Responses
200Success
application/json
post
POST /dotswap/api/swap/create_psbt HTTP/1.1
Host: test-api-proxy.ddpurse.com
Authorization: text
User-Id: text
User-Agent: text
Content-Type: application/json
Accept: */*
Content-Length: 372

"{\n    \"Address\":\n    \"from_token\": {\n        \"coin_type\": \"btc\",\n        \"tick\": \"btc\",\n        \"token_id\": \"72\",\n        \"amount\": \"10000000\"\n    },\n    \"to_token\": {\n        \"coin_type\": \"runes\",\n        \"tick\": \"BITCOIN•TESTNET\",\n        \"token_id\": \"35\",\n        \"amount\": \"4944080\"\n    },\n    \"fee_rate\": 1\n}"
200Success
{
  "code": 1,
  "msg": "text",
  "data": {
    "request_id": "text",
    "psbts": [
      "text"
    ]
  },
  "req_id": "text"
}

1、The quote_id in this interface is the return value obtained from the quotation interface.

2、Please set use_bitcoin_channel to false by default, and set inscription to an empty array [].

Note: The current interface returns a psbts array. If the psbts array contains more than 0 items, you need to use signPsbts for signing. Otherwise, use signPsbt.

Aggregate and create a Swap order

post
Header parameters
AuthorizationstringRequired
User-IdstringRequired
User-AgentstringRequiredExample: Apifox/1.0.0 (https://apifox.com)
Content-TypestringRequiredExample: application/json
Body
request_idstringRequired

obtained from the PSBT creation

psbtsstring[]Required
psbt_is_base64booleanOptional

false:hex true:base64

Responses
200Success
application/json
post
POST /dotswap/api/swap/submit_psbt HTTP/1.1
Host: test-api-proxy.ddpurse.com
Authorization: text
User-Id: text
User-Agent: text
Content-Type: application/json
Accept: */*
Content-Length: 372

"{\n    \"Address\":\n    \"from_token\": {\n        \"coin_type\": \"btc\",\n        \"tick\": \"btc\",\n        \"token_id\": \"72\",\n        \"amount\": \"10000000\"\n    },\n    \"to_token\": {\n        \"coin_type\": \"runes\",\n        \"tick\": \"BITCOIN•TESTNET\",\n        \"token_id\": \"35\",\n        \"amount\": \"4944080\"\n    },\n    \"fee_rate\": 1\n}"
200Success
{
  "code": 1,
  "msg": "text",
  "data": {
    "order_id": "text",
    "tx_id": "text"
  },
  "req_id": "text"
}
  1. The request_id is obtained from the create_psbt response.

  2. Please set psbt_is_base64 according to your signing result; by default, it is usually false.

Last updated

Was this helpful?