22: Broken

This commit is contained in:
2026-06-30 19:09:42 +02:00
parent efd340961d
commit 12f2612bfa
2 changed files with 24 additions and 2 deletions
@@ -8,6 +8,7 @@ import com.r35157.libs.solana.SolanaAccountInfo;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Base64;
@@ -57,7 +58,15 @@ public class AnchorIdlJupiterPerpsPositionDecoder {
.valueOf(rawSizeUsd)
.movePointLeft(6);
BigInteger cumulativeInterestSnapshot = decodeCumulativeInterestSnapshot(accountInfo);
AnchorIdlJupiterPerpsCustodyDecoder custodyDecoder = new AnchorIdlJupiterPerpsCustodyDecoder();
BigInteger currentCumulativeInterestRate = custodyDecoder.decodeCurrentCumulativeInterestRate(collateralCustodyAccountInfo);
BigInteger cumulativeInterestSnapshot = decodeCumulativeInterestSnapshot(positionAccountInfo);
BigInteger difference = currentCumulativeInterestRate.subtract(cumulativeInterestSnapshot);
ΩUSDCAmountΩ borrowFeeUsd =
new BigDecimal(difference)
.multiply(sizeUsd)
.divide(BigDecimal.valueOf(1_000_000_000L), 6, RoundingMode.CEILING);
JupiterPerpsPosition pos = new JupiterPerpsPosition(
positionAccount,
@@ -65,7 +74,8 @@ public class AnchorIdlJupiterPerpsPositionDecoder {
direction,
tradedTokenMint,
sizeUsd,
collateralUsd
collateralUsd,
borrowFeeUsd
);
return pos;
@@ -14,10 +14,14 @@ import java.lang.management.ClassLoadingMXBean;
import java.lang.management.ManagementFactory;
import com.r35157.libs.jupiter.perps.impl.anchoridl.AnchorIdlJupiterPerpsCustodyDecoder;
import com.r35157.libs.solana.SolanaAccountInfo;
import java.math.BigDecimal;
import java.math.BigInteger;
import com.r35157.nenjim.hubd.ctx.ContextManager;
import com.r35157.nenjim.hubd.journal.JournalManager;
import com.r35157.nenjim.hubd.impl.ref.JournalManagerImpl;
import java.math.RoundingMode;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Set;
@@ -49,6 +53,14 @@ public class Main {
System.out.println("currentCumulativeInterestRate: " + currentCumulativeInterestRate);
System.out.println("cumulativeInterestSnapshot: " + cumulativeInterestSnapshot);
System.out.println("difference: " + difference);
BigDecimal borrowFeeUsdCandidate =
new BigDecimal(difference)
.multiply(position.sizeUsd())
.divide(BigDecimal.valueOf(1_000_000_000L), 6, RoundingMode.CEILING);
System.out.println("borrowFeeUsdCandidate: " + borrowFeeUsdCandidate);
System.out.println();
}