DeFi of Thrones - Smart Contract Audit Report

Summary

DeFi of Thrones Game DeFi of Thrones is a game on the Ethereum blockchain for betting which one of two selected DeFi projects gain more value over the course of a week.
Each week two DeFi projects are chosen. Whichever project performs best during the week-long period shall be deemed the winner of the 'battle.' Users will choose one of these two DeFi projects and buy 'tickets' for the game using the platform's native DoTx token. Players also have the ability to switch houses (DeFi Projects). The winning project is selected by calling a Chainlink Oracle operating by the team. Once the final prices are received users who bought tickets to the winning project will split the jackpot of tokens for the round that players will subsequently claim.

We audited Defi of Thrones' contracts at commit e08ec9bb9e428da0de0d97e2414eceb110be7550 on GitHub.
  • DoTxTokenContract is deployed at 0xFAb5a05C933f1A2463E334E011992E897D56eF0a
  • DoTxGameContract is deployed at 0xbca23d091af20516814f4431cf75ac590d17bcce
  • Crowdsale is deployed at 0x2f76ddcfde182a95a1aa25cbb0cf8c31201b29d7

  • Team Token Lock is deployed at 0xFAb5a05C933f1A2463E334E011992E897D56eF0a
  • Marketing Fund Vesting is deployed at 0xFAb5a05C933f1A2463E334E011992E897D56eF0a
  • Public Sale (Finished) is deployed at 0xFAb5a05C933f1A2463E334E011992E897D56eF0a
  • Audit Findings:
    • DoTx token was only minted upon deployment. 6 Million tokens were minted. Tokens can be burned, so the total supply can only decrease.
    • The owner of the token contract has the ability to pause transfers of the token. We have verified that the owner has renounced their ownership at transaction 0x3c3af3d3fb5dbb822f65fe6d0f1dc730c551c50c42d0ee03da9d3f09a3518ab2.
    • Only the owner of the game contract can start and end the game.
    • The project implements a Chainlink Node to provide price data from the CoinGecko API. When the owner closes the round, data from the Chainlink Node is directly entered into the Game Controller contract as the prices to be used to determine the winner.
    • The owner must set certian data related to the oracle in the DoTxLib contract. For best security, the owner should burn the keys for this contract after this data is set. We will add a transaction if they choose to do this.

    • Date: December 7th, 2020.


    Date: December 7th, 2020
    Vulnerability Category Notes Result
    Arbitrary Storage Write N/A PASS
    Arbitrary Jump N/A PASS
    Delegate Call to Untrusted Contract N/A PASS
    Dependence on Predictable Variables N/A PASS
    Deprecated Opcodes N/A PASS
    Ether/Token Thief N/A PASS
    Exceptions N/A PASS
    External Calls N/A PASS
    Integer Over/Underflow N/A PASS
    Multiple Sends N/A PASS
    Oracle The project Chainlink, which is the emerging industry standard. PASS
    Suicide N/A PASS
    State Change External Calls N/A PASS
    Unchecked Retval N/A PASS
    User Supplied Assertion N/A PASS
    Critical Solidity Compiler N/A PASS
    Overall Contract Safety  -----> PASS

    Function Graph

    Smart Contract Graph

    Inheritence Chart

    Smart Contract Inheritance

    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 #
    
     +  Context 
        - [Int]  #
        - [Int] _msgSender
        - [Int] _msgData
    
     + [Lib] EnumerableSet 
        - [Prv] _add #
        - [Prv] _remove #
        - [Prv] _contains
        - [Prv] _length
        - [Prv] _at
        - [Int] add #
        - [Int] remove #
        - [Int] contains
        - [Int] length
        - [Int] at
        - [Int] add #
        - [Int] remove #
        - [Int] contains
        - [Int] length
        - [Int] at
    
     +  Ownable (Context)
        - [Int]  #
        - [Pub] owner
        - [Pub] renounceOwnership #
           - modifiers: onlyOwner
        - [Pub] transferOwnership #
           - modifiers: onlyOwner
    
     +  Pausable (Ownable)
        - [Pub]  #
        - [Pub] pause #
           - modifiers: onlyOwner,whenNotPaused
        - [Pub] unpause #
           - modifiers: onlyOwner,whenPaused
        - [Pub] publicSaleContractAddress
        - [Pub] publicSaleContractAddress #
           - modifiers: onlyOwner
        - [Pub] swapWallet
        - [Pub] swapWallet #
           - modifiers: onlyOwner
    
     + [Lib] Address 
        - [Int] isContract
        - [Int] sendValue #
    
     +  AccessControl (Context)
        - [Pub] hasRole
        - [Pub] getRoleMemberCount
        - [Pub] getRoleMember
        - [Pub] getRoleAdmin
        - [Pub] grantRole #
        - [Pub] revokeRole #
        - [Pub] renounceRole #
        - [Int] _setupRole #
        - [Int] _setRoleAdmin #
        - [Prv] _grantRole #
        - [Prv] _revokeRole #
    
     + [Lib] SafeMath 
        - [Int] add
        - [Int] sub
        - [Int] sub
        - [Int] mul
        - [Int] div
        - [Int] div
        - [Int] mod
        - [Int] mod
    
     +  ERC20 (Context, IERC20)
        - [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] _setupDecimals #
        - [Int] _beforeTokenTransfer #
    
     +  TokenRecover (Ownable)
        - [Pub] recoverERC20 #
           - modifiers: onlyOwner
    
     +  ERC20Burnable (Context, ERC20)
        - [Pub] burn #
        - [Pub] burnFrom #
    
     + [Int] IERC165 
        - [Ext] supportsInterface
    
     +  ERC165 (IERC165)
        - [Int]  #
        - [Pub] supportsInterface
        - [Int] _registerInterface #
    
     + [Int] IERC1363 (IERC20, IERC165)
        - [Ext] transferAndCall #
        - [Ext] transferAndCall #
        - [Ext] transferFromAndCall #
        - [Ext] transferFromAndCall #
        - [Ext] approveAndCall #
        - [Ext] approveAndCall #
    
     +  Roles (AccessControl)
        - [Pub]  #
    
     + [Int] IERC1363Receiver 
        - [Ext] onTransferReceived #
    
     + [Int] IERC1363Spender 
        - [Ext] onApprovalReceived #
    
     +  ERC1363 (ERC20, IERC1363, ERC165)
        - [Pub]  ($)
           - modifiers: ERC20
        - [Pub] transferAndCall #
        - [Pub] transferAndCall #
        - [Pub] transferFromAndCall #
        - [Pub] transferFromAndCall #
        - [Pub] approveAndCall #
        - [Pub] approveAndCall #
        - [Int] _checkAndCallTransfer #
        - [Int] _checkAndCallApprove #
    
     +  ERC20Capped (ERC20)
        - [Pub]  #
        - [Pub] cap
        - [Int] _beforeTokenTransfer #
    
     +  DotTokenContract (ERC20Capped, ERC20Burnable, ERC1363, Roles, TokenRecover, Pausable)
        - [Pub]  #
           - modifiers: ERC20Capped,ERC1363
        - [Pub] transferEnabled
        - [Pub] transfer #
           - modifiers: validDestination,canTransfer,whenNotPaused
        - [Pub] transferFrom #
           - modifiers: validDestination,canTransfer,whenNotPaused
        - [Pub] approve #
           - modifiers: whenNotPaused
        - [Pub] increaseAllowance #
           - modifiers: whenNotPaused
        - [Pub] decreaseAllowance #
           - modifiers: whenNotPaused
        - [Pub] enableTransfer #
           - modifiers: onlyOwner
        - [Int] _beforeTokenTransfer #
           - modifiers: validDestination
     
    							

    Function Graph

    Smart Contract Graph

    Inheritence Chart

    Smart Contract Inheritance

    Functions Overview

    
    
     + [Int] IDotTokenContract 
        - [Ext] balanceOf
        - [Ext] totalSupply
        - [Ext] transfer #
        - [Ext] transferFrom #
        - [Ext] allowance
        - [Ext] approve #
    
     + [Lib] SafeMath 
        - [Int] add
        - [Int] sub
        - [Int] sub
        - [Int] mul
        - [Int] div
        - [Int] div
        - [Int] mod
        - [Int] mod
    
     + [Int] IDoTxLib 
        - [Ext] queryChainLinkPrice #
        - [Ext] fetchFirstDayPrices #
        - [Ext] fetchLastDayPrices #
        - [Ext] setDoTxGame #
        - [Ext] calculateHousePerf
        - [Ext] calculatePercentage
        - [Ext] calculateReward
        - [Ext] getWarIndex
    
     +  Context 
        - [Int]  #
        - [Int] _msgSender
        - [Int] _msgData
    
     +  Ownable (Context)
        - [Int]  #
        - [Pub] owner
        - [Pub] owner2
        - [Pub] setOwner2 #
           - modifiers: onlyOwner
        - [Pub] transferOwnership #
           - modifiers: onlyOwner
    
     +  DoTxGameContract (Ownable)
        - [Pub]  #
        - [Pub] startWar #
           - modifiers: onlyOwner
        - [Pub] buyTickets #
           - modifiers: onlyIfTicketsPurchasable
        - [Pub] switchHouse #
           - modifiers: onlyIfTicketsPurchasable
        - [Pub] claimRewardAndTickets #
           - modifiers: onlyIfCurrentWarFinished
        - [Pub] fetchFirstDayPrices #
           - modifiers: onlyOwner
        - [Pub] fetchLastDayPrices #
           - modifiers: onlyOwner,onlyIfCurrentWarFinished
        - [Pub] selectWinner #
           - modifiers: onlyOwner,onlyIfCurrentWarFinished,onlyIfPricesFetched
        - [Ext] firstHouseOpen #
           - modifiers: onlyDoTxLib
        - [Ext] secondHouseOpen #
           - modifiers: onlyDoTxLib
        - [Ext] firstHouseClose #
           - modifiers: onlyDoTxLib
        - [Ext] secondHouseClose #
           - modifiers: onlyDoTxLib
        - [Prv] openPriceEvent #
        - [Prv] closePriceEvent #
        - [Pub] getUserDoTxInBalance
        - [Pub] getFeesForSwitchHouse
        - [Pub] getUser
        - [Pub] getHouse
        - [Pub] getBurnStake
        - [Pub] getWarsHouses
        - [Pub] setSelectWinnerPrecision #
           - modifiers: onlyOwner
        - [Pub] setStakingBurnPercentageWar #
           - modifiers: onlyOwner
        - [Pub] setStakingBurnPercentage #
           - modifiers: onlyOwner
        - [Pub] setMultiplicatorWar #
           - modifiers: onlyOwner
        - [Pub] setMultiplicator #
           - modifiers: onlyOwner
        - [Pub] withdrawFees #
           - modifiers: onlyOwner
        - [Pub] setDoTxLib #
           - modifiers: onlyOwner
        - [Pub] setStakingAddress #
           - modifiers: onlyOwner
        - [Prv] getHouseStg
        - [Prv] checkIfHouseInCompetition
        - [Pub] getCurrentRewardString
        - [Pub] getCurrentReward
        - [Pub] calculateBurnStaking
        - [Pub] stringToBytes32
        - [Pub] bytes32ToString
    
    							

    Function Graph

    Smart Contract Graph

    Inheritence Chart

    Smart Contract Inheritance

    Functions Overview

    
    
     ($) = payable function
     # = non-constant function
     
     Int = Internal
     Ext = External
     Pub = Public
    
     + [Lib] CBORChainlink 
        - [Prv] encodeType
        - [Prv] encodeIndefiniteLengthType
        - [Int] encodeUInt
        - [Int] encodeInt
        - [Int] encodeBytes
        - [Int] encodeString
        - [Int] startArray
        - [Int] startMap
        - [Int] endSequence
    
     + [Lib] BufferChainlink 
        - [Int] init
        - [Int] fromBytes
        - [Prv] resize
        - [Prv] max
        - [Int] truncate
        - [Int] write
        - [Int] append
        - [Int] append
        - [Int] writeUint8
        - [Int] appendUint8
        - [Prv] write
        - [Int] writeBytes20
        - [Int] appendBytes20
        - [Int] appendBytes32
        - [Prv] writeInt
        - [Int] appendInt
    
     + [Lib] Chainlink 
        - [Int] initialize
        - [Int] setBuffer
        - [Int] add
        - [Int] addBytes
        - [Int] addInt
        - [Int] addUint
        - [Int] addStringArray
    
     + [Int] ENSInterface 
        - [Ext] setSubnodeOwner #
        - [Ext] setResolver #
        - [Ext] setOwner #
        - [Ext] setTTL #
        - [Ext] owner
        - [Ext] resolver
        - [Ext] ttl
    
     + [Int] LinkTokenInterface 
        - [Ext] allowance
        - [Ext] approve #
        - [Ext] balanceOf
        - [Ext] decimals
        - [Ext] decreaseApproval #
        - [Ext] increaseApproval #
        - [Ext] name
        - [Ext] symbol
        - [Ext] totalSupply
        - [Ext] transfer #
        - [Ext] transferAndCall #
        - [Ext] transferFrom #
    
     + [Int] ChainlinkRequestInterface 
        - [Ext] oracleRequest #
        - [Ext] cancelOracleRequest #
    
     + [Int] PointerInterface 
        - [Ext] getAddress
    
     +  ENSResolver_Chainlink 
        - [Pub] addr
    
     + [Lib] SafeMathChainlink 
        - [Int] add
        - [Int] sub
        - [Int] mul
        - [Int] div
        - [Int] mod
    
     +  ChainlinkClient 
        - [Int] buildChainlinkRequest
        - [Int] sendChainlinkRequest #
        - [Int] sendChainlinkRequestTo #
        - [Int] cancelChainlinkRequest #
        - [Int] setChainlinkOracle #
        - [Int] setChainlinkToken #
        - [Int] setPublicChainlinkToken #
        - [Int] chainlinkTokenAddress
        - [Int] chainlinkOracleAddress
        - [Int] addChainlinkExternalRequest #
           - modifiers: notPendingRequest
        - [Int] useChainlinkWithENS #
        - [Int] updateChainlinkOracleWithENS #
        - [Prv] encodeRequest
        - [Int] validateChainlinkCallback #
           - modifiers: recordChainlinkFulfillment
    
     + [Int] IDotxGame 
        - [Ext] firstHouseOpen #
        - [Ext] secondHouseOpen #
        - [Ext] firstHouseClose #
        - [Ext] secondHouseClose #
    
     +  Context 
        - [Int]  #
        - [Int] _msgSender
        - [Int] _msgData
    
     +  Ownable (Context)
        - [Int]  #
        - [Pub] owner
        - [Pub] renounceOwnership #
           - modifiers: onlyOwner
        - [Pub] transferOwnership #
           - modifiers: onlyOwner
    
     +  DoTxLib (ChainlinkClient, Ownable)
        - [Pub]  #
        - [Ext] calculateHousePerf
        - [Pub] calculatePercentage
        - [Pub] calculateReward
        - [Pub] fetchFirstDayPrices #
           - modifiers: onlyDoTxGame
        - [Pub] fetchLastDayPrices #
           - modifiers: onlyDoTxGame
        - [Pub] queryChainLinkPrice #
           - modifiers: onlyDoTxGame
        - [Pub] firstHouseOpen #
           - modifiers: recordChainlinkFulfillment
        - [Pub] secondHouseOpen #
           - modifiers: recordChainlinkFulfillment
        - [Pub] firstHouseClose #
           - modifiers: recordChainlinkFulfillment
        - [Pub] secondHouseClose #
           - modifiers: recordChainlinkFulfillment
        - [Pub] setChainLinkOracleAddress #
           - modifiers: onlyOwner
        - [Pub] setChainJobId #
           - modifiers: onlyOwner
        - [Pub] setOraclePaymentAmount #
           - modifiers: onlyOwner
        - [Pub] withdrawLink #
           - modifiers: onlyOwner
        - [Pub] setDoTxGame #
           - modifiers: onlyOwner
        - [Pub] setRewardPrecision #
           - modifiers: onlyOwner
        - [Pub] getWarIndex
        - [Pub] setWarIndex #
           - modifiers: onlyOwner
        - [Pub] stringToBytes32
        - [Pub] bytes32ToString
        - [Pub] append