Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ carbon-phoenix-v1-decoder = { path = "decoders/phoenix-v1-decoder", version = "0
carbon-postgres-client = { path = "crates/postgres-client", version = "0.9.1" }
carbon-proc-macros = { path = "crates/proc-macros", version = "0.9.1" }
carbon-prometheus-metrics = { path = "metrics/prometheus-metrics", version = "0.9.1" }
carbon-pump-fees-decoder = { path = "decoders/pump-fees-decoder", version = "0.9.1" }
carbon-pump-swap-decoder = { path = "decoders/pump-swap-decoder", version = "0.9.1" }
carbon-pumpfun-decoder = { path = "decoders/pumpfun-decoder", version = "0.9.1" }
carbon-raydium-amm-v4-decoder = { path = "decoders/raydium-amm-v4-decoder", version = "0.9.1" }
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ Decoders for most popular Solana programs are published and maintained:
| `carbon-phoenix-v1-decoder` | Phoenix V1 Program Decoder | PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY |
| `carbon-pumpfun-decoder` | Pumpfun Program Decoder | 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P |
| `carbon-pump-swap-decoder` | PumpSwap Program Decoder | pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA |
| `carbon-pump-fees-decoder` | Pump Fees Program Decoder | pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ |
| `carbon-raydium-amm-v4-decoder` | Raydium AMM V4 Program Decoder | 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 |
| `carbon-raydium-clmm-decoder` | Raydium CLMM Program Decoder | CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK |
| `carbon-raydium-cpmm-decoder` | Raydium CPMM Program Decoder | CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C |
Expand Down
23 changes: 23 additions & 0 deletions decoders/pump-fees-decoder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "carbon-pump-fees-decoder"
version = "0.9.1"
description = "PumpFees Decoder"
license = { workspace = true }
edition = { workspace = true }
readme = "README.md"
repository = { workspace = true }
keywords = ["solana", "decoder", "pump-fees"]
categories = ["encoding"]

[lib]
crate-type = ["rlib"]

[dependencies]
carbon-core = { workspace = true }
serde = { workspace = true }
solana-account = { workspace = true }
solana-instruction = { workspace = true, default-features = false }
solana-pubkey = { workspace = true }

[dev-dependencies]
carbon-test-utils = { workspace = true }
1 change: 1 addition & 0 deletions decoders/pump-fees-decoder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Carbon PumpFees Decoder
14 changes: 14 additions & 0 deletions decoders/pump-fees-decoder/src/accounts/fee_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use super::super::types::*;

use carbon_core::{borsh, CarbonDeserialize};

#[derive(
CarbonDeserialize, Debug, serde::Deserialize, serde::Serialize, PartialEq, Eq, Clone, Hash,
)]
#[carbon(discriminator = "0x8f3492bbdb7b4c9b")]
pub struct FeeConfig {
pub bump: u8,
pub admin: solana_pubkey::Pubkey,
pub flat_fees: Fees,
pub fee_tiers: Vec<FeeTier>,
}
35 changes: 35 additions & 0 deletions decoders/pump-fees-decoder/src/accounts/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use carbon_core::account::AccountDecoder;
use carbon_core::deserialize::CarbonDeserialize;

use crate::PROGRAM_ID;

use super::PumpFeesDecoder;
pub mod fee_config;

pub enum PumpFeesAccount {
FeeConfig(fee_config::FeeConfig),
}

impl AccountDecoder<'_> for PumpFeesDecoder {
type AccountType = PumpFeesAccount;
fn decode_account(
&self,
account: &solana_account::Account,
) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
if !account.owner.eq(&PROGRAM_ID) {
return None;
}

if let Some(decoded_account) = fee_config::FeeConfig::deserialize(account.data.as_slice()) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: PumpFeesAccount::FeeConfig(decoded_account),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}

None
}
}
34 changes: 34 additions & 0 deletions decoders/pump-fees-decoder/src/instructions/get_fees.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use carbon_core::{account_utils::next_account, borsh, CarbonDeserialize};

#[derive(
CarbonDeserialize, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Hash,
)]
#[carbon(discriminator = "0xe7257e55cf5b3f34")]
pub struct GetFees {
pub is_pump_pool: bool,
pub market_cap_lamports: u128,
pub trade_size_lamports: u64,
}

#[derive(Debug, PartialEq, Eq, Clone, Hash, serde::Serialize, serde::Deserialize)]
pub struct GetFeesInstructionAccounts {
pub fee_config: solana_pubkey::Pubkey,
pub config_program_id: solana_pubkey::Pubkey,
}

impl carbon_core::deserialize::ArrangeAccounts for GetFees {
type ArrangedAccounts = GetFeesInstructionAccounts;

fn arrange_accounts(
accounts: &[solana_instruction::AccountMeta],
) -> Option<Self::ArrangedAccounts> {
let mut iter = accounts.iter();
let fee_config = next_account(&mut iter)?;
let config_program_id = next_account(&mut iter)?;

Some(GetFeesInstructionAccounts {
fee_config,
config_program_id,
})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use carbon_core::{account_utils::next_account, borsh, CarbonDeserialize};

#[derive(
CarbonDeserialize, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Hash,
)]
#[carbon(discriminator = "0x3ea214857941911b")]
pub struct InitializeFeeConfig {}

#[derive(Debug, PartialEq, Eq, Clone, Hash, serde::Serialize, serde::Deserialize)]
pub struct InitializeFeeConfigInstructionAccounts {
pub admin: solana_pubkey::Pubkey,
pub fee_config: solana_pubkey::Pubkey,
pub system_program: solana_pubkey::Pubkey,
pub config_program_id: solana_pubkey::Pubkey,
pub event_authority: solana_pubkey::Pubkey,
pub program: solana_pubkey::Pubkey,
}

impl carbon_core::deserialize::ArrangeAccounts for InitializeFeeConfig {
type ArrangedAccounts = InitializeFeeConfigInstructionAccounts;

fn arrange_accounts(
accounts: &[solana_instruction::AccountMeta],
) -> Option<Self::ArrangedAccounts> {
let mut iter = accounts.iter();
let admin = next_account(&mut iter)?;
let fee_config = next_account(&mut iter)?;
let system_program = next_account(&mut iter)?;
let config_program_id = next_account(&mut iter)?;
let event_authority = next_account(&mut iter)?;
let program = next_account(&mut iter)?;

Some(InitializeFeeConfigInstructionAccounts {
admin,
fee_config,
system_program,
config_program_id,
event_authority,
program,
})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use carbon_core::{borsh, CarbonDeserialize};

#[derive(
CarbonDeserialize, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Hash,
)]
#[carbon(discriminator = "0xe445a52e51cb9a1d598af4e60a38e27e")]
pub struct InitializeFeeConfigEvent {
pub timestamp: i64,
pub admin: solana_pubkey::Pubkey,
pub fee_config: solana_pubkey::Pubkey,
}
60 changes: 60 additions & 0 deletions decoders/pump-fees-decoder/src/instructions/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
use crate::PROGRAM_ID;

use super::PumpFeesDecoder;

pub mod get_fees;
pub mod initialize_fee_config;
pub mod initialize_fee_config_event;
pub mod update_admin;
pub mod update_admin_event;
pub mod update_fee_config;
pub mod update_fee_config_event;
pub mod upsert_fee_tiers;
pub mod upsert_fee_tiers_event;

#[derive(
carbon_core::InstructionType,
serde::Serialize,
serde::Deserialize,
PartialEq,
Eq,
Debug,
Clone,
Hash,
)]
pub enum PumpFeesInstruction {
GetFees(get_fees::GetFees),
InitializeFeeConfig(initialize_fee_config::InitializeFeeConfig),
UpdateAdmin(update_admin::UpdateAdmin),
UpdateFeeConfig(update_fee_config::UpdateFeeConfig),
UpsertFeeTiers(upsert_fee_tiers::UpsertFeeTiers),
InitializeFeeConfigEvent(initialize_fee_config_event::InitializeFeeConfigEvent),
UpdateAdminEvent(update_admin_event::UpdateAdminEvent),
UpdateFeeConfigEvent(update_fee_config_event::UpdateFeeConfigEvent),
UpsertFeeTiersEvent(upsert_fee_tiers_event::UpsertFeeTiersEvent),
}

impl carbon_core::instruction::InstructionDecoder<'_> for PumpFeesDecoder {
type InstructionType = PumpFeesInstruction;

fn decode_instruction(
&self,
instruction: &solana_instruction::Instruction,
) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
if !instruction.program_id.eq(&PROGRAM_ID) {
return None;
}

carbon_core::try_decode_instructions!(instruction,
PumpFeesInstruction::GetFees => get_fees::GetFees,
PumpFeesInstruction::InitializeFeeConfig => initialize_fee_config::InitializeFeeConfig,
PumpFeesInstruction::UpdateAdmin => update_admin::UpdateAdmin,
PumpFeesInstruction::UpdateFeeConfig => update_fee_config::UpdateFeeConfig,
PumpFeesInstruction::UpsertFeeTiers => upsert_fee_tiers::UpsertFeeTiers,
PumpFeesInstruction::InitializeFeeConfigEvent => initialize_fee_config_event::InitializeFeeConfigEvent,
PumpFeesInstruction::UpdateAdminEvent => update_admin_event::UpdateAdminEvent,
PumpFeesInstruction::UpdateFeeConfigEvent => update_fee_config_event::UpdateFeeConfigEvent,
PumpFeesInstruction::UpsertFeeTiersEvent => upsert_fee_tiers_event::UpsertFeeTiersEvent,
)
}
}
42 changes: 42 additions & 0 deletions decoders/pump-fees-decoder/src/instructions/update_admin.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use carbon_core::{account_utils::next_account, borsh, CarbonDeserialize};

#[derive(
CarbonDeserialize, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Hash,
)]
#[carbon(discriminator = "0xa1b028d53cb8b3e4")]
pub struct UpdateAdmin {}

#[derive(Debug, PartialEq, Eq, Clone, Hash, serde::Serialize, serde::Deserialize)]
pub struct UpdateAdminInstructionAccounts {
pub admin: solana_pubkey::Pubkey,
pub fee_config: solana_pubkey::Pubkey,
pub new_admin: solana_pubkey::Pubkey,
pub config_program_id: solana_pubkey::Pubkey,
pub event_authority: solana_pubkey::Pubkey,
pub program: solana_pubkey::Pubkey,
}

impl carbon_core::deserialize::ArrangeAccounts for UpdateAdmin {
type ArrangedAccounts = UpdateAdminInstructionAccounts;

fn arrange_accounts(
accounts: &[solana_instruction::AccountMeta],
) -> Option<Self::ArrangedAccounts> {
let mut iter = accounts.iter();
let admin = next_account(&mut iter)?;
let fee_config = next_account(&mut iter)?;
let new_admin = next_account(&mut iter)?;
let config_program_id = next_account(&mut iter)?;
let event_authority = next_account(&mut iter)?;
let program = next_account(&mut iter)?;

Some(UpdateAdminInstructionAccounts {
admin,
fee_config,
new_admin,
config_program_id,
event_authority,
program,
})
}
}
11 changes: 11 additions & 0 deletions decoders/pump-fees-decoder/src/instructions/update_admin_event.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use carbon_core::{borsh, CarbonDeserialize};

#[derive(
CarbonDeserialize, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Hash,
)]
#[carbon(discriminator = "0xe445a52e51cb9a1de198ab57f63f42ea")]
pub struct UpdateAdminEvent {
pub timestamp: i64,
pub old_admin: solana_pubkey::Pubkey,
pub new_admin: solana_pubkey::Pubkey,
}
44 changes: 44 additions & 0 deletions decoders/pump-fees-decoder/src/instructions/update_fee_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use super::super::types::*;

use carbon_core::{account_utils::next_account, borsh, CarbonDeserialize};

#[derive(
CarbonDeserialize, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Hash,
)]
#[carbon(discriminator = "0x68b867f258976b14")]
pub struct UpdateFeeConfig {
pub fee_tiers: Vec<FeeTier>,
pub flat_fees: Fees,
}

#[derive(Debug, PartialEq, Eq, Clone, Hash, serde::Serialize, serde::Deserialize)]
pub struct UpdateFeeConfigInstructionAccounts {
pub fee_config: solana_pubkey::Pubkey,
pub admin: solana_pubkey::Pubkey,
pub config_program_id: solana_pubkey::Pubkey,
pub event_authority: solana_pubkey::Pubkey,
pub program: solana_pubkey::Pubkey,
}

impl carbon_core::deserialize::ArrangeAccounts for UpdateFeeConfig {
type ArrangedAccounts = UpdateFeeConfigInstructionAccounts;

fn arrange_accounts(
accounts: &[solana_instruction::AccountMeta],
) -> Option<Self::ArrangedAccounts> {
let mut iter = accounts.iter();
let fee_config = next_account(&mut iter)?;
let admin = next_account(&mut iter)?;
let config_program_id = next_account(&mut iter)?;
let event_authority = next_account(&mut iter)?;
let program = next_account(&mut iter)?;

Some(UpdateFeeConfigInstructionAccounts {
fee_config,
admin,
config_program_id,
event_authority,
program,
})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use super::super::types::*;

use carbon_core::{borsh, CarbonDeserialize};

#[derive(
CarbonDeserialize, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Hash,
)]
#[carbon(discriminator = "0xe445a52e51cb9a1d5a1741233ef4bcd0")]
pub struct UpdateFeeConfigEvent {
pub timestamp: i64,
pub admin: solana_pubkey::Pubkey,
pub fee_config: solana_pubkey::Pubkey,
pub fee_tiers: Vec<FeeTier>,
pub flat_fees: Fees,
}
Loading
Loading