A Position Decrease can currently reduce an open Jupiter Perps position completely to zero.
We need a configurable minimum remaining position size so Evelyn can retain part of the position.
The reserve must be based on the position's USD size, not its collateral amount.
For example:
Collateral: 1 USDC
Leverage: 10x
Size: 10 USD
The Position Decrease therefore represents a $10 reduction of the position size. It is this $10 size reduction that must be used when checking the reserve.
Configuration
Add a mandatory top-level configuration field:
RESERVE_POSITION_SIZE_USD_LIMIT 10
The value defines the minimum sizeUsd that must remain after a Position Decrease.
A value of 0 explicitly disables the reserve and permits the position to be reduced completely to zero.
Missing, duplicate or negative values must cause a clear configuration error.
Behavior
Before building, signing or submitting a Position Decrease transaction, calculate:
decreaseSizeUsd must be the resolved position size reduction derived from the configured collateral and leverage. The collateral amount alone must not be used for this check.
If the decrease would leave the position below the configured reserve, skip the entire action. Do not automatically reduce or otherwise modify the requested decrease amount.
Log a clear message containing:
The current position size
The requested position size decrease
The configured reserve
The resulting position size
Examples
With:
RESERVE_POSITION_SIZE_USD_LIMIT 10
Position size $30, decrease size $10 → continue; $20 remains.
Position size $15, decrease size $10 → skip; only $5 would remain.
Position size $10, decrease size $10 → skip; the position would be closed.
Acceptance criteria
RESERVE_POSITION_SIZE_USD_LIMIT is mandatory.
Zero is allowed and disables the reserve.
Negative values, duplicate definitions and missing values are rejected.
The check uses the decrease's calculated sizeUsd, including leverage.
The check uses the current position's sizeUsd, not its collateral.
A decrease leaving exactly the configured reserve is allowed.
A decrease leaving less than the reserve is skipped before any Jupiter transaction is built.
The requested decrease amount is never adjusted automatically.
Existing behavior is preserved when the reserve is explicitly set to zero.
The project compiles successfully.
## Background
A Position Decrease can currently reduce an open Jupiter Perps position completely to zero.
We need a configurable minimum remaining position size so Evelyn can retain part of the position.
The reserve must be based on the position's USD size, not its collateral amount.
For example:
```text
Collateral: 1 USDC
Leverage: 10x
Size: 10 USD
```
The Position Decrease therefore represents a `$10` reduction of the position size. It is this `$10` size reduction that must be used when checking the reserve.
## Configuration
Add a mandatory top-level configuration field:
```text
RESERVE_POSITION_SIZE_USD_LIMIT 10
```
The value defines the minimum `sizeUsd` that must remain after a Position Decrease.
A value of `0` explicitly disables the reserve and permits the position to be reduced completely to zero.
Missing, duplicate or negative values must cause a clear configuration error.
## Behavior
Before building, signing or submitting a Position Decrease transaction, calculate:
```text
remainingPositionSize =
currentPositionSizeUsd - decreaseSizeUsd
```
The decrease may only continue when:
```text
remainingPositionSize >= RESERVE_POSITION_SIZE_USD_LIMIT
```
This is equivalent to requiring:
```text
currentPositionSizeUsd >=
decreaseSizeUsd + RESERVE_POSITION_SIZE_USD_LIMIT
```
`decreaseSizeUsd` must be the resolved position size reduction derived from the configured collateral and leverage. The collateral amount alone must not be used for this check.
If the decrease would leave the position below the configured reserve, skip the entire action. Do not automatically reduce or otherwise modify the requested decrease amount.
Log a clear message containing:
* The current position size
* The requested position size decrease
* The configured reserve
* The resulting position size
## Examples
With:
```text
RESERVE_POSITION_SIZE_USD_LIMIT 10
```
* Position size `$30`, decrease size `$10` → continue; `$20` remains.
* Position size `$20`, decrease size `$10` → continue; exactly `$10` remains.
* Position size `$15`, decrease size `$10` → skip; only `$5` would remain.
* Position size `$10`, decrease size `$10` → skip; the position would be closed.
## Acceptance criteria
* `RESERVE_POSITION_SIZE_USD_LIMIT` is mandatory.
* Zero is allowed and disables the reserve.
* Negative values, duplicate definitions and missing values are rejected.
* The check uses the decrease's calculated `sizeUsd`, including leverage.
* The check uses the current position's `sizeUsd`, not its collateral.
* A decrease leaving exactly the configured reserve is allowed.
* A decrease leaving less than the reserve is skipped before any Jupiter transaction is built.
* The requested decrease amount is never adjusted automatically.
* Existing behavior is preserved when the reserve is explicitly set to zero.
* The project compiles successfully.
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
A Position Decrease can currently reduce an open Jupiter Perps position completely to zero.
We need a configurable minimum remaining position size so Evelyn can retain part of the position.
The reserve must be based on the position's USD size, not its collateral amount.
For example:
The Position Decrease therefore represents a
$10reduction of the position size. It is this$10size reduction that must be used when checking the reserve.Configuration
Add a mandatory top-level configuration field:
The value defines the minimum
sizeUsdthat must remain after a Position Decrease.A value of
0explicitly disables the reserve and permits the position to be reduced completely to zero.Missing, duplicate or negative values must cause a clear configuration error.
Behavior
Before building, signing or submitting a Position Decrease transaction, calculate:
The decrease may only continue when:
This is equivalent to requiring:
decreaseSizeUsdmust be the resolved position size reduction derived from the configured collateral and leverage. The collateral amount alone must not be used for this check.If the decrease would leave the position below the configured reserve, skip the entire action. Do not automatically reduce or otherwise modify the requested decrease amount.
Log a clear message containing:
Examples
With:
$30, decrease size$10→ continue;$20remains.$20, decrease size$10→ continue; exactly$10remains.$15, decrease size$10→ skip; only$5would remain.$10, decrease size$10→ skip; the position would be closed.Acceptance criteria
RESERVE_POSITION_SIZE_USD_LIMITis mandatory.sizeUsd, including leverage.sizeUsd, not its collateral.