import Decimal from "decimal.js"; import { ethers } from "ethers"; import { BigNumber, BigNumberish, BN } from "./BigNumberUtils"; export type Decimalish = string | number | Decimal; export declare const AddressZero = "0x0000000000000000000000000000000000000000"; export declare const MAX_BIG_INT: ethers.BigNumber; /** * toBNWei. * * @param {BigNumberish} num * @param {number} decimals * @returns {BN} */ export declare const toBNWei: (num: BigNumberish, decimals?: number) => BN; /** * fromWei. * * @param {BigNumberish} num * @param {number} decimals * @returns {string} */ export declare const fromWei: (num: BigNumberish, decimals?: number) => string; /** * min. * * @param {BigNumberish} a * @param {BigNumberish} b * @returns {BN} */ export declare function min(a: BigNumberish, b: BigNumberish): BN; /** * max. * * @param {BigNumberish} a * @param {BigNumberish} b * @returns {BN} */ export declare function max(a: BigNumberish, b: BigNumberish): BN; export declare const fixedPointAdjustment: ethers.BigNumber; /** * Convert an amount of native gas token into a token given price and token decimals. * * @param {BigNumberish} fromAmount - Amount of native gas token to convert. * @param {string | number} [ price=1 ] - The price as native gas token per token, ie how much native gas token can 1 token buy. * @param {} [ toDecimals=18 ] - Number of decimals for the token currency. * @param {} [ nativeDecimals=18 ] - Number of decimals for the native token currency. * @returns {string} The number of tokens denominated in token decimals in the smallest unit (wei). */ export declare function nativeToToken(fromAmount: BigNumberish, price?: string | number, toDecimals?: number, nativeDecimals?: number): string; /** * Convert a gas amount and gas price to wei. * * @param {number} gas - gas amount. * @param {BigNumberish} gasPrice - gas price in gwei. * @returns {BigNumber} - total fees in wei. */ export declare const gasCost: (gas: BigNumberish, gasPrice: BigNumberish) => BigNumber; /** * getGasFees. Low level pure function call to calculate gas fees. * * @param {number} gas - The gast cost for transfer, use constants defined in file. * @param {BigNumberish} gasPrice - Estimated gas price in wei. * @param {string | number} [price = 1] - The price of the token in native gas token, how much native gas token can 1 token buy. * @param {number} [decimals=18] - Number of decimals of token. * @returns {string} - The value of fees native to the token provided, in its smallest unit. */ export declare function calculateGasFees(gas: number, gasPrice: BigNumberish, price?: string | number, decimals?: number): string; /** * percent. * * @param {BigNumberish} numerator * @param {BigNumberish} denominator * @returns {BN} */ export declare function percent(numerator: BigNumberish, denominator: BigNumberish): BN; /** * calcContinuousCompoundInterest. From https://www.calculatorsoup.com/calculators/financial/compound-interest-calculator.php?given_data=find_r&A=2&P=1&n=0&t=1&given_data_last=find_r&action=solve * Returns a yearly interest rate if start/end amount had been continuously compounded over the period elapsed. Multiply result by 100 for a %. * * @param {string} startAmount * @param {string} endAmount * @param {string} periodsElapsed * @param {string} periodsPerYear */ export declare const calcContinuousCompoundInterest: (startAmount: Decimalish, endAmount: Decimalish, periodsElapsed: Decimalish, periodsPerYear: Decimalish) => string; /** * calcPeriodicCompoundInterest. Taken from https://www.calculatorsoup.com/calculators/financial/compound-interest-calculator.php?given_data=find_r&A=2&P=1&n=365&t=1&given_data_last=find_r&action=solve * This will return a periodically compounded interest rate for 1 year. Multiply result by 100 for a %. * * @param {string} startAmount - Starting amount or price * @param {string} endAmount - Ending amount or price * @param {string} periodsElapsed - How many periods elapsed for the start and end amount. * @param {string} periodsPerYear - How many periods in 1 year. */ export declare const calcPeriodicCompoundInterest: (startAmount: Decimalish, endAmount: Decimalish, periodsElapsed: Decimalish, periodsPerYear: Decimalish) => string; /** * calcApr. Simple apr calculation based on extrapolating the difference for a short period over a year. * * @param {Decimalish} startAmount - Starting amount or price * @param {Decimalish} endAmount - Ending amount or price * @param {Decimalish} periodsElapsed - periods elapsed from start to end * @param {Decimalish} periodsPerYear - periods per year */ export declare const calcApr: (startAmount: Decimalish, endAmount: Decimalish, periodsElapsed: Decimalish, periodsPerYear: Decimalish) => string; /** * Takes two values and returns a list of number intervals * * @example * ```js * getSamplesBetween(1, 9, 3) //returns [[1, 3], [4, 7], [8, 9]] * ``` */ export declare const getSamplesBetween: (min: number, max: number, size: number) => number[][]; /** * A promise that resolves after a specified number of seconds * @param seconds The number of seconds to wait */ export declare function delay(seconds: number): Promise; /** * Attempt to retry a function call a number of times with a delay between each attempt * @param call The function to call * @param times The number of times to retry * @param delayS The number of seconds to delay between each attempt * @returns The result of the function call. */ export declare function retry(call: () => Promise, times: number, delayS: number): Promise; export type TransactionCostEstimate = { nativeGasCost: BigNumber; tokenGasCost: BigNumber; gasPrice: BigNumber; opStackL1GasCost?: BigNumber; }; export declare function randomAddress(): string;