DeepFreeze

Smart Contract Audit Report

Audit Summary

DeepFreeze Audit Report DeepFreeze is creating two new ERC-20 tokens, an NFT, and multiple staking contracts.

For this audit, we reviewed the following contracts:

Audit Findings

All findings have been resolved.
Date: April 5th, 2022.
Updated: April 18th, 2022 to reflect changes from commit 998a65da708d8bbcf13aa5dded2e73a7139a5d78 to commit d92f3fc82b3dda4126eeeba51ac51b5baab94e32.
Updated: June 14th, 2022 to validate the deployment of the frToken and NonFungiblePositionManager contracts at 0xb4bd4628e6efb0cb521d9ec35050c75840320374 and 0x6c4e530a6f5cec117bbd1ed2937584a71c75ca22 on the Ethereum Mainnet.

Finding #1 - TrueFreezeGovernor - High (Resolved)

Description: In the withdrawWAsset() function, the contract grants approval of the user's deposited asset token amount to the user before transferring to them.
	wAsset.approve(msg.sender, amountLocked);
	wAsset.transfer(msg.sender, amountLocked);
	emit withdrawedWAsset(msg.sender, _tokenId, amountLocked, 0, 0);
} else if (progress < 100) {
	// if progress < 100 user need to pay a wAsset fee
	uint256 sendToUser = amountLocked - feesToPay;
	wAsset.approve(msg.sender, sendToUser);
	wAsset.transfer(msg.sender, sendToUser);
Risk/Impact: After being transferred the asset token, the user will be able to withdraw the same amount from the contract again, as they have been given approval. This amount would come from other user's deposited amounts, potentially preventing other users from withdrawing their asset tokens. Recommendation: The approval calls in the withdrawWAsset() function should be removed.
Resolution: The team has removed the approval calls.

Finding #2 - TrueFreezeGovernor - Informational (Resolved)

Description: The division used in the _calculateBurnAndSend() may result in minor inaccuracies when calculating frToken amounts to burn and transfer.
uint256 toSend = (_penaltyPaid - _tokenMinted) / 2;
uint256 toBurn = _tokenMinted + (_penaltyPaid - _tokenMinted) / 2;
Risk/Impact: In Solidity, division can lead to integer truncation, which could result in small amounts of frTokens becoming trapped in the contract.
Recommendation: The team can implement the following change to account for any truncation:
uint256 toSend = (_penaltyPaid - _tokenMinted) / 2;
uint256 toBurn = _tokenMinted + (_penaltyPaid - tokenMinted) - toSend;
Resolution: The team has implemented the above recommendation.

Contracts Overview

  • As the contracts are implemented with Solidity v0.8.x or SafeMath, they are safe from any possible overflows/underflows.
  • ReentrancyGuard is utilized in applicable contracts, protecting them from any potential reentrancy attacks.
FRZtoken Contract:
  • Upon deployment, 100 million tokens are minted to a specified "Merkle Tree Airdrop" address.
  • The mint() function can then be called once per year by any user, which will mint a percentage of existing total supply to a specified staking contract to be used for rewards.
  • The first mint will mint 10% of the total supply, followed by 9%, then 8%, 7%, etc. until the floor of 2% is reached, where it will no longer decrease.
  • This contract complies with the ERC-20 token standard.
frToken Contract:
  • This contract complies with the ERC-20 token standard.
  • Upon deployment, the Governor Role is granted to the owner.
  • The owner can then update the Governor Role a single time.
  • The Governor Role can mint any amount of tokens to any address at any time.
  • The Governor Role can also burn any amount of tokens from any address at any time.
  • Users are permitted to burn their tokens at any time to reduce total supply.
  • The Governor Role is set to the TrueFreezeGovernor contract and cannot be updated.
MultiRewards & StakingRewards Contracts:
  • These contracts allow users to deposit a specified staking token in return for rewards in potentially multiple various reward tokens.
  • The StakingRewards contract contains the same functionality as the MultiRewards contract; however, users cannot withdraw any of their staked tokens once they have been deposited.
  • Users must claim their rewards separately; they are not claimed during a deposit or withdrawal.
  • Users may elect to exit the MultiRewards contract, withdrawing their total balance and claiming all rewards.
  • Rewards must be supplied from an external rewards distributor for each reward token.
  • The reward distributor for a reward token can update its duration once its reward period has expired.
  • The team should exercise caution if using a fee-on-transfer token as the staking token or reward token and ensure that the proper exemptions are made.
  • The owner may add a reward token with a specified rewards duration and rewards distributor at any time.
  • The owner may update the reward distributor associated with a token at any time.
  • The owner is able to withdraw any non-staking and non-rewards token from the contracts at any time.
NonFungiblePositionManager Contract:
  • This contract complies with the ERC-721 standard and grants additional permissions to a Governor Role.
  • TrueFreeze NFTs are used to track users' positions within the TrueFreezeGovernor contract.
  • Upon deployment, the Governor Role is granted to the owner.
  • The owner can then update the Governor Role a single time.
  • The Governor can mint an NFT with any ID to any address at any time.
  • The Governor can also burn any user's NFTs at any time.
  • The Governor Role is set to the TrueFreezeGovernor contract and cannot be updated.
TrueFreezeGovernor Contract:
  • This contract allows users to lock a specified asset token in the contract for a specified number of days in exchange for frTokens.
  • The lock duration specified must be between 7 and 1,100 days, inclusive.
  • Upon locking, the user will be minted an amount of frTokens based on the amount locked and the lock duration.
  • They will also be minted a TrueFreeze NFT with an ID corresponding to their position information.
  • Once the lock duration has passed, users can withdraw their locked amount without paying any fees.
  • Users also have the option to withdraw early by paying fees.
  • If over 67% and less than 100% of the lock duration has passed, users will have .25% of their locked tokens taken as a fee, which is then sent to a specified staking contract for rewards.
  • They also must transfer back a portion of their minted frTokens as an additional fee, which are subsequently burned. This fee decreases based on the percentage of the lock duration that has passed.
  • If users attempt to withdraw when 67% or less of the lock duration has passed, users must pay back all of the frTokens minted to them for the position plus an additional fee based on the percentage of the lock duration that has passed.
  • The original amount of minted frTokens paid back plus half of the additional fee are burned. The remaining half is sent to the staking contract for rewards.
  • After withdrawing, the user's position will be marked as inactive and their corresponding TrueFreeze NFT will be burned.
  • The team should exercise caution if using a fee-on-transfer token as the asset token and ensure that the proper exemptions are made.

Audit Results

Vulnerability CategoryNotesResult
Arbitrary Jump/Storage WriteN/APASS
Centralization of Control
  • The owner has the permissions described above.
PASS
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

FRZToken Contract

Smart Contract Audit - Inheritance

Smart Contract Audit - Graph


 ($) = payable function
 # = non-constant function
 
 Int = Internal
 Ext = External
 Pub = Public
 
  + [Int] IERC20 
    - [Ext] totalSupply
    - [Ext] balanceOf
    - [Ext] transfer #
    - [Ext] allowance
    - [Ext] approve #
    - [Ext] transferFrom #

 + [Int] IERC20Metadata (IERC20)
    - [Ext] name
    - [Ext] symbol
    - [Ext] decimals

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

 +  ERC20 (Context, IERC20, IERC20Metadata)
    - [Pub]  #
    - [Pub] name
    - [Pub] symbol
    - [Pub] decimals
    - [Pub] totalSupply
    - [Pub] balanceOf
    - [Pub] transfer #
    - [Pub] allowance
    - [Pub] approve #
    - [Pub] transferFrom #
    - [Pub] increaseAllowance #
    - [Pub] decreaseAllowance #
    - [Int] _transfer #
    - [Int] _mint #
    - [Int] _burn #
    - [Int] _approve #
    - [Int] _spendAllowance #
    - [Int] _beforeTokenTransfer #
    - [Int] _afterTokenTransfer #

 +  FRZtoken (ERC20)
    - [Pub]  #
       - modifiers: ERC20


 

frToken Contract

Smart Contract Audit - Inheritance

Smart Contract Audit - Graph


 ($) = payable function
 # = non-constant function
 
 Int = Internal
 Ext = External
 Pub = Public
 
  + [Int] IERC20 
    - [Ext] totalSupply
    - [Ext] balanceOf
    - [Ext] transfer #
    - [Ext] allowance
    - [Ext] approve #
    - [Ext] transferFrom #

 + [Int] IERC20Metadata (IERC20)
    - [Ext] name
    - [Ext] symbol
    - [Ext] decimals

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

 +  ERC20 (Context, IERC20, IERC20Metadata)
    - [Pub]  #
    - [Pub] name
    - [Pub] symbol
    - [Pub] decimals
    - [Pub] totalSupply
    - [Pub] balanceOf
    - [Pub] transfer #
    - [Pub] allowance
    - [Pub] approve #
    - [Pub] transferFrom #
    - [Pub] increaseAllowance #
    - [Pub] decreaseAllowance #
    - [Int] _transfer #
    - [Int] _mint #
    - [Int] _burn #
    - [Int] _approve #
    - [Int] _spendAllowance #
    - [Int] _beforeTokenTransfer #
    - [Int] _afterTokenTransfer #

 +  ERC20Burnable (Context, ERC20)
    - [Pub] burn #
    - [Pub] burnFrom #

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

 +  frToken (ERC20, ERC20Burnable, Ownable)
    - [Pub]  #
       - modifiers: ERC20
    - [Ext] setOnlyGovernor #
       - modifiers: onlyOwner
    - [Ext] mint #
       - modifiers: onlyGovernor
    - [Ext] burn #
       - modifiers: onlyGovernor



MultiRewards & StakingRewards Contracts

Smart Contract Audit - Inheritance

Smart Contract Audit - Graph


 ($) = payable function
 # = non-constant function
 
 Int = Internal
 Ext = External
 Pub = Public
 
  + [Lib] Address 
    - [Int] isContract

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

 + [Lib] Math 
    - [Int] max
    - [Int] min
    - [Int] average

 +  Owned 
    - [Pub]  #
    - [Ext] nominateNewOwner #
       - modifiers: onlyOwner
    - [Ext] acceptOwnership #
    - [Prv] _onlyOwner

 +  Pausable (Owned)
    - [Int]  #
    - [Ext] setPaused #
       - modifiers: onlyOwner

 +  ReentrancyGuard 
    - [Int]  #

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

 + [Lib] SafeMath 
    - [Int] add
    - [Int] sub
    - [Int] mul
    - [Int] div
    - [Int] mod

 +  MultiRewards (ReentrancyGuard, Pausable)
    - [Pub]  #
       - modifiers: Owned
    - [Pub] addReward #
       - modifiers: onlyOwner
    - [Ext] totalSupply
    - [Ext] balanceOf
    - [Pub] lastTimeRewardApplicable
    - [Pub] rewardPerToken
    - [Pub] earned
    - [Ext] getRewardForDuration
    - [Ext] setRewardsDistributor #
       - modifiers: onlyOwner
    - [Ext] stake #
       - modifiers: nonReentrant,notPaused,updateReward
    - [Pub] withdraw #
       - modifiers: nonReentrant,updateReward
    - [Pub] getReward #
       - modifiers: nonReentrant,updateReward
    - [Ext] exit #
    - [Ext] notifyRewardAmount #
       - modifiers: updateReward
    - [Ext] recoverERC20 #
       - modifiers: onlyOwner
    - [Ext] setRewardsDuration #




NonFungiblePositionManager Contract

Smart Contract Audit - Inheritance

Smart Contract Audit - Graph


 ($) = payable function
 # = non-constant function
 
 Int = Internal
 Ext = External
 Pub = Public
 
  + [Int] IERC165 
    - [Ext] supportsInterface

 + [Int] IERC721 (IERC165)
    - [Ext] balanceOf
    - [Ext] ownerOf
    - [Ext] safeTransferFrom #
    - [Ext] transferFrom #
    - [Ext] approve #
    - [Ext] getApproved
    - [Ext] setApprovalForAll #
    - [Ext] isApprovedForAll
    - [Ext] safeTransferFrom #

 + [Int] IERC721Receiver 
    - [Ext] onERC721Received #

 + [Int] IERC721Metadata (IERC721)
    - [Ext] name
    - [Ext] symbol
    - [Ext] tokenURI

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

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

 + [Lib] Strings 
    - [Int] toString
    - [Int] toHexString
    - [Int] toHexString

 +  ERC165 (IERC165)
    - [Pub] supportsInterface

 +  ERC721 (Context, ERC165, IERC721, IERC721Metadata)
    - [Pub]  #
    - [Pub] supportsInterface
    - [Pub] balanceOf
    - [Pub] ownerOf
    - [Pub] name
    - [Pub] symbol
    - [Pub] tokenURI
    - [Int] _baseURI
    - [Pub] approve #
    - [Pub] getApproved
    - [Pub] setApprovalForAll #
    - [Pub] isApprovedForAll
    - [Pub] transferFrom #
    - [Pub] safeTransferFrom #
    - [Pub] safeTransferFrom #
    - [Int] _safeTransfer #
    - [Int] _exists
    - [Int] _isApprovedOrOwner
    - [Int] _safeMint #
    - [Int] _safeMint #
    - [Int] _mint #
    - [Int] _burn #
    - [Int] _transfer #
    - [Int] _approve #
    - [Int] _setApprovalForAll #
    - [Prv] _checkOnERC721Received #
    - [Int] _beforeTokenTransfer #
    - [Int] _afterTokenTransfer #

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

 + [Lib] Base64 
    - [Int] encode
    - [Int] decode

 + [Lib] Utils 
    - [Int] getIntAndDigit
    - [Prv] _daysToDate
    - [Int] timestampToDate
    - [Int] uint2str

 + [Lib] NFTDescriptor 
    - [Int] _constructTokenURI
    - [Int] _constructParamsTokenURI
    - [Int] generateSVG
    - [Int] generateStyle
    - [Int] generateLinearGradient
    - [Int] generateAmountLocked
    - [Int] generateMiddle
    - [Int] generateMaturity
    - [Int] generateLocking
    - [Int] generateBottom

 + [Int] ITrueFreezeGovernor 
    - [Ext] getPositions
    - [Ext] getTokenSymbol

 +  NonFungiblePositionManager (ERC721, Ownable)
    - [Pub]  #
       - modifiers: ERC721
    - [Ext] setOnlyGovernor #
       - modifiers: onlyOwner
    - [Ext] mint #
       - modifiers: onlyGovernor
    - [Ext] burn #
       - modifiers: onlyGovernor
    - [Pub] tokenURI




TrueFreezeGovernor Contract

Smart Contract Audit - Inheritance

Smart Contract Audit - Graph


 ($) = 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]  #

 + [Int] IfrToken (IERC20)
    - [Ext] mint #
    - [Ext] burn #

 + [Int] IwAsset (IERC20)

 + [Int] IMultiRewards 
    - [Ext] notifyRewardAmount #

 + [Int] INonFungiblePositionManager 
    - [Ext] mint #
    - [Ext] burn #
    - [Ext] ownerOf

 +  TrueFreezeGovernor (Ownable, ReentrancyGuard)
    - [Pub]  #
    - [Ext] lockWAsset #
       - modifiers: nonReentrant
    - [Ext] withdrawWAsset #
       - modifiers: nonReentrant
    - [Prv] _createPosition #
    - [Prv] _mintToken #
    - [Pub] getPositions
    - [Pub] getProgress
    - [Pub] getUnlockCost
    - [Pub] getWAssetFees
    - [Int] _calculate_frToken
    - [Int] _calculateProgress
    - [Int] _calculateWithdrawCost
    - [Int] _calculateWAssetFees
    - [Int] _calculateBurnAndSend




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 1800+ 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.