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
_governance
address
Address of the governance account that will have the GOV_ROLE.
_deployer
address
Address of the Deployer contract.
_oracleFeeds
address
Address of the OracleFeeds contract.
_poolImplementation
address
Address of the Pool implementation contract.
_bondImplementation
address
Address of the BondToken implementation contract.
_leverageImplementation
address
Address of the LeverageToken implementation contract.
_distributorImplementation
address
Address of the Distributor implementation contract.
createPool
Creates a new pool with the given parameters
Parameters
params
PoolParams
Struct containing pool parameters
reserveAmount
uint256
Amount of reserve tokens to seed the pool
bondAmount
uint256
Amount of bond tokens to mint
leverageAmount
uint256
Amount of leverage tokens to mint
bondName
string
bondSymbol
string
leverageName
string
leverageSymbol
string
Returns
<none>
address
Address of the newly created pool
poolsLength
Returns the number of pools created.
Returns
<none>
uint256
The length of the pools array.
grantRole
Grants role
to account
. If account
had not been already granted role
, emits a {RoleGranted} event.
Parameters
role
bytes32
The role to grant
account
address
The account to grant the role to
revokeRole
Revokes role
from account
. If account
had been granted role
, emits a {RoleRevoked} event.
Parameters
role
bytes32
The role to revoke
account
address
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
newImplementation
address
Address of the new implementation
Events
PoolCreated
Emitted when a new pool is created
Parameters
pool
address
Address of the newly created pool
reserveAmount
uint256
Amount of reserve tokens
bondAmount
uint256
Amount of bond tokens
leverageAmount
uint256
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