Skip to content

Commit

Permalink
chore: normalize reserve shortfall
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Jun 5, 2024
1 parent 6b2bc81 commit 26952ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/pages/Reserve.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const Reserve = () => {
isLoading={moduleAccountsLoading}
error={moduleAccountsError}
/>
<ReserveShortfall data={reserveDashboardQueryData} isLoading={isLoading} />
<ReserveShortfall data={reserveDashboardQueryData} boardAuxes={boardAuxes} isLoading={isLoading} />
</div>
<ReserveHistoryGraph tokenNames={tokenNames} error={tokenNamesError} isLoading={tokenNamesIsLoading} />
</PageContent>
Expand Down
8 changes: 5 additions & 3 deletions src/widgets/ReserveShortfall.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { Skeleton } from '@/components/ui/skeleton';
import { ValueCard } from '@/components/ValueCard';
import { formatPrice } from '@/utils';
import { formatPrice, getTokenDivisor } from '@/utils';
import { ReserveDashboardData } from '@/types/reserve-types';

type Props = {
title?: string;
data: ReserveDashboardData;
isLoading: boolean;
boardAuxes: { [key: string]: number };
};

export function ReserveShortfall({ title = 'Reserve Shortfall', data, isLoading }: Props) {
export function ReserveShortfall({ title = 'Reserve Shortfall', data, boardAuxes, isLoading }: Props) {
if (isLoading || !data) {
return <ValueCard title={title} value={<Skeleton className="w-[100px] h-[32px] rounded-full" />} />;
}
const shortfall = data.reduce((agg, node) => agg + Number(node.shortfallBalance), 0) / 1_000_000;
const istDivisor = getTokenDivisor(boardAuxes, 'IST');
const shortfall = data.reduce((agg, node) => agg + Number(node.shortfallBalance), 0) / istDivisor;
return <ValueCard title={title} value={formatPrice(shortfall)} />;
}

0 comments on commit 26952ae

Please sign in to comment.