49: Add high-level Jupiter position decrease operation
This commit is contained in:
@@ -132,6 +132,31 @@ public interface JupiterPerpsService {
|
|||||||
@NotNull SolanaSignedTransaction transaction
|
@NotNull SolanaSignedTransaction transaction
|
||||||
) throws IOException, InterruptedException;
|
) throws IOException, InterruptedException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decreases an existing Jupiter Perps position.
|
||||||
|
*
|
||||||
|
* <p>The service constructs the transaction, asks the supplied wallet to
|
||||||
|
* sign it, and submits it to Jupiter.</p>
|
||||||
|
*
|
||||||
|
* @param wallet the wallet that owns the position
|
||||||
|
* @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 Solana transaction signature
|
||||||
|
* @throws IllegalArgumentException if an amount, mint, or slippage value is invalid
|
||||||
|
* @throws IOException if the transaction cannot be constructed, signed, or submitted
|
||||||
|
* @throws InterruptedException if the calling thread is interrupted
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
ΩSolanaTransactionSignatureΩ executePositionDecrease(
|
||||||
|
@NotNull SolanaWallet wallet,
|
||||||
|
@NotNull ΩJupiterPerpsPositionAccountΩ positionAccount,
|
||||||
|
@NotNull ΩSPLMintAddressΩ receiveTokenMint,
|
||||||
|
@NotNull ΩUSDCAmountΩ sizeUsdDelta,
|
||||||
|
int maxSlippageBps
|
||||||
|
) throws IOException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an unsigned Solana transaction for decreasing
|
* Constructs an unsigned Solana transaction for decreasing
|
||||||
* an existing Jupiter Perps position.
|
* an existing Jupiter Perps position.
|
||||||
|
|||||||
+22
@@ -221,6 +221,28 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
|
|||||||
return response.txid();
|
return response.txid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull ΩSolanaTransactionSignatureΩ executePositionDecrease(
|
||||||
|
@NotNull SolanaWallet wallet,
|
||||||
|
@NotNull ΩJupiterPerpsPositionAccountΩ positionAccount,
|
||||||
|
@NotNull ΩSPLMintAddressΩ receiveTokenMint,
|
||||||
|
@NotNull ΩUSDCAmountΩ sizeUsdDelta,
|
||||||
|
int maxSlippageBps
|
||||||
|
) throws IOException, InterruptedException {
|
||||||
|
SolanaUnsignedTransaction unsignedTransaction =
|
||||||
|
buildPositionDecreaseTransaction(
|
||||||
|
positionAccount,
|
||||||
|
receiveTokenMint,
|
||||||
|
sizeUsdDelta,
|
||||||
|
maxSlippageBps
|
||||||
|
);
|
||||||
|
|
||||||
|
SolanaSignedTransaction signedTransaction =
|
||||||
|
wallet.signTransaction(unsignedTransaction);
|
||||||
|
|
||||||
|
return executePositionDecreaseTransaction(signedTransaction);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull SolanaUnsignedTransaction buildPositionDecreaseTransaction(
|
public @NotNull SolanaUnsignedTransaction buildPositionDecreaseTransaction(
|
||||||
@NotNull ΩJupiterPerpsPositionAccountΩ positionAccount,
|
@NotNull ΩJupiterPerpsPositionAccountΩ positionAccount,
|
||||||
|
|||||||
Reference in New Issue
Block a user