Search…
⌃K
Links

3. Methodology

Genius DEX v1

3.1 Smart Swaps

Genius DEX’s core primitive is the Smart Swap, which enables many of the DEX’s novel functionalities in a computationally efficient and elegant way. Smart Swaps are buy or sell orders that automatically execute based on some programmable logic. Smart swaps are to the DEX what smart contracts are to the ledger. They allow for the automated execution of a trade triggered by a verifiable set of conditions. This enables users to submit orders that do not get filled instantly at the market price but instead ‘wait’ on the ledger until certain conditions are met to execute the swap.
Smart Swaps are not unique to Genius Yield. For example, a limit order is a type of smart swap in which a trade is triggered once a price is available. Such order types are prevalent in traditional, centralized exchanges e.g. Coinbase, Robinhood, etc. However, they are not common within DeFi, because the AMM model used by most DEXs makes such order types unfeasible.
DeFi protocols designed specifically for an UTxO model can provide new functionalities not feasible on other smart contract blockchains. Maladex, another well researched and designed Cardano DEX, has already introduced the idea of programmable swaps [21] and other DEXs are experimenting with new and creative architectures [22]. UTxO-based blockchains are now leading the charge in the research and development of the next generation of DEXs.
Smart swaps don’t just limit themselves to limit orders. On the contrary, they allow for incredible flexibility and modularity with the potential to provide sophisticated trading functionalities not found in centralized exchanges.
Below are different types of Smart Swaps made available by Genius DEX:
  • Market Order: An order to immediately execute a swap at the best possible market price. Since it has no trigger conditions, the execution price fluctuates with the market. It is equivalent to a swap on an AMM-based DEX.
  • Limit Order: An order to buy or sell a token for a specific price. As opposed to a market order, it does not execute immediately. Rather, it waits until a matching order (either a smart swap or liquidity provider) in the opposite direction becomes available. A limit order can be filled fully or partially based on the depth of market. Moreover, the order can be configured to expire after a certain time or be active until canceled.
  • Stop Order: A stop order will submit an order when a stop price has been met. A stop order functions like a limit order but with two critical differences. The first is that a limit order uses a price to designate the least acceptable amount for the transaction to take place. On the other hand, a stop order uses a price to merely trigger an actual order when the specified price has been traded. The second is that a limit order is visible in the order book while a stop order is invisible until it is triggered. A stop order helps traders protect profits, limit losses, and initiate new positions.
  • Dynamic Order: An order where the trigger value is not price, but another data type such as an oracle data stream. More specifically, the trigger value can be a statistical metric or financial indicator commonly used in trading technical analysis tools. For example, a momentum indicator, such as the relative strength index (RSI) and moving average convergence divergence (MACD). These indicators are typically used by traders to determine the strength or weakness of a stock's price. With dynamic orders, trades can be triggered based on these metrics automatically, opening the door to more complex trading strategies.
  • Algorithmic Order: This type of order can combine all order types described above into a meta order. An algorithmic order can chain an arbitrary number of orders triggered by an arbitrary number of conditions spread out across time. This allows entire algorithmic trading strategies to be defined and executable within a single Smart Swap. For example, if a trader is bullish on the long term price of an asset, but believes short-term dips are likely, they may adopt a “buy the dip” strategy. On the other hand, if the investor believes a token pair is intrinsically correlated (such as two stablecoins tracking the same asset), then a good strategy would be to trade the volatility. Algorithmic orders allow for abstraction and automation of advanced trading strategies within a smart contract.
Genius’s Smart Swap is a flexible and composable protocol on which expressive and powerful orders can be defined. In fact, Genius Yield’s second product, Smart Liquidity Management, leverages the algorithmic order type to develop advanced strategies designed and backtested by our inhouse Genius Labs team. We will dive deeper into the algorithmic order and backtesting platform in a future paper.
The Smart Swap protocol is simple by design and is defined by three attributes:
  • Assets - Token pairs that will be traded for each other
  • Action - Behavior of the swap when the order is executed
  • Conditions - Set of conditions that must be met to trigger the action
Therefore a limit order can be represented as a Smart Swap in which the Action is a buy/sell transaction and the Condition, a price at which it must occur. Such a design provides a lot of flexibility and allows for complex order behaviors to emerge from the composability of order types. Figure 9 illustrates how different order types can be combined together to create different algorithmic strategies.
Figure 9: Examples of order types: (a) Market order, (b) Stop-Limit order: stop order triggers a sell limit order, (c) ”buy the dip” strategy: an algorithmic order transfers 10 ADA into a dynamic order, which submits a Buy market order when RSI (relative strength index) < 30 (signaling an undervalued asset)

Smart Swap (Market Taker) State Machine

The EUTxO smart contract paradigm gives state machine diagrams the most intuitive representation of a protocol’s functionalities (Fig. 10 & Fig. 12). For the market taker, the state machine diagram in Fig. 8a shows how a Smart Swap is defined in three states and five state transitions.
Smart Swap states:
  • Open: an order submitted to the DEX (EUTxO at the script address), but not yet processed
  • Filled: once an order’s trigger conditions are met, routing bots execute the swap
  • Close: open orders not yet triggered can be canceled or expire after a set time
Figure 10: Market Maker State Machine
Smart Swap state transitions:
  • Smart Swap - submit a Smart Swap order to the DEX
  • Process Order - a routing bot matching the smart swap with a liquidity position and executing the transaction
  • Cancel Order - order canceled by owner before it is processed
  • Position Expires - order canceled itself after a predefined time
  • Wallet Deposit - Transaction outputs return to owner wallets

Scalable Swaps

The appeal of such a design is in their relative simplicity and full parallelizability. The separation of order submission and order execution into distinct states means users can submit DEX orders onto the blockchain in parallel without congesting the execution of other swaps. This is unlike traditional AMM DEXs where all swaps are market orders that must be executed the moment they are submitted regardless of congestion or transaction fees. Additionally, Smart Swaps can be defined with minimum information (i.e. no pool state needed), resulting in lower fees.

3.2 Concentrated Liquidity Provider

A DEX that supports concentrated liquidity empowers liquidity providers (LPs) to optimize their liquidity allocation strategy. This enables LPs to potentially earn more yield, while making the DEX more performant and decentralized.
In a traditional exchange, a liquidity provider (or market maker) has the function to supply liquidity to a tradable asset and help stabilize price variation (volatility), reducing price slippage, and more generally facilitating efficient price discovery. This is achieved by quoting both buy and sell orders of an asset with the goal of making a profit on the bid-ask spread.
In an AMM DEX, price is computationally derived by the constant product formula, whereas in an order-book price is defined by market forces of supply and demand. Therefore, LPs play a crucial role in providing the liquidity depth necessary to allow for an efficient marketplace. In other words, LPs supply the liquidity needed for the DEX to function, whereas the users represent the demand for said liquidity. It is the very interaction of traders, facilitated by the liquidity providers, that makes price discovery decentralized.
Let’s say we have a market for a trading pair A/B. A liquidity position would supply both sides of the trade at a specific price. Once a user opens a buy order for A at price X, a matching sell order for A will be executed between the two parties. The sell order can either come from another party’s limit order or a LP position available at that price. LP positions are very similar to limit orders except they are reversible orders. Once a LP position participates in a trade, the received liquidity stays in the same LP position to supply the other side of the trade.
Figure11: Example of a Smart Order Router matching a Smart Swap with a liquidity position
In Fig. 11, we have an example of a GENS/ADA pool. A user submits a Buy GENS limit order at price P3. However, no matching Sell GENS order exists on the DEX. Instead of remaining open, the order is matched with a GENS liquidity position, also available at price P3. The user wallet receives the GENS tokens and the LP receives ADA in return. For the LP, the ADA tokens are added back into its liquidity position at price P3, ready to accept trades in the opposite direction. In the next block, a buy and sell order gets submitted at P4. No ADA is available at P4 so the sell order stays open. However GENS liquidity is available at P4 and the buy order can be executed. Now ADA is available at P4 and the sell order can go through. Note that if the sell and buy orders at P4 were for the same amount, they could have been filled without using any of the pool’s liquidity.

How liquidity providers earn profits?

A LP earns a portion of the execution fee paid by the DEX user (Section 3.5: fee structure). In addition, Genius Yield will give liquidity mining incentives to LPs that contribute liquidity to certain pools. Liquidity mining allows LPs to earn additional GENS protocol token used for governance such as voting on Genius Improvement Proposals (GIP).

Liquidity Providers (Market Maker)

State Machine In Fig.12, the state machine diagram for market makers depicts how liquidity positions are defined in three states and seven state transitions.
Liquidity Position states:
  • Open: a liquidity position submitted to a pool at a specific price range, ready to absorb trades. LP rewards are automatically reinvested, but can also be withdrawn without closing the position
  • Filled: once an order matches with a liquidity position, routing bots execute the swap. The leftover liquidity is either maintained in the current position or transferred in a more optimal price point determined by the Smart Liquidity Vault
  • Close: the full liquidity can be returned to the LP’s wallet by closing the position
Figure 12: Market Taker State Machine
Liquidity Position state transitions:
  • Liquidity Position: add concentrated liquidity to a pool
  • Process LP - a routing bot matching LP with an order and executing the transaction
  • Close LP: LP is closed by owner
  • Maintain Position: LP is reopened at the same price to accept trades in the opposite direction
  • Smart Liquidity Management: rebalance LP to a new price point based on strategy defined in the Smart Liquidity Vault
  • Update LP: add/remove liquidity or change price of liquidity position

Scalable Liquidity Pool

In a UTxO architecture, centralizing the pool state into one UTxO (as in a traditional AMM) would constrain the DEX to one transaction per block. To achieve high throughput, the DEX must take advantage of the inherent parallelism properties made possible by UTxOs. For this reason, the pool state is divided along two dimensions (e.i. price ticks and liquidity providers), enabling parallel processing of UTxOs within the same block (Fig. 13). In addition to increased throughput, fragmentation also minimizes memory requirements. Since each transaction is only dependent on a local state, this results in lower transaction sizes and thereby lower fees. Another desirable property of fragmented liquidity is the emergence of arbitrary liquidity curves. Instead of predefining a fixed curve like in an AMM, the liquidity distribution is dynamic, decentralized, and governed by market sentiment, resulting in more efficient asset allocation.
Figure 13: Fragmented Liquidity Pool with UTxOs sitting at various price sticks P

3.3 Smart Order Router

Orders on the Genius DEX have two main phases (Fig. 14). First, orders are submitted to the Cardano ledger, then they are picked up and executed by Smart Order Routers (SOR). SORs are off-chain bots that execute a routing algorithm that scans the blockchain for open orders, matches them based on their trigger conditions and submits new transactions back to the ledger to perform the swap state transitions. Each Smart Swap encodes trigger conditions that must be fulfilled by the SOR to execute the swap.
Figure 14: Smart Order Router: off-chain bots responsible for matching orders and processing them.
SORs automate the process of handling orders and are designed to take the best available opportunity across a range of market conditions. They need to continuously scan and analyze the current state of the DEX (set of UTxOs defined by Smart Swaps and Liquidity Providers) and rely on a set of rules, configurations and algorithms to best execute a customer's order, based on price and liquidity.

Order Selection Strategies

Order selection is a complex topic and an active area of research [23][24][25]. It is particularly challenging when designing strategies within a decentralized environment. For example, large orders may need to be matched across multiple orders to obtain sufficient liquidity. However, the more UTxOs are combined, the higher the likelihood at least one UTxO will already have been spent by another SOR by the time the transaction is submitted (transaction sequences are mutually exclusive creating a race condition). To reduce the number of UTxO needed to fill an order, one simple strategy is to search for the closest matching order value. However, this strategy tends to create a lot of ‘dust’, small unspent outputs that remain unused.
Alternatively, supporting partial orders through large order fragmentation could give more flexibility to SORs to optimize order selection. The issue here is that partial orders require more transactions and therefore incur more fees. Moreover, the generation of more transactions may worsen blockchain congestion (though L2 scaling solutions like Hydra will lessen this problem). All in all, order selection strategies need to be carefully crafted and fine-tuned to function effectively. It is an active area of research at Genius Labs, and the team is taking a first principles approach to designing and validating strategies using simulations. As a starting point, Genius Labs is taking inspiration from IOHK’s coin selection algorithms used by the Cardano Wallet [26].

Decentralization

The code governing the Smart Order Router will be made open source for maximum transparency and accountability. SORs can be deployed by anyone willing to support the DEX and even customize the underlying matching algorithm for their own benefit. The goal is to foster an open, competitive environment where the core DEX operation is in the hands of the community and market forces. As a first step however, a restricted version of the DEX will be released with vetted SOR operators in order to ensure a stable DEX experience. As trading volume and liquidity grows, further decentralization will be introduced progressively.

Scalable SORs

As explained in an earlier section, off-chain computation is both practical and desirable in a UTxO model. Similar to Bitcoin, Cardano’s settlement layer is a verification model that validates off-chain computation. Therefore the distribution of off-chain logic can be used to scale order processing. At scale, the DEX’s operation is powered by multiple Smart Order Routers competing with each other for the best trades in order to maximize personal rewards. With the right set of incentives, competition can become a desirable force maintaining DEX performance. Genius Labs takes an iterative approach combined with rigorous stress testing to produce fast order execution, efficient flow of liquidity and market-driven price discoverability.

How do Smart Order Routers earn profits?

SOR operators do not get a cut of the execution fee charged by the DEX. Instead, the SOR exclusively makes profits from the bid/ask spread caused by price volatility, low trading volume and other inefficiencies in the market. For example a user wants to buy 1 GENS at a price of 10 ADA, but GENS liquidity is available for 9.5 ADA. In this case, the SOR can make a profit of 0.5 ADA per GENS token sold. SORs are essentially arbitrage bots that are rewarded for removing capital inefficiency in the market. When the prices of two assets fall out of line, the SORs will buy and sell until the relationship gets back in line. Therefore, introducing a competitive environment with many independent SORs will result in a tight, deep, and liquid order-book.

Security

Operating a SOR is both a privileged position and potentially very lucrative one. Therefore, adversarial behaviors taking advantage of vulnerabilities are to be expected. Genius Labs is carefully evaluating all possible attack vectors and manipulation strategies e.g. front-running, pool extractable value, trickle attacks, denial of service, etc. to produce a high performance, secure, and fair DEX experience. In future articles, Genius Labs will explore DEX attack management and mitigation strategies.

3.4 Smart Liquidity Vault

A separate paper will be dedicated to the Genius Yield Optimizer protocol, describing in detail how the AI-powered algorithmic strategies are designed and optimized for each vault. Below is a brief introduction to this protocol.
In a concentrated DEX, creating liquidity positions becomes an active job for liquidity providers. LPs need to strategically position their liquidity at the optimal price to capture trade volume and maximize rewards. Moreover, liquidity positions need to be adjusted frequently to stay within the optimal price range where swaps are happening. This requires active monitoring and interaction with the DEX. For users that are looking for a more passive yield farming experience, Genius Yield has created an active liquidity management protocol, called the Smart Liquidity Vault.
As shown in Fig. 15, vaults are liquidity pools managed by a trading bot executing a machine learning optimized algorithmic strategy. Different vaults execute different strategies based on the users’ risk tolerance and outlook on the market. Vaults automate simple strategies like DCA (Dollar Cost Averaging), Smart Rebalance, or more advanced ones like modeling volatility and forecasting trend reversals. Each strategy is developed using a powerful backtesting ML platform leveraging historical data and blockchain data streams. The performance of each strategy is methodologically tested and validated before deployed to the Genius Yield platform.
Figure 15: Smart Liquidity Vault
Under the hood, Smart Liquidity Vaults leverage the Smart Swap abstraction and concentrated liquidity positioning functionality to execute their strategy. More specifically, the flexibility, expressiveness, and composability of dynamic order and algorithmic order types are the building blocks of these strategies.
For these reasons, nothing stops a user from designing their own algorithmic strategies using Smart Swaps and competing with the Genius Vaults. In fact we encourage it, and aim to support community-designed vaults in the future. Through a social trading leaderboard, any users will be able to learn and benefit from the community’s best strategies. The vision is to empower the community to learn from the best and democratize yield optimization for all.

3.5 Genius Yield Platform

The Genius Yield platform ties together each of the components described above into an all-in-one DeFi ecosystem on Cardano. The platform is composed of two layers: the Genius DEX and the Smart Liquidity Vault.

Genius DEX

The Genius DEX is the core protocol that brings together the traders, liquidity providers and SORs to create the token swap marketplace. At its core the DEX places orders onto the Cardano ledger and SORs match and processes them. Orders can either be Smart Swaps or concentrated liquidity positions.

Smart Liquidity Vault

The Genius Yield Optimizer sits on a level of abstraction above the DEX. It executes algorithmic trading strategies defined by each vault as a way to optimize a user’s yield farming opportunities.
Figure 16: Overview of the Genius Yield Platform

Genius DEX Fee Structure

The Genius DEX does not charge a fee for placing an order except for the standard Cardano transaction fee. Therefore, it is almost free to submit a Smart Swap or place a liquidity position onto the Genius DEX.
Order Fee(Smart Swap or Liquidity Position)=Cardano Transaction fee\text{Order Fee} (\text{Smart Swap or Liquidity Position}) = \text{Cardano Transaction fee}
A fee is only paid when the order gets executed by a Smart Order Router. The execution fee is charged as a percentage of the total order value and is divided into two components.
where
  • Genius DEX Fee: fees to the Genius Yield company, 20% of which is returned to GENS holders through the GENS staking program
  • LP Fee: fees to the liquidity provider
As mentioned in Section 3.3, the Smart Order Router operator does not get a cut of the execution fee, instead earns profits from the bid/ask spread. That means the DEX user does not pay for its order to be matched and processed, instead the market’s inefficiency does. This is an elegant solution to align incentives across the three parties while providing the cheapest possible price for the DEX user.
Note: the exact fee percentage breakdown is being researched. The document will be updated once finalized.

Smart Liquidity Vault Fee Structure

The Smart Liquidity Vault fee structure is centered around the vault fee. Smart Liquidity Vaults give users access to AI-powered algorithmic trading strategies. These vaults are actively maintained and optimized by the Genius Labs team, charging a management fee combined with a performance fee.
Vault Fee=Management Fee+Performance Fee\text{Vault Fee} = \text{Management Fee} + \text{Performance Fee}
where
  • Management Fee: fee charged as a percentage of the TVL (Total Value Locked) in the vault, 20% of which is returned to GENS stakers
  • Performance Fee: fee charged as a percentage of the profits generated by the vault strategy, 20% of which is returned to GENS stakers
Note: the exact fee percentage breakdown is being researched. The document will be updated once finalized.

GENS Staking Program

GENS token is only an utility token, therefore it is not used for any transaction payments. However GENS holders can choose to stake their GENS in a Genius pool to earn extra rewards through yield farming and other platform benefits.
GENS token’s value centers around the GENS Staking Program. The program is incentivized to create high demand for GENS by providing staking yields. APY generated by staking GENS comes from two sources, as outlined in Fig. 17.
Figure 17: GENS Staking Program reward structure
Staking Rewards:
  1. 1.
    Redistribution of 20% of Genius Yield platform fees
  2. 2.
    Earn GENS through liquidity mining incentives
GENS staking isn’t just a source of yield, it also unlocks a number of platform features.
Staking Benefits:
  1. 1.
    Access to advanced DEX trading features
  2. 2.
    Access to premium Smart Liquidity Vaults
  3. 3.
    Governance i.e. voting power in Genius Improvement Proposals (GIP)
  4. 4.
    Unlock Genius NFTs
  5. 5.
    Get access to Genius X sales
  6. 6.
    Get access to Genius Academy premium content