ImTokenGateway

Git Source

Title: ImTokenGateway

Author: Merge Layers Inc.

Gateway interface for cross-chain mToken operations

Functions

extractForRebalancing

Extract amount to be used for rebalancing operation

function extractForRebalancing(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256The amount to rebalance

setPaused

Set pause for a specific operation

function setPaused(ImTokenOperationTypes.OperationType _type, bool state) external;

Parameters

NameTypeDescription
_typeImTokenOperationTypes.OperationTypeThe pause operation type
stateboolThe pause operation status

updateAllowedCallerStatus

Set caller status for msg.sender

function updateAllowedCallerStatus(address caller, bool status) external;

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;

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

liquidate

Liquidate a user

function liquidate(address userToLiquidate, uint256 liquidateAmount, address collateral, address receiver)
    external
    payable;

Parameters

NameTypeDescription
userToLiquidateaddressThe user to liquidate
liquidateAmountuint256The amount to liquidate
collateraladdressThe collateral address
receiveraddressThe receiver address

outHere

Extract tokens

function outHere(bytes calldata journalData, bytes calldata seal, uint256[] memory amounts, address receiver)
    external;

Parameters

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

rolesOperator

Roles

function rolesOperator() external view returns (IRoles roles);

Returns

NameTypeDescription
rolesIRolesRoles operator contract

blacklistOperator

Blacklist operator

function blacklistOperator() external view returns (IBlacklister blacklister);

Returns

NameTypeDescription
blacklisterIBlacklisterBlacklister contract

underlying

Returns the address of the underlying token

function underlying() external view returns (address underlyingToken);

Returns

NameTypeDescription
underlyingTokenaddressThe address of the underlying token

isPaused

Returns pause state for operation

function isPaused(ImTokenOperationTypes.OperationType _type) external view returns (bool paused);

Parameters

NameTypeDescription
_typeImTokenOperationTypes.OperationTypeThe operation type

Returns

NameTypeDescription
pausedboolTrue if paused

accAmountIn

Returns accumulated amount in per user

function accAmountIn(address user) external view returns (uint256 amountIn);

Parameters

NameTypeDescription
useraddressUser address

Returns

NameTypeDescription
amountInuint256Accumulated amount in

accAmountOut

Returns accumulated amount out per user

function accAmountOut(address user) external view returns (uint256 amountOut);

Parameters

NameTypeDescription
useraddressUser address

Returns

NameTypeDescription
amountOutuint256Accumulated amount out

getProofData

Returns the proof data journal

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

Parameters

NameTypeDescription
useraddressUser address
dstIduint32Destination chain identifier

Returns

NameTypeDescription
dataRootuint256The proof data root
journalHashuint256The proof journal hash

gasFee

Returns the gas fee for Linea

function gasFee() external view returns (uint256 fee);

Returns

NameTypeDescription
feeuint256Gas fee amount

Events

AllowedCallerUpdated

Emitted when a user updates allowed callers

event AllowedCallerUpdated(address indexed sender, address indexed caller, bool status);

Parameters

NameTypeDescription
senderaddressThe caller updating permissions
calleraddressThe address whose status is updated
statusboolWhether the caller is allowed

mTokenGateway_Supplied

Emitted when a supply operation is initiated

event mTokenGateway_Supplied(
    address indexed from,
    address indexed receiver,
    uint256 accAmountIn,
    uint256 accAmountOut,
    uint256 amount,
    uint32 srcChainId,
    uint32 dstChainId,
    bytes4 lineaMethodSelector
);

Parameters

NameTypeDescription
fromaddressSender on source chain
receiveraddressReceiver on destination
accAmountInuint256Accumulated amount in
accAmountOutuint256Accumulated amount out
amountuint256Supplied amount
srcChainIduint32Source chain ID
dstChainIduint32Destination chain ID
lineaMethodSelectorbytes4Linea method selector

mTokenGateway_Liquidate

Emitted when a liquidate operation is initiated

event mTokenGateway_Liquidate(
    address indexed from,
    address indexed receiver,
    uint256 amount,
    uint32 srcChainId,
    uint32 dstChainId,
    address userToLiquidate,
    address collateral
);

Parameters

NameTypeDescription
fromaddressSender on source chain
receiveraddressReceiver of seized collateral
amountuint256Liquidation amount
srcChainIduint32Source chain ID
dstChainIduint32Destination chain ID
userToLiquidateaddressUser being liquidated
collateraladdressCollateral market address

mTokenGateway_Extracted

Emitted when an extract was finalized

event mTokenGateway_Extracted(
    address indexed msgSender,
    address indexed srcSender,
    address indexed receiver,
    uint256 accAmountIn,
    uint256 accAmountOut,
    uint256 amount,
    uint32 srcChainId,
    uint32 dstChainId
);

Parameters

NameTypeDescription
msgSenderaddressSender on host chain
srcSenderaddressSender on source chain
receiveraddressReceiver of funds
accAmountInuint256Accumulated amount in
accAmountOutuint256Accumulated amount out
amountuint256Amount extracted
srcChainIduint32Source chain ID
dstChainIduint32Destination chain ID

mTokenGateway_Skipped

Emitted when a proof was skipped

event mTokenGateway_Skipped(
    address indexed msgSender,
    address indexed srcSender,
    address indexed receiver,
    uint256 accAmountIn,
    uint256 accAmountOut,
    uint256 amount,
    uint32 srcChainId,
    uint32 dstChainId
);

Parameters

NameTypeDescription
msgSenderaddressSender on host chain
srcSenderaddressSender on source chain
receiveraddressReceiver of funds
accAmountInuint256Accumulated amount in
accAmountOutuint256Accumulated amount out
amountuint256Amount skipped
srcChainIduint32Source chain ID
dstChainIduint32Destination chain ID

mTokenGateway_GasFeeUpdated

Emitted when the gas fee is updated

event mTokenGateway_GasFeeUpdated(uint256 amount);

Parameters

NameTypeDescription
amountuint256New gas fee amount

mTokenGateway_PausedState

Emitted when pause state changes

event mTokenGateway_PausedState(ImTokenOperationTypes.OperationType indexed _type, bool _status);

Parameters

NameTypeDescription
_typeImTokenOperationTypes.OperationTypeOperation type paused/unpaused
_statusboolPause status

ZkVerifierUpdated

Emitted when zk verifier is updated

event ZkVerifierUpdated(address indexed oldVerifier, address indexed newVerifier);

Parameters

NameTypeDescription
oldVerifieraddressPrevious verifier
newVerifieraddressNew verifier

mTokenGateway_UserWhitelisted

Emitted when user whitelist status changes

event mTokenGateway_UserWhitelisted(address indexed user, bool status);

Parameters

NameTypeDescription
useraddressUser address
statusboolWhitelist status

mTokenGateway_WhitelistEnabled

Emitted when whitelist is enabled

event mTokenGateway_WhitelistEnabled();

mTokenGateway_WhitelistDisabled

Emitted when whitelist is disabled

event mTokenGateway_WhitelistDisabled();

Errors

mTokenGateway_ChainNotValid

Thrown when the chain id is not LINEA

error mTokenGateway_ChainNotValid();

mTokenGateway_AddressNotValid

Thrown when the address is not valid

error mTokenGateway_AddressNotValid();

mTokenGateway_AmountNotValid

Thrown when the amount specified is invalid (e.g., zero)

error mTokenGateway_AmountNotValid();

mTokenGateway_JournalNotValid

Thrown when the journal data provided is invalid

error mTokenGateway_JournalNotValid();

mTokenGateway_AmountTooBig

Thrown when there is insufficient cash to release the specified amount

error mTokenGateway_AmountTooBig();

mTokenGateway_ReleaseCashNotAvailable

Thrown when there is insufficient cash to release the specified amount

error mTokenGateway_ReleaseCashNotAvailable();

mTokenGateway_NonTransferable

Thrown when token is tranferred

error mTokenGateway_NonTransferable();

mTokenGateway_CallerNotAllowed

Thrown when caller is not allowed

error mTokenGateway_CallerNotAllowed();

mTokenGateway_Paused

Thrown when market is paused for operation type

error mTokenGateway_Paused(ImTokenOperationTypes.OperationType _type);

mTokenGateway_NotRebalancer

Thrown when caller is not rebalancer

error mTokenGateway_NotRebalancer();

mTokenGateway_LengthNotValid

Thrown when length is not valid

error mTokenGateway_LengthNotValid();

mTokenGateway_NotEnoughGasFee

Thrown when not enough gas fee was received

error mTokenGateway_NotEnoughGasFee();

mTokenGateway_L1InclusionRequired

Thrown when L1 inclusion is required

error mTokenGateway_L1InclusionRequired();

mTokenGateway_UserNotWhitelisted

Thrown when user is not whitelisted

error mTokenGateway_UserNotWhitelisted();

mTokenGateway_UserBlacklisted

Thrown when user is blacklisted

error mTokenGateway_UserBlacklisted();