docs: add StakingPoolFactory contract docs #1317
Merged
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 deploying and managing staking pools in the protocol. It uses a beacon proxy pattern to deploy pools efficiently while keeping gas costs low.However, users should not call
StakingPoolFactory.create()
directly. Instead, staking pools are created throughStakingProducts.createStakingPool()
, which:StakingPoolFactory.create()
to deploy the pool.Only the
StakingProducts
contract has operator permissions to create staking pools, ensuring pools are deployed securely and with proper configuration.Key Concepts
Staking Pool Creation
StakingProducts.createStakingPool()
, not directly viaStakingPoolFactory.create()
.StakingProducts
acts as the operator ofStakingPoolFactory
and manages pool creation.StakingProducts.createStakingPool()
is called:StakingPoolFactory.create()
is executed, deploying a beacon proxy staking pool.StakingProducts
assigns a pool manager.StakingProducts
configures initial cover products for the pool.This ensures all pools are properly registered, assigned managers, and configured correctly.
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
StakingProducts
is the operator ofStakingPoolFactory
.changeOperator(newOperator)
, but only the current operator (StakingProducts
) can perform this action.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.Frequently Asked Questions
Who can create a staking pool?
Users cannot directly call
StakingPoolFactory.create()
(onlyStakingProducts
can). Instead, user's should callStakingProducts.createStakingPool()
to create staking pools.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.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.