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? (%)
InstaDapp's smart contracts can be found under the respective platform's tabs in their documentation; Ethereum Mainnet's smart contracts can be found here. A screenshot of a sample of addresses can be found in the appendix.
2. How active is the primary contract? (%)
The protocol's Index contract logs in more than 10 internal transactions a day, earning the protocol a 100% on this question. A screenshot of their transaction history can be found in the appendix.
3. Does the protocol have a public software repository? (Y/N)
InstaDapp's software repo can be found here.
4. Is there a development history visible? (%)
Found in the GitHub, Instadapp's dsa-connectors repository records a total of 1196 commits and 5 branches, giving the protocol a nice 100%.
5. Is the team public (not anonymous)?
The InstaDapp team can be found on their LinkedIn page. The protocol earns a 100% as 2+ names can be found associated to the page.
This section looks at the software documentation. The document explaining these questions is here.
7. Is the protocol's software architecture documented? (Y/N)
The protocol's basic functions are described here.
8. Does the software documentation fully cover the deployed contracts' source code? (%)
There is partial coverage of deployed contracts by software function documentation; a written description of smart contract functions are available on the same page as the addresses. There are missing contract functions such as InstaFlashResolver, Treasury, etc.
9. Is it possible to trace the documented software to its implementation in the protocol's source code? (%)
While there is implicit traceability of smart contract code and documentation, giving the protocol a 60%, InstaDapp could earn 100% by linking the documentation to the source 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 393% 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? (%)
InstaDapp's code coverage is fully documented within their GitHub repository.
12. Does the protocol provide scripts and instructions to run their tests? (Y/N)
InstaDapp provides scripts to run their tests in each respective smart contract repository. An example of this would be the test repository in dsa-contracts.
13. Is there a detailed report of the protocol's test results?(%)
InstaDapp displays test reports in their GitHub Actions tab, such as here.
14. Has the protocol undergone Formal Verification? (Y/N)
InstaDapp has not undergone formal verification.
15. Were the smart contracts deployed to a testnet? (Y/N)
InstaDapp has not provided any smart contract address issued from their testnet usage.
This section looks at the 3rd party software audits done. It is explained in this document.
16. Is the protocol sufficiently audited? (%)
While Peckshield's V2 version seems to be the most recent audit available, there are only 1 audit performed before deployment of the current version of InstaDapp. The other audits such as Samczsun's do not provide enough information to confirm subsantial auditing. Because of Peckshield's audits and OpenZeppelin Security, the protocol earns a 90% on this question.
17. Is the bounty value acceptably high (%)
An active bug bounty of 50K can be found under InstaDapp on Immunefi's website/
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 under the "Governance" section in the footer of the webpage.
19. Are relevant contracts clearly labelled as upgradeable or immutable? (%)
InstaDapp clearly labels the protocol's functionalities as being upgradeable in the Introduction section here.
20. Is the type of smart contract ownership clearly indicated? (%)
Ownership is indicated as OnlyOwner for dsa-contracts in the code and governance proposals are set as MultiSig in their documentation.
21. Are the protocol's smart contract change capabilities described? (%)
The smart contract change capabilities are not covered by the documentation, there is only mention of the upgradeability with no specification.
22. Is the protocol's admin control information easy to understand? (%)
The admin control information regarding upgradeability and governance are easy to understand.
23. Is there sufficient Pause Control documentation? (%)
There is no Pause Control documentation available on the developer documentation
24. Is there sufficient Timelock documentation? (%)
The protocol identifies a timelock and a duration of 10 days in their timelock.sol contract
25. Is the Timelock of an adequate length? (Y/N)
As specified here, the timelock is a minimum of 2 days to a maximum of 30 days, which is well above the appropriate length.
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? (%)
InstaDapp explains why their Smart Wallet service is not susceptible to oracle attacks.
27. Is front running mitigated by this protocol? (Y/N)
InstaDapp escribes why the Smart wallet is not vulnerable to front running attacks here.
28. Can flashloan attacks be applied to the protocol, and if so, are those flashloan attack risks mitigated? (Y/N)
InstaDapp offers a flash loan functionality and describes why the Smart wallet is not vulnerable to flash loan attacks here.
1pragma solidity ^0.7.0;
2pragma experimental ABIEncoderV2;
3
4/**
5 * @title InstaIndex
6 * @dev Main Contract For DeFi Smart Accounts. This is also a factory contract, Which deploys new Smart Account.
7 * Also Registry for DeFi Smart Accounts.
8 */
9
10interface AccountInterface {
11 function version() external view returns (uint);
12 function enable(address authority) external;
13 function cast(address[] calldata _targets, bytes[] calldata _datas, address _origin) external payable returns (bytes32[] memory responses);
14}
15
16interface ListInterface {
17 function init(address _account) external;
18}
19
20contract AddressIndex {
21
22 event LogNewMaster(address indexed master);
23 event LogUpdateMaster(address indexed master);
24 event LogNewCheck(uint indexed accountVersion, address indexed check);
25 event LogNewAccount(address indexed _newAccount, address indexed _connectors, address indexed _check);
26
27 // New Master Address.
28 address private newMaster;
29 // Master Address.
30 address public master;
31 // List Registry Address.
32 address public list;
33
34 // Connectors Modules(Account Module Version => Connectors Registry Module Address).
35 mapping (uint => address) public connectors;
36 // Check Modules(Account Module Version => Check Module Address).
37 mapping (uint => address) public check;
38 // Account Modules(Account Module Version => Account Module Address).
39 mapping (uint => address) public account;
40 // Version Count of Account Modules.
41 uint public versionCount;
42
43 /**
44 * @dev Throws if the sender not is Master Address.
45 */
46 modifier isMaster() {
47 require(msg.sender == master, "not-master");
48 _;
49 }
50
51 /**
52 * @dev Change the Master Address.
53 * @param _newMaster New Master Address.
54 */
55 function changeMaster(address _newMaster) external isMaster {
56 require(_newMaster != master, "already-a-master");
57 require(_newMaster != address(0), "not-valid-address");
58 require(newMaster != _newMaster, "already-a-new-master");
59 newMaster = _newMaster;
60 emit LogNewMaster(_newMaster);
61 }
62
63 function updateMaster() external {
64 require(newMaster != address(0), "not-valid-address");
65 require(msg.sender == newMaster, "not-master");
66 master = newMaster;
67 newMaster = address(0);
68 emit LogUpdateMaster(master);
69 }
70
71 /**
72 * @dev Change the Check Address of a specific Account Module version.
73 * @param accountVersion Account Module version.
74 * @param _newCheck The New Check Address.
75 */
76 function changeCheck(uint accountVersion, address _newCheck) external isMaster {
77 require(_newCheck != check[accountVersion], "already-a-check");
78 check[accountVersion] = _newCheck;
79 emit LogNewCheck(accountVersion, _newCheck);
80 }
81
82 /**
83 * @dev Add New Account Module.
84 * @param _newAccount The New Account Module Address.
85 * @param _connectors Connectors Registry Module Address.
86 * @param _check Check Module Address.
87 */
88 function addNewAccount(address _newAccount, address _connectors, address _check) external isMaster {
89 require(_newAccount != address(0), "not-valid-address");
90 versionCount++;
91 require(AccountInterface(_newAccount).version() == versionCount, "not-valid-version");
92 account[versionCount] = _newAccount;
93 if (_connectors != address(0)) connectors[versionCount] = _connectors;
94 if (_check != address(0)) check[versionCount] = _check;
95 emit LogNewAccount(_newAccount, _connectors, _check);
96 }
97
98}
99
100contract CloneFactory is AddressIndex {
101 /**
102 * @dev Clone a new Account Module.
103 * @param version Account Module version to clone.
104 */
105 function createClone(uint version) internal returns (address result) {
106 bytes20 targetBytes = bytes20(account[version]);
107 // solium-disable-next-line security/no-inline-assembly
108 assembly {
109 let clone := mload(0x40)
110 mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
111 mstore(add(clone, 0x14), targetBytes)
112 mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
113 result := create(0, clone, 0x37)
114 }
115 }
116
117 /**
118 * @dev Check if Account Module is a clone.
119 * @param version Account Module version.
120 * @param query Account Module Address.
121 */
122 function isClone(uint version, address query) external view returns (bool result) {
123 bytes20 targetBytes = bytes20(account[version]);
124 // solium-disable-next-line security/no-inline-assembly
125 assembly {
126 let clone := mload(0x40)
127 mstore(clone, 0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000)
128 mstore(add(clone, 0xa), targetBytes)
129 mstore(add(clone, 0x1e), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
130
131 let other := add(clone, 0x40)
132 extcodecopy(query, other, 0, 0x2d)
133 result := and(
134 eq(mload(clone), mload(other)),
135 eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
136 )
137 }
138 }
139}
140
141contract InstaIndex is CloneFactory {
142
143 event LogAccountCreated(address sender, address indexed owner, address indexed account, address indexed origin);
144
145 /**
146 * @dev Create a new DeFi Smart Account for a user and run cast function in the new Smart Account.
147 * @param _owner Owner of the Smart Account.
148 * @param accountVersion Account Module version.
149 * @param _targets Array of Target to run cast function.
150 * @param _datas Array of Data(callData) to run cast function.
151 * @param _origin Where Smart Account is created.
152 */
153 function buildWithCast(
154 address _owner,
155 uint accountVersion,
156 address[] calldata _targets,
157 bytes[] calldata _datas,
158 address _origin
159 ) external payable returns (address _account) {
160 _account = build(_owner, accountVersion, _origin);
161 if (_targets.length > 0) AccountInterface(_account).cast{value: msg.value}(_targets, _datas, _origin);
162 }
163
164 /**
165 * @dev Create a new DeFi Smart Account for a user.
166 * @param _owner Owner of the Smart Account.
167 * @param accountVersion Account Module version.
168 * @param _origin Where Smart Account is created.
169 */
170 function build(
171 address _owner,
172 uint accountVersion,
173 address _origin
174 ) public returns (address _account) {
175 require(accountVersion != 0 && accountVersion <= versionCount, "not-valid-account");
176 _account = createClone(accountVersion);
177 ListInterface(list).init(_account);
178 AccountInterface(_account).enable(_owner);
179 emit LogAccountCreated(msg.sender, _owner, _account, _origin);
180 }
181
182 /**
183 * @dev Setup Initial things for InstaIndex, after its been deployed and can be only run once.
184 * @param _master The Master Address.
185 * @param _list The List Address.
186 * @param _account The Account Module Address.
187 * @param _connectors The Connectors Registry Module Address.
188 */
189 function setBasics(
190 address _master,
191 address _list,
192 address _account,
193 address _connectors
194 ) external {
195 require(
196 master == address(0) &&
197 list == address(0) &&
198 account[1] == address(0) &&
199 connectors[1] == address(0) &&
200 versionCount == 0,
201 "already-defined"
202 );
203 master = _master;
204 list = _list;
205 versionCount++;
206 account[versionCount] = _account;
207 connectors[versionCount] = _connectors;
208 }
209
210}
Tests to Code: 3482 / 885 = 393 %