HomeKnowledge BaseNavigating the Evolution of CoW Swap: From Market Orders to Programmatic Orders

Navigating the Evolution of CoW Swap: From Market Orders to Programmatic Orders

6 min read

CoW Swap, a DEX trading platform, has undergone a remarkable transformation over the last few years.

The platform has transformed substantially from its early days as a dutch auction swap to a leading authority on intents forging new ground through conditional programmatic orders. In a recent presentation, Alex Vinas, the Product Marketing Manager at CoW Swap, traced CoW Swap’s journey and offered insights into its history, pivotal developments, and the promise of the brand new Programmatic Order Framework (Please Note: At the time of the presentation, the Programmatic Order Framework was known as “Composable CoW.”)

What follows is a transcript of Alex’s talk:

A Brief History of CoW Swap

1-navigating-the-evolution-of-cow-swap.webp

Cow Swap’s journey began back when its current team was a part of Gnosis. At the time, the team was working on decentralized mechanisms for trading prediction market outcomes. It was this work that helped bring to life the famous “x*y=k” formula for AMMs back in 2017 — earlier than even the founding of Uniswap.

Dutch Auctions

While their initial ideas were good, Gnosis recognized the vulnerabilities of the traditional AMM design and its weakness toward MEV, so the team pivoted to Dutch auctions.

However, this mechanism also came with its own set of downfalls.

It worked well for initial coin offerings and wasn’t susceptible to MEV, however it fell short when faced with the growing diversity of tokens on Ethereum. Dutch auctions also had to compromise on speed, resulting in a slow trading experience for users.

Batch Auctions

The team realized they needed a new auction mechanism for trading large amounts. It was here that the batch auction was born.

After cycling through several different iterations of batch auction DEX’s, CoW Protocol was born in 2021. CoW Protocol was built on the learnings from earlier projects and introduced innovative features like an intents-based architecture and comprehensive MEV protection.

The product was designed to address the challenges faced by retail users, smart contract accounts, and decentralized autonomous organizations (DAOs). At the core of the protocol is a delegated trading execution model in which bonded third parties known as “solvers” handle order execution on behalf of users.

The delegated trading model of CoW Protocol offers several benefits:

  • For retail users, it abstracts away Ethereum complexities such as gas fees, MEV, and the need to search for the most up-to-date AMM pools
  • For smart contract wallets, it enables a seamless trading experience. Before CoW Swap, smart contract wallets often had their trade execution paths expire by the time they gathered signatures. Today, smart contract wallets only commit to a particular price (rather than a specific trading path), leading to more flexibility and optimizing order execution
  • For DAOs, features like the Milkman contract bridge the gap in time between a governance proposal and an on-chain swap by allowing the DAO to specify an on-chain price feed from which to pull real-time prices (rather than specifying a fixed price)

The Path Toward Smart Contract Intents

Initially, gasless trading was limited to EOAs since smart contract wallets don’t have private keys and thus can’t sign messages. It wasn’t until the introduction of ERC-1271 smart orders that gasless trading was enabled for smart contracts using a new method called “isValidSignature.” This allowed smart contracts to delegate order placement while maintaining control through interactive signature verifications.

The first implementation of smart orders in CoW Swap was the native ETH flow which allowed traders to trade ETH just like they would any other ERC-20 token. The second implementation was the Milkman contract. Milkman protects governance-based swaps from price exploitation as users specify an on-chain data source from which to pull prices rather than specifying a fixed amount and slippage. This allows the “minOut” variable of a swap to be modular and enables much more streamlined governance-based swaps.

While ERC-1271 smart orders have advantages including conditional on-chain guarantees, they also have drawbacks: they are gas-heavy for autonomous execution, require trust in an intermediary contract holding funds, and are limited to one order per signature.

Enter the Era of Programmatic Orders

Programmatic orders build on top of batch auctions to enable even more user-friendly, trustless, and autonomous trading.

Programmatic orders take advantage of ERC-1271 smart orders to unlock intents for smart contracts. This has been transformative for the ecosystem, as it allows smart contracts to delegate order placement while still ensuring secure and customizable trading conditions.

The Programmatic Order Framework from CoW Protocol allows users to execute unlimited smart orders in parallel, with enhanced gas efficiency and full self-custody. The Framework opens the door to a number of use-cases including automated fee collection, DAO payrolls, TWAP orders, and even private conditional orders such as stop-loss.

Understanding the Programmatic Order Framework Architecture

Programmatic orders operate through a decentralized architecture that ensures trustless execution by holding assets in the user’s safe.

2-navigating-the-evolution-of-cow-swap.webp

The Programmatic Order Framework involves four main customizable parameters which combine with the order handling of CoW Protocol to allow developers to deploy ANY codeable strategy.

Each conditional order has the following properties or data available at settlement:

  • handler — verifies the conditional order parameters via a smart contract (Programmatic Order Framework)
  • salt — allows for multiple conditional orders of the same type and data (Merkle root)
  • staticData — data available to ALL discrete orders created by the conditional order
  • offchainData — data optionally provided from off-chain to a discrete order

The Future of Programmatic Orders

Programmatic Orders open a world of possibilities by allowing users to turn their Safes into autonomous traders. While the Programmatic Order Framework is currently developer-focused, it unlocks a wide range of use-cases for retail users as well. The integration of CoW Hooks in the future could further enhance the user experience, combining composable smart orders with additional functionalities.

In conclusion, CoW Swap’s journey to perfect DeFi orders embodies the protocol’s commitment to users and innovation. The Programmatic Order Framework emerges as a pivotal milestone, showcasing CoW Swap’s adaptability and dedication to meeting the evolving needs of the crypto community.