If you notice some outdated information please let us know!
PASS
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? (%)
They can be found at https://docs.liquity.org/documentation/resources , as indicated in the Appendix.
2. How active is the primary contract? (%)
Contract Borrow Operations is used 20+ times a day, as indicated in the Appendix.
3. Does the protocol have a public software repository? (Y/N)
https://github.com/liquity
4. Is there a development history visible? (%)
At 2830 commits and 52 branches, this protocol has some of the most well-moisturised development history we've ever seen. This protocol's development history exemplifies the following traits: "Unbothered. Moisturized. Happy. In My Lane. Focused. Flourishing."
5. Is the team public (not anonymous)?
This team is fully public.
The difference between this and the old link is solely the link. This section looks at the software documentation. The document explaining these questions is here.
6. Is there a whitepaper? (Y/N)
Location: https://docs.liquity.org/
7. Is the protocol's software architecture documented? (Y/N)
This protocol's software architecture is documented in full.
8. Does the software documentation fully cover the deployed contracts' source code? (%)
There is full coverage of deployed contracts by software function documentation.
9. Is it possible to trace the documented software to its implementation in the protocol's source code? (%)
There is clear and explicit traceability between software documentation and implemented code.
10. Has the protocol tested their deployed code? (%)
Code examples are in the Appendix at the end of this report.. As per the SLOC, there is 287% testing to code (TtC). This score is guided by the Test to Code ratio (TtC). Generally a good test to code ratio is over 100%. However, the reviewer's best judgement is the final deciding factor.
11. How covered is the protocol's code? (%)
This protocol documents 98% code coverage.
12. Does the protocol provide scripts and instructions to run their tests? (Y/N)
Scripts/Instructions location: https://github.com/liquity/dev#running-tests
13. Is there a detailed report of the protocol's test results?(%)
A full report is detailed
14. Has the protocol undergone Formal Verification? (Y/N)
This protocol has not undergone formal verification.
15. Were the smart contracts deployed to a testnet? (Y/N)
This protocol has been deployed to a testnet.
This section looks at the 3rd party software audits done. It is explained in this document.
16. Is the protocol sufficiently audited? (%)
Liquity was audited multiple times before launch.
17. Is the bounty value acceptably high (%)
This protocol offers an active bug bounty of $250K
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 was fully documented at this location. This took some looking.
19. Are relevant contracts clearly labelled as upgradeable or immutable? (%)
The relevant contracts are identified as immutable, as identified here.
20. Is the type of smart contract ownership clearly indicated? (%)
Ownership is clearly indicated in this location.
21. Are the protocol's smart contract change capabilities described? (%)
This protocol is immutable.
22. Is the protocol's admin control information easy to understand? (%)
This information is not in software specific language.
23. Is there sufficient Pause Control documentation? (%)
This protocol's pause control is not documented - this is not relevant because the protocol is immutable. Nevertheless, it possesses something called a recovery mode.
24. Is there sufficient Timelock documentation? (%)
This protocol does not stake it possesses a timelock, though this is clear from the fact that all contracts are immutable.
25. Is the Timelock of an adequate length? (Y/N)
This protocol has no timelock.
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. This is explained in this document.
26. Is the protocol's Oracle sufficiently documented? (%)
The protocol's oracle source is sufficiently documented at this location. The contracts dependent are identified. There is relevant software function documentation.
27. Is front running mitigated by this protocol? (Y/N)
This protocol documents substantial and impressive front running mitigation techniques at this location. This protocol's readme.md is beautiful and other protocols should view it as an example of great process quality they would do well to emulate.
28. Can flashloan attacks be applied to the protocol, and if so, are those flashloan attack risks mitigated? (Y/N)
This protocol documents flashloan countermeasures at this location. It incentivises potential exploiters to focus on flashloan attacks in their bug bounty offering.
1/ SPDX-License-Identifier: MIT
2
3pragma solidity 0.6.11;
4
5import './Interfaces/IActivePool.sol';
6import "./Dependencies/SafeMath.sol";
7import "./Dependencies/Ownable.sol";
8import "./Dependencies/CheckContract.sol";
9import "./Dependencies/console.sol";
10
11/*
12 * The Active Pool holds the ETH collateral and LUSD debt (but not LUSD tokens) for all active troves.
13 *
14 * When a trove is liquidated, it's ETH and LUSD debt are transferred from the Active Pool, to either the
15 * Stability Pool, the Default Pool, or both, depending on the liquidation conditions.
16 *
17 */
18contract ActivePool is Ownable, CheckContract, IActivePool {
19 using SafeMath for uint256;
20
21 string constant public NAME = "ActivePool";
22
23 address public borrowerOperationsAddress;
24 address public troveManagerAddress;
25 address public stabilityPoolAddress;
26 address public defaultPoolAddress;
27 uint256 internal ETH; // deposited ether tracker
28 uint256 internal LUSDDebt;
29
30 // --- Events ---
31
32 event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress);
33 event TroveManagerAddressChanged(address _newTroveManagerAddress);
34 event ActivePoolLUSDDebtUpdated(uint _LUSDDebt);
35 event ActivePoolETHBalanceUpdated(uint _ETH);
36
37 // --- Contract setters ---
38
39 function setAddresses(
40 address _borrowerOperationsAddress,
41 address _troveManagerAddress,
42 address _stabilityPoolAddress,
43 address _defaultPoolAddress
44 )
45 external
46 onlyOwner
47 {
48 checkContract(_borrowerOperationsAddress);
49 checkContract(_troveManagerAddress);
50 checkContract(_stabilityPoolAddress);
51 checkContract(_defaultPoolAddress);
52
53 borrowerOperationsAddress = _borrowerOperationsAddress;
54 troveManagerAddress = _troveManagerAddress;
55 stabilityPoolAddress = _stabilityPoolAddress;
56 defaultPoolAddress = _defaultPoolAddress;
57
58 emit BorrowerOperationsAddressChanged(_borrowerOperationsAddress);
59 emit TroveManagerAddressChanged(_troveManagerAddress);
60 emit StabilityPoolAddressChanged(_stabilityPoolAddress);
61 emit DefaultPoolAddressChanged(_defaultPoolAddress);
62
63 _renounceOwnership();
64 }
65
66 // --- Getters for public variables. Required by IPool interface ---
67
68 /*
69 * Returns the ETH state variable.
70 *
71 *Not necessarily equal to the the contract's raw ETH balance - ether can be forcibly sent to contracts.
72 */
73 function getETH() external view override returns (uint) {
74 return ETH;
75 }
76
77 function getLUSDDebt() external view override returns (uint) {
78 return LUSDDebt;
79 }
80
81 // --- Pool functionality ---
82
83 function sendETH(address _account, uint _amount) external override {
84 _requireCallerIsBOorTroveMorSP();
85 ETH = ETH.sub(_amount);
86 emit ActivePoolETHBalanceUpdated(ETH);
87 emit EtherSent(_account, _amount);
88
89 (bool success, ) = _account.call{ value: _amount }("");
90 require(success, "ActivePool: sending ETH failed");
91 }
92
93 function increaseLUSDDebt(uint _amount) external override {
94 _requireCallerIsBOorTroveM();
95 LUSDDebt = LUSDDebt.add(_amount);
96 ActivePoolLUSDDebtUpdated(LUSDDebt);
97 }
98
99 function decreaseLUSDDebt(uint _amount) external override {
100 _requireCallerIsBOorTroveMorSP();
101 LUSDDebt = LUSDDebt.sub(_amount);
102 ActivePoolLUSDDebtUpdated(LUSDDebt);
103 }
104
105 // --- 'require' functions ---
106
107 function _requireCallerIsBorrowerOperationsOrDefaultPool() internal view {
108 require(
109 msg.sender == borrowerOperationsAddress ||
110 msg.sender == defaultPoolAddress,
111 "ActivePool: Caller is neither BO nor Default Pool");
112 }
113
114 function _requireCallerIsBOorTroveMorSP() internal view {
115 require(
116 msg.sender == borrowerOperationsAddress ||
117 msg.sender == troveManagerAddress ||
118 msg.sender == stabilityPoolAddress,
119 "ActivePool: Caller is neither BorrowerOperations nor TroveManager nor StabilityPool");
120 }
121
122 function _requireCallerIsBOorTroveM() internal view {
123 require(
124 msg.sender == borrowerOperationsAddress ||
125 msg.sender == troveManagerAddress,
126 "ActivePool: Caller is neither BorrowerOperations nor TroveManager");
127 }
128
129 // --- Fallback function ---
130
131 receive() external payable {
132 _requireCallerIsBorrowerOperationsOrDefaultPool();
133 ETH = ETH.add(msg.value);
134 emit ActivePoolETHBalanceUpdated(ETH);
135 }
136}