Skip to content

Commit

Permalink
polished up solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor committed Jan 24, 2024
1 parent 24f3bfa commit e7663d5
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/app/components/OrderBook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,16 @@ function CurrentPriceRow() {
);

let spreadString = "";
let spreadValue = "";

// checking for past trades here because adexState.currentPairInfo.lastPrice
// is never null, and is = -1 if there were no trades
let lastPrice = "";
if (trades.length > 0) {
lastPrice = orderBook.lastPrice?.toString() || "";
//The full solution causes display issues as it will always display min digits
/*
lastPrice =
orderBook.lastPrice?.toLocaleString(undefined, {
minimumFractionDigits: token2MaxDecimals,
}) || "";
*/
lastPrice = utils.displayNumber(
orderBook.lastPrice || 0,
CHARACTERS_TO_DISPLAY
);
} else {
lastPrice = "No trades have occurred yet";
}
Expand All @@ -93,20 +90,22 @@ function CurrentPriceRow() {
2
);

spreadString = `${spread} (${spreadPercent}%)`;
spreadString = `(${spreadPercent}%)`;
spreadValue = `Spread ${spread}`;
}

return (
<>
<div className="text-2xl text-accent text-left col-span-2 my-1 py-1 ml-2">
<div className="text-xl text-accent text-left col-span-2 my-1 py-1 ml-2">
{lastPrice}
</div>

<div className="flex text-accent justify-end col-span-2 text-sm my-1 py-1 whitespace-nowrap">
<span className="my-auto">Spread</span>{" "}
<span className="my-auto px-1 border-r-2 border-accent">
{spreadString}
</span>
<div className="flex text-accent justify-end items-center col-span-2 text-sm my-1 py-1 whitespace-nowrap">
<div className="tooltip tooltip-left" data-tip={spreadValue}>
<span className="my-auto px-1 border-r-2 border-accent">
{spreadString}
</span>
</div>
</div>
</>
);
Expand Down

0 comments on commit e7663d5

Please sign in to comment.