CertiK reviewed TOP PROTOCOL (TOP PROTOCOL - Audit) on 1 Nov 2024: 32 findings, 0 critical; 19 marked fixed, 6 acknowledged, 7 open.
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 | 0 | 2 | 2 |
| Medium | 0 | 4 | 3 |
| Low | 7 | 0 | 14 |
In the `_tokenTransfer` function of the `Top` contract, there is a conditional block that handles the calculation of profits when tokens are sold. Specifically, this block updates the `buyValue` for the `sender` when a sale occurs. This conditional block only executes if `_sell_profit_fee` is greater than zero: ```solidity if (_swapPairList[recipient] && !isAdd && !isRemove && !_feeWhiteList[sender]){ if(_sell_profit_fee>0){ uint256 v = getTokenValue(tAmount); if (v >= _burnInfo[sender].buyValue) { uint256 profitFees; uint256 tokenAmount = getUSDTValue(_burnInfo[sender].buyValue); profitFees += ((tAmount - tokenAmount) * _sell_profit_fee) / 10000; feeAmount += profitFees; _ts.deadAmount += profitFees*5/10; _ts.redeemAmount += profitFees*5/10; v = _burnInfo[sender].buyValue; _takeTransfer(sender,address(this),profitFees); } _burnInfo[sender].buyValue -=v; } } ``` The issue with this implementation is that if `_sell_profit_fee` is set to zero under some conditions, the logic to update the `buyValue` and `buyAmount` for a user (`sender`) upon selling does not execute. This results in a scenario where a user's `buyValue` and `buyAmount` remain unchanged even after they have sold their tokens. This could potentially misrepresent the actual economic activity of the user, as the historical purchase values (`buyValue`) that contribute to profit calculations during sales are not decreased upon the sale of tokens.
In the `_transfer` function of the `Top` contract, there is a specific condition where `lpAmount` for the sender (`from`) is incremented only if the sender of the transaction is the same as the transaction originator (`tx.origin`). This is particularly checked when tokens are being transferred to the pair (`_mainPair`), which usually signifies a liquidity provision operation. ```solidity=611 if (to == _mainPair && tx.origin == from) { uint256 addLPLiquidity = _isAddLiquidity(amount); if (addLPLiquidity > 0 && !isContract(from)) { isAdd = true; } lpAmountAll += amount; lpAmount[from] += amount; ``` However, this approach does not account for scenarios where `transferFrom` is used to add liquidity. In such cases, `tx.origin` would not match `from` if the liquidity is added through a different address initiates the transfer on behalf of the original holder. Consequently, `lpAmount[from]` would not be updated even though liquidity is being added, leading to potential discrepancies in tracking liquidity provisions. We would like to confirm with the team whether this implementation detail is intentional or if adjustments are required to ensure that `lpAmount` correctly reflects all liquidity additions, regardless of whether they are conducted directly by the token holder or through an intermediary address.
The implementation of the function `isContract()` check can not cover all scenarios. The check can be bypassed if the call is from the constructor of a smart contract or when the contract is destroyed. Because, in that case, the codesize will also be zero. The "isContract" function in the OpenZeppelin "Address" library uses the same implementation, but comments mention that "it's unsafe to rely on the check and it can be bypassed". Reference: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol
There should always be events emitted in the sensitive functions that are controlled by centralization roles.
The **require** can be used to check for conditions and throw an exception if the condition is not met. It is better to provide a string message containing details about the error that will be passed back to the caller.
In the `swapTokenForFund` function, the `if (_ts.rewardAmount >= 0) ` condition check is redundant as the `rewardAmount` is uint256 which is always zero or greater than zero. ```solidity=877 @> if (_ts.rewardAmount >= 0) { if(rewardPath.length != 1){ try _swapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens( _rewardAmount, 0, rewardPath, address(this), block.timestamp ) ```
The linked variables assigned in the constructor can be declared as `immutable`. Immutable state variables can be assigned during contract creation but will remain constant throughout the lifetime of a deployed contract. A big advantage of immutable variables is that reading them is significantly cheaper than reading from regular state variables since they will not be stored in storage.
| Address | Chain | Source code |
|---|---|---|
| 0xe855…d68e0xe85562c6ff86a8ff0268222aff0205a26d37d68e | Chain: BNB Chain | Source code: Verified source |
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