Collar Stake

Smart Contract Audit Report

Audit Summary

Collar Stake Audit Report Collar Quest is building a new platform where users can stake tokens and earn rewards.

For this audit, we reviewed the project team's _CollarStake_ contract at 0x9611f925f2ec07dd553a088ec8dc1a8781bf71ce on the Goerli Testnet.

Audit Findings

All findings have been resolved.
Date: January 9th, 2023.
Updated: January 18th, 2023 to reflect the contract's latest Testnet address that resolves Findings #1 - #3.
Updated: February 2nd, 2023 to reflect the contract's latest Tesnet address.

Finding #1 - _CollarStake_ - High (Resolved)

Description: The owner can call the failSafe() function and withdraw any staked tokens from the contract.
function failSafe(address _tokenAddress, address _receiver,uint256 _tokenAmount) external onlyOwner {
    safeTransfer(IERC20(_tokenAddress), _receiver, _tokenAmount);
    emit FailSafe(_msgSender(), _receiver, _tokenAmount);
Risk/Impact: The team can withdraw any user's staked tokens at any time.
Recommendation: The failSafe() function should be modified to disallow the owner from being able to withdraw tokens that have been assigned as staking tokens.
Resolution: The team has removed the failSafe() function from the contract.

Finding #2 - _CollarStake_ - Medium (Resolved)

Description: The team can elect to add the reward token as one of the contract's staking tokens. In the event that this occurs, the contract does not contain logic to ensure that rewards are not funded by users' staked tokens.
Risk/Impact: If the team has not properly supplied reward tokens to the contract, rewards will be funded with other users' staked tokens which will prevent users from being able to withdraw their staked tokens.
Recommendation: The team should include logic to keep track of the number of tokens in the contract that were deposited as staked tokens and disallow these tokens from being used to fund rewards.
Resolution: The team has implemented the above recommendation.

Finding #3 - _CollarStake_ - Informational (Resolved)

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

Contract Overview

  • Any user can use this contract to stake tokens approved by the project team in order to earn rewards.
  • The owner will specify 6 "LP" token addresses, 3 "Native" token addresses, and the reward token address upon deployment.
  • Users can specify an amount of an approved LP token or Native token to stake into the contract.
  • Each stake is assigned a stake ID and the reward end time for each stake is set for 5 years in the future.
  • The total number of reward tokens due to all users for the full 5-year stake duration cannot exceed the maximum reward values for both LP token and Native token stakes.
  • Users can specify a stake ID to claim rewards for at any time. The number of reward tokens sent to the user is calculated based on the user's total number of staked tokens, the time difference between now and the user's last claim, and the fixed rewards percentage of the contract.
  • Users can specify a stake ID to withdraw for at any time. The user's original stake amount and any pending rewards are sent to their wallet address.
  • The team must ensure that a sufficient number of reward tokens are in the contract to support claims.
  • The team must exercise caution when assigning the staking tokens to avoid using fee-on-transfer tokens. If a fee-on-transfer token is assigned, the team must ensure that the proper addresses are excluded from fees.
  • The team must ensure that all staking tokens have 18 decimals as the contract uses a fixed reward rate based on the user's staked amount when calculating rewards.
  • The owner can pause/unpause the contract at any time which disables all staking, claiming, and withdrawing.
  • The owner can replace a current LP or Native token on the approved token list with a new token at any time.
  • The owner can update the Reward token at any time.

Audit Results

Vulnerability Category Notes Result
Arbitrary Jump/Storage Write N/A PASS
Centralization of Control N/A PASS
Compiler Issues N/A PASS
Delegate Call to Untrusted Contract N/A PASS
Dependence on Predictable Variables N/A PASS
Ether/Token Theft N/A PASS
Flash Loans N/A PASS
Front Running N/A PASS
Improper Events N/A PASS
Improper Authorization Scheme N/A PASS
Integer Over/Underflow N/A PASS
Logical Issues N/A PASS
Oracle Issues N/A PASS
Outdated Compiler Version N/A PASS
Race Conditions N/A PASS
Reentrancy N/A PASS
Signature Issues N/A PASS
Sybil Attack N/A PASS
Unbounded Loops N/A PASS
Unused Code N/A PASS
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

 + [Int] IERC20 
    - [Ext] totalSupply
    - [Ext] decimals
    - [Ext] symbol
    - [Ext] name
    - [Ext] getOwner
    - [Ext] balanceOf
    - [Ext] transfer #
    - [Ext] allowance
    - [Ext] approve #
    - [Ext] transferFrom #

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

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

 +  ReentrancyGuard 
    - [Pub]  #

 +  Pausable (Context)
    - [Pub]  #
    - [Pub] paused
    - [Int] _pause #
       - modifiers: whenNotPaused
    - [Int] _unpause #
       - modifiers: whenPaused

 + [Lib] Address 
    - [Int] isContract
    - [Int] functionCall #
    - [Int] functionCall #
    - [Int] functionCallWithValue #
    - [Int] functionCallWithValue #
    - [Prv] _functionCallWithValue #
    - [Int] verifyCallResult

 +  SafeERC20 
    - [Int] safeTransfer #
    - [Int] safeTransferFrom #
    - [Prv] _callOptionalReturn #

 +  _CollarStake_ (Ownable, ReentrancyGuard, Pausable, SafeERC20)
    - [Pub]  #
    - [Pub] isContract
    - [Ext] pause #
       - modifiers: onlyOwner
    - [Ext] unPause #
       - modifiers: onlyOwner
    - [Ext] depositTokens #
       - modifiers: whenNotPaused,nonReentrant
    - [Pub] checkTokenLimit
    - [Pub] pendingReward
    - [Prv] calculateReward
    - [Pub] claimReward #
       - modifiers: whenNotPaused
    - [Ext] withdraw #
       - modifiers: whenNotPaused,nonReentrant
    - [Ext] updateToken #
       - modifiers: onlyOwner

About SourceHat

SourceHat (formerly Solidity Finance - founded in 2020) has quickly grown to have one of the most experienced and well-equipped smart contract auditing teams in the industry. Our team has conducted 1700+ 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!
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.