Pisa Fees: A Decentralized Protocol for Paying Transaction Fees with Non-ADA Assets
Transaction fees are a fundamental component of the Cardano network. They maintain the network's health and decentralization by rewarding stake pools and delegators while contributing to reserve funds. The ledger requires all transactions to pay fees in Cardano's native currency, ADA. Hence, it is commonly understood among community members that transaction fees are payable only in ADA.
However, Pisa Fees introduces an innovative solution that allows transaction fees to be paid in any Cardano native asset, all while maintaining full decentralization without requiring complex ledger modifications or obligating liquidity providers to operate nodes.
How It Works
Pisa Fees is a lightweight Cardano smart contract designed to enable DEX-like operations, specifically for swapping transaction fees. Understanding Pisa Fees requires a basic grasp of how the Cardano ledger verifies transaction fees.
The ledger calculates transaction fees by comparing the total value of inputs with the total value of outputs. The difference between these values determines the fee amount. Importantly, the ledger does not require fees to originate from a user address; as long as the required amount is present within the transaction, it is valid. This flexibility allows even smart contracts to "pay" for transactions, which is the core idea that allows Pisa Fees to exist.
When users wish to pay transaction fees using a token of their choice, Pisa Fees facilitates this by accepting the token and releasing a corresponding amount of ADA. The released ADA is sufficient to cover the transaction fees, satisfying the ledger's requirements. From the ledger's perspective, the transaction includes the correct amount of ADA for the fee. This process, where users swap tokens to cover transaction fees, is referred to as a "Feeswap."
Fully Decentralized
The Pisa Fees smart contract is fully decentralized, meaning it operates without centralized state threads or on-chain parameters that would introduce dependencies. It is intentionally designed as a standalone system, with all required states managed within the datums of its UTxOs. This design minimizes the cost of using the Feeswap feature.
Each Liquidity Provider creates a position by sending ADA to the Pisa Fees address, accompanied by a datum specifying:
The desired exchange rates for tokens they wish to trade using the supplied ADA.
Their public key hash (pubkeyhash) which will be used to retrieve any leftover ADA or exchanged tokens.
The smart contract ensures security by only unlocking funds under three conditions:
The transaction is signed by the position owner.
The transaction performs a valid Feeswap, where the script accepts the correct amount of the target asset at the specified exchange rate in exchange for releasing ADA.
The provided datum is not malformed. This criterion is to prevent a Denial-of-Service attack by spamming UTxOs into the Pisa Fees address.
Users of the protocol can select any Pisa Fees UTxO (referred to as a "fee position") to perform a Feeswap. Typically, users will look for positions with sufficient ADA to cover transaction fees and one that accepts their desired non-ADA asset to trade with. If multiple positions meet these criteria, the backend algorithm will prioritize those offering the most favorable exchange rate. Most of this position-selection process will be automated through backend implementations.
UTxO Contention
UTxO contention is a common issue in UTxO-based blockchain networks such as Cardano and Bitcoin. In these networks, the tokens held by users or smart contract accounts are represented as unspent transaction outputs (UTxO) that users can unlock and spend in subsequent transactions. While this design is less problematic for user accounts—since users typically send transactions sequentially—it becomes more challenging for smart contracts, which are accessible to multiple users simultaneously. When multiple users attempt to spend the same script UTxO at the same time, a race condition occurs. Inevitably, only one transaction will be successfully submitted to the network, causing all other transactions with similar intentions to fail. This phenomenon is known as UTxO contention.
The current design of Pisa Fees adopts a first-come, first-serve approach for conducting fee swaps per UTxOs, which raises valid concerns about UTxO contention. Multiple users attempting to access the same position simultaneously may encounter double spending and may experience the UTxO contention issues described above. This contention issue is an inherent trade-off to the design of the protocol made to favor a minimal and efficient script.
Fortunately, a robust solution exists. The task of indexing positions and preventing double-spending is offloaded to the Pisa Fees backend. Rather than relying on each off-chain integration to balance and submit transactions individually, the backend accepts unbalanced transactions, runs a balancing algorithm using the users' balances and configuration, and submits the finalized transactions. By processing transactions sequentially, the Pisa Fees backend strategically selects UTxOs to prevent double-spending.
Users can still interact directly with Pisa Fees by building transactions locally, bypassing the backend. In these cases, double-spending remains a potential issue as the Pisa Fees backend can not detect independent users' choice of UTxOs. However, we anticipate such occurrences to be infrequent due to Pisa Fees' horizontal scalability (explained in detail below). Even when UTxO contention issues arise, for users using the Pisa Fees backend automated mechanisms will detect and resolve these conflicts by retrying new positions, ensuring a seamless experience. Additionally, if UTxO contention proves more problematic than expected, our team has plans to extend the smart contract to allow liquidity providers to mandate the use of specific Pisa Fees backend operators.
This design also offers a significant advantage: scalability. With the backend handling the majority of requests, Pisa Fees can achieve horizontal scalability at no additional cost. Since positions operate independently, the system can support higher market demand simply by creating additional positions.
Business Model
The Pisa Fees protocol adopts a laissez-faire approach to pricing and profitability, imposing no restrictions on profit margins or price configurations. This flexibility allows users to optimize their position settings to maximize profitability.
The exchange rate for Feeswap is determined by market dynamics. Additionally, there is an option to collect a fixed fee for every Feeswap transaction. Upon initial launch, MLabs will serve as the first provider of Pisa Fees backend services. We will regularly update prices to align with market exchange rates to prevent unreasonable profit margins initially.
Use Cases
The concept of using non-ADA tokens for transaction fees is entirely new to the Cardano community. So, below are some potential applications to spark new ideas to integrate Pisa Fees into projects of your own:
Blockchain Integrations for Games
Many outstanding game projects are utilizing the Cardano network to power in-game currencies, items, and other assets. However, when each game employs its own currency, facilitating in-game transactions—such as transferring items or currency between users or smart contracts—require players to fund their wallets with ADA to cover transaction fees. While this process may be straightforward for seasoned Cardano enthusiasts, it can pose a significant barrier for casual gamers unfamiliar with blockchain technology, potentially discouraging them from engaging with blockchain-powered games.
By leveraging Pisa Fees, game developers can simplify this process. Pisa Fees allows game developers to enable users to conduct transactions using in-game currencies without the need to continually "charge up" their ADA wallets to continue the game. This greatly enhances both accessibility and usability.
Moreover, because Pisa Fees operates via smart contracts, game developers don't need to run their own Cardano nodes. They can simply generate Pisa Fees UTxOs, making implementation straightforward, cheap, and easy to maintain.
DeFi Integration
As a flexible, single-script protocol, Pisa Fees can seamlessly integrate with existing decentralized finance (DeFi) smart contracts. For example, decentralized exchanges (DEXs) like Minswap could use Pisa Fees to facilitate swaps between tokens, such as DJED and LQ, without requiring users to spend ADA on transaction fees. Similarly, lending protocols like Liqwid could enable users to supply LQ to smart contracts without drawing ADA from their wallets.
While this may sound like a small convenience, it is particularly valuable for users with low-valued accounts who wish to explore different DeFi protocols. By eliminating the need to continuously top up ADA for transactions, Pisa Fees makes Cardano's amazing DeFi ecosystem more accessible, encouraging broader adoption and showcasing the innovative opportunities within Cardano's DeFi space.
Beyond
The use cases for Pisa Fees are virtually limitless. This protocol can be applied to any transaction involving the transfer of non-ADA tokens, significantly enhancing user accessibility. From wallet actions to airdrops and beyond, Pisa Fees offers unparalleled flexibility for a wide range of applications.
The Future of Pisa Fees
The initial development of Pisa Fees was funded by Catalyst Fund 12. So far, we have successfully developed the on-chain scripts, conducted extensive testing, and implemented parts of the backend. To further advance the Pisa Fees project, we have submitted a proposal for Catalyst Fund 13, aiming to complete the backend development and integrate an off-chain framework with support for CTL, Lucid(-evolution), and Atlas, making Pisa Fees available to be integrated into existing and new projects as easy as possible.
If you find Pisa Fees interesting or believe it could enhance your projects' user experiences, we encourage you to check out and vote for our proposal in Catalyst Fund 13. Your support will help us greatly in delivering Pisa Fees early next year!
See our full proposal here:
https://cardano.ideascale.com/c/cardano/idea/132201
Acknowledgement
I want to mark my heartfelt gratitude to Mikhail Lazarev (Misha), Jordan Hill, Rajdeep Maity (Chase), and Luke Mahoney for your outstanding contributions and dedication. Your efforts have been instrumental in making our vision into reality. This project would not have been possible without your invaluable support and collaboration.