changed 5 years ago
Linked with GitHub

Yearn Protocol

GitHub license
Lint
Test

Yearn Protocol is a set of Ethereum Smart Contracts focused on creating a simple way to generate high risk-adjusted returns for depositors of various assets via best-in-class lending protocols, liquidity pools, and community-made yield farming strategies on Ethereum.

Before getting started with this repo, please read:

Requirements

To run the project you need:

  • Python 3.8 local development environment and Node.js 10.x development environment for Ganache.
  • Brownie local environment setup. See instructions: ETH Brownie.
  • Local env variables for Etherscan API and Infura (ETHERSCAN_TOKEN, WEB3_INFURA_PROJECT_ID).
  • Local Ganache environment installed with npm install -g ganache-cli@6.11.

Installation

To run the yearn protocol, pull the repository from GitHub and install its dependencies. You will need yarn installed.

git clone https://github.com/iearn-finance/yearn-protocol
cd yearn-protocol
yarn install --lock-file

Compile the Smart Contracts:

brownie compile

Note that you can run this project from Mac, Linux, Windows, or the Windows Subsystem for Linux.

Extended Instructions

The below guide covers installation on Mac, Linux, Windows, and Windows using the Windows Subsystem for Linux.

Any command in code blocks is meant to be executed from a Mac/Linux terminal or Windows command prompt.

  1. Note for Windows users: if you want to use the Windows Subsystem for Linux (WSL), go ahead and install it now.
    • After it's installed, launch the your chosen linux subsystem.
    • Follow the linux instructions below from within your terminal, except for VSCode. Any VSCode installation happens in Windows, not the linux subsystem.
  2. Install VSCode
  3. Install VSCode Extensions
    • Solidity
    • Python
    • If you're using the WSL
      • Wait to install the Solidity Compiler, you'll do this in a later step.
      • Install Remote - WSL
  4. Install Python 3.8
  5. Setup Brownie
    • python3 -m pip install --user pipx
      • Note, if you get an error to the effect of python3 not being installed or recognized, run python --version, if it returns back something like Python 3.8.x then just replace python3 with python for all python commands in these instructions.
    • python3 -m pipx ensurepath
    • pipx install eth-brownie
      • If you're on Windows (pure Windows, not WSL), you'll need to install the C++ Build Tools before executing this.
  6. Install Node.js 10.x
  7. Install Ganache
    • npm install -g ganache-cli@6.11
  8. Install Yarn
  9. Install Black
    • python3 -m pip install black
  10. Setup an account on Etherscan and create an API key
    • Set ETHERSCAN_TOKEN environment variable to this key's value
      • Windows: setx ETHERSCAN_TOKEN yourtokenvalue
      • Mac/Linux: echo "export ETHERSCAN_TOKEN=\"yourtokenvalue\"" | sudo tee -a ~/.bash_profile
  11. Setup an account on Infura and create an API key
    • Set WEB3_INFURA_PROJECT_ID environment variable to this key's value
      • Windows: setx WEB3_INFURA_PROJECT_ID yourtokenvalue
      • Mac/Linux: echo "export WEB3_INFURA_PROJECT_ID=\"yourtokenvalue\"" | sudo tee -a ~/.bash_profile
  12. Close & re-open your terminal before proceeding (to get the new environment variable values).
  13. If you don't have git yet, go set it up.
  14. Pull the repository from GitHub and install its dependencies.
    • git clone https://github.com/iearn-finance/yearn-protocol
    • cd yearn-protocol
    • yarn install --lock-file
      • You may have to install with --ignore-engines
  15. Compile the Smart Contracts:
    • brownie compile
  16. brownie test -s
    • Everthing should be green and say 'passed'.
  17. Launch VSCode
    • If you're in Windows using WSL, type code . to launch VSCode
    • Open one of the .sol files, right click the code and click Soldity: Change Workspace compiler version (Remote), Change to 0.5.17
      • Alternatively, go to File -> Preferences -> Settings
      • If you’re using WSL, go to the Remote [WSL] tab.
      • Otherwise choose the Workspace tab
        • Search for Solidity and copy and paste v0.5.17+commit.d19bba13 into the Solidity: Compile Using Remote Version textbox.
    • Set Black as the linter.
      • You'll see a toast notification the bottom right asking about linting, choose Black.
      • If you don't see this, just go to File -> Preferences -> Settings
        • If you're using WSL, go to the Remote [WSL] tab.
        • Otherwise choose the Workspace tab
        • Search for python formatting provider and choose black.
        • Search for format on save and check the box.
  18. Lastly, you'll want to add .vscode to to your global .gitignore
    • Use a terminal on Mac / Linux, use Git Bash on Windows
    • touch ~/.gitignore_global
    • use your favorite editor and add .vscode/ to the ignore file
    • git config --global core.excludesfile ~/.gitignore_global
  19. Congratulations! You're all set up.
    • Use git pull to stay up to date with any changes made to the source code.
    • If you want to switch to the master branch, use git checkout master. By default you'll be in develop, which is where you can see the latest features getting ready for release.

Tests

If you're not familiar with brownie, see the quickstart.

Tests are commented following the NumPy docstring style. [Draft Note from Shade: This is not true yet but I'm working on adding comments right now, so we'll have them around the time this readme is checked in.

Run tests:

[Draft Note from Shade: There's a PR waiting that will change this to brownie test -s -n auto, which will parallelize the tests, this note is my reminder to update the docs once that PR goes through.]

brownie test -s

Run tests with coverage:

brownie test -s --coverage

Formatting

Check linter rules for *.json and *.sol files:

yarn lint:check

Fix linter errors for *.json and *.sol files:

yarn lint:fix

Check linter rules for *.py files:

black . --check

Fix linter errors for *.py files:

black .

Security

For security concerns, please visit Bug Bounty.

Documentation

You can read more about yearn finance on our documentation webpage.

Discussion

For questions not covered in the docs, please visit our Discord server.

Select a repo