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.
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.
Deposit Recipe
The Weiroll Script/Recipe that will be executed to deposit funds into this campaign's corresponding protocol.
Must give the Deposit Executor a max allowance to spend the receipt token (for withdrawals) and the campaign's input tokens (to refund dust/excess tokens).
This recipe must be verified by the Campaign Verifier before it can be executed.
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 for the Weiroll Wallet.
Merkle Deposit Recipe IAMs: The merkle root for all deposits included in this bridge and the total deposit amount accounted for in the merkle tree.
Individual Deposit Recipe IAMs: Each depositor's address and deposit amounts included in this bridge.
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/market.
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.
Making Withdrawals
Call
withdrawMerkleDeposit()
from the address you used to deposit on the source chain and a merkle proof demonstrating that the deposit belongs to you.Can only withdraw 1 deposit per invocation.
Individual Deposit Recipe IAMs
Call
withdrawIndividualDeposits()
from the address you used to deposit on the source chain.Can withdraw funds from multiple Weiroll Wallets in a single invocation.
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 Campaign Owner of each campaign/market
Campaigns are identified by their corresponding Royco IAM'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 reverify the campaign params before the deposit recipe can be executed
Set the deposit recipe
The Weiroll Script/Recipe that will be executed to deposit tokens into the intended DApp/Protocol.
Must return receipt tokens and dust to the Weiroll Wallet and give a max allowance to the Deposit Executor to spend them for withdrawals.
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
Execute deposit recipes to deposit liquidity into your DApp/Protocol.
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