Instant Trades Now Possible without the Need for Centralized Exchanges
Last week I received a private invite to the beta launch of Sparkswap, a semi-decentralized built on the Lightning Network. The only centralized part of the exchange is the “relayer,” which the Sparkswap team controls to perform certain functions like aggregating the orderbook with bids and asks. For the most part, however, the users (aka “brokers”) are in total control: they host nodes themselves, their own wallets with their private keys, conduct transactions directly with the counterparty, etc.
Trey Griffith, founder of Sparkswap, explained in an exclusive interview with #TeamLunar what inspired him to start the Sparkswap project:
“I started working on this because I was worried about putting my own assets on the exchanges out there and was shocked that there wasn’t a non-custodial alternative that worked for real trading. Most of the projects I saw were either low performance, didn’t support real Bitcoin, or were just re-creations of the existing financial systems. I thought (and still think) we can do better.”
The Lightning Network
For those that are unfamiliar with the Lightning Network, it may be hard to understand the significance of being able to launch an exchange on the network. The Lightning Network is a “Layer 2” protocol built on top of existing blockchains, most notably Bitcoin. The whitepaper (BOLT — Basis of Lightning Technology) was published in 2015 by Joseph Poon, who is now working on Plasma with Ethereum and OmiseGO, and Thaddeus Dryja, a University of Virginia PhD candidate in cryptography and network security.
The Lightning Network was conceptualized to combat the clunky and slow nature of blockchain — which is essentially a long list of immutable, cryptographically confirmed transactions. The basic idea of the Lightning Network is that we don’t need the entire ledger of every single transaction that’s been recorded since 2009. To put into perspective the size of Bitcoin’s blockchain, none of our eight servers at Lunar Digital Assets had enough disk space to demonstrate the Lightning Network exchange. To become a broker, it’s required to host your own nodes, which meant we needed to download over 200 GB worth of transaction data for Bitcoin alone (each trading pair needs to download its entire blockchain as well). Ultimately I decided to ditch the idea of using our servers and launch a VMware Ubuntu instance on my local computer at home.
The Lightning Network adds an extra protocol (layer 2 solutions) on top of existing blockchains, allowing transactions to be light, nearly instant and free, and cross-chain compatible. This is made possible by “Lightning Nodes” that set up a two-way channel between two parties. In these nodes are pre-deposited funds that are simply redistributed between shared multisig wallets. This allows the impression of an instant transfer of funds, but the transaction isn’t recorded on the actual mainnet chain until the channel is closed. The Lightning Nodes are an integral part of the network, giving more liquidity and transferable funds to users that do not run a node themselves.
Lightning Network Gaining Rapid Traction
On May 10th, 2017, the first Lightning Network transaction was made on Litecoin’s mainnet. The first Lightning Network transaction on the Bitcoin mainnet was made months later in December. Since then there have been many other blockchains that successfully integrated the Lightning Network; Vertcoin, Stellar Lumens, Ravencoin, Decred, and Nimiq are among the growing list. Despite the critics that have vocally argued that a layer 2 solution was insecure or not the optimal way to fix the bottleneck of Bitcoin, the Lightning Network has been growing steadily, now faster than ever with over 7.5K nodes, almost 40K open channels, and a network capacity of over 1K BTC. Whether the critics like it or not, it looks like the Lightning Network is here to stay.
Griffith, in the interview confirmed his reasoning to use Lightning Network as the foundation of Sparkswap:
“We chose the Lightning Network (and Payment Channel Networks more generally) as a platform for two major reasons: 1) we can interoperate with the most liquid blockchains (i.e. Bitcoin) and 2) we can execute and settle trades with speeds that are comparable to custodial exchanges. So while we only support BTC/LTC right now, over time we can support nearly all of the large trading volume cryptocurrencies, and since we can execute and settle trades completely off-chain we can actually compete with the biggest players in the space.”
A much more comprehensive text can be read here where he explains the implementation, drawbacks, and a lot more technical reasoning.
Sparkswap: Requirements and Installation
The private beta of Sparkswap only has one trading pair Bitcoin and Litecoin. However, with the growing number of coins with Lightning implemented, more coins can easily be introduced to the exchange for trade in the future. The recommended system requirements are currently 3 GB ram and 250 GB of disk space (mostly due to Bitcoin’s massive size). Again, full nodes are required to become a broker on the exchange, as well as full payment channel nodes.
The installation is pretty straightforward for anyone that’s familiar with CLI interfaces. There are some open-source software that’s required for installation: nvm (a nodejs package manager), NodeJS 8.11+, and Docker. From there it’s only a matter of downloading some bash files and letting Docker install the pre-built image.
Once installation is finished, the script will give you a unique link to register yourself with the relayer. Unfortunately registration is currently in private beta, but feel free to apply for an invite on their website. Once registered, you’ll have to set up your Bitcoin and Litecoin wallets and “commit” your balance to the respective wallets.
Now the Fun Part: Placing Your First LN Order
At the time there are only four types of orders: limit buy/sell, and market buy/ sell. As the project continues to improve, I’m sure more order types will be integrated. This is only the beginning, and that’s the exciting part.
Streaming the Orderbook for the BTC/LTC pair:
sparkswap orderbook --market BTC/LTC
Placing a Limit Order to buy 0.001 BTC at a price of 1.297 LTC per BTC:
sparkswap buy 0.001 1.297 --market BTC/LTC
Placing a Market Order to place a market order to buy 0.0001 BTC:
sparkswap buy 0.0001 --market BTC/LTC
Obstacles, Dilemmas, Regulatory Woes, and Future Goals
Pretty fascinating and beautiful work, right? We absolutely think so. But it’s not all glory. When asked about the obstacles that he faces, Griffith goes on to explain a variety of things, including regulatory worries:
“We’re building on some very new technology, so things take longer and have worse UX than we’d like. Nearly every problem you’ve read about with Lightning we’ve encountered and worked around or papered over to make the UX passable, and it’s still only really suitable for professional and semi-professional users. The structure of the atomic swap itself is pretty interesting and challenging.
Since we are a business and parts of what we do are pretty centralized, we’re being more conservative than most when it comes to regulatory compliance. Not all of our users agree with that approach, but we think a shipped product with good user experience is more important than chasing the elusive decentralized ideal, especially in the short term. The result is a product that works better and exposes us and our users to less risk, but is more restrictive in its deployment.
Our goal is to be a high performance trading venue that supports highly liquid trading pairs without taking custody of assets. We’re working on the cutting edge of deployed technologies in this space to achieve that. We’re not a non-custodial GDAX/Kraken/Binance yet, but we’re getting closer.”
This is definitely one of the more exciting use of the Lightning Network that we have seen. Fully decentralized exchanges are slow, orders do not always go through as expected, and the volatile nature of cryptocurrencies create uncertainties in the final purchase price. Atomic swaps take too long to trade with “GDAX” like speeds, which is crucial for day traders and market makers. Sparkswap, on the other hand, is revolutionary in that the exchange speeds can rival that of actual centralized exchanges — without having to give up custody of your private keys. There’s no slow withdrawal times to worry about, making arbitrage opportunities very attractive on Sparkswap. Exchange hackings, surprisingly, are still a common occurrence, which is very concerning as many exchanges are more focused on profits than the security of its users’ funds. The UI is very straightforward, elegant and, dare I say, beautiful — which is almost an oxymoron for most CLI-based programs.
However, all this is not to say that there are no drawbacks. First of all, not all blockchains have Lightning Network implemented, nor do they plan to. That eliminates the vast majority of assets tradeable on Sparkswap. Secondly, the vast majority of retail traders are not familiar with any CLI-based tech, whether on Linux or Windows. nvm, npm, NodeJS, Docker can be very difficult for these traders without a technical background. Thirdly, the need to download entire blockchain nodes for each asset can be very off-putting for those with limited disk space, slow or throttled internet, or very expensive storage prices for those that like to use cloud-based services.
Innovators Welcome & Appreciated
I applaud the Sparkswap team for the incredible work that they have achieved so far. We don’t feature projects often, but when we do, it’s with strong conviction. #TeamLunar welcomes innovation and risk-takers, and we wish the Sparkswap team the best of luck. We especially respect projects that open source their code, as it is in my opinion that without the open source community, the internet would be radically different from what it is today, and Bitcoin would not exist. And come on, let’s admit it — what they’re doing is freakin’ cool. We encourage everyone to check the project out and show support; without innovators, the world would be a dull place.