# @uma/financial-templates-lib

> Arbitrage automation and libraries for UMA financial templates

Latest version **2.37.2** (published 2025-09-24) · AGPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @uma/financial-templates-lib
pnpm add @uma/financial-templates-lib
yarn add @uma/financial-templates-lib
bun add @uma/financial-templates-lib
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.37.2 |
| Published | 2025-09-24 |
| First published | 2020-09-16 |
| Weekly downloads | 0 |
| License | AGPL-3.0-or-later |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 24 |
| Unpacked size | 548.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 486 |
| Maintainers | mrice32, chrismaree, evaldofelipe, nicholaspai |

## Links

- npm: https://www.npmjs.com/package/@uma/financial-templates-lib
- Repository: https://github.com/UMAprotocol/protocol
- Homepage: https://umaproject.org
- Issues: https://github.com/UMAprotocol/protocol/issues
- npm.io page: https://npm.io/package/@uma/financial-templates-lib

## Dependencies (24)

- [web3](https://npm.io/package/web3.md) ^1.6.0
- [bn.js](https://npm.io/package/bn.js.md) ^4.11.9
- [dotenv](https://npm.io/package/dotenv.md) ^9.0.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.20
- [mathjs](https://npm.io/package/mathjs.md) ^9.2.0
- [moment](https://npm.io/package/moment.md) ^2.29.1
- [winston](https://npm.io/package/winston.md) ^3.2.1
- [@uma/sdk](https://npm.io/package/@uma/sdk.md) ^0.34.13
- [bluebird](https://npm.io/package/bluebird.md) ^3.7.2
- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [discord.js](https://npm.io/package/discord.js.md) ^14.11.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0
- [@uma/common](https://npm.io/package/@uma/common.md) ^2.40.0
- [@uma/logger](https://npm.io/package/@uma/logger.md) ^1.3.3
- [superstruct](https://npm.io/package/superstruct.md) ^1.0.3
- [@uniswap/sdk](https://npm.io/package/@uniswap/sdk.md) ^2.0.5
- [node-pagerduty](https://npm.io/package/node-pagerduty.md) ^1.2.0
- [@pagerduty/pdjs](https://npm.io/package/@pagerduty/pdjs.md) ^2.2.4
- [moment-timezone](https://npm.io/package/moment-timezone.md) ^0.5.33
- [winston-transport](https://npm.io/package/winston-transport.md) ^4.3.0
- [@uma/contracts-node](https://npm.io/package/@uma/contracts-node.md) ^0.4.28
- [@ethersproject/bignumber](https://npm.io/package/@ethersproject/bignumber.md) ^5.4.2
- [@google-cloud/trace-agent](https://npm.io/package/@google-cloud/trace-agent.md) ^5.1.6
- [@google-cloud/logging-winston](https://npm.io/package/@google-cloud/logging-winston.md) ^4.1.1

## Recent versions

- 2.37.2 (latest) — 2025-09-24
- 2.5.0-beta.0 (next) — 2021-07-06
- 2.37.0 — 2025-07-15
- 2.36.3 — 2024-10-29
- 2.36.1 — 2024-07-20
- 2.36.0 — 2024-04-30
- 2.35.2 — 2024-04-09
- 2.35.1 — 2024-03-07
- 2.35.0 — 2023-11-13
- 2.34.1 — 2023-10-13
- 2.34.0 — 2023-09-28
- 2.33.0 — 2023-07-17
- 2.32.11 — 2023-04-18
- 2.32.10 — 2023-03-30
- 2.32.9 — 2023-03-23
- … 70 more at https://npm.io/package/@uma/financial-templates-lib/versions

## README

# @uma/financial-templates-lib

This package contains various clients and helpers to interact with UMA's financial templates. It is primarily used to
power the disputer, liquidator, and monitor bots.

## Installing the package

```bash
yarn add @uma/financial-templates-lib
```

## Importing the package

```js
const { FinancialContractClient, GasEstimator } = require("@uma/financial-templates-lib")
```

## Clients

The three clients available are:

1. The `FinancialContractClient` can be used to access information about Financial Contract sponsors and their collateralization
   ratios. To understand how to interact with the client, see the class documentation
   [here](./src/clients/FinancialContractClient.js).

1. The `FinancialContractEventClient` can be used to access historical events that were emitted by a Financial Contract. To
   understand how to interact with the client, see the class documentation
   [here](./src/clients/FinancialContractEventClient.js).

1. The `TokenBalanceClient` tracks the collateral and synthetic balances for a list of wallets. To understand how to
   interact with the client, see the class documentation
   [here](./src/clients/TokenBalanceClient.js).

## Price Feeds

The package offers a variety of price feed implementations that adere to the `PriceFeedInterface` (docs can be found in
the interface file [here](./src/price-feed/PriceFeedInterface.js)):

- The `CryptoWatchPriceFeed`, found [here](./src/price-feed/CryptoWatchPriceFeed.js), uses https://cryptowat.ch/ as a
  source of CEX price data.
- The `UniswapPriceFeed`, found [here](./src/price-feed/UniswapPriceFeed.js), uses a Uniswap (v2) market TWAP as the
  price source. Note: the TWAP length can be set to 0 to make this an instantaneous price.
- THe `BalancerPriceFeed`, found [here](./src/price-feed/BalancerPriceFeed.js), uses a Balancer market as the price
  source.
- The `MedianizerPriceFeed`, found [here](./src/price-feed/MedianizerPriceFeed.js), takes multiple price feeds and
  returns the median of their prices.

There are a few other helper/utility files that are relevant:

- [CreatePriceFeed.js](./src/price-feed/CreatePriceFeed.js) has a variety of factory utilities that will create a
  price feed given an input configuration.
- [DefaultPriceFeedConfigs.js](./src/price-feed/DefaultPriceFeedConfigs.js) contains a list of default price feeds
  for different identifiers in the UMA ecosystem. These are used by `CreatePriceFeed.js` to create price feeds with
  no or incomplete input configurations.
- [Networker.js](./src/price-feed/CreatePriceFeed.js) has a mockable object that sends network requests and is used by
  many objects in financial-templates-lib to send requests.

## Logger

The [Logger](./src/logger) directory contains helpers and factories for logging with Winston. To get the default
logger:

```js
const { Logger, createPriceFeed, Networker } = require("@uma/financial-templates-lib");

// A winston logger is required for createPriceFeed, networker and other objects in financial-templates-lib.
const networker = new Networker(Logger);
const priceFeed = createPriceFeed(Logger, web3, networker, ...);

// You can also log directly using the winston logger.
Logger.debug({
    at: "createPriceFeed",
    message: "Creating CryptoWatchPriceFeed",
    otherParam: 5
});
```

## Helpers

There are two helper files that are available in financial-templates-lib:

- [delay.js](./src/helpers/delay.js): simple file containing a function to "sleep".
- [GasEstimator.js](./src/helpers/GasEstimator.js): `GasEstimator` provides an estimate of the current fast gas price.

---
_Source: https://npm.io/package/@uma/financial-templates-lib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
