Thursday, December 9, 2021

To celebrate the launch of Stakenet DEX (Win|Mac|Linux) and its off-chain BTC/ETH pair, here is a technical overview of the project written specifically for r/cryptocurrency.

What is Stakenet DEX?

Stakenet DEX utilizes multiple Layer 2 protocols - Lightning Network (LND) and Connext - to achieve cross-platform interoperability off-chain, at high frequency, and between otherwise incompatible chain pairs.

In more technical terms, Stakenet DEX is a qt5 GUI-based multicurrency light wallet that runs a state channel-based Connext node 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 but with the additional functionality of zk-rollups 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, on the other hand, make use of multiple coin-specific LN daemons (i.e. BTC LND and LTC LND) that run simultaneously and the instant, low fee nature of payment channels to foster an automated ecosystem of channel “rentals” that ultimately allow 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 kinds of coins 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 directly from high-speed LN-based payment channels or vice-versa.

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

How does it all work?

Stakenet DEX’s multicurrency wallet 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 takes approximately 20 minutes for Bitcoin to sync fully. It functions like an ordinary multicurrency wallet capable of sending and receiving funds on-chain.

On Windows, you will likely get a Firewall prompt asking to allow different variants of the Lightning Network Daemon to operate on the network (public/private). The LNDs that open with the wallet correspond to the coin pair selected on the DEX tab. If BTC/LTC is selected, the wallet will open with BTC LND and LTC LND. If the pair is switched to BTC/ETH, the LTC LND will close. If it is switched again to BTC/XSN (Stakenet’s native coin), the XSN LND will open. The LN daemons are light clients as well.

LND is a mature, robust, open-source implementation of Lightning Network. Stock, unmodified variants of the LND protocol are the implementation of choice for Stakenet DEX. Funds can be transferred in and out of the wallet the traditional way (deposits pending x confirmations) or via LN invoices directly.

Getting setup to trade on Stakenet 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. Alternatively, you can set everything up manually and make small tweaks to your benefit. To illustrate how the manual setup works, let’s use an on-chain Bitcoin deposit as an example. Assuming the deposit has been confirmed and the funds are available to use, there is a slider function in the wallet tab that gives you the option to transfer either partial amounts or the entire balance to a LN BTC payment channel. Low, medium, and high priority options are available to either reduce fees or expedite the tx time. 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 “Offline” to “Online”. You can then buy or sell into orders posted to the book, and the BTC in your payment channel will swap into an LTC or XSN balance in 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 Stakenet 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.

What is its background?

Stakenet DEX was created by the X9 Developers. It has been in development since 2018. They achieved their first Lightning swaps between XSN and LTC in October 2018. The DEX entered Alpha towards the end of 2019, gradually implemented a slew of automated utilities including channel rentals that allow for swaps from one coin deposits, and went into Open Beta in August 2020 with LN-based coin pairs only. Since then, an additional slew of automated features including the simple swap feature and ETH interoperability have been implemented. After much stress-testing, the team announced a release for December 10, 2021. This release is considered a very late stage beta.

What is its future?

The future of upgrades to Stakenet and Stakenet DEX is a topic that would take its own extensive thread to cover in detail. Put briefly, XSN (Stakenet’s native coin launched in 2018) is a hybrid staking/masternode coin based on BTC, PeerCoin, and DASH that utilizes the X11 hashing algo. It features a vastly decentralized network with an average 2500 masternodes. A chain upgrade, dubbed “Hydra” is in development to turn XSN into an EVM-compatible token secured by ETH. The upgrade is meant to make much more effective use of smart contracts, with tokenomics to attract liquidity providers and orderbook hosting done directly by the masternode network to make it redundant and immutable.

Layer 3 interoperability is a game-changer. It allows two remote parties to exchange completely different assets in a decentralized manner free of third party custodians and middlemen. It bridges the two largest cryptocurrencies (by far) together in a secure, decentralized manner. It is insanely fast and inexpensive, allowing for CEX-like high-frequency trading. Lastly, it extends some very useful attributes of EVM-based chains like DeFi and smart contracts to UTXO-based coins like BTC and LTC. DeFi for Bitcoin is but a frontier at this moment in time but it’s something that could turn into a multi-trillion dollar market.

Why have I never heard of Stakenet?

Stakenet launched right at the start of the 2018 bear market when money and focus on crypto was quickly fleeting, especially for altcoins. The Stakenet team allotted almost the entirety of the funds available to them for development, and spent the entirety of the bear market developing their L3 DEX in a rather isolated manner with very little paid marketing.

Who am I?

I’ve been testing the wallet since the 2019 alpha builds and got the privilege to watch this progress from its formative days. I hope this thread has been informative. If you may have any questions, I’ll do my best to answer.


No comments:

Post a Comment