import BigNumber from "bignumber.js"; export const isCurrentRoute = (route: string) => window.location.pathname === route; export const trimAddress = (address: string) => { return address.slice(0, 6) + '...' + address.slice(-3); } export const getOrderPair = ( chain: string | null, tokenAddress: string | null ) => (chain && tokenAddress ? `${chain}_${tokenAddress.toLowerCase()}` : ""); export const formatAmount = ( amount: string | number | bigint, decimals: number, toFixed = 4 ) => { const bigAmount = new BigNumber(amount); if (bigAmount.isZero()) return 0; const value = bigAmount.dividedBy(10 ** decimals); let temp = value.toFixed(toFixed, BigNumber.ROUND_DOWN); while ( temp .split(".")[1] ?.split("") .every((d) => d === "0") && temp.split(".")[1].length < 8 ) { temp = value.toFixed(temp.split(".")[1].length + 2, BigNumber.ROUND_DOWN); } return Number(temp); };