1use std::sync::Arc;
2
3use anchor_lang::pubkey;
4use solana_client::rpc_client::RpcClient;
5use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
6
7pub mod instructions;
8pub use instructions::*;
9pub mod constants;
10pub mod errors;
11use crate::errors::ErrorCode;
12pub mod pda;
13pub mod states;
14
15pub const PUMP_DOT_FUN_PROGRAM_ID: Pubkey = pubkey!("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P");
16
17pub struct PumpDotFunSdk {
18 pub rpc: Arc<RpcClient>,
19}
20
21impl PumpDotFunSdk {
22 pub fn new(rpc: Arc<RpcClient>) -> Self {
23 Self { rpc }
24 }
25
26 pub fn create(
27 &self,
28 accounts: instructions::create::CreateAccounts,
29 args: instructions::create::CreateArgs,
30 ) -> Instruction {
31 instructions::create::create_ix(&PUMP_DOT_FUN_PROGRAM_ID, accounts, args)
32 }
33
34 pub fn buy(
35 &self,
36 accounts: instructions::buy::BuyAccounts,
37 args: instructions::buy::Buy,
38 ) -> Result<Vec<Instruction>, ErrorCode> {
39 instructions::buy::buy_ix(&self.rpc, &PUMP_DOT_FUN_PROGRAM_ID, accounts, args)
40 }
41
42 pub fn sell(
43 &self,
44 accounts: instructions::sell::SellAccounts,
45 args: instructions::sell::Sell,
46 ) -> Result<Vec<Instruction>, ErrorCode> {
47 instructions::sell::sell_ix(&self.rpc, &PUMP_DOT_FUN_PROGRAM_ID, accounts, args)
48 }
49}