RewardsDistributorFactoryV1
Overview
RewardsDistributorFactoryV1 is a contract that facilitates the creation of IncentiveRewardsDistributor contracts within the EYWA ecosystem. It is closely integrated with the Escrow Vote Manager, ensuring that only the authorized vote manager can instantiate new rewards distributor contracts.
Key Roles and Features:
Factory Functionality: Provides a
createRewardsDistributor
method for deploying new IncentiveRewardsDistributor contracts on-demand.Access Control: Only the
ESCROW_VOTE_MANAGER
is allowed to create new distributors, preventing unauthorized contract deployments.Upgradeable and Ownable: Uses UUPSUpgradeable and OwnableUpgradeable to allow controlled upgrades and ownership transfers.
This factory contract standardizes the creation process for new incentive rewards distributors, ensuring that they are always integrated with the authorized ecosystem components (Escrow Vote Manager and Escrow Manager) and follow a secure and maintainable pattern.
Inherited Contracts and Interfaces
UUPSUpgradeable (OpenZeppelin): Enables the contract to be upgraded via a UUPS proxy pattern, ensuring controlled and secure upgrades.
OwnableUpgradeable (OpenZeppelin): Allows for ownership management, restricting certain operations (like contract upgrades) to the owner.
IRewardsDistributorFactoryV1: Interface defining the initialization and distributor creation functions, as well as related events and errors.
Additional References:
IncentiveRewardsDistributor: The contract deployed by this factory for reward distribution. It is integrated with the Escrow Vote Manager and Escrow Manager.
State Variables
s_escrowVoteManager
Type:
address
Description: The address of the escrow vote manager contract. Only this address is authorized to call
createRewardsDistributor
.
Constructor
constructor()
Description: Disables initializers to prevent re-initialization. Called once when the proxy is deployed.
External Functions
initialize(...)
initialize(...)
Signature:
Description: Initializes the factory contract by setting the contract owner and the escrow vote manager address. This function can only be called once during the contractβs lifecycle (by the proxyβs initialization).
Parameters:
owner_
: The address that will be set as the contract owner.escrowVoteManager_
: The address of the escrow vote manager contract, which will be the only authorized caller for distributor creation.
Effects:
Calls
__UUPSUpgradeable_init()
and__Ownable_init(owner_)
to set up upgradeability and ownership.Assigns
s_escrowVoteManager
to the providedescrowVoteManager_
address.
createRewardsDistributor(...)
createRewardsDistributor(...)
Signature:
Description:
Creates a new IncentiveRewardsDistributor contract instance. Can only be called by s_escrowVoteManager
. If called by any other address, the function reverts with InvalidCaller()
.
Parameters:
escrowManager_
: The address of the escrow manager associated with the newly created incentive rewards distributor. The created distributor relies on this manager for lock and ownership data.
Checks & Constraints:
msg.sender
must equals_escrowVoteManager
. Otherwise,InvalidCaller()
is thrown.
Effects:
Deploys a new
IncentiveRewardsDistributor
instance by passingmsg.sender
(the escrow vote manager) andescrowManager_
to its constructor.Returns the address of the newly created incentive rewards distributor.
Return:
address
: The newly created incentive rewards distributor contract.
Internal Functions
_authorizeUpgrade(address)
_authorizeUpgrade(address)
Signature:
Description: Ensures that only the contract owner can authorize upgrades to the implementation. Protects the contract from unauthorized changes to its logic.
Errors
InvalidCaller()
: Thrown ifcreateRewardsDistributor
is called by an address other thans_escrowVoteManager
. Ensures that only the designated escrow vote manager can spawn new distributors.
Summary
RewardsDistributorFactoryV1 provides a secure and controlled way to create new incentive rewards distributor contracts in the EYWA ecosystem. By restricting distributor creation to the escrow vote manager, it ensures that all deployed distributors are authorized and properly integrated, maintaining the integrity and security of the reward distribution infrastructure. Using a UUPS upgradeable pattern and an ownership model, this contract can be managed and improved over time while preserving its essential access control and functionality.
Last updated