Links
☝

Gas Fees for Cross-chain Operations & Advisor

Who and how pays fees for cross-chain operations via the Symbiosis protocol.

Who Pays Gas Fees

The Symbiosys protocol currently implements the following cross-chain operations:
  • Cross-chain swaps,
  • Cross-chain zaps,
  • Interchain communicating (adding liquidity to third-party DeFi protocols),
  • Bridging,
  • Reverting stuck cross-chain operations.
Each cross-chain operation is a sequence of steps on the source and destination blockchains. Let’s consider the cross-chain swap in Scheme 1 as an example.
Scheme 1. A cross-chain swap as an example of a cross-chain operation.
For the user, there is just one transaction (Step 1 in Scheme 1). The user signs this transaction and sends it to the source blockchain. The user pays gas fees for this transaction.
In fact, there are always two transactions (Steps 1 and 5 in Scheme 1). Relayers signs and sends the second transaction. And the relayers pay the gas fee for it on the second blockchain. Let’s figure out how the user refunds the gas fee for the second transaction.

Withholding the cost of gas

We will show withholding the cost of gas on the example of cross-chain swaps below. The logic of withholding the cost of gas for other cross-chain operations is exactly the same.
If you want to collect some additional fee on top of our logic, you should deploy and use collector smart contracts on your own.
We advise using either the Symbiosis SDKs or the Symbiosis API to estimate gas prices and compose the initial calldata properly.
Please check out our documentation for software developers Symbiosis Developer Tools
Let’s add to Scheme 1 workflow of withholding stablecoins for the gas on the destination blockchain (Scheme 2).
Scheme 2. Withholding the cost of gas as an example of cross-chain swap.
Step 1. The calldata for the initial transaction contains:
  1. 1.
    The sequence of steps on the source and destination blockchains to obtain the destination asset from the source one,
  2. 2.
    Some restrictions (the slippage tolerance and the deadline for the cross-chain operations),
  3. 3.
    The estimated gas fee (in the stablecoin equivalent) for the second transaction. This amount will be deducted from the amount of the cross-chain operation on the destination blockchain. It’s GasEstimatedUSD in Scheme 2
The user has this information at the time of transaction signing. By signing, they accept all these steps, restrictions, and fees. The user pays the gas fees for this transaction on the source blockchain (it’s Binance Smart Chain in the example).
Steps 2-4. The Symbiosis protocol follows instructions from the calldata (Step 1) for the source blockchain.
Step 5. The Symbiosis protocol creates Oracle that contains the rest of the instructions (including the accepted GasEstimatedUSD) from the initial calldata (Step 1) for the destination blockchain.
Step 6. Relayers do a number of checks, including whether GasEstimatedUSD is enough to pay the gas fee for the second transaction on the destination blockchain. If it’s not enough, there is no second transaction. Relayers call Microservice Advisor to check whether GasEstimatedUSD is enough to pay the gas fee.
Step 7. The Symbiosis protocol releases stablecoins on the destination blockchain, deducts an amount equal to GasEstimatedUSD, and keeps it. The remaining stablecoins are for the user.
Step 8. The Symbiosis protocol follows instructions from the calldata for the destination blockchain.
The instructions and GasEstimatedUSD for the initial calldata get obtained in Step 1 and remain unchanged until the end of the cross-chain operation.
To complete the picture, there is another example of a cross-chain operation: Scheme 3.
Please consider the difference:
  • Scheme 2: a cross-chain swap from a blockchain with a lower gas fee to a blockchain with a high gas fee (high/low is in the USD equivalent). In the example, we go from Binance Smart Chain to Ethereum.
  • Scheme 3: a cross-chain swap from a blockchain with a high gas fee to a blockchain with a lower gas fee (high/low is in the USD equivalent). In the example, we go from Ethereum to Binance Smart Chain.
Scheme 3. Withholding the cost of gas as an example of cross-chain swap.
Scheme 3. Withholding the cost of gas as an example of cross-chain swap.
Step 6. The Symbiosis protocol mints sTokens on the destination blockchain, deducts an amount equal to GasEstimatedUSD, and keeps it. The remaining stablecoins are for the user.
Thus, we explained withholding the cost of gas on the example of cross-chain swaps. The logic of withholding the cost of gas for other cross-chain operations is exactly the same.
If you want to collect some additional fee on top of our logic, you should deploy and use a collector smart contracts on your own.

Advisor

Microservice Advisor:
  1. 1.
    Checks that the amount of the cross-chain operation is within limits applied by the Symbiosis protocol,
  2. 2.
    Estimates gas cost (in the USD equivalent) to execute the given calldata,
  3. 3.
    Checks whether the given gas cost is enough to run the given calldata (Relayers and Broadcaster’s calls).
For Points 2 and 3, Advisor calls an appropriate method on the destination blockchain to simulate the given calldata execution. If the given calldata is not executable, then
  1. 1.
    Gas cost cannot be estimated,
  2. 2.
    The check whether the given gas cost is enough to run the given calldata returns false.
Scheme 3. Advisor ecosystem.