Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(builder): cancel transaction when replacement underpriced #720

Merged
merged 2 commits into from
Jun 18, 2024
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
21 changes: 19 additions & 2 deletions crates/builder/src/bundle_proposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,21 @@ impl<UO: UserOperation> Bundle<UO> {
pub(crate) trait BundleProposer: Send + Sync + 'static {
type UO: UserOperation;

/// Constructs the next bundle
///
/// If `min_fees` is `Some`, the proposer will ensure the bundle has
/// at least `min_fees`.
async fn make_bundle(
&self,
required_fees: Option<GasFees>,
min_fees: Option<GasFees>,
is_replacement: bool,
) -> anyhow::Result<Bundle<Self::UO>>;

/// Gets the current gas fees
///
/// If `min_fees` is `Some`, the proposer will ensure the gas fees returned are at least `min_fees`.
async fn estimate_gas_fees(&self, min_fees: Option<GasFees>)
-> anyhow::Result<(GasFees, U256)>;
}

#[derive(Debug)]
Expand Down Expand Up @@ -138,6 +148,13 @@ where
{
type UO = UO;

async fn estimate_gas_fees(
&self,
required_fees: Option<GasFees>,
) -> anyhow::Result<(GasFees, U256)> {
self.fee_estimator.required_bundle_fees(required_fees).await
}

async fn make_bundle(
&self,
required_fees: Option<GasFees>,
Expand All @@ -148,7 +165,7 @@ where
self.provider
.get_latest_block_hash_and_number()
.map_err(anyhow::Error::from),
self.fee_estimator.required_bundle_fees(required_fees)
self.estimate_gas_fees(required_fees)
)?;
if ops.is_empty() {
return Ok(Bundle::default());
Expand Down
Loading
Loading