Defining good behavior for just-in-time liquidity bots

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.

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

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.


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.

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.

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



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store