Scalable decentralized finance
Abstract: This blog presents a fully documented framework for DeFi solutions, such as “Automated Market Makers” (AMMs), on a highly scalable blockchain like the Partisia Blockchain. The framework guarantees fixed prices across independent liquidity pools and effectively addresses front-running with MPC.
Financial inclusion is at the heart of the original narrative that formed the beginning of blockchain and later Decentralized Finance (DeFi). The global financial crisis in and around 2008 revealed several weaknesses in traditional financial systems. The global financial crisis was part of the motivation behind the Bitcoin protocol creation. Although the challenges behind the global financial crisis were more significant than what immutable money could fix, it initiated and accelerated innovations that improved traditional finance and pushed to new horizons.
The very same crisis inspired the origin of Partisia. However, innovation was a different type of decentralized cryptography that was also designed to remove intermediates, which manage private information, such as sealed bids in financial markets. The initial work by Partisia was the world’s first Decentralized Exchange (DEX) with sealed bidding which went into commercial use in 2008.
The Partisia Blockchain established in 2020, is a combination and extension of these two narratives and provides a powerful encrypted computation network and tool set to continue fixing weaknesses in both Decentralized Finance (DeFi) and Centralized Finance (CeFi), as exemplified by the solution described in this blog.
DeFi and scalable blockchains
DeFi is an important part of Web 3.0 and provides solutions that may most likely drive and enhance financial inclusion. This blog focuses on so-called Automated Market Makers (AMM) as a simple and decentralized way to exchange crypto assets. The core innovation behind AMMs is to conduct trading without direct interaction and matching of buyers or sellers of crypto assets. This significantly reduces the complexity of the market solution. Since the entire AMM solution is a set of smart contracts, the security model was also significantly improved as a genuinely decentralized trading platform.
Ethereum has been the most used blockchain platform for AMM solutions. And token bridges–as well as second layer blockchains–have broadened the uptake to other blockchain networks. Recent developments take this development one step further and run AMMs across independent blockchain platforms, i.e. cross-chain DeFi. This poses a set of new obstacles, such as the challenge of representing states (data and tokens) across independent blockchain platforms.
Mechanism to guarantee fixed prices
Another challenge preventing a simple copy-paste of the Ethereum model to sharded or cross-chain blockchains is the economics instilled into the Ethereum execution model. This is primarily the arbitrage opportunity coming from the “all or nothing” execution (atomic execution), as well as the sequential use of the entire AMM solution (one user at a time). With Uniswap (one of the most applied AMMs) for example, a user can swap asset A to asset B, and then swap asset B to asset C, and then potentially swap asset C back to asset A without other users interfering. Sometimes this set of swaps returns profit to the user. This type of arbitrage essentially for free since the public ledger allows anyone to constantly monitor the AMM solution. This is, however, only feasible due to the atomic execution and sequential use of the AMM solution, and cannot be transferred to a sharded blockchain or to cross-chain AMM solutions without additional economic mechanisms.
The Partisia Blockchain team has jointly worked with researchers specializing in AMMs and economic mechanism design. And together developed a mechanism which guarantees fixed prices as well as the “multi-swap” arbitrage opportunities described above. The key component is a “lock-swap” mechanism that guarantees a user fixed prices for a given swap. The mechanism only locks the actual requested trade and allows other users to use all liquidity pools without the non-scalable sequential use of the entire AMM solution as we know it from Ethereum.
The mechanism essentially works as follows: every pool keeps track of two pools, the “actual liquidity pool”, and a “virtual liquidity pool”. The actual liquidity pool keeps track of all the instant swaps, i.e. those that are actually executed. The virtual pool keeps track of the lock swaps, since such swaps might be canceled later on. Hence, by submitting a lock-swap the user secures fixed prices by the lock-swap function, which only affects the virtual liquidity pool. For any user after the lock-swap, the protocol ensures the smallest amount of assets across the actual liquidity pool and the virtual liquidity pool. Hereby, the mechanism favors first movers that fixed prices using the lock-swap function. Unlike the Ethereum sequential use, the lock-swap minimizes the impact on the entire AMM solution so assets can be exchanged in parallel and across independent blockchains and shards. And also in liquidity pools with one or more lock-swaps. Read more about the mechanism here.
In other words, the mechanism ensures the liquidity managed by the AMM solution is put to maximal use in two ways:
- First movers that discover and, hence, secure fixed prices (lock-swap) have a minimal impact on other users’ ability to use the AMM solution.
- The mechanism allows for completely independent execution across shards and blockchains to support unlimited scalability.
The mechanism is designed to fully utilize sharding where transactions are automatically off-loaded across different shards in an ideal way that favors unlimited parallelization, i.e. asynchronous and concurrent execution. This type of sharding is native to the Partisia Blockchain and will be instrumental in ensuring unlimited parallelization needed to match the demand as decentralization flourish. Read more about the sharding model here.
Finally, note that since cross-chain AMMs are similar in nature, the proposed mechanism also supports use of liquidity pools operated on completely separated blockchains.
Remove front-running opportunities
Another challenge and obstacle for a broad uptake of AMM solutions within and beyond the blockchain ecosystem is front-running. On Ethereum and similar blockchain platforms, the AMM transactions are transparent to all, but added to the blockchain consensus model by one or more actors, such as “mempool operators” or “block producers”. The problem is that these actors can delay and place their own AMM valuable transaction, i.e. front-running.
Front-running is a critical problem that needs to be solved for the sake of the users, but also a problem that is critical for the DeFi narrative as a “single point of trust” failure. Fortunately, the advanced encrypted computation that is built-in to Partisia Blockchain provides a decentralized solution, which points back to the original work by Partisia and the first commercial use of MultiParty Computation (MPC) for safeguarding sealed bids.
However, as a big contrast to the first commercial use of MPC, Partisia Blockchain provides a simple interface that allows any developers (without cryptographic skills) to script the required computation and leave it to the network to compile and run the encrypted computations. The concrete solution is an encrypted computation which keeps the actual swap secret until it is fully executed. Hereby, the arbitrage opportunity from frontrunning is effectively addressed.
Regulation and traditional finance
Ensuring that DeFi solutions comply with the jurisdictional regulation is, of course, an obligation for any DeFi service provider. It may also soon be a competitive advantage and a requirement for expanding the use of DeFi solutions outside of blockchain.
While financial fraud regulations, such as KYC and AML, are obvious, matters that are addressed in this blog may become essential regulatory requirements as well:
- First, front-running needs to be effectively addressed, and for the sake of the blockchain narrative, in a decentralized fashion, such as the privacy-preserving swapping on Partisia Blockchain.
- Second, the built-in “free” arbitrage opportunities may not be acceptable for financial regulators. The proposed lock-swap is a simple add-on feature that can be switched off unlike the AMMs on Ethereum where free arbitrage is cooked into the very foundation of the blockchain platform.
- Third, privacy-preserving computation may involve data that need to operate on nodes running in designated jurisdiction, which is a built-in functionality on the Partisia Blockchain.
Although future regulatory requirements are unknown, building a blockchain network that is sufficiently flexible to quickly adjust to regulatory requirements may be crucial. For DeFi service providers that aim at offering DeFi solutions outside of the blockchain ecosystem and in direct competition with traditional financial solutions, regulatory requirements will be instrumental.
Get started and resources
For DeFi teams considering to build the next generation of scalable DeFi solutions on Partisia Blockchain, please find links to the scientific work, description, and template smart contracts below: