Code Monkey home page Code Monkey logo

solidity-staking-vault's Introduction

solidity-staking-vault

Requirements

  • You are asked to write smart contracts for an ETH staking app.
  • User can stake their ETH in a vault (Constant APR 10%)
  • User gets rewarded in devUSDC (an ERC20 token you will create as well)
  • Assume that devUSDC is always worth $1
  • When a user stakes ETH: all of that ETH will be put as collateral in Compound (v2).
  • When a user wants to Withdraw their ETH. The vault will take out the ETH the user staked (without the yields) from Compound - and will give it back to the user with the devUSDC rewards
  • Minimum amount to stake is 5 ETH
  • To get the price of ETH you will need to use a price oracle from chainlink

Deployments

Source Address
Vault.sol 0x714d3F5F2F1529541E306034498492c941B5C370
DevUSDC.sol 0xE592BF7Fe43a5e76BEF7E336cA846bAa57A44241

Development

Install dependencies

npm install

Lint code

npm run lint

Execute test cases

Tests are executed in a mainnet fork at block 15804036. Forking mainnet requires an active internet connection.

npx hardhat test

Configure environment variables in .env.local file

cp .env .env.local
vim .env.local

Deploy contracts

Make sure to set an appropriate GOERLI_PRIVATE_KEY variable in the .env.local file before executing any commands.

npx hardhat run --network goerli scripts/deploy.ts

Verify contracts

Make sure to set the ETHERSCAN_API_KEY variable in the .env.local file before executing any commands.

# replace placeholders with the values logged by deploy script
npx hardhat verify --network goerli <devusdc-address>
npx hardhat verify --network goerli <vault-address> <devusdc-address> <price-feed-address> <compound-ether-address>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.