Comment on page
Factory
mapping(uint256 => bool) public vaultVersionBlocked;
mapping(address => uint256) public vaultIndex;
mapping(uint256 => vaultVersionInfo) public vaultDetails;
bool public newVaultInfoSet;
uint16 public latestVaultVersion;
string public baseURI;
address[] public allVaults;
constructor() ERC721("Arcadia Vault", "ARCADIA");
Function used to create a Vault
This is the starting point of the Vault creation process. Safe to cast a uint256 to a bytes32 since the space of both is 2^256.
function createVault(uint256 salt, uint256 vaultVersion) external returns (address vault);
Parameters
Name | Type | Description |
---|---|---|
salt | uint256 | A salt to be used to generate the hash. |
vaultVersion | uint256 | The Vault version. |
Returns
Name | Type | Description |
---|---|---|
vault | address | The contract address of the proxy contract of the newly deployed vault. |
View function to see if an address is a vault
Function is used to verify if certain calls are to be made to an actual vault or not.
function isVault(address vaultAddr) public view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
vaultAddr | address | The address to be checked. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool whether the address is a vault or not. |
This function allows vault owners to upgrade the logic of the vault.
As each vault is a proxy, the implementation of the proxy can be changed by the owner of the vault. Checks are done such that only compatible versions can be upgraded to. Merkle proofs and their leaves can be found on https://www.github.com/arcadia-finance.
function upgradeVaultVersion(address vault, uint16 version, bytes32[] calldata proofs) external;
Parameters
Name | Type | Description |
---|---|---|
vault | address | Vault that needs to get updated. |
version | uint16 | The vaultversion to upgrade to. |
proofs | bytes32[] | The merkle proofs that prove the compatibility of the upgrade. |
Function to get the latest and current versioning root.
The versioning root is the root of the merkle tree of all the compatible vault versions. The root is updated every time a new vault version is confirmed. The root is used to verify the proofs when a vault is being upgraded.
function getVaultVersionRoot() public view returns (bytes32);
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32 | The latest and current versioning root. |
Function used to transfer a vault between users
This method overwrites the safeTransferFrom function in ERC721.sol to also transfer the vault proxy contract to the new owner.
function safeTransferFrom(address from, address to, uint256 id) public override;
Parameters
Name | Type | Description |
---|---|---|
from | address | sender. |
to | address | target. |
id | uint256 | of the vault that is about to be transfered. |
Function used to transfer a vault between users
This method overwrites the safeTransferFrom function in ERC721.sol to also transfer the vault proxy contract to the new owner.
function safeTransferFrom(address from, address to, uint256 id, bytes memory data) public override;
Parameters
Name | Type | Description |
---|---|---|
from | address | sender. |
to | address | target. |
id | uint256 | of the vault that is about to be transfered. |
data | bytes | additional data, only used for onERC721Received. |
Function used to transfer a vault between users
This method overwrites the safeTransferFrom function in ERC721.sol to also transfer the vault proxy contract to the new owner.
function transferFrom(address from, address to, uint256 id) public override;
Parameters
Name | Type | Description |
---|---|---|
from | address | sender. |
to | address | target. |
id | uint256 | of the vault that is about to be transfered. |
Function to set new contracts to be used for new deployed vaults
Two step function to confirm new logic to be used for new deployed vaults. Changing any of the contracts does NOT change the contracts for already deployed vaults, unless the vault owner explicitly choose to upgrade their vault version to a newer version ToDo Add a time lock between setting a new vault version, and confirming a new vault version Changing any of the logic contracts with this function does NOT immediately take effect, only after the function 'confirmNewVaultInfo' is called. If a new Main Registry contract is set, all the BaseCurrencies currently stored in the Factory (and the corresponding Liquidity Pool Contracts) must also be stored in the new Main registry contract.
function setNewVaultInfo(address registry, address logic, bytes32 versionRoot) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
registry | address | The contract addres of the Main Registry |
logic | address | The contract address of the Vault logic |
versionRoot | bytes32 | The root of the merkle tree of all the compatible vault versions |
Function confirms the new contracts to be used for new deployed vaults
Two step function to confirm new logic to be used for new deployed vaults. Changing any of the contracts does NOT change the contracts for already deployed vaults, unless the vault owner explicitly chooses to upgrade their vault version to a newer version ToDo Add a time lock between setting a new vault version, and confirming a new vault version If no new vault info is being set (newVaultInfoSet is false), this function will not do anything The variable factoryInitialised is set to true as soon as one vault version is confirmed
function confirmNewVaultInfo() public onlyOwner;
Function to block a certain vault logic version from being created as a new vault.
Should any vault logic version be phased out, this function can be used to block it from being created for new vaults.
function blockVaultVersion(uint256 version) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
version | uint256 | The vault version to be phased out. |
Function used by a keeper to start the liquidation of a vault.
This function is called by an external user or a bot to start the liquidation process of a vault.
function liquidate(address vault) external;
Parameters
Name | Type | Description |
---|---|---|
vault | address | Vault that needs to get liquidated. |
Internal function used to start the liquidation of a vault.
**
function _liquidate(address vault, address sender) internal;
Parameters
Name | Type | Description |
---|---|---|
vault | address | Vault that needs to get liquidated. |
sender | address | The msg.sender of the liquidator. Also the 'keeper' |
Helper transfer function that allows the contract to transfer ownership of the erc721.
This function is called by the contract when a vault is liquidated. This includes a transfer of ownership of the vault. We circumvent the ERC721 transfer function.
function _liquidateTransfer(address vault, address liquidator) internal;
Parameters
Name | Type | Description |
---|---|---|
vault | address | Vault that needs to get transfered. |
liquidator | address | |
Function returns the total number of vaults
function allVaultsLength() external view returns (uint256 numberOfVaults);
Returns
Name | Type | Description |
---|---|---|
numberOfVaults | uint256 | The total number of vaults |
Returns address of the most recent Main Registry
function getCurrentRegistry() external view returns (address registry);
Returns
Name | Type | Description |
---|---|---|
registry | address | The contract addres of the Main Registry of the latest Vault Version |
Function that stores a new base URI.
tokenURI's of Arcadia Vaults are not meant to be immutable and might be updated later to allow users to choose/create their own vault art, as such no URI freeze is added.
function setBaseURI(string calldata newBaseURI) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
newBaseURI | string | the new base URI to store |
Function that returns the token URI as defined in the erc721 standard.
function tokenURI(uint256 tokenId) public view override returns (string memory uri);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The id if the vault |
Returns
Name | Type | Description |
---|---|---|
uri | string | The token uri. |
function onERC721Received(address, address, uint256, bytes calldata) public pure returns (bytes4);
struct vaultVersionInfo {
address registry;
address logic;
bytes32 versionRoot;
}
Last modified 8mo ago