# Token-Farm Note
## Summary
This is a repo to build your own full stack defi staking application for yield farming, borrowing and lending, or any other project you can think of. It allows you to:
- `stakeTokens`: Add any approved token to the farming contract for yeild farming, collateral, or whatever you want to do.
- `unStakeTokens`: Remove your tokens from the contract.
- `getUserTotalValue`: Get the total value that users have supplied based on calculations from the Chainlink Price Feeds.
- `issueTokens`: Issue a reward to the users staking on your platform!
## Prerequisites
Please install or have installed the following:
- [nodejs and npm](https://nodejs.org/en/download/)
- [python](https://www.python.org/downloads/)
## Installation
1. [Install Brownie](https://eth-brownie.readthedocs.io/en/stable/install.html), if you haven't already. Here is a simple way to install brownie.
pip install eth-brownie
pip3 install eth-brownie
2. Clone this repo
```
git clone https://github.com/MilkShakeBro/Token-Farm
or
Download .zip file
```
3. Manually change npm's default directory
```
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
```
4. [Install ganache-cli](https://www.npmjs.com/package/ganache-cli)
```bash
cd ~/Desktop/Token-Farm/
npm install -g ganache-cli
```
## Front end
```bash
cd front_end
npm install --global yarn
yarn
yarn start
```
and you'll be able to interact with the UI
---
---
---
4. Set your environment variables
Set your `WEB3_INFURA_PROJECT_ID`, and `PRIVATE_KEY` [environment variables](https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html).
You can get a `WEB3_INFURA_PROJECT_ID` by getting a free trial of [Infura](https://infura.io/). At the moment, it does need to be infura with brownie. You can find your `PRIVATE_KEY` from your ethereum wallet like [metamask](https://metamask.io/).
You'll also need testnet rinkeby or Kovan ETH and LINK. You can get LINK and ETH into your wallet by using the [rinkeby faucets located here](https://docs.chain.link/docs/link-token-contracts#rinkeby). If you're new to this, [watch this video.](https://www.youtube.com/watch?v=P7FX_1PePX0)
You'll also want an [Etherscan API Key](https://etherscan.io/apis) to verify your smart contracts.
You can add your environment variables to the `.env` file:
```bash
export WEB3_INFURA_PROJECT_ID=<PROJECT_ID>
export PRIVATE_KEY=<PRIVATE_KEY>
export ETHERSCAN_TOKEN=<YOUR_TOKEN>
```
> DO NOT SEND YOUR KEYS TO GITHUB
> If you do that, people can steal all your funds. Ideally use an account with no real money in it.
# Usage
## Scripts
```bash
brownie run scripts/deploy.py
```
This will deploy the contracts, depoly some mock Chainlink contracts for you to interact with.
```bash
brownie run scripts/deploy.py --network kovan
```
This will do the same thing... but on Kovan.
## Testing
```
brownie test
```
## Linting
```
pip install black
pip install autoflake
autoflake --in-place --remove-unused-variables -r .
black .
```
# Resources
To get started with Brownie:
* [Chainlink Documentation](https://docs.chain.link/docs)
* Check out the [Chainlink documentation](https://docs.chain.link/docs) to get started from any level of smart contract engineering.
* Check out the other [Brownie mixes](https://github.com/brownie-mix/) that can be used as a starting point for your own contracts. They also provide example code to help you get started.
* ["Getting Started with Brownie"](https://medium.com/@iamdefinitelyahuman/getting-started-with-brownie-part-1-9b2181f4cb99) is a good tutorial to help you familiarize yourself with Brownie.
* For more in-depth information, read the [Brownie documentation](https://eth-brownie.readthedocs.io/en/stable/).
* [Create React App](https://create-react-app.dev/docs/adding-typescript/) for front end fun
* [Materials-UI](https://material-ui.com/)
Shoutout to [Matt Durkin](https://twitter.com/mdurkin92) on twitter for creating the UI!
Shoutout to [Gregory from Dapp University](https://www.dappuniversity.com/) for the inspiration for this!
Any questions? Join our [Discord](https://discord.gg/2YHSAey) or open an issue.
# License
This project is licensed under the [MIT license](LICENSE).