BatchSubmitter
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
| Name | Type | Description |
|---|---|---|
_roles | address | The roles contract address |
_zkVerifier | address | The ZkVerifier contract address |
owner_ | address | The owner address |
updateZkVerifier
Updates IZkVerifier address
function updateZkVerifier(address _zkVerifier) external onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
_zkVerifier | address | the verifier address |
batchProcess
Execute multiple operations in a single transaction
function batchProcess(BatchProcessMsg calldata data) external;
Parameters
| Name | Type | Description |
|---|---|---|
data | BatchProcessMsg | The batch process message data |
_verifyProof
Verifies the proof using ZkVerifier
function _verifyProof(bytes calldata journalData, bytes calldata seal) private view;
Parameters
| Name | Type | Description |
|---|---|---|
journalData | bytes | The journal data to verify |
seal | bytes | The 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
| Name | Type | Description |
|---|---|---|
initHash | bytes32 | The initialization hash |
receiver | address | The receiver address |
mToken | address | The mToken address |
amount | uint256 | The amount |
minAmountOut | uint256 | The minimum amount out |
selector | bytes4 | The function selector |
reason | bytes | The failure reason |
BatchProcessSuccess
Event emitted when batch process succeeds
event BatchProcessSuccess(
bytes32 initHash, address receiver, address mToken, uint256 amount, uint256 minAmountOut, bytes4 selector
);
Parameters
| Name | Type | Description |
|---|---|---|
initHash | bytes32 | The initialization hash |
receiver | address | The receiver address |
mToken | address | The mToken address |
amount | uint256 | The amount |
minAmountOut | uint256 | The minimum amount out |
selector | bytes4 | The function selector |
ZkVerifierUpdated
Event emitted when ZkVerifier is updated
event ZkVerifierUpdated(address indexed oldVerifier, address indexed newVerifier);
Parameters
| Name | Type | Description |
|---|---|---|
oldVerifier | address | The old verifier address |
newVerifier | address | The 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
| Name | Type | Description |
|---|---|---|
receivers | address[] | Funds receivers |
journalData | bytes | Encoded journal data |
seal | bytes | Seal data for verification |
mTokens | address[] | Array of mToken addresses |
amounts | uint256[] | Array of amounts for each operation |
minAmountsOut | uint256[] | Array of minimum output amounts |
selectors | bytes4[] | Array of function selectors for each operation |
initHashes | bytes32[] | Array of initial hashes for journals |
startIndex | uint256 | Start index for processing journals |
userToLiquidate | address[] | Array of users to liquidate (for liquidateExternal operations) |
collateral | address[] | Array of collateral addresses (for liquidateExternal operations) |