diff --git a/.eslintcache b/.eslintcache
new file mode 100644
index 000000000..9eef86c6c
--- /dev/null
+++ b/.eslintcache
@@ -0,0 +1 @@
+[{"/home/tonio/Workspaces/Origin/origin-defi/libs/shared/utils/src/formatters.ts":"1"},{"size":1067,"mtime":1694612446615,"results":"2","hashOfConfig":"3"},{"filePath":"4","messages":"5","suppressedMessages":"6","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"pshlvk","/home/tonio/Workspaces/Origin/origin-defi/libs/shared/utils/src/formatters.ts",[],[]]
\ No newline at end of file
diff --git a/libs/oeth/history/src/components/APYContainer.tsx b/libs/oeth/history/src/components/APYContainer.tsx
index eb035899d..f3a05dfcc 100644
--- a/libs/oeth/history/src/components/APYContainer.tsx
+++ b/libs/oeth/history/src/components/APYContainer.tsx
@@ -1,7 +1,8 @@
import { Divider, Stack, Typography } from '@mui/material';
-import { valueFormat } from '@origin/shared/components';
+import { valueFormat } from '@origin/shared/utils';
import { useIntl } from 'react-intl';
import { useAccount } from 'wagmi';
+
import { useHistoryTableQuery } from '../queries.generated';
export function APYContainer() {
diff --git a/libs/oeth/history/src/components/HistoryTable.tsx b/libs/oeth/history/src/components/HistoryTable.tsx
index 36560d798..c12d6ea70 100644
--- a/libs/oeth/history/src/components/HistoryTable.tsx
+++ b/libs/oeth/history/src/components/HistoryTable.tsx
@@ -2,7 +2,6 @@ import { useMemo } from 'react';
import {
Box,
- Button,
Stack,
Table,
TableBody,
@@ -10,7 +9,8 @@ import {
TableHead,
TableRow,
} from '@mui/material';
-import { LinkIcon, quantityFormat } from '@origin/shared/components';
+import { LinkIcon } from '@origin/shared/components';
+import { quantityFormat } from '@origin/shared/utils';
import {
createColumnHelper,
flexRender,
@@ -19,11 +19,11 @@ import {
} from '@tanstack/react-table';
import { useIntl } from 'react-intl';
-import type { HistoryTableQuery } from '../queries.generated';
-import usePagination from '@mui/material/usePagination/usePagination';
import { HistoryFilterButton } from './HistoryButton';
import { HistoryCell } from './HistoryCell';
+import type { HistoryTableQuery } from '../queries.generated';
+
export type Rows = HistoryTableQuery['addressById']['history'];
interface Props {
diff --git a/libs/oeth/swap/src/components/SwapRouteAccordionItem.tsx b/libs/oeth/swap/src/components/SwapRouteAccordionItem.tsx
index e877c47b9..746a5711c 100644
--- a/libs/oeth/swap/src/components/SwapRouteAccordionItem.tsx
+++ b/libs/oeth/swap/src/components/SwapRouteAccordionItem.tsx
@@ -1,7 +1,7 @@
import { alpha, Box, Stack, Typography } from '@mui/material';
-import { currencyFormat, quantityFormat } from '@origin/shared/components';
import { tokens } from '@origin/shared/contracts';
import { usePrices } from '@origin/shared/providers';
+import { currencyFormat, quantityFormat } from '@origin/shared/utils';
import { useIntl } from 'react-intl';
import { formatUnits } from 'viem';
diff --git a/libs/oeth/swap/src/components/SwapRouteCard.tsx b/libs/oeth/swap/src/components/SwapRouteCard.tsx
index 24c08fa22..ba2c3c5ba 100644
--- a/libs/oeth/swap/src/components/SwapRouteCard.tsx
+++ b/libs/oeth/swap/src/components/SwapRouteCard.tsx
@@ -1,7 +1,7 @@
import { alpha, Box, Card, CardHeader, Stack, Typography } from '@mui/material';
-import { currencyFormat, quantityFormat } from '@origin/shared/components';
import { tokens } from '@origin/shared/contracts';
import { usePrices } from '@origin/shared/providers';
+import { currencyFormat, quantityFormat } from '@origin/shared/utils';
import { useIntl } from 'react-intl';
import { formatUnits } from 'viem';
diff --git a/libs/oeth/swap/src/components/TokenSelectModal.tsx b/libs/oeth/swap/src/components/TokenSelectModal.tsx
index f65380ea1..dd454311c 100644
--- a/libs/oeth/swap/src/components/TokenSelectModal.tsx
+++ b/libs/oeth/swap/src/components/TokenSelectModal.tsx
@@ -8,6 +8,7 @@ import {
Typography,
} from '@mui/material';
import { usePrices } from '@origin/shared/providers';
+import { currencyFormat, formatAmount } from '@origin/shared/utils';
import { useIntl } from 'react-intl';
import { useAccount, useBalance } from 'wagmi';
@@ -141,18 +142,11 @@ function TokenListItem({ token, ...rest }: TokenListItemProps) {
{isBalanceLoading ? (
) : (
- intl.formatNumber(bal, {
- minimumFractionDigits: 0,
- maximumFractionDigits: 4,
- })
+ formatAmount(balance.value, balance.decimals)
)}
- {intl.formatNumber(balUsd, {
- style: 'currency',
- currency: 'USD',
- minimumFractionDigits: 2,
- })}
+ {intl.formatNumber(balUsd, currencyFormat)}
diff --git a/libs/shared/components/src/Cards/SwapCard/Input.tsx b/libs/shared/components/src/Cards/SwapCard/Input.tsx
index 48d66cceb..5fe206cc2 100644
--- a/libs/shared/components/src/Cards/SwapCard/Input.tsx
+++ b/libs/shared/components/src/Cards/SwapCard/Input.tsx
@@ -1,12 +1,12 @@
import { useState } from 'react';
import { alpha, Box, InputBase, Stack, Typography } from '@mui/material';
+import { currencyFormat } from '@origin/shared/utils';
import { useDebouncedEffect } from '@react-hookz/web';
import { useIntl } from 'react-intl';
import { Loader } from '../../Loader';
import { cardStyles } from '../Card';
-import { currencyFormat } from './SwapCard';
import { SwapItem } from './SwapItem';
import { styles } from './utils';
diff --git a/libs/shared/components/src/Cards/SwapCard/Output.tsx b/libs/shared/components/src/Cards/SwapCard/Output.tsx
index cca386040..b30f1fbe2 100644
--- a/libs/shared/components/src/Cards/SwapCard/Output.tsx
+++ b/libs/shared/components/src/Cards/SwapCard/Output.tsx
@@ -1,9 +1,9 @@
import { alpha, Box, Typography } from '@mui/material';
+import { currencyFormat, valueFormat } from '@origin/shared/utils';
import { useIntl } from 'react-intl';
import { Loader } from '../../Loader';
import { cardStyles } from '../Card';
-import { currencyFormat, valueFormat } from './SwapCard';
import { SwapItem } from './SwapItem';
import { styles } from './utils';
diff --git a/libs/shared/components/src/Cards/SwapCard/SwapCard.tsx b/libs/shared/components/src/Cards/SwapCard/SwapCard.tsx
index 51b564e3d..c8851aa65 100644
--- a/libs/shared/components/src/Cards/SwapCard/SwapCard.tsx
+++ b/libs/shared/components/src/Cards/SwapCard/SwapCard.tsx
@@ -7,21 +7,6 @@ import { Input } from './Input';
import { Output } from './Output';
import { SwapButton } from './SwapButton';
-import type { FormatNumberOptions } from 'react-intl';
-
-export const valueFormat: FormatNumberOptions = {
- minimumFractionDigits: 2,
-};
-export const currencyFormat: FormatNumberOptions = {
- style: 'currency',
- currency: 'USD',
- minimumFractionDigits: 2,
-};
-export const quantityFormat: FormatNumberOptions = {
- minimumFractionDigits: 0,
- maximumFractionDigits: 4,
-};
-
interface Props {
title: string | React.ReactNode;
baseTokenName: string;
diff --git a/libs/shared/components/src/Cards/SwapCard/TokenListItem.tsx b/libs/shared/components/src/Cards/SwapCard/TokenListItem.tsx
index cfb54a802..e69e08c10 100644
--- a/libs/shared/components/src/Cards/SwapCard/TokenListItem.tsx
+++ b/libs/shared/components/src/Cards/SwapCard/TokenListItem.tsx
@@ -1,8 +1,8 @@
import { Box, MenuItem, Stack, Typography } from '@mui/material';
+import { currencyFormat, quantityFormat } from '@origin/shared/utils';
import { useIntl } from 'react-intl';
import { Mix } from '../../Mix';
-import { currencyFormat, quantityFormat } from './SwapCard';
import type { Option } from './TokenListModal';
diff --git a/libs/shared/components/src/Inputs/TokenInput.tsx b/libs/shared/components/src/Inputs/TokenInput.tsx
index 46523f1f6..eace65a0c 100644
--- a/libs/shared/components/src/Inputs/TokenInput.tsx
+++ b/libs/shared/components/src/Inputs/TokenInput.tsx
@@ -1,10 +1,10 @@
import { forwardRef } from 'react';
import { alpha, Box, IconButton, Stack, Typography } from '@mui/material';
+import { formatAmount } from '@origin/shared/utils';
import { useIntl } from 'react-intl';
import { formatUnits } from 'viem';
-import { currencyFormat } from '../Cards';
import { Loader } from '../Loader';
import { BigIntInput } from './BigIntInput';
@@ -60,13 +60,6 @@ export const TokenInput = forwardRef(
) => {
const intl = useIntl();
- // const handleMaxClick = () => {
- // if (onAmountChange) {
- // onAmountChange(balance);
- // }
- // };
-
- const bal = +formatUnits(balance, decimals);
const amountUsd = +formatUnits(amount, decimals) * tokenPriceUsd;
return (
@@ -127,7 +120,7 @@ export const TokenInput = forwardRef(
{intl.formatMessage(
{ defaultMessage: 'Balance: {number}' },
{
- number: intl.formatNumber(bal || 0, currencyFormat),
+ number: formatAmount(balance, decimals),
},
)}