-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #725 from yieldprotocol/dev
v2.0.42
- Loading branch information
Showing
37 changed files
with
2,182 additions
and
573 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,15 @@ | ||
# Yield app v2 | ||
# Basic Sample Hardhat Project | ||
|
||
## A. Setup Blockchain Environment | ||
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, a sample script that deploys that contract, and an example of a task implementation, which simply lists the available accounts. | ||
|
||
### Option 1: Run development environment locally **(Recommended for now)** | ||
Try running some of the following tasks: | ||
|
||
In a new console: | ||
|
||
1. **clone** the environments-v2 repo: `git clone https://github.com/yieldprotocol/environments-v2.git` | ||
2. **checkout tagged release** `git checkout RC4` | ||
3. **install** the environment `yarn` | ||
4. **Start a local hardhat chain instance**: `npx hardhat node` | ||
5. optional: **Add your testing account** to the list of accounts to be auto-funded with test tokens: | ||
|
||
(edit `externalTestAccounts` array line 32 in file `./environments/development.ts` ) | ||
|
||
In a new console | ||
|
||
1. **Run the dev environment deploy/setup** `npx hardhat run ./environments/development.ts --network localhost` | ||
|
||
### Option 2: Use Rinkeby Testnet | ||
|
||
No setup required, simply point metamask to the correct network | ||
|
||
## B. Run User Interface (this Repo): | ||
|
||
Fire up the UI locally: | ||
|
||
1. **install and run** `yarn && yarn start` | ||
2. In the browser, connect metamask to the localhost network, and reset the metamask account (for just in case). | ||
```shell | ||
npx hardhat accounts | ||
npx hardhat compile | ||
npx hardhat clean | ||
npx hardhat test | ||
npx hardhat node | ||
node scripts/sample-script.js | ||
npx hardhat help | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require("@nomiclabs/hardhat-waffle"); | ||
|
||
// This is a sample Hardhat task. To learn how to create your own go to | ||
// https://hardhat.org/guides/create-task.html | ||
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { | ||
const accounts = await hre.ethers.getSigners(); | ||
for (const account of accounts) { | ||
console.log(account.address); | ||
} | ||
}); | ||
|
||
|
||
|
||
/* npx hardhat harvest --whale 0xa29332b560103d52f758b978e0661420a9d40cb5 --token 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 */ | ||
task("harvest", "Fund accounts by impersonating whales", async (taskArgs, hre) => { | ||
|
||
const topupList = [ '0x1Bd3Abb6ef058408734EA01cA81D325039cd7bcA' ]; | ||
|
||
const whaleAddr = taskArgs.whale; | ||
const tokenAddr = taskArgs.token; | ||
|
||
await hre.network.provider.request({ | ||
method: "hardhat_impersonateAccount", | ||
params: [taskArgs.whale], | ||
}); | ||
|
||
const signer = await ethers.getSigner(taskArgs.whale) // UNI whale 0xa29332b560103d52f758b978e0661420a9d40cb5 | ||
const uniAddr = taskArgs.token; // '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984'; | ||
// The ERC-20 most simple Contract ABI | ||
const erc20Abi = ["function transfer(address to, uint amount)","function balanceOf(address) view returns (uint)",]; | ||
const uni = new ethers.Contract(uniAddr, erc20Abi, signer); | ||
const amount = ethers.utils.parseUnits("1000.0", 18); | ||
await Promise.all( topupList.map(async (addr) => { | ||
await uni.transfer( addr, amount); | ||
console.log( (await uni.balanceOf(addr)).toString() ) | ||
})) | ||
}) | ||
.addParam("whale", "The account's address") | ||
.addParam("token", "The account's address"); | ||
|
||
/** | ||
* @type import('hardhat/config').HardhatUserConfig | ||
*/ | ||
module.exports = { | ||
solidity: "0.8.4", | ||
networks: { | ||
hardhat: { | ||
chainId: 1, | ||
forking: { | ||
url: "https://mainnet.infura.io/v3/2af222f674024a0f84b5f0aad0da72a2", | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// We require the Hardhat Runtime Environment explicitly here. This is optional | ||
// but useful for running the script in a standalone fashion through `node <script>`. | ||
// | ||
// When running the script with `npx hardhat run <script>` you'll find the Hardhat | ||
// Runtime Environment's members available in the global scope. | ||
const hre = require("hardhat"); | ||
|
||
async function main() { | ||
// Hardhat always runs the compile task when running scripts with its command | ||
// line interface. | ||
// | ||
// If this script is run directly using `node` you may want to call compile | ||
// manually to make sure everything is compiled | ||
// await hre.run('compile'); | ||
|
||
// We get the contract to deploy | ||
const Greeter = await hre.ethers.getContractFactory("Greeter"); | ||
const greeter = await Greeter.deploy("Hello, Hardhat!"); | ||
|
||
await greeter.deployed(); | ||
|
||
console.log("Greeter deployed to:", greeter.address); | ||
} | ||
|
||
// We recommend this pattern to be able to use async/await everywhere | ||
// and properly handle errors. | ||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.