5/5
Exchange Overview To swap tokens on Curve V2 AMM, the user will call the `exchange` function. For example, we can use the usdc / wbtc / eth pool, and if the user wants to swap eth to usdc, they will call the `exchange` function and also send eth to the Curve V2 pool contract. The Curve V2 pool contract will calculate the amount of usdc to send back to the user, and then transfer this from the pool to the user. The user also has the option to swap weth instead of eth on the `CurveTricryptoOptimizedWETH` contract. For example, if instead of swapping eth for usdc, the user wants to swap weth for usdc, in the first step, the user will send weth to the pool contract. The pool contract will then convert this weth back into eth. To do this, the pool contract will call the `withdraw` function on the weth contract. Weth is sent from the pool contract back to the weth contract, and in return the weth contract will return eth back to the pool contract. Once the pool contract has eth, it will calculate the amount of usdc to send back to the user, and then transfer this from the pool to the user.
Exchange Overview
To swap tokens on Curve V2 AMM, the user will call the exchange function. For example, we can use the usdc / wbtc / eth pool, and if the user wants to swap eth to usdc, they will call the exchange function and also send eth to the Curve V2 pool contract. The Curve V2 pool contract will calculate the amount of usdc to send back to the user, and then transfer this from the pool to the user.
The user also has the option to swap weth instead of eth on the CurveTricryptoOptimizedWETH contract. For example, if instead of swapping eth for usdc, the user wants to swap weth for usdc, in the first step, the user will send weth to the pool contract. The pool contract will then convert this weth back into eth. To do this, the pool contract will call the withdraw function on the weth contract. Weth is sent from the pool contract back to the weth contract, and in return the weth contract will return eth back to the pool contract. Once the pool contract has eth, it will calculate the amount of usdc to send back to the user, and then transfer this from the pool to the user.
A comprehensive guide to building a smart contract lottery using Vyper. This lesson covers the fundamental concepts of smart contracts, how to implement randomness, and the intricacies of creating a secure and functional lottery application. The video breaks down the steps of building a smart contract lottery, including setting up the contract structure, implementing entrance fee management, and designing a random winner selection mechanism.
Previous lesson
Previous
Next lesson
Next
Course Overview
About the course
AMM math for Curve Cryptoswap
How liquidity is concentrated
Price-repegging
How function calls interact with the AMM
Curve Cryptoswap state variables
How the function exchange works
How to swap tokens
How to add and remove liquidity
Math for Curve Cryptoswap’s internal price oracle
Implicit differentiation
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,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 January 13, 2026
Duration: 5min
Duration: 1h 21min
Duration: 28min
Duration: 26min
Duration: 15min
Duration: 25min
Duration: 1h
Duration: 5min
Course Overview
About the course
AMM math for Curve Cryptoswap
How liquidity is concentrated
Price-repegging
How function calls interact with the AMM
Curve Cryptoswap state variables
How the function exchange works
How to swap tokens
How to add and remove liquidity
Math for Curve Cryptoswap’s internal price oracle
Implicit differentiation
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,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 January 13, 2026