Client
The YoClient class is the main entry point for @yo-protocol/core. It wraps all vault reads, actions, and API calls.
Creating a Client
import { createYoClient } from '@yo-protocol/core'
// Minimal — auto-creates a publicClient
const client = createYoClient({ chainId: 8453 })
// With partner ID and custom viem clients
import { createPublicClient, http } from 'viem'
import { base } from 'viem/chains'
const client = createYoClient({
chainId: 8453,
partnerId: 42,
publicClient: createPublicClient({ chain: base, transport: http() }),
walletClient: myWalletClient,
})Config
chainId
1 | 8453
Ethereum (1) or Base (8453)
publicClient
PublicClient
Optional viem public client
walletClient
WalletClient
Optional viem wallet client (needed for transactions)
partnerId
number
Optional partner attribution ID for gateway calls (default: 0)
Methods
Vault Reads
getVaults()
VaultConfig[]
List vaults for the current chain
getVaultState(vault)
VaultState
On-chain vault state (name, totalAssets, exchangeRate, etc.)
previewDeposit(vault, assets)
bigint
Preview shares received for a deposit
previewRedeem(vault, shares)
bigint
Preview assets received for a redemption
convertToAssets(vault, shares)
bigint
Convert share amount to assets
convertToShares(vault, assets)
bigint
Convert asset amount to shares
Gateway Quote Reads
quotePreviewDeposit(vault, assets)
bigint
Gateway-aware deposit preview
quotePreviewRedeem(vault, shares)
bigint
Gateway-aware redeem preview
quotePreviewWithdraw(vault, assets)
bigint
Gateway-aware withdraw preview (shares needed)
quoteConvertToAssets(vault, shares)
bigint
Gateway-aware share-to-asset conversion
quoteConvertToShares(vault, assets)
bigint
Gateway-aware asset-to-share conversion
Balance Reads
getTokenBalance(token, account)
TokenBalance
ERC-20 balance
getShareBalance(vault, account)
bigint
Vault share balance
getUserPosition(vault, account)
UserVaultPosition
Full position (shares, assets)
Allowance Reads
getAllowance(token, owner, spender)
TokenAllowance
Current ERC-20 allowance
hasEnoughAllowance(token, owner, spender, amount)
boolean
Check if allowance is sufficient
getShareAllowance(vault, owner)
bigint
Gateway share allowance
getAssetAllowance(vault, owner)
bigint
Gateway asset allowance
Actions (require walletClient)
deposit(params)
DepositResult
Deposit assets via gateway
redeem(params)
RedeemResult
Redeem shares for assets via gateway
approve(token, amount, spender?)
ApproveResult
Approve token spending
approveMax(token, spender?)
ApproveResult
Approve max uint256
depositWithApproval(params)
DepositWithApprovalResult
Approve (if needed) + deposit in one call
waitForTransaction(hash)
TransactionReceipt
Wait for transaction confirmation
waitForRedeemReceipt(hash)
RedeemReceipt
Wait + decode instant/requestId from redeem tx
Prepared Transactions (call data mode)
prepareApprove(params)
PreparedTransaction
Build approve call data without executing
prepareDeposit(params)
PreparedTransaction
Build deposit call data without executing
prepareRedeem(params)
PreparedTransaction
Build redeem call data without executing
prepareDepositWithApproval(params)
PreparedTransaction[]
Build approve+deposit bundle for AA wallets
API Methods
getVaultSnapshot(vault)
VaultSnapshot
Off-chain snapshot (TVL, APY, pools)
getVaultYieldHistory(vault)
TimeseriesPoint[]
Historical APY timeseries
getVaultTvlHistory(vault)
TimeseriesPoint[]
Historical TVL timeseries
getUserHistory(vault, user, limit?)
UserHistoryItem[]
User transaction history
getUserPoints(user)
UserPoints | null
User points and rank
getPendingRedemptions(vault, user)
PendingRedeem
User pending redemptions
getVaultPendingRedeems(vault)
PendingRedeem
Vault-level pending redeems