X: Add a lot of new fields to 'JupiterPerpsPostion'

This commit is contained in:
2026-07-04 16:25:05 +02:00
parent 24a05ff382
commit b989ab441d
2 changed files with 54 additions and 11 deletions
@@ -1,5 +1,7 @@
package com.r35157.libs.jupiter.perps;
import com.r35157.libs.valuetypes.basic.MoneyAmount;
import java.math.BigDecimal;
/**
@@ -10,18 +12,36 @@ import java.math.BigDecimal;
* position.</p>
*
* @param positionAccount the Solana account address of the Jupiter Perps position
* @param entryPrice the entry price of the position, denominated in USDC
* @param direction whether the position is long or short
* @param tradedTokenMint the mint address of the token being traded
* @param sizeUsd the size of this position in USD
* @param collateralUsd the amount of USD representing the collateral for this position
* @param direction whether the position is long or short
* @param value the amount the position is worth if closed now
* @param size the leveraged amount used to open the contracts
* @param pnl the amount in usd in profit or loss on this position
* @param pnlPercent the profit and loss represented as a percentage
* @param leverage TODO
* @param entryPrice the entry price of the position, denominated in USDC
* @param marketPrice the current spot price of the token
* @param collateral the amount of USD representing the collateral for this position
* @param totalFees the total amount of fees (TODO: is that including pending/due fees)
* @param borrowFeesDue the amount of USD that is currently outstanding
* @param closeFeePending the fee in USD for closing the account (TODO: multiple accounts - when adding collateral?)
* @param accountRent refundable amount locked for Solana account renting
*/
public record JupiterPerpsPosition(
ΩJupiterPerpsPositionAccountΩ positionAccount,
ΩUSDCPriceΩ entryPrice,
JupiterPerpsPositionDirection direction,
ΩSPLMintAddressΩ tradedTokenMint,
ΩUSDCAmountΩ sizeUsd,
ΩUSDCAmountΩ collateralUsd
JupiterPerpsPositionDirection direction,
ΩUSDCAmountΩ value,
ΩUSDCAmountΩ size,
ΩUSDCAmountΩ pnl,
BigDecimal pnlPercent,
BigDecimal leverage,
ΩUSDCPriceΩ entryPrice,
ΩUSDCPriceΩ marketPrice,
ΩUSDCAmountΩ collateral,
ΩUSDCAmountΩ totalFees,
ΩUSDCAmountΩ borrowFeesDue,
ΩUSDCAmountΩ closeFeePending,
ΩSolanaAmountΩ accountRent
) {
}
@@ -5,12 +5,16 @@ import com.r35157.libs.codec.impl.ref.Base58CodecImpl;
import com.r35157.libs.jupiter.perps.JupiterPerpsPosition;
import com.r35157.libs.jupiter.perps.JupiterPerpsPositionDirection;
import com.r35157.libs.solana.SolanaAccountInfo;
import com.r35157.libs.valuetypes.basic.MoneyAmount;
import com.r35157.libs.valuetypes.basic.WellKnownCurrencyTypes;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Base64;
import static java.math.BigDecimal.ZERO;
class AnchorIdlJupiterPerpsPositionDecoder {
JupiterPerpsPosition decode(
@@ -56,13 +60,32 @@ class AnchorIdlJupiterPerpsPositionDecoder {
.valueOf(rawSizeUsd)
.movePointLeft(6);
ΩUSDCAmountΩ value = ZERO; // TODO - Dummy
ΩUSDCAmountΩ pnl = ZERO; // TODO - Dummy
BigDecimal pnlPercent = ZERO; // TODO - Dummy
BigDecimal leverage = ZERO; // TODO - Dummy
ΩUSDCPriceΩ marketPrice = ZERO; // TODO - Dummy
ΩUSDCAmountΩ totalFees = ZERO; // TODO - Dummy
ΩUSDCAmountΩ borrowFeesDue = ZERO; // TODO - Dummy
ΩUSDCAmountΩ closeFeePending = ZERO; // TODO - Dummy
ΩSolanaAmountΩ accountRent = new MoneyAmount(ZERO, WellKnownCurrencyTypes.SOLANA.getCurrencyType()); // TODO - Dummy
JupiterPerpsPosition pos = new JupiterPerpsPosition(
positionAccount,
entryPrice,
direction,
tradedTokenMint,
direction,
value,
sizeUsd,
collateralUsd
pnl,
pnlPercent,
leverage,
entryPrice,
marketPrice,
collateralUsd,
totalFees,
borrowFeesDue,
closeFeePending,
accountRent
);
return pos;