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
How Secured Assets Work on Rujira
Deposit: Users deposit L1 tokens (e.g., BTC) into THORChain, creating a corresponding Secured Asset.
Representation: The Secured Asset represents shares in the pool of deposited L1 tokens.
Trading and Swapping: On Rujira, users can trade or swap Secured Assets (e.g.,
BTC-BTC
) quickly and efficiently, without Layer1 fees.Smart Contracts: Secured Assets interact with dApps on Rujira via CosmWasm, enabling features like limit orders, lending, or liquidity staking.
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:
Swapping and Trading
On Rujira, Secured Assets can be swapped or traded like any other token, enabling quick and low-fee transactions.
Example:
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:
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
MsgDeposit is initiated by the user with a compound memo such as swap:BTC.BTC:{contract}|exec:{contract}:{encodedFunctionCall}.
The deposit is passed through the pipeline without any validation by the Smart Contract at this stage (no validation until the contract is called).
The L1 Pools execute the swap first, as specified in the memo.
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.
The entire transaction is handled sequentially based on the memo instructions. The memo’s pipe operator (|) ensures that each action occurs in order.
The contract is only called when required, such as during the final execution step after the swap has occurred.
After all steps are completed, a response is returned to the user.
Path 2: Multiple Messages in a CosmWasm Contract
The user sends a MsgDeposit to a contract.
The Smart Contract internally creates multiple messages:
MsgSwap for swapping assets.
MsgAdd for adding liquidity.
MsgMint for minting LP tokens.
MsgExec to stake LP tokens in a yield farming contract.
Each message is executed in sequence:
The L1 Pools handle the swap and liquidity actions.
TxOut generates output when LP tokens are minted.
The smart contract handles the final action of staking LP tokens in the yield contract.
Once all actions are completed, the contract returns a response to the user.
Last updated