X: More logging

This commit is contained in:
2026-08-05 10:12:38 +02:00
parent 5c9f6251e5
commit e0713c9121
3 changed files with 18 additions and 1 deletions
@@ -18,9 +18,11 @@ public final class JupiterPerpsAlarmImpl {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Config config; Config config;
System.out.println("Starting Jupiter Perps Alarms...");
try { try {
System.out.print("Parsing commandline parameters... ");
config = Config.parse(args, System.getenv()); config = Config.parse(args, System.getenv());
System.out.println("Done.");
} catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) {
printUsage(); printUsage();
String errMsg = "Could not parse configuration for JupiterPerpsAlarm: " + exception.getMessage() + "!"; String errMsg = "Could not parse configuration for JupiterPerpsAlarm: " + exception.getMessage() + "!";
@@ -31,7 +33,9 @@ public final class JupiterPerpsAlarmImpl {
AlarmConfiguration alarmConfiguration; AlarmConfiguration alarmConfiguration;
try { try {
System.out.print("Parsing alarm configuration... ");
alarmConfiguration = AlarmConfigurationParser.parse(config.alarmConfiguration()); alarmConfiguration = AlarmConfigurationParser.parse(config.alarmConfiguration());
System.out.println("Done.");
definitions = alarmConfiguration.definitions(); definitions = alarmConfiguration.definitions();
} catch (Exception exception) { } catch (Exception exception) {
String errMsg = "Could not load alarm configuration: " + exception.getMessage() + "!"; String errMsg = "Could not load alarm configuration: " + exception.getMessage() + "!";
@@ -42,11 +46,16 @@ public final class JupiterPerpsAlarmImpl {
alarmConfiguration.variables() alarmConfiguration.variables()
); );
System.out.print("Initializing dependecies... ");
SolanaBlockChain solanaBlockChain = new SolanaBlockChainImpl(); SolanaBlockChain solanaBlockChain = new SolanaBlockChainImpl();
JupiterPerpsService jupiterPerpsService = new AnchorIdlJupiterPerpsServiceImpl(solanaBlockChain); JupiterPerpsService jupiterPerpsService = new AnchorIdlJupiterPerpsServiceImpl(solanaBlockChain);
JupiterPerpsEntryPriceVariableRefresher entryPriceVariableRefresher = JupiterPerpsEntryPriceVariableRefresher entryPriceVariableRefresher =
new JupiterPerpsEntryPriceVariableRefresher(alarmConfiguration.variables(), jupiterPerpsService); new JupiterPerpsEntryPriceVariableRefresher(alarmConfiguration.variables(), jupiterPerpsService);
System.out.println("Done.");
System.out.println("Executing first pre-run data fetch:");
entryPriceVariableRefresher.refresh(); entryPriceVariableRefresher.refresh();
System.out.println("Fetching done.");
JupiterPerpsEntryPriceVariableRefreshWatcher entryPriceVariableRefreshWatcher = JupiterPerpsEntryPriceVariableRefreshWatcher entryPriceVariableRefreshWatcher =
new JupiterPerpsEntryPriceVariableRefreshWatcher( new JupiterPerpsEntryPriceVariableRefreshWatcher(
@@ -27,6 +27,7 @@ public final class JupiterPerpsEntryPriceVariableRefresher {
} }
try { try {
System.out.println(" Fetching 'Open Positions':");
Set<JupiterPerpsPosition> positions = jupiterPerpsService.getOpenPositions(wallet); Set<JupiterPerpsPosition> positions = jupiterPerpsService.getOpenPositions(wallet);
System.out.println( System.out.println(
@@ -73,6 +73,7 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
Set<JupiterPerpsPosition> positions = new HashSet<>(); Set<JupiterPerpsPosition> positions = new HashSet<>();
for (SolanaAccountInfo accountInfo : accountInfos) { for (SolanaAccountInfo accountInfo : accountInfos) {
System.out.println(" Found " + accountInfos.size() + " postion candidates...");
ΩSolanaProgramIdΩ programId = accountInfo.owner(); ΩSolanaProgramIdΩ programId = accountInfo.owner();
ΩJupiterPerpsPositionAccountΩ positionAccount = accountInfo.address(); ΩJupiterPerpsPositionAccountΩ positionAccount = accountInfo.address();
@@ -104,7 +105,9 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
) throws IOException, InterruptedException { ) throws IOException, InterruptedException {
ΩJupiterPerpsCustodyAccountAddressΩ custodyAccountAddress = perpsPositionInfo.custodyAccountAddress(); ΩJupiterPerpsCustodyAccountAddressΩ custodyAccountAddress = perpsPositionInfo.custodyAccountAddress();
System.out.print(" Getting account info for: " + custodyAccountAddress + "...");
ΩJupiterCustodyAccountInfoEncodedΩ encodedCustodyAccountInfo = solanaBlockChain.getAccountInfo(custodyAccountAddress); ΩJupiterCustodyAccountInfoEncodedΩ encodedCustodyAccountInfo = solanaBlockChain.getAccountInfo(custodyAccountAddress);
System.out.println(" Done.");
if (encodedCustodyAccountInfo == null) { if (encodedCustodyAccountInfo == null) {
String errorMsg = "Jupiter Perps custody account does not exist: " + custodyAccountAddress; String errorMsg = "Jupiter Perps custody account does not exist: " + custodyAccountAddress;
@@ -118,14 +121,17 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
ΩJupiterPerpsCollateralCustodyAccountAddressΩ collateralCustodyAccountAddress = ΩJupiterPerpsCollateralCustodyAccountAddressΩ collateralCustodyAccountAddress =
perpsPositionInfo.collateralCustodyAccountAddress(); perpsPositionInfo.collateralCustodyAccountAddress();
System.out.print(" Getting collateral custody account Info for: " + custodyAccountAddress + "...");
ΩJupiterCustodyAccountInfoEncodedΩ encodedCollateralCustodyAccountInfo = ΩJupiterCustodyAccountInfoEncodedΩ encodedCollateralCustodyAccountInfo =
solanaBlockChain.getAccountInfo(collateralCustodyAccountAddress); solanaBlockChain.getAccountInfo(collateralCustodyAccountAddress);
System.out.println(" Done.");
if (encodedCollateralCustodyAccountInfo == null) { if (encodedCollateralCustodyAccountInfo == null) {
String errorMsg = "Jupiter Perps collateral custody account does not exist: " + collateralCustodyAccountAddress; String errorMsg = "Jupiter Perps collateral custody account does not exist: " + collateralCustodyAccountAddress;
throw new IllegalArgumentException(errorMsg); throw new IllegalArgumentException(errorMsg);
} }
System.out.print(" Calculating fiels in position...");
JupiterCustodyAccountInfo collateralCustodyAccountInfo = JupiterCustodyAccountInfo collateralCustodyAccountInfo =
custodyDecoder.decode(encodedCollateralCustodyAccountInfo); custodyDecoder.decode(encodedCollateralCustodyAccountInfo);
@@ -174,6 +180,7 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
accountRent accountRent
); );
System.out.println(" Done.");
return pos; return pos;
} }