Switcheo Exchange, a Singapore-based decentralized exchange hosting markets on the NEO and Ethereum blockchains, recently announced the addition of cross-chain trading (atomic swaps) to its product. Switcheo users can now trade cross-chain between its NEO-based SWTH token and Ether (ETH). Switcheo’s decentralized market is the first to offer a trading pair between the Ethereum and NEO blockchains.
Although cross-chain trading has been a highly anticipated feature in the world of blockchain, practical implementations for traders and the public have remained elusive.
NEO News Today’s Colin Closser made a call to John Wong, VP of Engineering at Switcheo Exchange, to talk about cross-chain trading. Support for multiple blockchains has been in Switcheo’s long-term development plans for some months, with Wong’s three-person team beginning work on the feature in January of 2019.
NNT- Colin: First off, congratulations on getting cross-chain swaps running.
John Wong, Switcheo Exchange: Thanks.
Colin: You’re one of the first exchanges to do that. I mean, Komodo has been working on it. Bisq (formerly Bitsquare), a distributed trading platform, has atomic swaps. Do you know if anyone else on a commercial platform has atomic swaps running?
John: No. I think the most common one is Komodo, for atomic swaps being used.
Colin: What R&D did you do to determine this was possible? Did you do any research beforehand to determine if it was possible?
John: We looked at what you were asking earlier, which commercial platforms were doing cross-chain trading. And we also looked at which hashing algorithm we should use, because we needed a common hashing algorithm for both NEO and Ethereum.
We also needed to figure out how we could make it simple for the users.
Colin: I noticed that your implementation right now is very simple. I think Switcheo is currently the only counterparty offered for swaps, correct?
John: Yes, Switcheo is counterparty on both sides.
Colin: So as long as that’s the case, that explains the spread, right?
John: There shouldn’t be a spread, but there will be slippage on both sides. The amount of slippage depends on the size of the liquidity pool.
We have plans to increase our pool a lot more by enabling other users [to act as counterparties] to commit to it.
Colin: Does your implementation of cross-chain use hashed time-lock contracts?
Colin: And you mentioned that Ethereum and NEO need to have the same hashing algorithm?
John: Yes, we need that internal synergy.
Colin: Are there certain blockchains that you can’t perform cross-chain with at this time?
John: So far, from what we’ve seen, there aren’t any blockchains that do not support the hashing that we use. We are using SHA-256. So it is also compatible with Bitcoin.
That was one of the key things we researched before: whether this algorithm that we use can extend the atomic swaps to other chains. The first atomic swap between Bitcoin and Ethereum was using this hashing algorithm. And that was also one of the reasons that we decided to go with this general algorithm.
Colin: What challenges did you come across while you were developing cross-chain?
John: One of the most difficult things was to create the pricing model. At first, we didn’t have a plan in place for how we were going to automate the swaps. We knew that we had to have an automated swap. But the pricing algorithm, we didn’t look into until much later.
One of the other things was deciding how the whole flow would go. There was discussion on who should be the first user to start the atomic swap transactions, whether it should be Switcheo or the user. Those were the most complicated ones to get right, as there were quite a few considerations for either strategy.
Colin: Can you elaborate on that? What most people don’t realize is that because either both sides of an atomic swap transaction go through, or neither go through, when one party goes first–the other party has the option, the right but not the obligation, to fulfill the contract. So when cryptocurrency prices move around, you’re giving someone a free option if you don’t create a deposit.
Right now, Switcheo is dealing with that by acting as the counterparty on every trade. But how do you see working with those inadvertent call options going forward?
John: Our plan for now is that Switcheo will always be the counterparty for atomic swaps. Right now there is also a small fee, but let’s go back to what you were saying. So for Switcheo, we are the counterparty, we are the ones who will lock our funds first for an atomic swap. So that exposes us to the risk that users will not fulfill their side of the swap.
The unique thing with Switcheo is that by depositing into our contract, users have already agreed to lock their funds into our contract, in a sense. So that allows us to lock their funds with ours even though we are the first to start the Atomic Swap transactions.
Colin: Okay, so with the smart contract, even if Switcheo can’t take custody of the funds, you can delay the user’s withdrawal to prevent abuse. That’s pretty interesting, I never considered that before.
In the future, when you have Switcheo Chain, do you plan on burning Switcheo tokens with every trade?
John: We are actually still discussing that. I think we are probably going to do the staking, and have a staking component. The burn component is still under consideration right now.
Colin: So the thing about different blockchains is they have different finality. Ethereum is probabilistic, while NEO uses consensus to have one-block finality. How do you determine when a trade is irreversible?
John: In the current setup [before a standalone Switcheo Chain], for Ethereum, we wait one block to consider it final, because for Ethereum, the transactions can only be trading transactions. The transactions which cause a user’s balance to decrease are only sendable by us. We’re not really worried about blocks because in the worst case, we can just rebroadcast the transaction and it will go through.
Colin: Yeah, I guess you have the advantage of your smart contracts where the users’ funds are already accounted for. You’re not beginning with a light wallet, you’re beginning with a smart contract.
How is the EOS/NEO cross-chain coming along?
John: We are just in the midst of it. The EOS contract has the atomic swap, we just haven’t fully tested it with NEO.
Colin: Is it a noticeably different process with the different chains?
John: Yes, it definitely is. With NEO, it’s a different environment…some parts are easier on some blockchains, and some parts are harder.
For example, Ethereum vs. NEO, Ethereum has unit testing for its smart contracts that makes it faster to develop the smart contracts. It’s easier to test at the moment. There are more development tools. Also on Ethereum, there’s the Ropsen TestNet, and a few different TestNets. For NEO, we are hosting our own TestNet in order to test our contracts.
Colin: What makes Switcheo’s solution to atomic swaps an elegant one? For me, one of the elegant aspects is that you already have the user funds locked in a smart contract. Are there any other aspects that you or your team have designed that you’re proud of?
John: Well, I think the other one would be, we are using the same pricing model as Uniswap. Uniswap’s pricing is a really simple formula. For example, you have a certain amount of Switcheo, and a certain amount of Ether. You multiply them together to get a value. The user wants to get a certain amount of Switcheo, then the amount of Ether needs to decrease so that the product [ETH value * SWTH value] remains the same as the initial product.
The formula is quite simple, but it balances quite well based on demand for either asset.
Uniswap of course is on a single chain, and there isn’t the potential for chains to be rolled back. So one of the innovations was to use their pricing model, but account for the possibility of chains being rolled back, and not allow the pricing model to be abused.
Colin: Do you think that you’re going to stay with the Uniswap pricing model?
John: For now, it depends. We might decide to change the way pricing is done. For now, it will depend on how much liquidity we have. It’s possible to tweak the formula and we are considering that as well.
Colin: How many atomic swaps are you doing per day right now? Are people playing with the feature?
John: Right now [April 27th, 2019], we’ve had about 100 swaps. The total volume is about $10,000 USD since we launched.
Colin: There’s an option called “Skip Waiting for Maker Transaction.” I think I read about this earlier in development. It’s an option to speed up the transaction by trusting Switcheo to deliver as the counter-party?
John: Yeah. Actually, you will send the transaction right away. But how long the user wants to wait is up to the user. So if he wants to wait 2-3 blocks to make it more secure, he can do so.
Colin: So where do you go from here? You bring more pairs, more chains. Switcheo Chain is coming. Is that correct?
John: The main things coming are tokenomics, making sure our token has good utility. And to improve the trading experience for users. Decreasing the network fees, and improving trading performance.
Colin: In the future, you’re talking about having people stake Switcheo tokens to oversee and validate trades on the decentralized network. Do you see a role for these validating nodes to improve cross-chain trading as well?
John: In addition to having a possible third party liquidity provider, we would like to allow users to have different types of orders in the future, like leverage, for example.
Colin: You’re talking about margin trading?
John: Well, the Switcheo Chain will enable us to do more things. Margin trading is quite possible. But there’s no direct tie-in between margin trading and atomic swaps.
Colin: But you will have different types of filling and executing orders?
John: Yes. And you won’t be limited between pairs anymore, by a single blockchain. So it could be between Ethereum and NEO.
Colin: Congratulations on getting this running so quickly. There’s a lot of people genuinely excited about this project.
John: Thank you for the interview.
About The Author: Colin Closser
Colin Closser, M.D., was a speaker at the first NEO DevCon in San Francisco. A devoted contrarian, he has managed the improbable: a peaceful and healthy life, despite holding a medical degree. He aspires towards the wisdom of Michael Lewis and Nassim Nicholas Taleb.
More posts by Colin Closser