Skip to content

Commit

Permalink
import/export hackery
Browse files Browse the repository at this point in the history
  • Loading branch information
pxrl committed Sep 4, 2024
1 parent 7bd5792 commit aec5c18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/gasPriceOracle/adapters/arbitrum.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { providers } from "ethers";
import { bnOne, parseUnits } from "../../utils";
import { BigNumber, bnOne, parseUnits } from "../../utils";
import { GasPriceEstimate } from "../types";
import * as ethereum from "./ethereum";

const DEFAULT_PRIORITY_FEE = parseUnits("1.5", 9);
let DEFAULT_PRIORITY_FEE: BigNumber | undefined = undefined;

// Arbitrum Nitro implements EIP-1559 pricing, but the priority fee is always refunded to the caller. Further,
// ethers typically hardcodes the priority fee to 1.5 Gwei. So, confirm that the priority fee supplied was 1.5
// Gwei, and then drop it to 1 Wei. Reference: https://developer.arbitrum.io/faqs/gas-faqs#q-priority
export async function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
DEFAULT_PRIORITY_FEE ??= parseUnits("1.5", 9);
const { maxFeePerGas: _maxFeePerGas, maxPriorityFeePerGas } = await ethereum.eip1559(provider, chainId);

// If this throws, ethers default behaviour has changed, or Arbitrum RPCs are returning something more sensible.
Expand Down
8 changes: 3 additions & 5 deletions src/utils/BigNumberUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
*/

import { utils as ethersUtils } from "ethers";
import * as ethersBigNumber from "@ethersproject/bignumber";
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";

export const { BigNumber } = ethersBigNumber;
export type BigNumberish = ethersBigNumber.BigNumberish;
export type BigNumber = ethersBigNumber.BigNumber;
export type BN = ethersBigNumber.BigNumber;
export * from "@ethersproject/bignumber";
export type BN = BigNumber;

export const { formatEther, formatUnits, parseEther, parseUnits } = ethersUtils;
export const bnZero = BigNumber.from("0");
Expand Down

0 comments on commit aec5c18

Please sign in to comment.