diff --git a/src/utils/ethers.ts b/src/utils/ethers.ts index b83051e44..0519946fe 100644 --- a/src/utils/ethers.ts +++ b/src/utils/ethers.ts @@ -1,14 +1,24 @@ -import { Contract, ethers } from "ethers"; +import { Contract, ethers, providers } from "ethers"; import type { Event } from "ethers"; import { Provider } from "@ethersproject/providers"; import { Signer } from "@ethersproject/abstract-signer"; import type { TypedEvent, TypedEventFilter } from "utils/typechain"; -export { Provider, Signer, Contract, TypedEventFilter, TypedEvent, Event }; +export { + Provider, + Signer, + Contract, + TypedEventFilter, + TypedEvent, + Event, + providers, +}; export type Result = ethers.utils.Result; +export type ContractTransaction = ethers.ContractTransaction; + export interface Callable { (...args: any[]): any; } diff --git a/src/utils/format.ts b/src/utils/format.ts index d87311ab3..abefd896c 100644 --- a/src/utils/format.ts +++ b/src/utils/format.ts @@ -292,5 +292,5 @@ export function humanReadableNumber(num: number, decimals = 0): string { */ export function formatUSD(value: BigNumberish): string { const formattedString = formatUnits(value, 18); - return numeral(formattedString).format("0.00"); + return numeral(formattedString).format("0,0.00"); } diff --git a/src/utils/transactions.ts b/src/utils/transactions.ts index b7617acaa..57ac68c3f 100644 --- a/src/utils/transactions.ts +++ b/src/utils/transactions.ts @@ -1,10 +1,10 @@ -import { Contract, ContractTransaction, ethers } from "ethers"; -import { parseEther } from "ethers/lib/utils"; import { fixedPointAdjustment, gasMultiplierPerChain, hubPoolChainId, } from "./constants"; +import { Contract, ContractTransaction, Signer, providers } from "./ethers"; +import { parseUnits } from "./format"; /** * This function takes a raw transaction and a signer and returns the result of signing the transaction. @@ -13,8 +13,8 @@ import { * @returns The raw transaction signed by the given `signer`. */ export function signTransaction( - rawTx: ethers.providers.TransactionRequest, - signer: ethers.Signer + rawTx: providers.TransactionRequest, + signer: Signer ): Promise { //TODO: here is where we might do safety checks on the transaction return signer.signTransaction(rawTx); @@ -22,8 +22,8 @@ export function signTransaction( export async function sendSignedTransaction( signedTx: string, - provider: ethers.providers.Provider -): Promise { + provider: providers.Provider +): Promise { const tx = await provider.sendTransaction(signedTx); return tx; } @@ -45,7 +45,7 @@ export async function getPaddedGasEstimation( const gasEstimation = await contract.estimateGas[method](...args); // Factor in the padding const gasToRecommend = gasEstimation - .mul(parseEther(String(gasMultiplier))) + .mul(parseUnits(String(gasMultiplier), 18)) .div(fixedPointAdjustment); return gasToRecommend; }