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

Fix the calculation for estimated gas price #3117

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

piersy
Copy link

@piersy piersy commented Dec 12, 2024

Updates estimateFeesPerGas to handle both the values
returned by the Celo L1 and also the values that will be returned
by the L2 Celo implementation.

Also removes the use of the viem multiplier for Celo L1 gas
calculations since the Celo L1 node already doubles the base fee.

Changes explained in detail:

Note the default viemMultiplier is 1.2 and the default celoMultiplier is 2.

The current gas maxFeePerGas suggested by viem (before this PR) is this:

  • Celo L1 - ((baseFee * celoMultiplier) * viemMultiplier) + suggestedTip
  • Op L2 stack - ((baseFee+suggestedTip) * viemMultiplier) + suggestedTip

With this PR we get:

  • Celo L1 - (baseFee * celoMultiplier) + suggestedTip
  • Op L2 stack - (baseFee * viemMultiplier) + suggestedTip

Copy link

changeset-bot bot commented Dec 12, 2024

🦋 Changeset detected

Latest commit: 5cb2631

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
viem ✅ Ready (Inspect) Visit Preview Dec 12, 2024 1:30pm

Copy link

vercel bot commented Dec 12, 2024

@piersy is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

The gas price returned by the rpc is base_fee + max_priority_fee.
So we shouldn't add the max_priority_fee onto that value since it's
already included. Also the logic used by viem for applying the
multiplier is to only apply the multiplier to the base fee and not the
priority fee, so we match that approach here.
@piersy piersy force-pushed the piersy/fix_gas_price_estimation branch from 819f98b to af51ad9 Compare December 12, 2024 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant