TxPipe and the Evolution of Sundae v3

Sundae Labs
2 min readMay 15, 2024

At Sundae Labs, we’re committed to ensuring that our decentralized exchange operates with the utmost efficiency and security. As part of our continuous effort to optimize our platform, we recently invited TxPipe to audit our new smart contracts. Their excellent report can be read in full here. Their insights were invaluable, not only in enhancing performance but also in fortifying our system’s security. They caught 2 critical vulnerabilities, 2 major vulnerabilities, and many smaller suggestions for improvements. In this post, I want to share how we’ve incorporated TxPipe’s feedback into our smart contract design.

Early Insights for Lasting Improvements

We engaged TxPipe early to review the design of our contracts, before they were finalized. This is how we encourage companies to engage us for their audits, and we believe this produces the best results.

This feedback was crucial for shaping early iterations of the contracts. Perhaps the largest area of impact that TxPipe had was in helping us develop an understanding of the performance characteristics of our contracts. Beyond just shaping how we thought about performance, they made several concrete suggestions:

  • They suggested we use anis_sqrt method, instead of directly calculating the square root inside of the contract, which saved significant costs when minting a new pool
  • They helped us simplify our our fee calculation logic to a single expression, rather than many summations
  • They provided an optimized implementation for calculating powers of 2
  • They recommended the removal of several redundant parameters and checks
  • They helped us simplify the formulas for calculating the LP tokens minted when depositing tokens.
  • Plus, many other great suggestions which are detailed in the report above.

Beyond the Audit: Innovations and Features

The audit was a pivotal part of our design process, but conversations with users and reflection on our own design patterns lead to extensive improvements as well.

We added a fee_manager feature, which allows for more flexible and efficient management of liquidity provider fees. Recognizing the importance of versatility in DeFi, we also introduced a pool mint fee to provide the DAO with an additional future source of income.

Moreover, the integration of Oracle and Donation orders mark a significant enhancement in how the Sundae protocol can integrate with other DeFi primitives, enabling powerful cross-protocol collaboration. Lastly, we’ve implemented the ability to evaporate pools, adding a layer of control and security that helps maintain the integrity of the trading environment.

Looking Forward

The journey of continuous improvement is never complete in the world of blockchain and DeFi. Each step we take is aimed at providing our users with a safer, more efficient, and user-friendly platform. The insights from TxPipe’s audit have been instrumental in this process, and we are grateful for their expert guidance.

We’re excited about the future of SundaeSwap and the innovations we continue to bring to the DeFi space. Stay tuned for more updates, and as always, thank you for your support and trust in us.



Sundae Labs

Building sweeter blockchain infrastructure. One scoop at a time. Website: https://sundae.fi/