Skip to main content

OriginationPoolScheduler

Git Source

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

NameTypeDescription
$OriginationPoolSchedulerStorageThe 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

NameTypeDescription
generalManager_addressThe address of the general manager
oPoolAdmin_addressThe address of the oPool admin

__OriginationPoolScheduler_init_unchained

Initializes the OriginationPoolScheduler contract only

function __OriginationPoolScheduler_init_unchained(address generalManager_, address oPoolAdmin_)
internal
onlyInitializing;

Parameters

NameTypeDescription
generalManager_addressThe address of the general manager
oPoolAdmin_addressThe address of the oPool admin

initialize

Initializes the OriginationPoolScheduler contract

function initialize(address generalManager_, address oPoolAdmin_) external initializer;

Parameters

NameTypeDescription
generalManager_addressThe address of the general manager
oPoolAdmin_addressThe 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

NameTypeDescription
newImplementationaddressThe address of the new implementation

_getRawEpoch

Gets the raw internal epoch needed for calculating timestamps

function _getRawEpoch() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
newGeneralManageraddressThe address of the new general manager

generalManager

Get the general manager address

function generalManager() public view override returns (address);

Returns

NameTypeDescription
<none>addressThe 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

NameTypeDescription
newOpoolAdminaddressThe 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

NameTypeDescription
<none>addressThe address of the origination pool admin

configLength

Get the number of origination pool configs

function configLength() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
indexuint256The index of the origination pool config to get the ID for

Returns

NameTypeDescription
oPoolConfigIdOPoolConfigIdThe 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

NameTypeDescription
indexuint256The index of the origination pool config to get

Returns

NameTypeDescription
<none>OriginationPoolConfigconfig 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

NameTypeDescription
indexuint256The index of the origination pool config to get the last deployment address from

Returns

NameTypeDescription
lastDeploymentRecordLastDeploymentRecordThe 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

NameTypeDescription
oPoolConfigIdOPoolConfigIdThe ID of the origination pool config to get the last deployment address from

Returns

NameTypeDescription
lastDeploymentRecordLastDeploymentRecordThe last deployment record

addConfig

Add a new origination pool config

function addConfig(OriginationPoolConfig memory config) external override onlyRole(Roles.DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
configOriginationPoolConfigThe origination pool config to add

removeConfig

Remove an origination pool config

function removeConfig(OriginationPoolConfig memory config) external override onlyRole(Roles.DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
configOriginationPoolConfigThe origination pool config to remove

currentEpoch

Get the current epoch. Indexed from 1

function currentEpoch() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256currentEpoch The current epoch

_updateRegistration

Updates the registration of an origination pool

function _updateRegistration(address originationPool, bool registered) internal;

Parameters

NameTypeDescription
originationPooladdressThe address of the origination pool
registeredboolWhether 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

NameTypeDescription
configOriginationPoolConfigThe config for the origination pool
lastDeploymentRecordLastDeploymentRecordThe last deployment record for the origination pool
currEpochuint256The current epoch

Returns

NameTypeDescription
bytecodebytesThe 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

NameTypeDescription
configOriginationPoolConfigThe config for the origination pool
lastDeploymentRecordLastDeploymentRecordThe last deployment record for the origination pool
_generalManageraddressThe address of the general manager
_oPoolAdminaddressThe address of the oPool admin
currEpochuint256The current epoch

Returns

NameTypeDescription
originationPooladdressThe 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

NameTypeDescription
lastDeploymentRecordLastDeploymentRecordThe last deployment record for the origination pool
defaultPoolLimituint256The default pool limit
poolLimitGrowthRateBpsuint16The pool limit growth rate in basis points
currEpochuint256The current epoch

Returns

NameTypeDescription
poolLimituint256The pool limit

deployOriginationPool

Deploy a new origination pool

function deployOriginationPool(OPoolConfigId oPoolConfigId)
external
whenNotPaused
returns (address deploymentAddress);

Parameters

NameTypeDescription
oPoolConfigIdOPoolConfigIdThe ID of the origination pool config to deploy

Returns

NameTypeDescription
deploymentAddressaddressThe 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

NameTypeDescription
oPoolConfigIdOPoolConfigIdThe ID of the origination pool config to predict the address for

Returns

NameTypeDescription
deploymentAddressaddressThe 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

NameTypeDescription
originationPooladdressThe address of the origination pool to check

Returns

NameTypeDescription
registeredboolWhether 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

NameTypeDescription
originationPooladdressThe address of the origination pool to update the registration for
registeredboolWhether the origination pool is registered

setPaused

Pause or unpause the contract

function setPaused(bool pause) external override onlyRole(Roles.PAUSE_ROLE);

Parameters

NameTypeDescription
pauseboolThe new paused state

paused

Get the paused state of the contract

function paused() public view override returns (bool);

Returns

NameTypeDescription
<none>boolThe 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

NameTypeDescription
_generalManageraddressThe address of the general manager
_oPoolAdminaddressThe address of the oPool admin
_epochCountStartuint256The epoch count start (helps start that count from 0 for the current epoch)
_oPoolConfigIdsOPoolConfigId[]Array of supported oPool config ids
_oPoolConfigIndexesmapping(OPoolConfigId => uint256)Mapping of ids to their index in the _oPoolConfigIds array
_oPoolConfigsmapping(OPoolConfigId => OriginationPoolConfig)Mapping of ids to the oPool configs
_oPoolLastDeploymentRecordsmapping(OPoolConfigId => LastDeploymentRecord)Mapping of ids to the last deployed origination pool with that config
_oPoolRegistrymapping(address => bool)Mapping of origination pool addresses to a boolean indicating if they are registered
_pausedboolWhether the contract is paused