TWAMM Research: Ferbruary 2023

First they ignore you, then they laugh at you, then they fight you, then you win.” It looks like we’re clearly in the fight phase now. After the recent banking meltdown (unrelated to crypto), Signature bank the last remaining large crypto-friendly bank was shuttered as well to completely choke out crypto on-ramps.

Unfortunately for the old guard, crypto has shown people a new way to control their financial future. You no longer have to trust centralized institutions with your life savings, just for them to mismanage it and lose it all in the next crisis. The final frontier is completely untethering from these centralized services and being completely on-chain!

Centralized Losses & Decentralized Wins

The fallout from the banking failures has been especially difficult for centralized exchanges and services that rely on them for settlement. OKCoin had to pause its OTC services while dealing with the banking contagion.

On the other hand, DEXs continued to operate under stress with zero downtime. There were record daily volumes transacted (~$22B) this past weekend. Users don’t have to worry about where their assets are or if they’ll be able to swap out risky assets on time because decentralized services give you complete control.

Final Frontier: Onchain

From the Luna crash, 3AC implosion, FTX scam, SVB mismanagement, and unprecedented foreclosure of Signature bank, it’s abundantly clear that relying on a few benefits of centralized services is not worth the risk. Moving assets off-chain is hazardous and incurs a huge opportunity cost.

Forward-thinking exchanges like Coinbase realize this and are already providing services to enable fully on-chain fund management. With Wallet as a Service, Coinbase users can be seamlessly integrated into DeFi protocols without having to jump through hoops or give up custody of their assets.

Product Updates

After completing the audit of our core contract earlier this month, we were invited to speak in a session hosted by Flashbots & Rook on the Numerical Analysis of a Non-Atomic Execution protocol. The presentation gave a background of TWAMM with select details on our optimizations and then proceeded to give an overview of the processes we employed to address numerical analysis considerations of our product.

Although it might seem heavyweight, it's important to consider that TWAMM's complexity exceeds that of most existing Constant Function Market Makers (CFMMs) and is also expected to execute significantly larger trades. The processes for numerical analysis included:

  • Code conventions:

    • Variable naming that differentiated representations from container sizes.

    • Tags for unchecked sections, expected overflows, and expected underflows

  • Annotated system schematics created from the Solidity code illustrating:

    • Data path widths and their propagated representations

    • Revert and require checks

    • Arithmetic operations

    • Storage

    • Color-coded confidence in the analysis

  • Focus area abstraction diagrams that helped guide general corrections (i.e. avoid token creation with operators that round up)

  • Concrete case studies of intended applications and extrema

See the full presentation on our documents page.

Automated tool flows would have been very helpful for much of this work (some of which were presented at Eth Denver, i.e. “HardSol: A Next-Gen Solidity Security Tool”). We also presented the key aspects of our development process that were helpful (a comprehensive safety test comparing our contract to an independent model and select analytical example calculations as well as a benchmark gas use design).

Dynamic Fees

The A16Z article "LVR: Quantifying the Cost of Providing Liquidity to Automated Market Makers" gave us much to think about improving the experience of LPs in Cron-Fi's TWAMM protocol. TL;DR: the article explains that AMM designers need to consider mechanisms to reduce impermanent loss, favoring rebalancing over arbitrage. One mechanism highlighted in the article is dynamic fees.

While Cron-Fi's TWAMM doesn't inherently have dynamic fees built into the contract (it was a late consideration, specifically a mechanism tied to the sales rates of each token, applying an asymmetric swap fee to the pool to increase the share captured by LPs during significant price movements in a particular direction), it does feature the ability to independently modify fees between 0 and 1% for short-term, partner, and long-term swaps. This would allow an external controller to monitor pool metrics and institute dynamic pricing when appropriate.

In addition to dynamic fees, the extensibility of Cron-Fi TWAMM pool's reward feature may offer the ability to incentivize rebalancing over arbitrage for the benefit of LPs and LT traders alike.

Successful Audit

Finally, we have completed the main audit for the protocol and the report has been published. We are preparing for a minor follow on audit for the delegate feature and periphery contract at the end of the month. After which, deployment to mainnet is planned for the first week of April.

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.