WePad Staking

Smart Contract Audit Report

Audit Summary

WePad Staking Audit Report WePad is a new IDO launchpad which is part of the WeWay Ecosystem and is building a staking contract in which users can stake tokens and earn rewards. WePad aims to be positioned as one of the most transparent and community driven IDO launchpads in the space.

For this audit, we reviewed the project team's StakingPool contract at commit bf8202b087d2b88c0e1c0c42fef07aa38d9eeb3c on the team's GitHub repository.

Audit Findings

The team has resolved all findings. Some centralized aspects are present.
Date: June 28th, 2022.
Updated: June 29th, 2022 to resolve findings, reduce centralized control, and reflect changes from commit 83a05c1844c564f74e1fccb3987571a467f92d01 to commit bf8202b087d2b88c0e1c0c42fef07aa38d9eeb3c.

Finding #1 - StakingPool - Medium (Resolved)

Description: The staking token and reward token are intended to be the same, but the contract does not keep track of the amount of tokens in the contract that are allocated for rewards.
Risk/Impact: Users' staked funds may be used to fund other user's rewards.
Recommendation: The team primarily include code to ensure that users' staked funds will not be used to fund rewards and should also ensure that enough tokens are provided to support the reward system.
Resolution: The team has included code to ensure that users' staked funds will not be used to fund rewards. If there are not enough reward tokens in the contract, the user will not receive their due rewards.

Finding #2 - StakingPool - Informational (Resolved)

Description: The withdrawStakingTime state variable cannot be modified, but is not declared constant.
Recommendation: This state variable can be declared constant for additional gas savings on each reference.
Resolution: The team has implemented the above recommendation.

Finding #3 - StakingPool - Informational (Resolved)

Description: Although the SafeMath library is utilized, the contract is deployed with Solidity v0.8.7 which has built-in overflow checks.
Recommendation: SafeMath could safely be removed to reduce contract size, deployment costs, and gas costs on all transactions that utilize it.
Resolution: The team has implemented the above recommendation.

Contract Overview

  • This contract is used to facilitate a single asset staking pool in which users deposit a team-designated staking token and accrue rewards in the form of a reward token; the same token is intended to be used for staking and for rewards.
  • The team can enable a deposit limit which will prevent users from staking more than a team-defined amount of tokens in the contract.
  • The user will receive a staking reward based on the reward rate determined by the team and proportional to the amount of tokens the user has staked relative to the total amount of tokens staked in the pool.
  • The user will not receive any rewards if the team has not provided the contract with enough tokens to fund rewards.
  • Staked funds and rewards are locked in the contract until 1 week after the user's most recent deposit time has passed.
  • Once the lock time has elapsed, staking rewards are calculated and harvested on deposits and withdrawals.
  • Users can reinvest their staking rewards into the pool at any time.
  • Staking rewards will not accrue after the end time has passed, unless the team decides to extend the end time.
  • The owner can extend the reward end time at any time.
  • The owner can increase or disable the deposit limit; once disabled it cannot be enabled again.
  • The owner can set the reward rate to any value above the minimim at any time.
  • The team must exercise caution when assigning the staking token to avoid using a fee-on-transfer token; if a fee-on-transfer token is used as the staking token, the contract must be exempt from the token's fee mechanism.
  • The team must adequately supply tokens to the contract to be used as rewards; otherwise, users' rewards may be funded with other users' staked tokens.
  • The contract utilizes ReentrancyGuard to protect against reentrancy exploits in the deposit and withdraw functions.
  • As the contract is implemented with solidity v0.8.7, it is safe from underflows/overflows.

Audit Results

Vulnerability CategoryNotesResult
Arbitrary Jump/Storage WriteN/APASS
Centralization of ControlN/APASS
Compiler IssuesN/APASS
Delegate Call to Untrusted ContractN/APASS
Dependence on Predictable VariablesN/APASS
Ether/Token TheftN/APASS
Flash LoansN/APASS
Front RunningN/APASS
Improper EventsN/APASS
Improper Authorization SchemeN/APASS
Integer Over/UnderflowN/APASS
Logical IssuesN/APASS
Oracle IssuesN/APASS
Outdated Compiler VersionN/APASS
Race ConditionsN/APASS
ReentrancyN/APASS
Signature IssuesN/APASS
Unbounded LoopsN/APASS
Unused CodeN/APASS
Overall Contract Safety PASS

Inheritance Chart

Smart Contract Audit - Inheritance

Function Graph

Smart Contract Audit - Graph

Functions Overview


 ($) = payable function
 # = non-constant function
 
 Int = Internal
 Ext = External
 Pub = Public

 +  Context 
    - [Int] _msgSender
    - [Int] _msgData

 +  Ownable (Context)
    - [Pub]  #
    - [Pub] owner
    - [Pub] renounceOwnership #
       - modifiers: onlyOwner
    - [Pub] transferOwnership #
       - modifiers: onlyOwner
    - [Int] _transferOwnership #

 + [Int] IERC20 
    - [Ext] totalSupply
    - [Ext] balanceOf
    - [Ext] transfer #
    - [Ext] allowance
    - [Ext] approve #
    - [Ext] transferFrom #

 +  ReentrancyGuard 
    - [Pub]  #

 + [Lib] SafeMath 
    - [Int] tryAdd
    - [Int] trySub
    - [Int] tryMul
    - [Int] tryDiv
    - [Int] tryMod
    - [Int] add
    - [Int] sub
    - [Int] mul
    - [Int] div
    - [Int] mod
    - [Int] sub
    - [Int] div
    - [Int] mod

 + [Lib] Address 
    - [Int] isContract
    - [Int] sendValue #
    - [Int] functionCall #
    - [Int] functionCall #
    - [Int] functionCallWithValue #
    - [Int] functionCallWithValue #
    - [Int] functionStaticCall
    - [Int] functionStaticCall
    - [Int] functionDelegateCall #
    - [Int] functionDelegateCall #
    - [Int] verifyCallResult

 + [Lib] SafeERC20 
    - [Int] safeTransfer #
    - [Int] safeTransferFrom #
    - [Int] safeApprove #
    - [Int] safeIncreaseAllowance #
    - [Int] safeDecreaseAllowance #
    - [Prv] _callOptionalReturn #

 + [Lib] EnumerableSet 
    - [Prv] _add #
    - [Prv] _remove #
    - [Prv] _contains
    - [Prv] _length
    - [Prv] _at
    - [Prv] _values
    - [Int] add #
    - [Int] remove #
    - [Int] contains
    - [Int] length
    - [Int] at
    - [Int] values
    - [Int] add #
    - [Int] remove #
    - [Int] contains
    - [Int] length
    - [Int] at
    - [Int] values
    - [Int] add #
    - [Int] remove #
    - [Int] contains
    - [Int] length
    - [Int] at
    - [Int] values

 +  IBEP20 (IERC20)
    - [Pub] decimals #

 +  StakingPool (Ownable, ReentrancyGuard)
    - [Pub] countOfStakers
    - [Pub] stakerAt
    - [Pub] getUserStakingInfo
    - [Pub]  #
    - [Ext] deposit #
       - modifiers: nonReentrant
    - [Ext] withdraw #
       - modifiers: nonReentrant
    - [Pub] stakeRewards #
    - [Ext] emergencyRewardWithdraw #
       - modifiers: onlyOwner
    - [Ext] recoverWrongTokens #
       - modifiers: onlyOwner
    - [Ext] stopReward #
       - modifiers: onlyOwner
    - [Ext] updatePoolLimitPerUser #
       - modifiers: onlyOwner
    - [Pub] shouldDepositAdmin
    - [Pub] shouldDepositAdminToExtendStaking
    - [Pub] extendStaking #
       - modifiers: onlyOwner
    - [Ext] updaterewardPerSecond #
       - modifiers: onlyOwner
    - [Ext] updateStartAndEndBlocks #
       - modifiers: onlyOwner
    - [Ext] pendingReward
    - [Int] _updatePool #
    - [Int] _getMultiplier

About SourceHat

SourceHat has quickly grown to have one of the most experienced and well-equipped smart contract auditing teams in the industry. Our team has conducted 1300+ solidity smart contract audits covering all major project types and protocols, securing a total of over $50 billion U.S. dollars in on-chain value across 1500 projects!.
Our firm is well-reputed in the community and is trusted as a top smart contract auditing company for the review of solidity code, no matter how complex. Our team of experienced solidity smart contract auditors performs audits for tokens, NFTs, crowdsales, marketplaces, gambling games, financial protocols, and more!

Contact us today to get a free quote for a smart contract audit of your project!

What is a SourceHat Audit?

Typically, a smart contract audit is a comprehensive review process designed to discover logical errors, security vulnerabilities, and optimization opportunities within code. A SourceHat Audit takes this a step further by verifying economic logic to ensure the stability of smart contracts and highlighting privileged functionality to create a report that is easy to understand for developers and community members alike.

How Do I Interpret the Findings?

Each of our Findings will be labeled with a Severity level. We always recommend the team resolve High, Medium, and Low severity findings prior to deploying the code to the mainnet. Here is a breakdown on what each Severity level means for the project:

  • High severity indicates that the issue puts a large number of users' funds at risk and has a high probability of exploitation, or the smart contract contains serious logical issues which can prevent the code from operating as intended.
  • Medium severity issues are those which place at least some users' funds at risk and has a medium to high probability of exploitation.
  • Low severity issues have a relatively minor risk association; these issues have a low probability of occurring or may have a minimal impact.
  • Informational issues pose no immediate risk, but inform the project team of opportunities for gas optimizations and following smart contract security best practices.