Skip to content

Exchange custody and sweeps

This section describes the exchange custody over transactions and custody of dedicated and multi-counterparty wallets.

Exchange standpoint: Dedicated vs multi-counterparty wallets

An Exchange acts as an additional approver for assets transferring out of a dedicated wallet. With the multi-counterparty wallet, the exchange does not perform custody on transfer out transactions. Therefore, exchange custody over multi-counterparty wallets is like a stripped down version of exchange custody over dedicated wallets.

Dedicated wallets feed

Apart from the exchange core client, you can additionally connect to a core client live websocket feed of connected dedicated wallet transactions. Once a dedicated wallet is connected, the feed publishes data upon any transfer in AND transfer out transaction.

As an example, you can use the Signing Client to connect to the websocket feed with connected dedicated wallet transactions.

  1. Launch the CLI and navigate to the directory where the Signing Client is located.
  2. In the CLI, type the following:
    ./partnerapi-sign websocket
    
  3. The prompt will ask you to enter the websocket URL. Paste in the following link:
    wss://api.qredo.network/api/v1/p/wallets/feed
    
  1. Launch cmd.exe and navigate to the directory where the Signing Client is located.
  2. In the cmd interface, type the following:
    partnerapi-sign.exe websocket
    
  3. The prompt will ask you to enter the websocket URL. Paste in the following link:
    wss://api.qredo.network/api/v1/p/wallets/feed
    

Upon success, the CLI will print out connected.

wallets feed is per API key and not per core client id

Notice that the feed is not per core client but rather than per API key. This means that if you have more than one exchange core client per account, it will be your responsibility to process and store the data per exchange core client.

Wallets feed object

The data object of wallets feed transactions is similar to that of GET /wallet/{wallet_id}/history:

{
  "Status": "approved",
  "amount": -100005000,
  "asset": "ETH-TESTNET",
  "chain_tx_id": "<on-chain tx ID, such as: 9b91468bb5a5e**************************724c1d1f927>",
  "fee": -5000,
  "net_amount": -100000000,
  "sweep_tx": false,
  "timestamp": "<Epoch timestamp when tx goes through, e.g. 1644500739>",
  "tx_id": "24vAO8****************8juqs",
  "wallet_id": "GguoQp2yV************************9KcA5jtdj4y"
}

When amount is a negative value, this marks a transfer out (outbound) transaction, and vice-versa: a positive amount value indicates a transfer in (inbound) transaction.

Details on tx-specific parameters

  • Status: tx status is always approved in this feed.
  • amount: tx amount equals the sum of fee and net_amount: |amount|=|net_amount|+|fee| with every transfer out tx. With transfer in transactions, the fee equals 0, so |amount|=|net_amount|.
  • asset: tx asset symbol type (BTC, ETH, etc.).
  • chain_tx_id: the on-chain tx ID.
  • fee: with outbound transactions, this is the portion of the asset amount, needed for the tx. With inbound transactions, always equals 0.
  • net_amount: the amount of asset in the transaction (excluding fee, if any).
  • sweep_tx: a flag indicating if this is a sweep transaction or not.
  • timestamp: when on-chain tx ID is written in ledger.
  • tx_id: transaction ID.
  • wallet_id: the ID of connected wallet with current tx.

The feed data object does not contain details, such as origin wallet address with inbound transactions; or destination wallet ID with outbound transactions.

Handling of connected wallets

When connected, the exchange core client receives a notification with action id details about each withdrawal or transfer request, submitted by the user.

Use the action id supplied in the feed to fetch pending transaction details, including the tx wallet ID, asset type and amount:

GET /coreclient/{client_id}/action/{action_id}

Learn more about GET /action/{action_id}.

  • Approve the transaction if the resulting balance is greater than any outstanding orders:
PUT /coreclient/{client_id}/action/{action_id}

Learn more about PUT /action/{action_id}.

  • Reject the transaction if the resulting balance is less than any outstanding orders:
DELETE /coreclient/{client_id}/action/{action_id}

Learn more about DELETE /action/{action_id}.

Transactions out a dedicated wallet undergo custody twice

The pending transaction must be approved by both exchange and approver. The exchange is not necessarily the same as the approver of the user’s wallet.

Sweep transactions

On Qredo, a sweep is a transaction that allows an exchange to transfer assets out of a connected wallet without undergoing wallet's custody. The transaction must still be approved by the exchange core client but the wallet/fund approvers do not participate in the sweep approval.

The exchange can perform sweep transactions out of both dedicated and multi-counterparty wallets.

Withdraw assets from a dedicated or multiparty wallet; e.g. to execute a limit order.

  • Perform a sweep:
POST /coreclient/{client_id}/sweep

Request body

You must specify a destination wallet.

{
  "wallet_id": "<dedicated wallet ID>",
  "recipient_wallet_id": "<destination wallet ID>",
  "expires": 1640998800,
  "reference": "CX15R99XX",
  "partner_txID": "",
  "send": {
    "symbol": "BTC",
    "amount": 800
  }
}
  • The core client must approve or reject the sweep request.

Info

Sweep into any Qredo wallet with the API or a browser wallet.


Last update: 2022-05-03