RUNES

dotswap V3 交易请求流程

dotswap V3 交易接口

聚合计算Swap报价

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

最小为1,用于过滤无可用UTXO的池子

Responses
200Success
application/json
post
/dotswap/api/swap/quote
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"
}

通过这个接口获取可兑换的数量。

例如:你想查询,0.1btc 可获得多少 YKO•KKK•KKK•KKK•KKK。那么 from_token 则为 btcto_tokenrunes,输入 from_token.amount 的值,接口返回的 to_amount 就是 YKO•KKK•KKK•KKK•KKK 的数量。

请保存当前接口的quote_id字段给后续接口使用。注意quote_id有效时间为 35s,请在有效时间内使用,否则你需要重新请求新的。

聚合创建Swap psbt

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

从计算接口获取

fee_rateintegerRequired

最小为1,用于构建交易

btc_addressstringRequired
ord_addressstringRequired
pubkeystringRequired
slippageintegerRequired
use_bitcoin_channelbooleanRequired
inscriptionstring[]Required

仅brc20需要

Responses
200Success
application/json
post
/dotswap/api/swap/create_psbt
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、这个接口的 quote_id 就是从报价接口中获取到的返回值。

2、use_bitcoin_channel请默认传falseinscription 默认传 []

注意:当前接口返回的是psbts数组,如果psbts数组大于 0,你需要使用 signPsbts 签名。否则使用 signPsbt 即可

聚合创建Swap订单

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

从创建psbt获取

psbtsstring[]Required
psbt_is_base64booleanOptional

false:hex true:base64

Responses
200Success
application/json
post
/dotswap/api/swap/submit_psbt
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、request_id 是你从create_psbt获取到的

2、psbt_is_base64 请和你的签名结果对应。默认一般是false

Last updated