Sign inLaunch App
BTC——·ETH——·GOLD——·NVDA——·SPCX——·SP500——·CC——·BTC——·ETH——·GOLD——·NVDA——·SPCX——·SP500——·CC——·
Perpetuals basics · 5 min read
canborsa
Perpetuals basics · 5 min read

How a perpetual DEX works, step by step

Step-by-step guide to trading perpetuals on DEXes: wallets, collateral, order types, and on-chain settlement.

How a perpetual DEX works, step by step · at a glance
5 min
at a steady paceRead time
6
in this guideSections
3
answered at the endQuestions
10
Perpetuals basicsIn this track
Quick answer · How a perpetual DEX works, step by step

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.

READ5 min
SECTIONS6
TRACKPerpetuals basics
What this guide covers
The building blocks of a perp DEX
Opening a position step by step
How matching happens on-chain
Liquidation on-chain
Settlement and closing a position
Guide
On this page
Quick answerThe building blocks of a perp DEXOpening a position step by stepHow matching happens on-chainLiquidation on-chainSettlement and closing a positionWhat differs from a centralized…FAQ

The building blocks of a perp DEX

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.

Opening a position step by step

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.

How matching happens on-chain

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.

Liquidation on-chain

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.

Settlement and closing a position

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.

What differs from a centralized venue

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 .

871 words · 6 sections · 7 linked pages · reviewed 8 Sep 2026

Frequently asked questions

What is how perpetual works?›

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.

What is dex mechanics?›

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.

What is order matching?›

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.

Keep exploring
More in Perpetuals Basics
Leverage ratios on perpsguide · perpetuals basics›How funding is calculatedguide · perpetuals basics›Mark price vs index priceguide · perpetuals basics›Collateral on perp positionsguide · perpetuals basics›All Learn guideslearn · index›
Markets on Canborsa
iShares MSCI South Korea ETF (EWY)Index · perp›Zcash (ZEC)Crypto · perp›S&P 500 (SP500)Index · perp›XRP (XRP)Crypto · perp›All 86 marketsindex›
Perp DEX reviews
GMX reviewplatform · profile›Ethereal reviewplatform · profile›GRVT reviewplatform · profile›edgeX reviewplatform · profile›All perp DEX reviewsindex›
CANBORSA · LIVE ON CANTON

Trade on Canborsa

86markets0.07% per side
86 markets · 0.07% per side
© Canborsa 2026TermsPrivacy