Skip to content

Instantly share code, notes, and snippets.

@matt-allan
Last active September 28, 2022 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-allan/3f7307d835026c215fc1d1ccb10af80e to your computer and use it in GitHub Desktop.
Save matt-allan/3f7307d835026c215fc1d1ccb10af80e to your computer and use it in GitHub Desktop.
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