A common description of a DEX (decentralized exchange) is that, unlike a centralized exchange, it operates onchain.
But what does that actually mean?
To understand this, it helps to take a step back.
Cryptocurrencies are controlled by programs on the blockchain. These programs track how many tokens exist and who owns them. Ownership is recorded globally on the blockchain, not inside an app or website.
When trading on a centralized exchange like Binance or Coinbase, tokens are usually transferred to the exchange first. The exchange then keeps track of balances internally. You can trade, buy, and sell, but ownership exists inside the exchange’s database, not directly on the blockchain.
You can usually withdraw tokens back to the blockchain, but while they are on the exchange, you are trusting that exchange to hold them correctly. If the exchange were to disappear or misuse funds, it could affect your assets.
A decentralized exchange works differently.
When trading on a DEX, tokens are never handed over to an exchange. Ownership stays recorded on the blockchain under your wallet. The only way those tokens can move is if your wallet approves it.
People often say tokens are “in your wallet,” but that’s not quite accurate. The blockchain records ownership, and the wallet is a tool that holds the keys needed to approve changes to that record. Without those keys, ownership cannot change.
Because of this design, there is no central authority that can take custody of your assets. No company, no exchange, and no intermediary controls them. Changing ownership would require control of the blockchain itself, which is not practical.
So how does trading actually happen?
A decentralized exchange maintains pools of tokens, called liquidity pools. This is a simplification, but a pool usually contains two tokens, for example SOL and USDC. An algorithm enforces a price relationship between those two tokens.
When someone sells SOL into the pool, the balance shifts and the price adjusts. When someone buys SOL, the price adjusts in the opposite direction. The pricing is automatic and enforced by code, not by a company.
Because anyone can create pools and exchanges, the same token can trade at slightly different prices across different pools. These differences are usually small and short-lived.
They disappear because of arbitrage. Automated programs monitor prices across exchanges and immediately buy where a token is cheaper and sell where it is more expensive. When they do this, the pool prices move back into alignment.
This is where a DEX aggregator comes in.
A DEX aggregator monitors prices across many pools and exchanges at once. When a trader submits a swap, the aggregator finds the best available price and routes the trade accordingly.
DFlow is a DEX aggregator. When you swap tokens, DFlow searches across available liquidity and executes the trade where pricing is most favorable.
The result is a single swap, executed onchain, without giving up custody of your assets.