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 thefeeTo
address.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 thefeeToSetter
variable with the provided address during contract deployment.
External Functions
-
allPoolsLength() external view returns (uint256)
: Returns the length of theallPools
array. -
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 newStakingPool
contract, sets the pool address in thegetPool
mapping, adds the pool address to theallPools
array, and emits thePoolCreated
event. Returns the address of the created pool. -
setFeeTo(address _feeTo) external
: Sets thefeeTo
address to the provided address. Only thefeeToSetter
can call this function. -
setFeeToSetter(address _feeToSetter) external
: Sets thefeeToSetter
address to the provided address. Only the currentfeeToSetter
can call this function.