stablecoin-yield
v0.1.0
Published
The official Barker JS/TS SDK for stablecoin yield data — real-time APY/TVL from 500+ DeFi protocols across 40+ chains, plus market overview and historical APY trend. Zero dependencies, Node 18+.
Maintainers
Readme
stablecoin-yield
The official Barker JS/TS SDK for stablecoin yield data — real-time APY/TVL from 500+ DeFi protocols across 40+ chains, plus market overview and historical APY trend vs US Treasury. Zero dependencies, Node 18+.
Powered by Barker — The Stablecoin Yield Map.
npm install stablecoin-yieldQuick Start
import { getVaults, formatApy } from 'stablecoin-yield';
// Top 5 USDC yields right now
const vaults = await getVaults({ asset: 'usdc', sort: 'apy', limit: 5 });
for (const v of vaults) {
console.log(
`${v.protocolName} (${v.chainName}) ${formatApy(v.supplyApyTotal)} $${v.supplyTvl.toLocaleString()}`
);
}
// Sky (Ethereum) 3.75% $6,350,244,063
// Aave (Arbitrum) 3.42% $1,210,455,028
// ...API Surface
Default client (zero config)
The simplest path — uses the public Barker API, no key required.
import { getVaults, getMarketOverview, getMarketTrend } from 'stablecoin-yield';
const vaults = await getVaults({ asset: 'usdc', sort: 'apy', limit: 10 });
const overview = await getMarketOverview();
const trend = await getMarketTrend({ days: 30 });Custom client
For custom config (timeouts, base URL, alternate fetch), instantiate Barker.
import { Barker } from 'stablecoin-yield';
const barker = new Barker({
baseUrl: 'https://api.barker.money/api/public/v1', // default
timeoutMs: 5_000, // default 10000
// fetch: customFetch, // optional
// userAgent: 'my-app/1.0', // optional
});
const vaults = await barker.getVaults({ minTvl: 1_000_000, limit: 20 });Error handling
All non-2xx responses, timeouts, and success: false payloads throw a BarkerApiError.
import { getVaults, BarkerApiError } from 'stablecoin-yield';
try {
const v = await getVaults({ asset: 'usdc' });
} catch (err) {
if (err instanceof BarkerApiError) {
console.error('Barker API failed:', err.status, err.endpoint);
} else {
throw err;
}
}Methods
getVaults(options?) → DefiVault[]
Real-time DeFi yield pools, sorted by APY (default).
Options:
| Field | Type | Description |
|---|---|---|
| asset | string | Stablecoin symbol filter, e.g. 'usdc', 'usdt', 'dai' |
| chain | string | Chain filter, e.g. 'ethereum', 'arbitrum', 'base' |
| protocol | string | Protocol uid filter, e.g. 'aave', 'compound' |
| sort | 'apy' \| 'tvl' | Default: 'apy' |
| order | 'asc' \| 'desc' | Default: 'desc' |
| limit | number | Max items |
| offset | number | Pagination offset |
| minTvl | number | Minimum TVL in USD (excludes tiny exotic pools) |
Returns DefiVault[] with camelCase fields — see index.d.ts for the full type. APY fields are decimal (see "APY units" below).
getMarketOverview() → MarketOverview
Total stablecoin market cap, asset/chain distribution, summary.
const ov = await getMarketOverview();
console.log(`Total: $${(ov.stablecoinMcap.total / 1e9).toFixed(1)}B`);
console.log(`Yield-bearing: $${(ov.stablecoinMcap.yieldBearing / 1e9).toFixed(1)}B`);
for (const a of ov.assetDistribution.slice(0, 5)) {
console.log(` ${a.assetSymbol}: ${(a.sharePct * 100).toFixed(1)}% of TVL`);
}getMarketTrend({ days? }) → MarketTrendPoint[]
Historical APY trend (avg / median / TVL-weighted) with US 3-month Treasury benchmark.
const trend = await getMarketTrend({ days: 30 });
const latest = trend.at(-1)!;
console.log(`Median DeFi: ${formatApy(latest.medianApy)}`);
console.log(`US Treasury 3m: ${formatApy(latest.treasuryYield3m)}`);
console.log(`Spread: ${formatApy(latest.medianApy - latest.treasuryYield3m)}`);APY units — the one rule
All APY fields returned by the API and this SDK are decimal, where:
0.0523means 5.23%0.10means 10%3.0007means 300.07% (a campaign pool, not a typo)
This matches Barker's internal storage. The trap to avoid: don't divide by 100 again when you see a value ≥ 1 — it's already a multiplier, not a percentage.
Use the built-in helpers to stay safe:
import { apyToPct, pctToApy, formatApy } from 'stablecoin-yield';
apyToPct(0.0523); // 5.23 (decimal → percent number)
pctToApy(5.23); // 0.0523 (percent number → decimal)
formatApy(0.0523); // "5.23%"
formatApy(0.0523, 1); // "5.2%"
formatApy(null); // "—"Public API limits
- Rate limit: 30 req/min per IP
- Auth: none — fully public read-only
- Sensitive data: never sent. Only public market parameters (symbol, chain, sort, limit) leave your machine.
Need higher limits, CEX per-venue detail, or historical raw data? See app.barker.money/enterprise.
TypeScript
Types ship with the package. No @types/... needed:
import type { DefiVault, MarketTrendPoint } from 'stablecoin-yield';Related
@barkermoney/skills— official Claude Code / agent skills that use this same data- GitHub repo — source SKILL.md files
License
MIT
