Files
pumpfun-bonkfun-bot/src/cleanup/modes.py
T

69 lines
1.8 KiB
Python
Raw Normal View History

2025-03-27 15:19:52 +00:00
from cleanup.manager import AccountCleanupManager
from utils.logger import get_logger
logger = get_logger(__name__)
2025-04-24 20:32:47 +00:00
def should_cleanup_after_failure(cleanup_mode) -> bool:
return cleanup_mode == "on_fail"
2025-03-27 15:19:52 +00:00
2025-04-24 20:32:47 +00:00
def should_cleanup_after_sell(cleanup_mode) -> bool:
return cleanup_mode == "after_sell"
2025-03-27 15:19:52 +00:00
2025-04-24 20:32:47 +00:00
def should_cleanup_post_session(cleanup_mode) -> bool:
return cleanup_mode == "post_session"
2025-03-27 15:19:52 +00:00
2025-04-24 20:32:47 +00:00
async def handle_cleanup_after_failure(
2025-07-18 12:03:00 +00:00
client,
wallet,
mint,
priority_fee_manager,
cleanup_mode,
cleanup_with_prior_fee,
force_burn,
):
2025-04-24 20:32:47 +00:00
if should_cleanup_after_failure(cleanup_mode):
2025-03-27 15:19:52 +00:00
logger.info("[Cleanup] Triggered by failed buy transaction.")
2025-07-18 12:03:00 +00:00
manager = AccountCleanupManager(
client, wallet, priority_fee_manager, cleanup_with_prior_fee, force_burn
)
2025-03-27 15:19:52 +00:00
await manager.cleanup_ata(mint)
2025-07-18 12:03:00 +00:00
2025-04-24 20:32:47 +00:00
async def handle_cleanup_after_sell(
2025-07-18 12:03:00 +00:00
client,
wallet,
mint,
priority_fee_manager,
cleanup_mode,
cleanup_with_prior_fee,
force_burn,
):
2025-04-24 20:32:47 +00:00
if should_cleanup_after_sell(cleanup_mode):
2025-03-27 15:19:52 +00:00
logger.info("[Cleanup] Triggered after token sell.")
2025-07-18 12:03:00 +00:00
manager = AccountCleanupManager(
client, wallet, priority_fee_manager, cleanup_with_prior_fee, force_burn
)
2025-03-27 15:19:52 +00:00
await manager.cleanup_ata(mint)
2025-07-18 12:03:00 +00:00
2025-04-24 20:32:47 +00:00
async def handle_cleanup_post_session(
2025-07-18 12:03:00 +00:00
client,
wallet,
mints,
priority_fee_manager,
cleanup_mode,
cleanup_with_prior_fee,
force_burn,
):
2025-04-24 20:32:47 +00:00
if should_cleanup_post_session(cleanup_mode):
2025-03-27 15:19:52 +00:00
logger.info("[Cleanup] Triggered post trading session.")
2025-07-18 12:03:00 +00:00
manager = AccountCleanupManager(
client, wallet, priority_fee_manager, cleanup_with_prior_fee, force_burn
)
2025-03-27 15:19:52 +00:00
for mint in mints:
await manager.cleanup_ata(mint)