@assertdesignuk/solana-rug
v0.0.3
Published
Rug check for solana tokens. Checks if the token is a rug or not.
Downloads
9
Maintainers
Readme
Solana Rugchecker
This project is under development. Results might fail or give false results. Please evaluate your current version yourself, until this notice disappears. But things are getting more stable since v0.0.14! Join the discord if you are looking for fellow degen developers!
SPLRugchecker is a TypeScript class that checks if a Solana token is a potential rug pull. It analyzes the blockchain to check the token's metadata, top holders and liquidity, and provides methods to calculate a rug score and determine if the token is a potential rug pull.
Installation
Just install it with npm or yarn or whatever.
npm install "@degenfrends/solana-rugchecker"
Configuration
To create an instance of SPLRugchecker
, you need to provide a RugCheckConfig
object with the solanaRpcEndpoint
and optional poolFilePath
or
poolAddress
property. But if you want to use environment variables for the configuration, that's possible too. You need to download the pool file
from https://api.raydium.io/v2/sdk/liquidity/mainnet.json and set the path of the file in the poolFilePath
property.
1. Configuration without environment variables
const rugCheckConfig = {
solanaRpcEndpoint: 'https://api.devnet.solana.com'
poolFilePath: './mainnet.json' //optional
poolAddress: '12345pooladdress' //optional, can't be set with environment variable, since it most likely changes on every check
heliusApiKey: 'your-api-key' //optional
};
const rugChecker = new SPLRugchecker(rugCheckConfig);
2. Configuration with environment variables
If you want to configure the rug checker with environment variables, you need to define a SOLANA_RPC_ENDPOINT
variable and pass an empty object {}
in the constructor. BE AWARE THAT YOU NEED AN RPC ENDPOINT THAT ALLOWS THE getTokenLargestAccounts
CALL! HELIUS.DEV IS WORKING WITH THE FREE TIER
FOR EXAMPLE!
SOLANA_RPC_ENDPOINT="https://api.devnet.solana.com"
const rugChecker = new SPLRugchecker({});
Usage
Checking a token
To check a token, call the check
method with the token's address. This method returns a Promise that resolves to a RugCheckResult
object. With
this result you can do your own calculations whether a token is a rug pull or not.
const result = await rugChecker.check('tokenAddress');
Calculating the rug score
If you don't want to implement your own logic to determine the likelyness of a rug pull, you can calculate the rug score with the rugScore
method.
const score = rugChecker.rugScore(result);
Determining if a token is a potential rug pull
To determine if a RugCheckResult
indicates a potential rug pull, call the isRug
method. This is only necessary if you don't want to determine
yourself, if the token is a rug or not based on the RugCheckResult
object or the rugScore
method.
Full example
const SPLRugchecker = require('@degenfrends/solana-rugchecker').default;
const rugCheckConfig = {
solanaRpcEndpoint: 'https://api.devnet.solana.com',
// If you set this option, you need to provide a downloaded version of this file: https://api.raydium.io/v2/sdk/liquidity/mainnet.json, otherwise the API from geckoterminal.com is used.
poolFilePath: './mainnet.json',
// If you set this option, you need to provide the pool address for the token yourself. This might be useful when you build a sniper that is listening on raydium pool creation.
poolAddress: '97oWtQfbZMdDbn1jdNciDHm2vnPBR8VT3Ns7vSS7i9cm',
// If you set this option, the metadata checker will try to get the Website and Social Media via Helius if the Metaplex request doesn't return any urls for Twitter, Telegram or the Website.
heliusApiKey: 'your-helius-key'
};
const rugChecker = new SPLRugchecker(rugCheckConfig);
const result = await rugChecker.check('tokenAddress');
// you can access the detailed results of each check. Log the result to see all information that is returned.
const score = rugChecker.rugScore(result);
const isRug = rugChecker.isRug(result);
You can use the checkers indivudually like this, in this example I use the website checker, which is not included in the actual rugchecking logic. But the whois information can give you additional insights about a website and its owner:
const MetadataChecker = require('@degenfrends/solana-rugchecker').MetadataChecker;
const WebsiteChecker = require('@degenfrends/solana-rugchecker').WebsiteChecker;
// get the token metadata first
const metadataChecker = new MetadataChecker({
solanaRpcEndpoint: 'https://api.devnet.solana.com',
heliusApiKey: 'your-api-key'
});
const metadataCheckResult = await metadataChecker.check('1234tokenaddress');
// and then get the whois information for further processing
const websiteChecker = new WebsiteChecker();
const websiteCheckResult = await websiteChecker.check(result.metadata.website);
If you have any questions or suggestions, join the discord!