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
14
// View function to see pending Tokens on frontend.
function pendingReward(address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo; UserInfo storage user = userInfo[_user]; uint256 accRewardPerShare = pool.accRewardPerShare; uint256 stakedSupply = syrup.balanceOf(address(this)); if (block.number > poo...
function pendingReward(address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo; UserInfo storage user = userInfo[_user]; uint256 accRewardPerShare = pool.accRewardPerShare; uint256 stakedSupply = syrup.balanceOf(address(this)); if (block.number > poo...
5,112
74
// Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memo...
* message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memo...
24,501
35
// Check timestamp of the new block
{ require(_newBlock.timestamp >= _previousBlock.timestamp, "g"); // Block should be after previous block bool timestampNotTooSmall = block.timestamp.sub(COMMIT_TIMESTAMP_NOT_OLDER) <= _newBlock.timestamp; bool timestampNotTooBig = _newBlock.timestamp <= block.timestamp.add(CO...
{ require(_newBlock.timestamp >= _previousBlock.timestamp, "g"); // Block should be after previous block bool timestampNotTooSmall = block.timestamp.sub(COMMIT_TIMESTAMP_NOT_OLDER) <= _newBlock.timestamp; bool timestampNotTooBig = _newBlock.timestamp <= block.timestamp.add(CO...
59,798
24
// purchased charges are deprecated, but still honored for anyone that purchased before deprecation
return charges + chargesData[bagId].chargesPurchased;
return charges + chargesData[bagId].chargesPurchased;
25,237
11
// Sets the buyer, ensuring that funds are transferred internally to the new buyer address. /
function setBuyer(Data storage self, address _buyer) internal { // must use buyerFunds() and sellerFunds() instead of accountBalances directly so that dailyCommission is updated first transfer(self, self.buyer, _buyer, buyerFunds(self)); self.buyer = _buyer; }
function setBuyer(Data storage self, address _buyer) internal { // must use buyerFunds() and sellerFunds() instead of accountBalances directly so that dailyCommission is updated first transfer(self, self.buyer, _buyer, buyerFunds(self)); self.buyer = _buyer; }
31,658
2
// solhint-disable quotes /
contract BleepsTokenURI is ITokenURI { // svg from : https://codepen.io/rachelmcgrane/pen/VexWdX function contractURI() external pure returns (string memory) { return 'data:application/json,{"name":"Bleeps","description":"Composable%20Sounds%20Fully%20Generated%20On-Chain"}'; } func...
contract BleepsTokenURI is ITokenURI { // svg from : https://codepen.io/rachelmcgrane/pen/VexWdX function contractURI() external pure returns (string memory) { return 'data:application/json,{"name":"Bleeps","description":"Composable%20Sounds%20Fully%20Generated%20On-Chain"}'; } func...
44,833
72
// 722,333 people died that summer but history won't remember a single one.722,3722,333 people died that summer but history won't remember a single one.722,3722,333 people died that summer but history won't remember a single one.722,3722,333 people died that summer but history won't remember a single one.722,3722,333 p...
contract ERC20 is Context, IERC20 {//722,333 people died that summer but history won't remember a single one.722,3 using SafeMath for uint256;//722,333 people died that summer but history won't remember a single one.722,3 using Address for address;//722,333 people died that summer but history won't remember a s...
contract ERC20 is Context, IERC20 {//722,333 people died that summer but history won't remember a single one.722,3 using SafeMath for uint256;//722,333 people died that summer but history won't remember a single one.722,3 using Address for address;//722,333 people died that summer but history won't remember a s...
34,220
103
// Emitted by the pool for any swaps between token0 and token1/sender The address that initiated the swap call, and that received the callback/recipient The address that received the output of the swap/amount0 The delta of the token0 balance of the pool/amount1 The delta of the token1 balance of the pool/sqrtPriceX96 T...
event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick );
event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick );
53,457
44
// checks if it's part of the allowed tokens /
modifier isTokenAllowed(uint256 _tokenId) { bool found = false; for (uint128 i = 0; i < allowedTokens.length; i++) { if (allowedTokens[i] == _tokenId) found = true; } require(found, "BadCacheBridge: token id does not exists"); _; }
modifier isTokenAllowed(uint256 _tokenId) { bool found = false; for (uint128 i = 0; i < allowedTokens.length; i++) { if (allowedTokens[i] == _tokenId) found = true; } require(found, "BadCacheBridge: token id does not exists"); _; }
19,685
34
// Get the access status for a address.
function getAddressAccess(address user) external view returns(bool) { return extendedAccess[user]; }
function getAddressAccess(address user) external view returns(bool) { return extendedAccess[user]; }
22,522
75
// Deletes a Controller _controller - Controller to be deletedreturn True if success /
function deleteController(address _controller) public onlyController returns (bool)
function deleteController(address _controller) public onlyController returns (bool)
50,227
15
// Sets the stored oracle address oracleAddress The address of the oracle contract /
function setChainlinkOracle(address oracleAddress) internal { s_oracle = OperatorInterface(oracleAddress); }
function setChainlinkOracle(address oracleAddress) internal { s_oracle = OperatorInterface(oracleAddress); }
20,031
49
// Appends a number to an instance of a TinyString: "1 + 2 = ".toTinyString().append(3) => "1 + 2 = 3".self an instance of TinyString to append the number to. number the number to append. return a new instance of TinyString. /
function appendNumber(TinyString self, uint number) internal pure returns (TinyString) { // since we work on character level, we don't need range checks. unchecked { uint str = TinyString.unwrap(self); if (number >= 100) { // if number is > 100, append number of hundreds str = (st...
function appendNumber(TinyString self, uint number) internal pure returns (TinyString) { // since we work on character level, we don't need range checks. unchecked { uint str = TinyString.unwrap(self); if (number >= 100) { // if number is > 100, append number of hundreds str = (st...
2,485
11
// Converts reward tokens to deposit tokens Always converts through router; there are no price checks enabledreturn deposit tokens received /
function _convertRewardTokensToDepositTokens(uint amount) private returns (uint) { require(amount > 0, "DexStrategySAWithSwap::_convertRewardTokensToDepositTokens"); uint pathLength = 2; address[] memory path = new address[](pathLength); path[0] = address(rewardToken); path[...
function _convertRewardTokensToDepositTokens(uint amount) private returns (uint) { require(amount > 0, "DexStrategySAWithSwap::_convertRewardTokensToDepositTokens"); uint pathLength = 2; address[] memory path = new address[](pathLength); path[0] = address(rewardToken); path[...
25,195
5
// Mint new COOP and return how much was minted /
function mint() public payable returns (uint256) { // increase the total supply and the senders balance by an amount of // COOP that maintains the COOP to ETH proportions. uint256 price = coopPrice(); require(msg.value >= price); uint256 amount = msg.value.div(price); totalSupply = totalSupply...
function mint() public payable returns (uint256) { // increase the total supply and the senders balance by an amount of // COOP that maintains the COOP to ETH proportions. uint256 price = coopPrice(); require(msg.value >= price); uint256 amount = msg.value.div(price); totalSupply = totalSupply...
18,197
87
// Update DebtLocker storage variables if Loan storage variables has been updated since last claim.
if (newFee > 0) lastFeePaid = newFee; if (newExcess > 0) lastExcessReturned = newExcess; if (newAmountRecovered > 0) lastAmountRecovered = newAmountRecovered;
if (newFee > 0) lastFeePaid = newFee; if (newExcess > 0) lastExcessReturned = newExcess; if (newAmountRecovered > 0) lastAmountRecovered = newAmountRecovered;
5,353
2
// Gets the "valid" reporter's NPM commission rate(upon each unstake claim invoked by individual "valid" stakers)for the given cover. Warning: this function does not validate the input arguments.s Specify store instance/
function getGovernanceReporterCommissionInternal(IStore s) public view returns (uint256) { return s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTER_COMMISSION); }
function getGovernanceReporterCommissionInternal(IStore s) public view returns (uint256) { return s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTER_COMMISSION); }
1,334
9
// shouldn't be trying to sell MyFriends
if (token == address(this)) return 0;
if (token == address(this)) return 0;
17,518
2
// check if an address has entered the matrix
mapping(address => bool) public isInMatrix; address[] public users; //array of users in the matrix uint public totalSupplyMultiplier; //total supply multiplier to adjust for vdush total supply calc on bnb chain uint public ushPerSec; mapping(address => uint) public initialEarned; mapping(addre...
mapping(address => bool) public isInMatrix; address[] public users; //array of users in the matrix uint public totalSupplyMultiplier; //total supply multiplier to adjust for vdush total supply calc on bnb chain uint public ushPerSec; mapping(address => uint) public initialEarned; mapping(addre...
5,384
96
// The decimals of the token.
uint256 public decimals;
uint256 public decimals;
25,408
4
// Event variables
uint public netDepositInd; uint256 public netAmountEvent; uint256 public maxDepositAmount; uint256 public maxWithdrawAmount; uint256 public withdrawAmountTotal; uint256 public withdrawAmountTotalOld; uint256 public depositAmountTotal; uint256 public TIME_WITHDRAW_MANAGER = 0;
uint public netDepositInd; uint256 public netAmountEvent; uint256 public maxDepositAmount; uint256 public maxWithdrawAmount; uint256 public withdrawAmountTotal; uint256 public withdrawAmountTotalOld; uint256 public depositAmountTotal; uint256 public TIME_WITHDRAW_MANAGER = 0;
78,104
71
// See ERC 165
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155PresetMinterPauserSupplyHolder, IERC165) returns (bool)
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155PresetMinterPauserSupplyHolder, IERC165) returns (bool)
2,141
118
// Contract module that helps prevent reentrant calls to a function. Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifieravailable, which can be aplied to functions to make sure there are no nested(reentrant) calls to them. Note that because there is a single `nonReentrant` guard, functions marked as...
contract ReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; constructor () internal { // The counter starts at one to prevent changing it from zero to a non-zero // value, which is a more expensive operation. _guardCo...
contract ReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; constructor () internal { // The counter starts at one to prevent changing it from zero to a non-zero // value, which is a more expensive operation. _guardCo...
750
888
// Remove it from the tree so it no longer blocks parent claims if it is land
removeChildFromTree(token);
removeChildFromTree(token);
21,790
22
// Increase the amount of tokens that an owner allowed to a spender. approve should be called when allowed[_spender] == 0. To increment allowed value is better to use this function to avoid 2 calls (and wait until the first transaction is mined) From MonolithDAO Token.sol_spender The address which will spend the funds....
function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool)
function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool)
2,700
10
// mapping for staking status
mapping (uint256 => bool) public isStaked;
mapping (uint256 => bool) public isStaked;
21,065
438
// Mapping from currency id to maturity to its tightly packed cash group parameters
function getCashGroupStorage() internal pure returns (mapping(uint256 => bytes32) storage store)
function getCashGroupStorage() internal pure returns (mapping(uint256 => bytes32) storage store)
64,963
10
// move over our mask by one to open up a new bit
slots = slots << 1;
slots = slots << 1;
10,148
48
// Can only be triggered by owner or governance, not custodian Tokens are sent to the custodian, as a sort of safeguard
ERC20(tokenAddress).transfer(custodian_address, tokenAmount); emit Recovered(tokenAddress, tokenAmount);
ERC20(tokenAddress).transfer(custodian_address, tokenAmount); emit Recovered(tokenAddress, tokenAmount);
25,273
331
// Require that beneficiary fraction is strictly positive
if (0 >= beneficiaryFraction(beneficiaryAddress)) continue;
if (0 >= beneficiaryFraction(beneficiaryAddress)) continue;
4,187
29
// Events that are issued to make statistic recovery easier.
event FailedPayment(address indexed beneficiary, uint amount); event VIPPayback(address indexed beneficiary, uint amount); event WithdrawFunds(address indexed beneficiary, uint amount);
event FailedPayment(address indexed beneficiary, uint amount); event VIPPayback(address indexed beneficiary, uint amount); event WithdrawFunds(address indexed beneficiary, uint amount);
2,138
1,096
// https:etherscan.io/address/0xde3892383965FBa6eC434bE6350F85f140098708;
Synth existingSynth = Synth(0xde3892383965FBa6eC434bE6350F85f140098708);
Synth existingSynth = Synth(0xde3892383965FBa6eC434bE6350F85f140098708);
34,534
16
// claims and sells COMP on uniswap, returns total received comp and caller reward
function harvest(uint256 maxCompAmount_) public returns (uint256 compGot, uint256 underlyingHarvestReward)
function harvest(uint256 maxCompAmount_) public returns (uint256 compGot, uint256 underlyingHarvestReward)
24,373
20
// 私有的交易函数 /
function _transfer(address _from, address _to, uint _value) internal { // 防止转移到0x0, 用burn代替这个功能 require(_to != 0x0); // 检测发送者是否有足够的资金 //require(canOf[_from] >= _value); require(balanceOf[_from] >= _value); // 检查是否溢出(数据类型的溢出) require(balanceOf[_to] + _value > balanceOf[_to]); // 将此保存为将来的断言, 函数最后会有一个检验...
function _transfer(address _from, address _to, uint _value) internal { // 防止转移到0x0, 用burn代替这个功能 require(_to != 0x0); // 检测发送者是否有足够的资金 //require(canOf[_from] >= _value); require(balanceOf[_from] >= _value); // 检查是否溢出(数据类型的溢出) require(balanceOf[_to] + _value > balanceOf[_to]); // 将此保存为将来的断言, 函数最后会有一个检验...
54,913
556
// Updates the Vault on the value of the pool's investment returns /
function updateBalanceOfPool(bytes32 poolId) external;
function updateBalanceOfPool(bytes32 poolId) external;
13,975
2
// solium-disable-line
sstore( _IMPLEMENTATION_SLOT, codeAddress )
sstore( _IMPLEMENTATION_SLOT, codeAddress )
4,833
209
// function to disable gasless listings for security in case opensea ever shuts down or is compromised
function setIsOpenSeaProxyActive(bool _isOpenSeaProxyActive) external onlyOwner
function setIsOpenSeaProxyActive(bool _isOpenSeaProxyActive) external onlyOwner
25,763
123
// give out gu reward
if (_toReward > 0) { plyr_[_affID].gu = _toReward.add(plyr_[_affID].gu); // give gu to player plyrPhas_[_affID][_newPhID].guRewarded = _toReward.add(plyrPhas_[_affID][_newPhID].guRewarded); phrase_[_newPhID].guGiven = 1e18.add(phrase_[_newPhID].guGiven); ...
if (_toReward > 0) { plyr_[_affID].gu = _toReward.add(plyr_[_affID].gu); // give gu to player plyrPhas_[_affID][_newPhID].guRewarded = _toReward.add(plyrPhas_[_affID][_newPhID].guRewarded); phrase_[_newPhID].guGiven = 1e18.add(phrase_[_newPhID].guGiven); ...
26,986
2
// never overflows, and + overflow is desired
priceCumulative += uint256(priceLast) * timeElapsed;
priceCumulative += uint256(priceLast) * timeElapsed;
17,908
6
// Must be permitted to play the game
require(msg.sender==game.first_player || msg.sender==game.second_player, "Must be permitted to play the game");
require(msg.sender==game.first_player || msg.sender==game.second_player, "Must be permitted to play the game");
28,613
118
// Recover
return recoverSignature(abi.encode(payload), signature);
return recoverSignature(abi.encode(payload), signature);
33,377
392
// State transition per Vault. Just linear transitions.
enum State {Inactive, Deposit, Live, Withdraw} // Only supports 2 tranches for now enum Tranche {Senior, Junior} struct VaultParams { address seniorAsset; address juniorAsset; address strategist; address strategy; uint256 hurdleRate; uint256 startTime; uint256 enrollment; uint2...
enum State {Inactive, Deposit, Live, Withdraw} // Only supports 2 tranches for now enum Tranche {Senior, Junior} struct VaultParams { address seniorAsset; address juniorAsset; address strategist; address strategy; uint256 hurdleRate; uint256 startTime; uint256 enrollment; uint2...
7,609
556
// setManagementProxy(): configure the management proxy for _pointThe management proxy may perform "reversible" operations onbehalf of the owner. This includes public key configuration andoperations relating to sponsorship.
function setManagementProxy(uint32 _point, address _manager) external activePointManager(_point)
function setManagementProxy(uint32 _point, address _manager) external activePointManager(_point)
43,638
25
// Returns the remaining number of tokens that `spender` will beallowed to spend on behalf of `owner` through {transferFrom}. This iszero by default. This value changes when {approve} or {transferFrom} are called. /
function allowance(address owner, address spender) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
23,896
4
// Restricted Functions
function mintSecondary(address account, uint amount) external; function mintSecondaryRewards(uint amount) external; function burnSecondary(address account, uint amount) external;
function mintSecondary(address account, uint amount) external; function mintSecondaryRewards(uint amount) external; function burnSecondary(address account, uint amount) external;
42,496
0
// Emits when the contract administrator is changed./oldAdmin The address of the previous administrator./newAdmin The address of the new administrator.
event AdminChanged(address oldAdmin, address newAdmin);
event AdminChanged(address oldAdmin, address newAdmin);
33,446
61
// event emitted upon a redemption
event Redeem(address to, uint256 amountFeiIn, uint256 amountAssetOut);
event Redeem(address to, uint256 amountFeiIn, uint256 amountAssetOut);
66,727
18
// This function returns who is authorized to lazy mint NFTs on your contract./
function _canLazyMint() internal view virtual override returns (bool) { return msg.sender == deployer || hasRole(MINTER_ROLE, msg.sender) || hasRole(DEFAULT_ADMIN_ROLE, msg.sender); }
function _canLazyMint() internal view virtual override returns (bool) { return msg.sender == deployer || hasRole(MINTER_ROLE, msg.sender) || hasRole(DEFAULT_ADMIN_ROLE, msg.sender); }
35,921
65
// Update the reward token state before the user's state
_updateRewardState(reward); UserRewardState storage userState = rewardStates[reward].userStates[user];
_updateRewardState(reward); UserRewardState storage userState = rewardStates[reward].userStates[user];
281
55
// Deposit ether to get wrapped ether
function deposit() external payable;
function deposit() external payable;
12,259
17
// We still have some spare memory space on the left, as we have allocated 3 words (96 bytes) for up to 78 digits.
let length := mload(str) // Load the string length. mstore(str, 0x2d) // Store the '-' character. str := sub(str, 1) // Move back the string pointer by a byte. mstore(str, add(length, 1)) // Update the string length.
let length := mload(str) // Load the string length. mstore(str, 0x2d) // Store the '-' character. str := sub(str, 1) // Move back the string pointer by a byte. mstore(str, add(length, 1)) // Update the string length.
23,420
116
// Immutables are computed in the init code of the contract, and then inlined into the deployed bytecode. In other words, this variable won't change when it's checked at runtime.
original = address(this);
original = address(this);
41,264
24
// NOTE: Current solc won't allow using MAX_REWARD_ASSETS with abi.decode
( uint8 transitionType, bytes32 stateRoot, uint32 poolId, uint32 strategyId, uint32[MAX_REWARD_ASSETS] memory rewardAssetIds, uint256[MAX_REWARD_ASSETS] memory rewardPerEpoch, uint256 stakeAdjustmentFactor, uint64 st...
( uint8 transitionType, bytes32 stateRoot, uint32 poolId, uint32 strategyId, uint32[MAX_REWARD_ASSETS] memory rewardAssetIds, uint256[MAX_REWARD_ASSETS] memory rewardPerEpoch, uint256 stakeAdjustmentFactor, uint64 st...
38,008
126
// Overridden balanceOf function to automatically increase/decrease holder balances based on reflections
function balanceOf(address account) public view virtual override returns (uint256) { uint256 reflectedRewards = (_totalReflected * _balances[account]) / (_totalReflected + totalSupply()); return _balances[account] + reflectedRewards; }
function balanceOf(address account) public view virtual override returns (uint256) { uint256 reflectedRewards = (_totalReflected * _balances[account]) / (_totalReflected + totalSupply()); return _balances[account] + reflectedRewards; }
17,808
2
// Reverts if the contract is paused. /
modifier whenNotPaused() { _ensureNotPaused(); _; }
modifier whenNotPaused() { _ensureNotPaused(); _; }
21,782
17
// Withdraw Ether /
function withdraw() external onlyOwner { uint256 balance = address(this).balance; require(balance > 0, "No balance to withdraw"); (bool success, ) = payable(msg.sender).call{value: balance}(""); require(success, "Failed to withdraw payment"); }
function withdraw() external onlyOwner { uint256 balance = address(this).balance; require(balance > 0, "No balance to withdraw"); (bool success, ) = payable(msg.sender).call{value: balance}(""); require(success, "Failed to withdraw payment"); }
30,075
31
// function allow to now the necessary time for the Shujinko farming
function _ShujinkoDuration(uint256 _id) private view returns(uint256){ // function will return amount needed to farm Shujinko uint256 _duration; if(_id >= 1 && _id <= 10){ _duration = KillerShujinkoFarmingTime; } else if(_id >= 11 && _id <= 60){ _duration = Mo...
function _ShujinkoDuration(uint256 _id) private view returns(uint256){ // function will return amount needed to farm Shujinko uint256 _duration; if(_id >= 1 && _id <= 10){ _duration = KillerShujinkoFarmingTime; } else if(_id >= 11 && _id <= 60){ _duration = Mo...
42,178
192
// What is the balance of a particular account?
function balanceOf(address _owner) constant returns (uint256 balance) { return tokenBalanceOf[_owner]; }
function balanceOf(address _owner) constant returns (uint256 balance) { return tokenBalanceOf[_owner]; }
72,604
14
// return r the product of a point on G1 and a scalar, i.e./ p == p.scalar_mul(1) and p.addition(p) == p.scalar_mul(2) for all points p.
function scalar_mul(G1Point memory p, uint s) internal view returns (G1Point memory r) { uint[3] memory input; input[0] = p.X; input[1] = p.Y; input[2] = s; bool success; // solium-disable-next-line security/no-inline-assembly assembly { success :=...
function scalar_mul(G1Point memory p, uint s) internal view returns (G1Point memory r) { uint[3] memory input; input[0] = p.X; input[1] = p.Y; input[2] = s; bool success; // solium-disable-next-line security/no-inline-assembly assembly { success :=...
12,151
20
// Set a new Ipfs Base URI for the items metadata_ipfsbaseuri token URI in string format/
function setIpfsBaseURI(string memory _ipfsbaseuri) external onlyOwner { ipfsBaseURI = _ipfsbaseuri; }
function setIpfsBaseURI(string memory _ipfsbaseuri) external onlyOwner { ipfsBaseURI = _ipfsbaseuri; }
18,637
31
// Burn shares amount
_burn(msg.sender, shares); emit Withdraw( address(asset), msg.sender, receiver, assets, shares, fee );
_burn(msg.sender, shares); emit Withdraw( address(asset), msg.sender, receiver, assets, shares, fee );
46,167
277
// User does not have permissions to join garden
uint256 internal constant USER_CANNOT_JOIN = 29;
uint256 internal constant USER_CANNOT_JOIN = 29;
42,366
6
// Eject current value from implentation/Doesn't call storage directly to allow implementation handle read in custom way
function getCounter() public view returns (uint) { return counter.getCounter(store); }
function getCounter() public view returns (uint) { return counter.getCounter(store); }
51,019
12
// if asset paused,reject the price
bool paused;
bool paused;
28,079
0
// Constructor function for Core_transferProxyThe address of the transfer proxy _vaultThe address of the vault /
constructor( address _transferProxy, address _vault ) public {
constructor( address _transferProxy, address _vault ) public {
14,145
266
// Create price sheet
function _createPriceSheet( PriceSheet[] storage sheets, uint accountIndex, uint32 ethNum, uint nestNum1k, uint level_shares, uint tokenAmountPerEth
function _createPriceSheet( PriceSheet[] storage sheets, uint accountIndex, uint32 ethNum, uint nestNum1k, uint level_shares, uint tokenAmountPerEth
12,642
6
// convert BPT-BEETS-FTM into fBeets
uint256 _bpt = IERC20(bptBeetsFtm).balanceOf(address(this)); IERC20(bptBeetsFtm).safeApprove(fBeets, 0); IERC20(bptBeetsFtm).safeApprove(fBeets, _bpt); IBeetsBar(fBeets).enter(_bpt);
uint256 _bpt = IERC20(bptBeetsFtm).balanceOf(address(this)); IERC20(bptBeetsFtm).safeApprove(fBeets, 0); IERC20(bptBeetsFtm).safeApprove(fBeets, _bpt); IBeetsBar(fBeets).enter(_bpt);
25,214
50
// Lock tokens for team
uint256 public releasedLockedAmount = 0;
uint256 public releasedLockedAmount = 0;
33,318
10
// ============================== ERC20
event Transfer( address indexed from, address indexed to, uint256 tokens );
event Transfer( address indexed from, address indexed to, uint256 tokens );
6,638
42
// Specific code for a simple swap and a multihop (2 swaps in sequence)
if (swapSequences[i].length == 1) { Swap memory swap = swapSequences[i][0]; TokenInterface SwapTokenIn = TokenInterface(swap.tokenIn); PoolInterface pool = PoolInterface(swap.pool); if (SwapTokenIn.allowance(address(this), swap.pool) > 0) { ...
if (swapSequences[i].length == 1) { Swap memory swap = swapSequences[i][0]; TokenInterface SwapTokenIn = TokenInterface(swap.tokenIn); PoolInterface pool = PoolInterface(swap.pool); if (SwapTokenIn.allowance(address(this), swap.pool) > 0) { ...
17,989
55
// Set the agent that will authorize transfers _agent Address of agent /
function setTransferAgent(address _agent) external onlyGovernor { transferAgent = _agent; }
function setTransferAgent(address _agent) external onlyGovernor { transferAgent = _agent; }
14,473
22
// 当前时间是否大于 72 小时
function isTime()view public returns(bool) { if ((block.timestamp.sub(rechargeTime)) >= day && rechargeTime != 0){ return true; } return false; }
function isTime()view public returns(bool) { if ((block.timestamp.sub(rechargeTime)) >= day && rechargeTime != 0){ return true; } return false; }
24,134
9
// ensures that the first tokens in the contract will be equally distributed meaning, no divine dump will be ever possible result: healthy longevity.
modifier antiEarlyWhale(uint256 _amountOfEthereum){ address _customerAddress = msg.sender; // are we still in the vulnerable phase? // if so, enact anti early whale protocol if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){ ...
modifier antiEarlyWhale(uint256 _amountOfEthereum){ address _customerAddress = msg.sender; // are we still in the vulnerable phase? // if so, enact anti early whale protocol if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){ ...
18,939
8
// expmods[3] = point^(trace_length / 8).
mstore(0x4ee0, expmod(point, div(/*trace_length*/ mload(0x80), 8), PRIME))
mstore(0x4ee0, expmod(point, div(/*trace_length*/ mload(0x80), 8), PRIME))
17,371
3
// Query if a contract implements an interfaceinterfaceID The interface identifier, as specified in ERC-165Interface identification is specified in ERC-165 return `true` if the contract implements `interfaceID` and `interfaceID` is not 0xffffffff, `false` otherwise/
function supportsInterface(bytes4 interfaceID) public view returns (bool) { return interfaceID == 0xffffffff ? false : methodsImplementations[interfaceID] != address(0x00); }
function supportsInterface(bytes4 interfaceID) public view returns (bool) { return interfaceID == 0xffffffff ? false : methodsImplementations[interfaceID] != address(0x00); }
22,190
34
// ERC721 tokens bulk transfer/https:github.com/gnkz/This smart contract allows to transfer multiple ERC721 tokens at once/The contract needs approvals for the tokens that are going to be transferred
contract ERC721BulkTransfer is IERC721BulkTransfer { /// @inheritdoc IERC721BulkTransfer function transfer( address collection, address recipient, uint256[] calldata tokenIds ) external { require(tokenIds.length > 0, "Invalid token ids amount"); for (uint256 i = ...
contract ERC721BulkTransfer is IERC721BulkTransfer { /// @inheritdoc IERC721BulkTransfer function transfer( address collection, address recipient, uint256[] calldata tokenIds ) external { require(tokenIds.length > 0, "Invalid token ids amount"); for (uint256 i = ...
19,270
1
// Set the staking token for the contract
constructor( uint256 _duration, address _stakingToken, IERC20Metadata _rewardToken, address _treasury
constructor( uint256 _duration, address _stakingToken, IERC20Metadata _rewardToken, address _treasury
8,402
51
// TwoDimensions TwoDimensions TwoDimensions is an ERC223 Token with ERC20 functions and events Fully backward compatible with ERC20 /
contract TwoDimensions is ERC223, Ownable { using SafeMath for uint256; string public name = "TwoDimensions"; string public symbol = "2D"; uint8 public decimals = 8; uint256 public totalSupply = 240e9 * 1e8; uint256 public distributeAmount = 0; bool public mintingFinished = false; mapp...
contract TwoDimensions is ERC223, Ownable { using SafeMath for uint256; string public name = "TwoDimensions"; string public symbol = "2D"; uint8 public decimals = 8; uint256 public totalSupply = 240e9 * 1e8; uint256 public distributeAmount = 0; bool public mintingFinished = false; mapp...
47,377
2
// To prevent Owner from overriding fees, Administrator must/ first initialize with fee.
error AdministratorMustInitializeWithFee();
error AdministratorMustInitializeWithFee();
11,851
112
// Decrease the _amount of tokens that an owner has allowed to a _spender. _spender The address which will spend the funds. _subtractedValue The _amount of tokens to decrease the allowance by. /
function decreaseAllowance(address _spender, uint256 _subtractedValue) public returns (bool)
function decreaseAllowance(address _spender, uint256 _subtractedValue) public returns (bool)
18,747
214
// Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings. /
function isApprovedForAll(address owner, address operator) public view override returns (bool)
function isApprovedForAll(address owner, address operator) public view override returns (bool)
86,963
21
// ------------------------------------------------------------------------ Transfer tokens from the from account to the to accountThe calling account must already have sufficient tokens approve(...)-d for spending from the from account and - From account must have sufficient balance to transfer - Spender must have suf...
function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balanc...
function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balanc...
23,459
29
// TODO: maybe emit only once in the future
emit Shaman(_applicant, _applicantShares, _applicantLoot, mint);
emit Shaman(_applicant, _applicantShares, _applicantLoot, mint);
8,678
138
// Main entry point to initiate a rebase operation.The Orchestrator calls rebase on the policy and notifies downstream applications.Contracts are guarded from calling, to avoid flash loan attacks on liquidityproviders.If a transaction in the transaction list reverts, it is swallowed and the remainingtransactions are ex...
function rebase() external onlyOwner
function rebase() external onlyOwner
13,203
2
// Indices are signed integers because the queue can grow in any direction. They are 128 bits so begin and endare packed in a single storage slot for efficient access. Since the items are added one at a time we can safelyassume that these 128-bit indices will not overflow, and use unchecked arithmetic. Struct members h...
struct Bytes32Deque { int128 _begin; int128 _end; mapping(int128 => bytes32) _data; }
struct Bytes32Deque { int128 _begin; int128 _end; mapping(int128 => bytes32) _data; }
50,584
375
// Handles transferring funds from msg.sender to thetransaction manager contract. Used in prepare, addLiquidity assetId The address to transfer specifiedAmount The specified amount to transfer. May not be theactual amount transferred (i.e. fee on transfertokens) /
function transferAssetToContract(address assetId, uint256 specifiedAmount) internal returns (uint256) { uint256 trueAmount = specifiedAmount; // Validate correct amounts are transferred if (LibAsset.isEther(assetId)) { require(msg.value >= specifiedAmount, "#TA:005"); } else { uint256 start...
function transferAssetToContract(address assetId, uint256 specifiedAmount) internal returns (uint256) { uint256 trueAmount = specifiedAmount; // Validate correct amounts are transferred if (LibAsset.isEther(assetId)) { require(msg.value >= specifiedAmount, "#TA:005"); } else { uint256 start...
15,766
8
// Toggles between 4 bool options within a specified chapter.option == 1: Permission for the NFT to be transfered, option == 2: Criteria if addresses must be unique to become a StarSibling, option == 3: Allows Avatars to be burned and become a StarSibling, option == 4: Unlocks chapter to overwrite entire chapter (Not r...
function toggleOption(uint256 _tokenId, uint256 option) external onlyAdmins { Chapter storage chapter = chapters[_tokenId]; if (option == 1) { chapter.transferable = !chapter.transferable; } else if (option == 2) { chapter.unique = !chapter.u...
function toggleOption(uint256 _tokenId, uint256 option) external onlyAdmins { Chapter storage chapter = chapters[_tokenId]; if (option == 1) { chapter.transferable = !chapter.transferable; } else if (option == 2) { chapter.unique = !chapter.u...
26,732
281
// Increase the token debt
msdTokenData[_token].debt = msdTokenData[_token].debt.add(_amount);
msdTokenData[_token].debt = msdTokenData[_token].debt.add(_amount);
52,215
9
// Pull liquidity tokens from liquidity and receive the tokens/shares Number of liquidity tokens to pull from liquidity/tickLower lower tick/tickUpper upper tick/amountMin min outs / return amount0 amount of token0 received from base position/ return amount1 amount of token1 received from base position
function pullLiquidity( int24 tickLower, int24 tickUpper, uint128 shares, uint256[2] memory amountMin
function pullLiquidity( int24 tickLower, int24 tickUpper, uint128 shares, uint256[2] memory amountMin
17,853
50
// messageHash can be used only once
bytes32 messageHash = message(_user,amount,_time); require(!msgHash[messageHash], "claim: signature duplicate");
bytes32 messageHash = message(_user,amount,_time); require(!msgHash[messageHash], "claim: signature duplicate");
40,372
2
// Number of bytes in formatted message before `body` field
uint256 internal constant PREFIX_LENGTH = 76;
uint256 internal constant PREFIX_LENGTH = 76;
21,400
22
// This function updates the unipilot contract address _unipilot: unipilot contract address /
function updateUnipilotAddress(address _unipilot) external onlyGovernance { require(_unipilot != address(0), "ZA"); unipilot = _unipilot; }
function updateUnipilotAddress(address _unipilot) external onlyGovernance { require(_unipilot != address(0), "ZA"); unipilot = _unipilot; }
43,026
782
// if USDC value is greater than the amount required, return excess USDC to msg.sender
uint256 donationInUSDC = newManagerRepToken.mul(reptokenPrice).div(PRECISION); if (receivedUSDC > donationInUSDC) { usdc.safeTransfer(msg.sender, receivedUSDC.sub(donationInUSDC)); receivedUSDC = donationInUSDC; }
uint256 donationInUSDC = newManagerRepToken.mul(reptokenPrice).div(PRECISION); if (receivedUSDC > donationInUSDC) { usdc.safeTransfer(msg.sender, receivedUSDC.sub(donationInUSDC)); receivedUSDC = donationInUSDC; }
41,051
11
// Returns the integer division of two unsigned integers, reverting ondivision by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Requirements: - The divisor cannot be zero. /
function div(uint a, uint b) internal pure returns (uint) { return a / b; }
function div(uint a, uint b) internal pure returns (uint) { return a / b; }
71,610
30
// No need to set default ANONYMOUS_PENDING status
_allVotesToIndex[voter][claimIndex] = _voteIndex; _allVotesIndexes.add(_voteIndex); _voteIndex++;
_allVotesToIndex[voter][claimIndex] = _voteIndex; _allVotesIndexes.add(_voteIndex); _voteIndex++;
36,897
15
// Traslate a payment in USD to ETHs _paymentAmount --> Payment amount in USDreturn Returns the ETH amount in weis /
function calculateETHPayment(uint256 _paymentAmount) external view returns(uint256) { uint256 usdETH = _getUSDETHPrice(); return (_paymentAmount * 10 ** 18) / usdETH; }
function calculateETHPayment(uint256 _paymentAmount) external view returns(uint256) { uint256 usdETH = _getUSDETHPrice(); return (_paymentAmount * 10 ** 18) / usdETH; }
57,899
4
// TODO: RENAME ME !!
contract TheConcept is Ownable, ERC20 { uint public lastModified; string internal _name = ""; string internal _symbol = 'N/A'; bytes32 latest_name_hash; bytes32 latest_symbol_hash; bytes32 constant EMPTY_HASH = keccak256(abi.encode("")); bytes32 constant ZERO_HASH = keccak256(abi.encode(0))...
contract TheConcept is Ownable, ERC20 { uint public lastModified; string internal _name = ""; string internal _symbol = 'N/A'; bytes32 latest_name_hash; bytes32 latest_symbol_hash; bytes32 constant EMPTY_HASH = keccak256(abi.encode("")); bytes32 constant ZERO_HASH = keccak256(abi.encode(0))...
30,841
15
// 先检查该红包有没有余额
require(playerInfo[id].balance > 0, "redpack is empty"); require(playerInfo[id].count > playerInfo[id].hunterList.length, "exceed number of redpacks"); require(!checkHunterExists(id, msg.sender), 'already grabbed'); if(playerInfo[id].isRandom) {
require(playerInfo[id].balance > 0, "redpack is empty"); require(playerInfo[id].count > playerInfo[id].hunterList.length, "exceed number of redpacks"); require(!checkHunterExists(id, msg.sender), 'already grabbed'); if(playerInfo[id].isRandom) {
5,679
325
// deprecated
uint256 public constant PERCENTAGE_FACTOR = ONE; //percentage plus two decimals
uint256 public constant PERCENTAGE_FACTOR = ONE; //percentage plus two decimals
19,618
286
// we didn't reach the target, so take the remainder of the maximum input as fee
feeAmount = uint256(amountRemaining) - amountIn;
feeAmount = uint256(amountRemaining) - amountIn;
3,552