Sharks Market

Smart Contract Audit Report

Audit Summary

Sharks is building a new platform where users can create new markets that are available for purchase.

For this audit, we reviewed the project team's Treasury and Market contracts at commit 2ec0605430325398757b7e31ec157ca8ed96e7c1 on the team's private GitHub repository.

We previously reviewed the project team's token contract here.

Audit Findings

An Informational finding was identified and the team may want to review it.
Date: April 24th, 2023.

Finding #1 - Treasury - Informational

Description: The revocable value assigned to each vesting schedule is not used in the contract.
Recommendation: The revocable value should either be removed from the VestingSchedule struct or utilized in a way that fits the project team's intended functionality.

Contracts Overview

  • As the contracts are implemented with Solidity v0.8.x, they are safe from any possible overflows/underflows.
Treasury Contract:
  • The owner can use this contract to vest tokens for users to claim throughout a specified vesting schedule.
  • The team will set the token address used in the contract upon deployment.
  • The owner can create a new vesting schedule for a beneficiary address at any time.
  • The owner will specify the start time, cliff time, duration, number of tokens, and a Market ID upon creating a vesting schedule.
  • The number of tokens allocated to the vest must not exceed the difference between the contract's token balance and the tokens allocated to all other vests.
  • The owner can revoke any vesting schedule at any time. Any current releasable tokens are released to the beneficiary.
  • The owner or the beneficiary of a vest can specify an amount of tokens to release to the beneficiary address at any time.
  • The specified amount cannot exceed the current releasable amount for the vest.
  • Tokens cannot be released if the vest's cliff time has not yet passed or if the vest has been revoked by the owner.
  • If the vest's full duration time has passed, all remaining tokens can be released to the beneficiary.
  • If the cliff time has passed but the full duration has not passed, the number of tokens sent to the beneficiary is calculated based on how much time has passed since the cliff time has passed and the number of slice periods set by the owner when creating the vesting schedule.
  • The owner can withdraw tokens from the contract that exceed the total amount required for all vesting schedules to their own address or a destination address at any time.
  • The contract utilizes ReentrancyGuard to prevent reentrancy attacks in applicable functions.
Market Contract:
  • This contract allows Operator addresses to create new markets that will be available for purchase.
  • The team will set the currency address used for purchases, Product treasury address, and Currency treasury address upon deployment, and the caller will be granted the Operator role and Whitelist role.
  • The Operator role can add a new Market to the contract by specifying a price, minimum and maximum order size, start time, cliff time, duration time, and a number of slice periods.
  • Users can initiate a buy transaction by specifying a valid Market ID, a number of tokens to buy, and a beneficiary address.
  • The beneficiary must have been granted the Whitelist role by the team if the specified Market enforces a whitelist.
  • The specified number of tokens must fall between the Market's minimum and maximum order size.
  • A number of Currency tokens are transferred from the caller to the Currency treasury address based on the price assigned to the Market. The caller must grant the contract a sufficient allowance in order for the transaction to successfully occur.
  • A "TGE" amount is calculated based on the specified number of tokens and the TGE ratio of the market.
  • A withdraw transaction is performed in the Treasury contract which transfers the full TGE amount from the Treasury contract to the beneficiary.
  • A new vesting schedule is created for the beneficiary in the Treasury contract for the remaining purchased tokens using the vesting details for the specified Market.
  • The Operator role can initiate a user-migrate transaction by specifying a Market ID, a number of tokens, and a beneficiary address.
  • The specified number of tokens must fall between the market's minimum and maximum order size.
  • A TGE amount is calculated based on the specified number of tokens and the TGE ratio of the market.
  • A withdraw transaction is performed in the Treasury contract which transfers the full TGE amount from the Treasury contract to the beneficiary.
  • A new vesting schedule is created for the beneficiary in the Treasury contract for the remaining tokens using the vesting details for the specified Market.
  • Any user can initiate a claim for all of their vesting schedules at any time.
  • Each vesting schedule assigned to the user is cycled through and any tokens available for release are transferred to the beneficiary from the Treasury contract.

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

Treasury 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] IERC20Permit 
    - [Ext] permit #
    - [Ext] nonces
    - [Ext] DOMAIN_SEPARATOR

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

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

 +  ReentrancyGuard 
    - [Pub]  #
    - [Prv] _nonReentrantBefore #
    - [Prv] _nonReentrantAfter #
    - [Int] _reentrancyGuardEntered

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

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

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

 +  Treasury (Ownable, ReentrancyGuard)
    - [Pub] initialize #
    - [Ext]  ($)
    - [Ext]  ($)
    - [Ext] getVestingSchedulesCountByBeneficiary
    - [Ext] getVestingIdAtIndex
    - [Ext] getVestingScheduleByAddressAndIndex
    - [Ext] getVestingSchedulesTotalAmount
    - [Ext] getToken
    - [Pub] createVestingSchedule #
       - modifiers: onlyOwner
    - [Pub] revoke #
       - modifiers: nonReentrant,onlyOwner,onlyIfVestingScheduleNotRevoked
    - [Pub] withdraw #
       - modifiers: nonReentrant,onlyOwner
    - [Pub] withdrawTo #
       - modifiers: nonReentrant,onlyOwner
    - [Ext] forceWithdraw #
       - modifiers: onlyOwner,nonReentrant,onlyIfVestingScheduleExists
    - [Pub] release #
       - modifiers: nonReentrant,onlyOwner,onlyIfVestingScheduleNotRevoked
    - [Pub] getVestingSchedulesCount
    - [Pub] computeReleasableAmount
       - modifiers: onlyIfVestingScheduleNotRevoked
    - [Pub] getVestingSchedule
    - [Pub] getWithdrawableAmount
    - [Pub] computeNextVestingScheduleIdForHolder
    - [Pub] getLastVestingScheduleForHolder
    - [Pub] computeVestingScheduleIdForAddressAndIndex
    - [Int] _computeReleasableAmount
    - [Pub] computeReleasableAmountTest #
       - modifiers: onlyIfVestingScheduleNotRevoked
    - [Int] _computeReleasableAmountTest #
    - [Int] getCurrentTime

Market 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 #

 + [Int] IERC20Permit 
    - [Ext] permit #
    - [Ext] nonces
    - [Ext] DOMAIN_SEPARATOR

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

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

 + [Int] IAccessControl 
    - [Ext] hasRole
    - [Ext] getRoleAdmin
    - [Ext] grantRole #
    - [Ext] revokeRole #
    - [Ext] renounceRole #

 + [Lib] Math 
    - [Int] max
    - [Int] min
    - [Int] average
    - [Int] ceilDiv
    - [Int] mulDiv
    - [Int] mulDiv
    - [Int] sqrt
    - [Int] sqrt
    - [Int] log2
    - [Int] log2
    - [Int] log10
    - [Int] log10
    - [Int] log256
    - [Int] log256

 + [Lib] SignedMath 
    - [Int] max
    - [Int] min
    - [Int] average
    - [Int] abs

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

 + [Int] IERC165 
    - [Ext] supportsInterface

 +  ERC165 (IERC165)
    - [Pub] supportsInterface

 +  AccessControl (Context, IAccessControl, ERC165)
    - [Pub] supportsInterface
    - [Pub] hasRole
    - [Int] _checkRole
    - [Int] _checkRole
    - [Pub] getRoleAdmin
    - [Pub] grantRole #
       - modifiers: onlyRole
    - [Pub] revokeRole #
       - modifiers: onlyRole
    - [Pub] renounceRole #
    - [Int] _setupRole #
    - [Int] _setRoleAdmin #
    - [Int] _grantRole #
    - [Int] _revokeRole #

 + [Int] ITreasury 
    - [Ext] computeNextVestingScheduleIdForHolder
    - [Ext] computeReleasableAmount
    - [Ext] computeVestingScheduleIdForAddressAndIndex
    - [Ext] createVestingSchedule #
    - [Ext] getLastVestingScheduleForHolder
    - [Ext] getToken
    - [Ext] getVestingIdAtIndex
    - [Ext] getVestingSchedule
    - [Ext] getVestingScheduleByAddressAndIndex
    - [Ext] getVestingSchedulesCount
    - [Ext] getVestingSchedulesCountByBeneficiary
    - [Ext] getVestingSchedulesTotalAmount
    - [Ext] getWithdrawableAmount
    - [Ext] owner
    - [Ext] release #
    - [Ext] renounceOwnership #
    - [Ext] revoke #
    - [Ext] transferOwnership #
    - [Ext] withdraw #
    - [Ext] withdrawTo #
    - [Ext] forceWithdraw #

 +  Market (AccessControl)
    - [Pub] initialize #
    - [Pub] deployMarket #
    - [Pub] migrateUser #
    - [Pub] buy #
    - [Prv] _migrateUser #
    - [Pub] calculateOrderSize
    - [Pub] calculateOrderPrice
    - [Pub] avaibleToClaim
    - [Pub] claim #
    - [Ext] forceWithdraw #
    - [Pub] getVestingScheduleForIndex
    - [Pub] getVestingSchedules
    - [Pub] getIndexCount
    - [Pub] getMarketInfo

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.