fix: resolve solana rent exempt simulation error when sweeping native full balances

This commit is contained in:
mstfyldz
2026-03-14 00:49:48 +03:00
parent 2de17043ca
commit a90b1707bb
4 changed files with 159 additions and 2 deletions

View File

@@ -264,9 +264,11 @@ export class CryptoEngine {
const destPubKey = new PublicKey(destinationAddress);
if (tokenSymbol === 'SOL' || tokenSymbol === 'NATIVE') {
// Get balance and send almost all (leave 5000 lamports for rent)
// Get balance and send almost all (leave exactly 0 to avoid rent-exempt errors)
// A standard Solana signature costs exactly 5000 lamports
const balance = await this.solConnection.getBalance(senderKeypair.publicKey);
const sendAmount = balance - 10000; // leave 0.00001 SOL for fees
const fee = 5000;
const sendAmount = balance - fee;
if (sendAmount <= 0) {
return { success: false, txHash: null, error: 'Insufficient SOL balance' };