# Base Layer Virtualization Strategy

The Base Layer Virtualization strategy is a single-sided passive market making strategy that allows Rujira App Layer to virtualize the liquidity in THORChain's Base Layer pools via an arbitrage mechanism.

On the Base Layer, all swaps are executed at the end of block and ranked by price impact. This means that despite the App Layer sharing the same blocktime and - in theory - supporting atomic transactions between CosmWasm contracts and THORChain Base Layer, in practice we cannot have atomicity with the Base Layer swaps, i.e. we cannot within the same block do something on the App Layer, then do a Base Layer swap, then do something else on the App Layer with the proceeds from that swap. The Base Layer Virtualization strategy is Rujira's answer to this problem, it allows the App Layer to tap into Base Layer liquidity while retaining transaction atomicity and composability.

Whenever someone want to do a swap on the App Layer (e.g. I want to swap 10,000 USDC for BTC), the market making strategy is able to query the Base Layer pools to see how many BTC it would get for 10,000 USDC and then provide a quote at a slightly worst price (Base Layer price + small margin). This quote appear in the orderbook alongside any pending fixed-price orders and tracking orders. Whenever an order is matched against it, the target asset is borrowed from RUJI Lending for the duration of 1 block and used to fill the buyer's order on the App Layer, then the opposite swap is executed on the Base Layer at the end of the block. Finally, in the next block, the loan is repaid with the proceeds from the Base Layer swap, and the remaining profits, if any, are split 50/50 (TBC) between the LPs in the pool and RUJI stakers. Over the long run, most trades are profitable for LPs, but it might be instances where the execution price in the Base Layer pool is worst than what was quoted, in that case the strategy makes a loss that is funded by the LPs in the pool.

The below chart illustrates how the strategy works with the various flow of funds. A complete walkthrough is available in this [video](https://www.youtube.com/watch?v=sGBNbV5z2cc).

<figure><img src="/files/l9T0rIkCxnJPcNYaAnyY" alt=""><figcaption></figcaption></figure>

{% embed url="<https://www.youtube.com/watch?v=sGBNbV5z2cc>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rujira.network/core-products/ruji-amm/base-layer-virtualization-strategy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
