CertiK reviewed Metacade (Metacade - Audit 2) on 15 Feb 2023: 20 findings, 0 critical; none marked fixed.
Report hosted on skynet.certik.com.
Trustblock does not review code.
Statuses are the security firm’s own, from its report.
| Severity | Open | Acknowledged | Fixed |
|---|---|---|---|
| Critical | 0 | 0 | 0 |
| High | 1 | 0 | 0 |
| Medium | 0 | 0 | 0 |
| Low | 19 | 0 | 0 |
In the contract `MetacadePresaleV2` the role `owner` has authority over the functions shown in the diagram below. Any compromise to the `owner` account may allow the hacker to take advantage of this authority and [fixme, describe what hacker can do and the impact]. 
`getLatestPrice()` makes use of the Chainlink's `latestRoundData()` function which does not check whether the return value contains outdated data. This could lead to stale prices according to the Chainlink documentation: https://docs.chain.link/data-feeds/price-feeds/historical-data ```solidity * @dev A timestamp with zero value means the round is not complete and should not be used. ```
The order of external call/transfer and storage manipulation must follow the check-effect-interaction pattern. A reentrancy attack can occur when the contract creates a function that makes an external call to another untrusted contract before resolving any effects. If the attacker can control the untrusted contract, they can make a recursive call back to the original function, repeating interactions that would have otherwise not run after the external call resolved the effects. ### External call(s) ```solidity=227 _sendValue(payable(owner()), ethAmount); ``` * This function call executes the following external call(s). * In `MetacadePresaleV2._sendValue`, * `(success) = _recipient.call{value: _weiAmount}()` ```solidity=229 if (excess > 0) _sendValue(payable(_msgSender()), excess); ``` ### State variables written after the call(s) ```solidity=233 if (stepAfterPurchase>currentStep) currentStep = stepAfterPurchase; ``` ```solidity=230 totalTokensSold += _amount; _userDeposits[_msgSender()] += _amount * 1e18; ```
One or more declarations do not conform to the [Solidity style guide](https://solidity.readthedocs.io/en/v0.7.3/style-guide.html#naming-conventions) with regards to its naming convention. Particularly: - `camelCase`: Should be applied to function names, argument names, local and state variable names, modifiers - `UPPER_CASE`: Should be applied to `constant` variables - `CapWords`: Should be applied to contract names, struct names, event names and enums ```solidity=26 uint256[9] public token_amount; ``` - Variable `token_amount` is not in `camelCase`. --- ```solidity=27 uint256[9] public token_price; ``` - Variable `token_price` is not in `camelCase`. --- ```solidity=28 uint8 constant maxStepIndex = 8; ``` - Constant variable `maxStepIndex` is not in `UPPER_CASE`. --- ```solidity=31 IERC20 public USDTInterface; ``` - Variable `USDTInterface` is not in `camelCase`.
The highlighted comment says "...current step `amount`..." when "...current step `index`..." would better represent the `stepIndex` value.
It is believed that the snippet below should include the case where `token_amount[stepIndex - 1] == totalTokensSold`: ```solidity=359 if (token_amount[stepIndex - 1] < totalTokensSold) break; ```
The first highlighted `require` statement will throw an error because the user is trying to buy more tokens than the maximum, not because the funds are not enough. The second highlighted `require` statement will throw an error because the user is trying to calculate the price using an excessive amount, not because the amount is insufficient.
The following checks are missing: - The length of `_token_amount` should be the same as the length of `_token_price`. - `_endTime` should be greater than `_endTime`.
There should always be events emitted in the sensitive functions that are controlled by centralization roles.
Addresses should be checked before assignment or external call to make sure they are not zero addresses.
Shouldn't `configureClaim()` check if `_claimStart > block.timestamp` and other `startTime` and `endTime` possibilities? Is it possible to set `claimStart` with a lower value than `startTime`? Is it possible to set `claimStart` with a lower value than `endTime`?
Shouldn't `userDeposits()` check if `_user` has claimed the tokens in `previousPresale` and `betaPresale` contracts to avoid claiming more tokens than the ones bought? Right now this attack scenario does not seem feasible, but the highlighted code could eventually allow it.
- The contract `MetacadePresaleV2` interacts with third party contract with `IERC20` interface via `USDTInterface`. ```solidity=31 IERC20 public USDTInterface; ``` --- - The contract `MetacadePresaleV2` interacts with third party contract with `IAggregator` interface via `aggregatorInterface`. ```solidity=32 IAggregator public aggregatorInterface; ``` --- - The function `MetacadePresaleV2.resqueERC20` interacts with third party contract with `IERC20` interface via `_tokenAddress`. ```solidity=206 function resqueERC20(address _tokenAddress, uint256 _amount) external onlyOwner { ```
The word rescue is misspelled along the contract.
The contracts cited have an unlocked compiler version. An unlocked compiler version in the source code of the contract permits the user to compile it at or above a particular version. This, in turn, leads to differences in the generated bytecode between compilations due to differing compiler version numbers. This can lead to ambiguity when debugging, as compiler specific bugs may occur in the codebase that would be hard to identify over a span of multiple compiler versions rather than a specific one.
The highlighted conditional logic does not seem necessary; in all cases the sale times will be the ones passed as arguments and the event will emit such information. Furthermore, the `changeSaleTimes()` function is not checking whether `_endTime` is greater than `_startTime`.
The type conversion `uint256(price * 1e10)` from type int256 to type uint256 may flip the value's sign: ```solidity=290 return uint256(price * 1e10); ```
`ClaimStartUpdated` is declared in `IMetacadePresaleV2` but never emitted. ```solidity=20 event ClaimStartUpdated( uint256 prevValue, uint256 newValue, uint256 timestamp ); ```
The variables `USDTInterface` and `aggregatorInterface` assigned in the constructor can be declared as `Immutable` or even as constant. Immutable state variables can be assigned during contract creation, but will remain constant throughout the lifetime of a deployed contract. An advantage of immutable variables is that reading them is significantly cheaper than reading from regular state variables since they are not located in storage.
The linked variable declarations do not have a visibility specifier explicitly set. Inconsistencies in the default visibility the Solidity compilers impose can cause issues in the functionality of the codebase.
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (2)
1,045 projects reviewed · 1,376 reports · latest May 2025
See CertiK’s auditsSomething wrong on this page? A missing report, a wrong date, a finding that was fixed since. Tell us and we check it against its source.
Tell us