IFastBridgeV2

Git Source

Inherits: IFastBridge

Functions

bridge

Initiates bridge on origin chain to be relayed by off-chain relayer, with the ability to provide temporary exclusivity fill rights for the quote relayer.

function bridge(BridgeParams memory params, BridgeParamsV2 memory paramsV2) external payable;

Parameters

NameTypeDescription
paramsBridgeParamsThe parameters required to bridge
paramsV2BridgeParamsV2The parameters for exclusivity fill rights (optional, could be left empty)

relay

Relays destination side of bridge transaction by off-chain relayer

function relay(bytes memory request, address relayer) external payable;

Parameters

NameTypeDescription
requestbytesThe encoded bridge transaction to relay on destination chain
relayeraddressThe address of the relaying entity which should have control of the origin funds when claimed

prove

Provides proof on origin side that relayer provided funds on destination side of bridge transaction

function prove(bytes32 transactionId, bytes32 destTxHash, address relayer) external;

Parameters

NameTypeDescription
transactionIdbytes32The transaction id associated with the encoded bridge transaction to prove
destTxHashbytes32The destination tx hash proving bridge transaction was relayed
relayeraddressThe address of the relaying entity which should have control of the origin funds when claimed

claim

Completes bridge transaction on origin chain by claiming originally deposited capital.

Can only send funds to the relayer address on the proof.

function claim(bytes memory request) external;

Parameters

NameTypeDescription
requestbytesThe encoded bridge transaction to claim on origin chain

bridgeRelays

Checks if a transaction has been relayed

function bridgeRelays(bytes32 transactionId) external view returns (bool);

Parameters

NameTypeDescription
transactionIdbytes32The ID of the transaction to check

Returns

NameTypeDescription
<none>boolTrue if the transaction has been relayed, false otherwise

bridgeStatuses

Returns the status of a bridge transaction

function bridgeStatuses(bytes32 transactionId) external view returns (BridgeStatus);

Parameters

NameTypeDescription
transactionIdbytes32The ID of the bridge transaction

Returns

NameTypeDescription
<none>BridgeStatusBridgeStatus Status of the bridge transaction

bridgeProofs

Returns the timestamp and relayer of a bridge proof

function bridgeProofs(bytes32 transactionId) external view returns (uint96 timestamp, address relayer);

Parameters

NameTypeDescription
transactionIdbytes32The ID of the bridge transaction

Returns

NameTypeDescription
timestampuint96The timestamp of the bridge proof
relayeraddressThe relayer address of the bridge proof

getBridgeTransactionV2

Decodes bridge request into a bridge transaction V2 struct used by FastBridgeV2

function getBridgeTransactionV2(bytes memory request) external view returns (BridgeTransactionV2 memory);

Parameters

NameTypeDescription
requestbytesThe bridge request to decode

Events

BridgeQuoteDetails

event BridgeQuoteDetails(bytes32 indexed transactionId, bytes quoteId);

Structs

BridgeTxDetails

struct BridgeTxDetails {
    BridgeStatus status;
    uint40 proofBlockTimestamp;
    uint48 proofBlockNumber;
    address proofRelayer;
}

BridgeRelay

struct BridgeRelay {
    uint48 blockNumber;
    uint48 blockTimestamp;
    address relayer;
}

BridgeParamsV2

New params introduced in the FastBridgeV2. We are passing fields from the older BridgeParams struct outside of this struct for backwards compatibility. Note: quoteRelayer and quoteExclusivitySeconds are either both zero (indicating no exclusivity) or both non-zero (indicating exclusivity for the given period).

struct BridgeParamsV2 {
    address quoteRelayer;
    int256 quoteExclusivitySeconds;
    bytes quoteId;
    bytes callParams;
}

BridgeTransactionV2

Updated bridge transaction struct to include parameters introduced in FastBridgeV2. Note: only exclusivityRelayer can fill such a transaction until exclusivityEndTime. TODO: consider changing the encoding scheme to prevent spending extra gas on decoding.

struct BridgeTransactionV2 {
    uint32 originChainId;
    uint32 destChainId;
    address originSender;
    address destRecipient;
    address originToken;
    address destToken;
    uint256 originAmount;
    uint256 destAmount;
    uint256 originFeeAmount;
    bool sendChainGas;
    uint256 deadline;
    uint256 nonce;
    address exclusivityRelayer;
    uint256 exclusivityEndTime;
    bytes callParams;
}

Enums

BridgeStatus

enum BridgeStatus {
    NULL,
    REQUESTED,
    RELAYER_PROVED,
    RELAYER_CLAIMED,
    REFUNDED
}