TWAMM Research: JanuaryΒ 2023

SpearbitDAO audit done βœ…, 0 criticals found 😎, guarded launch by ETH Denver πŸš€! In other news, the fallout from FTX has continued to erode trust in centralized services. OTC desks are seeing a massive drop in volume and this trend will continue as DeFi native options come online. Traders will no longer need to take on counter-party risk for optimal execution.

DAOs Trading On-Chain

There have been a few DAOs that recently conducted large treasury sales and buybacks. BitDAOs proposal to buy $2M USDT worth of $BIT tokens over 50 days is exactly the type of use case that TWAMMs are built to serve.

Another proposal was ENS DAO, even though the community wanted a DCA option, they elected to conduct it via CowSwap because that gave them the best execution. Unfortunately, our TWAMM was not live yet, or it would have been the preferred solution by the DAO.

Drawbacks of DEXs & Aggregators

@0x94305 did a great analysis thread on how the execution of the ENS trade cost roughly $100k. One of the difficulties DEXs and Aggregators have is that they have to execute the trade in a very short time frame, usually in a single block. Although the slippage was relatively low, the handicap is insurmountable in a single block.

@0xShitTrader wrote a great piece on how these trades are meant to be executed on a TWAMM and the fallbacks other execution platforms face. tldr; TWAMMs minimize value left on table and maximize transparency.

We also wrote up a short post on the ENS DAO forum explaining the pros & cons of leveraging TWAMMs. Working with talented treasury management teams like Karpatkey, we can help ENS diversify the 40,000 ETH in their endaoment.

The good news is this is only the start, more DAOs, protocols, and even whales will need to swap large amounts on-chain and TWAMMs will be able to meet that demand!

Product Updates

This month was largely focused on preparing our code for audit and addressing the issues brought up by the SpearbitDAO auditors. We had an amazing experience with the audit, and couldn't be happier with the results! There were 0 critical issues found, and a few high-risk issues that were immediately patched.

Audit Process

In small teams, it's important to shake things up with different perspectives if you don't have additional developers to review work and ensure there are no mistakes. One approach we took to get ready for our audit besides analytical tests and a block-accurate Typescript model of our TWAMM pool was to create a system diagram.

The diagram below shows annotated container types, representation types, flows, and transformations--all facilitating analysis of data paths and any potential errors we may have overlooked in our other processes. This is a time-consuming and difficult process and although we didn't perform it for the entire system at large, we were able to take advantage of several unchecked arithmetic optimizations as a result of it, thereby saving users gas fees.

Code Updates

Between preparing for the audit and working closely with the auditors to rapidly address issues and concerns, the Cron-Fi TWAMM product underwent some significant changes:

  1. Removal of the configurable Liquidity Provider holding period penalty.

  2. Removal of protocol-specific arbitrage partner infrastructure.

  3. Modification of the staking algorithm's proceeds scaling system.

The first change, removing the holding period penalty, was an important simplification of the contract that reduces gas use, contract size, attack surface area, and UI complexity for a risk that might be better managed outside of the contract. The threat itself is relatively low, but cannot be accurately predicted at this time due to a lack of reliable data in estimating attackers with large sums of liquidity gaining reward information to provide large amounts of liquidity that are then removed after gaining outsize amounts of recent MEV rewards.

The second change was a holdover from earlier days that cleaned the contract up significantly while reducing attack surface area and making the arbitrage incentive system more extensible.

The third change in conjunction with others that go unmentioned herein are
exciting and will be detailed in our forthcoming paper on our development
process and numerical analysis. What's important to note about this change is
that it allows the Cron-Fi TWAMM contract to keep its advantageous gas
optimization while being robust in the face of significant reserve magnitude
disparities--be they the result of decimal place differences or price
movements.

Next Steps

In the upcoming 2 week fix period, we plan on polishing the code further, creating a periphery contract, generating documentation, and preparing for the guarded launch of ETH/USDC & OHM/DAI pools.

Additionally, we’ll be attending ETH Denver for the first time! So if you’re a DAO, protocol, whale, LP, arbitrageur, or simply an interested party of TWAMM please reach out and let’s meet IRL!

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.