Symbiosis Finance - The Mechanics behind it's Cross Chain Swaps

By kev_nag | kev_nag | 21 Mar 2022


Introduction

Symbiosis Finance, in simple terms, is a multi-chain Automated Market Maker (AMM), that operates as a Decentralized Exchange pooling liquidity from multiple users and pricing said pooled assets utilizing algorithms. As per the Symbiosis Finance web page, the protocol permits users to: “Move liquidity across Any Chain. Symbiosis aggregates decentralized exchange liquidity across any EVM and non-EVM networks. Swap any token and transfer liquidity. Yes, any.” [Symbiosis Finance. Symbiosis/Website. (Accessed March 21, 2022)].

So, just how does Symbiosis Finance accomplish the cross chain transfers? Let’s take a few moments and investigate the mechanics that make this protocol run.

The Mechanics Behind Symbiosis’ Cross Chain Swaps

Basic Scheme as to How the Protocol Works

20220321 2.png
Photo Source

In essence, three layers comprise the basic mechanics structure of the Symbiosis protocol.

  • Layer 1: (known as the Front-End) The purpose of this layer is to act as a web interface (or in the alternative, a mobile application). This front-end collects all relevant information concerning the assets on the blockchains covered by Symbiosis. Once collected, the front-end operates to build the routes with the lowest prices for swap execution. Finally, this layer assists the user in signing and transmitting the desired swap to the appropriate blockchains.
  • Layer 2: (known as the Cross-Chain Liquidity Engine) This layer is where the magic happens. This layer is a set of smart contracts, which may be broken down into three separate groupings, which operate to execute the cross-chain swap.

20220321 5.png
Photo Source

In its simplest form, this layer operates all of the liquidity pools on the various blockchains plus the necessary routing mechanisms to access AMM liquidity on the various chains to permit the cross-chain swaps.

  • Layer 3: (known as the Relayers Network) This layer may be diagramed as follows:

20220321 7.png
Photo Source

To simplify, this layer is nothing more than a P2P node network comprised of decentralized relayers whose job it is to monitor events on each supported blockchain by Symbiosis that is transmitted by the cross-chain liquidity engine, reach a consensus, and direct the transaction to its proper blockchain.

Diving Deeper - The Meat and Potatoes (Using Wrapped Tokens and sTokens)

With regard to cross-chain swaps, Symbiosis uses wrapped tokens to exchange an asset existing on one blockchain into a representative asset on a different blockchain. This representative (wrapped) token is backed by a 1:1 ratio with the original asset which is held by a smart contract within the Symbiosis protocol. Symbiosis distinguishes these wrapped tokens used in cross-chain swaps as sTokens where the s represents synthetic.

The protocol has chosen a stablecoin on each supported blockchain and for each blockchain pair sTokens are processed by the protocol on the chain with the lowest gas fees. The blockchains supported by the Symbiosis protocol are displayed in the following diagram:

20220321 3.png
Photo Source

The protocol operates using a single stablecoin on each of the blockchains it supports. Symbiosis maintains a single liquidity pool for each pair of blockchains for which it supports swaps. To keep operating costs in check, this liquidity pool is always found on the blockchain with the lowest gas fees. In diagram form, this liquidity pool appears as follows:

20220321 9.png
Photo Source

If a user desires to initiate a transaction in the nature of a cross-chain swap, and the original asset chosen by the user is different from the blockchain asset chosen by Symbiosis, the original asset is first swapped for the protocol chosen stablecoin.

By way of example let’s take a user who wishes to swap between the Ethereum chain and the Binance Smart Chain. Symbiosis has chosen BSC for the location of this liquidity pool and said liquidity pool consists of BUSD <> sUSDC. (It should be noted that Symbiosis did not choose the Ethereum chain to host a USDC <> sBUSD liquidity pool as the gas fees on Ethereum far exceed the fees on BSC).

The Deepest Dive - How a Cross-Chain Swap Works

The documents found in the Symbiosis web site provides a somewhat complex and convoluted example for the mechanics of a protocol cross-chain swap. Let’s try and simplify this as much as possible. The example contemplates a cross-chain swap of ERC20 UNI tokens from the Ethereum blockchain to BEP2O CAKE tokens on the BSC blockchain. A diagram of this transaction appears as follows:

20220321 11.png
Photo Source

So, let’s try to uncomplicate this diagram by taking the transaction step-by-step as performed by the protocol’s algorithm.

  1. The user accesses Symbiosis Finance and chooses to swap UNI ERC2O tokens to CAKE BEP20 tokens.
  2. The front-end then searches for and discovers a path for the transaction with the lowest available fees. The front-end advises the user of all required intermediate swaps and all fees relative to them including gas. In our present example, the Symbiosis algorithm identified three intermediate swaps are necessary, to wit: UNI swapped to USDC; sUSDC swapped to BUSD; and BUSD to CAKE.
  3. If the steps and fees are acceptable to the user, the user signs only one transaction which permits the protocol to conduct all three intermediate swaps.
  4. The front-end then transmits the transaction to the originating blockchain (in this example, as UNI is an ERC20 token, the origin chain is Ethereum).
  5. The protocol next uses the AMM with the lowest fee (as was chosen step 2) to perform the UNI to USDC swap.
  6. When the USDC is deposited into the portal smart contract the BridgeV2 contract broadcasts an event to the relayers that a cross-chain swap is pending.
  7. After listening to the cross-chain request events, the relayers reach consensus and sign the transaction.
  8. The relayers then perform the task of sending the transaction to the destination chain (in this example, as we are swapping for BEP20 CAKE, the destination chain is BSC).
  9. The Symbiosis synthesis contract on the BSC side receives the details concerning the transaction.
  10. The synthesis contract then mints sUSDC tokens in a 1:1 ratio with the USDC deposited into the portal smart contract above. The Symbiosis protocol then performs the sUSDC to BUSD swap using the liquidity pool maintained by Symbiosis on BSC.
  11. Now that the protocol has the BUSD, it transmits the BUSD to CAKE swap to the AMM with the lowest price as was previously identified in step 2 above.
  12. Once the protocol receives the CAKE tokens from the AMM, the CAKE tokens are deposited into the user’s targeted address.

These steps comprise each action taken by the Symbiosis protocol algorithm for each cross-chain swap requested.

Final Thoughts

It is vital for the reader to recognize that all twelve of the foregoing steps go on in the background. To effect a cross-chain swap the procedure for the user to follow is simple and intuitive. Simply input the token you wish to swap and the quantity you desire to swap as well as the token you wish to receive in return. The interface is self-explanatory:

20220321 16.png
Photo Source

Once the user has entered the necessary information reflective of their choices (and approved the transaction and fees), all they need to do is sit back and let the Symbiosis protocol’s algorithms take care of the rest.

How do you rate this article?


12

0

kev_nag
kev_nag

Just an ordinary casual crypto investor.


kev_nag
kev_nag

Retired, finally. I enjoy learning about crypto and sharing my discoveries. Also, I follow the News closely and enjoy discussing current events. I have no political agenda, but advance views based in reality with a slant toward real world consequences.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.