Unnamed: 0
int64
0
7.36k
comments
stringlengths
3
35.2k
code_string
stringlengths
1
527k
code
stringlengths
1
527k
__index_level_0__
int64
0
88.6k
59
// Internal Write Functions
function __updateYieldReward(address address_) internal { uint40 _time = __getSmallerValueUint40(uint40(block.timestamp), yieldEndTime); uint40 _lastUpdate = addressToYield[address_].lastUpdatedTime_; if (_lastUpdate > 0) { addressToYield[address_].pendingRewards_ += __calculateYieldReward(address_); } else { // Migrate Rewards Logic if _lastUpdate is 0 if (migrationEnabled) { __migrateRewards(address_); } } if (_lastUpdate != yieldEndTime) { addressToYield[address_].lastUpdatedTime_ = _time; } }
function __updateYieldReward(address address_) internal { uint40 _time = __getSmallerValueUint40(uint40(block.timestamp), yieldEndTime); uint40 _lastUpdate = addressToYield[address_].lastUpdatedTime_; if (_lastUpdate > 0) { addressToYield[address_].pendingRewards_ += __calculateYieldReward(address_); } else { // Migrate Rewards Logic if _lastUpdate is 0 if (migrationEnabled) { __migrateRewards(address_); } } if (_lastUpdate != yieldEndTime) { addressToYield[address_].lastUpdatedTime_ = _time; } }
25,365
136
// Balancer pool WETH-MUSD
address balancerPool;
address balancerPool;
19,134
29
// Returns balance for the token defined by the provided index
function balances(uint256 index) external view returns (uint256);
function balances(uint256 index) external view returns (uint256);
72,034
38
// Gives all stableSwap info at once. Reduces front-end RPC calls./ All return values have 18 decimals except fee that has 6.
function getStableSwapInfo(uint256 inAmount, address stableIn, address stableOut) public view returns( uint256 inStablecoinPriceUSD, uint256 outStablecoinPriceUSD, uint256 quoteS2S1, uint256 fee, uint256 feeAmount, uint256 outStablecoinAmount
function getStableSwapInfo(uint256 inAmount, address stableIn, address stableOut) public view returns( uint256 inStablecoinPriceUSD, uint256 outStablecoinPriceUSD, uint256 quoteS2S1, uint256 fee, uint256 feeAmount, uint256 outStablecoinAmount
28,951
32
// Transfers control of the contract to a newOwner. _newOwner The address to transfer ownership to. /
function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; }
function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; }
2,870
114
// See {_burn} and {_approve}. /
function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve( account, _msgSender(), _allowances[account][_msgSender()].sub( amount, "ERC20: burn amount exceeds allowance" ) );
function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve( account, _msgSender(), _allowances[account][_msgSender()].sub( amount, "ERC20: burn amount exceeds allowance" ) );
64,090
10
// Check the amount of already added percents in all other rules.percent Proposal percents./
modifier canAddRuleWithThisValueOfPercents(uint256 percent) { require(amountOfRulesPercents + percent <= MAX_PERCENTS); _; }
modifier canAddRuleWithThisValueOfPercents(uint256 percent) { require(amountOfRulesPercents + percent <= MAX_PERCENTS); _; }
12,006
23
// ------------------------------------------------------------------------ Token holders can stake their tokens using this functiontokens number of tokens to stake ------------------------------------------------------------------------
function STAKE(uint256 tokens) external { require(IERC20(EMax).transferFrom(msg.sender, address(this), tokens), "Tokens cannot be transferred from user account"); // add pending rewards to remainder to be claimed by user later, if there is any existing stake uint256 owing = pendingReward(msg.sender); stakers[msg.sender].remainder = stakers[msg.sender].remainder.add(owing); stakers[msg.sender].stakedTokens = tokens.add(stakers[msg.sender].stakedTokens); stakers[msg.sender].lastDividends = 0; stakers[msg.sender].fromTotalDividend= totalDividends; stakers[msg.sender].round = round; stakers[msg.sender].remainder = 0; totalStakes = totalStakes.add(tokens); emit STAKED(msg.sender, tokens); }
function STAKE(uint256 tokens) external { require(IERC20(EMax).transferFrom(msg.sender, address(this), tokens), "Tokens cannot be transferred from user account"); // add pending rewards to remainder to be claimed by user later, if there is any existing stake uint256 owing = pendingReward(msg.sender); stakers[msg.sender].remainder = stakers[msg.sender].remainder.add(owing); stakers[msg.sender].stakedTokens = tokens.add(stakers[msg.sender].stakedTokens); stakers[msg.sender].lastDividends = 0; stakers[msg.sender].fromTotalDividend= totalDividends; stakers[msg.sender].round = round; stakers[msg.sender].remainder = 0; totalStakes = totalStakes.add(tokens); emit STAKED(msg.sender, tokens); }
44,789
14
// Do not allow the owner to prematurely steal tokens that do not belong to them
if(!hasLaunched){ require(tokenAddress != counter); }else{
if(!hasLaunched){ require(tokenAddress != counter); }else{
46,520
14
// 賽局陣列
Game[] public games;
Game[] public games;
10,483
5
// Check that the proposed set natural unit is a multiple of current set natural unit, or vice versa. Done to make sure that when calculating token units there will are be rounding errors.
require( naturalUnitsAreValid(currentSet, _nextSet), "Invalid natural unit" );
require( naturalUnitsAreValid(currentSet, _nextSet), "Invalid natural unit" );
51,221
77
// Returns list of owners./ return List of owner addresses.
function getOwners() public view returns (address[] memory)
function getOwners() public view returns (address[] memory)
18,365
130
// think of useful event scheme for in-flight outputs finalization
} else {
} else {
26,764
12
// Of the remaining tokens, set aside 1/4 of the tokens to LP, swap the rest for ETH. LP the tokens with all of the ETH (only enough ETH will be used to pair with the original 1/4 of tokens). Send the remaining ETH (about half the original balance) to my wallet.
uint tokensForLiq = balanceOf(address(this)) / 4; uint tokensToSwap = balanceOf(address(this)) - tokensForLiq;
uint tokensForLiq = balanceOf(address(this)) / 4; uint tokensToSwap = balanceOf(address(this)) - tokensForLiq;
21,761
1,424
// Decrypt secret key contribution
uint secret = Decryption(contractManager.getContract("Decryption")).decrypt( complaints[schainId].keyShare, sha256(abi.encodePacked(key)) ); badNode = ( _checkCorrectMultipliedShare(multipliedShare, secret) && multipliedShare.isEqual(complaints[schainId].sumOfVerVec) ? complaints[schainId].fromNodeToComplaint : complaints[schainId].nodeToComplaint
uint secret = Decryption(contractManager.getContract("Decryption")).decrypt( complaints[schainId].keyShare, sha256(abi.encodePacked(key)) ); badNode = ( _checkCorrectMultipliedShare(multipliedShare, secret) && multipliedShare.isEqual(complaints[schainId].sumOfVerVec) ? complaints[schainId].fromNodeToComplaint : complaints[schainId].nodeToComplaint
13,788
204
// checks if the address provided is part of the presale
function checkPresaleAddress(address _address) public view returns (bool) { return presaleAddressAllowed[_address]; }
function checkPresaleAddress(address _address) public view returns (bool) { return presaleAddressAllowed[_address]; }
82,515
74
// Delegate votes. Delegate votes. delegatee The address to delegate the votes to./
function delegate(address delegatee) external payable { require(compToken.delegates(address(this)) != delegatee, "Already delegated to same delegatee."); compToken.delegate(delegatee); emit LogDelegate(delegatee); }
function delegate(address delegatee) external payable { require(compToken.delegates(address(this)) != delegatee, "Already delegated to same delegatee."); compToken.delegate(delegatee); emit LogDelegate(delegatee); }
71,276
0
// string uri = "https:bafybeihdyeow5r7wbfvtwachwysomdk2ue2pfj5pbx5svpzxx62ymhf4cu.ipfs.dweb.link/MoonCats/";
uint public priceNFT = 0;
uint public priceNFT = 0;
16,558
74
// The operation should be approved if the signer address has no cosigner (i.e. signer == cosigner)
require(address(authorizations[authVersion + uint256(msg.sender)]) == msg.sender, "Invalid authorization."); internalInvoke(0, data);
require(address(authorizations[authVersion + uint256(msg.sender)]) == msg.sender, "Invalid authorization."); internalInvoke(0, data);
20,091
59
// we sent more funds for the farmer to farm, reflect this
ACTIVELY_FARMED = ACTIVELY_FARMED.add(_amountChange); emit RebalanceHot(0, _amountChange, block.timestamp);
ACTIVELY_FARMED = ACTIVELY_FARMED.add(_amountChange); emit RebalanceHot(0, _amountChange, block.timestamp);
22,434
34
// set new CL
creditLine = IV2CreditLine(newCl);
creditLine = IV2CreditLine(newCl);
42,567
71
// See {IERC20-transfer}. Requirements: - `account` cannot be the zero address.- the caller must have a balance of at least `amount`. /
function burn(uint256 amount) public virtual returns (bool) { _burn(_msgSender(), amount); return true; }
function burn(uint256 amount) public virtual returns (bool) { _burn(_msgSender(), amount); return true; }
14,876
0
// from -> identity -> tokens
mapping(address => mapping(uint256 => EnumerableSet.UintSet)) IdentityTokens;
mapping(address => mapping(uint256 => EnumerableSet.UintSet)) IdentityTokens;
4,951
840
// Update fractional reward
fractionalRewardByWallet[wallet].fraction = fraction.clampMax(uint256(ConstantsLib.PARTS_PER())); fractionalRewardByWallet[wallet].nonce = ++nonceByWallet[wallet]; fractionalRewardByWallet[wallet].unlockTime = block.timestamp.add(unlockTimeoutInSeconds);
fractionalRewardByWallet[wallet].fraction = fraction.clampMax(uint256(ConstantsLib.PARTS_PER())); fractionalRewardByWallet[wallet].nonce = ++nonceByWallet[wallet]; fractionalRewardByWallet[wallet].unlockTime = block.timestamp.add(unlockTimeoutInSeconds);
22,093
214
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
mapping(uint256 => uint256) private _allTokensIndex;
23,205
23
// Function to return whether they are a holder or not
function isHolder(address _address) public view returns(bool)
function isHolder(address _address) public view returns(bool)
50,426
18
// Add enabled chain direction to bridge _chainId Id of chain enabled True - enabled, false - disabled direction /
function updateChain(uint256 _chainId, bool enabled) external onlyRole(ADMIN_ROLE)
function updateChain(uint256 _chainId, bool enabled) external onlyRole(ADMIN_ROLE)
46,958
226
// find amount to redeem in underlying
uint256 redeemAmount = Math.min(invested, supplyShare.mul(invested).div(1e18));
uint256 redeemAmount = Math.min(invested, supplyShare.mul(invested).div(1e18));
44,585
6
// Updates the administrative operator/_administrativeOperator The to-be-set administrative operator
function updateAdministrativeOperator(address _administrativeOperator) external
function updateAdministrativeOperator(address _administrativeOperator) external
38,802
6
// Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. _spender The address which will spend the funds. _value The amount of tokens to be spent. /
function approve(address _spender, uint256 _value) public override returns (bool) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
function approve(address _spender, uint256 _value) public override returns (bool) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
2,986
66
// Make sure the new addresses are not address(0)
require(custodian_address != address(0) && timelock_address != address(0), "Invalid custodian or timelock");
require(custodian_address != address(0) && timelock_address != address(0), "Invalid custodian or timelock");
10,560
15
// Get deployer
address caller = _msgSender();
address caller = _msgSender();
1,261
35
// ERC20 代币总量 /
function totalSupply() public view returns (uint256){ return tokenStore.totalSupply(); }
function totalSupply() public view returns (uint256){ return tokenStore.totalSupply(); }
33,997
138
// Possible ways this could break addressed 1) Accessing before event is over and resetting eth contributed -- added require 2) No uniswap pair - impossible at this moment because of the LPGenerationCompleted bool 3) LP per unit is 0 - impossible checked at generation function
function claimLPTokens() public { require(LPGenerationCompleted, "Event not over yet"); require(ethContributed[msg.sender] > 0 , "Nothing to claim, move along"); IUniswapV2Pair pair = IUniswapV2Pair(tokenUniswapPair); uint256 amountLPToTransfer = ethContributed[msg.sender].mul(LPperETHUnit).div(1e18); pair.transfer(msg.sender, amountLPToTransfer); // stored as 1e18x value for change ethContributed[msg.sender] = 0; emit LPTokenClaimed(msg.sender, amountLPToTransfer); }
function claimLPTokens() public { require(LPGenerationCompleted, "Event not over yet"); require(ethContributed[msg.sender] > 0 , "Nothing to claim, move along"); IUniswapV2Pair pair = IUniswapV2Pair(tokenUniswapPair); uint256 amountLPToTransfer = ethContributed[msg.sender].mul(LPperETHUnit).div(1e18); pair.transfer(msg.sender, amountLPToTransfer); // stored as 1e18x value for change ethContributed[msg.sender] = 0; emit LPTokenClaimed(msg.sender, amountLPToTransfer); }
34,520
2
// mapping of all the Requests
mapping(bytes32 => Request) public requests;
mapping(bytes32 => Request) public requests;
46,295
49
// calculate and transfer tokens
uint256 rescuedRewards = 0; if (sc.dateEnd > block.timestamp || sc.dateEnd == 0) { _plans[stakingPlanId].availableTokensBeStaked += uStake.amount; } else {
uint256 rescuedRewards = 0; if (sc.dateEnd > block.timestamp || sc.dateEnd == 0) { _plans[stakingPlanId].availableTokensBeStaked += uStake.amount; } else {
34,815
4
// https:github.com/makerdao/dss/blob/master/src/pot.sol
contract PotAbstract { function wards(address) public view returns (uint256); function rely(address) external; function deny(address) external; function pie(address) public view returns (uint256); function Pie() public view returns (uint256); function dsr() public view returns (uint256); function chi() public view returns (uint256); function vat() public view returns (address); function vow() public view returns (address); function rho() public view returns (uint256); function live() public view returns (uint256); function file(bytes32, uint256) external; function file(bytes32, address) external; function cage() external; function drip() external returns (uint256); function join(uint256) external; function exit(uint256) external; }
contract PotAbstract { function wards(address) public view returns (uint256); function rely(address) external; function deny(address) external; function pie(address) public view returns (uint256); function Pie() public view returns (uint256); function dsr() public view returns (uint256); function chi() public view returns (uint256); function vat() public view returns (address); function vow() public view returns (address); function rho() public view returns (uint256); function live() public view returns (uint256); function file(bytes32, uint256) external; function file(bytes32, address) external; function cage() external; function drip() external returns (uint256); function join(uint256) external; function exit(uint256) external; }
16,567
68
// Prevents division by zero and other undesirable behaviour
uint public constant MIN_RESERVE = 1000; using Address for address; using Clones for address; mapping (address => mapping (address => uint)) public debtOf; mapping (address => mapping (address => uint)) public accountInterestSnapshot; mapping (address => uint) public cumulativeInterestRate; // 100e18 = 100% mapping (address => uint) public totalDebt; mapping (address => IERC20) public lpToken;
uint public constant MIN_RESERVE = 1000; using Address for address; using Clones for address; mapping (address => mapping (address => uint)) public debtOf; mapping (address => mapping (address => uint)) public accountInterestSnapshot; mapping (address => uint) public cumulativeInterestRate; // 100e18 = 100% mapping (address => uint) public totalDebt; mapping (address => IERC20) public lpToken;
13,859
6
// -----------------------------------------------------------------------/ ERC721 Approval Storage/ -----------------------------------------------------------------------
mapping(uint256 => address) public getApproved; mapping(address => mapping(address => bool)) public isApprovedForAll;
mapping(uint256 => address) public getApproved; mapping(address => mapping(address => bool)) public isApprovedForAll;
22,017
1
// AB Drop Manager address
address public dropManager;
address public dropManager;
3,180
43
// Set token offering to approve allowance for offering contract to distribute tokens Note that if _amountForSale is 0, then it is assumed that the fullremaining crowdsale supply is made available to the crowdsale. offeringAddr Address of token offerng contract amountForSale Amount of tokens for sale, set 0 to max out /
function setTokenOffering(address offeringAddr, uint256 amountForSale) external onlyOwner { require(!transferEnabled); uint256 amount = (amountForSale == 0) ? TokenAllowance : amountForSale; require(amount <= TokenAllowance); approve(offeringAddr, amount); tokenAllowanceAddr = offeringAddr; }
function setTokenOffering(address offeringAddr, uint256 amountForSale) external onlyOwner { require(!transferEnabled); uint256 amount = (amountForSale == 0) ? TokenAllowance : amountForSale; require(amount <= TokenAllowance); approve(offeringAddr, amount); tokenAllowanceAddr = offeringAddr; }
37,407
21
// Entry point function to commence the flash loan sequence/
function executeFlashLoans( uint256 _flashDaiAmt, uint256 _flashsUSDAmt, uint256 _coverAmtInDai, uint256 _exploitVolume
function executeFlashLoans( uint256 _flashDaiAmt, uint256 _flashsUSDAmt, uint256 _coverAmtInDai, uint256 _exploitVolume
19,724
4
// Integer division of two unsigned integers truncating the quotient, reverts on division by zero. /
function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
3,019
143
// Compute claim fee.
function claimFee(uint256 _wid, uint256 amount) public view returns (uint256){ WineInfo storage wine = wineInfo[_wid]; return amount * wine.fixedPrice * (totalFee) / (base); }
function claimFee(uint256 _wid, uint256 amount) public view returns (uint256){ WineInfo storage wine = wineInfo[_wid]; return amount * wine.fixedPrice * (totalFee) / (base); }
46,547
134
// make it only callable if lastRequestId is fulfilled & didn't result in a win yet
require( s_requests[lastRequestId].fulfilled && !s_requests[lastRequestId].finished); uint256[] memory _r = s_requests[lastRequestId].randomWords; address[] memory qa = iCMON.getQa(); address[] memory _cca = new address[](qa.length); uint256[] memory _ccv = new uint256[](qa.length); uint256[] memory _icv = new uint256[](qa.length); uint256 _entry; for (uint256 i = 0; i < qa.length; i++) { address _p = qa[i]; _cca[i] = _p;
require( s_requests[lastRequestId].fulfilled && !s_requests[lastRequestId].finished); uint256[] memory _r = s_requests[lastRequestId].randomWords; address[] memory qa = iCMON.getQa(); address[] memory _cca = new address[](qa.length); uint256[] memory _ccv = new uint256[](qa.length); uint256[] memory _icv = new uint256[](qa.length); uint256 _entry; for (uint256 i = 0; i < qa.length; i++) { address _p = qa[i]; _cca[i] = _p;
31,388
238
// Borrowing fee has been paid. Emitted only if the actual fee was paid - doesn't happen with no fees are/ paid./collateralToken Collateral token used to mint R./position The address of position's owner that triggered the fee payment./feeAmount The amount of tokens paid as the borrowing fee.
event RBorrowingFeePaid(IERC20 collateralToken, address indexed position, uint256 feeAmount);
event RBorrowingFeePaid(IERC20 collateralToken, address indexed position, uint256 feeAmount);
21,837
3
// ============ Immutable storage ============randomizer addressIRandomizer private randomizer; NFT owner
address public immutable owner;
address public immutable owner;
21,825
96
// Should never actually reach this require check, but here in case.
require(self.gasPrice <= tx.gasprice);
require(self.gasPrice <= tx.gasprice);
10,858
58
// Emitted when `owner` enables `approved` to manage the `tokenId` token. /
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
10,082
51
// Governor/admin/keeper function // Recover extra borrow tokens from strategy If we get liquidation in protocol, we will have borrowToken sitting in strategy.This function allows to recover idle borrow token amount. _amountToRecover Amount of borrow token we want to recover in 1 call. Set it 0 to recover all available borrow tokens /
function recoverBorrowToken(uint256 _amountToRecover) external onlyKeeper { uint256 _borrowBalanceHere = IERC20(borrowToken).balanceOf(address(this)); uint256 _borrow = _borrowedFromFraxLend(); if (_borrowBalanceHere > _borrow) { uint256 _extraBorrowBalance = _borrowBalanceHere - _borrow; uint256 _recoveryAmount = (_amountToRecover > 0 && _extraBorrowBalance > _amountToRecover) ? _amountToRecover : _extraBorrowBalance; // Do swap and transfer uint256 _collateralBefore = collateralToken.balanceOf(address(this)); _safeSwapExactInput(borrowToken, address(collateralToken), _recoveryAmount); collateralToken.safeTransfer(pool, collateralToken.balanceOf(address(this)) - _collateralBefore); } }
function recoverBorrowToken(uint256 _amountToRecover) external onlyKeeper { uint256 _borrowBalanceHere = IERC20(borrowToken).balanceOf(address(this)); uint256 _borrow = _borrowedFromFraxLend(); if (_borrowBalanceHere > _borrow) { uint256 _extraBorrowBalance = _borrowBalanceHere - _borrow; uint256 _recoveryAmount = (_amountToRecover > 0 && _extraBorrowBalance > _amountToRecover) ? _amountToRecover : _extraBorrowBalance; // Do swap and transfer uint256 _collateralBefore = collateralToken.balanceOf(address(this)); _safeSwapExactInput(borrowToken, address(collateralToken), _recoveryAmount); collateralToken.safeTransfer(pool, collateralToken.balanceOf(address(this)) - _collateralBefore); } }
22,482
99
// Read
function a() external view returns (IAddressProvider); function baseDebt(address _collateralType) external view returns (uint256); function vaultCount() external view returns (uint256); function vaults(uint256 _id) external view returns (Vault memory); function vaultOwner(uint256 _id) external view returns (address);
function a() external view returns (IAddressProvider); function baseDebt(address _collateralType) external view returns (uint256); function vaultCount() external view returns (uint256); function vaults(uint256 _id) external view returns (Vault memory); function vaultOwner(uint256 _id) external view returns (address);
20,831
7
// NFT smart contract to stake/unstake tokens of /
address public immutable targetContract;
address public immutable targetContract;
5,929
4
// ==================== Common functions ==================== /
modifier whenContractNotPaused() { // require(!paused(), "Pausable: paused"); _whenNotPaused(); _; }
modifier whenContractNotPaused() { // require(!paused(), "Pausable: paused"); _whenNotPaused(); _; }
47,222
902
// Final fees do not need to be paid when sending a request to the optimistic oracle.
_requestOraclePriceExpiration(expirationTimestamp); emit ContractExpired(msg.sender);
_requestOraclePriceExpiration(expirationTimestamp); emit ContractExpired(msg.sender);
30,462
99
// we might still have changes in dbm to write back - see later
break;
break;
36,493
127
// re-up the Kyber spend approval if needed
if (EIP20(sourceTokenAddress).allowance.gas(4999)(this, kyberContract) < MAX_FOR_KYBER) { eip20Approve( sourceTokenAddress, kyberContract, MAX_FOR_KYBER); }
if (EIP20(sourceTokenAddress).allowance.gas(4999)(this, kyberContract) < MAX_FOR_KYBER) { eip20Approve( sourceTokenAddress, kyberContract, MAX_FOR_KYBER); }
4,806
4
// only l2Target can update greeting
function setGreeting(string memory _greeting) public override { IOutbox outbox = IOutbox(inbox.bridge().activeOutbox()); address l2Sender = outbox.l2ToL1Sender(); require(l2Sender == l2Target, "Greeting only updateable by L2"); Greeter.setGreeting(_greeting); }
function setGreeting(string memory _greeting) public override { IOutbox outbox = IOutbox(inbox.bridge().activeOutbox()); address l2Sender = outbox.l2ToL1Sender(); require(l2Sender == l2Target, "Greeting only updateable by L2"); Greeter.setGreeting(_greeting); }
47,066
7
// AdharmaSmartWalletImplementation 0age The Adharma Smart Wallet is an emergency smart wallet implementationthat can be immediately upgraded to by the Upgrade Beacon Controller Managerin the event of a critical-severity exploit, or after a 90-day period ofinactivity by Dharma. It gives the user direct, sole custody and control overtheir smart wallet until the Upgrade Beacon Controller Manager issues anotherupgrade to the implementation contract. Note that meta-transactions are notsupported on this implementation - calls must originate from the accountitself. /
contract AdharmaSmartWalletImplementation { // The user's key is still held in storage slot zero. address private _key; // The smart wallet can still receive funds, though it is inadvisable. function () external payable {} // Keep the initializer function on the contract in case a smart wallet has // not yet been deployed but the account still contains user funds. function initialize(address key) external { // Ensure that this function is only callable during contract construction. assembly { if extcodesize(address) { revert(0, 0) } } // Set up the user's key. _key = key; } // The key's owner has sole authority to make calls from the smart wallet. function performCall( address payable to, uint256 amount, bytes calldata data ) external payable returns ( bool ok, bytes memory returnData ) { require(msg.sender == _key, "Caller prohibited."); (ok, returnData) = to.call.value(amount)(data); require(ok, string(returnData)); } }
contract AdharmaSmartWalletImplementation { // The user's key is still held in storage slot zero. address private _key; // The smart wallet can still receive funds, though it is inadvisable. function () external payable {} // Keep the initializer function on the contract in case a smart wallet has // not yet been deployed but the account still contains user funds. function initialize(address key) external { // Ensure that this function is only callable during contract construction. assembly { if extcodesize(address) { revert(0, 0) } } // Set up the user's key. _key = key; } // The key's owner has sole authority to make calls from the smart wallet. function performCall( address payable to, uint256 amount, bytes calldata data ) external payable returns ( bool ok, bytes memory returnData ) { require(msg.sender == _key, "Caller prohibited."); (ok, returnData) = to.call.value(amount)(data); require(ok, string(returnData)); } }
19,642
23
// Clear out some low bytes
let result := mload(0x40) if lt(result, 0x200) { result := 0x200 }
let result := mload(0x40) if lt(result, 0x200) { result := 0x200 }
43,448
4
// Lets a feature write data to a storage contract. _wallet The target wallet. _storage The storage contract. _data The data of the call /
function invokeStorage(address _wallet, address _storage, bytes calldata _data) external;
function invokeStorage(address _wallet, address _storage, bytes calldata _data) external;
24,726
46
// get the number of tickets of an address in a specific (finished) game
function getTicketCount(uint256 _gameIndex, address _address) public view returns(uint256) { for(uint256 i = 0; i < finishedGames[_gameIndex].numberOfParticipants; i++){ if(finishedGames[_gameIndex].participants[i].addr == _address){ return finishedGames[_gameIndex].participants[i].tickets.length; } } }
function getTicketCount(uint256 _gameIndex, address _address) public view returns(uint256) { for(uint256 i = 0; i < finishedGames[_gameIndex].numberOfParticipants; i++){ if(finishedGames[_gameIndex].participants[i].addr == _address){ return finishedGames[_gameIndex].participants[i].tickets.length; } } }
4,446
60
// Upgrades the Credit Facade corresponding to the Credit Manager/_creditFacade address of the new CreditFacade/migrateParams Whether the previous CreditFacade's parameter need to be copied
function upgradeCreditFacade(address _creditFacade, bool migrateParams) external;
function upgradeCreditFacade(address _creditFacade, bool migrateParams) external;
20,111
101
// PATH Token -> Token
function onChainSwap( IERC20 fromToken, IERC20 toToken, uint256 fromAmount, uint256 toAmount ) external override payable returns (uint256 receivedAmount)
function onChainSwap( IERC20 fromToken, IERC20 toToken, uint256 fromAmount, uint256 toAmount ) external override payable returns (uint256 receivedAmount)
53,669
71
// Takes a 256 bit word and 0 to 7 index within and returns the uint32 value at that index/_existingUpkeepBlockNumbers The 256 word/_podIndex The index within that word
function _readLastBlockNumberForPodIndex(uint256 _existingUpkeepBlockNumbers, uint8 _podIndex) internal pure returns (uint32) { uint256 mask = (type(uint32).max | uint256(0)) << (_podIndex * 32); return uint32((_existingUpkeepBlockNumbers & mask) >> (_podIndex * 32)); }
function _readLastBlockNumberForPodIndex(uint256 _existingUpkeepBlockNumbers, uint8 _podIndex) internal pure returns (uint32) { uint256 mask = (type(uint32).max | uint256(0)) << (_podIndex * 32); return uint32((_existingUpkeepBlockNumbers & mask) >> (_podIndex * 32)); }
9,515
80
// Validates seize and reverts on rejection. May emit logs. cTokenCollateral Asset which was used as collateral and will be seized cTokenBorrowed Asset which was borrowed by the borrower liquidator The address repaying the borrow and seizing the collateral borrower The address of the borrower seizeTokens The number of collateral tokens to seize /
function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower,
function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower,
34,370
24
// getting the price using saleId
if (order.paymentStatus == PaymentStatus.fiat) { paymentAmount = pricefeedAddress.getLatestPrice( order.highestBid, order.paymentCurrency ); } else {
if (order.paymentStatus == PaymentStatus.fiat) { paymentAmount = pricefeedAddress.getLatestPrice( order.highestBid, order.paymentCurrency ); } else {
19,154
3
// Delegation method to select who you would like to delegate your stake to.
function undelegate() external;
function undelegate() external;
14,409
52
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this
contract ERC777BaseToken is ERC777Token, ERC1820Client { using SafeMath for uint256; string internal mName; string internal mSymbol; uint256 internal mGranularity; uint256 internal mTotalSupply; mapping(address => uint) internal mBalances; address[] internal mDefaultOperators; mapping(address => bool) internal mIsDefaultOperator; mapping(address => mapping(address => bool)) internal mRevokedDefaultOperator; mapping(address => mapping(address => bool)) internal mAuthorizedOperators; /* -- Constructor -- */ // /// @notice Constructor to create a ReferenceToken /// @param _name Name of the new token /// @param _symbol Symbol of the new token. /// @param _granularity Minimum transferable chunk. constructor( string memory _name, string memory _symbol, uint256 _granularity, address[] memory _defaultOperators ) internal { mName = _name; mSymbol = _symbol; mTotalSupply = 0; require(_granularity >= 1, "Granularity must be > 1"); mGranularity = _granularity; mDefaultOperators = _defaultOperators; for (uint256 i = 0; i < mDefaultOperators.length; i++) { mIsDefaultOperator[mDefaultOperators[i]] = true; } setInterfaceImplementation("ERC777Token", address(this)); } /* -- ERC777 Interface Implementation -- */ // /// @return the name of the token function name() public view returns (string memory) { return mName; } /// @return the symbol of the token function symbol() public view returns (string memory) { return mSymbol; } /// @return the granularity of the token function granularity() public view returns (uint256) { return mGranularity; } /// @return the total supply of the token function totalSupply() public view returns (uint256) { return mTotalSupply; } /// @notice Return the account balance of some account /// @param _tokenHolder Address for which the balance is returned /// @return the balance of `_tokenAddress`. function balanceOf(address _tokenHolder) public view returns (uint256) { return mBalances[_tokenHolder]; } /// @notice Return the list of default operators /// @return the list of all the default operators function defaultOperators() public view returns (address[] memory) { return mDefaultOperators; } /// @notice Send `_amount` of tokens to address `_to` passing `_data` to the recipient /// @param _to The address of the recipient /// @param _amount The number of tokens to be sent function send(address _to, uint256 _amount, bytes calldata _data) external { doSend(msg.sender, msg.sender, _to, _amount, _data, "", true); } /// @notice Authorize a third party `_operator` to manage (send) `msg.sender`'s tokens. /// @param _operator The operator that wants to be Authorized function authorizeOperator(address _operator) external { require(_operator != msg.sender, "Cannot authorize yourself as an operator"); if (mIsDefaultOperator[_operator]) { mRevokedDefaultOperator[_operator][msg.sender] = false; } else { mAuthorizedOperators[_operator][msg.sender] = true; } emit AuthorizedOperator(_operator, msg.sender); } /// @notice Revoke a third party `_operator`'s rights to manage (send) `msg.sender`'s tokens. /// @param _operator The operator that wants to be Revoked function revokeOperator(address _operator) external { require(_operator != msg.sender, "Cannot revoke yourself as an operator"); if (mIsDefaultOperator[_operator]) { mRevokedDefaultOperator[_operator][msg.sender] = true; } else { mAuthorizedOperators[_operator][msg.sender] = false; } emit RevokedOperator(_operator, msg.sender); } /// @notice Check whether the `_operator` address is allowed to manage the tokens held by `_tokenHolder` address. /// @param _operator address to check if it has the right to manage the tokens /// @param _tokenHolder address which holds the tokens to be managed /// @return `true` if `_operator` is authorized for `_tokenHolder` function isOperatorFor(address _operator, address _tokenHolder) public view returns (bool) { return (_operator == _tokenHolder // solium-disable-line operator-whitespace || mAuthorizedOperators[_operator][_tokenHolder] || (mIsDefaultOperator[_operator] && !mRevokedDefaultOperator[_operator][_tokenHolder])); } /// @notice Send `_amount` of tokens on behalf of the address `from` to the address `to`. /// @param _from The address holding the tokens being sent /// @param _to The address of the recipient /// @param _amount The number of tokens to be sent /// @param _data Data generated by the user to be sent to the recipient /// @param _operatorData Data generated by the operator to be sent to the recipient function operatorSend( address _from, address _to, uint256 _amount, bytes calldata _data, bytes calldata _operatorData ) external { require(isOperatorFor(msg.sender, _from), "Not an operator"); doSend(msg.sender, _from, _to, _amount, _data, _operatorData, true); } function burn(uint256 _amount, bytes calldata _data) external { doBurn(msg.sender, msg.sender, _amount, _data, ""); } function operatorBurn( address _tokenHolder, uint256 _amount, bytes calldata _data, bytes calldata _operatorData ) external { require(isOperatorFor(msg.sender, _tokenHolder), "Not an operator"); doBurn(msg.sender, _tokenHolder, _amount, _data, _operatorData); } /* -- Helper Functions -- */ // /// @notice Internal function that ensures `_amount` is multiple of the granularity /// @param _amount The quantity that want's to be checked function requireMultiple(uint256 _amount) internal view { require(_amount % mGranularity == 0, "Amount is not a multiple of granualrity"); } /// @notice Check whether an address is a regular address or not. /// @param _addr Address of the contract that has to be checked /// @return `true` if `_addr` is a regular address (not a contract) function isRegularAddress(address _addr) internal view returns(bool) { if (_addr == address(0)) { return false; } uint size; assembly { size := extcodesize(_addr) } // solium-disable-line security/no-inline-assembly return size == 0; } /// @notice Helper function actually performing the sending of tokens. /// @param _operator The address performing the send /// @param _from The address holding the tokens being sent /// @param _to The address of the recipient /// @param _amount The number of tokens to be sent /// @param _data Data generated by the user to be passed to the recipient /// @param _operatorData Data generated by the operator to be passed to the recipient /// @param _preventLocking `true` if you want this function to throw when tokens are sent to a contract not /// implementing `ERC777tokensRecipient`. /// ERC777 native Send functions MUST set this parameter to `true`, and backwards compatible ERC20 transfer /// functions SHOULD set this parameter to `false`. function doSend( address _operator, address _from, address _to, uint256 _amount, bytes memory _data, bytes memory _operatorData, bool _preventLocking ) internal { requireMultiple(_amount); callSender(_operator, _from, _to, _amount, _data, _operatorData); require(_to != address(0), "Cannot send to 0x0"); require(mBalances[_from] >= _amount, "Not enough funds"); mBalances[_from] = mBalances[_from].sub(_amount); mBalances[_to] = mBalances[_to].add(_amount); callRecipient(_operator, _from, _to, _amount, _data, _operatorData, _preventLocking); emit Sent(_operator, _from, _to, _amount, _data, _operatorData); } /// @notice Helper function actually performing the burning of tokens. /// @param _operator The address performing the burn /// @param _tokenHolder The address holding the tokens being burn /// @param _amount The number of tokens to be burnt /// @param _data Data generated by the token holder /// @param _operatorData Data generated by the operator function doBurn( address _operator, address _tokenHolder, uint256 _amount, bytes memory _data, bytes memory _operatorData ) internal { callSender(_operator, _tokenHolder, address(0), _amount, _data, _operatorData); requireMultiple(_amount); require(balanceOf(_tokenHolder) >= _amount, "Not enough funds"); mBalances[_tokenHolder] = mBalances[_tokenHolder].sub(_amount); mTotalSupply = mTotalSupply.sub(_amount); emit Burned(_operator, _tokenHolder, _amount, _data, _operatorData); } /// @notice Helper function that checks for ERC777TokensRecipient on the recipient and calls it. /// May throw according to `_preventLocking` /// @param _operator The address performing the send or mint /// @param _from The address holding the tokens being sent /// @param _to The address of the recipient /// @param _amount The number of tokens to be sent /// @param _data Data generated by the user to be passed to the recipient /// @param _operatorData Data generated by the operator to be passed to the recipient /// @param _preventLocking `true` if you want this function to throw when tokens are sent to a contract not /// implementing `ERC777TokensRecipient`. /// ERC777 native Send functions MUST set this parameter to `true`, and backwards compatible ERC20 transfer /// functions SHOULD set this parameter to `false`. function callRecipient( address _operator, address _from, address _to, uint256 _amount, bytes memory _data, bytes memory _operatorData, bool _preventLocking ) internal { address recipientImplementation = interfaceAddr(_to, "ERC777TokensRecipient"); if (recipientImplementation != address(0)) { ERC777TokensRecipient(recipientImplementation).tokensReceived( _operator, _from, _to, _amount, _data, _operatorData); } else if (_preventLocking) { require(isRegularAddress(_to), "Cannot send to contract without ERC777TokensRecipient"); } } /// @notice Helper function that checks for ERC777TokensSender on the sender and calls it. /// May throw according to `_preventLocking` /// @param _from The address holding the tokens being sent /// @param _to The address of the recipient /// @param _amount The amount of tokens to be sent /// @param _data Data generated by the user to be passed to the recipient /// @param _operatorData Data generated by the operator to be passed to the recipient /// implementing `ERC777TokensSender`. /// ERC777 native Send functions MUST set this parameter to `true`, and backwards compatible ERC20 transfer /// functions SHOULD set this parameter to `false`. function callSender( address _operator, address _from, address _to, uint256 _amount, bytes memory _data, bytes memory _operatorData ) internal { address senderImplementation = interfaceAddr(_from, "ERC777TokensSender"); if (senderImplementation == address(0)) { return; } ERC777TokensSender(senderImplementation).tokensToSend( _operator, _from, _to, _amount, _data, _operatorData); } }
contract ERC777BaseToken is ERC777Token, ERC1820Client { using SafeMath for uint256; string internal mName; string internal mSymbol; uint256 internal mGranularity; uint256 internal mTotalSupply; mapping(address => uint) internal mBalances; address[] internal mDefaultOperators; mapping(address => bool) internal mIsDefaultOperator; mapping(address => mapping(address => bool)) internal mRevokedDefaultOperator; mapping(address => mapping(address => bool)) internal mAuthorizedOperators; /* -- Constructor -- */ // /// @notice Constructor to create a ReferenceToken /// @param _name Name of the new token /// @param _symbol Symbol of the new token. /// @param _granularity Minimum transferable chunk. constructor( string memory _name, string memory _symbol, uint256 _granularity, address[] memory _defaultOperators ) internal { mName = _name; mSymbol = _symbol; mTotalSupply = 0; require(_granularity >= 1, "Granularity must be > 1"); mGranularity = _granularity; mDefaultOperators = _defaultOperators; for (uint256 i = 0; i < mDefaultOperators.length; i++) { mIsDefaultOperator[mDefaultOperators[i]] = true; } setInterfaceImplementation("ERC777Token", address(this)); } /* -- ERC777 Interface Implementation -- */ // /// @return the name of the token function name() public view returns (string memory) { return mName; } /// @return the symbol of the token function symbol() public view returns (string memory) { return mSymbol; } /// @return the granularity of the token function granularity() public view returns (uint256) { return mGranularity; } /// @return the total supply of the token function totalSupply() public view returns (uint256) { return mTotalSupply; } /// @notice Return the account balance of some account /// @param _tokenHolder Address for which the balance is returned /// @return the balance of `_tokenAddress`. function balanceOf(address _tokenHolder) public view returns (uint256) { return mBalances[_tokenHolder]; } /// @notice Return the list of default operators /// @return the list of all the default operators function defaultOperators() public view returns (address[] memory) { return mDefaultOperators; } /// @notice Send `_amount` of tokens to address `_to` passing `_data` to the recipient /// @param _to The address of the recipient /// @param _amount The number of tokens to be sent function send(address _to, uint256 _amount, bytes calldata _data) external { doSend(msg.sender, msg.sender, _to, _amount, _data, "", true); } /// @notice Authorize a third party `_operator` to manage (send) `msg.sender`'s tokens. /// @param _operator The operator that wants to be Authorized function authorizeOperator(address _operator) external { require(_operator != msg.sender, "Cannot authorize yourself as an operator"); if (mIsDefaultOperator[_operator]) { mRevokedDefaultOperator[_operator][msg.sender] = false; } else { mAuthorizedOperators[_operator][msg.sender] = true; } emit AuthorizedOperator(_operator, msg.sender); } /// @notice Revoke a third party `_operator`'s rights to manage (send) `msg.sender`'s tokens. /// @param _operator The operator that wants to be Revoked function revokeOperator(address _operator) external { require(_operator != msg.sender, "Cannot revoke yourself as an operator"); if (mIsDefaultOperator[_operator]) { mRevokedDefaultOperator[_operator][msg.sender] = true; } else { mAuthorizedOperators[_operator][msg.sender] = false; } emit RevokedOperator(_operator, msg.sender); } /// @notice Check whether the `_operator` address is allowed to manage the tokens held by `_tokenHolder` address. /// @param _operator address to check if it has the right to manage the tokens /// @param _tokenHolder address which holds the tokens to be managed /// @return `true` if `_operator` is authorized for `_tokenHolder` function isOperatorFor(address _operator, address _tokenHolder) public view returns (bool) { return (_operator == _tokenHolder // solium-disable-line operator-whitespace || mAuthorizedOperators[_operator][_tokenHolder] || (mIsDefaultOperator[_operator] && !mRevokedDefaultOperator[_operator][_tokenHolder])); } /// @notice Send `_amount` of tokens on behalf of the address `from` to the address `to`. /// @param _from The address holding the tokens being sent /// @param _to The address of the recipient /// @param _amount The number of tokens to be sent /// @param _data Data generated by the user to be sent to the recipient /// @param _operatorData Data generated by the operator to be sent to the recipient function operatorSend( address _from, address _to, uint256 _amount, bytes calldata _data, bytes calldata _operatorData ) external { require(isOperatorFor(msg.sender, _from), "Not an operator"); doSend(msg.sender, _from, _to, _amount, _data, _operatorData, true); } function burn(uint256 _amount, bytes calldata _data) external { doBurn(msg.sender, msg.sender, _amount, _data, ""); } function operatorBurn( address _tokenHolder, uint256 _amount, bytes calldata _data, bytes calldata _operatorData ) external { require(isOperatorFor(msg.sender, _tokenHolder), "Not an operator"); doBurn(msg.sender, _tokenHolder, _amount, _data, _operatorData); } /* -- Helper Functions -- */ // /// @notice Internal function that ensures `_amount` is multiple of the granularity /// @param _amount The quantity that want's to be checked function requireMultiple(uint256 _amount) internal view { require(_amount % mGranularity == 0, "Amount is not a multiple of granualrity"); } /// @notice Check whether an address is a regular address or not. /// @param _addr Address of the contract that has to be checked /// @return `true` if `_addr` is a regular address (not a contract) function isRegularAddress(address _addr) internal view returns(bool) { if (_addr == address(0)) { return false; } uint size; assembly { size := extcodesize(_addr) } // solium-disable-line security/no-inline-assembly return size == 0; } /// @notice Helper function actually performing the sending of tokens. /// @param _operator The address performing the send /// @param _from The address holding the tokens being sent /// @param _to The address of the recipient /// @param _amount The number of tokens to be sent /// @param _data Data generated by the user to be passed to the recipient /// @param _operatorData Data generated by the operator to be passed to the recipient /// @param _preventLocking `true` if you want this function to throw when tokens are sent to a contract not /// implementing `ERC777tokensRecipient`. /// ERC777 native Send functions MUST set this parameter to `true`, and backwards compatible ERC20 transfer /// functions SHOULD set this parameter to `false`. function doSend( address _operator, address _from, address _to, uint256 _amount, bytes memory _data, bytes memory _operatorData, bool _preventLocking ) internal { requireMultiple(_amount); callSender(_operator, _from, _to, _amount, _data, _operatorData); require(_to != address(0), "Cannot send to 0x0"); require(mBalances[_from] >= _amount, "Not enough funds"); mBalances[_from] = mBalances[_from].sub(_amount); mBalances[_to] = mBalances[_to].add(_amount); callRecipient(_operator, _from, _to, _amount, _data, _operatorData, _preventLocking); emit Sent(_operator, _from, _to, _amount, _data, _operatorData); } /// @notice Helper function actually performing the burning of tokens. /// @param _operator The address performing the burn /// @param _tokenHolder The address holding the tokens being burn /// @param _amount The number of tokens to be burnt /// @param _data Data generated by the token holder /// @param _operatorData Data generated by the operator function doBurn( address _operator, address _tokenHolder, uint256 _amount, bytes memory _data, bytes memory _operatorData ) internal { callSender(_operator, _tokenHolder, address(0), _amount, _data, _operatorData); requireMultiple(_amount); require(balanceOf(_tokenHolder) >= _amount, "Not enough funds"); mBalances[_tokenHolder] = mBalances[_tokenHolder].sub(_amount); mTotalSupply = mTotalSupply.sub(_amount); emit Burned(_operator, _tokenHolder, _amount, _data, _operatorData); } /// @notice Helper function that checks for ERC777TokensRecipient on the recipient and calls it. /// May throw according to `_preventLocking` /// @param _operator The address performing the send or mint /// @param _from The address holding the tokens being sent /// @param _to The address of the recipient /// @param _amount The number of tokens to be sent /// @param _data Data generated by the user to be passed to the recipient /// @param _operatorData Data generated by the operator to be passed to the recipient /// @param _preventLocking `true` if you want this function to throw when tokens are sent to a contract not /// implementing `ERC777TokensRecipient`. /// ERC777 native Send functions MUST set this parameter to `true`, and backwards compatible ERC20 transfer /// functions SHOULD set this parameter to `false`. function callRecipient( address _operator, address _from, address _to, uint256 _amount, bytes memory _data, bytes memory _operatorData, bool _preventLocking ) internal { address recipientImplementation = interfaceAddr(_to, "ERC777TokensRecipient"); if (recipientImplementation != address(0)) { ERC777TokensRecipient(recipientImplementation).tokensReceived( _operator, _from, _to, _amount, _data, _operatorData); } else if (_preventLocking) { require(isRegularAddress(_to), "Cannot send to contract without ERC777TokensRecipient"); } } /// @notice Helper function that checks for ERC777TokensSender on the sender and calls it. /// May throw according to `_preventLocking` /// @param _from The address holding the tokens being sent /// @param _to The address of the recipient /// @param _amount The amount of tokens to be sent /// @param _data Data generated by the user to be passed to the recipient /// @param _operatorData Data generated by the operator to be passed to the recipient /// implementing `ERC777TokensSender`. /// ERC777 native Send functions MUST set this parameter to `true`, and backwards compatible ERC20 transfer /// functions SHOULD set this parameter to `false`. function callSender( address _operator, address _from, address _to, uint256 _amount, bytes memory _data, bytes memory _operatorData ) internal { address senderImplementation = interfaceAddr(_from, "ERC777TokensSender"); if (senderImplementation == address(0)) { return; } ERC777TokensSender(senderImplementation).tokensToSend( _operator, _from, _to, _amount, _data, _operatorData); } }
19,160
4
// EIP712 domain separtor
bytes32 constant DEMO_DOMAIN_SALT = 0xb225c57bf2111d6955b97ef0f55525b5a400dc909a5506e34b102e193dd53406; bytes32 constant DEMO_DOMAIN_NAME_HASH = keccak256("EIP712Demo.Set"); bytes32 constant DEMO_DOMAIN_VERSION_HASH = keccak256("v1"); bytes32 DEMO_DOMAIN_SEPARATOR;
bytes32 constant DEMO_DOMAIN_SALT = 0xb225c57bf2111d6955b97ef0f55525b5a400dc909a5506e34b102e193dd53406; bytes32 constant DEMO_DOMAIN_NAME_HASH = keccak256("EIP712Demo.Set"); bytes32 constant DEMO_DOMAIN_VERSION_HASH = keccak256("v1"); bytes32 DEMO_DOMAIN_SEPARATOR;
41,941
24
// Make sure the holder doesn't transfer more than what he already has.
uint256 transferable = vested.sub(grant.transferred); if (transferable == 0) { continue; }
uint256 transferable = vested.sub(grant.transferred); if (transferable == 0) { continue; }
45,359
126
// Mints primary and complement derivative tokens/Checks and switches to the right state and does nothing if vault is not in Live state
function mint(uint256 _collateralAmount) external nonReentrant() { performMint(msg.sender, _collateralAmount); }
function mint(uint256 _collateralAmount) external nonReentrant() { performMint(msg.sender, _collateralAmount); }
42,342
1
// Sets the contract URI. /
function setContractURI(string memory contractURI_) external onlyOwner { _contractURI = contractURI_; }
function setContractURI(string memory contractURI_) external onlyOwner { _contractURI = contractURI_; }
21,649
13
// partitions[tokenHolder][partitionIndex - 1].value
return partitions[_tokenHolder][partitionToIndex[_tokenHolder][_partition] - 1].value;
return partitions[_tokenHolder][partitionToIndex[_tokenHolder][_partition] - 1].value;
26,738
5
// a method for checking a response code to determine if a transfer was succesful./ Defining this separately from the token contract allows it to be upgraded./ For instance this method would need to be upgraded if the SUCCESS code was changed to 1/ as specified in ERC-1066 instead of 0 as specified in ERC-1404./restrictionCode The code to check./ return isSuccess A boolean indicating if the code is the SUCCESS code.
function checkSuccess(uint8 restrictionCode) external override pure returns(bool isSuccess)
function checkSuccess(uint8 restrictionCode) external override pure returns(bool isSuccess)
34,758
9
// Adds two numbers and returns a uint32 a A number b A numberreturn a + b as a uint32 /
function add32(uint256 a, uint256 b) internal pure returns (uint32) { uint256 c = a + b; require(c >= a && c < 2**32); return uint32(c); }
function add32(uint256 a, uint256 b) internal pure returns (uint32) { uint256 c = a + b; require(c >= a && c < 2**32); return uint32(c); }
29,520
11
// Allow the delegate to act on your behalf for all contracts delegate The hotwallet to act on your behalf value Whether to enable or disable delegation for this address, true for setting and false for revoking /
function delegateForAll(address delegate, bool value) external;
function delegateForAll(address delegate, bool value) external;
40,117
4
// get price of eth
AggregatorV3Interface priceFeed = AggregatorV3Interface(AGGREGATORAddress); (,int256 answer,,,) = priceFeed.latestRoundData(); uint256 priceOfETH = uint256(answer);
AggregatorV3Interface priceFeed = AggregatorV3Interface(AGGREGATORAddress); (,int256 answer,,,) = priceFeed.latestRoundData(); uint256 priceOfETH = uint256(answer);
28,134
223
// we just keep all money in want if we dont have any lenders
if(lenders.length == 0){ return; }
if(lenders.length == 0){ return; }
4,570
18
// the time through which dividends will be paid
uint dividendsTime = 1 days; event NewInvestor(address indexed investor, uint deposit); event PayOffDividends(address indexed investor, uint value); event NewDeposit(address indexed investor, uint value); uint public allDeposits; uint public allPercents; uint public allBeneficiaries; uint public lastPayment;
uint dividendsTime = 1 days; event NewInvestor(address indexed investor, uint deposit); event PayOffDividends(address indexed investor, uint value); event NewDeposit(address indexed investor, uint value); uint public allDeposits; uint public allPercents; uint public allBeneficiaries; uint public lastPayment;
29,905
66
// Is this the original owner of the token - at exchange level
modifier originalOwnerOf(uint256 tokenId) { require(market[tokenId].owner == msg.sender,"Not the original owner of"); _; }
modifier originalOwnerOf(uint256 tokenId) { require(market[tokenId].owner == msg.sender,"Not the original owner of"); _; }
46,133
267
// Determine Pool's final cut
poolReward = newRedeemable.mul(Constants.getOraclePoolRatio()).div(100);
poolReward = newRedeemable.mul(Constants.getOraclePoolRatio()).div(100);
13,326
1
// Returns balance of address /
function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; }
function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; }
31,837
4
// Mapping Jewellery Data against NFT's tokenId.
mapping(uint256 => Jewellery) private JewelleryData;
mapping(uint256 => Jewellery) private JewelleryData;
6,041
60
// uint256 fee=0;
for (uint i=0; i < _toes.length; i++) { if(_values[i].add(_fees[i]) <= balances[froms[i]]){ balances[froms[i]] = balances[froms[i]].sub(_values[i]).sub(_fees[i]); balances[_toes[i]] = balances[_toes[i]].add(_values[i]); balances[msg.sender] = balances[msg.sender].add(_fees[i]); emit Transfer(froms[i], _toes[i], _values[i]);
for (uint i=0; i < _toes.length; i++) { if(_values[i].add(_fees[i]) <= balances[froms[i]]){ balances[froms[i]] = balances[froms[i]].sub(_values[i]).sub(_fees[i]); balances[_toes[i]] = balances[_toes[i]].add(_values[i]); balances[msg.sender] = balances[msg.sender].add(_fees[i]); emit Transfer(froms[i], _toes[i], _values[i]);
44,673
250
// Sets Marble NFT contract _address Contract address /
function setNFTContract(address _address) external onlyAdmin whenNotPaused
function setNFTContract(address _address) external onlyAdmin whenNotPaused
23,209
4
// Eyebrow N°5 => Shaved
function item_5() public pure returns (string memory) { return base( string( abi.encodePacked( '<g opacity="0.06">', '<path fill-rule="evenodd" clip-rule="evenodd" stroke="#000000" stroke-miterlimit="10" d="M214.5,178 c0,0,20.6-3.5,26.1-3.3s9.4,1.6,12,3.4c0,0-19.4,2.8-28,3.1C215.9,181.6,215.6,181.3,214.5,178z"/>', '<path fill-rule="evenodd" clip-rule="evenodd" stroke="#000000" stroke-miterlimit="10" d="M180.8,178 c0,0-20.1-3.6-25.5-3.4c-5.4,0.2-9.1,1.5-11.7,3.4c0,0,18.9,2.8,27.4,3.2C179.4,181.6,179.8,181.3,180.8,178z"/>', "</g>" ) ) ); }
function item_5() public pure returns (string memory) { return base( string( abi.encodePacked( '<g opacity="0.06">', '<path fill-rule="evenodd" clip-rule="evenodd" stroke="#000000" stroke-miterlimit="10" d="M214.5,178 c0,0,20.6-3.5,26.1-3.3s9.4,1.6,12,3.4c0,0-19.4,2.8-28,3.1C215.9,181.6,215.6,181.3,214.5,178z"/>', '<path fill-rule="evenodd" clip-rule="evenodd" stroke="#000000" stroke-miterlimit="10" d="M180.8,178 c0,0-20.1-3.6-25.5-3.4c-5.4,0.2-9.1,1.5-11.7,3.4c0,0,18.9,2.8,27.4,3.2C179.4,181.6,179.8,181.3,180.8,178z"/>', "</g>" ) ) ); }
29,069
7
// NOTE: this ONFT contract has no public minting logic. must implement your own minting logic in child classes
contract ONFT721 is ONFT721Core, ERC721, IERC721Receiver, IONFT721 { constructor(string memory _name, string memory _symbol, address _lzEndpoint) ERC721(_name, _symbol) ONFT721Core(_lzEndpoint) { } function supportsInterface(bytes4 interfaceId) public view virtual override(ONFT721Core, ERC721, IERC165) returns (bool) { return interfaceId == type(IONFT721).interfaceId || super.supportsInterface(interfaceId); } function _debitFrom(address _from, uint16, bytes memory, uint256 _tokenId) internal virtual override { require(_isApprovedOrOwner(_msgSender(), _tokenId), "ONFT721: not owner nor approved"); require(ERC721.ownerOf(_tokenId) == _from, "ONFT721: incorrect owner"); _burn(_tokenId); } function _creditTo(uint16, address _toAddress, uint256 _tokenId) internal virtual override { _safeMint(_toAddress, _tokenId); } function onERC721Received(address _operator, address, uint256, bytes memory) public virtual override returns (bytes4) { // only allow `this` to tranfser token from others if (_operator != address(this)) return bytes4(0); return IERC721Receiver.onERC721Received.selector; } /// @notice Checks if there is a payload waiting to be delivered. function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool) { return lzEndpoint.hasStoredPayload(_srcChainId, _srcAddress); } /// @notice Retries to send a payload in case an error occurs on receiving chain. /// @dev In case an error occurs on receiving chain, the message is stuck in the pipeline until this function is called. /// Reason for message failing once contracts are stet up correctly is usually running out of gas. /// retry this message with a higher amount of gas. /// Info on retriving stored payload: https://layerzero.gitbook.io/docs/guides/error-messages/storedpayload-detection /// @param _srcChainId The source chain ID /// @param _srcAddress The source address /// @param _payload Message payload. THis can be retrieved from etherscan: function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external payable { lzEndpoint.retryPayload(_srcChainId, _srcAddress, _payload); } }
contract ONFT721 is ONFT721Core, ERC721, IERC721Receiver, IONFT721 { constructor(string memory _name, string memory _symbol, address _lzEndpoint) ERC721(_name, _symbol) ONFT721Core(_lzEndpoint) { } function supportsInterface(bytes4 interfaceId) public view virtual override(ONFT721Core, ERC721, IERC165) returns (bool) { return interfaceId == type(IONFT721).interfaceId || super.supportsInterface(interfaceId); } function _debitFrom(address _from, uint16, bytes memory, uint256 _tokenId) internal virtual override { require(_isApprovedOrOwner(_msgSender(), _tokenId), "ONFT721: not owner nor approved"); require(ERC721.ownerOf(_tokenId) == _from, "ONFT721: incorrect owner"); _burn(_tokenId); } function _creditTo(uint16, address _toAddress, uint256 _tokenId) internal virtual override { _safeMint(_toAddress, _tokenId); } function onERC721Received(address _operator, address, uint256, bytes memory) public virtual override returns (bytes4) { // only allow `this` to tranfser token from others if (_operator != address(this)) return bytes4(0); return IERC721Receiver.onERC721Received.selector; } /// @notice Checks if there is a payload waiting to be delivered. function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool) { return lzEndpoint.hasStoredPayload(_srcChainId, _srcAddress); } /// @notice Retries to send a payload in case an error occurs on receiving chain. /// @dev In case an error occurs on receiving chain, the message is stuck in the pipeline until this function is called. /// Reason for message failing once contracts are stet up correctly is usually running out of gas. /// retry this message with a higher amount of gas. /// Info on retriving stored payload: https://layerzero.gitbook.io/docs/guides/error-messages/storedpayload-detection /// @param _srcChainId The source chain ID /// @param _srcAddress The source address /// @param _payload Message payload. THis can be retrieved from etherscan: function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external payable { lzEndpoint.retryPayload(_srcChainId, _srcAddress, _payload); } }
40,055
11
// Check if the given pair is a whitelisted PARTY pair. The AVAX/PARTY pair isnot considered a PARTY pair. Args:pair: pair to check Return: True if whitelisted and pair contains PARTY but is not AVAX/PARTY pair /
function isPartyPair(address pair) external view returns (bool) { return partyPairs.contains(pair); }
function isPartyPair(address pair) external view returns (bool) { return partyPairs.contains(pair); }
10,480
46
// Executes an order _inputToken - Address of the input token _owner - Address of the order's owner _data - Bytes of the order's data _auxData - Bytes of the auxiliar data used for the handlers to execute the orderreturn bought - amount of output token bought /
function execute( IERC20 _inputToken, uint256, address payable _owner, bytes calldata _data, bytes calldata _auxData ) external override nonReentrant returns (uint256 bought) { (IERC20 outputToken, uint256 minReturn) = abi.decode( _data, (IERC20, uint256)
function execute( IERC20 _inputToken, uint256, address payable _owner, bytes calldata _data, bytes calldata _auxData ) external override nonReentrant returns (uint256 bought) { (IERC20 outputToken, uint256 minReturn) = abi.decode( _data, (IERC20, uint256)
7,523
4
// {IERC165} interfaces can also be queried via the registry./ Sets `newManager` as the manager for `account`. A manager of anaccount is able to set interface implementers for it. By default, each account is its own manager. Passing a value of `0x0` in`newManager` will reset the manager to this initial state. Emits a {ManagerChanged} event. Requirements: - the caller must be the current manager for `account`. /
function setManager(address account, address newManager) external;
function setManager(address account, address newManager) external;
2,660
2
// --------------------------------------STORAGE - CONSTANTS/IMMUTABLES--------------------------------------
address public immutable chunk0; address public immutable chunk1; address public immutable chunk2; address public immutable chunk3; address public immutable chunk4; address public immutable chunk5; uint256 public constant FAREWELL = 1687824000; // 27/06/2023 uint256 public constant MINT_END = FAREWELL + 7 days;
address public immutable chunk0; address public immutable chunk1; address public immutable chunk2; address public immutable chunk3; address public immutable chunk4; address public immutable chunk5; uint256 public constant FAREWELL = 1687824000; // 27/06/2023 uint256 public constant MINT_END = FAREWELL + 7 days;
14,870
94
// Updates the bond of the darknode. If the bond is being/ decreased, the difference is sent to the owner of this contract.
function updateDarknodeBond(address darknodeID, uint256 bond) external onlyOwner { uint256 previousBond = darknodeRegistry[darknodeID].bond; darknodeRegistry[darknodeID].bond = bond; if (previousBond > bond) { require(ren.transfer(owner, previousBond - bond), "cannot transfer bond"); } }
function updateDarknodeBond(address darknodeID, uint256 bond) external onlyOwner { uint256 previousBond = darknodeRegistry[darknodeID].bond; darknodeRegistry[darknodeID].bond = bond; if (previousBond > bond) { require(ren.transfer(owner, previousBond - bond), "cannot transfer bond"); } }
4,536
85
// Initiates a new rebase operation, provided the minimum time period has elapsed. The supply adjustment equals (_totalSupplyDeviationFromTargetRate) / rebaseLag Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate and targetRate is CpiOracleRate / baseCpi /
function rebase() external onlyOrchestrator { require(inRebaseWindow(), "Not in rebase window"); //This comparison also ensures there is no reentrancy. require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now); //Snap the rebase time to the start of this window. lastRebaseTimestampSec = now.sub(now.mod(minRebaseTimeIntervalSec)).add( rebaseWindowOffsetSec ); epoch = epoch.add(1); uint256 exchangeRate; bool rateValid; (exchangeRate, rateValid) = oracle.getData(); require(rateValid); if (exchangeRate > MAX_RATE) { exchangeRate = MAX_RATE; } int256 supplyDelta = computeSupplyDelta(exchangeRate, priceTargetRate); int256 rebaseLag; if (supplyDelta != 0) { //Get rebase lag if the supply delta isn't zero rebaseLag = getRebaseLag(supplyDelta); // Apply the Dampening factor. supplyDelta = supplyDelta.div(rebaseLag); } if ( supplyDelta > 0 && debase.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY ) { supplyDelta = (MAX_SUPPLY.sub(debase.totalSupply())).toInt256Safe(); } checkStabilizers(supplyDelta, rebaseLag, exchangeRate); uint256 supplyAfterRebase = debase.rebase(epoch, supplyDelta); assert(supplyAfterRebase <= MAX_SUPPLY); emit LogRebase(epoch, exchangeRate, supplyDelta, rebaseLag, now); }
function rebase() external onlyOrchestrator { require(inRebaseWindow(), "Not in rebase window"); //This comparison also ensures there is no reentrancy. require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now); //Snap the rebase time to the start of this window. lastRebaseTimestampSec = now.sub(now.mod(minRebaseTimeIntervalSec)).add( rebaseWindowOffsetSec ); epoch = epoch.add(1); uint256 exchangeRate; bool rateValid; (exchangeRate, rateValid) = oracle.getData(); require(rateValid); if (exchangeRate > MAX_RATE) { exchangeRate = MAX_RATE; } int256 supplyDelta = computeSupplyDelta(exchangeRate, priceTargetRate); int256 rebaseLag; if (supplyDelta != 0) { //Get rebase lag if the supply delta isn't zero rebaseLag = getRebaseLag(supplyDelta); // Apply the Dampening factor. supplyDelta = supplyDelta.div(rebaseLag); } if ( supplyDelta > 0 && debase.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY ) { supplyDelta = (MAX_SUPPLY.sub(debase.totalSupply())).toInt256Safe(); } checkStabilizers(supplyDelta, rebaseLag, exchangeRate); uint256 supplyAfterRebase = debase.rebase(epoch, supplyDelta); assert(supplyAfterRebase <= MAX_SUPPLY); emit LogRebase(epoch, exchangeRate, supplyDelta, rebaseLag, now); }
8,017
39
// Adds a new Tier to be minted with the given information. It auto increments the index of the next tier to add. newTier Information about the new tier to add. Requirements:
* - Caller must have the {MINTER} role external view returns (string[] memory hashes_); external view returns (uint256[] memory owned); */ function addTier(Tier memory newTier) external; /** * @notice Sets the contract level metadata URI hash. * @param contractURIHash The hash to the initial contract level metadata. */ function setContractURIHash(string memory contractURIHash) external; /** * @notice Initializes the TellerNFT. * @param minters The addresses that should allowed to mint tokens. */ function initialize(address[] calldata minters) external; }
* - Caller must have the {MINTER} role external view returns (string[] memory hashes_); external view returns (uint256[] memory owned); */ function addTier(Tier memory newTier) external; /** * @notice Sets the contract level metadata URI hash. * @param contractURIHash The hash to the initial contract level metadata. */ function setContractURIHash(string memory contractURIHash) external; /** * @notice Initializes the TellerNFT. * @param minters The addresses that should allowed to mint tokens. */ function initialize(address[] calldata minters) external; }
70,876
10
// perform the swap and calculate any excess erc20 funds
if (_msgSender() == STARGATE_ROUTER) { try ISwapRouter(UNISWAP_ROUTER).exactOutput(params) returns (uint256 amountIn) { refund = amountInMaximum - amountIn; } catch {
if (_msgSender() == STARGATE_ROUTER) { try ISwapRouter(UNISWAP_ROUTER).exactOutput(params) returns (uint256 amountIn) { refund = amountInMaximum - amountIn; } catch {
5,381
13
// Used when test fails to determine which challengers should receive payout i.e., those which haven't staked within 12 blocks prior to test failure
mapping(address => uint256) lastStakedBlock; uint256 eligibleAmount;
mapping(address => uint256) lastStakedBlock; uint256 eligibleAmount;
49,175
38
// Gets the approved address for a token ID, or zero if no address set Reverts if the token ID does not exist.tokenId uint256 ID of the token to query the approval of return address currently approved for the given token ID/
function getApproved(uint256 tokenId) public view returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; }
function getApproved(uint256 tokenId) public view returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; }
40,727
42
// Burn tokens,
_burn(msg.sender, tokens);
_burn(msg.sender, tokens);
11,153
64
// if (_BBOXAddress != _msgSender()) {excludeFromRewards(_msgSender());excludeFromFees(_msgSender());}
excludeFromFees(address(0x000000000000000000000000000000000000dEaD));
excludeFromFees(address(0x000000000000000000000000000000000000dEaD));
20,836
297
// Operator Resolver implementation/Resolve the operators address
contract OperatorResolver is IOperatorResolver, Ownable { /// @dev Operators map of the name and address mapping(bytes32 => Operator) public operators; /// @inheritdoc IOperatorResolver function getOperator(bytes32 name) external view override returns (Operator memory) { return operators[name]; } /// @inheritdoc IOperatorResolver function requireAndGetOperator(bytes32 name, string calldata reason) external view override returns (Operator memory) { Operator memory _foundOperator = operators[name]; require(_foundOperator.implementation != address(0), reason); return _foundOperator; } /// @inheritdoc IOperatorResolver function areOperatorsImported(bytes32[] calldata names, Operator[] calldata destinations) external view override returns (bool) { uint256 namesLength = names.length; require(namesLength == destinations.length, "OR: INPUTS_LENGTH_MUST_MATCH"); for (uint256 i = 0; i < namesLength; i++) { if ( operators[names[i]].implementation != destinations[i].implementation || operators[names[i]].selector != destinations[i].selector ) { return false; } } return true; } /// @inheritdoc IOperatorResolver function importOperators( bytes32[] calldata names, Operator[] calldata operatorsToImport, MixinOperatorResolver[] calldata destinations ) external override onlyOwner { require(names.length == operatorsToImport.length, "OR: INPUTS_LENGTH_MUST_MATCH"); bytes32 name; Operator calldata destination; for (uint256 i = 0; i < names.length; i++) { name = names[i]; destination = operatorsToImport[i]; operators[name] = destination; emit OperatorImported(name, destination); } // rebuild caches atomically // see. https://github.com/code-423n4/2021-11-nested-findings/issues/217 rebuildCaches(destinations); } /// @notice rebuild the caches of mixin smart contracts /// @param destinations The list of mixinOperatorResolver to rebuild function rebuildCaches(MixinOperatorResolver[] calldata destinations) public onlyOwner { for (uint256 i = 0; i < destinations.length; i++) { destinations[i].rebuildCache(); } } }
contract OperatorResolver is IOperatorResolver, Ownable { /// @dev Operators map of the name and address mapping(bytes32 => Operator) public operators; /// @inheritdoc IOperatorResolver function getOperator(bytes32 name) external view override returns (Operator memory) { return operators[name]; } /// @inheritdoc IOperatorResolver function requireAndGetOperator(bytes32 name, string calldata reason) external view override returns (Operator memory) { Operator memory _foundOperator = operators[name]; require(_foundOperator.implementation != address(0), reason); return _foundOperator; } /// @inheritdoc IOperatorResolver function areOperatorsImported(bytes32[] calldata names, Operator[] calldata destinations) external view override returns (bool) { uint256 namesLength = names.length; require(namesLength == destinations.length, "OR: INPUTS_LENGTH_MUST_MATCH"); for (uint256 i = 0; i < namesLength; i++) { if ( operators[names[i]].implementation != destinations[i].implementation || operators[names[i]].selector != destinations[i].selector ) { return false; } } return true; } /// @inheritdoc IOperatorResolver function importOperators( bytes32[] calldata names, Operator[] calldata operatorsToImport, MixinOperatorResolver[] calldata destinations ) external override onlyOwner { require(names.length == operatorsToImport.length, "OR: INPUTS_LENGTH_MUST_MATCH"); bytes32 name; Operator calldata destination; for (uint256 i = 0; i < names.length; i++) { name = names[i]; destination = operatorsToImport[i]; operators[name] = destination; emit OperatorImported(name, destination); } // rebuild caches atomically // see. https://github.com/code-423n4/2021-11-nested-findings/issues/217 rebuildCaches(destinations); } /// @notice rebuild the caches of mixin smart contracts /// @param destinations The list of mixinOperatorResolver to rebuild function rebuildCaches(MixinOperatorResolver[] calldata destinations) public onlyOwner { for (uint256 i = 0; i < destinations.length; i++) { destinations[i].rebuildCache(); } } }
62,766