Skip to content

Commit

Permalink
pool portfolio break down
Browse files Browse the repository at this point in the history
  • Loading branch information
Robiquet committed Mar 25, 2024
1 parent 5ea8ca3 commit 299e178
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
11 changes: 8 additions & 3 deletions components/portfolio/Breakdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export type PortfolioBreakdownProps =
* @returns JSX.Element
*/
export const PortfolioBreakdown = (props: PortfolioBreakdownProps) => {
const { data: pools } = useAccountAmm2Pool(props.address);
const { data: pools, isLoading: poolIsLoading } = useAccountAmm2Pool(
props.address,
);
const poolZtgTotal = pools?.reduce<Decimal>((total, pool) => {
return total.plus(pool.addressZtgValue);
}, new Decimal(0));

return (
<div className="flex flex-col gap-y-[30px] md:flex-row">
Expand Down Expand Up @@ -56,12 +61,12 @@ export const PortfolioBreakdown = (props: PortfolioBreakdownProps) => {

<div className="flex w-full max-w-[600px] md:pl-4">
<div className="flex-1 border-r-2 border-gray-200">
{"loading" in props ? (
{"loading" in props || poolIsLoading ? (
<BreakdownSlotSkeleton />
) : (
<BreakdownSlot
title="Liquidity"
value={props.subsidy.value}
value={poolZtgTotal?.mul(ZTG) ?? new Decimal(0)}
usdZtgPrice={props.usdZtgPrice}
changePercentage={props.subsidy.changePercentage}
/>
Expand Down
3 changes: 2 additions & 1 deletion lib/hooks/queries/useAccountAmm2Pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export const useAccountAmm2Pool = (address?: string) => {
const addressValue = totalValue.mul(percentageOwnership).div(ZTG);

const addressUsdValue = addressValue.mul(baseAssetUsdPrice);
const addressZtgValue = addressUsdValue.mul(ztgPrice);
const addressZtgValue = addressUsdValue.div(ztgPrice);

return {
...pool,
totalValue,
Expand Down
1 change: 1 addition & 0 deletions pages/portfolio/[address].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const Portfolio: NextPageWithLayout = () => {
{address && <PortfolioIdentity address={address} />}
<div className="mb-12">
<PortfolioBreakdown
address={address}
{...(breakdown ?? {
loading: true,
})}
Expand Down

0 comments on commit 299e178

Please sign in to comment.