First, let’s dive into the issue of concurrency on the Cardano platform. I’ll cover the basics before we get into the solutions presented Genius Yield and SundaeSwap. Concurrency is the ability for multiple processors or actors to progress on a task without interfering with each other. Parallelism is the ability of those multiple actors to handle tasks simultaneously without interfering with each other. Contention happens when multiple actors interfere with each other while working either concurrently or in parallel.
- Global State — On the Ethereum platform, there is a global state that keeps an account balance of all addresses. A global state would be similar to our bank accounts, which updates based on every transaction. Each transaction must be processed in order, as each transaction can affect the global state. However, there exists a potential that the global state changes before a transaction is submitted and when that transaction is processed. This can result in high transaction costs, or gas fees, during times of congestion and even transaction failure with the loss of gas fees. Users face non-determinism in transaction fees, as gas fees can’t be actually predicted when the transaction is submitted.
- Local State — Cardano uses the eUTXO (extended unspent transaction output) model, which builds on bitcoin’s UTXO model. Cardano has no global state. Each UTXO, or unspent transaction output, is an individual transaction created and contained on the blockchain. Each UTXO can only be spent as a whole transaction. The UTXO model is similar to having cash in your wallet. For example, if you have $20 in your wallet and you pay for a product at a store that it is worth $15, you would give the cashier a $20 dollar bill, and receive a $5 dollar bill and $10 dollar bill. UTXO transactions work the same way. The UTXOs are indivisible, similar to cash.
Note: There is no account balance, or global state, that says your new available balance is $15. In the UTXO model, all of the UTXO transactions associated with your wallet on the blockchain are added together to show that your total funds are $15. This is analogous to opening your physical wallet and counting each of the bills to see the total amount of cash you have.
- Parallelism — A global state is not needed since each transaction is done locally. Parallelism is possible as many transactions can happen and have no effect on each other.
- Determinism — Users know the impact of the transaction on the on-chain state, including the transaction cost, before submitting the transaction. Transactions can still be rejected if the expected input has already been spent during a single block.
Concurrency Issue — As mentioned above, transactions on Cardano are deterministic, but can still be rejected since a UTXO can only be spent once. A UTXO that hasn’t been spent can be used as an input in a block. A a new block of transaction data for Cardano is created every 20 seconds and permanently added to the blockchain. If multiple actors try to spend the same UTXO in a block, only one actor will be successful and all other transactions will be rejected. Many people wrongly interpreted the design structure of Cardano as meaning that only one transaction can happen every 20 seconds. For a DEX (decentralized exchange), if true, this throughput would be unacceptable.
In order for a DEX to be viable, it has to process thousands of transactions per hour. How is Genius Yield and SundaeSwap handling concurrency and parallelism with their DEXes? What are the strengths and weaknesses of their solutions?
- Scooper model/AMM Orderbook — Market participants can place good-until-canceled orders onto the blockchain. Since the orders don’t interact with any pre-existing entities, they don’t suffer from the UTXO contention issues. However, the model is not a pure orderbook. Liquidity pools, similar to Uniswap, are used to allow the execution of swaps via the AMM (automated market maker).
- What’s the role of scoopers? 30 SPOs (Stake pool operators), who currently participate in Cardano’s delegated proof of stake protocol, are selected to be scoopers. These scoopers build and submit transactions that execute the swaps against the AMM, receiving an ADA fee in return.
- How will the scoopers be selected? In order to avoid centralization by either having itself as the scooper or handpicking the scoopers, SundaeSwap conducted one of the largest on-chain voting events for the Cardano platform by having the community vote for the SPOs that would be scoopers. The SPOs selected by ADA holders would be given the software and licenses by SundaeSwap to be scoopers. The licenses would expire periodically and would have to be renewed. Since the licenses are temporary, more votes can be held by the community to not renew licenses for scoopers who are misbehaving. SundaeSwap’s goal is to have governance ran by the SundaeSwap DAO via its SUNDAE token. SundaeSwap plans to launch its DAO in the summer 2022 if Cardano’s parameter updates allow its efficient functionality.
- Order Book Model with Liquidity Pools — Genius Yield’s DEX will use the order book model, similar to major centralized exchanges such as the Nasdaq, Coinbase, and Binance. For DEXes, specifically built on Ethereum, using an AMM with liquidity pools allowed liquidity for even thinly traded securities due to its design, which is typically the Constant Formula Market Maker. However, order book exchanges have no global state. An order book listing the bid and ask prices and amounts of each token is made available to all traders, allowing each trader to analyze market factors such as depth, demand, and supply before making trades.
- Smart Swaps — Users will be able to create programmable orders that only execute based on a set of conditions, or Smart Swaps. Smart Swaps will include market orders, limit orders, stop orders, dynamic orders, and algorithmic orders. These orders are similar to the limit or stop orders available on standard stock brokerage accounts. Due to the eUTXO design of Cardano’s platform, order submission and order execution can be separate, allowing DEX orders to be entered on-chain in parallel.
- Liquidity Pools — Liquidity for the DEX has two sources. First, liquidity comes from the total amount of limit buy or sell orders listed in the orderbook. Next, there will be liquidity pools supplied by liquidity providers (LPs). LP funds will be used to create liquidity for an asset, even for thinly traded tokens. A buy or sell order can matched with another order so that the trade can executed. The other side of an order can also come for the LP’s funds, guaranteeing liquidity. LPs are incentivized to provide liquidity fee as they are rewarded with execution fees for each order.
- Concentrated liquidity — Similar to Uniswap v3, the DEX will allow LPs to concentrated their liquidity. Concentrated liquidity allows capital efficiency, higher returns, and reduces impermanent loss by allowing LPs funds to be used within the likely price range for certain assets.
- Genius Yield Smart Order Routers — Smart Order Router (SORs) will pick up and execute orders submitted to the Cardano ledger. SORs are off-chain bots that scans the open orders on the blockchains and matches them based on their conditions, such as a limit price. SORs only make money on the bid/ask spread, similar to market makers on stock exchanges. SORs could be incentivized to match orders across a variety of tokens to maximize profit based on volumes and wide bid/ask spreads. Genius Yield eventually plans to open source the code governing the Smart Order Routers, so that anyone can deploy or customize the code for their own benefit.
LPs have a similar role to market makers for stock exchanges. For stock exchanges, liquidity is guaranteed by market makers, whose role is to ensure liquidity for a security by being willing to buy or sell a security for their own account. Market makers will fulfill market orders and even post limit orders to ensure liquidity.
Why would an entity take on the risk of continually buying a security that is falling in price? Market makers make profit off of the bid/ask spread. They sell the stock at higher price than the price they will buy the stock. For example, Stock A traded on centralized exchange XYZ for one day with an average ask price for investors of $101 and a bid price of $100 that investors are willing to sell Stock A. The market maker would sell Stock A to investors at the ask price of $100 while also buying Stock A from investors at a price of $100. The bid/ask spread is $1. The market maker makes a $1 profit each time he can buy Stock A for $100 and sell Stock A for $100. The role of market makers is somewhat similar to the role of Genius Yield’s smart order routers.
- Centralization risk — Only the scoopers can process transactions, causing centralization. SundaeSwap, by having the community vote for the scoopers, is trying to decentralize the selection of the scoopers by requiring license renewals. Eventually, the DAO will be able to remove misbehaving scoopers or those who provide substandard service.
- High Scooper fees — The current scooper fees are exorbitant, at 2.5 ADA per trade. Muesliswap, which currently uses a pure-order book model, is significantly cheaper. This 2.5 ADA scooper fee, according to SundaeSwap, could come down in the future.
- Centralization of Cardano’s network — SundaeSwap’s ISO gave scoopers the ability to distribute Sundae tokens to delegators. 7 billion ADA was delegated to these scoopers, many of whom run multiple pools. This notably decreased the decentralization of Cardano’s platform dropping the Nakamato Coefficient from 25 to 22.
- Prioritizing transactions and potential pay-to-play — Over the weeks, scooper SPOs have begun to prioritize transactions related to SundaeSwap over other transactions on the blockchain. While the scoopers have a financial incentive to do so due to the scooper fees, this outcome harms the overall decentralization of the platform. Could a public or private actor financially incentivize SPOs in the future to prioritize its transactions? The need for scalability and parameters that promote decentralization are needed.
- Programmability — Compared to SundaeSwap, Genius Yield DEX’s will provide more programmability of orders, allowing a range of limit orders, stop orders, and dynamic orders that is not possible on SundaeSwap’s DEX.
- Potentially lower fees — While Genius Yield has not released its fee structure, the SORs, unlike the scoopers, don’t receive a fee for executing an order. SORs only make money on the bid-ask spread.
- Decentralization — Unlink SundaeSwap’s Scooper model, anyone can be a SOR. Genius Yield eventually plans to open source the code governing the Smart Order Routers, so that anyone can deploy or customize the code for their own benefit. However, the initial release of the DEX will only have vetted SOR operators before the code is made available to the public. This approach is made to ensure stability before turning over this function to the public. This method is similar to IOG running the protocol with federated nodes before slowly transitioning all block production to non-federated nodes.
- Liquidity for many assets — SORs could be incentivized to provide service to thinly trading markets because of wider bid/ask spreads. LPs could be incentivized to provide liquidity to these thinly traded tokens for higher LP fees. However, SORs and LPs could shift their resources away from thinly traded tokens to other tokens or pools with higher profit potential if interest in the thinly traded token is too low.
- Concentrated Liquidity — No other DEX currently available on Cardano’s mainnet offers concentrated liquidity. Offering this option for users could see LPs shift their resources to Genius YIeld’s platform.
- While stock exchanges have market makers that guarantee liquidity, how would a DEX that utilizes an order-book model guarantee liquidity in thinly traded tokens?
- Since Genius Yield’s plans to eventually open source the code for SORs, what mechanisms or incentives will dissuade SORs from behaving maliciously?
- How would the DEX handle large orders? Would an actor with a large order have to break up their order into several smaller orders, increasing their trade fees? (Genius Yield’s DEX whitepaper indicates that the team is conducting research on this topic.)