Integrate Fees in your Factory
Creation fee
The creation fee must be implemented in your Factory when a user clones the model contract. Consequently the burnOrTransferTokenAmount
function must be called within the deploy
function of your Factory.
Usage Fee
The Usage fee must be implemented in the model contract that your Factory clones. Consequently the payFee
function must be called within the model contract depending on your business logic.
For example Covenants Farming provides a Usage Fee when farmers withdraw their cash/reward
Integrate Fees
In order to implement the two FoF methods explained in the previous page, you have to:
create your own system to interact with the two FoF functions, being able to create custom behaviors. You could build an abstract utility contract or, simply, a set of utility functions in your Factory contract
An example is the EthereansFactory
contract. This is an abstract utility contract that all the Factories of EthereansOs implement such as Farming Factory, Routines Factory, Organization Factory, Delegation Factory and so on.
You can take the EthereansFactory
contract as a guideline to create your own system that interacts with the two FoF methods (burnOrTransferTokenAmount
and payFee
).
In this way, you can:
Have an easy interaction with the FoF. For example,
EthereansFactory
allows to initialize a series of parameters passed as input parameters when interacting with the two FoF fees methods. In this way, you don't have to pass theburnOrTransferTokenAmount
andpayFee
input parameters from outside/frontendHave a system that can be reused for multiple factories. As said before, the
EthereansFactory
is implemented in more than five different FactoriesHave a completely customizable logic,
EthereansFactory
provides a series of virtual functions that can be overridden in Factories implementing it. For example, the Farming Factory has a custom logic: even if the fee set is a transfer fee, if the token to pay the fees with is $OS, the fee is burned
In the following page you can have a look at the EthereansFactory
contract.
Last updated