20: Fetch open Perps positions JupiterPerpsEntryPriceVariableRefresher

This commit is contained in:
2026-06-28 11:36:05 +02:00
parent 520a0bcd92
commit 384fad01bf
@@ -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<JupiterPerpsPosition> 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<String, String> variables;