VaultFactoryVariables
ERC721_NAME
string ERC721_NAME
ERC721 tokens name
ERC721_SYMBOL
string ERC721_SYMBOL
ERC721 tokens symbol
_deployers
mapping(address => bool) _deployers
deployer can deploy new Vault contract owner can add/remove deployer. Owner is deployer by default.
_globalAuths
mapping(address => bool) _globalAuths
global auths can update any vault config. owner can add/remove global auths. Owner is global auth by default.
_vaultAuths
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
uint256 _totalVaults
total no of vaults deployed by the factory only addresses that have deployer role or owner can deploy new vault.
_vaultDeploymentLogics
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
constructor(address owner_) internal
VaultFactoryEvents
VaultDeployed
event VaultDeployed(address vault, uint256 vaultId)
Emitted when a new vault is deployed.
Parameters
Name | Type | Description |
---|---|---|
vault | address | The address of the newly deployed vault. |
vaultId | uint256 | The id of the newly deployed vault. |
NewPositionMinted
event NewPositionMinted(address vault, address user, uint256 tokenId)
Emitted when a new token/position is minted by a vault.
Parameters
Name | Type | Description |
---|---|---|
vault | address | The address of the vault that minted the token. |
user | address | The address of the user who received the minted token. |
tokenId | uint256 | The ID of the newly minted token. |
LogSetDeployer
event LogSetDeployer(address deployer, bool allowed)
Emitted when the deployer is modified by owner.
Parameters
Name | Type | Description |
---|---|---|
deployer | address | Address whose deployer status is updated. |
allowed | bool | Indicates whether the address is authorized as a deployer or not. |
LogSetGlobalAuth
event LogSetGlobalAuth(address globalAuth, bool allowed)
Emitted when the globalAuth is modified by owner.
Parameters
Name | Type | Description |
---|---|---|
globalAuth | address | Address whose globalAuth status is updated. |
allowed | bool | Indicates whether the address is authorized as a deployer or not. |
LogSetVaultAuth
event LogSetVaultAuth(address vaultAuth, bool allowed, address vault)
Emitted when the vaultAuth is modified by owner.
Parameters
Name | Type | Description |
---|---|---|
vaultAuth | address | Address whose vaultAuth status is updated. |
allowed | bool | Indicates whether the address is authorized as a deployer or not. |
vault | address | Address of the specific vault related to the authorization change. |
LogSetVaultDeploymentLogic
event LogSetVaultDeploymentLogic(address vaultDeploymentLogic, bool allowed)
Emitted when the vault deployment logic is modified by owner.
Parameters
Name | Type | Description |
---|---|---|
vaultDeploymentLogic | address | The address of the vault deployment logic contract. |
allowed | bool | Indicates whether the address is authorized as a deployer or not. |
VaultFactoryCore
constructor
constructor(address owner_) internal
validAddress
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
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
Name | Type | Description |
---|---|---|
deployer_ | address | The address to be set as deployer. |
allowed_ | bool | A boolean indicating whether the specified address is allowed to deploy vaults. |
setGlobalAuth
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
Name | Type | Description |
---|---|---|
globalAuth_ | address | The address to be set as global authorization. |
allowed_ | bool | A boolean indicating whether the specified address is allowed to update any vault config. |
setVaultAuth
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
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault for which the authorization is being set. |
vaultAuth_ | address | The address to be set as vault authorization. |
allowed_ | bool | A boolean indicating whether the specified address is allowed to update the specific vault config. |
setVaultDeploymentLogic
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
Name | Type | Description |
---|---|---|
deploymentLogic_ | address | The address of the vault deployment logic contract to be set. |
allowed_ | bool | A boolean indicating whether the specified address is allowed to deploy new type of vault. |
spell
function spell(address target_, bytes data_) external returns (bytes response_)
Spell allows owner aka governance to do any arbitrary call on factory
Parameters
Name | Type | Description |
---|---|---|
target_ | address | Address to which the call needs to be delegated |
data_ | bytes | Data to execute at the delegated address |
isDeployer
function isDeployer(address deployer_) public view returns (bool)
Checks if the provided address (deployer_
) is authorized as a deployer.
Parameters
Name | Type | Description |
---|---|---|
deployer_ | address | The address to be checked for deployer authorization. |
Return Values
Name | Type | Description |
---|---|---|
0 | bool | Returns true if the address is a deployer, otherwise false . |
isGlobalAuth
function isGlobalAuth(address globalAuth_) public view returns (bool)
Checks if the provided address (globalAuth_
) has global vault authorization privileges.
Parameters
Name | Type | Description |
---|---|---|
globalAuth_ | address | The address to be checked for global authorization privileges. |
Return Values
Name | Type | Description |
---|---|---|
0 | bool | Returns true if the given address has global authorization privileges, otherwise false . |
isVaultAuth
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
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault to check. |
vaultAuth_ | address | The address to be checked for vault authorization privileges. |
Return Values
Name | Type | Description |
---|---|---|
0 | bool | Returns true if the given address has vault authorization privileges for the specified vault, otherwise false . |
isVaultDeploymentLogic
function isVaultDeploymentLogic(address vaultDeploymentLogic_) public view returns (bool)
Checks if the provided (vaultDeploymentLogic_
) address has authorization for vault deployment.
Parameters
Name | Type | Description |
---|---|---|
vaultDeploymentLogic_ | address | The address of the vault deploy logic to check for authorization privileges. |
Return Values
Name | Type | Description |
---|---|---|
0 | bool | Returns true if the given address has authorization privileges for vault deployment, otherwise false . |
VaultFactoryDeployment
implements VaultFactory deploy vault related methods.
_deploy
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
Name | Type | Description |
---|---|---|
bytecode_ | bytes | The bytecode of the contract to be deployed. |
Return Values
Name | Type | Description |
---|---|---|
address_ | address | Returns the address of the deployed contract. |
deployVault
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
Name | Type | Description |
---|---|---|
vaultDeploymentLogic_ | address | The address of the vault deployment logic contract. |
vaultDeploymentData_ | bytes | The data to be used for vault deployment. |
Return Values
Name | Type | Description |
---|---|---|
vault_ | address | Returns the address of the newly deployed vault. |
getVaultAddress
function getVaultAddress(uint256 vaultId_) public view returns (address vault_)
Computes the address of a vault based on its given ID (vaultId_
).
Parameters
Name | Type | Description |
---|---|---|
vaultId_ | uint256 | The ID of the vault. |
Return Values
Name | Type | Description |
---|---|---|
vault_ | address | Returns the computed address of the vault. |
isVault
function isVault(address vault_) public view returns (bool)
Checks if a given address (vault_
) corresponds to a valid vault.
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The vault address to check. |
Return Values
Name | Type | Description |
---|---|---|
0 | bool | Returns true if the given address corresponds to a valid vault, otherwise false . |
totalVaults
function totalVaults() external view returns (uint256)
Returns the total number of vaults deployed by the factory.
Return Values
Name | Type | Description |
---|---|---|
0 | uint256 | Returns the total number of vaults. |
VaultFactoryERC721
mint
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
Name | Type | Description |
---|---|---|
vaultId_ | uint256 | The ID of the vault that's minting the token. |
user_ | address | The address receiving the minted token. |
Return Values
Name | Type | Description |
---|---|---|
tokenId_ | uint256 | The ID of the newly minted token. |
tokenURI
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
Name | Type | Description |
---|---|---|
id_ | uint256 | The ID of the token to query. |
Return Values
Name | Type | Description |
---|---|---|
0 | string | An 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
constructor(address owner_) public