Giter Club home page Giter Club logo

justlend-protocol-'s Introduction

JustLend Protocol

JustLend Protocol is an TRON smart contract protocol for supplying or borrowing assets. Through the jToken contracts, accounts on the TRON blockchain supply capital (TRX or TRC20 tokens) to receive jTokens or borrow assets from the protocol (holding other assets as collateral). The JustLend jToken contracts track these balances and algorithmically set interest rates for borrowers.

Before getting started with this repo, please read:

For questions about interacting with JustLend, please visit our Telegram Group.

Contracts

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

CToken, CErc20 and CEther
The Justlend jTokens which are self-contained borrowing and lending contracts, are deployed from the code of CToken and CEther contracts. CToken contains the core logic and CErc20 and CEther add public interfaces for TRC20 tokens and TRX, respectively. Each jToken is assigned an interest rate and risk model (see InterestRateModel and Comptroller parts), and allows accounts to mint (supply capital), redeem (withdraw capital), borrow and repay a borrow. Each jToken is an TRC20 compliant token where balances represent ownership of the market.
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 cTokens.
GovernorAlpha (Deprecated)
Old governance contract. The administrator of the Justlend timelock contract. Holders of JST token may create and vote on proposals which will be queued into the Justlend timelock and then have effects on Justlend jToken and Comptroller contracts.
GovernorBravo
The current used governance contract. The administrator of the Justlend timelock contract. Holders of JST token may create and vote on proposals which will be queued into the Justlend timelock and then have effects on Justlend jToken and Comptroller contracts.
InterestRateModel
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).
ErrorReporter
Library for tracking error codes and failure conditions.
Exponential
Library for handling fixed-point decimal numbers.
WhitePaperInterestRateModel
Initial interest rate model, as defined in the Whitepaper. This contract accepts a base rate and slope parameter in its constructor.
Careful Math
Library for safe math operations.
SafeToken
Library for safely handling Trc20 interaction.

Deployment

TronBox is being used in this project. Before getting started with the deployment script, please read:

Compile and Deployment

To get started, first create and initialize a NodeJS 8.0+ environment. Next, clone the repo and install the developer dependencies:

Setup

npm i

OS requirement

  • Linux
  • Mac OS X

Compile The Contract

Run this by using tronbox embedded solc:

tronbox compile

Or you may want to use external compilers. You can get the compiler from here

And rename the compiler executable file to solc512, then compile the contracts with these commands.

./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/Unitroller.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/Comptroller.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/Governance/WJST.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/Governance/GovernorBravoDelegator.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/Timelock.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/JumpRateModelV2.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/WhitePaperInterestRateModel.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/CEther.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/CErc20Delegate.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/CErc20Delegator.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/PriceOracle/PriceOracle.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/PriceOracleProxy.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/PriceOracle/PriceOracle.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/PriceOracleProxy.sol
./solc512   --allow-paths $YOUR_PATH/justlend-protocol/, --bin --abi --optimize $YOUR_PATH/justlend-protocol/Lens/CompoundLens.sol

Deploy on Nile TestNet

Before use, sample-env should be renamed to .env with the added network config:

PRIVATE_KEY_NILE=YOUR_PRIVATE_KEY
RESERVER_ADMIN=YOUR_RESERVE_ADMIN_ADMIN_ADDRESS
ADMIN=YOUR_ADMIN_ADDRESS

Assuming all contracts haven't been deployed, the user must deploy the script one by one individually by replacing xx with the correct number of the file and then record the contract addresses and data to ../data/test-xxx.json. Please feel free to modify the migrations and contract data.

tronbox migrate --network nile -f xx --to xx

For example, if you want to run 3_deploy_comptroller.js, the command will be tronbox migrate --network nile -f 3 --to 3.

Due to the limitation of Tronbox, Governor.setTimelock() is unable to be invoked among the migration script. Therefore, the related script is inside script/2_setTimelock.js. Please run it for setting up the timelock address from Governor.

Contract Callers

The sample of contract invokers is inside the script folder.

Discussion

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

For security concerns, please email [email protected].

_© Copyright 2022 JustLend DAO

justlend-protocol-'s People

Contributors

huffstarrr81256 avatar supersmartguy01 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.