Metfi

CertiKFiles named in the report

CertiK reviewed MetFi DAO (Metfi) on 6 Feb 2023: 30 findings, 0 critical; 11 marked fixed, 19 open.

No open critical findings
Open the reportOpen MetFi DAO’s security record

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings30

Statuses are the security firm’s own, from its report.

SeverityOpenAcknowledgedFixed
Critical000
High101
Medium100
Low17010
HighCentralization Related RisksOpen

In `ContractRegistry`, the addresses with `realmGuardians` set to `true` have authority over the following functions: - `setContractAddress`: Change or set the address associated with `name` for the variable `contractAddress` - `setMatrixAddress`: Change or set the address associated with `level` for the variable `matrices` - `addMatrixLevel`: Add a matrix level to the variable `matrices` - `setLiquidityControllerAddress`: Change or set the address associated with `name` for the variable `liquidityControllers` - `setBuybackControllerAddress`: Change or set the address associated with `name` for the variable `buybackControllers` - `setPriceCalcAddress`: Change or set the address associated with `currencyAddress` for the variable `priceCalcAddresses` - `setRealmGuardian`: Change or set an address as a `realmGuardians` - `setCoinMaster`: Change or set an address as a `coinMasters` Furthermore, `ContractRegistry` serves as the access control for all contracts within the audit scope. The roles include `router`, `treasury`, `token_collector`, `reward_distributor`, `staking_manager`, `token_collector`, `treasury_extender`, `account_token`, and address in `coinMasters`. Any compromise to a `realmGuardians` account will allow the malicious actor to take advantage of this authority and change the value of sensitive state variables and addresses used across the platform for access control. The malicious actor can then call functions such as `getLostTokens` and/or `destroyContract` to steal all the tokens and ethers owned by the contracts.

MediumUsing PancakeSwap Reserves As Price FeedOpen

According to the code implementation, the price of MFI is directly calculated via "reserves" from PancakeSwap Pair. i.e., `(uint256 reserve0, uint256 reserve1,) = pancakePair.getReserves();`, which can be affected by on-chain swapping. For example, the amount of MFI tokens that can be minted is calculated via the following code snippet: ```solidity=59 function getBonusTokens(uint256 busdPrice) public onlyRouter override returns (uint256) { IPriceCalculator priceCalc = IPriceCalculator(contractRegistry.getPriceCalculator(contractRegistry.getContractAddress(MFI_HASH))); IERC20 MFI = IERC20(contractRegistry.getContractAddress(MFI_HASH)); address to = contractRegistry.getContractAddress(STAKING_MANAGER_HASH); uint256 tokensForPrice = priceCalc.tokensForPrice(busdPrice); uint256 tokensFromSwap = (tokensForPrice * bonusTokenPercentageFromSwap) / 100; uint256 tokensToMint = tokensForPrice - tokensFromSwap; if (tokensToMint > 0) { MetFi(address(MFI)).mint(to, tokensToMint); } ... ``` The price of the MFI token is calculated via the function `tokensForPrice()`, whose logic is specified in the `PriceCalculator.sol`: ```solidity=87 function tokensForPrice(uint256 reserveTokenAmount) public override view returns (uint256) { if(!contractRegistry.contractAddressExists(PANCAKE_ROUTER_HASH)) return reserveTokenAmount; IPancakeRouter02 pancakeRouter = IPancakeRouter02(contractRegistry.getContractAddress(PANCAKE_ROUTER_HASH)); IPancakeFactory factory = IPancakeFactory(pancakeRouter.factory()); IPancakePair pancakePair = IPancakePair(factory.getPair(stableTokenAddress, calculatedToken)); if (address(pancakePair) == address(0)) { return reserveTokenAmount; } address token0 = pancakePair.token0(); (uint256 reserve0, uint256 reserve1,) = pancakePair.getReserves(); uint256 calculatedTokenReserve; uint256 reserveTokenReserve; (calculatedTokenReserve, reserveTokenReserve) = calculatedToken == token0 ? (reserve0, reserve1) : (reserve1, reserve0); require(calculatedTokenReserve > 0 && reserveTokenReserve > 0, 'No liquidity in pool'); uint256 amountInWithFee = reserveTokenAmount * 9975; uint256 numerator = amountInWithFee * calculatedTokenReserve; uint256 denominator = (reserveTokenReserve * 10000) + amountInWithFee; return numerator / denominator; } ``` As the code implementation shows above, the price of MFI is directly calculated via "reserves" from PancakeSwap Pair. i.e., `(uint256 reserve0, uint256 reserve1,) = pancakePair.getReserves();`. Therefore, the value of `reserve0` and `reserve1` can be updated by swapping, thus affecting the price of MFI. In this case, it will inflate the amount of MFI tokens that can be minted. The price calculation in the `PriceCalculator.sol` is based on reserves in the PancakeSwap and the affected functions are shown below: - `getPriceInUSD()` - `tokensForPrice()` - `priceForTokens()`

LowCheck Effect Interaction Pattern ViolatedOpen

The order of external call/transfer and storage manipulation must follow the check-effect-interaction pattern. If an external call is made before storage is updated, it could potentially lead to a reentrancy attack.

LowConfusing Function NameOpen

The function `getTokensForCollector` transfers a specified amount of tokens to a specified address. Typically functions with function names starting from "get" are non-state modifying functions.

LowFunction Visibility OptimizationOpen

The following functions are declared as `public` despite not being invoked in any of the contracts contained within the project's scope. The functions that are never called internally should have `external` visibility. - `ERC20TreasuryFundsLock.returnFundsToTreasury` - `MetFiVoteCalculator.availableVotes` - `MetFiVoteCalculator.availableVotesForNFT` - `ContractRegistry.contractAddressExists` - `ContractRegistry.matrixExists` - `ContractRegistry.liquidityControllerExists` - `ContractRegistry.buybackControllerExists` - `ContractRegistry.priceCalculatorExists` - `ContractRegistry.getContractAddress` - `ContractRegistry.getMatrix` - `ContractRegistry.getLiquidityController` - `ContractRegistry.getBuybackController` - `ContractRegistry.getPriceCalculator` - `ContractRegistry.isCoinMaster` - `ContractRegistry.setContractAddress` - `ContractRegistry.setMatrixAddress` - `ContractRegistry.addMatrixLevel` - `ContractRegistry.setLiquidityControllerAddress` - `ContractRegistry.setPriceCalcAddress` - `ContractRegistry.setRealmGuardian` - `ContractRegistry.setCoinMaster` - `Treasury.getTotalRewardsPaid` - `Treasury.getValue` - `Treasury.onERC721Received` - `TokenCollector.getBonusTokens` - `TokenCollector.getTokens` - `TokenCollector.getCollectionType` - `TokenCollector.getPriceCalculationType` - `TokenCollector.getAdditionalTokensPercentage` - `TokenCollector.setCollectionType` - `TokenCollector.setPriceCalculationType` - `TokenCollector.setAdditionalTokensPercentage` - `TokenCollector.setBonusTokenPercentageFromSwap` - `TokenCollector.getLostTokens` - `TokenCollector.destroyContract` - `RewardDistributor.getAccountInfo` - `RewardDistributor.createAccount` - `RewardDistributor.accountUpgraded` - `RewardDistributor.liquidateAccount` - `RewardDistributor.distributeRewards` - `RewardDistributor.getLostTokens` - `RewardDistributor.setBonusActivationTimeOut` - `RewardDistributor.destroyContract` - `Router.createAccount` - `Router.createAccountWithReferral` - `Router.setReferralLink` - `Router.liquidateAccount` - `Router.cancelLiquidation` - `Router.stakeTokens` - `Router.buyTokens` - `Router.totalLevels` - `PancakeSwapBuybackController.buyBackMFI` - `PancakeSwapBuybackController.getLostTokens` - `PancakeSwapBuybackController.destroyContract` - `PancakeSwapLiquidityController.getLPTokenAddress` - `PancakeSwapLiquidityController.claimableTokensFromTreasuryLPTokens` - `PancakeSwapLiquidityController.mfiRequiredForProvidingLiquidity` - `PancakeSwapLiquidityController.provideLiquidity` - `PancakeSwapLiquidityController.removeLiquidity` - `PancakeSwapLiquidityController.destroyContract` - `EmptyTreasuryExtender.getValue` - `EmptyTreasuryExtender.getLostTokens` - `EmptyTreasuryExtender.destroyContract` - `PriceCalculator.exchangePairSet` - `PriceCalculator.getReserves` - `PriceCalculator.getPriceInUSD` - `PriceCalculator.tokensForPrice` - `PriceCalculator.priceForTokens` - `PriceCalculator.destroyContract` - `UnstakedNFTs.mintUnstakedTokens` - `UnstakedNFTs.tokenURI` - `UnstakedNFTs.supportsInterface` - `UnstakedNFTs.getLostTokens` - `PlatformView.getWalletData` - `PlatformView.getReferralCodeData` - `PlatformView.referralLinkExists` - `PlatformView.getMFIPrice` - `PlatformView.getPlatformData` - `PlatformView.getTreeData` - `PlatformView.stakedTokensForAddress` - `PlatformView.getLostTokens` - `PlatformView.destroyContract` - `Matrix.getUsersInLevels` - `Matrix.getDistributionNodes` - `Matrix.addNode` - `Matrix.getNode` - `Matrix.getSubtreeNode` - `Matrix.getSubNodesToLevel` - `Matrix.getLostTokens` - `Matrix.destroyContract` - `AccountToken.createAccount` - `AccountToken.setReferralLink` - `AccountToken.upgradeAccountToLevel` - `AccountToken.getAddressNFTs` - `AccountToken.getLiquidationInfo` - `AccountToken.requestLiquidation` - `AccountToken.liquidateAccount` - `AccountToken.cancelLiquidation` - `AccountToken.getAccountLevel` - `AccountToken.getAccountDirectlyEnrolledMembers` - `AccountToken.getAccountReferralLink` - `AccountToken.getAccountByReferral` - `AccountToken.referralLinkExists` - `AccountToken.getLevelMatrixParent` - `AccountToken.getDirectUplink` - `AccountToken.getAverageAPY` - `AccountToken.totalMembers` - `AccountToken.getLostTokens` - `AccountToken.destroyContract` - `AccountToken.setLiquidationPeriods` - `StakingManager.createStakingAccount` - `StakingManager.liquidateAccount` - `StakingManager.addTokensToStaking` - `StakingManager.upgradeStakingAccountToLevel` - `StakingManager.timeToNextRebase` - `StakingManager.nextRebaseAt` - `StakingManager.rebase` - `StakingManager.totalLevels` - `StakingManager.enterLiquidation` - `StakingManager.destroyContract` - `StakingManager.getLostTokens`

LowHardcoded Value For Minted TokensOpen

```solidity=131 uint256 valueFromSwap = (busdPrice * 85) / 100; uint256 minTokensOutSwap = (minTokensOut * 85) / 100; ``` ```solidity=153 uint256 tokensToMint = (receivedTokens * 15) / 85; //Mint 15% of tokens to staking manager MetFi(address(MFI)).mint(to, tokensToMint); ``` The amount to be minted to cover costs and rewards is a hard-coded percentage. In the case that this figure needs to be changed, the contract might need to be updated and re-deployed.

LowInconsistency Between Whitepaper and CalculatingOpen

This issue is related to the implementation of the number of NFTs that a user can hold. Based on the assumption from the whitepapers that each user must purchase a certain level and all the NFT levels preceding that level, this would create a few issues. Firstly, this would mean that the function `availableVotesForNFT()` will be run for every level NFT that the user holds, compounding the weighted votes for each level. This could be an issue, especially for the few users who hold the relatively higher levels (especially in the earlier stages where there are fewer users). This could present a centralization issue where whales who hold the highest NFT levels and hold large amounts of MFI can possibly have more control over voting. Another issue that arises is checking for NFT levels that are purchased on secondhand markets. The current implementation for account creation and upgrading levels seems to only deem the latest and highest level as being valid. If this is the expected implementation, then users can purchase other levels from secondhand markets and effectively compound their votes as long as all the NFTs are categorized under the same address. This is another way users can artificially game the system to inflate their votes.

LowLack of Input ValidationOpen

According to the documentation, there are 10 NFT levels. However, no input validation is available for the length of `_levelSettings`.

LowLack of Input ValidationOpen

According to the documentation, there are 10 NFT levels. However, no input validation is available for the length of `_rebaseMultipliers`. Furthermore, if the multiplier is greater than 1000000000, line 161 will revert due to an underflow.

LowMisleading Value After BurnOpen

The value of `mfiTotalMembers` is not adjusted when an NFT is burnt. Although `mfiTotalMembers` is not used in any calculation, not having the value adjusted will only continue to increase the value of `mfiTotalMembers` and mislead users into believing that there are more active users than there really are.

Show 9 more
LowMisleading Value After BurnOpen

The value of `totalAPY` is not adjusted when an NFT is burnt. As a result, the value returned by calling the function `getAverageAPY` will increase since the total supply will decrease after an NFT is burnt. Although `totalAPY` is not used in the calculation for any critical functionalities, it can mislead users to believe the APY is higher than it actually is.

LowUnknown Purpose: the Detailed Design of `EmptyTreOpen

`Treasury Extender` is created to manage any new tokens the `Treasury` wishes to add where the `EmptyTreasuryExtender.sol` acts as a template for the contracts of `Treasury Extenders`. Since the audit team does not know the actual detailed design of the Treasury Extenders, it is assumed that the developer can implement any logic in these extenders. The function `getValue()` in `EmptyTreasuryExtender.sol` can be used in `Treasury.sol` contract and will always return (0, 0) for the `riskFreeValue` and `totalValue`. Moreover, according to the function `manage()` in `Treasury.sol`, `Treasury Extender` can transfer any token to any address.

LowUnnecessary Condition CheckingOpen

Since `parentLeg` is a `uint256` data type, checking `parentLeg >= 0` is unnecessary since it will always evaluate as true.

LowUnused EventOpen

Although `ITreasuryExtender` is imported in `EmptyTreasuryExtender.sol` and `Treasury.sol`, the events are not used anywhere.

LowUnused EventOpen

The following events are not used in `IRewardDistributor` are unused: - `AccountCreated` - `AccountUpgraded` - `AccountLiquidated`

LowUnused ImportOpen

`IMatrix.sol` is imported despite not being used.

LowUnused ImportOpen

`ITreasuryAllocator.sol` is imported despite not being used.

LowUnused ImportOpen

`Ownable.sol` is imported despite not being used.

LowUnused SafeERC20Open

Despite `SafeERC20` being imported and attached to `IERC20`, the functions are not used.

Contracts in scope

No deployed address is recorded for this audit.

The report names a repository or files. Open the report to see its scope.

Repository and files the report names (42)

  • interfaces/ITreasury.sol
  • PlatformView.sol
  • other/ERC20TreasuryFundsLock.sol
  • Router.sol
  • voting/MetFiVoteCalculator.sol
  • interfaces/IContractRegistry.sol
  • side_utils/PancakeFactory.sol
  • interfaces/IPancakeRouter02.sol
  • side_utils/PancakeRouter.sol
  • PancakeSwapBuybackController.sol
  • interfaces/ILiquidityController.sol
  • interfaces/IPancakeFactory.sol
  • interfaces/IPlatformView.sol
  • interfaces/IRewardDistributor.sol
  • interfaces/IMatrix.sol
  • StakingManager.sol
  • interfaces/ITreasuryExtender.sol
  • interfaces/IAccountToken.sol
  • UnstakedNFTs.sol
  • PancakeSwapLiquidityController.sol
  • interfaces/IRouter.sol
  • interfaces/IStakingManager.sol
  • ContractRegistry.sol
  • Treasury.sol
  • PriceCalculator.sol
  • interfaces/IUnstakedNFTMinter.sol
  • interfaces/IERC2981.sol
  • interfaces/IAllocationProvider.sol
  • MFI.sol
  • interfaces/IBuybackController.sol
  • interfaces/ILostTokenProvider.sol
  • TokenCollector.sol
  • interfaces/IPriceCalculator.sol
  • AccountToken.sol
  • interfaces/ITreasuryAllocator.sol
  • interfaces/IDestroyableContract.sol
  • interfaces/IPancakeRouter01.sol
  • EmptyTreasuryExtender.sol
  • interfaces/ITokenCollector.sol
  • interfaces/IPancakePair.sol
  • Matrix.sol
  • RewardDistributor.sol

Part of MetFi DAO’s security record

MetFi DAO
Audits4 audits by 1 firmLast audit Feb 2024, by CertiK.
Critical findingsNo open critical findingsAcross the 4 reports, 1 critical finding was reported. It is marked fixed by the firm that reported it.
Open MetFi DAO’s security record

Security firm

CertiK

1,045 projects reviewed · 1,376 reports · latest May 2025

See CertiK’s audits

Something wrong on this page? A missing report, a wrong date, a finding that was fixed since. Tell us and we check it against its source.

Tell us