IBridgeAdapter
Functions
initialize
Initializer of the contract.
function initialize(address controller, bytes calldata initData) external;
Parameters
Name | Type | Description |
---|---|---|
controller | address | The bridge controller contract. |
initData | bytes | The optional initialization data. |
controller
Address of the bridge controller contract.
function controller() external view returns (address);
bridgeId
ID of the adapted external bridge.
function bridgeId() external view returns (uint16);
approvalTarget
Address of the external bridge approval target contract.
function approvalTarget() external view returns (address);
executionTarget
Address of the external bridge execution target contract.
function executionTarget() external view returns (address);
receiveSource
Address of the external bridge contract responsible for sending output funds.
function receiveSource() external view returns (address);
nextOutTransferId
ID of the next outgoing transfer.
function nextOutTransferId() external view returns (uint256);
nextInTransferId
ID of the next incoming transfer.
function nextInTransferId() external view returns (uint256);
scheduleOutBridgeTransfer
Schedules an outgoing bridge transfer and returns the message hash.
Emits an event containing the id of the transfer and the hash of the bridge transfer message.
function scheduleOutBridgeTransfer(
uint256 destinationChainId,
address recipient,
address inputToken,
uint256 inputAmount,
address outputToken,
uint256 minOutputAmount
) external;
Parameters
Name | Type | Description |
---|---|---|
destinationChainId | uint256 | The ID of the destination chain. |
recipient | address | The address of the recipient on the destination chain. |
inputToken | address | The address of the input token. |
inputAmount | uint256 | The amount of the input token to transfer. |
outputToken | address | The address of the output token on the destination chain. |
minOutputAmount | uint256 | The minimum amount of the output token to receive. |
sendOutBridgeTransfer
Executes a scheduled outgoing bridge transfer.
function sendOutBridgeTransfer(uint256 transferId, bytes calldata data) external;
Parameters
Name | Type | Description |
---|---|---|
transferId | uint256 | The ID of the transfer to execute. |
data | bytes | The optional data needed to execute the transfer. |
outBridgeTransferCancelDefault
Returns the default amount that must be transferred to the adapter to cancel an outgoing bridge transfer.
If the transfer has not yet been sent, or if the full amount was refunded to this contract by the external bridge, returns 0.
If the bridge retains a fee upon cancellation and only a partial refund was received, the returned value reflects that fee.
In all other cases (e.g. including pending refunds or successful bridge transfers), returns the full amount of the transfer.
function outBridgeTransferCancelDefault(uint256 transferId) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
transferId | uint256 | The ID of the transfer to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount required to cancel the transfer. |
cancelOutBridgeTransfer
Cancels an outgoing bridge transfer.
function cancelOutBridgeTransfer(uint256 transferId) external;
Parameters
Name | Type | Description |
---|---|---|
transferId | uint256 | The ID of the transfer to cancel. |
authorizeInBridgeTransfer
Registers a message hash as authorized for an incoming bridge transfer.
function authorizeInBridgeTransfer(bytes32 messageHash) external;
Parameters
Name | Type | Description |
---|---|---|
messageHash | bytes32 | The hash of the message to authorize. |
claimInBridgeTransfer
Transfers a received bridge transfer out of the adapter.
function claimInBridgeTransfer(uint256 transferId) external;
Parameters
Name | Type | Description |
---|---|---|
transferId | uint256 | The ID of the transfer to claim. |
withdrawPendingFunds
Resets internal state for a given token address, and transfers token balance to associated controller.
This function is intended to be used by the DAO to unlock funds stuck in the adapter, typically in response to operator deviations or external bridge discrepancies.
function withdrawPendingFunds(address token) external;
Parameters
Name | Type | Description |
---|---|---|
token | address | The address of the token. |
Events
InBridgeTransferAuthorized
event InBridgeTransferAuthorized(bytes32 indexed messageHash);
OutBridgeTransferCancelled
event OutBridgeTransferCancelled(uint256 indexed transferId);
InBridgeTransferClaimed
event InBridgeTransferClaimed(uint256 indexed transferId);
InBridgeTransferReceived
event InBridgeTransferReceived(uint256 indexed transferId);
OutBridgeTransferSent
event OutBridgeTransferSent(uint256 indexed transferId);
OutBridgeTransferScheduled
event OutBridgeTransferScheduled(uint256 indexed transferId, bytes32 indexed messageHash);
PendingFundsWithdrawn
event PendingFundsWithdrawn(address indexed token, uint256 amount);
Structs
OutBridgeTransfer
struct OutBridgeTransfer {
address recipient;
uint256 destinationChainId;
address inputToken;
uint256 inputAmount;
address outputToken;
uint256 minOutputAmount;
bytes encodedMessage;
}
InBridgeTransfer
struct InBridgeTransfer {
address sender;
uint256 originChainId;
address inputToken;
uint256 inputAmount;
address outputToken;
uint256 outputAmount;
}
BridgeMessage
struct BridgeMessage {
uint256 outTransferId;
address sender;
address recipient;
uint256 originChainId;
uint256 destinationChainId;
address inputToken;
uint256 inputAmount;
address outputToken;
uint256 minOutputAmount;
}