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.

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;

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

NameTypeDescription
contextzContext
zrc20address
amountuint256
targetaddress
messagebytes

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

NameTypeDescription
tokenAaddress
tokenBaddress

Returns

NameTypeDescription
token0addresstoken1, returns sorted token addresses,.
token1address

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

NameTypeDescription
factoryaddress
tokenAaddress
tokenBaddress

Returns

NameTypeDescription
pairaddresstokens pair address.

setGasPrice

Fungible module updates the gas price oracle periodically.

function setGasPrice(uint256 chainID, uint256 price) external;

Parameters

NameTypeDescription
chainIDuint256
priceuint256

setGasCoinZRC20

Setter for gasCoinZRC20ByChainId map.

function setGasCoinZRC20(uint256 chainID, address zrc20) external;

Parameters

NameTypeDescription
chainIDuint256
zrc20address

setGasZetaPool

Set the pool wzeta/erc20 address.

function setGasZetaPool(uint256 chainID, address erc20) external;

Parameters

NameTypeDescription
chainIDuint256
erc20address

setWZETAContractAddress

Setter for wrapped ZETA address.

function setWZETAContractAddress(address addr) external;

Parameters

NameTypeDescription
addraddress

setConnectorZEVMAddress

Setter for zetaConnector ZEVM Address

function setConnectorZEVMAddress(address addr) external;

Parameters

NameTypeDescription
addraddress

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);