5/5
### Second Exercise: Swapping WETH to USDC In this exercise we will be swapping one WETH to USDC. You may be wondering where we obtained this one WETH. Looking inside the `setUp` function we can see that the contract is given one WETH. ```javascript deal(WETH, address(this), 1e18); ``` The next line is important as well, it approves the pool to pull WETH from this contract. ```javascript weth.approve(address(pool), type(uint256).max); ``` These two setup functions ensure that the swap will be successful if we write the code correctly. Our exercise is to call the exchange on the pool contract to swap one WETH to USDC.
In this exercise we will be swapping one WETH to USDC. You may be wondering where we obtained this one WETH.
Looking inside the setUp function we can see that the contract is given one WETH.
The next line is important as well, it approves the pool to pull WETH from this contract.
These two setup functions ensure that the swap will be successful if we write the code correctly. Our exercise is to call the exchange on the pool contract to swap one WETH to USDC.
A beginner's guide to building a vyper smart contract lottery or raffle. The lesson explains how to create a weak randomness lottery using on-chain randomness, or, for a secure solution, how to utilize Chainlink VRF 2.5. It also covers how to write tests for the contract and how to deploy it to a blockchain.
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