(connection: Connection, baseMint: PublicKey)
| 60 | } |
| 61 | |
| 62 | export 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 |
no test coverage detected