From b5033c34fa6f8f0c85af080295005716b2fa93c1 Mon Sep 17 00:00:00 2001 From: Momin Ahmad Date: Mon, 13 Feb 2023 10:18:31 -0500 Subject: [PATCH] cratio color, number formatting --- src/client/components/app/LineDetailsDisplay/LineMetadata.tsx | 4 +++- src/utils/line.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client/components/app/LineDetailsDisplay/LineMetadata.tsx b/src/client/components/app/LineDetailsDisplay/LineMetadata.tsx index 6893b3df..4d7e5af9 100644 --- a/src/client/components/app/LineDetailsDisplay/LineMetadata.tsx +++ b/src/client/components/app/LineDetailsDisplay/LineMetadata.tsx @@ -123,6 +123,7 @@ const StatusWithColor = styled.span<{ status: string }>` const CratioWithColor = styled.span<{ diff: number }>` color: ${({ diff }) => { + console.log('CRATIO', diff); if (diff >= 15) return '#6AFF4D'; // decent margin - light green else if (diff < 0) return '#FF1919'; // liquidatable - bright red else return '#E6E600'; // close to liquidatable - darkish yellow @@ -279,6 +280,7 @@ export const LineMetadata = (props: LineMetadataProps) => { const { revenueValue, revenueSummary: revenue } = spigot!; const renderEscrowMetadata = () => { + console.log(cratio); if (!deposits) return null; if (!collateralValue) return ( @@ -330,7 +332,7 @@ export const LineMetadata = (props: LineMetadataProps) => { {t('lineDetails:metadata.cratio')}: {' '} - {cratio}% + {normalizeAmount(cratio, 2)}% {t('lineDetails:metadata.tooltip.min-cratio')}}> diff --git a/src/utils/line.ts b/src/utils/line.ts index f273e56e..12e17495 100644 --- a/src/utils/line.ts +++ b/src/utils/line.ts @@ -385,7 +385,7 @@ export const formatSecuredLineData = ( collateralValue: formatUnits(unnullify(collateralValue), 6).toString(), cratio: parseUnits(credit.principal.toString(), 'ether').eq(0) ? '0' - : String(Number(BigNumber.from(10000).mul(collateralValue).div(credit.principal).toString()) / 100), + : String(Number(BigNumber.from(10000).mul(collateralValue).div(credit.principal).toString())), minCRatio: escrow.minCRatio, events: escrowCollateralEvents, deposits, @@ -434,7 +434,7 @@ export const formatSecuredLineData = ( }; const positions = createPositionsMap(positionFrags, tokenPrices); - + console.log('CRATIO', aggregatedEscrow.cratio); return { credit: { highestApy,