@kairos-loan/aleno-tb
v1.0.17
Published
This module provides functionalities for manipulating tornado-blast-subgraph.
Downloads
10
Keywords
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:
Install the module using npm:
npm install @kairos-loan/aleno-tb
Import the module in your code:
import alenoTb from "@kairos-loan/aleno-tb";
Configure the environment variables as mentioned in the Configuration section above.
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.