Dexter Guide. The first decentralized exchange on Tezos

Dexter Guide. The first decentralized exchange on Tezos

By Crypt0nio | Crypt0nio | 11 Dec 2020


In this guide we will take a look at the following:

  • What is Dexter.
  • How we trade XTZ/Tokens and what "Slippage" is.
  • How we become Liquidity providers (LP) and what do we earn from doing so.
  • How we remove liquidity and take our assets back.
  • What "impermanent loss" and "arbitrage" are.

Hint: Things are not as complicated as you may think.

Let's begin!

 

What is Dexter;

Dexter, just like the title claims, is the first decentralized exchange on Tezos, where you can easily trade between your XTZ and different Tezos tokens like tzBTC (wrapped Bitcoin) or USDtz (Dollar pegged stablecoin), ETHtz (wrapped ETH) and soon XTZGold, XTZSilver and many more. In Dexter you can also become a liquidity provider, and earn proportional rewards from the 0.3% fees that traders pay in every trade.

Being decentralized, Dexter doen't require KYC, all the trades happen from inside our wallet (non custodial) and it removes the need of a centralized order book, letting the users to set the exchange rates through the trades they perform. All these may sound Greek to you if you have never had experience with a dex or providing liquidity before, but they are much simpler than they sound. So let's see it in action, starting with the suggested wallets you can use.

 

Suggested Wallets

  • Thanos  (Web wallet, works as a browser extention, supports ledger devices. Similar to metamask for Ethereum)
  • Kukai (Web wallet, supports Ledger devices, has a DirectAuth feature)
  • Galleon  (Desktop wallet, can also be used to mint wXTZ)  
  • Magma Wallet (Mobile wallet, very user friendly and easy to use, made by Camlcase, the same company that created Dexter.)

In this guide we will look into using Dexter on a PC with the Thanos wallet. For the mobile version through the Magma wallet I will make a seperate guide/review in the future.

 

Connecting Thanos Wallet to Dexter

Once we have installed Thanos wallet in our browser, we go to app.dexter.exchange, click on "Connect Wallet"(1), then on "Thanos Wallet"(2), then we need to "Confirm"(3) in the pop up window, and finally click "Done"(4).

29a0d1ac49e92058380de0ec952bc3085274bb0ebf74b0993fdd0338d78dbc2a.png  49e21ecea082df795aa6c56a94187bc2029d55c15a9d60c847e712babb31962a.png 16fa530d18a3ca97b09843b6c479f135ab4bd721b9b8451b22423f203c4f636d.png  b8c774eb57697f7a6c28b99cfacecd6015c05de225b2a3e127421f5b236ee146.png

 

We have now successfully connected our wallet and we are ready to begin. For start, let's look into the Exchange part and later we will talk about Liquidity providing.

 

Exchange

Basic points:

b1cca215f8163dcfd964f130b9c93b55eea40e519460697fff232fd86a2f8c37.png

 

1) The coin/Token we will give.

2) The coin/Token we will get.

3) The exchange rate of the trade.

4) Estimated Slippage (Will explain it right after). 

5) Our wallet balance (coins and tokens).

6) Most recent transactions we have made.

 

Slippage

Slippage is the (possible) difference between the price we intend to execute a trade, and the price it is actually executed. 

Since many trades might be happening at the same time, we need to set an acceptable margin in which the trades can proceed normally. The estimated slippage of a trade, changes depending on the amount we want to trade. That happens because the trades and the exchange rates are directly connected to the reserves of liquidity that the specific pair has.

The default slippage setting in Dexter is 0.5% and we can change it by clicking on "advanced options" and then set the percentage we want.

 a005fa83bf07f1abc9c42d76c0c455a723f6625730ce0c10f94cfc41b190a1f2.png

f5b5444b27ca5c58beae440f5f513c04bcd5df7ea7114e6e6194aac01299395e.png

 

Now that we understand Slippage, we can proceed with our first trade. In our example we will trade 10 XTZ for 22.64 USDtz. So once we have typed the amount, we click "Exchange" (1), and then click "Confirm" (2) on the new window that opens up.

91fcfffb7113c07b518160b891671563cda1b45cf717182179b16a34c5451d58.png

 

After that we wait for the transaction to be completed, and the tokens to show up in our wallet balance.

a6f1873e87e8525bffe0ecc5534884c9cbc9cc0d54417e0611b3f2679630b16f.png

 

That's it! The tokens are now in our wallet. We can trade any pair of coins/Tokens in exactly the same way. As we said before, for every trade we perform, we pay a fee of 0.3% which is paid to the people that provide liquidity to the exchange. So let's see how we can also become Liquidity providers.

 

Liquidity Providing

We click on the "Liquidity Pool" tab.

22f8407664f9401eaf65b8bb132bc3505ea31b5ddc4dc4a48f175bf2e8a74a87.png

 

Add Liquidity

Adding liquidity to the exchange, can only be done in pairs of coins/tokens and the amounts of both must be of equal value. A pair could be XTZ/USDtz or XTZ/tzBTC etc 

So if for example we want to provide liquidity to the XTZ/USDtz pair and we want to add 5 XTZ, we will have to add the equivalent in value USDtz based on their exchange rate of that moment (1). For the assets we provide as liquidity, we get a number of pool tokens (2) which represents the percentage of liquidity we have added to that pairs' pools.

321633c338ffd924cc4800181135a18fd0c2ce327e2a514ebe9c9c571cb7d481.png

 

So we click on "Add liquidity" and then "Confirm" on the window that pops up.

8340aa3ca5e8506c7106e5d3e0d50b4522ee32a3ee71e0a49b5d5c820b1643cb.png

 

Once the transaction is complete, we can see our pool tokens here:

78d8c2973ca33424eabcff5022606c90d5abde174ead958e31c70e100a4c2604.png

 

Piece of cake, right!? Now our assets have been added as liquidity to that specific pair, and for as long as we leave our assets in the liquidity pools, we will be getting proportional rewards for every trade that happens in that pair. In the example above we can see that our pool tokens represent 0.01% of the total liquidity pools, so for every trade that happens between XTZ/USDtz (and vive verca), we get 0.01% of the fees that the traders pay! So the more liquidity we provide, the bigger rewards we get!

To check the total of every pairs' liquidity pools we can go to the "Pool Data' tab.

89a20401d4772f4ff64cf31a9e58e3a7e666274f76c1c0362efa5dff7916babb.png

 

It is impotant to note that all the XTZ we provide as liquidity, are automatically staked and we receive staking rewards for them, straight to our wallet. So on top of the rewards from the fees, we also get staking rewards!

 

Remove Liquidity

To redeem our pool tokens and get back our assets we go to the "Remove liquidity" tab (1), we type the number of pool tokens we want to redeem (2), and then click the "Redeem pool tokens" button (3) and "Confirm" in the pop up window (4).

668abc71a898960a60c8dd10c79b487d607834ddda0c41c63d78a7f26c8751f0.png

 

 

Impermanent loss, Arbitrage and more

An important part we need to understand, and which you might have heard a lot around Liquidity providing, is the term "Impermanent Loss". The simplest explanation I could give you on impermanent loss is:

 

Impermanent loss is the difference between the profits we would have by simply holding 2 assets for a specific period of time, compared to the profits we would get if we provided those 2 assets as liquidity in that same period of time.

 

Let's see a few things in a little more detail and then we will also see an example with numbers to understand it better.

In Dexter, every pair of coins/Tokens has 2 pools, for example the pair of XTZ/USDtz has a pool for the XTZ coins and a seperate pool for the USDtz tokens. The ratio between these 2 pools is what determines the exchange rate between these 2 assets. So let's say if the XTZ pool has a reserve of 100.000 XTZ and the pool of USDtz has a reserve of 200.000 USDtz, then the exchange rate between these assets will be 1 XTZ = 2 USDtz (keep in mind USDtz is a stable coin and 1 USDtz represents $1)

So now lets say that the price of XTZ in other exchanges (Kraken, Coinbase etc) goes from $2 to $3. This price raise will lead to traders that hold USDtz, to trade them for XTZ because the price of XTZ in Dexter is still at $2 (2USDtz). This difference in price between Exchanges, gives the opportunity to traders to buy XTZ for $2 in one exchange and then go sell it for $3 in the other exchange. These differences in the price of an asset between various exchanges is also known as arbitrage opportunities.

So when these trades happen in Dexter, what actually happens is the traders give their USDtz (which go into the USDtz pool of the pair) and they get XTZ (which come out of the XTZ pool of that pair). That leads to a change in the ratio between the 2 pools, and also a change in the exchange rate of these 2 assets in Dexter. The trades will go on until the exchange rate of Dexter comes close to the exchange rate of the other exchanges and there is no longer an arbitrage opportunity. And that's pretty much how the automated market making works in Dexter.

As we said before, when we provide our assets as liquidity to Dexter, we do it at the exchange rate the assets have in that moment. In return we get pool tokens that represent the percentage of our contribution to the 2 pools of the pair. So when the reserves in the pools change, the same thing happens to the assets that correspond to our pool tokens. Let's jump into an example with numbers to understand it better and see where exactly the impermanent loss is.

Example:

1) The exchange rate for the pair XTZ / USDtz is 1 XTZ= 2 USDtz.
2) We provide liquidity with 10 XTZ and 20 USDtz which are worth 10*2=$20 and 20*1=$20 so in total 20+20=$40
3) We receive a number of pool tokens for our contribution.
4) After a while, the exchange rate goes to 1 XTZ = $3 and the reserves in the pools of the pair change accordingly.
5) Because of the change in the reserves, our Pool tokens now correspond to 7 ΧΤΖ and 21 USDtz.
6) So at this point, if we redeem our pool tokens, our assets wil be worth 7 ΧΤΖ * $3 = $21 and 21 USDtz * $1 = $21 so in total 21+21= $42
7) If we had just kept the assets in our wallet instead of providing them as liquidity, we would now have: 10 ΧΤΖ * $3 = $30 and 20 USDtz * $1 = $20 so in total 30+20=$50
8) As we see, by providing those starting assets we had to the liquidity pools, we have $8 less profit compared to if we just kept them in our wallet. That's exactly what impermanent loss is.

They call it impermanent because the assets are volatile, so if you don't redeem your pool tokens and the exchange rate drops back down, then you won't have lost any profits and you will be at the same level, with the huge difference that for the whole period that your assets have been sitting in the liquidity pools, you have gained a lot of rewards from the trading fees!

Even in the case that the exchange rate doesn't come back down, if the pair you have chosen to proide liquidity to, has a lot of trades, the rewards from the fees will probably cover the impermanent loss. So depending on the case, impermanent loss is not as bad as it sounds.

 

That's all folks! Feel free to reach out if you think I left out anything important. You can also find more info about Dexter at dexter.exchange/docs/dexter-intro/

 


Heya! I am Crypt0nio and I am a Tezos enthusiast. You can easily find me on Twitter with the twitter handle @Crypt0nio

I also run the Tezos Greece  Twitter account and have made the Tezos Greece Telegram Group.



Crypt0nio
Crypt0nio

Tezos related guides and articles

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.