Rules Deposit And Redeem

A comprehensive guide to fuzz testing a stablecoin protocol with Mochi. The lesson covers how to set up a fuzz testing environment, define rules for actions, and write invariants to ensure the protocol's stability.

1. Intro
A challenging workshop on building a stablecoin - This lesson builds upon previous concepts by walking through the creation and testing of a decentralized stablecoin. Duration: 6min
2. What Is A Stablecoin
A comprehensive guide to stablecoins - This lesson covers the basics of stablecoins, their different types and properties, and the key takeaways for investors and developers in the DeFi space. Duration: 29min
3. Setup
A beginner's guide to building a decentralized stablecoin on the Vyper blockchain. The lesson covers setting up the development environment, creating a stablecoin contract, and exporting functions like 'mint' and 'burn' for use in another contract. Duration: 6min
4. Engine Intro
A comprehensive guide to creating a smart contract for a decentralized stablecoin with collateralized value. The lesson walks through setting up the contract's structure, including its stability mechanism, and provides insights on best practices in building a secure and efficient DeFi applications functionality, and implementing the necessary interfaces for interacting with a stablecoin and its collateral. Duration: 7min
5. Deposit Collateral
A comprehensive guide to creating a deposit collateral function in Solidity. This lesson explains how to set up the function's parameters, define checks to ensure valid collateral, and implement interactions with the external contract to transfer the collateral. Duration: 7min
6. Health Factor
A comprehensive guide to understanding and implementing health factors in Solidity smart contracts. The lesson explores concepts like overcollateralization, calculating health factors, and creating liquidation thresholds to ensure robust and secure stablecoin systems. Duration: 16min
7. Minting Dsc
A technical walkthrough of minting DSC and its relation to the health factor. This lesson explains how to deposit collateral for minting DSC, how to mint DSC based on the collateral deposited, and how the health factor is calculated based on the amount of DSC minted and the total USD value of collateral deposited. Duration: 2min
8. Redeem Collateral
A comprehensive guide to redeeming collateral in a decentralized stablecoin system using Viper smart contracts. The lesson covers writing a redeemCollateral function, implementing tests to ensure proper functionality, and utilizing a burnDSC function to handle token destruction. Duration: 8min
9. Liquidation
A comprehensive guide to implementing a liquidation function in a Stablecoin smart contract, covering crucial checks, debt coverage, collateral distribution, and the use of liquidation bonus. Duration: 10min
10. Deployment
A comprehensive guide to deploying your DSC engine and DSC contracts using Moccasin. The lesson covers deploying your DSC stablecoin contract, MockV3Aggregator contract, Mock token contract, and setting the minter and ownership of the DSC engine. Duration: 11min
11. Testing
A comprehensive guide to writing unit and fuzz tests for a decentralized stablecoin engine using Python, Pytest, and Hypothesis. The lesson covers creating fixtures to set up the testing environment, writing tests for initialization, collateral deposit, and ensuring code reverts in error conditions. Duration: 12min
12. Workshop 1
A practical workshop for writing unit tests in Python for a Solidity smart contract. This lesson will cover best practices for testing smart contracts, using real-world examples to guide you through the process. Duration: 3min
13. Fuzz Setup
A comprehensive guide to setting up fuzz tests in a Solidity smart contract. The lesson covers the basics of setting up a fuzz testing environment, writing the fuzz test, initializing the testing suite, and defining rules for the fuzz test. Duration: 6min
14. Invariant
A powerful guide to using Invariants in Hypothesis fuzzing - This lesson describes the Invariant keyword within the Hypothesis testing framework, and explains how to use it to define important properties of the system that should always hold true. Duration: 5min
15. Rules Deposit And Redeem
A comprehensive guide to fuzz testing a stablecoin protocol with Mochi. The lesson covers how to set up a fuzz testing environment, define rules for actions, and write invariants to ensure the protocol's stability. Duration: 13min
16. Rules Mint Dsc
A comprehensive guide to adding a mint DSC function in a Stablecoin fuzzer. The lesson covers the basics of writing a mint function with a try/catch block, handling errors, and using a view function for calculations. Duration: 7min
17. Rules Update Price
A comprehensive guide to creating fuzz tests to validate Solidity smart contracts. This lesson demonstrates how to set up a fuzz testing environment using Python and Hypothesis, along with practical examples of fuzzing rules and invariants. Duration: 8min
18. Workshop 2
A comprehensive workshop on writing a liquidation function for a decentralized stablecoin protocol using Hypothesis and Solidity. The lesson demonstrates how to use a fuzz tester to ensure a protocol’s invariant is always maintained, even under stress from market price fluctuations. Duration: 3min
19. Audit Readiness
A comprehensive guide to smart contract audits - This lesson explores the importance of smart contract audits, outlining the audit process, and offering insights into how to make your audit successful. Duration: 11min
20. Recap
A comprehensive recap of the Moccasin Stablecoin project - This video recaps the key components of the Moccasin Stablecoin project, including the stablecoin itself, its different types, how it works, and deployment strategies. Duration: 5min

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