Last active
September 28, 2022 15:01
-
-
Save matt-allan/3f7307d835026c215fc1d1ccb10af80e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Connection, PublicKey, clusterApiUrl } from '@solana/web3.js'; | |
(async () => { | |
const conn = new Connection( | |
process.env.RPC_URL ?? clusterApiUrl('mainnet-beta'), | |
'confirmed' | |
); | |
// From https://orca-so.gitbook.io/orca-developer-portal/whirlpools/interacting-with-the-protocol/orca-whirlpools-parameters | |
const whirlpoolProgramId = new PublicKey('whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc'); | |
const accounts = await conn.getProgramAccounts(whirlpoolProgramId, { | |
filters: [ | |
// Filter on size to exclude tick array accounts | |
// See https://github.com/orca-so/whirlpools/blob/4e72234a767ab32b756c61590c242dc410e8285a/programs/whirlpool/src/state/whirlpool.rs#L60 | |
{ dataSize: 8 + 261 + 384 } | |
// You can also filter on the parameters used to create the pool with a memcmp filter | |
// See https://github.com/orca-so/whirlpools/blob/4e72234a767ab32b756c61590c242dc410e8285a/programs/whirlpool/src/state/whirlpool.rs#L14 | |
// { memcmp: } | |
] | |
}); | |
console.log(`${accounts.length} accounts found`); | |
const accountData = accounts.map((account) => `https://solscan.io/account/${account.pubkey.toBase58()}`); | |
console.table(accountData); | |
})() | |
.catch(console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment