K9 Finance

Smart Contract Audit Report

Audit Summary

K9 Finance Audit Report K9 Finance is building a new ERC-20 token and vesting platform.

For this audit, we reviewed the project team's Token contract at 0x91fbB2503AC69702061f1AC6885759Fc853e6EaE and Vesting contract at 0x38347536479f4f37b063b54aa07e52e2fb5f5812 on the Ethereum Mainnet.

Audit Findings

All findings have been resolved.
Date: January 30th, 2024.
Updated: February 5th, 2024 to reflect changes from commit 5b902603ab68ee53894fca86c225ddee51e9d1b1 to commit a6eb5d45074edaa1f0aaa8f9bbd2290e3536a26d, capping fees at 30%.
Updated: February 15th, 2024 to include the Vesting contract in the audit scope.
Updated: February 20th, 2024 to reflect updates made to the Vesting contract that resolves Finding #1.
Updated: March 7th, 2024 to reflect the Token contract's mainnet address.
Updated: March 12th, 2024 to reflect changes made to the Vesting contract from commit 8d0baa3ccc5a5da804e5fdf60a18bb7f56655f41 to commit db11b61631ea48ee3fb313f52294a81a4073dd3c.
Updated: March 14th, 2024 to reflect the mainnet address of the Vesting contract.
Updated: March 26th, 2024 to reflect the current state of token holders for the Token contract.

Finding #1 - Vesting - Low (Resolved)

Description: The following calculation in the available() function performs a multiplication on the result of a division.
return (info.amount / info.duration) * monthPassed - claimed[user]; 
Risk/Impact: Division can lead to integer truncation, therefore dividing and subsequently multiplying will cause the function's return value to lose precision, leading to users receiving fewer tokens than what is currently due to them upon claiming.
Recommendation: The above calculation should be modified to perform multiplication before division as follows:
return (info.amount * monthPassed) / info.duration - claimed[user];
Resolution: The team has implemented the above recommendation.

Contracts Overview

Token contract:
  • The maximum supply of the token is set to ~999.99 billion $KNINE [999,999,999,999].
  • 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 up to their granted allowance at any time.
  • If any tokens have been burned, the Multisig address can mint any number of tokens to any address up to the maximum supply cap at any time.
  • At the time of writing this report, there are 6,236 total token holders. The token allocation is as follows:

  • Blacklisted accounts are prohibited from initiating transfers and burns if they have not been added to the contract's whitelist.
  • There is a fee charged on all buys and sells via any Pair address associated with this token.
  • The tokens collected through the fee are sent to the Fee Receiver address set by the Multisig address.
  • Ownership has been transferred to a Gnosis Safe Multisig address.
  • The Multisig address can set the contract's Buy fee and Sell fee to any percentages up to 30% at any time.
  • The Multisig address can set the Fee Receiver address to any address at any time.
  • The Multisig address can include and exclude any accounts from fees at any time.
  • The Multisig address can pause/unpause the contract at any time. When paused, all transfers, mints, and burns are prohibited from occurring when the sender's address is not whitelisted.
  • The Multisig address can add/remove any addresses from the contract's blacklist at any time.
  • The Multisig address can add/remove any addresses from the contract's whitelist at any time.
  • As the contract is implemented with Solidity v0.8.x, it is safe from any possible overflows/underflows.
  • The contract complies with the ERC-20 token standard.
Vesting Contract:
  • The deployer will specify the vesting token address referenced in the contract upon deployment. The vesting token should not be a fee-on-transfer token; if such a token is used, this contract must be exempt from the token's fee mechanism.
  • The Multisig address can specify a list of users and vesting schedules that will correspond with each user. Each vesting schedule consists of the total amount of tokens that are to be vested for the user, the total duration of the vesting period in months, the cliff period before which no tokens can be claimed, and start time of the vesting period.
  • Vesting starts after an initial 30 days plus an additional 30 days for each month in the cliff period from the start time.
  • The total number of tokens allocated to each user is transferred from the Multisig address to the contract. The Multisig address must grant the contract a sufficient allowance in order for the transaction to successfully occur.
  • The Multisig address can revoke a vesting schedule for any specified address at any time.
  • The remaining unvested tokens allocated to the user are transferred from the contract to the Multisig address.
  • Any user that has been allocated tokens can initiate a claim at any time.
  • The number of tokens sent to the user from the contract is calculated linearly based on how many months have passed in the vesting schedule since the cliff time was reached.
  • As the contract is implemented with Solidity v0.8.x, it is safe from any possible overflows/underflows.

Audit Results

Vulnerability Category Notes Result
Arbitrary Jump/Storage Write N/A PASS
Centralization of Control
  • Ownership has been transferred to a Gnosis Safe Multisig address.
  • The Multisig address can set the contract's Buy fee and Sell fee to any percentages up to 30%.
  • The Multisig address can add any address to the contract's blacklist.
  • If any tokens have been burned, the Multisig address can mint any number of tokens to any address up to the maximum supply cap.
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

Token Contract

Smart Contract Audit - Inheritance

Smart Contract Audit - Graph


 ($) = payable function
 # = non-constant function
 
 Int = Internal
 Ext = External
 Pub = Public
 
 + [Int] IPair 
    - [Ext] token0
    - [Ext] token1

 + [Int] IFactory 
    - [Ext] getPair

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

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

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

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

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

 + [Int] IERC20Errors 

 + [Int] IERC721Errors 

 + [Int] IERC1155Errors 

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

 +  ERC20Capped (ERC20)
    - [Pub]  #
    - [Pub] cap
    - [Int] _update #

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

 +  Token (ERC20Burnable, ERC20Capped, Pausable, Ownable)
    - [Pub]  #
       - modifiers: Ownable,ERC20,ERC20Capped
    - [Ext] mint #
       - modifiers: onlyOwner
    - [Ext] pause #
       - modifiers: onlyOwner
    - [Ext] unpause #
       - modifiers: onlyOwner
    - [Ext] changeWhiteStatus #
       - modifiers: onlyOwner
    - [Ext] changeBlackStatus #
       - modifiers: onlyOwner
    - [Ext] changeExcludedStatus #
       - modifiers: onlyOwner
    - [Ext] changeSettings #
       - modifiers: onlyOwner
    - [Int] _chageSettings #
    - [Int] _update #
    - [Int] _pairCheck
    - [Int] isContract

Vesting 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
    - [Int] _contextSuffixLength

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

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

 + [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] sendValue #
    - [Int] functionCall #
    - [Int] functionCallWithValue #
    - [Int] functionStaticCall
    - [Int] functionDelegateCall #
    - [Int] verifyCallResultFromTarget
    - [Int] verifyCallResult
    - [Prv] _revert

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

 +  Vesting (Ownable, ReentrancyGuard)
    - [Pub]  #
       - modifiers: Ownable
    - [Ext] addVestedUsers #
       - modifiers: onlyOwner,nonReentrant
    - [Ext] removeUser #
       - modifiers: onlyOwner,nonReentrant
    - [Ext] claim #
       - modifiers: nonReentrant
    - [Pub] currentTime
    - [Pub] available
    - [Pub] getUserInfo

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.