add close account

This commit is contained in:
William
2025-01-25 01:04:45 +08:00
parent 14b77dbdf4
commit 87810d47bb
2 changed files with 21 additions and 1 deletions
Regular → Executable
View File
+21 -1
View File
@@ -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(),