Skip to content

Commit

Permalink
Improved Performance
Browse files Browse the repository at this point in the history
  • Loading branch information
kryptobrah committed Jun 12, 2024
1 parent d9c03d0 commit f388dab
Show file tree
Hide file tree
Showing 8 changed files with 723 additions and 712 deletions.
5 changes: 5 additions & 0 deletions .changeset/improvedperformance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@degenfrends/solana-rugchecker': patch
---

## @degenfrends/solana-rugchecker: Initial version
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ const SPLRugchecker = require('./dist/index.js').default;
const WebsiteChecker = require('./dist/index.js').WebsiteChecker;
async function main() {
const rugCheckConfig = {
solanaRpcEndpoint: 'https://solana-mainnet.rpc.extrnode.com/036e028d-7094-4f3d-876e-956d6e56f0ff',
poolFilePath: './all_pools.json'
solanaRpcEndpoint: 'https://solana-mainnet.rpc.extrnode.com/036e028d-7094-4f3d-876e-956d6e56f0ff'
//poolFilePath: './all_pools.json'
};
const rugChecker = new SPLRugchecker(rugCheckConfig);
const result = await rugChecker.check('97oWtQfbZMdDbn1jdNciDHm2vnPBR8VT3Ns7vSS7i9cm');
const result = await rugChecker.check('7Hk81bdBwjgfNDvJc6WBzjEw95Rnt5Tts6qJg2Mnt38L');
const score = rugChecker.rugScore(result);
const isRug = rugChecker.isRug(result);
console.log(result);
Expand Down
318 changes: 159 additions & 159 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
"license": "MIT",
"devDependencies": {
"@changesets/cli": "^2.27.5",
"@swc/core": "^1.5.7",
"@swc/core": "^1.5.28",
"@types/jest": "^29.5.12",
"jest": "^29.7.0",
"ts-jest": "^29.1.4",
"ts-node": "^10.9.2",
"tsup": "^8.0.2",
"tsup": "^8.1.0",
"typescript": "^5.4.5"
},
"dependencies": {
"@metaplex-foundation/js": "^0.20.1",
"@raydium-io/raydium-sdk": "^1.3.1-beta.52",
"@raydium-io/raydium-sdk": "1.3.1-beta.54",
"@solana/web3.js": "^1.92.3",
"axios": "^1.7.2",
"dotenv": "^16.4.5",
Expand Down
1,067 changes: 532 additions & 535 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/checker/holders-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default class HoldersChecker {
for (const holder of largestHoldersResponse.value) {
const tokenAccountsResponse = await this.connection.getParsedAccountInfo(holder.address);
const walletAddress = (tokenAccountsResponse.value?.data as ParsedAccountData)?.parsed?.info?.owner;
await sleep(300);
if (holder.uiAmount !== null && walletAddress !== null && walletAddress !== '5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1') {
whaleSupply += holder.uiAmount;
let topHolder = new HolderCheckResult();
Expand All @@ -53,6 +52,7 @@ export default class HoldersChecker {
holdersCheckResult.topHolders = topHolders;
holdersCheckResult.topHoldersPercentage = topHoldersPercentage;
holdersCheckResult.raydiumPercentage = raydiumPercentage;

return holdersCheckResult;
}
}
23 changes: 15 additions & 8 deletions src/checker/liquidity-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ export default class LiquidityChecker {
private connection: Connection;

private poolFilePath: string;

constructor({ solanaRpcEndpoint, poolFilePath }: LiquidityCheckConfig, connection?: Connection) {
private poolAddress: string;
constructor({ solanaRpcEndpoint, poolFilePath, poolAddress }: LiquidityCheckConfig, connection?: Connection) {
if (!solanaRpcEndpoint) {
solanaRpcEndpoint = String(process.env.SOLANA_RPC_ENDPOINT);
}
if (!poolFilePath) {
poolFilePath = String(process.env.POOL_FILE_PATH);
} else {
this.poolFilePath = poolFilePath;
}
if (poolAddress) {
this.poolAddress = poolAddress;
}
this.poolFilePath = poolFilePath;
if (!connection) {
connection = new Connection(solanaRpcEndpoint);
}
Expand All @@ -26,10 +30,14 @@ export default class LiquidityChecker {

async check(tokenAddress: string): Promise<LiquidityCheckResult> {
let poolAddress;
if (!this.poolFilePath) {
poolAddress = await this.getRaydiumPoolAddress(tokenAddress);
if (this.poolAddress) {
poolAddress = this.poolAddress;
} else {
poolAddress = await this.getLiquidityPool(tokenAddress);
if (!this.poolFilePath) {
poolAddress = await this.getRaydiumPoolAddress(tokenAddress);
} else {
poolAddress = await this.getLiquidityPool(tokenAddress);
}
}
const liquidityCheckResult = new LiquidityCheckResult();
if (!poolAddress) {
Expand All @@ -51,6 +59,7 @@ export default class LiquidityChecker {
liquidityCheckResult.isLiquidityLocked = burnPct > 95;
liquidityCheckResult.burnt = burnPct;
liquidityCheckResult.liquidityPoolAddress = poolAddress;

return liquidityCheckResult;
}

Expand All @@ -73,9 +82,7 @@ export default class LiquidityChecker {
async getRaydiumPoolAddress(mintAddress: string) {
try {
const url = 'https://api.geckoterminal.com/api/v2/networks/solana/tokens/' + mintAddress;

const response = await axios.get(url);
console.log(response);
return response.data.data.relationships.top_pools.data[0].id.replace('solana_', '');
} catch (error) {
console.error('Error fetching pool address:', error);
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ export default class SPLRugchecker {
}

async check(tokenAddress: string): Promise<RugCheckResult> {
const metadataCheckResult = await this.metadataChecker.check(tokenAddress);
const holdersCheckResult = await this.holdersChecker.check(tokenAddress);
const liquidityCheckResult = await this.liquidityChecker.check(tokenAddress);
const [metadataCheckResult, holdersCheckResult, liquidityCheckResult] = await Promise.all([
this.metadataChecker.check(tokenAddress),
this.holdersChecker.check(tokenAddress),
this.liquidityChecker.check(tokenAddress)
]);

const rugCheckResult = new RugCheckResult();
rugCheckResult.metadata = metadataCheckResult;
Expand Down

0 comments on commit f388dab

Please sign in to comment.