> For the complete documentation index, see [llms.txt](https://docs.rujira.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rujira.network/core-products/ruji-amm/base-layer-virtualization-strategy.md).

# Base Layer Virtualization Strategy

The Base Layer Virtualization Strategy (VS) 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 wants 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 worse price (Base Layer price + small margin). This quote appears in the orderbook alongside any pending fixed-price orders, tracking orders and CCL 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 retained in the VS contract as reserve to absorb any future loss from unfavourable base layer execution. Over the long run, most trades from the VS should be breakeven or slightly profitable, but there might be instances where the execution price in the Base Layer pool is worse than what was quoted, in that case the strategy makes a loss that is offset by the contract's reserve.

The chart below illustrates how the strategy works with the various flows 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.
