How It Works

To understand how Rujira is the App Layer built on THORChain, please refer to the THORChain Docs, where the assets that tie the base layer (THORChain) together with the app layer (Rujira) is referred to as Secured Assets.

Secured Assets enable users to deposit Layer1 (L1) tokens (e.g., Bitcoin, Ethereum) into THORChain, minting corresponding tokens that can be used on Rujira and across the THORChain ecosystem. These assets offer fast, efficient trading and transfer options and are designed to integrate seamlessly with CosmWasm smart contracts and connect to other IBC-enabled chains.

Key Features of Secured Assets

  • Backed by L1 Deposits: Users deposit L1 tokens like BTC, which mints a corresponding Secured Asset (e.g., BTC-BTC). These tokens represent ownership of the underlying L1 asset pool.

  • Fungible and Transferrable: Secured Assets are easily transferred between accounts or sent across IBC to other chains, enabling cross-chain trading and interoperability.

  • App Layer Use (Rujira): Within Rujira, Secured Assets can be used for trading, swapping, and interacting with decentralized apps (dApps) like limit orders, lending, or liquidity provision.

  • Efficient Arbitrage: Secured Assets allow traders (especially bots) to perform faster, more capital-efficient arbitrage compared to synthetics, adjusting market prices with less capital.

Flow: Using Secured Assets on Rujira

Step 1: Deposit L1 Tokens ➡ Mint Secured Assets ➡ Trade or Swap on Rujira ➡ Withdraw L1 Tokens

How Secured Assets Work on Rujira

  1. Deposit: Users deposit L1 tokens (e.g., BTC) into THORChain, creating a corresponding Secured Asset.

  2. Representation: The Secured Asset represents shares in the pool of deposited L1 tokens.

  3. Trading and Swapping: On Rujira, users can trade or swap Secured Assets (e.g., BTC-BTC) quickly and efficiently, without Layer1 fees.

  4. Smart Contracts: Secured Assets interact with dApps on Rujira via CosmWasm, enabling features like limit orders, lending, or liquidity staking.

  5. Withdraw: When users want to convert back to L1 tokens, they can withdraw their Secured Assets for an equivalent amount of the original token (e.g., Bitcoin).

Security

Secured Assets are backed by L1 deposits but are separate from THORChain liquidity pools. To maintain security:

  • Incentive Pendulum ensures the total value of L1 assets (including Secured Assets) does not exceed the security provided by bonded nodes.

  • Automatic Liquidation can be triggered if L1 asset values exceed bonded security, diluting Secured Asset holders and redistributing liquidity to safeguard the network.

Using Secured Assets in Rujira

Minting Secured Assets

To mint Secured Assets, users send L1 tokens with a specific memo to THORChain’s vault. The asset is then converted into a Secured Asset.

Example:

S+:thor1... (BTC-BTC added)

Swapping and Trading

On Rujira, Secured Assets can be swapped or traded like any other token, enabling quick and low-fee transactions.

Example:

=:BTC-BTC:thor1... (Swap BTC-BTC to another asset)

Withdrawing Secured Assets

Users can convert their Secured Assets back into L1 tokens by sending a withdrawal memo, receiving the equivalent L1 token (e.g., Bitcoin) based on their Secured Asset balance.

Example:

S-:bc1... (Withdraw BTC)

Transaction Flow

To understand the the interactions between smart contracts on Rujira, L1 pools on THORChain, and transactions out to the user, there are essentially two pathways for the compounded transactions sent on Rujira:

  • Path 1: Compound Memo using the | Operator

  • Path 2: Multiple Messages in a CosmWasm Contract

Path 1: Using the | Operator in Memo

  1. MsgDeposit is initiated by the user with a compound memo such as swap:BTC.BTC:{contract}|exec:{contract}:{encodedFunctionCall}.

  2. The deposit is passed through the pipeline without any validation by the Smart Contract at this stage (no validation until the contract is called).

  3. The L1 Pools execute the swap first, as specified in the memo.

  4. TxOut generates an output for the swap and continues processing the next step (e.g., executing the encoded function call) using the pipe operator (|) rather than DexAgg.

  5. The entire transaction is handled sequentially based on the memo instructions. The memo’s pipe operator (|) ensures that each action occurs in order.

  6. The contract is only called when required, such as during the final execution step after the swap has occurred.

  7. After all steps are completed, a response is returned to the user.

Path 2: Multiple Messages in a CosmWasm Contract

  1. The user sends a MsgDeposit to a contract.

  2. The Smart Contract internally creates multiple messages:

    1. MsgSwap for swapping assets.

    2. MsgAdd for adding liquidity.

    3. MsgMint for minting LP tokens.

    4. MsgExec to stake LP tokens in a yield farming contract.

  3. Each message is executed in sequence:

    1. The L1 Pools handle the swap and liquidity actions.

    2. TxOut generates output when LP tokens are minted.

    3. The smart contract handles the final action of staking LP tokens in the yield contract.

  4. Once all actions are completed, the contract returns a response to the user.

Last updated