@hyperlane-xyz/sdk
Version:
The official SDK for the Hyperlane Network
40 lines • 1.76 kB
TypeScript
export declare const MAX_BPS = 10000n;
/**
* Maximum decimal places supported for fractional bps values.
* The precision scaling in convertToBps/convertFromBps uses 10^MAX_BPS_DECIMALS
* as a multiplier. Values with more decimal places will be rejected to prevent
* silent precision loss during bigint arithmetic.
*/
export declare const MAX_BPS_DECIMALS = 4;
/**
* Bigint precision multiplier for fractional bps arithmetic.
* Equals 10^MAX_BPS_DECIMALS = 10_000n.
*/
export declare const BPS_PRECISION: bigint;
/**
* Returns true if bps has at most MAX_BPS_DECIMALS decimal places.
* Uses epsilon comparison to avoid IEEE 754 false positives
* (e.g. 0.3 * 10000 = 2999.9999... which strict equality would wrongly reject).
*/
export declare function isBpsPrecisionValid(bps: number): boolean;
/**
* Validates that a bps value does not exceed MAX_BPS_DECIMALS decimal places.
* @throws Error if bps has too many decimal places
*/
export declare function assertBpsPrecision(bps: number): void;
/**
* Assumed maximum transfer amount for zero-supply tokens.
* 10^36 is astronomically large (10^18 tokens with 18 decimals).
* This ensures maxFee * amount won't overflow for any realistic transfer
* in the LinearFee contract's _quoteTransfer calculation.
*/
export declare const ASSUMED_MAX_AMOUNT_FOR_ZERO_SUPPLY: bigint;
/**
* Converts fee parameters to basis points (BPS)
* @param maxFee - Maximum fee amount
* @param halfAmount - Half of the amount at which maxFee is applied
* @returns Fee in basis points (up to MAX_BPS_DECIMALS decimal places)
* @throws Error if halfAmount is zero to prevent division by zero
*/
export declare function convertToBps(maxFee: bigint, halfAmount: bigint): number;
//# sourceMappingURL=utils.d.ts.map