@metamask/gas-fee-controller 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/GasFeeController.d.ts +229 -0
- package/dist/GasFeeController.js +264 -0
- package/dist/GasFeeController.js.map +1 -0
- package/dist/determineGasFeeCalculations.d.ts +40 -0
- package/dist/determineGasFeeCalculations.js +87 -0
- package/dist/determineGasFeeCalculations.js.map +1 -0
- package/dist/fetchBlockFeeHistory.d.ts +115 -0
- package/dist/fetchBlockFeeHistory.js +202 -0
- package/dist/fetchBlockFeeHistory.js.map +1 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory/calculateGasFeeEstimatesForPriorityLevels.d.ts +16 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory/calculateGasFeeEstimatesForPriorityLevels.js +89 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory/calculateGasFeeEstimatesForPriorityLevels.js.map +1 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory/fetchLatestBlock.d.ts +10 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory/fetchLatestBlock.js +32 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory/fetchLatestBlock.js.map +1 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory/medianOf.d.ts +10 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory/medianOf.js +17 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory/medianOf.js.map +1 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory/types.d.ts +10 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory/types.js +3 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory/types.js.map +1 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory.d.ts +21 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory.js +53 -0
- package/dist/fetchGasEstimatesViaEthFeeHistory.js.map +1 -0
- package/dist/gas-util.d.ts +41 -0
- package/dist/gas-util.js +140 -0
- package/dist/gas-util.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { BN } from 'ethereumjs-util';
|
|
3
|
+
/**
|
|
4
|
+
* Finds the median among a list of numbers. Note that this is different from the implementation
|
|
5
|
+
* in the MetaSwap API, as we want to hold to using BN as much as possible.
|
|
6
|
+
*
|
|
7
|
+
* @param numbers - A list of numbers, as BNs. Will be sorted automatically if unsorted.
|
|
8
|
+
* @returns The median number.
|
|
9
|
+
*/
|
|
10
|
+
export default function medianOf(numbers: BN[]): BN;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Finds the median among a list of numbers. Note that this is different from the implementation
|
|
5
|
+
* in the MetaSwap API, as we want to hold to using BN as much as possible.
|
|
6
|
+
*
|
|
7
|
+
* @param numbers - A list of numbers, as BNs. Will be sorted automatically if unsorted.
|
|
8
|
+
* @returns The median number.
|
|
9
|
+
*/
|
|
10
|
+
function medianOf(numbers) {
|
|
11
|
+
const sortedNumbers = numbers.slice().sort((a, b) => a.cmp(b));
|
|
12
|
+
const len = sortedNumbers.length;
|
|
13
|
+
const index = Math.floor((len - 1) / 2);
|
|
14
|
+
return sortedNumbers[index];
|
|
15
|
+
}
|
|
16
|
+
exports.default = medianOf;
|
|
17
|
+
//# sourceMappingURL=medianOf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"medianOf.js","sourceRoot":"","sources":["../../src/fetchGasEstimatesViaEthFeeHistory/medianOf.ts"],"names":[],"mappings":";;AAEA;;;;;;GAMG;AACH,SAAwB,QAAQ,CAAC,OAAa;IAC5C,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACxC,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AALD,2BAKC","sourcesContent":["import { BN } from 'ethereumjs-util';\n\n/**\n * Finds the median among a list of numbers. Note that this is different from the implementation\n * in the MetaSwap API, as we want to hold to using BN as much as possible.\n *\n * @param numbers - A list of numbers, as BNs. Will be sorted automatically if unsorted.\n * @returns The median number.\n */\nexport default function medianOf(numbers: BN[]): BN {\n const sortedNumbers = numbers.slice().sort((a, b) => a.cmp(b));\n const len = sortedNumbers.length;\n const index = Math.floor((len - 1) / 2);\n return sortedNumbers[index];\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { BN } from 'ethereumjs-util';
|
|
3
|
+
export declare type EthBlock = {
|
|
4
|
+
number: BN;
|
|
5
|
+
baseFeePerGas: BN;
|
|
6
|
+
};
|
|
7
|
+
export declare type EthQuery = {
|
|
8
|
+
getBlockByNumber: (blockNumber: BN | 'latest' | 'earliest' | 'pending') => Promise<EthBlock>;
|
|
9
|
+
};
|
|
10
|
+
export declare type FeeRange = [string, string];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/fetchGasEstimatesViaEthFeeHistory/types.ts"],"names":[],"mappings":"","sourcesContent":["import { BN } from 'ethereumjs-util';\n\nexport type EthBlock = {\n number: BN;\n baseFeePerGas: BN;\n};\n\nexport type EthQuery = {\n getBlockByNumber: (\n blockNumber: BN | 'latest' | 'earliest' | 'pending',\n ) => Promise<EthBlock>;\n};\n\nexport type FeeRange = [string, string];\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GasFeeEstimates } from './GasFeeController';
|
|
2
|
+
import { EthQuery } from './fetchGasEstimatesViaEthFeeHistory/types';
|
|
3
|
+
/**
|
|
4
|
+
* Generates gas fee estimates based on gas fees that have been used in the recent past so that
|
|
5
|
+
* those estimates can be displayed to users.
|
|
6
|
+
*
|
|
7
|
+
* To produce the estimates, the last 5 blocks are read from the network, and for each block, the
|
|
8
|
+
* priority fees for transactions at the 10th, 20th, and 30th percentiles are also read (here
|
|
9
|
+
* "percentile" signifies the level at which those transactions contribute to the overall gas used
|
|
10
|
+
* for the block, where higher percentiles correspond to higher fees). This information is used to
|
|
11
|
+
* calculate reasonable max priority and max fees for three different priority levels (higher
|
|
12
|
+
* priority = higher fee).
|
|
13
|
+
*
|
|
14
|
+
* Note that properties are returned for other data that are normally obtained via the API; however,
|
|
15
|
+
* to prevent extra requests to Infura, these properties are empty.
|
|
16
|
+
*
|
|
17
|
+
* @param ethQuery - An EthQuery instance.
|
|
18
|
+
* @returns Base and priority fee estimates, categorized by priority level, as well as an estimate
|
|
19
|
+
* for the next block's base fee.
|
|
20
|
+
*/
|
|
21
|
+
export default function fetchGasEstimatesViaEthFeeHistory(ethQuery: EthQuery): Promise<GasFeeEstimates>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const ethjs_unit_1 = require("ethjs-unit");
|
|
16
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
17
|
+
const fetchBlockFeeHistory_1 = __importDefault(require("./fetchBlockFeeHistory"));
|
|
18
|
+
const fetchLatestBlock_1 = __importDefault(require("./fetchGasEstimatesViaEthFeeHistory/fetchLatestBlock"));
|
|
19
|
+
const calculateGasFeeEstimatesForPriorityLevels_1 = __importDefault(require("./fetchGasEstimatesViaEthFeeHistory/calculateGasFeeEstimatesForPriorityLevels"));
|
|
20
|
+
/**
|
|
21
|
+
* Generates gas fee estimates based on gas fees that have been used in the recent past so that
|
|
22
|
+
* those estimates can be displayed to users.
|
|
23
|
+
*
|
|
24
|
+
* To produce the estimates, the last 5 blocks are read from the network, and for each block, the
|
|
25
|
+
* priority fees for transactions at the 10th, 20th, and 30th percentiles are also read (here
|
|
26
|
+
* "percentile" signifies the level at which those transactions contribute to the overall gas used
|
|
27
|
+
* for the block, where higher percentiles correspond to higher fees). This information is used to
|
|
28
|
+
* calculate reasonable max priority and max fees for three different priority levels (higher
|
|
29
|
+
* priority = higher fee).
|
|
30
|
+
*
|
|
31
|
+
* Note that properties are returned for other data that are normally obtained via the API; however,
|
|
32
|
+
* to prevent extra requests to Infura, these properties are empty.
|
|
33
|
+
*
|
|
34
|
+
* @param ethQuery - An EthQuery instance.
|
|
35
|
+
* @returns Base and priority fee estimates, categorized by priority level, as well as an estimate
|
|
36
|
+
* for the next block's base fee.
|
|
37
|
+
*/
|
|
38
|
+
function fetchGasEstimatesViaEthFeeHistory(ethQuery) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const latestBlock = yield (0, fetchLatestBlock_1.default)(ethQuery);
|
|
41
|
+
const blocks = yield (0, fetchBlockFeeHistory_1.default)({
|
|
42
|
+
ethQuery,
|
|
43
|
+
endBlock: latestBlock.number,
|
|
44
|
+
numberOfBlocks: 5,
|
|
45
|
+
percentiles: [10, 20, 30],
|
|
46
|
+
});
|
|
47
|
+
const estimatedBaseFee = (0, ethjs_unit_1.fromWei)(latestBlock.baseFeePerGas, controller_utils_1.GWEI);
|
|
48
|
+
const levelSpecificEstimates = (0, calculateGasFeeEstimatesForPriorityLevels_1.default)(blocks);
|
|
49
|
+
return Object.assign(Object.assign({}, levelSpecificEstimates), { estimatedBaseFee, historicalBaseFeeRange: null, baseFeeTrend: null, latestPriorityFeeRange: null, historicalPriorityFeeRange: null, priorityFeeTrend: null, networkCongestion: null });
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.default = fetchGasEstimatesViaEthFeeHistory;
|
|
53
|
+
//# sourceMappingURL=fetchGasEstimatesViaEthFeeHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchGasEstimatesViaEthFeeHistory.js","sourceRoot":"","sources":["../src/fetchGasEstimatesViaEthFeeHistory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2CAAqC;AACrC,iEAAkD;AAGlD,kFAA0D;AAC1D,4GAAoF;AACpF,8JAAsI;AAEtI;;;;;;;;;;;;;;;;;GAiBG;AACH,SAA8B,iCAAiC,CAC7D,QAAkB;;QAElB,MAAM,WAAW,GAAG,MAAM,IAAA,0BAAgB,EAAC,QAAQ,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,MAAM,IAAA,8BAAoB,EAAC;YACxC,QAAQ;YACR,QAAQ,EAAE,WAAW,CAAC,MAAM;YAC5B,cAAc,EAAE,CAAC;YACjB,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;SAC1B,CAAC,CAAC;QACH,MAAM,gBAAgB,GAAG,IAAA,oBAAO,EAAC,WAAW,CAAC,aAAa,EAAE,uBAAI,CAAC,CAAC;QAElE,MAAM,sBAAsB,GAC1B,IAAA,mDAAyC,EAAC,MAAM,CAAC,CAAC;QAEpD,uCACK,sBAAsB,KACzB,gBAAgB,EAChB,sBAAsB,EAAE,IAAI,EAC5B,YAAY,EAAE,IAAI,EAClB,sBAAsB,EAAE,IAAI,EAC5B,0BAA0B,EAAE,IAAI,EAChC,gBAAgB,EAAE,IAAI,EACtB,iBAAiB,EAAE,IAAI,IACvB;IACJ,CAAC;CAAA;AAzBD,oDAyBC","sourcesContent":["import { fromWei } from 'ethjs-unit';\nimport { GWEI } from '@metamask/controller-utils';\nimport { GasFeeEstimates } from './GasFeeController';\nimport { EthQuery } from './fetchGasEstimatesViaEthFeeHistory/types';\nimport fetchBlockFeeHistory from './fetchBlockFeeHistory';\nimport fetchLatestBlock from './fetchGasEstimatesViaEthFeeHistory/fetchLatestBlock';\nimport calculateGasFeeEstimatesForPriorityLevels from './fetchGasEstimatesViaEthFeeHistory/calculateGasFeeEstimatesForPriorityLevels';\n\n/**\n * Generates gas fee estimates based on gas fees that have been used in the recent past so that\n * those estimates can be displayed to users.\n *\n * To produce the estimates, the last 5 blocks are read from the network, and for each block, the\n * priority fees for transactions at the 10th, 20th, and 30th percentiles are also read (here\n * \"percentile\" signifies the level at which those transactions contribute to the overall gas used\n * for the block, where higher percentiles correspond to higher fees). This information is used to\n * calculate reasonable max priority and max fees for three different priority levels (higher\n * priority = higher fee).\n *\n * Note that properties are returned for other data that are normally obtained via the API; however,\n * to prevent extra requests to Infura, these properties are empty.\n *\n * @param ethQuery - An EthQuery instance.\n * @returns Base and priority fee estimates, categorized by priority level, as well as an estimate\n * for the next block's base fee.\n */\nexport default async function fetchGasEstimatesViaEthFeeHistory(\n ethQuery: EthQuery,\n): Promise<GasFeeEstimates> {\n const latestBlock = await fetchLatestBlock(ethQuery);\n const blocks = await fetchBlockFeeHistory({\n ethQuery,\n endBlock: latestBlock.number,\n numberOfBlocks: 5,\n percentiles: [10, 20, 30],\n });\n const estimatedBaseFee = fromWei(latestBlock.baseFeePerGas, GWEI);\n\n const levelSpecificEstimates =\n calculateGasFeeEstimatesForPriorityLevels(blocks);\n\n return {\n ...levelSpecificEstimates,\n estimatedBaseFee,\n historicalBaseFeeRange: null,\n baseFeeTrend: null,\n latestPriorityFeeRange: null,\n historicalPriorityFeeRange: null,\n priorityFeeTrend: null,\n networkCongestion: null,\n };\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { GasFeeEstimates, EthGasPriceEstimate, EstimatedGasFeeTimeBounds, LegacyGasPriceEstimate } from './GasFeeController';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a decimal GWEI value to a decimal string rounded to the nearest WEI.
|
|
4
|
+
*
|
|
5
|
+
* @param n - The input GWEI amount, as a decimal string or a number.
|
|
6
|
+
* @returns The decimal string GWEI amount.
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeGWEIDecimalNumbers(n: string | number): any;
|
|
9
|
+
/**
|
|
10
|
+
* Fetch gas estimates from the given URL.
|
|
11
|
+
*
|
|
12
|
+
* @param url - The gas estimate URL.
|
|
13
|
+
* @param clientId - The client ID used to identify to the API who is asking for estimates.
|
|
14
|
+
* @returns The gas estimates.
|
|
15
|
+
*/
|
|
16
|
+
export declare function fetchGasEstimates(url: string, clientId?: string): Promise<GasFeeEstimates>;
|
|
17
|
+
/**
|
|
18
|
+
* Hit the legacy MetaSwaps gasPrices estimate api and return the low, medium
|
|
19
|
+
* high values from that API.
|
|
20
|
+
*
|
|
21
|
+
* @param url - The URL to fetch gas price estimates from.
|
|
22
|
+
* @param clientId - The client ID used to identify to the API who is asking for estimates.
|
|
23
|
+
* @returns The gas price estimates.
|
|
24
|
+
*/
|
|
25
|
+
export declare function fetchLegacyGasPriceEstimates(url: string, clientId?: string): Promise<LegacyGasPriceEstimate>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a gas price estimate from the network using the `eth_gasPrice` method.
|
|
28
|
+
*
|
|
29
|
+
* @param ethQuery - The EthQuery instance to call the network with.
|
|
30
|
+
* @returns A gas price estimate.
|
|
31
|
+
*/
|
|
32
|
+
export declare function fetchEthGasPriceEstimate(ethQuery: any): Promise<EthGasPriceEstimate>;
|
|
33
|
+
/**
|
|
34
|
+
* Estimate the time it will take for a transaction to be confirmed.
|
|
35
|
+
*
|
|
36
|
+
* @param maxPriorityFeePerGas - The max priority fee per gas.
|
|
37
|
+
* @param maxFeePerGas - The max fee per gas.
|
|
38
|
+
* @param gasFeeEstimates - The gas fee estimates.
|
|
39
|
+
* @returns The estimated lower and upper bounds for when this transaction will be confirmed.
|
|
40
|
+
*/
|
|
41
|
+
export declare function calculateTimeEstimate(maxPriorityFeePerGas: string, maxFeePerGas: string, gasFeeEstimates: GasFeeEstimates): EstimatedGasFeeTimeBounds;
|
package/dist/gas-util.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.calculateTimeEstimate = exports.fetchEthGasPriceEstimate = exports.fetchLegacyGasPriceEstimates = exports.fetchGasEstimates = exports.normalizeGWEIDecimalNumbers = void 0;
|
|
13
|
+
const ethereumjs_util_1 = require("ethereumjs-util");
|
|
14
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
15
|
+
const makeClientIdHeader = (clientId) => ({ 'X-Client-Id': clientId });
|
|
16
|
+
/**
|
|
17
|
+
* Convert a decimal GWEI value to a decimal string rounded to the nearest WEI.
|
|
18
|
+
*
|
|
19
|
+
* @param n - The input GWEI amount, as a decimal string or a number.
|
|
20
|
+
* @returns The decimal string GWEI amount.
|
|
21
|
+
*/
|
|
22
|
+
function normalizeGWEIDecimalNumbers(n) {
|
|
23
|
+
const numberAsWEIHex = (0, controller_utils_1.gweiDecToWEIBN)(n).toString(16);
|
|
24
|
+
const numberAsGWEI = (0, controller_utils_1.weiHexToGweiDec)(numberAsWEIHex).toString(10);
|
|
25
|
+
return numberAsGWEI;
|
|
26
|
+
}
|
|
27
|
+
exports.normalizeGWEIDecimalNumbers = normalizeGWEIDecimalNumbers;
|
|
28
|
+
/**
|
|
29
|
+
* Fetch gas estimates from the given URL.
|
|
30
|
+
*
|
|
31
|
+
* @param url - The gas estimate URL.
|
|
32
|
+
* @param clientId - The client ID used to identify to the API who is asking for estimates.
|
|
33
|
+
* @returns The gas estimates.
|
|
34
|
+
*/
|
|
35
|
+
function fetchGasEstimates(url, clientId) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const estimates = yield (0, controller_utils_1.handleFetch)(url, clientId ? { headers: makeClientIdHeader(clientId) } : undefined);
|
|
38
|
+
return {
|
|
39
|
+
low: Object.assign(Object.assign({}, estimates.low), { suggestedMaxPriorityFeePerGas: normalizeGWEIDecimalNumbers(estimates.low.suggestedMaxPriorityFeePerGas), suggestedMaxFeePerGas: normalizeGWEIDecimalNumbers(estimates.low.suggestedMaxFeePerGas) }),
|
|
40
|
+
medium: Object.assign(Object.assign({}, estimates.medium), { suggestedMaxPriorityFeePerGas: normalizeGWEIDecimalNumbers(estimates.medium.suggestedMaxPriorityFeePerGas), suggestedMaxFeePerGas: normalizeGWEIDecimalNumbers(estimates.medium.suggestedMaxFeePerGas) }),
|
|
41
|
+
high: Object.assign(Object.assign({}, estimates.high), { suggestedMaxPriorityFeePerGas: normalizeGWEIDecimalNumbers(estimates.high.suggestedMaxPriorityFeePerGas), suggestedMaxFeePerGas: normalizeGWEIDecimalNumbers(estimates.high.suggestedMaxFeePerGas) }),
|
|
42
|
+
estimatedBaseFee: normalizeGWEIDecimalNumbers(estimates.estimatedBaseFee),
|
|
43
|
+
historicalBaseFeeRange: estimates.historicalBaseFeeRange,
|
|
44
|
+
baseFeeTrend: estimates.baseFeeTrend,
|
|
45
|
+
latestPriorityFeeRange: estimates.latestPriorityFeeRange,
|
|
46
|
+
historicalPriorityFeeRange: estimates.historicalPriorityFeeRange,
|
|
47
|
+
priorityFeeTrend: estimates.priorityFeeTrend,
|
|
48
|
+
networkCongestion: estimates.networkCongestion,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.fetchGasEstimates = fetchGasEstimates;
|
|
53
|
+
/**
|
|
54
|
+
* Hit the legacy MetaSwaps gasPrices estimate api and return the low, medium
|
|
55
|
+
* high values from that API.
|
|
56
|
+
*
|
|
57
|
+
* @param url - The URL to fetch gas price estimates from.
|
|
58
|
+
* @param clientId - The client ID used to identify to the API who is asking for estimates.
|
|
59
|
+
* @returns The gas price estimates.
|
|
60
|
+
*/
|
|
61
|
+
function fetchLegacyGasPriceEstimates(url, clientId) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const result = yield (0, controller_utils_1.handleFetch)(url, {
|
|
64
|
+
referrer: url,
|
|
65
|
+
referrerPolicy: 'no-referrer-when-downgrade',
|
|
66
|
+
method: 'GET',
|
|
67
|
+
mode: 'cors',
|
|
68
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, (clientId && makeClientIdHeader(clientId))),
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
low: result.SafeGasPrice,
|
|
72
|
+
medium: result.ProposeGasPrice,
|
|
73
|
+
high: result.FastGasPrice,
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.fetchLegacyGasPriceEstimates = fetchLegacyGasPriceEstimates;
|
|
78
|
+
/**
|
|
79
|
+
* Get a gas price estimate from the network using the `eth_gasPrice` method.
|
|
80
|
+
*
|
|
81
|
+
* @param ethQuery - The EthQuery instance to call the network with.
|
|
82
|
+
* @returns A gas price estimate.
|
|
83
|
+
*/
|
|
84
|
+
function fetchEthGasPriceEstimate(ethQuery) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const gasPrice = yield (0, controller_utils_1.query)(ethQuery, 'gasPrice');
|
|
87
|
+
return {
|
|
88
|
+
gasPrice: (0, controller_utils_1.weiHexToGweiDec)(gasPrice).toString(),
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
exports.fetchEthGasPriceEstimate = fetchEthGasPriceEstimate;
|
|
93
|
+
/**
|
|
94
|
+
* Estimate the time it will take for a transaction to be confirmed.
|
|
95
|
+
*
|
|
96
|
+
* @param maxPriorityFeePerGas - The max priority fee per gas.
|
|
97
|
+
* @param maxFeePerGas - The max fee per gas.
|
|
98
|
+
* @param gasFeeEstimates - The gas fee estimates.
|
|
99
|
+
* @returns The estimated lower and upper bounds for when this transaction will be confirmed.
|
|
100
|
+
*/
|
|
101
|
+
function calculateTimeEstimate(maxPriorityFeePerGas, maxFeePerGas, gasFeeEstimates) {
|
|
102
|
+
const { low, medium, high, estimatedBaseFee } = gasFeeEstimates;
|
|
103
|
+
const maxPriorityFeePerGasInWEI = (0, controller_utils_1.gweiDecToWEIBN)(maxPriorityFeePerGas);
|
|
104
|
+
const maxFeePerGasInWEI = (0, controller_utils_1.gweiDecToWEIBN)(maxFeePerGas);
|
|
105
|
+
const estimatedBaseFeeInWEI = (0, controller_utils_1.gweiDecToWEIBN)(estimatedBaseFee);
|
|
106
|
+
const effectiveMaxPriorityFee = ethereumjs_util_1.BN.min(maxPriorityFeePerGasInWEI, maxFeePerGasInWEI.sub(estimatedBaseFeeInWEI));
|
|
107
|
+
const lowMaxPriorityFeeInWEI = (0, controller_utils_1.gweiDecToWEIBN)(low.suggestedMaxPriorityFeePerGas);
|
|
108
|
+
const mediumMaxPriorityFeeInWEI = (0, controller_utils_1.gweiDecToWEIBN)(medium.suggestedMaxPriorityFeePerGas);
|
|
109
|
+
const highMaxPriorityFeeInWEI = (0, controller_utils_1.gweiDecToWEIBN)(high.suggestedMaxPriorityFeePerGas);
|
|
110
|
+
let lowerTimeBound;
|
|
111
|
+
let upperTimeBound;
|
|
112
|
+
if (effectiveMaxPriorityFee.lt(lowMaxPriorityFeeInWEI)) {
|
|
113
|
+
lowerTimeBound = null;
|
|
114
|
+
upperTimeBound = 'unknown';
|
|
115
|
+
}
|
|
116
|
+
else if (effectiveMaxPriorityFee.gte(lowMaxPriorityFeeInWEI) &&
|
|
117
|
+
effectiveMaxPriorityFee.lt(mediumMaxPriorityFeeInWEI)) {
|
|
118
|
+
lowerTimeBound = low.minWaitTimeEstimate;
|
|
119
|
+
upperTimeBound = low.maxWaitTimeEstimate;
|
|
120
|
+
}
|
|
121
|
+
else if (effectiveMaxPriorityFee.gte(mediumMaxPriorityFeeInWEI) &&
|
|
122
|
+
effectiveMaxPriorityFee.lt(highMaxPriorityFeeInWEI)) {
|
|
123
|
+
lowerTimeBound = medium.minWaitTimeEstimate;
|
|
124
|
+
upperTimeBound = medium.maxWaitTimeEstimate;
|
|
125
|
+
}
|
|
126
|
+
else if (effectiveMaxPriorityFee.eq(highMaxPriorityFeeInWEI)) {
|
|
127
|
+
lowerTimeBound = high.minWaitTimeEstimate;
|
|
128
|
+
upperTimeBound = high.maxWaitTimeEstimate;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
lowerTimeBound = 0;
|
|
132
|
+
upperTimeBound = high.maxWaitTimeEstimate;
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
lowerTimeBound,
|
|
136
|
+
upperTimeBound,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
exports.calculateTimeEstimate = calculateTimeEstimate;
|
|
140
|
+
//# sourceMappingURL=gas-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gas-util.js","sourceRoot":"","sources":["../src/gas-util.ts"],"names":[],"mappings":"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","sourcesContent":["import { BN } from 'ethereumjs-util';\nimport {\n query,\n handleFetch,\n gweiDecToWEIBN,\n weiHexToGweiDec,\n} from '@metamask/controller-utils';\nimport {\n GasFeeEstimates,\n EthGasPriceEstimate,\n EstimatedGasFeeTimeBounds,\n unknownString,\n LegacyGasPriceEstimate,\n} from './GasFeeController';\n\nconst makeClientIdHeader = (clientId: string) => ({ 'X-Client-Id': clientId });\n\n/**\n * Convert a decimal GWEI value to a decimal string rounded to the nearest WEI.\n *\n * @param n - The input GWEI amount, as a decimal string or a number.\n * @returns The decimal string GWEI amount.\n */\nexport function normalizeGWEIDecimalNumbers(n: string | number) {\n const numberAsWEIHex = gweiDecToWEIBN(n).toString(16);\n const numberAsGWEI = weiHexToGweiDec(numberAsWEIHex).toString(10);\n return numberAsGWEI;\n}\n\n/**\n * Fetch gas estimates from the given URL.\n *\n * @param url - The gas estimate URL.\n * @param clientId - The client ID used to identify to the API who is asking for estimates.\n * @returns The gas estimates.\n */\nexport async function fetchGasEstimates(\n url: string,\n clientId?: string,\n): Promise<GasFeeEstimates> {\n const estimates = await handleFetch(\n url,\n clientId ? { headers: makeClientIdHeader(clientId) } : undefined,\n );\n return {\n low: {\n ...estimates.low,\n suggestedMaxPriorityFeePerGas: normalizeGWEIDecimalNumbers(\n estimates.low.suggestedMaxPriorityFeePerGas,\n ),\n suggestedMaxFeePerGas: normalizeGWEIDecimalNumbers(\n estimates.low.suggestedMaxFeePerGas,\n ),\n },\n medium: {\n ...estimates.medium,\n suggestedMaxPriorityFeePerGas: normalizeGWEIDecimalNumbers(\n estimates.medium.suggestedMaxPriorityFeePerGas,\n ),\n suggestedMaxFeePerGas: normalizeGWEIDecimalNumbers(\n estimates.medium.suggestedMaxFeePerGas,\n ),\n },\n high: {\n ...estimates.high,\n suggestedMaxPriorityFeePerGas: normalizeGWEIDecimalNumbers(\n estimates.high.suggestedMaxPriorityFeePerGas,\n ),\n suggestedMaxFeePerGas: normalizeGWEIDecimalNumbers(\n estimates.high.suggestedMaxFeePerGas,\n ),\n },\n estimatedBaseFee: normalizeGWEIDecimalNumbers(estimates.estimatedBaseFee),\n historicalBaseFeeRange: estimates.historicalBaseFeeRange,\n baseFeeTrend: estimates.baseFeeTrend,\n latestPriorityFeeRange: estimates.latestPriorityFeeRange,\n historicalPriorityFeeRange: estimates.historicalPriorityFeeRange,\n priorityFeeTrend: estimates.priorityFeeTrend,\n networkCongestion: estimates.networkCongestion,\n };\n}\n\n/**\n * Hit the legacy MetaSwaps gasPrices estimate api and return the low, medium\n * high values from that API.\n *\n * @param url - The URL to fetch gas price estimates from.\n * @param clientId - The client ID used to identify to the API who is asking for estimates.\n * @returns The gas price estimates.\n */\nexport async function fetchLegacyGasPriceEstimates(\n url: string,\n clientId?: string,\n): Promise<LegacyGasPriceEstimate> {\n const result = await handleFetch(url, {\n referrer: url,\n referrerPolicy: 'no-referrer-when-downgrade',\n method: 'GET',\n mode: 'cors',\n headers: {\n 'Content-Type': 'application/json',\n ...(clientId && makeClientIdHeader(clientId)),\n },\n });\n return {\n low: result.SafeGasPrice,\n medium: result.ProposeGasPrice,\n high: result.FastGasPrice,\n };\n}\n\n/**\n * Get a gas price estimate from the network using the `eth_gasPrice` method.\n *\n * @param ethQuery - The EthQuery instance to call the network with.\n * @returns A gas price estimate.\n */\nexport async function fetchEthGasPriceEstimate(\n ethQuery: any,\n): Promise<EthGasPriceEstimate> {\n const gasPrice = await query(ethQuery, 'gasPrice');\n return {\n gasPrice: weiHexToGweiDec(gasPrice).toString(),\n };\n}\n\n/**\n * Estimate the time it will take for a transaction to be confirmed.\n *\n * @param maxPriorityFeePerGas - The max priority fee per gas.\n * @param maxFeePerGas - The max fee per gas.\n * @param gasFeeEstimates - The gas fee estimates.\n * @returns The estimated lower and upper bounds for when this transaction will be confirmed.\n */\nexport function calculateTimeEstimate(\n maxPriorityFeePerGas: string,\n maxFeePerGas: string,\n gasFeeEstimates: GasFeeEstimates,\n): EstimatedGasFeeTimeBounds {\n const { low, medium, high, estimatedBaseFee } = gasFeeEstimates;\n\n const maxPriorityFeePerGasInWEI = gweiDecToWEIBN(maxPriorityFeePerGas);\n const maxFeePerGasInWEI = gweiDecToWEIBN(maxFeePerGas);\n const estimatedBaseFeeInWEI = gweiDecToWEIBN(estimatedBaseFee);\n\n const effectiveMaxPriorityFee = BN.min(\n maxPriorityFeePerGasInWEI,\n maxFeePerGasInWEI.sub(estimatedBaseFeeInWEI),\n );\n\n const lowMaxPriorityFeeInWEI = gweiDecToWEIBN(\n low.suggestedMaxPriorityFeePerGas,\n );\n const mediumMaxPriorityFeeInWEI = gweiDecToWEIBN(\n medium.suggestedMaxPriorityFeePerGas,\n );\n const highMaxPriorityFeeInWEI = gweiDecToWEIBN(\n high.suggestedMaxPriorityFeePerGas,\n );\n\n let lowerTimeBound;\n let upperTimeBound;\n\n if (effectiveMaxPriorityFee.lt(lowMaxPriorityFeeInWEI)) {\n lowerTimeBound = null;\n upperTimeBound = 'unknown' as unknownString;\n } else if (\n effectiveMaxPriorityFee.gte(lowMaxPriorityFeeInWEI) &&\n effectiveMaxPriorityFee.lt(mediumMaxPriorityFeeInWEI)\n ) {\n lowerTimeBound = low.minWaitTimeEstimate;\n upperTimeBound = low.maxWaitTimeEstimate;\n } else if (\n effectiveMaxPriorityFee.gte(mediumMaxPriorityFeeInWEI) &&\n effectiveMaxPriorityFee.lt(highMaxPriorityFeeInWEI)\n ) {\n lowerTimeBound = medium.minWaitTimeEstimate;\n upperTimeBound = medium.maxWaitTimeEstimate;\n } else if (effectiveMaxPriorityFee.eq(highMaxPriorityFeeInWEI)) {\n lowerTimeBound = high.minWaitTimeEstimate;\n upperTimeBound = high.maxWaitTimeEstimate;\n } else {\n lowerTimeBound = 0;\n upperTimeBound = high.maxWaitTimeEstimate;\n }\n\n return {\n lowerTimeBound,\n upperTimeBound,\n };\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GasFeeController';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./GasFeeController"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC","sourcesContent":["export * from './GasFeeController';\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@metamask/gas-fee-controller",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Periodically calculates gas fee estimates based on various gas limits as well as other data displayed on transaction confirm screens",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"MetaMask",
|
|
7
|
+
"Ethereum"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/MetaMask/controllers/tree/main/packages/gas-fee-controller#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/MetaMask/controllers/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/MetaMask/controllers.git"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build:docs": "typedoc",
|
|
25
|
+
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/gas-fee-controller",
|
|
26
|
+
"prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
|
|
27
|
+
"publish:preview": "yarn npm publish --tag preview",
|
|
28
|
+
"test": "jest",
|
|
29
|
+
"test:watch": "jest --watch"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@metamask/base-controller": "~1.0.0",
|
|
33
|
+
"@metamask/controller-utils": "~1.0.0",
|
|
34
|
+
"@metamask/network-controller": "~1.0.0",
|
|
35
|
+
"@types/uuid": "^8.3.0",
|
|
36
|
+
"babel-runtime": "^6.26.0",
|
|
37
|
+
"eth-query": "^2.1.2",
|
|
38
|
+
"ethereumjs-util": "^7.0.10",
|
|
39
|
+
"ethjs-unit": "^0.1.6",
|
|
40
|
+
"immer": "^9.0.6",
|
|
41
|
+
"uuid": "^8.3.2"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@metamask/auto-changelog": "^3.1.0",
|
|
45
|
+
"@types/jest": "^26.0.22",
|
|
46
|
+
"@types/jest-when": "^2.7.3",
|
|
47
|
+
"deepmerge": "^4.2.2",
|
|
48
|
+
"jest": "^26.4.2",
|
|
49
|
+
"jest-when": "^3.4.2",
|
|
50
|
+
"nock": "^13.0.7",
|
|
51
|
+
"sinon": "^9.2.4",
|
|
52
|
+
"ts-jest": "^26.5.2",
|
|
53
|
+
"typedoc": "^0.22.15",
|
|
54
|
+
"typedoc-plugin-missing-exports": "^0.22.6",
|
|
55
|
+
"typescript": "~4.6.3"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=14.0.0"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public",
|
|
62
|
+
"registry": "https://registry.npmjs.org/"
|
|
63
|
+
}
|
|
64
|
+
}
|