MetaMask Swaps Case Study: Removing User Frictions from P2P Trading

ConsenSys teams MetaMask and Codefi collaborated to create MetaMask Swaps, a price information aggregation feature that ensures users have the best prices with the lowest network fees.

  • ConsenSys teams MetaMask and Codefi collaborated to create MetaMask Swaps, a feature that draws information from multiple decentralized exchange aggregators, professional market makers, and individual DEXs—including Uniswap, AirSwap, 0x API,, Paraswap, and Totle—to ensure users have the best pricing information with the lowest network fees.
  • MetaMask users also benefit from additional features which provide for fewer approvals, reduced gas costs, and user-interface tools such as slippage protection.
  • The simple, streamlined experience reduces friction for new token users—bringing more people, greater transparency, and increased efficiency to DeFi on Ethereum.




A disjointed peer-to-peer trading experience involving various liquidity protocols, multiple approvals, and high gas costs

The year 2020 saw the largest scale adoption of decentralized exchanges (DEXs). Compared to centralized exchanges, DEXs offer more pairs when trading, provide access to a greater diversity of tokens, and enable non-custodial swaps that keep funds safer. However, DEX users often don’t receive the best price when there is insufficient liquidity, or if a particular DEX doesn’t offer the most attractive price.

Before MetaMask Swaps, users needed to navigate many DEXs to compare prices and swap tokens. However, using a single DEX or DEX aggregator did not always yield the best price for every trade, as each aggregator performs differently under different circumstances. Additionally, users needed to approve each token on each DEX, incurring expensive gas costs.

MetaMask collaborated with the Codefi team to solve these problems, remove friction for millions of users, increase the efficiency of these systems, and further democratizing access to Web3 and DeFi.




A Price Information Aggregation API to remove user frictions and increase trade flow efficiency

MetaMask and Codefi together built Swaps, a feature that enables any Web3 or DeFi user to easily access the tokens they need for the sites they use. This gives users the flexibility to shop for the best decentralized exchange rates before making their purchase, via:

  • Real time pricing information from multiple sources
  • A secure, reliable digital wallet
  • The convenience of the MetaMask app or web browser extension


Empowering Users to Select the Best Prices

The pricing offered through decentralized protocols depends on factors such as the size of a swap and the tokens a user is attempting to swap. Certain decentralized exchange protocols appear to perform better for certain types of trades. For example, automated market makers appear to provide users the best quotes for smaller trades, while request-for-quote based protocols appear to perform better for larger trades. By drawing information from the largest decentralized exchanges in the ecosystem— including Uniswap, AirSwap, 0x API,, Paraswap, and Totle—MetaMask Swaps allows users to access real time pricing information from a variety of sources all from the safety of their wallet. 


Improving MetaMask’s User Experience for Swapping Ethereum Tokens

In addition to solving the price inefficiency problem, the Codefi Markets team also sought to improve user experience across multiple protocols. Each protocol (and the user interface that comes along with it) involved different paths to complete a trade. The Codefi Markets team abstracted these flows for MetaMask customers and provided a user interface for previously unconnected decentralized protocols— simultaneously providing solutions for both price inefficiency and user experience.

All underlying smart contracts for MetaMask Swaps were audited by ConsenSys Diligence. A report can be found here.

Codefi pioneered a new and highly innovative approach to token swaps that allows our 1M± monthly users to access the best rates in the decentralized ecosystem.

Jacob Cantele

Head of Product at MetaMask


A better DeFi experience for the Ethereum ecosystem

By building a single end-to-end experience, MetaMask and Codefi empower Web3 users to browse and interact with the entire decentralized web. MetaMask users now enjoy the following benefits:

  • The best price every time. By requesting prices from all available aggregators, along with individual market makers, Swaps ensures that every MetaMask user always has access to great liquidity, the largest selection of tokens, and the most competitive prices. A service fee of 0.875% is automatically factored into each quote, which supports ongoing development to make MetaMask even better.
  • Fewer approvals. No need to approve every token on multiple DEXs and aggregators for each trade. With Swaps, users only need to approve each token once, reducing gas costs and shortening the path to executing a swap.
  • Reduced gas costs. Each aggregator pursues a different path to locate the best trade. Each route requires a varying amount of gas fees to execute the transaction. Swaps sources the best prices and determines which aggregator is the most gas efficient for every trade.
  • Slippage protection. Large swaps are often subject to wild price swings when there is insufficient liquidity available on a particular DEX. When swapping in MetaMask, orders are spread across virtually all DEXs to reduce slippage impact on the final price.

The simple, streamlined experience reduces friction for new token users, bringing more people into DeFi. It enables more trades, faster, by providing an optimized path for fees. And, crucially, bringing greater transparency and efficiency to decentralized finance on Ethereum. This equates to a better network for all — one with fewer fees and reduced network congestion.

MetaMask Swaps launched in October 2020. As of March 2021, users have completed over 341,000 peer-to-peer swaps worth over US$1 billion.

See the real-time MetaMask Swaps dashboard on Dune Analytics here.

Codefi Markets will make its Price Information Aggregation API available for other Codefi partners—a big step in Codefi’s goal of offering interoperable API-first product modules to power next-generation commerce and finance.