Dydx exchange is a venue for reduce-only trims and complete closes
Dydx exchange is a decentralized perpetuals venue where a reduce-only order subtracts from an existing position and stops at zero. A long requires a sell, and a short requires a buy. The order never adds exposure or crosses into the opposite side. On the current dYdX interface, reduce-only execution uses Immediate-or-Cancel (IOC), so any amount that does not fill immediately leaves the order book as a canceled remainder.
Filled size determines the cost of reducing exposure
Reduce-only execution costs are taker-side trading costs because IOC orders immediately match resting liquidity.
dYdX Chain separates two fee roles: makers add orders to the book, while takers remove that liquidity. A reduce-only order must use Immediate-or-Cancel, so its executed amount occupies the taker role even when the user selects a limit price. The applicable tier comes from trailing 30-day USD trading volume across perpetual markets. Governance controls the schedule, so a durable calculation uses the displayed taker rate multiplied by filled notional. USDC supplies the common quote and collateral denomination in the account view. The Portfolio fee view shows the live tier applied to the account.
An IOC close splits the request into at most two pieces: the filled amount and the canceled remainder. The filled piece incurs the trading fee, while the canceled piece incurs zero trading fee. Under default dYdX Chain settings, trade submission also adds zero separate gas charge for the trader.
The cost formula has three inputs: fill price, filled size, and the applicable taker rate. Requested size matters only to the extent that it matches. This keeps fee arithmetic tied to the execution record rather than the original close instruction.
Can a reduce-only order reverse a dYdX position?
A reduce-only order is an execution constraint that stops a dYdX position at zero instead of crossing through it.
The protocol keeps one net perpetual position for each market within each subaccount. That position has one of two directions while open: long or short. The protocol applies two protections: a reduce-only fill cannot increase absolute position size, and it cannot change the position side. These checks use the position at execution, not the size at entry. A full close therefore targets 100% of the remaining absolute size, and a successful complete fill leaves a position size of zero. The current interface runs both tests before submitting a direct close.
- A sell order reduces a long position.
- A buy order against a long fails the guard.
- A buy order reduces a short position.
- A sell order against a short fails the guard.
The current interface also compares a direct market or limit order with the remaining exposure. It rejects an oversized direct close rather than letting the order cross zero. Conditional stops and take-profit orders follow a different sizing path because the protocol reevaluates them when their trigger activates.
Immediate-or-cancel turns every reduction into a short-lived instruction
Immediate-or-Cancel is a time-in-force rule that matches available orders now and discards every unmatched unit.
The order message carries a Boolean reduce-only field alongside its time-in-force setting. The protocol encodes IOC as time-in-force value 1, while default and post-only use values 0 and 2. Fill-or-Kill remains the deprecated value 3 and fails current placement validation. A reduce-only request therefore pairs the Boolean with IOC. Good-Til-Time would leave an order resting on the book, so the current implementation does not accept that pairing for reduce-only execution.
IOC produces at most two execution outcomes within one request: a fill and a canceled balance. A market close matches the best available resting prices until its IOC quantity stops filling. A limit close matches only at its limit price or better. Neither leaves residual maker liquidity, so the refreshed position determines whether another reduction is needed.
What happens when a conditional close exceeds the open position?
A conditional reduce-only order is a stored trigger that gets capped at the remaining position size before execution.
The dYdX interface exposes six order types, including four conditional variants: Stop Market, Stop Limit, Take Profit Market, and Take Profit Limit. Those four variants belong to two condition families, stop loss and take profit. Each conditional order carries one trigger price. The market variants execute against available book liquidity after activation, while the limit variants also apply a separate limit price. Reduce-only remains disabled by default when a trader creates these conditional orders.
The interface accepts a conditional reduce-only size above the current position. When the trigger fires, the software compares that size with the exposure still open and reduces the executable quantity to the smaller amount. A prior manual trim therefore does not let the later conditional order reverse the position. If the position already stands at zero, no quantity remains for that IOC output to reduce. A companion page walks through Exchange details.
Seven stages from entry fill to confirmed exit
The position lifecycle is a seven-stage sequence that starts with one fill and ends with refreshed indexed state.
Within the Dydx exchange workflow, the dYdX Indexer supplies the readable position and fill records, while validators handle signed order execution. Position status alone is insufficient during a fresh update. Side, absolute size, order status, and filled amount should describe the same event before the next adjustment uses them.
| Stage | Resulting status | Required beforehand |
|---|---|---|
| 1. Enter the market | Position becomes OPEN with signed size | Funded subaccount and executable market |
| 2. Read the position | Side and current size become visible | Confirmed entry fill and fresh Indexer data |
| 3. Set the reduction | Target size stays within open exposure | Current absolute position size |
| 4. Choose the order side | Sell opposes long; buy opposes short | Recorded position direction |
| 5. Configure the exit | Reduce-only and IOC govern execution | Compatible direct or conditional order |
| 6. Submit and match | Filled quantity trims the position | Opposing order-book liquidity |
| 7. Reconcile the outcome | Position remains OPEN or reaches CLOSED | Fill record and refreshed position data |
| Summary | Entry, reading, adjustment, and close form one lifecycle | Accurate current size at every action |
The sequence separates intent from state. Submission marks stage 6, while the updated balance completes stage 7. A trader who wants another trim starts again from the newly indexed size, keeping every later order anchored to the position that still exists.
Partial fills leave a smaller position and a canceled remainder
Partial filling is an execution outcome that reduces the open balance only by the quantity that actually matched. Three values then matter: requested size, filled size, and remaining position size. Validators cancel the unmatched IOC remainder, while the dYdX Indexer records the fill and refreshed position separately. A routine adjustment starts from the new absolute position size. The next instruction therefore belongs after the refreshed balance appears, when its quantity reflects the position that remains.
Net-position management suits deliberate trims and complete exits
Net-position management is a workflow for traders and software that maintain one directional exposure per market and subaccount.
Day to day, dYdX Chain runs as a sovereign application built with Cosmos SDK and CometBFT, while USDC supplies the account's quote and collateral unit. The same reduce-only relationship applies to symbols such as BTC-USD, ETH-USD, and SOL-USD: sell to reduce a long, or buy to reduce a short. The guard always evaluates the specific market and subaccount carried by the order. That separation matters when one wallet operates several subaccounts because identical symbols do not merge their balances.
Automation uses the dYdX Indexer for reads and the dYdX TypeScript, Python, or Rust clients for signed writes. Those three client paths expose the same core order fields. An OrderId has four coordinates: subaccount ID, client ID, order flags, and CLOB pair ID. The client ID occupies a 32-bit field, while size and price use two 64-bit integer fields. Exact market step sizes still control valid increments.
The workflow fits planned scaling out, complete manual closes, and conditional exits that respect a changing position balance. Its operating boundary is immediate order-book liquidity and the chosen limit, making refreshed position data the final measure of every reduction.
Common questions
-
Does the Close Position control enable reduce-only automatically?
- Yes, the dYdX Close Position control submits a market order with reduce-only enabled. The simplified iOS close flow also defaults its amount to 100% of the open position, while the percentage selector supports a smaller reduction. The resulting IOC order fills against available liquidity, and validators cancel any unmatched remainder. Confirm the updated position size after the fill rather than treating submission as completion.
-
Which order side reduces a long or short position?
- A sell order reduces a long, while a buy order reduces a short. Reduce-only checks the direction against the position held by the same subaccount and market. A buy against a long or a sell against a short would add exposure, so the order fails the guard. The direction rule applies equally to immediate market or limit exits and to triggered stop or take-profit exits.
-
Can an API client submit reduce-only orders without the web interface?
- Yes, an API client can submit reduce-only orders without the web interface. The dYdX TypeScript, Python, and Rust clients expose an order message with the reduce_only Boolean set to true. Execution must use IOC, and the order side must oppose the current position. Software should fetch the latest position from the dYdX Indexer, calculate the reduction, assign a unique client ID, submit, and reconcile refreshed position data.
-
Is Fill-or-Kill valid for a reduce-only order on dYdX Chain?
- Fill-or-Kill is not valid for a current dYdX reduce-only order. The order schema retains it as a deprecated enum value, and placement validation rejects that time-in-force choice. Use IOC for reduce-only execution. IOC permits an immediate partial fill and cancels the balance, whereas Fill-or-Kill would require the entire quantity at once. The rejected instruction leaves the existing position unchanged.
-
Can one subaccount reduce a position held in another subaccount?
- A dYdX order cannot reduce a position held in another subaccount. Its OrderId identifies one subaccount, and the reduce-only check reads the position attached to that same subaccount and CLOB pair. Holding an offsetting position elsewhere does not satisfy the check. Reducing exposure in two subaccounts requires a correctly directed order from each, sized from each subaccount's current position.
-
Where does realized PnL appear after a reduce-only fill?
- Realized PnL appears in the account and history data after the fill updates the position. A partial reduction realizes profit or loss only for the matched quantity, while the remaining quantity stays open and continues carrying market exposure. The portfolio view and dYdX Indexer also expose fill price, filled size, fees, and position fields, letting the final state reconcile with the execution record.
-
Does an isolated-margin reduction transfer extra collateral?
- An isolated-margin reduction transfers no additional collateral into the position. The order decreases that position's notional size, while realized PnL and trading fees update its equity. Closing the full position brings size to zero; the interface then handles the resulting isolated collateral state under its account workflow. Target leverage changes alone do not transfer collateral until a new order triggers the relevant action.
-
When does funding stop after a reduce-only close?
- Funding stops accruing on the quantity that no longer remains open. A partial reduce-only fill leaves the balance exposed to future hourly funding payments, while a complete close leaves zero position size for later funding intervals. The fill itself still reflects trading fees, realized PnL, and any funding already accumulated in account history. Check the refreshed size first because an unfilled IOC remainder leaves some exposure active.