MCPcopy Index your code
hub / github.com/cutupdev/Solana-Volume-Bot / PoolKeys

Class PoolKeys

utils/getPoolKeys.ts:7–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5dotenv.config();
6
7export class PoolKeys {
8 static SOLANA_ADDRESS = 'So11111111111111111111111111111111111111112'
9 static RAYDIUM_POOL_V4_PROGRAM_ID = '675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8';
10 static OPENBOOK_ADDRESS = 'srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX';
11 static SOL_DECIMALS = 9
12
13 static async fetchMarketId(connection: Connection, baseMint: PublicKey, quoteMint: PublicKey, commitment: Commitment) {
14 let accounts = await connection.getProgramAccounts(
15 new PublicKey('srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX'),
16 {
17 commitment,
18 filters: [
19 { dataSize: MARKET_STATE_LAYOUT_V3.span },
20 {
21 memcmp: {
22 offset: MARKET_STATE_LAYOUT_V3.offsetOf("baseMint"),
23 bytes: baseMint.toBase58(),
24 },
25 },
26 {
27 memcmp: {
28 offset: MARKET_STATE_LAYOUT_V3.offsetOf("quoteMint"),
29 bytes: quoteMint.toBase58(),
30 },
31 },
32 ],
33 }
34 );
35 if(!accounts)
36 accounts = await connection.getProgramAccounts(
37 new PublicKey('srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX'),
38 {
39 commitment,
40 filters: [
41 { dataSize: MARKET_STATE_LAYOUT_V3.span },
42 {
43 memcmp: {
44 offset: MARKET_STATE_LAYOUT_V3.offsetOf("quoteMint"),
45 bytes: baseMint.toBase58(),
46 },
47 },
48 {
49 memcmp: {
50 offset: MARKET_STATE_LAYOUT_V3.offsetOf("baseMint"),
51 bytes: quoteMint.toBase58(),
52 },
53 },
54 ],
55 }
56 );
57 console.log(accounts)
58 return accounts.map(({ account }) => MARKET_STATE_LAYOUT_V3.decode(account.data))[0].ownAddress
59 }
60
61 static async fetchMarketInfo(connection: Connection, marketId: PublicKey) {
62 const marketAccountInfo = await connection.getAccountInfo(marketId, "processed");
63 if (!marketAccountInfo) {
64 throw new Error('Failed to fetch market info for market id ' + marketId.toBase58());

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected