diff --git a/.changeset/addreadme.md b/.changeset/addreadme.md new file mode 100644 index 0000000..6c58c09 --- /dev/null +++ b/.changeset/addreadme.md @@ -0,0 +1,5 @@ +--- +'@degenfrends/solana-rugchecker': patch +--- + +## @degenfrends/solana-rugchecker: Initial version diff --git a/README.md b/README.md index e88abab..0da89d5 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ # Solana Rugchecker -![Static Badge](https://img.shields.io/badge/degen-100%25-pink) ![NPM Version](https://img.shields.io/npm/v/@degenfrends/solana-rugchecker) +![Static Badge](https://img.shields.io/badge/degen-100%25-pink) +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/degenfrends/solana-rugchecker/publish.yml) +![NPM License](https://img.shields.io/npm/l/%40degenfrends%2Fsolana-rugchecker) +![NPM Version](https://img.shields.io/npm/v/@degenfrends/solana-rugchecker) ![NPM Downloads](https://img.shields.io/npm/dw/@degenfrends/solana-rugchecker) - -![Discord](https://img.shields.io/discord/1242753898964582440) +![GitHub Repo stars](https://img.shields.io/github/stars/degenfrends/solana-rugchecker) ![X (formerly Twitter) URL](https://img.shields.io/twitter/url?url=https%3A%2F%2Fx.com%2Fkryptobrah&label=Twitter%2FX) -## 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](https://discord.gg/HUVAbet2Dp) and teach me what I did wrong, or fork it and do it better! +## This project is under development. Results might fail or give false results. Please evaluate your current version yourself, until this notice disappears. [Join the discord if you are looking for fellow degen developers!](https://discord.gg/HUVAbet2Dp) 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. @@ -21,9 +23,9 @@ npm install "@degenfrends/solana-rugchecker" ## Configuration -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. +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 @@ -51,8 +53,10 @@ 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. +### 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. ```typescript const result = await rugChecker.check('tokenAddress'); @@ -78,10 +82,16 @@ const SPLRugchecker = require('@degenfrends/solana-rugchecker').default; const rugCheckConfig = { solanaRpcEndpoint: 'https://api.devnet.solana.com' - poolFilePath: './mainnet.json' + // 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' }; 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); ``` + +If you have any questions or suggestions, [join the discord!](https://discord.gg/HUVAbet2Dp) diff --git a/src/checker/liquidity-checker.ts b/src/checker/liquidity-checker.ts index b92c90b..172375d 100644 --- a/src/checker/liquidity-checker.ts +++ b/src/checker/liquidity-checker.ts @@ -25,7 +25,12 @@ export default class LiquidityChecker { } async check(tokenAddress: string): Promise { - const poolAddress = await this.getRaydiumPoolAddress(tokenAddress); + let poolAddress; + if (!this.poolFilePath) { + poolAddress = await this.getRaydiumPoolAddress(tokenAddress); + } else { + poolAddress = await this.getLiquidityPool(tokenAddress); + } const liquidityCheckResult = new LiquidityCheckResult(); if (!poolAddress) { //throw new Error('No pool found'); diff --git a/src/model/config/liquidity-check.ts b/src/model/config/liquidity-check.ts index 04b000c..34c0c78 100644 --- a/src/model/config/liquidity-check.ts +++ b/src/model/config/liquidity-check.ts @@ -1,4 +1,5 @@ export default class LiquidityCheckConfig { solanaRpcEndpoint?: string; poolFilePath?: string; + poolAddress?: string; } diff --git a/src/model/config/rug-check.ts b/src/model/config/rug-check.ts index 8e4a9e2..92c0cb8 100644 --- a/src/model/config/rug-check.ts +++ b/src/model/config/rug-check.ts @@ -1,4 +1,5 @@ export default class RugCheckConfig { solanaRpcEndpoint?: string; poolFilePath?: string; + poolAddress?: string; }