mTokenGateway
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
Name | Type | Description |
---|---|---|
_type | OperationType | the 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
Name | Type | Description |
---|---|---|
user | address | The user address |
state | bool | The 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
Name | Type | Description |
---|---|---|
_type | OperationType | The pause operation type |
state | bool | The pause operation status |
extractForRebalancing
Extract amount to be used for rebalancing operation
function extractForRebalancing(uint256 amount) external notPaused(OperationType.Rebalancing);
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount to rebalance |
setUnderlying
function setUnderlying(address _addr) external onlyOwner;
setGasFee
Sets the gas fee
function setGasFee(uint256 amount) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | the new gas fee |
withdrawGasFees
Withdraw gas received so far
function withdrawGasFees(address payable receiver) external;
Parameters
Name | Type | Description |
---|---|---|
receiver | address payable | the receiver address |
updateZkVerifier
Updates IZkVerifier address
function updateZkVerifier(address _zkVerifier) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_zkVerifier | address | the verifier address |
updateAllowedCallerStatus
Set caller status for msg.sender
function updateAllowedCallerStatus(address caller, bool status) external override;
Parameters
Name | Type | Description |
---|---|---|
caller | address | The caller address |
status | bool | The 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
Name | Type | Description |
---|---|---|
amount | uint256 | The supplied amount |
receiver | address | The receiver address |
lineaSelector | bytes4 | The 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
Name | Type | Description |
---|---|---|
journalData | bytes | The supplied journal |
seal | bytes | The seal address |
amounts | uint256[] | The amounts to withdraw for each journal |
receiver | address | The 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);