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 Mainnet that gets reviewed and its corresponding software repository. The document explaining these questions is here.
1. Are the executing code addresses readily available? (%)
The address was clearly labelled on their documentation, but was not easy to find. They are available at website https://docs.idex.io/#url-amp-contract-addresses as indicated in the Appendix.
2. Is the code actively being used? (%)
Activity is 80 transactions a day on contract exchange.sol, as indicated in the Appendix.
3. Is there a public software repository? (Y/N)
Is there a public software repository with the code at a minimum, but also normally test and scripts. Even if the repository was created just to hold the files and has just 1 transaction, it gets a "Yes". For teams with private repositories, this answer is "No"
4. Is there a development history visible? (%)
With 92 commits and 9 branches this is a semi-healthy repository.
This metric checks if the software repository demonstrates a strong steady history. This is normally demonstrated by commits, branches and releases in a software repository. A healthy history demonstrates a history of more than a month (at a minimum).
5. Is the team public (not anonymous)? (Y/N)
Team names on Github; https://github.com/idexio/idex-contracts
For a "Yes" in this question, the real names of some team members must be public on the website or other documentation (LinkedIn, etc). If the team is anonymous, then this question is a "No".
This section looks at the software documentation. The document explaining these questions is here.
6. Is there a whitepaper? (Y/N)
7. Are the basic software functions documented? (Y/N)
There is robust API documentation available.
8. Does the software function documentation fully (100%) cover the deployed contracts? (%)
There is robust API documentation of any API contracts.
9. Are there sufficiently detailed comments for all functions within the deployed contract code (%)
The Comments to Code (CtC) ratio is the primary metric for this score.
10. Is it possible to trace from software documentation to the implementation in code (%)
While the robust API code does implicitly document many external functions, the actual code is never mentioned so no traceability
11. Full test suite (Covers all the deployed code) (%)
With a TtC of 278%, there is clearly a robust set of tests.
This score is guided by the Test to Code ratio (TtC). Generally a good test to code ratio is over 100%. However the reviewers best judgement is the final deciding factor.
12. Code coverage (Covers all the deployed lines of code, or explains misses) (%)
Their Audit by Quantstamp points to a 100% code coverage.
13. Scripts and instructions to run the tests? (Y/N)
Location: https://github.com/idexio/idex-contracts
14. Report of the results (%)
Code coverage results in the GitHub coveralls results.
15. Formal Verification test done (%)
16. Stress Testing environment (%)
Their contracts have been clearly well-tested on the RinkBy testnet.
This section looks at the 3rd party software audits done. It is explained in this document.
17. Did 3rd Party audits take place? (%)
Quantstamp preformed an audit on IDEX V2 on July 21st 2020.
18. Is the bug bounty acceptable high? (%)
There is no apparent bug bounty program.
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.
19. Can a user clearly and quickly find the status of the access controls (%)
Idex.io has a Governance.md file that contains information about admin controls.
20. Is the information clear and complete (%)
21. Is the information in non-technical terms that pertain to the investments (%)
Guidance: 100% All the contracts are immutable 90% Description relates to investments safety and updates in clear, complete non-software l language 30% Description all in software specific language 0% No admin control information could not be found
22. Is there Pause Control documentation including records of tests (%)
Guidance: 100% All the contracts are immutable or no pause control needed and this is explained OR 100% Pause control(s) are clearly documented and there is records of at least one test within 3 months 80% Pause control(s) explained clearly but no evidence of regular tests 40% Pause controls mentioned with no detail on capability or tests 0% Pause control not documented or explained
1// SPDX-License-Identifier: LGPL-3.0-only
2
3pragma solidity 0.6.8;
4pragma experimental ABIEncoderV2;
5
6import { Address } from '@openzeppelin/contracts/utils/Address.sol';
7import {
8 SafeMath as SafeMath256
9} from '@openzeppelin/contracts/math/SafeMath.sol';
10
11import { ICustodian } from './libraries/Interfaces.sol';
12import { Owned } from './Owned.sol';
13
14
15contract Governance is Owned {
16 using SafeMath256 for uint256;
17
18 /**
19 * @notice Emitted when admin initiates upgrade of `Exchange` contract address on `Custodian` via
20 * `initiateExchangeUpgrade`
21 */
22 event ExchangeUpgradeInitiated(
23 address oldExchange,
24 address newExchange,
25 uint256 blockThreshold
26 );
27 /**
28 * @notice Emitted when admin cancels previously started `Exchange` upgrade with `cancelExchangeUpgrade`
29 */
30 event ExchangeUpgradeCanceled(address oldExchange, address newExchange);
31 /*
32 * @notice Emitted when admin finalizes `Exchange` upgrade via `finalizeExchangeUpgrade`
33 */
34 event ExchangeUpgradeFinalized(address oldExchange, address newExchange);
35 /*
36 * @notice Emitted when admin initiates upgrade of `Governance` contract address on `Custodian` via
37 * `initiateGovernanceUpgrade`
38 */
39 event GovernanceUpgradeInitiated(
40 address oldGovernance,
41 address newGovernance,
42 uint256 blockThreshold
43 );
44 /**
45 * @notice Emitted when admin cancels previously started `Governance` upgrade with `cancelGovernanceUpgrade`
46 */
47 event GovernanceUpgradeCanceled(address oldGovernance, address newGovernance);
48 /**
49 * @notice Emitted when admin finalizes `Governance` upgrade via `finalizeGovernanceUpgrade`, effectively replacing
50 * this contract and rendering it non-functioning
51 */
52 event GovernanceUpgradeFinalized(
53 address oldGovernance,
54 address newGovernance
55 );
56
57 // Internally used structs //
58
59 struct ContractUpgrade {
60 bool exists;
61 address newContract;
62 uint256 blockThreshold;
63 }
64
65 // Storage //
66
67 uint256 immutable _blockDelay;
68 ICustodian _custodian;
69 ContractUpgrade _currentExchangeUpgrade;
70 ContractUpgrade _currentGovernanceUpgrade;
71
72 /**
73 * @notice Instantiate a new `Governance` contract
74 *
75 * @dev Sets `owner` and `admin` to `msg.sender`. Sets the values for `_blockDelay` governing `Exchange`
76 * and `Governance` upgrades. This value is immutable, and cannot be changed after construction
77 *
78 * @param blockDelay The minimum number of blocks that must be mined after initiating an `Exchange`
79 * or `Governance` upgrade before the upgrade may be finalized
80 */
81 constructor(uint256 blockDelay) public Owned() {
82 _blockDelay = blockDelay;
83 }
84
85 /**
86 * @notice Sets the address of the `Custodian` contract. The `Custodian` accepts `Exchange` and
87 * `Governance` addresses in its constructor, after which they can only be changed by the
88 * `Governance` contract itself. Therefore the `Custodian` must be deployed last and its address
89 * set here on an existing `Governance` contract. This value is immutable once set and cannot be
90 * changed again
91 *
92 * @param newCustodian The address of the `Custodian` contract deployed against this `Governance`
93 * contract's address
94 */
95 function setCustodian(ICustodian newCustodian) external onlyAdmin {
96 require(_custodian == ICustodian(0x0), 'Custodian can only be set once');
97 require(Address.isContract(address(newCustodian)), 'Invalid address');
98
99 _custodian = newCustodian;
100 }
101
102 // Exchange upgrade //
103
104 /**
105 * @notice Initiates `Exchange` contract upgrade proccess on `Custodian`. Once `blockDelay` has passed
106 * the process can be finalized with `finalizeExchangeUpgrade`
107 *
108 * @param newExchange The address of the new `Exchange` contract
109 */
110 function initiateExchangeUpgrade(address newExchange) external onlyAdmin {
111 require(Address.isContract(address(newExchange)), 'Invalid address');
112 require(
113 newExchange != _custodian.loadExchange(),
114 'Must be different from current Exchange'
115 );
116 require(
117 !_currentExchangeUpgrade.exists,
118 'Exchange upgrade already in progress'
119 );
120
121 _currentExchangeUpgrade = ContractUpgrade(
122 true,
123 newExchange,
124 block.number.add(_blockDelay)
125 );
126
127 emit ExchangeUpgradeInitiated(
128 _custodian.loadExchange(),
129 newExchange,
130 _currentExchangeUpgrade.blockThreshold
131 );
132 }
133
134 /**
135 * @notice Cancels an in-flight `Exchange` contract upgrade that has not yet been finalized
136 */
137 function cancelExchangeUpgrade() external onlyAdmin {
138 require(_currentExchangeUpgrade.exists, 'No Exchange upgrade in progress');
139
140 address newExchange = _currentExchangeUpgrade.newContract;
141 delete _currentExchangeUpgrade;
142
143 emit ExchangeUpgradeCanceled(_custodian.loadExchange(), newExchange);
144 }
145
146 /**
147 * @notice Finalizes the `Exchange` contract upgrade by changing the contract address on the `Custodian`
148 * contract with `setExchange`. The number of blocks specified by `_blockDelay` must have passed since calling
149 * `initiateExchangeUpgrade`
150 *
151 * @param newExchange The address of the new `Exchange` contract. Must equal the address provided to
152 * `initiateExchangeUpgrade`
153 */
154 function finalizeExchangeUpgrade(address newExchange) external onlyAdmin {
155 require(_currentExchangeUpgrade.exists, 'No Exchange upgrade in progress');
156 require(
157 _currentExchangeUpgrade.newContract == newExchange,
158 'Address mismatch'
159 );
160 require(
161 block.number >= _currentExchangeUpgrade.blockThreshold,
162 'Block threshold not yet reached'
163 );
164
165 address oldExchange = _custodian.loadExchange();
166 _custodian.setExchange(newExchange);
167 delete _currentExchangeUpgrade;
168
169 emit ExchangeUpgradeFinalized(oldExchange, newExchange);
170 }
171
172 // Governance upgrade //
173
174 /**
175 * @notice Initiates `Governance` contract upgrade proccess on `Custodian`. Once `blockDelay` has passed
176 * the process can be finalized with `finalizeGovernanceUpgrade`
177 *
178 * @param newGovernance The address of the new `Governan
Comments to Code: 782 / 1531 = 51 %
Tests to Code: 4268 / 1531 = 279 %