49: Hide low-level Jupiter position increase operations
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
package com.r35157.libs.jupiter.perps;
|
package com.r35157.libs.jupiter.perps;
|
||||||
|
|
||||||
import com.r35157.cryptowallet.solana.SolanaWallet;
|
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.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -75,63 +73,6 @@ public interface JupiterPerpsService {
|
|||||||
int maxSlippageBps
|
int maxSlippageBps
|
||||||
) throws IOException, InterruptedException;
|
) 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.
|
* Decreases an existing Jupiter Perps position.
|
||||||
*
|
*
|
||||||
@@ -156,53 +97,4 @@ public interface JupiterPerpsService {
|
|||||||
@NotNull ΩUSDCAmountΩ sizeUsdDelta,
|
@NotNull ΩUSDCAmountΩ sizeUsdDelta,
|
||||||
int maxSlippageBps
|
int maxSlippageBps
|
||||||
) throws IOException, InterruptedException;
|
) 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;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-8
@@ -139,8 +139,7 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
|
|||||||
return executePositionIncreaseTransaction(signedTransaction);
|
return executePositionIncreaseTransaction(signedTransaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private @NotNull SolanaUnsignedTransaction buildPositionIncreaseTransaction(
|
||||||
public @NotNull SolanaUnsignedTransaction buildPositionIncreaseTransaction(
|
|
||||||
@NotNull ΩSolanaWalletIdΩ owner,
|
@NotNull ΩSolanaWalletIdΩ owner,
|
||||||
@NotNull ΩSPLMintAddressΩ tradedTokenMint,
|
@NotNull ΩSPLMintAddressΩ tradedTokenMint,
|
||||||
@NotNull JupiterPerpsPositionDirection direction,
|
@NotNull JupiterPerpsPositionDirection direction,
|
||||||
@@ -190,8 +189,7 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private @NotNull ΩSolanaTransactionSignatureΩ
|
||||||
public @NotNull ΩSolanaTransactionSignatureΩ
|
|
||||||
executePositionIncreaseTransaction(
|
executePositionIncreaseTransaction(
|
||||||
@NotNull SolanaSignedTransaction transaction
|
@NotNull SolanaSignedTransaction transaction
|
||||||
) throws IOException, InterruptedException {
|
) throws IOException, InterruptedException {
|
||||||
@@ -243,8 +241,7 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
|
|||||||
return executePositionDecreaseTransaction(signedTransaction);
|
return executePositionDecreaseTransaction(signedTransaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private @NotNull SolanaUnsignedTransaction buildPositionDecreaseTransaction(
|
||||||
public @NotNull SolanaUnsignedTransaction buildPositionDecreaseTransaction(
|
|
||||||
@NotNull ΩJupiterPerpsPositionAccountΩ positionAccount,
|
@NotNull ΩJupiterPerpsPositionAccountΩ positionAccount,
|
||||||
@NotNull ΩSPLMintAddressΩ receiveTokenMint,
|
@NotNull ΩSPLMintAddressΩ receiveTokenMint,
|
||||||
@NotNull ΩUSDCAmountΩ sizeUsdDelta,
|
@NotNull ΩUSDCAmountΩ sizeUsdDelta,
|
||||||
@@ -290,8 +287,7 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private @NotNull ΩSolanaTransactionSignatureΩ
|
||||||
public @NotNull ΩSolanaTransactionSignatureΩ
|
|
||||||
executePositionDecreaseTransaction(
|
executePositionDecreaseTransaction(
|
||||||
@NotNull SolanaSignedTransaction transaction
|
@NotNull SolanaSignedTransaction transaction
|
||||||
) throws IOException, InterruptedException {
|
) throws IOException, InterruptedException {
|
||||||
|
|||||||
Reference in New Issue
Block a user