Is a decentralized exchange basically a smart contract that includes all the exchange functionality? Where is the engine?
3 Answers
There are a few layers to a dececentralized exchange (DEX) to be aware of.
The application layer is the front end interface that most users interact with. Examples of this include the Forkdelta front end and Paradex. On this layer, users can visually see orders in an orderbook and inspect the state of the exchange via graphs and other tools. Users can use this layer to trade and place orders. The actions and data on this page are (usually) all performed and read from the smart contract layer.
The smart contract layer refers to the smart contracts that run the exchanges. Examples of these contracts are the Forkdelta smart contract, or a Uniswap exchange contract. These smart contracts hold all of the state of the exchange (current and past orders and trades) and process all of the logic passed to it from the front end. When a user makes a trade on the front end, it will trigger this smart contract, that proceeds to perform calculations and checks required to execute the trade. When all of the processing is complete, the trade will have executed and the smart contract will upgrade, which will subsequently upgrade the front end.
The EVM is the underlaying layer that runs all smart contracts on Ethereum. All smart contracts are simply a wrapper over EVM executions. This layer is the most fundamental layer on Ethereum.
-
1
-
1Correct. All of the logic and trades are done on the smart contracts. Apr 13, 2019 at 23:45
Yes, a decentralized Exchange performs all the functionality of a centralized exchange, using smart contracts. the smart contracts handle all the functionalities. these type of exchanges as more reliable as they follow the code and there is no human error (except if someone writes a contract with an error).
-
1The last part is not true. There can always be human errors, even when writing smart contracts. Apr 13, 2019 at 18:20
Technically, all transactions facilitated on DEXs are executed using Smart Contracts. A DEX could facilitate faster and cheaper transactions than a centralized exchange since there is no additional fee fixed by the third party. The only fee users have to pay is Gas Fee — the cost of sending transactions over the Ethereum blockchain. DEXs are more secure than centralized models since all interactions are peer-to-peer and permissionless. You can go over a comparison between DEXs and centralized exchanges in my blog.
-
That's not an entirely accurate. There is an additional fee that needs to be paid and that goes to the liquidity provider. Aug 13, 2021 at 19:50