2025-08-18 18:00:14 +08:00
|
|
|
pub mod calc;
|
2025-09-07 19:00:08 +08:00
|
|
|
pub mod price;
|
2025-07-10 18:14:21 +08:00
|
|
|
use crate::trading;
|
|
|
|
|
use crate::SolanaTrade;
|
|
|
|
|
use solana_sdk::pubkey::Pubkey;
|
|
|
|
|
use solana_sdk::signature::Keypair;
|
|
|
|
|
use solana_sdk::signer::Signer;
|
|
|
|
|
|
|
|
|
|
impl SolanaTrade {
|
|
|
|
|
#[inline]
|
|
|
|
|
pub async fn get_sol_balance(&self, payer: &Pubkey) -> Result<u64, anyhow::Error> {
|
|
|
|
|
trading::common::utils::get_sol_balance(&self.rpc, payer).await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub async fn get_payer_sol_balance(&self) -> Result<u64, anyhow::Error> {
|
|
|
|
|
trading::common::utils::get_sol_balance(&self.rpc, &self.payer.pubkey()).await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub async fn get_token_balance(
|
|
|
|
|
&self,
|
|
|
|
|
payer: &Pubkey,
|
|
|
|
|
mint: &Pubkey,
|
|
|
|
|
) -> Result<u64, anyhow::Error> {
|
|
|
|
|
trading::common::utils::get_token_balance(&self.rpc, payer, mint).await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub async fn get_payer_token_balance(&self, mint: &Pubkey) -> Result<u64, anyhow::Error> {
|
|
|
|
|
trading::common::utils::get_token_balance(&self.rpc, &self.payer.pubkey(), mint).await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn get_payer_pubkey(&self) -> Pubkey {
|
|
|
|
|
self.payer.pubkey()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn get_payer(&self) -> &Keypair {
|
|
|
|
|
self.payer.as_ref()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub async fn transfer_sol(
|
|
|
|
|
&self,
|
|
|
|
|
payer: &Keypair,
|
|
|
|
|
receive_wallet: &Pubkey,
|
|
|
|
|
amount: u64,
|
|
|
|
|
) -> Result<(), anyhow::Error> {
|
|
|
|
|
trading::common::utils::transfer_sol(&self.rpc, payer, receive_wallet, amount).await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub async fn close_token_account(&self, mint: &Pubkey) -> Result<(), anyhow::Error> {
|
|
|
|
|
trading::common::utils::close_token_account(&self.rpc, self.payer.as_ref(), mint).await
|
|
|
|
|
}
|
|
|
|
|
}
|