CPSC 3640 / CPSC 5400

Decentralized Payments, Contracts, and Finance for Humans and AI

Lab 2: Design a Better AMM

  • Released: Sunday, October 25, 2026
  • Due: Monday, November 2, 2026 at 11:59 PM ET
  • You can collaborate (e.g., discuss) with another student, but each student should submit their own results.

Introduction

In this lab, you will design a fee strategy for an AMM and make a submission to Paradigm’s AMM puzzle.

Setting

Your AMM serves ordinary traders who want to exchange tokens and arbitrageurs who profit from differences between the pool’s price and the outside market price. It competes with another AMM that charges a fixed trading fee. Your goal is to earn fees without losing too much to arbitrageurs.

Dynamic fees

In class, we covered fixed fees, but a fixed fee that works well for volatile markets may not work well for stable markets. This lab asks you to design dynamic fees.

Recall PS2’s question “Fees Create a Bid–Ask Spread in a CPMM”: fees create a range of market prices within which arbitrage is not profitable. A higher fee widens this range. For example, suppose your pool prices ETH at 2,000 USDC, but its market price jumps to 2,020 USDC. A 0.3% fee raises the pool’s ask price to about 2,006 USDC per ETH, so arbitrageurs can still buy underpriced ETH from your pool and profit. A 1% fee raises the pool’s ask price to about 2,020.20 USDC, making it unprofitable to buy from the pool and sell at 2,020 USDC. However, keeping that fee high when prices are stable may drive ordinary traders to the competing AMM.

You will write a Solidity strategy that sets your AMM’s fees and can update them after each swap. The hard part is that your strategy cannot directly observe the outside market price or tell whether a trader is an arbitrageur. It must infer what is happening from the swaps it sees.

How to work on this lab

This lab is intended to be solved using AI. We have covered the basic concepts for you to understand the task, but we haven’t covered the math behind the most advanced solutions. This is the point: with the help of AI and an understanding of the basics, one can solve difficult problems.

Suggested strategies:

  1. Understand the problem with the help of your agent. Start with the puzzle instructions and starter code.
  2. Ask your agent to start with something simple. Submit a valid solution to check that the submission process works and earn your 60 points.
  3. Work with your agent to improve. You can take the scholarly route: ask it to find and explain relevant papers. You can give it your own intuitive ideas to test, or take the brute-force route and ask it to give you the best strategies. There is no single recipe for the best solution.

Papers that might be helpful:

What to submit

Submit a PDF through Canvas containing:

  • A link to your Paradigm submission (example).
  • An explanation of your strategy.

You can use the LaTeX template for your PDF submission.

The authors of the top three submissions will be asked to share their strategies with the class.

Grading

Any valid, evaluated submission earns 60 points. The remaining points come from your global leaderboard rank (up to 20) and your rank within the class (up to 20). The global bonus reaches 20 points at rank 3 or better. The class bonus grows superlinearly as you approach the top of the class.