Skip to content

Capx-Fi/Capx-Lend-Protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Capx-Lend-Protocol

The project provides a decentralized platform allowing WVT holders to lend out their stable coins by keeping WVTs as collateral.
Enabling WVT holders with the ability to get P2P loans from the blockchain community.

Architecture

Architecture

Deploying the Smart Contracts

The deployment script is written in the migrations file "1_initial_migration". This project has total of 4 contracts which are deployed in succession with multiple functions called in between.

How to deploy a contract in migration files

Normal Deployment

const instanceVariable = await deployer.deploy(contractVariable, contructorArguments)

Deployment with proxy

const instanceVariable = await deployProxy(contractVariable, [args], { kind: 'uups' });

## Step 1

Importing the contracts

```javascript
const oracle = artifacts.require("Oracle");
const Master = artifacts.require("Master");
const LendNFT = artifacts.require("LendNFT");
const Lend = artifacts.require("Lend");

Step 2

Gets the accounts to be used for deployment

const accounts = await web3.eth.getAccounts();

Step 3

Deploys lendNFT contract using openzeppelin upgradable plugin.

let nftinstance = await deployProxy(LendNFT,[],{kind: 'uups'});

Step 4

Deploys oracle contract using openzeppelin.

await deployer.deploy(oracle);

Step 5

Deploys master contract using openzeppelin upgradable plugin.

let MasterInstance =  await deployProxy(Master, [oracleInstance.address,"500"], { kind: 'uups' });

Step 6

Deploys lend contract using openzeppelin upgradable plugin.

let lendInstance = await deployProxy(Lend, [MasterInstance.address, nftinstance.address], { kind: 'uups' });

Run Migrate to deploy the contracts.

truffle migrate


Subgraph Query URLs

Ethereum

Subgraph Query URL
Lend Subgraph https://api.thegraph.com/subgraphs/name/shreyas3336/lend

BSC

Subgraph Query URL
Lend Subgraph https://api.thegraph.com/subgraphs/name/shreyas3336/lend-bsc

Matic (Polygon)

Subgraph Query URL
Lend Subgraph https://api.thegraph.com/subgraphs/name/shreyas3336/lend-matic

Avalanche

Subgraph Query URL
Lend Subgraph https://api.thegraph.com/subgraphs/name/shreyas3336/lend-avax

Implementation Details

Lend contract

The Lend contract is the contract from which the user interacts with. This contract is responsible for lending, repayment and liquidation. For more details see Lend.md

Master Contract

The Master contract is the contract from which the lend contract gets calculated values and conversion according to current market prices. For more details see Master.md

Oracle Contract

The Oracle contract is the contract from which the master contract fetch current prices for calculation. For more details see Oracle.md

LendNFT Contract

The LendNFT contract is the contract from which the lend contract uses to mint and burn lend NFTs which are essentially a proof of lend.


Lifecycle of Loan

Lifecycle


User Flows

Borrower

Borrower

Lender

Lender