Farming Extensions

Extensions play a fundamental role in Covenants farming. They make it possible to customize farming contracts to achieve an extremely high level of security in hosting. Indeed, all farming contracts must have extensions, as these set the parameters for both basic and more advanced functionalities. There are two possible farming extensions:

Default Extension

The default extension has been developed to be used by individual wallets or other hosts that do not require customized integrations, methods or features. It is deployed and cloned through the Factory contract (the address of the default extension was passed in the Factory Constructor). If you want to use default extension, clone it with the cloneFarmDefaultExtension function:

function cloneFarmDefaultExtension() public override returns(address clonedExtension) {
    emit ExtensionCloned(clonedExtension = _clone(farmDefaultExtension));
}

Please note that the standard logic of the default extension can only be updated by the Covenants DFO, governed exclusively by $UniFi holders.

Its main functions are:

  • Init function

function init(bool byMint, address host, address treasury) public virtual override {

This sets the three main data parameters: a boolean value representing if the reward token is generated by mint (true) or by reserve (false); the host address; and the treasury address.

  • setHost

function setHost(address host) public virtual override hostOnly {

This is used to update the extension host.

  • setTreasury

function setTreasury(address treasury) public virtual override hostOnly {

This is used to update the extension treasury.

  • setFarmingSetups

function setFarmingSetups(FarmingSetupConfiguration[] memory farmingSetups) public virtual override hostOnly {

This is used to create / update / disable the farming setups of a contract directly via the extension.

  • backToYou

The backToYou function is called in the Farming contract to retrieve reward tokens, in case the amount of reward tokens sent by the extension to the Farming contract is not sufficient to activate the setup(s). Look here for more infos.

function backToYou(uint256 amount) payable public virtual override farmMainOnly {
  • transferTo

function transferTo(uint256 amount) public virtual override farmMainOnly {

This allows the extension to transfer the required amount of reward token to the contract. If the tokens are to be issued from a reserve, the _safeTransfer function is called to transfer them there from the reserve; if they are to be minted, the _mintAndTransfer function is called to first mint and then transfer them to the contract. This function is used to qualify a setup for activation (see here for more details).

return _byMint ? _mintAndTransfer(_rewardTokenAddress, _farmMainContract, amount) : _safeTransfer(_rewardTokenAddress, _farmMainContract, amount);
  • _mintAndTransfer

function _mintAndTransfer(address erc20TokenAddress, address recipient, uint256 value) internal virtual {

This calls the classic IERC20 mint method on the passed ERC20 token address.

  • _burn

function _burn(address erc20TokenAddress, uint256 value) internal virtual {

This calls the classic IERC20 burn method on the passed ERC20 token address.

Custom Extension

Ccustom extensions allows for external integration of Covenants farming with different projects, such as DFOs, DAOs, dApps and custom smart contracts. The extension is the de facto integration mode.

For more details, see the DFO / DAO / Customized Smart Contract Integration section.

Last updated