How DXS Talks to the Blockchain
There are two ways that DXS ‘talks to the blockchain’. They are explained in this post with examples: opening a trade and closing a trade
Last updated
There are two ways that DXS ‘talks to the blockchain’. They are explained in this post with examples: opening a trade and closing a trade
Last updated
There are two ways that DXS ‘talks to the blockchain’. They can be explained with examples: opening a trade and closing a trade.
You’re logged into DXS with your Web3 Wallet (we’ll use HandCash in our examples). You’re feeling bearish on Gold:
You want to go short $30 of Gold at 30x leverage ($1 margin in BSV):
You open the trade. $1 of margin in BSV is sent from your HandCash wallet and the trade is opened instantly:
DXS communicated with HandCash servers via the Connect API:
“This HandCash user would like to authorize a 0.02030457 BSV payment ($1 value as calculated by DXS at that moment). Here is the user session token that authorizes the request”
“Build a transaction for the user where the first output is 0.02030457 BSV and pays to the DXS margin hot wallet address”
“Include in the same transaction an OP_RETURN data payload that describes the trade”
“Ensure the transaction pays a sufficient miner fee so it is mined into a block”
“Broadcast the transaction to miners”
“Send us the raw transaction”
HandCash do the above and give DXS the raw transaction:
DXS check the 0.02030457 BSV output is correct
DXS check the OP_RETURN data payload is correct
DXS calculates the TXID from the raw transaction
DXS checks if the TXID exists in the mempool using Consigliere
DXS only cares about two things:
That the transaction makes it into the longest chain
That the user can immediately look up their TXID on an independent service (does not need to trust DXS)
We have a high-confidence proxy for these two outcomes: that the transaction exists in a miner’s mempool.
What can stop a transaction from being in a miner’s mempool?
Broadcast error
Unfortunately this is relatively common
Miner chooses not to include the transaction
Fee is insufficient
UTXO is blacklisted
Any other arbitrary reason
Miner cannot include the transaction
Transaction is invalid (structure or signatures are not correct)
UTXO is already consumed (double spend)
Confirming the transaction is in a miner’s mempool means none of the above has occurred! However, we are still left with one business risk which stems from a fundamental understanding of the bitcoin network:
There are only ‘mempools’. Each node has its own view of the network and hence its own mempool. It is still possible for a double spend to occur… But:
Both margin return transactions and profit return transactions spend the user’s margin commitment UTXO. If the user double spends their margin payment, both the margin return and the profit return transactions will fail.
“Holy shit DXS - you can do instant, bulletproof financial settlement at near zero cost?”
Yes we can. A key reason why we love the UTXO…
You close your Gold position. Your trade is closed immediately:
Margin is returned to the user’s Web3 Wallet instantly:
DXS communicates with HandCash servers via the Connect API:
“What address should be used for a payment to this user?”
HandCash responds with address
DXS communicates with Consigliere:
“Query the DXS margin hot wallet address for the margin commitment UTXO for this particular trade”
“Build a transaction that uses this UTXO as the input that pays the entire amount (0.02030457 BSV) minus 700 satoshis (DXS coverage for miner fees and change output) to an output addressed to the user”
“Include in the same transaction an OP_RETURN data payload that describes the trade”
“Ensure the transaction pays a sufficient miner fee so it is mined into a block”
“Ensure the transaction has a change output that will later be consumed in the profit return transaction”
“Add the transaction to the mempool of Consigliere’s connected BSV pruned node”
Consigliere does the above and returns the TXID to DXS
DXS sends the raw TX to HandCash
User can independently verify the transaction:
Profit is returned at the end of the 8 hour trading session:
DXS communicates with HandCash servers via the Connect API:
“What address should be used for a payment to this user?”
HandCash responds with address
DXS communicates with Consigliere:
“Query the DXS margin hot wallet address for the change UTXO from 1(e) above”
“Query the DXS margin hot wallet address for any UTXO that is both sufficient in size and not relating to a currently open or unsettled trade”
“Build a transaction that uses these UTXOs as the inputs that pay the entire profit amount to an output belonging to the user”
“Include in the same transaction an OP_RETURN data payload that describes the trade”
“Ensure the transaction pays a sufficient miner fee so it is mined into a block”
“Add the transaction to the mempool of Consigliere’s connected BSV pruned node”
Consigliere does the above and returns the TXID to DXS
DXS sends the raw TX to HandCash
User can independently verify the transaction: