Skip to content

VaultFactoryVariables ​

ERC721_NAME ​

solidity
string ERC721_NAME

ERC721 tokens name

ERC721_SYMBOL ​

solidity
string ERC721_SYMBOL

ERC721 tokens symbol

_deployers ​

solidity
mapping(address => bool) _deployers

deployer can deploy new Vault contract owner can add/remove deployer. Owner is deployer by default.

_globalAuths ​

solidity
mapping(address => bool) _globalAuths

global auths can update any vault config. owner can add/remove global auths. Owner is global auth by default.

_vaultAuths ​

solidity
mapping(address => mapping(address => bool)) _vaultAuths

vault auths can update specific vault config. owner can add/remove vault auths. Owner is vault auth by default. vault => auth => add/remove

_totalVaults ​

solidity
uint256 _totalVaults

total no of vaults deployed by the factory only addresses that have deployer role or owner can deploy new vault.

_vaultDeploymentLogics ​

solidity
mapping(address => bool) _vaultDeploymentLogics

vault deployment logics for deploying vault These logic contracts hold the deployment logics of specific vaults and are called via .delegatecall inside deployVault(). only addresses that have owner can add/remove new vault deployment logic.

constructor ​

solidity
constructor(address owner_) internal

VaultFactoryEvents ​

VaultDeployed ​

solidity
event VaultDeployed(address vault, uint256 vaultId)

Emitted when a new vault is deployed.

Parameters ​

NameTypeDescription
vaultaddressThe address of the newly deployed vault.
vaultIduint256The id of the newly deployed vault.

NewPositionMinted ​

solidity
event NewPositionMinted(address vault, address user, uint256 tokenId)

Emitted when a new token/position is minted by a vault.

Parameters ​

NameTypeDescription
vaultaddressThe address of the vault that minted the token.
useraddressThe address of the user who received the minted token.
tokenIduint256The ID of the newly minted token.

LogSetDeployer ​

solidity
event LogSetDeployer(address deployer, bool allowed)

Emitted when the deployer is modified by owner.

Parameters ​

NameTypeDescription
deployeraddressAddress whose deployer status is updated.
allowedboolIndicates whether the address is authorized as a deployer or not.

LogSetGlobalAuth ​

solidity
event LogSetGlobalAuth(address globalAuth, bool allowed)

Emitted when the globalAuth is modified by owner.

Parameters ​

NameTypeDescription
globalAuthaddressAddress whose globalAuth status is updated.
allowedboolIndicates whether the address is authorized as a deployer or not.

LogSetVaultAuth ​

solidity
event LogSetVaultAuth(address vaultAuth, bool allowed, address vault)

Emitted when the vaultAuth is modified by owner.

Parameters ​

NameTypeDescription
vaultAuthaddressAddress whose vaultAuth status is updated.
allowedboolIndicates whether the address is authorized as a deployer or not.
vaultaddressAddress of the specific vault related to the authorization change.

LogSetVaultDeploymentLogic ​

solidity
event LogSetVaultDeploymentLogic(address vaultDeploymentLogic, bool allowed)

Emitted when the vault deployment logic is modified by owner.

Parameters ​

NameTypeDescription
vaultDeploymentLogicaddressThe address of the vault deployment logic contract.
allowedboolIndicates whether the address is authorized as a deployer or not.

VaultFactoryCore ​

constructor ​

solidity
constructor(address owner_) internal

validAddress ​

solidity
modifier validAddress(address value_)

validates that an address is not the zero address

VaultFactoryAuth ​

Implements Vault Factory auth-only callable methods. Owner / auths can set various config values and can define the allow-listed deployers.

setDeployer ​

solidity
function setDeployer(address deployer_, bool allowed_) external

Sets an address (deployer_) as allowed deployer or not. This function can only be called by the owner.

Parameters ​

NameTypeDescription
deployer_addressThe address to be set as deployer.
allowed_boolA boolean indicating whether the specified address is allowed to deploy vaults.

setGlobalAuth ​

solidity
function setGlobalAuth(address globalAuth_, bool allowed_) external

Sets an address (globalAuth_) as a global authorization or not. This function can only be called by the owner.

Parameters ​

NameTypeDescription
globalAuth_addressThe address to be set as global authorization.
allowed_boolA boolean indicating whether the specified address is allowed to update any vault config.

setVaultAuth ​

solidity
function setVaultAuth(address vault_, address vaultAuth_, bool allowed_) external

Sets an address (vaultAuth_) as allowed vault authorization or not for a specific vault (vault_). This function can only be called by the owner.

Parameters ​

NameTypeDescription
vault_addressThe address of the vault for which the authorization is being set.
vaultAuth_addressThe address to be set as vault authorization.
allowed_boolA boolean indicating whether the specified address is allowed to update the specific vault config.

setVaultDeploymentLogic ​

solidity
function setVaultDeploymentLogic(address deploymentLogic_, bool allowed_) public

Sets an address as allowed vault deployment logic (deploymentLogic_) contract or not. This function can only be called by the owner.

Parameters ​

NameTypeDescription
deploymentLogic_addressThe address of the vault deployment logic contract to be set.
allowed_boolA boolean indicating whether the specified address is allowed to deploy new type of vault.

spell ​

solidity
function spell(address target_, bytes data_) external returns (bytes response_)

Spell allows owner aka governance to do any arbitrary call on factory

Parameters ​

NameTypeDescription
target_addressAddress to which the call needs to be delegated
data_bytesData to execute at the delegated address

isDeployer ​

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

Checks if the provided address (deployer_) is authorized as a deployer.

Parameters ​

NameTypeDescription
deployer_addressThe address to be checked for deployer authorization.

Return Values ​

NameTypeDescription
[0]boolReturns true if the address is a deployer, otherwise false.

isGlobalAuth ​

solidity
function isGlobalAuth(address globalAuth_) public view returns (bool)

Checks if the provided address (globalAuth_) has global vault authorization privileges.

Parameters ​

NameTypeDescription
globalAuth_addressThe address to be checked for global authorization privileges.

Return Values ​

NameTypeDescription
[0]boolReturns true if the given address has global authorization privileges, otherwise false.

isVaultAuth ​

solidity
function isVaultAuth(address vault_, address vaultAuth_) public view returns (bool)

Checks if the provided address (vaultAuth_) has vault authorization privileges for the specified vault (vault_).

Parameters ​

NameTypeDescription
vault_addressThe address of the vault to check.
vaultAuth_addressThe address to be checked for vault authorization privileges.

Return Values ​

NameTypeDescription
[0]boolReturns true if the given address has vault authorization privileges for the specified vault, otherwise false.

isVaultDeploymentLogic ​

solidity
function isVaultDeploymentLogic(address vaultDeploymentLogic_) public view returns (bool)

Checks if the provided (vaultDeploymentLogic_) address has authorization for vault deployment.

Parameters ​

NameTypeDescription
vaultDeploymentLogic_addressThe address of the vault deploy logic to check for authorization privileges.

Return Values ​

NameTypeDescription
[0]boolReturns true if the given address has authorization privileges for vault deployment, otherwise false.

VaultFactoryDeployment ​

implements VaultFactory deploy vault related methods.

_deploy ​

solidity
function _deploy(bytes bytecode_) internal returns (address address_)

_Deploys a contract using the CREATE opcode with the provided bytecode (bytecode_). This is an internal function, meant to be used within the contract to facilitate the deployment of other contracts._

Parameters ​

NameTypeDescription
bytecode_bytesThe bytecode of the contract to be deployed.

Return Values ​

NameTypeDescription
address_addressReturns the address of the deployed contract.

deployVault ​

solidity
function deployVault(address vaultDeploymentLogic_, bytes vaultDeploymentData_) external returns (address vault_)

Deploys a new vault using the specified deployment logic vaultDeploymentLogic_ and data vaultDeploymentData_. Only accounts with deployer access or the owner can deploy a new vault.

Parameters ​

NameTypeDescription
vaultDeploymentLogic_addressThe address of the vault deployment logic contract.
vaultDeploymentData_bytesThe data to be used for vault deployment.

Return Values ​

NameTypeDescription
vault_addressReturns the address of the newly deployed vault.

getVaultAddress ​

solidity
function getVaultAddress(uint256 vaultId_) public view returns (address vault_)

Computes the address of a vault based on its given ID (vaultId_).

Parameters ​

NameTypeDescription
vaultId_uint256The ID of the vault.

Return Values ​

NameTypeDescription
vault_addressReturns the computed address of the vault.

isVault ​

solidity
function isVault(address vault_) public view returns (bool)

Checks if a given address (vault_) corresponds to a valid vault.

Parameters ​

NameTypeDescription
vault_addressThe vault address to check.

Return Values ​

NameTypeDescription
[0]boolReturns true if the given address corresponds to a valid vault, otherwise false.

totalVaults ​

solidity
function totalVaults() external view returns (uint256)

Returns the total number of vaults deployed by the factory.

Return Values ​

NameTypeDescription
[0]uint256Returns the total number of vaults.

VaultFactoryERC721 ​

mint ​

solidity
function mint(uint256 vaultId_, address user_) external returns (uint256 tokenId_)

Mints a new ERC721 token for a specific vault (vaultId_) to a specified user (user_). Only the corresponding vault is authorized to mint a token.

Parameters ​

NameTypeDescription
vaultId_uint256The ID of the vault that's minting the token.
user_addressThe address receiving the minted token.

Return Values ​

NameTypeDescription
tokenId_uint256The ID of the newly minted token.

tokenURI ​

solidity
function tokenURI(uint256 id_) public view virtual returns (string)

Returns the URI of the specified token ID (id_). In this implementation, an empty string is returned as no specific URI is defined.

Parameters ​

NameTypeDescription
id_uint256The ID of the token to query.

Return Values ​

NameTypeDescription
[0]stringAn empty string since no specific URI is defined in this implementation.

FluidVaultFactory ​

creates Fluid vault protocol vaults, which are interacting with Fluid Liquidity to deposit / borrow funds. Vaults are created at a deterministic address, given an incrementing vaultId (see getVaultAddress()). Vaults can only be deployed by allow-listed deployer addresses. This factory also implements ERC721-Enumerable, the NFTs are used to represent created user positions. Only vaults can mint new NFTs.

Note the deployed vaults start 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 vault deployment logic contracts for new, future vaults.

constructor ​

solidity
constructor(address owner_) public