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: use different gas pricing api to replace gasnow #30

Merged
merged 1 commit into from
Oct 14, 2021

Conversation

sambacha
Copy link
Contributor

@sambacha sambacha commented Oct 9, 2021

Change Gas Pricing API Endpoint

this closes #24

  • utilizes api.txprice.com
  • fixes some shell formatting and permissions
  • all prices are denominated in nanoeth (gwei)
{
	"system": "ethereum",
	"network": "main",
	"unit": "gwei",
	"maxPrice": 123,
	"currentBlockNumber": 13005095,
	"msSinceLastBlock": 3793,
	"blockPrices": [{
    "blockNumber": 13005096,
    "baseFeePerGas": 94.647990462,
    "estimatedTransactionCount": 137,
      "estimatedPrices": [              // json.blockPrices[0].estimatedPrices[0] 
        {
          "confidence": 99,             // json.blockPrices[0].estimatedPrices[0].confidence
          "price": 104,                 // json.blockPrices[0].estimatedPrices[0].price
          "maxPriorityFeePerGas": 9.86, // json.blockPrices[0].estimatedPrices[0].maxFeePerGas
          "maxFeePerGas": 199.16        // json.blockPrices[0].estimatedPrices[0].maxFeePerGas 
        }
    ]
}]
}

Additional available data points

.blockPrices[0].baseFeePerGas = 95.787159441;
.blockPrices[0].blockNumber = 13146395;
.currentBlockNumber = 13146394;
.maxPrice = 275;
.msSinceLastBlock = 70024;
.blockPrices[0].estimatedPrices[0].maxFeePerGas 
blockPrices[0].estimatedPrices[0].maxFeePerGas
blockPrices[0].estimatedPrices[0].price
blockPrices[0].estimatedPrices[0].confidence // 99,95,90,80,70
blockPrices[0].estimatedPrices

Confidence Interval

confidence is defined as the, "

0-99 likelihood the next block will contain a transaction with a gas price >= to the listed price

I can override the default confidence level order response (99,95,90,80,70) with a response of up to 5 confidence levels from 1 - 99 if yall think it would be more useful. I can provide this as a separate api endpoint (e.g. dapptools.txprice.com or w/e).

Signed-off-by: sam bacha sam@manifoldfinance.com

Signed-off-by: sam bacha <sam@manifoldfinance.com>
@gakonst
Copy link
Member

gakonst commented Oct 11, 2021

@mds1 @transmissions11 wdyt about using the above provider?

@mds1
Copy link
Contributor

mds1 commented Oct 11, 2021

Yea I like blocknative's estimates, and this one is just a proxy to blocknative, so good with me

Comment on lines +117 to +120
rapid=$(($(jq '.blockPrices[0].estimatedPrices[0].maxFeePerGas' <<<"$TXPRICE_RESPONSE")))
fast=$(($(jq '.blockPrices[0].estimatedPrices[1].maxFeePerGas' <<<"$TXPRICE_RESPONSE")))
standard=$(($(jq '.blockPrices[0].estimatedPrices[2].maxFeePerGas' <<<"$TXPRICE_RESPONSE")))
slow=$(($(jq '.blockPrices[0].estimatedPrices[3].maxFeePerGas' <<<"$TXPRICE_RESPONSE")))
Copy link
Contributor

Choose a reason for hiding this comment

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

Blocknative docs say "Order of confidence intervals is subject to change", so we might want to be a little smarter about finding the confidence value in the array instead of assuming the order. This is probably ok for now though and we could create an issue to handle it better in the future. Will defer to @gakonst here

@sambacha
Copy link
Contributor Author

as an alternative, you can use https://etherchain.org/api/gasnow @gakonst if you prefer to use a miner provided API

@gakonst
Copy link
Member

gakonst commented Oct 14, 2021

Yeah I'm OK with that - thank you! We can reconsider if it ends up not working well enough.

@gakonst gakonst merged commit f432aa2 into foundry-rs:master Oct 14, 2021
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.

3 participants