Haidamo

Smart Contract Audit Report

Audit Summary

Haidamo Audit Report Haidamo is building new LP token vesting contracts.

For this audit, we reviewed the TokenVestingBase, LPCapitalization, and PriceOracle contracts provided to us by the project team.

Audit Findings

Please ensure trust in the team prior to investing as they have some control in the ecosystem.
Date: March 17th, 2022.
Updated: April 8th, 2022 to address changes made by the team.

Finding #1 - LPCapitalization - Medium (Resolved)

Description: In the calculatePayout() function, the $DAMO reward amount is calculated based on using the inherited getReserves() function and Uniswap liquidity pools to determine the value of the deposited LP tokens in $DAMO.
Risk/Impact: Anyone can use flash loans to manipulate the ratio of the reward token to $DAI liquidity pair, thereby greatly increasing the determined value of LP tokens deposited in the contract. The new inflated value would automatically set the user's reward to an inflated amount.
Recommendation: The team should implement a Time Weighted Average Price (TWAP) or utilize Chainlink to mitigate potential price manipulations.
Resolution: The team has implemented a TWAP using a Uniswap oracle in order to determine the value of the LP tokens as recommended above.

Finding #2 - Haidamo - Informational

Description: Several functions are declared public, but are never called internally.
TokenVestingBase.createVestingSchedule, TokenVestingBase.revoke, TokenVestingBase.withdraw, TokenVestingBase.computeReleasableAmount, TokenVestingBase.computeLatestVestingScheduleIdForHolder, TokenVestingBase.getLastVestingScheduleForHolder
Recommendation: We recommend declaring these functions external for additional gas savings on each call.

Contracts Overview

  • As the contracts are implemented with Solidity v0.8.X, they are protected from any underflow/overflow attacks.
  • The team must exercise caution when designating reward tokens and must avoid fee-on-transfer tokens (unless the proper exemptions are made).
TokenVestingBase Contract:
  • This contract enables users to claim their vested reward tokens until rewards are depleted or their rewards are revoked.
  • Reward token vesting begins once the specified start time of the vesting entry has been reached; however, reward tokens are not claimable until the vesting entry's cliff period has elapsed as well as a full reward interval period.
  • The cliff period is a specified duration of time after the start time in which the user cannot claim their reward tokens.
  • The rate at which the reward tokens vest is dependent on the vesting entry's total duration and amount.
  • Users can claim vested rewards as long as their vesting amount has not been revoked; When a users' vesting token amount is revoked, any vested tokens are transferred to the vesting entry's owner while unvested tokens are forfeited.
  • The owner can transfer ownership of the contract at any time.
  • The owner can revoke any users' vesting tokens at any time unless the vesting entry is irrevocable.
  • The owner can only withdraw reward tokens from the contract that exceed the total amount required for rewards.
  • ReentrancyGuard is utilized within the release() function to prevent re-entrancy attacks.
LPCapitalization Contract:
  • This contract enables users to deposit a designated LP token in exchange for vesting reward tokens until the contract's maximum deposit limit is reached; the vesting properties are stored within the vestingContractAddress contract address.
  • The TokenVestingBase contract is intended to be used as the vestingContractAddress.
  • The vesting start time is set as the current time, the reward interval is one second, and the total duration is set to 3 days.
  • There is no cliff period set so users' can claim rewards from the TokenVestingBase contract at any time as long as a full reward interval has elapsed.
  • Users' rewards are based on the reserve amount of both tokens in the liquidity pair, $DAMO value of the deposited LP tokens, and bonus percentage.
  • The $DAMO value of the deposited LP tokens is calculated based on a Time Weighted Average Price (TWAP) for $DAMO tokens from the PriceOracle contract and the amount of $DAMO tokens that would be returned from liquidating the deposited LP tokens and swapping the $DAI token asset for the $DAMO token asset.
  • The vesting reward entries from this contract cannot be revoked within the TokenVestingBase contract.
  • The owner can transfer ownership of the contract at any time.
  • The owner can update the liquidity pair address at any time.
  • The owner can change the bonus percentage at any time.
  • The owner can update the maximum total deposit limit at any time.

Audit Results

Vulnerability CategoryNotesResult
Arbitrary Jump/Storage WriteN/APASS
Centralization of ControlN/APASS
Compiler IssuesN/APASS
Delegate Call to Untrusted ContractN/APASS
Dependence on Predictable VariablesN/APASS
Ether/Token TheftN/APASS
Flash LoansN/APASS
Front RunningN/APASS
Improper EventsN/APASS
Improper Authorization SchemeN/APASS
Integer Over/UnderflowN/APASS
Logical IssuesN/APASS
Oracle IssuesN/APASS
Outdated Compiler VersionN/APASS
Race ConditionsN/APASS
ReentrancyN/APASS
Signature IssuesN/APASS
Unbounded LoopsN/APASS
Unused CodeN/APASS
Overall Contract Safety PASS

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

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

 + [Int] IUniswapV2Pair 
    - [Ext] name
    - [Ext] symbol
    - [Ext] decimals
    - [Ext] totalSupply
    - [Ext] balanceOf
    - [Ext] allowance
    - [Ext] approve #
    - [Ext] transfer #
    - [Ext] transferFrom #
    - [Ext] DOMAIN_SEPARATOR
    - [Ext] PERMIT_TYPEHASH
    - [Ext] nonces
    - [Ext] permit #
    - [Ext] MINIMUM_LIQUIDITY
    - [Ext] factory
    - [Ext] token0
    - [Ext] token1
    - [Ext] getReserves
    - [Ext] price0CumulativeLast
    - [Ext] price1CumulativeLast
    - [Ext] kLast
    - [Ext] mint #
    - [Ext] burn #
    - [Ext] swap #
    - [Ext] skim #
    - [Ext] sync #
    - [Ext] initialize #

 + [Lib] UniswapV2Library 
    - [Int] sortTokens
    - [Int] pairFor
    - [Int] getReserves
    - [Int] quote
    - [Int] getAmountOut
    - [Int] getAmountIn
    - [Int] getAmountsOut
    - [Int] getAmountsIn

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

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

 +  ReentrancyGuard 
    - [Pub]  #

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

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

 + [Int] ITokenVestingBase 
    - [Ext] getVestingSchedulesCountByBeneficiary
    - [Ext] getVestingIdAtIndex
    - [Ext] getVestingSchedulesTotalAmount
    - [Ext] getToken
    - [Ext] createVestingSchedule #
    - [Ext] revoke #
    - [Ext] withdraw #
    - [Ext] release #
    - [Ext] getVestingSchedulesCount
    - [Ext] computeReleasableAmount
    - [Ext] getWithdrawableAmount
    - [Ext] computeNextVestingScheduleIdForHolder
    - [Ext] computeLatestVestingScheduleIdForHolder
    - [Ext] computeVestingScheduleIdForAddressAndIndex

 + [Lib] console 
    - [Prv] _sendLogPayload
    - [Int] log
    - [Int] logInt
    - [Int] logUint
    - [Int] logString
    - [Int] logBool
    - [Int] logAddress
    - [Int] logBytes
    - [Int] logBytes1
    - [Int] logBytes2
    - [Int] logBytes3
    - [Int] logBytes4
    - [Int] logBytes5
    - [Int] logBytes6
    - [Int] logBytes7
    - [Int] logBytes8
    - [Int] logBytes9
    - [Int] logBytes10
    - [Int] logBytes11
    - [Int] logBytes12
    - [Int] logBytes13
    - [Int] logBytes14
    - [Int] logBytes15
    - [Int] logBytes16
    - [Int] logBytes17
    - [Int] logBytes18
    - [Int] logBytes19
    - [Int] logBytes20
    - [Int] logBytes21
    - [Int] logBytes22
    - [Int] logBytes23
    - [Int] logBytes24
    - [Int] logBytes25
    - [Int] logBytes26
    - [Int] logBytes27
    - [Int] logBytes28
    - [Int] logBytes29
    - [Int] logBytes30
    - [Int] logBytes31
    - [Int] logBytes32
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log
    - [Int] log

 +  LPCapitalization (Ownable)
    - [Pub]  #
    - [Ext] setDamoDaiPair #
       - modifiers: onlyOwner
    - [Pub] calculatePayout
    - [Ext] deposit #
    - [Int] _updateLiquidity #
    - [Ext] updateMAX_LP #
       - modifiers: onlyOwner
    - [Ext] updateDiscount #
       - modifiers: onlyOwner
    - [Int] _applyDiscount

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

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

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

 +  ReentrancyGuard 
    - [Pub]  #

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

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

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

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

 +  TokenVestingBase (Ownable, ReentrancyGuard)
    - [Pub]  #
    - [Ext]  ($)
    - [Ext]  ($)
    - [Ext] getVestingSchedulesCountByBeneficiary
    - [Ext] getVestingIdAtIndex
    - [Ext] getVestingScheduleByAddressAndIndex
    - [Ext] getVestingSchedulesTotalAmount
    - [Ext] getToken
    - [Pub] createVestingSchedule #
    - [Int] _createVestingSchedule #
    - [Pub] revoke #
       - modifiers: onlyOwner,onlyIfVestingScheduleNotRevoked
    - [Pub] withdraw #
       - modifiers: nonReentrant,onlyOwner
    - [Pub] release #
       - modifiers: nonReentrant,onlyIfVestingScheduleNotRevoked
    - [Pub] getVestingSchedulesCount
    - [Pub] computeReleasableAmount
       - modifiers: onlyIfVestingScheduleNotRevoked
    - [Pub] getVestingSchedule
    - [Pub] getWithdrawableAmount
    - [Pub] computeNextVestingScheduleIdForHolder
    - [Pub] computeLatestVestingScheduleIdForHolder
    - [Pub] getLastVestingScheduleForHolder
    - [Pub] computeVestingScheduleIdForAddressAndIndex
    - [Int] _computeReleasableAmount
    - [Int] getCurrentTime

PriceOracle Contract

Smart Contract Audit - Inheritance

Smart Contract Audit - Graph


 ($) = payable function
 # = non-constant function
 
 Int = Internal
 Ext = External
 Pub = Public
 
   + [Int] IUniswapV2Pair 
    - [Ext] name
    - [Ext] symbol
    - [Ext] decimals
    - [Ext] totalSupply
    - [Ext] balanceOf
    - [Ext] allowance
    - [Ext] approve #
    - [Ext] transfer #
    - [Ext] transferFrom #
    - [Ext] DOMAIN_SEPARATOR
    - [Ext] PERMIT_TYPEHASH
    - [Ext] nonces
    - [Ext] permit #
    - [Ext] MINIMUM_LIQUIDITY
    - [Ext] factory
    - [Ext] token0
    - [Ext] token1
    - [Ext] getReserves
    - [Ext] price0CumulativeLast
    - [Ext] price1CumulativeLast
    - [Ext] kLast
    - [Ext] mint #
    - [Ext] burn #
    - [Ext] swap #
    - [Ext] skim #
    - [Ext] sync #
    - [Ext] initialize #

 + [Lib] FixedPoint 
    - [Int] encode
    - [Int] encode144
    - [Int] div
    - [Int] mul
    - [Int] fraction
    - [Int] decode
    - [Int] decode144

 + [Int] KeeperCompatibleInterface 
    - [Ext] checkUpkeep #
    - [Ext] performUpkeep #

 + [Lib] UniswapV2OracleLibrary 
    - [Int] currentBlockTimestamp
    - [Int] currentCumulativePrices

 + [Lib] SafeMath 
    - [Int] add
    - [Int] sub
    - [Int] mul

 + [Lib] UniswapV2Library 
    - [Int] sortTokens
    - [Int] pairFor
    - [Int] getReserves
    - [Int] quote
    - [Int] getAmountOut
    - [Int] getAmountIn
    - [Int] getAmountsOut
    - [Int] getAmountsIn

 + [Int] IPriceOracle 
    - [Ext] update #
    - [Ext] consult

 +  PriceOracle (IPriceOracle, KeeperCompatibleInterface)
    - [Pub]  #
    - [Ext] checkUpkeep
    - [Ext] performUpkeep #
    - [Ext] update #
    - [Int] _update #
    - [Ext] consult

About Solidity Finance

Solidity Finance was founded in 2020 and quickly grew to have one of the most experienced and well-equipped smart contract auditing teams in the industry. Our team has conducted 1000+ 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 Solidity Audit?

Typically, a smart contract audit is a comprehensive review process designed to discover logical errors, security vulnerabilities, and optimization opportunities within code. A Solidity 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.