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

@kairos-loan/aleno-tb

v1.0.17

Published

This module provides functionalities for manipulating tornado-blast-subgraph.

Downloads

10

Readme

Aleno-tb

Introduction

This module provides functionalities for manipulating tornado-blast-subgraph.

Configuration

Before using this module, you need to configure the following environment variables:

  • USDB_ADDRESS: The address for USDB token. You can set this environment variable to the desired USDB token address. If not provided, the default address "0x4300000000000000000000000000000000000003" will be used.
  • WETH_ADDRESS: The address for WETH token. You can set this environment variable to the desired WETH token address. If not provided, the default address "0x4300000000000000000000000000000000000004" will be used.
  • THE_GRAPH_URL: The URL for The Graph API endpoint. You can set this environment variable to the desired endpoint URL. If not provided, the default development URL https://api.studio.thegraph.com/query/64686/tornado-blast-subgraph-mainnet/version/latest will be used. This is a blast-mainnet rate limited endpoint for testing purpose only.

Installation

To install and use this module in your project, follow these steps:

  1. Install the module using npm:

    npm install @kairos-loan/aleno-tb
  2. Import the module in your code:

    import alenoTb from "@kairos-loan/aleno-tb";
  3. Configure the environment variables as mentioned in the Configuration section above.

  4. Start using the module's functionalities in your code.

Usage

Here are some examples of how to use this module:

Use existing queries with typing:

import * as alenoTb from "@kairos-loan/aleno-tb";

const tokenIds = [alenoTb.WETH_ADDRESS, alenoTb.USDB_ADDRESS];
console.log(await alenoTb.getTokensInfo(tokenIds));

Example of a custom query:

import * as alenoTb from "@kairos-loan/aleno-tb";

const tokenInfoQuery = alenoTb.gql`
    query GetTokenInfo($tokenIds: [ID!]) {
        tokens(
            where: { 
                id_in: $tokenIds, 
            }, 
            first: 1000,
            orderBy: createdAtTimestamp, 
            orderDirection: desc
        ) {
          id
          symbol
          name
          decimals
        }
    }
`;
console.log(await alenoTb.executeQuery(tokenInfoQuery, { tokenIds }));

Get trending tokens:

import * as alenoTb from "@kairos-loan/aleno-tb";

console.log(await alenoTb.getTrendingTokens());

Get new tokens:

import * as alenoTb from "@kairos-loan/aleno-tb";

console.log(await alenoTb.getNewTokens());

Get first 1000 results of user leader board by volume:

import * as alenoTb from "@kairos-loan/aleno-tb";

console.log(await alenoTb.fetchUsersLeaderBoardByVolume(0, 1000));

Example of setting the GemFinder:

import * as alenoTb from "@kairos-loan/aleno-tb";

const userCache = await alenoTb.initUserCache(alenoTb.getTimestamp24HoursAgo());
const updateIntervalInSeconds = 15 * 60;
// Using pnl of 1$ in testnet for testing, this must be increased on mainnet
const pnlThreshold = 1;
let gems = await alenoTb.findGems(userCache, pnlThreshold);

const updateCacheAndFindGems = async () => {
  await alenoTb.updateUserCache(userCache, updateIntervalInSeconds);
  gems = await alenoTb.findGems(userCache, pnlThreshold);
};
setInterval(updateCacheAndFindGems, updateIntervalInSeconds * 1000);

Example get pnl and swaps for a given User:

import * as alenoTb from "@kairos-loan/aleno-tb";

const { totalPnl, processedSwaps } = await alenoTb.getPnlForUser(
  "0x00c53938f938098f82c60603386d872cbea7ceb3",
  userCache,
);
console.log(totalPnl, processedSwaps);

Get User info:

import * as alenoTb from "@kairos-loan/aleno-tb";

console.log(
  await alenoTb.getUserInfo(
    "0x001a1a6126adfd06637a75bc08ed0bc4d9f3de87",
    userCache,
  ),
);

User leaderboard based on PnL:

You can implement a user leaderboard based on PnL by requesting all the users using a timestamp parameter of 0. However, this approach may be resource-intensive over time, and not all users might have a realized pnl.

Feel free to adjust the formatting or add any additional explanations as needed.