Difference between revisions of "BSQ swaps"

From Bisq Wiki
Jump to navigation Jump to search
(initial creation; more thorough proofing needed)
 
m (fix typos)
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
  
 
== Process ==
 
== Process ==
 
[[File:Create-bsq-swap-offer.png|600px|thumb|left|Creating a BSQ swap offer.]]
 
  
 
With the BSQ swap protocol, BSQ and BTC can be traded in a single transaction without much of the baggage of the conventional trade protocol.
 
With the BSQ swap protocol, BSQ and BTC can be traded in a single transaction without much of the baggage of the conventional trade protocol.
  
 
From a user's perspective, the process is rather seamless. No special payment accounts need to be created. The offer maker creates the offer (BSQ is default trade currency).
 
From a user's perspective, the process is rather seamless. No special payment accounts need to be created. The offer maker creates the offer (BSQ is default trade currency).
 +
 +
[[File:Create-bsq-swap-offer.png|600px|thumb|left|Creating a BSQ swap offer.]]
  
 
As long as the offer maker has enough of what they want to trade in their wallet (either BTC or BSQ), the offer will be live and visible on the network. If the relevant wallet balance ever goes below the amount required to complete the swap, the swap offer automatically deactivates.
 
As long as the offer maker has enough of what they want to trade in their wallet (either BTC or BSQ), the offer will be live and visible on the network. If the relevant wallet balance ever goes below the amount required to complete the swap, the swap offer automatically deactivates.
Line 25: Line 25:
 
== Troubleshooting ==
 
== Troubleshooting ==
  
Since the protocol is trustless, BSQ swaps do not require Bisq's conventional dispute resolution. Rarely, an invalid transaction could be committed to a your wallet. In such a case, you will need to [[Resyncing SPV file|resync your SPV file]] to get rid of it.
+
Since the protocol is trustless, BSQ swaps do not require Bisq's conventional [[dispute resolution]].  
 +
 
 +
Rarely, an invalid transaction could be committed to your wallet. In such a case, you will need to [[Resyncing SPV file|resync your SPV file]] to get rid of it.
  
 
== Background ==
 
== Background ==
Line 33: Line 35:
 
Here we cover the basic mechanics of BSQ swaps.
 
Here we cover the basic mechanics of BSQ swaps.
  
BTC buyers and sellers need to pay BTC mining fees and BSQ trading fees, but the BSQ swap protocol simplifies the transaction by only having BTC inputs for BTC sellers and BSQ inputs for BSQ sellers. The appropriate dedications are made from the outputs (e.g. the BTC buyer/BSQ seller gets BTC with their share of mining fees and trading fees deducted; similarly, the BTC seller/BSQ buyer gets BSQ with their share of mining fees and trading fees deducted).
+
BTC buyers and sellers need to pay BTC mining fees and BSQ trading fees, but the BSQ swap protocol simplifies the transaction by only having BTC inputs for BTC sellers and BSQ inputs for BSQ sellers. The appropriate deductions are made from the outputs (e.g. the BTC buyer/BSQ seller gets BTC with their share of mining fees and trading fees deducted; similarly, the BTC seller/BSQ buyer gets BSQ with their share of mining fees and trading fees deducted).
  
Now let us examine an example trade to get an idea of the structure of such a transaction.
+
Now let us examine an example trade to see the structure of such a transaction.
  
 
This is how a transaction for a 1 BTC/50,000 BSQ swap with a 0.5 BSQ maker fee and 1.5 BSQ taker fee would look. We estimate the buyer's share of the mining fee to be 2000 sats and the seller's share of the mining fee to be 2500 sats.
 
This is how a transaction for a 1 BTC/50,000 BSQ swap with a 0.5 BSQ maker fee and 1.5 BSQ taker fee would look. We estimate the buyer's share of the mining fee to be 2000 sats and the seller's share of the mining fee to be 2500 sats.
Line 52: Line 54:
 
With the conventional Bisq trade protocol, the maker fee transaction acts as a spam prevention measure: you cannot create an offer without spending bitcoin.
 
With the conventional Bisq trade protocol, the maker fee transaction acts as a spam prevention measure: you cannot create an offer without spending bitcoin.
  
The BSQ swap protocol has no such transaction, so instead, a proof-of-work mechanism is used. The difficulty level (number of leading zeros) is set in the filter. When creating an offer, the maker does the required POW and attaches the resulting data to their offer. Each node verifies the POW and only shows offers with valid POW.
+
The BSQ swap protocol has no such transaction, so instead, a proof-of-work (POW) mechanism is used. The difficulty level (number of leading zeros) is set in the filter. When creating an offer, the maker does the required POW and attaches the resulting data to their offer. Each node verifies the POW and only shows offers with valid POW.
  
 
If POW difficulty is increased, offer makers must re-do their POW in the background and republish their offers. Old offers are removed from the network and new offers with new POW are added.
 
If POW difficulty is increased, offer makers must re-do their POW in the background and republish their offers. Old offers are removed from the network and new offers with new POW are added.
  
Each offer has a counter appended to its offer ID (after the version number, in the full offer ID) each time a new POW is completed. This enables each re-published offer with new POW to have a new offer ID that looks the same to users (short offer ID doesn't change).
+
Each offer has a counter appended to its offer ID (after the version number, in the full offer ID) each time a new POW is completed. This enables each re-published offer with new POW to have a new offer ID that looks the same to users (since the short offer ID doesn't change).
  
 
At first, POW difficulty will be set to a very low value so users do not notice anything (low milliseconds on modern laptop hardware), but will be increased as needed.
 
At first, POW difficulty will be set to a very low value so users do not notice anything (low milliseconds on modern laptop hardware), but will be increased as needed.

Latest revision as of 16:37, 19 October 2021

BSQ swaps allow BSQ colored bitcoin and BTC to be traded atomically: instantly, risklessly, with less fees, and with no special Bisq account setup required.

Process

With the BSQ swap protocol, BSQ and BTC can be traded in a single transaction without much of the baggage of the conventional trade protocol.

From a user's perspective, the process is rather seamless. No special payment accounts need to be created. The offer maker creates the offer (BSQ is default trade currency).

Creating a BSQ swap offer.

As long as the offer maker has enough of what they want to trade in their wallet (either BTC or BSQ), the offer will be live and visible on the network. If the relevant wallet balance ever goes below the amount required to complete the swap, the swap offer automatically deactivates.

  • if a user creates a swap offer to sell 1000 BSQ, the offer will remain live as long as their BSQ wallet has more than 1000 BSQ
  • if a user creates a swap offer to buy 0.5 BTC, the offer will remain live as long as their Bisq BTC wallet has more than 0.5 BTC

Offers can still be activated or deactivated manually in Portfolio > My Open Offers as usual.

Taken offers show in a new BSQ Swap Trades tab on the Portfolio screen.

Of course, this trade protocol can only work while both users are online, but Bisq offers can only be taken when both maker and taker are online anyway, and these trades can be settled almost instantly so there is no further expectation that users be online for any particular amount of time (e.g. for 1 hour with instant altcoins offers).

Troubleshooting

Since the protocol is trustless, BSQ swaps do not require Bisq's conventional dispute resolution.

Rarely, an invalid transaction could be committed to your wallet. In such a case, you will need to resync your SPV file to get rid of it.

Background

Transaction structure

Here we cover the basic mechanics of BSQ swaps.

BTC buyers and sellers need to pay BTC mining fees and BSQ trading fees, but the BSQ swap protocol simplifies the transaction by only having BTC inputs for BTC sellers and BSQ inputs for BSQ sellers. The appropriate deductions are made from the outputs (e.g. the BTC buyer/BSQ seller gets BTC with their share of mining fees and trading fees deducted; similarly, the BTC seller/BSQ buyer gets BSQ with their share of mining fees and trading fees deducted).

Now let us examine an example trade to see the structure of such a transaction.

This is how a transaction for a 1 BTC/50,000 BSQ swap with a 0.5 BSQ maker fee and 1.5 BSQ taker fee would look. We estimate the buyer's share of the mining fee to be 2000 sats and the seller's share of the mining fee to be 2500 sats.

Assuming Alice makes an offer to buy BTC (sell BSQ) and Bob takes her offer (making him BTC seller/BSQ buyer):

  • Alice's BSQ input(s): min. 50,000 BSQ + 0.5 BSQ trade fee
  • Bob's BTC input(s): min. 1 BTC + 2500 sat - 150 sat (his BSQ trade fee will be used for mining fee, so he needs a bit less of a mining fee)
  • Bob's BSQ payout output: 50,000 BSQ - 1.5 BSQ trade fee
  • Alice's BSQ change output: xxx BSQ - optional, can be omitted in case input was exact
  • Alice's BTC payout output: 1 BTC - 2000 sat miner fee + 50 sat from BSQ fee
  • Bob's BTC change output: yyy BTC - optional, can be omitted in case input was exact

Spam prevention

With the conventional Bisq trade protocol, the maker fee transaction acts as a spam prevention measure: you cannot create an offer without spending bitcoin.

The BSQ swap protocol has no such transaction, so instead, a proof-of-work (POW) mechanism is used. The difficulty level (number of leading zeros) is set in the filter. When creating an offer, the maker does the required POW and attaches the resulting data to their offer. Each node verifies the POW and only shows offers with valid POW.

If POW difficulty is increased, offer makers must re-do their POW in the background and republish their offers. Old offers are removed from the network and new offers with new POW are added.

Each offer has a counter appended to its offer ID (after the version number, in the full offer ID) each time a new POW is completed. This enables each re-published offer with new POW to have a new offer ID that looks the same to users (since the short offer ID doesn't change).

At first, POW difficulty will be set to a very low value so users do not notice anything (low milliseconds on modern laptop hardware), but will be increased as needed.