Automated market maker integration

Assignment Help Other Subject
Reference no: EM133976699

Lab: Blockchain-Based Ecosystems: Memecoins & Stablecoins Development, Attack Simulation, and Auditing

1. Overview
This lab guides students through designing, implementing, deploying, testing, and auditing a simple memecoin (ERC-20) and a minimal ecosystem around it (liquidity pool, simple governance, and a front-end). The lab emphasizes on hands-on smart contract development, off-chain assets, tampering/attack simulation, and understanding security tradeoffs. Enjoy trusted, budget-friendly assignment help from today onward!
Students will:
Build a token
Deploy it to a local testnet
Create a Uniswap-style liquidity pair
Implement simple governance
Simulate common memecoin attacks like rug-pull, unauthorized minting, honeypot
Detect attacks and propose mitigations.
2. Lab Environment Setup
You will be running our code locally using Visual Studio Code to edit our code and using the terminal to run commands. I will reference the code using a file name as label or function name in cases where we have more than a function inside a file. Below are the tools we would be using
Node.js v16+ and npm
Hardhat local node (an Ethereum local chain)
Ethers.js
MetaMask (for manual UI testing) or a local script wallet
Python 3.8+ for off-chain helper scripts
3. Tasks (Lab Steps)
Part 1: Mime Coin
Task 0 - Environment & Setup

Task 1 - Create a basic ERC-20 memecoin
Implement Memecoin.sol (ERC-20) with these features:
name, symbol, decimals.
initialSupply minted to deployer.
mint function restricted to onlyOwner.
burn function available to any holder.
setMaxWallet(uint256) (optional anti-whale).
Deploy and record the token address and owner address.

Task 2 - Add simple tokenomics and on-chain rules
Add configurable transaction fee (tax) on transfers that routes to a treasury address.
Implement enableTrading() gating so token is non-transferable until the owner opens trading (useful for launch control).
Add excludeFromFees(address) and isExcludedFromFees(address) logic.

Task 3 - Provide liquidity & interact with an Automated Market Maker (AMM) integration
Using a Uniswap v2 fork or the provided simplified AMM, create a token-ETH pair and add liquidity programmatically from your deployer account
Show the token price after adding liquidity.

Task 4 - Attack simulations & tamper exercises
This mirrors the vulnerability and tamper simulations from Project 1 but adapted to tokens.
Unauthorized Minting / Owner Key Leak simulation
Create a second (attacker) signer and simulate that signer calling mint() (if onlyOwner is removed or the owner key is compromised). Demonstrate supply inflation and its effect on price.
Rug-pull simulation
Owner adds liquidity and then withdraws all liquidity from the pool (or transfers treasury tokens and removes liquidity). Show how token price collapses and holders are stuck with worthless tokens.
Honeypot / Transfer Revert
Introduce a buggy transfer logic that allows buys but prevents sells (simulate a honeypot). Demonstrate a transaction that fails on sell.
Front-end social engineering simulation
Show how a malicious UI could trick users to approve unlimited allowance or sign a permit that transfers tokens. Demonstrate by interacting with a script that calls approve(spender, type(uint256).max) and then transferFrom.
For each simulation:
Run tests showing the exploit succeeds (or fails if protections exist).
Recompute on-chain states (supply, balances, reserves) and show the exact mismatch (before/after)

Task 5 - Detection and mitigation of attack
Write unit tests that assert invariants such as total supply cap, owner balance limits, and that enableTrading gating prevents transfers pre-launch.
Implement fixes: reintroduce onlyOwner on mint, add timelock for owner actions, add a renounceOwnership() demonstration and explain consequences.

Part 2: Stable Coin: Students will build a simplified Collateralized Stablecoin
Task 0 - The Stablecoin Creation
Create the assets and the pricing mechanism.
StableCoin.sol: A standard ERC-20 (symbol: USDM) where mint and burn are restricted to the Vault contract.
MockOracle.sol: A simple contract that stores a variable ethPriceUSD.
Task 1 - The Vault (Minting & Redeeming)
Allow users to deposit ETH and borrow USDM against it.
Deposit/Mint:
User sends ETH.
Contract calculates USD value using MockOracle.
Checks if (ETH Value / Mint Amount) >= 1.5
Mints USDM to user.
Repay/Withdraw:
User approves and sends USDM back to Vault.
Vault burns USDM.
Vault returns equivalent ETH to user.
Calculate the Health Factor if the position is at risk of attack using ETH collateral amount * ETH Price / USDM Minted

Task 2 - Attack Simulation: The Death Spiral
Simulate what happens when the collateral asset crashes like the DeFi exploits.
Set Oracle price of ETH to $3000.
User A deposits 1 ETH ($3000 value) and mints 2000 USDM. (Ratio: 1.5).
The attacker (or market conditions) calls MockOracle.setPrice(1500).
User A's collateral is now worth $1500, but they owe 2000 USDM. The system is under-collateralized.
User A decides never to repay the loan because keeping the 2000 USDM is more profitable than getting back $1500 of ETH. The protocol is now insolvent.

Task 3 - Detection & Mitigation of the Death Spial Attack

How the code of how you would detect this attack and mitigate the attack from happening

Reference no: EM133976699

Questions Cloud

What is the adjustment at the end of the accounting period : What is the adjustment at the end of the accounting period, assuming that the period ends (i) on Monday or (ii) on Wednesday?
Design project that will be completed in four parts : Design project that will be completed in four parts during the course. This project provides you an opportunity to solve a comprehensive problem in firewall
How can we most accurately assess personality : How can we most accurately assess personality? What are the major types of personality measures?
Which is true when comparing next months estimates : Miller Company's contribution format income statement for the most recent month. Which is true when comparing next month's estimates to the most recent month?
Automated market maker integration : Implement enableTrading() gating so token is non-transferable until the owner opens trading - Create a second (attacker) signer and simulate that signer calling
Determine the amount of wages paid during the year : The balances of the two accounts related to wages at October 31, after adjustments at the end of the first. Determine the amount of wages paid during the year.
What social group did you investigate : What social group did you investigate? Why did you choose this group? Give a short background of your group, assuming that your reader knows nothing about it.
By how much would income before taxes have been misstated : Assume the accruals apply to the current year and were not recorded at the end of the year. By how much would income before taxes have been misstated?
Explain the impact on offering yield of adding call feature : Explain the impact on the offering yield of adding a call feature to a proposed bond issue.

Reviews

Write a Review

Other Subject Questions & Answers

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd