WTF is THORChain
Let’s start with an example of what THORChain actually does low-level, then we will look at some pretty interfaces that make it easier and discuss the magic. This is how wallets and web interfaces interact with THORChain.
Say I want to swap some BNB for BTC. I visit this site:
I find the section for BNB and copy the
address. This is the current BNB “vault address” THORChain is managing. If you look it up it’s got shitloads of funds in it.
I fire up my iPhone Trust Wallet, choose BNB and ‘Send’. I paste in the THORChain inbound vault address from above.
I attach a special memo
SWAP:BTC.BTC:<my bitcoin address>.
I hold my breath, press Send and wait …
My BNB has vanished. Nothing has happened (that I can see…yet).
Then I remember that THORChain is a native Layer 1 (“L1”) platform — these are actual on-chain native trades, not some database record in a centralised platform. My outbound transaction is in the Bitcoin mempool waiting to be mined:
Mind blown. Native L1 Bitcoin, straight to my wallet. No KYC. No 2FA logins. Not even any email required to doxx my address. No state controlled/regulated centralised exchange. No risk of some centralised exchange founders stealing all my funds whilst on-exchange. No transferring onto and off a centralised exchange (with associated fees). No photocopying drivers license and uploading to who-knows-where ready to be stolen along with my identity.
Here is the transaction if you’re interested.
Let’s just consider this for a moment: I just sent some BNB to an address with a short message of what to do, and native L1 funds appeared in my Bitcoin wallet. 🤯
To date (14th June 2021), THORChain has processed 325,449 swaps worth $1.7bn. And it’s still in beta (“chaosnet”). It is advised not to use large funds. For goodness sake don’t 🦍 in your life savings. Yes this still happens 🤦♂️
Around July/August 2021, when feature complete and declared stable, it will be re-branded “mainnet” and some artificial safety limit caps will be lifted. But it will inherently be the same system as now.
Check out the size of the pools managed by THORChain below. When you swap, you send funds into one of these pools, and the system sends funds out from another. For small swaps like I did above, the fee is dominated by the L1 outbound transaction fee. This varies by chain and today BTC was a very low $3.50 so THORChain will set aside $10.50 (3x outbound) from your outbound amount. For large swaps, the variable slip fee starts to dominate, but it depends on the size of the swap relative to the pool size. For example a 5.0 BTC swap ($200k) may incur 1% slip with today’s pool sizes, where as my swap above was 0.0005%. THORChain works best for swaps in the range $20 to $200,000 (depending on chain & pool). And of course the user pays the inbound fee themselves to send the asset (for BNB this was about $0.02).
How you do these in real life
We’re not all computer hackers crafting our own transaction memo’s, so there are interfaces that take away the hard work. A popular website is THORSwap (https://thorswap.finance). I also love the ASGARDEX desktop wallet:
As you can see, this interface shows much more detailed fee estimates and does the transaction + memo transaction broadcast for you. Nice.
THORChain is so easy to use for existing wallet providers that you may see it silently replace existing centralised swap mechanisms without you even realising it.
For example ShapeShift (https://shapeshift.com) uses THORChain under the hood — quite passionately supported by Erik Voorhees in his Medium article here: https://erikvoorhees.medium.com/an-introduction-to-thorchain-for-bitcoiners-3f621bf0028e
It gets better
The observant amongst you will wonder where do these big vaults full of $20m in Bitcoin and Ethereum come from. The answer is, YOU! (well, other people like you. But maybe you in the future after reading this).
You see, normally most traditional exchanges are just places where buyers and sellers meet. Where two people agree, a trade is executed. Millions of these trades happen every second on equity, bond and crypto markets.
THORChain instead works via “Continuous Liquidity Pools”. As briefly mentioned before, instead of joining a buyer and seller, you transact with giant asset pools (vaults). You add a little to one pool, and take a little from another. There is always a buyer/seller (the pool!). And the system encourages people to add money into these pools to earn rewards.
People who want to earn an annual percentage yield (often called “APY”) on their otherwise dormant assets such as Bitcoin Cash, Litecoin, USDT, Bitcoin, ETH etc., can send it to a THORChain managed vault to sit and earn fees by “providing liquidity” (often called “LP”). Every time a swap happens, some of the fees go to these liquidity providers. You just send crypto to one of the vaults with a slightly different memo (e.g.
ADD:BTC.BTC) and it will sit there and slowly credit you (the sender) with a percentage ownership of the pool. When you want your asset back under your control, send the current vault a transaction with memo
WITHDRAW:BTC.BTC:10000 (10000 means 100%) and it will send it back with your rewards, minus outbound transaction fee.
When you send your assets into pools to earn yield, you are now in the world of Decentralised Finance (DeFi). This may look complex at first but the important metric is earnings compared to if you just held (LP vs HODL). As you can see, this has earned 0.85% in 2 months, equivalent to 4.95% APY.
One way you can easily add liquidity with a beautiful interface is via ASGARDEX:
THORChain doesn’t know about pricing of its assets. They are just assets in different ratio’s of pools. When pools get out of balance with external asset prices (for example the price of ETH, Bitcoin and RUNE vary on 3rd party exchanges every second), sophisticated traders arbitrage these small differences with bots and perform dozens of small transactions to re-balance pools and make a little money for themselves. This adds to transaction fees earned by the Liquidity Providers (you!).
What’s the catch?
Probably the biggest risk with DeFi is the protocol being hacked and pool funds stolen. If you visit https://www.rekt.news you will see many examples of sophisticated hacks against the protocol or finance model to artificially manipulate pool sizes and steal funds on single-chain DeFi platforms. Many of these don’t apply to THORChain however with the code size being many hundreds of thousands of lines, the attack surface is moderate and some loss-of-fund bugs could appear in the future. The advantage of THORChain is it is isolated and built upon Cosmos tendermint engine which is a very stable and popular platform, and many transactions require small fees to prevent most attacks.
If you are concerned about this, one mitigation is don’t 🦍 in your life savings providing liquidity, especially during Chaosnet. You can also look at decentralised insurance offerings such as https://app.nexusmutual.io/cover which insure you against protocol hacks for a small fee.
Another risk is Impermanent Loss (“IL”) which where you LP in two assets, which gives you a percentage ownership over the pool (say, 1%). Then over the following weeks, the pool sizes change ratio and when you withdraw, your 1% ownership is converted to a different ratio of assets than you initially put in. And in some circumstances you can end up with less assets than if you had just HODL’d. To protect against this, THORChain has IL Protection where if you LP for 100 days, the system reserve will top-up your withdrawal to make sure you are never worse off. This completely eliminates IL risk for most liquidity providers.
Lastly the current yields are artificially quite high due to LP caps during beta. This means more rewards flow into Liquidity Providers and also means the swap rewards are distributed to a smaller number of LP’s. So the current 20–50% APY on major assets will likely decrease to a respectable 5–15% once the pool sizes grow ridiculously large. Or they could stay high if the platform is used a lot.
So what is RUNE (ᚱ) ???
Did you notice we got this far without mentioning RUNE? This is deliberate: a lot of Bitcoin maximalists shit on any project that has its own token. So why is there a native token?
Answer: RUNE is used to secure the network and provide a common base pair for each asset pool. Plus a bunch of other stuff like fees & incentives.
Let’s pull this thread a little to explain these concepts.
Let’s start with securing the network, which needs a quick explainer of who is running the network.
Validators/nodes == the network operators
Let’s fire up https://thorchain.network and take a look:
These are the validators that run the THORChain code that make up the network. The ones marked ACTIVE are “churned in”. They all post a Bond (currently around ᚱ 550,000 each ~ $5–10m) to ensure they are honest. Each node runs a cluster of software including every supported chain.
Every 3 days, 2 nodes are churned out (oldest and “worst performing”) and the 3–4 highest STANDBY bond nodes are churned in, up to 100 nodes for now. This could be increased in the future. They together create new vault addresses and transfer ALL of the assets from the old vaults to the new vaults. This constantly proves the network is healthy and owns all funds (as opposed to a centralised exchange: do they even have enough to cover your withdrawal? Have they lost their private keys in a boating accident?)
The THORChain modules above constantly observe every transaction on every chain looking for THORChain related transactions (like my swap!) and read transaction memo’s. Incorrect memo transactions are returned to sender minus a fee.
The node then communicates with all of the other nodes and agrees upon what is the truth (by majority consensus) and they collectively assign individual nodes to perform small tasks. Since they are all running the same software, they will all agree on the same logic and come to consensus. Rogue nodes will be ignored, temporarily “jailed” by consensus and eventually churned out.
The magic is that transactions can only be signed by 2/3 of nodes, without any individual node knowing the private key(s). This was made possibly only recently by a pivotal cryptography paper on Threshold Signature Schemes (“TSS”):
This gets to the sole purpose of RUNE : to secure the network. The validators all bond collectively say 10M RUNE. The system will then only allow at most 10M RUNE worth of pools (ideally 5M). The ideal ratio is 2:1 bonded:pooled. If the ratio is incorrect, the fee rewards flow more to the side that doesn’t have enough RUNE. For example right now there is too much bonded, meaning the network is too secure.
For a truly decentralised system you need to assume some or even all validators/nodes can be dishonest, but incentive them not to be. If 2/3 of validators get together and decide to steal all of the funds by generating a threshold signature, then the entire THORChain network will be useless and the value of their RUNE instantly drops to $0 (and/or halted) on all markets. They have just lost more value in RUNE than they stole in assets. They won’t do this.
Now imagine if RUNE didn’t exist and the network was secured by validators bonding 100 Bitcoin. If 2/3 of nodes decided to conspire and modify their software to steal funds, they would pillage the pools AND keep their Bitcoin bond which doesn’t drop in value. The security of the network needs to be done with an asset that is tied to the value of the network. Hence RUNE.
The other thing to be aware of is an attack to shut down THORChain would require 1/3 + 1 evil nodes to be simultaneously churned-in all at once, then disable their software to cause threshold signature failure. This would cost around $50m at todays prices: possibly 2–3x if they tried to buy up a large amount of circulating supply of RUNE which would push prices up significantly. Say $100m+ to shut down THORChain. Probably not realistic. Of course there are non-economic incentives to stealing/shutting down, such as market competition or nation state attacks. A nation-state would probably not be incentivised to spend this much shutting down THORChain because all of the transactions on-chain are publicly viewable so it doesn’t provide any form of anonymity over a regular old BTC to BTC transaction. A market competitor would be highly unlikely to spend similar amounts ($100m+ currently and possibly higher in the future) to shut down THORChain.
The bigger THORChain gets, the safer it becomes.
A small detour about Yggdrasil
Threshold signatures are quite computationally expensive (tens of seconds CPU each on the fastest CPU), so this doesn’t scale well. They also get quadratically more expensive as you add validators, so at 40 validators, the network actually shards into two groups of 20. Another clever trick is used by assigning each node a small independent vault (“yggdrasil”) they completely own (a human node operator can actually see this private key and steal these funds, but will incur a 1.5x fine straight from their bond for illegal transactions. Also the amount given is small: just a small fraction of their bond).
The THORChain nodes will sign TSS transactions to fill these small wallets with sufficient funds (and top them up regularly), and for the tens of thousands of small swaps that occur daily, the nodes will collectively choose an individual node to perform an individual swap transaction. This ensures that the “heavy lifting” transactions are done by expensive TSS compute, and the lite transactions are done with small vaults by individual nodes, with a good risk:reward profile.
Who chooses the pools? That sounds centralised to me…
The initial chains supported are BTC, BNB, ETH, LTC, BCH. All of those native assets plus some tokens like USDT were initially supported in pools and natively grown from tiny seed funding by LP’s.
What happens next is there’s a list of Standby pools, with a requirement that it needs 10k RUNE worth of assets (it needs to be liquid…). Anybody can make a standby pool with any asset (read: token) on a supported chain. Every churn, the best one is picked! Fuck yeah — decentralised. Vote with your wallet. Anything that drops below 10k RUNE is evicted. This avoids shitcoins and fakecoins trying to steal RUNE from the network.
New chains like Dogecoin or Binance Smart Chain need to be supported by node operators (validators) all collectively agreeing to run new full-node chain client software nodes, then updating the THORChain software to support the new chain. Discussion on this is in the public THORChain Comunity Dev Discord server. The next chain addition is likely 1–2 months away.
The best thing about this model is ANY asset can be listed. For example Celsius (ERC20
CEL) which is a pretty awesome token #43 by market cap currently is unavailable on Binance because CZ sees it as a threat. No problems — if you are a CEL 🐋 just add a THORChain standby pool and have it listed on THORChain. If you have the deepest pool in Standby (above 10k RUNE), it’s getting listed in 1–3 days. Bam — instant access to all the BTC whales using THORChain to trade CEL. I hope you’re starting to realise how much centralised exchanges suck. When they work yeah they’re fine, but when they don’t work, they are really lame.
Of course Uniswap v3 may be a great place for you to swap your ETH assets but THORChain offers a way to do it cross-chain.
THORChain is the only cross chain decentralised exchange.
It’s probably important to realise that THORChain is more of a “short tail” (maybe in the future “medium tail”) market — deep asset pools for major asset classes like Bitcoin, Ethereum, Binance, Litecoin and Bitcoin Cash (and associated major tokens). It doesn’t aim to be pancakeswap where you trade your latest Reddit pirate/dog/cum themed coins. Well maybe they could appear on THORChain if somebody adds them, but probably not!
You said something about pools and RUNE? Huh?
Yep that’s right — each pool is actually an ASSET:RUNE pair. For example:
You get the point; you’re not stupid. Also congrats for reading this far. Mad respect.
A swap from BNB to BTC in my example was actually two swaps:
- BNB to RUNE
- RUNE to BTC
This happens under the hood. You can also do a single swap to/from RUNE if you’d like.
This means that all swaps can be done via RUNE which adds commonality. No more trying to trade from Asset A to asset B via ETH or BTC. The system is agnostic to what is the “best” asset. They are all just assets traded in different ratio’s to match external market conditions. No price “oracle” is needed. When the interfaces show the price of assets in $USD, they just assume one of the USD Stablecoin pools is $1 USD, then show every other asset as a ratio of that.
It is important to understand ratio’s because if you decide to LP, you are actually participating in an ASSET:RUNE pool. And you can either stake asymmetrically (just deposit either RUNE or Asset), or symmetrically (stake 50:50 of both in the same ratio as the pool).
You actually want to LP in/out symmetrically using both RUNE & Asset because if you add the correct ratio of RUNE to Asset, then there is less slippage (fees). You can of course LP with just Asset (for example LP 1.0 BTC direct) but there will be a slightly higher fee because you’ve just unbalanced the pool and somebody else needs to come along and provide the RUNE side in another transaction to balance it. (Side note: there is some development discussion in public chats about switching to a “queued liquidity” model for better asymmetric LP experience).
😅 nearly finished
I agree — what a journey. And we haven’t even touched on Synths, fixed interest savings and lending. These are not yet shipped so we shall update when they arrive.
So that’s it — THORChain is currently the only decentralised exchange made up of liquidity pools filled by LP’ers such as yourself earning yield on your otherwise parked assets, protected by Impermanent Loss, used by swappers to do native cross-chain L1 transactions between different short-tail asset classes, and secured & run by node operators (validators) bonding extraordinary amounts of RUNE to run the network and also receive rewards.
And it’s working now, doing literally $billions in transactions, growing rapidly, is about 4–8 weeks away from “mainnet” and more features shipping soon. To say I’m bullish is an understatement.
One last thing ;)
Did I mention the RUNE price is deterministic?! The floor of the price is 3x the total value of all non-RUNE assets in pools (currently $72M, with 250M RUNE circulating implies $0.87 price floor. Current price is $8 which means there is a 9x speculative multiplier — token holders are assuming at least 9x pool size growth in the coming months, and/or that’s just the fair market price for the current LP/Bond yields on offer).
Uniswap has $1.7bn in ETH assets. There is $7.4bn wrapped bitcoin. BlockFi has $15bn assets yielding 0.5–2.0%. Celsius, Binance, Crypto.com — all centralised custodial platforms offering Bitcoin yield with billions and billions in FUM. There are no decentralised BTC DeFi options…until now.
THORChain is open source and can be forked but unlike a 300 line ETH smart-contract, is very complex and would realistically require 6–18 months for engineers to understand the project, safely fork and slowly grow the pools, ecosystem and validators — not to mention repurpose existing tokens to serve as a security token. It’s fine and do-able, but not as simple as “steal the code and do better marketing” like non-tech people often assume. But when it does happen, which is absolutely fine & inevitable, the one trillion dollar Bitcoin pie is so big, all ships will rise on the incoming tide and hopefully we have a handful of great decentralised trading systems fulfilling different niches.
And did you notice the THORChain BTC pool is currently only $20m? Do the math.