Skip to main content

RegeneratorPool

RegeneratorPool

This contract manages the distribution of Regeneration Credit tokens as rewards to regenerators for their ecosystem regeneration service provided. The reward is distributed related to the RegenerationScore, the result of each inspection that ranges from [0, 64].

Inherits core functionalities from Poolable (for pool management), Ownable (for deploy setup only), Blockable (for era/epoch tracking), and Callable (for whitelisted caller control).

regenerationCredit

contract IRegenerationCredit regenerationCredit

Interface to the Regeneration Credit token contract, used to decrease total locked.

regeneratorRulesAddress

address regeneratorRulesAddress

The address of the RegeneratorRules contract.

MAX_NEW_LEVELS

uint256 MAX_NEW_LEVELS

Maximum possible score from a single resource.

hasProcessedLevel

mapping(uint64 => bool) hasProcessedLevel

Tracks unique resource IDs to ensure levels for a resource are added only once.

constructor

constructor(address regenerationCreditAddress, uint256 _halving, uint256 _blocksPerEra) public

Initializes the RegeneratorPool contract. Sets up the Regeneration Credit token interface and initializes inherited base contracts.

Parameters

NameTypeDescription
regenerationCreditAddressaddressThe address of the RegenerationCredit token contract.
_halvinguint256The number of eras that constitute one halving cycle/epoch for reward adjustments. Passed to the Blockable base contract.
_blocksPerErauint256The number of blocks that constitute a single era. Passed to the Blockable base contract.

setContractCall

function setContractCall(address _regeneratorRulesAddress) external

onlyOwner function to set contract call addresses. This function must be called only once after the contract deploy and ownership must be renounced.

Parameters

NameTypeDescription
_regeneratorRulesAddressaddressAddress of RegeneratorRules.

withdraw

function withdraw(address delegate, uint256 era) external

This function can only be called by the RegeneratorRules contract, whitelisted via the Callable contract's mechanisms. The user must also be eligible for withdrawal based on the Blockable contract's era tracking.

Allows an authorized caller, the Regenerator contract, to trigger a token withdrawal for a user. This function calculates the eligible tokens for the user's era and transfers them.

Parameters

NameTypeDescription
delegateaddressThe address of the user (regenerator) for whom the withdrawal is being processed.
erauint256The last recorded era of the delegate user, used for reward calculation and eligibility.

addLevel

function addLevel(address regenerator, uint256 levels, uint64 inspectionId) external

Can only be called by the regeneratorRules address.

Allows an authorized caller to increase the user pool level. This function updates the regenerator level within the system's pooling mechanism.

Parameters

NameTypeDescription
regeneratoraddressThe wallet address of the regenerator.
levelsuint256The number of levels to increase the regenerator's pool level by.
inspectionIduint64The id of the inspection being processed.

removePoolLevels

function removePoolLevels(address addr, uint256 amountToRemove, bool denied) external

Can only be called by regeneratorRules address.

Allows an authorized caller to decrease an regenerator's pool level. This function adjusts the regenerator's level downwards within the system's pooling mechanism.

Parameters

NameTypeDescription
addraddressThe wallet address of the regenerator.
amountToRemoveuint256The number of levels/score points to decrease.
deniedboolRemove level user status. If true, user is being denied.

haveTokensToWithdraw

function haveTokensToWithdraw(address delegate, uint256 era) public view returns (bool)

View function to check if a user have tokens to withdraw at an era.

Parameters

NameTypeDescription
delegateaddressUser address.
erauint256User current era.

Return Values

NameTypeDescription
[0]boolbool True if have tokens to withdraw, false if will just update era.