☝️Gas Fees for Cross-chain Operations via Symbiosis
Who and how pays transaction fees for cross-chain operations conducted with the Symbiosis protocol.
Last updated
Who and how pays transaction fees for cross-chain operations conducted with the Symbiosis protocol.
Last updated
The Symbiosis protocol implements the following cross-chain operations:
Cross-chain swaps,
Cross-chain zaps (adding liquidity to Symbiosis Octopjols,
Interchain communicating (adding liquidity to third-party DeFi protocols via cross-chain Zaps),
Bridging,
Reverting stuck cross-chain operations.
Each cross-chain operation is a sequence of steps on the source blockchain, S-chain, and destination blockchains. Let’s consider the cross-chain swap in Scheme 1 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 blockchain where the user has assets). The user pays gas fees for this transaction.
In fact, a cross-chain operation always involves more than one transaction. Relayers sign and send transactions for S-chain (Step 5 in Scheme 1) and the destination blockchain (Step 9 in Scheme 1). And the relayers pay the gas fee for the transactions. Let’s figure out how the user refunds the gas fee.
We will show withholding the cost of gas on the example of a cross-chain swap. The logic of withholding the cost of gas for other cross-chain operations is the same.
If Boba BNB (Symbiosis S-chain) is the source or destination blockchain of a cross-chain operation, then there is one calldata and one transaction less in the cross-chain operation.
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 properly estimate gas prices and compose calldata.
Please check out our documentation for software developers Symbiosis Developer Tools
Let’s add to Scheme 1 workflow of withholding gas cost on the S-chain and destination blockchain (Scheme 2).
Step 1. In fact, the initial transaction contains 3 calldatas:
Calldata0: the sequence of steps to do on the source blockchain.
Calldata1: the sequence of steps to do on S-chain. This calldata includes the estimated gas fee for the transaction execution on this blockchain in the stablecoin equivalent: GasEstimatedUSD1
in Scheme 2.
Calldata2: the sequence of steps to do on the destination blockchain. This calldata includes the estimated gas fee for the transaction execution on this blockchain in the stablecoin equivalent: GasEstimatedUSD2
in Scheme 2.
In addition, the calldatas contain some restrictions (the slippage tolerance and the deadline for the cross-chain operation).
All this information is defined by the time of the initial transaction signing and cannot be modified later. By signing, the user accepts all these intermediate steps, restrictions, and fees. The user pays the gas fees for this transaction on the source blockchain (it’s Polygon in the example).
Steps 2-4. The Symbiosis protocol follows instructions from Calldata0 (Step 1) for the source blockchain. Once the instructions are done, the Symbiosis protocol creates an Oracle request (a message for listeners) that contains Calldata1 and Calldata2 for further steps.
Step 5. Relayers are listening for Oracle requests issued by the Symbiosis contracts. They take information from the Oracle request and do a number of checks, including whether GasEstimatedUSD1
is enough to pay the gas fee for the second transaction on the S-chain. If the checks are passed, and the approved gas fee is enough, they sign a transaction that includes Calldata1 and Calldata 2 with their MPC key and send it to the next blockchain. The relayers pay for the transactions that they sign and send, and users refund these expenses.
Step 6. The Symbiosis protocol follows instructions from Calldata1 (Step 1) for S-chain. The Symbiosis protocol mints sTokens on the S-chain, deducts an amount equal to GasEstimatedUSD1
, and keeps it. The remaining sTokens continue participating in the further steps of the cross-chain swap.
Steps 7-8. The Symbiosis protocol follows instructions from Calldata1 (Step 1) for S-chain. Once the instructions are done, the Symbiosis protocol creates an Oracle request (a message for listeners) containing Calldata2 (Step 1) for further steps of the cross-chain swap.
Step 9. Relayers are listening for Oracle requests issued by the Symbiosis contracts. They take information from the Oracle request and do a number of checks, including whether GasEstimatedUSD2
is enough to pay the gas fee for the transaction on the destination blockchain. If the checks are passed, and the approved gas fee is enough, they sign a transaction that includes Calldata 2 with their MPC key and send it to the destination blockchain. The relayers pay for the transactions that they sign and send, and users refund these expenses.
Step 10. The Symbiosis protocol follows instructions from Calldata2 (Step 1) for the destination blockchain. The Symbiosis protocol releases stablecoins on the destination blockchain, deducts an amount equal to GasEstimatedUSD2
, and keeps it. The remaining stablecoins continue participating in the intermediate steps of the cross-chain swap.
Step 11. The Symbiosis protocol follows instructions from Calldata2 (Step 1) for the destination blockchain. Once the last instruction from Calldata2 is accomplished, the user gets tokens to their address on the destination chain.
The intermediate instructions, restrictions, GasEstimatedUSD1
and
GasEstimatedUSD2
get obtained in Step 1 and remain unchanged until the end of the cross-chain operation.
Microservice Advisor:
Checks that the amount of the cross-chain operation is within limits applied by the Symbiosis protocol,
Estimates gas cost (in the USD equivalent) to execute the given calldata,
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
Gas cost cannot be estimated,
The check whether the given gas cost is enough to run the given calldata returns false.