Metacade - Audit 2

CertiKFiles named in the report

CertiK reviewed Metacade (Metacade - Audit 2) on 15 Feb 2023: 20 findings, 0 critical; none marked fixed.

No open critical findings
Open the reportOpen Metacade’s security record

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings20

Statuses are the security firm’s own, from its report.

SeverityOpenAcknowledgedFixed
Critical000
High100
Medium000
Low1900
HighCentralization Risks in MetacadePresaleV2Open

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]. ![](https://accelerator-tasks-prod.acc.corp.certik.com/187834691c914e3ba4073fd58cdf8634/diagrams/centralization_MetacadePresale.v2-MetacadePresaleV2-owner.svg)

LowChainlink's `latestRoundData()` might return stalOpen

`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. ```

LowCheck Effect Interaction Pattern ViolatedOpen

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; ```

LowDeclaration Naming ConventionOpen

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`.

LowIncorrect CommentOpen

The highlighted comment says "...current step `amount`..." when "...current step `index`..." would better represent the `stepIndex` value.

LowIncorrect Current Step CalculationOpen

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; ```

LowIncorrect Error MessageOpen

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.

LowMissing ChecksOpen

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`.

LowMissing Emit EventsOpen

There should always be events emitted in the sensitive functions that are controlled by centralization roles.

LowMissing Zero Address ValidationOpen

Addresses should be checked before assignment or external call to make sure they are not zero addresses.

Show 10 more
LowShouldn't `configureClaim()` check `_claimStart >Open

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`?

LowShouldn't `userDeposits()` check if `_user` hasClOpen

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.

LowThird Party DependencyOpen

- 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 { ```

LowTypos In The ContractOpen

The word rescue is misspelled along the contract.

LowUnlocked Compiler VersionOpen

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.

LowUnnecessary and Missing ChecksOpen

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`.

LowUnsafe Integer CastOpen

The type conversion `uint256(price * 1e10)` from type int256 to type uint256 may flip the value's sign: ```solidity=290 return uint256(price * 1e10); ```

LowUnused EventOpen

`ClaimStartUpdated` is declared in `IMetacadePresaleV2` but never emitted. ```solidity=20 event ClaimStartUpdated( uint256 prevValue, uint256 newValue, uint256 timestamp ); ```

LowVariable Can Be Declared as ImmutableOpen

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.

LowVisibility Specifiers MissingOpen

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.

Contracts in scope

No deployed address is recorded for this audit.

The report names a repository or files. Open the report to see its scope.

Repository and files the report names (2)

  • contracts/v2/MetacadePresale.v2.sol
  • contracts/interfaces/v2/IMetacadePresale.v2.sol

Part of Metacade’s security record

Metacade
Audits2 audits by 1 firmLast audit Feb 2023, by CertiK.
Critical findingsNo open critical findingsAcross 2 reports.
Open Metacade’s security record

Security firm

CertiK

1,045 projects reviewed · 1,376 reports · latest May 2025

See CertiK’s audits

Something 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