Skip to content

Commit

Permalink
changed lqp check
Browse files Browse the repository at this point in the history
  • Loading branch information
kryptobrah committed Jun 9, 2024
1 parent bcdc40e commit bfb3eb6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/addreadme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@degenfrends/solana-rugchecker': patch
---

## @degenfrends/solana-rugchecker: Initial version
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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

Expand Down Expand Up @@ -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');
Expand All @@ -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)
7 changes: 6 additions & 1 deletion src/checker/liquidity-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ export default class LiquidityChecker {
}

async check(tokenAddress: string): Promise<LiquidityCheckResult> {
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');
Expand Down
1 change: 1 addition & 0 deletions src/model/config/liquidity-check.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default class LiquidityCheckConfig {
solanaRpcEndpoint?: string;
poolFilePath?: string;
poolAddress?: string;
}
1 change: 1 addition & 0 deletions src/model/config/rug-check.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default class RugCheckConfig {
solanaRpcEndpoint?: string;
poolFilePath?: string;
poolAddress?: string;
}

0 comments on commit bfb3eb6

Please sign in to comment.