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
130
// get token amount which has a max price impact of 2.5% for sells !!IMPORTANT!! => Any functions using return value from this MUST call `sync` on the pair before calling this function!
function getMaxSwappableAmount() public view returns (uint) { uint tokensAvailable = Token(trustedRewardTokenAddress).balanceOf(trustedDepositTokenAddress); uint maxSwappableAmount = tokensAvailable.mul(MAGIC_NUMBER).div(1e18); return maxSwappableAmount; }
function getMaxSwappableAmount() public view returns (uint) { uint tokensAvailable = Token(trustedRewardTokenAddress).balanceOf(trustedDepositTokenAddress); uint maxSwappableAmount = tokensAvailable.mul(MAGIC_NUMBER).div(1e18); return maxSwappableAmount; }
68,990
2
// check `assetInfo()` for more information
enum AssetType { TOKEN, LIQUIDITY }
enum AssetType { TOKEN, LIQUIDITY }
42,202
0
// Throws if called by any account other than the minter. /
modifier onlyGameContractOrOwner() { require(gameContracts[_msgSender()] || _msgSender() == owner(), "Caller is not game contract nor owner"); _; }
modifier onlyGameContractOrOwner() { require(gameContracts[_msgSender()] || _msgSender() == owner(), "Caller is not game contract nor owner"); _; }
2,980
20
// create new Round on behalf of the lender, each deposit has its own round `lender` must approve the amount to be deposited first only `Owner` can launch a new round add new round to `_lenderRounds` `amount` will be transferred from `lender` to `address(this)` emits Deposit event lender, address of the lender amount, amount to be deposited by the lender, must be greater than minimumDeposit bonusAPY, bonus ratio to be applied paidTrade, specifies whether if stable rewards will be paid in Trade(true) or in stable(false) /
function newRound( address lender, uint amount, uint16 bonusAPY, bool paidTrade
function newRound( address lender, uint amount, uint16 bonusAPY, bool paidTrade
17,538
23
// TODO: transfer `_value` tokens from `_from` to `_to`
require(_value <= balances[_from]); require(_value >= 1); require(_value <= allowances[_from][msg.sender]); balances[_from] -= _value; balances[_to] += _value; allowances[_from][msg.sender] -= _value; emit Transfer(_from,_to,_value); return true;
require(_value <= balances[_from]); require(_value >= 1); require(_value <= allowances[_from][msg.sender]); balances[_from] -= _value; balances[_to] += _value; allowances[_from][msg.sender] -= _value; emit Transfer(_from,_to,_value); return true;
3,614
51
// Pair[token][isSupply] supply = true, borrow = false
mapping (address => mapping (address => mapping (bool => PoolPosition))) public pidByPairToken;
mapping (address => mapping (address => mapping (bool => PoolPosition))) public pidByPairToken;
45,996
25
// Withdraw Tokens /
function withdrawTokens(uint256 _id) public { require(block.timestamp >= lockedToken[_id].unlockTime); require(msg.sender == lockedToken[_id].withdrawalAddress); require(!lockedToken[_id].withdrawn); lockedToken[_id].withdrawn = true; /* update balance in address */ walletTokenBalance[lockedToken[_id].tokenAddress][msg.sender] = walletTokenBalance[lockedToken[_id].tokenAddress][msg.sender].sub(lockedToken[_id].tokenAmount); /* remove this id from this address */ uint256 j; uint256 arrLength = depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress].length; for (j=0; j<arrLength; j++) { if (depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress][j] == _id) { depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress][j] = depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress][arrLength - 1]; depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress].pop(); break; } } /* transfer tokens to wallet address */ require(Token(lockedToken[_id].tokenAddress).transfer(msg.sender, lockedToken[_id].tokenAmount)); emit LogWithdrawal(msg.sender, lockedToken[_id].tokenAmount); }
function withdrawTokens(uint256 _id) public { require(block.timestamp >= lockedToken[_id].unlockTime); require(msg.sender == lockedToken[_id].withdrawalAddress); require(!lockedToken[_id].withdrawn); lockedToken[_id].withdrawn = true; /* update balance in address */ walletTokenBalance[lockedToken[_id].tokenAddress][msg.sender] = walletTokenBalance[lockedToken[_id].tokenAddress][msg.sender].sub(lockedToken[_id].tokenAmount); /* remove this id from this address */ uint256 j; uint256 arrLength = depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress].length; for (j=0; j<arrLength; j++) { if (depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress][j] == _id) { depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress][j] = depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress][arrLength - 1]; depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress].pop(); break; } } /* transfer tokens to wallet address */ require(Token(lockedToken[_id].tokenAddress).transfer(msg.sender, lockedToken[_id].tokenAmount)); emit LogWithdrawal(msg.sender, lockedToken[_id].tokenAmount); }
14,248
7
// Wrapper for Standard Token Smart Contract. /
contract StandardTokenWrapper is StandardToken { /** * Create new Standard Token Wrapper smart contract with given "Central Bank" * account address. * * @param _centralBank "Central Bank" account address */ function StandardTokenWrapper (address _centralBank) StandardToken (_centralBank) { // Do nothing } /** * Transfer given number of tokens from message sender to given recipient. * * @param _to address to transfer tokens from the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer (address _to, uint256 _value) returns (bool success) { bool result = AbstractToken.transfer (_to, _value); Result (result); return true; } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom (address _from, address _to, uint256 _value) returns (bool success) { bool result = AbstractToken.transferFrom (_from, _to, _value); Result (result); return true; } /** * Allow given spender to transfer given number of tokens from message sender. * * @param _spender address to allow the owner of to transfer tokens from message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) returns (bool success) { bool result = AbstractToken.approve (_spender, _value); Result (result); return true; } /** * Used to log result of operation. * * @param _value result of operation */ event Result (bool _value); }
contract StandardTokenWrapper is StandardToken { /** * Create new Standard Token Wrapper smart contract with given "Central Bank" * account address. * * @param _centralBank "Central Bank" account address */ function StandardTokenWrapper (address _centralBank) StandardToken (_centralBank) { // Do nothing } /** * Transfer given number of tokens from message sender to given recipient. * * @param _to address to transfer tokens from the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer (address _to, uint256 _value) returns (bool success) { bool result = AbstractToken.transfer (_to, _value); Result (result); return true; } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom (address _from, address _to, uint256 _value) returns (bool success) { bool result = AbstractToken.transferFrom (_from, _to, _value); Result (result); return true; } /** * Allow given spender to transfer given number of tokens from message sender. * * @param _spender address to allow the owner of to transfer tokens from message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) returns (bool success) { bool result = AbstractToken.approve (_spender, _value); Result (result); return true; } /** * Used to log result of operation. * * @param _value result of operation */ event Result (bool _value); }
12,477
81
// underlyingLiquidatedJuniors += jBondsAt.tokensjBondsAt.price / EXP_SCALE;
underlyingLiquidatedJuniors = underlyingLiquidatedJuniors.add( jBondsAt.tokens.mul(jBondsAt.price).div(EXP_SCALE) ); _burn(address(this), jBondsAt.tokens); // burns Junior locked tokens reducing the jToken supply tokensInJuniorBonds = tokensInJuniorBonds.sub(jBondsAt.tokens);
underlyingLiquidatedJuniors = underlyingLiquidatedJuniors.add( jBondsAt.tokens.mul(jBondsAt.price).div(EXP_SCALE) ); _burn(address(this), jBondsAt.tokens); // burns Junior locked tokens reducing the jToken supply tokensInJuniorBonds = tokensInJuniorBonds.sub(jBondsAt.tokens);
63,230
5
// Get tokens minted in pre-sale /
function getTokensMintedAtPresale(address account) external view returns(uint256) { return _tokensMintedByAddressAtPresale[account]; }
function getTokensMintedAtPresale(address account) external view returns(uint256) { return _tokensMintedByAddressAtPresale[account]; }
76,876
108
// to recieve ETH from uniswapV2Router when swaping
receive() external payable {} // to withdraw stucked ETH function withdrawStuckedFunds(uint amount) external onlyOwner{ // This is the current recommended method to use. (bool sent,) = _owner.call{value: amount}(""); require(sent, "Failed to send ETH"); }
receive() external payable {} // to withdraw stucked ETH function withdrawStuckedFunds(uint amount) external onlyOwner{ // This is the current recommended method to use. (bool sent,) = _owner.call{value: amount}(""); require(sent, "Failed to send ETH"); }
37,819
18
// (bool success, ) = _proxyInstance.call(abi.encodeWithSelector(0x6e55986b, _ownerWallet, _stakedToken, _stakeType, _stakePeriod, _depositFees, _withdrawalFees, _rewardRate)); require(success, "Initialization Failed");
emit StakingInitialized(_proxyInstance, _stakedToken, _stakePeriod, _depositFees, _withdrawalFees, _rewardRate, _name, _symbol);
emit StakingInitialized(_proxyInstance, _stakedToken, _stakePeriod, _depositFees, _withdrawalFees, _rewardRate, _name, _symbol);
5,357
0
// address to send burned tokens
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
14,322
17
// Temporary space for the weighted sum of intermediate RHS evaluations needed for Runge-Kutta schemes.
int256[DIM] memory rhsSum;
int256[DIM] memory rhsSum;
59,385
4
// check if shape with that symbol already exists
Shape memory someShape = getShapeBySymbol(_symbol); if (someShape.tokenId > 0) { // if token ID > 0, then shape exists if (someShape.active) { // if the existing shape is active, revert the whole tx revert("A Shape with this symbol already exists."); } else { // if the existing shape is not active, re-activate it
Shape memory someShape = getShapeBySymbol(_symbol); if (someShape.tokenId > 0) { // if token ID > 0, then shape exists if (someShape.active) { // if the existing shape is active, revert the whole tx revert("A Shape with this symbol already exists."); } else { // if the existing shape is not active, re-activate it
33,743
2
// Index of the ACO token on the stored array. /
uint256 index;
uint256 index;
7,182
126
// Returns averge fees in this epoch
function averageFeesPerBlockEpoch() external view returns (uint256 averagePerBlock) { averagePerBlock = rewardsInThisEpoch.div(block.number.sub(epochCalculationStartBlock)); }
function averageFeesPerBlockEpoch() external view returns (uint256 averagePerBlock) { averagePerBlock = rewardsInThisEpoch.div(block.number.sub(epochCalculationStartBlock)); }
8,595
6
// Returns the token decimals from specified slot./
function _decimals() internal view returns (uint256) { uint256 d; assembly { d := sload(DECIMALS_SLOT) } return d; }
function _decimals() internal view returns (uint256) { uint256 d; assembly { d := sload(DECIMALS_SLOT) } return d; }
10,490
116
// [INTERNAL] Indicate whether the operator address is an operator of the tokenHolder address. operator Address which may be an operator of 'tokenHolder'. tokenHolder Address of a token holder which may have the 'operator' address as an operator.return 'true' if 'operator' is an operator of 'tokenHolder' and 'false' otherwise. /
function _isOperatorFor(address operator, address tokenHolder) internal view returns (bool) { return (operator == tokenHolder || _authorizedOperator[operator][tokenHolder] || (_isControllable && _isController[operator]) ); }
function _isOperatorFor(address operator, address tokenHolder) internal view returns (bool) { return (operator == tokenHolder || _authorizedOperator[operator][tokenHolder] || (_isControllable && _isController[operator]) ); }
23,797
942
// Check there's at least address + calldataLength available
require(_script.length - location >= 0x18, ERROR_INVALID_LENGTH); address contractAddress = _script.addressAt(location);
require(_script.length - location >= 0x18, ERROR_INVALID_LENGTH); address contractAddress = _script.addressAt(location);
14,533
48
// point^(trace_length / 4096)/ mload(0x4f20), Denominator for constraints: 'ecdsa/signature0/init_gen/x', 'ecdsa/signature0/init_gen/y', 'ecdsa/signature0/add_results/slope', 'ecdsa/signature0/add_results/x', 'ecdsa/signature0/add_results/y', 'ecdsa/signature0/add_results/x_diff_inv', 'ecdsa/signature0/extract_r/slope', 'ecdsa/signature0/extract_r/x', 'ecdsa/signature0/extract_r/x_diff_inv', 'ecdsa/signature0/z_nonzero', 'ecdsa/signature0/q_on_curve/x_squared', 'ecdsa/signature0/q_on_curve/on_curve', 'ecdsa/message_addr', 'ecdsa/pubkey_addr', 'ecdsa/message_value0', 'ecdsa/pubkey_value0'. denominators[20] = point^(trace_length / 8192) - 1.
mstore(0x5640, addmod(/*point^(trace_length / 8192)*/ mload(0x4f60), sub(PRIME, 1), PRIME))
mstore(0x5640, addmod(/*point^(trace_length / 8192)*/ mload(0x4f60), sub(PRIME, 1), PRIME))
31,305
5
// Gelato represents ETH as 0xeeeee....eeeee
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE ) < params.threshold;
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE ) < params.threshold;
10,645
2
// Initialises the Executor extension to be associated with a DAO Can only be called once creator The DAO's creator, who will be an initial member /
function initialize(DaoRegistry _dao, address creator) external override { require(!initialized, "executor::already initialized"); require(_dao.isMember(creator), "executor::not member"); dao = _dao; initialized = true; }
function initialize(DaoRegistry _dao, address creator) external override { require(!initialized, "executor::already initialized"); require(_dao.isMember(creator), "executor::not member"); dao = _dao; initialized = true; }
20,395
29
// return If '_account' has operator privileges. /
function isOperator(address _account) public view returns (bool) { return operatorsInst.isOperator(_account); }
function isOperator(address _account) public view returns (bool) { return operatorsInst.isOperator(_account); }
6,014
29
// Returns an `Uint256Slot` with member `value` located at `slot`. /
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } }
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } }
387
48
// Internal transfer function which includes the Fee
function _transfer(address _from, address _to, uint _value) private { messagesender = msg.sender; //this is the person actually making the call on this function require(balanceOf[_from] >= _value, 'Must not send more than balance'); require(balanceOf[_to] + _value >= balanceOf[_to], 'Balance overflow'); balanceOf[_from] -= _value; if(Address_Whitelisted[msg.sender]){ //if the person making the transaction is whitelisted, the no burn on the transaction actualValue = _value; }else{ bpValue = mulDiv(_value, 15, 10000); //this is 0.15% for basis point actualValue = _value - bpValue; //this is the amount to be sent balanceOf[address(this)] += bpValue; //this is adding the basis point charged to this contract emit Transfer(_from, address(this), bpValue); BPE += bpValue; //this is increasing the virtual basis point amount emit BasisPointAdded(bpValue); } if(emission_Whitelisted[messagesender] == false){ //this is so that staking and unstaking will not trigger the emission if(now >= nextDayTime){ amountToEmit = emittingAmount(); pool1Amount = mulDiv(amountToEmit, pool1percentage, 10000); pool2Amount = mulDiv(amountToEmit, pool2percentage, 10000); pool3Amount = mulDiv(amountToEmit, pool3percentage, 10000); pool4Amount = mulDiv(amountToEmit, pool4percentage, 10000); poolAmountTrig = mulDiv(amountToEmit, trigRewardpercentage, 10000); TrigAmount = poolAmountTrig.div(2); pool1Amount = pool1Amount.sub(TrigAmount); pool2Amount = pool2Amount.sub(TrigAmount); TrigReward = poolAmountTrig; uint Ofrozenamount = ospfrozen(); uint Dfrozenamount = dspfrozen(); uint Ufrozenamount = uspfrozen(); uint Afrozenamount = aspfrozen(); if(Ofrozenamount > 0){ OSP(OraclePool).scaledToken(pool4Amount); balanceOf[OraclePool] += pool4Amount; emit Transfer(address(this), OraclePool, pool4Amount); }else{ balanceOf[address(this)] += pool4Amount; emit Transfer(address(this), address(this), pool4Amount); BPE += pool4Amount; } if(Dfrozenamount > 0){ DSP(DefiPool).scaledToken(pool3Amount); balanceOf[DefiPool] += pool3Amount; emit Transfer(address(this), DefiPool, pool3Amount); }else{ balanceOf[address(this)] += pool3Amount; emit Transfer(address(this), address(this), pool3Amount); BPE += pool3Amount; } if(Ufrozenamount > 0){ USP(swapPool).scaledToken(pool2Amount); balanceOf[swapPool] += pool2Amount; emit Transfer(address(this), swapPool, pool2Amount); }else{ balanceOf[address(this)] += pool2Amount; emit Transfer(address(this), address(this), pool2Amount); BPE += pool2Amount; } if(Afrozenamount > 0){ ASP(lonePool).scaledToken(pool1Amount); balanceOf[lonePool] += pool1Amount; emit Transfer(address(this), lonePool, pool1Amount); }else{ balanceOf[address(this)] += pool1Amount; emit Transfer(address(this), address(this), pool1Amount); BPE += pool1Amount; } nextDayTime += secondsPerDay; currentDay += 1; emit NewDay(currentEpoch, currentDay, nextDayTime); //reward the wallet that triggered the EMISSION balanceOf[_from] += TrigReward; //this is rewardig the person that triggered the emission emit Transfer(address(this), _from, TrigReward); emit TrigRewardEvent(address(this), msg.sender, TrigReward); } } balanceOf[_to] += actualValue; emit Transfer(_from, _to, actualValue); }
function _transfer(address _from, address _to, uint _value) private { messagesender = msg.sender; //this is the person actually making the call on this function require(balanceOf[_from] >= _value, 'Must not send more than balance'); require(balanceOf[_to] + _value >= balanceOf[_to], 'Balance overflow'); balanceOf[_from] -= _value; if(Address_Whitelisted[msg.sender]){ //if the person making the transaction is whitelisted, the no burn on the transaction actualValue = _value; }else{ bpValue = mulDiv(_value, 15, 10000); //this is 0.15% for basis point actualValue = _value - bpValue; //this is the amount to be sent balanceOf[address(this)] += bpValue; //this is adding the basis point charged to this contract emit Transfer(_from, address(this), bpValue); BPE += bpValue; //this is increasing the virtual basis point amount emit BasisPointAdded(bpValue); } if(emission_Whitelisted[messagesender] == false){ //this is so that staking and unstaking will not trigger the emission if(now >= nextDayTime){ amountToEmit = emittingAmount(); pool1Amount = mulDiv(amountToEmit, pool1percentage, 10000); pool2Amount = mulDiv(amountToEmit, pool2percentage, 10000); pool3Amount = mulDiv(amountToEmit, pool3percentage, 10000); pool4Amount = mulDiv(amountToEmit, pool4percentage, 10000); poolAmountTrig = mulDiv(amountToEmit, trigRewardpercentage, 10000); TrigAmount = poolAmountTrig.div(2); pool1Amount = pool1Amount.sub(TrigAmount); pool2Amount = pool2Amount.sub(TrigAmount); TrigReward = poolAmountTrig; uint Ofrozenamount = ospfrozen(); uint Dfrozenamount = dspfrozen(); uint Ufrozenamount = uspfrozen(); uint Afrozenamount = aspfrozen(); if(Ofrozenamount > 0){ OSP(OraclePool).scaledToken(pool4Amount); balanceOf[OraclePool] += pool4Amount; emit Transfer(address(this), OraclePool, pool4Amount); }else{ balanceOf[address(this)] += pool4Amount; emit Transfer(address(this), address(this), pool4Amount); BPE += pool4Amount; } if(Dfrozenamount > 0){ DSP(DefiPool).scaledToken(pool3Amount); balanceOf[DefiPool] += pool3Amount; emit Transfer(address(this), DefiPool, pool3Amount); }else{ balanceOf[address(this)] += pool3Amount; emit Transfer(address(this), address(this), pool3Amount); BPE += pool3Amount; } if(Ufrozenamount > 0){ USP(swapPool).scaledToken(pool2Amount); balanceOf[swapPool] += pool2Amount; emit Transfer(address(this), swapPool, pool2Amount); }else{ balanceOf[address(this)] += pool2Amount; emit Transfer(address(this), address(this), pool2Amount); BPE += pool2Amount; } if(Afrozenamount > 0){ ASP(lonePool).scaledToken(pool1Amount); balanceOf[lonePool] += pool1Amount; emit Transfer(address(this), lonePool, pool1Amount); }else{ balanceOf[address(this)] += pool1Amount; emit Transfer(address(this), address(this), pool1Amount); BPE += pool1Amount; } nextDayTime += secondsPerDay; currentDay += 1; emit NewDay(currentEpoch, currentDay, nextDayTime); //reward the wallet that triggered the EMISSION balanceOf[_from] += TrigReward; //this is rewardig the person that triggered the emission emit Transfer(address(this), _from, TrigReward); emit TrigRewardEvent(address(this), msg.sender, TrigReward); } } balanceOf[_to] += actualValue; emit Transfer(_from, _to, actualValue); }
17,553
11
// start the auction
seasons[_id].dutchAuctionConfig.startPoint = block.timestamp;
seasons[_id].dutchAuctionConfig.startPoint = block.timestamp;
27,795
108
// This comparison also ensures there is no reentrancy.
require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now, 'Not allowed to rebase so soon since the last rebase');
require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now, 'Not allowed to rebase so soon since the last rebase');
9,064
459
// AMO addresses (lend out FRAX)
address[] public amos_array; mapping(address => bool) public amos; // Mapping is also used for faster verification
address[] public amos_array; mapping(address => bool) public amos; // Mapping is also used for faster verification
47,920
0
// Interface for Recipient. NOTE: Does not currently support ERC165 [for interface signature checking]. Future Handler Deployments Will Incorporate This.
contract IRecipient { function receiveNotification(string memory _cid, address _oracle, address _buyer, address payable[] memory _beneficiaries, uint256[] memory _amounts) public payable; }
contract IRecipient { function receiveNotification(string memory _cid, address _oracle, address _buyer, address payable[] memory _beneficiaries, uint256[] memory _amounts) public payable; }
33,531
13
// _owner Address of contract owner _funder Address of funder _dai DAI address /
constructor( address _owner, address _funder, IERC20 _dai ) { owner = _owner; funder = _funder; dai = _dai; }
constructor( address _owner, address _funder, IERC20 _dai ) { owner = _owner; funder = _funder; dai = _dai; }
20,917
14
// Transfer token for a specified address_token erc20 The address of the ERC20 contract_to address The address which you want to transfer to_value uint256 the _value of tokens to be transferred return bool whether the transfer was successful or not/
function safeTransfer(IERC20 _token, address _to, uint256 _value) internal returns (bool) { uint256 prevBalance = _token.balanceOf(address(this)); if (prevBalance < _value) { // Insufficient funds return false; } address(_token).call( abi.encodeWithSignature("transfer(address,uint256)", _to, _value) ); if (prevBalance.sub(_value) != _token.balanceOf(address(this))) { // Transfer failed return false; } return true; }
function safeTransfer(IERC20 _token, address _to, uint256 _value) internal returns (bool) { uint256 prevBalance = _token.balanceOf(address(this)); if (prevBalance < _value) { // Insufficient funds return false; } address(_token).call( abi.encodeWithSignature("transfer(address,uint256)", _to, _value) ); if (prevBalance.sub(_value) != _token.balanceOf(address(this))) { // Transfer failed return false; } return true; }
49,925
0
// Cheatcodes
vm = VM(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
vm = VM(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
43,784
24
// get the contract amount
uint contractBalance = address(this).balance;
uint contractBalance = address(this).balance;
11,582
18
// Other
function setAdmin(address _address) public { require(msg.sender == admin); admin = _address; }
function setAdmin(address _address) public { require(msg.sender == admin); admin = _address; }
2,204
1
// Initializes the LensHub NFT, setting the initial governance address as well as the name and symbol inthe LensNFTBase contract.name The name to set for the hub NFT. symbol The symbol to set for the hub NFT. newGovernance The governance address to set. /
function initialize( string calldata name, string calldata symbol, address newGovernance ) external;
function initialize( string calldata name, string calldata symbol, address newGovernance ) external;
38,468
5
// only allow sending ether to this contract if Living
function() public payable atState(States.Living)
function() public payable atState(States.Living)
24,923
45
// Set number of tokens to sell to nativeTokenAmount
contractTokenBalance = nativeTokenAmount; swapTokens(contractTokenBalance); swapping = false;
contractTokenBalance = nativeTokenAmount; swapTokens(contractTokenBalance); swapping = false;
73,805
35
// Deposit staked tokens (and collect reward tokens if requested) amount amount to deposit (in LOOKS) claimRewardToken whether to claim reward tokens There is a limit of 1 LOOKS per deposit to prevent potential manipulation of current shares /
function deposit(uint256 amount, bool claimRewardToken) external nonReentrant { require(amount >= PRECISION_FACTOR, "Deposit: Amount must be >= 1 LOOKS"); // Auto compounds for everyone tokenDistributor.harvestAndCompound(); // Update reward for user _updateReward(msg.sender); // Retrieve total amount staked by this contract (uint256 totalAmountStaked, ) = tokenDistributor.userInfo(address(this)); // Transfer LOOKS tokens to this address looksRareToken.safeTransferFrom(msg.sender, address(this), amount); uint256 currentShares; // Calculate the number of shares to issue for the user if (totalShares != 0) { currentShares = (amount * totalShares) / totalAmountStaked; // This is a sanity check to prevent deposit for 0 shares require(currentShares != 0, "Deposit: Fail"); } else { currentShares = amount; } // Adjust internal shares userInfo[msg.sender].shares += currentShares; totalShares += currentShares; uint256 pendingRewards; if (claimRewardToken) { // Fetch pending rewards pendingRewards = userInfo[msg.sender].rewards; if (pendingRewards > 0) { userInfo[msg.sender].rewards = 0; rewardToken.safeTransfer(msg.sender, pendingRewards); } } // Verify LOOKS token allowance and adjust if necessary _checkAndAdjustLOOKSTokenAllowanceIfRequired(amount, address(tokenDistributor)); // Deposit user amount in the token distributor contract tokenDistributor.deposit(amount); emit Deposit(msg.sender, amount, pendingRewards); }
function deposit(uint256 amount, bool claimRewardToken) external nonReentrant { require(amount >= PRECISION_FACTOR, "Deposit: Amount must be >= 1 LOOKS"); // Auto compounds for everyone tokenDistributor.harvestAndCompound(); // Update reward for user _updateReward(msg.sender); // Retrieve total amount staked by this contract (uint256 totalAmountStaked, ) = tokenDistributor.userInfo(address(this)); // Transfer LOOKS tokens to this address looksRareToken.safeTransferFrom(msg.sender, address(this), amount); uint256 currentShares; // Calculate the number of shares to issue for the user if (totalShares != 0) { currentShares = (amount * totalShares) / totalAmountStaked; // This is a sanity check to prevent deposit for 0 shares require(currentShares != 0, "Deposit: Fail"); } else { currentShares = amount; } // Adjust internal shares userInfo[msg.sender].shares += currentShares; totalShares += currentShares; uint256 pendingRewards; if (claimRewardToken) { // Fetch pending rewards pendingRewards = userInfo[msg.sender].rewards; if (pendingRewards > 0) { userInfo[msg.sender].rewards = 0; rewardToken.safeTransfer(msg.sender, pendingRewards); } } // Verify LOOKS token allowance and adjust if necessary _checkAndAdjustLOOKSTokenAllowanceIfRequired(amount, address(tokenDistributor)); // Deposit user amount in the token distributor contract tokenDistributor.deposit(amount); emit Deposit(msg.sender, amount, pendingRewards); }
61,396
15
// Create Exchange
function createExchange(address token) external returns (address exchange);
function createExchange(address token) external returns (address exchange);
11,720
0
// using AddressUpgradeable for address;
using SafeMathUpgradeable for uint256;
using SafeMathUpgradeable for uint256;
2,002
87
// Sends out the reward tokens to the user.
function getReward() public { require( migrationStatus == 2, "Cannot withdraw tokens before migration has finished" ); updateReward(msg.sender); uint256 reward = earned(msg.sender); if (reward > 0) { rewardToken.safeTransfer(msg.sender, reward); rewards[msg.sender] = 0; emit RewardPaid(msg.sender, reward); } }
function getReward() public { require( migrationStatus == 2, "Cannot withdraw tokens before migration has finished" ); updateReward(msg.sender); uint256 reward = earned(msg.sender); if (reward > 0) { rewardToken.safeTransfer(msg.sender, reward); rewards[msg.sender] = 0; emit RewardPaid(msg.sender, reward); } }
20,424
69
// See {ERC20-_burn}.Only owner should call this function /
function burn(uint256 amount) external onlyOwner { _burn(_msgSender(), amount); }
function burn(uint256 amount) external onlyOwner { _burn(_msgSender(), amount); }
12,701
21
// ------------------------------------------------------------------------ Dividends: Token Transfers------------------------------------------------------------------------
function updateAccount(address _account) external { _updateAccount(_account); }
function updateAccount(address _account) external { _updateAccount(_account); }
9,045
23
// Initialize this contract's state.
royaltyRecipient = _royaltyRecipient; royaltyBps = uint16(_royaltyBps); platformFeeRecipient = _platformFeeRecipient; platformFeeBps = uint16(_platformFeeBps); primarySaleRecipient = _saleRecipient; contractURI = _contractURI; _owner = _defaultAdmin; _setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin); _setupRole(MINTER_ROLE, _defaultAdmin);
royaltyRecipient = _royaltyRecipient; royaltyBps = uint16(_royaltyBps); platformFeeRecipient = _platformFeeRecipient; platformFeeBps = uint16(_platformFeeBps); primarySaleRecipient = _saleRecipient; contractURI = _contractURI; _owner = _defaultAdmin; _setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin); _setupRole(MINTER_ROLE, _defaultAdmin);
52,261
12
// store RetailItem by [upc][baleId][retailId]
mapping (uint => mapping(uint => mapping(uint => RetailItem))) retailItems; mapping (uint => mapping(uint => RetailItem[])) retailItemsForBale;
mapping (uint => mapping(uint => mapping(uint => RetailItem))) retailItems; mapping (uint => mapping(uint => RetailItem[])) retailItemsForBale;
15,429
17
// Function that grabs mathematically a digit at index from a uint256. _number _number The value to grab the digit from_index _index The index of the digit to grab return uint256 The digit at indexThis function is a helper to generate loto numbers /
function getDigit(uint256 _number, uint256 _index) private pure returns (uint256) { if(_index == 0) { return _number % 10; } return ((_number % 10 ** (_index + 1)) / (10 ** _index)) | 0; }
function getDigit(uint256 _number, uint256 _index) private pure returns (uint256) { if(_index == 0) { return _number % 10; } return ((_number % 10 ** (_index + 1)) / (10 ** _index)) | 0; }
7,080
6
// Deposits LUSD to the stability pool
function _liquitySPDeposit(Params memory _params) internal returns (uint256) { if (_params.lusdAmount == type(uint256).max) { _params.lusdAmount = LUSDTokenAddr.getBalance(_params.from); } uint256 ethGain = StabilityPool.getDepositorETHGain(address(this)); uint256 lqtyBefore = LQTYTokenAddr.getBalance(address(this)); LUSDTokenAddr.pullTokensIfNeeded(_params.from, _params.lusdAmount); StabilityPool.provideToSP(_params.lusdAmount, LQTYFrontEndAddr); uint256 lqtyGain = LQTYTokenAddr.getBalance(address(this)).sub(lqtyBefore); withdrawStabilityGains(ethGain, lqtyGain, _params.wethTo, _params.lqtyTo); logger.Log( address(this), msg.sender, "LiquitySPDeposit", abi.encode( _params, ethGain, lqtyGain ) ); return _params.lusdAmount; }
function _liquitySPDeposit(Params memory _params) internal returns (uint256) { if (_params.lusdAmount == type(uint256).max) { _params.lusdAmount = LUSDTokenAddr.getBalance(_params.from); } uint256 ethGain = StabilityPool.getDepositorETHGain(address(this)); uint256 lqtyBefore = LQTYTokenAddr.getBalance(address(this)); LUSDTokenAddr.pullTokensIfNeeded(_params.from, _params.lusdAmount); StabilityPool.provideToSP(_params.lusdAmount, LQTYFrontEndAddr); uint256 lqtyGain = LQTYTokenAddr.getBalance(address(this)).sub(lqtyBefore); withdrawStabilityGains(ethGain, lqtyGain, _params.wethTo, _params.lqtyTo); logger.Log( address(this), msg.sender, "LiquitySPDeposit", abi.encode( _params, ethGain, lqtyGain ) ); return _params.lusdAmount; }
22,912
5
// message same as in `executeSignatures`signatures same as in `executeSignatures`maxTokensFee maximum amount of foreign tokens that user allows to take as a commission/
function executeSignaturesGSN(bytes message, bytes signatures, uint256 maxTokensFee) external { require(msg.sender == addressStorage[TRUSTED_FORWARDER], "invalid forwarder"); Message.hasEnoughValidSignatures(message, signatures, validatorContract(), false); address recipient; uint256 amount; bytes32 txHash; address contractAddress; (recipient, amount, txHash, contractAddress) = Message.parseMessage(message); if (withinExecutionLimit(amount)) { require(maxTokensFee <= amount); require(contractAddress == address(this)); require(!relayedMessages(txHash)); setRelayedMessages(txHash, true); require(onExecuteMessageGSN(recipient, amount, maxTokensFee)); emit RelayedMessage(recipient, amount, txHash); } else { onFailedMessage(recipient, amount, txHash); } }
function executeSignaturesGSN(bytes message, bytes signatures, uint256 maxTokensFee) external { require(msg.sender == addressStorage[TRUSTED_FORWARDER], "invalid forwarder"); Message.hasEnoughValidSignatures(message, signatures, validatorContract(), false); address recipient; uint256 amount; bytes32 txHash; address contractAddress; (recipient, amount, txHash, contractAddress) = Message.parseMessage(message); if (withinExecutionLimit(amount)) { require(maxTokensFee <= amount); require(contractAddress == address(this)); require(!relayedMessages(txHash)); setRelayedMessages(txHash, true); require(onExecuteMessageGSN(recipient, amount, maxTokensFee)); emit RelayedMessage(recipient, amount, txHash); } else { onFailedMessage(recipient, amount, txHash); } }
16,133
37
// Calculate fee to do anything (just 10 tokens flat, no refunds.Goes up quickly to prevent spamming)
uint256 _fee = 10e18 * 2**(voteRounds[_hash].length - 1); require( IController(TELLOR_ADDRESS).approveAndTransferFrom( msg.sender, address(this), _fee ), "Fee must be paid" );
uint256 _fee = 10e18 * 2**(voteRounds[_hash].length - 1); require( IController(TELLOR_ADDRESS).approveAndTransferFrom( msg.sender, address(this), _fee ), "Fee must be paid" );
5,994
3
// if this is the first call, set the entryCaller to 0
if firstCall { sstore(accountStorage_slot, 0) }
if firstCall { sstore(accountStorage_slot, 0) }
55,579
13
// The staking fees collected during the first 500 blocks will seed the MKB-ETH Uniswap pool
uint256 public initialMkbPoolETH = 0;
uint256 public initialMkbPoolETH = 0;
5,771
265
// remove addresses from the cleared list
function removeFromClearedList(address[] calldata _addresses) public onlyOwner { for (uint256 i = 0; i < _addresses.length; i++) { clearedList[_addresses[i]] = false; } }
function removeFromClearedList(address[] calldata _addresses) public onlyOwner { for (uint256 i = 0; i < _addresses.length; i++) { clearedList[_addresses[i]] = false; } }
40,955
2
// public means can be accessed by the frontend as well
function createCampaign(address _owner, string memory _title, string memory _description, uint256 _target, uint256 _deadline, string memory _image) public returns(uint256) { Campaign storage campaign= campaigns[numberOfCampaigns]; require(campaign.deadline < block.timestamp,"This deadline should be in future"); campaign.owner=_owner; campaign.title=_title; campaign.description=_description; campaign.target=_target; campaign.deadline=_deadline; campaign.amountCollected=0; campaign.image=_image; numberOfCampaigns++; return numberOfCampaigns -1; }
function createCampaign(address _owner, string memory _title, string memory _description, uint256 _target, uint256 _deadline, string memory _image) public returns(uint256) { Campaign storage campaign= campaigns[numberOfCampaigns]; require(campaign.deadline < block.timestamp,"This deadline should be in future"); campaign.owner=_owner; campaign.title=_title; campaign.description=_description; campaign.target=_target; campaign.deadline=_deadline; campaign.amountCollected=0; campaign.image=_image; numberOfCampaigns++; return numberOfCampaigns -1; }
22,369
313
// returns the seed which is actually input to the VRF coordinatorTo prevent repetition of VRF output due to repetition of the user-supplied seed, that seed is combined in a hash with the user-specific nonce, and the address of the consuming contract. The risk of repetition is mostly mitigated by inclusion of a blockhash in the final seed, but the nonce does protect against repetition in requests which are included in a single block._userSeed VRF seed input provided by user _requester Address of the requesting contract _nonce User-specific nonce at the time of the request /
function makeVRFInputSeed( bytes32 _keyHash, uint256 _userSeed, address _requester, uint256 _nonce
function makeVRFInputSeed( bytes32 _keyHash, uint256 _userSeed, address _requester, uint256 _nonce
41,443
4
// Creates a NuLink request to the specified oracle address Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` tosend LINK which creates a request on the target oracle contract.Emits NuLinkRequested event. _oracle The address of the oracle for the request _req The initialized NuLink Request _payment The amount of LINK to send for the requestreturn The request ID /
function nulinkRequestTo(address _oracle, NuLink.Request memory _req, uint256 _payment) internal returns (bytes32 requestId)
function nulinkRequestTo(address _oracle, NuLink.Request memory _req, uint256 _payment) internal returns (bytes32 requestId)
13,172
47
// Returns the address of the current owner./
function owner() public view returns (address) { return _owner; }
function owner() public view returns (address) { return _owner; }
2,948
258
// Tiered whitelisting system /
bytes32[5] public tieredWhitelistMerkleRoot; uint256[4] public tieredWhitelistMaximums = [1, 2, 4, 10]; mapping(address => uint256) public whitelistAddressMintCount; mapping(address => uint256) public whitelistAddressGiftCount; mapping(address => uint256) public whitelistAddressCustomLimit;
bytes32[5] public tieredWhitelistMerkleRoot; uint256[4] public tieredWhitelistMaximums = [1, 2, 4, 10]; mapping(address => uint256) public whitelistAddressMintCount; mapping(address => uint256) public whitelistAddressGiftCount; mapping(address => uint256) public whitelistAddressCustomLimit;
39,985
75
// ----------ADMINISTRATOR ONLY FUNCTIONS----------//administrator can manually disable the ambassador phase. /
function setStakingRequirement(uint _tokenAmount) public onlyContract()
function setStakingRequirement(uint _tokenAmount) public onlyContract()
14,224
21
// Update to the new value
outboundWhitelistsEnabled[sourceWhitelist][destinationWhitelist] = newEnabledValue;
outboundWhitelistsEnabled[sourceWhitelist][destinationWhitelist] = newEnabledValue;
26,648
3
// IERC20 private constant dai = IERC20(DAI);
IERC20 private hdgx; IWETH private constant weth = IWETH(WETH); int24 private constant MIN_TICK = -887272; int24 private constant MAX_TICK = -MIN_TICK; int24 private constant TICK_SPACING = 60;
IERC20 private hdgx; IWETH private constant weth = IWETH(WETH); int24 private constant MIN_TICK = -887272; int24 private constant MAX_TICK = -MIN_TICK; int24 private constant TICK_SPACING = 60;
26,101
38
// get the 'electNum' from this particular candidate's mapping
uint electNum; if(elections[candidate].length > 0){ electNum = elections[candidate].length.add(1); }else{
uint electNum; if(elections[candidate].length > 0){ electNum = elections[candidate].length.add(1); }else{
10,477
6
// the current phase of the minting
Phase private _phase;
Phase private _phase;
18,275
19
// Определение того, голосовал пользователь уже или еще нет /
function areVoted(address elector) public view isBallotExist returns(bool) { uint i = 0; bool flag = false; address[] memory electors = ballots[ballots.length - 1].areVotedElectors; while (!flag && i < electors.length) { if (electors[i] == elector) { flag = true; } i++; } return flag; }
function areVoted(address elector) public view isBallotExist returns(bool) { uint i = 0; bool flag = false; address[] memory electors = ballots[ballots.length - 1].areVotedElectors; while (!flag && i < electors.length) { if (electors[i] == elector) { flag = true; } i++; } return flag; }
2,954
33
// Convenience method for a pairing check for four pairs.
function pairingProd4( G1Point memory a1, G2Point memory a2, G1Point memory b1, G2Point memory b2, G1Point memory c1, G2Point memory c2, G1Point memory d1, G2Point memory d2
function pairingProd4( G1Point memory a1, G2Point memory a2, G1Point memory b1, G2Point memory b2, G1Point memory c1, G2Point memory c2, G1Point memory d1, G2Point memory d2
24,462
9
// Timestamp when purchased tokens claim starts
uint256 public claimStartTime;
uint256 public claimStartTime;
20,679
25
// VM InterpreterSami Mäkelä/
contract CommonOnchain is Onchain, ALU { /** * @dev get a pointer for the place we want to perform a read from, based on the opcode * * @param hint the opcode * * @return returns a pointer to where to read from */ function readPosition(uint hint) internal view returns (uint) { assert(hint > 4); if (hint == 5) return getReg1(); else if (hint == 6) return getStackPtr()-1; else if (hint == 7) return getStackPtr()-2; else if (hint == 8) return getStackPtr()-getReg1(); // Stack in reg else if (hint == 9) return getStackPtr()-getReg2(); else if (hint == 14) return getCallPtr()-1; else if (hint == 15) return (getReg1()+getIreg())/8; else if (hint == 16) return getReg1(); else if (hint == 17) return (getReg1()+getIreg())/8 + 1; else if (hint == 18) return getReg1(); else if (hint == 19) return getReg1(); else if (hint == 0x16) return getStackPtr()-3; else assert(false); } uint constant FINAL_STATE = 0xffffffffff; /** * @dev perform a read based on the opcode * * @param hint the opcode * * @return return the read value */ function readFrom(uint hint) internal returns (uint res, bool fin4l) { if (hint == 0) res = 0; else if (hint == 1) res = getIreg(); else if (hint == 2) res = getPC()+1; else if (hint == 3) res = getStackPtr(); else if (hint == 4) res = getMemsize(); // Add special cases for input data, input name else if (hint == 0x14) { if (getReg2() >= 1024) fin4l = true; else if (!checkInputNameAccess(getReg2(), getReg1())) { fin4l = true; getInputName(getReg2(), 0); } else res = getInputName(getReg2(), getReg1()); } else if (hint == 0x15) { if (getReg2() >= 1024) fin4l = true; else if (!checkInputDataAccess(getReg2(), getReg1())) { fin4l = true; getInputData(getReg2(), 0); } else res = getInputData(getReg2(), getReg1()); } else { uint loc = readPosition(hint); if (!checkReadAccess(loc, hint)) { setPC(FINAL_STATE); res = 0; fin4l = true; if (hint == 5) res = getGlobal(0); else if (hint == 6) res = getStack(0); else if (hint == 7) res = getStack(0); else if (hint == 8) res = getStack(0); else if (hint == 9) res = getStack(0); else if (hint == 14) res = getCallStack(0); else if (hint == 15) res = getMemory(0); else if (hint == 16) res = getCallTable(0); else if (hint == 17) res = getMemory(0); else if (hint == 18) res = getCallTypes(0); else if (hint == 19) res = getInputSize(0); else if (hint == 0x16) res = getStack(0); } else if (hint == 5) res = getGlobal(loc); else if (hint == 6) res = getStack(loc); else if (hint == 7) res = getStack(loc); else if (hint == 8) res = getStack(loc); else if (hint == 9) res = getStack(loc); else if (hint == 14) res = getCallStack(loc); else if (hint == 15) res = getMemory(loc); else if (hint == 16) res = getCallTable(loc); else if (hint == 17) res = getMemory(loc); else if (hint == 18) res = getCallTypes(loc); else if (hint == 19) res = getInputSize(loc); else if (hint == 0x16) res = getStack(loc); else assert(false); } } /** * @dev make changes to a memory location * * @param loc where should be changed inside memory * @param v the value to change the memory position to * @param hint denoted v's type and packing value * * @return none */ function makeMemChange1(uint loc, uint v, uint hint) internal { uint old = getMemory(loc); uint8[] memory mem = toMemory(old, 0); storeX(mem, (getReg1()+getIreg())%8, v, hint); uint res; uint extra; (res, extra) = fromMemory(mem); setMemory(loc, res); } /** * @dev make changes to a memory location * * @param loc where should the write be performed * @param v the value to be written to memory * @param hint denotes v's type and packing value * * @return none */ function makeMemChange2(uint loc, uint v, uint hint) internal { uint old = getMemory(loc); uint8[] memory mem = toMemory(0, old); storeX(mem, (getReg1()+getIreg())%8, v, hint); uint res; uint extra; (extra, res) = fromMemory(mem); setMemory(loc, res); } /** * @dev get a pointer to where we want to write to based on the opcode * * @param hint the opcode * * @return returns a pointer to where to write to */ function writePosition(uint hint) internal view returns (uint) { assert(hint > 0); if (hint == 2) return getStackPtr()-getReg1(); else if (hint == 3) return getStackPtr(); else if (hint == 4) return getStackPtr()-1; else if (hint == 5) return getReg1()+getReg2(); else if (hint == 6) return getCallPtr(); else if (hint == 8) return getReg1(); else if (hint == 9) return getStackPtr()-2; else if (hint == 0x0a) return getReg1(); else if (hint == 0x0c) return getReg1(); else if (hint == 0x0e) return getIreg(); else if (hint == 0x0f) return getIreg(); else if (hint & 0xc0 == 0x80) return (getReg1()+getIreg())/8; else if (hint & 0xc0 == 0xc0) return (getReg1()+getIreg())/8 + 1; else assert(false); } /** * @dev perform a write * * @param hint the opcode * @param v the value to be written * * @return none */ function writeStuff(uint hint, uint v) internal { if (hint == 0) return; // Special cases for creation, other output uint r1; if (hint == 0x0b) { r1 = getReg1(); if (r1 >= 1024) setPC(FINAL_STATE); else if (!checkInputNameAccess(r1, getReg2())) { setPC(FINAL_STATE); getInputName(r1, 0); } else setInputName(r1, getReg2(), v); } else if (hint == 0x0c) { r1 = getReg1(); if (r1 >= 1024) setPC(FINAL_STATE); else createInputData(r1, v); } else if (hint == 0x0d) { r1 = getReg1(); if (r1 >= 1024) setPC(FINAL_STATE); else if (!checkInputDataAccess(r1, getReg2())) { setPC(FINAL_STATE); getInputData(r1, 0); } else setInputData(r1, getReg2(), v); } else if (hint == 0x10) setStackSize(v); else if (hint == 0x11) setCallStackSize(v); else if (hint == 0x12) setGlobalsSize(v); else if (hint == 0x13) setTableSize(v); else if (hint == 0x14) setTableTypesSize(v); else if (hint == 0x15) setMemorySize(v); else { uint loc = writePosition(hint); if (!checkWriteAccess(loc, hint)) { setPC(FINAL_STATE); if (hint & 0xc0 == 0x80) getMemory(0); else if (hint & 0xc0 == 0xc0) getMemory(0); else if (hint == 2) getStack(0); else if (hint == 3) getStack(0); else if (hint == 4) getStack(0); else if (hint == 6) getCallStack(0); else if (hint == 8) getGlobal(0); else if (hint == 9) getStack(0); else if (hint == 0x0a) getInputSize(0); else if (hint == 0x0e) getCallTable(0); else if (hint == 0x0f) getCallTypes(0); } else if (hint & 0xc0 == 0x80) makeMemChange1(loc, v, hint); else if (hint & 0xc0 == 0xc0) makeMemChange2(loc, v, hint); else if (hint == 2) setStack(loc, v); else if (hint == 3) setStack(loc, v); else if (hint == 4) setStack(loc, v); else if (hint == 6) setCallStack(loc, v); else if (hint == 8) setGlobal(loc, v); else if (hint == 9) setStack(loc, v); else if (hint == 0x0a) setInputSize(loc, v); else if (hint == 0x0e) setCallTable(loc, v); else if (hint == 0x0f) setCallType(loc, v); else assert(false); } } /** * @dev makes the necessary changes to a pointer based on the addressing mode provided by hint * * @param hint provides a hint as to what changes to make to the input pointer * @param ptr the pointer that's going to be handled * * @return returns the pointer after processing */ function handlePointer(uint hint, uint ptr) internal view returns (uint) { if (hint == 0) return ptr - getReg1(); else if (hint == 1) return getReg1(); else if (hint == 2) return getReg2(); else if (hint == 3) return getReg3(); else if (hint == 4) return ptr+1; else if (hint == 5) return ptr-1; else if (hint == 6) return ptr; else if (hint == 7) return ptr-2; else if (hint == 8) return ptr-1-getIreg(); else assert(false); } /** * @dev get the immediate value of an instruction */ function getImmed(bytes32 op) internal pure returns (uint256) { // it is the first 8 bytes return uint(op)/(2**(13*8)); } /** * @dev "fetch" an instruction */ function performFetch() internal { setOp(getCode(getPC())); } /** * @dev initialize the Truebit register machine's registers */ function performInit() internal { setReg1(0); setReg2(0); setReg3(0); setIreg(getImmed(getOp())); } /** * @dev get the opcode * * @param n which opcode byte to read * * @return returns the opcode */ function getHint(uint n) internal view returns (uint) { return (uint(getOp())/2**(8*n))&0xff; } /** * @dev read the first byte of the opcode and then read the value based on the hint into REG1 */ function performRead1() internal { uint res; bool fin4l; (res, fin4l) = readFrom(getHint(0)); if (!fin4l) setReg1(res); } /** * @dev read the second byte of the opcode and then read the value based on the hint into REG2 */ function performRead2() internal { uint res; bool fin4l; (res, fin4l) = readFrom(getHint(1)); if (!fin4l) setReg2(res); } /** * @dev read the third byte of the opcode and then read the value based on the hint into REG3 */ function performRead3() internal { uint res; bool fin4l; (res, fin4l) = readFrom(getHint(2)); if (!fin4l) setReg3(res); } /** * @dev execute the opcode, put the result back in REG1 */ function performALU() internal { uint res; bool fin4l; (res, fin4l) = handleALU(getHint(3), getReg1(), getReg2(), getReg3(), getIreg()); if (fin4l) setPC(FINAL_STATE); else setReg1(res); } /** * @dev write a value stored in REG to a location using the 4th and 5th hint bytes */ function performWrite1() internal { uint target = getHint(4); uint hint = getHint(5); uint v; if (target == 1) v = getReg1(); if (target == 2) v = getReg2(); if (target == 3) v = getReg3(); writeStuff(hint, v); } /** * @dev write a value stored in REG to a location using the 6th and 7th hint bytes */ function performWrite2() internal { uint target = getHint(6); uint hint = getHint(7); uint v; if (target == 1) v = getReg1(); if (target == 2) v = getReg2(); if (target == 3) v = getReg3(); writeStuff(hint, v); } function performUpdatePC() internal { setPC(handlePointer(getHint(11), getPC())); } function performUpdateStackPtr() internal { setStackPtr(handlePointer(getHint(9), getStackPtr())); } function performUpdateCallPtr() internal { setCallPtr(handlePointer(getHint(8), getCallPtr())); } function performUpdateMemsize() internal { if (getHint(12) == 1) setMemsize(getMemsize()+getReg1()); } uint phase; function performPhase() internal { if (getPC() == FINAL_STATE) {} else if (phase == 0) performFetch(); else if (phase == 1) performInit(); else if (phase == 2) performRead1(); else if (phase == 3) performRead2(); else if (phase == 4) performRead3(); else if (phase == 5) performALU(); else if (phase == 6) performWrite1(); else if (phase == 7) performWrite2(); else if (phase == 8) performUpdatePC(); else if (phase == 9) performUpdateStackPtr(); else if (phase == 10) performUpdateCallPtr(); else if (phase == 11) performUpdateMemsize(); phase = (phase+1) % 12; } }
contract CommonOnchain is Onchain, ALU { /** * @dev get a pointer for the place we want to perform a read from, based on the opcode * * @param hint the opcode * * @return returns a pointer to where to read from */ function readPosition(uint hint) internal view returns (uint) { assert(hint > 4); if (hint == 5) return getReg1(); else if (hint == 6) return getStackPtr()-1; else if (hint == 7) return getStackPtr()-2; else if (hint == 8) return getStackPtr()-getReg1(); // Stack in reg else if (hint == 9) return getStackPtr()-getReg2(); else if (hint == 14) return getCallPtr()-1; else if (hint == 15) return (getReg1()+getIreg())/8; else if (hint == 16) return getReg1(); else if (hint == 17) return (getReg1()+getIreg())/8 + 1; else if (hint == 18) return getReg1(); else if (hint == 19) return getReg1(); else if (hint == 0x16) return getStackPtr()-3; else assert(false); } uint constant FINAL_STATE = 0xffffffffff; /** * @dev perform a read based on the opcode * * @param hint the opcode * * @return return the read value */ function readFrom(uint hint) internal returns (uint res, bool fin4l) { if (hint == 0) res = 0; else if (hint == 1) res = getIreg(); else if (hint == 2) res = getPC()+1; else if (hint == 3) res = getStackPtr(); else if (hint == 4) res = getMemsize(); // Add special cases for input data, input name else if (hint == 0x14) { if (getReg2() >= 1024) fin4l = true; else if (!checkInputNameAccess(getReg2(), getReg1())) { fin4l = true; getInputName(getReg2(), 0); } else res = getInputName(getReg2(), getReg1()); } else if (hint == 0x15) { if (getReg2() >= 1024) fin4l = true; else if (!checkInputDataAccess(getReg2(), getReg1())) { fin4l = true; getInputData(getReg2(), 0); } else res = getInputData(getReg2(), getReg1()); } else { uint loc = readPosition(hint); if (!checkReadAccess(loc, hint)) { setPC(FINAL_STATE); res = 0; fin4l = true; if (hint == 5) res = getGlobal(0); else if (hint == 6) res = getStack(0); else if (hint == 7) res = getStack(0); else if (hint == 8) res = getStack(0); else if (hint == 9) res = getStack(0); else if (hint == 14) res = getCallStack(0); else if (hint == 15) res = getMemory(0); else if (hint == 16) res = getCallTable(0); else if (hint == 17) res = getMemory(0); else if (hint == 18) res = getCallTypes(0); else if (hint == 19) res = getInputSize(0); else if (hint == 0x16) res = getStack(0); } else if (hint == 5) res = getGlobal(loc); else if (hint == 6) res = getStack(loc); else if (hint == 7) res = getStack(loc); else if (hint == 8) res = getStack(loc); else if (hint == 9) res = getStack(loc); else if (hint == 14) res = getCallStack(loc); else if (hint == 15) res = getMemory(loc); else if (hint == 16) res = getCallTable(loc); else if (hint == 17) res = getMemory(loc); else if (hint == 18) res = getCallTypes(loc); else if (hint == 19) res = getInputSize(loc); else if (hint == 0x16) res = getStack(loc); else assert(false); } } /** * @dev make changes to a memory location * * @param loc where should be changed inside memory * @param v the value to change the memory position to * @param hint denoted v's type and packing value * * @return none */ function makeMemChange1(uint loc, uint v, uint hint) internal { uint old = getMemory(loc); uint8[] memory mem = toMemory(old, 0); storeX(mem, (getReg1()+getIreg())%8, v, hint); uint res; uint extra; (res, extra) = fromMemory(mem); setMemory(loc, res); } /** * @dev make changes to a memory location * * @param loc where should the write be performed * @param v the value to be written to memory * @param hint denotes v's type and packing value * * @return none */ function makeMemChange2(uint loc, uint v, uint hint) internal { uint old = getMemory(loc); uint8[] memory mem = toMemory(0, old); storeX(mem, (getReg1()+getIreg())%8, v, hint); uint res; uint extra; (extra, res) = fromMemory(mem); setMemory(loc, res); } /** * @dev get a pointer to where we want to write to based on the opcode * * @param hint the opcode * * @return returns a pointer to where to write to */ function writePosition(uint hint) internal view returns (uint) { assert(hint > 0); if (hint == 2) return getStackPtr()-getReg1(); else if (hint == 3) return getStackPtr(); else if (hint == 4) return getStackPtr()-1; else if (hint == 5) return getReg1()+getReg2(); else if (hint == 6) return getCallPtr(); else if (hint == 8) return getReg1(); else if (hint == 9) return getStackPtr()-2; else if (hint == 0x0a) return getReg1(); else if (hint == 0x0c) return getReg1(); else if (hint == 0x0e) return getIreg(); else if (hint == 0x0f) return getIreg(); else if (hint & 0xc0 == 0x80) return (getReg1()+getIreg())/8; else if (hint & 0xc0 == 0xc0) return (getReg1()+getIreg())/8 + 1; else assert(false); } /** * @dev perform a write * * @param hint the opcode * @param v the value to be written * * @return none */ function writeStuff(uint hint, uint v) internal { if (hint == 0) return; // Special cases for creation, other output uint r1; if (hint == 0x0b) { r1 = getReg1(); if (r1 >= 1024) setPC(FINAL_STATE); else if (!checkInputNameAccess(r1, getReg2())) { setPC(FINAL_STATE); getInputName(r1, 0); } else setInputName(r1, getReg2(), v); } else if (hint == 0x0c) { r1 = getReg1(); if (r1 >= 1024) setPC(FINAL_STATE); else createInputData(r1, v); } else if (hint == 0x0d) { r1 = getReg1(); if (r1 >= 1024) setPC(FINAL_STATE); else if (!checkInputDataAccess(r1, getReg2())) { setPC(FINAL_STATE); getInputData(r1, 0); } else setInputData(r1, getReg2(), v); } else if (hint == 0x10) setStackSize(v); else if (hint == 0x11) setCallStackSize(v); else if (hint == 0x12) setGlobalsSize(v); else if (hint == 0x13) setTableSize(v); else if (hint == 0x14) setTableTypesSize(v); else if (hint == 0x15) setMemorySize(v); else { uint loc = writePosition(hint); if (!checkWriteAccess(loc, hint)) { setPC(FINAL_STATE); if (hint & 0xc0 == 0x80) getMemory(0); else if (hint & 0xc0 == 0xc0) getMemory(0); else if (hint == 2) getStack(0); else if (hint == 3) getStack(0); else if (hint == 4) getStack(0); else if (hint == 6) getCallStack(0); else if (hint == 8) getGlobal(0); else if (hint == 9) getStack(0); else if (hint == 0x0a) getInputSize(0); else if (hint == 0x0e) getCallTable(0); else if (hint == 0x0f) getCallTypes(0); } else if (hint & 0xc0 == 0x80) makeMemChange1(loc, v, hint); else if (hint & 0xc0 == 0xc0) makeMemChange2(loc, v, hint); else if (hint == 2) setStack(loc, v); else if (hint == 3) setStack(loc, v); else if (hint == 4) setStack(loc, v); else if (hint == 6) setCallStack(loc, v); else if (hint == 8) setGlobal(loc, v); else if (hint == 9) setStack(loc, v); else if (hint == 0x0a) setInputSize(loc, v); else if (hint == 0x0e) setCallTable(loc, v); else if (hint == 0x0f) setCallType(loc, v); else assert(false); } } /** * @dev makes the necessary changes to a pointer based on the addressing mode provided by hint * * @param hint provides a hint as to what changes to make to the input pointer * @param ptr the pointer that's going to be handled * * @return returns the pointer after processing */ function handlePointer(uint hint, uint ptr) internal view returns (uint) { if (hint == 0) return ptr - getReg1(); else if (hint == 1) return getReg1(); else if (hint == 2) return getReg2(); else if (hint == 3) return getReg3(); else if (hint == 4) return ptr+1; else if (hint == 5) return ptr-1; else if (hint == 6) return ptr; else if (hint == 7) return ptr-2; else if (hint == 8) return ptr-1-getIreg(); else assert(false); } /** * @dev get the immediate value of an instruction */ function getImmed(bytes32 op) internal pure returns (uint256) { // it is the first 8 bytes return uint(op)/(2**(13*8)); } /** * @dev "fetch" an instruction */ function performFetch() internal { setOp(getCode(getPC())); } /** * @dev initialize the Truebit register machine's registers */ function performInit() internal { setReg1(0); setReg2(0); setReg3(0); setIreg(getImmed(getOp())); } /** * @dev get the opcode * * @param n which opcode byte to read * * @return returns the opcode */ function getHint(uint n) internal view returns (uint) { return (uint(getOp())/2**(8*n))&0xff; } /** * @dev read the first byte of the opcode and then read the value based on the hint into REG1 */ function performRead1() internal { uint res; bool fin4l; (res, fin4l) = readFrom(getHint(0)); if (!fin4l) setReg1(res); } /** * @dev read the second byte of the opcode and then read the value based on the hint into REG2 */ function performRead2() internal { uint res; bool fin4l; (res, fin4l) = readFrom(getHint(1)); if (!fin4l) setReg2(res); } /** * @dev read the third byte of the opcode and then read the value based on the hint into REG3 */ function performRead3() internal { uint res; bool fin4l; (res, fin4l) = readFrom(getHint(2)); if (!fin4l) setReg3(res); } /** * @dev execute the opcode, put the result back in REG1 */ function performALU() internal { uint res; bool fin4l; (res, fin4l) = handleALU(getHint(3), getReg1(), getReg2(), getReg3(), getIreg()); if (fin4l) setPC(FINAL_STATE); else setReg1(res); } /** * @dev write a value stored in REG to a location using the 4th and 5th hint bytes */ function performWrite1() internal { uint target = getHint(4); uint hint = getHint(5); uint v; if (target == 1) v = getReg1(); if (target == 2) v = getReg2(); if (target == 3) v = getReg3(); writeStuff(hint, v); } /** * @dev write a value stored in REG to a location using the 6th and 7th hint bytes */ function performWrite2() internal { uint target = getHint(6); uint hint = getHint(7); uint v; if (target == 1) v = getReg1(); if (target == 2) v = getReg2(); if (target == 3) v = getReg3(); writeStuff(hint, v); } function performUpdatePC() internal { setPC(handlePointer(getHint(11), getPC())); } function performUpdateStackPtr() internal { setStackPtr(handlePointer(getHint(9), getStackPtr())); } function performUpdateCallPtr() internal { setCallPtr(handlePointer(getHint(8), getCallPtr())); } function performUpdateMemsize() internal { if (getHint(12) == 1) setMemsize(getMemsize()+getReg1()); } uint phase; function performPhase() internal { if (getPC() == FINAL_STATE) {} else if (phase == 0) performFetch(); else if (phase == 1) performInit(); else if (phase == 2) performRead1(); else if (phase == 3) performRead2(); else if (phase == 4) performRead3(); else if (phase == 5) performALU(); else if (phase == 6) performWrite1(); else if (phase == 7) performWrite2(); else if (phase == 8) performUpdatePC(); else if (phase == 9) performUpdateStackPtr(); else if (phase == 10) performUpdateCallPtr(); else if (phase == 11) performUpdateMemsize(); phase = (phase+1) % 12; } }
48,252
39
// uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply > 0) { uint256 BavaForFarmer; (, BavaForFarmer, , ,) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); accBavaPerShare = accBavaPerShare+(BavaForFarmer*(1e12)/(lpSupply)); }
if (block.number > pool.lastRewardBlock && lpSupply > 0) { uint256 BavaForFarmer; (, BavaForFarmer, , ,) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); accBavaPerShare = accBavaPerShare+(BavaForFarmer*(1e12)/(lpSupply)); }
35,266
334
// xref:ROOT:erc1155.adocbatch-operations[Batched] version of {_mint}. Requirements: - `ids` and `amounts` must have the same length.- If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return theacceptance magic value. /
function _mintBatch(
function _mintBatch(
74,842
12
// Return the final owner in the chain
return currentOwnerAddress;
return currentOwnerAddress;
10,224
206
// Mints 'quantity' tokens and transfers them to 'to'. This function is intended for efficient minting only during contract creation.
* It emits only one {ConsecutiveTransfer} as defined in * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309), * instead of a sequence of {Transfer} event(s). * * Calling this function outside of contract creation WILL make your contract * non-compliant with the ERC721 standard. * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309 * {ConsecutiveTransfer} event is only permissible during contract creation. * * Requirements: * * - 'to' cannot be the zero address. * - 'quantity' must be greater than 0. * * Emits a {ConsecutiveTransfer} event. */ function _mintERC2309(address to, uint256 quantity) internal virtual { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are unrealistic due to the above check for 'quantity' to be below the limit. unchecked { // Updates: // - 'balance += quantity'. // - 'numberMinted += quantity'. // // We can directly add to the 'balance' and 'numberMinted'. _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - 'address' to the owner. // - 'startTimestamp' to the timestamp of minting. // - 'burned' to 'false'. // - 'nextInitialized' to 'quantity == 1'. _packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to); _currentIndex = startTokenId + quantity; } _afterTokenTransfers(address(0), to, startTokenId, quantity); }
* It emits only one {ConsecutiveTransfer} as defined in * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309), * instead of a sequence of {Transfer} event(s). * * Calling this function outside of contract creation WILL make your contract * non-compliant with the ERC721 standard. * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309 * {ConsecutiveTransfer} event is only permissible during contract creation. * * Requirements: * * - 'to' cannot be the zero address. * - 'quantity' must be greater than 0. * * Emits a {ConsecutiveTransfer} event. */ function _mintERC2309(address to, uint256 quantity) internal virtual { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are unrealistic due to the above check for 'quantity' to be below the limit. unchecked { // Updates: // - 'balance += quantity'. // - 'numberMinted += quantity'. // // We can directly add to the 'balance' and 'numberMinted'. _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - 'address' to the owner. // - 'startTimestamp' to the timestamp of minting. // - 'burned' to 'false'. // - 'nextInitialized' to 'quantity == 1'. _packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to); _currentIndex = startTokenId + quantity; } _afterTokenTransfers(address(0), to, startTokenId, quantity); }
23,322
50
// The vehicle owner is given the ability to modify the URI with the documentation if there are any errors discovered.
function setNewDocumentationURI( string calldata newDocumentationURI
function setNewDocumentationURI( string calldata newDocumentationURI
14,208
17
// Goes through every pending reward on a [gauge][token] pair and calculates the pending rewards. _gauge The token underlying the supported gauge. _token The incentive deposited on this gauge.return _amount the updated reward amount /
function calculatePendingRewards(address _gauge, address _token) public view returns (uint _amount) { _amount = 0; for (uint i = 0; i < pendingRewardAddresses[_gauge][_token].length; i++) { address pendingRewardAddress = pendingRewardAddresses[_gauge][_token][i]; uint _rewardAmount = viewGaugeReturn(_gauge, _token, pendingRewardAddress); _amount += _rewardAmount; } }
function calculatePendingRewards(address _gauge, address _token) public view returns (uint _amount) { _amount = 0; for (uint i = 0; i < pendingRewardAddresses[_gauge][_token].length; i++) { address pendingRewardAddress = pendingRewardAddresses[_gauge][_token][i]; uint _rewardAmount = viewGaugeReturn(_gauge, _token, pendingRewardAddress); _amount += _rewardAmount; } }
23,690
87
// Add to balance.
_addToBalanceOf(_projectId, _amount, _shouldRefundHeldFees, _memo, _metadata);
_addToBalanceOf(_projectId, _amount, _shouldRefundHeldFees, _memo, _metadata);
14,312
159
// Withdraw a token from the reserve and transfer it to the owner without exchanging it/_nftId NFT token ID/_tokenIndex Index in array of tokens for this NFT and holding.
function withdraw(uint256 _nftId, uint256 _tokenIndex) external;
function withdraw(uint256 _nftId, uint256 _tokenIndex) external;
60,257
96
// move topping to pool
vat.frob(ilk, urn, urn, urn, 0, toInt(top)); vat.move(urn, pool, dtab);
vat.frob(ilk, urn, urn, urn, 0, toInt(top)); vat.move(urn, pool, dtab);
41,219
11
// Calculates the total units, loot and locked loot before any internal transfers it considers the locked loot to be able to calculate the fair amount to ragequit, but locked loot can not be burned.
uint256 initialTotalUnitsAndLoot = bank.balanceOf(TOTAL, UNITS) + bank.balanceOf(TOTAL, LOOT);
uint256 initialTotalUnitsAndLoot = bank.balanceOf(TOTAL, UNITS) + bank.balanceOf(TOTAL, LOOT);
72,098
474
// zero all bytes to the right
exp(0x100, sub(32, mlength)) ),
exp(0x100, sub(32, mlength)) ),
47,236
9
// move to operational
isFinalized = true; if(!ethFundDeposit.send(address(this).balance)) revert(); // send the eth to Brave International
isFinalized = true; if(!ethFundDeposit.send(address(this).balance)) revert(); // send the eth to Brave International
24,260
71
// The current minimum delay for a payment is `timeLock`. Thus the following ensuress that the `securityGuard` has checked in after the payment was createdearliestPayTime is updated when a payment is delayed. Which may require another checkIn before the payment can be collected.We add 30 mins to this to reduce (not eliminate) the risk of front-running
require(securityGuardLastCheckin >= p.earliestPayTime - timeLock + 30 minutes); super.disburseAuthorizedPayment(_idPayment);
require(securityGuardLastCheckin >= p.earliestPayTime - timeLock + 30 minutes); super.disburseAuthorizedPayment(_idPayment);
46,629
258
// Pool Delegate Setter Functions ///
function setLiquidityCap(uint256 newLiquidityCap) external { _whenProtocolNotPaused(); _isValidDelegateOrPoolAdmin(); liquidityCap = newLiquidityCap; emit LiquidityCapSet(newLiquidityCap); }
function setLiquidityCap(uint256 newLiquidityCap) external { _whenProtocolNotPaused(); _isValidDelegateOrPoolAdmin(); liquidityCap = newLiquidityCap; emit LiquidityCapSet(newLiquidityCap); }
59,736
7
// The ID of the permission required to call the `updateVotingSettings` function.
bytes32 public constant UPDATE_VOTING_SETTINGS_PERMISSION_ID = keccak256("UPDATE_VOTING_SETTINGS_PERMISSION");
bytes32 public constant UPDATE_VOTING_SETTINGS_PERMISSION_ID = keccak256("UPDATE_VOTING_SETTINGS_PERMISSION");
27,784
46
// [6] Sell price
sellPrice() );
sellPrice() );
41,963
487
// UniswapV2Router
IUniswapV2Router02 public uniV2Router;
IUniswapV2Router02 public uniV2Router;
27,756
52
// Proposal index, begin from 1
uint256 private _proposalIndex;
uint256 private _proposalIndex;
9,427
233
// A number between 0 and 216, normalized over 0 - 10000
numberDrawn = ((uint(randomBytes[i])*256 + uint(randomBytes[i+1]))*10000)/2**16; rangeUpperEnd = 0; amountWonSpin = 0; for (uint j = 0; j < probabilities.length; j++) { rangeUpperEnd += probabilities[j]; if (numberDrawn < rangeUpperEnd) { amountWonSpin = (spins[myid].amountWagered * multipliers[j]) / nSpins; amountWonTotal += amountWonSpin; break; }
numberDrawn = ((uint(randomBytes[i])*256 + uint(randomBytes[i+1]))*10000)/2**16; rangeUpperEnd = 0; amountWonSpin = 0; for (uint j = 0; j < probabilities.length; j++) { rangeUpperEnd += probabilities[j]; if (numberDrawn < rangeUpperEnd) { amountWonSpin = (spins[myid].amountWagered * multipliers[j]) / nSpins; amountWonTotal += amountWonSpin; break; }
32,721
17
// Uint256 Column/
function readUint256Column(bytes32 columnSlot, uint ordinal) public view returns ( uint
function readUint256Column(bytes32 columnSlot, uint ordinal) public view returns ( uint
39,161
45
// uint8 set
struct uint8Set { uint8[] members; mapping (uint8 => bool) memberExists; mapping (uint8 => uint) memberIndex; }
struct uint8Set { uint8[] members; mapping (uint8 => bool) memberExists; mapping (uint8 => uint) memberIndex; }
20,361
106
// Triggers update of the member rewards
function committeeMembershipWillChange(address guardian, uint256 weight, uint256 totalCommitteeWeight, bool inCommittee, bool inCommitteeAfter) external /* onlyCommitteeContract */;
function committeeMembershipWillChange(address guardian, uint256 weight, uint256 totalCommitteeWeight, bool inCommittee, bool inCommitteeAfter) external /* onlyCommitteeContract */;
2,314
13
// initiation participant token balances
mapping(address => uint256) private _staked;
mapping(address => uint256) private _staked;
17,684
8
// function to open the sale/requires contract owner
function openSale() external onlyOwner { require(_auctionSet, "auction not set"); startsAt = block.timestamp; saleOpen = true; }
function openSale() external onlyOwner { require(_auctionSet, "auction not set"); startsAt = block.timestamp; saleOpen = true; }
24,349
45
// the ordered list of target addresses for calls to be made
address[] targets;
address[] targets;
28,928
38
// Don't mess the dates
if(startsAt >= endsAt) { throw; }
if(startsAt >= endsAt) { throw; }
4,034
22
// Contructor that gives msg.sender all of existing tokens. /
constructor() public { //init tokens admin = msg.sender; }
constructor() public { //init tokens admin = msg.sender; }
53,461
200
// Base URI
string private _baseURI; address public exPlatform;
string private _baseURI; address public exPlatform;
28,242
5
// based on https:github.com/OpenZeppelin/openzeppelin-solidity/tree/v1.10.0/ SafeMath Math operations with safety checks that throw on error /
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } }
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } }
9,507
33
// Sender repays a borrow belonging to borrower borrower the account with the debt being payed off repayAmount The amount to repayreturn (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. /
function repayBorrowBehalf(address borrower, uint repayAmount) external nonReentrant returns (uint) { uint err = accrueInterest(); if (err != 0) { return fail(Error(err), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED); } (err,) = repayBorrowFresh(msg.sender, borrower, repayAmount); return err; }
function repayBorrowBehalf(address borrower, uint repayAmount) external nonReentrant returns (uint) { uint err = accrueInterest(); if (err != 0) { return fail(Error(err), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED); } (err,) = repayBorrowFresh(msg.sender, borrower, repayAmount); return err; }
16,001
17
// Returns whether staking restrictions can be set in given execution context.
function _canSetStakeConditions() internal view virtual override returns (bool) { return msg.sender == owner(); }
function _canSetStakeConditions() internal view virtual override returns (bool) { return msg.sender == owner(); }
6,681
6
// update balance in address
walletTokenBalance[_tokenAddress][_withdrawalAddress] = walletTokenBalance[_tokenAddress][_withdrawalAddress].add(_amounts[i]); _id = ++depositId; lockedToken[_id].tokenAddress = _tokenAddress; lockedToken[_id].withdrawalAddress = _withdrawalAddress; lockedToken[_id].tokenAmount = _amounts[i]; lockedToken[_id].unlockTime = _unlockTimes[i]; lockedToken[_id].withdrawn = false; allDepositIds.push(_id);
walletTokenBalance[_tokenAddress][_withdrawalAddress] = walletTokenBalance[_tokenAddress][_withdrawalAddress].add(_amounts[i]); _id = ++depositId; lockedToken[_id].tokenAddress = _tokenAddress; lockedToken[_id].withdrawalAddress = _withdrawalAddress; lockedToken[_id].tokenAmount = _amounts[i]; lockedToken[_id].unlockTime = _unlockTimes[i]; lockedToken[_id].withdrawn = false; allDepositIds.push(_id);
47,269
1
// [email protected]@[email protected]@@@[email protected]@@@@[email protected]@@[email protected]@@OO| [email protected]@@[email protected]@@WWWWWWW\OWWWO\[email protected]@@O.'\[email protected]@@[email protected]@@@@@OOW\ \[email protected]@@@@@@O'. `,[email protected]@@OOOOOOOOOOWW\ \[email protected]@@@@@OOO)\,[email protected]@@@@OOOOOOWWWWW\ \[email protected]@@@@OOOO.' `[email protected]@@@[email protected]@W\ \WOO|\UO-~' ([email protected]/\W\___\WO) `~-~'' \ \WW=' __\ \ \\\__\ \\ \ \ \ \\\ \\\ \ SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.4;
pragma solidity ^0.8.4;
57,034