mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-08-13 23:38:04 +00:00
feat: added cleanup manager and modes
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from cleanup.manager import AccountCleanupManager
|
||||
from config import CLEANUP_MODE, CLEANUP_WITHOUT_PRIORITY_FEE
|
||||
from utils.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def should_cleanup_after_failure() -> bool:
|
||||
return CLEANUP_MODE == "on_fail"
|
||||
|
||||
|
||||
def should_cleanup_after_sell() -> bool:
|
||||
return CLEANUP_MODE == "after_sell"
|
||||
|
||||
|
||||
def should_cleanup_post_session() -> bool:
|
||||
return CLEANUP_MODE == "post_session"
|
||||
|
||||
|
||||
async def handle_cleanup_after_failure(client, wallet, mint):
|
||||
if should_cleanup_after_failure():
|
||||
logger.info("[Cleanup] Triggered by failed buy transaction.")
|
||||
manager = AccountCleanupManager(client, wallet, use_priority_fee=not CLEANUP_WITHOUT_PRIORITY_FEE)
|
||||
await manager.cleanup_ata(mint)
|
||||
|
||||
|
||||
async def handle_cleanup_after_sell(client, wallet, mint):
|
||||
if should_cleanup_after_sell():
|
||||
logger.info("[Cleanup] Triggered after token sell.")
|
||||
manager = AccountCleanupManager(client, wallet, use_priority_fee=not CLEANUP_WITHOUT_PRIORITY_FEE)
|
||||
await manager.cleanup_ata(mint)
|
||||
|
||||
|
||||
async def handle_cleanup_post_session(client, wallet, mints):
|
||||
if should_cleanup_post_session():
|
||||
logger.info("[Cleanup] Triggered post trading session.")
|
||||
manager = AccountCleanupManager(client, wallet, use_priority_fee=not CLEANUP_WITHOUT_PRIORITY_FEE)
|
||||
for mint in mints:
|
||||
await manager.cleanup_ata(mint)
|
||||
|
||||
Reference in New Issue
Block a user