Skip to content

Commit

Permalink
Merge pull request #1150 from oraidex/fix/minor-issue
Browse files Browse the repository at this point in the history
fix crash pool
  • Loading branch information
haunv3 authored Feb 7, 2025
2 parents 6e4615f + 4da9405 commit 28c6ce7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pages/Pool-V3/components/PoolList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import CreateNewPosition from '../CreateNewPosition';
import styles from './index.module.scss';
import PoolItemDataMobile from './PoolItemDataMobile';
import PoolItemTData from './PoolItemTData';
import { isScientificFormat } from 'pages/Pools/helpers';

export enum PoolColumnHeader {
POOL_NAME = 'Pool name',
Expand Down Expand Up @@ -156,17 +157,16 @@ const PoolList = ({ search, filterType }: { search: string; filterType: POOL_TYP
const showVolume = type === POOL_TYPE.V3 ? volumeV3 : toDisplay(volumeV2 || 0);

let showApr = aprInfo?.[poolKey] || aprInfo?.[liquidityAddr] || {};

if (type === POOL_TYPE.V2) {
showApr = {
...showApr,
apr: {
min: (showApr['apr']?.['min'] || 0),
max: (showApr['apr']?.['max'] || 0)
min: isScientificFormat(showApr['apr']?.['min']),
max: isScientificFormat(showApr['apr']?.['max'])
},
swapFee: {
min: (showApr['swapFee']?.['min'] || 0),
max: (showApr['swapFee']?.['max'] || 0)
min: isScientificFormat(showApr['swapFee']?.['min']),
max: isScientificFormat(showApr['swapFee']?.['max'])
}
};
}
Expand Down Expand Up @@ -194,7 +194,7 @@ const PoolList = ({ search, filterType }: { search: string; filterType: POOL_TYP
return new BigDecimal(CoefficientBySort[sortOrder]).mul(a.showVolume - b.showVolume).toNumber();
case PoolColumnHeader.APR:
return new BigDecimal(CoefficientBySort[sortOrder])
.mul((a?.showApr.apr.max || 0) - (b?.showApr.apr.max || 0))
.mul((a?.showApr.apr?.max || 0) - (b?.showApr.apr?.max || 0))
.toNumber();

default:
Expand Down
8 changes: 8 additions & 0 deletions src/pages/Pools/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,11 @@ export const listFactoryV1Pools: FACTORY_V1_POOL[] = [
]
}
];

export const isScientificFormat = (value) => {
// "6e-7" is in scientific format? true
// "-1.5e3" is in scientific format? true
// "0.001" is in scientific format? false
const regex = /^\d+e[+-]?\d+$/;
return !value || regex.test(value) ? 0 : value;
};

0 comments on commit 28c6ce7

Please sign in to comment.