Creating an IAM
Recipe vs. Vault
The first step is to identify if you want to build a Recipe or Vault. See more on that here.
Creating a Vault IAM
ERC-4626 Compatible Vault:
The underlying ERC-4626 Vault that will be incentivized must be deployed before deploying your Vault IAM. Royco is compatible with a wide variety of ERC-4626 Vaults, but generally, the more a specific Vault conforms to the expected standard behavior, the more Royco functionality will be supported.
ERC-4626 Actions:
The underlying ERC-4626 Vault can be expressive, but generally, the action the IAM incentivizes should be: calling the vault’s `deposit()` function, and moving an amount of asset tokens equal to the `quantity` parameter passed in the function call.
If a non-conforming ERC-4626 Vault is unavoidable, it is still possible for the Wrapped Vault to function, and even cross-margin offers, if the following requirements still hold:
Requirements to distribute incentives to APs via Wrapped Vault:
asset() function doesn’t revert
deposit() function doesn’t revert
convertToAssets() function doesn’t revert
Working previewDeposit() function with accurate return value
ERC20 functionality intact
Requirements to enable cross-margin offers on Royco IAMs: An AP may earn incentives from one vault while waiting for a conditional offer to fill on a different market.
Withdraw function must return exactly `quantity` token to the withdrawer immediately
Working maxWithdraw() function with accurate return value
Always defer to checking the Royco codebase to confirm vault compatibility, especially when integrating irregular vaults.
Creating a Recipe IAM
Recipe Weiroll Scripts: Recipe IAMs rely on Weiroll, an operation-chaining/functional scripting language where all function calls are smart contract interactions. Unlike multicall, Weiroll allows “carrying” function outputs into the inputs of other function calls–enabling expressive, complex smart contract interactions.
Weiroll scripts are represented as an array of bytes32 commands, so they are difficult to create without using online builders–such as the one on Royco.org. These online builders drastically simplify script creation. It is recommended to use one of the transpilers specifically designed for generating Weiroll scripts, if you are to create a Weiroll script without an online builder.
Requirements for Recipe Weiroll scripts, at a minimum:
A valid ‘deposit recipe’ script that defines the incentivized action, to be executed by the AP’s disposable smart contract wallet.
A valid ‘withdrawal recipe’ script that calls all of the functions required to unwind an AP’s position. Without this, the AP will still be able to exit their position, but will need to execute the function calls manually.
Once the Weiroll script is complete, a Recipe Market can be created by calling ```function createMarket( address inputToken, uint256 lockupTime, uint256 frontendFee, Recipe calldata depositRecipe, Recipe calldata withdrawRecipe, RewardStyle rewardStyle) ``
`.
`inputToken`
the token that will be transferred to the AP’s Weiroll Wallet for availability during script execution. I.e. If the action is “deposit USDC in a liquidity pool,” then inputToken would be set to the AP’s current address, and anytime an offer is filled, the fill quantity of USDC will be transferred from the AP to the AP’s Weiroll Wallet, and may be used by the script.`lockupTime`
the number of seconds the Weiroll Wallet is time-locked, the AP will agree to not being able to withdraw or otherwise interact with their assets until the lockup expires.`frontendFee`
the % of incentives offered to be paid to the frontend. Must be higher than the minimum value set by the protocol. Frontends may opt to give increased visibility, preferred treatment, etc. to markets with higher fees.`
depositRecipe`
and`withdrawRecipe`
are the Weiroll scripts generated prior to market creation.`rewardStyle`
is an enum that determines how and when the incentives are paid to the AP, its enumerated values are as follows:0. Upfront:
1. Arrear:
2. Forfeitable:
Last updated