ILZCrossChainBridge
Title: ILZCrossChainBridge
Interface for the LZ Cross-Chain Bridge facilitator, the user-facing entry point for sending OHM to other chains via LayerZero V2.
It is a periphery contract, as it does not require any privileged access to the Olympus protocol. It transfers OHM from the user to the gateway, which handles burning and sending.
Functions
sendOhm
Sends OHM to a destination chain via the gateway.
The user must approve this contract for the OHM amount before calling. OHM is transferred from the user to the gateway, then the gateway burns and sends via LayerZero. The caller must send the native token with the call to cover the LayerZero messaging fee; excess is refunded to msg.sender. Use estimateSendFee() to determine the required fee.
function sendOhm(uint32 dstEid_, address to_, uint256 amount_) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
| dstEid_ | uint32 | The LayerZero destination endpoint ID. |
| to_ | address | The recipient address on the destination chain. |
| amount_ | uint256 | The amount of OHM to send. |
setGateway
Sets the gateway address.
Only callable by the address pinned in configurator, which is expected to be
an LZBridgeAndDelegateConfig instance (the timelock policy).
function setGateway(address gateway_) external;
Parameters
| Name | Type | Description |
|---|---|---|
| gateway_ | address | The new gateway address. |
setReEnabler
Sets the address authorized to call reEnable().
Only callable by the address pinned in configurator, which is expected to be
an LZBridgeAndDelegateConfig instance (the timelock policy). The zero address
is permitted and effectively disables the reEnable() entry point until a
non-zero address is set.
function setReEnabler(address reEnabler_) external;
Parameters
| Name | Type | Description |
|---|---|---|
| reEnabler_ | address | The new re-enabler address, or address(0) to clear. |
setConfigurator
Sets the configurator address.
Bootstrap: when configurator is the zero address, only the owner may set the
first non-zero configurator. After bootstrap, rotation is only allowed by the
current configurator. The configurator is expected to be an
LZBridgeAndDelegateConfig instance (the timelock policy).
In both cases the new configurator must implement ILZBridgeAndDelegateConfig
via ERC-165 to prevent the bridge from being bricked by an incompatible address.
function setConfigurator(address newConfigurator_) external;
Parameters
| Name | Type | Description |
|---|---|---|
| newConfigurator_ | address | The new configurator address. |
validateSetGateway
Validates the payload that would be passed to setGateway.
Mirrors the input invariants enforced by setGateway so that callers (for
instance, a timelock policy) can fail early at queue time rather than at
execution time.
function validateSetGateway(address gateway_) external pure;
Parameters
| Name | Type | Description |
|---|---|---|
| gateway_ | address | The candidate gateway address. |
validateSetConfigurator
Validates the payload that would be passed to setConfigurator.
Mirrors the payload invariants enforced by setConfigurator: the zero-address
check and the ERC-165 ILZBridgeAndDelegateConfig guard.
function validateSetConfigurator(address newConfigurator_) external view;
Parameters
| Name | Type | Description |
|---|---|---|
| newConfigurator_ | address | The candidate configurator address. |
gateway
Returns the LZBridgeGateway address.
function gateway() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
reEnabler
Returns the address authorized to call reEnable().
Returns address(0) when no re-enabler has been configured.
function reEnabler() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
configurator
Returns the configurator address (an LZBridgeAndDelegateConfig instance).
Returns address(0) before the owner has performed the bootstrap call.
function configurator() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
OHM
Returns the OHM token address.
function OHM() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
estimateSendFee
Estimates the fee for sending OHM to a destination chain.
function estimateSendFee(
uint32 dstEid_,
address to_,
uint256 amount_
) external view returns (MessagingFee memory fee);
Parameters
| Name | Type | Description |
|---|---|---|
| dstEid_ | uint32 | The LayerZero destination endpoint ID. |
| to_ | address | The recipient address on the destination chain. |
| amount_ | uint256 | The amount of OHM to send. |
Returns
| Name | Type | Description |
|---|---|---|
| fee | MessagingFee | The estimated messaging fee (native + lzToken (unused)). |
sendable
Returns the current outbound capacity for a destination endpoint, with the in-flight amount decayed against the current timestamp.
function sendable(uint32 dstEid_) external view returns (uint256 inFlight, uint256 available);
Parameters
| Name | Type | Description |
|---|---|---|
| dstEid_ | uint32 | The LayerZero destination endpoint ID. |
Returns
| Name | Type | Description |
|---|---|---|
| inFlight | uint256 | The decayed outbound in-flight amount at the current timestamp. |
| available | uint256 | The amount that may still be sent to the destination before the outbound rate limit is exceeded. |
receivable
Returns the current inbound capacity for a source endpoint, with the in-flight amount decayed against the current timestamp.
function receivable(uint32 srcEid_) external view returns (uint256 inFlight, uint256 available);
Parameters
| Name | Type | Description |
|---|---|---|
| srcEid_ | uint32 | The LayerZero source endpoint ID. |
Returns
| Name | Type | Description |
|---|---|---|
| inFlight | uint256 | The decayed inbound in-flight amount at the current timestamp. |
| available | uint256 | The amount that may still be received from the source before the inbound rate limit is exceeded. |
Events
Bridged
Emitted when OHM is sent to another chain.
event Bridged(
address indexed sender,
uint256 amount,
uint32 indexed dstEid,
uint256 nativeFee,
uint256 msgValue
);
Parameters
| Name | Type | Description |
|---|---|---|
| sender | address | The address that initiated the bridge transfer. |
| amount | uint256 | The amount of OHM bridged. |
| dstEid | uint32 | The LayerZero destination endpoint ID. |
| nativeFee | uint256 | The native token fee actually charged by LayerZero, read fromMessagingReceipt. May be less than msgValue when the caller overpays;the excess is refunded to the sender by the LayerZero endpoint. |
| msgValue | uint256 | The native value the caller supplied with the transaction. |
GatewaySet
Emitted when the gateway address is updated.
event GatewaySet(address indexed gateway);
Parameters
| Name | Type | Description |
|---|---|---|
| gateway | address | The new gateway address. |
ReEnablerSet
Emitted when the re-enabler address is updated.
Setting the re-enabler to the zero address effectively disables the
reEnable() entry point until a non-zero address is configured again.
event ReEnablerSet(address indexed reEnabler);
Parameters
| Name | Type | Description |
|---|---|---|
| reEnabler | address | The new re-enabler address, or address(0) to clear. |
ConfiguratorSet
Emitted when the configurator address is updated.
event ConfiguratorSet(address indexed configurator);
Parameters
| Name | Type | Description |
|---|---|---|
| configurator | address | The new configurator address. |
Errors
LZCrossChainBridge_InvalidAddress
Thrown when an address argument is the zero address.
error LZCrossChainBridge_InvalidAddress(string parameter);
Parameters
| Name | Type | Description |
|---|---|---|
| parameter | string | The name of the invalid parameter. |
LZCrossChainBridge_InsufficientAmount
Thrown when the send amount is zero.
error LZCrossChainBridge_InsufficientAmount();
LZCrossChainBridge_InvalidConfigurator
Thrown when setConfigurator is supplied a contract that does not implement the
ILZBridgeAndDelegateConfig interface via ERC-165.
error LZCrossChainBridge_InvalidConfigurator(address newConfigurator);
Parameters
| Name | Type | Description |
|---|---|---|
| newConfigurator | address | The unsupported new configurator address. |