Skip to content

Commit

Permalink
cratio color, number formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mostarz93 committed Feb 13, 2023
1 parent 6909ac5 commit b5033c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -330,7 +332,7 @@ export const LineMetadata = (props: LineMetadataProps) => {
<StyledIcon Component={InfoIcon} size="1.5rem" />
</Tooltip>
<MetadataTitle>{t('lineDetails:metadata.cratio')}: </MetadataTitle>{' '}
<CratioWithColor diff={Number(cratio) - Number(minCRatio)}>{cratio}%</CratioWithColor>
<CratioWithColor diff={Number(cratio) - Number(minCRatio)}>{normalizeAmount(cratio, 2)}%</CratioWithColor>
</MetadataRow>
<MetadataRow>
<Tooltip placement="bottom-start" tooltipComponent={<>{t('lineDetails:metadata.tooltip.min-cratio')}</>}>
Expand Down
4 changes: 2 additions & 2 deletions src/utils/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -434,7 +434,7 @@ export const formatSecuredLineData = (
};

const positions = createPositionsMap(positionFrags, tokenPrices);

console.log('CRATIO', aggregatedEscrow.cratio);
return {
credit: {
highestApy,
Expand Down

0 comments on commit b5033c3

Please sign in to comment.