mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-25 11:28:51 +01:00
7b963cabd7
When a lot of transactions are occurring on the network, such as during an NFT drop, it drives gas fees up. When this happens, we want to not only inform the user about this, but also dissuade them from using a higher gas fee (as we have proved in testing that high gas fees can cause bidding wars and exacerbate the situation). The method for determining whether the network is "busy" is already handled by GasFeeController, which exposes a `networkCongestion` property within the gas fee estimate data. If this number exceeds 0.66 — meaning that the current base fee is above the 66th percentile among the base fees over the last several days — then we determine that the network is "busy".
71 lines
1.7 KiB
JavaScript
71 lines
1.7 KiB
JavaScript
import { addHexPrefix } from 'ethereumjs-util';
|
|
import { MIN_GAS_LIMIT_HEX } from '../../ui/pages/send/send.constants';
|
|
|
|
const ONE_HUNDRED_THOUSAND = 100000;
|
|
|
|
export const GAS_LIMITS = {
|
|
// maximum gasLimit of a simple send
|
|
SIMPLE: addHexPrefix(MIN_GAS_LIMIT_HEX),
|
|
// a base estimate for token transfers.
|
|
BASE_TOKEN_ESTIMATE: addHexPrefix(ONE_HUNDRED_THOUSAND.toString(16)),
|
|
};
|
|
|
|
/**
|
|
* These are already declared in @metamask/controllers but importing them from
|
|
* that module and re-exporting causes the UI bundle size to expand beyond 4MB
|
|
*/
|
|
export const GAS_ESTIMATE_TYPES = {
|
|
FEE_MARKET: 'fee-market',
|
|
LEGACY: 'legacy',
|
|
ETH_GASPRICE: 'eth_gasPrice',
|
|
NONE: 'none',
|
|
};
|
|
|
|
/**
|
|
* These represent gas recommendation levels presented in the UI
|
|
*/
|
|
export const GAS_RECOMMENDATIONS = {
|
|
LOW: 'low',
|
|
MEDIUM: 'medium',
|
|
HIGH: 'high',
|
|
};
|
|
|
|
/**
|
|
* These represent types of gas estimation
|
|
*/
|
|
export const PRIORITY_LEVELS = {
|
|
TEN_PERCENT_INCREASED: 'tenPercentIncreased',
|
|
LOW: 'low',
|
|
MEDIUM: 'medium',
|
|
HIGH: 'high',
|
|
CUSTOM: 'custom',
|
|
DAPP_SUGGESTED: 'dappSuggested',
|
|
};
|
|
|
|
/**
|
|
* Represents the user customizing their gas preference
|
|
*/
|
|
export const CUSTOM_GAS_ESTIMATE = 'custom';
|
|
|
|
/**
|
|
* These represent the different edit modes presented in the UI
|
|
*/
|
|
export const EDIT_GAS_MODES = {
|
|
SPEED_UP: 'speed-up',
|
|
CANCEL: 'cancel',
|
|
MODIFY_IN_PLACE: 'modify-in-place',
|
|
SWAPS: 'swaps',
|
|
};
|
|
|
|
/**
|
|
* Represents levels for `networkCongestion` (calculated along with gas fee
|
|
* estimates; represents a number between 0 and 1) that we use to render the
|
|
* network status slider on the send transaction screen and inform users when
|
|
* gas fees are high
|
|
*/
|
|
export const NETWORK_CONGESTION_THRESHOLDS = {
|
|
NOT_BUSY: 0,
|
|
STABLE: 0.33,
|
|
BUSY: 0.66,
|
|
};
|