Skip to content

Improve calculateGasPriceFromGasNow() readeabilty #26

Open
@haythemsellami

Description

I think the current calculateGasPriceFromGasNow() implementation make it hard to read the function or to change it for a new developer.

export async function calculateGasPriceFromGasNow() {
  return BigNumber.from((await (await fetch(gasNowUrl)).json()).data.rapid)
    .mul(Math.round(Number(process.env.GAS_PRICE_MULTIPLIER) * 100000000))
    .div(100000000);
}

IMO make sense to separate and assign values to some variables.

E.g

const rapidGasNow = (await fetch(gasNowUrl)).json()).data.rapid;
const multipliedGasNow = rapidGasNow.mul(...);
...

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions