EthMultiVault.sol
Protocol documentation for the Intuition EthMultiVault.sol smart contract.
Contract Information
Inherits:
IEthMultiVault,
Initializable, ReentrancyGuardUpgradeable & PausableUpgradeable from OpenZeppelin
Author: 0xIntuition
Core contract of the Intuition protocol. Manages the creation and management of vaults associated with Atoms & Triples.
State Variables
count
ID of the last vault to be created
VaultState
VaultFees
Mappings
Vault ID -> Atom Data
Hash -> Atom ID
Triple ID -> Vault IDs
Hash -> Triple ID
Vault Id -> (Is Triple)
Triple ID -> Atom ID -> Account Address -> Atom Balance
Write Methods
createAtom
Creates an atom with the given atom data and returns its vault ID. Requires a payment of ETH to cover the atom cost.
Inputs:
bytes calldata atomData
: The data of the atom to be created.
Outputs:
uint256 id
: The vault ID of the created atom.
createTriple
Creates a triple from three given atom IDs and returns its vault ID. Requires a payment of ETH to cover the triple cost.
Inputs:
uint256 subjectId
: Vault ID of the subject atom.uint256 predicateId
: Vault ID of the predicate atom.uint256 objectId
: Vault ID of the object atom.
Outputs:
uint256 id
: The vault ID of the created triple.
depositAtom
Deposits ETH into an atom vault, granting ownership of shares to the specified receiver.
Inputs:
address receiver
: The address to receive the shares.uint256 id
: The vault ID of the atom.
Outputs:
uint256 shares
: Amount of shares minted.
depositTriple
Deposits ETH into a triple vault, granting ownership of shares to the specified receiver.
Inputs:
address receiver
: The address to receive the shares.uint256 id
: The vault ID of the triple.
Outputs:
uint256 shares
: Amount of shares minted.
redeemAtom
Redeems assets from an atom vault in exchange for a specified number of shares. The assets are sent to the specified receiver.
Inputs:
uint256 shares
: Amount of shares to redeem.address receiver
:
Outputs:
uint256 assets
: The amount of assets (ETH) withdrawn.
redeemTriple
Redeems assets from a triple vault in exchange for a specified number of shares. The assets are sent to the specified receiver.
Inputs:
uint256 shares
: Amount of shares to redeem.address receiver
: Address to receive the assets.uint256 id
: The vault ID of the triple.
Outputs:
uint256 assets
: The amount of assets (ETH) withdrawn.
Read Methods
vaults
A mapping that provides information about all vaults, including total assets and shares.
Inputs:
uint256 id
: Vault ID.
Outputs:
Returns a
VaultState
struct for the corresponding vault ID.
previewDeposit
Simulates the deposit process, giving an estimate of the shares that would be minted from a specified amount of assets.
Inputs:
uint256 assets
: Amount of assets to deposit.uint256 id
: Vault ID.
Outputs:
uint256 shares
: Estimated number of shares to be minted from the deposit.
previewRedeem
Simulates the redemption process, estimating the amount of assets that would be returned for a specified number of shares from a given vault.
Inputs:
uint256 shares
: Amount of shares to redeem.uint256 id
: Vault ID.
Outputs:
uint256 assets
: Estimated amount of assets to be returned.
maxRedeem
Returns the maximum number of shares that can be redeemed from the specified vault by the given owner.
Inputs:
address owner
: Address of the account to check.uint256 id
: Vault ID.
Outputs:
uint256 shares
: Maximum amount of shares that can be redeemed by the specified owner.
getVaultBalance
Retrieves the balance of a particular user in a specified vault.
Inputs:
uint256 vaultId
: ID of the vault.address user
: Address of the user.
Outputs:
uint256
: Balance of the user in the specified vault.
currentSharePrice
Calculates and returns the current price per share in the specified vault.
Inputs:
uint256 id
: Vault ID.
Outputs:
uint256 price
: Current share price in the vault.
convertToAssets
Converts a specified number of shares to its equivalent amount in assets for a given vault.
Inputs:
uint256 shares
: Number of shares.uint256 id
: Vault ID.
Outputs:
uint256 assets
: Equivalent amount of assets for the given shares.
convertToShares
Converts a specified amount of assets to its equivalent number of shares in a given vault.
Inputs:
uint256 assets
: Amount of assets.uint256 id
: Vault ID.
Outputs:
uint256 shares
: Equivalent amount of shares for the given assets.
vaultFees
A mapping that provides information about the fees associated with each vault.
Inputs:
uint256 id
: Vault ID.
Outputs:
Returns a
VaultFees
struct for the corresponding vault ID.
getVaultStates
Returns the states (including total assets and shares) of all vaults.
Inputs: None.
Outputs:
Types.VaultState[] memory states
: An array ofVaultState
structures for all vaults.
isTriple
Checks if a given vault ID represents a triple.
Inputs:
uint256 id
: Vault ID.
Outputs:
bool
: Indicates whether the specified vault ID corresponds to a triple.
Last updated