Wemix Retainer 111 Wonder Staking

CertiKFiles named in the report

Audit

Part of CertiK’s retainer series

CertiK reviewed WEMIX (Wemix Retainer 111 Wonder Staking) on 15 Apr 2024: 21 findings, 0 critical; 12 marked fixed, 9 open.

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

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings21

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

SeverityOpenAcknowledgedFixed
Critical000
High200
Medium203
Low509
MediumDepositors cannot withdraw all their deposits dueFixed

In the function `withdrawRequest()`, there is no check to ensure that the input parameter `amount` or the caller's deposited amount is greater than 0. Therefore, a malicious user can call the function `withdrawRequest()` with `amount = 0` multiple times to reduce `totalDepositors` of the pool to 0. When a depositor attempts to withdraw all tokens from the pool, the `totalDepositors` will underflow and the function will revert. ```solidity=1096 if (user.amount == 0) { pool.totalDepositors--; } ```

MediumIncorrect user account addressFixed

The Staking contract calls the function `ncpDeposit()` to deposit tokens to the pool for `to` account address. The depositor is `to` address. Then the `to` address withdraw their tokens from the pool through the Staking contract using the function `ncpWithdraw()`. Before withdrawing tokens, the function `_updateMP()` is invoked to update reward variables of the given pool. However, The input parameter `account` of the function `_updateMP()` is set as the caller instead of the depositor. This incorrect user account leads to the user receiving fewer rewards.

MediumStakers will not be able to withdraw when the pooFixed

A pool can be removed without sanity validation in the function `removePool()`. Any withdrawal attempts after pool removal will revert. In this case, users will lose unclaimed stakings and rewards.

LowConstant token IdFixed

In the functions `emergencyTransfer()` and `emergencyChange()`, the `tokenId` is constant. This implies that these functions are specifically designed for particular token IDs. If the token ID changes, these functions become obsolete. ```solidity=158 uint256 tokenId = 1334; ``` ```solidity=162 tokenId = 1335; ``` ```solidity=170 uint256 tokenId = 1373; ```

LowFunction `setRewardFeeRatio()` can be invoked witFixed

If the owner of the rewarder wants to set the reward fee ratio, they must first call the function `setRewardFeeRatioRequest()` to create a request. After waiting for `feeRatioRequestDelay` blocks, they can call the function `setRewardFeeRatio()` to update the fee ratio of the pool and delete the request. However, the current inspection conditions are not stringent enough, allowing the owner to set the fee ratio to 0 for the specified pool, thereby bypassing critical checks. ```solidity=415 require( feeRatioRequests[pid].requestBlockNumber <= block.number, "STAKING: FeeRatio request is not ready." ); require( feeRatioRequests[pid].ratio >= 0 && feeRatioRequests[pid].ratio <= 10000, "fee Ratio is invalid" ); ```

LowMissing Zero Address ValidationFixed

Addresses are not validated before assignment or external calls, potentially allowing the use of zero addresses and leading to unexpected behavior or vulnerabilities. For example, transferring tokens to a zero address can result in a permanent loss of those tokens. ```solidity=131 registry = _registry; ``` - `_registry` is not zero-checked before being used. --- ```solidity=135 platformFeeCollector = _platformFeeCollector; ``` - `_platformFeeCollector` is not zero-checked before being used. --- ```solidity=45 govStaking = _govStaking; ``` - `_govStaking` is not zero-checked before being used. --- ```solidity=46 staking = _staking; ``` - `_staking` is not zero-checked before being used. --- ```solidity=49 ncp = _ncp; ``` - `_ncp` is not zero-checked before being used. --- ```solidity=68 to.transfer(rewardValue); ``` - `to` is not zero-checked before being used. --- ```solidity=69 feeCollector.transfer(rewardFee); ``` - `feeCollector` is not zero-checked before being used. --- ```solidity=70 platform.transfer(platformFee); ``` - `platform` is not zero-checked before being used. --- ```solidity=126 ncp = _ncp; ``` - `_ncp` is not zero-checked before being used.

LowParameter `to` is unusedFixed

In the function `withdraw()`, the parameter `to` is intended to receive tokens. However, the withdrawal amount is directly transferred to the `msg.sender` instead of using the `to` parameter. ```solidity=1215 payable(address((msg.sender))).sendValue(withdrawalRequestInfo.amount); ```

LowPotential Divide by ZeroFixed

Performing division by zero would raise an error and revert the transaction. ```solidity=901 uint256 reductionMP = (mpInfo.staked * amount) / user.amount; ``` The expression `(mpInfo.staked * amount) / user.amount` may divide by zero. Its divisor has has estimated interval [-115792089237316195423570985008687907853269984665640564039457584007913129639935, 231584178474632390847141970017375815706539969331281128078915168015826259279870]. --- ```solidity=1089 uint256 reductionMP = (mpInfo.staked * amount) / user.amount; ``` The expression `(mpInfo.staked * amount) / user.amount` may divide by zero. Its divisor has has estimated interval [-115792089237316195423570985008687907853269984665640564039457584007913129639935, 231584178474632390847141970017375815706539969331281128078915168015826259279870].

LowThe different addresses map to the same rewarderFixed

In the function `initialize()`, the `ncp` address is mapped to the `rewarderCount` `1`. when the owner calls the function `addRewarder()`, the `rewarderCount` increases by 1, and the new `_rewarder` maps to the new `rewarderCount`. However, the function `setNCP()` directly updates the `rewarderCount` to the `ncp` address. This means that the `ncp` address and the last `_rewarder` have the same `rewarderCount` because the `rewarderCount` does not increase by 1. Additionally, the `rewarderCount` of old `ncp` is not updated to 0. ```solidity=125 function setNCP(address _ncp) external onlyOwner { ncp = _ncp; isRewarder[ncp] = rewarderCount; } ```

LowThe function `_updateMP()` is not invoked beforeFixed

The calculation of the `rewardDebt` relies on the `user.amount` and `mpInfo.staked`. However, the function `claim()` does not invoke the function `_updateMP()` to update the `mpInfo.staked` before updating the `rewardDebt`, resulting in the `rewardDebt` not being updated in time. ```solidity user.rewardDebt = ((user.amount + mpInfo.staked) * pool.accRewardPerShare) / ACC_REWARD_PRECISION; ```

Show 2 more
LowUsage of `transfer`/`send` for Sending Native TokFixed

It is not recommended to use Solidity's `transfer()` and `send()` functions for transferring native tokens, since some contracts may not be able to receive the funds. Those functions forward only a fixed amount of gas (2300 specifically) and the receiving contracts may run out of gas before finishing the transfer. Also, EVM instructions' gas costs may increase in the future. Thus, some contracts that can receive now may stop working in the future due to the gas limitation. ```solidity=68 to.transfer(rewardValue); ``` - `Rewarder.onReward` uses `transfer()`.

LowWithdraw requests that have not reached the claimFixed

The users call the function `withdrawRequest()` to request withdrawal from the given pool and the claimable time is updated to the current block number plus the unbound time. In the function `withdraw()`, if the `tokenId` is 0, it is updated to the first withdrawable token ID of the user. However, if the `tokenId` is not 0 and the withdrawal request is obtained from the function `getWithdrawalRequestInfo()`, there is no check to verify if the claimable time of the request is less than or equal to the current block number. Therefore, the withdraw requests that have not reached the claimable time can be withdrawn.

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 (3)

  • contracts/NCPStaking.sol
  • contracts/Rewarder.sol
  • contracts/withdrawalToken/WithdrawalNFT.sol

Part of WEMIX’s security record

WEMIX
Audits75 audits by 1 firmLast audit Feb 2025, by CertiK.
Critical findingsNo open critical findingsAcross the 75 reports, 17 critical findings were reported. Each is marked fixed by the firm that reported it.
Open WEMIX’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