Defining good behavior for just-in-time liquidity bots

Composable Foundation
8 min readMar 23, 2022

--

Disclaimer: Information as of Mar 23, 2022. For the most recent updates, dive into our comprehensive documentation here

As an extra layer of assurance that cross-chain transfers always go through, Mosaic allows for community members to provide just-in-time (JIT) liquidity through running liquidity bots with the active liquidity SDK. This creates a dynamic cross-chain liquidity marketplace where Mosaic’s own rebalancing and various bots from the community cooperate to make transfers happen while competing for rewards. It is therefore crucial that we define the desirable features for the marketplace as well as for the bots to guide the design of reward allocation and the necessary technologies to facilitate the desirable features.

Role of JIT bots in the Mosaic ecosystem

Mosaic, Composable’s cross-chain transfer availability layer, allows community members to front-run Mosaic’s own rebalancing and provide just-in-time liquidity to meet the demand of large cross-chain transfers. If Mosaic’s own rebalancing takes too long, liquidity bots can step in to facilitate transfers and earn a greater share of rewards.

The JIT liquidity provision works synergistically with Mosaic’s other features to ensure that there’s no more stuck cross-chain transactions; including:

  • Single-sided liquidity provisioning, which means community members can provide liquidity just for one asset;
  • Liquidity forecasting leveraging machine learning, which allows Mosaic to forecast liquidity shortfalls and rebalances its vaults proactively;
  • Rebalancing of its vaults through external bridges such as Connext or Hop.

High level view of Mosaic’s active liquidity module, where bots front-run Mosaic’s rebalancing process. More details here.

We’re building an Active Liquidity Bot SDK so that community members can install and run their own bots. When the active liquidity module is live, Mosaic will be connected with a host of bots providing liquidity on various networks it supports, including Ethereum, Polygon, Avalanche, Arbitrum, etc. This makes Mosaic a high-speed, interactive liquidity marketplace. Each bot provides and withdraws liquidity from Mosaic to maximize their return; they both react to and shape Mosaic’s liquidity. It is thus crucial that we understand the game theory of active liquidity provisioning to induce maximal outcome for all parties involved.

At Composable, we aim to incentivize bots behaviors that are aligned with all of Mosaic’s stakeholders — users, passive liquidity providers, bridges, and other applications Mosaic is integrated with. Below, we share our thinking on the desirable features for the cross-chain liquidity marketplace and how we define ‘good behavior’ on those bots. These will guide the design on the marketplace and reward allocation.

Desirable features for the cross-chain liquidity marketplace

User experience in cross-chain transfer is mainly determined by two factors, transfer time and fee. Both are in turn dependent on having sufficient liquidity in the marketplace and deploying the liquidity efficiently. While TVL is the main KPI for most DeFi Dapps at the moment, we think in the long term, capital efficiency is crucial in maintaining a sustainable yield and locking in TVL. In addition to the financial metrics, decentralization is needed to ensure resilience in the system.

Capital efficiency

DeFi Dapps aren’t just about the TVL, but also the capital efficiency in using the TVL. If through Mosaic’s own rebalancing and active liquidity provisioning, $10M is sufficient to avoid vault depletion or high transfer fees, there is no need in locking in $100M in the liquidity vault. Higher efficiency means that the rewards can be shared with a smaller capital base, meaning higher APYs for the liquidity providers involved.

We want to induce active bots to respond to the network needs precisely; there are two aspects to the precise response: the amount of liquidity provided and the time liquidity is provided. In terms of liquidity, bots reacting to transfers above a given threshold should be rewarded more than those not targeting any transfers; in terms of time, Capital efficiency requires liquidity to be provided “Just In Time” rather than “Just Whenever”. See the ‘Desirable features for JIT bots’ section for more details.

Decentralization

In the steady state, Mosaic’s liquidity provisioning should not be dependent on any liquidity provisioning party. If a vault needs $20M in liquidity, having five parties providing $4M each is more desirable than having two parties providing $10M; decentralization minimizes the risk of central point of failure and also increases competition and the incentive for liquidity provisioning parties to be responsive.It is better to have multiple actors supporting the vaults and share rewards widely with the community rather than having one actor dominating a vault and hoarding the rewards.

Mosaic’s cross-chain liquidity vault set-up supports decentralization by design. Since one vault is for one coin on one chain, assuming there are five coins for each chain and ten chains supported, there will be around 50 vaults, thus hard for one party to impact the liquidity on Mosaic overall.

Another innovative feature is that the JIT liquidity bots can provide and withdraw liquidity to any chains supported by Mosaic; this allows the bots to respond to demand/supply dynamics on different chains, rather than hoarding over a given vault. The demand and supply for vaults change over time to respond to network activities (new product launch, liquidity rush, etc.) as well as the amount of active and passive liquidity flowing in and out of the vault. For a large capital provider, dividing up the capital to provide liquidity on different vaults is very likely to provide higher yield than putting all the capital in one vault; meaning that the active liquidity providers are economically incentivized to decentralize.

Desirable features for JIT bots

We want to incentivize bots that are active and attentive to the liquidity dynamics on Mosaic, which can be broadly categorized into three criteria:

Provide Liquidity Just In Time

We want to incentivize provide liquidity as close as possible to the moment before the relayer attempts to act on the transfer, this allows for better visibility of the liquidity levels on the vaults. A lot of things could happen in the span of a couple blocks. If the bot provides liquidity too early, the vaults liquidity could vary wildly by the time the relayer acts on the transfer.

Provide Just Enough Liquidity

A good bot will be efficient with how much active liquidity is being provided. Good bots should participate in the system in an educated fashion that shows they are paying attention to the vault liquidity demand. Ideally, the bot will see a transfer of X tokens and supply X tokens + 5% of X tokens to take account of the changing liquidity levels between provisioning liquidity and relayer acting on the transfer needs. They shouldn’t just blindly provide 50% of the vault’s liquidity when only 2% is needed to facilitate the transfers.

Withdraw Liquidity Just In Time

A good bot will ensure that it is being efficient with its funds and it also has the goal of keeping liquidity at a “Just Enough” level. This is partly achieved by incentivizing the bot to attempt withdrawal immediately after min active liquidity lock time, i.e. the minimum amount of time the bots need to wait before withdrawal. This behavior also helps maintain a higher velocity of money, which in turn makes the vault more efficient.

Reap benefits of cross chain extractable value

MEV strategies have been hugely profitable; the ability to provide and withdraw liquidity to any chain on Mosaic opens up a new frontier, the ‘cross-chain extractable value’. There are quite a few overlaps between the strategies of MEV and cross-chain extractable value; as such, we expect the MEV searchers can develop profitable cross-chain strategies in a short period of time. For example, ‘Sandwiching’, the most common form of MEV, works by front-running large pending orders and profit from large orders’ price impact, this is similar to how JIT liquidity bots work on Mosaic — they provide liquidity to the destination chain in anticipation of large transfer requests. However, importantly, in the case of Mosaic the front-runners are not competing for the end users’ profit, instead they are facilitating a cross-chain transfer that might otherwise take a lot longer to complete. ‘Arbitrage’, another common MEV strategy that involves buying an asset in one place and selling it in another to exploit the price differences, will find new applications on Mosaic — the JIT liquidity bots can provide USDC on the Ethereum chain and withdraw it on Arbitrum to take advantage of differences in yields on different chains for the same asset.

The flexibility of operating on different chains also opens up new strategies beyond the common ones on MEV. Our active liquidity lead has teased the strategies before, but to recap, users have the flexibility to:

  • Provide and withdraw liquidity to the same network (Strategy 1)
  • Use the API in the active liquidity SDK to check for lowest network fees for withdraw and then withdraw to where the fee is lowest (Strategy 2)
  • Set a network to withdraw to and wait for when the fee is below a certain threshold, which allows you do transfer to another chain while earning a fee (Strategy 3)
  • Set up two bots on different networks and loop the liquidity provisioning/withdrawal strategis. Provide liquidity on network A, withdraw to B, use the liquidity to provide liquidity on A, then withdraw on A, and repeat (Strategy 4)
  • Convert part of the liquidity to native gas tokens for lower network fees. (Strategy 5)

The cross-chain extractable value opens up exciting opportunities for MEV searchers to explore. We will facilitate target the MEV community and facilitate the onboarding to cross-chain extractable value through the active liquidity SDK and hands-on guides. The active liquidity SDK, currently under development, allows users to set up as many instances of JIT bots on as many chains supported by Mosaic as they want; it will be accompanied by guides and code examples. We will also share how-to guides, video clips, and host AMAs to familiarize the community with the cross chain LP opportunities.

Conclusion

The active liquidity SDK will allow community members to run bots and provide active liquidity. The active liquidity will cooperate with Mosaic’s passive liquidity to make sure transfers go through as well as competing for rewards, creating a cross-chain liquidity marketplace. In this article we shared the design principles for the marketplace and bots’ behavior. We aim to create a marketplace that is focused on capital efficiency and decentralization; instead of just a high TVL, we want to ensure that the liquidity providers can maximize their rewards and there is less reliance on large capital providers. For the bots, we aim to give higher rewards to those that provide and withdraw liquidity at the right amount and right time; we will also induce strategies that fully take advantage of Mosaic’s cross-chain liquidity provisioning opportunities.

For more information about Composable and how it is architecting the unified DeFi landscape of the future, check out our socials:

Twitter | Telegram | Discord | Website | GitHub | LinkedIn

--

--

Composable Foundation
Composable Foundation

Written by Composable Foundation

Powering the future of chain-agnostic intention execution.

No responses yet