Skip to content

Commit

Permalink
feat(builder): remove fixed priority fee mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dancoombs committed Jul 28, 2023
1 parent a89be00 commit 716844a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/builder/bundle_proposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ mod tests {
max_bundle_size,
beneficiary,
use_bundle_priority_fee: Some(true),
priority_fee_mode: PriorityFeeMode::PriorityFeePercent(10),
priority_fee_mode: PriorityFeeMode::PriorityFeeIncreasePercent(10),
bundle_priority_fee_overhead_percent: 0,
},
event_sender,
Expand Down
4 changes: 2 additions & 2 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ pub struct CommonArgs {
long = "priority_fee_mode_kind",
name = "priority_fee_mode_kind",
env = "PRIORITY_FEE_MODE_KIND",
value_parser = PossibleValuesParser::new(["fixed", "base_fee_percent", "priority_fee_percent"]),
default_value = "fixed"
value_parser = PossibleValuesParser::new(["base_fee_percent", "priority_fee_increase_percent"]),
default_value = "priority_fee_increase_percent"
)]
priority_fee_mode_kind: String,

Expand Down
20 changes: 4 additions & 16 deletions src/common/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,15 @@ impl GasFees {

#[derive(Debug, Clone, Copy)]
pub enum PriorityFeeMode {
Fixed(u64),
BaseFeePercent(u64),
PriorityFeePercent(u64),
PriorityFeeIncreasePercent(u64),
}

impl PriorityFeeMode {
pub fn try_from(kind: &str, value: u64) -> anyhow::Result<Self> {
match kind {
"fixed" => Ok(Self::Fixed(value)),
"base_fee_percent" => Ok(Self::BaseFeePercent(value)),
"priority_fee_percent" => Ok(Self::PriorityFeePercent(value)),
"priority_fee_increase_percent" => Ok(Self::PriorityFeeIncreasePercent(value)),
_ => anyhow::bail!("Invalid priority fee mode: {}", kind),
}
}
Expand All @@ -133,19 +131,9 @@ impl PriorityFeeMode {
let base_fee = bundle_fees.max_fee_per_gas - bundle_fees.max_priority_fee_per_gas;

let max_priority_fee_per_gas = match *self {
PriorityFeeMode::Fixed(value) => {
bundle_fees.max_priority_fee_per_gas.max(U256::from(value))
}
PriorityFeeMode::BaseFeePercent(percent) => math::percent(base_fee, percent),
PriorityFeeMode::PriorityFeePercent(percent) => {
let ret = math::increase_by_percent(bundle_fees.max_priority_fee_per_gas, percent);
tracing::info!(
"bundle_fees {:?} max_priority_fee_per_gas {:?} percent {:?}",
bundle_fees,
ret,
percent
);
ret
PriorityFeeMode::PriorityFeeIncreasePercent(percent) => {
math::increase_by_percent(bundle_fees.max_priority_fee_per_gas, percent)
}
};

Expand Down

0 comments on commit 716844a

Please sign in to comment.