+ Tip: Open the developer tools to view logs
+
+ );
+});
+
+async function initializeSparkOrderbook() {
+ const provider = await Provider.create(TESTNET_NETWORK);
+ const wallet = Wallet.fromPrivateKey(TEST_PRIVATE_KEY, provider);
+
+ const spark = new SparkOrderbook({
+ networkUrl: TESTNET_NETWORK,
+ contractAddresses: CONTRACT_ADDRESSES,
+ wallet,
+ });
+
+ spark.setActiveMarket(MARKET, INDEXER);
+ return spark;
+}
+
+// Subscription for active orders by type
+function subscribeActiveOrders(spark: SparkOrderbook, orderType: OrderType, market: string[], limit: number) {
+ // queryObject - ActiveBuyOrder | ActiveSellOrder
+ //
+ // subscription ${queryObject}Query(
+ // $limit: Int!
+ // $offset: Int!
+ // $where: ${queryObject}_bool_exp
+ // $priceOrder: order_by!
+ // ) {
+ // ${queryObject}(limit: $limit, offset: $offset, where: $where, order_by: { price: $priceOrder }) {
+ // id
+ // market
+ // tradeSize
+ // tradePrice
+ // buyer
+ // buyOrderId
+ // buyerBaseAmount
+ // buyerQuoteAmount
+ // seller
+ // sellOrderId
+ // sellerBaseAmount
+ // sellerQuoteAmount
+ // sellerIsMaker
+ // timestamp
+ // }
+ // }
+ const subscription = spark.subscribeActiveOrders