PoolFactory
This contract is responsible for creating and managing pools. It inherits from various OpenZeppelin upgradeable contracts for enhanced functionality and security.
State Variables
GOV_ROLE
Role identifier for governance accounts that can perform admin actions. Has the power to upgrade the implementation of the factory and its beacons.
POOL_ROLE
Role identifier for users that can interact with the factory to create new pools.
MINTER_ROLE
Role identifier for accounts that can mint tokens. Given to the pool contracts for their bond and leverage tokens.
pools
Array to store addresses of created pools
governance
Address of the governance contract
oracleFeeds
Address of the OracleFeeds contract
deployer
Instance of the Deployer contract
poolBeacon
Address of the UpgradeableBeacon for Pool
bondBeacon
Address of the UpgradeableBeacon for BondToken
leverageBeacon
Address of the UpgradeableBeacon for LeverageToken
distributorBeacon
Address of the UpgradeableBeacon for Distributor
distributors
Mapping to store distributor addresses for each pool
Functions
constructor
Note: oz-upgrades-unsafe-allow: constructor
initialize
Initializes the contract with the governance address and sets up roles. This function is called once during deployment or upgrading to initialize state variables.
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the governance account that will have the GOV_ROLE. |
|
| Address of the Deployer contract. |
|
| Address of the OracleFeeds contract. |
|
| Address of the Pool implementation contract. |
|
| Address of the BondToken implementation contract. |
|
| Address of the LeverageToken implementation contract. |
|
| Address of the Distributor implementation contract. |
createPool
Creates a new pool with the given parameters
Parameters
Name | Type | Description |
---|---|---|
|
| Struct containing pool parameters |
|
| Amount of reserve tokens to seed the pool |
|
| Amount of bond tokens to mint |
|
| Amount of leverage tokens to mint |
|
| |
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| Address of the newly created pool |
poolsLength
Returns the number of pools created.
Returns
Name | Type | Description |
---|---|---|
|
| The length of the pools array. |
grantRole
Grants role
to account
. If account
had not been already granted role
, emits a {RoleGranted} event.
Parameters
Name | Type | Description |
---|---|---|
|
| The role to grant |
|
| The account to grant the role to |
revokeRole
Revokes role
from account
. If account
had been granted role
, emits a {RoleRevoked} event.
Parameters
Name | Type | Description |
---|---|---|
|
| The role to revoke |
|
| The account to revoke the role from |
pause
Pauses contract. Reverts any interaction except upgrade.
unpause
Unpauses contract.
_authorizeUpgrade
Authorizes an upgrade to a new implementation. Can only be called by the owner of the contract.
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the new implementation |
Events
PoolCreated
Emitted when a new pool is created
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the newly created pool |
|
| Amount of reserve tokens |
|
| Amount of bond tokens |
|
| Amount of leverage tokens |
Errors
ZeroDebtAmount
Error thrown when bond amount is zero
ZeroReserveAmount
Error thrown when reserve amount is zero
ZeroLeverageAmount
Error thrown when leverage amount is zero
Structs
PoolParams
Last updated