# 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.

{% hint style="info" %}
Currently there are no bridges implemented on SYMMIO.
{% endhint %}

***

### 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:**

```solidity
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:**

```solidity
// 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)`

{% hint style="info" %}
The `transactionId` emitted from this is used to withdraw from the bridge.
{% endhint %}

***

### 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:**

```solidity
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:**

```solidity
// 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:**

```solidity
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:**

```solidity
// 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:**

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

**Parameters:**

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

**Example:**

```solidity
// 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:**

```solidity
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:**

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

**Events Emitted:**

* `RestoreBridgeTransaction(uint256 indexed transactionId, uint256 validAmount`
