Skip to content

Commit

Permalink
filter nan in orderbook
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarnadas committed Mar 12, 2024
1 parent 79a972f commit e41d76e
Showing 1 changed file with 36 additions and 32 deletions.
68 changes: 36 additions & 32 deletions sdk/hooks/src/Orderbook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,42 @@ export const Orderbook: FC = () => {
<Box>Price (USDC)</Box>
<Box>Quantity (ETH)</Box>
<Box>Total (ETH)</Box>
{data.asks?.map(([price, quantity, aggregated]) => {
const gradient = (100 * aggregated) / data.asks[0][2];
return (
<>
<Box className="ask">{price}</Box>
<Box>{quantity}</Box>
<Box
style={{
background: `linear-gradient(to left, rgba(161, 6, 6, 0.2) ${gradient}%, transparent ${gradient}%)`
}}
>
{aggregated}
</Box>
</>
);
})}
{data.bids?.map(([price, quantity, aggregated]) => {
const gradient = (100 * aggregated) / data.bids[data.bids.length - 1][2];
return (
<>
<Box className="bid">{price}</Box>
<Box>{quantity}</Box>
<Box
style={{
background: `linear-gradient(to left, rgba(4, 109, 4, 0.2) ${gradient}%, transparent ${gradient}%)`
}}
>
{aggregated}
</Box>
</>
);
})}
{data.asks
?.filter(([price]) => !Number.isNaN(price))
.map(([price, quantity, aggregated]) => {
const gradient = (100 * aggregated) / data.asks[0][2];
return (
<>
<Box className="ask">{price}</Box>
<Box>{quantity}</Box>
<Box
style={{
background: `linear-gradient(to left, rgba(161, 6, 6, 0.2) ${gradient}%, transparent ${gradient}%)`
}}
>
{aggregated}
</Box>
</>
);
})}
{data.bids
?.filter(([price]) => !Number.isNaN(price))
.map(([price, quantity, aggregated]) => {
const gradient = (100 * aggregated) / data.bids[data.bids.length - 1][2];
return (
<>
<Box className="bid">{price}</Box>
<Box>{quantity}</Box>
<Box
style={{
background: `linear-gradient(to left, rgba(4, 109, 4, 0.2) ${gradient}%, transparent ${gradient}%)`
}}
>
{aggregated}
</Box>
</>
);
})}
</Grid>
)}
</Flex>
Expand Down

0 comments on commit e41d76e

Please sign in to comment.