Skip to content

PromiseFunding/fund-contract-v1

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Fund Contract V1

A preliminary contract for Yield Funding
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

This is the first contract for YieldMe - a trustless, decentralized, and lossless crowdfunding platform. Users can stake their ERC20 funds in a project they believe in and the funds are deposited into a Lending Protocol or alternative decentralized yield generating source. The proceeds generated by the yield accumulation are then made available to the benefactor to fund their project. In future iterations users will be able to get incentives based on their average contribution over time, promoting a productive and sustainable system.

(back to top)

Built With

  • Hardhat

(back to top)

Getting Started

To run this contract follow these steps.

Prerequisites

Install yarn

npm install --global yarn

Installation

  1. Clone the repo
    git clone https://github.com/YieldMe/fund-contract-v1.git
  2. Install NPM packages
    yarn install
  3. Make a copy of the .env.example file called .env and populate it with your keys. You can get your private key from MetaMask and RPC Urls from alchemy

(back to top)

Usage

Deploying YieldFund

Choose a network when deploying with YieldFund. If you're using a network that isn't already in the hardhat.config.ts and the helper-hardhat-config.ts you have to define the network as the other networks are defined.

  1. Deploy (and compile) contract
hh deploy --network {network}
  1. Run tests
hh test --network {network}

You can run the tests on three different networks at the moment. goerli which requires no additional setup other than deploying YieldFund to the network, hardhat which is similarly straightforward, but requires the deployment of mocks, and localhost which requires you launching the aave-sandbox forked environement.


Mocks

This contract comes with several Mocks which together simulate a Mock AAVE pool. This is extremely useful because it allows you to test the YieldFund protocol in an environment which you have complete control over. To best use the mocks, follow these steps:

  1. Deploy the test network.
hh node

This will deploy all three mock contracts, along with the YieldFund contract. It will supply the deployer (account #1) with mock USDT tokens. When you run the command, it will split out 20 accounts in the console, with the deployer being Account #0. To access this account's funds add the account's private key to your metamask.

  1. Run the frontend by following the instructions here.
  2. Using the deployer account that you added to metamask, deposit some USDT into the YieldFund contract.
  3. If you would like to withdraw from the fund, you must do so after the lockTime is complete. To bypass the locktime, run the following command:
hh run scripts/bypassLocktime.ts --network localhost
  1. In the production version of YieldFund, yield will be generated via gaining interest from a Liquidity Pool. Since there is of course no borrowing party on these mocks, we have to simulate the interest payout in order to withdraw proceeds from YieldFund. We can do so by running:
hh run scripts/payout.ts --network localhost

Tests

There are three different ways to run tests based on what type of network you are using. We define the three networks here.

Type Description
hardhat This is the local hardhat network. It is the default network for this project, and runs the tests using the mocks described above
localhost This runs on a forked mainnet using the aave-sandbox repository. We give instructions on how to spin this up above
testnet This uses a testnet or your choice. Currently, we support goerli and arbitrum_goerli

  1. To run on hardhat, simply run the command
yarn hardhat test
  1. To run on localhost, first you have to spin up the aave-sandbox environment. In this repo, we have configured it to fork polygon mainnet.
  • First clone the aave-sandbox repo
  • Follow the instructions to get set up.
  • In one terminal run
npm run node:fork:polygon-v3
  • In another run:
npm run feed-accounts:polygon-v3 -- --accounts 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266,0x70997970C51812dc3A010C7d01b50e0d17dc79C8
  • This will feed the two first accounts of the hardhat network with fake funds. The hardhat.config.ts in this repo is configured to have the first account be the deployer and the second account to be a user.
  • Now the aave-sandbox is fully set up, and you can run the test.
yarn hardhat test --network localhost
  1. Lastly, you can run tests on a testnet. This assumes you have already run yarn hardhat deploy --network {network} to deploy a fund factory. Pick either goerli or arbitrum-goerli and run:
yarn hardhat test --network {network}

To make sure everything is running properly. All three types of tests must be run and must be passing all tests. They each test a different aspect of the project, so make sure to test all. If you configure the aave network correctly, then you can run all three tests at once:

hh test --network arbitrum_goerli && hh test --network localhost && hh test

(back to top)

Roadmap

  • YieldFund v1
  • Frontend v1
  • More advanced contracts

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Silas Lenihan - @silas_lenihan - [email protected] Dylan Paul - @dylanpaul230 - [email protected]

Project Link: https://github.com/YieldMe/fund-contract-v1

(back to top)

Common Problems

When Running locally Error: cannot get the transaction for YieldFund's previous deployment, please check your node synced status.

(back to top)

About

Smart Contract Repo for Promise Funding

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published