Symbiosis
Search…
Cross-chain Swaps | Symbiosis
Cross-chain swaps with the Symbiosis protocol in a nutshell.
The purpose of the Symbiosis protocol is to do cross-chain swaps. This document explains how the Symbiosis protocol handles them.
For better comprehension of this document, please read Wrapped Tokens and sTokens | Symbiosis first.
High/low gas fees. A gas fee is always paid for in the native cryptocurrency of that blockchain, where the transaction gets executed. Thus, when we compare gas prices on different blockchains, we compare them, for example, in the USD equivalent.
There are two cases while doing cross-chain swaps:
  • Case 1: a cross-chain swap from a blockchain with a high gas fee to a blockchain with a lower gas fee,
  • Case 2: a cross-chain swap from a blockchain with a lower gas fee to a blockchain with a high gas fee.
As an example, let us consider the pair Ethereum — Binance Smart Chain.
The Symbiosis protocol works with USDC on Ethereum and BUSD on Binance Smart Chain. Since the gas fee on Ethereum is higher than the gas fee on Binance Smart Chain, the liquidity pool to do cross-chain swaps for this pair is located on Binance Smart Chain. This liquidity pool contains sUSDC <> BUSD, where sUSDC represents USDC of Ethereum on Binance Smart Chain with the ratio of 1:1.

Case 1

There is an example of a cross-chain swap from a blockchain with a high gas fee to a blockchain with a lower gas fee.
A user would like to do a cross-chain swap: UNI ERC20 on Ethereum → CAKE BEP20 on Binance Smart Chain.
The route of UNI to CAKE will look like: UNI → USDC → sUSDC → BUSD → CAKE
The algorithm of this cross-chain swap is shown in Scheme 1. An explanation follows Scheme 1.
Scheme 1. UNI → CAKE cross-chain swap.
  1. 1.
    Within this step:
    1. 1.
      The user selects assets to swap: UNI to CAKE
    2. 2.
      The front-end finds the path with the lowest fees for this swap and provides the user with details: all intermediate swaps, fees associated with the intermediate swaps, and gas fees. In this case, there are three intermediate swaps:
      UNI → USDC; sUSDC → BUSD; BUSD → CAKE
    3. 3.
      If the user agrees with the fees, the user signs ONE transaction. That allows the Symbiosis protocol to do all these intermediate swaps on behalf of the user.
  2. 2.
    The front-end sends the transaction to the origin blockchain (Ethereum in this case).
  3. 3.
    The Symbiosis protocol does UNI → USDC swap on behalf of the user on the AMM with the best price. The AMM is selected within Step 1. This AMM does not belong to Symbiosis.
  4. 4.
    As soon as USDC is deposited to the Portal contract address, the BridgeV2 contract issues an event informing listeners that there is a request to perform a cross-chain swap. More information on the Portal and BridgeV2 contracts is here Cross-chain liquidity engine
  5. 5.
    The relayers listen to events of cross-chain swap requests. More information on the relayers is here Relayers network | Symbiosis Finance
  6. 6.
    The relayers reach a consensus for this particular event and sign a transaction.
  7. 7.
    The relayers send the transaction to the destination blockchain (Binance Smart Chain in this case).
  8. 8.
    The Synthesis contract receives information about the request.
  9. 9.
    The Synthesis contract mints sUSDC with the ratio 1:1 to the USDC deposited in Step 4. The Symbiosis protocol does sUSDC → BUSD swap on behalf of the user on AMM belonging to Symbiosis.
  10. 10.
    The Symbiosis protocol does BUSD → CAKE swap on behalf of the user on AMM with the best price. The AMM is selected within Step 1. This AMM does not belong to Symbiosis.
  11. 11.
    As soon as the swap BUSD → CAKE is accomplished, CAKE gets deposited to the user's address.
NB Through all these steps, the user is the sole owner of the swapping assets. The user allows to do these swaps on their behalf to the Symbiosis protocol by signing the transaction in Step 1.

Case 2

There is an example of a cross-chain swap from a blockchain with a lower gas fee to a blockchain with a high gas fee.
A user would like to do a cross-chain swap: CAKE BEP20 on Binance Smart Chain → UNI ERC20 on Ethereum.
The route of CAKE to UNI will look like: CAKE → BUSD → sUSDC → USDC → UNI
The algorithm of this cross-chain swap is shown in Scheme 2. An explanation follows Scheme 2.
Scheme 2. CAKE → UNI cross-chain swap.
  1. 1.
    Within this step:
    1. 1.
      The user selects assets to swap: CAKE to UNI
    2. 2.
      The front-end finds the path with the lowest fees for this swap and provides the user with details: all intermediate swaps, fees associated with the intermediate swaps, and gas fees. In this case there are three intermediate swaps: CAKE → BUSD; BUSD → sUSDC; USDC → UNI
    3. 3.
      If the user agrees with the fees, the user signs ONE transaction. That allows the Symbiosis protocol to do all these intermediate swaps on behalf of the user.
  2. 2.
    The front-end sends the transaction to the origin blockchain (Binance Smart Chain in this case).
  3. 3.
    The Symbiosis protocol does CAKE → BUSD swap on behalf of the user on the AMM with the best price. The AMM is selected within Step 1. This AMM does not belong to Symbiosis.
  4. 4.
    The Symbiosis protocol does BUSD → sUSDC swap on behalf of the user on AMM belonging to Symbiosis. As soon as sUSDC is deposited to the Symbiosis contract address, the Symbiosis contract burns sUSDC and informs the BridgeV2 contract that there is a request to perform a cross-chain swap.
  5. 5.
    The Symbiosis contract informs the BridgeV2 contract that there is a request to perform a cross-chain swap. The BridgeV2 contract issues an event informing listeners that there is a request to perform a cross-chain swap. More information on the Symbiosis and BridgeV2 contracts is here Cross-chain liquidity engine
  6. 6.
    The relayers listen to events of cross-chain swap requests. More information on the relayers is here Relayers network | Symbiosis Finance
  7. 7.
    The relayers reach a consensus for this particular event and sign a transaction.
  8. 8.
    The relayers send the transaction to the destination blockchain (Ethereum in this case).
  9. 9.
    The Portal contract receives information about the request.
  10. 10.
    The Portal contract releases USDC the ratio 1:1 to the sUSDC burnt in Step 4. The Symbiosis protocol does USDC → UNI swap on behalf of the user on AMM with the best price. The AMM is selected within Step 1. This AMM does not belong to Symbiosis.
  11. 11.
    As soon as the swap USDC → UNI is accomplished, UNI gets deposited to the user's address.
NB Through all these steps, the user is the sole owner of the swapping assets. The user allows to do these swaps on their behalf to the Symbiosis protocol by signing the transaction in Step 1.

More information

The Metarouter contract does all steps on behalf of a user during a cross-chain swap. Please refer to Metarouter V3 | Symbiosis Financefor more information.