-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
75 lines (68 loc) · 2.74 KB
/
Copy pathindex.js
File metadata and controls
75 lines (68 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function formatLargeNumber(num) {
if (num >= 1e9) {
return Math.floor(num / 1e9) + ' B';
} else if (num >= 1e6) {
return Math.floor(num / 1e6) + ' M';
} else if (num >= 1e3) {
return Math.floor(num / 1e3) + ' K';
}
return num.toString();
}
function formatMins(num) {
if(num >= 60){
return Math.floor(num / 60) + 'hour ' + (num % 60) + 'mins ago'
} else
return num + 'mins ago'
}
(async () => {
const mintAddress = '';
console.log(mintAddress)
const tokenInfo = await (await fetch(`https://api.rugcheck.xyz/v1/tokens/${mintAddress}/report`)).json();
const name = tokenInfo.tokenMeta.name;
const symbol = tokenInfo.tokenMeta.symbol;
const price = tokenInfo.price.toFixed(5);
const liquidity = tokenInfo.totalMarketLiquidity.toFixed(2);
const decimals = tokenInfo.token.decimals;
const totalSupplyNumber = tokenInfo.token.supply / 10 ** decimals;
const totalSupply = formatLargeNumber(totalSupplyNumber);
const ownerAddress = tokenInfo.creator;
const devWalletTokens = await(await fetch(`https://mainnet.helius-rpc.com/?api-key=35f98539-6eae-4584-a11c-6feae60f0393`, {
method: 'POST',
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"id": "text",
"jsonrpc": "2.0",
"method": "getTokenAccounts",
"params": {
"mint": mintAddress,
"owner": ownerAddress,
}
})
})).json();
const devWalletBalance = devWalletTokens.result.token_accounts.length ? devWalletTokens.result.token_accounts[0].amount : 0;
const devHolderPercentage = ((devWalletBalance / tokenInfo.token.supply) * 100).toFixed(2);
const topHolderPercentage = tokenInfo.topHolders[0].pct.toFixed(2);
let lpLockedUSD = 0, totallpUSD = 0;
tokenInfo.markets.map(pair => {
lpLockedUSD += pair.lp.lpLockedUSD;
totallpUSD += (pair.lp.quoteUSD + pair.lp.baseUSD);
})
const lpTokenPercentage = (lpLockedUSD / totallpUSD * 100).toFixed(2);
const dexScreenerData = await (await fetch(`https://api.dexscreener.com/latest/dex/tokens/${mintAddress}`)).json();
const marketCap = Math.floor(dexScreenerData.pairs.reduce((sum, pair) => sum + pair.marketCap, 0));
const pair = dexScreenerData.pairs[0];
const createdAt = formatMins(Math.floor((Date.now() - pair.pairCreatedAt) / 60000));
//help
console.log(`📌 ${name} (${symbol})
💰 Price: ${price}
🆔 CA: ${mintAddress}
⏳ Created: ${createdAt}
📈 Market Cap: ${marketCap}
💧 Liquidity: $${liquidity}
💵 Total Supply: ${totalSupply}
👨💻 Dev Hold: ${devHolderPercentage}%
🏦 Top Holder: ${topHolderPercentage}%
🪣 LP Tokens: ${lpTokenPercentage}%`)
})();