Margin Lending app connecting lenders and borrowers

Demo Video Source Code




The Graph API


Aave Risk Framework

Aave Credit Delegation


This project leverages off the credit delegation feature of Aave v2 protocol by enabling depositors and borrowers to connect on a single platform. Depositors deposit their aTokens and delegate a portion of the deposit to a margin Pool. The margin pool acts as a margin account that borrowers interact with. These borrowers can take loans and invest them into investment strategies integrated to our App (yearn dai vault only at the moment). The running interest on the loan is computed in advance and needs to be deposited in the margin account by the borrower. Upon repayment and withdrawal of the invested amount, the loan is repaid to aave lending pool, the interest is paid to the credit pool and rewards from the investment are split between the depositor pool (credit pool) and the borrower.

How It's Made

We used Aave Credit Delegation as the core component. The rate management system that computes the reward split between the credit pool and the borrowers uses aave risk framework and the borrow rate calculation formula. The borrow rate output is what represents the % of the reward that will be allocated to the borrower. (1 - borrow rate) is what is given to the credit pool. We think this can help incentivizing liquidity balance between loans available and loans taken. Running interests on the loan is computed using Graph QL. We also use YFI contracts to integrate a DAI vault. We also use Chainlink to get the usd value of liquidity. We used scaffold-eth for the structure.


thibault bouzat Fred Faye Saurabh Wadhwa Viraz Malhotra Sergi Alcaraz
← click here to see all projects