Mjölnir : telegram bot for accessing liquidity provided by THORChain protocol

Hoodieonwho
3 min readNov 22, 2020

Mjölnir is the hammer of Thor, the Norse god associated with thunder.

The idea of the Mjölnir Telegram bot comes from the vision of interacting with THORChain liquidity protocol from a fundamental and direct level while making the transaction convenient and seamless. Just like the hammer itself, Mjölnir Telegram bot serves as a tool to help people access the liquidity but not removing the process of using the “weapon”.

Accessing THORChain liquidity using only telegram and TrustWallet

Mjölnir: telegram bot for accessing liquidity provided by THORChain protocol

In this playlist, you can find examples of using the bot to carry out transactions (Swap, Stake asymmetrically, Withdraw, Add) simply using the telegram bot and TrustWallet, this is made possible by THORChain’s mechanism of only observing memo of transactions and TrustWallet’s deep link capability. I hope this tool can get some adoption before TrustWallet itself integrates THORChain.

When conducting swaps, all fees are taken into account, and if splitting transaction can increase output amount, user will also be notified.

Technology and Byzantine process of picking Thornode

This bot uses a self-made thorchain-python-sdk module to pull data from THORNode and Midgard and make sure they are legit. Steps are followings:

1. get 3 node from seed with same pool_addresses

2. get active nodes from previously proofed 3 node

3. parse pool_address proofed by ⌈1/2⌉ nodes obtained from 2

4. parse pool_depth proofed by 3 nodes (comparing asset_depth for all pools pulled from nodes) obtained from 2

The pool address is cached every 3 minutes, and pool depth is cached every 3 seconds to provide more accurate data and a slight edge over using Midgard. Above caching time is deemed appropriate for now, but subject to change in the future.

A profile system is also introduced in the bot so that the user can bind their address and check staked asset. Users can also set strategy for a swap routine, so they don’t have to go through the same steps.

Current limitation and future Plan

Limitation:

  1. It’s not possible to stake symmetrically because trust wallet doesn’t offer multi-asset transfer.
  2. It’s not possible to set multiple strategies in the profile.
  3. User must input the correct bnb address otherwise they won’t be able to access the profile section unless I delete their information for the database.
  4. It’s not possible to delete trust wallet link because keep track of each individual message is too much to handle currently, instead 3 minutes warning is accompanied by each link. Given that after clicking the link, user still needs to do two more steps to send away their asset, I consider this secure enough.

Future plan:

  1. User can set limit-order alert such that a notification and trust wallet link will be sent when pool_depth can provide user with desired output quantity.
  2. Double-swap and cross-chain compatibility. (Memo field can’t be set with trust wallet for BTC transaction, user would only be able to send BNB asset and receive bitcoin)
  3. Market price comparison with CEX(FTX, Binance) so user know they are getting the best deal on THORChain

Contact:

telegram: @hoodieonwho

twitter: @hoodieonwho

--

--