Skip to content

Commit

Permalink
changed liquidity check result handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kryptobrah committed Jun 9, 2024
1 parent 7937416 commit d2d730c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/liquiditychecker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@degenfrends/solana-rugchecker': patch
---

## @degenfrends/solana-rugchecker: Initial version
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/checker/liquidity-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ export default class LiquidityChecker {

async check(tokenAddress: string): Promise<LiquidityCheckResult> {
const poolAddress = await this.getLiquidityPool(tokenAddress);
const liquidityCheckResult = new LiquidityCheckResult();
if (!poolAddress) {
throw new Error('No pool found');
//throw new Error('No pool found');
liquidityCheckResult.liquidityPoolAddress = '';
return liquidityCheckResult;
}
const acc = await this.connection.getMultipleAccountsInfo([new PublicKey(poolAddress)]);
const parsed = acc.map((v) => (v ? LIQUIDITY_STATE_LAYOUT_V4.decode(v.data) : null));
Expand All @@ -39,9 +42,9 @@ export default class LiquidityChecker {
const maxLpSupply = Math.max(actualSupply, lpReserve - 1);
const burnAmt = lpReserve - actualSupply;
const burnPct = (burnAmt / lpReserve) * 100;
const liquidityCheckResult = new LiquidityCheckResult();
liquidityCheckResult.isLiquidityLocked = burnPct > 95;
liquidityCheckResult.burnt = burnPct;
liquidityCheckResult.liquidityPoolAddress = poolAddress;
return liquidityCheckResult;
}

Expand Down
1 change: 1 addition & 0 deletions src/model/result/liquidity-check.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default class LiquidityCheckResult {
isLiquidityLocked: boolean;
burnt: number;
liquidityPoolAddress: string;
}

0 comments on commit d2d730c

Please sign in to comment.