OriginationPoolScheduler
Inherits: Initializable, ERC165Upgradeable, AccessControlUpgradeable, UUPSUpgradeable, IOriginationPoolScheduler
Title: OriginationPoolScheduler
Author: SocksNFlops
The OriginationPoolScheduler contract manages the creation and configuration of origination pools
State Variables
OriginationPoolSchedulerStorageLocation
The storage location of the OriginationPoolScheduler contract
keccak256(abi.encode(uint256(keccak256("buttonwood.storage.OriginationPoolScheduler")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OriginationPoolSchedulerStorageLocation =
0x51ba61e21d0a5bc73e422280ccd2621682937c38ec72703c8f08348fe6a50f00
Functions
_getOriginationPoolSchedulerStorage
Gets the storage location of the OriginationPoolScheduler contract
function _getOriginationPoolSchedulerStorage() private pure returns (OriginationPoolSchedulerStorage storage $);
Returns
| Name | Type | Description |
|---|---|---|
$ | OriginationPoolSchedulerStorage | The storage location of the OriginationPoolScheduler contract |
__OriginationPoolScheduler_init
Initializes the OriginationPoolScheduler contract and calls parent initializers
function __OriginationPoolScheduler_init(address generalManager_, address oPoolAdmin_) internal onlyInitializing;
Parameters
| Name | Type | Description |
|---|---|---|
generalManager_ | address | The address of the general manager |
oPoolAdmin_ | address | The address of the oPool admin |
__OriginationPoolScheduler_init_unchained
Initializes the OriginationPoolScheduler contract only
function __OriginationPoolScheduler_init_unchained(address generalManager_, address oPoolAdmin_)
internal
onlyInitializing;
Parameters
| Name | Type | Description |
|---|---|---|
generalManager_ | address | The address of the general manager |
oPoolAdmin_ | address | The address of the oPool admin |
initialize
Initializes the OriginationPoolScheduler contract
function initialize(address generalManager_, address oPoolAdmin_) external initializer;
Parameters
| Name | Type | Description |
|---|---|---|
generalManager_ | address | The address of the general manager |
oPoolAdmin_ | address | The address of the oPool admin |
constructor
Note: oz-upgrades-unsafe-allow: constructor
constructor() ;
whenNotPaused
Modifier to check if the contract is paused
modifier whenNotPaused() ;
_authorizeUpgrade
Authorizes the upgrade of the contract. Only the admin can authorize the upgrade
function _authorizeUpgrade(address newImplementation) internal virtual override onlyRole(Roles.DEFAULT_ADMIN_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
newImplementation | address | The address of the new implementation |
_getRawEpoch
Gets the raw internal epoch needed for calculating timestamps
function _getRawEpoch() internal view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The raw epoch |
supportsInterface
Returns true if this contract implements the interface defined by
interfaceId. See the corresponding
https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
to learn more about how these ids are created.
This function call must use less than 30 000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
override(AccessControlUpgradeable, ERC165Upgradeable)
returns (bool);
setGeneralManager
Set the general manager address
function setGeneralManager(address newGeneralManager) external override onlyRole(Roles.DEFAULT_ADMIN_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
newGeneralManager | address | The address of the new general manager |
generalManager
Get the general manager address
function generalManager() public view override returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the general manager |
setOpoolAdmin
Set the admin address that is assigned to the origination pools on deployment
function setOpoolAdmin(address newOpoolAdmin) external override onlyRole(Roles.DEFAULT_ADMIN_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
newOpoolAdmin | address | The address of the new origination pool admin |
oPoolAdmin
Get the admin address that is assigned to the origination pools on deployment
function oPoolAdmin() public view override returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the origination pool admin |
configLength
Get the number of origination pool configs
function configLength() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The number of origination pool configs |
configIdAt
Get the origination pool config ID at the given index
function configIdAt(uint256 index) public view override returns (OPoolConfigId oPoolConfigId);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index of the origination pool config to get the ID for |
Returns
| Name | Type | Description |
|---|---|---|
oPoolConfigId | OPoolConfigId | The ID of the origination pool config |
configAt
Get the origination pool config at the given index
function configAt(uint256 index) public view override returns (OriginationPoolConfig memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index of the origination pool config to get |
Returns
| Name | Type | Description |
|---|---|---|
<none> | OriginationPoolConfig | config The origination pool config |
lastConfigDeployment
Get the last deployment address from the given config index
function lastConfigDeployment(uint256 index)
public
view
override
returns (LastDeploymentRecord memory lastDeploymentRecord);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index of the origination pool config to get the last deployment address from |
Returns
| Name | Type | Description |
|---|---|---|
lastDeploymentRecord | LastDeploymentRecord | The last deployment record |
lastConfigDeployment
Get the last deployment address from the given config ID
function lastConfigDeployment(OPoolConfigId oPoolConfigId)
public
view
override
returns (LastDeploymentRecord memory lastDeploymentRecord);
Parameters
| Name | Type | Description |
|---|---|---|
oPoolConfigId | OPoolConfigId | The ID of the origination pool config to get the last deployment address from |
Returns
| Name | Type | Description |
|---|---|---|
lastDeploymentRecord | LastDeploymentRecord | The last deployment record |
addConfig
Add a new origination pool config
function addConfig(OriginationPoolConfig memory config) external override onlyRole(Roles.DEFAULT_ADMIN_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
config | OriginationPoolConfig | The origination pool config to add |
removeConfig
Remove an origination pool config
function removeConfig(OriginationPoolConfig memory config) external override onlyRole(Roles.DEFAULT_ADMIN_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
config | OriginationPoolConfig | The origination pool config to remove |
currentEpoch
Get the current epoch. Indexed from 1
function currentEpoch() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | currentEpoch The current epoch |
_updateRegistration
Updates the registration of an origination pool
function _updateRegistration(address originationPool, bool registered) internal;
Parameters
| Name | Type | Description |
|---|---|---|
originationPool | address | The address of the origination pool |
registered | bool | Whether the origination pool is registered |
_getOriginationPoolBytecode
Generates the bytecode for an origination pool
function _getOriginationPoolBytecode(
OriginationPoolConfig memory config,
LastDeploymentRecord memory lastDeploymentRecord,
uint256 currEpoch
) internal view returns (bytes memory bytecode);
Parameters
| Name | Type | Description |
|---|---|---|
config | OriginationPoolConfig | The config for the origination pool |
lastDeploymentRecord | LastDeploymentRecord | The last deployment record for the origination pool |
currEpoch | uint256 | The current epoch |
Returns
| Name | Type | Description |
|---|---|---|
bytecode | bytes | The bytecode for the origination pool |
_deployOriginationPool
Deploys an origination pool
function _deployOriginationPool(
OriginationPoolConfig memory config,
LastDeploymentRecord memory lastDeploymentRecord,
address _generalManager,
address _oPoolAdmin,
uint256 currEpoch
) internal returns (address originationPool);
Parameters
| Name | Type | Description |
|---|---|---|
config | OriginationPoolConfig | The config for the origination pool |
lastDeploymentRecord | LastDeploymentRecord | The last deployment record for the origination pool |
_generalManager | address | The address of the general manager |
_oPoolAdmin | address | The address of the oPool admin |
currEpoch | uint256 | The current epoch |
Returns
| Name | Type | Description |
|---|---|---|
originationPool | address | The address of the deployed origination pool |
_calculatePoolLimit
Calculates the pool limit for an origination pool
function _calculatePoolLimit(
LastDeploymentRecord memory lastDeploymentRecord,
uint256 defaultPoolLimit,
uint16 poolLimitGrowthRateBps,
uint256 currEpoch
) internal view returns (uint256 poolLimit);
Parameters
| Name | Type | Description |
|---|---|---|
lastDeploymentRecord | LastDeploymentRecord | The last deployment record for the origination pool |
defaultPoolLimit | uint256 | The default pool limit |
poolLimitGrowthRateBps | uint16 | The pool limit growth rate in basis points |
currEpoch | uint256 | The current epoch |
Returns
| Name | Type | Description |
|---|---|---|
poolLimit | uint256 | The pool limit |
deployOriginationPool
Deploy a new origination pool
function deployOriginationPool(OPoolConfigId oPoolConfigId)
external
whenNotPaused
returns (address deploymentAddress);
Parameters
| Name | Type | Description |
|---|---|---|
oPoolConfigId | OPoolConfigId | The ID of the origination pool config to deploy |
Returns
| Name | Type | Description |
|---|---|---|
deploymentAddress | address | The address of the deployed origination pool |
predictOriginationPool
Predict the origination pool address for the given config ID and current epoch. If already deployed, will return the already deployed address.
function predictOriginationPool(OPoolConfigId oPoolConfigId) external view returns (address deploymentAddress);
Parameters
| Name | Type | Description |
|---|---|---|
oPoolConfigId | OPoolConfigId | The ID of the origination pool config to predict the address for |
Returns
| Name | Type | Description |
|---|---|---|
deploymentAddress | address | The predicted deployment address |
isRegistered
Check if an origination pool is registered (deployed by the scheduler)
function isRegistered(address originationPool) external view override returns (bool registered);
Parameters
| Name | Type | Description |
|---|---|---|
originationPool | address | The address of the origination pool to check |
Returns
| Name | Type | Description |
|---|---|---|
registered | bool | Whether the origination pool is registered |
updateRegistration
Update the registration of an origination pool
function updateRegistration(address originationPool, bool registered)
external
override
onlyRole(Roles.DEFAULT_ADMIN_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
originationPool | address | The address of the origination pool to update the registration for |
registered | bool | Whether the origination pool is registered |
setPaused
Pause or unpause the contract
function setPaused(bool pause) external override onlyRole(Roles.PAUSE_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
pause | bool | The new paused state |
paused
Get the paused state of the contract
function paused() public view override returns (bool);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | The paused state of the contract |
Structs
OriginationPoolSchedulerStorage
The storage for the OriginationPoolScheduler contract
Note: storage-location: erc7201:buttonwood.storage.OriginationPoolScheduler
struct OriginationPoolSchedulerStorage {
address _generalManager;
address _oPoolAdmin;
uint256 _epochCountStart;
OPoolConfigId[] _oPoolConfigIds;
mapping(OPoolConfigId => uint256) _oPoolConfigIndexes;
mapping(OPoolConfigId => OriginationPoolConfig) _oPoolConfigs;
mapping(OPoolConfigId => LastDeploymentRecord) _oPoolLastDeploymentRecords;
mapping(address => bool) _oPoolRegistry;
bool _paused;
}
Properties
| Name | Type | Description |
|---|---|---|
_generalManager | address | The address of the general manager |
_oPoolAdmin | address | The address of the oPool admin |
_epochCountStart | uint256 | The epoch count start (helps start that count from 0 for the current epoch) |
_oPoolConfigIds | OPoolConfigId[] | Array of supported oPool config ids |
_oPoolConfigIndexes | mapping(OPoolConfigId => uint256) | Mapping of ids to their index in the _oPoolConfigIds array |
_oPoolConfigs | mapping(OPoolConfigId => OriginationPoolConfig) | Mapping of ids to the oPool configs |
_oPoolLastDeploymentRecords | mapping(OPoolConfigId => LastDeploymentRecord) | Mapping of ids to the last deployed origination pool with that config |
_oPoolRegistry | mapping(address => bool) | Mapping of origination pool addresses to a boolean indicating if they are registered |
_paused | bool | Whether the contract is paused |