I am not a JavaScript developer, so I am pretty sure I didn't really got the concept of asynchronous programming. And I am not sure if I did everything correct with the npm package. If someone has too much time, join the discord and teach me what I did wrong, or fork it and do it better!
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.
Just install it with npm or yarn or whatever.
npm install "@degenfrends/solana-rugchecker"
To create an instance of SPLRugchecker
, you need to provide a RugCheckConfig
object with the solanaRpcEndpoint
and poolFilePath
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.
const rugCheckConfig = {
solanaRpcEndpoint: 'https://api.devnet.solana.com'
poolFilePath: './mainnet.json'
};
const rugChecker = new SPLRugchecker(rugCheckConfig);
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({});
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');
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);
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.
const SPLRugchecker = require('@degenfrends/solana-rugchecker').default;
const rugCheckConfig = {
solanaRpcEndpoint: 'https://api.devnet.solana.com'
poolFilePath: './mainnet.json'
};
const rugChecker = new SPLRugchecker(rugCheckConfig);
const result = await rugChecker.check('tokenAddress');
const score = rugChecker.rugScore(result);
const isRug = rugChecker.isRug(result);