Skip to content

Commit 0b6779c

Browse files
smypmsaclaude
andauthored
Fix buy/sell transactions silently failing on-chain (#157)
* fix(core): disable account_data_size limit and add meta.err checking The 12.5MB setLoadedAccountsDataSizeLimit was causing all buy transactions to fail with MaxLoadedAccountsDataSizeExceeded since pump.fun migrated to Token-2022. Transactions landed on-chain (fees paid) but inner instructions were rejected — the bot paid gas for nothing. Changes: - Disable account_data_size in all bot configs (Token-2022 needs >12.5MB) - Add meta.err check in get_buy_transaction_details() for clear error reporting when transactions fail on-chain - Include tx signature in platform_aware.py error messages for debugging Tested: full buy→sell→cleanup cycle works on pump_fun with geyser listener. * fix(core): check meta.err in confirm_transaction to detect failed txs Solana transactions can be "confirmed" (included in a block) but still fail execution if inner program instructions are rejected. Previously, confirm_transaction only checked that the tx landed on-chain, causing silent failures in buy, sell, and cleanup operations. Now fetches the transaction result after confirmation and checks meta.err, returning False when the transaction failed. This fixes the ATA cleanup issue where sells were silently failing with Custom: 6003 errors, leaving non-zero token balances. * fix(core): treat failed tx fetch as unconfirmed in confirm_transaction When _get_transaction_result returns None (RPC failure, timeout, etc.), the function was falling through to return True — silently treating an unknown state as success. Now returns False with a warning log. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c5b0161 commit 0b6779c

6 files changed

Lines changed: 39 additions & 8 deletions

File tree

bots/bot-sniper-1-geyser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ compute_units:
6363
# Note: Savings don't show in "consumed CU" but improve tx priority/cost.
6464
# Note (Nov 23, 2025): with data size set to 512KB, transactions fail - increasing to 12.5MB resolves the issue.
6565
# Reference: https://www.anza.xyz/blog/cu-optimization-with-setloadedaccountsdatasizelimit
66-
account_data_size: 12_500_000
66+
# account_data_size: 12_500_000 # Disabled: causes MaxLoadedAccountsDataSizeExceeded with Token-2022
6767

6868
# Filters for token selection
6969
filters:

bots/bot-sniper-2-logs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ compute_units:
6363
# Note: Savings don't show in "consumed CU" but improve tx priority/cost.
6464
# Note (Nov 23, 2025): with data size set to 512KB, transactions fail - increasing to 12.5MB resolves the issue.
6565
# Reference: https://www.anza.xyz/blog/cu-optimization-with-setloadedaccountsdatasizelimit
66-
account_data_size: 12_500_000
66+
# account_data_size: 12_500_000 # Disabled: causes MaxLoadedAccountsDataSizeExceeded with Token-2022
6767

6868
# Filters for token selection
6969
filters:

bots/bot-sniper-3-blocks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ compute_units:
6363
# Note: Savings don't show in "consumed CU" but improve tx priority/cost.
6464
# Note (Nov 23, 2025): with data size set to 512KB, transactions fail - increasing to 12.5MB resolves the issue.
6565
# Reference: https://www.anza.xyz/blog/cu-optimization-with-setloadedaccountsdatasizelimit
66-
account_data_size: 12_500_000
66+
# account_data_size: 12_500_000 # Disabled: causes MaxLoadedAccountsDataSizeExceeded with Token-2022
6767

6868
# Filters for token selection
6969
filters:

bots/bot-sniper-4-pp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ compute_units:
6161
# Note: Savings don't show in "consumed CU" but improve tx priority/cost.
6262
# Note (Nov 23, 2025): with data size set to 512KB, transactions fail - increasing to 12.5MB resolves the issue.
6363
# Reference: https://www.anza.xyz/blog/cu-optimization-with-setloadedaccountsdatasizelimit
64-
account_data_size: 12_500_000
64+
# account_data_size: 12_500_000 # Disabled: causes MaxLoadedAccountsDataSizeExceeded with Token-2022
6565

6666
# Filters for token selection
6767
filters:

src/core/client.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,26 +280,47 @@ async def build_and_send_transaction(
280280
async def confirm_transaction(
281281
self, signature: str, commitment: str = "confirmed"
282282
) -> bool:
283-
"""Wait for transaction confirmation.
283+
"""Wait for transaction confirmation and verify execution success.
284+
285+
Confirms the transaction landed on-chain, then checks meta.err to
286+
ensure the inner program instructions actually succeeded. A transaction
287+
can be "confirmed" (included in a block) but still fail execution.
284288
285289
Args:
286290
signature: Transaction signature
287291
commitment: Confirmation commitment level
288292
289293
Returns:
290-
Whether transaction was confirmed
294+
Whether transaction was confirmed AND executed successfully
291295
"""
292296
await self._rate_limiter.acquire()
293297
client = await self.get_client()
294298
try:
295299
await client.confirm_transaction(
296300
signature, commitment=commitment, sleep_seconds=1
297301
)
298-
return True
299302
except Exception:
300303
logger.exception(f"Failed to confirm transaction {signature}")
301304
return False
302305

306+
# Verify the transaction actually succeeded (no program errors)
307+
result = await self._get_transaction_result(str(signature))
308+
if not result:
309+
logger.warning(
310+
f"Could not fetch transaction {str(signature)[:16]}... "
311+
f"to verify execution — treating as unconfirmed"
312+
)
313+
return False
314+
315+
tx_err = result.get("meta", {}).get("err")
316+
if tx_err:
317+
logger.error(
318+
f"Transaction {str(signature)[:16]}... confirmed but failed: {tx_err}"
319+
)
320+
return False
321+
322+
return True
323+
303324
async def get_transaction_token_balance(
304325
self, signature: str, user_pubkey: Pubkey, mint: Pubkey
305326
) -> int | None:
@@ -354,6 +375,15 @@ async def get_buy_transaction_details(
354375
return None, None
355376

356377
meta = result.get("meta", {})
378+
379+
# Check for transaction execution errors (e.g., MaxLoadedAccountsDataSizeExceeded)
380+
tx_err = meta.get("err")
381+
if tx_err:
382+
logger.error(
383+
f"Transaction {signature[:16]}... failed with error: {tx_err}"
384+
)
385+
return None, None
386+
357387
mint_str = str(mint)
358388

359389
# Get tokens received from pre/post token balance diff

src/trading/platform_aware.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ async def execute(self, token_info: TokenInfo) -> TradeResult:
156156
else:
157157
raise ValueError(
158158
f"Failed to parse transaction details: tokens={tokens_raw}, "
159-
f"sol_spent={sol_spent}"
159+
f"sol_spent={sol_spent} (tx: {tx_signature}). "
160+
f"The transaction may have failed on-chain — check explorer."
160161
)
161162

162163
return TradeResult(

0 commit comments

Comments
 (0)