# Deposit Locker

The **Deposit Locker** is a singleton contract that holds deposits on the source chain and handles the bridging of deposits to the destination chain. It receives inflows of deposits from [**Royco Recipe IAMs**](/more/cross-chain-deposit-module-ccdm/ccdm-recipe-iams.md) on the source chain and bridges outflows of deposits to the [**Deposit Executor**](/more/cross-chain-deposit-module-ccdm/deposit-executor.md) on the destination chain. Here is a rundown on how the **Deposit Locker** functions:

## Deposits

* Whenever an offer is filled in a [**CCDM enabled market**](/more/cross-chain-deposit-module-ccdm/ccdm-recipe-iams.md), funds are automatically deposited by the AP's Weiroll Wallet into the **Deposit Locker**.&#x20;
* Deposits are held by the **Deposit Locker** until they are bridged or withdrawn.

## Withdrawals

* [**Merkle Deposit Recipe IAMs**](/more/cross-chain-deposit-module-ccdm/ccdm-recipe-iams.md#merkle-deposit-recipe-iams)
  * Withdrawals are not enabled by default
    * In the rare case that they are needed,  the [**Deposit Locker Owner**](/more/cross-chain-deposit-module-ccdm/deposit-locker.md#deposit-locker-owner) can eternally halt all deposits and bridges for the market and enable withdrawals.&#x20;
    * Then `executeWithdrawalScript()` can be called after the Weioll Wallet's locktime has elapsed.
      * Sends the deposit amount back to the AP.
      * Does not forfeit any incentives.
* [**Individual Deposit Recipe IAMs**](/more/cross-chain-deposit-module-ccdm/ccdm-recipe-iams.md#individual-deposit-recipe-iams)
  * Withdrawals are enabled by default
  * Depositors can withdraw their deposits on a Weiroll Wallet specific basis from the **Deposit Locker** in one of two scenarios:
    1. Calling `forfeit()` in the case of forfeitable IAMs through the [**Recipe Market Hub**](/for-incentive-providers/contract-addresses.md#ethereum).
       1. This will forfeit any incentives allocated to the depositor and automatically trigger the withdrawal recipe: sending the original deposit amount back to the AP.
    2. Calling  `executeWithdrawalScript()` after the Weioll Wallet's locktime has elapsed.
       1. This will happen in the rare case that the deposit made by the Weiroll Wallet was not bridged to the[ **Deposit Executor** ](/more/cross-chain-deposit-module-ccdm/deposit-executor.md)before the Weiroll Wallet's unlock timestamp has passed.
       2. Sends the deposit amount back to the AP.
       3. Does not forfeit any incentives.
* **Note: Deposits cannot be withdrawn from the source chain once they are bridged. They must be withdrawn from the** [**Deposit Executor**](/more/cross-chain-deposit-module-ccdm/deposit-executor.md) **after the campaign's unlock timestamp has passed on the destination chain.**

## Bridging Deposits

* Bridging deposits from the **Deposit Locker** to the [**Deposit Executor**](/more/cross-chain-deposit-module-ccdm/deposit-executor.md) is facilitated by [**LayerZero V2**](https://docs.layerzero.network/v2)
  * All tokens are bridged using LZ V2's [**OFT standard**](https://docs.layerzero.network/v2/home/token-standards/oft-standard).
* Deposits for a particular market are bridgeable by the [**Market Owner**](#market-owners) once the rage quit period has elapsed after the [**Green Lighter**](#green-lighter) gives their green light.
  * The **rage quit period**
    * This duration gives ample time for depositors to withdraw from a market if they change their mind, or they deem the destination action logic to be malicious.
* [**Merkle Deposit Recipe IAMs**](/more/cross-chain-deposit-module-ccdm/ccdm-recipe-iams.md#merkle-deposit-recipe-iams)
  * The [**Deposit Locker**](/more/cross-chain-deposit-module-ccdm/deposit-locker.md) exposes these functions to bridge deposits for Merkle Deposit Markets:
    * [**Bridging Single Tokens**](/more/cross-chain-deposit-module-ccdm/token-support.md#single-tokens)**:** `merkleBridgeSingleTokens()`
    * [**Bridging UNI V2 LP Tokens**](/more/cross-chain-deposit-module-ccdm/token-support.md#uniswap-v2-lp-tokens)**:** `merkleBridgeLpTokens()`
* [**Individual Deposit Recipe IAMs**](/more/cross-chain-deposit-module-ccdm/ccdm-recipe-iams.md#individual-deposit-recipe-iams)
  * The [**Deposit Locker**](/more/cross-chain-deposit-module-ccdm/deposit-locker.md) exposes these functions to bridge deposits for Individual Deposit Markets:
    * [**Bridging Single Tokens**](/more/cross-chain-deposit-module-ccdm/token-support.md#single-tokens)**:**  `bridgeSingleTokens()`
    * [**Bridging UNI V2 LP Tokens**](/more/cross-chain-deposit-module-ccdm/token-support.md#uniswap-v2-lp-tokens)**:** `bridgeLpTokens()`

## Administrative Roles

### **Deposit Locker Owner**

1. Sets the LayerZero V2 endpoint for the source chain.
2. Sets the LayerZero EID (Endpoint ID) for **the destination chain**.
3. Sets the address of the [**Deposit Executor**](/more/cross-chain-deposit-module-ccdm/deposit-executor.md) on **the destination chain**.
4. Sets the wrapped native asset token (i.e. WETH) for the source chain.
5. Sets the [**Royco Recipe Market Hub**](/for-incentive-providers/contract-addresses.md#ethereum) address for the source chain.
6. Sets the Uniswap V2 Router for the source chain.
7. Sets the OFT entrypoint (Stargate Pools/Hydra, OFT adapters, etc.) for each supported token.
8. Sets the [**Campaign Owner**](#campaign-owners) (IP / Party responsible for bridging deposits) for each market.&#x20;
9. Delegates a [**Green Lighter** ](#green-lighter)to flag when deposits are bridgeable for each market.
10. Sets the base gas limit passed to lzReceive on the destination chain when bridging funds. This will be added to whatever gas the OFT passes by default if it has enforced options set for lzReceive.
11. In the rare case that deposits and bridging need to be permanently disabled for a market, they can halt the market.

### **Green Lighter**

1. Maintains a holistic view of the entire system (Deposit Locker and Deposit Executor).
2. Green light markets - rendering their deposits bridgeable after the Rage Quit duration has elapsed (if applicable).
   1. Green lighting should only be done once the destination campaign's deposit recipe and parameters have been thoroughly verified and tested/simulated.

### **Campaign Owners**

1. This role is played by the same party as the [**Campaign Owner**](/more/cross-chain-deposit-module-ccdm/deposit-executor.md#campaign-owners) in the [**Deposit Executor**](/more/cross-chain-deposit-module-ccdm/deposit-executor.md).&#x20;
2. Responsible for bridging deposits for their respective markets.
3. For [**UNI V2 LP token**](/more/cross-chain-deposit-module-ccdm/token-support.md#uniswap-v2-lp-tokens) markets, the owner is also responsible for setting minimum amounts redeemed for each constituent in the liquidity pool when bridging deposits.
   1. **Note: Impermanent loss becomes permanent on bridge, so the thresholds must be set accordingly.**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.royco.org/more/cross-chain-deposit-module-ccdm/deposit-locker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
