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.
- Launch the CLI and navigate to the directory where the Signing Client is located.
- In the CLI, type the following:
./partnerapi-sign websocket
- The prompt will ask you to enter the websocket URL. Paste in the following link:
wss://api.qredo.network/api/v1/p/wallets/feed
- Launch
cmd.exe
and navigate to the directory where the Signing Client is located. - In the
cmd
interface, type the following:partnerapi-sign.exe websocket
- 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 alwaysapproved
in this feed.amount
: tx amount equals the sum offee
andnet_amount
:|amount|=|net_amount|+|fee|
with every transfer out tx. With transfer in transactions, thefee
equals0
, 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 equals0
.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.