MCPcopy Create free account
hub / github.com/cutupdev/Solana-Volume-Bot / getPoolKeys

Function getPoolKeys

utils/getPoolInfo.ts:62–83  ·  view source on GitHub ↗
(connection: Connection, baseMint: PublicKey)

Source from the content-addressed store, hash-verified

60}
61
62export const getPoolKeys = async (connection: Connection, baseMint: PublicKey) => {
63 try {
64 const res = await fetch(`https://api.dexscreener.com/latest/dex/tokens/${baseMint.toBase58()}`, {
65 method: 'GET',
66 headers: {
67 Accept: 'application/json',
68 'Content-Type': 'application/json'
69 }
70 })
71 const data = await res.clone().json()
72 if (data.pairs.length == 0) {
73 return null
74 } else {
75 const raydiumPairId = data.pairs.filter((pair: any) => pair.dexId === "raydium" && pair.quoteToken.address == NATIVE_MINT.toBase58())[0].pairAddress
76 const poolState = await _formatAmmKeysById(raydiumPairId, connection)
77 return poolState
78 }
79 } catch (e) {
80 console.log("error in fetching price of pool", e)
81 return null
82 }
83}
84

Callers 2

mainFunction · 0.90
mainFunction · 0.90

Calls 1

_formatAmmKeysByIdFunction · 0.85

Tested by

no test coverage detected