BIFROST
Published in

BIFROST

Designing a cross-chain DEX

Analyzing different approaches to swapping assets across chains and the design of BIFROST Cross—chain DEX.

Introduction

There is no question that a solution that would allow for a frictionless and secure exchange of assets on different chains was to improve the user experience for crypto users in general. Today, the market is dominated by centralized exchanges — when users have to make a chain-agnostic trade, they generally go to Binance, Coinbase, or any other CEX. While there is a lot of research & development dedicated to this problem, the killer app that would challenge CEXes the same way Uniswap did for chain-specific assets is yet to come.

There are a few teams approaching this problem from different angles — some of them have been around for quite some time, while others use state-of-the-art tech that has recently become available. Design decisions for a cross-chain DEX are something the BIFROST team has been researching extensively. The reason is that BIFROST’s cross-chain DEX is the first priority post-mainnet launch, and we want to roll out the best possible product that will improve the user experience from the solutions currently available on the market.

In this article, we will look into three main designs that are functional on the mainnet adopted by THORchain, SushiXSwap, and Hashflow, and compare them to the design of the BIFROST cross-chain DEX. Each of the three exchanges we analyze has processed billions of dollars and can be considered a relative success.

THORchain — building natively cross-chain AMM

THORchain is a layer-one blockchain based on Tendermint & Cosmos-SDK, with the main purpose of redirecting liquidity across chains. It operates only with native tokens and requires liquidity pools for all the supported assets on all the supported networks.

On a high level, it would be fair to describe THORchain as cross-chain Uniswap, as the liquidity model is similar. Fees and token incentives encourage users to provide liquidity to the pools, and this liquidity is used by the traders. Unlike Uniswap though, THORchain has a settlement token, which every supported asset is paired to — a native token of the network RUNE. In this aspect, THORchain is more similar to Bancor Network which also pairs all the pairs with its native token BNC.

The THORchain network is secured by the THORnodes. They have to bond a significant amount of RUNE that is subject to slashing. To ensure that malicious behavior is economically irrational, the network is designed to keep a balance between the bonded amount and the amount of liquidity in the pools. In the optimal state, the bonded amount is roughly equal to pooled capital.

In this state, the pooled liquidity is secured by the minimum sufficient amount of bonded capital. Security is economically ensured in the most capital-efficient way. THORchain has an algorithm called “Incentive Pendulum” that allocates rewards in a way to pursue this equilibrium.

Currently, THORchain supports native BTC, BCH, LTC, and DOGE, as well as assets on Ethereum, Avalanche, BNB, and Cosmos networks.

SushiXSwap — tapping into existing liquidity pools

Sushi has been around since 2020, and has been able to attract enough liquidity and secure the position of #2 DEX on the Ethereum network. Part of Sushiswap’s expansion strategy is to deploy on every new chain, so going cross-chain was a natural choice for them. To achieve it, Sushi has partnered with LayerZero and integrated Stargate. With SushiXSwap, users can swap assets across 7 networks — Ethereum, Polygon, Avalanche, Fantom, Binance Chain, Arbitrum, Optimism, and more to come.

How does it work under the hood? Let’s start by taking a look at LayerZero, the protocol that enables the cross-chain capabilities of SushiXSwap.

LayerZero is a generalized data messaging protocol that passes lightweight messages across chains through smart contracts. These smart contracts, called endpoints, are implemented on the supported chains. In LayerZero’s design, there are two off-chain components — oracles and relayers, that pass messages between endpoints. Oracle’s job is to forward a block header from one chain to another, while the relayer passes the proof to the chain B that the transaction has been validated on chain A. LayerZero is a trustless protocol and its security assumptions hold as far as the relayer and oracle are run independently and don’t collude.

SushiXSwap uses Stargate protocol, which is a bridge built on top of LayerZero. It allows users to perform chain-agnostic swaps tapping into the liquidity of existing Sushi pools on different chains. That is perhaps the main advantage of Sushi’s cross-chain AMM — they don’t have to attract liquidity from scratch. The routing process finds the most efficient way from one asset on chain A to another asset on chain B. In the future, Sushi is planning to connect other bridges as well (in a similar way as AAVE Portal allows users to choose from approved bridges).

HashFlow — request for quote (RFQ)

Hashflow has quite a unique design for DeFi — it doesn’t rely on either AMM or bridges. Instead, it relies on liquidity providers and market makers, who facilitate cross-chain transactions. Currently, Hashflow is available on Ethereum, Polygon, Avalanche, Optimism, Arbitrum, and the BNB chain.

Hashflow argues that liquidity managed by market makers is a much more capital-efficient way of structuring the exchange. On top of that, users get MEV protection and zero slippage. While this is true, all these good properties come from the fact that Hashflow doesn’t work in a permissionless manner, skipping the pros and cons of operating fully on-chain. Whitelisted market makers are the ones who provide quotes, and these quotes are arbitrary and depend exclusively on them. In other more DeFi-native designs, the system has to be structured in a way that balances incentives. In Hashflow, it’s more about trusting the market makers.

Hashflow is not the first project to heavily rely on market-makers and other institutions in DeFi. We’ve seen market-makers dominating the DOV (decentralized option vaults) space through RFQ, although the largest DOV providers switched to the auction model since then. Uncollateralized lending is another niche where crypto-native institutions have the dominant power of deciding on either approving or rejecting the loan.

BIFROST Cross-chain DEX

When considering the design for our cross-chain DEX, we wanted to take advantage of the design of the BIFROST Network, as well as implement what works best according to the trial-and-error of other projects.

Our cross-chain DEX shares some similarities and differences with both THORchain and SushiXSwap models. To understand them, it’s important to have a high-level overview of the BIFROST Network. Two major pieces of BIFROST’s Network off-chain architecture that pass the transaction data across chains are relayer and oracle, and on-chain components represented by socket contracts deployed on the supported chains. This model might remind you LayerZero. But unlike Sushi, BIFROST doesn’t have existing pools to tap into and has to build liquidity from the ground up.

A cross-chain DEX is a multi-facet service of settlement and liquidity management. Like THORChain, the exchange requests are settled in the native tokens of the network — BFC. And, like SushiXSwap, we take a more practical approach by separating settlement and liquidity management, for which we can employ multiple methods.

BIFROST cross-chain DEX is based on the model that utilizes two types of AMM curves — one for stablecoin pairs uses a Curve-type slope, and another for assets paired with a settlement token BFC, uses a more traditional Uniswap-like slope. This twin pool model is designed to help to attract liquidity, while also allowing for the shortest possible root across different chains. With fewer trades in the route, we aim to reduce slippage and improve prices for traders. In addition, when the coin that the user wants to exchange is not in supported chains or lacks liquidity, the ChainRunner engine will provide an optimal swap through different dex of each chain.

BIFROST Network has bonding requirements for full nodes to make sure that attacks are economically unviable and liquidity is secured, as well as a set of economic incentives for basic nodes and liquidity providers. Details on these incentives and deep dive into security mechanics will be revealed in the upcoming articles.

Learn more

We have exciting news coming soon! Follow us on Twitter and join our Discord community to not miss opportunities to participate.

If you are as excited about the cross-chain future as we are, and want to build cool applications on BIFROST Network, contact us!

--

--

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