Version: current

Performing Atomic Swaps

Atomic Swaps enable you to exchange assets with another member on the Qredo Network. Quotes can be shared with individual members or posted to the Liquidity Hub for all members.

The member you want to trade with must have a fund containing both assets you want to swap with (e.g. ETH & BTC).

Overview of Steps#

  1. A Maker creates and posts their quote.
  2. The quote is authorized by the Maker's Custodians.
  3. The quote is added to the Liquidity Hub OR passed directly to another Network Member.
  4. A potential Taker views quotes on the Liquidity Hub
  5. A Taker uses the swap transaction_id to take the quote.
  6. The quote is authorized by the Taker's Custodians
  7. The Atomic swap completes in a single transaction.

STEP 01 - Create Atomic Swap#

  1. Select a fund with required assets and quantities to swap with and note its fund_id.

  2. Specify the assets and quantities you want to send and receive.

  3. Set an expiry time for the swap.

  4. Use this endpoint to make a quote and initiate an Atomic Swap.

POST https://api.qredo.net/api/v1/p/company/{company_id}/atomicswap/make

EXAMPLE ATOMIC SWAP MAKE REQUEST#

curl -X POST "https://api.qredo.net/api/v1/p/company/<MAKER_COMPANY_ID>/atomicswap/make"
-H "accept: application/json"
-H "X-API-KEY: <YOUR_API_KEY>"
-H "Content-Type: application/json"
-d "
{
"fund_id": "<MAKER_FUND_ID>",
"expires": 1640998800,
"reference": "CX15R99XX",
"send": {
"symbol": "BTC",
"amount": 800
},
"receive": {
"symbol": "ETH",
"amount": 2536
}
}

EXAMPLE ATOMIC SWAP MAKE RESPONSE#

{
"tx_id": "bda3daa7c3************eec4eae4e80",
"tx_url": "https://qredo.network/aswp<tx_id>"
}

STEP 02 - Custodial Approval - Maker side#

Once an Atomic Swap request has been made it must be approved by Custodians before it can be taken. This is either by the Custodian's Qredo Signing App or via the Qredo Core Client.

STEP 03 - Post to Liquidity Hub#

The Liquidity Hub is the place to broadcast quotes and view available quotes.

  1. Add your Atomic Swap quote using the tx_id obtained in the first step.

  2. Use the Maker company_id.

  3. A standard HTTP 200 OK response is returned.

The Atomic Swap quote is now viewable by all members of the network.

EXAMPLE ATOMIC SWAP REQUEST#

curl -X POST "https://api.qredo.net/api/v1/p/company/{company_id}/liquidityhub"
-H "accept: application/json"
-H "X-API-KEY: <YOUR_API_KEY>"
-H "Content-Type: application/json"
-d "
{
"tx_id": "1lm519eiGT**********HrEYvSBuSn"
}

STEP 04 - Retrieve all Active Swaps#

As a potential Taker, you can view all active Swaps at the Liquidity Hub in two ways:

1. Liquidity Hub endpoint#

Use this endpoint to get a list of all active swaps:

curl -X GET "https://api.qredo.net/api/v1/p/company/<COMPANY_ID>/atomicswap/make"

Use a specific company_id to view all Atomic Swaps associated with that company. These will be indicated in the 'Owner' field of the response.

EXAMPLE LIQUIDITY HUB RESPONSE#

{"items":
[
{
"tx_id":"ioaco989089jkYn",
"send_amount": 800,
"send_asset": "ETH",
"receive_amount": "BTC",
"receive_asset": "ETH",
"owner": false,
"expires": 189896876,
"added":198787878
}
]
}

2. Liquidity Hub Websocket Feed#

Use this endpoint to get a real-time feed of all active swaps in the Liquidity Hub.

wss://api.qredo.network/api/v1/p/liquidityhub/feed

STEP 05 - Take the Quote#

  1. Use the Swap transaction_id from the Maker to perform the Swap.

  2. You can also use the transaction_id to get more details about the quote using the following endpoint.

curl -X GET "https://api.qredo.net/api/v1/p/company/<COMPANY_ID>/atomicswap/make/{tx_id}"
  1. Select a fund with the required assets and quantities to receive and send.

  2. Complete the swap at the following endpoint:

curl -X POST "https://api.qredo.net/api/v1/p/company/<COMPANY_ID>/atomicswap/take/"

Use your fund_id, the swap_id and your reference to take the quote before it expires.

EXAMPLE ATOMIC SWAP TAKE REQUEST#

curl -X POST "https://api.qredo.net/api/v1/p/company/{company_id}/atomicswap/take"
-H "accept: application/json"
-H "X-API-KEY: <YOUR_API_KEY>"
-H "Content-Type: application/json"
-d "
{
"swap_id": "1l65SpjcfhSEgjObPPHU7vwTNzb",
"fund_id": "1l62uLH2KKuXpb4hNIgp7DLWGRN",
"reference": "CX15R99XX"
}

STEP 06 - Custodial Approval - Taker side#

Once a request has been made it must be approved by Custodians before it can be taken. This is either by the Custodian's Qredo Signing App or via the Qredo Core Client.

STEP 07 - Swap Completes#

Successful completion of the Atomic Swap returns a new tx_id.

View Transaction Status using the tx_id.

Retrieve Holdings to confirm the Swap has executed.