# Bridge Facet

The Bridge Facet handles the transfer of collateral to and from registered bridge addresses. It allows users to send funds to a bridge for cross-chain movement and to claim funds received from a bridge on the destination chain. Administrators can suspend and restore bridge transactions for dispute resolution. The underlying logic is implemented in the `BridgeFacetImpl` library.

{% hint style="info" %}
In v0.8.5, the Bridge Facet is retained alongside the new Withdraw System (see WithdrawFacet). The new withdraw system introduces a multi-provider architecture with express and virtual providers for cross-chain withdrawals and instant payouts. The Bridge Facet serves as the direct bridge transfer mechanism, while the WithdrawFacet handles the broader cooldown-based withdrawal flows with provider integration.
{% endhint %}

### Overview

The Bridge Facet provides the following key functionalities:

* **Transfer to Bridge:** Users send collateral from their protocol balance to a registered bridge address, initiating a cross-chain transfer.
* **Withdraw Received Bridge Value:** Users claim funds that have arrived via a bridge transaction on the destination chain.
* **Transaction Suspension:** A suspender role can freeze suspicious bridge transactions pending investigation.
* **Transaction Restoration:** A dispute role can restore suspended transactions with a validated amount, resolving disputes.

***

### transferToBridge()

Transfers a specified amount of collateral from the caller's balance to a registered bridge address.

**Function Signature:**

```solidity
function transferToBridge(uint256 amount, address bridgeAddress) external whenNotAccountingPaused notSuspended(signer);
```

**Parameters:**

* `amount`: The amount to transfer (in collateral decimals).
* `bridgeAddress`: The address of the registered bridge to receive the funds.

**Example:**

```solidity
// Transfer 500 tokens to a bridge for cross-chain movement
symmioDiamond.transferToBridge(500, bridgeAddress);
```

**Events Emitted:**

* `TransferToBridge(address sender, uint256 amount, address bridgeAddress, uint256 transactionId)`

***

### withdrawReceivedBridgeValue()

Claims the funds associated with a specific bridge transaction that has been received on this chain.

**Function Signature:**

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

**Parameters:**

* `transactionId`: The ID of the bridge transaction to claim.

**Example:**

```solidity
// Claim funds from a completed bridge transaction
symmioDiamond.withdrawReceivedBridgeValue(transactionId);
```

**Events Emitted:**

* `WithdrawReceivedBridgeValue(uint256 transactionId)`

***

### withdrawReceivedBridgeValues()

Claims funds from multiple bridge transactions in a single call.

**Function Signature:**

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

**Parameters:**

* `transactionIds`: An array of bridge transaction IDs to claim.

**Events Emitted:**

* `WithdrawReceivedBridgeValues(uint256[] transactionIds)`

***

### suspendBridgeTransaction()

Suspends a specific bridge transaction, freezing it pending investigation. Only callable by the suspender role.

**Function Signature:**

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

**Parameters:**

* `transactionId`: The ID of the bridge transaction to suspend.

**Access:** Requires `SUSPENDER_ROLE`.

**Events Emitted:**

* `SuspendBridgeTransaction(uint256 transactionId)`

***

### restoreBridgeTransaction()

Restores a previously suspended bridge transaction with a validated amount. This resolves a dispute by confirming the correct transfer amount, which may differ from the originally reported amount.

**Function Signature:**

```solidity
function restoreBridgeTransaction(uint256 transactionId, uint256 validAmount) external onlyRole(DISPUTE_ROLE);
```

**Parameters:**

* `transactionId`: The ID of the suspended bridge transaction to restore.
* `validAmount`: The validated amount to associate with the restored transaction.

**Access:** Requires `DISPUTE_ROLE`.

**Events Emitted:**

* `RestoreBridgeTransaction(uint256 transactionId, uint256 validAmount)`
