User Incentives on Decentralized Cryptocurrency Exchanges (with BarterDex as an example). Part 1

Most people do not realize the real difficulty of the task of building a truly decentralized currency exchange. When they need to exchange their currency into a foreign currency, they are likely to use a kiosk at their local bank or airport. When buying and selling cryptocurrencies, they would typically use a centralized exchange such as Coinbase, Gdax, Binance or Kucoin. They do not realize that all these ways of buying and selling currencies are centralized, which means that there is a central point that hackers and attackers could focus on. With a physical kiosk, physical theft can occur. With a centralized exchange, hackers can find a way to divert the coin holdings, which is exactly what happened with Mt. Gox, a centralized cryptocurrency exchange website that was processing over 70% of worldwide bitcoin transactions by the end of 2013. In 2014, the website ceased operations and filed for bankruptcy protection because hackers have stolen over 850,000 bitcoins, valued at over $400 million at the time. One of the reasons why hackers were able to target the website was that there was “a website,” a central place through which all the operations were going.

The existence of such a central place is also the reason why in the past hackers were able to steal data from some of the biggest corporations in the world, including Equifax, Yahoo, Target, and others.

While centralized systems are proving time and time again that they are very vulnerable to attacks, errors and mismanagement, there are a lot of things they can do to protect themselves and their customers that decentralized systems can’t do. For example, a centralized exchange may require a customer to present a government identification document and then it would have employees checking the validity of the ID. A decentralized system can’t do that because it does not have employees, a compliance center or a customer support center.


Atomic swaps on decentralized exchanges

The idea behind decentralized exchanges is to create a transparent process that users can fully understand and agree to participate in. The process also needs to have incentives and disincentives for users, so that malicious actors do not abuse the system with spam transactions and honest users have an incentive to move on with the process.

While this may sound complex, in reality there are only eight ways to get rid of an unwanted behavior. The branch of science that studies these ways is called behavioral psychology and in the last several decades it has made amazing progress.

While the technology behind decentralized networks may seem complex, computers still execute code one line at a time, which means that for a transaction to happen, someone needs to start it.

With BarterDex, the person who wants to exchange the funds sends a request to the decentralized exchange. Let’s assume that this person wants to exchange an altcoin for bitcoin and let’s call this person Alice (so that the first letter of the name is the same as the first letter in the word altcoin). The exchange then publishes the request and other users can respond. Let’s call the responding user Bob (so that the first letter in the name of the user is the same as the first letter in the word Bitcoin).

Decentralized exchange BarterDex does not break funds in the wallets of users to match the transactions (in technical terms, this means that BarderDex works with existing UTXOs in the wallets of users but doesn’t modify UTXOs nor does it create new UTXOs).

This also means that users need to have funds broken into the sizes of transaction before they start an atomic swap with a decentralized exchange. User that is requesting a transaction needs to have two UTXOs: one in the size of the desired order and another one equal to the transaction fee, which is 1/777, or about 0.12% of the transaction.

Bob is on the other side of the transaction and he also needs to have two UTXOs, but his UTXOs  need to be of different sizes. The first one is 112.5% of the transaction that he wants to engage and the second one is 100% of the transaction, meaning that the total amount of funds needs to be 212.5%, which is why users who choose to participate in the transactions already posted on the network are also known as liquidity providers. The UTXO of 112.5% becomes a deposit and the UTXO of 100% is the amount that participates in the transaction.


Incentives and disincentives at the beginning of an atomic swap

If Bob chooses to participate in a trade with Alice, but does not send a deposit after accepting the offer to trade, Alice will lose the fee (which is 1/777, or about 0.12% of the transaction). While Bob does not lose any funds, he loses much more. The network will put a note on his public profile about him abandoning a transaction, which hurts his reputation and makes users not want to do business with him in the future. Komodo developers believe that this will prevent liquidity providers from abandoning transactions and therefore, the instances where Alices lose their transaction fees without actual transactions completing will be low. At the same time, if the number of abandoned transactions were to go up, the code of the BarterDex exchange has a contingency scenario in which Alice gets a refund, should she experience a big loss.