mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2025-11-24 21:51:10 +10:00
feat: add support for wsol swaps
This commit is contained in:
@ -1,31 +1,36 @@
|
||||
import { Connection, PublicKey } from '@solana/web3.js';
|
||||
import { Commitment, Connection, PublicKey } from '@solana/web3.js';
|
||||
import {
|
||||
GetStructureSchema,
|
||||
MARKET_STATE_LAYOUT_V3,
|
||||
} from '@raydium-io/raydium-sdk';
|
||||
import { USDC_TOKEN_ID } from '../common';
|
||||
import {
|
||||
MINIMAL_MARKET_STATE_LAYOUT_V3,
|
||||
OPENBOOK_PROGRAM_ID,
|
||||
|
||||
} from '../liquidity';
|
||||
|
||||
export type MinimalOpenBookAccountData = {
|
||||
id: PublicKey;
|
||||
programId: PublicKey;
|
||||
};
|
||||
export type MinimalMarketStateLayoutV3 = typeof MINIMAL_MARKET_STATE_LAYOUT_V3;
|
||||
export type MinimalMarketLayoutV3 =
|
||||
GetStructureSchema<MinimalMarketStateLayoutV3>;
|
||||
|
||||
export async function getAllMarketsV3(
|
||||
connection: Connection,
|
||||
quoteMint: PublicKey,
|
||||
commitment?: Commitment,
|
||||
): Promise<MinimalOpenBookAccountData[]> {
|
||||
const { span } = MARKET_STATE_LAYOUT_V3;
|
||||
const accounts = await connection.getProgramAccounts(OPENBOOK_PROGRAM_ID, {
|
||||
dataSlice: { offset: 0, length: 0 },
|
||||
commitment: 'processed',
|
||||
commitment: commitment,
|
||||
filters: [
|
||||
{ dataSize: span },
|
||||
{
|
||||
memcmp: {
|
||||
offset: MARKET_STATE_LAYOUT_V3.offsetOf('quoteMint'),
|
||||
bytes: USDC_TOKEN_ID.toBase58(),
|
||||
bytes: quoteMint.toBase58(),
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user