Wednesday, September 27, 2023

To celebrate the launch of Hydranet DEX (Win|Linux) and its offchain BTC/ETH pair, here is a technical overview written specifically for r/cryptocurrency.

What is Hydranet DEX?

Hydranet DEX utilizes multiple Layer 2 protocols - Lightning Network (LND) for LN-compatible coins (i.e. BTC, LTC), Vector (initially developed by Connext) for state-channel management of ERC20s, and Arbitrum One (byte-compatible with ETH, very fast and affordable) - to achieve cross-platform interoperability between otherwise incompatible coin pairs off-chain at fast speeds for an affordable price.

In more technical terms, Hydranet DEX is a qt5 GUI-based multicurrency light wallet that runs state channel nodes and multiple LND node variants simultaneously. Each wallet acts as a dedicated LN node and features an integrated LN backup manager. It uses a 24 word mnemonic seed phrase for recoveries, and an additional layer of password protection to further restrict access to the wallet after recovery.

How does it differ?

DEXs fall roughly into 1 of 3 unique categories at this moment in time:

Layer 1 DEXs: Utilize HTLCs to execute decentralized atomic swaps between two blockchains, true to the nature of the very first atomic swaps done by bitcointalk legend JL777 in 2015.

Layer 2 DEXs: Utilize HTLCs to execute atomic swaps much like an L1 DEX, with the additional functionality of zk-rollups or state channels for intra-ERC DEXs, or Lightning Network for intra-LN coins. In short, zk-rollups consolidate several otherwise individual transactions into one discrete “rolled up” tx that makes much more optimal use of the ETH blockchain and eliminates further congestion on its network. Lightning-based DEXs make use of multiple coin-specific LN daemons (i.e. BTC LND, LTC LND) that run simultaneously and utilize the instant, low fee nature of payment channels to foster an automated ecosystem of channel “rentals” – ultimately allowing the user to deposit one coin (BTC) and swap it into a different coin (LTC) off-chain.

Layer 3 DEXs: Utilize multiple L2 scaling solutions built for different blockchain technologies and runs them simultaneously to achieve a bridging layer between otherwise incompatible chains. With this additional layer of abstraction and interoperability, UTXO-based blockchains like Bitcoin and Litecoin are capable of directly interacting with EVM-based chains like Ethereum and ERC20s like Tether directly from high-speed LN-based payment channels or vice-versa.

As Hydranet DEX allows for direct P2P trading of UTXO-based coins for EVM-based tokens (and vice-versa) via multiple L2 protocols that run simultaneously, it is considered to be a Layer 3 DEX.

How does it all work?

Hydranet DEX’s multicurrency wallet (MCLW) is a light client that references the reliable network of full nodes running on each respective chain it supports. During the initial wallet setup, you are given the option to either restore from backup or generate a new wallet. It functions like an ordinary multicurrency wallet capable of sending and receiving funds on-chain.

For UTXO-based blockchains, Hydranet DEX utilizes the Lightning Network Daemon (LND). It should be noted that the LN daemons are light clients. LND is a mature, robust, open-source implementation of Lightning Network. Stock, unmodified variants of the LND protocol are the implementation of choice for Hydranet DEX. Funds can be transferred in and out of the wallet the traditional way (deposits pending x confirmations) or via LN invoices directly.

On Windows, you will likely get a Firewall prompt asking to allow Bitcoin’s LND to operate on the network (public/private). The LND that opens with the wallet corresponds to the coin pair selected on the DEX tab. During the DEX’s testnet phase, there were multiple LN-based coin pairs featured, including Litecoin. For the recent launch (9/23), however, it was decided to feature BTC as the sole LN coin pair. A certain feature of the MCLW, dubbed “L2 Active Enhancement”, ensures that different LNDs for different coins stay active and syncing even if they have not been actively selected in the DEX. This eliminates any wait times on otherwise inactive coin pairs needing to sync to the present and catch up. In other words, once LTC returns as a featured coin pair, and BTC/AETH is selected as the active coin pair in the DEX, the wallet will open the LND for BTC and LTC simulatenously. If the active coin pair in the DEX is switched to BTC/LTC, there is virtually no wait time. In the past, the DEX used to open and close different LNDs on demand. L2 Active Enhancement made this process much more convenient to the end-user.

For EVM-based blockchains, Vector is the DEX’s platform of choice. It is an efficient state channel management system that is directly compatible with Ethereum, ERC20s, their respective Arbitrum equivalents, and native Arbitrum tokens (i.e. HDN, Hydranet’s token). In the future, it could be extended to networks like BSC, Polygon, and Harmony with relative ease. For each specific wallet, a state channel must be opened one time per network (i.e. Ethereum mainnet vs Arbitrum One) for a small fee. From that point, the state channel is permanent and funds can be moved in and out of it as needed. For effective state channel management, the MCLW features a reconciliation button that immediately recalls the state channels when a new session is started (i.e. after the wallet has been closed for a few days) and syncs them to their current status. The Hydranet developers built upon Vector extensively, and they are the only ones to successfully utilize it in a major product.

Getting setup to trade on Hydranet DEX is a little different, but straightforward. For ease of use and convenience, it features a “simple swap” utility that can automatically turn an on-chain deposit of one coin into an off-chain balance in another. For cross-platform interoperability, the only inconvenient catch at the moment is that, for BTC to be swapped into an EVM chain like (i.e. ETH or AUSDT), a state channel must be opened first in order for LND and the Hydranet DEX Hub to interact with it. Once this state channel is opened one time, liquidity for it can be “rented” with LN BTC.

You can set everything about your LN and State Channels manually and make small tweaks to your benefit. To illustrate how the manual setup works, we’ll use an on-chain Bitcoin deposit as an example. Assuming the L1 deposit has been confirmed and the funds are available to use, a slider function in the wallet tab gives you the option to transfer either partial or entire amounts of a BTC balance to a LN BTC payment channel. Low, medium, and high priority options are available to either reduce fees or expedite the tx time. At this current moment in time, the BTC network is quite congested, so paying a higher fee in sat/vByte will guarantee a much shorter wait-time for moving funds from L1 to L2. For BTC to be readily spendable from a LN channel, 6 on-chain confirmations are required. In the event of there being a dissatisfaction with on-chain wait times, a “fee bump” feature has been recently added to the MCLW. Assuming there is additional BTC on L1, it will take a bit more of it and bump the fee beyond the dynamic average of the moment, guaranteeing a much faster route to 6/6 confirmations.

Once your funds are in a LN channel, you are given the option to rent a 2nd channel for the coin you want to swap into. When the rental channel has been confirmed, the status of the DEX will go from “Inactive” to “Online”. You can then buy or sell into orders posted to the DEX orderbook, and the BTC in your payment channel will swap into your rental channel. If Bitcoin is sent to the DEX via a Lightning invoice, the manual process is significantly faster as the initial deposit and transfer confirmation wait times are bypassed. In any event, there are multiple ways of getting to L3 interoperability and even the most laborious methods have been reduced to a few clicks, automation, and a slightly longer wait for the same results.

Buys and sells can be placed on the Hydranet DEX orderbooks manually if direct P2P trades are preferred. Alternatively, the orderbook is given deeper liquidity by “Vortex”, a built-in feature that utilizes arbitrage trading and aggregates orders placed on CEXs.

The current swap success rate between all existing coin pairs stands at 99.7%. Since the DEX is entirely non-custodial, and each individual swap is contingent on all terms of the contract being fulfilled, the worst-case scenario is one where a swap might fail and the funds locked into the A/B contract will be returned to their origin wallets. In the event of a swap failure, there is a “fee refund” feature.

What is its background?

Hydranet DEX has a lengthy, storied background. It was the result of what can only be called a “hostile community takeover” from its previous dev team and project management during the first half of 2022, which itself was the result of the previous team “launching” the DEX in a broken and dire state. This Medium article is a comprehensive retelling of the events leading up to the mutiny and how the community gained full access to the front and back-end source code before ejecting the old team from the project entirely. Hydranet’s founding team and leadership came entirely from the pre-existing community, with nearly all of its founding members being unanimously selected by the community itself.

The current team took over a DEX that, though in development since 2018, was very broken. They decided to switch 100% of the coin pairs entirely to a testnet environment. They, very quickly, improved a number of its features and components and got the DEX into a stable, working order. In 18 weeks, they accomplished more than the old team did in 18 months. Their first prototype build, dubbed “Lazarus” as a nod to its resurrection, debuted at the end of April 2022. It spent an additional 6-8 months in its 2nd phase of testnet, dubbed “Atlas”. In December of 2022, the team hit the 3rd and final phase of development dubbed “Phoenix”. This was when mainnet funds debuted. Over the past 8-10 months, extensive testing was done to guarantee a stable, fast swap environment. Several dozen builds were released, with some weeks seeing anywhere from 5-7 new updated builds.

After all of this, a tremendous amount of hard work and passion was put into making this project the next frontier of crypto trading – a DEX that is honorable to the trustless cypherpunk nature of BTC. The quest will not finish until the deed is done.

Hydranet DEX debuted worldwide on September 23, 2023. It is hosted on Storj, and can be downloaded from their website hydranet.ai for Windows and Linux. The only trading restriction in place currently is a $100 limit per swap. This is temporary and intended to rise into the future.

Linux users: Currently, Hydranet DEX is only available as an AppImage. However, there have been a number of individual requests for a Flatpak distribution. I’m fond of Linux myself and have personally tested on Debian Stable and Fedora.

MacOS users running on Apple Silicon: It may be some time until Hydranet DEX is available. It does not run well in a virtual machine, but there have been multiple attempts to do it anyway.

Who am I?

I am an old-timer from the Hydranet community. I’ve been testing the wallet since the 2019 alpha builds and got the privilege to watch this progress from its formative days. I’m also somewhat of an old-timer on r/cryptocurrency (much respect to the 2013-2016 veterans). In December 2021, I posted a thread on r/cc very similar to this one. Unfortunately, the old team’s DEX and its launch was so bad that I went completely quiet on this subreddit until just now. Fortunately, the community pushed through and ushered in a build that exceeds any and all expectations. I hope this post has been informative. If you may have any questions, I’ll do my best to answer.


No comments:

Post a Comment