Get Earn Vault
earn.getVault
Gets a vault's configuration, accounting state, and supported actions.
Usage
import { } from './viem.config'
const = await ..({
: '0x0000000000000000000000000000000000000001',
})
{// assetToken: '0x20c0...0001',// asyncJanitor: '0x0000...0000',
// capabilities: {
// asyncRedeem: false,
// exactWithdraw: true,
// inKindDeposit: true,
// syncRedeem: true,
// },
// depositsPaused: false,
// emergencyGuardian: '0x0000...0000',
// engine: {
// address: '0x0000...0002',
// name: 'Example Vault',
// symbol: 'evUSD',
// totalAssets: 1_000_000_000n,
// },
// engineMigrationMode: 'userOnly',
// engineShares: 1_000_000_000n,
// feesActive: true,
// isSynced: true,
// operator: '0x0000...0003',
// pendingRedeemCount: 0n,
// shareSupply: 995_000_000n,
// shareToken: '0x20c0...0002',
// }import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Recipes
Gate Deposits on Vault Health
Check depositsPaused and isSynced before routing customer funds into a vault with
earn.depositSync.
import { } from './viem.config'
const = '0x0000000000000000000000000000000000000001'
const = await ..({ : })
if (. || !.)
throw new ('Vault is not accepting deposits.')
const = await ..({
: 100_000_000n,
: 99_500_000n,
: ,
})import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Check the matching field under capabilities before specialized entries and exits, such as venue
share deposits or exact withdrawals.
Format Amounts with Token Metadata
Combine assetToken and shareToken with
token.getMetadata to resolve the symbols and decimals a
dashboard needs to render vault balances.
import { } from './viem.config'
const = await ..({
: '0x0000000000000000000000000000000000000001',
})
const [, ] = await .([
..({ : . }),
..({ : . }),
])
.(`${.} is backed by ${.}`)
evUSD is backed by pathUSDimport { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Return Value
type ReturnValue = {
/** Token accepted by the vault. */
assetToken: Address
/** Address allowed to cancel queued redemptions. */
asyncJanitor: Address
/** Actions supported by the current venue integration. */
capabilities: {
asyncRedeem: boolean
exactWithdraw: boolean
inKindDeposit: boolean
syncRedeem: boolean
}
/** Whether new deposits are paused. */
depositsPaused: boolean
/** Address allowed to pause deposits. */
emergencyGuardian: Address
/** Current venue integration. */
engine: {
address: Address
name: string
symbol: string
totalAssets: bigint
}
/** Who may change the venue integration. */
engineMigrationMode: 'operatorEnabled' | 'userOnly'
/** Venue shares held for the vault. */
engineShares: bigint
/** Whether fees are active. */
feesActive: boolean
/** Whether Earn share supply matches its asset backing. */
isSynced: boolean
/** Vault governance address. */
operator: Address
/** Open queued redemptions. */
pendingRedeemCount: bigint
/** Active Earn share supply. */
shareSupply: bigint
/** Token representing Earn shares. */
shareToken: Address
}Parameters
vault
- Type:
Address
Vault address.
blockNumber (optional)
- Type:
bigint
Block number to read the state from.
blockOverrides (optional)
- Type:
BlockOverrides
Block overrides to apply to the state.
blockTag (optional)
- Type:
BlockTag
Block tag to read the state from.
stateOverride (optional)
- Type:
StateOverride
State override to apply.
Errors
| Error | Description |
|---|---|
GetVaultEngineChangedError | The vault changed venue integrations while its state was being read. |