Bridge Facet (0.8.4)

The Bridge Facet provides an alternative withdrawal pathway within SYMMIO by enabling users to transfer collateral directly to a trusted "bridge" address. This process bypasses the full cooldown period for withdrawals. Once transferred, the designated bridge sends the funds to the user's external wallet. After the cooldown period elapses, the bridge is allowed to withdraw the corresponding funds from SYMMIO. The bridge is responsible for ensuring that users comply with system regulations; if any non-compliant behavior is detected, the bridge transaction can be suspended and later restored with a validated amount.

Currently there are no bridges implemented on SYMMIO.


Overview

The Bridge Facet allows designated addresses—referred to as bridges—to facilitate expedited withdrawals. Users call the transferToBridge method to initiate a bridge transaction that moves funds from their SYMMIO balance to a bridge. Later, once the cooldown period has passed, the bridge may withdraw the funds. If any wrongdoing is detected, the bridge transaction can be suspended or later restored with a validated amount.


transferToBridge()

Description: Transfers a specified amount of collateral to a designated bridge address. This function bypasses the full cooldown period by immediately moving the requested withdrawal amount into a bridge transaction.

Function Signature:

function transferToBridge(uint256 amount, address bridgeAddress) external whenNotAccountingPaused notSuspended(msg.sender);

Parameters:

  • amount: The amount of collateral to transfer (specified in collateral decimals).

  • bridgeAddress: The address of the designated bridge. This address must be registered as a valid bridge within the system.

Returns:

  • A uint256 transaction ID representing the newly created bridge transaction.

Example:

// Transfer 50 tokens to the designated bridge address
uint256 transactionId = symmDiamond.transferToBridge(50, bridgeAddress);

Events Emitted:

  • TransferToBridge(address indexed sender, uint256 amount, address indexed bridgeAddress, uint256 transactionId)

The transactionId emitted from this is used to withdraw from the bridge.


withdrawReceivedBridgeValue()

Description: Allows the designated bridge to withdraw the funds from a specific bridge transaction after the required cooldown period has elapsed. This ensures that the funds can be forwarded to the user's external wallet.

Function Signature:

function withdrawReceivedBridgeValue(uint256 transactionId) external whenNotAccountingPaused notSuspended(msg.sender);

Parameters:

  • transactionId: The ID of the bridge transaction from which the funds will be withdrawn.

Example:

// Bridge withdraws funds from a specific transaction
symmDiamond.withdrawReceivedBridgeValue(transactionId);

Events Emitted:

  • WithdrawReceivedBridgeValue(uint256 indexed transactionId)


withdrawReceivedBridgeValues

Description: Allows the designated bridge to withdraw funds from multiple bridge transactions in a single call. All specified transactions must meet the cooldown and authorization requirements.

Function Signature:

function withdrawReceivedBridgeValues(uint256[] memory transactionIds) external whenNotAccountingPaused notSuspended(msg.sender);

Parameters:

  • transactionIds: An array of bridge transaction IDs for which the funds will be withdrawn.

Example:

// Withdraw funds for multiple transactions
uint256[] memory txIds = new uint256[](2);
txIds[0] = firstTransactionId;
txIds[1] = secondTransactionId;
symmDiamond.withdrawReceivedBridgeValues(txIds);

Events Emitted:

  • WithdrawReceivedBridgeValues(uint256[] transactionIds)


suspendBridgeTransaction

Description: Suspends a specific bridge transaction. This function is used to halt a withdrawal if suspicious behavior is detected, thereby preventing the bridge from withdrawing the funds.

Function Signature:

function suspendBridgeTransaction(uint256 transactionId) external onlyRole(LibAccessibility.SUSPENDER_ROLE);

Parameters:

  • transactionId: The ID of the bridge transaction to be suspended.

Example:

// Suspend a bridge transaction due to detected irregularities
symmDiamond.suspendBridgeTransaction(transactionId);

Events Emitted:

  • SuspendBridgeTransaction(uint256 indexed transactionId)


restoreBridgeTransaction

Description: Restores a previously suspended bridge transaction and updates its valid withdrawal amount. This function is typically called after a dispute resolution or verification process confirms that part of the transaction is valid.

Function Signature:

function restoreBridgeTransaction(uint256 transactionId, uint256 validAmount) external onlyRole(LibAccessibility.DISPUTE_ROLE);

Parameters:

  • transactionId: The ID of the suspended bridge transaction.

  • validAmount: The validated amount that will be associated with the restored transaction (must be less than or equal to the original amount).

Example:

// Restore a suspended bridge transaction with a validated amount of 40 tokens
symmDiamond.restoreBridgeTransaction(transactionId, 40);

Events Emitted:

  • RestoreBridgeTransaction(uint256 indexed transactionId, uint256 validAmount)


This documentation provides a clear, modular overview of all functions exposed by the Bridge Facet. Each section includes detailed descriptions, usage examples with code snippets, parameter lists, and the events emitted by the function. This format is intended to assist developers in effectively integrating and interacting with the Bridge Facet within the SYMM protocol.

Last updated