22: Add method decodeCumulativeInterestSnapshot

This commit is contained in:
2026-06-30 15:18:44 +02:00
parent d2cce123b9
commit a7858ff3fd
@@ -62,8 +62,6 @@ class AnchorIdlJupiterPerpsPositionDecoder {
CUMULATIVE_INTEREST_SNAPSHOT_OFFSET
);
System.out.println("cumulativeInterestSnapshot = " + cumulativeInterestSnapshot);
JupiterPerpsPosition pos = new JupiterPerpsPosition(
positionAccount,
entryPrice,
@@ -76,6 +74,22 @@ class AnchorIdlJupiterPerpsPositionDecoder {
return pos;
}
BigInteger decodeCumulativeInterestSnapshot(SolanaAccountInfo accountInfo) {
byte[] data = Base64.getDecoder().decode(accountInfo.dataBase64());
if (data.length < CUMULATIVE_INTEREST_SNAPSHOT_OFFSET + U128_LENGTH) {
throw new IllegalArgumentException(
"Jupiter Perps position account data is too short: " + data.length
);
}
BigInteger value = readU128(
data,
CUMULATIVE_INTEREST_SNAPSHOT_OFFSET
);
return value;
}
ΩSolanaAddressΩ decodeCustodyAccount(SolanaAccountInfo accountInfo) {
byte[] data = Base64.getDecoder().decode(accountInfo.dataBase64());