Atokens

A practical guide to re-balancing and withdrawing from Aave. This lesson demonstrates how to re-balance your crypto assets within Aave, and then withdraw your assets, including tokens and interest accrued, by using their smart contracts.

1. Intro
A beginner's guide to building a Mocaasin DeFi algorithmic trading script. The lesson introduces the concept of DeFi and covers how to leverage protocols like Aave and Uniswap to automate portfolio rebalancing, ensuring optimal asset allocation and maximizing yield. Duration: 6min
2. Real Demo
A practical guide to real Aave and Uniswap scripting - This lesson demonstrates how to use Python scripts to deposit, rebalance and trade on Aave and Uniswap, using a live example with real money on the zkSync network. Duration: 8min
3. AMM
A comprehensive explanation of AMMs, including their advantages over traditional order books and the roles of traders and liquidity providers in the decentralized exchange process. The lesson covers how AMMs solve liquidity and gas fee issues, as well as how liquidity providers can earn fees from traders. Duration: 5min
4. Constant Product AMM
A basic explanation of the Constant Product AMM (Automatic Market Maker) - This lesson covers how the constant product formula x * y = k can be used to calculate the exchange rate of tokens in an AMM. It explains the concept through a visual example showing how the token balances must stay on a curve, and how changes in one balance affect the other. Duration: 2min
5. Constant Sum AMM
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. Duration: 2min
6. Setup
A comprehensive guide to setting up a Python-based project for algorithmic trading on the blockchain. This lesson walks through creating a new directory, setting up the project with the help of the Mocassin package, and outlining the key goals of the project. Duration: 2min
7. Forked Network Setup
A practical guide to setting up a forked network for testing smart contracts in Python. This lesson covers setting up a forked network using Alchemy and configuring the environment file to connect to the network. Duration: 10min
8. Minting Weth
A practical guide to minting WETH - This lesson covers the concept of Wrapped Ether (WETH), how to mint WETH by depositing ETH, and how to withdraw ETH from WETH, including how to call functions in a Solidity smart contract from Python. Duration: 2min
9. Getting Abis From The Explorer
A comprehensive guide to working with ABIs in the Mocassin framework. This lesson teaches you how to fetch, store, and use ABIs for your projects, demonstrating how to configure your Mocassin.toml and setup your development environment. Duration: 4min
10. Minting Usdc
A practical guide to minting fake USDC on a forked Ethereum network using Python and Boa library. The lesson covers using Boa's 'env.prank' to mock the USDC contract owner and mint tokens, then demonstrates how to verify the balance before and after minting. Duration: 5min
11. Juypter Notebook
A powerful introduction to utilizing Jupyter Notebook with Mocassin - This lesson teaches how to run and use Mocassin within the Jupyter Notebook framework. It explains the advantages of using notebooks over regular Python scripts and outlines the setup process including installing necessary extensions and selecting the correct kernel. Duration: 6min
12. Depositing Into Aave
A comprehensive guide to depositing into Aave - This video covers how to find the Aave pool address in the Aave documentation, as well as how to store that address in a TOML file. The video then covers the steps to create a deposit function in Python that interacts with a pool contract to deposit tokens into Aave. Duration: 12min
13. Atokens
A practical guide to re-balancing and withdrawing from Aave. This lesson demonstrates how to re-balance your crypto assets within Aave, and then withdraw your assets, including tokens and interest accrued, by using their smart contracts. Duration: 9min
14. Portfolio Allocations
A comprehensive guide to calculating portfolio allocations on the Aave protocol. This lesson covers retrieving token balances, normalizing them, fetching prices from Chainlink Price Feeds, calculating value based on prices, and ultimately determining whether rebalancing is necessary. Duration: 11min
15. Withdrawing From Aave
A practical guide to withdrawing from Aave - This lesson covers how to withdraw tokens from Aave using Python code. The lesson covers using the Aave pool contract to withdraw tokens and provides a practical code example for withdrawing all tokens in the pool. Duration: 3min
16. Uniswap
A practical guide to using Uniswap for swapping tokens - Learn how to interact with Uniswap V3 to swap tokens and understand important considerations like MEV. The lesson covers setting up a development environment, finding the contract address, and implementing a swap in your Solidity code. Duration: 12min
17. Finish Rebalance
A comprehensive guide to rebalancing a USDC/WETH portfolio in Aave V3 - The lesson covers calculating the needed trades to rebalance a portfolio, depositing USDC and WETH tokens, and checking the current allocation percentages of USDC and WETH. Duration: 4min
18. Zksync Demo
A practical demonstration of rebalancing a portfolio on Zksync. The lesson shows how to set up a Zksync chain and contract addresses in a codebase, and how to rebalance the portfolio by withdrawing ETH from Aave Zksync and swapping it for USDC. Duration: 4min
19. Workshop
A practical DeFi workshop on algorithmic trading. The lesson covers copying code from a Jupyter Notebook into scripts, running the scripts on a virtual network, and adjusting the target allocations for optimal results. Duration: 3min
20. Recap
A comprehensive introduction to DeFi and algorithmic trading - This lesson covers the fundamentals of decentralized finance, including Aave and Uniswap. We'll write a Python script to practice portfolio management strategies and test our code on a forked network. Duration: 8min

Course Overview

About the course

What you'll learn

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!

Course Description

Who is this course for?

  • Software engineers
  • Web3 developers
  • Finance developers
  • AI developers
  • Anyone interested in learning Python and smart contracts

Potential Careers

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)

Meet your instructors

Patrick Collins

Patrick Collins

Founder at Cyfrin

Web3 engineer, educator, and Cyfrin co-founder. Patrick's smart contract development and security courses have helped hundreds of thousands of engineers kickstarting their careers into web3.

Last updated on April 21, 2025