SystemContract
Git Source (opens in a new tab)
Inherits: SystemContractErrors
The system contract it's called by the protocol to interact with the blockchain. Also includes a lot of tools to make easier to interact with ZetaChain.
State Variables
gasPriceByChainId
Map to know the gas price of each chain given a chain id.
mapping(uint256 => uint256) public gasPriceByChainId;
gasCoinZRC20ByChainId
Map to know the ZRC20 address of a token given a chain id, ex zETH, zBNB etc.
mapping(uint256 => address) public gasCoinZRC20ByChainId;
gasZetaPoolByChainId
mapping(uint256 => address) public gasZetaPoolByChainId;
FUNGIBLE_MODULE_ADDRESS
Fungible address is always the same, it's on protocol level.
address public constant FUNGIBLE_MODULE_ADDRESS = 0x735b14BB79463307AAcBED86DAf3322B1e6226aB;
uniswapv2FactoryAddress
Uniswap V2 addresses.
address public immutable uniswapv2FactoryAddress;
uniswapv2Router02Address
address public immutable uniswapv2Router02Address;
wZetaContractAddress
Address of the wrapped ZETA to interact with Uniswap V2.
address public wZetaContractAddress;
zetaConnectorZEVMAddress
Address of ZEVM Zeta Connector.
address public zetaConnectorZEVMAddress;
Functions
constructor
Only fungible module can deploy a system contract.
constructor(address wzeta_, address uniswapv2Factory_, address uniswapv2Router02_);
depositAndCall
Deposit foreign coins into ZRC20 and call user specified contract on zEVM.
function depositAndCall(
zContext calldata context,
address zrc20,
uint256 amount,
address target,
bytes calldata message
)
external;
Parameters
Name | Type | Description |
---|---|---|
context | zContext | |
zrc20 | address | |
amount | uint256 | |
target | address | |
message | bytes |
sortTokens
Sort token addresses lexicographically. Used to handle return values from pairs sorted in the order.
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1);
Parameters
Name | Type | Description |
---|---|---|
tokenA | address | |
tokenB | address |
Returns
Name | Type | Description |
---|---|---|
token0 | address | token1, returns sorted token addresses,. |
token1 | address |
uniswapv2PairFor
Calculates the CREATE2 address for a pair without making any external calls.
function uniswapv2PairFor(address factory, address tokenA, address tokenB) public pure returns (address pair);
Parameters
Name | Type | Description |
---|---|---|
factory | address | |
tokenA | address | |
tokenB | address |
Returns
Name | Type | Description |
---|---|---|
pair | address | tokens pair address. |
setGasPrice
Fungible module updates the gas price oracle periodically.
function setGasPrice(uint256 chainID, uint256 price) external;
Parameters
Name | Type | Description |
---|---|---|
chainID | uint256 | |
price | uint256 |
setGasCoinZRC20
Setter for gasCoinZRC20ByChainId map.
function setGasCoinZRC20(uint256 chainID, address zrc20) external;
Parameters
Name | Type | Description |
---|---|---|
chainID | uint256 | |
zrc20 | address |
setGasZetaPool
Set the pool wzeta/erc20 address.
function setGasZetaPool(uint256 chainID, address erc20) external;
Parameters
Name | Type | Description |
---|---|---|
chainID | uint256 | |
erc20 | address |
setWZETAContractAddress
Setter for wrapped ZETA address.
function setWZETAContractAddress(address addr) external;
Parameters
Name | Type | Description |
---|---|---|
addr | address |
setConnectorZEVMAddress
Setter for zetaConnector ZEVM Address
function setConnectorZEVMAddress(address addr) external;
Parameters
Name | Type | Description |
---|---|---|
addr | address |
Events
SystemContractDeployed
Custom SystemContract errors.
event SystemContractDeployed();
SetGasPrice
event SetGasPrice(uint256, uint256);
SetGasCoin
event SetGasCoin(uint256, address);
SetGasZetaPool
event SetGasZetaPool(uint256, address);
SetWZeta
event SetWZeta(address);
SetConnectorZEVM
event SetConnectorZEVM(address);