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.
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.
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 checkliquidate 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.
Min collateral floor
Even when the health check passes, removal cannot take collateral belowMIN_COLLATERAL_USDC = $10. The instruction fails with BelowMinCollateral
(error code 2006).
| Constant | Value | Behavior on breach |
|---|---|---|
MIN_COLLATERAL_USDC | $10 (10_000_000 base units) | update_position_margin reverts with BelowMinCollateral (code 2006) |
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 viaposition.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.