49: Hide low-level Jupiter position increase operations

This commit is contained in:
2026-08-05 10:12:39 +02:00
parent 2a64809d97
commit 6c48e3741a
2 changed files with 4 additions and 116 deletions
@@ -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.
*
* <p>The transaction is constructed for the supplied wallet, traded asset,
* position direction, USDC collateral amount, position-size delta, and
* slippage limit.</p>
*
* <p>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.</p>
*
* @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.
*
* <p>The supplied transaction must previously have been constructed by
* {@link #buildPositionIncreaseTransaction} and signed by its required
* Solana wallet.</p>
*
* <p>Unlike the build method, this operation submits the transaction and
* may therefore modify blockchain state.</p>
*
* @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.
*
* <p>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.</p>
*
* @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.
*
* <p>The supplied transaction must previously have been constructed by
* {@link #buildPositionDecreaseTransaction} and signed by its required
* Solana wallet.</p>
*
* <p>Unlike the build method, this operation submits the transaction and
* may therefore modify blockchain state.</p>
*
* @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;
}
@@ -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 {