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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@blend-money/sdk-core

v0.1.11

Published

Core utilities for Blend SDK.

Downloads

334

Readme

@blend-money/sdk-core

Type-safe SDK for interacting with the Blend API. Provides precise decimal arithmetic using Decimal.js and comprehensive type safety for all API operations.

Features

  • Type-safe API client with full TypeScript support
  • Precise decimal arithmetic using Decimal.js for financial calculations
  • Automatic retry logic with exponential backoff for failed requests
  • Safe address caching to minimize API calls
  • Comprehensive error handling with detailed error types
  • Isomorphic - works in both browser and Node.js environments

Install

pnpm add @blend-money/sdk-core

Quick Start

import { BlendClient } from "@blend-money/sdk-core";

const client = new BlendClient({
  baseUrl: "https://api.blend.money",
  userAddress: "0x742d35Cc6634C0532925a3b8D",
  integratorId: "my-app-v1.0",
});

// Resolve Safe address
const safeResolution = await client.safe.resolveSafeAddress(
  "0x742d35Cc6634C0532925a3b8D",
  8453,
);

// Get available strategies
const strategies = await client.strategy.getAvailableStrategies();

// Get yield information
const yieldSummary = await client.strategy.getAllYieldsFromVault(strategies[0]);

Configuration

import { BlendClient } from "@blend-money/sdk-core";

const client = new BlendClient({
  baseUrl: "https://api.blend.money", // Required: API base URL
  userAddress: "0x742d35Cc6634C0532925a3b8D", // Required: User's EOA address
  integratorId: "my-app-v1.0", // Required: Integrator identifier
  timeoutMs: 30000, // Optional: Request timeout (default: 15000)
  retries: 5, // Optional: Retry attempts (default: 3)
  alchemyApiKey: "your-key", // Optional: For balance queries
});

Decimal Arithmetic

The SDK uses Decimal.js for precise financial calculations:

import { Decimal } from "decimal.js";

const price = new Decimal("1.5"); // new Decimal(1.5)
const quantity = new Decimal("1000"); // new Decimal(1000)
const total = price.mul(quantity); // new Decimal(1500)

// Convert back to number if needed
const totalNumber = total.toNumber(); // 1500

Error Handling

import { BlendClient, SdkError } from "@blend-money/sdk-core";

try {
  const result = await client.safe.resolveSafeAddress(address, chainId);
} catch (error) {
  if (error instanceof SdkError) {
    console.error(`API Error ${error.status}: ${error.message}`);
    console.error(`User-friendly: ${error.getUserMessage()}`);
  }
}

API Reference

BlendClient

Main client class providing access to all SDK functionality.

Constructor

  • new BlendClient(config: BlendClientConfig)

Modules

  • client.safe - Safe address resolution and deployment
  • client.strategy - Yield and balance information
  • client.actions - Deposit, withdraw, and rebalance operations

Strategy Methods

  • client.strategy.getAvailableIntegrations()string[]
    • Lists supported integrations (e.g., "MESA_CAPITAL").

Types

  • Percent - Percentage values using Decimal.js (1 = 100%)
  • Usd - USD values using Decimal.js
  • Price - Token prices using Decimal.js
  • Token - Token configuration with address, symbol, decimals, chainId
  • TokenAmount - Token amount with native decimal scaling
  • VaultConfig - Vault configuration and metadata
  • YieldSummary - Comprehensive yield information
  • BalanceSummary - Balance information across all positions

Utilities

  • parseAmount(amountStr, decimals) - Parse string to BigInt with decimals
  • formatAmount(amount, decimals, precision?) - Format BigInt to string
  • tokenAmountToDecimal(amount) - Convert TokenAmount to Decimal
  • decimalToTokenAmount(decimal, decimals) - Convert Decimal to TokenAmount
  • validateAddress(address) - Validate Ethereum address
  • validateChainId(chainId) - Validate chain ID format

License

MIT