```typescript
"use client";
import React, { useEffect, useRef } from "react";
type Props = {};

type PriceData = {
  [pair: string]: {
    [exchange: string]: any;
    extremum: any;
  };
};
const exchanges = ["Binance", "ByBit", "Coinbase", "Kraken"];
const page = (props: Props) => {
  let prices: PriceData = {
    BTCUSDT: {
      Binance: 0,
      ByBit: 0,
      Coinbase: 0,
      Kraken: 0,
      extremum: {
        max: {
          exchange: "",
          price: "",
        },
        min: {
          exchange: "",
          price: "",
        },
        difference: ["", ""],
      },
    },
    ETHUSDT: {
      Binance: 0,
      ByBit: 0,
      Coinbase: 0,
      Kraken: 0,
      extremum: {
        max: {
          exchange: "",
          price: "",
        },
        min: {
          exchange: "",
          price: "",
        },
        difference: ["", ""],
      },
    },
    XRPUSDT: {
      Binance: 0,
      ByBit: 0,
      Coinbase: 0,
      Kraken: 0,
      extremum: {
        max: {
          exchange: "",
          price: "",
        },
        min: {
          exchange: "",
          price: "",
        },
        difference: ["", ""],
      },
    },
  };
  useEffect(() => {
    //ByBit--------------------------------------------------------------------------
    const bybitWs = new WebSocket(
      "wss://stream.bybit.com/contract/usdt/public/v3"
    );
    bybitWs.onopen = () => {
      bybitWs.send(
        JSON.stringify({
          op: "subscribe",
          args: [
            "publicTrade.BTCUSDT",
            "publicTrade.ETHUSDT",
            "publicTrade.XRPUSDT",
          ],
          req_id: "test",
        })
      );
    };
    bybitWs.onmessage = (event: any) => {
      const message = JSON.parse(event.data);
      const symbol = structuredClone(message).data?.pop().s;
      const price = structuredClone(message).data?.pop().p;
      if (prices[symbol]) {
        prices[symbol].ByBit = price;
      }
      findMaxMin();
    };

    //Binance------------------------------------------------------------------------
    const binanceWs = new WebSocket(
      "wss://stream.binance.com:9443/stream?streams=btcusdt@trade/ethusdt@trade/xrpusdt@trade"
    );
    binanceWs.onmessage = (event: any) => {
      const message = JSON.parse(event.data);
      const symbol = message.data.s;
      const price = message.data.p;
      if (prices[symbol]) {
        prices[symbol].Binance = price;
      }
      findMaxMin();
    };

    //Coinbse------------------------------------------------------------------
    const coinbaseWs = new WebSocket("wss://ws-feed.exchange.coinbase.com");
    coinbaseWs.onopen = () => {
      coinbaseWs.send(
        JSON.stringify({
          type: "subscribe",
          product_ids: ["BTC-USDT", "ETH-USDT", "XRP-USD"],
          channels: ["ticker"],
        })
      );
    };
    coinbaseWs.onmessage = (event: any) => {
      const message = JSON.parse(event.data);
      const symbol = message.product_id?.replace("-", "");
      const price = message.price;
      if (prices[symbol]) {
        prices[symbol].Coinbase = price;
      }
      findMaxMin();
    };

    //Kraken------------------------------------------------------------------
    const krakenWs = new WebSocket("wss://ws.kraken.com/");
    krakenWs.onopen = () => {
      krakenWs.send(
        JSON.stringify({
          event: "subscribe",
          pair: ["BTC/USDT", "ETH/USDT", "XRP/USDT"],
          subscription: {
            name: "ticker",
          },
        })
      );
    };
    krakenWs.onmessage = (event: any) => {
      const message = JSON.parse(event.data);
      if (!("event" in message)) {
        let symbol = message[3].replace("/", "");
        const price = message[1]?.c[0];
        if (symbol.includes("XBT")) {
          symbol = symbol.replace("XBT", "BTC");
        }
        if (prices[symbol]) {
          prices[symbol].Kraken = price;
        }
      }
      findMaxMin();
    };

    //calculatePriceDifference---------------------------------------------------
    function findMaxMin() {
      for (let pair in prices) {
        let maxPrice = 0;
        let minPrice = Infinity;
        let maxExchange = "";
        let minExchange = "";
        for (let exchange in prices[pair]) {
          if (exchange !== "extremum") {
            if (prices[pair][exchange] > maxPrice) {
              maxPrice = prices[pair][exchange];
              maxExchange = exchange;
            }
            if (prices[pair][exchange] < minPrice) {
              minPrice = prices[pair][exchange];
              minExchange = exchange;
            }
          }
        }
        if (prices[pair]) {
          const extremum = {
            max: {
              exchange: maxExchange,
              price: maxPrice,
            },
            min: {
              exchange: minExchange,
              price: minPrice,
            },
            difference: [
              maxPrice - minPrice,
              100 - (minPrice * 100) / maxPrice,
            ],
          };
          prices[pair].extremum = extremum;
        }

      }
    }
  }, []);
  return (
    <>

    </>
  );
};

export default page;


```
Максимально оптимизируй этот код, что бы он работал очень быстро, и перепеши мне готовый вариант