From 87810d47bb3245429f4b12084ed81e382f33c09c Mon Sep 17 00:00:00 2001 From: William Date: Sat, 25 Jan 2025 01:04:45 +0800 Subject: [PATCH] add close account --- src/common/mod.rs | 0 src/lib.rs | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/common/mod.rs diff --git a/src/common/mod.rs b/src/common/mod.rs old mode 100644 new mode 100755 diff --git a/src/lib.rs b/src/lib.rs index db5bbcc..157ac8b 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,12 +20,13 @@ use solana_sdk::{ }; use spl_associated_token_account::{ get_associated_token_address, - create_associated_token_account, + instruction::create_associated_token_account, }; use common::logs_subscribe; use common::logs_subscribe::SubscriptionHandle; use common::logs_events::DexEvent; +use spl_token::instruction::close_account; use std::sync::Arc; use std::time::Instant; @@ -167,6 +168,7 @@ impl PumpFun { &self.payer.pubkey(), &self.payer.pubkey(), &mint.pubkey(), + &constants::accounts::TOKEN_PROGRAM, )); } @@ -217,6 +219,7 @@ impl PumpFun { &self.payer.pubkey(), &self.payer.pubkey(), mint, + &constants::accounts::TOKEN_PROGRAM, )); } @@ -271,6 +274,7 @@ impl PumpFun { &self.payer.pubkey(), &self.payer.pubkey(), mint, + &constants::accounts::TOKEN_PROGRAM, )); } @@ -346,6 +350,14 @@ impl PumpFun { }, )); + instructions.push(close_account( + &spl_token::ID, + &ata, + &self.payer.pubkey(), + &self.payer.pubkey(), + &[&self.payer.pubkey()], + ).unwrap()); + let recent_blockhash = self.rpc.get_latest_blockhash()?; let transaction = Transaction::new_signed_with_payer( &instructions, @@ -451,6 +463,14 @@ impl PumpFun { }, )); + instructions.push(close_account( + &spl_token::ID, + &ata, + &self.payer.pubkey(), + &self.payer.pubkey(), + &[&self.payer.pubkey()], + ).unwrap()); + instructions.push( system_instruction::transfer( &self.payer.pubkey(),