From e605485ecfba4f854075c7f93674cd886ffae21a Mon Sep 17 00:00:00 2001 From: 0xfnzero <0xfnzero@users.noreply.github.com> Date: Sat, 9 May 2026 14:46:52 +0800 Subject: [PATCH] fix(bonding-curve): tolerate extra trailing bytes in account data BondingCurveAccount::try_from_slice requires the entire input slice to be consumed, which fails with "Not all bytes read" when the on-chain bonding curve account has been extended with new fields (e.g. after a protocol upgrade). Switch to BorshDeserialize::deserialize which reads the known fields and silently ignores any trailing bytes. --- src/instruction/utils/pumpfun.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/instruction/utils/pumpfun.rs b/src/instruction/utils/pumpfun.rs index f2da8f9..6ec6308 100644 --- a/src/instruction/utils/pumpfun.rs +++ b/src/instruction/utils/pumpfun.rs @@ -545,7 +545,11 @@ pub async fn fetch_bonding_curve_account( return Err(anyhow!("Bonding curve not found")); } - let mut bonding_curve = BondingCurveAccount::try_from_slice(&account.data[8..]) + // Use `deserialize` instead of `try_from_slice` so that extra trailing bytes + // (from on-chain schema additions like new fields) are silently ignored. + // `try_from_slice` requires the entire slice to be consumed, causing + // "Not all bytes read" when the account has been extended. + let mut bonding_curve = BondingCurveAccount::deserialize(&mut &account.data[8..]) .map_err(|e| anyhow::anyhow!("Failed to decode bonding curve account: {}", e))?; bonding_curve.account = bonding_curve_pda;