# BridgeReceiver

Currently integrated with LayerZero v1, v2 and Stargate v1, v2.

***

An internal Replete contract which proxies all communications from [RepletePool](https://docs.replete.fi/contracts/repletepool) to the Pool contract on Pool Chain. A mapping of `bridgeModules` are stored in the contract which are [IBridgeModule](https://github.com/RepleteFinance/replete-protocol/blob/main/src/interfaces/IBridgeModule.sol) adapters, allowing to bridge assets from Pool Chain to any remote chain, most likely used by `{*AndBridgeVia*}` methods on [RepletePool](https://docs.replete.fi/contracts/repletepool).

Whilst the [BridgeReceiver](https://github.com/RepleteFinance/replete-protocol/blob/main/src/hosted/BridgeReceiver.sol) performs actions on behalf of the user, some safety features exist to protect user funds. All assets are supplied on behalf of the user, rather than the [BridgeReceiver](https://github.com/RepleteFinance/replete-protocol/blob/main/src/hosted/BridgeReceiver.sol) contract, so users are able to withdraw assets, in the case of an emergency, by withdrawing directly on the Pool contract. This also means that Replete is unable to directly create a borrow position on your behalf or withdraw your assets.

When you borrow through [RepletePool](https://docs.replete.fi/contracts/repletepool), you sign a credit delegation signature `bridgeDelegationData` which allows the [BridgeReceiver](https://github.com/RepleteFinance/replete-protocol/blob/main/src/hosted/BridgeReceiver.sol) contract to create a borrow position from your collateral for the amount you allowed. These signatures are one time use and expire if unused. This also prevents replay attacks if the underlying cross chain messaging service is compromised. Read more about [Borrowing Security](https://docs.replete.fi/developers/how-to-borrow#borrowing-security).

When you withdraw through [RepletePool](https://docs.replete.fi/contracts/repletepool), you sign a permit signature `permitSignature` which allows the [BridgeReceiver](https://github.com/RepleteFinance/replete-protocol/blob/main/src/hosted/BridgeReceiver.sol) contract to withdraw your assets for up to the amount you allowed. These signatures are one time use and expire if unused. This also prevents replay attacks if the underlying cross chain messaging service is compromised. Read more about [Withdrawing Security](https://docs.replete.fi/developers/how-to-withdraw#withdrawing-security).
