FarmRegistry

Git Source

Inherits: IFarmRegistry, OwnableUpgradeable

Author: Sperax Foundation.

This contract tracks fee details, privileged users, deployed farms and farm deployers.

State Variables

farms

address[] internal farms;

deployerList

address[] internal deployerList;

feeReceiver

address public feeReceiver;

feeToken

address public feeToken;

feeAmount

uint256 public feeAmount;

extensionFeePerDay

uint256 public extensionFeePerDay;

farmRegistered

mapping(address => bool) public farmRegistered;

deployerRegistered

mapping(address => bool) public deployerRegistered;

isPrivilegedUser

mapping(address => bool) public isPrivilegedUser;

Functions

constructor

constructor();

initialize

constructor

function initialize(address _feeReceiver, address _feeToken, uint256 _feeAmount, uint256 _extensionFeePerDay)
    external
    initializer;

Parameters

NameTypeDescription

_feeReceiver

address

Receiver of the fees.

_feeToken

address

The fee token for farm creation.

_feeAmount

uint256

The fee amount to be paid by the creator.

_extensionFeePerDay

uint256

Extension fee per day.

registerFarm

Register a farm created by registered Deployer.

Only registered deployer can register a farm.

function registerFarm(address _farm, address _creator) external;

Parameters

NameTypeDescription

_farm

address

Address of the created farm contract

_creator

address

Address of the farm creator.

registerFarmDeployer

Register a new farm deployer.

Only owner can call this function.

function registerFarmDeployer(address _deployer) external onlyOwner;

Parameters

NameTypeDescription

_deployer

address

Address of deployer to be registered.

removeDeployer

Remove an existing deployer from registry.

Only owner can call this function.

function removeDeployer(uint16 _id) external onlyOwner;

Parameters

NameTypeDescription

_id

uint16

ID of the deployer to be removed (0 index based).

updatePrivilege

Function to add/remove privileged User.

Only callable by the owner.

function updatePrivilege(address _user, bool _privilege) external onlyOwner;

Parameters

NameTypeDescription

_user

address

User Address for which privilege is to be updated.

_privilege

bool

Privilege(bool) whether true or false.

getFarmDeployerList

Get list of registered deployer.

function getFarmDeployerList() external view returns (address[] memory);

Returns

NameTypeDescription

<none>

address[]

Returns array of registered deployer addresses.

getFarmList

Get list of farms created via registered deployer.

function getFarmList() external view returns (address[] memory);

Returns

NameTypeDescription

<none>

address[]

Returns array of farm addresses.

getFeeParams

Get all the fee parameters for creating farm.

It returns fee amount and extension fee as 0 if _user is privileged.

function getFeeParams(address _user) external view returns (address, address, uint256, uint256);

Parameters

NameTypeDescription

_user

address

The account creating the farm.

Returns

NameTypeDescription

<none>

address

Receiver of the fees.

<none>

address

Token in which fee is to be paid.

<none>

uint256

Amount of fees to be paid for creation of farm.

<none>

uint256

Extension fee per day in case of extending a farm.

updateFeeParams

Update the fee params for registry.

function updateFeeParams(address _receiver, address _feeToken, uint256 _amount, uint256 _extensionFeePerDay)
    public
    onlyOwner;

Parameters

NameTypeDescription

_receiver

address

FeeReceiver address.

_feeToken

address

Token address for fee.

_amount

uint256

Amount of token to be collected.

_extensionFeePerDay

uint256

Extension fee per day.

_validateNonZeroAddr

Validate address.

function _validateNonZeroAddr(address _addr) private pure;