|
| 1 | +# ZetaChain Gas Fee Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Gas fees in ZetaChain refer to the amount paid by users to execute transactions on connected chains. These fees **do not** include any gas payments that users make on the source chain to initiate transactions. |
| 6 | + |
| 7 | +## Key Concepts |
| 8 | + |
| 9 | +- **Deposit**: Transfer tokens from a connected chain to ZetaChain |
| 10 | +- **Withdraw**: Transfer tokens from ZetaChain to a connected chain |
| 11 | +- **Coin Types**: Different token types used for transactions (Gas, ERC20, ZETA, No Asset) |
| 12 | +- **Revert**: When a transaction fails and needs to be reverted |
| 13 | + |
| 14 | +## V2 Protocol Flows |
| 15 | + |
| 16 | +### Deposit Transactions |
| 17 | + |
| 18 | +Deposits transfer tokens from connected chains to ZetaChain. |
| 19 | + |
| 20 | +- Gas Fee is always in GAS ZRC20. If the amount is in a different ERC20, it's swapped to buy Gas tokens |
| 21 | + |
| 22 | +| Transaction Type | GAS FEE Deposit | GAS FEE Revert | Notes | |
| 23 | +|------------------|-----------------|----------------|-------| |
| 24 | +| Deposit | Free | User Pays based on cointype | Revert fees paid using the GAS ZRC20 on source chain | |
| 25 | +| DepositAndCall | Free | User Pays based on cointype | Revert fees paid using the GAS ZRC20 on source chain | |
| 26 | +| Call | Free | Revert Not supported | Revert fees paid using the GAS ZRC20 on source chain | |
| 27 | + |
| 28 | +#### Gas Fee Payment by Coin Type |
| 29 | + |
| 30 | +1. **CoinType ERC20** |
| 31 | + - User is using ERC20/ZRC20 tokens |
| 32 | + - `Protocol` calculates expected gas cost on connected chain, using `Current Gas Price` * `Revert Gas Limit` + Protocol Flat Fee |
| 33 | + - ERC20 tokens are swapped to buy gas ZRC20 tokens |
| 34 | + - Gas ZRC20 tokens are burned to pay for the gas fee |
| 35 | + |
| 36 | +2. **CoinType Gas** |
| 37 | + - User paid in the native gas token on a connected chain |
| 38 | + - `Protocol` calculates expected gas cost on connected chain, using `Current Gas Price` * `Revert Gas Limit` + Protocol Flat Fee |
| 39 | + - Gas token can be directly burned to pay for the gas fee |
| 40 | + |
| 41 | +3. **NoAssetCall** |
| 42 | + - No revert processing in this case, the cross-chain transaction is aborted |
| 43 | + |
| 44 | +### Withdraw Transactions |
| 45 | + |
| 46 | +Withdrawals transfer tokens from ZetaChain to connected chains. |
| 47 | + |
| 48 | +| Transaction Type | GAS FEE Withdraw | GAS FEE Revert | Notes | |
| 49 | +|------------------|-----------------|----------------|-------| |
| 50 | +| Withdraw | User Pays based on withdraw type | Free call to OnRevert using fixed GasLimit | Initiated through Gateway smart contract | |
| 51 | +| WithdrawAndCall | User Pays based on withdraw type | Free call to OnRevert using fixed GasLimit | Initiated through Gateway smart contract | |
| 52 | +| Call | User Pays based on withdraw type | Free call to OnRevert using fixed GasLimit | Initiated through Gateway smart contract | |
| 53 | + |
| 54 | +- Withdrawals are initiated by users through zEVM smart contract calls |
| 55 | +- Fees are always paid in the GAS ZRC20 token for the target connected chain, this fees is paid separately by the user an is not deducted from the amount.However when the transaction reverts, the revert fee is deducted from the amount |
| 56 | +- CCTX type is either GAS or ERC20 depending on the token |
| 57 | + |
| 58 | +**Gas Fee Payment by withdraw type:** |
| 59 | + |
| 60 | +1. **Withdraw** |
| 61 | + - `Gateway Smart contract` calculates expected gas cost on connected chain based on `gasPrice` * `ZRC20.GasLimit` + Protocol Flat Fee |
| 62 | + |
| 63 | +2. **WithdrawAndCall** |
| 64 | + - `Gateway Smart contract` calculates expected gas cost on connected chain based on `gasPrice` * `CallOptions.GasLimit` + Protocol Flat Fee |
| 65 | + |
| 66 | +3. **Call** |
| 67 | + - `Gateway Smart contract` calculates expected gas cost on connected chain based on `gasPrice` * `ZRC20.GasLimit` + Protocol Flat Fee |
| 68 | + |
| 69 | +## V1 Protocol Flows |
| 70 | + |
| 71 | +- V1 flows for ERC20/ZRC20 and GAS tokens have already been deprecated |
| 72 | +- V1 flows for ZETA token deposits and withdrawals are still supported but are planned to be deprecated soon. |
| 73 | + |
| 74 | +### Deposit Transactions |
| 75 | + |
| 76 | +| Transaction Type | GAS FEE Deposit | GAS FEE Revert | Notes | |
| 77 | +|------------------|-----------------|----------------|-------| |
| 78 | +| Deposit zEVM | Free | User pays based on coin type | Gas fee for revert based on cointype | |
| 79 | +| Deposit Connected Chain (Msg-Passing) | User pays based on coin type | User pays based on coin type | Fees in connected chain's gas token | |
| 80 | + |
| 81 | +#### Gas Fee Payment by Coin Type |
| 82 | + |
| 83 | +1. **CoinType Zeta** |
| 84 | + - User is using ERC20/ZRC20 "Zeta Token" |
| 85 | + - `Protocol` calculates expected gas cost on connected chain using `gasPrice * 2` * `CallOptions.GasLimit` + Protocol Flat Fee |
| 86 | + - Zeta tokens are swapped to buy gas ZRC20 tokens |
| 87 | + - Gas tokens are burned to pay for the gas fee |
| 88 | + - **Important**: Gas price is multiplied by 2× when calculating the fee |
| 89 | + |
| 90 | +2. **CoinType ERC20** |
| 91 | + - User is using ERC20/ZRC20 tokens |
| 92 | + - `Protocol` calculates expected gas cost on connected chain using `gasPrice` * `GasZRC20.GasLimit` + Protocol Flat Fee |
| 93 | + - ERC20 tokens are swapped to buy gas ZRC20 tokens |
| 94 | + - Gas tokens are burned to pay for the gas fee |
| 95 | + |
| 96 | +3. **CoinType Gas** |
| 97 | + - User paid in native gas token on connected chain |
| 98 | + - `Protocol` calculates expected gas cost on connected chain using `gasPrice` * `GasZRC20.GasLimit` + Protocol Flat Fee |
| 99 | + - Gas token can be directly burned to pay for fee |
| 100 | + |
| 101 | +### Withdraw Transactions |
| 102 | + |
| 103 | +| Transaction Type | GAS FEE Deposit | GAS FEE Revert | Notes | |
| 104 | +|------------------|-----------------|----------------|-------| |
| 105 | +| ZRC20 Withdraw | User pays | Not supported | Uses same mechanism as V2 withdrawals | |
| 106 | +| ZETA Sent | User pays | Free call to OnRevert using fixed GasLimit | Total Zeta (value + gas) is burned | |
| 107 | + |
| 108 | +#### Details by Withdraw Type |
| 109 | + |
| 110 | +1. **ZRC20 Withdraw** |
| 111 | + - Uses the same mechanism as V2 withdrawals but initiated through ZRC20 contract |
| 112 | + |
| 113 | +2. **ZETA Sent** |
| 114 | + - Total Zeta amount (value + gas) is burned |
| 115 | + - A portion is minted to swap and pay for gas in outbound chain |
| 116 | + - `Protocol` calculates expected gas cost on a connected chain using `gasPrice * 2` * `CallOptions.GasLimit` + Protocol Flat Fee |
| 117 | + - Value portion is unlocked in connected chain after successful outbound transaction |
0 commit comments