diff --git a/src/main/tjava/com/r35157/jupiterperpsalarm/impl/ref/JupiterPerpsEntryPriceVariableRefresher.tjava b/src/main/tjava/com/r35157/jupiterperpsalarm/impl/ref/JupiterPerpsEntryPriceVariableRefresher.tjava index 1236363..b5ad44e 100644 --- a/src/main/tjava/com/r35157/jupiterperpsalarm/impl/ref/JupiterPerpsEntryPriceVariableRefresher.tjava +++ b/src/main/tjava/com/r35157/jupiterperpsalarm/impl/ref/JupiterPerpsEntryPriceVariableRefresher.tjava @@ -1,9 +1,12 @@ package com.r35157.jupiterperpsalarm.impl.ref; +import com.r35157.libs.jupiter.perps.JupiterPerpsPosition; import com.r35157.libs.jupiter.perps.JupiterPerpsService; +import java.io.IOException; import java.util.Map; import java.util.Objects; +import java.util.Set; public final class JupiterPerpsEntryPriceVariableRefresher { @@ -16,14 +19,30 @@ public final class JupiterPerpsEntryPriceVariableRefresher { } public void refresh() { - String wallet = variables.get("JUPITER_PERPS_WALLET"); + ΩSolanaWalletIdΩ wallet = variables.get("JUPITER_PERPS_WALLET"); if (wallet == null || wallet.isBlank()) { System.err.println("Cannot refresh Jupiter Perps entry price variables: JUPITER_PERPS_WALLET is not configured"); return; } - System.out.println("Jupiter Perps entry price variable refresh requested for wallet: " + wallet); + try { + Set positions = jupiterPerpsService.getOpenPositions(wallet); + + System.out.println( + "Fetched " + positions.size() + + " open Jupiter Perps positions for wallet: " + wallet + ); + } catch (IOException | InterruptedException exception) { + if (exception instanceof InterruptedException) { + Thread.currentThread().interrupt(); + } + + System.err.println( + "Could not refresh Jupiter Perps entry price variables: " + + exception.getMessage() + ); + } } private final Map variables;