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 |
|---|---|---|---|---|
10 | // require(_to != 0x0); Prevent transfer to 0x0 address. Use burn() instead | require(_value > 0);
require(balanceOf[_from] >= _value); // Check if the sender has enough
require(balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
emit Transfer(_from, _to, _value);
return true;
| require(_value > 0);
require(balanceOf[_from] >= _value); // Check if the sender has enough
require(balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
emit Transfer(_from, _to, _value);
return true;
| 13,156 |
206 | // The transfer amount does not include any used fuel | emit Transfer(from, to, transferAmount);
| emit Transfer(from, to, transferAmount);
| 67,344 |
4 | // This is where the magic is withdrawn.For users with balances. Can only be used to withdraw full balance. | function withdraw()
checkZeroBalance()
| function withdraw()
checkZeroBalance()
| 28,125 |
47 | // not/allow contract to receive funds | function() public payable {
if (!IsPayble) revert();
}
| function() public payable {
if (!IsPayble) revert();
}
| 13,733 |
138 | // call claim with msg.sender as _for | claimFor(msg.sender, _conditionIndex);
| claimFor(msg.sender, _conditionIndex);
| 29,800 |
54 | // Compute and store the bytecode hash. | mstore8(0x00, 0xff) // Write the prefix.
mstore(0x35, hash)
mstore(0x01, shl(96, address()))
mstore(0x15, salt)
predicted := keccak256(0x00, 0x55)
| mstore8(0x00, 0xff) // Write the prefix.
mstore(0x35, hash)
mstore(0x01, shl(96, address()))
mstore(0x15, salt)
predicted := keccak256(0x00, 0x55)
| 20,452 |
5 | // Creator, betId, betId, schedule, initialPool, description | event CreatedBet(address indexed, string indexed, string, uint64, uint256, string);
| event CreatedBet(address indexed, string indexed, string, uint64, uint256, string);
| 36,810 |
160 | // Helper to transfer full contract balances of assets to the specified VaultProxy | function __transferContractAssetBalancesToFund(address _vaultProxy, address[] memory _assets)
private
| function __transferContractAssetBalancesToFund(address _vaultProxy, address[] memory _assets)
private
| 57,601 |
49 | // Compute the number of full vesting periods that have elapsed. | uint256 timeFromStart = currentTime - vestingSchedule.start;
uint256 secondsPerSlice = vestingSchedule.slicePeriodSeconds;
uint256 vestedSlicePeriods = timeFromStart / secondsPerSlice;
uint256 vestedSeconds = vestedSlicePeriods * secondsPerSlice;
| uint256 timeFromStart = currentTime - vestingSchedule.start;
uint256 secondsPerSlice = vestingSchedule.slicePeriodSeconds;
uint256 vestedSlicePeriods = timeFromStart / secondsPerSlice;
uint256 vestedSeconds = vestedSlicePeriods * secondsPerSlice;
| 9,032 |
622 | // Remember the last 32 bytes of source This needs to be done here and not after the loop because we may have overwritten the last bytes in source already due to overlap. | let last := mload(sEnd)
| let last := mload(sEnd)
| 36,015 |
52 | // Add deposit to balance of sender if enough ETH included | else { balances[msg.sender] += msg.value;
}
| else { balances[msg.sender] += msg.value;
}
| 13,358 |
38 | // Reverts if the contract is paused. | modifier whenNotPaused() {
require(!paused(), "CIP");
_;
}
| modifier whenNotPaused() {
require(!paused(), "CIP");
_;
}
| 30,939 |
34 | // return the duration of the token vesting. / | function duration() public view returns(uint256) {
return _duration;
}
| function duration() public view returns(uint256) {
return _duration;
}
| 2,376 |
15 | // This is the definition of the Tryvium ERC20 token. Alessandro Sanino (@saniales) / | contract TryviumToken is ERC20, ERC20Burnable, ERC20Capped, Ownable {
/**
* @notice The current supply of the TRYV token.
*/
uint256 private _tokenSupply;
/**
* @notice The address in which the Team reserved funds are sent.
* They correspond to the % of the supply specified in the whitepaper.
*/
TokenVault immutable public TEAM_VAULT;
/**
* @notice The address in which the Bounty reserved funds are sent.
* They correspond to the % of the supply specified in the whitepaper.
*/
BountyVault immutable public BOUNTY_VAULT;
/**
* @notice The address in which the various Token Sales reserved
* funds are sent.
* They correspond to the % of the supply specified in the whitepaper.
*/
TokenVault immutable public SALES_VAULT;
/**
* @notice The address in which the funds reserved for future
* developments are sent.
* They correspond to the % of the supply specified in the whitepaper.
*/
TokenVault immutable public RESERVED_FUNDS_VAULT;
/**
* @notice Creates a new instance of the Tryvium ERC20 Token contract and
* performs the minting of the tokens to the vaults specified in
* the whitepaper.
* @param _maxSupply The token max supply.
* @param _teamVault The address of the vault which will contain the
* tokens reserved to the Tryvium team.
* @param _bountyVault The address of the vault which will contain the
* tokens reserved to the Tryvium bounties and airdrops.
* @param _salesVault The address of the vault which will contain the
* tokens reserved to the Tryvium various token sales.
* @param _reservedFundsVault The address of the vault which will contain the
* tokens reserved to the Tryvium project future developments.
*/
constructor(
uint256 _maxSupply,
TokenVault _teamVault,
BountyVault _bountyVault,
TokenVault _salesVault,
TokenVault _reservedFundsVault
) ERC20("Tryvium Token", "TRYV") ERC20Capped(_maxSupply) {
_tokenSupply = _maxSupply;
TEAM_VAULT = _teamVault;
BOUNTY_VAULT = _bountyVault;
SALES_VAULT = _salesVault;
RESERVED_FUNDS_VAULT = _reservedFundsVault;
ERC20._mint(address(_teamVault), _maxSupply * 10 / 100);
ERC20._mint(address(_bountyVault), _maxSupply * 10 / 100);
ERC20._mint(address(_salesVault), _maxSupply * 60 / 100);
ERC20._mint(address(_reservedFundsVault), _maxSupply * 20 / 100);
}
/**
* @notice Gets the current balance of the team vault.
* @return The current balance of the team vault.
*/
function getTeamVaultBalance() external view returns (uint256) {
return this.balanceOf(address(TEAM_VAULT));
}
/**
* @notice Gets the current balance of the bounty vault.
* @return The current balance of the bounty vault.
*/
function getBountyVaultBalance() external view returns (uint256) {
return this.balanceOf(address(BOUNTY_VAULT));
}
/**
* @notice Gets the current balance of the reserved funds vault.
* @return The current balance of the reserved funds vault.
*/
function getReservedFundsVaultBalance() external view returns (uint256) {
return this.balanceOf(address(RESERVED_FUNDS_VAULT));
}
/**
* @notice Gets the current balance of the sales vault.
* @return The current balance of the sales vault.
*/
function getSalesVaultBalance() external view returns (uint256) {
return this.balanceOf(address(SALES_VAULT));
}
/** @notice Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - Cannot increase over the max supply.
*/
function _mint(address account, uint256 amount) internal override (ERC20, ERC20Capped) {
ERC20Capped._mint(account, amount);
}
/** @notice Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - Cannot increase over the max supply.
*/
function mint(address account, uint256 amount) onlyOwner external {
_mint(account, amount);
}
}
| contract TryviumToken is ERC20, ERC20Burnable, ERC20Capped, Ownable {
/**
* @notice The current supply of the TRYV token.
*/
uint256 private _tokenSupply;
/**
* @notice The address in which the Team reserved funds are sent.
* They correspond to the % of the supply specified in the whitepaper.
*/
TokenVault immutable public TEAM_VAULT;
/**
* @notice The address in which the Bounty reserved funds are sent.
* They correspond to the % of the supply specified in the whitepaper.
*/
BountyVault immutable public BOUNTY_VAULT;
/**
* @notice The address in which the various Token Sales reserved
* funds are sent.
* They correspond to the % of the supply specified in the whitepaper.
*/
TokenVault immutable public SALES_VAULT;
/**
* @notice The address in which the funds reserved for future
* developments are sent.
* They correspond to the % of the supply specified in the whitepaper.
*/
TokenVault immutable public RESERVED_FUNDS_VAULT;
/**
* @notice Creates a new instance of the Tryvium ERC20 Token contract and
* performs the minting of the tokens to the vaults specified in
* the whitepaper.
* @param _maxSupply The token max supply.
* @param _teamVault The address of the vault which will contain the
* tokens reserved to the Tryvium team.
* @param _bountyVault The address of the vault which will contain the
* tokens reserved to the Tryvium bounties and airdrops.
* @param _salesVault The address of the vault which will contain the
* tokens reserved to the Tryvium various token sales.
* @param _reservedFundsVault The address of the vault which will contain the
* tokens reserved to the Tryvium project future developments.
*/
constructor(
uint256 _maxSupply,
TokenVault _teamVault,
BountyVault _bountyVault,
TokenVault _salesVault,
TokenVault _reservedFundsVault
) ERC20("Tryvium Token", "TRYV") ERC20Capped(_maxSupply) {
_tokenSupply = _maxSupply;
TEAM_VAULT = _teamVault;
BOUNTY_VAULT = _bountyVault;
SALES_VAULT = _salesVault;
RESERVED_FUNDS_VAULT = _reservedFundsVault;
ERC20._mint(address(_teamVault), _maxSupply * 10 / 100);
ERC20._mint(address(_bountyVault), _maxSupply * 10 / 100);
ERC20._mint(address(_salesVault), _maxSupply * 60 / 100);
ERC20._mint(address(_reservedFundsVault), _maxSupply * 20 / 100);
}
/**
* @notice Gets the current balance of the team vault.
* @return The current balance of the team vault.
*/
function getTeamVaultBalance() external view returns (uint256) {
return this.balanceOf(address(TEAM_VAULT));
}
/**
* @notice Gets the current balance of the bounty vault.
* @return The current balance of the bounty vault.
*/
function getBountyVaultBalance() external view returns (uint256) {
return this.balanceOf(address(BOUNTY_VAULT));
}
/**
* @notice Gets the current balance of the reserved funds vault.
* @return The current balance of the reserved funds vault.
*/
function getReservedFundsVaultBalance() external view returns (uint256) {
return this.balanceOf(address(RESERVED_FUNDS_VAULT));
}
/**
* @notice Gets the current balance of the sales vault.
* @return The current balance of the sales vault.
*/
function getSalesVaultBalance() external view returns (uint256) {
return this.balanceOf(address(SALES_VAULT));
}
/** @notice Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - Cannot increase over the max supply.
*/
function _mint(address account, uint256 amount) internal override (ERC20, ERC20Capped) {
ERC20Capped._mint(account, amount);
}
/** @notice Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - Cannot increase over the max supply.
*/
function mint(address account, uint256 amount) onlyOwner external {
_mint(account, amount);
}
}
| 14,388 |
92 | // Token creation functions - can only be called by the tokensale controller during the tokensale period | * @param _owner {address}
* @param _amount {uint256}
* @return success {bool}
*/
function mint(address _owner, uint256 _amount) public onlyController canMint returns (bool) {
uint256 curTotalSupply = totalSupply();
uint256 previousBalanceTo = balanceOf(_owner);
require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
emit Transfer(0, _owner, _amount);
return true;
}
| * @param _owner {address}
* @param _amount {uint256}
* @return success {bool}
*/
function mint(address _owner, uint256 _amount) public onlyController canMint returns (bool) {
uint256 curTotalSupply = totalSupply();
uint256 previousBalanceTo = balanceOf(_owner);
require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
emit Transfer(0, _owner, _amount);
return true;
}
| 15,397 |
78 | // 收取手续费到项目方指定地址 | _transfer(from, commissionAddr, commission/2);
| _transfer(from, commissionAddr, commission/2);
| 24,724 |
105 | // i < tokenBalanceOwner because tokenBalanceOwner is 1-indexed | for (uint256 i = 0; i < tokenBalanceOwner; i++) {
// Further Checks, Effects, and Interactions are contained within
// the _claim() function
_claim(
basedContract.tokenOfOwnerByIndex(_msgSender(), i),
_msgSender()
);
}
| for (uint256 i = 0; i < tokenBalanceOwner; i++) {
// Further Checks, Effects, and Interactions are contained within
// the _claim() function
_claim(
basedContract.tokenOfOwnerByIndex(_msgSender(), i),
_msgSender()
);
}
| 32,000 |
9 | // if locked amount 0 return 0 | if (lockedAmount == 0){
return 0;
}
| if (lockedAmount == 0){
return 0;
}
| 431 |
80 | // Delegates votes from signatory to `delegatee` delegatee The address to delegate votes to nonce The contract state required to match the signature expiry The time at which to expire the signature v The recovery byte of the signature r Half of the ECDSA signature pair s Half of the ECDSA signature pair / | function delegateBySig(
address delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
| function delegateBySig(
address delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
| 30,710 |
38 | // Mint a random Spiral | function mintSpiralRandom() external payable nonReentrant {
entropy = keccak256(abi.encode(block.timestamp, blockhash(block.number), msg.sender, price, entropy));
_mintSpiral(entropy);
}
| function mintSpiralRandom() external payable nonReentrant {
entropy = keccak256(abi.encode(block.timestamp, blockhash(block.number), msg.sender, price, entropy));
_mintSpiral(entropy);
}
| 11,887 |
28 | // Returns the current LP tokens equivalent to 'amount' input tokens. / | function lpTokens(uint256 amount) external view returns (uint256) {
return
calculateMintAmount(
amount * 10**(18 - tokenInfo[address(inputToken)].tokenDecimals),
totalSupply(),
vaultTotalScaledValue()
);
}
| function lpTokens(uint256 amount) external view returns (uint256) {
return
calculateMintAmount(
amount * 10**(18 - tokenInfo[address(inputToken)].tokenDecimals),
totalSupply(),
vaultTotalScaledValue()
);
}
| 29,586 |
51 | // ---STORAGE METHODS--- //get subscriber dots remaining for specified provider endpoint | function getDots(
address providerAddress,
address subscriberAddress,
bytes32 endpoint
)
public
view
returns (uint64)
| function getDots(
address providerAddress,
address subscriberAddress,
bytes32 endpoint
)
public
view
returns (uint64)
| 23,435 |
6 | // total amount for Co and Founder | uint public constant TOTAL_WITHDRAWAL_AMT_PER_INTERVAL = 2340000000000000000000000;
| uint public constant TOTAL_WITHDRAWAL_AMT_PER_INTERVAL = 2340000000000000000000000;
| 24,450 |
2 | // Exclusions | mapping(address => bool) private _isExcludedFromFee;
mapping(address => bool) private _isExcludedFromMaxTx;
| mapping(address => bool) private _isExcludedFromFee;
mapping(address => bool) private _isExcludedFromMaxTx;
| 11,139 |
6 | // Creates new tokens/ return success Operation successful | function mint(uint _value) public onlyOwner returns (bool) {
totalSupply_ = totalSupply_.add(_value);
balances[owner] = balances[owner].add(_value);
emit LogMint(_value);
return true;
}
| function mint(uint _value) public onlyOwner returns (bool) {
totalSupply_ = totalSupply_.add(_value);
balances[owner] = balances[owner].add(_value);
emit LogMint(_value);
return true;
}
| 17,876 |
71 | // Contract address of the interest setter for this market | address interestSetter;
| address interestSetter;
| 17,266 |
88 | // Transfer farm to a new controller_farmAddress Contract address of farm to transfer _newController The new controller which receives the farm / | function transferFarm(address _farmAddress, address _newController)
public
onlyOwner
| function transferFarm(address _farmAddress, address _newController)
public
onlyOwner
| 21,343 |
153 | // Reset the delegation of the previous delegate | memberAddressesByDelegatedKey[
getCurrentDelegateKey(memberAddr)
] = address(0x0);
memberAddressesByDelegatedKey[newDelegateKey] = memberAddr;
_createNewDelegateCheckpoint(memberAddr, newDelegateKey);
emit UpdateDelegateKey(memberAddr, newDelegateKey);
| memberAddressesByDelegatedKey[
getCurrentDelegateKey(memberAddr)
] = address(0x0);
memberAddressesByDelegatedKey[newDelegateKey] = memberAddr;
_createNewDelegateCheckpoint(memberAddr, newDelegateKey);
emit UpdateDelegateKey(memberAddr, newDelegateKey);
| 14,434 |
112 | // get the target token amount | uint256 targetAmount = removeLiquidityTargetAmount(
liquidity.poolToken,
liquidity.reserveToken,
liquidity.poolAmount,
liquidity.reserveAmount,
packedRates,
liquidity.timestamp,
time()
);
| uint256 targetAmount = removeLiquidityTargetAmount(
liquidity.poolToken,
liquidity.reserveToken,
liquidity.poolAmount,
liquidity.reserveAmount,
packedRates,
liquidity.timestamp,
time()
);
| 45,487 |
46 | // Function to get the transfer history of EINs self is the mapping of ItemOwner to users, useful in keeping a history of transfers _transferCount is the total transfers done for a particular file/ | function getHistoralEINsForGlobalItems(
mapping (uint8 => ItemOwner) storage self,
uint8 _transferCount
)
external view
| function getHistoralEINsForGlobalItems(
mapping (uint8 => ItemOwner) storage self,
uint8 _transferCount
)
external view
| 24,490 |
6 | // Call proxy with final init code | (bool success, bytes memory data) = proxy.call{value: 0}(_creationCode);
| (bool success, bytes memory data) = proxy.call{value: 0}(_creationCode);
| 17,754 |
8 | // 구매 함수 | function purchaseAnimalToken(uint256 _animalTokenId) public payable{
uint256 price = animalTokenPrices[_animalTokenId];
address animalTokenOwner = mintAnimalTokenAddress.ownerOf(_animalTokenId);
require(price > 0, "Animal token not sale.");
require(price <= msg.value, "Caller sent lower than price");
require(animalTokenOwner != msg.sender, "Caller is aninal token owner.");
payable(animalTokenOwner).transfer(msg.value);
mintAnimalTokenAddress.safeTransferFrom(animalTokenOwner, msg.sender, _animalTokenId); //토큰 구매자에게 이동
animalTokenPrices[_animalTokenId] = 0;
for(uint256 i=0; i < onSaleAnimalTokenArray.length; i++){
if(animalTokenPrices[onSaleAnimalTokenArray[i]] == 0){
onSaleAnimalTokenArray[i] = onSaleAnimalTokenArray[onSaleAnimalTokenArray.length - 1];
onSaleAnimalTokenArray.pop();
}
}
}
| function purchaseAnimalToken(uint256 _animalTokenId) public payable{
uint256 price = animalTokenPrices[_animalTokenId];
address animalTokenOwner = mintAnimalTokenAddress.ownerOf(_animalTokenId);
require(price > 0, "Animal token not sale.");
require(price <= msg.value, "Caller sent lower than price");
require(animalTokenOwner != msg.sender, "Caller is aninal token owner.");
payable(animalTokenOwner).transfer(msg.value);
mintAnimalTokenAddress.safeTransferFrom(animalTokenOwner, msg.sender, _animalTokenId); //토큰 구매자에게 이동
animalTokenPrices[_animalTokenId] = 0;
for(uint256 i=0; i < onSaleAnimalTokenArray.length; i++){
if(animalTokenPrices[onSaleAnimalTokenArray[i]] == 0){
onSaleAnimalTokenArray[i] = onSaleAnimalTokenArray[onSaleAnimalTokenArray.length - 1];
onSaleAnimalTokenArray.pop();
}
}
}
| 4,099 |
112 | // Add asset | function setAsset(address _assetAddress, uint256 _weiRaised, uint256 _minAmount, uint256 _rate) public onlyOwner {
asset[_assetAddress].weiRaised = _weiRaised;
asset[_assetAddress].minAmount = _minAmount;
asset[_assetAddress].rate = _rate;
asset[_assetAddress].active = true;
}
| function setAsset(address _assetAddress, uint256 _weiRaised, uint256 _minAmount, uint256 _rate) public onlyOwner {
asset[_assetAddress].weiRaised = _weiRaised;
asset[_assetAddress].minAmount = _minAmount;
asset[_assetAddress].rate = _rate;
asset[_assetAddress].active = true;
}
| 19,555 |
76 | // Stage 6: up to 3000 Ether, exchange rate of 1 ETH for 3000 BUX | tokenAllocation = calcpresaleAllocations(weiUsing, 3000);
| tokenAllocation = calcpresaleAllocations(weiUsing, 3000);
| 20,797 |
3 | // Main Tokens are not deposited in the dieselToken address. Instead, they're deposited in a gearbox vault. Therefore, to remove liquidity, we withdraw tokens from the vault, and not from the wrapped token. | IGearboxVault gearboxVault = IGearboxVault(wrappedToken.owner());
gearboxVault.removeLiquidity(dieselAmount, recipient);
_setChainedReference(outputReference, gearboxVault.fromDiesel(dieselAmount));
| IGearboxVault gearboxVault = IGearboxVault(wrappedToken.owner());
gearboxVault.removeLiquidity(dieselAmount, recipient);
_setChainedReference(outputReference, gearboxVault.fromDiesel(dieselAmount));
| 27,901 |
74 | // Returns informations for a country for previous games | function country_getOldInfoForCountry(uint256 _countryId, uint256 _gameId)
public
view
returns (
bool oldEliminatedBool_,
uint256 oldMaxLovesForTheBest_
)
| function country_getOldInfoForCountry(uint256 _countryId, uint256 _gameId)
public
view
returns (
bool oldEliminatedBool_,
uint256 oldMaxLovesForTheBest_
)
| 37,559 |
71 | // Array with all auctions | Auction[] public auctions;
| Auction[] public auctions;
| 21,256 |
13 | // Make a bet and transfer tokens to this contract. Bet will go to common prize fund./ | function bet() public {
require(isRoundActive(), "Round must be active");
require(_tokenContract.balanceOf(msg.sender) >= betAmount, "Sender has not enough balance");
require(_tokenContract.allowance(msg.sender, address(this)) >= betAmount, "Lottery contract is not allowed to transfer tokens");
emit BetPlaced(msg.sender, betAmount);
_tokenContract.transferFrom(msg.sender, address(this), betAmount);
prizeFund = prizeFund.add(betAmount);
lastInvestedTime = block.timestamp;
lastInvestorAddress = msg.sender;
roundCloseTime = roundCloseTime + betTimeDelay;
}
| function bet() public {
require(isRoundActive(), "Round must be active");
require(_tokenContract.balanceOf(msg.sender) >= betAmount, "Sender has not enough balance");
require(_tokenContract.allowance(msg.sender, address(this)) >= betAmount, "Lottery contract is not allowed to transfer tokens");
emit BetPlaced(msg.sender, betAmount);
_tokenContract.transferFrom(msg.sender, address(this), betAmount);
prizeFund = prizeFund.add(betAmount);
lastInvestedTime = block.timestamp;
lastInvestorAddress = msg.sender;
roundCloseTime = roundCloseTime + betTimeDelay;
}
| 1,885 |
20 | // executes an approved transaction revaling publicHash hash, friends addresses and set new recovery parameters _executeHash Seed of `peerHash` _merkleRoot Revealed merkle root _calldest Address will be called _calldata Data to be sent _leafData Pre approved leafhashes and it's weights as siblings ordered by descending weight _proofs parents proofs _proofFlags indexes that select the hashing pairs from calldata `_leafHashes` and `_proofs` and from memory `hashes` / | function execute(
bytes32 _executeHash,
bytes32 _merkleRoot,
address _calldest,
bytes calldata _calldata,
bytes32[] calldata _leafData,
bytes32[] calldata _proofs,
bool[] calldata _proofFlags
)
external
| function execute(
bytes32 _executeHash,
bytes32 _merkleRoot,
address _calldest,
bytes calldata _calldata,
bytes32[] calldata _leafData,
bytes32[] calldata _proofs,
bool[] calldata _proofFlags
)
external
| 45,790 |
28 | // Allow the CONTRACT owner/admin to END an offer. / | function revokeSale(uint punkIndex) public adminRequired {
require(punkIndex < 10000,"Token index not valid");
punksOfferedForSale[punkIndex] = Offer(false, punkIndex, address(0x0), 0, address(0x0));
emit PunkNoLongerForSale(punkIndex);
}
| function revokeSale(uint punkIndex) public adminRequired {
require(punkIndex < 10000,"Token index not valid");
punksOfferedForSale[punkIndex] = Offer(false, punkIndex, address(0x0), 0, address(0x0));
emit PunkNoLongerForSale(punkIndex);
}
| 3,774 |
171 | // Issue early contribution receipt | EarlyContribReceipt(addr, tokenAmount, memo);
| EarlyContribReceipt(addr, tokenAmount, memo);
| 37,423 |
19 | // EVENTS //- Events for Proposals | event SubmittedProposal(bytes32 proposalId, uint256 flags);
event SponsoredProposal(
bytes32 proposalId,
uint256 flags,
address votingAdapter
);
event ProcessedProposal(bytes32 proposalId, uint256 flags);
event AdapterAdded(
bytes32 adapterId,
address adapterAddress,
| event SubmittedProposal(bytes32 proposalId, uint256 flags);
event SponsoredProposal(
bytes32 proposalId,
uint256 flags,
address votingAdapter
);
event ProcessedProposal(bytes32 proposalId, uint256 flags);
event AdapterAdded(
bytes32 adapterId,
address adapterAddress,
| 63,404 |
1,662 | // 832 | entry "uncocooned" : ENG_ADJECTIVE
| entry "uncocooned" : ENG_ADJECTIVE
| 17,444 |
20 | // ========== RESTRICTED FUNCTIONS ========== / Used by pools when user redeems | function pool_burn_from(address b_address, uint256 b_amount) public onlyPools {
super._burnFrom(b_address, b_amount);
emit FRAXBurned(b_address, msg.sender, b_amount);
}
| function pool_burn_from(address b_address, uint256 b_amount) public onlyPools {
super._burnFrom(b_address, b_amount);
emit FRAXBurned(b_address, msg.sender, b_amount);
}
| 33,518 |
775 | // Initialize can only be called once. It saves the block number in which it was initialized.Initialize this kernel instance along with its ACL and set `_permissionsCreator` as the entity that can create other permissions_baseAcl Address of base ACL app_permissionsCreator Entity that will be given permission over createPermission/ | function initialize(IACL _baseAcl, address _permissionsCreator) public onlyInit {
initialized();
// Set ACL base
_setApp(KERNEL_APP_BASES_NAMESPACE, KERNEL_DEFAULT_ACL_APP_ID, _baseAcl);
// Create ACL instance and attach it as the default ACL app
IACL acl = IACL(newAppProxy(this, KERNEL_DEFAULT_ACL_APP_ID));
acl.initialize(_permissionsCreator);
_setApp(KERNEL_APP_ADDR_NAMESPACE, KERNEL_DEFAULT_ACL_APP_ID, acl);
recoveryVaultAppId = KERNEL_DEFAULT_VAULT_APP_ID;
}
| function initialize(IACL _baseAcl, address _permissionsCreator) public onlyInit {
initialized();
// Set ACL base
_setApp(KERNEL_APP_BASES_NAMESPACE, KERNEL_DEFAULT_ACL_APP_ID, _baseAcl);
// Create ACL instance and attach it as the default ACL app
IACL acl = IACL(newAppProxy(this, KERNEL_DEFAULT_ACL_APP_ID));
acl.initialize(_permissionsCreator);
_setApp(KERNEL_APP_ADDR_NAMESPACE, KERNEL_DEFAULT_ACL_APP_ID, acl);
recoveryVaultAppId = KERNEL_DEFAULT_VAULT_APP_ID;
}
| 5,949 |
92 | // update storage | state.accruedAmount = sub_(state.accruedAmount, amount);
superiorAccruedAmount = sub_(superiorAccruedAmount, amount);
emit Claimed(account, receiver, amount);
return amount;
| state.accruedAmount = sub_(state.accruedAmount, amount);
superiorAccruedAmount = sub_(superiorAccruedAmount, amount);
emit Claimed(account, receiver, amount);
return amount;
| 18,866 |
202 | // presale settings | address private signerAddress;
mapping(address => uint256) public presaleMinted;
uint256 public presaleMaxSupply = 5555;
uint256 public presaleMaxPerMint = 3;
uint256 public presalePricePerToken = 0;
uint256 public tokenfyPresalePrice = 0;
| address private signerAddress;
mapping(address => uint256) public presaleMinted;
uint256 public presaleMaxSupply = 5555;
uint256 public presaleMaxPerMint = 3;
uint256 public presalePricePerToken = 0;
uint256 public tokenfyPresalePrice = 0;
| 36,420 |
109 | // Calculate sign of x, i.e. -1 if x is negative, 0 if x if zero, and 1 if xis positive.Note that sign (-0) is zero.Revert if x is NaN.x quadruple precision numberreturn sign of x / | function sign(bytes16 x) internal pure returns (int8) {
uint128 absoluteX = uint128(x) & 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
require(absoluteX <= 0x7FFF0000000000000000000000000000); // Not NaN
if (absoluteX == 0) return 0;
else if (uint128(x) >= 0x80000000000000000000000000000000) return -1;
else return 1;
}
| function sign(bytes16 x) internal pure returns (int8) {
uint128 absoluteX = uint128(x) & 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
require(absoluteX <= 0x7FFF0000000000000000000000000000); // Not NaN
if (absoluteX == 0) return 0;
else if (uint128(x) >= 0x80000000000000000000000000000000) return -1;
else return 1;
}
| 58,591 |
102 | // msg.value | uint256 value;
| uint256 value;
| 23,793 |
64 | // sets recipient of transfer fee only callable by owner _newBeneficiary new beneficiary / | function setBeneficiary(address _newBeneficiary) public onlyOwner {
setExcludeFromFee(_newBeneficiary, true);
emit BeneficiaryUpdated(beneficiary, _newBeneficiary);
beneficiary = _newBeneficiary;
}
| function setBeneficiary(address _newBeneficiary) public onlyOwner {
setExcludeFromFee(_newBeneficiary, true);
emit BeneficiaryUpdated(beneficiary, _newBeneficiary);
beneficiary = _newBeneficiary;
}
| 32,668 |
83 | // Anti-bot and anti-whale mappings and variables | mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
bool public transferDelayEnabled = false;
uint256 public buyTotalFees;
uint256 public buyMarketingFee;
uint256 public buyLiquidityFee;
uint256 public buyDevFee;
uint256 public sellTotalFees;
uint256 public sellMarketingFee;
| mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
bool public transferDelayEnabled = false;
uint256 public buyTotalFees;
uint256 public buyMarketingFee;
uint256 public buyLiquidityFee;
uint256 public buyDevFee;
uint256 public sellTotalFees;
uint256 public sellMarketingFee;
| 5,333 |
99 | // calculate current ratio of debt to payout token supplyprotocols using Olympus Pro should be careful when quickly adding large %s to total supply return debtRatio_ uint / | function debtRatio() public view returns ( uint debtRatio_ ) {
debtRatio_ = FixedPoint.fraction(
currentDebt().mul( 10 ** payoutToken.decimals() ),
payoutToken.totalSupply()
).decode112with18().div( 1e18 );
}
| function debtRatio() public view returns ( uint debtRatio_ ) {
debtRatio_ = FixedPoint.fraction(
currentDebt().mul( 10 ** payoutToken.decimals() ),
payoutToken.totalSupply()
).decode112with18().div( 1e18 );
}
| 5,559 |
4 | // Returns list of all endaoments / | function getEndaoments() external view returns (address[] memory) {
return endaoments;
}
| function getEndaoments() external view returns (address[] memory) {
return endaoments;
}
| 9,903 |
181 | // agregar require para que solo pueda ser llamado por cardsContract | _burn(tokenId);
| _burn(tokenId);
| 25,406 |
138 | // Look up information about a specific tick in the pool/tick The tick to look up/ return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or/ tick upper,/ liquidityNet how much liquidity changes when the pool price crosses the tick,/ feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,/ feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,/ tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick/ secondsPerLiquidityOutsideX128 the seconds spent | function ticks(int24 tick)
external
view
returns (
uint128 liquidityGross,
int128 liquidityNet,
uint256 feeGrowthOutside0X128,
uint256 feeGrowthOutside1X128,
int56 tickCumulativeOutside,
uint160 secondsPerLiquidityOutsideX128,
| function ticks(int24 tick)
external
view
returns (
uint128 liquidityGross,
int128 liquidityNet,
uint256 feeGrowthOutside0X128,
uint256 feeGrowthOutside1X128,
int56 tickCumulativeOutside,
uint160 secondsPerLiquidityOutsideX128,
| 36,410 |
290 | // Returns the value in the latest checkpoint, or zero if there are no checkpoints. / | function latest(History storage self) internal view returns (uint256) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? 0 : self._checkpoints[pos - 1]._value;
}
| function latest(History storage self) internal view returns (uint256) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? 0 : self._checkpoints[pos - 1]._value;
}
| 12,659 |
5 | // adding village admins | function addSuperAdmin(address _superAdmin,string memory _village ) onlyOwner public {
superAdmin[_village]=_superAdmin;
}
| function addSuperAdmin(address _superAdmin,string memory _village ) onlyOwner public {
superAdmin[_village]=_superAdmin;
}
| 16,411 |
30 | // no reveal now | deadlines[2] = deadlines[3] = t + votingPeriod;
| deadlines[2] = deadlines[3] = t + votingPeriod;
| 28,111 |
32 | // --- END CONTRACT ACTIONS --- // --- DATA & EVENTS --- //A bet struct is created for each bet, so it is optimised for data sizeBets are stored as a doubly linked list per house, so previous_house_betand next_house_bet are pointers within global bets mapping.Resolved bets are deleted and removed from relevant house list./ | struct Bet {
address house; // House.
uint56 price_gwei; // Price of bet in GWEI.
uint40 timestamp; // Bet creation time.
address player; // Player.
uint32 previous_house_bet; // Previous undecided bet for same house.
uint32 next_house_bet; // Next undecided bet for same house.
uint32 odds; // Odds of winning (odds to 1).
bytes32 randomness; // Random value provided by player.
}
| struct Bet {
address house; // House.
uint56 price_gwei; // Price of bet in GWEI.
uint40 timestamp; // Bet creation time.
address player; // Player.
uint32 previous_house_bet; // Previous undecided bet for same house.
uint32 next_house_bet; // Next undecided bet for same house.
uint32 odds; // Odds of winning (odds to 1).
bytes32 randomness; // Random value provided by player.
}
| 37,843 |
187 | // Underlying is a special case and its LT is stored in Slot1, to be accessed frequently | if (token == underlying) {
| if (token == underlying) {
| 29,003 |
48 | // Create a uniswap pair for token | uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
| uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
| 7,144 |
89 | // addr The user to look up staking information for.return The number of staking tokens deposited for addr. / | function totalStakedFor(address addr) public view returns (uint256) {
return
totalStakingShares > 0
? totalStaked().mul(_userTotals[addr].stakingShares).div(
totalStakingShares
)
: 0;
}
| function totalStakedFor(address addr) public view returns (uint256) {
return
totalStakingShares > 0
? totalStaked().mul(_userTotals[addr].stakingShares).div(
totalStakingShares
)
: 0;
}
| 35,564 |
64 | // Tax and project development fees will start at 0 so we don't have a big impact when deploying to Uniswap project development wallet address is null but the method to set the address is exposed | uint256 private _taxFee = 2; // 2% reflection fee for every holder
uint256 private _projectDevelopmentFee = 10; // 10% project development
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousProjectDevelopmentFee = _projectDevelopmentFee;
address payable public _projectDevelopmentWalletAddress = payable(0x94f345bd57FcB293D18F13722AE40C17207a20aE);
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
| uint256 private _taxFee = 2; // 2% reflection fee for every holder
uint256 private _projectDevelopmentFee = 10; // 10% project development
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousProjectDevelopmentFee = _projectDevelopmentFee;
address payable public _projectDevelopmentWalletAddress = payable(0x94f345bd57FcB293D18F13722AE40C17207a20aE);
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
| 4,707 |
100 | // Operation to delete token/token The token address to be deleted/ return responseCode The response code for the status of the request. SUCCESS is 22. | function deleteToken(address token) external returns (int64 responseCode);
| function deleteToken(address token) external returns (int64 responseCode);
| 15,801 |
5 | // Set the properties of the PF Distribution | pfdistribution.fundManager = _fundManager;
pfdistribution.fundDetails = _fundDetails;
pfdistribution.amountSubscribed = 0;
| pfdistribution.fundManager = _fundManager;
pfdistribution.fundDetails = _fundDetails;
pfdistribution.amountSubscribed = 0;
| 26,050 |
4 | // Méthode permettant de retrouver la balance ou le solde d'Ether du Smart Contract/ | function getTotal() public constant returns (uint) {
return this.balance;
}
| function getTotal() public constant returns (uint) {
return this.balance;
}
| 13,700 |
42 | // Invariant: There will always be an initialized ownership slot (i.e. `ownership.addr != address(0) && ownership.burned == false`) before an unintialized ownership slot (i.e. `ownership.addr == address(0) && ownership.burned == false`) Hence, `tokenId` will not underflow. We can directly compare the packed value. If the address is zero, packed will be zero. | for (;;) {
unchecked {
packed = ERC721AStorage.layout()._packedOwnerships[--tokenId];
}
| for (;;) {
unchecked {
packed = ERC721AStorage.layout()._packedOwnerships[--tokenId];
}
| 10,850 |
46 | // Check if crowdsale has ended/ return `ended` If the crowdsale has ended |
function isEnded() public constant returns (bool ended);
|
function isEnded() public constant returns (bool ended);
| 43,127 |
58 | // Safely transfers the ownership of a given token ID to another addressIf the target address is a contract, it must implement `onERC721Received`,which is called upon a safe transfer, and return the magic value`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,the transfer is reverted. Requires the msg sender to be the owner, approved, or operator _from current owner of the token _to address to receive the ownership of the given token ID _tokenId uint256 ID of the token to be transferred/ | function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId
)
public
| function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId
)
public
| 8,069 |
4 | // Basic proxy that delegates all calls to a fixed implementing contract. / | contract Proxy {
/* This is the keccak-256 hash of "biconomy.scw.proxy.implementation" subtracted by 1, and is validated in the constructor */
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x37722d148fb373b961a84120b6c8d209709b45377878a466db32bbc40d95af26;
event Received(uint indexed value, address indexed sender, bytes data);
constructor(address _implementation) {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("biconomy.scw.proxy.implementation")) - 1));
assembly {
sstore(_IMPLEMENTATION_SLOT,_implementation)
}
}
fallback() external payable {
address target;
// solhint-disable-next-line no-inline-assembly
assembly {
target := sload(_IMPLEMENTATION_SLOT)
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), target, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {revert(0, returndatasize())}
default {return (0, returndatasize())}
}
}
receive() external payable {
emit Received(msg.value, msg.sender, "");
}
} | contract Proxy {
/* This is the keccak-256 hash of "biconomy.scw.proxy.implementation" subtracted by 1, and is validated in the constructor */
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x37722d148fb373b961a84120b6c8d209709b45377878a466db32bbc40d95af26;
event Received(uint indexed value, address indexed sender, bytes data);
constructor(address _implementation) {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("biconomy.scw.proxy.implementation")) - 1));
assembly {
sstore(_IMPLEMENTATION_SLOT,_implementation)
}
}
fallback() external payable {
address target;
// solhint-disable-next-line no-inline-assembly
assembly {
target := sload(_IMPLEMENTATION_SLOT)
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), target, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {revert(0, returndatasize())}
default {return (0, returndatasize())}
}
}
receive() external payable {
emit Received(msg.value, msg.sender, "");
}
} | 27,191 |
8 | // transfer by approved person from original address of an amount within approved limit /_from, address sending to and the amount to send/_to receiver of token/_value amount value of token to send/internal helper transfer function with required safety checks/ return true, success once transfered from original account Allow _spender to spend up to _value on your behalf | function transferFrom(address _from, address _to, uint256 _value) external returns (bool) {
require(_value <= balanceOf[_from]);
require(_value <= allowance[_from][msg.sender]);
allowance[_from][msg.sender] = allowance[_from][msg.sender] - (_value);
_transfer(_from, _to, _value);
return true;
}
| function transferFrom(address _from, address _to, uint256 _value) external returns (bool) {
require(_value <= balanceOf[_from]);
require(_value <= allowance[_from][msg.sender]);
allowance[_from][msg.sender] = allowance[_from][msg.sender] - (_value);
_transfer(_from, _to, _value);
return true;
}
| 31,968 |
83 | // ERC-20 overridden function that include logic to check for trade validity._to The address of the receiver_value The number of tokens to transfer return `true` if successful and `false` if unsuccessful/ | function transfer(address _to, uint256 _value) public returns (bool) {
require(_checkVested(msg.sender, balanceOf(msg.sender), _value), "Cannot send vested amount!");
require(_check(msg.sender, _to, _value), "Cannot transfer!");
return super.transfer(_to, _value);
}
| function transfer(address _to, uint256 _value) public returns (bool) {
require(_checkVested(msg.sender, balanceOf(msg.sender), _value), "Cannot send vested amount!");
require(_check(msg.sender, _to, _value), "Cannot transfer!");
return super.transfer(_to, _value);
}
| 3,006 |
1 | // sBTC pool | uint256[3] calldata amounts,
uint256 min_mint_amount
) external;
function add_liquidity(
| uint256[3] calldata amounts,
uint256 min_mint_amount
) external;
function add_liquidity(
| 47,937 |
2 | // event to signal purchase | event Purchase(uint256 _uid, string _link);
| event Purchase(uint256 _uid, string _link);
| 23,236 |
80 | // Generate the requestId | requestId = generateRequestId();
address mainPayee;
int256 mainExpectedAmount;
| requestId = generateRequestId();
address mainPayee;
int256 mainExpectedAmount;
| 47,198 |
195 | // Pausing is optimized for speed of action. The guardian is intended to be the option with the least friction, though manager or affiliate can pause as well. | function pause() external {
require(msg.sender == guardian || msg.sender == manager || msg.sender == affiliate, "only-authorized-pausers");
_pause();
}
| function pause() external {
require(msg.sender == guardian || msg.sender == manager || msg.sender == affiliate, "only-authorized-pausers");
_pause();
}
| 66,686 |
74 | // Returns the admin of a proxy. Only the admin can query it.return The address of the current admin of the proxy. / | function getProxyAdmin(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("admin()")) == 0xf851a440
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
require(success);
return abi.decode(returndata, (address));
}
| function getProxyAdmin(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("admin()")) == 0xf851a440
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
require(success);
return abi.decode(returndata, (address));
}
| 31,201 |
4 | // address of the ERC20 token | IERC20 public tokenAddress;
uint256 public amountPerNFT = 10_000_000 ether; // amount of tokens per NFT
uint256 public totalStaked; // total amount of tokens staked
uint256 public totalNFTsStaked; // total amount of NFTs staked
uint256 public totalMultiplers; // total amount of multipliers
uint256 public activeRewardId; // id of the active reward
| IERC20 public tokenAddress;
uint256 public amountPerNFT = 10_000_000 ether; // amount of tokens per NFT
uint256 public totalStaked; // total amount of tokens staked
uint256 public totalNFTsStaked; // total amount of NFTs staked
uint256 public totalMultiplers; // total amount of multipliers
uint256 public activeRewardId; // id of the active reward
| 23,546 |
10 | // Amount of veToken Boosts bought | uint256 boughtAmount;
| uint256 boughtAmount;
| 37,906 |
15 | // made by sambitsargam | function sendMessage(address friend_key, string calldata _msg) external {
require(checkUserExists(msg.sender), "Create an account first!");
require(checkUserExists(friend_key), "User is not registered!");
require(checkAlreadyFriends(msg.sender,friend_key), "You are not friends with the given user");
bytes32 chatCode = _getChatCode(msg.sender, friend_key);
message memory newMsg = message(msg.sender, block.timestamp, _msg);
allMessages[chatCode].push(newMsg);
}
| function sendMessage(address friend_key, string calldata _msg) external {
require(checkUserExists(msg.sender), "Create an account first!");
require(checkUserExists(friend_key), "User is not registered!");
require(checkAlreadyFriends(msg.sender,friend_key), "You are not friends with the given user");
bytes32 chatCode = _getChatCode(msg.sender, friend_key);
message memory newMsg = message(msg.sender, block.timestamp, _msg);
allMessages[chatCode].push(newMsg);
}
| 9,999 |
10 | // Approve 0 token amount | reward.safeApprove(poolAddress, 0);
emit PoolRemoved(_poolId, poolAddress);
| reward.safeApprove(poolAddress, 0);
emit PoolRemoved(_poolId, poolAddress);
| 70,835 |
63 | // If some amount is owed, pay it back NOTE: Since debt is adjusted in step-wise fashion, it is appropiate to always trigger here, because the resulting change should be large (might not always be the case) | uint256 outstanding = vault.debtOutstanding();
if (outstanding > 0) return true;
| uint256 outstanding = vault.debtOutstanding();
if (outstanding > 0) return true;
| 25,029 |
211 | // Throws if player does not own the hero, or the hero is still in cooldown period, and no pending power update. / | modifier heroAllowedToChallenge(uint _heroId) {
// You can only challenge with your own hero.
require(heroTokenContract.ownerOf(_heroId) == msg.sender);
// Hero must not be in cooldown period
uint cooldownRemainingTime = _computeCooldownRemainingTime(_heroId);
require(cooldownRemainingTime == 0);
// Prevent player to perform training and challenge in the same block to avoid bot exploit.
require(block.number > playerToLastActionBlockNumber[msg.sender]);
_;
}
| modifier heroAllowedToChallenge(uint _heroId) {
// You can only challenge with your own hero.
require(heroTokenContract.ownerOf(_heroId) == msg.sender);
// Hero must not be in cooldown period
uint cooldownRemainingTime = _computeCooldownRemainingTime(_heroId);
require(cooldownRemainingTime == 0);
// Prevent player to perform training and challenge in the same block to avoid bot exploit.
require(block.number > playerToLastActionBlockNumber[msg.sender]);
_;
}
| 42,892 |
331 | // assigned (and available on the emitted {IERC721-Transfer} event), and the tokenURI autogenerated based on the base URI passed at construction. See {ERC721-_mint}. Requirements: - the caller must have the `MINTER_ROLE`. / | function mint(address to) public virtual {
require(hasRole(MINTER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have minter role to mint");
| function mint(address to) public virtual {
require(hasRole(MINTER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have minter role to mint");
| 10,815 |
7 | // SIMPLE POLICY | mapping(bytes32 => SimplePolicy) simplePolicies; // objectId => SimplePolicy struct
| mapping(bytes32 => SimplePolicy) simplePolicies; // objectId => SimplePolicy struct
| 36,947 |
6 | // Returns the hash agreed upon by a threshold of the enabled oraclesAdapters./domain Uint256 identifier for the domain to query./id Uint256 identifier to query./ return hash Bytes32 hash agreed upon by a threshold of the oracles for the given domain./Reverts if no threshold is not reached./Reverts if no oracles are set for the given domain. | function getThresholdHash(uint256 domain, uint256 id) public view returns (bytes32 hash) {
hash = _getThresholdHash(domain, id);
}
| function getThresholdHash(uint256 domain, uint256 id) public view returns (bytes32 hash) {
hash = _getThresholdHash(domain, id);
}
| 12,484 |
773 | // Reduce the value to transfer if balance is insufficient after reclaimed | value = value > balanceAfter ? balanceAfter : value;
return super._internalTransfer(messageSender, to, value);
| value = value > balanceAfter ? balanceAfter : value;
return super._internalTransfer(messageSender, to, value);
| 34,369 |
211 | // URI locked | bool public URIlocked;
| bool public URIlocked;
| 23,863 |
21 | // iterate; | uint256 bcodesLen = bcodes[currentPeriod].length;
for (uint256 i = 0; i < bcodesLen; i++) {
if (revealBonusCodes[currentPeriod][bcodes[currentPeriod][i]].prefix != winnerBcode.prefix) {
continue;
}
| uint256 bcodesLen = bcodes[currentPeriod].length;
for (uint256 i = 0; i < bcodesLen; i++) {
if (revealBonusCodes[currentPeriod][bcodes[currentPeriod][i]].prefix != winnerBcode.prefix) {
continue;
}
| 40,505 |
177 | // allow governance to remove bad reserve prices | function removeReserve(address _user) external {
require(msg.sender == Ownable(settings).owner(), "remove:not gov");
require(auctionState == State.inactive, "update:auction live cannot update price");
uint256 old = userPrices[_user];
require(0 != old, "update:not an update");
uint256 weight = balanceOf(_user);
votingTokens -= weight;
reserveTotal -= weight * old;
userPrices[_user] = 0;
emit PriceUpdate(_user, 0);
}
| function removeReserve(address _user) external {
require(msg.sender == Ownable(settings).owner(), "remove:not gov");
require(auctionState == State.inactive, "update:auction live cannot update price");
uint256 old = userPrices[_user];
require(0 != old, "update:not an update");
uint256 weight = balanceOf(_user);
votingTokens -= weight;
reserveTotal -= weight * old;
userPrices[_user] = 0;
emit PriceUpdate(_user, 0);
}
| 32,632 |
26 | // USDC subtotal assuming FRAX drops to the CR and all reserves are arbed | uint256 usdc_subtotal = usdc_in_contract.add(usdc_withdrawable);
return [
frax_in_contract, // [0] Free FRAX in the contract
frax_withdrawable, // [1] FRAX withdrawable from the FRAX3CRV tokens
frax_withdrawable.add(frax_in_contract), // [2] FRAX withdrawable + free FRAX in the the contract
usdc_in_contract, // [3] Free USDC
usdc_withdrawable, // [4] USDC withdrawable from the FRAX3CRV tokens
usdc_subtotal, // [5] USDC subtotal assuming FRAX drops to the CR and all reserves are arbed
usdc_subtotal.add((frax_in_contract.add(frax_withdrawable)).mul(fraxDiscountRate()).div(1e6 * (10 ** missing_decimals))), // [6] USDC Total
| uint256 usdc_subtotal = usdc_in_contract.add(usdc_withdrawable);
return [
frax_in_contract, // [0] Free FRAX in the contract
frax_withdrawable, // [1] FRAX withdrawable from the FRAX3CRV tokens
frax_withdrawable.add(frax_in_contract), // [2] FRAX withdrawable + free FRAX in the the contract
usdc_in_contract, // [3] Free USDC
usdc_withdrawable, // [4] USDC withdrawable from the FRAX3CRV tokens
usdc_subtotal, // [5] USDC subtotal assuming FRAX drops to the CR and all reserves are arbed
usdc_subtotal.add((frax_in_contract.add(frax_withdrawable)).mul(fraxDiscountRate()).div(1e6 * (10 ** missing_decimals))), // [6] USDC Total
| 28,683 |
164 | // Returns how many tokens are still available to be claimed / | function getAvailableTokens() external view returns (uint256) {
return availableTokens.length;
}
| function getAvailableTokens() external view returns (uint256) {
return availableTokens.length;
}
| 73,476 |
9 | // CounterRegistry/Fully onchain NFT gated Counter Registry/Harrison (@PopPunkOnChain)/OptimizationFans | contract CounterRegistry is Ownable, ERC721A {
struct Counter {
uint256 value;
address owner;
}
mapping (uint256 => Counter) public counterRegistry;
error UnauthorizedAccess();
constructor() ERC721A("CounterRegistry", "CREG") {
_initializeOwner(msg.sender);
}
function initializeCounter(uint256 _startingValue) external returns (uint256) {
uint256 id = _nextTokenId();
counterRegistry[id] = Counter(_startingValue, msg.sender);
_mint(msg.sender, 1);
return id;
}
function increment(uint256 _counterId) external {
Counter storage counter = counterRegistry[_counterId];
if (counter.owner != msg.sender) revert UnauthorizedAccess();
unchecked {
counter.value++;
}
}
function decrement(uint256 _counterId) external {
Counter storage counter = counterRegistry[_counterId];
if (counter.owner != msg.sender) revert UnauthorizedAccess();
unchecked {
counter.value--;
}
}
function adminIncrementClawback(uint256 _counterId) external onlyOwner {
unchecked {
counterRegistry[_counterId].value--;
}
}
function transferFrom(address from, address to, uint256 tokenId) public payable virtual override {
if (from != address(0)) {
counterRegistry[tokenId].owner = to;
}
super.transferFrom(from, to, tokenId);
}
function getCounter(uint256 _id) external view returns (uint256, address) {
Counter memory counter = counterRegistry[_id];
return (counter.value, counter.owner);
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
return "https://imgur.com/gX03aPZ";
}
} | contract CounterRegistry is Ownable, ERC721A {
struct Counter {
uint256 value;
address owner;
}
mapping (uint256 => Counter) public counterRegistry;
error UnauthorizedAccess();
constructor() ERC721A("CounterRegistry", "CREG") {
_initializeOwner(msg.sender);
}
function initializeCounter(uint256 _startingValue) external returns (uint256) {
uint256 id = _nextTokenId();
counterRegistry[id] = Counter(_startingValue, msg.sender);
_mint(msg.sender, 1);
return id;
}
function increment(uint256 _counterId) external {
Counter storage counter = counterRegistry[_counterId];
if (counter.owner != msg.sender) revert UnauthorizedAccess();
unchecked {
counter.value++;
}
}
function decrement(uint256 _counterId) external {
Counter storage counter = counterRegistry[_counterId];
if (counter.owner != msg.sender) revert UnauthorizedAccess();
unchecked {
counter.value--;
}
}
function adminIncrementClawback(uint256 _counterId) external onlyOwner {
unchecked {
counterRegistry[_counterId].value--;
}
}
function transferFrom(address from, address to, uint256 tokenId) public payable virtual override {
if (from != address(0)) {
counterRegistry[tokenId].owner = to;
}
super.transferFrom(from, to, tokenId);
}
function getCounter(uint256 _id) external view returns (uint256, address) {
Counter memory counter = counterRegistry[_id];
return (counter.value, counter.owner);
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
return "https://imgur.com/gX03aPZ";
}
} | 29,398 |
3 | // Make sure the result is less than 2256. Also prevents denominator == 0 | require(denominator > prod1, 'denom <= prod1');
| require(denominator > prod1, 'denom <= prod1');
| 26,949 |
220 | // Gets address of cryptopunk smart contract / | function punkContract()
public
view
returns (address)
| function punkContract()
public
view
returns (address)
| 43,065 |
139 | // View function to see pending Farmer on frontend. | function pendingFarmer(uint256 _pid, address _user) public returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accFarmerPerLPShare = pool.accFarmerPerLPShare;
// Users LP tokens who is connected to the site
uint256 lpSupply = pool.lpTokenContract.balanceOf(address(this));
pool.lpTokenHolding = lpSupply;
if (block.number > pool.lastRewardedBlock && lpSupply > 0) {
uint256 FarmerReward = getFarmerAmountInRange(pool.lastRewardedBlock, block.number).mul(pool.allocPoints).div(totalAllocPoints);
FarmerReward = FarmerReward.mul(1000e18);
accFarmerPerLPShare = accFarmerPerLPShare.add(FarmerReward.div(lpSupply));
}
return user.amount.mul(accFarmerPerLPShare).div(1000e18).sub(user.rewardDebt);
}
| function pendingFarmer(uint256 _pid, address _user) public returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accFarmerPerLPShare = pool.accFarmerPerLPShare;
// Users LP tokens who is connected to the site
uint256 lpSupply = pool.lpTokenContract.balanceOf(address(this));
pool.lpTokenHolding = lpSupply;
if (block.number > pool.lastRewardedBlock && lpSupply > 0) {
uint256 FarmerReward = getFarmerAmountInRange(pool.lastRewardedBlock, block.number).mul(pool.allocPoints).div(totalAllocPoints);
FarmerReward = FarmerReward.mul(1000e18);
accFarmerPerLPShare = accFarmerPerLPShare.add(FarmerReward.div(lpSupply));
}
return user.amount.mul(accFarmerPerLPShare).div(1000e18).sub(user.rewardDebt);
}
| 35,665 |
14 | // at the end the function returns the new token Id | return newTokenId;
| return newTokenId;
| 15,948 |
8 | // 當前時間要大於空投開始時間 | require(block.timestamp >= airdropStartTime, "Airdropper: not started");
if (airdropTotalAmount > 0) {
| require(block.timestamp >= airdropStartTime, "Airdropper: not started");
if (airdropTotalAmount > 0) {
| 25,165 |
38 | // Admin function for pending governor to accept role and update governor.This function must called by the pending governor. / | function acceptOwnership() external {
require(
pendingGovernor != address(0) && msg.sender == pendingGovernor,
"Caller must be pending governor"
);
address oldGovernor = governor;
address oldPendingGovernor = pendingGovernor;
governor = pendingGovernor;
pendingGovernor = address(0);
emit NewOwnership(oldGovernor, governor);
emit NewPendingOwnership(oldPendingGovernor, pendingGovernor);
}
| function acceptOwnership() external {
require(
pendingGovernor != address(0) && msg.sender == pendingGovernor,
"Caller must be pending governor"
);
address oldGovernor = governor;
address oldPendingGovernor = pendingGovernor;
governor = pendingGovernor;
pendingGovernor = address(0);
emit NewOwnership(oldGovernor, governor);
emit NewPendingOwnership(oldPendingGovernor, pendingGovernor);
}
| 3,991 |
27 | // Increase the amount of tokens that an owner allowed to a spender. approve should be called when allowed[_spender] == 0. To incrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.sol _spender The address which will spend the funds. _addedValue The amount of tokens to increase the allowance by. / | function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| 30,129 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.