GG Token

Smart Contract Audit Report

Audit Summary

GG Token is a new ERC-20 token with governance features.

For this audit, we reviewed the project team's GG contract at commit a7a3229bfa5b6b563e7235b98d4ba8f7b76129c4 on the team's private GitHub repository.

Audit Findings

All findings have been resolved.
Date: July 28th, 2023.
Updated: December 15th, 2023 to reflect updates made to the contract from commit f0b976fed01f04c296ea4e21b92c309d9a87ef8b to commit 84bc04204dd9138a1f8057a62f05dddf0249676f.
Updated: December 26th, 2023 to reflect updates made to the contract from commit 84bc04204dd9138a1f8057a62f05dddf0249676f to commit a7a3229bfa5b6b563e7235b98d4ba8f7b76129c4.

Finding #1 - GG - High (Resolved)

Description: The _delegate() function incorrectly calls getVotes() instead of balanceOf() when setting delegatorBalance. The getVotes() function returns the vote count from the last checkpoint, which may not reflect current token balance, leading to potential inaccuracies in the delegation of votes.
Risk/Impact: Setting delegatorBalance using getVotes() can lead to imprecise voting power delegation, as it may not reflect current token balances. This discrepancy could lead to issues in vote re-delegation and misrepresent the user’s actual voting power.
Recommendation: The balanceOf() function should be used when setting delegatorBalance in the _delegate() function.
Resolution: The team has implemented the above recommendation.

Contract Overview

  • The total supply of the token is set to 1 billion [1,000,000,000] and is minted to an address set by the team upon deployment.
  • No mint functions are accessible beyond deployment.
  • Any user can burn their own tokens to reduce the total supply at any time.
  • Any user can burn tokens on another user's behalf if an allowance has been granted.
  • The token represents votes intended to be used in a DAO where one token represents one vote.
  • Any user can delegate their votes to another address allowing them to vote on their behalf.
  • The contract utilizes LayerZero contracts to support cross-chain functionality.
  • The contract implements the EIP-2612 standard to support permits which allows for approvals to be made via signatures.
  • As the contract is implemented with Solidity v0.8.x, it is protected from overflows/underflows.
  • The contract complies with the ERC-20 token standard.

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] balanceOf
    - [Ext] transfer #
    - [Ext] allowance
    - [Ext] approve #
    - [Ext] transferFrom #

 + [Int] IERC165 
    - [Ext] supportsInterface

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

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

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

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

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

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

 +  EIP712 
    - [Pub]  #
    - [Int] _domainSeparatorV4
    - [Prv] _buildDomainSeparator
    - [Int] _hashTypedDataV4

 + [Lib] ECDSA 
    - [Prv] _throwError
    - [Int] tryRecover
    - [Int] recover
    - [Int] tryRecover
    - [Int] recover
    - [Int] tryRecover
    - [Int] recover
    - [Int] toEthSignedMessageHash
    - [Int] toEthSignedMessageHash
    - [Int] toTypedDataHash

 + [Lib] Counters 
    - [Int] current
    - [Int] increment #
    - [Int] decrement #
    - [Int] reset #

 +  ERC20Permit (ERC20, IERC20Permit, EIP712)
    - [Pub]  #
       - modifiers: EIP712
    - [Pub] permit #
    - [Pub] nonces
    - [Ext] DOMAIN_SEPARATOR
    - [Int] _useNonce #

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

 + [Lib] SafeCast 
    - [Int] toUint224
    - [Int] toUint128
    - [Int] toUint96
    - [Int] toUint64
    - [Int] toUint32
    - [Int] toUint16
    - [Int] toUint8
    - [Int] toUint256
    - [Int] toInt128
    - [Int] toInt64
    - [Int] toInt32
    - [Int] toInt16
    - [Int] toInt8
    - [Int] toInt256

 +  ERC20Votes (ERC20Permit)
    - [Pub] checkpoints
    - [Pub] numCheckpoints
    - [Pub] delegates
    - [Pub] getVotes
    - [Pub] getPastVotes
    - [Pub] getPastTotalSupply
    - [Prv] _checkpointsLookup
    - [Pub] delegate #
    - [Pub] delegateBySig #
    - [Int] _maxSupply
    - [Int] _mint #
    - [Int] _burn #
    - [Int] _afterTokenTransfer #
    - [Int] _delegate #
    - [Prv] _moveVotingPower #
    - [Prv] _writeCheckpoint #
    - [Prv] _add
    - [Prv] _subtract

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

 +  ERC165 (IERC165)
    - [Pub] supportsInterface

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

 +  GG (ERC20Burnable, ERC20Votes, AccessControl)
    - [Pub]  #
       - modifiers: ERC20,ERC20Permit
    - [Pub] delegates
    - [Pub] delegate #
       - modifiers: onlyRole
    - [Ext] mint #
       - modifiers: onlyRole
    - [Ext] governanceMint #
       - modifiers: onlyRole
    - [Int] _afterTokenTransfer #
    - [Int] _mint #
    - [Int] _burn #
    - [Pub] delegate
    - [Pub] delegateBySig #

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.