A simple yield farm exchange that lets users stake ERC20/DAI tokens and accrue interest of ERC20 tokens:
- This smart contract lets you stake ERC20 tokens (DAI) and accrue interest of ERC20 tokens (flux tokens).
- Stake Tokens
- Accrue interest of 1 ERC20/Flux Token for each staked ERC20/DAI token for each day staked
- withdraw yield to receive accrued interest
- unstake tokens to recieve back your staked DAI
- contracts: Smart contracts that are deployed in Rinkeby testnet:
- Escrow.sol : farming smart contract.
- FluxTokens.sol : reward/ineterest ERC20 tokens.
- MockERC20.sol: to mock DAI tokens.
- migrations: Migration files for deploying contracts in contracts directory.
- test: Tests for smart contracts.
- Docs: smart contracts auto generated docs using @primitivefi/hardhat-dodoc
- Node.js >= v14
- Hardhat
- Npm
- Run (sudo) npm install in project root to install dependencies.
- First Test (contracts.test.ts):
- Run test using: ( npx hardhat test tests/contracts.test.ts )
- Second Test (mainnetFork.test.ts):
- Create a mainnet node on Alchemy and place the API key in the .env file
- Fetch DAI token address from etherscan mainnet and place it in the .env file (it's already there in the .env.example file tho)
- Fetch DAI Whales addresses and place them in the .env file and make sure they have enough eth to make txs (you'll find whales addresses in the .env.example file as well)
- Run ($source .env) in the root directory to use those vars
- In one terminal run:
( npx hardhat node --fork https://eth-mainnet.alchemyapi.io/v2/$ALCHEMY_KEY ) - In another terminal run:
( npx hardhat test tests/mainnetFork.test.ts --network mainnet_fork ) - You can also run contracts.test.ts on the mainnet fork.