From 12f2612bfa3dd8ce357d750a2c5d49b519223dc29a1d09da2421f3bab82635a8 Mon Sep 17 00:00:00 2001 From: Minimons Date: Tue, 30 Jun 2026 19:09:42 +0200 Subject: [PATCH] 22: Broken --- .../AnchorIdlJupiterPerpsPositionDecoder.tjava | 14 ++++++++++++-- .../com/r35157/nenjim/hubd/impl/ref/Main.tjava | 12 ++++++++++++ 2 files changed, 24 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 288e5e2..bdca852 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 @@ -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; diff --git a/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/Main.tjava b/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/Main.tjava index 61be688..04d6647 100644 --- a/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/Main.tjava +++ b/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/Main.tjava @@ -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(); }