CertiK reviewed BetFin (Betfin Core Contracts) on 20 May 2024: 58 findings, 1 critical; 35 marked fixed, 23 open.
Report hosted on skynet.certik.com.
Trustblock does not review code.
Statuses are the security firm’s own, from its report.
| Severity | Open | Acknowledged | Fixed |
|---|---|---|---|
| Critical | 0 | 0 | 1 |
| High | 2 | 0 | 4 |
| Medium | 5 | 0 | 12 |
| Low | 16 | 0 | 18 |
In the contract `Affiliate` the role `BINAR` has authority over the functions shown in the diagram below. Any compromise to the `BINAR` account may allow the hacker to take advantage of this authority.  In the contract `Affiliate` the role `TIMELOCK` has authority over the functions shown in the diagram below. Any compromise to the `TIMELOCK` account may allow the hacker to take advantage of this authority.  ----- In the contract `AffiliateFund` the role `TIMELOCK` has authority over the functions shown in the diagram below. Any compromise to the `TIMELOCK` account may allow the hacker to take advantage of this authority.  ----- In the contract `BetsMemory` the role `AGGREGATOR` has authority over the functions shown in the diagram below. Any compromise to the `AGGREGATOR` account may allow the hacker to take advantage of this authority.  In the contract `BetsMemory` the role `TIMELOCK` has authority over the functions shown in the diagram below. Any compromise to the `TIMELOCK` account may allow the hacker to take advantage of this authority.  ----- In the contract `Core` the role `PARTNER` has authority over the functions shown in the diagram below. Any compromise to the `PARTNER` account may allow the hacker to take advantage of this authority.  In the contract `Core` the role `TIMELOCK` has authority over the functions shown in the diagram below. Any compromise to the `TIMELOCK` account may allow the hacker to take advantage of this authority.  ----- In the contract `Partner` the role `_owner` has authority over the functions shown in the diagram below. Any compromise to the `_owner` account may allow the hacker to take advantage of this authority.  ----- In the contract `TimeLock` the role `DEFAULT_ADMIN_ROLE` has authority over the functions shown in the diagram below. Any compromise to the `DEFAULT_ADMIN_ROLE` account may allow the hacker to take advantage of this authority.  ----- In the contract `AffiliateMember` the role `AFFILIATE` has authority over the functions shown in the diagram below. Any compromise to the `AFFILIATE` account may allow the hacker to take advantage of this authority.  In the contract `AffiliateMember` the role `TIMELOCK` has authority over the functions shown in the diagram below. Any compromise to the `TIMELOCK` account may allow the hacker to take advantage of this authority.  ----- In the contract `Predict` the role `TIMELOCK` has authority over the functions shown in the diagram below. Any compromise to the `TIMELOCK` account may allow the hacker to take advantage of this authority.  ----- In the contract `PredictBet` the role `_owner` has authority over the functions shown in the diagram below. Any compromise to the `_owner` account may allow the hacker to take advantage of this authority.  ----- In the contract `PredictGame` the role `_owner` has authority over the functions shown in the diagram below. Any compromise to the `_owner` account may allow the hacker to take advantage of this authority.  addresses. This is a centralization risk because the deployer or the owner(s) of the EOAs can distribute tokens without obtaining the consensus of the community. Any compromise to these addresses may allow a hacker to steal and sell tokens on the market, resulting in severe damage to the project.
The `stake` function in the `ConservativeStakingPool` contract uses the `start` time to initialize the `start` property of a new `Stake`. This `start` time is set once and is the same for all stakes as it's determined by the contract's deployment timestamp (`block.timestamp` at the time of contract creation). The issue with this approach is that regardless of when an individual decides to stake, their stake's `start` time will always be set to the contract's deployment time, rather than the time the stake was actually created. ```solidity // update user's stake if (stakes[staker].exists && !stakes[staker].ended) { // update amount if stake exists stakes[staker].amount += amount; } else if (stakes[staker].exists && stakes[staker].ended) { // create new stake if exists but ended Stake memory _stake = Stake(start, start + duration, amount, staker, false, true); // push new stake to all stakes stakes[staker] = _stake; } else { // create new stake if does not exist Stake memory _stake = Stake(start, start + duration, amount, staker, false, true); // push new stake to all stakes stakes[staker] = _stake; // push staker to stakers stakers.push(staker); } ``` This implementation doesn't accurately reflect the duration for which a stake is active. A stake made long after the contract's deployment will incorrectly have a start time that suggests it's been active since the contract was created. This could cause unexpected behaviors.
The `calculateProfit` function within the `ConservativeStaking` contract is designed to determine and assign profits to each of the conservative staking pools. This function is publicly accessible, allowing any user to initiate the profit calculation process. It operates based on two parameters, `offset` and `count`, which dictate the starting point and the number of pools for which profits will be calculated during the function's execution. ```solidity=185 function calculateProfit(uint256 offset, uint256 count) external { require(isCalculation(), "CS03"); // calculate current cycle uint256 cycle = block.timestamp / SECONDS_IN_WEEK; // calculate profit if not calculated if (!calculated[cycle]) calculateDistribution(); // calculate profit and distribute between pools beased on staked amount uint256 toDistribute = calculatedProfit[cycle]; // distribute profit between pools for (uint256 i = offset; i < count; i++) { if (i >= pools.length) break; // sjip if pool is disrtibuted this cycle if (distributedByCycle[cycle][address(pools[i])]) continue; // skip if pool has no stakes if (pools[i].totalStaked() == 0) continue; // calculate profit of pool uint256 profit = (toDistribute * pools[i].totalStaked()) / _totalStaked; // send profit token.transfer(address(pools[i]), profit); // update total profit _totalProfit += profit; // set pool as distributed distributedByCycle[cycle][address(pools[i])] = true; } } ``` The function first confirms that it is being called during the designated calculation period. It then identifies the current staking cycle based on the timestamp. If profits for this cycle have not yet been calculated, the contract proceeds to determine the distribution amount. The variable `toDistribute` holds the total profit amount available for distribution across all pools. Within a for-loop, the function iterates through the specified range of pools. For each pool, it checks whether the profit for the current cycle has already been distributed and whether there is a staked amount to consider. If these conditions are met, the contract calculates each pool's share of the profit. This share is proportional to the pool's staked amount relative to the total staked amount across all pools. The determined profit is then transferred to the pool's contract. There is an issue with this approach: if profits are calculated and distributed for some pools in one transaction and the remaining pools in subsequent transactions, the later pools could receive a smaller share of profits. This is because the contract's balance (`toDistribute`) is diminished with each distribution, affecting the calculation for subsequent pools within the same cycle. For instance, if there are two active pools with a collective profit of 100 BET tokens, and the first pool's profit is calculated, it might receive 50 BET tokens. After this distribution, the remaining profit is only 50 BET tokens. If the second pool's profit is then calculated in a new cycle, it would receive only 25 BET tokens, based on the updated `toDistribute` value, leading to an unfair distribution.
The `DynamicStaking` contract contains a function `addGame` which is intended to grant the `GAME` role to a game contract, allowing it to call the `reserveFunds` function. However, the contract deployer, who is automatically granted the `DEFAULT_ADMIN_ROLE`, also has the authority to call `grantRole` directly and can grant the `GAME` role to any account. This presents a potential security risk, as an account with the `GAME` role can repeatedly call `reserveFunds` to withdraw `BET` tokens from the dynamic staking contract. The `reserveFunds` function is designed to allow game contracts to reserve funds for their operations. However, if the `DEFAULT_ADMIN_ROLE` is compromised or misused, an attacker could grant the `GAME` role to malicious contracts or accounts, which can then drain funds from the staking contract by repeatedly calling `reserveFunds`. ```solidity=149 function addGame(address _game) external onlyRole(TIMELOCK) { require(core.isGame(_game), "DS05"); grantRole(GAME, _game); } ``` ```solidity=379 function reserveFunds(uint256 amount) external onlyRole(GAME) { require(!isCalculation(), "DS04"); require(amount * 20 <= token.balanceOf(address(this)), "DS06"); token.transfer(_msgSender(), amount); } ``` Additionally, the `BetsMemory` contract, which also inherits from OpenZeppelin's `AccessControl`, allows for role-based permission management. The contract includes specific functions like `addAggregator` and `removeAggregator`, which are intended to be called by an account holding the `TIMELOCK` role in order to manage entities with the `AGGREGATOR` role. However, since the contract also inherits the `grantRole` and `revokeRole` functions from `AccessControl`, and the deployer is typically granted the `DEFAULT_ADMIN_ROLE` upon contract deployment, the deployer inherently possesses the ability to directly grant or revoke any roles, including the `AGGREGATOR` role. This makes the custom `addAggregator` and `removeAggregator` functions redundant, as the deployer or any account with the `DEFAULT_ADMIN_ROLE` can manage roles without the need for these specialized functions. ```solidity function addAggregator(address _aggregator) public onlyRole(TIMELOCK) { _grantRole(AGGREGATOR, _aggregator); emit NewAggregator(_aggregator); } function removeAggregator(address _aggregator) public onlyRole(TIMELOCK) { _revokeRole(AGGREGATOR, _aggregator); emit AggregatorRemoved(_aggregator); } ```
The contract defined a state variable `affiliate` and granted it the role **AFFILIATE**. The privileged function `setAffiliate` allows the modify the value of the state variable `affiliate` and grants the new one the role. The issue is that the privileged role is not revoked from the previous `affiliate`, which means the previous one still has the authority.
In the `ConservativeStakingPool` smart contract, when users stake repeatedly within the same pool, their staking balances are cumulatively tracked. ```solidity if (stakes[staker].exists && !stakes[staker].ended) { // if an existing stake is not ended, increment the staked amount stakes[staker].amount += amount; } ``` Profit distribution to stakers is proportional to the size of their stake in the pool. ```solidity function distributeProfit() external { ... // calculate the staker's share of the profit uint256 amount = _profit * stakes[stakers[i]].amount / totalStaked; // increment the staker's claimable profit claimable[stakers[i]] += amount; // record the profit for the staker profit[stakers[i]] += amount; ... } ``` However, this system is vulnerable to an exploit commonly known as "last-minute staking" or "flash staking," where a user can manipulate the payout mechanism by initially staking a small amount and then substantially increasing their stake just before profits are distributed. This poses several problems: 1. **Unequal Profit Sharing**: This tactic enables a user to claim a disproportionately high portion of the profits compared to their average investment duration in the pool, which is unfair to other participants who may have committed larger sums for more extended periods. 2. **Disincentive to Long-Term Holding**: The staking system is designed to promote sustained investment and engagement. Last-minute staking subverts this goal, encouraging users to delay substantial investment until the final moment, which contradicts the principle of rewarding ongoing support. 3. **Gaming the System**: Engaging in last-minute staking allows users to game the reward system for personal gain. This fosters a competitive environment where participants are motivated to opportunistically time their investments rather than contributing constructively to the ecosystem's long-term stability.
This [Checks-Effects-Interactions Pattern](https://docs.soliditylang.org/en/latest/security-considerations.html#use-the-checks-effects-interactions-pattern) is a best practice for writing secure smart contracts that involves performing all state changes before making any external function calls. ### External call(s) ```solidity=131 token.transferFrom(_msgSender(), address(this), amount); ``` ### State variables written after the call(s) ```solidity=139 _totalStaked += amount; // update count of stakers if (!isStaker[staker]) { // update count of stakers _totalStakers++; // set staker as staker // set staker as staker isStaker[staker] = true; } // update staked amount of player staked[staker] += amount; ``` --- ### External call(s) ```solidity=85 token.transferFrom(_msgSender(), _stake.staker, amount); ``` ### State variables written after the call(s) ```solidity=86 // update stake; _stake.ended = true; // update staked staked[_stake.staker] -= _stake.amount; ``` --- ### External call(s) ```solidity=75 if (getClaimable(_msgSender()) > 0) claim(); ``` ### State variables written after the call(s) ```solidity=77 _stake.ended = true; // update staked amount staked[_msgSender()] -= _stake.amount; // update total staked amount _totalStaked -= _stake.amount; ``` --- ### External call(s) ```solidity=26 super._safeMint(member, membersCount + 1); ``` ### State variables written after the call(s) ```solidity=28 super._push(member, inviter); ```
The `Betfin` project's design, there are concerns regarding gas efficiency. The project architecture involves creating a significant number of contracts for various operations, such as placing bets, setting up staking pools, and managing tariffs. Creating new contracts on the blockchain is a gas-intensive operation due to the computational work required to establish and store the contract code on the network. The audit team suggests that some functionalities, which currently lead to contract creation, could be restructured to use contract storage variables instead. This would mean maintaining certain states within a single contract or a smaller number of contracts, which could be updated as necessary, rather than deploying new contracts for each action. Such a change could potentially reduce the transaction costs for users and optimize the overall gas consumption of the project. However, refactoring the current implementation will require a lot of effort. The audit team would to know more details of the purpose in the current design. As for the strategy of deploying multiple contracts rather than leveraging storage variables, we are curious to understand the rationale behind this architectural choice. Besides, we also provide a POC to showcase that creating bet contracts would consume much more gas. In the case below, we can save around **three times** the gas by using storage in a single contract (Game2) compared to deploying a new contract for each bet (Game1).
When 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 ```solidity=233 token.transferFrom(player, address(this), amount); ``` - Transferring tokens by `amount`. ```solidity=237 StakingInterface(staking).stake(player, amount); ``` - The `amount` appears to be used for bookkeeping purposes without compensating the potential transfer fees. - Note: `stake` is an external function and its behavior wasn't evaluated. --- ```solidity=235 token.transferFrom(_msgSender(), address(this), amount); ``` - Transferring tokens by `amount`. ```solidity=243 currentPool.stake(staker, amount); ``` - The `amount` appears to be used for bookkeeping purposes without compensating the potential transfer fees. - Note: `stake` is an external function and its behavior wasn't evaluated. --- ```solidity=96 token.transferFrom(_msgSender(), address(this), amount); ``` - Transferring tokens by `amount`. ```solidity=81 stakes[staker].amount += amount; ``` - The `amount` appears to be used for bookkeeping purposes without compensating the potential transfer fees. --- ```solidity=287 token.transferFrom(_msgSender(), address(this), amount); ``` - Transferring tokens by `amount`. ```solidity=295 currentPool.stake(staker, amount); ``` - The `amount` appears to be used for bookkeeping purposes without compensating the potential transfer fees. - Note: `stake` is an external function and its behavior wasn't evaluated. --- ```solidity=138 token.transfer(_msgSender(), amount); ``` - Transferring tokens by `amount`. ```solidity=139 realStaked -= amount; ``` - The `amount` appears to be used for bookkeeping purposes without compensating the potential transfer fees.
One or more `view` functions always return the same constant value, leading to unnecessary gas costs. ```solidity=146 function validateLimits(uint256 count, uint256[] memory data) internal view returns (bool) { ``` - `Roulette.validateLimits` always returns `true`.
One or more parameters with `memory` data location are never modified in their functions and those functions are never called internally within the contract. Thus, their data location can be changed to `calldata` to avoid the gas consumption copying from calldata to memory. ```solidity=22 function placeBet(address game, uint256 totalAmount, bytes memory data) public returns (address) { ``` `placeBet` has memory location parameters: `data`. --- ```solidity=48 function addGame( ``` `addGame` has memory location parameters: `_symbol`. --- ```solidity=261 function setLimit(string memory limit, uint256 min, uint256 max) public onlyRole(TIMELOCK) { ``` `setLimit` has memory location parameters: `limit`.
The `Core` contract currently permits any user to execute the `addPartner()` function, enabling them to attain the status of a partner simply by paying a specified token amount. However, the contract lacks a corresponding mechanism to revoke partnership status and reimburse the tokens previously paid. The audit team is seeking clarification to ascertain if this design aligns with the initial requirements set for the contract.
Addresses are not validated before assignment or external calls, potentially allowing the use of zero addresses and leading to unexpected behavior or vulnerabilities. For example, transferring tokens to a zero address can result in a permanent loss of those tokens.
When a loop allows an arbitrary number of iterations or accesses state variables in its body, the function may run out of gas and revert the transaction. ```solidity=74 for (uint256 i = 0; i < count; i++) { ``` Function `Affiliate.checkMatchingCondition` contains a loop and its loop condition depends on external calls: `pass.getInviteesCount`. --- ```solidity=55 for (uint256 i = bets.length - 1 - _offset; i >= 0; i--) { ``` Function `BetsMemory.getBets` contains a loop and its loop condition depends on parameters: `offset`. --- ```solidity=28 while (!data[t].exist) t--; ``` Function `DataFeed.getDataBefore` contains a loop and its loop condition depends on state variables: `data`. --- ```solidity=35 while (!data[t].exist) t++; ``` Function `DataFeed.getDataAfter` contains a loop and its loop condition depends on state variables: `data`. --- ```solidity=63 for (uint64 i = aggregatorRoundId; i >= aggregatorRoundId - _count; i--) { ``` Function `DataFeed.fillHistory` contains a loop and its loop condition depends on parameters: `_count`. --- ```solidity=91 for (uint256 i = 0; i < count; i++) { ``` Function `Roulette.getPossibleWin` contains a loop and its loop condition depends on parameters: `data`. --- ```solidity=113 for (uint256 i = 0; i < stakedPools[staker].length; i++) { ``` Function `ConservativeStaking.getProfit` contains a loop and its loop condition depends on state variables: `stakedPools`. --- ```solidity=121 for (uint256 i = 0; i < stakedPools[staker].length; i++) { ``` Function `ConservativeStaking.getClaimable` contains a loop and its loop condition depends on state variables: `stakedPools`. --- ```solidity=149 for (uint256 i = 0; i < stakedPools[_msgSender()].length; i++) { ``` Function `ConservativeStaking.claimAll` contains a loop and its loop condition depends on state variables: `stakedPools`. --- ```solidity=160 for (uint256 i = 0; i < stakedPools[_msgSender()].length; i++) { ``` Function `ConservativeStaking.withdraw` contains a loop and its loop condition depends on state variables: `stakedPools`. --- ```solidity=194 for (uint256 i = offset; i < count; i++) { ``` Function `ConservativeStaking.calculateProfit` contains a loop and its loop condition depends on parameters: `count`, `offset`. --- ```solidity=187 for (uint256 i = offset; i < offset + count; i++) { ``` Function `DynamicStaking.calculateProfit` contains a loop and its loop condition depends on parameters: `offset`, `count`.
A reentrancy attack can occur when the contract creates a function that makes an external call to another untrusted contract before resolving any effects. If the attacker can control the untrusted contract, they can make a recursive call back to the original function, repeating interactions that would have otherwise not run after the external call resolved the effects.
In the `BetsMemory` smart contract, there exists a potential risk for an underflow condition when a `_game` address that has not been logged is provided as an argument. ```solidity function getBets( uint256 _limit, uint256 _offset, address _game ) public view returns (BetInterface[] memory) { ... uint256 resultIndex = 0; for (uint256 i = bets.length - 1 - _offset; i >= 0; i--) { if ( _game == address(0) || BetInterface(bets[i]).getGame() == _game ) { result[resultIndex] = BetInterface(bets[i]); resultIndex++; if (resultIndex == _limit) { break; } } } return result; } ``` When an `_game` that does not exist is passed to the function, it will not satisfy the `if` check. Consequently, when the variable `i` decreases to zero and then attempts to decrease further, an underflow will occur.
The `getDataBefore` method in the `DataFeed` contract retrieves the closest timestamp with a valid price before a specified timestamp. For this function to work correctly, it assumes that the `data` mapping has been continuously updated with new price data. If any `roundId` updates are missed, there might be gaps in the data, leading to potentially stale or inaccurate prices being returned. The `PredictGame` contract uses the `getDataBefore` method to fetch the start and end prices for a betting round. If the `DataFeed` contract has missed updating some `roundId`s, the prices fetched could be older than expected, leading to inaccurate calculations in the `PredictGame` contract. This could result in unfair game outcomes, as bets might be settled based on outdated price information.
Comparisons that are always true or always false may be incorrect or unnecessary. ```solidity=132 require(value >= 0, "A04"); ``` --- ```solidity=139 require(value >= 0, "A04"); ``` --- ```solidity=146 require(value >= 0, "A04"); ``` --- ```solidity=55 for (uint256 i = bets.length - 1 - _offset; i >= 0; i--) { ``` --- ```solidity=78 for (uint256 i = bets.length - 1; i >= 0; i--) { ``` --- ```solidity=71 require(_price >= 0, "C09"); ```
In the recent commit [ee87c3eeabf050e4fa542d1ace60943dba1e0bed](https://github.com/betfinio/contracts/tree/ee87c3eeabf050e4fa542d1ace60943dba1e0bed), it introduced a new refund mechanism in the `calculateBets` function of the `PredictGame` contract. ```solidity function calculateBets(uint256 round, bool winSide) private returns (uint256 count) { uint256 longs = longPool[round]; uint256 shorts = shortPool[round]; if(longs == 0 || shorts == 0) { refund(round); return 0; } ``` The current logic dictates that if all participants wager on the same outcome (for instance, if they all predict an increase in the value of BTC), a refund is issued to all players, even if their prediction is correct. However, during this refund process, a game fee of 3.6% is deducted from each player's bet, which mirrors the treatment of a draw result. The team is questioning why the system does not reimburse the full betting amount to players in the event of a refund. Moreover, this approach appears to disadvantage early players who have made successful predictions, as they still incur a 3.6% fee loss. Without the refund mechanism, their potential loss could be less than this percentage of the bet amount.
The contract acts as the fundamental mechanism for interfacing with external parties such as **Chainlink**. Within the scope of this audit, these third-party entities are considered as black boxes, with their functional correctness taken as a given. However, it should be noted that in a practical context, these third-party entities could potentially be compromised. Such breaches could result in the loss or theft of assets. **DataFeed** - `dataFeed`: The chainlink `AggregatorV3Interface` implementation. **Roulette** - `vrfCoordinator`: The chainlink VRF coordinator. It is assumed that these contracts or addresses are trusted and implemented properly within the whole project. **The team utilizes the subscription method of the Chainlink VRF service to generate random numbers. It is assumed that the team maintains a sufficient balance to fund requests from consuming contracts. If the balance is insufficient, the 'Roulette' contract could be paused and tokens could be locked in the contract.**
The return values of the `transfer()` and `transferFrom()` calls in the smart contract are not checked. Some ERC-20 tokens' transfer functions return no values, while others return a bool value, they should be handled with care. If a function returns `false` instead of reverting upon failure, an unchecked failed transfer could be mistakenly considered successful in the contract. ```solidity=91 token.transfer(member, claimable); ``` --- ```solidity=103 token.transfer(_msgSender(), claimable); ``` --- ```solidity=103 token.transferFrom(_msgSender(), address(this), tariff.price()); ``` --- ```solidity=204 token.transferFrom(player, _msgSender(), partnerFee); ``` --- ```solidity=206 token.transferFrom(player, iGame.getStaking(), baseFee - partnerFee); ``` --- ```solidity=208 token.transferFrom(player, game, totalAmount - baseFee); ``` --- ```solidity=211 token.transfer(_msgSender(), partnerFee); ``` --- ```solidity=213 token.transferFrom(player, game, totalAmount); ``` --- ```solidity=233 token.transferFrom(player, address(this), amount); ``` --- ```solidity=239 token.transfer(_msgSender(), amount * Tariff(Partner(_msgSender()).tariff()).stakeProfit() / 100_00); ``` --- ```solidity=33 core.token().transfer(owner(), core.token().balanceOf(address(this))); ``` --- ```solidity=85 core.token().transfer(_game, _amount - _amount * core.fee() / 100_00); ``` --- ```solidity=132 predict.core().token().transfer(_bet.getPlayer(), amount); ``` --- ```solidity=178 predict.core().token().transfer(bet.getPlayer(), winnings + bonusWinnings); ``` --- ```solidity=136 staking.token().transfer(address(staking), totalAmount); ``` --- ```solidity=184 core.token().transfer(player, amount); ``` --- ```solidity=187 core.token().transfer(address(staking), reservedFunds[requestId] - amount); ``` --- ```solidity=203 token.transfer(address(pools[i]), profit); ``` --- ```solidity=235 token.transferFrom(_msgSender(), address(this), amount); ``` --- ```solidity=96 token.transferFrom(_msgSender(), address(this), amount); ``` --- ```solidity=105 token.transfer(staker, toClaim); ``` --- ```solidity=127 token.transfer(staker, amount); ``` --- ```solidity=228 if (poolProfit > 0) token.transfer(address(pool), poolProfit); ``` --- ```solidity=287 token.transferFrom(_msgSender(), address(this), amount); ``` --- ```solidity=325 token.transfer(_msgSender(), amount); ``` --- ```solidity=97 token.transferFrom(_msgSender(), address(this), amount / 2); ``` --- ```solidity=110 token.transferFrom(_msgSender(), address(this), realStaked); ``` --- ```solidity=121 token.transfer(staker, _share); ``` --- ```solidity=127 token.transfer(_msgSender(), token.balanceOf(address(this))); ``` --- ```solidity=138 token.transfer(_msgSender(), amount); ``` --- ```solidity=161 token.transfer(stakers[i], _profit); ``` --- ```solidity=164 token.transfer(_msgSender(), token.balanceOf(address(this)) - realStaked); ```
The for loop contains repeated storage read access in the condition check. Given that the ending condition does not change in the for loop, the repeated storage read is unnecessary, and its associated high gas cost can be eliminated. ```solidity=115 for (uint256 i = 0; i < bets.length; i++) { ``` Loop condition `i < bets.length` accesses the `length` field of a storage array. --- ```solidity=146 for (uint256 i = 0; i < stakers.length; i++) { ``` Loop condition `i < stakers.length` accesses the `length` field of a storage array.
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (28)
1,045 projects reviewed · 1,376 reports · latest May 2025
See CertiK’s auditsSomething 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