From 6c48e3741a76e60a1871bebefa764e2d82b9276a Mon Sep 17 00:00:00 2001 From: Minimons Date: Tue, 28 Jul 2026 21:20:53 +0200 Subject: [PATCH] 49: Hide low-level Jupiter position increase operations --- .../jupiter/perps/JupiterPerpsService.tjava | 108 ------------------ .../AnchorIdlJupiterPerpsServiceImpl.tjava | 12 +- 2 files changed, 4 insertions(+), 116 deletions(-) diff --git a/src/main/tjava/com/r35157/libs/jupiter/perps/JupiterPerpsService.tjava b/src/main/tjava/com/r35157/libs/jupiter/perps/JupiterPerpsService.tjava index 607bee5..37af1a7 100644 --- a/src/main/tjava/com/r35157/libs/jupiter/perps/JupiterPerpsService.tjava +++ b/src/main/tjava/com/r35157/libs/jupiter/perps/JupiterPerpsService.tjava @@ -1,8 +1,6 @@ package com.r35157.libs.jupiter.perps; import com.r35157.cryptowallet.solana.SolanaWallet; -import com.r35157.libs.solana.SolanaSignedTransaction; -import com.r35157.libs.solana.SolanaUnsignedTransaction; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -75,63 +73,6 @@ public interface JupiterPerpsService { int maxSlippageBps ) throws IOException, InterruptedException; - /** - * Constructs an unsigned Solana transaction for opening or increasing - * a Jupiter Perps position. - * - *

The transaction is constructed for the supplied wallet, traded asset, - * position direction, USDC collateral amount, position-size delta, and - * slippage limit.

- * - *

This method does not sign or submit the transaction and therefore does - * not modify blockchain state. The returned transaction must be signed by - * the supplied wallet and submitted separately.

- * - * @param owner the wallet that owns or will own the position - * @param tradedTokenMint the mint address of the asset being traded - * @param direction whether the position is long or short - * @param inputTokenAmount the amount of USDC to supply as collateral - * @param sizeUsdDelta the requested increase in position size, denominated in USD - * @param maxSlippageBps the maximum accepted slippage, in basis points - * @return the complete unsigned Solana transaction - * @throws IllegalArgumentException if an amount, mint, or slippage value is invalid - * @throws IOException if Jupiter cannot construct the transaction or its response - * cannot be decoded - * @throws InterruptedException if the calling thread is interrupted while - * communicating with Jupiter - */ - @NotNull SolanaUnsignedTransaction buildPositionIncreaseTransaction( - @NotNull ΩSolanaWalletIdΩ owner, - @NotNull ΩSPLMintAddressΩ tradedTokenMint, - @NotNull JupiterPerpsPositionDirection direction, - @NotNull ΩUSDCAmountΩ inputTokenAmount, - @NotNull ΩUSDCAmountΩ sizeUsdDelta, - int maxSlippageBps - ) throws IOException, InterruptedException; - - /** - * Executes a signed Jupiter Perps position-increase transaction. - * - *

The supplied transaction must previously have been constructed by - * {@link #buildPositionIncreaseTransaction} and signed by its required - * Solana wallet.

- * - *

Unlike the build method, this operation submits the transaction and - * may therefore modify blockchain state.

- * - * @param transaction the complete signed position-increase transaction - * @return the Solana transaction signature - * @throws IllegalArgumentException if the transaction is missing or blank - * @throws IOException if Jupiter rejects the transaction or its response - * cannot be decoded - * @throws InterruptedException if the calling thread is interrupted while - * communicating with Jupiter - */ - @NotNull - ΩSolanaTransactionSignatureΩ executePositionIncreaseTransaction( - @NotNull SolanaSignedTransaction transaction - ) throws IOException, InterruptedException; - /** * Decreases an existing Jupiter Perps position. * @@ -156,53 +97,4 @@ public interface JupiterPerpsService { @NotNull ΩUSDCAmountΩ sizeUsdDelta, int maxSlippageBps ) throws IOException, InterruptedException; - - /** - * Constructs an unsigned Solana transaction for decreasing - * an existing Jupiter Perps position. - * - *

This method does not sign or submit the transaction and therefore - * does not modify blockchain state. The returned transaction must be - * signed by the position owner's wallet and submitted separately.

- * - * @param positionAccount the Jupiter Perps position to decrease - * @param receiveTokenMint the mint address of the token to receive - * @param sizeUsdDelta the requested decrease in position size, denominated in USD - * @param maxSlippageBps the maximum accepted slippage, in basis points - * @return the complete unsigned Solana transaction - * @throws IllegalArgumentException if an amount, mint, or slippage value is invalid - * @throws IOException if Jupiter cannot construct the transaction or its response - * cannot be decoded - * @throws InterruptedException if the calling thread is interrupted while - * communicating with Jupiter - */ - @NotNull SolanaUnsignedTransaction buildPositionDecreaseTransaction( - @NotNull ΩJupiterPerpsPositionAccountΩ positionAccount, - @NotNull ΩSPLMintAddressΩ receiveTokenMint, - @NotNull ΩUSDCAmountΩ sizeUsdDelta, - int maxSlippageBps - ) throws IOException, InterruptedException; - - /** - * Executes a signed Jupiter Perps position-decrease transaction. - * - *

The supplied transaction must previously have been constructed by - * {@link #buildPositionDecreaseTransaction} and signed by its required - * Solana wallet.

- * - *

Unlike the build method, this operation submits the transaction and - * may therefore modify blockchain state.

- * - * @param transaction the complete signed position-decrease transaction - * @return the Solana transaction signature - * @throws IllegalArgumentException if the transaction is missing or blank - * @throws IOException if Jupiter rejects the transaction or its response - * cannot be decoded - * @throws InterruptedException if the calling thread is interrupted while - * communicating with Jupiter - */ - @NotNull - ΩSolanaTransactionSignatureΩ executePositionDecreaseTransaction( - @NotNull SolanaSignedTransaction transaction - ) throws IOException, InterruptedException; } diff --git a/src/main/tjava/com/r35157/libs/jupiter/perps/impl/anchoridl/AnchorIdlJupiterPerpsServiceImpl.tjava b/src/main/tjava/com/r35157/libs/jupiter/perps/impl/anchoridl/AnchorIdlJupiterPerpsServiceImpl.tjava index c3fac43..df6ff04 100644 --- a/src/main/tjava/com/r35157/libs/jupiter/perps/impl/anchoridl/AnchorIdlJupiterPerpsServiceImpl.tjava +++ b/src/main/tjava/com/r35157/libs/jupiter/perps/impl/anchoridl/AnchorIdlJupiterPerpsServiceImpl.tjava @@ -139,8 +139,7 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService { return executePositionIncreaseTransaction(signedTransaction); } - @Override - public @NotNull SolanaUnsignedTransaction buildPositionIncreaseTransaction( + private @NotNull SolanaUnsignedTransaction buildPositionIncreaseTransaction( @NotNull ΩSolanaWalletIdΩ owner, @NotNull ΩSPLMintAddressΩ tradedTokenMint, @NotNull JupiterPerpsPositionDirection direction, @@ -190,8 +189,7 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService { } } - @Override - public @NotNull ΩSolanaTransactionSignatureΩ + private @NotNull ΩSolanaTransactionSignatureΩ executePositionIncreaseTransaction( @NotNull SolanaSignedTransaction transaction ) throws IOException, InterruptedException { @@ -243,8 +241,7 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService { return executePositionDecreaseTransaction(signedTransaction); } - @Override - public @NotNull SolanaUnsignedTransaction buildPositionDecreaseTransaction( + private @NotNull SolanaUnsignedTransaction buildPositionDecreaseTransaction( @NotNull ΩJupiterPerpsPositionAccountΩ positionAccount, @NotNull ΩSPLMintAddressΩ receiveTokenMint, @NotNull ΩUSDCAmountΩ sizeUsdDelta, @@ -290,8 +287,7 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService { } } - @Override - public @NotNull ΩSolanaTransactionSignatureΩ + private @NotNull ΩSolanaTransactionSignatureΩ executePositionDecreaseTransaction( @NotNull SolanaSignedTransaction transaction ) throws IOException, InterruptedException {