Skip to content

smart contract to interact with Aave lending protocol to deposit ETH and borrow DAI

Notifications You must be signed in to change notification settings

MatricksDeCoder/AaveDeFi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AaveDeFi Fullstack applications

About

A simple full stack application with smart contract that allows to interact with the Aave lending protocol. With a single function you can deposit ETH and then borrow some DAI against that ETH to your wallet address.

Usage

You need to have Metamask Wallet. Connect to the app using your wallet. When connected, your address will show on the top navigation bar. You can follow the Metamask prompts to complete the transactions on the Dapp.

Technology Stack and Tools

Folder / Directory Structure (key folders)
  • AaveDefi
    • migrations
    • public
    • src
      • abis
      • components
      • contracts index.js
    • test

Preconfiguration, Installation and Running project locally

You will node installed node (14.15.4) is preferred

  1. Clone repository
$ git clone https://github.com/MatricksDeCoder/AaveDeFi.git
  1. Enter project directory and install dependancies
$ cd AaveDeFi
$ npm install 
  1. Install truffle globally (preferrably truffle@v5.1.10)
$ npm install -g truffle
  1. Install ganache globally
$ npm install -g ganache-cli
  1. Run local blockchain as a fork of Ethereum mainnet using ganache-cli and Infura Allow to work with the state of mainnet and deployed contracts on mainnet Go to infura create a new project and copy the mainnet URL e.g Mainnet URL https://mainnet.infura.io/v3/11111111111111111
$ ganache-cli -f https://mainnet.infura.io/v3/11111111111111111

Above should run local blockchain with ganache. Ensure truffle-config.js networks config is your Ganache port. By default it should be host: 127.0.0.1 and port: 8545

  1. Connect your ganache addresses to Metamask! Copy private Key of the addresses in ganache and import to Metamask Connect your metamask to network Localhost 8545

Migrating contracts and Testing

  1. To compile contracts e.g you make changes to contracts
$ truffle compile 
  1. Migrate contracts to local running instance fork
$ truffle migrate --reset 
  1. To test contracts
$ truffle test

Front End and how to use Dapp

  1. Run app locally
$ npm run start

Enter amount of ETH to deposit. Aave has no lower or upper bound amount you may enter. Eg. enter 1 ETH or 0.1 ETH etc Click the button "Borrow DAI" to deposit ETH and borrow an amount of DAI into your wallet from Aave protocol To interact with DAPP you need Metamask installed

To do app extension ideas

  • Dapp functionalty hardcoded to only deposit ETH and borrow DAI will in future extend to lend any EC20 and borrow any asset offered in Aave markets
  • Display interest rates for borrowing assets
  • Display your transactions using subscribe to events e.g DepositBorrow in event in contract or such other etc
  • Repay borrowed amount etc
  • Withdraw collateral etc
  • Metrics like interest rate, liquidation, availaleBorrowsETH, etc

LINK TO VIDEO

License

MIT

About

smart contract to interact with Aave lending protocol to deposit ETH and borrow DAI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published