LendingFactoryVariables

LIQUIDITY

contract IFluidLiquidity LIQUIDITY

address of the Liquidity contract.

_NATIVE_TOKEN_ADDRESS

address _NATIVE_TOKEN_ADDRESS

address that is mapped to the chain native token

_auths

mapping(address => uint256) _auths

auths can update rewards related config at created fToken contracts. owner can add/remove auths. Owner is auth by default.

_deployers

mapping(address => uint256) _deployers

deployers can deploy new fTokens. owner can add/remove deployers. Owner is deployer by default.

_allTokens

address[] _allTokens

list of all created tokens. Solidity creates an automatic getter only to fetch at a certain position, so explicitly define a getter that returns all.

_fTokenTypes

string[] _fTokenTypes

available fTokenTypes for deployment. At least EIP2612Deposits, Permit2Deposits, NativeUnderlying. Solidity creates an automatic getter only to fetch at a certain position, so explicitly define a getter that returns all.

_fTokenCreationCodePointers

mapping(bytes32 => address) _fTokenCreationCodePointers

fToken creation code for each fTokenType, accessed via SSTORE2. maps keccak256(abi.encode(fTokenType)) -> SSTORE2 written creation code for the fToken contract

constructor

constructor(contract IFluidLiquidity liquidity_, address owner_) internal

allTokens

function allTokens() public view returns (address[])

list of all created tokens

fTokenTypes

function fTokenTypes() public view returns (string[])

list of all fToken types that can be deployed

fTokenCreationCode

function fTokenCreationCode(string fTokenType_) public view returns (bytes)

returns the creation code for a certain fTokenType_

LendingFactoryAdmin

validAddress

modifier validAddress(address value_)

validates that an address is not the zero address

onlyAuths

modifier onlyAuths()

validates that msg.sender is auth or owner

onlyDeployers

modifier onlyDeployers()

validates that msg.sender is deployer or owner

isAuth

function isAuth(address auth_) public view returns (bool)

reads if a certain auth_ address is an allowed auth or not. Owner is auth by default.

isDeployer

function isDeployer(address deployer_) public view returns (bool)

reads if a certain deployer_ address is an allowed deployer or not. Owner is deployer by default.

setAuth

function setAuth(address auth_, bool allowed_) external

Sets an address as allowed auth or not. Only callable by owner.

Parameters

NameTypeDescription
auth_addressaddress to set auth value for
allowed_boolbool flag for whether address is allowed as auth or not

setDeployer

function setDeployer(address deployer_, bool allowed_) external

Sets an address as allowed deployer or not. Only callable by owner.

Parameters

NameTypeDescription
deployer_addressaddress to set deployer value for
allowed_boolbool flag for whether address is allowed as deployer or not

setFTokenCreationCode

function setFTokenCreationCode(string fTokenType_, bytes creationCode_) external

Sets the creationCode_ bytecode for a certain fTokenType_. Only callable by auths.

Parameters

NameTypeDescription
fTokenType_stringthe fToken Type used to refer the creation code
creationCode_bytescontract creation code. can be set to bytes(0) to remove a previously available fTokenType_

createToken

function createToken(address asset_, string fTokenType_, bool isNativeUnderlying_) external returns (address token_)

creates token for asset_ for a lending protocol with interest. Only callable by deployers.

Parameters

NameTypeDescription
asset_addressaddress of the asset
fTokenType_stringtype of fToken: - if it's the native token, it should use NativeUnderlying - otherwise it should use fToken - could be more types available, check fTokenTypes()
isNativeUnderlying_boolflag to signal fToken type that uses native underlying at Liquidity

Return Values

NameTypeDescription
token_addressaddress of the created token

_getSalt

function _getSalt(address asset_, string fTokenType_) internal pure returns (bytes32)

_gets the CREATE3 salt for asset_andfTokenType**

FluidLendingFactory

creates Fluid lending protocol fTokens, which are interacting with Fluid Liquidity. fTokens are ERC20 & ERC4626 compatible tokens that allow to deposit to Fluid Liquidity to earn interest. Tokens are created at a deterministic address (see computeToken()), only executable by allow-listed auths.

Note the deployed token starts out with no config at Liquidity contract. This must be done by Liquidity auths in a separate step, otherwise no deposits will be possible. This contract is not upgradeable. It supports adding new fToken creation codes for future new fToken types.

constructor

constructor(contract IFluidLiquidity liquidity_, address owner_) public

initialize liquidity contract address & owner

computeToken

function computeToken(address asset_, string fTokenType_) public view returns (address token_)

computes deterministic token address for asset_ for a lending protocol

Parameters

NameTypeDescription
asset_addressaddress of the asset
fTokenType_stringtype of fToken: - if it's the native token, it should use NativeUnderlying - otherwise it should use fToken - could be more types available, check fTokenTypes()

Return Values

NameTypeDescription
token_addressdetemrinistic address of the computed token