Creation and Initialization
Create a Farming Contract
Hosts use the deploy
function to have the Factory clone the model (which, as mentioned, contains the standard logic):
When the Factory does this, it calls the init
function for the farming contract, passing the encoded data as a data parameter.
The init
function works as follow:
extension
-> theaddress
of the deployed extension to be linked to the contractextensionInitData
-> the encoded initialize extension data (available if aninit
extension function is provided). The default extension's init data contains three parameters: a boolean value representing if the reward token is minted (true
) or from reserve (false
); the host address; and the treasuryaddress
.rewardTokenAddress
-> theaddress
of the reward token of the contract. Each contract has one.farmingSetupInfoBytes
-> ABI-encoded data of the contract's setups, which can be created directly during the initialization phase.
The extension (whether default or custom) must be deployed before deploying the farming contract through the Factory's deploy
function. This allows the deployed extension to be linked to the Farming contract through the Farming contract init
function. As noted above, the deployed extension doesn't need to have been initialized before this (and thus an init
function is not provided), but can be done directly through the contract's init
function, passing the extensionInitData
in the payload
.
If the extension has an init
function, it will be called, otherwise not:
If the farmingSetupInfoBytes
parameter was passed in init
function, also the passed setups are created.
Otherwise, setups can be created directly using the setFarmingSetups
function (look at the Add New Farming Setups to a Contract section to see how to customize setups and create new ones).
Last updated