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
177
// revert if allowance limited and smaller than used
uint256 used = members[member.account].used; if (used > member.allowance) { revert UsedBiggerThanAllowance(member.account, used, member.allowance); }
uint256 used = members[member.account].used; if (used > member.allowance) { revert UsedBiggerThanAllowance(member.account, used, member.allowance); }
13,715
1
// Tell the forwarder type return Always 1 (ForwarderType.NO_CONTEXT)/
function forwarderType() override external pure returns (ForwarderType) { return ForwarderType.NO_CONTEXT; }
function forwarderType() override external pure returns (ForwarderType) { return ForwarderType.NO_CONTEXT; }
15,098
7
// Methods ///
function setTokenId( string memory tokenId_
function setTokenId( string memory tokenId_
3,530
169
// ERC1363 approveAndCall
function approveAndCall(address spender, uint256 value) public override returns (bool) { return approveAndCall(spender, value, ""); }
function approveAndCall(address spender, uint256 value) public override returns (bool) { return approveAndCall(spender, value, ""); }
28,761
107
// Mint everything which belongs to `msg.sender` across multiple gauges gauges List of `LiquidityGauge` addresses /
function mintMany(address[] calldata gauges) external returns (uint256);
function mintMany(address[] calldata gauges) external returns (uint256);
41,447
2
// Returns the amount of tokens owned by `account`. /
function balanceOf(address account) external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
13,727
59
// IMPLEMENTATION: setLimits
function _setLimits(uint128 _minBorrowedAmount, uint128 _maxBorrowedAmount) internal {
function _setLimits(uint128 _minBorrowedAmount, uint128 _maxBorrowedAmount) internal {
28,805
32
// Variable to represnt the block that this card can expire.
uint MaxBlock;
uint MaxBlock;
33,536
4
// Rewards
mapping(address => uint256) private rewardPerTokenSum; mapping(address => uint256) private pendingReward; mapping(address => mapping(address => uint256)) private previousReward; mapping(address => mapping(address => uint256)) private claimableReward;
mapping(address => uint256) private rewardPerTokenSum; mapping(address => uint256) private pendingReward; mapping(address => mapping(address => uint256)) private previousReward; mapping(address => mapping(address => uint256)) private claimableReward;
6,918
125
// Hour
dt.hour = getHour(timestamp);
dt.hour = getHour(timestamp);
40,263
51
// This is safe from underflow - users won't ever have a balance larger than `totalSupply`.
unchecked { totalSupply -= amount; }
unchecked { totalSupply -= amount; }
30,986
213
// reverse-for-loops with unsigned integer/ solium-disable-next-line security/no-modify-for-iter-var / find the last non-zero byte in order to determine the length
if (result[i] != 0) { uint256 length = i + 1;
if (result[i] != 0) { uint256 length = i + 1;
2,375
1,058
// For the same reason described above, when the last user is repaying it might happen that user rateuser balance > avg ratetotal supply. In that case, we simply set the avg rate to 0
if (secondTerm >= firstTerm) { newAvgStableRate = _avgStableRate = _totalSupply = 0; } else {
if (secondTerm >= firstTerm) { newAvgStableRate = _avgStableRate = _totalSupply = 0; } else {
15,463
14
// Adds extra collateral to the position of the borrower. offerId the id of the offer. /
function addCollateral(uint256 offerId) external payable nonReentrant() { require(offers[offerId].borrower == msg.sender, "Only borrower can add collateral"); require(keccak256(abi.encodePacked(offers[offerId].status)) == keccak256(abi.encodePacked("On")), "Offer is not On"); offers[offerId].collateral = offers[offerId].collateral + msg.value; }
function addCollateral(uint256 offerId) external payable nonReentrant() { require(offers[offerId].borrower == msg.sender, "Only borrower can add collateral"); require(keccak256(abi.encodePacked(offers[offerId].status)) == keccak256(abi.encodePacked("On")), "Offer is not On"); offers[offerId].collateral = offers[offerId].collateral + msg.value; }
50,490
50
// Calculate the base reward expressed in system coins
uint256 newBaseReward = divide(multiply(baseRewardFiatValue, RAY), oracleRelayer.redemptionPrice()); newBaseReward = divide(multiply(newBaseReward, targetReceiver.baseRewardMultiplier), HUNDRED);
uint256 newBaseReward = divide(multiply(baseRewardFiatValue, RAY), oracleRelayer.redemptionPrice()); newBaseReward = divide(multiply(newBaseReward, targetReceiver.baseRewardMultiplier), HUNDRED);
2,033
173
// Transfer from recipient to this contract Emits a transfer event if successful
function _pull(address sender, uint256 amount) internal { _move(sender, address(this), amount); }
function _pull(address sender, uint256 amount) internal { _move(sender, address(this), amount); }
14,107
12
// --------------------------------------------------------------------------------------------------------------- (3b) load up the destination jump address for actual purging (4), jump or raise `invalid` op-code--------------------------------------------------------------------------------------------------------------- 0x60|0x60_43| PUSH1 67 (^) | jumpDestination (0xFF00...00 == calldata) 0x57|0x57 | JUMPI| 0xFE|0xFE | INVALID|--------------------------------------------------------------------------------------------------------------- (4 bytes: 63-66 in deployed contract)
hex"60_43_57_FE",
hex"60_43_57_FE",
4,304
65
// Base Standard token class wich is basicalle burnable ERC20 token with custom decimals Useful when you need to deploy a token with a custom decimals value instead of the default 18. /
abstract contract AbstractStandardToken is ERC20 { uint8 immutable private _decimals; /** * @dev Initializes {decimals} with * a custom value * * All three of these values are immutable: they can only be set once during * construction. */ constructor (uint8 decimals_) { _decimals = decimals_; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return _decimals; } }
abstract contract AbstractStandardToken is ERC20 { uint8 immutable private _decimals; /** * @dev Initializes {decimals} with * a custom value * * All three of these values are immutable: they can only be set once during * construction. */ constructor (uint8 decimals_) { _decimals = decimals_; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return _decimals; } }
6,118
111
// Represents rewards and fees to be distributed to delegators
struct Data { uint256 rewardPool; // Rewards in the pool uint256 feePool; // Fees in the pool uint256 totalStake; // Transcoder's total stake during the pool's round uint256 claimableStake; // Stake that can be used to claim portions of the fee and reward pool uint256 transcoderRewardCut; // Reward cut for the reward pool uint256 transcoderFeeShare; // Fee share for the fee pool }
struct Data { uint256 rewardPool; // Rewards in the pool uint256 feePool; // Fees in the pool uint256 totalStake; // Transcoder's total stake during the pool's round uint256 claimableStake; // Stake that can be used to claim portions of the fee and reward pool uint256 transcoderRewardCut; // Reward cut for the reward pool uint256 transcoderFeeShare; // Fee share for the fee pool }
45,747
187
// ========== DATA TYPES ========== / UIntStorage;
function getUIntValue(bytes32 record) external view returns (uint) { return UIntStorage[record]; }
function getUIntValue(bytes32 record) external view returns (uint) { return UIntStorage[record]; }
20,636
11
// Constructor
constructor() public { // 01.01.2019 00:00 UTC crowdsaleStartsAt = 1546300800; // 01.05.2019 00:00 UTC crowdsaleEndsAt = 1556668800; //Amount of raised Funds in wei weiRaised = 0; //Wallet for raised crowdsale funds crowdsaleWallet = 0xedaFdA45fedcCE4D2b81e173F1D2F21557E97aA5; //VANM token address tokenAddress = 0x0d155aaa5C94086bCe0Ad0167EE4D55185F02943; token = VANMToken(tokenAddress); }
constructor() public { // 01.01.2019 00:00 UTC crowdsaleStartsAt = 1546300800; // 01.05.2019 00:00 UTC crowdsaleEndsAt = 1556668800; //Amount of raised Funds in wei weiRaised = 0; //Wallet for raised crowdsale funds crowdsaleWallet = 0xedaFdA45fedcCE4D2b81e173F1D2F21557E97aA5; //VANM token address tokenAddress = 0x0d155aaa5C94086bCe0Ad0167EE4D55185F02943; token = VANMToken(tokenAddress); }
25,294
210
// Mints a token to an address with a tokenURI. fee may or may not be required_to address of the future owner of the token_amount number of tokens to mint/
function mintToMultiple(address _to, uint256 _amount) public payable { require(_amount >= 1, "Must mint at least 1 token"); require(_amount <= maxBatchSize, "Cannot mint more than max mint per transaction"); require(mintingOpen == true && onlyAllowlistMode == false, "Public minting is not open right now!"); require(canMintAmount(_to, _amount), "Wallet address is over the maximum allowed mints"); require(currentTokenId() + _amount <= collectionSize, "Cannot mint over supply cap of 777"); require(msg.value == getPrice(_amount), "Value below required mint fee for amount"); _safeMint(_to, _amount); updateMintCount(_to, _amount); }
function mintToMultiple(address _to, uint256 _amount) public payable { require(_amount >= 1, "Must mint at least 1 token"); require(_amount <= maxBatchSize, "Cannot mint more than max mint per transaction"); require(mintingOpen == true && onlyAllowlistMode == false, "Public minting is not open right now!"); require(canMintAmount(_to, _amount), "Wallet address is over the maximum allowed mints"); require(currentTokenId() + _amount <= collectionSize, "Cannot mint over supply cap of 777"); require(msg.value == getPrice(_amount), "Value below required mint fee for amount"); _safeMint(_to, _amount); updateMintCount(_to, _amount); }
33,348
9
// Only exit for msg.sender
function exit(address adapterAddr) external payable whenAdapterIsValid(adapterAddr) returns (uint256 withdrawAmount, uint256 rewardsAmount)
function exit(address adapterAddr) external payable whenAdapterIsValid(adapterAddr) returns (uint256 withdrawAmount, uint256 rewardsAmount)
51,237
48
// query the available amount of LINK to withdraw by msg.sender /
function withdrawable() external view returns (uint256);
function withdrawable() external view returns (uint256);
24,973
204
// Checks if an address is either the owner, or the approved alternate signer. /
function _checkValidSigner(address signer) internal view { require(signer == owner() || signer == alternateSignerAddress, "Not valid signer."); }
function _checkValidSigner(address signer) internal view { require(signer == owner() || signer == alternateSignerAddress, "Not valid signer."); }
8,577
529
// Constructs the FundingRateApplier contract. Called by child contracts. _fundingRateIdentifier identifier that tracks the funding rate of this contract. _collateralAddress address of the collateral token. _finderAddress Finder used to discover financial-product-related contracts. _configStoreAddress address of the remote configuration store managed by an external owner. _tokenScaling initial scaling to apply to the token value (i.e. scales the tracking index). _timerAddress address of the timer contract in test envs, otherwise 0x0. /
constructor( bytes32 _fundingRateIdentifier, address _collateralAddress, address _finderAddress, address _configStoreAddress, FixedPoint.Unsigned memory _tokenScaling, address _timerAddress
constructor( bytes32 _fundingRateIdentifier, address _collateralAddress, address _finderAddress, address _configStoreAddress, FixedPoint.Unsigned memory _tokenScaling, address _timerAddress
17,383
22
// Create a mask with the highest `_len` bits set. _lenThe lengthreturnmask - The mask /
function leftMask(uint8 _len) private pure returns (uint256 mask) { // ugly. redo without assembly? assembly { // solium-disable-previous-line security/no-inline-assembly mask := sar( sub(_len, 1), 0x8000000000000000000000000000000000000000000000000000000000000000 ) } }
function leftMask(uint8 _len) private pure returns (uint256 mask) { // ugly. redo without assembly? assembly { // solium-disable-previous-line security/no-inline-assembly mask := sar( sub(_len, 1), 0x8000000000000000000000000000000000000000000000000000000000000000 ) } }
46,623
13
// Describes Distribution destination and its share of all incoming funds.
struct Distribution {
struct Distribution {
457
1
// 0x6086e7f8 ===bytes4(keccak256('activityStopped(uint256)')) /
function activityStopped(uint256 _tokenId) public;
function activityStopped(uint256 _tokenId) public;
38,120
106
// contract creator gets 90% of the token to create LP-Pair
uint256 deployerBalance=_circulatingSupply; _balances[msg.sender] = deployerBalance; emit Transfer(address(0), msg.sender, deployerBalance);
uint256 deployerBalance=_circulatingSupply; _balances[msg.sender] = deployerBalance; emit Transfer(address(0), msg.sender, deployerBalance);
27,778
23
// Once we have the funds, transfer back to owner
uint256 balance = dai.balanceOf(address(this)); dai.transfer(msg.sender, balance); emit Withdraw(msg.sender, amountDeposited, locationOfFunds);
uint256 balance = dai.balanceOf(address(this)); dai.transfer(msg.sender, balance); emit Withdraw(msg.sender, amountDeposited, locationOfFunds);
18,733
49
// Pop the buyer from the array without preserving order (we don't care about that)
buyers.pop(); IERC20(tokenAddress).transfer(buyer, tokens); emit TokensAirdropped(buyer, tokens);
buyers.pop(); IERC20(tokenAddress).transfer(buyer, tokens); emit TokensAirdropped(buyer, tokens);
25,766
4
// Thrown if this operation would cause an incorrect change in Well reserves. /
error InvalidReserves();
error InvalidReserves();
29,787
54
// the module that set the last lock
address locker;
address locker;
43,684
203
// main supply, locked for 4 months (TimeVested contract) 56 mln
address public mainSupply;
address public mainSupply;
29,889
43
// elopment kept original RFI naming -> "reward" as in reflection
function excludeFromReward(address account) public onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); }
function excludeFromReward(address account) public onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); }
15,445
44
// can only support tokens with decimals() API
setDecimals(contracts.token); kncPerEthBaseRatePrecision = contracts.feeBurner.kncPerEthRatePrecision();
setDecimals(contracts.token); kncPerEthBaseRatePrecision = contracts.feeBurner.kncPerEthRatePrecision();
16,750
24
// add new facet address if it does not exist
if (selectorPosition == 0) { enforceHasContractCode(_facetAddress, "LibDiamondCut: New facet has no code"); ds.facetFunctionSelectors[_facetAddress].facetAddressPosition = uint16(ds.facetAddresses.length); ds.facetAddresses.push(_facetAddress); }
if (selectorPosition == 0) { enforceHasContractCode(_facetAddress, "LibDiamondCut: New facet has no code"); ds.facetFunctionSelectors[_facetAddress].facetAddressPosition = uint16(ds.facetAddresses.length); ds.facetAddresses.push(_facetAddress); }
22,585
4
// Returns a single market
function CallTest( uint16 currencyId ) external view returns (MarketParameters memory)
function CallTest( uint16 currencyId ) external view returns (MarketParameters memory)
33,090
13
// transfer token for a specified address with froze status checking _toMulti The addresses to transfer to. _values The array of the amount to be transferred. /
// function transferMultiAddress(address[] _toMulti, uint256[] _values) public whenNotPaused returns (bool) { // require(!frozenAccount[msg.sender]); // assert(_toMulti.length == _values.length); // uint256 i = 0; // while (i < _toMulti.length) { // require(_toMulti[i] != address(0)); // require(_values[i] <= balances[msg.sender]); // // SafeMath.sub will throw if there is not enough balance. // balances[msg.sender] = balances[msg.sender].sub(_values[i]); // balances[_toMulti[i]] = balances[_toMulti[i]].add(_values[i]); // Transfer(msg.sender, _toMulti[i], _values[i]); // i = i.add(1); // } // return true; // }
// function transferMultiAddress(address[] _toMulti, uint256[] _values) public whenNotPaused returns (bool) { // require(!frozenAccount[msg.sender]); // assert(_toMulti.length == _values.length); // uint256 i = 0; // while (i < _toMulti.length) { // require(_toMulti[i] != address(0)); // require(_values[i] <= balances[msg.sender]); // // SafeMath.sub will throw if there is not enough balance. // balances[msg.sender] = balances[msg.sender].sub(_values[i]); // balances[_toMulti[i]] = balances[_toMulti[i]].add(_values[i]); // Transfer(msg.sender, _toMulti[i], _values[i]); // i = i.add(1); // } // return true; // }
40,343
1
// range: [0, 2144 - 1] resolution: 1 / 2112
struct uq144x112 { uint _x; }
struct uq144x112 { uint _x; }
5,472
42
// This is safe as we're incrementing a timestamp.
nextWeek = firstIncompleteWeek + 1 weeks; if (block.timestamp < nextWeek) {
nextWeek = firstIncompleteWeek + 1 weeks; if (block.timestamp < nextWeek) {
25,876
24
// send the ether back to the sender
(bool sent, ) = msg.sender.call{value: amount}("");
(bool sent, ) = msg.sender.call{value: amount}("");
28,124
130
// Removes tokens from this Strategy that are not the type of tokens managed by this Strategy. This may be used in case of accidentally sending the wrong kind of token to this Strategy.Tokens will be sent to `governance()`.This will fail if an attempt is made to sweep `want`, or any tokens that are protected by this Strategy.This may only be called by governance. Implement `protectedTokens()` to specify any additional tokens that should be protected from sweeping in addition to `want`. _token The token to transfer out of this vault. /
function sweep(address _token) external onlyGovernance { require(_token != address(want), "!want"); require(_token != address(vault), "!shares"); address[] memory _protectedTokens = protectedTokens(); for (uint256 i; i < _protectedTokens.length; i++) require(_token != _protectedTokens[i], "!protected"); IERC20(_token).safeTransfer(governance(), IERC20(_token).balanceOf(address(this))); }
function sweep(address _token) external onlyGovernance { require(_token != address(want), "!want"); require(_token != address(vault), "!shares"); address[] memory _protectedTokens = protectedTokens(); for (uint256 i; i < _protectedTokens.length; i++) require(_token != _protectedTokens[i], "!protected"); IERC20(_token).safeTransfer(governance(), IERC20(_token).balanceOf(address(this))); }
32,477
207
// whitelist check
function isWhitelisted(address _user) public view returns (bool) { for (uint i = 0; i < whitelistedAddresses.length; i++) { if (whitelistedAddresses[i] == _user) { return true; } } return false; }
function isWhitelisted(address _user) public view returns (bool) { for (uint i = 0; i < whitelistedAddresses.length; i++) { if (whitelistedAddresses[i] == _user) { return true; } } return false; }
9,915
380
// Sets `_tokenURI` as the tokenURI of `tokenId`.
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual
5,078
40
// worth 5x Eth then the price for OMG would be 510e18 or Exp({mantissa: 5000000000000000000}). map: assetAddress -> Exp/
mapping(address => Exp) public _assetPrices; constructor( ) public {
mapping(address => Exp) public _assetPrices; constructor( ) public {
34,145
3
// Maps an address to how much they can withdraw.
mapping (address => uint256) public creatorsBobbaMoney;
mapping (address => uint256) public creatorsBobbaMoney;
880
10
// Dividends
uint8 maxDividendDenominations; mapping(bytes32 => bytes32[]) dividendDenominations; // object => tokenId of the dividend it allows mapping(bytes32 => mapping(bytes32 => uint8)) dividendDenominationIndex; // entity ID => (token ID => index of dividend denomination) mapping(bytes32 => mapping(uint8 => bytes32)) dividendDenominationAtIndex; // entity ID => (index of dividend denomination => token id) mapping(bytes32 => mapping(bytes32 => uint256)) totalDividends; // token ID => (denomination ID => total dividend) mapping(bytes32 => mapping(bytes32 => mapping(bytes32 => uint256))) withdrawnDividendPerOwner; // entity => (tokenId => (owner => total withdrawn dividend)) NOT per share!!! this is TOTAL
uint8 maxDividendDenominations; mapping(bytes32 => bytes32[]) dividendDenominations; // object => tokenId of the dividend it allows mapping(bytes32 => mapping(bytes32 => uint8)) dividendDenominationIndex; // entity ID => (token ID => index of dividend denomination) mapping(bytes32 => mapping(uint8 => bytes32)) dividendDenominationAtIndex; // entity ID => (index of dividend denomination => token id) mapping(bytes32 => mapping(bytes32 => uint256)) totalDividends; // token ID => (denomination ID => total dividend) mapping(bytes32 => mapping(bytes32 => mapping(bytes32 => uint256))) withdrawnDividendPerOwner; // entity => (tokenId => (owner => total withdrawn dividend)) NOT per share!!! this is TOTAL
36,950
8
// supposed to be called once while initializing. one of the contractsa that inherits this contract follows proxy pattern so it is not possible to do this in a constructor
function _initializeEIP712( string memory name ) internal initializer
function _initializeEIP712( string memory name ) internal initializer
2,854
129
// id => creator
mapping (uint256 => address) public creators;
mapping (uint256 => address) public creators;
16,637
4
// Based on: https:github.com/Synthetixio/Unipool/tree/master/contracts/changelog:Added SPDX-License-IdentifierUpdate to solidity ^0.8.0Update openzeppelin importsIRewardDistributionRecipient integrated in Unipool and removedAdded virtual and override to stake and withdraw methodsAdded constructors to LPTokenWrapper and UnipoolChange transfer to allocate (TokenVesting)Added `stakeWithPermit` function for NODE and the BridgeToken /
contract LPTokenWrapper is Initializable { using SafeMathUpgradeable for uint256; uint256 private _totalStaked; mapping(address => uint256) private _balances; function __LPTokenWrapper_initialize() public initializer {} function _totalSupply() internal view returns (uint256) { return _totalStaked; } function _balanceOf(address account) internal view returns (uint256) { return _balances[account]; } function stake(address user, uint256 amount) internal virtual { _totalStaked = _totalStaked.add(amount); _balances[user] = _balances[user].add(amount); } function withdraw(address user, uint256 amount) internal virtual { _totalStaked = _totalStaked.sub(amount); _balances[user] = _balances[user].sub(amount); } }
contract LPTokenWrapper is Initializable { using SafeMathUpgradeable for uint256; uint256 private _totalStaked; mapping(address => uint256) private _balances; function __LPTokenWrapper_initialize() public initializer {} function _totalSupply() internal view returns (uint256) { return _totalStaked; } function _balanceOf(address account) internal view returns (uint256) { return _balances[account]; } function stake(address user, uint256 amount) internal virtual { _totalStaked = _totalStaked.add(amount); _balances[user] = _balances[user].add(amount); } function withdraw(address user, uint256 amount) internal virtual { _totalStaked = _totalStaked.sub(amount); _balances[user] = _balances[user].sub(amount); } }
17,591
96
// Returns the `account` data of `seasonNumber` season. /
function accountInSeason(address account, uint16 seasonNumber) public view returns (uint256 vokenIssued, uint256 vokenBonus, uint256 vokenReferral, uint256 vokenReferrals, uint256 weiPurchased, uint256 weiReferrals, uint256 weiRewarded, uint256 usdPurchased, uint256 usdReferrals,
function accountInSeason(address account, uint16 seasonNumber) public view returns (uint256 vokenIssued, uint256 vokenBonus, uint256 vokenReferral, uint256 vokenReferrals, uint256 weiPurchased, uint256 weiReferrals, uint256 weiRewarded, uint256 usdPurchased, uint256 usdReferrals,
46,768
15
// Allows users to enter bids for any Cryptopunk /
function enterBidForPunk(uint punkIndex) payable public whenNotPaused nonReentrant() { require(punkIndex < 10000,"Token index not valid"); require (punksWrapperContract.ownerOf(punkIndex) != msg.sender,"You already own this punk"); require (msg.value > 0,"Cannot enter bid of zero"); Bid memory existing = punkBids[punkIndex]; require (msg.value > existing.value,"your bid is too low"); if (existing.value > 0) { // Refund the failing bid _withdraw(existing.bidder,existing.value); } punkBids[punkIndex] = Bid(true, punkIndex, msg.sender, msg.value); emit PunkBidEntered(punkIndex, msg.value, msg.sender); }
function enterBidForPunk(uint punkIndex) payable public whenNotPaused nonReentrant() { require(punkIndex < 10000,"Token index not valid"); require (punksWrapperContract.ownerOf(punkIndex) != msg.sender,"You already own this punk"); require (msg.value > 0,"Cannot enter bid of zero"); Bid memory existing = punkBids[punkIndex]; require (msg.value > existing.value,"your bid is too low"); if (existing.value > 0) { // Refund the failing bid _withdraw(existing.bidder,existing.value); } punkBids[punkIndex] = Bid(true, punkIndex, msg.sender, msg.value); emit PunkBidEntered(punkIndex, msg.value, msg.sender); }
3,763
20
// 取得精準度
function decimals() public onlyOwner view override returns (uint8) { return decimals_; }
function decimals() public onlyOwner view override returns (uint8) { return decimals_; }
24,174
43
// This is necessary because the automatically generated nftList/ getter will not include an array of comments in the returned tuple for/ gas reasons:/ https:docs.soliditylang.org/en/latest/contracts.htmlvisibility-and-getters
function getComments(uint256 tokenId) public view virtual returns (string[] memory, address[] memory)
function getComments(uint256 tokenId) public view virtual returns (string[] memory, address[] memory)
12,124
31
// import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { AddressArrayUtils } from "../lib/AddressArrayUtils.sol";
using AddressArrayUtils for address[];
using AddressArrayUtils for address[];
8,867
14
// get the balance of the offer
uint256 nBalance = balanceOf(aSender);
uint256 nBalance = balanceOf(aSender);
1,684
3
// Set the epoch length. Set epoch length to `_epochLength` blocks _epochLength Epoch length in blocks /
function setEpochLength(uint256 _epochLength) external override onlyGovernor { require(_epochLength > 0, "Epoch length cannot be 0"); require(_epochLength != epochLength, "Epoch length must be different to current"); lastLengthUpdateEpoch = currentEpoch(); lastLengthUpdateBlock = currentEpochBlock(); epochLength = _epochLength; emit EpochLengthUpdate(lastLengthUpdateEpoch, epochLength); }
function setEpochLength(uint256 _epochLength) external override onlyGovernor { require(_epochLength > 0, "Epoch length cannot be 0"); require(_epochLength != epochLength, "Epoch length must be different to current"); lastLengthUpdateEpoch = currentEpoch(); lastLengthUpdateBlock = currentEpochBlock(); epochLength = _epochLength; emit EpochLengthUpdate(lastLengthUpdateEpoch, epochLength); }
32,376
250
// concatenated symbol string: LP ETH 04DEC2020 C
return string( abi.encodePacked( "LP ", underlying, " ", _uintTo2Chars(day), monthSymbol, Strings.toString(year), " ",
return string( abi.encodePacked( "LP ", underlying, " ", _uintTo2Chars(day), monthSymbol, Strings.toString(year), " ",
2,095
271
// 竞拍购买
function buyBids(uint8 _level, uint8 _type, uint256 _price) public payable returns (bool) { require(_level >= 2 && _level <= 5, "Error: invalid level"); require(_type >= 1 && _level <= 12, "Error: invalid animal"); require(_price > buyOrder[_level][_type].price, "Error: price is too low"); require(msg.value == _price, "Error: invalid value"); payable(buyOrder[_level][_type].buyer).transfer(buyOrder[_level][_type].price); buyOrder[_level][_type] = Buyer(msg.sender, _price); return true; }
function buyBids(uint8 _level, uint8 _type, uint256 _price) public payable returns (bool) { require(_level >= 2 && _level <= 5, "Error: invalid level"); require(_type >= 1 && _level <= 12, "Error: invalid animal"); require(_price > buyOrder[_level][_type].price, "Error: price is too low"); require(msg.value == _price, "Error: invalid value"); payable(buyOrder[_level][_type].buyer).transfer(buyOrder[_level][_type].price); buyOrder[_level][_type] = Buyer(msg.sender, _price); return true; }
17,076
46
// Register the addresses that you want to allow to be receive._whiteAddresses address[] The specify what to receive target./
function addAllowReceivers(address[] memory _whiteAddresses) public onlyOwner { for (uint256 i = 0; i < _whiteAddresses.length; i++) { addAllowReceiver(_whiteAddresses[i]); } }
function addAllowReceivers(address[] memory _whiteAddresses) public onlyOwner { for (uint256 i = 0; i < _whiteAddresses.length; i++) { addAllowReceiver(_whiteAddresses[i]); } }
1,637
29
// first 32 bytes, after the length prefix
r := mload(add(sig, 32))
r := mload(add(sig, 32))
25,528
782
// Initiates a flashloan used to repay partially or fully the debt position of msg.sender _amount: Pass -1 to fully close debt position, otherwise Amount to be repaid with a flashloan _vault: The vault address where the debt position exist. _flashnum: integer identifier of flashloan provider /
function flashClose( int256 _amount, address _vault, uint8 _flashnum
function flashClose( int256 _amount, address _vault, uint8 _flashnum
39,682
176
// --> We continue only if in "currentStage" or later stages
uint256 maxCommittableEth = committableEthAtStage(stageId, currentStage); uint256 newlyCommittableEth = byStage.pendingETH; uint256 returnEth = 0; uint256 overflowEth = 0;
uint256 maxCommittableEth = committableEthAtStage(stageId, currentStage); uint256 newlyCommittableEth = byStage.pendingETH; uint256 returnEth = 0; uint256 overflowEth = 0;
8,762
183
// 本回合死亡队伍数
uint256 _dead = 0;
uint256 _dead = 0;
7,973
9
// allows owner to create new credentialing orgs_shortName shortName of Credentialing orgs_officialSchoolName official School Name_schoolAddress address of credential org. return createStatus bool noting creation status success or failure/
function createCredentialOrg(string _shortName, string _officialSchoolName, address _schoolAddress) public onlyOwner whenNotPaused returns (bool createStatus)
function createCredentialOrg(string _shortName, string _officialSchoolName, address _schoolAddress) public onlyOwner whenNotPaused returns (bool createStatus)
18,763
18
// Total fee needed for full contract execution
uint256 public totalFee;
uint256 public totalFee;
43,566
90
// IRelayRecipient.isTrustedForwarder implementation
function versionRecipient() external override pure returns (string memory)
function versionRecipient() external override pure returns (string memory)
26,131
130
// Returns the total supply of DYDX token at a specific block number. blockNumber Blocknumber at which to fetch DYDX token supply.return Total DYDX token supply at block number. /
function _getTotalSupplyAt(uint256 blockNumber) internal view returns (uint256) { IDydxToken dydxToken = IDydxToken(DYDX_TOKEN); uint256 snapshotsCount = dydxToken._totalSupplySnapshotsCount(); // Iterate in reverse over the total supply snapshots, up to index 1. for (uint256 i = snapshotsCount - 1; i != 0; i--) { GovernancePowerDelegationERC20Mixin.Snapshot memory snapshot = dydxToken._totalSupplySnapshots(i); if (snapshot.blockNumber <= blockNumber) { return snapshot.value; } } // If blockNumber was on or after the first snapshot, then return the initial supply. // Else, blockNumber is before token launch so return 0. GovernancePowerDelegationERC20Mixin.Snapshot memory firstSnapshot = dydxToken._totalSupplySnapshots(0); if (firstSnapshot.blockNumber <= blockNumber) { return firstSnapshot.value; } else { return 0; } }
function _getTotalSupplyAt(uint256 blockNumber) internal view returns (uint256) { IDydxToken dydxToken = IDydxToken(DYDX_TOKEN); uint256 snapshotsCount = dydxToken._totalSupplySnapshotsCount(); // Iterate in reverse over the total supply snapshots, up to index 1. for (uint256 i = snapshotsCount - 1; i != 0; i--) { GovernancePowerDelegationERC20Mixin.Snapshot memory snapshot = dydxToken._totalSupplySnapshots(i); if (snapshot.blockNumber <= blockNumber) { return snapshot.value; } } // If blockNumber was on or after the first snapshot, then return the initial supply. // Else, blockNumber is before token launch so return 0. GovernancePowerDelegationERC20Mixin.Snapshot memory firstSnapshot = dydxToken._totalSupplySnapshots(0); if (firstSnapshot.blockNumber <= blockNumber) { return firstSnapshot.value; } else { return 0; } }
57,790
42
// Check if the user has not already purchased a hero
require( warriors[user].myHero == 0, "You got hero already!" );
require( warriors[user].myHero == 0, "You got hero already!" );
27,874
297
// Returns the address of the current super admin /
function superAdmin() public view returns (address) { return _superAdmin; }
function superAdmin() public view returns (address) { return _superAdmin; }
23,150
2
// Info of each MCV2 pool./ `allocPoint` The amount of allocation points assigned to the pool./ Also known as the amount of REWARD_TOKEN to distribute per block.
struct PoolInfo { uint256 accRewardTokenPerShare; uint256 lastRewardTime; uint256 allocPoint; }
struct PoolInfo { uint256 accRewardTokenPerShare; uint256 lastRewardTime; uint256 allocPoint; }
33,653
15
// Checks whether output with a given outputId is finalized outputId Output ID to check /
function isOutputFinalized(bytes32 outputId) external view returns (bool) { return outputsFinalizations[outputId] != 0; }
function isOutputFinalized(bytes32 outputId) external view returns (bool) { return outputsFinalizations[outputId] != 0; }
28,587
103
// 当前ETH余额。
uint256 initialBalance = address(recipient).balance;//兑换前ETH余额
uint256 initialBalance = address(recipient).balance;//兑换前ETH余额
15,060
77
// save for distribution HBR
tokenDeposited[investor] = tokenDeposited[investor].add(weiAmount);
tokenDeposited[investor] = tokenDeposited[investor].add(weiAmount);
29,486
63
// Total tokens created
uint256 public constant TOKENS_TOTAL_SUPPLY = 150000000 ether;
uint256 public constant TOKENS_TOTAL_SUPPLY = 150000000 ether;
17,407
40
// Method: Validate if record can be updated to requested state @access public@type method uint8 _record_iduint8 _new_state return bool /
function isFundingStageUpdateAllowed(uint8 _new_state ) public view returns (bool) { var (CurrentRecordState, RecordStateRequired, EntityStateRequired) = getRequiredStateChanges(); CurrentRecordState = 0; EntityStateRequired = 0; if(_new_state == uint8(RecordStateRequired)) { return true; } return false; }
function isFundingStageUpdateAllowed(uint8 _new_state ) public view returns (bool) { var (CurrentRecordState, RecordStateRequired, EntityStateRequired) = getRequiredStateChanges(); CurrentRecordState = 0; EntityStateRequired = 0; if(_new_state == uint8(RecordStateRequired)) { return true; } return false; }
12,386
43
// Delegate notifier method /
function notifyGameEnded() internal { BattleRoyaleArena arena = BattleRoyaleArena(payable(delegate)); arena.gameDidEnd(address(this)); }
function notifyGameEnded() internal { BattleRoyaleArena arena = BattleRoyaleArena(payable(delegate)); arena.gameDidEnd(address(this)); }
20,325
32
// Returns the amount of tokens approved by the owner that can betransferred to the spender&39;s account tokenOwner The address of the owner of the token spender The address of the spender of the tokenreturn Number of tokens that are approved for spending from the tokenOwner /
function allowance(address tokenOwner, address spender) public constant returns (uint256 remaining) { requireTrade(tokenOwner); return allowed[tokenOwner][spender]; }
function allowance(address tokenOwner, address spender) public constant returns (uint256 remaining) { requireTrade(tokenOwner); return allowed[tokenOwner][spender]; }
34,646
432
// Transfers ownership of the contract to a new account (`newOwner`).Can only be called by the current owner. /
function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); }
function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); }
56
100
// Allows admin to add a new asset for price tracking /
function addAsset(address assetAddress, address priceFeedContract)
function addAsset(address assetAddress, address priceFeedContract)
12,075
45
// The only wallet allowed for Company supply
address public companyWallet;
address public companyWallet;
26,980
145
// rate governs how often you receive your token
uint256 public rate;
uint256 public rate;
30,793
265
// Collateral token address cannot be zero.
error CollateralTokenAddressCannotBeZero();
error CollateralTokenAddressCannotBeZero();
6,096
0
// States
mapping(string => address) public subdomains; mapping(string => bool) public subdomainsPresent;
mapping(string => address) public subdomains; mapping(string => bool) public subdomainsPresent;
7,932
8
// As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules
setupModules(to, data); if (payment > 0) {
setupModules(to, data); if (payment > 0) {
58,049
39
// NFT methods for admin to manage by this contract URL
function erc721Approve( address _ERC721Address, address _to, uint256 _tokenId
function erc721Approve( address _ERC721Address, address _to, uint256 _tokenId
43,328
1,864
// Publishes price for a requested query. Will revert if request hasn't been requested yet or has beenresolved already. /
function _publishPrice( uint8 chainID, bytes32 identifier, uint256 time, bytes memory ancillaryData, int256 price
function _publishPrice( uint8 chainID, bytes32 identifier, uint256 time, bytes memory ancillaryData, int256 price
44,453
67
// sellCliffFee = _cliffFee;
sellTotalFees = sellTreasuryFee + sellLiquidityFee /*+ sellCliffFee*/; require(sellTotalFees <= 25, "Must keep fees at 25% or less");
sellTotalFees = sellTreasuryFee + sellLiquidityFee /*+ sellCliffFee*/; require(sellTotalFees <= 25, "Must keep fees at 25% or less");
39,904
101
// Lets a contract admin set auction buffers.
function setAuctionBuffers(uint256 _timeBuffer, uint256 _bidBufferBps) external onlyRole(DEFAULT_ADMIN_ROLE) { require(_bidBufferBps < MAX_BPS, "invalid BPS."); timeBuffer = uint64(_timeBuffer); bidBufferBps = uint64(_bidBufferBps); emit AuctionBuffersUpdated(_timeBuffer, _bidBufferBps); }
function setAuctionBuffers(uint256 _timeBuffer, uint256 _bidBufferBps) external onlyRole(DEFAULT_ADMIN_ROLE) { require(_bidBufferBps < MAX_BPS, "invalid BPS."); timeBuffer = uint64(_timeBuffer); bidBufferBps = uint64(_bidBufferBps); emit AuctionBuffersUpdated(_timeBuffer, _bidBufferBps); }
57,092
30
// Update the quorum by adding the voteWeight
disp.disputeUintVars[keccak256("quorum")] += voteWeight;
disp.disputeUintVars[keccak256("quorum")] += voteWeight;
49,785
15
// Keep a track of the number of tokens per address
mapping(address => uint) nftsPerWallet;
mapping(address => uint) nftsPerWallet;
8,936
1
// Create a new instance with required parameters/_rocketJoeFactory Address of the RocketJoeFactory
constructor(address _rocketJoeFactory) { rocketJoeFactory = IRocketJoeFactory(_rocketJoeFactory); }
constructor(address _rocketJoeFactory) { rocketJoeFactory = IRocketJoeFactory(_rocketJoeFactory); }
1,603
935
// Fetches a resolved Oracle price from the Oracle. Reverts if the Oracle hasn't resolved for this request.
function _getOraclePriceExpiration(uint256 requestedTime) internal returns (FixedPoint.Unsigned memory) { // Create an instance of the oracle and get the price. If the price is not resolved revert. OptimisticOracleInterface optimisticOracle = _getOptimisticOracle(); require( optimisticOracle.hasPrice( address(this), _transformPriceIdentifier(requestedTime), requestedTime, _getAncillaryData() ) ); int256 optimisticOraclePrice = optimisticOracle.settleAndGetPrice( _transformPriceIdentifier(requestedTime), requestedTime, _getAncillaryData() ); // For now we don't want to deal with negative prices in positions. if (optimisticOraclePrice < 0) { optimisticOraclePrice = 0; } return _transformPrice(FixedPoint.Unsigned(uint256(optimisticOraclePrice)), requestedTime); }
function _getOraclePriceExpiration(uint256 requestedTime) internal returns (FixedPoint.Unsigned memory) { // Create an instance of the oracle and get the price. If the price is not resolved revert. OptimisticOracleInterface optimisticOracle = _getOptimisticOracle(); require( optimisticOracle.hasPrice( address(this), _transformPriceIdentifier(requestedTime), requestedTime, _getAncillaryData() ) ); int256 optimisticOraclePrice = optimisticOracle.settleAndGetPrice( _transformPriceIdentifier(requestedTime), requestedTime, _getAncillaryData() ); // For now we don't want to deal with negative prices in positions. if (optimisticOraclePrice < 0) { optimisticOraclePrice = 0; } return _transformPrice(FixedPoint.Unsigned(uint256(optimisticOraclePrice)), requestedTime); }
10,235
47
// uint public created_time = now;
uint rate = 1000; uint PresaleStart = 0; uint CrowdsaleStart = 0; uint PresalePeriod = 1 days; uint CrowdsalePeriod = 1 days; uint public threshold = 1000000000000000;
uint rate = 1000; uint PresaleStart = 0; uint CrowdsaleStart = 0; uint PresalePeriod = 1 days; uint CrowdsalePeriod = 1 days; uint public threshold = 1000000000000000;
59,589
56
// Player has won a two white pyramid prize!
profit = SafeMath.mul(spin.tokenValue, 2); category = 19; emit TwoWhitePyramids(target, spin.blockn);
profit = SafeMath.mul(spin.tokenValue, 2); category = 19; emit TwoWhitePyramids(target, spin.blockn);
51,320
149
// Enable whitelist
_whitelistEnabled = true;
_whitelistEnabled = true;
38,830
37
// Returns whether the target address is a contract This function will return false if invoked during the constructor of a contract,as the code is not actually created until after the constructor finishes. _addr address to checkreturn whether the target address is a contract /
function isContract(address _addr) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solium-disable-next-line security/no-inline-assembly assembly { size := extcodesize(_addr) } return size > 0; }
function isContract(address _addr) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solium-disable-next-line security/no-inline-assembly assembly { size := extcodesize(_addr) } return size > 0; }
25,873
3
// Who ever creates the pool becomes the first beneficiary of the pool and the first to accrue interest./
function joinNewPool(uint256 principal) external returns(bool) { if (initialized == true) { return false; } beneficiary = operator = address(msg.sender); minPoolPrincipal = principal; token.approve(address(rDAI), minPoolPrincipal * MAX_PARTICIPANTS); // Give rDAI enough allowance to cover pool size token.transferFrom(msg.sender, address(this), minPoolPrincipal); selectHat(minPoolPrincipal, false); pardners.push(beneficiary); pardnersPool[msg.sender] = Pardner(Status.ACTIVE, msg.sender, principal, 0); epochStartTime = now; uint256 poolID = 0; initialized = true; emit NewPool(beneficiary, poolID); return true; }
function joinNewPool(uint256 principal) external returns(bool) { if (initialized == true) { return false; } beneficiary = operator = address(msg.sender); minPoolPrincipal = principal; token.approve(address(rDAI), minPoolPrincipal * MAX_PARTICIPANTS); // Give rDAI enough allowance to cover pool size token.transferFrom(msg.sender, address(this), minPoolPrincipal); selectHat(minPoolPrincipal, false); pardners.push(beneficiary); pardnersPool[msg.sender] = Pardner(Status.ACTIVE, msg.sender, principal, 0); epochStartTime = now; uint256 poolID = 0; initialized = true; emit NewPool(beneficiary, poolID); return true; }
41,514