If you notice some outdated information please let us know!
FAIL
The final review score is indicated as a percentage. The percentage is calculated as Achieved Points due to MAX Possible Points. For each element the answer can be either Yes/No or a percentage. For a detailed breakdown of the individual weights of each question, please consult this document.
Very simply, the audit looks for the following declarations from the developer's site. With these declarations, it is reasonable to trust the smart contracts.
This report is for informational purposes only and does not constitute investment advice of any kind, nor does it constitute an offer to provide investment advisory or other services. Nothing in this report shall be considered a solicitation or offer to buy or sell any security, token, future, option or other financial instrument or to offer or provide any investment advice or service to any person in any jurisdiction. Nothing contained in this report constitutes investment advice or offers any opinion with respect to the suitability of any security, and the views expressed in this report should not be taken as advice to buy, sell or hold any security. The information in this report should not be relied upon for the purpose of investing. In preparing the information contained in this report, we have not taken into account the investment needs, objectives and financial circumstances of any particular investor. This information has no regard to the specific investment objectives, financial situation and particular needs of any specific recipient of this information and investments discussed may not be suitable for all investors.
Any views expressed in this report by us were prepared based upon the information available to us at the time such views were written. The views expressed within this report are limited to DeFiSafety and the author and do not reflect those of any additional or third party and are strictly based upon DeFiSafety, its authors, interpretations and evaluation of relevant data. Changed or additional information could cause such views to change. All information is subject to possible correction. Information may quickly become unreliable for various reasons, including changes in market conditions or economic circumstances.
This completed report is copyright (c) DeFiSafety 2023. Permission is given to copy in whole, retaining this copyright label.
This section looks at the code deployed on the relevant chain that gets reviewed and its corresponding software repository. The document explaining these questions is here.
1. Are the smart contract addresses easy to find? (%)
JustLend's smart contract addresses can be found in their GitHub repository.
2. How active is the primary contract? (%)
JustLend's GovernorAlpha smart contract recorded more than 10 transactions in the last month, but failed to pass the 10 transactions in the last week mark. The protocol therefore earns 40%. A screenshot of the TRONscan can be found in the appendix. There are no contracts relating to lending / borrowing their repository, making us unable to award higher marks here.
3. Does the protocol have a public software repository? (Y/N)
JustLend's software repository can be found here.
4. Is there a development history visible? (%)
The protocol's justlend-protocol shows 9 commits and 2 branches, which demonstrates poor development history. This earns the protocol no marks.
5. Is the team public (not anonymous)?
JustLend's team can be found publicly on their LinkedIn page. A screenshot of the team page can be found in the appendix.
This section looks at the software documentation. The document explaining these questions is here.
6. Is there a whitepaper? (Y/N)
7. Is the protocol's software architecture documented? (Y/N)
This protocol's software architecture can be found in the third segment of the whitepaper: Architecture of JustLend Protocol. See the question above for the whitepaper link.
8. Does the software documentation fully cover the deployed contracts' source code? (%)
As there is a documentation related to partial deployed contracts' documentation in the Contracts section of the protocol's whitepaper but no code associated to the documentation explaining those functions, the protocol receives 50% on this question.
9. Is it possible to trace the documented software to its implementation in the protocol's source code? (%)
There is implicit traceability to the documented software as each smart contract files are covered within the README.md of the justlend-protocol repository.
10. Has the protocol tested their deployed code? (%)
There is no evidence of code deployment testing in the protocol's Github repository.
11. How covered is the protocol's code? (%)
There is no code coverage documentation available on JustLend.
12. Does the protocol provide scripts and instructions to run their tests? (Y/N)
There are no scripts or instructions provided for JustLend's testsuite.
13. Is there a detailed report of the protocol's test results?(%)
There are no detailed reports of the protocol's test results.
14. Has the protocol undergone Formal Verification? (Y/N)
JustLend has not undergone Formal Verification.
15. Were the smart contracts deployed to a testnet? (Y/N)
There is no evidence of testnet deployment for JustLend's protocol.
This section looks at the 3rd party software audits done. It is explained in this document.
16. Is the protocol sufficiently audited? (%)
JustLend has undergone 1 audit with CertiK, which was performed post-launch with partial implementation of changes and recommendations. Because of that, the protocol earns a 50%.
17. Is the bounty value acceptably high (%)
There is no bug bounty available for JustLend.
This section covers the documentation of special access controls for a DeFi protocol. The admin access controls are the contracts that allow updating contracts or coefficients in the protocol. Since these contracts can allow the protocol admins to "change the rules", complete disclosure of capabilities is vital for user's transparency. It is explained in this document.
18. Is the protocol's admin control information easy to find?
Admin control information can be found in the 3.7 Governance segment of JustLend's whitepaper.
19. Are relevant contracts clearly labelled as upgradeable or immutable? (%)
The relevant contracts are not identified as immutable / upgradeable.
20. Is the type of smart contract ownership clearly indicated? (%)
There is indication of ownership in JustLend's documentation: it is in the hands of JST holders.
21. Are the protocol's smart contract change capabilities described? (%)
Admin capabilities are listed in the Governance segment of the whitepaper. However, there is no mention of change capabilities for all smart contracts, which earns the protocol a 50%.
22. Is the protocol's admin control information easy to understand? (%)
Admin control information can be easily understood and is written in non-software specific language.
23. Is there sufficient Pause Control documentation? (%)
There is no pause control documentation for the protocol.
24. Is there sufficient Timelock documentation? (%)
A timelock.sol contract can be found in the GitHub repository which displays the duration in the code. The protocol therefore gets 60% on this question.
25. Is the Timelock of an adequate length? (Y/N)
The minimum delay for the timelock is 2 days, maximum delay being 30 days with a grace period of 14 days. Since the maximum timelock goes beyond 1 week, the protocol scores 50% on this question.
This section goes over the documentation that a protocol may or may not supply about their Oracle usage. Oracles are a fundamental part of DeFi as they are responsible for relaying tons of price data information to thousands of protocols using blockchain technology. Not only are they important for price feeds, but they are also an essential component of transaction verification and security. These questions are explained in this document.
26. Is the protocol's Oracle sufficiently documented? (%)
JustLend's Oracle usage is documented in its whitepaper at the section 3.5 ["Price Oracle"]https://www.justlend.link/docs/justlend_whitepaper_en.pdf). Because only the oracle source (JustSwap) is identified, the protocol earns 50%. Identifying which smart contracts are affected and what the timeframe is would allow the protocol to earn 100% on this score.
27. Is front running mitigated by this protocol? (Y/N)
JustLend mentions "smooth mechanisms" to avoid risks and greater volatility of prices, however this does not provide enough documentation to prove front running mitigation.
28. Can flashloan attacks be applied to the protocol, and if so, are those flashloan attack risks mitigated? (Y/N)
There is no flashloan attack mitigation technique documented for JustLend.
1pragma solidity ^0.5.12;
2
3import "./CToken.sol";
4
5/**
6 * @title Compound's CErc20 Contract
7 * @notice CTokens which wrap an EIP-20 underlying
8 * @author Compound
9 */
10contract CErc20 is CToken, CErc20Interface {
11
12 address constant USDTAddr = 0xa614f803B6FD780986A42c78Ec9c7f77e6DeD13C;// nile:0xECa9bC828A3005B9a3b909f2cc5c2a54794DE05F mainnet:0xa614f803B6FD780986A42c78Ec9c7f77e6DeD13C
13
14 /**
15 * @notice Initialize the new money market
16 * @param underlying_ The address of the underlying asset
17 * @param comptroller_ The address of the Comptroller
18 * @param interestRateModel_ The address of the interest rate model
19 * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18
20 * @param name_ ERC-20 name of this token
21 * @param symbol_ ERC-20 symbol of this token
22 * @param decimals_ ERC-20 decimal precision of this token
23 */
24 function initialize(address underlying_,
25 ComptrollerInterface comptroller_,
26 InterestRateModel interestRateModel_,
27 uint initialExchangeRateMantissa_,
28 string memory name_,
29 string memory symbol_,
30 uint8 decimals_,
31 uint256 newReserveFactorMantissa_) public {
32 // CToken initialize does the bulk of the work
33 super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_, newReserveFactorMantissa_);
34
35 // Set underlying and sanity check it
36 underlying = underlying_;
37 EIP20Interface(underlying).totalSupply();
38 }
39
40 /*** User Interface ***/
41
42 /**
43 * @notice Sender supplies assets into the market and receives cTokens in exchange
44 * @dev Accrues interest whether or not the operation succeeds, unless reverted
45 * @param mintAmount The amount of the underlying asset to supply
46 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
47 */
48 function mint(uint mintAmount) external returns (uint) {
49 (uint err,) = mintInternal(mintAmount);
50 return err;
51 }
52
53 /**
54 * @notice Sender redeems cTokens in exchange for the underlying asset
55 * @dev Accrues interest whether or not the operation succeeds, unless reverted
56 * @param redeemTokens The number of cTokens to redeem into underlying
57 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
58 */
59 function redeem(uint redeemTokens) external returns (uint) {
60 return redeemInternal(redeemTokens);
61 }
62
63 /**
64 * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset
65 * @dev Accrues interest whether or not the operation succeeds, unless reverted
66 * @param redeemAmount The amount of underlying to redeem
67 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
68 */
69 function redeemUnderlying(uint redeemAmount) external returns (uint) {
70 return redeemUnderlyingInternal(redeemAmount);
71 }
72
73 /**
74 * @notice Sender borrows assets from the protocol to their own address
75 * @param borrowAmount The amount of the underlying asset to borrow
76 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
77 */
78 function borrow(uint borrowAmount) external returns (uint) {
79 return borrowInternal(borrowAmount);
80 }
81
82 /**
83 * @notice Sender repays their own borrow
84 * @param repayAmount The amount to repay
85 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
86 */
87 function repayBorrow(uint repayAmount) external returns (uint) {
88 (uint err,) = repayBorrowInternal(repayAmount);
89 return err;
90 }
91
92 /**
93 * @notice Sender repays a borrow belonging to borrower
94 * @param borrower the account with the debt being payed off
95 * @param repayAmount The amount to repay
96 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
97 */
98 function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {
99 (uint err,) = repayBorrowBehalfInternal(borrower, repayAmount);
100 return err;
101 }
102
103 /**
104 * @notice The sender liquidates the borrowers collateral.
105 * The collateral seized is transferred to the liquidator.
106 * @param borrower The borrower of this cToken to be liquidated
107 * @param repayAmount The amount of the underlying borrowed asset to repay
108 * @param cTokenCollateral The market in which to seize collateral from the borrower
109 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
110 */
111 function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint) {
112 (uint err,) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral);
113 return err;
114 }
115
116 /**
117 * @notice The sender adds to reserves.
118 * @param addAmount The amount fo underlying token to add as reserves
119 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
120 */
121 function _addReserves(uint addAmount) external returns (uint) {
122 return _addReservesInternal(addAmount);
123 }
124
125 /*** Safe Token ***/
126
127 /**
128 * @notice Gets balance of this contract in terms of the underlying
129 * @dev This excludes the value of the current message, if any
130 * @return The quantity of underlying tokens owned by this contract
131 */
132 function getCashPrior() internal view returns (uint) {
133 EIP20Interface token = EIP20Interface(underlying);
134 return token.balanceOf(address(this));
135 }
136
137 /**
138 * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.
139 * This will revert due to insufficient balance or insufficient allowance.
140 * This function returns the actual amount received,
141 * which may be less than `amount` if there is a fee attached to the transfer.
142 *
143 * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.
144 * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca
145 */
146 function doTransferIn(address from, uint amount) internal returns (uint) {
147 EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);
148 uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this));
149 token.transferFrom(from, address(this), amount);
150
151 bool success;
152 assembly {
153 switch returndatasize()
154 case 0 { // This is a non-standard ERC-20
155 success := not(0) // set success to true
156 }
157 case 32 { // This is a compliant ERC-20
158 returndatacopy(0, 0, 32)
159 success := mload(0) // Set `success = returndata` of external call
160 }
161 default { // This is an excessively non-compliant ERC-20, revert.
162 revert(0, 0)
163 }
164 }
165 require(success, "TOKEN_TRANSFER_IN_FAILED");
166
167 // Calculate the amount that was *actually* transferred
168 uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this));
169 require(balanceAfter >= balanceBefore, "TOKEN_TRANSFER_IN_OVERFLOW");
170 return balanceAfter - balanceBefore; // underflow already checked above, just subtract
171 }
172
173 /**
174 * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory
175 * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to
176 * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified
177 * it is >= amount, this should not revert in normal conditions.
178 *
179 * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.
180 * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca
181 */
182 function doTransferOut(address payable to, uint amount) internal {
183 EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);
184 token.transfer(to, amount);
185
186 bool success;
187 if(address(token) == USDTAddr){
188 return;
189 }
190 assembly {
191 switch returndatasize()
192 case 0 { // This is a non-standard ERC-20
193 success := not(0) // set success to true
194 }
195 case 32 { // This is a complaint ERC-20
196 returndatacopy(0, 0, 32)
197 success := mload(0) // Set `success = returndata` of external call
198 }
199 default { // This is an excessively non-compliant ERC-20, revert.
200 revert(0, 0)
201 }
202 }
203 require(success, "TOKEN_TRANSFER_OUT_FAILED");