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 🙏

© 2024 – Pkg Stats / Ryan Hefner

sushiprices

v1.0.4

Published

Get current and historical prices from uniswap decentralized exchange. Request prices by block number, by date, or request price trend for the last 6 months.

Downloads

3

Readme

🍣 Sushiprices

Overview

  • Historical Prices
  • Search by date
  • Search by block number
  • Request price trend over a time period

Usage

npm i sushiprices

Javascript

const Sushiprices = require("sushiprices");

const sushiprices = new Sushiprices(
  web3 // Web3 object, required.
);

// @dev Getting token price
let prices = await sushiprices.getPriceCurrent(
  "0xE41d2489571d322189246DaFA5ebDe1F4699F498" // @note will throw on err if invalid address 
);
Response is returned as an object
{
    sell: {
        eth: 705.1327229984558, // Sell price. Tokens to ETH.
        token: 0.0014181727317201672 // Sell price. ETH to token.
    },
    buy: {
        eth: 711.0950709237676, // Buy price. Tokens to ETH.
        token: 0.0014062817208125526 // Buy price. ETH to token.
    }
}
*/
Getting token price for given block

let priceByBlock = await sushiprices.getPriceByBlock(
  "0xE41d2489571d322189246DaFA5ebDe1F4699F498", // Token address, required. If address is not valid uniswap token will trow an error.
  9301593 // Block number, required.
);
// Returns an object:
{
    sell: {
        eth: 660.0046170034753, // Sell price. Tokens to ETH.
        token: 0.001515140916044129 // Sell price. ETH to token.
    },
    buy: {
        eth: 665.5473066426158, // Buy price. Tokens to ETH.
        token: 0.0015025227959294828 // Buy price. ETH to token.
    }
}
Or false if the price for a given block is not found
*/
Getting token price for given date
let priceByDate = await sushiprices.getPriceByDate(
  "0xE41d2489571d322189246DaFA5ebDe1F4699F498", // Token address, required. If address is not valid uniswap token will trow an error.
  "2019-09-02T12:00:00Z" // Date, required. Any valid moment.js value: string, milliseconds, Date() object, moment() object.
);

/*
Returns an object:
{
    sell: {
        eth: 1049.308625825207, // Sell price. Tokens to ETH.
        token: 0.0009530084623230564 // Sell price. ETH to token.
    },
    buy: {
        eth: 1064.442519929068, // Buy price. Tokens to ETH.
        token: 0.000939458901046754 // Buy price. ETH to token.
    }
}
Or false if the price for a given date is not found
*/
Price trend over 1h, 12h, 1d, 7d, 1m, 3m or 6m
// 
let priceTrend = await sushiprices.getPriceTrend(
  "0xE41d2489571d322189246DaFA5ebDe1F4699F498" // Token address, required. If address is not valid uniswap token will trow an error.
);

/*
Returns an object:
{
    '1h': {
        sell: { eth: 706.3144725491642, token: 0.0014157999571931372 },
        buy: { eth: 712.2882035638517, token: 0.0014039261004135906 }
    },
    '12h': {
        sell: { eth: 706.3144725491642, token: 0.0014157999571931372 },
        buy: { eth: 712.2882035638517, token: 0.0014039261004135906 }
    },
    '1d': {
        sell: { eth: 667.0258578485677, token: 0.0014991922550430213 },
        buy: { eth: 672.6366528114763, token: 0.0014866867510419117 }
    },
    '7d': {
        sell: { eth: 702.3071222116168, token: 0.0014238784833206963 },
        buy: { eth: 708.8714215292256, token: 0.0014106930673587208 }
    },
    '3m': {
        sell: { eth: 568.2301739407155, token: 0.0017598502259479304 },
        buy: { eth: 574.8297096923411, token: 0.0017396456431161454 }
    },
    '1m': {
        sell: { eth: 668.2651684571723, token: 0.001496411974169933 },
        buy: { eth: 674.3174301154061, token: 0.0014829810936799529 }
    },
    '6m': {
        sell: { eth: 943.5426765954456, token: 0.001059835474117893 },
        buy: { eth: 955.6376597573558, token: 0.0010464217162118833 }
    }
}
*/

License

MIT