GithubHelp home page GithubHelp logo

kennylflim / venus-protocol Goto Github PK

View Code? Open in Web Editor NEW

This project forked from venusprotocol/venus-protocol

1.0 0.0 0.0 52.39 MB

BNB Smart Chain Venus Protocol

License: BSD 3-Clause "New" or "Revised" License

Shell 0.01% JavaScript 24.15% TypeScript 29.06% Handlebars 0.04% Solidity 46.75%

venus-protocol's Introduction

GitHub Actions GitHub Actions

Venus Protocol

The Venus Protocol is a BNB Chain collection of smart contract for supplying or borrowing assets. Through the vToken contracts, accounts on the blockchain supply capital (BNB or BEP-20 tokens) to receive vTokens or borrow assets from the protocol (holding other assets as collateral). The protocol will also enable the minting of VAI, which is the first synthetic stablecoin on Venus that aims to be pegged to 1 USD. VAI is minted by the same collateral that is supplied to the protocol. The Venus vToken contracts track these balances and algorithmically set interest rates for borrowers and suppliers.

Before getting started with this repo, please read:

Interested in contributing? Please checkout our contributing guidelines

Isolated pool is the updated version of the Venus protocol. The Venus "Core Pool" uses the codebase in this repository. On the other hand, Isolated pools use the codebase in the isolated-pools repository.

Contracts

We detail a few of the core contracts in the Venus protocol.

VToken, VBep20 and VBNB
The Venus vTokens, which are self-contained borrowing and lending contracts. VToken contains the core logic and VBep20, VBUSD, and VBNB add public interfaces for BEP-20 tokens and bnb, respectively. Each VToken is assigned an interest rate and risk model (see InterestRateModel and Comptroller sections), and allows accounts to *mint* (supply capital), *redeem* (withdraw capital), *borrow* and *repay a borrow*. Each VToken is an BEP-20 compliant token where balances represent ownership of the market.
Diamond Comptroller
The risk model contract, which validates permissible user actions and disallows actions if they do not fit certain risk parameters. For instance, the Comptroller enforces that each borrowing user must maintain a sufficient collateral balance across all vTokens. The Comptroller is implemented as a Diamond proxy with several facets (MarketFacet, PolicyFacet, RewardFacet, SetterFacet) corresponding to the particular parts of the Comptroller functionality.
XVS
The Venus Governance Token (XVS). Holders of this token have the ability to govern the protocol via the governor contract.
Governor Bravo
The administrator of the Venus Timelock contracts. Holders of XVS token who have locked their tokens in XVSVault may create and vote on proposals which will be queued into the Venus Timelock and then have effects on other Venus contracts.
InterestRateModel, JumpRateModel, WhitepaperInterestRateModel
Contracts which define interest rate models. These models algorithmically determine interest rates based on the current utilization of a given market (that is, how much of the supplied assets are liquid versus borrowed).
Careful Math
Library for safe math operations.
ErrorReporter
Library for tracking error codes and failure conditions.
Exponential
Library for handling fixed-point decimal numbers.

Documentation

  • Public documentation site: https://docs.venus.io, including autogernated documentation, guides, addresses of the deployment contracts and more content.
  • Documentation autogenerated using solidity-docgen.
  • To generate the documentation from the natspec comments embedded in the contracts, use yarn docgen

Installation

To run venus, pull the repository from GitHub and install its dependencies. You will need yarn or npm installed.

git clone https://github.com/VenusProtocol/venus-protocol
cd venus-protocol
yarn install --lock-file # or `npm install`

Testing

Contract tests are defined under the tests directory. To run the tests run:


    yarn test

  • To run fork tests add FORK=true, FORKED_NETWORK and one ARCHIVE_NODE var in the .env file.

Code Coverage

To run code coverage, run:


npx hardhat coverage

Deployment


npx hardhat deploy

  • This command will execute all the deployment scripts in ./deploy directory - It will skip only deployment scripts which implement a skip condition - Here is example of a skip condition: - Skipping deployment script on bsctestnet network func.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.name !== "bsctestnet";
  • The default network will be hardhat
  • Deployment to another network: - Make sure the desired network is configured in hardhat.config.ts - Add MNEMONIC variable in .env file - Execute deploy command by adding --network <network_name> in the deploy command above - E.g. npx hardhat deploy --network bsctestnet
  • Execution of single or custom set of scripts is possible, if:
    • In the deployment scripts you have added tags for example: - func.tags = ["MockTokens"];
    • Once this is done, adding --tags "<tag_name>,<tag_name>..." to the deployment command will execute only the scripts containing the tags.

Deployed Contracts

Contract addresses deployed before hardhat-deploy was adopted are available in the networking directory in JSON files by network name.

Contract addresses and abis deployed with hardhat deploy are exported in the deployments directory. To create a summary export of all contracts deployed to a network run.

$ yarn hardhat --network <network-name> --export ./deployments/<network-name>.json

Source Code Verification

In order to verify the source code of already deployed contracts, run: npx hardhat etherscan-verify --network <network_name>

Make sure you have added ETHERSCAN_API_KEY in .env file.

Linting

To lint the code, run:


yarn lint

To format the code, run:


yarn prettier

Hardhat Commands


npx hardhat accounts

npx hardhat compile

npx hardhat clean

npx hardhat test

npx hardhat node

npx hardhat help

REPORT_GAS=true npx hardhat test

npx hardhat coverage

TS_NODE_FILES=true npx ts-node scripts/deploy.ts

npx eslint '\*_/_.{js,ts}'

npx eslint '\*_/_.{js,ts}' --fix

npx prettier '\*_/_.{json,sol,md}' --check

npx prettier '\*_/_.{json,sol,md}' --write

npx solhint 'contracts/\*_/_.sol'

npx solhint 'contracts/\*_/_.sol' --fix

MNEMONIC="<>" BSC_API_KEY="<>" npx hardhat run ./script/hardhat/deploy.ts --network testnet

Discussion

For any concerns with the protocol, open an issue or visit us on Telegram to discuss.

For security concerns, please contact the administrators of our telegram chat.

© Copyright 2023, Venus Protocol

venus-protocol's People

Contributors

narayanprusty avatar kkirka avatar 0xlucian avatar gitguru7 avatar coreyar avatar debugger022 avatar chechu avatar defistar avatar toolsvenus avatar brightdev33 avatar gryincent avatar uravgdeveloper avatar drinyx avatar blockplus avatar roserompkxm avatar thodges-gh avatar greenrose51 avatar swipedevelopment avatar superdev810 avatar gleiser-oliveira avatar

Stargazers

Opportunity network  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.