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

@vols/sdk-core

v1.2.2

Published

vols sdk core

Readme

@vols/sdk-core

A TypeScript library providing core functionality for blockchain and DeFi applications, with a focus on token handling, currency conversions, and price calculations.

npm version License: MIT

Installation

# Using npm
npm install @vols/sdk-core

# Using yarn
yarn add @vols/sdk-core

Features

  • Token Management: Easily create and manage ERC20 tokens with support for various chain IDs
  • Currency Handling: Work with native currencies (like ETH) and ERC20 tokens
  • Price Calculations: Utilities for price impact calculations and conversions
  • Fraction Utilities: Precise fraction handling for financial calculations
  • Address Validation: Tools for validating and parsing Ethereum addresses
  • Multi-chain Support: Built-in support for multiple blockchain networks

Usage Examples

Working with Tokens

import { Token, ChainId } from '@vols/sdk-core'

// Create a token instance
const myToken = new Token(
  1, // Ethereum Mainnet
  '0x1234567890123456789012345678901234567890', // Token address
  18, // Decimals
  'TKN', // Symbol
  'My Token' // Name
)

// Check if two tokens are the same
const isSameToken = myToken.equals(otherToken)

Working with Currency Amounts

import { Token, CurrencyAmount } from '@vols/sdk-core'

// Create a token
const myToken = new Token(1, '0x...', 18, 'TKN', 'My Token')

// Create a currency amount
const amount = CurrencyAmount.fromRawAmount(myToken, '1000000000000000000') // 1 TKN

// Perform operations
const doubled = amount.multiply('2')
const halved = amount.divide('2')

Price Calculations

import { Price, Token, CurrencyAmount } from '@vols/sdk-core'

// Create tokens
const tokenA = new Token(1, '0x...', 18, 'TKNA')
const tokenB = new Token(1, '0x...', 6, 'TKNB')

// Create amounts
const amountA = CurrencyAmount.fromRawAmount(tokenA, '1000000000000000000') // 1 TKNA
const amountB = CurrencyAmount.fromRawAmount(tokenB, '2000000') // 2 TKNB

// Create a price
const price = new Price(
  tokenA,
  tokenB,
  amountA.quotient,
  amountB.quotient
)

// Price is 2 TKNB per 1 TKNA
console.log(`Price: ${price.toSignificant(6)} ${tokenB.symbol} per ${tokenA.symbol}`)

Address Validation

import { validateAndParseAddress } from '@vols/sdk-core'

try {
  const parsedAddress = validateAndParseAddress('0x1234...')
  console.log('Valid address:', parsedAddress)
} catch (error) {
  console.error('Invalid address')
}

Core Components

Entities

  • Token: Represents an ERC20 token with address, decimals, symbol, and name
  • Currency: Base class for all currency types
  • NativeCurrency: Represents native blockchain currencies (like ETH)
  • CurrencyAmount: Represents an amount of a specific currency
  • Fraction: Provides precise fraction calculations
  • Price: Represents the price of one currency in terms of another
  • Percent: Utility for working with percentages

Utilities

  • validateAndParseAddress: Validates and checksums Ethereum addresses
  • computePriceImpact: Calculates price impact for trades
  • sqrt: Square root implementation optimized for DeFi calculations
  • sortedInsert: Utility for sorted insertions in arrays
  • computeZksyncCreate2Address: Utility for zkSync address computation

Development

# Install dependencies
yarn

# Start development mode
yarn start

# Build the package
yarn build

# Run tests
yarn test

# Lint the code
yarn lint

License

MIT

Contributing

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