Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.parquet.exchange/llms.txt

Use this file to discover all available pages before exploring further.

Why manage margin

Once a position is open, you can adjust the collateral backing it without closing and reopening. There are two reasons you might want to:
  • Add margin to lower liquidation risk — more collateral pushes your liquidation price further away from the mark.
  • Remove margin to free wallet collateral when the position is comfortably in profit and you want to redeploy capital.
Both flows use a single on-chain instruction: update_position_margin(amount, direction), signed by the position owner. direction selects add or remove; amount is the USDC delta in 6-decimal base units.
Margin updates require a fresh oracle read and therefore revert outside US Regular Trading Hours. You cannot top up a position over the weekend or at 3 a.m. ET — the oracle_adapter CPI returns PriceStale. If a position is approaching liquidation into the close, add buffer before 16:00 ET on Friday or accept that the next opportunity is 09:30 ET Monday.

Adds are always allowed

Adding margin is straightforward. The only constraint is your wallet USDC balance — the instruction transfers from your token account into the position’s vault PDA. New collateral lifts your effective equity directly, which moves the liquidation price away from current mark. There is no upper bound and no health check needed on the add path: more collateral can only make a position safer.

Removes are gated by a PnL-aware health check

Removal runs the same check liquidate uses. After the proposed removal, the position’s health must still exceed the maintenance margin requirement (health > MMR, where MMR = 20 bps). The math — including how unrealized PnL feeds in — is documented in Liquidations. If the requested removal would drop health to or below MMR, the instruction fails before any tokens move. You cannot accidentally remove yourself into a liquidatable state.
If you want to take profit but keep the position open, partial close is usually cleaner than removing margin — it locks in PnL and reduces size proportionally, rather than just thinning the buffer.

Min collateral floor

Even when the health check passes, removal cannot take collateral below MIN_COLLATERAL_USDC = $10. The instruction fails with BelowMinCollateral (error code 2006).
ConstantValueBehavior on breach
MIN_COLLATERAL_USDC$10 (10_000_000 base units)update_position_margin reverts with BelowMinCollateral (code 2006)
This floor exists to keep dust positions from clogging the keeper’s liquidation queue. If you want to go below $10 of collateral, close the position instead.

v4 quirk: queue-drawn collateral

Under the v4 LP payout queue, a position’s collateral can be partly drawn from the queue rather than from the trader’s wallet. The position account tracks this split via position.collateral_from_queue. When you remove margin, the instruction pulls from the wallet portion first and only touches the queue-drawn portion once the wallet portion is exhausted. This protects queue claims from being silently withdrawn through a margin remove.
If your position has no queue-drawn collateral (collateral_from_queue == 0), this rule has no effect — every removal comes from your wallet portion as expected. See Payout queue for the full picture on how queue-drawn collateral enters a position.