The world of Decentralized Finance (DeFi) is growing at an exponential pace. We are seeing more retail investors get into the space, and decentralized exchanges increasingly utilized. Uniswap, a popular decentralized exchange is pulling in billions of dollars of trading volume each week. But how do we use a Decentralized Exchange (DEX)? The technical barrier can sometimes keep traditional investors away. However, the centralized model cannot compete with some of the returns we are seeing in the space. Why keep my money in the bank that does not even offer an interest rate that competes with inflation? Let us walk through an example of how a DEX operates under the hood by using an app that is built on a test network, so we do not need to spend any real money!
If you have not already setup a Metamask wallet, you can follow one of our earlier blog posts here on how you can set that up. This is what allows us to interact with many Dapps, and DEX’s built on the blockchain, and we will use this throughout the article. Once you’ve got your Metamask setup, make sure you are on the “Ropsten” test network:
From here, we can navigate to the following URL: https://decentralized-exchange-byb.herokuapp.com/ . If your wallet is correctly setup to Ropsten you should be prompted with a Metamask notification. This is Metamask asking you if it is okay to connect and engage with our exchange. All DEX’s such as Uniswap and 1inch also have the same authentication process.
Now that we are logged in, let’s fund our account with some test tokens. On this DEX we have provided faucets for 4 ERC-20 (Ethereum based) tokens. On the top left you will see a dropdown of these token names:
You can click “Get Test DAI Tokens” to get started trading the other tokens in the list. DAI is the currency, the stablecoin of the DEX, when you buy and sell tokens, the transaction currency is in DAI. You will see the balance change as you are trading.
If we click on any other token, we will see the trading screen for that token:
Here you want to make sure you have a balance in the DEX for that token to buy/sell with. If you do not have any tokens in your DEX or Wallet, click “Get Test Tokens” to fund your wallet with some testnet tokens. Once they are in your wallet you can deposit/withdraw them to the dex in the “Transfer BAT” section.
Let’s say I want to BUY 500 tokens; we can see there is already a few SELL orders out there for 2000 tokens. Which would mean one of those orders (the best pri would get partially filled and update from 2000, to 1500(subtracting the 500 tokens I want to buy). This means, when I submit my order to BUY 500 tokens, which SELL order someone else has placed for 2000 tokens will be partially filled since I want to buy 500 of them.
Simply fill out the form, hit submit and a Metamask prompt will show up asking if you authorize the transaction:
Once you confirm, we will wait for the transaction to confirm on the blockchain. When this happens, your browser will give you a confirmation notification. Once confirmed, you will see the UI update. One of our 2000 token SELL orders just changed to 1500, and our DEX wallet balance is updated with 500 additional tokens!
You will also see your trade show up in the “All Trades” section above now that it has been traded.
The order we first saw that was already existent was placed by another trader, just like yourself! Except he wanted to SELL his tokens, so if they were to login to the DEX, they would see their token balance subtracted, and they would gain some DAI tokens based on what amount it was sold for. You have now exchanged currency with another in a truly decentralized, trustworthy fashion. No need for a broker or a go-between. This is what is happening under the hood of popular decentralized exchanges, like Uniswap. They log in with Metamask, say they want 500 tokens of something and are willing to buy it at either the market price or a limit price. Then you come along and fill that order by selling some of yours. This practice is completely decentralized and does not need any third party. In the centralized financed world, you would need a broker to facilitate a transaction like this.
We hope you enjoyed experimenting with our test DEX and are always looking for feedback and love to answer questions. Feel free to ask us anything or comment down below!