Plaza Finance
  • Plaza Overview
  • What are programmable derivatives?
  • Plaza Assets
    • bondETH - An Ethereum-backed Bond
    • levETH - Levered Ethereum
  • Plaza Points (PP)
    • Season 2 Guide
    • Season 1 Guide
    • Pre-Season Guide
  • Protocol Mechanics
    • Create (Buy)
    • Redeem (Sell)
    • Claiming Coupons
    • Coupon Distributions
    • Coupon Auction
  • Contracts
    • Addresses
    • Pool
    • PoolFactory
    • Distributor
    • Auction
    • BondToken
    • LeverageToken
    • BalancerOracleAdapter
    • Audit Reports
  • Miscellaneous
    • Terms of Service
Powered by GitBook
On this page
  • State Variables
  • Functions
  • Events
  • Errors
  • Structs
  1. Contracts

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.

bytes32 public constant GOV_ROLE = keccak256("GOV_ROLE");

POOL_ROLE

Role identifier for users that can interact with the factory to create new pools.

bytes32 public constant POOL_ROLE = keccak256("POOL_ROLE");

MINTER_ROLE

Role identifier for accounts that can mint tokens. Given to the pool contracts for their bond and leverage tokens.

bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

pools

Array to store addresses of created pools

address[] public pools;

governance

Address of the governance contract

address public governance;

oracleFeeds

Address of the OracleFeeds contract

address public oracleFeeds;

deployer

Instance of the Deployer contract

Deployer private deployer;

poolBeacon

Address of the UpgradeableBeacon for Pool

address public poolBeacon;

bondBeacon

Address of the UpgradeableBeacon for BondToken

address public bondBeacon;

leverageBeacon

Address of the UpgradeableBeacon for LeverageToken

address public leverageBeacon;

distributorBeacon

Address of the UpgradeableBeacon for Distributor

address public distributorBeacon;

distributors

Mapping to store distributor addresses for each pool

mapping(address => address) public distributors;

Functions

constructor

Note: oz-upgrades-unsafe-allow: constructor

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.

function initialize(
    address _governance,
    address _deployer,
    address _oracleFeeds,
    address _poolImplementation,
    address _bondImplementation,
    address _leverageImplementation,
    address _distributorImplementation
) public initializer;

Parameters

Name
Type
Description

_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

function createPool(
    PoolParams calldata params,
    uint256 reserveAmount,
    uint256 bondAmount,
    uint256 leverageAmount,
    string memory bondName,
    string memory bondSymbol,
    string memory leverageName,
    string memory leverageSymbol
) external whenNotPaused onlyRole(POOL_ROLE) returns (address);

Parameters

Name
Type
Description

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

Name
Type
Description

<none>

address

Address of the newly created pool

poolsLength

Returns the number of pools created.

function poolsLength() external view returns (uint256);

Returns

Name
Type
Description

<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.

function grantRole(bytes32 role, address account) public virtual override onlyRole(GOV_ROLE);

Parameters

Name
Type
Description

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.

function revokeRole(bytes32 role, address account) public virtual override onlyRole(GOV_ROLE);

Parameters

Name
Type
Description

role

bytes32

The role to revoke

account

address

The account to revoke the role from

pause

Pauses contract. Reverts any interaction except upgrade.

function pause() external onlyRole(GOV_ROLE);

unpause

Unpauses contract.

function unpause() external onlyRole(GOV_ROLE);

_authorizeUpgrade

Authorizes an upgrade to a new implementation. Can only be called by the owner of the contract.

function _authorizeUpgrade(address newImplementation) internal override onlyRole(GOV_ROLE);

Parameters

Name
Type
Description

newImplementation

address

Address of the new implementation

Events

PoolCreated

Emitted when a new pool is created

event PoolCreated(address pool, uint256 reserveAmount, uint256 bondAmount, uint256 leverageAmount);

Parameters

Name
Type
Description

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

error ZeroDebtAmount();

ZeroReserveAmount

Error thrown when reserve amount is zero

error ZeroReserveAmount();

ZeroLeverageAmount

Error thrown when leverage amount is zero

error ZeroLeverageAmount();

Structs

PoolParams

struct PoolParams {
    uint256 fee;
    address reserveToken;
    address couponToken;
    uint256 distributionPeriod;
    uint256 sharesPerToken;
    address feeBeneficiary;
}
PreviousPoolNextDistributor

Last updated 5 months ago

Page cover image