80
80
} ,
81
81
sqlx:: types:: time:: OffsetDateTime ,
82
82
std:: {
83
- cmp:: max,
84
83
result,
85
84
sync:: {
86
85
atomic:: Ordering ,
@@ -193,7 +192,7 @@ impl From<(SimulatedBid, bool)> for MulticallData {
193
192
// 1. There will be more gas required for the transaction, which will result in a higher minimum bid amount.
194
193
// 2. The transaction size limit will be reduced for each bid.
195
194
// 3. Gas consumption limit will decrease for the bid
196
- const TOTAL_BIDS_PER_AUCTION : usize = 5 ;
195
+ const TOTAL_BIDS_PER_AUCTION : usize = 3 ;
197
196
198
197
#[ tracing:: instrument( skip_all) ]
199
198
async fn get_winner_bids (
@@ -560,7 +559,7 @@ async fn verify_bid_exceeds_gas_cost<G>(
560
559
estimated_gas : U256 ,
561
560
oracle : G ,
562
561
bid_amount : U256 ,
563
- threshold : U256 ,
562
+ multiplier : U256 ,
564
563
) -> Result < ( ) , RestError >
565
564
where
566
565
G : GasOracle ,
@@ -570,12 +569,12 @@ where
570
569
. await
571
570
. map_err ( |_| RestError :: TemporarilyUnavailable ) ?;
572
571
let gas_price = base_fee_per_gas * estimated_gas;
573
- if bid_amount >= gas_price * threshold {
572
+ if bid_amount >= gas_price * multiplier {
574
573
Ok ( ( ) )
575
574
} else {
576
575
Err ( RestError :: BadParameters ( format ! (
577
- "Bid amount is insufficient for gas. gas price: {}, threshold : {}" ,
578
- gas_price, threshold
576
+ "Insufficient bid amount. Based on the current gas fees, your bid should be larger than : {}" ,
577
+ gas_price * multiplier
579
578
) ) )
580
579
}
581
580
}
@@ -596,8 +595,6 @@ async fn verify_bid_under_gas_limit(
596
595
}
597
596
}
598
597
599
- const MINIMUM_GAS_MULTIPLIER : usize = 5 ;
600
-
601
598
// As we submit bids together for an auction, the bid is limited as follows:
602
599
// 1. The bid amount should cover gas fees for all bids included in the submission.
603
600
// 2. Depending on the maximum number of bids in the auction, the transaction size for the bid is limited.
@@ -644,15 +641,13 @@ pub async fn handle_bid(
644
641
Err ( e) => {
645
642
return match e {
646
643
ContractError :: Revert ( reason) => {
647
- if let Some ( decoded_error) = ExpressRelayErrors :: decode_with_selector ( & reason) {
648
- if let ExpressRelayErrors :: ExternalCallFailed ( failure_result) =
649
- decoded_error
650
- {
651
- return Err ( RestError :: SimulationError {
652
- result : failure_result. status . external_result ,
653
- reason : failure_result. status . multicall_revert_reason ,
654
- } ) ;
655
- }
644
+ if let Some ( ExpressRelayErrors :: ExternalCallFailed ( failure_result) ) =
645
+ ExpressRelayErrors :: decode_with_selector ( & reason)
646
+ {
647
+ return Err ( RestError :: SimulationError {
648
+ result : failure_result. status . external_result ,
649
+ reason : failure_result. status . multicall_revert_reason ,
650
+ } ) ;
656
651
}
657
652
Err ( RestError :: BadParameters ( format ! (
658
653
"Contract Revert Error: {}" ,
@@ -677,9 +672,9 @@ pub async fn handle_bid(
677
672
bid. amount ,
678
673
// To submit TOTAL_BIDS_PER_AUCTION together, each bid must cover the gas fee for all of the submitted bids.
679
674
// Therefore, the bid amount needs to be TOTAL_BIDS_PER_AUCTION times the gas fee.
680
- // The threshold will be multiplied by two to ensure the bid is beneficial, as well as to allow for estimation errors .
675
+ // In order to make sure estimation errors are covered, it is summed up with one .
681
676
// For example, if we are unable to submit the bid in the current block.
682
- U256 :: from ( max ( TOTAL_BIDS_PER_AUCTION * 2 , MINIMUM_GAS_MULTIPLIER ) ) ,
677
+ U256 :: from ( TOTAL_BIDS_PER_AUCTION + 1 ) ,
683
678
)
684
679
. await ?;
685
680
// The transaction body size will be automatically limited when the gas is limited.
0 commit comments