npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@circle-fin/provider-borrow-service

v1.0.0

Published

Provider for BorrowKit's Circle-hosted lending backend

Readme

Borrow Service Provider

License

Borrow Service Provider defines the provider contract used by Borrow Kit and ships the default HTTP implementation for Circle's Borrow Service, covering loan listing (getLoans), partial repayment (repay, getRepayQuote), loan position reads (getPosition), collateral management (addCollateral, withdrawCollateral), reward claiming (claimRewards, getRewards), and registerWebhook.

registerWebhook builds the EIP-712 WebhookRegistration typed data, obtains a signature via the connected adapter, and submits the signed registration for verification (including EIP-1271 support for smart contract accounts). This is a permissionless, client-signed flow with no on-chain transaction and no API key.

Health-band notifications sent to the registered URL are delivered at-least-once: the same crossing can arrive more than once. Deduplicate on the notification's event_id, which is stable across redeliveries of one crossing.

Installation

npm install @circle-fin/provider-borrow-service
# or
yarn add @circle-fin/provider-borrow-service

This provider is included by default in @circle-fin/borrow-kit. Import it directly when you need to customize provider construction or compose your own Borrow Kit context.

Quick Start

Note: @circle-fin/borrow-kit is not yet published — this example shows the intended usage once it ships. Until then, construct BorrowServiceProvider and call registerWebhook on it directly with a resolved EVMChainDefinition; see Configuration below.

import {
  createBorrowKitContext,
  registerWebhook,
} from "@circle-fin/borrow-kit";
import { BorrowServiceProvider } from "@circle-fin/provider-borrow-service";
import { createViemAdapterFromPrivateKey } from "@circle-fin/adapter-viem-v2";

const provider = new BorrowServiceProvider();
const context = createBorrowKitContext({ providers: [provider] });
const privateKey = process.env.PRIVATE_KEY;
if (!privateKey) throw new Error("PRIVATE_KEY is required");
const adapter = createViemAdapterFromPrivateKey({ privateKey });

const result = await registerWebhook(context, {
  from: { adapter, chain: "Arc_Testnet" },
  loanId: "11111111-1111-4111-8111-111111111111",
  webhookUrl: "https://example.com/webhook",
});

console.log(`Registered webhook: ${result.webhookUrl}`);

Configuration

BorrowServiceProvider accepts default configuration in the constructor and per-operation configuration on each request. Per-operation values take precedence, while omitted values continue to use constructor defaults.

An API key is optional only for borrow and getBorrowQuote, and required for getIntegratorConfig and setIntegratorConfig. Every other API rejects a configured key before making a request (or, for registerWebhook, before signing).

const provider = new BorrowServiceProvider({
  apiKey: process.env.CIRCLE_API_KEY,
  baseUrl: "https://api-staging.circle.com",
});

apiKey takes a Circle API key (<ENV>_API_KEY:<keyId>:<keySecret>). A legacy KIT_KEY:<keyId>:<keySecret> value goes in the same field and still authenticates; the console no longer issues them. It is a server-only secret and is refused in a browser. Omit it for keyless routes.

Calling registerWebhook directly on the provider requires a resolved EVMChainDefinition and the connected wallet's address in addition to the adapter. EVMChainDefinition values (such as ArcTestnet) currently live in the internal @core/chains package, which is not published standalone — the snippet below illustrates the shape expected until @circle-fin/borrow-kit (which resolves chains by name, as shown in Quick Start) is published:

import { ArcTestnet } from "@core/chains";

const result = await provider.registerWebhook({
  adapter,
  chain: ArcTestnet,
  address: "0x1234567890123456789012345678901234567890",
  loanId: "11111111-1111-4111-8111-111111111111",
  webhookUrl: "https://example.com/webhook",
  deadline: Math.floor(Date.now() / 1000) + 300,
});

console.log(`Registered webhook: ${result.webhookUrl}`);

The BorrowServiceProvider implements wallet-scoped loan listing through GET /v1/borrowKit/loans, including cursor pagination, response validation, retry behavior, and structured errors.

It also implements the partial-repayment and full-close prepare/quote endpoints. Repay requests reuse a caller-provided idempotency key or generate one when omitted; full-close writes generate one. Quote requests remain side-effect free and omit it.

License

This project is licensed under the Apache 2.0 License. Contact support for details.