K9 Finance

Smart Contract Audit Report

K9 Finance Audit Report

Executive Summary

This report presents the outcomes of our collaborative engagement with the K9 Finance team, focusing on the comprehensive evaluation of the Token, Vesting, and KNINEToken contracts.

Our team conducted an initial security assessment from June 13 to June 17th, 2024. On June 18th our team amended this report to reflect the most recent commit for the KNINEToken contract on the team's GitHub repository.

K9 Finance has developed two ERC-20 tokens, one on Ethereum and another for the Shibarium network, along with a vesting platform to manage token distribution.


Audit Scope

Name

Address/Source Code

Visualized

KNINEToken

4839be3

Inheritance Chart.  Function Graph.

Token

ETH Mainnet

Inheritance Chart.  Function Graph.

Vesting

ETH Mainnet

Inheritance Chart.  Function Graph.


Audit Findings

All findings have been resolved, though some centralized aspects are present.

Finding #1

KNINEToken

High Resolved

Finding #1 - KNINEToken
High Resolved

Description: The following logic in the _update() function will cause a transaction to revert if the 'from' address is not whitelisted, even when the contract is not paused and the 'from' address is not blacklisted. Additionally, a transaction will revert if the 'from' address is whitelisted, even when the contract is not paused and the 'from' address is not blacklisted:

if (!whitelist[from] || !(paused() || blacklist[from])) {
	revert TransferForbidden(_msgSender(), paused(), blacklist[from]);
}

Risk/Impact: Transfers and burns cannot take place on the platform unless the 'from' address is whitelisted and the contract is paused.

Recommendation: The logic should be modified to disallow transfers only when the 'from' address is not whitelisted and either the contract is paused, the 'from' address is blacklisted, or both conditions are true.

if (!whitelist[from] && (paused() || blacklist[from])) {
	revert TransferForbidden(_msgSender(), paused(), blacklist[from]);
}

Resolution: The team has implemented the above recommendation.

Finding #2

KNINEToken

Low Resolved

Finding #2 - KNINEToken
Low Resolved

Description: The contract uses the .transfer() function to send ETH to the Fee Receiver address in the _collectFees() function.

function _collectFees(uint256 feeAmount) private {
    uint256 initialBalance = address(this).balance;

    _swapTokensForBONE(feeAmount);

    uint256 newBalance = address(this).balance - initialBalance;
    payable(taxes.feeReceiver).transfer(newBalance);

Risk/Impact: The .transfer() function sends only 2300 gas, which is not enough for executing any logic upon receiving BONE on the recipient's end. If the Fee Receiver address is a contract that executes logic upon receiving BONE, this can result in a denial of service (DOS) on buys and sells.

Recommendation: The .call() function should be used instead to send BONE to the Fee Receiver address.

Resolution: The team has implemented the above recommendation.

Finding #3

Vesting

Low Resolved

Finding #3 - 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.

Finding #4

KNINEToken

InformationalResolved

Finding #4 - KNINEToken
InformationalResolved

Description: The WrongTaxes and TransferForbidden custom errors are defined but are not used in the contract.

Recommendation: The WrongTaxes and TransferForbidden custom errors should either be removed to reduce contract size and deployment costs or utilized in a way that fits the project team's intended functionality.

Resolution: The WrongTaxes custom error has been removed and the TransferForbidden custom error is now utilized in the _update() function.


System Overview

KNINE Token

TOKENOMICS

The initial supply of the token is set to zero upon deployment. The maximum supply of the token is set to ~999.99 billion $KNINE (999,999,999,999). The Child-Chain Manager contract can specify a number of tokens to mint to a recipient address up to the maximum supply cap at any time. Any user can burn their own tokens to reduce the total supply at any time.

TOKEN ATTRIBUTES

Trading is initially paused after deployment. Trading must be unpaused by the owner in order for all token transfers to take place on the platform. Only whitelisted accounts are enabled to transfer or burn tokens while trading is paused. Blacklisted accounts are prohibited from transferring or burning their tokens.

Each $KNINE token represents votes intended to be used in a DAO where one token represents one vote. Users must delegate to themselves in order to have their voting power tracked. Users may elect to delegate their votes to another address allowing them to vote on behalf of the user.

There is a Buy fee or Sell fee on all buys and sells via any Pair address involving the KNINE token, provided the recipient is not excluded from fees on buys and the sender is not excluded from fees on sells. The Factory address associated with the Pair must be added as a Valid Factory address by the owner for the transaction to be recognized as a buy or sell. If the transaction is a sell, the tokens collected through the fee are swapped for BONE and sent to the Fee Receiver address set by the team in the same transaction. If the transaction is a buy, the tokens are transferred directly to the Fee Receiver address.

The Child-Chain Manager contract can initiate a deposit by specifying a recipient address and token amount. The specified number of tokens is minted to the recipient. The Child-Chain Manager contract is not included in the scope of this audit, so our team cannot assess its security.

As the contract is implemented with Solidity v0.8.x, it is protected from overflows/underflows. The contract complies with the ERC-20 standard.

OWNERSHIP CONTROLS

The owner can set the Buy fee and Sell fee to any percentage up to 30% each at any time. The owner can include and exclude accounts from the Buy fee and Sell fee at any time.

The owner can pause/unpause the contract at any time. When paused, all transfers and burns are prohibited from occurring unless the sender address has been added to the contract's whitelist. The owner can add or remove addresses from the contract's blacklist and whitelist at any time.

The owner can initiate a withdrawal of any tokens or BONE from the contract to the Fee Receiver address at any time. The owner can add/remove any address as a valid Factory address at any time. The owner can update the Child-Chain Manager and Uniswap Router addresses referenced in the contract to any addresses at any time.

K9 Finance DAO Token

TOKENOMICS

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.

CURRENT TOKEN HOLDERS

At the time of writing this report, there are 6,915 token holders. The current token allocation is as follows:

TOKEN ATTRIBUTES

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.

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.

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.

Vesting

CONFIGURATION

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.

REVOKE

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.

CLAIMING

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.

Vulnerability Analysis

Vulnerability Category Notes Result
Arbitrary Jump/Storage Write N/A PASS
Centralization of Control
  • The owner can add any address to the contract's blacklist at any time in the KNINEToken contract.
  • The owner can set total fees on buys and sells up to 30% each at any time in the KNINEToken contract.
  • Ownership of K9 Finance DAO token contract and Vesting contract have 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% in the K9 Finance DAO token.
  • The Multisig address can add any address to the contract's blacklist in the K9 Finance DAO token.
  • If any tokens have been burned, the Multisig address can mint any number of tokens to any address up to the maximum supply cap in the K9 Finance DAO token.
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

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.