Deposit Executor

An overview of the CCDM Deposit Executor

The Deposit Executor is a singleton contract that receives and holds bridged deposits on the destination chain and deploys them into protocols by executing Weiroll Scripts/Recipes through Weiroll Wallets. It also allows APs to withdraw their deposits once the campaign's unlock timestamp has passed by distributing the receipt tokens for each deposit.

Creating Campaigns

  • IPs create and set the parameters of their Deposit Campaigns

    • Each campaign maps directly to a CCDM enabled market on the source chain.

      • Campaigns are identified by their corresponding Royco Market's hash on the source chain.

    • Parameters

      • Unlock timestamp

        • The absolute timestamp that deposits for this campaign will be unlocked for withdrawal.

        • All deposits for this campaign will be withdrawable at this timestamp, regardless of when they were bridged and deposited.

      • Deposit Recipe

        • The Weiroll Script that will be executed to deposit funds into this campaign's corresponding protocol.

        • This script must be verified by the Campaign Verifier before it can be executed.

      • Receipt token

        • The ERC20 receipt token that will represent a depositor's position in the campaign's corresponding protocol.

        • These tokens must be returned to the Weiroll Wallet when it executes the deposit recipe.

Receiving Bridged Deposits

When the Deposit Executor receives deposits from the Deposit Locker, it triggers the following logic:

  1. Creates one Weiroll Wallet per CCDM Nonce received for a given Market Hash.

    1. If a wallet has already been created, it will use the cached wallet for the following steps.

  2. Stores accounting information about each depositor's deposit amount in the Weiroll Wallet.

  3. Holds the deposits until the deposit recipe is executed for the Weiroll Wallet.

For more information on how deposits are bridged, refer to Bridging Deposits.

Executing Deposit Recipes

  • Campaign owners are responsible for executing deposit recipes for Weiroll Wallets belonging to their campaign.

  • Upon calling executeDepositRecipes(), the following logic is triggered:

    1. The Weiroll Wallet is funded with the total amounts of each token deposited into the wallet.

    2. The deposit recipe is executed by the Weiroll Wallet.

    3. The Deposit Executor checks that:

      1. Receipt tokens were received by the Weiroll Wallet

      2. The Weiroll Wallet gave max allowance to the Deposit Executor to spend its receipt tokens

        1. This will be used to distribute receipt tokens to depositors on withdrawal.

      3. The Weiroll Wallet gave max allowance to the Deposit Executor to spend all the campaign's input tokens

        1. This will be used to distribute dust amounts of deposit tokens to depositors on withdrawal.

Withdrawals

Depositors can withdraw from the Deposit Executor (on a per Weiroll Wallet basis) once the campaign's unlock timestamp has passed. Withdrawals can take one of two flows:

  1. If the Weiroll Wallet has executed the deposit recipe, the depositor withdraws their pro rata share of the receipt tokens from the Weiroll Wallet.

  2. If the Weiroll Wallet has not executed the deposit recipe, the depositor withdraws their original deposit amount for each deposited token.

Administrative Roles

Deposit Executor Owner

  1. Sets the LayerZero V2 endpoint for the destination chain.

  2. Sets the LayerZero EID (Endpoint ID) for the source chain.

  3. Sets the address of the Deposit Locker on the source chain.

  4. Sets the wrapped native asset token (i.e. WETH) for the destination chain.

  5. Sets the owner of each campaign

    1. Campaigns are identified by their corresponding Royco Market's hash on the source chain.

  6. Delegates a Campaign Verifier to verify campaign parameters

Campaign Owners

  1. Set the absolute unlock timestamp

    1. This can only be set ONCE.

    2. This is the timestamp that all deposits for your campaign will be withdrawable.

    3. This has to be set to less than 4 months after the the current timestamp in order to disallow unreasonable lock ups.

  2. Set the campaign's receipt token

    1. The receipt token that will represent a depositor's position in the campaign's corresponding protocol.

    2. This can only be set until the first deposit recipe is executed for the campaign.

    3. Every time it is set, the Campaign Verifier must verify the script before it can be executed

  3. Set the deposit recipe

    1. This can be set an unbounded amount of times

    2. Every time it is set, the Campaign Verifier must verify the script before it can be executed

Campaign Verifier

  1. Verify a campaign

    1. Should consider that the campaign's input tokens, receipt token, and deposit recipe will work correctly through rigorous testing and simulation.

    2. Deposit recipes can now be executed for this campaign.

  2. Unverify a campaign

    1. Deposit recipes cannot be executed for this campaign.

Last updated