Skip to content

Commit

Permalink
fix: negative liquidity
Browse files Browse the repository at this point in the history
  • Loading branch information
TbIKoBKa committed Oct 30, 2024
1 parent 700d207 commit 63a134f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/components/Charts/Density/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function DensityChart({ address, client }: IProps) {
borderColor: null,
borderWidth: 2,
},
data: data?.formatData.map(({ isCurrent, activeLiquidity }) => (isCurrent ? 0 : activeLiquidity)).toReversed(),
data: data?.formatData.map(({ isCurrent, activeLiquidity }) => (isCurrent ? 0 : Math.max(activeLiquidity, 0))).toReversed(),
},
{
name: 'Active Tick',
Expand All @@ -133,7 +133,7 @@ function DensityChart({ address, client }: IProps) {
borderColor: null,
borderWidth: 2,
},
data: data?.formatData.map(({ isCurrent, activeLiquidity }) => (isCurrent ? activeLiquidity : 0)).toReversed(),
data: data?.formatData.map(({ isCurrent, activeLiquidity }) => (isCurrent ? Math.max(activeLiquidity, 0) : 0)).toReversed(),
},
],
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/Charts/Density/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const getRenderTooltip =
const token1 = poolData?.token1;
const price0 = tick?.price0;
const price1 = tick?.price1;
const tvlToken0 = tick?.tvlToken0;
const tvlToken1 = tick?.tvlToken1;
const tvlToken0 = Math.max(tick?.tvlToken0 || 0, 0);
const tvlToken1 = Math.max(tick?.tvlToken1 || 0, 0);

if (!tvlToken0 && !tvlToken1) {
return '';
Expand Down
4 changes: 2 additions & 2 deletions src/components/Charts/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ export const Terminal: React.FC<React.PropsWithChildren> = () => {
return <TerminalChart poolAddress="0xa0131792b824c2f5ffcc37173460c01a066abfd6" chainId={ChainId.ZKSYNC} />;
};

const client = new GraphQLClient('https://metis.graph.wagmi.com/subgraphs/name/v3');
const client = new GraphQLClient('https://kava.graph.wagmi.com/subgraphs/name/v3');
const queryClient = new QueryClient();

export const Density: React.FC<React.PropsWithChildren> = () => {
return (
<QueryClientProvider client={queryClient}>
<Flex minHeight={400}>
<DensityChart address="0xfc0AE5EB117a4Ae1b9348956EbBd308b30DA1Bd4" client={client} />
<DensityChart address="0x86350BA4da1DAB2920B89300C4e25F2C8044040F" client={client} />
</Flex>
</QueryClientProvider>
)
Expand Down

0 comments on commit 63a134f

Please sign in to comment.