Giter Club home page Giter Club logo

lending's Introduction

Solidity DeFi

This project is a simple lending/borrow protocol.

Introduction

How it works

Depositors can deposit DAI into the protocol's lending pool and receive bDAI (interest bearing DAI) in return. Subsequent the protocol deposits that amount of DAI inside AAVE Lending Pool to earn interest while waits a borrower or a depositor to withdraw.

Borrowers can deposit ether as collateral and borrow DAI up to 80% of its collateral value. When the value of the borrow surpass 80% of its collateral value, liquidation occurs.

*Note: The ether deposited as collateral is also deposited into AAVE's lending pool to earn interest.

The protocol also has a reserve, this reserve receives all the interest of the deposits and collateral from AAVE's lending pool, and every time a lend is paid, the interest of the lending goes here.

Liquidation occurs every time the borrowed value if higher than 80% of the collateral's value. The ether liquidated is swapped for DAI using Uniswap and that value goes to the reserve.

The protocols fees is calculated based on a variable call utilization ratio.

utilization

There's another variable called interest multiplier, this variable is used to calculate the borrow rate.

interest

This indicators makes rates variable based on protocol usage. When the protocol has a lower utilization ratio, it lower the deposit/borrow rate to attract more borrowers than depositors. When the portocol usage is high, it increase the borrow/deposit rates, to attract deposits and drive borrowers away.

Borrow rate formula:

borrow

Deposit rate formula:

deposit

Each bDAI is convertible into a increasing quantity of DAI as interest accrues, the exchange rate between bDAI and DAI is calculated using this formula:

exchangeRate

*Note: this formulas is inspired by Anchor protocol and Compound, this way is no sustainable, was made for study purposes only.

Getting started

Rename the .env.example file to .env and replace the credentials necessary.

*Note: the addresses are hardcoded on the contract for kovan testnet, if you want to deploy in another testnet or even deploy to mainnet, make sure to change the addresses on the contract

Instaling

$ npm install

Testing

$ npm test

Deploy

npm run deploy

Verify contract

npm run verify "CONTRACT ADDRESS"

lending's People

Contributors

alexramos93 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.