JupiterPerpsService currently supports increasing a position through:
buildPositionIncreaseTransaction(...)
executePositionIncreaseTransaction(...)
We need the corresponding API and implementation for decreasing an existing Jupiter Perps position.
A decrease is identified by the existing Jupiter Perps position account. Unlike an increase, the request therefore does not need the wallet address, traded asset, or position direction.
As with the existing increase flow, transaction signing remains the responsibility of a compatible wallet and is not performed by JupiterPerpsService.
Implementation
Implement the methods in AnchorIdlJupiterPerpsServiceImpl.
Building the transaction should call:
POST https://perps-api.jup.ag/v2/positions/decrease
The protocol request contains:
positionPubkey
receiveToken
sizeUsdDelta
maxSlippageBps
The response contains:
positionPubkey
serializedTxBase64
txMetadata
The returned serializedTxBase64, blockhash, and last valid block height should be exposed as a SolanaUnsignedTransaction, following the existing increase implementation.
Executing the signed transaction should use the existing transaction-execution endpoint:
POST https://perps-api.jup.ag/v2/transaction/execute
with the action:
decrease-position
Validation
The implementation should reject:
A missing position account
An unsupported receive-token mint
A position-size delta that is zero or negative
A slippage value outside the accepted basis-point range
Missing or blank serialized transactions
Jupiter responses without the required transaction or metadata fields
Scope
This issue covers partial position decreases only.
Closing an entire position using entirePosition = true, closing all positions, and wallet signing are outside the scope of this issue.
Acceptance criteria
JupiterPerpsService exposes both decrease methods.
A partial decrease transaction can be constructed as a SolanaUnsignedTransaction.
The transaction can be signed by the existing Solana wallet implementation.
A signed decrease transaction can be submitted through executePositionDecreaseTransaction(...).
The returned Solana transaction signature is exposed as ΩSolanaTransactionSignatureΩ.
Existing position-increase functionality continues to work.
## Background
`JupiterPerpsService` currently supports increasing a position through:
* `buildPositionIncreaseTransaction(...)`
* `executePositionIncreaseTransaction(...)`
We need the corresponding API and implementation for decreasing an existing Jupiter Perps position.
A decrease is identified by the existing Jupiter Perps position account. Unlike an increase, the request therefore does not need the wallet address, traded asset, or position direction.
## Proposed API
Add the following methods to `JupiterPerpsService`:
```java
@NotNull SolanaUnsignedTransaction buildPositionDecreaseTransaction(
@NotNull ΩJupiterPerpsPositionAccountΩ positionAccount,
@NotNull ΩSPLMintAddressΩ receiveTokenMint,
@NotNull ΩUSDCAmountΩ sizeUsdDelta,
int maxSlippageBps
) throws IOException, InterruptedException;
```
```java
@NotNull ΩSolanaTransactionSignatureΩ executePositionDecreaseTransaction(
@NotNull SolanaSignedTransaction transaction
) throws IOException, InterruptedException;
```
As with the existing increase flow, transaction signing remains the responsibility of a compatible wallet and is not performed by `JupiterPerpsService`.
## Implementation
Implement the methods in `AnchorIdlJupiterPerpsServiceImpl`.
Building the transaction should call:
```text
POST https://perps-api.jup.ag/v2/positions/decrease
```
The protocol request contains:
* `positionPubkey`
* `receiveToken`
* `sizeUsdDelta`
* `maxSlippageBps`
The response contains:
* `positionPubkey`
* `serializedTxBase64`
* `txMetadata`
The returned `serializedTxBase64`, blockhash, and last valid block height should be exposed as a `SolanaUnsignedTransaction`, following the existing increase implementation.
Executing the signed transaction should use the existing transaction-execution endpoint:
```text
POST https://perps-api.jup.ag/v2/transaction/execute
```
with the action:
```text
decrease-position
```
## Validation
The implementation should reject:
* A missing position account
* An unsupported receive-token mint
* A position-size delta that is zero or negative
* A slippage value outside the accepted basis-point range
* Missing or blank serialized transactions
* Jupiter responses without the required transaction or metadata fields
## Scope
This issue covers partial position decreases only.
Closing an entire position using `entirePosition = true`, closing all positions, and wallet signing are outside the scope of this issue.
## Acceptance criteria
* `JupiterPerpsService` exposes both decrease methods.
* A partial decrease transaction can be constructed as a `SolanaUnsignedTransaction`.
* The transaction can be signed by the existing Solana wallet implementation.
* A signed decrease transaction can be submitted through `executePositionDecreaseTransaction(...)`.
* The returned Solana transaction signature is exposed as `ΩSolanaTransactionSignatureΩ`.
* Existing position-increase functionality continues to work.
* The project compiles successfully.
## References
* https://github.com/jup-ag/cli/blob/main/src/clients/PerpsClient.ts
* https://github.com/jup-ag/cli/blob/main/docs/perps.md
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Background
JupiterPerpsServicecurrently supports increasing a position through:buildPositionIncreaseTransaction(...)executePositionIncreaseTransaction(...)We need the corresponding API and implementation for decreasing an existing Jupiter Perps position.
A decrease is identified by the existing Jupiter Perps position account. Unlike an increase, the request therefore does not need the wallet address, traded asset, or position direction.
Proposed API
Add the following methods to
JupiterPerpsService:As with the existing increase flow, transaction signing remains the responsibility of a compatible wallet and is not performed by
JupiterPerpsService.Implementation
Implement the methods in
AnchorIdlJupiterPerpsServiceImpl.Building the transaction should call:
The protocol request contains:
positionPubkeyreceiveTokensizeUsdDeltamaxSlippageBpsThe response contains:
positionPubkeyserializedTxBase64txMetadataThe returned
serializedTxBase64, blockhash, and last valid block height should be exposed as aSolanaUnsignedTransaction, following the existing increase implementation.Executing the signed transaction should use the existing transaction-execution endpoint:
with the action:
Validation
The implementation should reject:
Scope
This issue covers partial position decreases only.
Closing an entire position using
entirePosition = true, closing all positions, and wallet signing are outside the scope of this issue.Acceptance criteria
JupiterPerpsServiceexposes both decrease methods.SolanaUnsignedTransaction.executePositionDecreaseTransaction(...).ΩSolanaTransactionSignatureΩ.References