TWAMM Research: September 2022

Ethereum merged successfully and we are officially feature complete 🎉! This milestone was later than we expected, but a big part of designing a robust new DeFi primitive is to ensure that it solves existing problems while being flexible enough to address impending future needs.

Given how important the topic of MEV has been before and after the merge, we believe the features baked into our implementation including MEV Aware Fee Capture and Automatic MEV Redistribution will help TWAMMs become a critical piece of DeFi infrastructure.

Big Picture

Although the post-merge ecosystem has been relatively quiet, there’s been lots of great discussion in the DEX space on design considerations, order flows, and MEV.

DEX Design Tradeoffs

The general sentiment in the market is that retail traders & professional LPs should be the focus for optimization. This makes sense given how nascent decentralized trade execution algorithms are and the scarcity of professional trading happening on-chain versus OTC.

However, looking to the future, there will be more advanced on-chain execution algorithms like TWAP, VWAP, and limit orders, etc. This will inevitably lead to more capital flow and trading activity on-chain.

On-chain advantages of programmability and composability of capital are too attractive to ignore. It's important to be cognizant of the unique advantages of DeFi -- the democratization of capital and access. Therefore, we need to strive to sustain the advantages and ensure a profitable enterprise for both minnows and whales.

Leveraging Order Flow

Speaking of capital moving on-chain, capturing order flow has become the goal of all the major MEV players in the space. However, there is more nuance to this statement because we need to discern between toxic and non-toxic order flows.

When a venue is primarily used for MEV trades, retail & passive LPs pay the price of digesting toxic order flows -- over 61% of Uni V3 flow in the last 30 days as seen in Dune Analytics chart below.

Source: Danning Su @ Dune Analytics
Source: Danning Su @ Dune Analytics

The reason such activity happens was covered in our last month’s update, but Benedict hit the nail on the head. Today’s dominant AMMs have naive fee capture mechanisms and execution engines -- two points our implementation of TWAMMs addresses directly.

New Paradigms

The future is really bright for on-chain trading with proper incentives and novel trade execution schemes. And if Coinbase’s new fee schedule is any indication, it’s a very profitable endeavor to be the go-to venue for large amounts of non-toxic order flow!

Product Updates

In the past month, our main focus was achieving feature completion. The primary effort was designing and implementing an MEV reward system that features a disincentive against MEV reward capture attacks. The MEV reward system allows select partners to reward the pool with assets periodically while enforcing a configurable holding period penalty on liquidity providers to ensure large amounts of liquidity are not used briefly to capture unfair amounts of a recent MEV reward.

Additionally, an oracle mechanism similar to Uniswap V2 was added to the pool implementation along with fee configuration for partners, short-term & long-term swaps. These configurable fees range from 0 to 1% and allow a pool to be tuned during operation to be more competitive with other AMMs. Lastly, a gas-efficient configurable fee splitting mechanism was added to allow the protocol to share in LP fees if the fee address is set; the configurable sharing is approximately 33%, 20%, 11%, or 6% with the protocol and uses very little gas when enabled.

MEV Transfer Mechanism

The final feature added is Automatic MEV Renvestment which presented interesting challenges to ensure rewards aren’t improperly gamed. We developed a system that allows LPs to transfer LP tokens and maintain the composability of positions while punishing mercenary liquidity from stealing rewards.

Flow diagram of MEV token transfers that maintains composability and disincentivizes cheating.
Flow diagram of MEV token transfers that maintains composability and disincentivizes cheating.

Testing & Analysis

Below is a snapshot of our current code coverage metrics. Future updates will present gas use details for the various functions as they undergo further optimization. as part of upcoming numerical analysis and optimization iterations. We also plan on releasing an in-depth blog post on our numerical analysis and operational parameter constraints before the product launch.

Code coverage in TWAMM V005
Code coverage in TWAMM V005

Upcoming Work

Next month's work largely involves finishing quantifying the operational limitations of our TWAMM implementation for the numerical optimizations we've made, incorporating safe math where appropriate (our implementation atop Balancer uses Solidity 0.7x, which does not feature built-in arithmetic checks), and further gas optimizations involving parameter use pattern analysis and bit-packing of those variables where possible. The coming work will also feature refactoring and documentation for audit and detailed partner review.

Future Roadmap

With V1 of our product we were able to research and build some really exciting features -- see dashed lines. However, what we have in store for future versions is even more exciting. Given the customer interest & macro conditions, there’s going to be an explosion of on-chain activity powered by these advanced trade execution algorithms!

Features implemented in dashed lines, and solid lines indicate potential future use cases and features
Features implemented in dashed lines, and solid lines indicate potential future use cases and features

Subscribe to 0x70626a
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.