If you notice some outdated information please let us know!
-4%(Penalty)
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 2021. 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? (%)
TempleDAO's addresses can be found at this location, as indicated in the Appendix. These were clearly labelled and easy to find.
2. How active is the primary contract? (%)
Contract VaultProxy is used up to 14 times a day, as indicated in the Appendix.
3. Does the protocol have a public software repository? (Y/N)
TempleDao stores their repositories in Github.
4. Is there a development history visible? (%)
At 908 commits and 24 branches, the temple repo has good development history.
5. Is the team public (not anonymous)?
TempleDao's white paper indicates that the team behind TempleDao remains anonymous.
This section looks at the software documentation. The document explaining these questions is here.
6. Is there a whitepaper? (Y/N)
Location: https://docs.templedao.link
7. Is the protocol's software architecture documented? (Y/N)
No software architecture found.
8. Does the software documentation fully cover the deployed contracts' source code? (%)
No software architecture found.
9. Is it possible to trace the documented software to its implementation in the protocol's source code? (%)
No software architecture found.
10. Has the protocol tested their deployed code? (%)
Testing files could not be found. Code examples are in the Appendix at the end of this report.. As per the SLOC, there is 189% 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? (%)
No code coverage report found but there is a clear complete set of tests.
12. Does the protocol provide scripts and instructions to run their tests? (Y/N)
Test instructions can be found in the temple repo README.md here.
13. Is there a detailed report of the protocol's test results?(%)
Test reports can be found in the temple repo CI; here is an example.
14. Has the protocol undergone Formal Verification? (Y/N)
TempleDAO has not undergone formal verification.
15. Were the smart contracts deployed to a testnet? (Y/N)
TempleDao has testnet deployment documentation here.
This section looks at the 3rd party software audits done. It is explained in this document.
16. Is the protocol sufficiently audited? (%)
TempleDAO has been audited once before deployment. Their PeckShield audit lists 4 issues of varying severity, 2 of which have not yet been fixed, one of which is of medium severity.
17. Is the bounty value acceptably high (%)
TempleDAO offers an active bug bounty of up to $310.8K with Hats Finance. View TempleDAO's medium article here for more details.
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 on the protocol's Admin Controls page.
19. Are relevant contracts clearly labelled as upgradeable or immutable? (%)
TempleDAO's contracts are labelled as immutable here.
20. Is the type of smart contract ownership clearly indicated? (%)
21. Are the protocol's smart contract change capabilities described? (%)
22. Is the protocol's admin control information easy to understand? (%)
TempleDAO's admin control information is clear and easy to understand.
23. Is there sufficient Pause Control documentation? (%)
TempleDAO's pause controls are documented here. This includes contracts affected by the pause controls and measures used if pause controls are necessary in specific situations.
24. Is there sufficient Timelock documentation? (%)
The protocol identifies why timelocks are not necessary in their Timelock documentation.
25. Is the Timelock of an adequate length? (Y/N)
The protocol identifies why timelocks are not necessary in their Timelock documentation.
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? (%)
TempleDAO clearly outlines that they do not use any oracle here.
27. Is front running mitigated by this protocol? (Y/N)
TempleDAO mentions a max slippage setting on their AMM as a mitigation technique to make frontrunning not profitable.
28. Can flashloan attacks be applied to the protocol, and if so, are those flashloan attack risks mitigated? (Y/N)
The protocol clearly outlines that flashloan attacks are not applicable to their protocol due to the locked fund function here.
1pragma solidity ^0.8.4;
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4import "@openzeppelin/contracts/access/Ownable.sol";
5import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
6
7import "./Vault.sol";
8import "../ABDKMathQuad.sol";
9import "../OGTemple.sol";
10import "../TempleERC20Token.sol";
11import "../TempleStaking.sol";
12import "../devotion/Faith.sol";
13
14/**
15 @notice A proxy contract for interacting with Temple Vaults.
16 */
17contract VaultProxy is Ownable {
18 using ABDKMathQuad for bytes16;
19 /** @notice Tokens / Contracted required for the proxy contract */
20 OGTemple public immutable ogTemple;
21 TempleERC20Token public immutable temple;
22 TempleStaking public immutable templeStaking;
23 Faith public immutable faith;
24 bool public faithClaimEnabled;
25
26 constructor(
27 OGTemple _ogTemple,
28 TempleERC20Token _temple,
29 TempleStaking _templeStaking,
30 Faith _faith
31 ) {
32 ogTemple = _ogTemple;
33 temple = _temple;
34 templeStaking = _templeStaking;
35 faith = _faith;
36 faithClaimEnabled = true;
37 }
38
39 bytes16 private constant MAX_MULT = 0x3fff4ccccccccccccccccccccccccccc; // 1.3
40 bytes16 private constant TA_MULT = 0x40004000000000000000000000000000; // 2.5
41
42 /**
43 @notice Given an amount of Faith and Temple, apply the boosting curve and strapiuce the amount of boosted Temple one can expect to receive.
44 Formula is BoostedTemple = TempleProvided * min(1.3, (1+faith/(2.5*TempleProvided)))
45 */
46 function getFaithMultiplier(uint256 _amountFaith, uint256 _amountTemple) pure public returns (uint256) {
47 // Tl = Ta * min(1.3, (1+faith/2.5*Ta))
48 bytes16 amountFaith = ABDKMathQuad.fromUInt(_amountFaith);
49 bytes16 amountTemple = ABDKMathQuad.fromUInt(_amountTemple);
50 bytes16 t = ABDKMathQuad.fromUInt(1).add(amountFaith.div(TA_MULT.mul(amountTemple)));
51 bytes16 mult = MAX_MULT < t ? MAX_MULT : t;
52
53 return ABDKMathQuad.toUInt(amountTemple.mul(mult));
54 }
55
56 /**
57 @notice Takes provided faith and Temple, applies the boost then immediate deposits into a vault
58 */
59 function depositTempleWithFaith(uint256 _amountTemple, uint112 _amountFaith, Vault vault) public {
60 require(faithClaimEnabled, "VaultProxy: Faith claim no longer enabled");
61 faith.redeem(msg.sender, _amountFaith);
62 uint256 boostedAmount = getFaithMultiplier(_amountFaith, _amountTemple);
63 SafeERC20.safeTransferFrom(temple, msg.sender, address(this), _amountTemple);
64 SafeERC20.safeIncreaseAllowance(temple, address(vault), boostedAmount);
65 vault.depositFor(msg.sender, boostedAmount);
66 }
67
68 /**
69 @notice Takes provided faith and OGT, unstakes the OGT into Temple, applies the boost and then immediately
70 deposits into a vault
71 */
72 function unstakeAndDepositTempleWithFaith(uint256 _amountOGT, uint112 _amountFaith, Vault vault) external {
73 require(faithClaimEnabled, "VaultProxy: Faith claim no longer enabled");
74 faith.redeem(msg.sender, _amountFaith);
75 uint256 unstakedTemple = unstakeOGT(_amountOGT);
76 uint256 boostedAmount = getFaithMultiplier(_amountFaith, unstakedTemple);
77 SafeERC20.safeIncreaseAllowance(temple, address(vault), boostedAmount);
78 vault.depositFor(msg.sender, boostedAmount);
79 }
80
81 /**
82 @notice Takes provided OGT, unstakes into Temple and immediately deposits into a vault
83 */
84 function unstakeAndDepositIntoVault(uint256 _amountOGT, Vault vault) external {
85 uint256 unstakedTemple = unstakeOGT(_amountOGT);
86 SafeERC20.safeIncreaseAllowance(temple, address(vault), unstakedTemple);
87 vault.depositFor(msg.sender, unstakedTemple);
88 }
89
90 /**
91 @notice Private function which will take OGT, unstake it, ensure correct amount came back and then pass back
92 to the calling function.
93 */
94 function unstakeOGT(uint256 _amountOGT) private returns (uint256) {
95 SafeERC20.safeIncreaseAllowance(ogTemple, address(templeStaking), _amountOGT);
96 SafeERC20.safeTransferFrom(ogTemple, msg.sender, address(this), _amountOGT);
97
98 uint256 templeBeforeBalance = temple.balanceOf(address(this));
99 templeStaking.unstake(_amountOGT);
100 uint256 templeAfterBalance = temple.balanceOf(address(this));
101 require(templeAfterBalance > templeBeforeBalance, "Vault Proxy: no Temple received when unstaking");
102
103 return templeAfterBalance - templeBeforeBalance;
104 }
105
106 /**
107 @notice A proxy function for depositing into a vault; useful if we wish to limit number of approvals to one, rather than for each underlying
108 vault instance.
109 */
110 function depositTempleFor(uint256 _amount, Vault vault) public {
111 SafeERC20.safeIncreaseAllowance(temple, address(vault), _amount);
112 SafeERC20.safeTransferFrom(temple, msg.sender, address(this), _amount);
113 vault.depositFor(msg.sender, _amount);
114 }
115
116 /**
117 * Toggle whether faith is claimable
118 */
119 function toggleFaithClaimEnabled() external onlyOwner {
120 faithClaimEnabled = !faithClaimEnabled;
121 }
122
123 /**
124 * transfer out amount of token to provided address
125 */
126 function withdraw(address token, address to, uint256 amount) external onlyOwner {
127 require(to != address(0), "to address zero");
128
129 if (token == address(0)) {
130 (bool sent,) = payable(to).call{value: amount}("");
131 require(sent, "send failed");
132 } else {
133 SafeERC20.safeTransfer(IERC20(token), to, amount);
134 }
135 }
136}
Tests to Code: 3522 / 994 = 354 %