Chainflip will beat all other AMMs on price. Here's how.

Chainflip will beat all other AMMs on price. Here's how.

The dominance of centralised exchanges

In a sea of emerging and maturing DeFi products, it might seem like innovation on the market design front has slowed. That is wrong.

On-chain markets have yet to reach the competitiveness of the centralised exchanges. You still can’t swap 5 native BTC for something else without eating well over $5k in slippage anywhere on-chain. Yet, if you were to do that same swap on Binance, it would literally take millions of dollars worth of BTC before you even eat 1% of slippage.

Yes, that's a large trade, but it’s the sort of swap that drives over 80% of all crypto spot volume, and it’s this severe lack of comparable on-chain markets that (at the time of writing) leaves the BTC & various other coins on chain/off chain volume split looking like this:

Source: Coinmarketcap snapshot as of 7th March 2023 - compiled by Chainflip.

Dismissing this as nothing more than a problem for whales misses the point entirely. This is an extreme example of a problem plaguing on-chain markets in every ecosystem. Centralised exchanges are almost universally more liquid than existing on-chain systems, and there are no on-chain markets that allow that liquidity on centralised exchanges to be passed on to the user. The potential capital efficiency gains and savings for users are huge.

How does Chainflip aim to fix this? Enter the magic of the JIT AMM.

Maybe you know what Uniswap v3 is and how that works. And perhaps when I say a ‘maker-only limit order,’ you also know roughly what that means. You might also have heard of ‘Just In Time Liquidity’ or ‘JIT’ or some other such term referring to some MEV magic happening on Uniswap.

But you don’t have to know about any of that. At the heart of it, all that’s happening is price matching. The technology around it sounds complex (and it can be), but the ‘magic’ is really just looking up prices and offering the same to users.

The Chainflip JIT AMM is purpose built to bring the benefits of that MEV magic to cross-chain swaps, and it does that using a Uniswap v3 AMM with maker-only limit orders layered on top in a unified pool.

Although not terribly complex, this hybrid pool, sitting on Chainflip’s app-chain, allows Liquidity Providers (LPs) to do some very cool stuff. Because all cross-chain transfers require confirmation time, ranging from seconds to minutes (depending on the chain), the LPs have time to update their range and limit orders before any swap is executed.

This gives them the ability to “bid” for those swaps by changing their order prices in an attempt to beat the other LPs. If they do, they win the swap and get the fees. Because centralised order book liquidity is so deep, the LP can immediately resell the proceeds of that swap on other exchanges, ending with the same assets they started with, plus a small profit, and the user just got an amazing price for their swap. Price matching.

It doesn’t get more capital efficient than this. LPs with a very small amount of capital don’t even need to do proper market making themselves - all they need to do is aggregate the liquidity available on public order books and offer a price. Done well, there’s no impermanent loss - also known as a Delta-neutral strategy. The system is predictable and fully transparent. If they don’t have the means or desire to programmatically offer prices like this (we will be open sourcing a bot to increase competition), they can also place their liquidity in typical range orders and still collect fees. It’s the best of both worlds, both for the user and for participating liquidity providers.

It’s like a public auction where OTC desks compete for your business - but it’s all on chain, totally permissionless, trustless, zero verification required, no trade limits. Oh, and you can trade BTC and many other chains fully natively for once. “God above, that is cool!” you may be saying to yourself. “So why isn’t anyone else doing this?”

Why are other people not doing this?

Other people are doing this. Every day. On the world's largest Decentralised Exchange.

JIT Liquidity works on Uniswap - albeit not that well. That’s because in order to provide that liquidity ‘Just In Time’ - you have to use a Flashbots bundle or something similar to bribe the block producing Validator to order the transactions in the block in a particular way, such that it goes ‘Add liquidity, do big swap, remove liquidity.’- in that order. Without this, the LP almost certainly loses money.

Take this wonderful chart produced by Kaiko in their JIT on Uniswap analysis article. It is very easy to see the difference between JIT and Organic Liquidity Events on Uniswap v3. The top half of the chart is minting events, and below burning events. Where those large dots occur with the same size and same location on both minting and burning sides, we can infer that it was a JIT event. Almost all of those large dots line up, meaning the majority of large liquidity events on Uniswap are JIT liquidity events. The tiny little dots along the bottom of each section are the organic liquidity events. As you can see, JIT events are very, very large on Uniswap.

The suboptimal thing about JIT on Uniswap is that the cost of doing it is very high in terms of added gas fees, the “bribes” sent to the participating validators, and the added price risk from the uncertainty of the bundle execution. It means that unless the opportunity is very large, it makes no sense. There is no way to fix this without completely changing the user experience of single-chain DEXes. However, it is very clear now that the estimated “3.5% of volume” and general downplaying of JIT by Uniswap in Sept22 has not aged well.

So we know JIT works. We know how to make it better using app-chain architecture. And it’s a perfect fit for Chainflip - a cross-chain DEX that can support practically any type of chain. Almost all of the top 100 coins would be better priced on the JIT AMM than any other on-chain trading facility that currently exists.

On top of that, Chainflip will also be able to offer much cheaper gas fees, by only requiring the user to pay for a transfer with a tiny bit of extra logic. It’ll end up being about a third of the gas spent doing a typical single-chain swap - just compare the price of a Uniswap v3 trade and a USDT transfer on the Etherscan Gas Guzzler page, for example. It will also be significantly cheaper than other styles of EVM cross-chain bridging which require large amounts of data to be included on-chain with each bridging/messaging event in addition to the swapping logic gas required on each chain.

This is because the Chainflip JIT AMM is ‘virtual’ in the sense that it runs on an app-chain only loosely connected to supported blockchains - meaning all sorts of processing, logic and computation take place on the Chainflip State Chain instead, avoiding paying external gas fees for it beyond the transfer in most cases. Nice.

Chainflip’s Offer


So to sum up:

For any chain that Chainflip supports, we’ll offer the best price, the lowest gas, and be just as fast as any other cross-chain DEX. And because of that, any neutral aggregator is going to direct users to Chainflip for their swap. Theoretically, that makes the JIT AMM a black hole for volume.

That’s the plan anyway. This might fall apart in real life - but it’s based on well understood ideas and principles which we’ve internally backtested. As long as Liquidity Providers compete for swaps, users will get amazing prices, no matter how big or small the swap. The barrier to entry to do this is comparatively very low compared to other types of market making, so even if the daily volume is not astronomical, it will still be profitable for smaller operators to compete. The more volume there is, the more capital will be thrown into the ring, and the larger the maximum sized swaps can be.

We got $2m in TVL in a Chainflip pool? Users can (at the hypothetical extreme) do a $1m swap with minimal slippage against the global index price of whatever asset you’re trading. Nice.

All that being said, the clickbait title is clickbaity, as there are some pairs that we can only match the price on. The biggest pools on Ethereum (ETH and USD) are so large that there is almost no added benefit to JIT liquidity unless the value of the swaps are in the millions. Chainflip is a cross-chain DEX though, and the gas savings for the cross-chain swaps we offer mean that anyone going from ETH to an asset on another chain will likely be directed to Chainflip regardless, even if it’s the same price as existing DEXes.

I hope you enjoyed this explainer. Got more questions? Hit us up in Discord. Or keep up to date with everything Chainflip & release related on our Twitter.