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:
Creates one Weiroll Wallet per CCDM Nonce received for a given Market Hash.
If a wallet has already been created, it will use the cached wallet for the following steps.
Stores accounting information about each depositor's deposit amount in the Weiroll Wallet.
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:The Weiroll Wallet is funded with the total amounts of each token deposited into the wallet.
The deposit recipe is executed by the Weiroll Wallet.
The Deposit Executor checks that:
Receipt tokens were received by the Weiroll Wallet
The Weiroll Wallet gave max allowance to the Deposit Executor to spend its receipt tokens
This will be used to distribute receipt tokens to depositors on withdrawal.
The Weiroll Wallet gave max allowance to the Deposit Executor to spend all the campaign's input tokens
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:
If the Weiroll Wallet has executed the deposit recipe, the depositor withdraws their pro rata share of the receipt tokens from the Weiroll Wallet.
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
Sets the LayerZero V2 endpoint for the destination chain.
Sets the LayerZero EID (Endpoint ID) for the source chain.
Sets the address of the Deposit Locker on the source chain.
Sets the wrapped native asset token (i.e. WETH) for the destination chain.
Sets the owner of each campaign
Campaigns are identified by their corresponding Royco Market's hash on the source chain.
Delegates a Campaign Verifier to verify campaign parameters
Campaign Owners
Set the absolute unlock timestamp
This can only be set ONCE.
This is the timestamp that all deposits for your campaign will be withdrawable.
This has to be set to less than 4 months after the the current timestamp in order to disallow unreasonable lock ups.
Set the campaign's receipt token
The receipt token that will represent a depositor's position in the campaign's corresponding protocol.
This can only be set until the first deposit recipe is executed for the campaign.
Every time it is set, the Campaign Verifier must verify the script before it can be executed
Set the deposit recipe
This can be set an unbounded amount of times
Every time it is set, the Campaign Verifier must verify the script before it can be executed
Campaign Verifier
Verify a campaign
Should consider that the campaign's input tokens, receipt token, and deposit recipe will work correctly through rigorous testing and simulation.
Deposit recipes can now be executed for this campaign.
Unverify a campaign
Deposit recipes cannot be executed for this campaign.
Last updated