Staking Pool Factory
The StakingPoolFactory contract is responsible for creating and managing staking pools. It allows the creation of staking pools for different tokens and keeps track of all the created pools.
State Variables
feeTo: The address that is supposed to receive the protocol fee.feeToSetter: The address that can set thefeeToaddress.getPool: A mapping from token address to pool address, which stores the pool address for each token.allPools: An array containing all the pool addresses.
Events
PoolCreated(address indexed token, address pool, uint256 timeStamp): Event emitted when a new staking pool is created. It includes the token address, pool address, and the timestamp of the creation.
Constructor
constructor(address _feeToSetter): Initializes thefeeToSettervariable with the provided address during contract deployment.
External Functions
-
allPoolsLength() external view returns (uint256): Returns the length of theallPoolsarray. -
createPool(address stoken, address rtoken) external returns (address): Creates a new staking pool for the specified staking token (stoken) and reward token (rtoken). It checks that the staking token address is not zero and there is no existing pool for the token. It deploys a newStakingPoolcontract, sets the pool address in thegetPoolmapping, adds the pool address to theallPoolsarray, and emits thePoolCreatedevent. Returns the address of the created pool. -
setFeeTo(address _feeTo) external: Sets thefeeToaddress to the provided address. Only thefeeToSettercan call this function. -
setFeeToSetter(address _feeToSetter) external: Sets thefeeToSetteraddress to the provided address. Only the currentfeeToSettercan call this function.