Base Layer Arbitrage strategy
Last updated
Last updated
The Base Layer Arbitrage strategy is a single-sided passive market making strategy that allows Rujira App Layer to virtualize the liquidity in THORChain's Base Layer pools.
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 Arbitrage 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 limit orders and oracle 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 .