BatchSubmitter

Git Source

Inherits: Ownable

Title: BatchSubmitter

Author: Merge Layers Inc.

Contract for batch processing multiple operations

State Variables

MINT_SELECTOR

The function selector for the supported mintExternal operation

bytes4 internal constant MINT_SELECTOR = ImErc20Host.mintExternal.selector

REPAY_SELECTOR

The function selector for the supported repayExternal operation

bytes4 internal constant REPAY_SELECTOR = ImErc20Host.repayExternal.selector

OUT_HERE_SELECTOR

The function selector for the supported outHere operation

bytes4 internal constant OUT_HERE_SELECTOR = ImTokenGateway.outHere.selector

LIQUIDATE_SELECTOR

The function selector for the supported liquidateExternal operation

bytes4 internal constant LIQUIDATE_SELECTOR = ImErc20Host.liquidateExternal.selector

ROLES_OPERATOR

The roles contract for access control

IRoles public immutable ROLES_OPERATOR

verifier

The ZkVerifier contract

IZkVerifier public verifier

Functions

constructor

Constructor

constructor(address _roles, address _zkVerifier, address owner_) Ownable(owner_);

Parameters

NameTypeDescription
_rolesaddressThe roles contract address
_zkVerifieraddressThe ZkVerifier contract address
owner_addressThe owner address

updateZkVerifier

Updates IZkVerifier address

function updateZkVerifier(address _zkVerifier) external onlyOwner;

Parameters

NameTypeDescription
_zkVerifieraddressthe verifier address

batchProcess

Execute multiple operations in a single transaction

function batchProcess(BatchProcessMsg calldata data) external;

Parameters

NameTypeDescription
dataBatchProcessMsgThe batch process message data

_verifyProof

Verifies the proof using ZkVerifier

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

Parameters

NameTypeDescription
journalDatabytesThe journal data to verify
sealbytesThe seal data for verification

Events

BatchProcessFailed

Event emitted when batch process fails

event BatchProcessFailed(
    bytes32 initHash,
    address receiver,
    address mToken,
    uint256 amount,
    uint256 minAmountOut,
    bytes4 selector,
    bytes reason
);

Parameters

NameTypeDescription
initHashbytes32The initialization hash
receiveraddressThe receiver address
mTokenaddressThe mToken address
amountuint256The amount
minAmountOutuint256The minimum amount out
selectorbytes4The function selector
reasonbytesThe failure reason

BatchProcessSuccess

Event emitted when batch process succeeds

event BatchProcessSuccess(
    bytes32 initHash, address receiver, address mToken, uint256 amount, uint256 minAmountOut, bytes4 selector
);

Parameters

NameTypeDescription
initHashbytes32The initialization hash
receiveraddressThe receiver address
mTokenaddressThe mToken address
amountuint256The amount
minAmountOutuint256The minimum amount out
selectorbytes4The function selector

ZkVerifierUpdated

Event emitted when ZkVerifier is updated

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

Parameters

NameTypeDescription
oldVerifieraddressThe old verifier address
newVerifieraddressThe new verifier address

Errors

BatchSubmitter_CallerNotAllowed

Error thrown when caller is not allowed

error BatchSubmitter_CallerNotAllowed();

BatchSubmitter_JournalNotValid

Error thrown when journal is not valid

error BatchSubmitter_JournalNotValid();

BatchSubmitter_InvalidSelector

Error thrown when selector is invalid

error BatchSubmitter_InvalidSelector();

BatchSubmitter_AddressNotValid

Error thrown when address is not valid

error BatchSubmitter_AddressNotValid();

Structs

BatchProcessMsg

Parameters used to process a batch of operations

struct BatchProcessMsg {
    address[] receivers;
    bytes journalData;
    bytes seal;
    address[] mTokens;
    uint256[] amounts;
    uint256[] minAmountsOut;
    bytes4[] selectors;
    bytes32[] initHashes;
    uint256 startIndex;
    address[] userToLiquidate;
    address[] collateral;
}

Properties

NameTypeDescription
receiversaddress[]Funds receivers
journalDatabytesEncoded journal data
sealbytesSeal data for verification
mTokensaddress[]Array of mToken addresses
amountsuint256[]Array of amounts for each operation
minAmountsOutuint256[]Array of minimum output amounts
selectorsbytes4[]Array of function selectors for each operation
initHashesbytes32[]Array of initial hashes for journals
startIndexuint256Start index for processing journals
userToLiquidateaddress[]Array of users to liquidate (for liquidateExternal operations)
collateraladdress[]Array of collateral addresses (for liquidateExternal operations)