Skip to main content

RegenEarningPowerCalculatorFactory

Git Source

Title: RegenEarningPowerCalculatorFactory

Author: Golem Foundation

Factory for deterministic RegenEarningPowerCalculator deployment via CREATE2

Final salt = keccak256(salt, owner). Ownership is set in the calculator's constructor.

Note: security-contact: [email protected]

State Variables

calculators

Tracks deployed calculators per deployer

mapping(address => CalculatorInfo[]) public calculators

Functions

deploy

Deploy a new RegenEarningPowerCalculator with deterministic address

function deploy(bytes32 salt, address owner, IAddressSet allowset, IAddressSet blockset, AccessMode accessMode)
external
returns (address calculator);

Parameters

NameTypeDescription
saltbytes32Salt for CREATE2 address derivation
owneraddressAddress that will own the calculator (Ownable admin)
allowsetIAddressSetAllowset contract address (active in ALLOWSET mode)
blocksetIAddressSetBlockset contract address (active in BLOCKSET mode)
accessModeAccessModeInitial access mode (NONE, ALLOWSET, or BLOCKSET)

Returns

NameTypeDescription
calculatoraddressDeployed calculator address

predictAddress

Predict deployment address before calling deploy

function predictAddress(
bytes32 salt,
address owner,
IAddressSet allowset,
IAddressSet blockset,
AccessMode accessMode
) external view returns (address predicted);

Parameters

NameTypeDescription
saltbytes32Salt for CREATE2 address derivation
owneraddressAddress that will own the calculator
allowsetIAddressSetAllowset contract address
blocksetIAddressSetBlockset contract address
accessModeAccessModeAccess mode

Returns

NameTypeDescription
predictedaddressPredicted deployment address

getCalculatorsByDeployer

Returns all calculators deployed by a specific address

function getCalculatorsByDeployer(address deployer) external view returns (CalculatorInfo[] memory);

Parameters

NameTypeDescription
deployeraddressDeployer address

_recordCalculator

function _recordCalculator(address owner, address deployedCalculator, bytes32 salt) internal;

Events

CalculatorDeployed

Emitted when a new RegenEarningPowerCalculator is deployed

event CalculatorDeployed(address indexed deployer, address indexed calculator, address indexed owner, bytes32 salt);

Parameters

NameTypeDescription
deployeraddressAddress that called deploy
calculatoraddressDeployed calculator address
owneraddressAddress that owns the calculator
saltbytes32Salt used for CREATE2 derivation

Structs

CalculatorInfo

Information about a deployed RegenEarningPowerCalculator

struct CalculatorInfo {
address deployerAddress;
uint256 timestamp;
address owner;
address calculatorAddress;
bytes32 salt;
}