IRebalancer

Git Source

Title: IRebalancer

Author: Merge Layers Inc.

Interface for rebalancer operations and configuration

Functions

sendMsg

Sends a bridge message

function sendMsg(address bridge, address _market, uint256 _amount, Msg calldata _msg) external payable;

Parameters

NameTypeDescription
bridgeaddressThe whitelisted bridge address
_marketaddressThe market to rebalance from address
_amountuint256The amount to rebalance
_msgMsgThe message data

nonce

Returns current nonce

function nonce() external view returns (uint256 currentNonce);

Returns

NameTypeDescription
currentNonceuint256Nonce value

isBridgeWhitelisted

Returns if a bridge implementation is whitelisted

function isBridgeWhitelisted(address bridge) external view returns (bool whitelisted);

Parameters

NameTypeDescription
bridgeaddressBridge address

Returns

NameTypeDescription
whitelistedboolTrue if whitelisted

isDestinationWhitelisted

Returns if a destination is whitelisted

function isDestinationWhitelisted(uint32 dstId) external view returns (bool whitelisted);

Parameters

NameTypeDescription
dstIduint32Destination chain ID

Returns

NameTypeDescription
whitelistedboolTrue if whitelisted

isMarketWhitelisted

Returns if a market is whitelisted

function isMarketWhitelisted(address market) external view returns (bool whitelisted);

Parameters

NameTypeDescription
marketaddressMarket address

Returns

NameTypeDescription
whitelistedboolTrue if whitelisted

Events

BridgeWhitelistedStatusUpdated

Emitted when bridge whitelist status changes

event BridgeWhitelistedStatusUpdated(address indexed bridge, bool status);

Parameters

NameTypeDescription
bridgeaddressBridge address
statusboolWhitelist status

MsgSent

Emitted when a message is sent through a bridge

event MsgSent(
    address indexed bridge, uint32 indexed dstChainId, address indexed token, bytes message, bytes bridgeData
);

Parameters

NameTypeDescription
bridgeaddressBridge address
dstChainIduint32Destination chain ID
tokenaddressToken address
messagebytesEncoded message
bridgeDatabytesBridge-specific data

EthSaved

Emitted when ETH is saved back to treasury

event EthSaved(uint256 amount);

Parameters

NameTypeDescription
amountuint256Amount saved

MaxTransferSizeUpdated

Emitted when max transfer size is updated

event MaxTransferSizeUpdated(uint32 indexed dstChainId, address indexed token, uint256 newLimit);

Parameters

NameTypeDescription
dstChainIduint32Destination chain ID
tokenaddressToken address
newLimituint256New limit

MinTransferSizeUpdated

Emitted when min transfer size is updated

event MinTransferSizeUpdated(uint32 indexed dstChainId, address indexed token, uint256 newLimit);

Parameters

NameTypeDescription
dstChainIduint32Destination chain ID
tokenaddressToken address
newLimituint256New limit

DestinationWhitelistedStatusUpdated

Emitted when destination whitelist status changes

event DestinationWhitelistedStatusUpdated(uint32 indexed dstChainId, bool status);

Parameters

NameTypeDescription
dstChainIduint32Destination chain ID
statusboolWhitelist status

AllowedListUpdated

Emitted when allowed list is updated

event AllowedListUpdated(address[] list, bool status);

Parameters

NameTypeDescription
listaddress[]List of addresses
statusboolWhitelist status

TokensSaved

Emitted when tokens are rescued

event TokensSaved(address indexed token, address indexed market, uint256 amount);

Parameters

NameTypeDescription
tokenaddressToken address
marketaddressMarket address
amountuint256Amount saved

AllowedTokensUpdated

Emitted when allowed tokens list is updated for a bridge

event AllowedTokensUpdated(address indexed bridge, bool status, address[] list);

Parameters

NameTypeDescription
bridgeaddressBridge address
statusboolWhitelist status
listaddress[]Token list

MarketListUpdated

Emitted when market list is updated

event MarketListUpdated(address[] list, bool status);

Parameters

NameTypeDescription
listaddress[]Market list
statusboolWhitelist status

Errors

Rebalancer_NotAuthorized

Error thrown when caller not authorized

error Rebalancer_NotAuthorized();

Rebalancer_MarketNotValid

Error thrown when market is not valid

error Rebalancer_MarketNotValid();

Rebalancer_RequestNotValid

Error thrown when request is not valid

error Rebalancer_RequestNotValid();

Rebalancer_AddressNotValid

Error thrown when address is not valid

error Rebalancer_AddressNotValid();

Rebalancer_BridgeNotWhitelisted

Error thrown when bridge is not whitelisted

error Rebalancer_BridgeNotWhitelisted();

Rebalancer_TransferSizeExcedeed

Error thrown when transfer size exceeds maximum

error Rebalancer_TransferSizeExcedeed();

Rebalancer_TransferSizeMinNotMet

Error thrown when transfer size below minimum

error Rebalancer_TransferSizeMinNotMet();

Rebalancer_DestinationNotWhitelisted

Error thrown when destination not whitelisted

error Rebalancer_DestinationNotWhitelisted();

Rebalancer_UnderlyingNotAllowedForBridge

Error thrown when underlying token not allowed for bridge

error Rebalancer_UnderlyingNotAllowedForBridge();

Structs

Msg

struct Msg {
    uint32 dstChainId;
    address token;
    bytes message;
    bytes bridgeData;
}