From 2ece1c9a2dfd1ff613d27e49f66d53da26fb0139 Mon Sep 17 00:00:00 2001 From: Anton Sauchyk Date: Tue, 28 Apr 2026 18:51:56 +0200 Subject: [PATCH] fix(trading): refresh creator_vault from on-chain BC state before sell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Post-2026-04-28, BC.creator can be delegated to a PFEE-program-owned PDA after the initial creator buy. The create-time creator_vault cached on TokenInfo goes stale before the sell lands, producing ConstraintSeeds (0x7d6) on the Sell instruction. The sell flow already re-fetches pool_state to refresh is_mayhem_mode and is_cashback_coin; extend it to also refresh token_info.creator and re-derive creator_vault from the current BC.creator. Mainnet validation: geyser listener buy+sell on BEE — buy 2TSqZHZh…k7uN, sell 3TevcP5g…f8nQ, err=None on both. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/trading/platform_aware.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/trading/platform_aware.py b/src/trading/platform_aware.py index 2ab08f2..162dc77 100644 --- a/src/trading/platform_aware.py +++ b/src/trading/platform_aware.py @@ -325,6 +325,24 @@ class PlatformAwareSeller(Trader): token_info.is_cashback_coin = pool_state.get( "is_cashback_coin", token_info.is_cashback_coin ) + # Refresh creator/creator_vault from current BC state. Post + # 2026-04-28 the program may delegate BC.creator to a PFEE-owned + # PDA after the initial creator buy, so the create-time vault + # cached on token_info goes stale before the sell lands. Failing + # to refresh manifests as ConstraintSeeds (0x7d6) on Sell. + fresh_creator = pool_state.get("creator") + if fresh_creator: + from solders.pubkey import Pubkey as _Pubkey + + new_creator = ( + _Pubkey.from_string(fresh_creator) + if isinstance(fresh_creator, str) + else fresh_creator + ) + token_info.creator = new_creator + token_info.creator_vault = address_provider.derive_creator_vault( + new_creator + ) except Exception as e: # noqa: BLE001 logger.warning( f"Could not refresh curve flags before sell ({e}); "