diff --git a/src/main/java/markets/arcana/obcranker/ObCrankerApplication.java b/src/main/java/markets/arcana/obcranker/ObCrankerApplication.java index e3c4ec6..d693e35 100644 --- a/src/main/java/markets/arcana/obcranker/ObCrankerApplication.java +++ b/src/main/java/markets/arcana/obcranker/ObCrankerApplication.java @@ -50,41 +50,49 @@ public void crankEventHeapLoop() { Account finalTradingAccount = tradingAccount; scheduler.scheduleAtFixedRate(() -> { - // SOL/USDC - PublicKey marketId = PublicKey.valueOf("C3YPL3kYCSYKsmHcHrPWx1632GUXGqi2yMXJbfeCc57q"); - Optional transactionId = manager.consumeEvents( - finalTradingAccount, - marketId, - 8 - ); - - if (transactionId.isPresent()) { - log.info("Cranked events: {}", transactionId.get()); - } else { - log.info("No events found to consume."); - } - - }, 0, 5, TimeUnit.SECONDS); - - scheduler.scheduleAtFixedRate(() -> { - manager.cacheMarkets(); - for (OpenBookMarket market : manager.getOpenBookMarkets()) { + try { + // SOL/USDC + PublicKey marketId = PublicKey.valueOf("CFSMrBssNG8Ud1edW59jNLnq2cwrQ9uY5cM3wXmqRJj3"); Optional transactionId = manager.consumeEvents( finalTradingAccount, - market.getMarketId(), + marketId, 8 ); if (transactionId.isPresent()) { - log.info("Cranked events [{}]: {}", market.getName(), transactionId.get()); + log.info("Cranked events: {}", transactionId.get()); } else { log.info("No events found to consume."); } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - log.error("Error consuming: {}", e.getMessage()); + } catch (Exception ex) { + log.error("Error cranking SOL/USDC: {}", ex.getMessage(), ex); + } + + }, 0, 5, TimeUnit.SECONDS); + + scheduler.scheduleAtFixedRate(() -> { + try { + manager.cacheMarkets(); + for (OpenBookMarket market : manager.getOpenBookMarkets()) { + Optional transactionId = manager.consumeEvents( + finalTradingAccount, + market.getMarketId(), + 8 + ); + + if (transactionId.isPresent()) { + log.info("Cranked events [{}]: {}", market.getName(), transactionId.get()); + } else { + log.info("No events found to consume."); + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + log.error("Error consuming: {}", e.getMessage()); + } } + } catch (Exception ex) { + log.error("Error caching/cranking markets: {}", ex.getMessage(), ex); } }, 0, 60, TimeUnit.SECONDS); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f88ed2e..2b65b66 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,2 @@ -application.endpoint=https://mainnet.helius-rpc.com/?api-key=a778b653-bdd6-41bc-8cda-0c7377faf1dd +application.endpoint=RPC application.privateKey=privateKey.json \ No newline at end of file