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? (%)
Three of StellaSwap's smart contract addresses can be found in its documentation. Other smart contract addresses can be found in the forked repos of OpenZeppelin and Uniswap within code. Because this takes a bit of looking and there isn't a clear set of smart contract addresses found in one place, the protocol received a 50. A screenshot of the smart contract addresses can be found in the appendix.
2. How active is the primary contract? (%)
The protocol's Router Smart Contract is active for well above 10 transactions a day. For that reason, the protocol earns a 100% score on this one. A screenshot of the Moonscan transaction list is available in the appendix.
3. Does the protocol have a public software repository? (Y/N)
You can find the protocol's public software repository here.
4. Is there a development history visible? (%)
StellaSwap's contract repository has just 6 commits.
5. Is the team public (not anonymous)?
While the StellaSwap team mentions itself being KYC-ed by Moonbeam's leadership team, as none of the members are public and found to be working on the protocol, the protocol cannot earn points for this one.
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 software architecture is not documented; there are no mentions of how smart contracts interact, nor how the architecture is built. Only written descriptions of strapiucts are available, which do not count as software architecture documentation. The CertiK audit covers some of the architecture through diagrams and arrows.
8. Does the software documentation fully cover the deployed contracts' source code? (%)
There are no smart contract documentation from the software aspect of things.
9. Is it possible to trace the documented software to its implementation in the protocol's source code? (%)
There are no software documentation available for StellaSwap.
10. Has the protocol tested their deployed code? (%)
There are no evidence of testing in the StellaSwap contract repository.
11. How covered is the protocol's code? (%)
There are no documented code coverage in the protocol nor the audits.
12. Does the protocol provide scripts and instructions to run their tests? (Y/N)
There are no scripts or instructions available to run tests for StellaSwap.
13. Is there a detailed report of the protocol's test results?(%)
There are no detailed reports on the protocol's test results.
14. Has the protocol undergone Formal Verification? (Y/N)
StellaSwap has not undergone formal verification.
15. Were the smart contracts deployed to a testnet? (Y/N)
While there are smart contract addresses attached to StellaSwap within the Moonbase testnet explorer, the protocol does not provide testnet addresses in their documentation. Nonetheless, since we found evidence of this deployment, we'll award points here.
This section looks at the 3rd party software audits done. It is explained in this document.
16. Is the protocol sufficiently audited? (%)
StellaSwap has gone through 2 audits post-launch and changes are needed but there are no visible documentation on changes made as a result of the audits. 4 major vulnerabilities were identified by CertiK that were not fixed, though 2 were mitigated. Score: 50%
17. Is the bounty value acceptably high (%)
There are no bug bounties available for StellaSwap.
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?
There are no admin control information readily available for users on StellaSwap's website. There is a mention of a governance portal launch in february 2022 but that portal is nowhere to be found.
19. Are relevant contracts clearly labelled as upgradeable or immutable? (%)
There are no mentions of upgradeability or immutability in the protocol's documentation nor code.
20. Is the type of smart contract ownership clearly indicated? (%)
StellaSwap does not indicate ownership of its smart contracts. Many of the protocol's contracts do mention in their code the OnlyOwner function but a mention of contract ownership in the documentation would greatly help users better understand the capacities and limitations of smart contract changes.
21. Are the protocol's smart contract change capabilities described? (%)
StellaSwap's documentation does not cover the capabilities for change of its smart contracts.
22. Is the protocol's admin control information easy to understand? (%)
There is no admin control information available in the protocol's website.
23. Is there sufficient Pause Control documentation? (%)
StellaSwap does not provide Pause Control documentation.
24. Is there sufficient Timelock documentation? (%)
StellaSwap's timelock function can be found in their Timelock.sol contract. The duration is specified within the contract. However, because there is no documentation clearly describing the timelock's purpose (there is a brief - yet irrelevant to smart contracts - mention of a timelock in "Staking & Locking" but this is not considered substantial) and which contracts it explicitly applies to, the protocol earns a 60%.
25. Is the Timelock of an adequate length? (Y/N)
StellaSwap's timelock has a minimum delay of 6 hours and a maximum delay of 30 days. Because the timelock can go beyond 48 hours but there is no explanation as to why there are variable delays, the protocol earns a 75%.
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? (%)
There is no documentation on StellaSwap's oracle(s). As a fork of Uni-V2, it is unlikely that they use them (though it is possible). Decentralised exchanges should identify this. As such, we will not be awarding points here.
27. Is front running mitigated by this protocol? (Y/N)
The protocol does not describe any front running mitigation techniques.
28. Can flashloan attacks be applied to the protocol, and if so, are those flashloan attack risks mitigated? (Y/N)
There are no mentions of flashloan attacks being applicable or not on the protocol/ flashloan attack mitigation techniques are not described.
1// SPDX-License-Identifier: GPL-3.0
2
3pragma solidity =0.6.12;
4
5import './StellaSwapV2ERC20.sol';
6import './libraries/Math.sol';
7import './libraries/UQ112x112.sol';
8import './interfaces/IERC20.sol';
9import './interfaces/IStellaSwapV2Factory.sol';
10import './interfaces/IStellaSwapV2Callee.sol';
11
12interface IMigrator {
13 // Return the desired amount of liquidity token that the migrator wants.
14 function desiredLiquidity() external view returns (uint256);
15}
16
17contract StellaSwapV2Pair is StellaSwapV2ERC20 {
18 using SafeMathStellaSwap for uint;
19 using UQ112x112 for uint224;
20
21 uint public constant MINIMUM_LIQUIDITY = 10**3;
22 bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
23
24 address public factory;
25 address public token0;
26 address public token1;
27
28 uint112 private reserve0; // uses single storage slot, accessible via getReserves
29 uint112 private reserve1; // uses single storage slot, accessible via getReserves
30 uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
31
32 uint public price0CumulativeLast;
33 uint public price1CumulativeLast;
34 uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
35
36 uint32 public swapFee = 25; // uses 0.25% default
37 uint32 public devFee = 5; // uses 0.05% default from swap fee
38
39 uint private unlocked = 1;
40 modifier lock() {
41 require(unlocked == 1, 'StellaSwapV2: LOCKED');
42 unlocked = 0;
43 _;
44 unlocked = 1;
45 }
46
47 function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
48 _reserve0 = reserve0;
49 _reserve1 = reserve1;
50 _blockTimestampLast = blockTimestampLast;
51 }
52
53 function _safeTransfer(address token, address to, uint value) private {
54 (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
55 require(success && (data.length == 0 || abi.decode(data, (bool))), 'StellaSwapV2: TRANSFER_FAILED');
56 }
57
58 event Mint(address indexed sender, uint amount0, uint amount1);
59 event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
60 event Swap(
61 address indexed sender,
62 uint amount0In,
63 uint amount1In,
64 uint amount0Out,
65 uint amount1Out,
66 address indexed to
67 );
68 event Sync(uint112 reserve0, uint112 reserve1);
69
70 constructor() public {
71 factory = msg.sender;
72 }
73
74 // called once by the factory at time of deployment
75 function initialize(address _token0, address _token1) external {
76 require(msg.sender == factory, 'StellaSwapV2: FORBIDDEN'); // sufficient check
77 token0 = _token0;
78 token1 = _token1;
79 }
80
81 function setSwapFee(uint32 _swapFee) external {
82 require(_swapFee > 0, "StellaSwapV2: lower then 0");
83 require(msg.sender == factory, 'StellaSwapV2: FORBIDDEN');
84 require(_swapFee <= 1000, 'StellaSwapV2: FORBIDDEN_FEE');
85 swapFee = _swapFee;
86 }
87
88 function setDevFee(uint32 _devFee) external {
89 require(_devFee > 0, "StellaSwapV2: lower then 0");
90 require(msg.sender == factory, 'StellaSwapV2: FORBIDDEN');
91 require(_devFee <= 500, 'StellaSwapV2: FORBIDDEN_FEE');
92 devFee = _devFee;
93 }
94
95 // update reserves and, on the first call per block, price accumulators
96 function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
97 require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'StellaSwapV2: OVERFLOW');
98 uint32 blockTimestamp = uint32(block.timestamp % 2**32);
99 uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
100 if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
101 // * never overflows, and + overflow is desired
102 price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
103 price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
104 }
105 reserve0 = uint112(balance0);
106 reserve1 = uint112(balance1);
107 blockTimestampLast = blockTimestamp;
108 emit Sync(reserve0, reserve1);
109 }
110
111 // if fee is on, mint liquidity equivalent to 1/5th of the growth in sqrt(k)
112 function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
113 address feeTo = IStellaSwapV2Factory(factory).feeTo();
114 feeOn = feeTo != address(0);
115 uint _kLast = kLast; // gas savings
116 if (feeOn) {
117 if (_kLast != 0) {
118 uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
119 uint rootKLast = Math.sqrt(_kLast);
120 if (rootK > rootKLast) {
121 uint numerator = totalSupply.mul(rootK.sub(rootKLast));
122 uint denominator = rootK.mul(devFee).add(rootKLast);
123 uint liquidity = numerator / denominator;
124 if (liquidity > 0) _mint(feeTo, liquidity);
125 }
126 }
127 } else if (_kLast != 0) {
128 kLast = 0;
129 }
130 }
131
132 // this low-level function should be called from a contract which performs important safety checks
133 function mint(address to) external lock returns (uint liquidity) {
134 (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
135 uint balance0 = IERC20StellaSwap(token0).balanceOf(address(this));
136 uint balance1 = IERC20StellaSwap(token1).balanceOf(address(this));
137 uint amount0 = balance0.sub(_reserve0);
138 uint amount1 = balance1.sub(_reserve1);
139
140 bool feeOn = _mintFee(_reserve0, _reserve1);
141 uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
142 if (_totalSupply == 0) {
143 address migrator = IStellaSwapV2Factory(factory).migrator();
144 if (msg.sender == migrator) {
145 liquidity = IMigrator(migrator).desiredLiquidity();
146 require(liquidity > 0 && liquidity != uint256(-1), "Bad desired liquidity");
147 } else {
148 require(migrator == address(0), "Must not have migrator");
149 liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
150 _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
151 }
152 } else {
153 liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
154 }
155 require(liquidity > 0, 'StellaSwapV2: INSUFFICIENT_LIQUIDITY_MINTED');
156 _mint(to, liquidity);
157
158 _update(balance0, balance1, _reserve0, _reserve1);
159 if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
160 emit Mint(msg.sender, amount0, amount1);
161 }
162
163 // this low-level function should be called from a contract which performs important safety checks
164 function burn(address to) external lock returns (uint amount0, uint amount1) {
165 (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
166 address _token0 = token0; // gas savings
167 address _token1 = token1; // gas savings
168 uint balance0 = IERC20StellaSwap(_token0).balanceOf(address(this));
169 uint balance1 = IERC20StellaSwap(_token1).balanceOf(address(this));
170 uint liquidity = balanceOf[address(this)];
171
172 bool feeOn = _mintFee(_reserve0, _reserve1);
173 uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
174 amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
175 amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
176 require(amount0 > 0 && amount1 > 0, 'StellaSwapV2: INSUFFICIENT_LIQUIDITY_BURNED');
177 _burn(address(this), liquidity);
178 _safeTransfer(_token0, to, amount0);
179 _safeTransfer(_token1, to, amount1);
180 balance0 = IERC20StellaSwap(_token0).balanceOf(address(this));
181 balance1 = IERC20StellaSwap(_token1).balanceOf(address(this));
182
183 _update(balance0, balance1, _reserve0, _reserve1);
184 if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
185 emit Burn(msg.sender, amount0, amount1, to);
186 }
187
188 // this low-level function should be called from a contract which performs important safety checks
189 function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
190 require(amount0Out > 0 || amount1Out > 0, 'StellaSwapV2: INSUFFICIENT_OUTPUT_AMOUNT');
191 (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings