diff --git a/src/instruction/pumpfun.rs b/src/instruction/pumpfun.rs index 28d3ce6..9ddc71b 100755 --- a/src/instruction/pumpfun.rs +++ b/src/instruction/pumpfun.rs @@ -1,5 +1,5 @@ use anyhow::{anyhow, Result}; -use solana_sdk::{instruction::Instruction, native_token::sol_to_lamports}; +use solana_sdk::{instruction::Instruction, native_token::sol_str_to_lamports}; use spl_associated_token_account::{ get_associated_token_address, instruction::create_associated_token_account, }; @@ -57,7 +57,7 @@ impl InstructionBuilder for PumpFunInstructionBuilder { let mut buy_token_amount = get_buy_token_amount_from_sol_amount(&bonding_curve, params.sol_amount); if buy_token_amount <= 100 * 1_000_000_u64 { - buy_token_amount = if max_sol_cost > sol_to_lamports(0.01) { + buy_token_amount = if max_sol_cost > sol_str_to_lamports("0.01").unwrap_or(0) { 25547619 * 1_000_000_u64 } else { 255476 * 1_000_000_u64 diff --git a/src/trading/common/transaction_builder.rs b/src/trading/common/transaction_builder.rs index 79fa518..178c77e 100755 --- a/src/trading/common/transaction_builder.rs +++ b/src/trading/common/transaction_builder.rs @@ -2,7 +2,7 @@ use solana_hash::Hash; use solana_sdk::{ instruction::Instruction, message::{v0, VersionedMessage}, - native_token::sol_to_lamports, + native_token::sol_str_to_lamports, pubkey::Pubkey, signature::Keypair, signer::Signer, @@ -85,7 +85,7 @@ pub async fn build_tip_transaction( instructions.push(transfer( &payer.pubkey(), tip_account, - sol_to_lamports(tip_amount), + sol_str_to_lamports(tip_amount.to_string().as_str()).unwrap_or(0), )); // 获取交易使用的blockhash @@ -191,7 +191,7 @@ pub async fn build_sell_tip_transaction( instructions.push(transfer( &payer.pubkey(), tip_account, - sol_to_lamports(tip_amount), + sol_str_to_lamports(tip_amount.to_string().as_str()).unwrap_or(0), )); // 获取地址查找表账户