A preliminary contract for Yield Funding
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
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.
To run this contract follow these steps.
Install yarn
npm install --global yarn
- Clone the repo
git clone https://github.com/YieldMe/fund-contract-v1.git
- Install NPM packages
yarn install
- 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
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.
- Deploy (and compile) contract
hh deploy --network {network}
- 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.
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:
- 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.
- Run the frontend by following the instructions here.
- Using the deployer account that you added to metamask, deposit some USDT into the YieldFund contract.
- 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
- 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
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 |
- To run on hardhat, simply run the command
yarn hardhat test
- 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
- 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 eithergoerli
orarbitrum-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
- YieldFund v1
- Frontend v1
- More advanced contracts
See the open issues for a full list of proposed features (and known issues).
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Silas Lenihan - @silas_lenihan - [email protected] Dylan Paul - @dylanpaul230 - [email protected]
Project Link: https://github.com/YieldMe/fund-contract-v1
When Running locally
Error: cannot get the transaction for YieldFund's previous deployment, please check your node synced status.