# Understanding Secured Assets

To understand how Rujira is the App Layer built on THORChain, please refer to the [THORChain Docs](https://docs.thorchain.org/frequently-asked-questions/app-layer-bridge-assets), where the assets that tie the base layer (THORChain) together with the app layer (Rujira) are 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 into THORChain's decentralized Asgard Vaults, which mints a corresponding Secured Asset (e.g., `BTC-BTC`). These Secured Asset tokens represent a share of ownership of the underlying L1 assets in the vault. The Asgard Vaults are secured by Threshold Signature Schemes (TSS) with the private keys split among \~100 independent node operators that churn every 3 days.
* **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.
* **No wrapping or third-party bridges:** Secured Assets remove all dependency to third-party bridges (e.g. Axellar, Gravity) and wrapping by centralized intermediaries (e.g. wBTC by BitGo, cbBTC by Coinbase), enabling access to DeFi with native assets from all connected chains.

#### Flow: Using Secured Assets on Rujira

```plaintext
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's decentralized Asgard Vaults, 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 provisioning.
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:

* **TVL Check** upon minting ensures that there is sufficient security budget to accommodate more Secured Assets.
* **Incentive Pendulum** can ensure the total value of L1 assets (including Secured Assets) does not exceed the security provided by bonded nodes. This feature is optional and controlled by a Mimir parameter '*PendulumUseVaultAssets'.* By default, Secured Assets are "optimistically secured" by THORChain validators (they are not inside the Incentive Pendulum). Secured Assets make THORChain nodes money from App Layer fees, that is how they pay for their security.

## 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**:

<pre><code><strong>S+:thor1... (BTC-BTC added)
</strong></code></pre>

#### 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 and the base layer L1 pools on THORChain, there are essentially two ways to call a contract:

* Path 1: Layer 1 Transaction + Memo
* Path 2: THORChain Transaction Direct Execution

#### Path 1: Layer 1 Transaction + Memo

A user initiates a transaction using a Layer 1 deposit along with a memo structured as `x:{contract}:{payload}`. This triggers the smart contract on Rujira, executing the specified function while utilizing the funds sent in the Layer 1 transaction. The smart contract can then emit sub-messages to perform additional actions such as:

* Swapping BTC to RUNE and bonding the RUNE with a Node Operator.
* Depositing BTC into a lending protocol, borrowing secured USDC, and withdrawing secured USDC to say Ethereum or any other network supporting USDC.

The execution follows the sequence dictated by the contract logic, with each step being carried out in order. Once all actions are completed, the contract returns a response to the user.

**Transaction flow using `x:` Memo in Layer 1 Transactions**

* User: A `MsgDeposit` is initiated by the user with a memo formatted as `x:{contract}:{payload}`.
* L1: The L1 performs a couple of actions when a user makes a deposit:
  * TxIn: The deposit is processed async without validation by the smart contract at this stage.
  * Mint Secured Asset: Mint x/bank token based on the user deposit
* The contract is called when required, executing the necessary actions once prior steps are complete.

<img src="https://780454749-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fjck9fGNvnlDMHj7pa6Gz%2Fuploads%2F1kc1eXtnJl8AfZk9YPvS%2Ffile.excalidraw.svg?alt=media&#x26;token=42ee38d4-6cc0-44db-b3b0-c345023f429b" alt="" class="gitbook-drawing">

#### Path 2: THORChain Transaction Direct Execution

A user interacts with the contract directly via a THORChain transaction using `MsgExecuteContract { contract, msg, funds }`. This method is functionally similar to the `x:` memo approach but offers additional capabilities:

* The `funds` field allows sending THORChain-native tokens such as `x/ruji`, which do not have a representation in `MsgDeposit` notation.
* The ability to send multiple tokens simultaneously, enabling operations like depositing `x/ruji` and `ETH-USDC` into a dual liquidity pool in a single transaction.

**Transaction flow using direct `MsgExecuteContract` Call**

* A user directly calls `MsgExecuteContract` on THORChain with `{ contract, msg, funds }`.
* The contract processes the message and executes multiple actions such as an asset swaps, adding liquidity, etc.
* The L1 Pools handle swap and liquidity actions.
* `TxOut` generates output upon LP token minting.
* The smart contract handles final steps such as staking LP tokens.
* The contract then returns a response to the user.

<img src="https://780454749-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fjck9fGNvnlDMHj7pa6Gz%2Fuploads%2FOXnoexNn7ZbjD5ert4VR%2Ffile.excalidraw.svg?alt=media&#x26;token=b0b20059-9b93-448c-993f-b41eff01be6e" alt="" class="gitbook-drawing">
