feat(pumpfun): align IDL for V2, Mayhem & Cashback

Update BondingCurve & Global structs, fix account mappings (Create/Buy/Sell), improve trade event merging, add missing fields to create events, and fix create_v2 user mapping.
This commit is contained in:
Estereg
2026-02-21 09:51:02 +00:00
parent 8e99720ce3
commit c2f2113211
5 changed files with 66 additions and 29 deletions
@@ -21,6 +21,11 @@ pub fn merge(instruction_event: &mut DexEvent, cpi_log_event: DexEvent) {
e.creator = cpie.creator;
e.creator_fee_basis_points = cpie.creator_fee_basis_points;
e.creator_fee = cpie.creator_fee;
e.track_volume = cpie.track_volume;
e.total_unclaimed_tokens = cpie.total_unclaimed_tokens;
e.total_claimed_tokens = cpie.total_claimed_tokens;
e.current_sol_volume = cpie.current_sol_volume;
e.last_update_timestamp = cpie.last_update_timestamp;
e.ix_name = cpie.ix_name.clone();
e.mayhem_mode = cpie.mayhem_mode;
e.cashback_fee_basis_points = cpie.cashback_fee_basis_points;
@@ -32,6 +32,22 @@ pub struct PumpFunCreateTokenEvent {
pub mint_authority: Pubkey,
#[borsh(skip)]
pub associated_bonding_curve: Pubkey,
#[borsh(skip)]
pub global: Pubkey,
#[borsh(skip)]
pub mpl_token_metadata: Pubkey,
#[borsh(skip)]
pub metadata_account: Pubkey,
#[borsh(skip)]
pub system_program: Pubkey,
#[borsh(skip)]
pub associated_token_program: Pubkey,
#[borsh(skip)]
pub rent: Pubkey,
#[borsh(skip)]
pub event_authority: Pubkey,
#[borsh(skip)]
pub program: Pubkey,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
@@ -58,6 +74,26 @@ pub struct PumpFunCreateV2TokenEvent {
pub mint_authority: Pubkey,
#[borsh(skip)]
pub associated_bonding_curve: Pubkey,
#[borsh(skip)]
pub global: Pubkey,
#[borsh(skip)]
pub system_program: Pubkey,
#[borsh(skip)]
pub associated_token_program: Pubkey,
#[borsh(skip)]
pub mayhem_program_id: Pubkey,
#[borsh(skip)]
pub global_params: Pubkey,
#[borsh(skip)]
pub sol_vault: Pubkey,
#[borsh(skip)]
pub mayhem_state: Pubkey,
#[borsh(skip)]
pub mayhem_token_vault: Pubkey,
#[borsh(skip)]
pub event_authority: Pubkey,
#[borsh(skip)]
pub program: Pubkey,
}
pub fn pumpfun_create_v2_token_event_log_decode(data: &[u8]) -> Option<PumpFunCreateV2TokenEvent> {
@@ -168,7 +168,16 @@ fn parse_create_token_instruction(
mint_authority: accounts[1],
bonding_curve: accounts[2],
associated_bonding_curve: accounts[3],
global: accounts[4],
mpl_token_metadata: accounts[5],
metadata_account: accounts[6],
user: accounts[7],
system_program: accounts[8],
token_program: accounts[9],
associated_token_program: accounts[10],
rent: accounts[11],
event_authority: accounts[12],
program: accounts[13],
..Default::default()
}))
}
@@ -231,7 +240,18 @@ fn parse_create_v2_token_instruction(
mint_authority: accounts[1],
bonding_curve: accounts[2],
associated_bonding_curve: accounts[3],
user: accounts[7],
global: accounts[4],
user: accounts[5],
system_program: accounts[6],
token_program: accounts[7],
associated_token_program: accounts[8],
mayhem_program_id: accounts[9],
global_params: accounts[10],
sol_vault: accounts[11],
mayhem_state: accounts[12],
mayhem_token_vault: accounts[13],
event_authority: accounts[14],
program: accounts[15],
..Default::default()
}))
}
@@ -21,9 +21,10 @@ pub struct BondingCurve {
pub complete: bool,
pub creator: Pubkey,
pub is_mayhem_mode: bool,
pub is_cashback_coin: bool,
}
pub const BONDING_CURVE_SIZE: usize = 8 * 5 + 1 + 32 + 1;
pub const BONDING_CURVE_SIZE: usize = 8 * 5 + 1 + 32 + 1 + 1;
pub fn bonding_curve_decode(data: &[u8]) -> Option<BondingCurve> {
if data.len() < BONDING_CURVE_SIZE {
@@ -78,9 +79,10 @@ pub struct Global {
pub reserved_fee_recipient: Pubkey,
pub mayhem_mode_enabled: bool,
pub reserved_fee_recipients: [Pubkey; 7],
pub is_cashback_enabled: bool,
}
pub const GLOBAL_SIZE: usize = 1 + 32 * 2 + 8 * 5 + 32 + 1 + 8 * 2 + 32 * 7 + 32 * 2 + 1 + 32 * 2 + 1 + 32 * 7;
pub const GLOBAL_SIZE: usize = 1 + 32 * 2 + 8 * 5 + 32 + 1 + 8 * 2 + 32 * 7 + 32 * 2 + 1 + 32 * 2 + 1 + 32 * 7 + 1;
pub fn global_decode(data: &[u8]) -> Option<Global> {
if data.len() < GLOBAL_SIZE {