GM Lending Pool Factory

This Factory contract deploys Lending Pool contracts and creates and stores a pool ID for future lookup. The Factory inherits from Solmate's Auth contract. The functions are:

constructor

The constructor assigns the owner and Authority roles (both hereafter referred to as Admin) to the addresses that the deployer passes in as arguments.

Parameters:

Name
Type
Description

_owner

address

The owner of the Factory

_authority

Authority

The Authority of the Factory

deployLendingPool

function deployLendingPool(string memory name) external returns (LendingPool pool, uint256 index) 

Uses the name provided, a poolNumber counter, as well as the CREATE2 opcode, to deploy a Lending Pool contract with a unique combination of pool ID and name. Upon success, the call emits a PoolDeployed event with the pool ID, the LendingPool contract, and the caller's address.

Parameters:

Name
Type
Description

name

string memory

The deployer-defined name of the Lending Pool

Returns:

Name
Type
Description

pool

LendingPool

The Lending Pool contract instance

index

uint256

The ID of the deployed pool contract

getPoolFromNumber

function getPoolFromNumber(uint256 id) external view returns (LendingPool pool) 

Uses the user-provided pool ID to retrieve the associated pool contract, by converting the CREATE2 hash into a contract instance.

Parameters:

Name
Type
Description

id

uint256

The ID of a Lending Pool contract

Returns:

Name
Type
Description

pool

LendingPool

The Lending Pool contract instance

Last updated