Skip to content

Commit 6ddd024

Browse files
authored
Update minimum bid amount calculation (#107)
1 parent 789b026 commit 6ddd024

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

auction-server/src/auction.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -559,22 +559,27 @@ async fn verify_bid_exceeds_gas_cost<G>(
559559
estimated_gas: U256,
560560
oracle: G,
561561
bid_amount: U256,
562-
multiplier: U256,
563562
) -> Result<(), RestError>
564563
where
565564
G: GasOracle,
566565
{
567-
let (base_fee_per_gas, _) = oracle
566+
let (maximum_gas_fee, priority_fee) = oracle
568567
.estimate_eip1559_fees()
569568
.await
570569
.map_err(|_| RestError::TemporarilyUnavailable)?;
571-
let gas_price = base_fee_per_gas * estimated_gas;
572-
if bid_amount >= gas_price * multiplier {
570+
571+
// To submit TOTAL_BIDS_PER_AUCTION together, each bid must cover the gas fee for all of the submitted bids.
572+
// To make sure we cover the estimation errors, we add the priority_fee to the final potential gas fee.
573+
// Therefore, the bid amount needs to be TOTAL_BIDS_PER_AUCTION times per potential gas fee.
574+
let potential_gas_fee = maximum_gas_fee * U256::from(TOTAL_BIDS_PER_AUCTION) + priority_fee;
575+
let minimum_bid_amount = potential_gas_fee * estimated_gas;
576+
577+
if bid_amount >= minimum_bid_amount {
573578
Ok(())
574579
} else {
575580
Err(RestError::BadParameters(format!(
576-
"Insufficient bid amount. Based on the current gas fees, your bid should be larger than: {}",
577-
gas_price * multiplier
581+
"Insufficient bid amount based on the current gas fees. estimated gas usage: {}, maximum fee per gas: {}, priority fee per gas: {}, minimum bid amount: {}",
582+
estimated_gas, maximum_gas_fee, priority_fee, minimum_bid_amount
578583
)))
579584
}
580585
}
@@ -670,11 +675,6 @@ pub async fn handle_bid(
670675
estimated_gas,
671676
EthProviderOracle::new(chain_store.provider.clone()),
672677
bid.amount,
673-
// To submit TOTAL_BIDS_PER_AUCTION together, each bid must cover the gas fee for all of the submitted bids.
674-
// Therefore, the bid amount needs to be TOTAL_BIDS_PER_AUCTION times the gas fee.
675-
// In order to make sure estimation errors are covered, it is summed up with one.
676-
// For example, if we are unable to submit the bid in the current block.
677-
U256::from(TOTAL_BIDS_PER_AUCTION + 1),
678678
)
679679
.await?;
680680
// The transaction body size will be automatically limited when the gas is limited.

gas-oracle/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ pub fn eip1559_default_estimator(base_fee_per_gas: U256, rewards: Vec<Vec<U256>>
7171
U256::from(EIP1559_FEE_ESTIMATION_DEFAULT_PRIORITY_FEE),
7272
);
7373

74-
// Minimum of 6 blocks needed to double the base fee.
75-
let potential_max_fee = base_fee_per_gas * 2;
74+
// Minimum of 4 blocks needed to 1.6 the base fee.
75+
let potential_max_fee = base_fee_per_gas * 16 / 10;
7676
(
7777
potential_max_fee + max_priority_fee_per_gas,
7878
max_priority_fee_per_gas,

0 commit comments

Comments
 (0)