Default and Custom
A contract can use either the Default Extension or a Custom Extension.
The default extension has been developed to be used by individual wallets and other hosts that do not require customized methods, features or integrations. It is deployed and cloned through the Factory contract (the
address
of the default extension is passed in the Factory Constructor
).
To use the default extension, clone it with the cloneFarmDefaultExtension
function:function cloneFarmDefaultExtension() public override returns(address clonedExtension) {
emit ExtensionCloned(clonedExtension = _clone(farmDefaultExtension));
}
Note that the standard logic of the default extension can only be updated by the Covenants DFO, which is governed by UniFi holders.
The default extension's main functions are:
Init
function
This establishes the three main initial data parameters:
- a boolean value; (
true
) if the reward token will be minted, (false
) if sent from a reserve - the host address;
- the treasury
address
function init(bool byMint, address host, address treasury) public virtual override {
setHost
This is used to update the extension host.
function setHost(address host) public virtual override hostOnly {
setTreasury
function setTreasury(address treasury) public virtual override hostOnly {
data
This function returns: the farming contract
address
deployed; whether the reward tokens are minted or if they come (true)
from a reserve (false)
; the host address
; the treasury address
; and the reward token address
.function data() view public virtual override returns(address farmMainContract, bool byMint, address host, address treasury, address rewardTokenAddress) {
return (_farmMainContract, _byMint, _host, _treasury, _rewardTokenAddress);
}
setFarmingSetups
This is used to create, update or disable the farming setups of a contract.
function setFarmingSetups(FarmingSetupConfiguration[] memory farmingSetups) public virtual override hostOnly {
transferTo
This allows the extension to transfer reward tokens to the contract. If they will be sent from a reserve, the
_safeTransfer
function is called to transfer them; if they will be minted, the _mintAndTransfer
function is called to first mint and then transfer them. This qualifies a setup for activation.function transferTo(uint256 amount) public virtual override farmMainOnly {
return _byMint ? _mintAndTransfer(_rewardTokenAddress, _farmMainContract, amount) : _safeTransfer(_rewardTokenAddress, _farmMainContract, amount);
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). See here for more info.function backToYou(uint256 amount) payable public virtual override farmMainOnly {
_mintAndTransfer
This calls the classic
IERC20 mint
method on the passed ERC20 token address
.function _mintAndTransfer(address erc20TokenAddress, address recipient, uint256 value) internal virtual {
_burn
This calls the classic
IERC20 burn
method on the passed ERC20 token address
.function _burn(address erc20TokenAddress, uint256 value) internal virtual {
Custom extensions allow for the integration of Covenant farming contracts with external protocols like DFOs, DAOs, dApps and custom smart contracts. The extension is the de facto integration mode.
Last modified 2yr ago