ISettlementChainGateway

Git Source

Inherits: IMigratable, IRegistryParametersErrors

A SettlementChainGateway exposes the ability to send parameters to any app chain gateways, via their respective inboxes on the settlement chain.

Functions

initialize

Initializes the contract.

function initialize() external;

deposit

Deposits fee tokens as gas token to an app chain.

function deposit(uint256 chainId_, address recipient_, uint256 amount_, uint256 gasLimit_, uint256 maxFeePerGas_)
    external;

Parameters

NameTypeDescription
chainId_uint256The chain ID of the target app chain.
recipient_addressThe recipient of the tokens.
amount_uint256The amount of tokens to deposit.
gasLimit_uint256The gas limit for the transaction on the app chain.
maxFeePerGas_uint256The maximum fee per gas (EIP-1559) for the transaction on the app chain.

depositWithPermit

Deposits fee tokens as gas token to an app chain, given caller's signed approval.

function depositWithPermit(
    uint256 chainId_,
    address recipient_,
    uint256 amount_,
    uint256 gasLimit_,
    uint256 maxFeePerGas_,
    uint256 deadline_,
    uint8 v_,
    bytes32 r_,
    bytes32 s_
) external;

Parameters

NameTypeDescription
chainId_uint256The chain ID of the target app chain.
recipient_addressThe recipient of the tokens.
amount_uint256The amount of tokens to deposit.
gasLimit_uint256The gas limit for the transaction on the app chain.
maxFeePerGas_uint256The maximum fee per gas (EIP-1559) for the transaction on the app chain.
deadline_uint256The deadline of the permit (must be the current or future timestamp).
v_uint8An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
r_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
s_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).

depositFromUnderlying

Deposits fee tokens as gas token to an app chain, by wrapping underlying fee tokens.

function depositFromUnderlying(
    uint256 chainId_,
    address recipient_,
    uint256 amount_,
    uint256 gasLimit_,
    uint256 maxFeePerGas_
) external;

Parameters

NameTypeDescription
chainId_uint256The chain ID of the target app chain.
recipient_addressThe recipient of the tokens.
amount_uint256The amount of underlying fee tokens to deposit.
gasLimit_uint256The gas limit for the transaction on the app chain.
maxFeePerGas_uint256The maximum fee per gas (EIP-1559) for the transaction on the app chain.

depositFromUnderlyingWithPermit

Deposits fee tokens as gas token to an app chain, by wrapping underlying fee tokens, given caller's signed approval.

function depositFromUnderlyingWithPermit(
    uint256 chainId_,
    address recipient_,
    uint256 amount_,
    uint256 gasLimit_,
    uint256 maxFeePerGas_,
    uint256 deadline_,
    uint8 v_,
    bytes32 r_,
    bytes32 s_
) external;

Parameters

NameTypeDescription
chainId_uint256The chain ID of the target app chain.
recipient_addressThe recipient of the tokens.
amount_uint256The amount of underlying fee tokens to deposit.
gasLimit_uint256The gas limit for the transaction on the app chain.
maxFeePerGas_uint256The maximum fee per gas (EIP-1559) for the transaction on the app chain.
deadline_uint256The deadline of the permit (must be the current or future timestamp).
v_uint8An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
r_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
s_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).

sendParameters

Sends parameters to the app chain as retryable tickets (which may be a direct contract call).

This will perform an L2->L3 message, where the settlement gateway alias must have enough balance to pay for the function call (IAppChainGateway.receiveParameters), and the gas limit and price must suffice. If not, the message will remain as a retryable ticket on the app chain, that anyone can trigger and pay for.

amountToSend_ (converted to wei) must be greater or equal to the sum of gasLimit_ multiplied by maxFeePerGas_, plus the submission fee for the retryable ticket.

The total amount of fee tokens that will be pulled from the caller is chainIds_.length multiplied by amountToSend_ (which is returned as totalSent_).

function sendParameters(
    uint256[] calldata chainIds_,
    string[] calldata keys_,
    uint256 gasLimit_,
    uint256 maxFeePerGas_,
    uint256 amountToSend_
) external returns (uint256 totalSent_);

Parameters

NameTypeDescription
chainIds_uint256[]The chain IDs of the target app chains.
keys_string[]The keys of the parameters.
gasLimit_uint256The gas limit for the transaction on the app chain.
maxFeePerGas_uint256The maximum fee per gas (EIP-1559) for the transaction on the app chain.
amountToSend_uint256The amount of fee tokens that will be pulled by each inbox.

Returns

NameTypeDescription
totalSent_uint256The total amount of fee tokens sent to all app chains combined.

sendParametersWithPermit

Sends parameters to the app chain as retryable tickets (which may be a direct contract call), given caller's signed approval to pull fee tokens.

This will perform an L2->L3 message, where the settlement gateway alias must have enough balance to pay for the function call (IAppChainGateway.receiveParameters), and the gas limit and price must suffice. If not, the message will remain as a retryable ticket on the app chain, that anyone can trigger and pay for.

amountToSend_ (converted to wei) must be greater or equal to the sum of gasLimit_ multiplied by maxFeePerGas_, plus the submission fee for the retryable ticket.

The total amount of fee tokens that will be pulled from the caller is chainIds_.length multiplied by amountToSend_ (which is returned as totalSent_).

function sendParametersWithPermit(
    uint256[] calldata chainIds_,
    string[] calldata keys_,
    uint256 gasLimit_,
    uint256 maxFeePerGas_,
    uint256 amountToSend_,
    uint256 deadline_,
    uint8 v_,
    bytes32 r_,
    bytes32 s_
) external returns (uint256 totalSent_);

Parameters

NameTypeDescription
chainIds_uint256[]The chain IDs of the target app chains.
keys_string[]The keys of the parameters.
gasLimit_uint256The gas limit for the transaction on the app chain.
maxFeePerGas_uint256The maximum fee per gas (EIP-1559) for the transaction on the app chain.
amountToSend_uint256The amount of fee tokens that will be pulled by each inbox.
deadline_uint256The deadline of the permit (must be the current or future timestamp).
v_uint8An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
r_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
s_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).

Returns

NameTypeDescription
totalSent_uint256The total amount of fee tokens sent to all app chains combined.

sendParametersFromUnderlying

Sends parameters to the app chain as retryable tickets (which may be a direct contract call).

This will perform an L2->L3 message, where the settlement gateway alias must have enough balance to pay for the function call (IAppChainGateway.receiveParameters), and the gas limit and price must suffice. If not, the message will remain as a retryable ticket on the app chain, that anyone can trigger and pay for.

amountToSend_ (converted to wei) must be greater or equal to the sum of gasLimit_ multiplied by maxFeePerGas_, plus the submission fee for the retryable ticket.

The total amount of fee tokens that will be pulled from the caller is chainIds_.length multiplied by amountToSend_ (which is returned as totalSent_).

function sendParametersFromUnderlying(
    uint256[] calldata chainIds_,
    string[] calldata keys_,
    uint256 gasLimit_,
    uint256 maxFeePerGas_,
    uint256 amountToSend_
) external returns (uint256 totalSent_);

Parameters

NameTypeDescription
chainIds_uint256[]The chain IDs of the target app chains.
keys_string[]The keys of the parameters.
gasLimit_uint256The gas limit for the transaction on the app chain.
maxFeePerGas_uint256The maximum fee per gas (EIP-1559) for the transaction on the app chain.
amountToSend_uint256The amount of fee tokens to send with the call to fund the alias on each app chain, which will first be converted from underlying fee tokens.

Returns

NameTypeDescription
totalSent_uint256The total amount of fee tokens sent to all app chains combined.

sendParametersFromUnderlyingWithPermit

Sends parameters to the app chain as retryable tickets (which may be a direct contract call), given caller's signed approval to pull underlying fee tokens.

This will perform an L2->L3 message, where the settlement gateway alias must have enough balance to pay for the function call (IAppChainGateway.receiveParameters), and the gas limit and price must suffice. If not, the message will remain as a retryable ticket on the app chain, that anyone can trigger and pay for.

amountToSend_ (converted to wei) must be greater or equal to the sum of gasLimit_ multiplied by maxFeePerGas_, plus the submission fee for the retryable ticket.

The total amount of fee tokens that will be pulled from the caller is chainIds_.length multiplied by amountToSend_ (which is returned as totalSent_).

function sendParametersFromUnderlyingWithPermit(
    uint256[] calldata chainIds_,
    string[] calldata keys_,
    uint256 gasLimit_,
    uint256 maxFeePerGas_,
    uint256 amountToSend_,
    uint256 deadline_,
    uint8 v_,
    bytes32 r_,
    bytes32 s_
) external returns (uint256 totalSent_);

Parameters

NameTypeDescription
chainIds_uint256[]The chain IDs of the target app chains.
keys_string[]The keys of the parameters.
gasLimit_uint256The gas limit for the transaction on the app chain.
maxFeePerGas_uint256The maximum fee per gas (EIP-1559) for the transaction on the app chain.
amountToSend_uint256The amount of fee tokens to send with the call to fund the alias on each app chain, which will first be converted from underlying fee tokens.
deadline_uint256The deadline of the permit (must be the current or future timestamp).
v_uint8An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
r_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
s_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).

Returns

NameTypeDescription
totalSent_uint256The total amount of fee tokens sent to all app chains combined.

updateInbox

Updates the inbox for a chain ID.

function updateInbox(uint256 chainId_) external;

Parameters

NameTypeDescription
chainId_uint256The chain ID.

receiveWithdrawal

Receives withdrawal of fee tokens from the app chain gateway.

function receiveWithdrawal(address recipient_) external returns (uint256 amount_);

Parameters

NameTypeDescription
recipient_addressThe recipient of the tokens.

Returns

NameTypeDescription
amount_uint256The amount of fee tokens withdrawn.

receiveWithdrawalIntoUnderlying

Receives withdrawal of fee tokens from the app chain gateway, and unwraps them into underlying fee tokens.

function receiveWithdrawalIntoUnderlying(address recipient_) external returns (uint256 amount_);

Parameters

NameTypeDescription
recipient_addressThe recipient of the underlying fee tokens.

Returns

NameTypeDescription
amount_uint256The amount of fee tokens withdrawn.

updatePauseStatus

Updates the pause status.

Ensures the new pause status is not equal to the old pause status.

function updatePauseStatus() external;

inboxParameterKey

The parameter registry key used to fetch the inbox.

function inboxParameterKey() external pure returns (string memory key_);

migratorParameterKey

The parameter registry key used to fetch the migrator.

function migratorParameterKey() external pure returns (string memory key_);

pausedParameterKey

The parameter registry key used to fetch the paused status.

function pausedParameterKey() external pure returns (string memory key_);

parameterRegistry

The address of the parameter registry.

function parameterRegistry() external view returns (address parameterRegistry_);

appChainGateway

The address of the app chain gateway.

function appChainGateway() external view returns (address appChainGateway_);

appChainAlias

This contract's alias address on the L3 app chain.

function appChainAlias() external view returns (address appChainAlias_);

feeToken

The address of the fee token on the settlement chain, that is used to pay for gas on app chains.

function feeToken() external view returns (address feeToken_);

paused

The pause status.

function paused() external view returns (bool paused_);

calculateMaxDepositFee

Calculates the maximum fees (in wei, 18 decimals) that will be consumed for a deposit to an app chain.

function calculateMaxDepositFee(uint256 chainId_, uint256 gasLimit_, uint256 maxFeePerGas_, uint256 maxBaseFee_)
    external
    view
    returns (uint256 fees_);

Parameters

NameTypeDescription
chainId_uint256The chain ID of the target app chain.
gasLimit_uint256The gas limit for the transaction on the app chain.
maxFeePerGas_uint256The maximum fee per gas (EIP-1559) for the transaction on the app chain.
maxBaseFee_uint256The maximum base fee of the settlement chain, in wei (18 decimals).

Returns

NameTypeDescription
fees_uint256The maximum fees (in wei, 18 decimals) that will be consumed for a deposit to an app chain.

getInbox

The inbox address for a chain ID.

function getInbox(uint256 chainId_) external view returns (address inbox_);

Events

Deposit

Emitted when fee tokens have been sent to the app chain (becoming native gas token).

event Deposit(
    uint256 indexed chainId, uint256 indexed messageNumber, address indexed recipient, uint256 amount, uint256 maxFees
);

Parameters

NameTypeDescription
chainIduint256The chain ID of the target app chain.
messageNumberuint256The message number, unique per inbox.
recipientaddressThe recipient of the tokens on the app chain.
amountuint256The amount of tokens sent.
maxFeesuint256The maximum fees that will be consumed for the deposit.

ParametersSent

Emitted when parameters have been sent to the app chain.

event ParametersSent(uint256 indexed chainId, uint256 indexed messageNumber, uint256 nonce, string[] keys);

Parameters

NameTypeDescription
chainIduint256The chain ID of the target app chain.
messageNumberuint256The message number, unique per inbox.
nonceuint256The nonce of the parameter transmission (to prevent out-of-sequence resets).
keysstring[]The keys of the parameters.

InboxUpdated

Emitted when the inbox for a chain ID has been updated.

event InboxUpdated(uint256 indexed chainId, address indexed inbox);

Parameters

NameTypeDescription
chainIduint256The chain ID.
inboxaddressThe inbox address.

WithdrawalReceived

Emitted when fee tokens are withdrawn from the app chain.

event WithdrawalReceived(address indexed recipient, uint256 amount);

Parameters

NameTypeDescription
recipientaddressThe recipient of the tokens.
amountuint256The amount of tokens withdrawn.

PauseStatusUpdated

Emitted when the pause status is set.

event PauseStatusUpdated(bool indexed paused);

Parameters

NameTypeDescription
pausedboolThe new pause status.

Errors

ZeroParameterRegistry

Thrown when the parameter registry address is zero (i.e. address(0)).

error ZeroParameterRegistry();

ZeroAppChainGateway

Thrown when the app chain gateway address is zero (i.e. address(0)).

error ZeroAppChainGateway();

ZeroFeeToken

Thrown when the fee token address is zero (i.e. address(0)).

error ZeroFeeToken();

TransferFromFailed

Thrown when the ERC20.transferFrom call fails.

This is an identical redefinition of SafeTransferLib.TransferFromFailed.

error TransferFromFailed();

NoChainIds

Thrown when no chain IDs are provided.

error NoChainIds();

NoKeys

Thrown when no keys are provided.

error NoKeys();

UnsupportedChainId

Thrown when the chain ID is not supported.

error UnsupportedChainId(uint256 chainId);

Paused

Thrown when any pausable function is called when the contract is paused.

error Paused();

NoChange

Thrown when there is no change to an updated parameter.

error NoChange();

ZeroBalance

Thrown when the balance is zero.

error ZeroBalance();

ZeroAmount

Thrown when the amount is zero.

error ZeroAmount();

ZeroRecipient

Thrown when the recipient is zero (i.e. address(0)).

error ZeroRecipient();

InvalidFeeTokenDecimals

Thrown when the fee token decimals are greater than 18.

error InvalidFeeTokenDecimals();

InsufficientAmount

Thrown when the amount is insufficient to cover the max submission and transaction costs.

error InsufficientAmount(uint256 appChainAmount, uint256 maxTotalCosts);