Create and Initialize a Covenant Inflation Contract
Any DFO, DAO, individual wallet or customized smart contract can host a Covenant Inflation contract. This flexible design makes it easy for hosts to set rules for distributing rewards (from a reserve or via minting) to farmers, while preventing them from touching farmer tokens or manipulating rewards for locked positions. This secures farmers from exploitation.
Hosts have the power to govern the extension linked to a specific inflation contract, and can call specific functions through the extension. For example, the host can:
set a new host
create an entry
change an entry
flushBack tokens back to the extension address
Create a Fixed Inflation Contract
At the heart of Covenant inflation architecture is the Inflation Factory.
The Factory is coded with the standard logic of the original model farming contract. Hosts can use it to clone the model to create their own contract. All clones necessarily maintain the model's logic, which allows them to clone and reference the model, and keep track of all event instances.
Hosts use the deploy function to have the Factory clone the model (which, as mentioned, contains the standard logic):
The deploy function deploys a new contract and calls the initialize function for it, passing the encoded data as a parameter.
The contract init function works as follow:
function init(address _extension, bytes memory extensionPayload, FixedInflationEntry memory newEntry, FixedInflationOperation[] memory newOperations) public returns(bytes memory extensionInitResult) {
_extension -> extension address to be linked to the contract
extensionPayload -> encoded data containing the initialize extension data (if an init extension function is provided); e.g., for the Default extension, this data contains the host address.
newEntry -> FixedInflationEntry struct containing the parameters of a contract entry
newOperations -> FixedInflationOperation struct containing the parameters of the operations to be performed
If 0x0000000000000000000000000000000000000000 is passed as the _extension address, the init function internally calls the deploy method on the Factory to have it clone the default extension. This means it is not necessary to have previously deployed an extension:
Then, if the newEntry and newOperations parameters were passed in init function, the _set function is called internally to create all the setups operations of the contract entry:
_set(newEntry, newOperations);
Remember that only oneEntry can be referred to each contract.
Send Tokens to the Extension
The extension must be sent and hold an amount of tokens that is at least equal to that needed to execute a contract's operations, otherwise the operations will be correctly created, but will fail at runtime and the extension will automatically become inactive.
If an entry's token are distributed by reserve, the best practice is to deploy the extension and the contract and then immediately send the extension the minimum amount of reward tokens needed to execute the operations.
If the host is a wallet or similar, simply send the amount of tokens manually via a transfer function (or simply transfer the tokens to the extension address using a provider such as Metamask).
If the host is a DFO, DAO or other type of organization, it is necessary to use the relevant procedure to transfer the tokens. If, for example, the host is a DFO, make a proposal to install the manageFixedInflation microservice (you only need to do this once; you won't have to again if you create more inflation Contracts in the future) and enable the extension in the DFO StateHolder (this must be done every time). This will authorize retrieval of the required quantity of tokens from the wallet/treasury DFO to the Inflation Contract extension:
After the extension has received the reward tokens, the transfer from the extension to the contract will be done automatically when an operation is executed, and does not require a manual transfer by the host.