#046: 🚀 Unlocking the Power of Cardano's E-UTxO Model

An Exploration into Cardano Swaps and the Potential of Distributed dApps.

Welcome to Just The Metrics

Read time: 5 minutes

Hey there, Just The Metrics Fam! 😄

Our book “A 3 Step Assessment Framework of Layer 1 Blockchains” went live on Book.io and we are amazed by all your feedback and support! 💙

Thank you so much! If you are curious, check it out here 👇

Powered by #Cardano and Published by book.io!

Okay, now let’s dive into today's topics. This is what we have for you today:

  • 🚀 Unlocking the Power of Cardano's E-UTxO Model: A Revolutionary DEX That Taps Into The Full Potential of Cardano’s E-UTxO Model

  • 💎 Gem of the Week

TL;DR

  • Gain a comprehensive knowledge of Cardano's superior Extended Unspent Transaction Output (E-UTxO) model and how it provides innovative, scalable solutions compared to Ethereum’s account-based approach.

  • Understand the groundbreaking concept of distributed dApps, discovering how they unlock Cardano's E-UTxO potential with examples like Cardano Swaps, a proof-of-concept distributed DEX.

  • Learn about the future of dApps on Cardano, where adopting new design paradigms that leverage concurrency and parallelism is key, paving the way for a new era of decentralized applications on the platform.

A Revolutionary DEX That Taps Into The Full Potential of Cardano’s E-UTxO Model

Trading on blockchains is often perceived as the future of financial transactions, promising decentralization, transparency, and security.

However, a closer look reveals some inherent inefficiencies that make this trading mode financially challenging, notably due to two major issues: impermanent loss and slippage.

These challenges underline why many traditional players have hesitated to embrace blockchain trading fully.

But with the innovative Distributed dApp design that fully exploits Cardano's E-UTxO model, it’s possible to build a DEX that can rival the efficiency of traditional systems

Ok, let’s dive in👇

What is a Concentrated DApp?

Before delving into the details of the revolutionary DEX design, it is essential to understand the concept of concentrated DApps and differentiate them from distributed dApps.

Concentrated DApps are a type of decentralized application architecture where users share a limited number of addresses while interacting with the DApp. This design choice can have several implications, such as centralization of assets, reduced user control, and potential security risks.

Structure and Functioning of Concentrated DApps

In concentrated DApps, users' assets are pooled together into one or more shared addresses, controlled by the DApp's smart contracts. This allows for easier management of funds and consolidation of value, but it comes at the expense of individual user control.

The shared addresses in concentrated DApps are governed by smart contracts that define the rules and conditions for transactions and interactions within the application. While this can simplify certain aspects of the DApp, it may introduce potential bottlenecks and challenges related to scalability and decentralization.

Challenges and Drawbacks of Concentrated DApps

1. dApps aren't truly decentralized in their current form

Current dApps, while built on a decentralized platform, have significant points of centralization. Assets are pooled into shared addresses, leading to centralized control and complex security models involving trusted admin keys, DAO structures, or dApp tokens.

This runs counter to blockchain's decentralization principles and creates scalability challenges.

2. These dApps fall short of facilitating decentralized scalability

As these dApps gain popularity, shared addresses and smart contracts may fail to cope with increased transaction volume, causing performance issues.

3. These dApps fail to facilitate delegation control

Few dApps allow full delegation control over user assets, leading to centralization of stakes as an L1 DApp's popularity grows on a PoS blockchain. Strategies to address this, like dividing asset pools or distributing governance tokens, often result in unequal distribution and inevitable stake centralization.

Distorting Ouroboros' game theory, the decoupling of delegation control complicates the estimation of distortion extent. Thus, it's critical for dApps to allow users full delegation control of their assets, as it's crucial for PoS blockchains' proper functioning.

Inherent Inefficiencies Of The Current DEXs

The Automated Market Maker (AMM) DEX model was developed to facilitate account-based swaps. This model became established largely due to the challenges of implementing order book models on Ethereum's account-based system.

Cardano’s E-UTxO model offers a platform to develop superior DEX models than AMM DEXs. However, even the current DEXs on Cardano, which largely mirror Ethereum's account-based programming, wrestle with several drawbacks, such as scalability issues and asset centralization

Let's consider the key weaknesses:

Impermanent Loss: The necessity for liquidity pools in centralized script addresses induces impermanent loss for LPs. Even with techniques like yield farming and concentrated liquidity, inefficiency persists.

Slippage: Due to insufficient liquidity and market volatility, the executed trade price often deviates from the expected price, leading to slippage. This financial inefficiency results in traders receiving less favorable outcomes than anticipated.

Scaling Issues: Solutions like batchers and execution engines introduce new problems:

  • Intermediaries could exploit their position in the user-protocol interface.

  • Despite mitigating MEV, growing user numbers inflate execution demand, risking intermediary centralization if batchers aren't permissionless.

  • Existing order-book DEXes confront scalability hurdles, with batcher resources unable to scale with user numbers unless new, permissionless batchers join during high demand.

Introduction to Distributed L1 DApps

Distributed L1 DApps, in contrast to concentrated DApps, are decentralized applications where each user has their own personal address while using the DApp. This design allows for greater decentralization and user control over assets.

Advantages of Distributed L1 DApps over Concentrated DApps

Distributed L1 DApps offer several advantages over concentrated DApps:

  1. Censorship Resistance: DeFi as a whole may be perceived as a threat by those in positions of high power. Therefore, censorship resistance is an essential feature for protocols that offer an alternative to the status quo. Fully p2p dApps offer the highest level of censorship resistance of any dApp architecture because users not only have full custody of their assets but can also fractionalize and recompose their interactions across an already decentralized ledger, instead of pooling their assets into one or a few contracts.

  1. Full delegation control: Users maintain full custody of their assets while using the DApp since owner-related actions must be approved by the staking credential.

  1. No “dApp” Tokens: Since contracts are open source and fully p2p, there is no need for additional governance/DAO/yield tokens for distributed dApps. All you need is ADA to pay for transactions and minUTxO fees.

  1. User ID simplification: The address itself can act as the User ID, eliminating the need to place a User ID in a datum and guard its usage.

  1. Improved concurrency: The distributed L1 DApp is naturally concurrent and becomes more concurrent as the number of users increases.

  1. Democratic upgradability: Users can choose to move their assets to an address using a newer version of the DApp's spending script.

  1. Easy integration: The DApp is easily integrable into existing frontends (wallets).

Designing of Distributed L1 DApps

Distributed L1 DApps typically follow a general design pattern:

  1. All user addresses employ the same spending script for a given use case.

  1. All user addresses must have a staking credential.

  1. The spending script delegates the authorization of owner-related actions to the address's staking credential. The staking key must sign, or the staking script must be successfully executed in the same transaction. This particular feature is also known as "Stake Key Overloading."

How is such a dApp design possible?

This dApp design is possible through Beacon Token, the native token standard (work in progress).

What is a Beacon Token?

A Beacon Token is a work-in-progress native token standard on Cardano that simplifies the querying of on-chain data by efficiently tagging it, making it easily accessible by off-chain APIs.

Beacon tokens in dApps perform two key roles:

Directing dApp logic: Through a carefully designed combination of token minting and script validator policies, Beacon tokens control the flow of the application's processes, enabling complex operations.

Data labeling: Beacon tokens tag or label data such as an address, UTXO, or transaction in a way that's meaningful for users. This labeling aids routing and indexing in distributed dApps, allowing the use of existing off-chain APIs for queries.

For example, a simple beacon token can be used to store an “address book” on-chain that spans multiple UTxOs. They can also be used to build complex distributed dApps.

How Do Beacon Tokens Work?

All native tokens on Cardano continuously broadcast their current address and any transactions they have been a part of. However, Beacon Tokens are specifically designed to broadcast information efficiently by tagging on-chain data, making it possible to query this data using off-chain API services.

While all native tokens can broadcast information, broadcasting is usually not the primary purpose of native tokens (e.g., governance tokens). In contrast, a Beacon Token’s sole purpose is to broadcast information, making it easier to identify and access specific transactions, addresses, or UTxOs.

Design of Beacon Tokens

On Cardano, each native token has two configurable aspects: the policy ID and the token name. Beacon Tokens use these to create unique tokens for specific applications, controlling UTxO spends as needed. These tokens are incorporated into the relevant areas to highlight certain transactions, addresses, or UTxOs.

DDoS and bloat prevention are ensured by aligning Beacon Tokens' minting policies with script spending policies. This safeguard enables secure, efficient broadcasting for users of applications like Cardano-Swaps.

Cardano Swaps: a proof of concept DEX based on distributed dApp design

Cardano Swaps is a proof-of-concept distributed DEX that leverages Cardano’s unique features. This section will break down how it works and explain its key functionalities.

Structure of Cardano Swaps

Cardano addresses consist of both a payment credential and a staking credential. Users maintain delegation control over their addresses as long as the staking credential is unique.

Cardano Swaps employs this concept by providing users with addresses composed of identical spending scripts (per swap pair) and unique staking credentials. The spending credential is designed to grant the staking credential authority over all owner-related actions, except for the actual swap execution.

Beacon Tokens are employed to tag Cardano Swaps addresses, making them easily queryable via off-chain APIs like Koios or Blockfrost. All addresses containing a specific native token can be easily found. The UTxO query also returns information about which UTxOs contain reference scripts, allowing users to execute their swaps.

In Cardano Swaps, each trading pair gets its own spending script, which is achieved through the use of an extra parameter. Each combination of swapOffer and swapAsk results in a different spending script, and consequently, a unique beacon policy. The beacon policy-id carries all the information needed to determine the trading pair being used.

Here are some examples:

Simple Swap

Complex Swap

Impactful Features of Cardano-Swaps

So let’s take a look at some of the key features of Cardano-Swaps that would set it apart from other DEXs on Cardano settlement layer (CSL).

  1. Full Custody - users always maintain full spending and delegation control over their assets.

  1. Natural Concurrency - throughput scales with the number of users. No specialized batchers/indexers are required.

  1. Composable Swaps - many swaps can be fulfilled in a single transaction by "chaining" swap logic.

  1. Emergent Liquidity - arbitragers are incentivized to spread liquidity to all trading pairs.

  1. Zero Slippage - minimum swap prices are explicitly defined

  1. No Superfluous "DEX" Tokens - ADA is all you need to pay for TX fees.

  1. Democratic Upgradability - users choose if/when to use new contracts.

  2. Frontend Agnosticism - relatively straightforward integration with existing frontends (i.e. wallets).

What prevents this DEX from deployment on Cardano today?

A notable limitation in deploying Cardano Swaps on the Cardano Settlement Layer (CSL) involves the redundant execution of validator scripts. In simpler terms, when multiple UTxOs are locked by a single validator script, the script has to execute once for every individual UTxO, regardless of whether the transaction validity relies on any specific UTxO.

This issue is particularly apparent in Cardano Swaps, where UTxOs are frequently composed, often from the same address or script. As a result, the validator script needs to execute multiple times for each UTxO. This redundancy not only leads to increased transaction fees but also quickly reaches the maximum limit for script execution units in a single transaction.

An important factor to consider when discussing dApps like Cardano Swaps is the programming language used for their development. Presently, many dApps, including Cardano Swaps, are written in Plutus-Tx, a high-level Haskell-like language that compiles to Untyped Plutus Core (UPLC). The UPLC code is then executed by the cardano-node. Although Plutus-Tx provides auditability and upgradeability, it demands substantial resources.

Newer, more resource-efficient languages that compile directly to UPLC, such as Aiken, could offer up to a 100-fold increase in execution unit headroom. This significant optimization has the potential to render redundant executions a negligible concern.

However, it is worth noting that directly addressing redundancy issues would necessitate hardfork-level changes to Plutus, which is a considerable challenge.

Conclusion

In conclusion, to achieve massive scale on the Cardano, dApps must adopt a groundbreaking approach that leverages the concurrency and parallelism offered by the eUTxO model, moving away from designs resembling the Ethereum Virtual Machine's (EVM) account-based paradigm. Embracing innovative design choices and harnessing the full potential of Cardano's eUTxO model is crucial for this evolution.

The realm of distributed dApps on Cardano is still relatively unexplored, with concepts like Cardano Swaps—a distributed Cardano DEX proof-of-concept employing composable atomic swaps—showing immense promise. By allowing users to maintain delegation control at all times, these pioneering solutions pave the way for a new era of decentralized applications on the Cardano platform.

That's it for this week. See you next Sunday!

Are you interested in sponsoring this Newsletter?

💎 Gem of the Week 🧵

Subscribe to Just The Metrics 👇

Ok, that's it for today. If you like what you are getting here, please

Share Just The Metrics

with friends, family, or just other Crypto & Cardano Enthusiasts

Give us Feeback!

We would love to hear from you!

  • What did you like?

  • What can we do better?

  • Which topics are you interested in?

Write us, we will read and answer every email, pinky promise :)

That's it for today, see you next week!

If you want to learn more about Cardano, crypto metrics and fundamentals give us a follow

DISCLAIMER: None of this is financial advice. This newsletter is strictly educational and is not investment advice or a solicitation to buy or sell assets or make financial decisions. Please be careful and do your own research.

Reply

or to participate.