MetFi DAO has 4 public audit reports from CertiK; the latest is CertiK, 1 Feb 2024; 1 critical finding, marked fixed by the firm.
Last updated . It holds audits and findings, contracts and incidents up to Nov 2026. Trustblock does not review code.
Statuses are the security firms’ own
45 findings are still open or acknowledged in the firms’ reports: 7 high, 6 medium, 32 low (41 open, 4 acknowledged).
Centralization Related Risks In Lending Module
Metfi Audit 4 · CertiK · 1 Feb 2024 · Report ↗
Centralization Related Risks In MetFiQuiz Module
Metfi Audit 4 · CertiK · 1 Feb 2024 · Report ↗
Potential Price Manipulation Attack that Bypasses
Metfi Audit 4 · CertiK · 1 Feb 2024 · Report ↗
Centralization Related Risks in MetFiNFTMarket Mo
Metfi Audit 2 · CertiK · 22 Mar 2023 · Report ↗
Centralization Related Risks in PayoutController
Metfi Audit 2 · CertiK · 22 Mar 2023 · Report ↗
Centralization Related Risks In UserConfig Module
Metfi Audit 2 · CertiK · 22 Mar 2023 · Report ↗
Centralization Related Risks
Metfi · CertiK · 6 Feb 2023 · Report ↗
Inconsistency Risk due to Primary Stable Coin Dec
Metfi Audit 4 · CertiK · 1 Feb 2024 · Report ↗
Potential False Liquidation Caused By Price Manip
Metfi Audit 4 · CertiK · 1 Feb 2024 · Report ↗
Potential Sandwich Attacks In `liquidateLoan()` F
Metfi Audit 4 · CertiK · 1 Feb 2024 · Report ↗
Newest first
| Report | Security firm | Date | Scope | Critical findings | Findings | Source |
|---|---|---|---|---|---|---|
| Metfi Audit 4 | Security firm: CertiK | Date: | Scope: Files listed | None open | Findings: 9 high · 10 medium · 23 low 26 fixed · 4 acknowledged · 12 open | skynet.certik.com ↗ |
| Metfi 3 | Security firm: CertiK | Date: | Scope: Files listed | 1 critical finding, fixed | Findings: 1 critical · 2 medium · 19 low 16 fixed · 6 open | skynet.certik.com ↗ |
| Metfi Audit 2 | Security firm: CertiK | Date: | Scope: Files listed | None open | Findings: 4 high · 11 low 11 fixed · 4 open | skynet.certik.com ↗ |
| Metfi | Security firm: CertiK | Date: | Scope: Files listed | None open | Findings: 2 high · 1 medium · 27 low 11 fixed · 19 open | skynet.certik.com ↗ |
Statuses are the security firm’s own, from each report.
| Severity | Open | Acknowledged | Fixed |
|---|---|---|---|
| Critical | 0 | 0 | 1 |
| High | 7 | 0 | 8 |
| Medium | 2 | 4 | 7 |
| Low | 32 | 0 | 48 |
### Lending Contract In the `Lending` contract, the following roles have authority over specific functions: - `LendingManager` - `setLendingConfiguration()`: Sets the lending configuration. - `setLendingManager()`: Assigns or removes the lending manager role from a given address. - `setBlackList()`: Allows the lending manager to manage the account blacklist. - `setApprovedCollateralCurrency()`: Allows the lending manager to add to or remove from the list of approved currencies for use as collateral in lending operations. - `setFailsafe()`: A safety switch that allows the Lending Manager to stop all lending activities until the issue is resolved. - `setFailsafePermanent()`: A safety feature that allows the Lending Manager to permanently stop all lending activities if a serious issue occurs. - `RealmGuardian` - `migrateToNewLendingContract()`: Migrates all active lending information and related assets to a new lending contract. - `Treasury` - `getLostTokens()`: Allows the Treasury contract to withdraw tokens from the contract. This will mostly be used to recover any lost or stuck tokens in the contract. Any compromise to the `LendingManager`, `Treasury`, `RealmGuardian` may allow the attacker to take advantage of their respective authorities and can potentially lead to security risks. ***The `LendingManager` role has the ability to manage lending configurations, manage the user blacklist, and halt all lending activities in the case of emergencies.*** ***The `Treasury` role has the authority to withdraw tokens from the contract. It is important to note that the `Treasury` role can only be designated by the `RealmGuardian` through the `ContractRegistry` contract. As a result, an attacker can use the `RealmGuardian` role to cause damage to the project through misuse of the `Treasury` role.*** ### LendingAuction Contract In the `LendingAuction` contract, the following roles have authority over specific functions: - `AuctionManager` - `setAuctionConfiguration()`: Sets the Auction configuration. - `setAuctionManager()`: Assigns or removes the auction manager role from a given address. - `setBlackList()`: Allows the auction manager to manage the account blacklist. - `setFailsafe()`: A safety switch that allows the Auction Manager to stop all lending activities until the issue is resolved. - `setFailsafePermanent()`: A safety feature that allows the Auction Manager to permanently stop all lending activities if a serious issue occurs. - `RealmGuardian` - `migrateToNewAuctionContract()`: Migrates all NFTs in this contract to a new Auction contract. - `Treasury` - `getLostTokens()`: Allows the Treasury contract to withdraw tokens from the contract. This will mostly be used to recover any lost or stuck tokens in the contract. Any compromise to the `LendingManager`, `Treasury`, `RealmGuardian` may allow the attacker to take advantage of their respective authorities and can potentially lead to security risks. ***The `AuctionManager` has the ability to manage auction configurations, manage the user blacklist, and halt all lending activities in the case of emergencies.*** ***The `Treasury` role has the authority to withdraw tokens from the contract. It is important to note that the `Treasury` role can only be designated by the `RealmGuardian` through the `ContractRegistry` contract. As a result, an attacker can use the `RealmGuardian` role to cause damage to the project through misuse of the `Treasury` role.*** --- **Potential Discrepancy Between Snapshot Voting Results and Executed Actions in DAO Governance** Despite using the Snapshot Platform for voting, the DAO's Multisig Manager contract includes a potential centralization risk. While Snapshot enables decentralized voting, the execution of the resulting actions is dependent on the `multiSigAccounts` assigned by the constructor. ```solidity constructor(ContractRegistry _contractRegistry, MultiSigAccount[] memory _multiSigAccounts, uint256 _signaturesRequired) EIP712("MultiSigMetFiManagerV4", "1") ContractRegistryAdmin(_contractRegistry) { for (uint256 x = 0; x < _multiSigAccounts.length; x++) { multiSigAccounts.push(_multiSigAccounts[x]); } require(_signaturesRequired < _multiSigAccounts.length, "You can't require 100% or more signatures"); signaturesRequired = _signaturesRequired; nextQueuedActionID.increment(); } ... function queueAction(Action memory action, bytes[] memory signatures, uint256 deadline) public { ... require(signatures.length >= signaturesRequired, "Not enough signatures"); require(block.timestamp < deadline, "Deadline exceeded"); verifySignatures(action.actionType, deadline, action.data, signatures, action.requestId); action.executionAvailableTime = block.timestamp + timeLockTime; action.executed = false; action.creator = msg.sender; allActions[actionId] =
Open the reportIn the `MetfiQuiz` contract, the following roles have authority over specific functions: - `RealmGuardian`: - `setAnswerOracle()`: Sets a new answer oracle and determines whether it is enabled or disabled. - `setSubscriptionId()`: Sets a new Chainlink VRF subscription ID. - `setConfig()`: Sets the configuration for the `MetFiQuiz` contract. - `endQuiz()`: Ends the quiz after the current round. - `AnswerOracles`: - `recordAnswer()`: Records the answer for a batch of tickets and whether the answer is correct or incorrect. - `Treasury` - `getLostTokens()`: Allows the Treasury contract to withdraw tokens from the contract. This will mostly be used to recover any lost or stuck tokens in the contract. Any compromise to the `RealmGuardian` and `AnswerOracles` may allow the attacker to take advantage of their respective authorities and can potentially lead to security risks. ***The `AnswerOracles` role has the ability to record answers for a group of tickets and whether the answer is correct or incorrect. This means that an attacker can take advantage of the authority of answer oracles to alter the outcome by determining the validity of answers submitted.*** ***The `Treasury` role has the authority to withdraw tokens from the contract. It is important to note that the `Treasury` role can only be designated by the `RealmGuardian` through the `ContractRegistry` contract. As a result, an attacker can use the `RealmGuardian` role to cause damage to the project through misuse of the `Treasury` role.*** ***The audit team strongly advises clients to mitigate this risk by applying decentralization and promoting transparency in future endeavors***.
Open the reportThe reliance on values extracted from liquidity pools, which can be manipulated by attackers, can potentially lead to project losses due to the inflation of collateral amounts allowing attackers to borrow more than normally allowed based on their underlying collateral of staked `METFI` tokens. The function `calculateLoanPercentageOfStakedMETFIValue()` determines the loan amount by comparing it to the value of staked `METFI` tokens. This value is obtained through `PancakeSwap.getAmountsOut()`, which means that an attacker could temporarily inflate the price of METFI in the same transaction using a flash loan, enabling them to bypass collateral checks and secure a larger loan than their collateral would normally permit. Moreover, it should be noted that the `checkLoanForInvalidation()` function within the `LendingCalculator` contract does not verify if the staked METFI meets the necessary collateral requirements. ```solidity function checkLoan(CreateLoanRequest calldata request, address msgSender) external view override { ... if ( getLendingCalculator().calculateLoanPercentageOfStakedMETFIValue(request.amount + interest, request.tokenId) > lendingConfiguration.creationLoanPercentageOfStakedValue ) { revert NotEnoughCollateral(); } ... } function calculateLoanPercentageOfStakedMETFIValue(uint256 outstandingLoanAmount, uint256 tokenId) external view override returns (uint256) { address[] memory path = new address[](2); path[0] = contractRegistry.getContractAddress(METFI_HASH); path[1] = address(getPrimaryStableCoin()); uint256 metfiValue = pancakeRouter.getAmountsOut( IStakingManagerV2(contractRegistry.getContractAddress(STAKING_MANAGER_HASH)).getAccountTokens(tokenId), path )[1]; if (metfiValue == 0) return 0; return ((outstandingLoanAmount * 1_000_000) / (metfiValue)); } ``` This attack could result in the protocol issuing undercollateralized loans, which could lead to insolvency if not addressed.
Open the reportIn the contract **MetFiNFTMarket**, the roles **_owner** and **FeeManager** have authorities over the functions: - `setPaymentCurrency()` to update the `paymentCurrencies` state for the input address `currency`; - `setTreasuryRoyaltiesPerCurrency()` to set the `treasuryRoyaltiesPerCurrency` value for the input address `currency`; - `setMarketRoyaltiesPerCurrency()` to set the `marketRoyaltiesPerCurrency` value for the input address `currency`; - `setFeeManger()` to update the `feeManager` state for the input address `manager`; - `setContractRegistry()` to set the input `registry` as the new `contractRegistry`; - `destroyContract()` to destroy the contract associated with the input `to`; - `collectFees()` to transfer all the balance of `MetFiNFTMarket` to the address associated with the input `destination`. Any compromise to the privileged accounts may allow a hacker to take advantage of this authority, modify the sensitive state variables and transfer the tokens from the project to the malicious account.
Open the reportIn the contract **MonthlyPayoutController**, the roles **_owner** and **receiver** have authorities over the following functions: - `destroy()` to destroy the account associated with `msg.sender`. - `doThePayout()` to make a payout for the receiver. --- In the contract **CommunityManagerPayoutController**, the role **RealmGuardian** has authority over the following functions: - `doThePayout()` to make a payout for the `RealmGuardian`. - `destroy()` to destroy the account associated with `msg.sender`. Any compromise to these privileged accounts may allow a hacker to take advantage of the authorities and cause unexpected consequences to the project.
Open the reportIn the contract **UserConfig**, the role **RealmGuardian** has authority over the functions: - `addAllowedStringValueKey()` to add a new value associated with `key` to `allowedStringValueKeys`. - `addAllowedUintValueKey()` to add a new value associated with `key` to `allowedUnitValueKeys`. Any compromise to the `RealmGuardian` account may allow a hacker to take advantage of this authority and add allowed keys.
Open the reportIn `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.
Open the reportWhen transferring deflationary ERC20 tokens, the input amount may not be equal to the received amount due to the charged transaction fee. For example, if a user sends 100 deflationary tokens (with a 10% transaction fee), only 90 tokens actually arrived to the contract. However, a failure to discount such fees may allow the same user to withdraw 100 tokens from the contract, which causes the contract to lose 10 tokens in such a transaction. Reference: https://thoreum-finance.medium.com/what-exploit-happened-today-for-gocerberus-and-garuda-also-for-lokum-ybear-piggy-caramelswap-3943ee23a39f ### RewardConverter ```solidity=36 primaryStableCoin.safeTransferFrom(msg.sender, address(this), amount); ``` - Transferring tokens by `amount`. ```solidity=29 try pancakeRouter.getAmountsOut(amount, path) returns (uint256[] memory amountsOut) { amountOut = amountsOut[1]; } catch { primaryStableCoin.safeTransferFrom(msg.sender, getAccountToken().ownerOf(nftId), amount); return; } ``` - The `amount` appears to be used for bookkeeping purposes without compensating the potential transfer fees. - Note: `getAmountsOut` is an external function and its behavior wasn't evaluated. ### TreasuryV2 ```solidity=213 IERC20(tokenToUse).safeTransfer(address(controller), amount); ``` - Transferring tokens by `amount`. ```solidity=215 controller.provideLiquidity(tokenToUse, amount, minMETFI); ``` - The `amount` appears to be used for bookkeeping purposes without compensating the potential transfer fees. - Note: `provideLiquidity` is an external function and its behavior wasn't evaluated. --- ```solidity=241 lpToken.safeTransfer(address(controller), lpTokenAmount); ``` - Transferring tokens by `lpTokenAmount`. ```solidity=243 controller.removeLiquidity(tokenToUse, lpTokenAmount, tokenMin); ``` - The `lpTokenAmount` appears to be used for bookkeeping purposes without compensating the potential transfer fees. - Note: `removeLiquidity` is an external function and its behavior wasn't evaluated. --- ```solidity=274 IERC20(token).safeTransferFrom(msg.sender, address(this), amount); ``` - Transferring tokens by `amount`. ```solidity=272 uint256 tokenValue = priceCalculator.tokensForPrice(amount); ``` - The `amount` appears to be used for bookkeeping purposes without compensating the potential transfer fees. - Note: `tokensForPrice` is an external function and its behavior wasn't evaluated. --- ```solidity=290 token.safeTransfer(address(buybackController), tokenAmount); ``` - Transferring tokens by `tokenAmount`. ```solidity=291 buybackController.buyBackMFI(tokenAddress, tokenAmount, minMETFIOut); ``` - The `tokenAmount` appears to be used for bookkeeping purposes without compensating the potential transfer fees. - Note: `buyBackMFI` is an external function and its behavior wasn't evaluated.
Open the reportAccording 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()`
Open the reportThe contract utilizes a `liquidationGracePeriod`, a period after which a loan in danger of under-collateralization can be liquidated. While this allows borrowers time to add more collateral or repay a portion of their loan, it does not consider scenarios where the collateral's value could drastically drop during this grace period. In such cases, this could lead to the loan being severely under-collateralized by the time liquidation occurs, thus causing financial loss to the lender. If the value of the collateral falls significantly during the `liquidationGracePeriod`, the amount recovered from the liquidation might not cover the outstanding loan. This would lead to a financial loss for the lender. In an extreme case, a significant market crash could render the collateral valueless before liquidation, leading to a total loss of the loan amount.
Open the reportThe `addCollateral()` function is vulnerable to incorrect collateral amount calculations when deflationary tokens are used as collateral. Deflationary tokens are tokens that burn or reduce a certain percentage of the tokens involved in a transfer operation. As a result, the actual amount of tokens transferred from the borrower to the contract would be less than the `request.amount`. The current implementation assumes that the full `request.amount` of tokens are transferred to the contract, and this amount is used to update the loan collateral value. This is not always the case when dealing with deflationary tokens. Specifically, the line `currentLoan.additionalCollateralAmounts[i] += request.amount;` is responsible for adding the `request.amount` to the current collateral value of the loan. This could lead to an over-estimation of the collateral's value in case of deflationary tokens, which can create risk and instability for the entire loan system.
Open the reportThe `checkLendingConfig()` function lacks some validation checks for all fields in the `LendingConfiguration` struct. Consequently, several fields can contain invalid values that could lead to unexpected behavior or potential attacks. - `treasuryInterestPercentage` should be less than or equal to 10,000 (100%). - `foreignCurrencyExchangeFeePercentage` should be less than or equal to 1,000,000 (100%). - Maximum allowable value for `loanExtensionFeeInBNB` and `loanLiquidationFeeInSelectedStablecoin`. - `liquidationFeePayoutCurve` should have all values between 0 and 1000 (100%).
Open the reportThe `shareOfLoan` is calculated as `(fundedAmount * SHARE_MULTIPLIER) / currentLoan.amount`. This `calculation` may lead to an issue if `fundedAmount` is significantly less than `currentLoan.amount`. Given the nature of integer division in Solidity, this could lead to rounding issues and the resulting `shareOfLoan` may end up being zero.
Open the reportIn the current implementation of contract `Router`, `tx.origin` is frequently used in checks, which is used to prevent potential flashloan attacks and reentrancy issues. `tx.origin` check will be no longer be valid after EIP-3074 is added. EIP3074 introduces two EVM instructions `AUTH` and `AUTHCALL`. The first instruction `AUTH` sets a context variable authorized address based on an ECDSA signature. The second instruction `AUTHCALL` sends a call as the authorized address. This essentially delegates control of the EOA to a smart contract. This means there will be a way for malicious smart contracts to send transactions in the context of `owner`, thus bypassing this check. Also, `tx.origin` is widely discouraged as there are possible phishing attempts and may also block wallet contracts from using the products.
Open the reportThe `migrateToNewAuctionContract` function does not fully migrate all the necessary information associated with an auction when migrating active auctions to a new contract. Specifically, only the `tokenId` of the auction is transferred to the new contract, while critical information such as `currentBid` and `currentBidder` remain in the old contract. This could potentially lead to a loss of critical auction data during the migration, disrupting active auctions, and causing losses for bidders.
Open the reportIn the current implementation of the `invalidateLoan()` function, there is a potential for a loss of precision which could result in a minor amount of funds remaining locked in the contract. Similar issues are present in the `removeFund()` function. The issue lies in the calculation of the amount of stablecoin to be refunded to each lender during the loan invalidation process. ```solidity=840 // Return funded amounts to lenders for (uint256 i = 0; i < currentLoan.lenderInfo.length; i++) { selectedStableCoin.safeTransfer( currentLoan.lenderInfo[i].lender, (currentLoan.lenderInfo[i].shareOfLoan * currentLoan.amount) / SHARE_MULTIPLIER ); } ``` Due to the way integer division is handled in Solidity, if `shareOfLoan * currentLoan.amount` is not a multiple of `SHARE_MULTIPLIER`, the result of the division will be rounded down to the nearest integer. This may cause the actual amount transferred to be less than the intended amount, with the remainder becoming inaccessible within the contract.
Open the reportThe lack of access controls around functions executing swaps between the contract and decentralized liquidity pools can lead to the loss of funds through manipulation by attackers. The `QuizKeeperFinalizer` contract will be utilized to trigger the `finalizeRound()` once the `randomNumbersReceived` is `true`. Additionally, the `checkUpkeep()` function will calculate the `minPotSize` to prevent potential price slippage or sandwich attacks when calling `finalizeRound()`. ```solidity=13 function checkUpkeep(bytes calldata) external view override returns (bool upkeepNeeded, bytes memory performData) { (bool canBeEnded, uint256 minPotSize) = getMetFiQuiz().canRoundBeFinalizedWithMinPotSize(); return (canBeEnded, abi.encode(minPotSize)); } function performUpkeep(bytes calldata performData) external override { getMetFiQuiz().finalizeRound(abi.decode(performData, (uint256))); } ``` However, since there is no access control to the `performUpkeep()` function, everyone can call the `finalizedRound()` directly and set the `minPotSize` to any value. Therefore, in theory, when the `minPotSize` is set to zero and the `primaryStableCoin.balanceOf(address(this))` is large enough, attackers can perform a sandwich attack targeting the `pancakeRouter.swapTokensForExactTokens()` in the function, which is executed to exchange the primary stablecoin for the required `METFI` tokens. A sandwich attack typically targets decentralized exchanges (like PancakeSwap) and exploits the price slippage that occurs when placing a large trade. Attackers manipulate token prices by placing a large buy order (front-running the target transaction) and then a large sell order after the target transaction has executed. This results in the victim paying a higher price for the tokens, while the attacker profits from the price manipulation.
Open the reportDepending on their level, users can use a certain defined percentage of METFI tokens in place of USDC to pay for the purchase of tickets which can potentially result in a decrease in their winning percentage. The `buyTickets()` function enables METFI NFT holders to use their METFI as a substitute for USDC when purchasing tickets. As a result, users will transfer a smaller amount of USDC to the contract. For instance, a level 9 NFT holder can pay for 10% of the ticket price using their METFI, and subsequently **transfers only 90% of the ticket price to the contract**. ```solidity if (useMETFIPercentage > (nftLevel + 1) * 1e3) { revert useMETFIPercentageTooHigh(useMETFIPercentage, (nftLevel + 1) * 1e3); } else if (useMETFIPercentage > 0) { uint256 metfiAmountOfPrice = totalTicketsPrice * useMETFIPercentage / 1e5; primaryStableCoinPrice -= metfiAmountOfPrice; IStakingManagerV3 stakingManager = getStakingManager(); uint256 metfiAmount = getPriceCalculator(contractRegistry.getContractAddress(METFI_HASH)).tokensForPrice(metfiAmountOfPrice); if (metfiAmount > stakingManager.getAccountTokens(nftId)) { revert NotEnoughMETFIInStaking(stakingManager.getAccountTokens(nftId), metfiAmount); } stakingManager.claimTokensFromAccount(nftId, metfiAmount, address(getBurnController())); getBurnController().burnExisting(); boughtTicketsInfo[newBatchId].spentMETFI = metfiAmount; } primaryStableCoin.safeTransferFrom(msg.sender, address(this), primaryStableCoinPrice); ``` A concern arises from the fact that winners receive a portion of all the USDCs transferred to the contract. Consequently, if fewer USDC is transferred to the contract, the winning expectation will decrease. This implies that using METFI as a substitute may actually lower the winning expectations. For example, let's assume the ticket price is 100 USDC each, and there are two level 9 players participating in the game. Both players buy a ticket using their METFI to substitute for 10% of the ticket price. Thus, each player spends assets worth 100 USDC, but only 180 USDC in total are transferred to the contract. The expected winnings for each player would be 180/2 = 90, which means they paid 100 USDC, but their winning expectation is only 90%. On the other hand, if they were to use 100 USDC without using METFI as a substitute, their winning expectation could be 100% instead.
Open the reportWhen users make transfers of METFI coins, it will trigger the `validateTransfer()` invocation in the `securityProxy` contract, and if the return value is `false`, the transfer transaction will revert. ```solidity=22 function _beforeTokenTransfer(address from, address to, uint256 amount) internal override { if (securityProxy != address(0)) { require(ISecurityProxy(securityProxy).validateTransfer(from, to, amount), "Transfer not allowed"); } super._beforeTokenTransfer(from, to, amount); } ``` Therefore, the `validateTransfer()` function of the `securityProxy` contract can possibly block users from transferring tokens. The scope of the audit treats the `securityProxy` contract as a black box and assumes its functional correctness. However, if the `securityProxy` contract is manipulated or compromised, it could block normal users from transferring tokens.
Open the reportThe following situations are not handled in the contracts and will cause the code to revert when encountered. The following situations have been observed. * When there are not enough native tokens sent: `msg.value < requiredBNBAmount` * When no pair for `stableCoin` and `paymentCurrency` is found
Open the reportThe `rebase()` function is designed to adjust the supply of tokens. If enough time has passed since the last rebase and the `dynamicDistribution` is not activated, the `reverseMETFIsPerFragment` will be updated based on a specific `rebaseMultiplier`. It then calculates the `additionalTokens`, the number of new tokens generated during this rebase. ```solidity=344 for (uint256 x = 0; x < levelSettings.length; x++) { currentLevelSettings = levelSettings[x]; oldTokenNum = currentLevelSettings.lockedReverseMETFIs / currentLevelSettings.reverseMETFIsPerFragment; levelSettings[x].reverseMETFIsPerFragment = currentLevelSettings.reverseMETFIsPerFragment * levelSettings[x].rebaseMultiplier[activeHalvingPeriod] / 1000000000; newTokenNum = (currentLevelSettings.lockedReverseMETFIs / levelSettings[x].reverseMETFIsPerFragment); additionalTokens += newTokenNum - oldTokenNum; emit StakingLevelRebased(x, newTokenNum); } rebasesInHalvingCounter.increment(); IMETFIStakingPool(contractRegistry.getContractAddress(METFI_STAKING_POOL_HASH)).withdrawMETFI(address(this), additionalTokens); ``` In the end, it will call the `withdrawMETFI` function in the `METFIStakingPool` contract to withdraw the newly generated tokens. However, there is no guarantee in the given code that the staking pool will always have enough tokens to cover the `additionalTokens` requested during the rebase. This could lead to unintended revert and denial of service in the system if the staking pool does not have enough tokens. The audit team would like to know the source of `METFI` tokens held in both the vault and staking pool contracts, as well as any mechanisms in place to guarantee that these contracts maintain a sufficient balance of `METFI` tokens.
Open the reportUsers may potentially experience price slippages and sandwich attacks. A sandwich attack might happen when an attacker observes a transaction swapping tokens or adding liquidity without setting restrictions on slippage or the minimum output amount. The attacker can manipulate the exchange rate by frontrunning (before the transaction being attacked) a transaction to purchase one of the assets and make profits by backrunning (after the transaction being attacked) a transaction to sell the asset. The following functions are called without limiting maximum input, potentially resulting in users paying more `paymentCurrency` than they intended: In the `NFTTransferProxyV2` contract, the following code is vulnerable to this attack. ```solidity=50 paymentCurrency.safeApprove(address(pancakeRouter), amounts[0]); paymentCurrency.safeTransferFrom(msg.sender, address(this), amounts[0]); pancakeRouter.swapExactTokensForTokens(amounts[0], amounts[1], path, contractRegistry.getContractAddress(TREASURY_HASH), block.timestamp); ``` The following functions are called without setting restrictions on minimum output amount, so transactions triggering these functions are vulnerable to sandwich attacks, especially when the input amount is large: In the `RewardConverter` contract, the following code is vulnerable to this attack. ```solidity=39 try pancakeRouter.getAmountsOut(amount, path) returns (uint256[] memory amountsOut) { amountOut = amountsOut[1]; } catch { primaryStableCoin.safeTransferFrom(msg.sender, getAccountToken().ownerOf(nftId), amount); return; } ... pancakeRouter.swapExactTokensForTokens( amount, amountOut, path, getAccountToken().ownerOf(nftId), block.timestamp); ``` In the `TokenCollectorV2` contract, the following code is vulnerable to this attack. ```solidity=61 uint256[] memory amounts = pancakeRouter.swapExactTokensForTokens( valueFromSwap, tokensFromSwap, path, to, block.timestamp ); ```
Open the reportThe audit team would like to confirm whether the `stakeTokens()` function in the `RouterV3` contract, which currently transfers users' `MFI` tokens to the staking manager, is consistent with the intended design of the new `StakingManagerV3`, `TokenCollectorV2`, and `TreasuryV2` contracts. These contracts specify that the `METFI` token, rather than the `MFI` token, will be stored in the `AccountToken` NFT. ```solidity=285 function stakeTokens(uint256 nftId, uint256 numberOfTokens) external override { verifySenderAndNFT(nftId); rebaseStaking(); //Add tokens to existing staking account IStakingManagerV3 stakingManager = getStakingManager(); stakingManager.addTokensToStaking(nftId, numberOfTokens); //Transfer MFI from user to staking manager IERC20(contractRegistry.getContractAddress(MFI_HASH)).safeTransferFrom(msg.sender, address(stakingManager), numberOfTokens); emit TokensStaked(nftId, numberOfTokens); } ```
Open the reportWhen transferring standard ERC20 deflationary tokens, the input amount may not be equal to the received amount due to the charged transaction fee. As a result, an inconsistency in the amount will occur, and the transaction may fail due to the validation checks. For example, if a user sends 100 deflationary tokens (with a 10% transaction fee) to the target contract, only 90 tokens actually arrive at the contract. There are several places in the implementation that may have issues with deflationary tokens. For example, in the function `checkAndTransferFunds()`, `msg.sender` transfers `royaltyAmount` to the contract account, and the contract then transfers `royaltyAmount` to the treasury. ```solidity=127 IERC20(listingData.currency).safeTransferFrom(msg.sender, address(this), royaltyAmount + marketFee); if (royaltyAmount > 0) { transferRoyaltiesToTreasury(royaltyAmount, listingData.currency); } ``` If the token is a deflationary token, the contract will receive less than `royaltyAmount` but still need to send `royaltyAmount` to the treasury, so it is losing money.
Open the reportThe 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.
Open the reportThe 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.
Open the reportThe 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`
Open the report```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.
Open the reportThis 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.
Open the reportAccording to the documentation, there are 10 NFT levels. However, no input validation is available for the length of `_levelSettings`.
Open the reportAccording 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.
Open the reportThe 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.
Open the reportThe 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.
Open the report`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.
Open the reportSince `parentLeg` is a `uint256` data type, checking `parentLeg >= 0` is unnecessary since it will always evaluate as true.
Open the reportAlthough `ITreasuryExtender` is imported in `EmptyTreasuryExtender.sol` and `Treasury.sol`, the events are not used anywhere.
Open the reportThe following events are not used in `IRewardDistributor` are unused: - `AccountCreated` - `AccountUpgraded` - `AccountLiquidated`
Open the report`IMatrix.sol` is imported despite not being used.
Open the report`ITreasuryAllocator.sol` is imported despite not being used.
Open the report`Ownable.sol` is imported despite not being used.
Open the reportDespite `SafeERC20` being imported and attached to `IERC20`, the functions are not used.
Open the reportThe reports name a repository or files. Open a report to see its scope.
Trustblock holds 4 public audit reports for MetFi DAO, dated 6 Feb 2023 to 1 Feb 2024. The latest is by CertiK (“Metfi Audit 4”).
CertiK wrote the 4 reports Trustblock holds for MetFi DAO.
45 findings are still open or acknowledged in the firms’ reports: 7 high, 6 medium, 32 low (41 open, 4 acknowledged). Of 1 critical finding: marked fixed by the firm. Statuses are the security firms’ own.
Is this your project? Show this record on your own website. The label states what the record holds, links to this page and updates by itself. It is free and needs no sign-in.
Automatic: the three strongest facts of this project’s own record (its last audit and two more), highlighted. They update with the record. Picking a fact turns Automatic off.
<head><script src="https://widget.trustblock.run/project-widget.min.js" defer></script></head><body><divdata-tb-project-widgetdata-tb-project-slug="metfi"></div></body>
Paste the code where the label should appear. It uses no API credit and updates by itself.
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