From 41fdf09b7b4253fcc762c4dcbb1b061cd6f766b7af36cd59d87e625efc35c187 Mon Sep 17 00:00:00 2001 From: Minimons Date: Tue, 30 Jun 2026 15:18:44 +0200 Subject: [PATCH] 22: Add method decodeCumulativeInterestSnapshot --- .../AnchorIdlJupiterPerpsPositionDecoder.tjava | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/tjava/com/r35157/libs/jupiter/perps/impl/anchoridl/AnchorIdlJupiterPerpsPositionDecoder.tjava b/src/main/tjava/com/r35157/libs/jupiter/perps/impl/anchoridl/AnchorIdlJupiterPerpsPositionDecoder.tjava index 89313c5..123f097 100644 --- a/src/main/tjava/com/r35157/libs/jupiter/perps/impl/anchoridl/AnchorIdlJupiterPerpsPositionDecoder.tjava +++ b/src/main/tjava/com/r35157/libs/jupiter/perps/impl/anchoridl/AnchorIdlJupiterPerpsPositionDecoder.tjava @@ -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());