Kannagi Finance

Smart Contract Audit Report

Audit Summary

Kannagi Finance Audit Report Kannagi Finance is building a new vault where deposits and withdrawals can be made on behalf of users.

For this audit, we reviewed the project team's Vault contract at commit 0dfec8c2c906c0e67ab5a5e1837375e01e1610ae on the team's GitHub repository.

Audit Findings

An Informational finding was identified and the team may want to review it. In addition, some centralized aspects are present.
Date: June 23rd, 2023.

Finding #1 - Vault - Informational

Description: Although the SafeMath library is utilized, the contract is implemented with Solidity v0.8.x which has built-in overflow checks.
Recommendation: SafeMath could be safely removed to reduce contract size, deployment costs, and gas costs on all transactions that utilize it.

Contract Overview

  • The MainChef address can initiate a deposit on behalf of a user by specifying the user's address and an amount to deposit. The MainChef contract was not included in the scope of this audit so our team is unable to provide an assessment with regard to its security.
  • If the Strategy contract address has been set, its beforeDeposit() function is triggered. The Strategy contract was not included in the scope of this audit so our team is unable to provide an assessment with regard to its security.
  • If the deposit asset is set to WETH and the Strategy contract address has been set, the provided ETH is deposited into the Strategy contract. The user's deposit amount and the contract's total assets of the vault are updated to reflect the deposit.
  • If the deposit asset is set to any other token, the specified amount of tokens are transferred from the MainChef contract to this contract and the deposit function in the Strategy contract is triggered. The user's deposit amount and the contract's total assets of the vault are updated to reflect the deposit.
  • The MainChef address can initiate a withdrawal on behalf of a user by specifying the user's address and an amount to withdraw.
  • If the withdraw asset is set to WETH, the specified amount of ETH is transferred from the contract to the user. The user's deposit amount and the contract's total assets of the vault are updated to reflect the withdrawal.
  • If the withdraw asset is set to any other token, the specified amount of tokens are transferred from the contract to the user and the withdraw function in the Strategy contract is triggered. The user's deposit amount and the contract's total assets of the vault are updated to reflect the withdrawal.
  • The owner can set the Strategy address to any address at any time.
  • The owner can set the MainChef address to any address at any time
  • The team can upgrade the contract at any time.
  • The contract utilizes ReentrancyGuard to prevent reentrancy attacks in applicable functions.
  • As the contract is implemented with Solidity v0.8.x, it is protected from overflows/underflows.

Audit Results

Vulnerability Category Notes Result
Arbitrary Jump/Storage Write N/A PASS
Centralization of Control The team can upgrade the contract at any time. WARNING
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

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

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

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

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

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

 + [Lib] TransferHelper 
    - [Int] safeApprove #
    - [Int] safeTransfer #
    - [Int] safeTransferFrom #
    - [Int] safeTransferETH #

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

 +  Initializable 
    - [Int] _disableInitializers #
    - [Int] _getInitializedVersion
    - [Int] _isInitializing

 +  ReentrancyGuardUpgradeable (Initializable)
    - [Int] __ReentrancyGuard_init #
       - modifiers: onlyInitializing
    - [Int] __ReentrancyGuard_init_unchained #
       - modifiers: onlyInitializing
    - [Prv] _nonReentrantBefore #
    - [Prv] _nonReentrantAfter #
    - [Int] _reentrancyGuardEntered

 +  ContextUpgradeable (Initializable)
    - [Int] __Context_init #
       - modifiers: onlyInitializing
    - [Int] __Context_init_unchained #
       - modifiers: onlyInitializing
    - [Int] _msgSender
    - [Int] _msgData

 +  OwnableUpgradeable (Initializable, ContextUpgradeable)
    - [Int] __Ownable_init #
       - modifiers: onlyInitializing
    - [Int] __Ownable_init_unchained #
       - modifiers: onlyInitializing
    - [Pub] owner
    - [Int] _checkOwner
    - [Pub] renounceOwnership #
       - modifiers: onlyOwner
    - [Pub] transferOwnership #
       - modifiers: onlyOwner
    - [Int] _transferOwnership #

 + [Int] IStrategy 
    - [Ext] want
    - [Ext] beforeDeposit #
    - [Ext] deposit #
    - [Ext] depositETH ($)
    - [Ext] withdraw #
    - [Ext] withdrawETH ($)
    - [Ext] balanceOf

 +  Vault (Initializable, OwnableUpgradeable, ReentrancyGuardUpgradeable)
    - [Pub] initialize #
       - modifiers: initializer
    - [Ext] setStrategy #
       - modifiers: onlyOwner
    - [Ext] setMainChef #
       - modifiers: onlyOwner
    - [Pub] available
    - [Pub] balance
    - [Pub] deposit ($)
       - modifiers: nonReentrant
    - [Prv] _depositETH #
    - [Prv] _deposit #
    - [Pub] withdraw #
       - modifiers: nonReentrant
    - [Ext]  ($)

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.