This post was last updated on December 28th, 2018 at 05:10 pm
This is part 1 of a series on decentralized cryptocurrency exchanges. I am joined today by Alex Wearn: Co-founder and CEO of Aurora Lab (IDEX).
This deep dive will be broken up into 10 chapters:
- Chapter 1: A primer on decentralized exchanges and the problems they actually solve
- Chapter 2: A step-by-step walkthrough of trade execution through post-trade settlement
- Chapter 3: A history of decentralized exchanges
- Chapter 4: The components and attributes of a decentralized exchange
- Chapter 5: Control and regulation
- Chapter 6: A review of the top blockchains for decentralized exchange
- Chapter 7: Sourcing liquidity
- Chapter 8: Different approaches to exchange tokens (Binance’s BNB token, for example)
- Chapter 9: A look at the organization around IDEX, Aurora DAO
- Chapter 10: The future of decentralized exchange might look like
In this episode, Alex and I will concentrate on the first five chapters. Listen in to hear what Alex has to say about the problems that a decentralized exchange solves, the smart contract-based approach, and the history of decentralized exchanges.
In this episode we discuss:
- Decentralized exchange definitions
- Problems solved by a decentralized exchanges
- Types of users attracted to particular feature sets
- Pros and cons of decentralized exchange
- How the dollar value of funds raised through an ICO in a given month correlates with revenue
- Steps that someone new to cryptocurrency would need to take to execute a trade on IDEX
- The smart contract-based approach
- The 0x protocol
- The history and emergence of decentralized exchanges
- How to handle the collision of taker orders
- The core functions that can be unbundled from each other in the execution of trades on an exchange
- The relationship between orders and trades
- Definitions of makers and takers
- Custody of funds and how it ties into trade settlement
Links Relevant To This Episode:
- Alex Wearn
- Ledger Wallet
- Air Swap
- Radar Relay
Thanks To Our Sponsor: Nomics’s Cryptocurrency Market Data API
The Nomics API offers squeaky clean and normalized primary source trade data offered through fast and modern endpoints. Instead of having to integrate with several exchange APIs of varying quality, you can get everything through one screaming fast fire hose. If you found that you or your developer have to spend too much time cleaning up and maintaining datasets, instead of identifying opportunities, or if you’re tired of interpolated data and want raw primary source trades delivered simply and consistently with top-notch support in SLAs, then check us out here.
Clay: Welcome to Flippening, the first and original podcast for full time professional and institutional crypto investors. I’m your host Clay Collins. Each week, we discuss the cryptocurrency economy, new investment strategies for maximizing returns and storage from the frontlines of financial disruption. Go to flippening.com to join our newsletter for cryptocurrency investors and find out just why this podcast is called Flippening.
Announcer: Clay Collins is the CEO of Nomics. All opinions expressed by Clay and podcasts guests are solely their own opinion and [00:00:30] do not reflect the opinion of Nomics or any other company. This podcast is for informational and entertainment purposes only and should not be relied upon as the basis for investment decisions.
Welcome to part one of this two-part series on decentralized cryptocurrency exchanges. Instead of beating around the bush, I’m just going to be upfront and tell you that this is the best content that you can find anywhere online [00:01:00] about this topic right now. I hope you’ll agree.
This deep dive is broken up into 10 chapters: Chapter 1 is a primer on decentralized exchanges and the problems they actually solve. Chapter 2 is a step-by-step walkthrough of what it would take for someone to get to the point where they can execute a trade on a decentralized exchange, all the way through post-trade settlement. Chapter 3 is a history of decentralized exchanges and how this all came to be. In Chapter 4, we [00:01:30] break down the components and attributes of a decentralized exchange. In Chapter 5 we look at control and regulation, and what decentralized exchange owners actually have control over. Chapter 6 is a review of the top blockchains for decentralized exchange. In Chapter 7, we talk about sourcing liquidity. Chapter 8 is about different approaches to exchange tokens, as an example, Binance’s Token BNB is an example of an exchange token. Chapter 9 is a look at [00:02:00] one organization that builds a decentralized exchange, Aurora DAO which is the creator of IDEX. Chapter 10 peers into the future and explores what the future of decentralized exchange might look like.
I’m joined in this exploration by Alex Wearn, cofounder and CEO of Aurora Lab, which creates IDEX, the number one decentralized application right now in terms of transaction volume on the Ethereum network.
We’re just about to kick things off, but before we do that, I wanted to [00:02:30] provide two announcements regarding Nomics.com, the company the produces and funds this podcast. Announcement number one is that I’ve launched a new podcast, which you can find at NomicsUpdate.com. As the URL suggests, the podcast is called The Nomics Update. I release the Nomics Update every single weekday; it’s my personal audio-journal as CEO of Nomics. During each episode, I tell stories from inside our startup including the ups and downs, high and lows. I also discuss our product roadmap, [00:03:30] announce new partnerships and features, and speak to important new ideas shaping the future of nomics.com and crypto asset data in general. To subscribe to the podcast, go to nomicsupdate.com, find the link to your favorite podcasting platform, and hit the subscribe button.
Announcement number two is that blocktrade.com has completed a deep data integration with nomics.com and their data is now available at nomics.com—our website—and via the nomics API. Blocktrade.com will be the first fully licensed security token exchange in Europe, [00:03:30] focused on listing crypto assets, security tokens, and other tokenized financial instruments. Trading is live on their platform currently. Blocktrade enables crypto trading to institutional traders while unlocking huge amounts of liquidity with their primary market partners. This integration means that we now have the best Blocktrade data available, including gapless raw trade data. If you’d like access go to nomicsapi.com and sign up for an API key. If you’re an [00:04:00] exchange operator who’d like to do a deep data integration with Nomics and become an a-plus verified exchange on the Nomics data platform, please see nomicsintegration.com.
Okay, back to our regularly scheduled program. Here is part one of our series in decentralized exchanges with Alex Wearn from IDEX.
Clay: [00:04:35] Let’s kick this off with chapter one which is really a primer on decentralized exchanges and the problems they solve. I think people mean a lot of different things when they refer to decentralized exchanges. What does decentralized exchange mean to you?
Alex: To me, a decentralized exchange is any exchange that uses a blockchain and private keys [00:05:00] to manage the custody of funds. Just to expound on that a little bit, the key is that the private keys that control the funds are not under the control of the exchange operators. It’s something that the end user is always in possession of and is using to actually give instructions to anything that has to do with the movement of funds. A traditional centralized exchange, when you want to trade on the platform, the first thing you have to do is send your cryptocurrency to a wallet that they control. That’s the deposit process. [00:05:30] Before you can do anything, you actually have to give up control of your cryptocurrency. There’s a phrase in the space that’s, if you don’t control the private keys, then it’s not your money.
Again and again, we see issues where centralized exchanges, they’re a big target for hackers and thieves, because of the fact that they’re pooling everybody’s funds into one place and under one kind of architecture or system. A decentralized exchange allows users to trade in a more peer-to-peer fashion, where they’re never giving up control [00:06:00] to that centralized entity, and everything that they do on the platform is explicitly authorized and approved through their own private key.
Clay: According to that definition, there does seem a little bit of gray area with an exchange like Shapeshift, where it’s noncustodial so they’re not holding your funds day in and day out, but they do hold your funds to make the trade. Perhaps they are custody-ing it, but it’s for a much shorter period of time. Is that the distinction? Would you call [00:06:30] Shapeshift a decentralized exchange or not?
Alex: I would not call it a centralized exchange because of the fact that you just mentioned, they’re holding it, even though it’s a brief period of time. It’s a great innovation on that front. It’s also great the way they are able to operate and connect across different blockchains. That’s one of the things that DEXs today cannot do. Because of that how do you connect that leap from one cryptocurrency on one blockchain to a cryptocurrency on another?
Shapeshift does that by minimizing the amount of time [00:07:00] that you have to trust that third party. But there’s still the risk that you send the initial funds, and you never get back what you first sent them. On a decentralized exchange, that’s never a problem because the transactions are what’s called atomic, meaning they either happen in both of the trades, both of the transactions go through, both parties’ assets are swapped, or the transaction fails. It’s all or nothing.
Clay: It might be spiritually kind of on the same continuum as a decentralized exchange, but it doesn’t quite hit the [00:07:30] mark in terms of qualifying as such. So, with the definition established, let’s move on to the problems that are solved. What problems do you think at the end of the day a decentralized exchange solves for other than or rather in addition to theft and security issues, and sort of trusting a centralized third party?
Alex: That first one, that issue of theft, that really can be defined as custody. If you want to trade your [00:08:00] assets, do you have to give up custody and give permission to a third party to control it? That to me is the primary benefit of a decentralized exchange and really kind of 95% of the reason for using one. If you’re a user that’s interested in either self-custodying, because that’s something that’s appealing to you, you like the digitization of assets, kind of this cryptocurrency revolution or because you have, and I think plenty of reason to do so, you have suspicion [00:08:30] on the ability for centralized exchanges to keep your cryptocurrency safe.
Another reason would be kind of the ease of onboarding. In order to trade on these decentralized exchanges, your account is actually your private key and your wallet. You don’t need to create a new signup process, and then deposit into the centralized exchange in order to participate. You just show up with your wallet and you’re ready to trade. That’s really helpful for new users that are already familiar with the cryptocurrency [00:09:00] process, understand kind of private key technology that they can easily move to one of these new platforms.
And I think that’s part of what gets me excited, you know, if we see continued development and hopefully future adoption of decentralized applications, is this notion that you have an account that can work and be used at all sorts of different platforms and applications. It’s actually something we have struggled with, with some of our users where they’re used to creating a username password and getting them used to this [00:09:30] notion that it’s actually this Ethereum wallet. That’s what you use. It’s your password, it’s your login, it’s your account, it’s everything but it’s not inherently restricted to just IDEX. That’s a bit of a mental model, kind of a shift that we have to work with to educate our users.
Clay: They already have their account if they have an Ethereum wallet. What other problems does it solve?
Alex: One of the other things that I think a lot of decentralized exchanges are doing is also help [00:10:00] democratizing access to these assets. We have, on our platform, we don’t charge any listing fees for projects that want to be listed on IDEX—that’s part philosophy, and in part a function of the way our operations work that. If we find a project that is high quality and has a team that’s trying to execute, we want them to be able to get exposure, and if others want to participate in the project, we’d like for them to be able to do so via IDEX. Part of that’s coming from our roots. We were bootstrapped in order to [00:10:30] develop and launch our product, and we don’t think those that can’t pay a large listing fee should be shut out of participating in these markets.
Clay: What kind of user persona do you think this feature set attracts? It’s a little bit difficult, because people are trading from the other side of Ethereum addresses and you don’t know who these people are, you probably can’t have them fill out an onboarding survey, or maybe you can, but you don’t because it’s not consistent with the ethos. But do you have a sense of [00:11:00] who your customer is?
Alex: I think we’ve seen a transition in the customer base that correlates roughly with the overall transition at kind of an aggregate level within the cryptocurrency space. When we were first developing this and first launching test nets, it was very much those who were already in the cryptocurrency space, often developers themselves, highly technical, and were very much just curious about the capabilities of trading through [00:11:30] a smart contract and directly with just using your private key as authorization. Over time, as the cryptocurrency market has grown and become more popular with “average consumers”, we’ve seen that user base transition as well. But you’re certainly going to be relatively technical to have found and be able to use IDEX.
One of the things is just the fact that IDEX only trades assets that are already on the Ethereum blockchain. You can’t show up with a credit card and use it on IDEX. You [00:12:00] have to have already acquired cryptocurrency, in this case ether. That in and of itself is one barrier that ensures that the users who have found us are relatively technical. Another one is the fact that you do use a private key or some sort of wallet—that’s another thing that users need to understand before they get there.
I think that’s one of our focuses from kind of a UX perspective. It’s really our job as DEX builders to make sure that we start to ease that process. We’ve started with kind of focusing on the market that understands and [00:12:30] is very receptive to this architecture. I think that’s going to be a big focus of ours over the next few years is how do we make it easy for someone who doesn’t want to necessarily learn those things, or those aspects aren’t of interest to them, to show up, use the platform and still get the benefits of a decentralized exchange without having to understand all the complexities.
Clay: We talked a little bit about the pros, and you touched a little bit on some of the cons to trading on a decentralized exchange. Let’s flush that out a little bit more. What other [00:13:00] downsides do you think exist with your average decentralized exchange? What isn’t available to traders on these platforms?
Alex: I mentioned how you can’t use a credit card or something to just jump into the platform immediately. that’s because inherently fiat currency is not supported on the exchange. That is changing a little bit with the introduction of stable coins. Stable coins are essentially a bridge between traditional bank accounts and currency into the cryptocurrency world. [00:13:30] You’ve got stable coins, Tether being the most famous, but also the launch of TrueUSD and Circle’s new USD Coin, that essentially becomes a representation of a bank account balance, but on the blockchain as a crypto asset.
We can’t trade dollars. The smart contract has no knowledge of dollars in your Bank of America bank account, but it is able to trade these cryptocurrencies that are issued by these third parties that are used to represent bank account balances that they control. That is an [00:14:00] element that is improving, kind of that ease of use.
One of the other challenges is that, and this kind of ties in with that previous comment, is that the only assets you can trade or those that are on that particular blockchain. IDEX operates on the Ethereum blockchain, which means that we’re unable to trade Bitcoin, Litecoin, Ripple, EOS, other assets that are on other competing blockchains and that’s just because of the nature of the fact that—similar to the reason it can’t interact with a bank account—it’s unable to [00:14:30] interact with other blockchains that it isn’t connected to. That again, is another issue and challenge that a lot of projects are working on, this notion of interoperability or cross chain communication where assets can be transferred, so to speak, from one blockchain to another.
Clay: In summary, the quote currency has to be Ethereum. In the case of IDEX, you’re limited to assets on the Ethereum blockchain, and there’s no easy [00:15:00] fiat on-ramps or new users who want to get involved. Is there anything else on that list?
Alex: I think that’s a pretty good list, at least off the top of my head.
Clay: Maybe some slight user experience challenges to getting a Ethereum wallet set up, why do you think, why are decentralized exchanges synonymous with Ethereum trading? I can’t think of a single notable—in terms of volume—decentralized exchange that doesn’t operate entirely within an Ethereum ecosystem.
Alex: I think the [00:15:30] reasons are twofold. The first Ethereum was the first capable smart contract blockchain that really had kind of the tooling, the scripting language, the ability to create a smart contract-based exchange. It’s the first one that people really looked at it and say actually from a technical perspective, “This is something we can build, and set out to do so.” The second I think is linked to the ICO boom of 2017 and early 2018 where [00:16:00] tying back to those previous comments, you can only trade what is on that particular blockchain.
Ethereum has been by far the dominant exchange for issuing ICOs and tokens. I think I read something like over 85% of tokens have been on the Ethereum blockchain itself. I do think you’re going to see this change, you’re going to see DEXs expand or build on other blockchains because (1) other blockchains are [00:16:30] coming out that have smart contract capabilities and you can create an exchange that trades using this same type of architecture, and (2) you’re going to start seeing projects either launching directly on or potentially migrating over to other blockchains.
Clay: To what extent is the dollar value of funds raised through an ICO in a given month, a leading indicator of what your revenue will be? Are they somewhat correlated, are they tightly correlated, or they loosely correlated?
Alex: [00:17:00] They’re definitely loosely correlated. I was looking at a chart the other day of ICO funding, and it was interesting to see how much it actually correlated with the price of ether. One of the individuals who was commenting on it was speculating that it’s actually ICO who is driving the Ethereum price. Which would make sense that if Ethereum is the funding mechanism of choice for ICOs, as there are more going on, demand for ether is going up. As there are less going on, demand for ether would go down, [00:17:30] either due to less users needing to buy it to get into the ICO or because ICOs themselves are selling after they’ve done their funding raise.
But back to the original question of correlation with IDEX, we’ve seen that it’s more followed kind of the macro trends within the crypto market, and it’s really just been a function of kind of traffic and interest from some of the more, you call them the retail trader or the average consumer. We saw a lot of activity in March and April of last year, and it’s definitely [00:18:00] dropped down a little bit with kind of some of the pullback in the ICO market.
Clay: Let’s transition now to chapter two, which is a step-by-step walkthrough of what it would take for someone who’s never acquired a crypto asset, and they’re coming to the space fresh. Let’s walk through step-by-step what it would take for that person to get to the point where they can execute a trade on IDEX, all the way through post-trade settlement. What does that look like?
Alex: The first step is [00:18:30] you have to get your funds converted into some sort of cryptocurrency, and ultimately it needs to be in ether. Being on the Ethereum blockchain, that’s going to be kind of the bridge between traditional currency and this exchange itself. We do not have a fiat on-ramp today, we’re exploring opportunities through partnerships, but what that looks like at this time is you would go to another exchange—one that does accept credit cards or wire transfers—a way to get something [00:19:30] from your bank account into that exchange, to then get Ethereum itself or get ether itself to bring over to IDEX.
Once you’ve made that purchase on another exchange, you actually have to have a way to interact with IDEX itself. You can’t just send from Coinbase directly to IDEX and start trading. This is what I mentioned earlier, the idea that your private key becomes your account of sorts. We support multiple different ways of interacting with IDEX. [00:19:30] And really all of them are, the term is wallets, but it’s really just different interfaces for managing and working with a private key. We have kind of a built-in wallet within IDEX, that if you want, you can just enter your private key directly into the website, and then begin depositing and trading from there. That feels very much like if you’ve used the MyEtherWallet interface and you go to their website, everything’s run locally on your computer, so your private key is never sent to the servers [00:20:00] of the website itself. But it gives you a web interface to interact with your private key and send instructions to the blockchain. In this case, deposit, trade or withdrawal.
The second and probably most popular option is through one of the many software wallets out there. MetaMask is probably the one that people are most familiar with. This is a browser plugin that keeps your private key and allows you to sign transactions using that private key at various applications. This is kind of a way to [00:20:30] separate the private key and message signing itself from the application that you’re interacting with. In this case, your key is never even exposed to the local version of IDEX. It’s always within just MetaMask itself, and you’re signing transactions and sending them to the exchange.
And then the third one that we recommend most users use is the hardware wallet approach, primarily Ledger Wallet. This is the safest way to trade and actually use decentralized applications because your [00:21:00] private key never touches a computer that is connected to a network. It’s stored within a physical hardware device, and then that device is connected to your computer through USB, and you’re just sending messages and information back and forth. When you want to do something on the exchange, it sends the correct details to the wallet, you then sign that transaction, and that signed message itself is set back to the exchange. You can think of MetaMask as a software [00:21:30] method for separating the key from the exchange, but the key is still stored on your computer somewhere. Whereas the hardware wallet takes it one step further and puts it on a separate device.
Clay: You’ve got some ether on a hardware wallet, and you go to the IDEX website, once someone’s gotten to that point, what do they do next?
Alex: You’ve got your wallet, you get to the website, and then at that point it really starts to feel like a traditional exchange, with the exception that every action you do is getting confirmed by your private key. [00:22:00] Let’s assume you’re using a Ledger Wallet, because like I said, that’s the one that we recommend. When you go to deposit funds, it feels just like a normal exchange. You fill out the amount and you click deposit. But instead of that happening automatically or telling you to send your cryptocurrency to a certain address, you then get a little pop-up, a notification on your ledger that’s asking you to confirm that action.
And this is where that interaction happens between the exchange and the hardware wallet. the wallet is getting instructions that says, “You’ve chosen to deposit this much of this [00:22:30] token or of ether.” and then you have to actually explicitly approve it on the hardware wallet itself. This is really that layer of security because no one can make any transactions or trades without also confirming on that hardware device.
Clay: You’re not depositing funds into a trade, you’re depositing funds into some kind of balance that exists on a smart contract out of which you can trade. Is that correct?
Alex: That’s exactly right. The way I describe the smart contract to [00:23:00] people is that it’s kind of like a giant vault safety deposit box. The vault itself is the outer layer of security, so that’s the smart contract. And then within it, you have individual safety deposit boxes associated with each customer. When you deposit into the smart contract, it’s going into the same smart contract that everyone else’s funds are, that larger vault. But within it, your private key is the only one that can access and authorize either a trade or a withdrawal of your [00:23:30] specific set of funds, your own individual safety deposit box.
Clay: You transfer funds to a smart contract that is kind of what you’re trading out of. Let’s say you want to go then make a trade, what does someone do in order to execute a trade?
Alex: That point it feels very much like a traditional exchange. You’ll head over to the part of the application that it’s got every other component that a traditional exchange would have. [00:24:30] It’s got a list of the markets, their recent prices and volumes. It’s got a chart for each market showing the trade history. There’s order books with bids and asks, where you can see orders that others have placed, existing limit orders that are available to fill. And then you’ve got a way to execute a buy or a sell. And just like a traditional exchange, you can either do a limit order, which you will be able to specify the exact price that you want to sell at.
Assuming there’s not an order on the books that meets your criteria, that will be added to the [00:24:30] books as a new limit order. Or you can take a market order, in which case you’re saying, “I want to buy or sell this amount at whatever the best price is on the market.” In that case, the system’s going to match you with other users who have already authorized their trades to happen within the same system.
Clay: This feels different than how other decentralized exchanges work. Is this idea of having an IDEX balance held in a contract, is that unique to how your exchange works?
Alex: [00:25:00] There are others that use a smart contract-based approach. [00:57:00] There’s kind of two different fundamental approaches. There’s trade directly from your wallet, where you are authorizing, 0x is the most popular of these, the 0x protocol. And essentially when you create a new trade or a new order, you are authorizing the 0x smart contracts to move those funds from your wallet in the event that they find a counterparty who meets your criteria.
In our case, we actually require the user to [00:25:30] deposit to the contract before they’re able to authorize any trades, and we do that for two reasons. One is the fact that if you are trading directly from your wallet, there’s a period of time where you could be matched with another user. The trade could be pending on the blockchain, but you can actually back out of the trade by moving your funds out of that wallet. There’s nothing that prevents you from backing out of a trade, if it moves against you during the time that it settles on the Ethereum network.
The other piece is that [00:26:00] because you’re relying on the blockchain and your wallet to be kind of the source of truth for how much funds you have and what’s available to trade, you have to wait in between every transaction before you can make another trade. Those are two—I think we’ll probably dig into it a little later—but kind of two elements of the user experience that the combination of using a deposit smart contract as well as routing orders, signed transactions through the exchange itself to submit to the contract, we’re able to solve a lot of the user [00:26:30] experience challenges that come from using a decentralized exchange.
Clay: I’m on your website now and I see in the upper right-hand corner a button that says “unlock wallet”. That is essentially analogous to logging into maybe a traditional Coinbase or Gemini— centralized exchange logs in on your website is “unlock wallet” is that correct?
Alex: That’s exactly right. It’s kind of bring your own account [00:27:00] type approach where, instead of creating a new username password, you’d actually come with your wallet and it’s, as I mentioned, it can be in one of those three forms, private key, key store, a software wallet or a hardware wallet.
Hey, this is Clay cutting in here from the editor’s booth to let you know that this episode of the Flippening podcast is brought to you by the Nomics API. If you need an enterprise-grade crypto market data API for your fund, smart contract, or app, then consider trying out the Nomics API. [00:27:30] Our API enables programmatic access to clean, normalized, and gapless primary source trade data across a number of cryptocurrency exchanges. Instead of having to integrate with multiple exchange APIs of varying quality, you can get everything through one screaming fast fire hose. If you found that you or your developer have to spend too much time cleaning up and maintaining datasets, instead of identifying opportunities, or if you’re tired of interpolated data and want raw primary source trades [00:28:00] delivered simply and consistently with top-notch support and SLAs, then check us out at NomicsApi.com.
Clay: Let’s move on to chapter three—the history of decentralized exchanges. I think now that we’ve spoken a little bit about what a decentralized exchange is and given folks a pretty concrete look at the step-by-step process for getting to the point where you can trade on one of these exchanges and actually [00:28:30] executing a trade, I think it’s important to take stock of where we’ve come from and how we’ve arrived here. Putting your historian hat on, how would you describe sort of the underpinnings and philosophies, and maybe first couple of steps that paved the way and laid the foundation for the emergence of decentralized exchanges?
Alex: I guess that there’s a couple of things that all decentralized exchanges have in common. [00:29:00] First, is this notion that users are authorizing all movement of funds with their private key. That’s kind of a fundamental tenet. And within that, what that means implicitly is that if you want to create an order ahead of time, create a limit order, that has to be authorized by the market maker, the person who’s creating that order and putting it out there in the world for someone else to come along and fill it. Where they start to diverge is in where those orders are hosted, and how [00:29:30] those orders are executed, and we’ll kind of dig into that a little bit.
This kind of talks to the evolution of decentralized exchanges. The very first iterations, and I mentioned earlier Etherx, so this is one my co-founder worked on that never made it to market but was one of these early implementations of a fully on-chain, as we call it, a fully on-chain version of a decentralized exchange. What that means is that anything related to orders or settlement actually was written into the blockchain. When you create a limit order, you’re specifying the [00:30:00] amount and the price.
For a simple example, you’ve got 10 clay tokens and you want to sell them for one ether. When you create that limit order, you’re signing with your private key that you will sell these 10 tokens for one ether, and no other deal is satisfactory. You’re not willing to sell them for 5, and if someone else is willing to pay 20 or pay you more, you’re unable to match with that. You’ve agreed to one explicit deal. The early implementations of this, you would actually send that transaction and [00:30:30] mine it in the blockchain, so that the order itself showed up in the contract, so that anyone else looking at the blockchain could see that this order existed and was available for taking.
One of the challenges with this is that any time you want to place an order, you’re having to pay the network gas fees in order to make that order and have it appear on the blockchain. Similarly, if you ever want to cancel that order, you have to pay another gas fee to remove it from the blockchain. And each of these requires not only a cost, but also time. You’ve got this latency component. [00:31:30] The next iteration looked at this and said, it’s no less secure if we mine the limit orders, than if we have the limit orders available off chain and available for someone else to come and fill and dispatch the whole trade itself to the blockchain.
Just to elaborate on that a little bit, there’s two pieces, there’s really two authorizations that are required for a DEX trade. [00:31:30] You have to have the maker sign his side of the trade that says, “I’m willing to,” in this case, “sell these 10 tokens for this one ether.” And then you’d have to have the taker come along who also agrees to the other side and says, “I’m willing to buy these 10 tokens for one ether.” The original versions had both the limit and the order being mined on the blockchain, while future ones said, “We can just have that user kind of pre-sign and authorize that trade,” but not until it needs to be executed do, we actually dispatch anything to the blockchain for settlement.
Clay: That first version, it sounds like the only type of order [00:32:00] that can be placed is an exactly priced order, and maybe there was some UI that would sort those in terms of variation off of some kind of derived spot price. But essentially, takers were just coming in and picking off a specific order, there was no unpriced orders that could take place. Is that correct?
Alex: That’s exactly right. And that’s exactly how it works even today on decentralized exchanges because [00:32:30] you are authorizing a specific order for it to be filed against. You’re saying, “This is either the price at which I want to buy or sell,” or as a taker you’re coming in and saying, “This is the order I want to be matched against and that I want to fill.”
Clay: So, on decentralized exchanges, at least today, there are no market orders, for example.
Alex: And the way you kind of describe market orders would be, it’s a UI type element, right? You can have an option in the UI that says market order, [00:33:30] but when you choose that, it’s really just saying, “Find the best priced order for me based on how much I want to buy or sell, and then match me with that specific order.” If that makes sense.
Clay: It’s hard coded into the transaction that you’re taking a specific order. So maybe there’s a slight, if highly improbable chance that that order could drop off.
Alex: Yeah, that’s exactly right. We actually we’re revisiting this. We’re planning to release an updated version of our contract that will [00:33:30] get rid of the specific order kind of a process, and instead make it one where, similar to existing exchanges where you say, “I’m willing to sell up to this price, or down to this price and I’m willing to buy up to this price.” And then it gives a little more leeway in terms of what trades can be matched with others.
Clay: Essentially, market orders with some built in like floors and ceilings.
Alex: Exactly, yeah. Because if someone can get a better deal by being matched with something else, [00:34:00] then of course they’re going to be okay with that.
Clay: You mentioned Etherx being one of the first decentralized exchanges that was about to launch, but perhaps never went live, or in fact never went live. What were some of the other early pioneers in the space?
Alex: Yeah, so I think Oasis DEX I believe was the first one to launch and really gain some traction, and that was an example of a 100% on-chain approach. Limit orders were mined into the blockchain, [00:34:30] and then users would come along. You could actually trade on it without even using their UI, because you could actually look at the blockchain itself and see what orders were available. Ether Delta came along, and they were the first ones to say, “We don’t have to have every limit order be mined into the blockchain because at that point no funds are actually being traded. It’s really only the full trade that we care about using the blockchain,” because that’s the critical step, right? That’s the part in which one user’s funds are [00:35:00] swapped for another. It’s essentially you can think of it, you deposit into the smart contract, which kind of acts as an escrow agent, and then you sign a limit order which is kind of preapproval for this trade and only this trade.
And then Ether Delta provided a UI where users could see and sort those orders and understand what kind of pre-approvals were out there to trade against. And this again, you didn’t actually need a UI, you could sign a preapproval and send it to someone via Skype [00:35:30] or a telegram. This was this kind of this notion that two users can agree to something without having to either mine it into the blockchain or necessarily know and trust each other.
Clay: These early 100% decentralized exchanges were essentially UIs on top of a smart contract, and they could be completely unbundled, the UI and the smart contract.
Alex: That’s exactly right.
Clay: Where does it go from there? This has a very short history. I know of Air Swap, and 0x and [00:36:30] Radar Relay, and Paradex, they’re some somewhat notable brands in this space. What’s the path between EtherDelta and the emergence of IDEX, were you developed in parallel to 0x and Air Swap? Were they around for you to consider building on top of their infrastructure? Where does IDEX come along in the arc of this very short history?
Alex: We were close to launch when 0x went live, and we actually looked at it as an alternative, thinking that [00:36:30] there’s someone to manage our smart contracts and certainly they had a lot of popularity and had a lot of mine share. We thought there would be many benefits to building on it, but there were actually some subtle nuances that made it not suitable for our design, at least the way 0x was designed at the time.
Just to dig into what those nuances are, for both OasisDEX and EtherDelta, there is this component of once a taker finds an order that [00:37:00] they want to fill, approves it and signs it with their private key, how does that transaction, that trade, then get to the Ethereum network for processing? On both OasisDEX and EtherDelta, as well as 0x relayers the taker is responsible for submitting that signed transaction.
There’s couple of implications of that. First off, when a taker submits a signed transaction to the network, everyone can now see it. It’s now public that it’s sitting there waiting to be mined. Other users are then able to [00:37:30] see this transaction and potentially front-run that trade by trying to sign a similar order or the same order but paying a higher gas price in order to do so.
You have these issues where users are able to jump in front of each other, and it doesn’t maintain the price-time priority that’s so important for decentralized exchanges. One of the other challenges is, in that example, you aren’t sure that your trade is actually going to go through. Which can be very problematic for those who are [00:38:00] performing algorithmic trading strategies where every trade is critical, and you’re making a small amount on mini trades overtime time.
Clay: Just interjecting here, is it actually possible to front-run in the traditional sense because the way these contracts work is that you’re actually sniping a specific order? If, you have a taker that wants to buy an order placed by a maker, they’re actually calling that out explicitly. If someone front-runs that, [00:38:30] it does not necessarily follow that the taker is going to buy from the front-runner of the original order placed by the maker. Correct?
Alex: Well, it is more so that someone else would front-run the taker and go for the maker order that they’ve already tried to submit.
Alex: If that makes sense. It’s really around this coordination piece. You can think of it as the UIs that you’re using, all of that updates with the speed of a [00:39:00] centralized server, so it happens pretty much immediately. But when you actually go to execute the trade and submit it to the Ethereum blockchain, there’s this waiting period where it’s out there, everyone can see it, but it has yet to mine. And that really has two implications; it’s that others can jump in front of you, so you’re not sure you’re going to get that order.
One simple example of this, it might not even be malicious. One of the big challenges was on EtherDelta, multiple users would try to fill the top orders on the books, because this is a popular market, [00:39:30] there’s a lot of trades going on, multiple users are trying to get it at the same time. Everybody’s dispatching their trade to the network, but only one of them is going to be successful. Everybody else’s trade is going to fail and then they’re going to have to go back to the order books and try to find the next best one.
Clay: And they just lost their gas.
Alex: They lost their gas, and it has this weird side effect where, as the volume grows, the user experience gets worse, because you’re gonna have more and more users competing for the same top-priced orders. It doesn’t even have to be malicious front-running, [00:40:00] it’s just the side effect of everybody trying to get the top order in their best interest.
Clay: This is more about the collision of take our orders, it’s not about algorithmically seeing that a taker order is there, buying it from the maker, and then turning around and immediately reselling it to the taker before their order can go through?
Alex: That’s exactly right. It’s more just the byproduct of users doing what they’re trying to do, which is fill the top best-priced order.
Clay: [00:40:30] You’ve got a 0x coming on the scene in a more primitive form than it is now, you considered that it didn’t meet your design requirements. What else was on the scene at the time? Was AirSwap around at the time or is this pre-AirSwap?
Alex: Just to really quickly finish up with the design requirement piece, the innovation that we had at IDEX was to once the orders are signed by the maker and the taker, that signed transaction is passed to IDEX itself, [00:41:00] and IDEX is the only one authorized in the contract to submit these trades for settlement. The reason that helps is because you now have one actor coordinating that trade submission process who can then say, as in this previous example, “Actually, that top order has already been filled by these two people over here, you now have to go to the next best priced one.”
You can have your order books update immediately even though there’s this delay in settlement. The other piece that’s beneficial is because [00:41:30] we know that users trades are going to mine, it’s just a matter of time. Users balances on IDEX actually update immediately, and they can continue to trade even while that first trade is waiting to settle. So, say you come in and you sell some tokens for Ether, you can immediately move to another market and use that Ether to buy a different set of tokens. Behind the scenes the exchange is dispatching those two trades in the correct order, so that the sell mines before the buy. That way the smart contract is always staying in sync with what’s happening within [00:42:00] the centralized exchange.
Clay: How do you handle the collision of taker orders? Is it based purely on timestamp? Do you go down to the millisecond, the nanosecond, what level of precision is available there and what do you do if two orders are placed at the same time?
Alex: It’s going to be based on which one gets to the server first. If two users are trying to get the same order on the books, one of them is going to be successful, whichever one shows up first, and then the other user [00:42:30] is going to get a message saying that the order is no longer available because it’s been filled by someone else. I was just going to say, that’s why when I mentioned earlier, we want to change that so that instead of matching with a specific order, you’re giving parameters. That way if there’s another order on the books that meets your criteria but isn’t the exact order you are trying to fill, we could then match you with that second-best order without you having to re-approve.
Clay: That makes complete sense. A decentralized exchange is almost [00:43:00] analogous to going into a store or going to amazon dot com, and not saying, “I want to purchase a tennis racket that is this model and brand, but actually I want to purchase inventory item number 1265041.” and if someone else has purchased that for you, then the order fails, which is kind of ridiculous.
Alex: Yeah. And then the goal of us as [00:43:30] UX designers is to make the front end so that from a user’s perspective, even though that’s how it’s working internally, they can’t tell the difference, right? If those two inventory items are in fact the exact same, and the user’s willing to pay the same price or both of them meet their criteria in terms of pricing and amounts, they’ll get matched with the second one without even knowing that the other alternative was there.
Clay: Let’s move on to chapter four, [00:44:00] which is about the components and attributes of a decentralized exchange. The way to approach this is to first speak to the components of any exchange. What do you think are the core functions that can be unbundled from each other in the execution of trades on an exchange?
Alex: Every exchange is going to have a set of order books. This is the way that those who are placing limit orders are able to communicate [00:44:30] with others what their price and amounts are. Actually, I shouldn’t say every exchange because there are platforms such as AirSwap that don’t actually have order books, and they actually use a different approach to match users ahead of time, and then have them work to negotiate price and amount. I shouldn’t say that the only way to trade is through an order book structure.
Bancor is another example where they have the automated liquidity provider where you don’t see an order book, you’re selling into this contract which is then giving you a price and [00:45:00] amount based on how much you’re trying to buy yourself. But the majority of exchanges that users are familiar with have this order book approach where you can see a list of existing orders, how much users are willing to buy or sell, and the amounts that they’re willing to do so with. That’s going to be pretty much universal to both centralized and decentralized exchanges.
Clay: I realized, this is kind of basic, but I want to make sure that this is a comprehensive guide. Let’s describe a little bit the relationship [00:45:30] between orders and trades. In a lot of ways, an order is a parent object of a trade, so you can have an order, it can be canceled, it can be 100% filled or it can be partially filled, it can be partially filled and then canceled. It almost seems like if you were using a database analogy, or an object-oriented analogy, there’s this parent-child relationship between orders and trades. There isn’t a one-to-one correlation there. [00:46:00] There can be a variety of trades executed against one order over a long period of time. Have I described that correctly?
Alex: Yeah, that’s exactly right. I would just say an order is just one-half of a completed trade. Someone’s got to be there first. Someone’s got to show up and say, “Hey, this is what I’m willing to sell or buy, and this is the price I’m willing to do so at.” And then others can come along and as you said, [00:46:30] that’s when a trade happens, when a counterparty comes along and says, “I agree to those terms.”
They might not want to fill all of it, which is how you get partial trades. That person who placed the first order, can then decide, “Do I want to cancel the rest of it, leave it out there for someone else to fill it?” Really, fundamentally, an order is that first person who is agreeing to what will ultimately be a two-sided market and a two-sided arrangement.
Clay: We’ve talked about order books. What are some other components that are common to almost all exchanges?
Alex: [00:47:00] The second big piece is the—and I’ll call it the matching process—and this is really how do users who are coming to buy or sell, who want to be takers, how do they find what orders are available? As I mentioned, some exchanges are taking the approach of matching makers and takers before they even create the orders and decide on quantity or amount. More traditionally, takers will come along and they’ll see the order books and then they have the option of either [00:47:30] selecting a specific order that they want to fill, or they can choose something like a market order, which is essentially a way of sorting, it’s kind of a sorting and matching process on what else exists out there.
A market order, the way it works is users will specify the amount that they want to buy or sell and then the exchange will match them with the best orders available that meet all of those criteria in terms of the full amount. If the top order doesn’t have enough inventory, then there’ll be routed into multiple orders. [00:48:00] Going back to what we were talking about earlier about matching with specific inventory, in the case of a DEX, you’re actually matched. It’s more of a sorting function, the UI, that actually helps you parse through what orders are available and helps match you with the specific order that meets your criteria.
One interesting, I think, concrete example of how this would differ from a centralized exchange is, say there are multiple orders to sell a certain token at one Ether. In a centralized exchange they could actually combine [00:48:30] all of those orders into one record on the order book because from a user perspective, they’re all the same thing. They’re all fungible. They don’t care which one they’re actually routed into.
In the decentralized exchange, those are actually each discrete signed transactions from potentially different market makers. It actually does matter which one you’re matched into, and each one, if you want to, have an order that’s big enough to fill all three of them, for example, you’re actually going to have three separate transactions dispatched to the network.
Clay: We’ve got [00:49:00] order books. We’ve got some kind of matching process that pairs makers with takers. For complete newbies listening to this, how would you define a maker and a taker?
Alex: The maker is the one who shows up first to this transaction. They’re the one who puts the initial order out there of, “These are my terms,” the price and the amount that they’re willing to buy or sell. The taker is the one who comes to the exchange and sees that available order and decides to take it from the books, hence the terminology.
Clay: [00:49:30] Essentially, taking the other side of that trade and completing the transaction. We’ve got order books, we’ve got a matching process, what is the next component of an exchange?
Alex: What we haven’t talked about is custody of funds and this ties into trade settlement as well—trade execution and settlement. In a centralized exchange, as I mentioned earlier, you’re depositing your funds and you’re sending them to a wallet that they control. When all of these trades are happening, [00:50:00] there’s actually no transfers going on, on the blockchain. The database that the exchange runs is updating everybody’s balances, tokens and cryptocurrencies are moving back and forth, but it’s all within their internal records. The blockchain itself isn’t updated until a user actually goes to withdraw. In that case, it’s an interesting paradigm where the settlement is one-and-the-same with execution, but there’s this extra step before you can take possession of it. There is a withdrawal process before it actually comes back to a key that you control.
[00:50:30] Decentralized exchanges are a little different in the sense that, the trade settlement actually moves the cryptocurrency on the blockchain, in the sense that it actually moves from control from one user to the other. If you’re buying tokens with Ether when that trade is settled, you’re actually relinquish control of that Ether and now you have tokens under your control and your possession.
One of the, and this ties into the differences in our design versus others, one of those nuances is the execution piece. As I mentioned, [00:51:00] our big difference is, once a maker and a taker have agreed to an order and both users have signed their side of the trade, how does that completed trade get to the Ethereum network for processing? On other decentralized exchanges, it’s the end user’s responsibility to dispatch it to the network, which can lead to some of those challenges where you can have multiple users trying to fill the same order at once. On IDEX, IDEX actually controls that execution process where matched trades are dispatched to the contract [00:51:30] through the exchange, so that we can continue to have trading activity and keep the order books up to date in real time while the settlement process is happening on the Ethereum network.
Clay: Thinking about centralization, decentralization, as a continuum, we have maybe OasisDEX or EtherDelta on one end of the spectrum, completely decentralized. We’ve got Coinbase, Gemini, Bittrex, other exchanges that folks have heard that are completely centralized, and we [00:52:00] have IDEX somewhere in the middle. Certainly not at either of those extremes. Let me see if I have this right, at IDEX the order books are centralized, the matching process is centralized, and the custody is decentralized, is there another parameter here to consider or is that basically correct?
Alex: Yeah, so those are the, I’d say the [00:52:30] base components of making a trade happen. There’s also the area of what assets are available for trading, the notion of token listings or asset listings. Under a centralized exchange, obviously, that’s entirely under their control. They’re choosing what is available for trading.
Under a fully decentralized exchange, you can control it through the UI, in the sense that OasisDEX could update their UI such that you can’t see certain tokens, or you can’t interact with certain [00:53:00] token contracts. But on the blockchain level, there’s no restrictions to what you can trade, because the contract itself is designed to be open and allow anyone to be able to trade and interact with it.
That’s a little different than our design. Because we’ve made the decision to have IDEX control the trade submission process that means we’re also in control of essentially what assets can be traded because all of the trade dispatches have to go through the exchange itself. Because of that, [00:53:30] we actually control the token listings and have a process to vet and approve projects before bringing them on the platform.
Clay: Can you mention just one or two other decentralized exchanges that are neither completely centralized nor completely decentralized, that might have a slightly different configuration than you do, and what components of those processes or of those exchanges are centralized versus decentralized?
Alex: Radar Relay is an example of one that [00:54:00] they are not fully decentralized in the sense that the orders are hosted off-chain. The limit orders are still these pre-approved transactions that the maker orders. It’s something that a user has signed ahead of time and given, in this case is 0x contracts, the approval to make the trade if someone else comes along and agrees to those terms. However, the dispatch process and the, I guess we’ll call it the execution process, how does a fully [00:54:30] signed and approved trade get to the network for processing that is decentralized. In the sense that you can go through.
When you’re on Radar Relay, your account is actually the one sending it to the network for dispatch. You could actually go to their website and you could get some of the orders and then dispatch them later entirely outside of the Radar Relay UI, or you could take a limit order that you created there and send it to a friend via Telegram, and he’d be able to fill the other side. And that’s because there’s really [00:55:30] no relation between the 0x contracts that are executing the trades and the exchange itself is more of a UI interface to interact with that set of contracts.
Clay: Not only is the matching process not on chain, it might not even be online at all. A couple of people might meet at a coffee shop and agree to a certain price and they’re just using the decentralized exchanges like a settlement in clearing house sort of mechanism. Is that right, or [00:55:30] am I not thinking about this correctly?
Alex: No, that’s exactly right. Fundamentally, it’s definitely a nuance point, but it hinges on whether or not if you can interact with the contract entirely without the assistance of a UI or another third party. As I mentioned, the fact that we control the dispatch process means that users are unable to initiate trades on IDEX without going through IDEX itself. [00:56:00] We talked about why we think that’s a valid and very beneficial trade-off because of the vast improvements it brings in UX. But one of the admittedly drawbacks is that other decentralized exchanges, their contracts can be interacted with directly without going through the UI of the creator.
[00:56:30] This wraps up and concludes part one of this two-part deep dive on decentralized exchanges. Part two comes out next week. See you then. If you’d like to discuss this episode with others, please go to nomicstelegram.com.
That’s it for this week. To sign-up for a free crypto investing newsletter, listen to other episodes, or get the show notes from this episode, please visit flippening.com. I also invite you to check out the startup that funds this podcast, [00:57:00] Nomics, at nomics.com. Finally, if you’ve got value from the show, the biggest thing you can do to help us out is to leave a five-star review with some comments and feedback on iTunes, Stitcher, or wherever you listen to podcast. Thanks for listening and see you next week.