LostBoy NFT Staking

Smart Contract Audit Report

Audit Summary

InheritanceNFTStaking Audit Report LostBoy is building a new ERC-20 token and NFT staking contract for users to stake NFTs in order to earn yield.

For this audit, we reviewed the project team's LostToken contract at commit f16459e48bf44aaa451647851c184e44124a49c8 and the LostStaking contract at commit 3a04fec075c21e0d99b117d8684f4b27c75583a4 on the team's GitHub repository.

Audit Findings

All findings have been resolved. Some centralized aspects are present. Off-chain logic is used to assign rarity values used to determine staking bonuses via a Merkle tree.
Date: March 15th, 2022.
Updated: June 15th, 2022 to include review of an updated LostStaking contract.
Updated: June 25th, 2022 to resolve findings.

Finding #1 - LostStaking - Low (Resolved)

Description: deposit()is a payable function, yet there is no method to withdraw ETH sent to the contract.
Risk/Impact: Team members or users that accidentally send ETH to this contract will have it permanently locked here.
Recommendation: We recommend removing the payable keyword or include functionality to withdraw ETH from the contract.
Resolution: The team has implemented the above recommendation.

Finding #2 - LostStaking - Informational (Resolved)

Description: _rarityValueArray is never used in the deposit() function and nullAddress is never used in this contract.
Recommendation: We recommend removing these variables to save on deployment costs and gas savings on each call.
Resolution: The team has implemented the above recommendation.

Finding #3 - LostStaking - Informational (Resolved)

Description: Several functions are declared public, but are never called internally.
LostStaking.pause, LostStaking.unpause, LostStaking.setOneDayPrev, LostStaking.updateReward, LostStaking.updateRarity, LostStaking.setExpiration, LostStaking.calculateRewards
Recommendation: We recommend declaring these functions external for additional gas savings on each call.
Resolution: The team has declared the functions external.

Contracts Overview

  • As the contracts are implemented with Solidity v0.8.X, they are protected from any underflow/overflow attacks.
LostToken Contract:
  • This token is intended to serve as the reward token within the LostStaking contract.
  • The total supply of the $LOST token is 200 million.
  • Initially, 100% of the total supply will be held by the owner.
  • There is no mint function so there is no way for the team to increase the total supply after the initial amount.
  • Any user can burn their own tokens to reduce the total supply.
  • Additionally, users can burn tokens from other addresses up to the amount of allowance they've been granted, also reducing the total supply.
  • No ownership-restricted functions are present.
  • There are no fees associated with transferring tokens.
  • The contract complies with the ERC20 standard.
LostStaking Contract:
  • This contract is intended to allow users to stake one or more Lostboy NFTs in order to earn rewards in the form of a designated ERC20 reward token.
  • Users can claim token rewards from staked NFTs at any point after the team determined number of days has passed since deployment.
  • Users' reward token amount is based on the days staked, NFT rarity reward value, and reward multiplier; the reward multiplier is intended to be based on the user's balance of Lostgirl NFTs with different multiplier values applied for users holding between 1 and 3, 4 and 6, 7 and 9, 10 and 15, and above 15 Lostgirl NFTs.
  • The Lostgirl NFT contract is not within the scope of this audit, so we are unable to provide an assessment of the contract with regards to security.
  • When a user deposits a Lostboy NFT to this contract to begin staking, their rarity value is determined through a Merkle Proof, based on data provided during the function call; users receive 1 of 4 rarity values used for reward token calculations. If there is no rarity value verified through the Merkle Proof, the staking deposit transaction will revert.
  • Users initiate a withdrawal by specifying a list of NFT ids they wish to withdraw. During a withdrawal, any token rewards for the NFTs are transferred to the user, and the staked NFTs are transferred back to the user.
  • The owner can pause and unpause the functionality of claiming rewards and withdrawing staked NFTs.
  • The owner can update the Merkle Tree roots at any time, effectively controlling the rarity of newly deposited NFTs at any time.
  • The owner can update the reward multiplier values used to apply bonuses to staking rewards based on Lostgirl NFT balances of a user.
  • The owner can update the rarity reward value applied to a users' reward token paid out.
  • The owner can set the expiration date to a determined number of days in the future after which users will be able to claim rewards.
  • ReentrancyGuard is utilized within the withdraw() function to prevent re-entrancy attacks.
  • The contract implements an onERC721Received() function to allow for this contract to receive NFTs.

Audit Results

Vulnerability CategoryNotesResult
Arbitrary Jump/Storage WriteN/APASS
Centralization of Control
  • The owner can pause deposits, reward claims, and withdrawals at any time.
  • The owner can update the Merkle Roots used to determine rarity rankings of staked NFTs at any time.
WARNING
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 IssuesThere aren't any conditions specified for _rarity values when depositing NFTs.WARNING
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

LostToken Contract

Smart Contract Audit - Inheritance

Smart Contract Audit - Graph


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

 + [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 #
    - [Prv] _checkOnERC721Received #
    - [Int] _beforeTokenTransfer #

 + [Int] IERC721Enumerable (IERC721)
    - [Ext] totalSupply
    - [Ext] tokenOfOwnerByIndex
    - [Ext] tokenByIndex

 +  ERC721Enumerable (ERC721, IERC721Enumerable)
    - [Pub] supportsInterface
    - [Pub] tokenOfOwnerByIndex
    - [Pub] totalSupply
    - [Pub] tokenByIndex
    - [Int] _beforeTokenTransfer #
    - [Prv] _addTokenToOwnerEnumeration #
    - [Prv] _addTokenToAllTokensEnumeration #
    - [Prv] _removeTokenFromOwnerEnumeration #
    - [Prv] _removeTokenFromAllTokensEnumeration #

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

 +  ERC721EnumerableNameable (ERC721Enumerable, Ownable)
    - [Pub]  #
       - modifiers: ERC721
    - [Pub] changeName #
    - [Pub] changeBio #
    - [Int] toggleReserveName #
    - [Pub] tokenNameByIndex
    - [Pub] tokenBioByIndex
    - [Pub] isNameReserved
    - [Pub] validateName
    - [Pub] toLower
    - [Int] _beforeTokenTransfer #
    - [Pub] supportsInterface

 +  Lostgirl (ERC721EnumerableNameable)
    - [Pub]  #
       - modifiers: ERC721EnumerableNameable
    - [Pub] toggleClaim #
       - modifiers: onlyOwner
    - [Pub] toggleToken #
       - modifiers: onlyOwner
    - [Pub] setSnapshotRoot #
       - modifiers: onlyOwner
    - [Pub] updateNameChangePrice #
       - modifiers: onlyOwner
    - [Pub] updateBioChangePrice #
       - modifiers: onlyOwner
    - [Pub] setBaseURI #
       - modifiers: onlyOwner
    - [Pub] ownerCollect #
       - modifiers: onlyOwner
    - [Pub] claim #
    - [Int] _baseURI

LostStaking 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
    - [Prv] _setOwner #

 + [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

 + [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] IERC721Enumerable (IERC721)
    - [Ext] totalSupply
    - [Ext] tokenOfOwnerByIndex
    - [Ext] tokenByIndex

 + [Int] IERC721Receiver 
    - [Ext] onERC721Received #

 + [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

 +  ReentrancyGuard 
    - [Pub]  #

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

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

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

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

 + [Lib] MerkleProof 
    - [Int] verify
    - [Int] processProof
    - [Prv] _efficientHash

 +  LostStaking (Ownable, IERC721Receiver, ReentrancyGuard, Pausable)
    - [Pub]  #
    - [Ext] pause #
       - modifiers: onlyOwner
    - [Ext] unpause #
       - modifiers: onlyOwner
    - [Ext] updateMarkelTree #
       - modifiers: onlyOwner
    - [Ext] updateReward #
       - modifiers: onlyOwner
    - [Ext] updateRarity #
       - modifiers: onlyOwner
    - [Ext] setExpiration #
       - modifiers: onlyOwner
    - [Ext] balanceOfLostGirl
    - [Ext] depositsOf
    - [Ext] calculateRewards
    - [Pub] calculateReward
       - modifiers: isExpired
    - [Pub] claimRewards #
       - modifiers: whenNotPaused
    - [Pub] deposit ($)
    - [Ext] withdraw #
       - modifiers: whenNotPaused,nonReentrant
    - [Ext] onERC721Received

About Solidity Finance

Solidity Finance was founded in 2020 and quickly grew to have one of the most experienced and well-equipped smart contract auditing teams in the industry. Our team has conducted 1000+ 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 Solidity Audit?

Typically, a smart contract audit is a comprehensive review process designed to discover logical errors, security vulnerabilities, and optimization opportunities within code. A Solidity 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.