1/5
## Constant Sum AMM We're going to discuss a different type of AMM called a constant sum AMM. The mathematical equation for a constant sum AMM is: ``` x + y = L ``` Where *x* and *y* are the token balances. For example, let's say we have starting token balances of 100 for *x* and 100 for *y*. Similar to a constant product AMM, the token balances must fall on a line (we'll call it the orange line). We'll disregard any negative values; all token balances must be greater than or equal to 0. Let's say we add 50 *x* tokens. The new *x* balance will be 150. Since the token balances must be on the orange line, the *y* balance must be 50. The difference between constant sum and constant product is that the exchange rate for a constant sum AMM is always 1:1. For every *x* token added, a *y* token is removed. And this is true no matter how many *x* tokens are added. For example, if we add 75 *x* tokens, 75 *y* tokens will be removed. The same is true if we remove *x* tokens. Let's say we remove 50 *x* tokens. We started with *x* = 100, so now *x* = 50. To maintain balance on the orange line, we must add 50 *y* tokens. The important takeaway with a constant sum AMM is that the amount of tokens you put in is the amount of tokens you get out. The exchange rate is always 1:1.
A simple introduction to Constant Sum AMM - This lesson covers the basics of Constant Sum AMMs, including their mathematical equation, token balances, and exchange rate. The lesson also includes a visual demonstration of how token balances change within a Constant Sum AMM.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
How to build a DeFi stablecoin and customized NFT
How to deploy your smart contract on ZKsync with Moccasin
Advanced testing techniques like stateful and stateless Python fuzzing
How to write algorithmic trading scripts in Python
Hashing signatures, proxies, delegate calls, upgradable contracts, random numbers, and more!
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on April 21, 2025
Duration: 2h 21min
Duration: 1h 58min
Duration: 2h 55min
Duration: 1h 55min
Duration: 46min
Course Overview
About the course
How to build a DeFi stablecoin and customized NFT
How to deploy your smart contract on ZKsync with Moccasin
Advanced testing techniques like stateful and stateless Python fuzzing
How to write algorithmic trading scripts in Python
Hashing signatures, proxies, delegate calls, upgradable contracts, random numbers, and more!
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on April 21, 2025