API client
The ApiClient provides access to off-chain data from the Yo REST API (https://api.yo.xyz).
Usage via YoClient
The YoClient creates an ApiClient internally:
const client = createYoClient({ chainId: 8453 })
const snapshot = await client.getVaultSnapshot(vaultAddress)
const yieldHistory = await client.getVaultYieldHistory(vaultAddress)
const tvlHistory = await client.getVaultTvlHistory(vaultAddress)
const userHistory = await client.getUserHistory(vaultAddress, userAddress, 50)
const points = await client.getUserPoints(userAddress)Standalone Usage
import { createApiClient } from '@yo-protocol/core'
const api = createApiClient()
// or with custom base URL:
const api = createApiClient({ baseUrl: 'https://custom-api.example.com' })Pending Redemptions
Query pending async redemptions for a user or an entire vault.
PendingRedeem
assets
FormattedValue | undefined
Pending asset amount
shares
FormattedValue | undefined
Pending share amount
Response Types
VaultSnapshot
address
string
Vault address
name
string
Vault name
symbol
string
Vault symbol
tvl
FormattedValue
Total value locked
apy
number
Current APY percentage
underlying
object
Underlying token info
pools
Pool[]
Optional pool allocations
TimeseriesPoint
timestamp
number
Unix timestamp
value
number
APY or TVL value
UserHistoryItem
type
'deposit' | 'withdraw' | 'redeem'
Transaction type
timestamp
number
Unix timestamp
assets
FormattedValue
Asset amount
shares
FormattedValue
Share amount
txHash
string
Transaction hash
Error Handling
API errors throw ApiError with a statusCode property: