Retrieve Vault Details
The Intuition protocol's EthMultiVault contract manages complex state involving Atoms, Triples, and their associated vaults. When interacting with these primitives, we recommend retrieving the state data directly from the EthMultiVault contract.
We utilize multicall operations that batch multiple read-only contract calls into a single request. This approach significantly reduces RPC calls and provides data you'll need for contract interactions, such as the atomCost that is referenced in the contract interaction guides.
Implementation
This implementation guide assumes that you've completed the steps in the Overview guide. Steps for creating the createMultivaultContract and the publicClient referenced in this implementation example can be found in the overview.
We recommend creating a multivault.ts that includes the following:
Core Multicall Configuration
// createMultiVaultcontract
const multiVaultContract = createMultiVaultContract(contract)
// Core multicall configuration
const coreContractConfigs = [
{
...multiVaultContract,
functionName: 'vaults',
args: [vid],
},
{
...multiVaultContract,
functionName: 'currentSharePrice',
args: [vid],
},
// ... additional calls
]
// Execute multicall
const resp: MulticallResponse[] = await publicClient.multicall({
contracts: coreContractConfigs,
})Complete Example
Here is a full example of the multicall pattern used in the getMultivaultConfig function:
Full Implementation
export async function getMultiVaultConfig(contract: string) {
const multiVaultContract = createMultiVaultContract(contract)
const coreContractConfigs = [
{
...multiVaultContract,
functionName: 'generalConfig',
args: [],
},
{
...multiVaultContract,
functionName: 'vaultFees',
args: [0],
},
{
...multiVaultContract,
functionName: 'atomConfig',
args: [],
},
]
const resp: MulticallResponse[] = await publicClient.multicall({
contracts: coreContractConfigs,
})
const admin = resp[0].result[0] as `0x${string}`
const protocol_vault = resp[0].result[1] as `0x${string}`
const fee_denominator = resp[0].result[2] as bigint
const formatted_fee_denominator = formatUnits(fee_denominator, 18)
const min_deposit = resp[0].result[3] as bigint
const formatted_min_deposit = formatUnits(min_deposit, 18)
const min_share = resp[0].result[4] as bigint
const formatted_min_share = formatUnits(min_share, 18)
const entry_fee = resp[1].result[0] as bigint
const formatted_entry_fee = formatUnits(entry_fee, 18)
const exit_fee = resp[1].result[1] as bigint
const formatted_exit_fee = formatUnits(exit_fee, 18)
const protocol_fee = resp[1].result[2] as bigint
const formatted_protocol_fee = formatUnits(protocol_fee, 18)
const atom_cost = resp[2].result[0] as bigint
const formatted_atom_cost = formatUnits(atom_cost, 18)
const atom_creation_fee = resp[2].result[1] as bigint
const formatted_atom_creation_fee = formatUnits(atom_creation_fee, 18)
return {
admin,
protocol_vault,
fee_denominator: fee_denominator.toString(),
formatted_fee_denominator,
min_deposit: min_deposit.toString(),
formatted_min_deposit,
min_share: min_share.toString(),
formatted_min_share,
entry_fee: entry_fee.toString(),
formatted_entry_fee,
exit_fee: exit_fee.toString(),
formatted_exit_fee,
protocol_fee: protocol_fee.toString(),
formatted_protocol_fee,
atom_cost: atom_cost.toString(),
formatted_atom_cost,
atom_creation_fee: atom_creation_fee.toString(),
formatted_atom_creation_fee,
} as MultivaultConfig
}Key Functions
We use this multicall pattern to retrieve configuration that we're able to use throughout the app:
getVaultDetails
Retrieves comprehensive vault information including total assets, conviction, current share price, fee configurations, user-specific positions, and counter-vault details.
getMultiVaultConfig
Retrieves global protocol configuration including fee structures, minimum deposits, and protocol admin addresses.
Usage Example
The full getVaultDetails function follows the same pattern used in the getMultiVaultConfig example but is too large to include in the docs. We recommend looking at the Intuition TypeScript SDK for a full reference implementation.
Basic Usage
// Fetch vault and countervault details with user positions:
const vaultDetails = await getVaultDetails(
MULTIVAULT_CONTRACT_ADDRESS,
vaultId,
userWallet,
counterVaultId
)
// Access formatted values such as atom_cost and triple_cost
console.log({
atomCost: vaultDetails.atom_cost,
tripleCost: vaultDetails.triple_cost,
})Reference Implementation
For a full example of how we implement all of our EthMultiVault multicalls, you can look at a reference implementation in our monorepo:
Best Practices
- Use multicall patterns to reduce RPC calls and improve performance
- Always handle errors gracefully when retrieving vault data
- Cache vault details when possible to reduce redundant calls
- Validate returned data before using it in your application
- Monitor vault state changes and update your UI accordingly
Next Steps
After retrieving vault details, explore:
- Create Atom - Create atoms and manage their vaults
- Create Triple - Create triples with associated vaults
- Deposit & Return - Manage vault deposits and withdrawals
For a full reference implementation, see the Intuition TypeScript SDK.