API Reference
This page lists every method on the client from createSmartRecipes(config). All methods are async. All rejections are typed SmartRecipeErrors.
Deposits
All deposit methods return a Quote. They share the core parameters: owner, amount, token, srcChainId, destChainId?, slippage?. See Deposits for the shared vocabulary.
| Method | Extra params | Notes |
|---|---|---|
sr.aave.deposit(p) | destChainId required, into optional | Omit into to supply the funding token's reserve. Pass an Aave listing to select a different reserve. |
sr.morpho.deposit(p) | into required | Vault id, address, or a Vault object. |
sr.fluid.deposit(p) | into required | |
sr.yearn.deposit(p) | into required | |
sr.erc4626.deposit(p) | into required | Any ERC-4626 vault, listed or not. |
sr.depositIntoVault(p) | into + protocol required | The generic engine. protocol: 'aave' | 'morpho' | 'fluid' | 'yearn' | 'erc4626'. |
Swaps
| Method | Params | Returns |
|---|---|---|
sr.bridgeAndSwap(p) | owner, amount, token, toToken, srcChainId, destChainId, slippage? | Quote (no vault fields) |
Discovery
| Method | Params | Returns |
|---|---|---|
sr.listVaults(p?) | asset?, chains?, protocol?, minTvl?, minApy?, page? | { vaults: Vault[]; nextPage: number | null } |
sr.getVault(vaultId, chainId?) | Pass chainId when known, for a direct lookup | VaultDetails |
sr.getChains() | (none) | ChainInfo[] |
sr.getTokens(p?) | chainId? | TokenInfo[] |
sr.listOpportunities(p?) | Alias of listVaults (back-compat) | VaultPage |
If you omit minTvl on listVaults, a $100,000 default minimum applies. Pass minTvl: 0 to include smaller vaults.
Status
| Method | Params | Returns |
|---|---|---|
sr.getStatus(sra) | The SRA address | RecipeStatus: state, deposits, failureReason? |
sr.watchStatus(sra, opts) | interval? (default 4000 ms), timeout? (default 10 min, 0 = forever), maxRetries? (default 5), onStatusChange, onError? | Watcher: callable unsubscribe, with .stop() and .done |
watchStatus polls with backoff. It stops on COMPLETED, FAILED, or ABANDONED. A persistent poll failure rejects watcher.done and calls onError.
SRA lifecycle
| Method | Params | Returns |
|---|---|---|
sr.preflight(p) | owner, vaultId, destChainId, amount, srcChainId?, srcToken? | Vault entry, maxDeposit, depositsDisabled, route |
sr.getSraInfo(p) | sra | The stored routing config: owner, actions, src tokens, slippage |
sr.getSraFeeEstimates(p) | sra | Per-chain fee estimates, with isSponsored flags |
sr.getDepositStatus(p) | sra, owner, destChainId, vaultId (the vault address) | phase, deposits, vaultBalance |
sr.getWithdrawCalls(p) | sra, tokens: [{ chainId, token }] | Owner-signed recovery calls, per chain |
Client config
createSmartRecipes({
serverUrl: string, // required
projectId: string, // required - sent on every request
fetch?: typeof fetch, // injectable, for tests / non-browser runtimes
timeoutMs?: number, // per-request abort timeout, default 30000
maxRetries?: number, // GET retries on 429/502/503/network, default 2
})The factory is synchronous. POST requests (quotes) are never retried. Each attempt can create a new SRA.
Exports
import {
createSmartRecipes,
TOKENS, // USDC | USDT | DAI | WETH | WBTC | EURC | NATIVE
SmartRecipeError, // base error, plus one subclass per code
QuoteExpiredError,
VaultCapExceededError,
// ... see Errors for the full list
} from "@zerodev/smart-recipes";Types: Quote, Vault, VaultDetails, DepositParams, BridgeAndSwapParams, RecipeStatus, RecipeState, Watcher, and the params and result types of every method above.