Skip to main content

MultiVault

Version: V2
View Markdown

MultiVault is the core of the protocol. It stores every atom and triple, holds the native TRUST behind every vault and mints and burns vault shares. On Intuition mainnet it lives at 0x6E35cF57A41fA15eA0EaE9C33e751b01A784Fe7e. The vaults concept explains the model. This page lists the contract surface.

Terms and their IDs​

A term is an atom or a triple. Its ID is a bytes32 computed from its content, so anyone can calculate it before it exists.

TermID
Atomkeccak256(abi.encodePacked(ATOM_SALT, keccak256(data))). Read it with calculateAtomId(data).
TripleHash of TRIPLE_SALT and the subject, predicate and object IDs. Read it with calculateTripleId(s, p, o).
Counter tripleHash of COUNTER_SALT and the triple ID. Read it with calculateCounterTripleId(s, p, o) or getCounterIdFromTripleId(tripleId).

Every triple has a counter triple, which holds the opposing position. Triple components can be atoms or other triples, so triples can nest. Use isTermCreated, isAtom, isTriple, isCounterTriple and getVaultType(termId) to classify an ID. getAtom(atomId) returns the stored bytes, and getTriple(tripleId) the three component IDs. Both revert for a missing term. getAtomCreator(atomId) and getAtomCreatedAt(atomId) record who created an atom and when.

Create terms​

FunctionNotes
createAtoms(data, assets)One atom per byte string, each with its own deposit. A duplicate atom reverts with MultiVault_AtomExists.
createAtomsWithUris(creator, data, assets, uris)Attaches one list of context URIs per atom. Nonempty lists are emitted in AtomContextRegistered. They are not part of the atom's ID or storage.
createTriples(subjectIds, predicateIds, objectIds, assets)Parallel arrays of equal length. Every component must already exist.
createAtomsFor(creator, data, assets), createTriplesFor(creator, …)Create on behalf of creator, who must have approved the caller for creation.

Each item's assets must cover the creation cost from getAtomCost() or getTripleCost(). Anything above it is deposited into the new term's default-curve vault for the creator. msg.value must equal the sum of assets exactly. A batch holds at most 150 items. Use previewAtomCreate(termId, assets) or previewTripleCreate(s, p, o, assets) to see the shares a creation will mint. See Configuration for the costs and input limits.

Deposit and redeem​

Every vault is identified by a term ID and a curve ID. Keep both when you store or display a position. The bonding curves page lists the curve IDs.

FunctionNotes
deposit(receiver, termId, curveId, minShares)Deposits msg.value and mints shares to receiver. Reverts if fewer than minShares would be minted.
depositBatch(receiver, termIds, curveIds, assets, minShares)Up to 150 deposits. msg.value must equal the sum of assets.
redeem(receiver, termId, curveId, shares, minAssets)Burns the receiver's shares and pays the receiver. Reverts if the payout is below minAssets.
redeemBatch(receiver, termIds, curveIds, shares, minAssets)Up to 150 redemptions.

A new vault on the default curve can only be opened by creating the term. On other curves, the first deposit must cover the minimum-share seed. previewDeposit(termId, curveId, assets) returns the expected shares and assets credited after fees. previewRedeem(termId, curveId, shares) takes no account, so on a curve with account-specific fees the real payout can differ. Read positions with getShares(account, termId, curveId), maxRedeem(account, termId, curveId), getVault(termId, curveId), currentSharePrice(termId, curveId), convertToShares and convertToAssets.

Act for another account​

An account can let another address create, deposit or redeem on its behalf. The account calls approve(sender, approvalType). The approval type is a bit set.

ValueTypeAllows
0NONENothing. Revokes the approval.
1DEPOSITDeposits that mint shares to the approving account
2REDEMPTIONRedemptions that burn and pay the approving account
3BOTHDeposits and redemptions
4CREATIONCreations with the approving account as creator
5DEPOSIT_AND_CREATIONDeposits and creations
6REDEMPTION_AND_CREATIONRedemptions and creations
7ALLAll three

approve replaces the stored value for that sender. Approving CREATION after DEPOSIT leaves only creation approval, so approve the combined value you need. Check with isApprovedToDeposit(sender, receiver), isApprovedToRedeem(sender, receiver) and isApprovedToCreate(sender, creator). FeeProxy relies on these approvals.

Combine calls with multicall​

multicall(data, values) runs several MultiVault calls in one transaction. Each element of data is ABI-encoded calldata for MultiVault, and the matching element of values is the native value that call receives. The values must sum to msg.value. If any call reverts, the whole multicall reverts. A multicall cannot contain another multicall. The proceeds of a redemption are paid out immediately, so they cannot fund a later call in the same multicall.

Fees​

MultiVault charges five kinds of fee, set as numerators over feeDenominator, which is 10,000. The rates below were read at Intuition mainnet block 12,026,592.

FeeMainnet rateCharged onPaid to
Protocol fee1.25%Every deposit and redemptionAccrues per epoch for the protocol multisig
Entry fee0.5%DepositsThe term's default-curve vault, raising its share price
Exit fee0.75%RedemptionsThe term's default-curve vault
Atom wallet deposit fee0.5%Atom creations and depositsThe atom's wallet
Atom deposit fraction0.9%Triple creations and depositsThe default-curve vaults of the triple's subject, predicate and object, split three ways

Creating a term also pays the flat creation fee in getAtomConfig() or getTripleConfig(). Fees from every curve go to the default-curve vault, so holders of the default vault earn from activity on all curves.

To protect a new vault's share price, entry and exit fees are waived until the default-curve vault holds at least feeThreshold shares, which is 1 share on mainnet. The atom deposit fraction is charged only when all three components clear the same threshold. The protocol fee and the atom wallet fee are always charged.

Protocol fees accumulate in accumulatedProtocolFees(epoch). Anyone can call sweepAccumulatedProtocolFees(epoch). It always sends to the configured protocol multisig, never to the caller. The fees and rewards concept walks through a worked example.

Utilization​

MultiVault tracks each account's net deposits per epoch for TrustBonding. Deposits add to utilization and redemptions subtract from it. getUserUtilizationInEpoch(account, epoch) and getTotalUtilizationForEpoch(epoch) feed the reward ratios. currentEpoch() reports the epoch MultiVault uses.

Pausing and administration​

Accounts with PAUSER_ROLE can pause MultiVault. Only the admin can unpause it. While MultiVault is paused, creations, deposits and redemptions revert. Approvals, atom wallet fee claims, protocol fee sweeps and every view keep working.

Every configuration setter, from setGeneralConfig to setWalletConfig, can only be called by the Parameters TimelockController. See Governance for who controls the timelocks.

Encode a deposit​

Pass the intended share floor as minShares. The encoder below produces calldata offline. A payable deposit also needs a target contract and native call value in wei. A preview describes the state read at quote time. Use the confirmed receipt and the target contract's events to determine the actual shares issued.

import { multiVaultDepositEncode } from '@0xintuition/protocol';
import type { Address, Hex } from 'viem';

// Caller-supplied values must describe an existing term and chosen curve.
export function encodeDeposit(
receiver: Address,
termId: Hex,
curveId: bigint,
minShares: bigint,
) {
return multiVaultDepositEncode(receiver, termId, curveId, minShares);
}

MultiVault interface · Term getters · MultiVault · Implementation library · V2 protocol wrappers

Applies to V2 · @0xintuition/protocol 4.1.0