22: Add method decodeCumulativeInterestSnapshot
This commit is contained in:
+16
-2
@@ -62,8 +62,6 @@ class AnchorIdlJupiterPerpsPositionDecoder {
|
|||||||
CUMULATIVE_INTEREST_SNAPSHOT_OFFSET
|
CUMULATIVE_INTEREST_SNAPSHOT_OFFSET
|
||||||
);
|
);
|
||||||
|
|
||||||
System.out.println("cumulativeInterestSnapshot = " + cumulativeInterestSnapshot);
|
|
||||||
|
|
||||||
JupiterPerpsPosition pos = new JupiterPerpsPosition(
|
JupiterPerpsPosition pos = new JupiterPerpsPosition(
|
||||||
positionAccount,
|
positionAccount,
|
||||||
entryPrice,
|
entryPrice,
|
||||||
@@ -76,6 +74,22 @@ class AnchorIdlJupiterPerpsPositionDecoder {
|
|||||||
return pos;
|
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) {
|
ΩSolanaAddressΩ decodeCustodyAccount(SolanaAccountInfo accountInfo) {
|
||||||
byte[] data = Base64.getDecoder().decode(accountInfo.dataBase64());
|
byte[] data = Base64.getDecoder().decode(accountInfo.dataBase64());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user