A perpetual DEX reproduces the mechanics of a centralized derivatives exchange, margin, leverage, funding and liquidation, but keeps custody of collateral and the record of every position on a blockchain or a chain-adjacent settlement layer instead of on the venue's own internal ledger. The result looks similar from the trading screen, but the machinery underneath it is built entirely differently.
Four pieces work together on every decentralized perp venue. A non-custodial wallet holds the trader's collateral and signs orders, meaning the trader alone controls the private key that authorizes every deposit, trade and withdrawal. A smart contract or app-chain settlement layer records positions and margin balances and finalizes trades on-chain, enforcing the venue's rules through code. A price oracle feeds the index price used for funding and liquidation, since the chain itself has no native view of off-chain spot markets and needs that price piped in from somewhere external. A matching engine pairs buyers and sellers, whether that is a fully on-chain order book, an off-chain order book with on-chain settlement, or an automated pool that prices trades algorithmically.
The oracle piece deserves particular attention because everything downstream, funding, mark price, liquidation, depends on it being accurate and hard to manipulate. Most venues source their oracle price from multiple independent feeds or from a decentralized oracle network, specifically so that a problem with one feed does not by itself corrupt the price used to settle every open position on the platform. An oracle failure or delay is one of the few single points of failure that can affect a fully on-chain venue despite there being no custodial operator holding the funds.
Every step after the deposit also carries a gas or execution cost paid to the underlying chain, separate from any trading fee the venue itself charges, which is why many perp DEXs run on a dedicated app-chain or a low-fee layer.
Order-book venues such as dYdX and Lighter run an off-chain or validator-matched order book with on-chain or app-chain settlement, giving price-time priority similar to a traditional exchange: the best-priced order that arrived first gets filled first. Pool-based venues such as gTrade price trades against a liquidity pool, quoting instantly with no waiting counterparty, though the price impact then comes from the pool's own pricing curve. Neither model is strictly better; each trades off latency, price certainty and dependence on external liquidity differently, and some venues blend the two by routing small orders through a pool and larger ones through an order book.
When a position's margin falls below the maintenance threshold, most perp DEXs do not rely on an internal risk desk the way a centralized venue might; instead the smart contract exposes a liquidation function that any external party, often an automated bot, can call to close the position and earn a fee for doing so. This permissionless design means liquidations happen as soon as the on-chain conditions are met, without depending on any single operator being available to act. The price used to trigger that liquidation is the mark price, a distinction from raw last-traded price covered fully in mark price versus index price .
Because anyone can run a liquidation bot and collect the fee, the role tends to attract competition among independent operators watching the chain for undercollateralized positions, similar in spirit to how arbitrage bots compete on decentralized spot exchanges. That competition generally keeps liquidations prompt during normal conditions, though during a fast, thin market with high network congestion, the liquidation transaction itself still has to be confirmed on-chain like any other transaction, which can introduce a short delay that would not exist on a centralized venue's internal matching engine.
Closing a position runs the same flow in reverse: an opposing order or instruction is submitted, matched and settled through the same mechanism that opened it. Realized profit or loss is credited or debited against the posted collateral, and the position record closes on-chain. Once a trade settles fully on-chain, the venue itself has no ability to reverse it; finality is enforced by the chain itself, a sharp contrast with a centralized exchange, where an operator can in principle adjust an internal ledger entry.
Collateral stays under the trader's own wallet control until it is posted as margin, positions are visible on-chain, and many venues skip a traditional identity-verification gate entirely; a list built around that last point is at best no-KYC perp DEX . The full custody-and-access comparison against a centralized exchange is covered in perpetual DEX versus CEX , and how the collateral itself is priced and haircut is covered in collateral types for perps .
A perpetual DEX works by combining a non-custodial wallet, an on-chain or app-chain settlement layer, a price oracle and a matching engine. Collateral moves from the trader's wallet into a smart contract as margin, an order is matched against a counterparty or a pool, and the resulting position and any funding payments are recorded on-chain for as long as it stays open.
DEX mechanics refers to how a decentralized exchange turns a submitted order into a settled position without a central operator taking custody of funds. A smart contract enforces deposits, matching and liquidations according to fixed rules, and a price oracle supplies the external index price the contract cannot see on its own.
Order matching is the process that pairs a buyer and a seller at an agreed price. On a perp DEX this happens either through an order book, matching resting orders by price and time priority, or through an automated pool that quotes a price algorithmically against its own reserves without waiting for a counter-order.