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