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

improve(API): Apply gas mark up to base fee rather than gas cost #1339

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

nicholaspai
Copy link
Member

@nicholaspai nicholaspai commented Dec 19, 2024

depends on across-protocol/sdk#801

We can test this by querying /api/gas-prices against the same endpoint on the prod deployment. This will show roughly how the gas costs will change with prod.

Ultimately, what matters is the gasFeeTotal in the /limits end point and we should compare with prod.

  • For WETH:
  • query /limits for every single destination chain once on Prod API and once on Preview API
  • Write down the gasFeeTotal and compare with Preview API
  • Note any differences:
  • If Prod API has higher gas fee total, then preview API will reduce gas fees but we need to make sure these gas fees are still deemed profitable by relayer
  • If preview API has higher gas fee total, then that’s notable as well

Results

  • Example GAS_MARKUP on the API: {"1": 0.05, "10": 1.0, "137": 2.0, "288": 1.0, "324": 0.01, "480": 1.0, "8453": 0.8, "42161": 1.0, "59144": 0.2, "34443": 1.0, "81457": 1.0, "534352": 1.0, "690": 1.0, "7777777": 1.0}
  • 137: limits?destinationChainId=137&token=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
    • gasFeeTotal is 3/2 higher in Prod API than Preview API. This is because the maxFeePerGas in Preview API is larger than Prod API but the Polygon GAS_MARKUP = 3 and in the preview API its only applied to the baseFee where in Prod API its applied to the full tokenGasCost = gasCost * maxFeePerGas
  • 1: limits?destinationChainId=1&token=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
    • gasFeeTotal is 1.17x higher in Prod API
  • 10: limits?destinationChainId=10&token=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
    • gasFeeTotal is 2x higher in Prod API
  • 8453: limits?destinationChainId=8453&token=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
    • gasFeeTotal is the same
  • 534352: limits?destinationChainId=534352&token=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
    • gasFeeTotal is the same
  • 324: limits?destinationChainId=324&token=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
    • gasFeeTotal is the same
  • 59144: limits?destinationChainId=59144&token=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
    • gasFeeTotal is 2x higher in Prod API
    • This is probably explained mostly by the fact we're using the NEW_GAS_ORACLE env var in the Preview API which gives much lower gas fees
  • 1135: limits?destinationChainId=1135&token=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
    • gasFeeTotal is 1.8x higher in Prod API
  • 42161: limits?destinationChainId=42161&token=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
    • gasFeeTotal is 1.9x higher in Prod API
  • 41455: limits?destinationChainId=41455&token=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
    • gasFeeTotal is the same
  • 690: limits?destinationChainId=690&token=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
    • gasFeeTotal is 2x higher in Prod API

Copy link

vercel bot commented Dec 19, 2024

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

Name Status Preview Comments Updated (UTC)
app-frontend-v3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 4, 2025 0:42am
sepolia-frontend-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 4, 2025 0:42am

Copy link
Contributor

@james-a-morris james-a-morris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should let integrators know about this prior to rolling out. This will change expected fees

api/_utils.ts Outdated
: DEFAULT_GAS_MARKUP;
return (
1 +
(sdk.utils.chainIsOPStack(Number(chainId))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One difference here. In the current multiplier use case, the SDK adds the gasMarkup to 1 here.

Whereas, the new SDK change I propose assumes that the passed in multiplier is complete already and doesn't need to be added to anything

@@ -1966,13 +1969,12 @@ export function latestGasPriceCache(chainId: number) {
* @returns The gas price in the native currency of the chain
*/
export async function getMaxFeePerGas(chainId: number): Promise<BigNumber> {
if (sdk.utils.chainIsOPStack(chainId)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important LOC we're removing. We should use gas price oracle for all estimates since it handles OP stack now

@nicholaspai
Copy link
Member Author

Note: because this PR uses the SDK's GasPriceOracle to compute gas prices even for OpStack chains we should NOT MERGE this PR until we set the GAS_PRICE_EIP1559_RAW_ variables equal to true (and probably also the NEW_GAS_PRICE_ORACLE_59144 ). Otherwise the API will give higher gas price estimates than we use currently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants