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
33
// Adds two int256 variables and fails on overflow. /
function add(int256 a, int256 b) internal pure returns (int256)
function add(int256 a, int256 b) internal pure returns (int256)
18,727
150
// if the pool is ILV Pool - create new ILV deposit and save it - push it into deposits array
Deposit memory newDeposit = Deposit({ tokenAmount: pendingYield, lockedFrom: uint64(now256()), lockedUntil: uint64(now256() + 365 days), // staking yield for 1 year weight: depositWeight, isYi...
Deposit memory newDeposit = Deposit({ tokenAmount: pendingYield, lockedFrom: uint64(now256()), lockedUntil: uint64(now256() + 365 days), // staking yield for 1 year weight: depositWeight, isYi...
31,460
35
// TTTC Token, with the addition of symbol, name and decimals and a fixed supply
contract TTTCToken is ERC20, Owned { using SafeMath for uint; event Pause(); event Unpause(); event ReleasedTokens(uint tokens); event AllocateTokens(address to, uint tokens); bool public paused = false; string public symbol; string public name; uint8 public decimals; ...
contract TTTCToken is ERC20, Owned { using SafeMath for uint; event Pause(); event Unpause(); event ReleasedTokens(uint tokens); event AllocateTokens(address to, uint tokens); bool public paused = false; string public symbol; string public name; uint8 public decimals; ...
24,496
36
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED');
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED');
78,038
23
// Subtract the amount from msg.sender
_balances[_msgSender()] = _balances[_msgSender()].sub(amount, "ERC20: transfer amount exceeds balance"); _stakingBalances[_msgSender()] = _stakingBalances[_msgSender()].add(amount); emit Transfer(_msgSender(),_msgSender(),amount); return true;
_balances[_msgSender()] = _balances[_msgSender()].sub(amount, "ERC20: transfer amount exceeds balance"); _stakingBalances[_msgSender()] = _stakingBalances[_msgSender()].add(amount); emit Transfer(_msgSender(),_msgSender(),amount); return true;
15,370
271
// Amounts of token0 and token1 held in vault's position. Includesowed fees but excludes the proportion of fees that will be paid to theprotocol. Doesn't include fees accrued since last poke. /
function getPositionAmounts(int24 tickLower, int24 tickUpper) public view returns (uint256 amount0, uint256 amount1)
function getPositionAmounts(int24 tickLower, int24 tickUpper) public view returns (uint256 amount0, uint256 amount1)
53,136
0
// Struct is like an objct in JS This is to specify types
struct Campaign { address owner; string title; string category; string description; uint256 target; uint256 deadline; uint256 amountCollected; string image; address[] donators; uint256[] donations; }
struct Campaign { address owner; string title; string category; string description; uint256 target; uint256 deadline; uint256 amountCollected; string image; address[] donators; uint256[] donations; }
27,585
9
// store referral values in BNB
mapping(address => uint256) referredBNBValue;
mapping(address => uint256) referredBNBValue;
25,401
8
// Metadata variables
string public _baseURI_;
string public _baseURI_;
66,239
16
// bytes32[] parentMerkleProof,
uint coinbaseTxIndex, uint parentNonce
uint coinbaseTxIndex, uint parentNonce
12,803
4
// Limits address to publicMintLimit per token.
mapping(address => mapping(uint256 => uint256)) private addressData; ContractStatus private contractStatus = ContractStatus.Paused;
mapping(address => mapping(uint256 => uint256)) private addressData; ContractStatus private contractStatus = ContractStatus.Paused;
7,380
145
// increase the allocation
increaseAllocations(_toDistribute);
increaseAllocations(_toDistribute);
47,341
292
// Shows current Sorbetto's balances/totalAmount0 Current token0 Sorbetto's balance/totalAmount1 Current token1 Sorbetto's balance
event Snapshot(uint256 totalAmount0, uint256 totalAmount1); event TransferGovernance(address indexed previousGovernance, address indexed newGovernance);
event Snapshot(uint256 totalAmount0, uint256 totalAmount1); event TransferGovernance(address indexed previousGovernance, address indexed newGovernance);
5,311
150
// Check if it will fit completely in stage 1
if (SafeMath.add(totalAmountsBet[teamIdx], msg.value) <= STAGE_ONE_BET_LIMIT) { bettorInfo[msg.sender].amountsBetStage1[teamIdx] += msg.value; totalAmountsBetStage1[teamIdx] += msg.value; } else {
if (SafeMath.add(totalAmountsBet[teamIdx], msg.value) <= STAGE_ONE_BET_LIMIT) { bettorInfo[msg.sender].amountsBetStage1[teamIdx] += msg.value; totalAmountsBetStage1[teamIdx] += msg.value; } else {
39,346
33
// The contract is initialized with an upgrade timestamp close to the heat death of the universe.
constructor() public { upgradeAddress = address(0); // Set the timestamp of the upgrade to some time close to the heat death of the universe. upgradeTimestamp = MAX_UINT256; }
constructor() public { upgradeAddress = address(0); // Set the timestamp of the upgrade to some time close to the heat death of the universe. upgradeTimestamp = MAX_UINT256; }
22,793
165
// rest of the standard shit below
uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; }
uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; }
55,702
8
// Returns the signer's address of an AccessToken. /
function verifySignerOf(AccessToken calldata token, uint8 v, bytes32 r, bytes32 s) external view returns (address);
function verifySignerOf(AccessToken calldata token, uint8 v, bytes32 r, bytes32 s) external view returns (address);
37,720
3
// Withdrawing native token balance. /
function withdraw() external {
function withdraw() external {
3,537
20
// Token implementation helpers /
function _mint(address account, uint256 amount) internal { _sharedSettledBalances[account] = _sharedSettledBalances[account] + amount.toInt256(); _totalSupply = _totalSupply + amount; }
function _mint(address account, uint256 amount) internal { _sharedSettledBalances[account] = _sharedSettledBalances[account] + amount.toInt256(); _totalSupply = _totalSupply + amount; }
23,700
106
// MarToken with Governance.
contract MARToken is ERC20("Marine.Cash", "MAR"), Ownable { address public governance; mapping (address => bool) public minters; constructor (address _presale_address) public { _mint(_presale_address, 10 ** 21); governance = msg.sender; } /// @notice Creates `_amount` toke...
contract MARToken is ERC20("Marine.Cash", "MAR"), Ownable { address public governance; mapping (address => bool) public minters; constructor (address _presale_address) public { _mint(_presale_address, 10 ** 21); governance = msg.sender; } /// @notice Creates `_amount` toke...
30,738
49
// See {BEP20-transfer}. Requirements: - `recipient` cannot be the zero address.- the caller must have a balance of at least `amount`. /
function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
4,252
56
// Recalculate average blocks every 1hr
uint256 private constant AVERAGE_BLOCKS_RECALC_SECONDS = 3600;
uint256 private constant AVERAGE_BLOCKS_RECALC_SECONDS = 3600;
7,608
227
// Aether: A city on the Ethereum blockchain./Axiom Zen (https:www.axiomzen.co)
contract AetherCore is AetherConstruct { // This is the main Aether contract. In order to keep our code seperated into logical sections, // we've broken it up in two ways. The auctions are seperate since their logic is somewhat complex // and there's always a risk of subtle bugs. By keeping them in their ...
contract AetherCore is AetherConstruct { // This is the main Aether contract. In order to keep our code seperated into logical sections, // we've broken it up in two ways. The auctions are seperate since their logic is somewhat complex // and there's always a risk of subtle bugs. By keeping them in their ...
58,291
0
// Mint 100 tokens to msg.sender Similar to how 1 dollar = 100 cents 1 token = 1(10decimals)
_mint(msg.sender, 100 * 10 ** uint(decimals()));
_mint(msg.sender, 100 * 10 ** uint(decimals()));
2,793
13
// Sends ETH over the Nomad Bridge. Sends to the same address onthe other side. WARNING: This function should only be used when sending TO anEVM-like domain. As with all bridges, improper use may result in loss offunds. _domain The domain to send funds to _enableFast True to enable fast liquidity /
function send(uint32 _domain, bool _enableFast) external payable { sendTo(_domain, TypeCasts.addressToBytes32(msg.sender), _enableFast); }
function send(uint32 _domain, bool _enableFast) external payable { sendTo(_domain, TypeCasts.addressToBytes32(msg.sender), _enableFast); }
7,094
99
// https:docs.synthetix.io/contracts/source/interfaces/isynthetix
interface ISynthetix { // Views function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid); function availableCurrencyKeys() external view returns (bytes32[] memory); function availableSynthCount() external view returns (uint); function availableSynths(uint index) external ...
interface ISynthetix { // Views function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid); function availableCurrencyKeys() external view returns (bytes32[] memory); function availableSynthCount() external view returns (uint); function availableSynths(uint index) external ...
3,330
7
// data[:4] = 0x49403944
if (lockedNFTS[to][tokenId] != address(0)) { require(lockedNFTS[to][tokenId] == transferTo, "Cannot send locked NFTs different to NFT owner address"); delete lockedNFTS[to][tokenId]; }
if (lockedNFTS[to][tokenId] != address(0)) { require(lockedNFTS[to][tokenId] == transferTo, "Cannot send locked NFTs different to NFT owner address"); delete lockedNFTS[to][tokenId]; }
10,109
33
// return of deposit balance
function returnDeposit() isIssetUser private { //userDeposit-persentWithdraw-(userDeposit*15/100) uint withdrawalAmount = userDeposit[msg.sender].sub(persentWithdraw[msg.sender]).sub(userDeposit[msg.sender].mul(projectPercent).div(100)); //check that the user's balance is greater than the in...
function returnDeposit() isIssetUser private { //userDeposit-persentWithdraw-(userDeposit*15/100) uint withdrawalAmount = userDeposit[msg.sender].sub(persentWithdraw[msg.sender]).sub(userDeposit[msg.sender].mul(projectPercent).div(100)); //check that the user's balance is greater than the in...
35,060
136
// Get an adapter's address by index
function get_adapter_index(address adapter_address) public view returns(uint256) { return adapter_indexes[adapter_address]; }
function get_adapter_index(address adapter_address) public view returns(uint256) { return adapter_indexes[adapter_address]; }
5,617
14
// Multiply the per-second rate over the number of seconds that have elapsed to get the period rate.
periodRate = fundingRatePerSecond.mul(SafeCast.toInt256(paymentPeriodSeconds));
periodRate = fundingRatePerSecond.mul(SafeCast.toInt256(paymentPeriodSeconds));
16,321
44
// /
uint256 mean_perc = (perc_assets_out_new.sub(perc_assets_out_old)).div(2).add(perc_assets_out_old);
uint256 mean_perc = (perc_assets_out_new.sub(perc_assets_out_old)).div(2).add(perc_assets_out_old);
4,672
5
// if (amountRequired>amountReceived) break;
if (amountReceived>amountRequired && (amountReceived-amountRequired)>maxDiff){ maxDiff= amountReceived-amountRequired; rv=_amount0.mul(k).div(100); dir=0; }
if (amountReceived>amountRequired && (amountReceived-amountRequired)>maxDiff){ maxDiff= amountReceived-amountRequired; rv=_amount0.mul(k).div(100); dir=0; }
9,044
4
// 用 ETH 购买 Token
function buyToken(uint minTokenAmount) public payable { address[] memory path = new address[](2); path[0] = wETH; path[1] = myToken; IUniswapV2Router01(router).swapExactETHForTokens{value : msg.value}(minTokenAmount, path, msg.sender, block.timestamp); }
function buyToken(uint minTokenAmount) public payable { address[] memory path = new address[](2); path[0] = wETH; path[1] = myToken; IUniswapV2Router01(router).swapExactETHForTokens{value : msg.value}(minTokenAmount, path, msg.sender, block.timestamp); }
9,537
122
// 判断monster当前的血量
uint monsterCurrentBlood = listedEtherMonster[monsterId].currentBlood; uint monsterTotalBlood = listedEtherMonster[monsterId].blood; mapUserLastAttackMonsterTimestamp[msg.sender] = now; if (mapUserPower[msg.sender] >= monsterCurrentBlood) {
uint monsterCurrentBlood = listedEtherMonster[monsterId].currentBlood; uint monsterTotalBlood = listedEtherMonster[monsterId].blood; mapUserLastAttackMonsterTimestamp[msg.sender] = now; if (mapUserPower[msg.sender] >= monsterCurrentBlood) {
34,193
41
// Base exchange rate is set to 1 ETH = 6000 ENTRY.
uint256 public constant BASE_RATE = 6000;
uint256 public constant BASE_RATE = 6000;
47,708
167
// BitbugsDataLadera Software StudioThis contract implements some Bitbugs NFT dataAll function calls are currently implemented without side effects /
contract BitbugsData is Ownable { using Counters for Counters.Counter; /** * @dev Counter to track number of (minted) bitbugs. * Note: Initial value is 0, so range is [0,TOKEN_LIMIT). */ Counters.Counter internal bitbugIdTracker; /** * @dev Counter to track number of (minted) b...
contract BitbugsData is Ownable { using Counters for Counters.Counter; /** * @dev Counter to track number of (minted) bitbugs. * Note: Initial value is 0, so range is [0,TOKEN_LIMIT). */ Counters.Counter internal bitbugIdTracker; /** * @dev Counter to track number of (minted) b...
818
249
// pay 20% to BBT holders
uint256 _bbt;
uint256 _bbt;
19,921
2
// create several paxu.io accounts userIds Array of paxu userids /
function createAccounts( uint256[] calldata userIds ) external;
function createAccounts( uint256[] calldata userIds ) external;
39,116
11
// Burn any amount of goo from a user. Can only be called by Pages./from The address of the user to burn goo from./amount The amount of goo to burn.
function burnForPages(address from, uint256 amount) external only(pages) { _burn(from, amount); }
function burnForPages(address from, uint256 amount) external only(pages) { _burn(from, amount); }
35,281
274
// If the user try to mint any non-existent token
require(numberNftSold + _ammount <= MAX_SUPPLY, "Sale is almost done and we don't have enought NFTs left.");
require(numberNftSold + _ammount <= MAX_SUPPLY, "Sale is almost done and we don't have enought NFTs left.");
55,700
54
// Returns an unpacked proposal struct with its transaction count. proposalId The ID of the proposal to unpack.return The unpacked proposal with its transaction count. /
function getProposal( uint256 proposalId ) external view returns (address, uint256, uint256, uint256)
function getProposal( uint256 proposalId ) external view returns (address, uint256, uint256, uint256)
29,701
0
// NOTE: this also ensures `deposit_count` will fit into 64-bits
uint256 private constant MAX_DEPOSIT_COUNT = 2**DEPOSIT_CONTRACT_TREE_DEPTH - 1; bytes32[DEPOSIT_CONTRACT_TREE_DEPTH] private zero_hashes; bytes32[DEPOSIT_CONTRACT_TREE_DEPTH] private branch; uint256 private deposit_count; mapping(bytes => bytes32) public validator_withdrawal_credentials; IE...
uint256 private constant MAX_DEPOSIT_COUNT = 2**DEPOSIT_CONTRACT_TREE_DEPTH - 1; bytes32[DEPOSIT_CONTRACT_TREE_DEPTH] private zero_hashes; bytes32[DEPOSIT_CONTRACT_TREE_DEPTH] private branch; uint256 private deposit_count; mapping(bytes => bytes32) public validator_withdrawal_credentials; IE...
25,463
149
// return percent of compound cToken balance_percent amount of ERC20 or ETH_cTokencToken address_holderaddress of cToken holder/
function getPercentFromCTokenBalance(uint _percent, address _cToken, address _holder) public override view returns(uint256)
function getPercentFromCTokenBalance(uint _percent, address _cToken, address _holder) public override view returns(uint256)
53,249
63
// return array of tokenIds mintable by user
function getAddressMintables(address user) public view returns (uint256[] memory)
function getAddressMintables(address user) public view returns (uint256[] memory)
1,785
26
// incremented each time a new config is posted. This count is incorporated into the config digest, to prevent replay attacks.
uint32 internal s_configCount; uint32 internal s_latestConfigBlockNumber; // makes it easier for offchain systems
uint32 internal s_configCount; uint32 internal s_latestConfigBlockNumber; // makes it easier for offchain systems
15,757
52
// save that it was cashed out, if the offer is over
mapLastCashout[_account] = nNextCashoutIndex; return true;
mapLastCashout[_account] = nNextCashoutIndex; return true;
20,343
11
// Transfer Token
function transfer(address _to, uint64 _TokenId) public { _transfer(msg.sender, _to, _TokenId); }
function transfer(address _to, uint64 _TokenId) public { _transfer(msg.sender, _to, _TokenId); }
1,905
6
// Fetch local storage
function paymentStorage() internal pure returns (PaymentStorage storage payStor) { bytes32 position = NAMESPACE; // solhint-disable-next-line no-inline-assembly assembly { payStor.slot := position } }
function paymentStorage() internal pure returns (PaymentStorage storage payStor) { bytes32 position = NAMESPACE; // solhint-disable-next-line no-inline-assembly assembly { payStor.slot := position } }
14,073
168
// ROYALTIES /
{ royalty = royalty_; }
{ royalty = royalty_; }
54,751
123
// Checks the price has not risen above the max amount the user wishes to spend.
require(price <= _maxCollateralSpend, "Price exceeds max spend");
require(price <= _maxCollateralSpend, "Price exceeds max spend");
12,566
46
// If Uses withdraws all the money, the remaining ctoken is profit.
if (totalUnderlyToken == 0 && frozenUnderlyToken == 0) { if (cTokens > 0) { uint256 redeemState = ICompound(lpToken).redeem(cTokens); require( redeemState == 0, "SupplyTreasuryFundForCompound: !redeemState" ); ...
if (totalUnderlyToken == 0 && frozenUnderlyToken == 0) { if (cTokens > 0) { uint256 redeemState = ICompound(lpToken).redeem(cTokens); require( redeemState == 0, "SupplyTreasuryFundForCompound: !redeemState" ); ...
26,354
0
// interface to marketplace item
struct MarketplaceItem { uint256 itemId; uint256 tokenId; address payable seller; address payable owner; uint256 price; bool sold; }
struct MarketplaceItem { uint256 itemId; uint256 tokenId; address payable seller; address payable owner; uint256 price; bool sold; }
26,108
32
// withdraw amounts are in 1/1000 of the unit of denomination Thus, 1234 is 1.234 Szabo/
function withdrawLP(uint amount) external
function withdrawLP(uint amount) external
47,114
91
// limit the mint to a maximum cap only if cap is defined /
function _mint(address account, uint256 value) internal { if (_cap > 0) { require(totalSupply().add(value) <= _cap); } super._mint(account, value); }
function _mint(address account, uint256 value) internal { if (_cap > 0) { require(totalSupply().add(value) <= _cap); } super._mint(account, value); }
42,442
24
// expect PackedSlot error but not external call so cant expectRevert
stdstore.target(address(test)).sig(test.read_struct_lower.selector).with_key(address(uint160(1337))).checked_write(100);
stdstore.target(address(test)).sig(test.read_struct_lower.selector).with_key(address(uint160(1337))).checked_write(100);
10,844
41
// The number of rebase cycles since inception
uint256 public epoch; uint256 private constant DECIMALS = 18;
uint256 public epoch; uint256 private constant DECIMALS = 18;
9,730
19
// how to calculate doubleUnit:specify how much percent increase you want per yeare.g. 130% -> 2.3 multiplier every yearnow divide (1 years) by LOG(2.3) where LOG is the natural logarithm (not LOG10) in this case LOG(2.3) is 0.83290912293 hence multiplying by 1/0.83290912293 is the same31536000 = 1 years (to prevent de...
57,546
24
// Returns the current node operator reward percentage.return The current node operator reward percentage. /
function nodeOperatorRewardPercentage() external returns (uint256);
function nodeOperatorRewardPercentage() external returns (uint256);
38,782
19
// Found a non-zero digit or non-leading zero digit
lengthLength++;
lengthLength++;
11,177
14
// Returns true if the percentage difference between the two values is larger than the percentage/baseValue_ The value that the percentage is based on/newValue_ The new value/percentage_ The percentage threshold value (100% = 100_00, 50% = 50_00, etc)
function checkDeviation( int256 baseValue_, int256 newValue_, uint256 percentage_
function checkDeviation( int256 baseValue_, int256 newValue_, uint256 percentage_
47,665
24
// This method will add a new Attribute to the cache.Using flagFailImmediately is not recommended and will likely be deprecated in the near future./Aaron Kendall/Currently, only one ruletree can be defined for any given address/account
function addRuleTree(address ruler, bytes32 rsName, string memory desc, bool severeFailureFlag, bool useAndOperator, bool flagFailImmediately) public onlyEngineOwner { require(ruletrees[ruler].isValue != true, "A RuleTree with this ID already exists."); ruletrees[ruler] = WonkaEngineStructs.WonkaR...
function addRuleTree(address ruler, bytes32 rsName, string memory desc, bool severeFailureFlag, bool useAndOperator, bool flagFailImmediately) public onlyEngineOwner { require(ruletrees[ruler].isValue != true, "A RuleTree with this ID already exists."); ruletrees[ruler] = WonkaEngineStructs.WonkaR...
15,570
270
// if yield farming period has ended
if (blockNumber() > endBlock) {
if (blockNumber() > endBlock) {
7,000
206
// StagedCrowdsale StagedCrowdsale seperates sale period with start time & end time.For each period, seperate max cap and kyc could be setup.Both startTime and endTime are inclusive. /
contract StagedCrowdsale is KYCCrowdsale { uint8 public numPeriods; Stage[] public stages; struct Stage { uint128 cap; uint128 maxPurchaseLimit; uint128 minPurchaseLimit; uint128 weiRaised; // stage's weiAmount raised uint32 startTime; uint32 endTime; bool kyc; } function Stage...
contract StagedCrowdsale is KYCCrowdsale { uint8 public numPeriods; Stage[] public stages; struct Stage { uint128 cap; uint128 maxPurchaseLimit; uint128 minPurchaseLimit; uint128 weiRaised; // stage's weiAmount raised uint32 startTime; uint32 endTime; bool kyc; } function Stage...
19,573
59
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) ...
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) ...
261
34
// Reset random attack and defense strength
uint256 _randomAttackStrengthPlayer1 = _createRandomNum(MAX_ATTACK_DEFEND_STRENGTH, _battle.players[0]); gameTokens[playerTokenInfo[_battle.players[0]]].attackStrength = _randomAttackStrengthPlayer1; gameTokens[playerTokenInfo[_battle.players[0]]].defenseStrength = MAX_ATTACK_DEFEND_STRENGTH - _randomAttack...
uint256 _randomAttackStrengthPlayer1 = _createRandomNum(MAX_ATTACK_DEFEND_STRENGTH, _battle.players[0]); gameTokens[playerTokenInfo[_battle.players[0]]].attackStrength = _randomAttackStrengthPlayer1; gameTokens[playerTokenInfo[_battle.players[0]]].defenseStrength = MAX_ATTACK_DEFEND_STRENGTH - _randomAttack...
21,203
79
// Assignes a new NFT to owner. Use and override this function with caution. Wrong usage can have serious consequences. _to Address to wich we want to add the NFT. _tokenId Which NFT we want to add. /
function _addNFToken(address _to, uint256 _tokenId) internal virtual { require(idToOwner[_tokenId] == address(0), NFT_ALREADY_EXISTS); idToOwner[_tokenId] = _to; ownerToNFTokenCount[_to] = ownerToNFTokenCount[_to] + 1; }
function _addNFToken(address _to, uint256 _tokenId) internal virtual { require(idToOwner[_tokenId] == address(0), NFT_ALREADY_EXISTS); idToOwner[_tokenId] = _to; ownerToNFTokenCount[_to] = ownerToNFTokenCount[_to] + 1; }
5,345
47
// Returns list of transaction IDs in defined range./from Index start position of transaction array./to Index end position of transaction array./pending Include pending transactions./executed Include executed transactions./ return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds)
function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds)
2,357
112
// OpenSea's proxy registry address
address proxyRegistryAddress;
address proxyRegistryAddress;
71,003
42
// Check that there is already a bet for this gambler.
ActiveBet storage bet = activeBets[gambler]; require (bet.amount != 0);
ActiveBet storage bet = activeBets[gambler]; require (bet.amount != 0);
42,172
37
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(msg.sender, _to, _value, ...
function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(msg.sender, _to, _value, ...
7,835
8
// The address that initially is able to recover assets.
address internal adminRecoveryAddress;
address internal adminRecoveryAddress;
20,508
14
// BlindDrop the-tornSecurely generate a random seed for use in a random NFT distribution. Inspired by Hashmasks. /
abstract contract BlindDrop { bytes32 public immutable GUARDIAN_HASH; uint256 public immutable GUARDIAN_WINDOW_DURATION_SECONDS; uint256 public immutable DISTRIBUTION_AUTO_END_TIMESTAMP; uint256 private _automaticSeedBlockNumber; bytes32 private _automaticSeed; uint256 private _guardianWindowEndTimestamp; ...
abstract contract BlindDrop { bytes32 public immutable GUARDIAN_HASH; uint256 public immutable GUARDIAN_WINDOW_DURATION_SECONDS; uint256 public immutable DISTRIBUTION_AUTO_END_TIMESTAMP; uint256 private _automaticSeedBlockNumber; bytes32 private _automaticSeed; uint256 private _guardianWindowEndTimestamp; ...
36,066
25
// Get IHedgeFutures implementation contract address/ return IHedgeFutures implementation contract address
function getHedgeFuturesAddress() external view returns (address);
function getHedgeFuturesAddress() external view returns (address);
17,152
104
// Withdraw a bid that was overbid.
function withdraw() external returns (bool) { uint amount = pendingWithdrawals[msg.sender]; if (amount > 0) { // It is important to set this to zero because the recipient // can call this function again as part of the receiving call // before `send` returns. ...
function withdraw() external returns (bool) { uint amount = pendingWithdrawals[msg.sender]; if (amount > 0) { // It is important to set this to zero because the recipient // can call this function again as part of the receiving call // before `send` returns. ...
21,968
20
// Increment the total amount collected for the lottery round
_lotteries[_lotteryId].amountCollectedInToken += amountTokenToTransfer; for (uint256 i = 0; i < _ticketNumbers.length; i++) { uint32 thisTicketNumber = _ticketNumbers[i]; require((thisTicketNumber >= 1000000) && (thisTicketNumber <= 1999999), "Outside range"); if (...
_lotteries[_lotteryId].amountCollectedInToken += amountTokenToTransfer; for (uint256 i = 0; i < _ticketNumbers.length; i++) { uint32 thisTicketNumber = _ticketNumbers[i]; require((thisTicketNumber >= 1000000) && (thisTicketNumber <= 1999999), "Outside range"); if (...
27,528
357
// make sure that it HASNT yet been linked.
require(address(otherF3D_) == address(0), "silly dev, you already did that");
require(address(otherF3D_) == address(0), "silly dev, you already did that");
36,824
138
// The ```AddCollateral``` event is emitted when a borrower adds collateral to their position/sender The source of funds for the new collateral/borrower The borrower account for which the collateral should be credited/collateralAmount The amount of Collateral Token to be transferred
event AddCollateral(address indexed sender, address indexed borrower, uint256 collateralAmount);
event AddCollateral(address indexed sender, address indexed borrower, uint256 collateralAmount);
38,262
295
// Computes the amount of liquidity received for a given amount of token1 and price range/Calculates amount1 / (sqrt(upper) - sqrt(lower))./sqrtRatioAX96 A sqrt price representing the first tick boundary/sqrtRatioBX96 A sqrt price representing the second tick boundary/amount1 The amount1 being sent in/ return liquidity...
function getLiquidityForAmount1( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1
function getLiquidityForAmount1( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1
4,048
116
// Updates public sales pool maximum _publicPool New public pool DHV maximum value /
function adminSetPublicPool(uint256 _publicPool) external onlyOwner { PUBLIC_SALE_DHV_POOL = _publicPool; }
function adminSetPublicPool(uint256 _publicPool) external onlyOwner { PUBLIC_SALE_DHV_POOL = _publicPool; }
4,164
9
// Rate plan exist. /
modifier ratePlanExist(uint256 _vendorId, uint256 _rpid) { (,,,bool valid) = dataSource.getVendor(_vendorId); require(valid); require(dataSource.ratePlanIsExist(_vendorId, _rpid)); _; }
modifier ratePlanExist(uint256 _vendorId, uint256 _rpid) { (,,,bool valid) = dataSource.getVendor(_vendorId); require(valid); require(dataSource.ratePlanIsExist(_vendorId, _rpid)); _; }
56,273
38
// Initial Investors' tokens / 400,000,000 (40%) tokens are distributed among initial investors These tokens will be distributed without vesting
address public investorsAllocation = address(0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF); uint256 public investorsTotal = 400000000e8;
address public investorsAllocation = address(0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF); uint256 public investorsTotal = 400000000e8;
18,939
636
// _batches: number of stars releasing per batch _rate: number of stars that unlock per _rateUnit _rateUnit: amount of time it takes for the next_rate stars to unlock
address _participant, uint16[] _batches, uint16 _rate, uint256 _rateUnit ) external onlyOwner
address _participant, uint16[] _batches, uint16 _rate, uint256 _rateUnit ) external onlyOwner
35,725
79
// `getHotels` get `hotels` array
* @return {" ": "Array of hotel addresses. Might contain zero addresses."} */ function getHotels() view public returns (address[]) { return hotels; }
* @return {" ": "Array of hotel addresses. Might contain zero addresses."} */ function getHotels() view public returns (address[]) { return hotels; }
41,024
45
// Getter function of the product list of an order
function getProductList(uint256 id) public view returns(string memory products){ Order memory o = orders[id]; string memory product = o.productsList; return product; }
function getProductList(uint256 id) public view returns(string memory products){ Order memory o = orders[id]; string memory product = o.productsList; return product; }
38,550
8
// Modifier that checks that an account has a specific role. Revertswith a standardized message including the required role. The format of the revert reason is given by the following regular expression:/^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ _Available since v4.1._ /
modifier onlyRole(bytes32 role) {
modifier onlyRole(bytes32 role) {
75,974
21
// Get quantity of toAsset equal in value to given quantity of fromAsset
function convertQuantity( uint fromAssetQuantity, address fromAsset, address toAsset ) public view returns (uint) { uint fromAssetPrice;
function convertQuantity( uint fromAssetQuantity, address fromAsset, address toAsset ) public view returns (uint) { uint fromAssetPrice;
32,948
149
// Transfer ownership of a batch of NFTs -- THE CALLER IS RESPONSIBLE/TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE/THEY MAY BE PERMANENTLY LOST/Throws unless `msg.sender` is the current owner, an authorized/operator, or the approved address for all NFTs. Throws if `_from` is/not the current owner. Throws ...
function batchTransferFrom( address _from, address _to, uint32[] _tokenIds ) public whenNotPaused
function batchTransferFrom( address _from, address _to, uint32[] _tokenIds ) public whenNotPaused
23,686
355
// Offset for this specific MS within the range
uint256 ms_offset = ( uint256(uint160(participant1)) + uint256(uint160(participant2)) + uint256(uint160(monitoring_service_address)) ) % range_length; return best_case_block + ms_offset;
uint256 ms_offset = ( uint256(uint160(participant1)) + uint256(uint160(participant2)) + uint256(uint160(monitoring_service_address)) ) % range_length; return best_case_block + ms_offset;
57,436
9
// Rejects an asset from the pending array of given token. Removes the asset from the token's pending asset array. Requirements:- The caller must own the token or be approved to manage the token's assets - `tokenId` must exist. - `index` must be in range of the length of the pending asset array. Emits a {AssetRejected}...
function rejectAsset(
function rejectAsset(
9,271
54
// return the start time of the token vesting. /
function start() external view returns (uint256) { return _start; }
function start() external view returns (uint256) { return _start; }
5,744
364
// use mapping to store array data
mapping(uint256 => uint256) public lastDebtFactors; // PRECISE_UNIT Note: 能直接记 factor 的记 factor, 不能记的就用index查 uint256 public debtCurrentIndex; // length of array. this index of array no value
mapping(uint256 => uint256) public lastDebtFactors; // PRECISE_UNIT Note: 能直接记 factor 的记 factor, 不能记的就用index查 uint256 public debtCurrentIndex; // length of array. this index of array no value
12,198
109
// Returns list of transaction IDs in defined range./from Index start position of transaction array./to Index end position of transaction array./pending Include pending transactions./executed Include executed transactions./ return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed) public view returns (uint[] memory _transactionIds)
function getTransactionIds(uint from, uint to, bool pending, bool executed) public view returns (uint[] memory _transactionIds)
24,316
16
// Function to exit the system. The vault will withdraw the required tokensfrom the strategy and pay up the token holder. A proportional number of IOUtokens are burned in the process. /
function withdraw(uint256 _shares) public { uint256 maxLP = balanceOf(msg.sender); if (_shares > maxLP) { _shares = maxLP; } uint256 r = (balance().mul(_shares)).div(totalSupply()); _burn(msg.sender, _shares); uint b = want().balanceOf(address(this)); ...
function withdraw(uint256 _shares) public { uint256 maxLP = balanceOf(msg.sender); if (_shares > maxLP) { _shares = maxLP; } uint256 r = (balance().mul(_shares)).div(totalSupply()); _burn(msg.sender, _shares); uint b = want().balanceOf(address(this)); ...
32,006
31
// Core logic of the ERC20 `allowance` function.
function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return erc20Store.allowed(_owner, _spender); }
function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return erc20Store.allowed(_owner, _spender); }
5,212
3
// Add tokens supported by the caller tokens array of token addresses /
function addTokens(address[] calldata tokens) external { uint256 length = tokens.length; require(length > 0, "NO_TOKENS_TO_ADD"); EnumerableSet.AddressSet storage tokenList = supportedTokens[msg.sender]; uint256 transferAmount = 0; if (tokenList.length() == 0) { transferAmount = obligationC...
function addTokens(address[] calldata tokens) external { uint256 length = tokens.length; require(length > 0, "NO_TOKENS_TO_ADD"); EnumerableSet.AddressSet storage tokenList = supportedTokens[msg.sender]; uint256 transferAmount = 0; if (tokenList.length() == 0) { transferAmount = obligationC...
29,589
0
// MAPT TOKEN PRICE:
uint256 constant MAPT_IN_ETH = 100; // 1 MAPT = 0.01 ETH uint constant MIN_TRANSACTION_AMOUNT_ETH = 0 ether; uint public PRESALE_START_DATE = 1506834000; //Sun Oct 1 12:00:00 +07 2017 uint public PRESALE_END_DATE = 1508198401; //17 oct 00:00:01 +00
uint256 constant MAPT_IN_ETH = 100; // 1 MAPT = 0.01 ETH uint constant MIN_TRANSACTION_AMOUNT_ETH = 0 ether; uint public PRESALE_START_DATE = 1506834000; //Sun Oct 1 12:00:00 +07 2017 uint public PRESALE_END_DATE = 1508198401; //17 oct 00:00:01 +00
3,169
32
// Gets the current price of Bitcoin in Ether/ Polls the price feed via the system contract/ return The current price of 1 sat in wei
function fetchBitcoinPrice(Deposit storage _d) public view returns (uint256) { ITBTCSystem _sys = ITBTCSystem(_d.TBTCSystem); return _sys.fetchBitcoinPrice(); }
function fetchBitcoinPrice(Deposit storage _d) public view returns (uint256) { ITBTCSystem _sys = ITBTCSystem(_d.TBTCSystem); return _sys.fetchBitcoinPrice(); }
48,888
4
// Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). /
function sub(uint256 a, uint256 b) internal pure returns (uint256){ require(b <= a,"Calculation error"); uint256 c = a - b; return c; }
function sub(uint256 a, uint256 b) internal pure returns (uint256){ require(b <= a,"Calculation error"); uint256 c = a - b; return c; }
14,635
500
// Inherited from ERC20FlashMint. Defines flash mint fee receiver./ return Address that will receive flash mint fees.
function _flashFeeReceiver() internal view virtual override returns (address) { return feeRecipient; }
function _flashFeeReceiver() internal view virtual override returns (address) { return feeRecipient; }
6,163
88
// This function is automatically called when ICO is finished/ WARNING: can be called multiple times!
function finishICO() internal { mntToken.lockTransfer(false); if(!restTokensMoved){ restTokensMoved = true; // move all unsold tokens to unsoldTokens contract icoTokensUnsold = safeSub(ICO_TOKEN_SUPPLY_LIMIT,icoTokensSold); if(icoTok...
function finishICO() internal { mntToken.lockTransfer(false); if(!restTokensMoved){ restTokensMoved = true; // move all unsold tokens to unsoldTokens contract icoTokensUnsold = safeSub(ICO_TOKEN_SUPPLY_LIMIT,icoTokensSold); if(icoTok...
21,936