Inflation Extension

The extension plays a fundamental role in Covenant Inflation. Its implementation makes it possible to customize and extend a contract to achieve an extremely high level of security. Indeed, a contract has no choice but to have an extension, as it sets the parameters for both basic and advanced functionalities. There are two types of Inflation extensions:

Default Extension

The default extension is developed to be used by individual wallets or projects that do not require special integration and/or custom methods or features. It is cloned and deployed by the Inflation Factory (the address of which was passed in Factory Constructor), in case you choose to use it:

function cloneFixedInflationDefaultExtension() public override returns(address clonedExtension) {
    emit ExtensionCloned(clonedExtension = _clone(fixedInflationDefaultExtension));
}

Please note that the logic of the default extension can also be updated by the Covenants DFO.

The extension has a status, i.e. it is active or it is inactive. By default, the extension is inactive, and must be activated by the host. The _setactive function is used to change the status of the extension. The active status allows the extension to perform contract operations.

The state of the extension also represents whether it correctly contains the amount of tokens needed to perform operations. When it is active and you try to perform an operation, this will only succeed if the extension has enough tokens. If it doesn't and the operation accordingly fails, the extension automatically becomes inactive through the deactivationByFailure and no more operations can be performed until the extension returns to the active state.

The default extension provides a set of basic and general purpose functionalities designed for wallets or hosts that do not require a level of customization in functionality to interact with farming contracts.

Its main functions are:

  • Init function

function init(address host) override public {

sets the as main parameters for he host address

  • setHost

function setHost(address host) public virtual override hostOnly {

updates the extension host

  • setActive

function setActive(bool _active) public override virtual hostOnly { active = _active; }

changes the extension status

  • setEntry

function setEntry(FixedInflationEntry memory newEntry, FixedInflationOperation[] memory newOperations) public override hostOnly { 
    IFixedInflation(_fixedInflationContract).setEntry(newEntry, newOperations); }

Calls internally the setEntry of the contract to create/update a contract directly from the extension

  • receiveTokens

function receiveTokens(address[] memory tokenAddresses, uint256[] memory transferAmounts, uint256[] memory amountsToMint) public override fixedInflationOnly {

used by the contract to request tokens from the extension to perform operations

If the tokens come from reserve (so amountsToMint [ ]=0), the function calls internally the safeTransfer to transfer the tokens to the extension. If they are minted ( so amountsToMint [ ] >0), the function calls internally the _mintAndTransfer to mint the required amount and sends them to the contract.

   _safeTransfer(tokenAddresses[i], msg.sender, transferAmounts[i]);
}
if(amountsToMint[i] > 0) {
   _mintAndTransfer(tokenAddresses[i], msg.sender, amountsToMint[i]);
}
  • flushBack

function flushBack(address[] memory tokenAddresses) public override hostOnly {

send back tokens from the contract to the extension address passing the token address(es)

  • deactivationByFailure

function deactivationByFailure() public override fixedInflationOnly {

called by the contract to automatically disable the extension if there aren't enough tokens to perform operations

  • _mintAndTransfer

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

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

Custom Extension

The use of a custom extension allows for the external integration of different projects (such as DFOs / DAOs / custom smart contracts) with Covenants inflation contracts. The extension is the de facto integration mode.

For more details, visit the DFO / DAO/ customized smart contract Integration section.

Last updated