Skip to main content

CaliberMailbox

Git Source

Inherits: MakinaGovernable, ReentrancyGuardUpgradeable, BridgeController, ICaliberMailbox

State Variables

hubChainId

uint256 public immutable hubChainId;

CaliberMailboxStorageLocation

bytes32 private constant CaliberMailboxStorageLocation =
0xc8f2c10c9147366283b13eb82b7eca93d88636f13eec15d81ed4c6aa5006aa00;

Functions

_getCaliberStorage

function _getCaliberStorage() private pure returns (CaliberMailboxStorage storage $);

constructor

constructor(address _registry, uint256 _hubChainId) MakinaContext(_registry);

initialize

function initialize(IMakinaGovernable.MakinaGovernableInitParams calldata mgParams, address _hubMachine)
external
override
initializer;

onlyFactory

modifier onlyFactory();

caliber

Address of the associated caliber.

function caliber() external view override returns (address);

getHubBridgeAdapter

Returns the foreign address of the Hub bridge adapter for a given bridge ID.

function getHubBridgeAdapter(uint16 bridgeId) external view override returns (address);

Parameters

NameTypeDescription
bridgeIduint16The ID of the bridge.

getSpokeCaliberAccountingData

Returns the accounting data of the associated caliber.

function getSpokeCaliberAccountingData() external view override returns (SpokeCaliberAccountingData memory data);

Returns

NameTypeDescription
dataSpokeCaliberAccountingDataThe accounting data.

manageTransfer

Manages the transfer of tokens between a machine and a caliber. The transfer direction depends on the caller.

function manageTransfer(address token, uint256 amount, bytes calldata data) external override nonReentrant;

Parameters

NameTypeDescription
tokenaddressThe address of the token.
amountuint256The amount of tokens to transfer.
databytesABI-encoded parameters required for bridge-related transfers. Ignored for transfers between a machine and its hub caliber.

sendOutBridgeTransfer

Executes a scheduled outgoing bridge transfer.

function sendOutBridgeTransfer(uint16 bridgeId, uint256 transferId, bytes calldata data) external onlyOperator;

Parameters

NameTypeDescription
bridgeIduint16The ID of the bridge.
transferIduint256The ID of the transfer to execute.
databytesThe optional data needed to execute the transfer.

authorizeInBridgeTransfer

Registers a message hash as authorized for an incoming bridge transfer.

function authorizeInBridgeTransfer(uint16 bridgeId, bytes32 messageHash) external notRecoveryMode onlyMechanic;

Parameters

NameTypeDescription
bridgeIduint16The ID of the bridge.
messageHashbytes32The hash of the message to authorize.

claimInBridgeTransfer

Transfers a received bridge transfer out of the adapter.

function claimInBridgeTransfer(uint16 bridgeId, uint256 transferId) external onlyOperator;

Parameters

NameTypeDescription
bridgeIduint16The ID of the bridge.
transferIduint256The ID of the transfer to claim.

cancelOutBridgeTransfer

Cancels an outgoing bridge transfer.

function cancelOutBridgeTransfer(uint16 bridgeId, uint256 transferId) external onlyOperator;

Parameters

NameTypeDescription
bridgeIduint16The ID of the bridge.
transferIduint256The ID of the transfer to cancel.

setCaliber

Sets the associated caliber address.

function setCaliber(address _caliber) external override onlyFactory;

Parameters

NameTypeDescription
_caliberaddress

setHubBridgeAdapter

Registers a hub bridge adapter.

function setHubBridgeAdapter(uint16 bridgeId, address adapter) external restricted;

Parameters

NameTypeDescription
bridgeIduint16The ID of the bridge.
adapteraddressThe foreign address of the bridge adapter.

setOutTransferEnabled

Sets the outgoing transfer enabled status for a bridge.

function setOutTransferEnabled(uint16 bridgeId, bool enabled) external override onlyRiskManagerTimelock;

Parameters

NameTypeDescription
bridgeIduint16The ID of the bridge.
enabledboolTrue to enable outgoing transfer for the given bridge ID, false to disable.

setMaxBridgeLossBps

Sets the maximum allowed value loss in basis points for transfers via this bridge.

function setMaxBridgeLossBps(uint16 bridgeId, uint256 maxBridgeLossBps) external override onlyRiskManagerTimelock;

Parameters

NameTypeDescription
bridgeIduint16The ID of the bridge.
maxBridgeLossBpsuint256The maximum allowed value loss in basis points.

resetBridgingState

Resets internal bridge counters for a given token, and withdraw token balances held by all bridge adapters.

This function is intended to be used by the DAO to realign bridge accounting state and maintain protocol consistency, typically in response to operator deviations, external bridge discrepancies, or unbounded counter growth.

function resetBridgingState(address token) external override onlySecurityCouncil;

Parameters

NameTypeDescription
tokenaddressThe address of the token.

Structs

CaliberMailboxStorage

Note: storage-location: erc7201:makina.storage.CaliberMailbox

struct CaliberMailboxStorage {
address _hubMachine;
address _caliber;
mapping(uint16 bridgeId => address adapter) _hubBridgeAdapters;
EnumerableMap.AddressToUintMap _bridgesIn;
EnumerableMap.AddressToUintMap _bridgesOut;
}