mTokenGateway

Git Source

Inherits: OwnableUpgradeable, ImTokenGateway, ImTokenOperationTypes

State Variables

rolesOperator

Roles manager

IRoles public rolesOperator;

verifier

IZkVerifier public verifier;

paused

mapping(OperationType => bool) public paused;

underlying

Returns the address of the underlying token

address public underlying;

accAmountIn

mapping(address => uint256) public accAmountIn;

accAmountOut

mapping(address => uint256) public accAmountOut;

allowedCallers

mapping(address => mapping(address => bool)) public allowedCallers;

userWhitelisted

mapping(address => bool) public userWhitelisted;

whitelistEnabled

bool public whitelistEnabled;

LINEA_CHAIN_ID

uint32 private constant LINEA_CHAIN_ID = 59144;

gasFee

gas fee for supplyOnHost

uint256 public gasFee;

Functions

constructor

Note: oz-upgrades-unsafe-allow: constructor

constructor();

initialize

function initialize(address payable _owner, address _underlying, address _roles, address zkVerifier_)
    external
    initializer;

notPaused

modifier notPaused(OperationType _type);

onlyAllowedUser

modifier onlyAllowedUser(address user);

isPaused

returns pause state for operation

function isPaused(OperationType _type) external view returns (bool);

Parameters

NameTypeDescription
_typeOperationTypethe operation type

isCallerAllowed

Returns if a caller is allowed for sender

function isCallerAllowed(address sender, address caller) external view returns (bool);

getProofData

Returns the proof data journal

function getProofData(address user, uint32) external view returns (uint256, uint256);

setWhitelistedUser

Sets user whitelist status

function setWhitelistedUser(address user, bool state) external onlyOwner;

Parameters

NameTypeDescription
useraddressThe user address
stateboolThe new staate

enableWhitelist

Enable user whitelist

function enableWhitelist() external onlyOwner;

disableWhitelist

Disable user whitelist

function disableWhitelist() external onlyOwner;

setPaused

Set pause for a specific operation

function setPaused(OperationType _type, bool state) external override;

Parameters

NameTypeDescription
_typeOperationTypeThe pause operation type
stateboolThe pause operation status

extractForRebalancing

Extract amount to be used for rebalancing operation

function extractForRebalancing(uint256 amount) external notPaused(OperationType.Rebalancing);

Parameters

NameTypeDescription
amountuint256The amount to rebalance

setUnderlying

function setUnderlying(address _addr) external onlyOwner;

setGasFee

Sets the gas fee

function setGasFee(uint256 amount) external onlyOwner;

Parameters

NameTypeDescription
amountuint256the new gas fee

withdrawGasFees

Withdraw gas received so far

function withdrawGasFees(address payable receiver) external;

Parameters

NameTypeDescription
receiveraddress payablethe receiver address

updateZkVerifier

Updates IZkVerifier address

function updateZkVerifier(address _zkVerifier) external onlyOwner;

Parameters

NameTypeDescription
_zkVerifieraddressthe verifier address

updateAllowedCallerStatus

Set caller status for msg.sender

function updateAllowedCallerStatus(address caller, bool status) external override;

Parameters

NameTypeDescription
calleraddressThe caller address
statusboolThe status to set for caller

supplyOnHost

Supply underlying to the contract

function supplyOnHost(uint256 amount, address receiver, bytes4 lineaSelector)
    external
    payable
    override
    notPaused(OperationType.AmountIn)
    onlyAllowedUser(msg.sender);

Parameters

NameTypeDescription
amountuint256The supplied amount
receiveraddressThe receiver address
lineaSelectorbytes4The method selector to be called on Linea by our relayer. If empty, user has to submit it

outHere

Extract tokens

function outHere(bytes calldata journalData, bytes calldata seal, uint256[] calldata amounts, address receiver)
    external
    notPaused(OperationType.AmountOutHere);

Parameters

NameTypeDescription
journalDatabytesThe supplied journal
sealbytesThe seal address
amountsuint256[]The amounts to withdraw for each journal
receiveraddressThe receiver address

_outHere

function _outHere(bytes memory journalData, uint256 amount, address receiver) internal;

_verifyProof

function _verifyProof(bytes calldata journalData, bytes calldata seal) private view;

_checkSender

function _checkSender(address msgSender, address srcSender) private view;

_getSequencerRole

function _getSequencerRole() private view returns (bytes32);

_getBatchProofForwarderRole

function _getBatchProofForwarderRole() private view returns (bytes32);

_getProofForwarderRole

function _getProofForwarderRole() private view returns (bytes32);

_isAllowedFor

function _isAllowedFor(address _sender, bytes32 role) private view returns (bool);