# @tetherto/wdk-pricing-provider

> Asset pricing provider for the WDK.

Latest version **1.0.0-beta.6** (published 2026-09-24) · APACHE-2.0 license · 0 weekly downloads

## Install

```sh
npm install @tetherto/wdk-pricing-provider
pnpm add @tetherto/wdk-pricing-provider
yarn add @tetherto/wdk-pricing-provider
bun add @tetherto/wdk-pricing-provider
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.0-beta.6 |
| Published | 2026-09-24 |
| First published | 2025-10-10 |
| Weekly downloads | 0 |
| License | APACHE-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 29.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Tether |
| Maintainers | mafintosh, prdn |
| Keywords | tetherto, wdk, wallet, bitcoin, ethereum, pricing, provider, bitfinex, blockchain |

## Links

- npm: https://www.npmjs.com/package/@tetherto/wdk-pricing-provider
- Repository: https://github.com/tetherto/wdk-pricing-provider
- Homepage: https://github.com/tetherto/wdk-pricing-provider#readme
- Issues: https://github.com/tetherto/wdk-pricing-provider/issues
- npm.io page: https://npm.io/package/@tetherto/wdk-pricing-provider

## Dependencies (2)

- [bare-node-runtime](https://npm.io/package/bare-node-runtime.md) ^1.4.0
- [@tetherto/wdk-failover-provider](https://npm.io/package/@tetherto/wdk-failover-provider.md) 1.0.0-beta.2

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.0-beta.6 (latest) — 2026-09-24
- 1.0.0-beta.5 — 2026-06-09
- 1.0.0-beta.4 — 2026-06-02
- 1.0.0-beta.3 — 2026-03-20
- 1.0.0-beta.2 — 2026-03-20
- 1.0.0-beta.1 — 2025-10-10

## README

# @tetherto/wdk-pricing-provider

Simple, cache-aware pricing provider utilities for WDK-based apps and the [WDK UI Kit](https://github.com/tetherto/wdk-uikit-react-native). It defines two core building blocks: `PricingClient` (an abstract fetcher that you implement) and `PricingProvider` (a wrapper that adds caching and a unified API).

## 🔍 About WDK

This module is part of the WDK (Wallet Development Kit) ecosystem, which helps developers build secure, non-custodial wallets and related services.

For more on the WDK project, visit [docs.wallet.tether.io](https://docs.wallet.tether.io).

## ✨ Features

- Minimal, composable pricing abstraction
- Pluggable client model (`PricingClient`)
- Built-in caching via `PricingProvider`
- Last price and historical price helpers

## ⬇️ Installation

```bash
npm install @tetherto/wdk-pricing-provider
```

## 🚀 Quick Start

```javascript
import { PricingProvider } from "@tetherto/wdk-pricing-provider";
import { BitfinexPricingClient } from "@tetherto/wdk-pricing-bitfinex-http";

// Create a concrete PricingClient implementation
const client = new BitfinexPricingClient();

// Wrap the client with a cache-enabled provider
const provider = new PricingProvider({
  client,
  cacheTTL: 60 * 60 * 1000, // 1 hour cache in ms
});

// Get latest price
const currentPrice = await provider.getLastPrice("BTC", "USD");

// Get historical price
const historicalPrice = await provider.getHistoricalPrice({
  from: "BTC",
  to: "USD",
  start: 1709906400000, // Optional, Start date for historical interval
  end: 1709913600000, // Optional, End date for historical interval
});
```

## 📚 API Reference

### PricingProvider

```javascript
new PricingProvider(options);
```

Parameters:

- `options.client`: Instance of your `PricingClient` implementation
- `options.cacheTTL` (number, optional): Cache time for last price lookups in ms

Methods:

- `getLastPrice(base: string, quote: string): Promise<number>`
- `getHistoricalPrice({ from, to, start?, end? }): Promise<number>`

### PricingClient (abstract)

You implement this interface for your data source (e.g., Bitfinex, Coinbase, etc.). At a minimum, provide methods that `PricingProvider` uses to fetch spot and historical prices.

## 🔍 Usage Examples

For detailed usage examples, please check the included test files `index.test.js` and `index.integration.test.js` in this repository.

## 🔗 Related Projects

- Bitfinex HTTP client: [wdk-pricing-bitfinex-http](https://github.com/tetherto/wdk-pricing-bitfinex-http)

## 🛠️ Development

```bash
# Install dependencies
npm install

# Lint
npm run lint
npm run lint:fix

# Tests
npm test
```

## 📜 License

This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.

## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## 🆘 Support

For support, please open an issue on the GitHub repository.

---

---
_Source: https://npm.io/package/@tetherto/wdk-pricing-provider · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
