Learn how Thorchain works in one article?

How is it possible to exchange BTC for ETH directly on the chain?

What is Thorchain and how does it enable the exchange of raw assets on different blockchains? This article will answer these questions.

DEX trading volumes, already in the billions of dollars, are gaining more and more traction, with daily volumes of over $1 billion on Uniswap already common.

While asset transactions like those within the ethereum ecosystem (protocols like Uniswap, Sushiswap or Curve) are already doing very well, they do not support exchanges between different blockchains.

To solve this problem, a common approach is to introduce external assets in the form of encapsulated (wrapped) or synthetic tokens on Ether. The most popular blockchain asset outside of ethereum is of course bitcoin. There are multiple ways to represent Bitcoin on Ether that allow it to be traded on DEX, such as renBTC, sBTC, etc.

While these methods work well, they usually do make certain trade-offs when it comes to the custody or security of the asset.

Is there a way to enable direct exchange of native assets? For example, a direct transaction between BTC from the Bitcoin blockchain and ETH from the Ether blockchain. This is where Thorchain comes into play.

Learn how Thorchain works in one article?

Thorchain is a decentralized liquidity protocol that allows the exchange of native assets between different blockchains (e.g. Bitcoin, Ether or BSC).

For managing liquidity, Thorchain uses the liquidity pool model of protocols such as Uniswap or Bancor.

In this model, the liquidity provider locks 2 assets in a liquidity pool and provides liquidity to traders of these 2 assets. Traders pay a small fee to the liquidity provider.

Thorchain is often interpreted as a cross-chain Uniswap. this analogy makes it easy to understand what Thorchain does, but there is actually a big difference between the two, as explained below.

Before we dive into the mechanics of Thorchain, let’s take a look at how the project came to be.

History of Thorchain
Thorchain was a small project at the 2018 Binance hackathon.

After the hackathon, the team behind Thorchain continued their research but decided to pause some of the work at hand as they waited for the technologies needed to create a cross-chain DEX, which were missing at the time, mainly the Tendermint & Cosmos SDK and the TSS- -threshold signature scheme.

When seeing the feasibility of the product, the team decided to raise a small amount of seed money and built a proof of concept for a DEX based on the Thorchain protocol called Instaswap, which was later demonstrated at the Cosmos hackathon in Berlin.

They then announced its first product to market, BEPSwap, in July 2019. the main goal of BEPSwap is to enable BEP2 asset swaps, limited to on Binance Chain.

Learn how Thorchain works in one article?

Also in July 2019, the team decided to raise more funds through an IDO (initial decentralized exchange offering) on Binance Dex. the IDO resulted in raising $1.5 million, enough to grow the project further.

The team continued their work on the protocol with the release of a restricted master network in April 2021 called the multi-chain chaos network (MCCN for short).

Interestingly, the Thorchain team was mostly anonymous, and remains so today.

Now, let’s see how Thorchain works under the hood (hood).

How it works
At the heart of the Thorchain protocol is this: a network of nodes built with Tendermint and Cosmos SDK.

This approach allows Thorchain to create an independent blockchain with its own consensus and network layers without having to build all the elements from scratch.

Thorchain utilizes the Tendermint BFT model to allow the network to reach consensus even if up to 1/3 of the nodes fail.

The consensus mechanism is important because Thorchain’s nodes must work together, such as recording transactions from other blockchains.

Let’s see how this works in practice with a quick example.

Suppose a user wants to exchange their BTC on the Bitcoin network for ETH on the Ether network.

The user sends a standard bitcoin transaction to the bitcoin vault – a bitcoin address that is controlled by the Thorchain network.

Thorchain nodes constantly monitor the vault address to confirm new transactions.

To do this, each Thorchain node (also known as a THORNode) consists of several major components, the most important of which are: the service that runs the Thorchain blockchain itself; each full node that connects to the blockchain, such as a Bitcoin or Ether node; and Bifrost.

Learn how Thorchain works in one article?

The Bifrost protocol acts as a connectivity layer between the Thorchain network and other networks, such as Bitcoin or Ether. One of its main responsibilities is to look at vault addresses in order to find inbound transactions, which are then converted into witness transactions for THORChain.

Witness transactions are initially recorded as “pending” – a state in the Thorchain state machine. After a majority of nodes agree on the status of the inbound transaction, the transaction is moved to the “finalized” state.

At this point, the user’s bitcoin deposit is recorded on the Thorchain blockchain.

It is time for the other part of the exchange to take place, sending the Ether back to the user.

Once a new inbound transaction has been identified, the Thorchain protocol initiates a swap. swap transactions are recorded on the Thorchain blockchain and the Bifrost protocol is used again, this time to withdraw ETH from the Ether outbound vault.

Using the appropriate chain client (in this case the Ether client), this outbound transaction is converted from within Thorchain into a valid transaction for the target chain and broadcast to the appropriate network.

At this point, the exchange is complete and the user ends up with Ether in their Ether wallet.

While this sounds simple enough, there are quite a few details that go into making this possible.

In order to sign transactions, the network must be able to control the vault address on each integrated blockchain.

Of course, storing private keys on each node has huge security risks, which is why Thorchain uses the aforementioned threshold signature scheme or TSS.

Learn how Thorchain works in one article?

TSS is a cryptographic primitive for distributed key generation and signing. You can think of it as a better version of multi-signature (multisig). Both are focused on achieving the same goal – allowing multiple parties to come together and sign transactions only when some previously set threshold is reached. The main difference is that multisig is usually implemented on the application layer of the blockchain, for example, as a smart contract on Ether, whereas what TSS supports is independent of the blockchain, as it relies on basic cryptographic elements.

This makes the whole process of signing transactions cheaper and more secure.

While TSS has many benefits, it is not yet as battle-tested as other popular cryptographic elements, such as ECDSA or certain hash functions.

Vault (Vault)
Another interesting detail of the Thorchain architecture is the way Vault works.

There are two types of vault – “in vault” and “out vault”.

Learn how Thorchain works in one article?

Inbound vaults store most of the funds in the system. They are slower, which can take up to 20 seconds, but are more secure because they require 2/3 of all TSS signers to sign a transaction.

This imposes a significant limitation on the overall system, so Thorchain introduced smaller, less secure outbound vaults run by each THORNode. These vaults are faster because they require only one signature on the node they are running on. The funds in these vaults are limited to 25% of the bond value of their assets. There is more on the bonding process later, which creates incentives to prevent node operators from stealing funds from outbound vaults. These vaults are also constantly recharged by the system as funds are used for outgoing transactions.

PoS & Churning
As mentioned earlier, Thorchain uses the Tendermint and Cosmos SDKs. in this model, the Thorchain network operates as a Proof-Of-Stake (PoS) system, where nodes that sign and verify transactions must pledge a certain number of RUNE tokens.

In the Thorchain ecosystem, the process of pledging RUNE tokens is also known as bonding.

On May 17, 2021, 1,000,000 (worth approximately $18 million) RUNE tokens are required to run a fully functional Thorchain node.

In contrast to most variations of PoS systems, commissioning of tokens is not allowed here. This is because it is important to ensure that all nodes in the network are treated equally and not allow a particular node operator to capture the majority of the tokens for a long period of time.

In fact, all nodes in the Thorchain network are anonymous and can only be identified by their IP addresses and public keys. They cannot brand or market the nodes like other systems that allow delegation.

To avoid always having the same nodes with the highest number of RUNE tokens signing transactions, Thorchain introduces the concept of churning.

Learn how Thorchain works in one article?

The network maintains a set of nodes that are active and capable of signing transactions and another set of nodes that are on standby.

Every 50,000 blocks, or every 3 days or so, the churning process is initiated and the oldest or least reliable nodes in the active zone are replaced by nodes in the standby zone.

The churning process ensures that new nodes that meet the pledge criteria can take turns signing transactions. In addition, each time the verifier set changes, the Thorchain network transfers the funds to a new vault, ensuring that active nodes still have access to funds.

Currently, there are 28 active nodes and 45 nodes on standby on the single-chain chaos network supporting BEPSwap, and 11 active nodes and 9 nodes on standby on the recently released multi-chain chaos network.

Currently, the multichain chaos network is in expansion mode, which means that for every node squeezed out of the network, 2 nodes will enter.

The multi-chain network can grow to 99 nodes before it encounters the Tendermint and TSS limits.

Even if the network grows to 99 active nodes, it can still scale further by having the ability to slice vaults.

It is also important to note that even though running a fully functional node requires a large number of RUNEs, one can still run nodes without bound RUNEs. These nodes are able to verify transactions without the ability to sign transactions.

RUNE tokens
The final key element of the Thorchain architecture – the RUNE token.

RUNE powers the Thorchain ecosystem and provides the financial incentive needed to protect the network.

Learn how Thorchain works in one article?

All liquidity pools in the system are composed of native tokens and RUNEs. For example, to swap from Bitcoin to Ether, the transaction must pass through the BTC-RUNE and ETH-RUNE pools. In this model, each asset must be paired with a RUNE. Here, the number of pools will be less than a system like Uniswap where pools can be created with any two assets.

In addition to this, Thorchain nodes must meet the pledge criteria by tying a specific number of RUNEs. This margin secures the system by underwriting the assets in the asset pool. If a node attempts to steal funds from the protocol, its bond will be deducted by the amount of assets it has stolen (1.5 times), thus making the asset pool complete. In addition, if nodes do not provide a reliable service, they risk having their bonds cut.

The Thorchain protocol also encourages node operators to maintain an optimal number of RUNEs at all times. This is achieved through a mechanism called “incentive pendulum”.

Learn how Thorchain works in one article?

The purpose of the incentive pendulum is to keep the system in the optimal state where 67% of all RUNEs in the system are bound and 33% are pooled into the pool.

If there is too much capital in the liquidity pool, the network increases the reward to the node operators and decreases the reward to the liquidity providers. If the nodes have too much capital tied up, the system increases the rewards to the liquidity providers and decreases the rewards to the node operators.

In an optimal state, for every $1 million of assets in the pool, the node will bind $2 million worth of RUNE.

In addition to this, RUNE is used to pay for transactions on the network, subsidize the gas needed to send outbound transactions to different networks; and can be used to participate in Thorchain governance, where users can signal which chains and assets should be added to the network next.

As shown above, there are significant differences between Thorchain and Uniswap or other DEXs on Ether.

First, Uniswap only allows the exchange of ERC-20 tokens, so if we want to trade assets from other blockchains, they have to be in the form of encapsulated or synthetic tokens. thorchain allows the exchange of local assets without the need to encapsulate them.

Swaps on Thorchain are charged both a fixed network fee and a dynamic slippage-based fee. This means that transactions that generate more slippage are charged more transaction fees. This makes it harder for bots to extract value from swaps, such as in the case of sandwich attacks – a common way to affect prices in liquidity pools, resulting in users getting worse prices on their trades.

Learn how Thorchain works in one article?

Regarding the speed of swap, assets on Ether can swap within 1 Ether block, which happens on average every 13 seconds. On Thorchain, it’s a bit more complicated. Swap times depend on which network we are swapping between. If it’s Bitcoin to Ether, it takes at least 1 block on the Bitcoin network – 10 minutes on average, plus the internal time to perform the swap on the Thorchain blockchain, plus the outbound Ether transaction – about 13 seconds.

Interestingly, a swap from Ether to Bitcoin would be even faster because the Thorchain network would only have to wait for an Ether transaction before sending a Bitcoin transaction outbound, which would result in the receiving wallet being able to spend Bitcoin UTXO directly after the transaction is broadcast.

In addition, Thorchain, as a standalone blockchain, loses some of the benefits of an Ether DApp, one of which is composability. For example, Uniswap can be incorporated into more complex contracts as part of a transaction. This is not possible in Thorchain.

Of course, the Thorchain network is also not as decentralized as the Bitcoin or Ether networks; the system instead relies on strong economic incentives.

This is not necessarily a bad thing, considering that Thorchain has a completely different application scenario than the Bitcoin network, which secures assets worth over $1T, and the Ether network, which secures billions of dollars of assets locked in smart contracts.

For its primary use case, exchanging assets between different blockchains, most users will not store their assets on the Thorchain blockchain for a very long time.

Summing up
Following the long-awaited release of the multi-chain chaos network, the Thorchain team is focusing on growing the Thorchain ecosystem while ensuring the system works as expected.

Learn how Thorchain works in one article?

When it comes to interactions with the Thorchain protocol, users have a variety of options. They can use a decentralized exchange like Thorswap or Asgardex, or a wallet like ShapeShift that integrates with Thorchain.

We should see more DApps and wallets integrate with Thorchain in the future.

In addition, we are likely to see more chains and assets, more Thorchain nodes joining the network, and more and more transaction volume and total value locked into liquid pools.

Eventually, redundant protections will be removed and the chaotic network will become the main network.

Thorchain is clearly an interesting protocol and the missing piece of the defi ecosystem that allows people to trade local assets directly without using CEX.

Posted by:CoinYuppie,Reprinted with attribution to:https://coinyuppie.com/learn-how-thorchain-works-in-one-article/
Coinyuppie is an open information publishing platform, all information provided is not related to the views and positions of coinyuppie, and does not constitute any investment and financial advice. Users are expected to carefully screen and prevent risks.

Like (0)
Donate Buy me a coffee Buy me a coffee
Previous 2021-05-18 14:13
Next 2021-05-18 14:28

Related articles