Routines Extension
The Extension plays a fundamental role in Covenants Routines. 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.
In particular, the Extension sends the token required by the specific Operation of the Routines contract. The Extension has also the right to mint tokens and send them to the Inflation contract if a mint is required by the Operation. There are two types of Routines 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 Routines Factory (the address of which was passed in Factory Constructor), in case you choose to use it:
1
function cloneFixedInflationDefaultExtension() external returns(address clonedExtension);
Copied!
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 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
1
function init(address host) override public {
Copied!
sets the input address as the host address
  • setHost
1
function setHost(address host) public virtual override hostOnly {
Copied!
updates the extension host
  • setActive
1
function setActive(bool _active) public override virtual hostOnly { active = _active; }
Copied!
changes the extension status
  • setEntry
1
function setEntry(FixedInflationEntry memory newEntry, FixedInflationOperation[] memory newOperations) public override hostOnly {
2
IFixedInflation(_fixedInflationContract).setEntry(newEntry, newOperations); }
Copied!
Calls internally the setEntry of the contract to create/update a contract directly from the extension
  • receiveTokens
1
function receiveTokens(address[] memory tokenAddresses, uint256[] memory transferAmounts, uint256[] memory amountsToMint) public override fixedInflationOnly {
Copied!
Function used by the FI 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.
  • flushBack
1
function flushBack(address[] memory tokenAddresses) public override hostOnly {
Copied!
send back tokens from the contract to the extension address passing the token address(es)
  • deactivationByFailure
1
function deactivationByFailure() public override fixedInflationOnly {
Copied!
called by the contract to automatically disable the extension if there aren't enough tokens to perform operations
  • _mintAndTransfer
1
function _mintAndTransfer(address erc20TokenAddress, address recipient, uint256 value) internal virtual {
Copied!
calls the classic IERC20 mint method on the ERC20 token address passed.
To perform this operation, the Extension contract must have minting rights of the token.
  • burnToken
1
function burnToken(address erc20TokenAddress, uint256 value) external override fixedInflationOnly
Copied!
This function, callable only by the FI contract itself, is used to perform a burn operation on an ERC20 calling the _burn function. This function is used when a burn operation is performed (address receiver passed as address(0) in the FixedInflationOperation.
  • _burn
1
function _burn(address erc20TokenAddress, uint256 value) internal virtual
Copied!
calls the classic IERC20 burn method on the ERC20 input/output token address passed.

Custom Extension

The use of a custom extension allows for the external integration of different projects (such as Organization / DAOs / custom smart contracts) with Covenants Inflation contracts. The extension is the de facto integration mode.
For more details, visit the Organization/ customized smart contract Integration section.
Copy link
Contents