docs: add StakingPoolFactory contract docs #1317
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
StakingPoolFactory Contract Developer Documentation
changeOperator
create
stakingPoolCount
Overview
The
StakingPoolFactory
contract is responsible for creating and managing staking pools in the protocol. It uses a minimal beacon proxy pattern to deploy staking pools efficiently and securely. The contract maintains a record of the number of staking pools created and allows an operator to manage pool creation and configuration.Key Concepts
Staking Pool Creation
The
StakingPoolFactory
creates staking pools by deploying minimal beacon proxies. Each pool is assigned a uniquepoolId
, which is incremented with every new pool creation.Beacon Proxy
The contract uses a beacon address to define the logic for staking pools. This allows for efficient deployment and potential upgrades of staking pools without affecting existing instances.
Operator Role
The operator is the only account authorized to create staking pools or change the operator itself. This ensures that pool creation is controlled and prevents unauthorized access.
Mutative Functions
changeOperator
Updates the operator address to a new address.
newOperator
Description:
operator
to the new address.Access Control: Only the current operator can call this function.
create
Creates a new staking pool using the provided beacon address.
_beacon
Returns:
poolId
: The unique ID of the newly created staking pool.stakingPoolAddress
: The address of the deployed staking pool.Description:
_stakingPoolCount
and assigns a newpoolId
.StakingPoolCreated
event.Access Control: Only the operator can call this function.
View Functions
stakingPoolCount
Returns the total number of staking pools created.
Returns:
uint
: The total number of staking pools created.Description:
Events
StakingPoolCreated(uint indexed poolId, address indexed stakingPoolAddress)
: Emitted when a new staking pool is successfully created.Integration Guidelines
operator
role is properly assigned to a trusted account before deploying staking pools.create
function to deploy new staking pools. This ensures that pools are properly recorded and managed.Frequently Asked Questions
Who can create a staking pool?
Only the account with the
operator
role can create staking pools using thecreate
function.What happens if the beacon address is incorrect?
If the provided beacon address is incorrect or undeployed:
"StakingPoolFactory: Failed to create staking pool"
.Ensure the beacon address is valid and points to a deployed contract.
How can the operator role be changed?
The operator role can be updated using the
changeOperator
function:changeOperator
with the new operator address.If the new operator address is invalid, the transaction will revert with:
"StakingPoolFactory: Invalid operator"
.Contact and Support
If you have questions or need assistance integrating with the
StakingPoolFactory
contract or other parts of the protocol, please reach out through the official support channels or developer forums.Disclaimer: This documentation provides a high-level overview of the
StakingPoolFactory
contract's functionality. It is intended for developers integrating with the protocol and may omit internal details not relevant to external interactions. Always refer to the latest contract code and official resources.