Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add StakingPoolFactory contract docs #1317

Draft
wants to merge 2 commits into
base: docs/smart-contracts-documentation
Choose a base branch
from

Conversation

rackstar
Copy link
Contributor

@rackstar rackstar commented Feb 6, 2025

StakingPoolFactory Contract Developer Documentation

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 unique poolId, 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.

function changeOperator(address newOperator) public;
Parameter Description
newOperator The new address to be assigned as the operator.

Description:

  • Verifies that the caller is the current operator.
  • Ensures the new operator address is not zero.
  • Updates the 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.

function create(address _beacon) external returns (uint poolId, address stakingPoolAddress);
Parameter Description
_beacon The address of the beacon for staking pool logic.

Returns:

  • poolId: The unique ID of the newly created staking pool.
  • stakingPoolAddress: The address of the deployed staking pool.

Description:

  • Verifies that the caller is the operator.
  • Increments the _stakingPoolCount and assigns a new poolId.
  • Deploys a new staking pool using the minimal beacon proxy pattern.
  • Ensures the new pool address is not zero.
  • Emits a StakingPoolCreated event.

Access Control: Only the operator can call this function.


View Functions

stakingPoolCount

Returns the total number of staking pools created.

function stakingPoolCount() external view returns (uint);

Returns:

  • uint: The total number of staking pools created.

Description:

  • Provides the current count of staking pools created by the factory.

Events

  • StakingPoolCreated(uint indexed poolId, address indexed stakingPoolAddress): Emitted when a new staking pool is successfully created.

Integration Guidelines

  • Operator Management: Ensure the operator role is properly assigned to a trusted account before deploying staking pools.
  • Beacon Address: Always provide a valid and deployed beacon address when creating staking pools. Incorrect addresses will result in failed pool deployments.
  • Pool Creation: Use the 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 the create function.


What happens if the beacon address is incorrect?

If the provided beacon address is incorrect or undeployed:

  • The deployment of the staking pool will fail.
  • An error will be thrown: "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:

  1. Call changeOperator with the new operator address.
  2. The caller must be the current operator.

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.

  • Developer Forums: Join our community forums to discuss with other developers and seek help.
  • Official Support Channels: Contact us via our official support email or join our Discord server.
  • Documentation Resources: Access additional documentation, tutorials, and FAQs on our official website.
  • GitHub Repository: Report issues or contribute to the codebase through our GitHub repository.

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.

@rackstar rackstar requested a review from MilGard91 February 6, 2025 08:19
@rackstar rackstar self-assigned this Feb 6, 2025
@rackstar rackstar linked an issue Feb 6, 2025 that may be closed by this pull request
@rackstar
Copy link
Contributor Author

rackstar commented Feb 6, 2025

Closes #1267

@rackstar rackstar force-pushed the docs/staking-pool-factory-contract-docs branch from 91f9aa9 to 00bb784 Compare February 6, 2025 10:11
@rackstar rackstar marked this pull request as draft February 6, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StakingFactory docs (2)
1 participant