Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: negative liquidity #72

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading