reading vault data.md
Reading Vault Data
Vault state is readable two ways: directly on-chain (standard ERC‑4626) and via the Public API (vault discovery, decoded transactions, performance with live share-price snapshots). Use on-chain reads for per-transaction accounting; prefer the Public API for anything performance- or time-series-related.
On-chain — ERC‑4626
Everything you need for basic accounting is already on the vault:
const vaultViewAbi = [
{type: 'function', stateMutability: 'view', name: 'asset',
inputs: [], outputs: [{type: 'address'}]},
{type: 'function', stateMutability: 'view', name: 'totalAssets',
inputs: [], outputs: [{type: 'uint256'}]},
{type: 'function', stateMutability: 'view', name: 'balanceOf',
inputs: [{type: 'address'}], outputs: [{type: 'uint256'}]},
{type: 'function', stateMutability: 'view', name: 'convertToAssets',
inputs: [{type: 'uint256'}], outputs: [{type: 'uint256'}]},
{type: 'function', stateMutability: 'view', name: 'convertToShares',
inputs: [{type: 'uint256'}], outputs: [{type: 'uint256'}]},
] as const
const [underlying, totalAssets, myShares] = await Promise.all([
client.readContract({address: vault, abi: vaultViewAbi, functionName: 'asset'}),
client.readContract({address: vault, abi: vaultViewAbi, functionName: 'totalAssets'}),
client.readContract({address: vault, abi: vaultViewAbi, functionName: 'balanceOf', args: [owner]}),
])
const myAssets = await client.readContract({
address: vault, abi: vaultViewAbi, functionName: 'convertToAssets',
args: [myShares],
})
Share price is totalAssets / totalSupply. The vault's value per share increases over time as yield compounds.
⚠️
totalAssetsand anything derived from it (share price,convertToAssets,convertToShares) only update when there's a transaction that touches the vault — deposit, withdrawal, rebalance, fee accrual. Between transactions, the on-chain numbers are stale against the underlying positions' live value. If you read the vault at a quiet period, you won't see yield that has accrued in the underlying positions since the last touch.For live, continuously-refreshed share price and performance, use the Public API — it publishes hourly snapshots with values simulated against current on-chain state, so they reflect yield accrued between vault transactions.
Public API — discovery, transactions, performance
For anything beyond bare ERC‑4626 state, use the Public API. It lets you:
- Look up vaults for a single client address or a batch of addresses.
- Fetch per-vault detail (asset, status, shares, fees, assigned strategy).
- Read decoded transaction history (deposits, withdrawals, rebalances).
- Pull performance time-series (APY/APR, TVL, hourly share-price snapshots).
For the full list of endpoints, request / response schemas, and a live "try it" UI, see Reference → Public API — it points to the published Swagger, which is the source of truth and stays in sync with the live service.