comment stringlengths 11 2.99k | function_code stringlengths 165 3.15k | version stringclasses 80
values |
|---|---|---|
// REDEEM AND BURN FUNCTIONS
// amount = number of tokens to burn | function redeem(uint256 amount)
public
profitable
returns (bool success) {
// the amount must be less than the total amount pooled
require(amount <= balanceOf[msg.sender]);
require(totalPooled >= amount);
uint256 num_redeemed = numberRedeemed(amount);
... | 0.6.12 |
// withdraw spaceport tokens
// percentile withdrawls allows fee on transfer or rebasing tokens to still work | function userWithdrawTokens () external nonReentrant {
require(STATUS.LP_GENERATION_COMPLETE, 'AWAITING LP GENERATION');
BuyerInfo storage buyer = BUYERS[msg.sender];
require(STATUS.LP_GENERATION_COMPLETE_TIME + SPACEPORT_VESTING.vestingCliff < block.timestamp, "vesting cliff : not time yet");
if ... | 0.6.12 |
// on spaceport success, this is the final step to end the spaceport, lock liquidity and enable withdrawls of the sale token.
// This function does not use percentile distribution. Rebasing mechanisms, fee on transfers, or any deflationary logic
// are not taken into account at this stage to ensure stated liquidity is ... | function addLiquidity() external nonReentrant {
require(!STATUS.LP_GENERATION_COMPLETE, 'GENERATION COMPLETE');
require(spaceportStatus() == 2, 'NOT SUCCESS'); // SUCCESS
// Fail the spaceport if the pair exists and contains spaceport token liquidity
if (SPACEPORT_LOCK_FORWARDER.plasmaswapPairIsInit... | 0.6.12 |
// editable at any stage of the presale | function editWhitelist(address[] memory _users, bool _add) external onlySpaceportOwner {
if (_add) {
for (uint i = 0; i < _users.length; i++) {
WHITELIST.add(_users[i]);
}
} else {
for (uint i = 0; i < _users.length; i++) {
WHITELIST.remove(_users[i]);
... | 0.6.12 |
/**
* @dev Multiplie two unsigned integers, revert on overflow.
*/ | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
... | 0.5.15 |
/**
* @dev Integer division of two unsigned integers truncating the quotient, revert on division by zero.
*/ | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
} | 0.5.15 |
/*
* @notify Update the address of a contract that this adjuster is connected to
* @param parameter The name of the contract to update the address for
* @param addr The new contract address
*/ | function modifyParameters(bytes32 parameter, address addr) external isAuthorized {
require(addr != address(0), "MinMaxRewardsAdjuster/null-address");
if (parameter == "oracleRelayer") {
oracleRelayer = OracleRelayerLike(addr);
oracleRelayer.redemptionPrice();
}
... | 0.6.7 |
/*
* @notify Change a parameter for a funding receiver
* @param receiver The address of the funding receiver
* @param targetFunction The function whose callers receive funding for calling
* @param parameter The name of the parameter to change
* @param val The new parameter value
*/ | function modifyParameters(address receiver, bytes4 targetFunction, bytes32 parameter, uint256 val) external isAuthorized {
require(val > 0, "MinMaxRewardsAdjuster/null-value");
FundingReceiver storage fundingReceiver = fundingReceivers[receiver][targetFunction];
require(fundingReceiver.lastUp... | 0.6.7 |
/*
* @notify Add a new funding receiver
* @param receiver The funding receiver address
* @param targetFunctionSignature The signature of the function whose callers get funding
* @param updateDelay The update delay between two consecutive calls that update the base and max rewards for this receiver
* @param ga... | function addFundingReceiver(
address receiver,
bytes4 targetFunctionSignature,
uint256 updateDelay,
uint256 gasAmountForExecution,
uint256 baseRewardMultiplier,
uint256 maxRewardMultiplier
) external isAuthorized {
// Checks
require(receiver ... | 0.6.7 |
/*
* @notify Recompute the base and max rewards for a specific funding receiver with a specific function offering funding
* @param receiver The funding receiver address
* @param targetFunctionSignature The signature of the function whose callers get funding
*/ | function recomputeRewards(address receiver, bytes4 targetFunctionSignature) external {
FundingReceiver storage targetReceiver = fundingReceivers[receiver][targetFunctionSignature];
require(both(targetReceiver.lastUpdateTime > 0, addition(targetReceiver.lastUpdateTime, targetReceiver.updateDelay) <= no... | 0.6.7 |
// // internal write functions
// mint | function _mint(address to_, uint256 tokenId_) internal virtual {
require(to_ != address(0x0), "ERC721I: _mint() Mint to Zero Address");
require(ownerOf[tokenId_] == address(0x0), "ERC721I: _mint() Token to Mint Already Exists!");
// ERC721I Starts Here
balanceOf[to_]++;
ow... | 0.8.7 |
// transfer | function _transfer(address from_, address to_, uint256 tokenId_) internal virtual {
require(from_ == ownerOf[tokenId_], "ERC721I: _transfer() Transfer Not Owner of Token!");
require(to_ != address(0x0), "ERC721I: _transfer() Transfer to Zero Address!");
// ERC721I Starts Here
// ch... | 0.8.7 |
// // Internal View Functions
// Embedded Libraries | function _toString(uint256 value_) internal pure returns (string memory) {
if (value_ == 0) { return "0"; }
uint256 _iterate = value_; uint256 _digits;
while (_iterate != 0) { _digits++; _iterate /= 10; } // get digits in value_
bytes memory _buffer = new bytes(_digits);
whi... | 0.8.7 |
// Functional Views | function _isApprovedOrOwner(address spender_, uint256 tokenId_) internal view virtual returns (bool) {
require(ownerOf[tokenId_] != address(0x0), "ERC721I: _isApprovedOrOwner() Owner is Zero Address!");
address _owner = ownerOf[tokenId_];
return (spender_ == _owner || spender_ == getApproved[... | 0.8.7 |
// // public write functions | function approve(address to_, uint256 tokenId_) public virtual {
address _owner = ownerOf[tokenId_];
require(to_ != _owner, "ERC721I: approve() Cannot approve yourself!");
require(msg.sender == _owner || isApprovedForAll[_owner][msg.sender], "ERC721I: Caller not owner or Approved!");
... | 0.8.7 |
// // public view functions
// never use these for functions ever, they are expensive af and for view only (this will be an issue in the future for interfaces) | function walletOfOwner(address address_) public virtual view returns (uint256[] memory) {
uint256 _balance = balanceOf[address_];
uint256[] memory _tokens = new uint256[] (_balance);
uint256 _index;
uint256 _loopThrough = totalSupply;
for (uint256 i = 0; i < _loopThrough; i+... | 0.8.7 |
// Governance Functions | function setPayableGovernanceShareholders(address payable[] memory addresses_, uint256[] memory shares_) public onlyPayableGovernanceSetter {
require(_payableGovernanceAddresses.length == 0 && _payableGovernanceShares.length == 0, "Payable Governance already set! To set again, reset first!");
require(... | 0.8.7 |
// Withdraw Functions | function withdrawEther() public onlyOwner {
// require that there has been payable governance set.
require(_payableGovernanceAddresses.length > 0 && _payableGovernanceShares.length > 0, "Payable governance not set yet!");
// this should never happen
require(_payableGovernanceAddress... | 0.8.7 |
// Internal Mint | function _mintMany(address to_, uint256 amount_) internal {
require(maxTokens >= totalSupply + amount_,
"Not enough tokens remaining!");
uint256 _startId = totalSupply + 1; // iterate from 1
for (uint256 i = 0; i < amount_; i++) {
_mint(to_, _startId + i);
... | 0.8.7 |
// Whitelist Mint Functions | function whitelistMint(bytes32[] calldata proof_, uint256 amount_) external payable
onlySender whitelistMintEnabled {
require(isWhitelisted(msg.sender, proof_),
"You are not Whitelisted!");
require(maxMintsPerWl >= addressToWlMints[msg.sender] + amount_,
"Over Max Mint... | 0.8.7 |
// Allows a token holder to burn tokens. Once burned, tokens are permanently
// removed from the total supply. | function burn(uint256 _amount) public returns (bool success) {
require(_amount > 0, 'Token amount to burn must be larger than 0');
address account = msg.sender;
require(_amount <= balanceOf(account), 'You cannot burn token you dont have');
balances[account] = balances[account].su... | 0.4.24 |
// Batch mint tokens. Assign directly to _to[]. | function mint(uint256 _id, address[] calldata _to, uint256[] calldata _quantities) external creatorOnly(_id) {
for (uint256 i = 0; i < _to.length; ++i) {
address to = _to[i];
uint256 quantity = _quantities[i];
// Grant the items to the caller
balances[_id][to] ... | 0.5.17 |
// Change the date and time: the beginning of the round, the end of the bonus, the end of the round. Available to Manager
// Description in the Crowdsale constructor | function changePeriod(uint256 _startTime, uint256 _endDiscountTime, uint256 _endTime) public{
require(wallets[uint8(Roles.manager)] == msg.sender);
require(!isInitialized);
// Date and time are correct
require(now <= _startTime);
require(_endDiscountTime > _startTime &... | 0.4.18 |
// Returns the percentage of the bonus on the given date. Constant. | function getProfitPercentForData(uint256 timeNow) public constant returns (uint256){
// if the discount is 0 or zero steps, or the round does not start, we return the minimum discount
if (profit.max == 0 || profit.step == 0 || timeNow > endDiscountTime){
return profit.min;
}
... | 0.4.18 |
// function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
// require(address(this).balance >= value, "Address: insufficient balance for call");
// return _functionCallWithValue(target, data, value, errorMessage);
// } | function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: ca... | 0.8.10 |
// Checking whether the rights to address ignore the "Pause of exchange". If the
// wallet is included in this list, it can translate tokens, ignoring the pause. By default,
// only the following wallets are included:
// - Accountant wallet (he should immediately transfer tokens, but not to non-ETH investors)
// ... | function unpausedWallet(address _wallet) internal constant returns(bool) {
bool _accountant = wallets[uint8(Roles.accountant)] == _wallet;
bool _manager = wallets[uint8(Roles.manager)] == _wallet;
bool _bounty = wallets[uint8(Roles.bounty)] == _wallet;
bool _company = wallets[uint8(R... | 0.4.18 |
// *********************************************************************************************
// Begin overrides to accomodate virtual owners information until owners are committed to state.
// ********************************************************************************************* | function tokenURI(uint256 tokenId) public pure override(ERC721) returns (string memory) {
// Since _owners starts empty but this contract represents 4012 NFTs, change the
// exists check for tokenURI.
require(0 < tokenId && tokenId < 4013, "Doesn't exist!");
return string(abi.encodeP... | 0.8.7 |
// Free OS Listings | function isApprovedForAll(
address owner,
address operator
)
public
view
override(ERC721)
returns (bool)
{
// Whitelist OpenSea proxy contract for easy trading.
ProxyRegistry proxyRegistry = ProxyRegistry(_openSea);
if (address(p... | 0.8.7 |
// If _balances for owner is not set in this contract, return balances from mint pass
// contract. | function balanceOf(address owner) public view virtual override(ERC721) returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
if (_balances[owner] == 0) {
return _ffmp.balanceOf(owner);
} else {
return _balances[owner];
... | 0.8.7 |
// smart contracts must implement the fallback function in order to deregister | function deregister()
external
{
Account storage account = accounts[msg.sender];
require(account.membership & VOTER != 0);
require(account.lastAccess + 7 days <= now);
account.membership ^= VOTER;
account.lastAccess = 0;
// the MANDATORY transfer keeps pop... | 0.4.20 |
// under no condition should you let anyone control two BOARD accounts | function appoint(address _board, string _vouch)
external {
require(accounts[msg.sender].membership & BOARD != 0);
Account storage candidate = accounts[_board];
if (candidate.membership & BOARD != 0) {
return;
}
address appt = candidate.appointer;
i... | 0.4.20 |
// bans prevent accounts from voting through this proposal
// this should only be used to stop a proposal that is abusing the VOTE token
// the burn is to penalize bans, so that they cannot suppress ideas | function banProposal(ProposalInterface _proposal, string _reason)
external payable
{
require(msg.value == proposalCensorshipFee);
require(accounts[msg.sender].membership & BOARD != 0);
Account storage account = accounts[_proposal];
require(account.membership & PROPOSAL != 0... | 0.4.20 |
// this code lives here instead of in the token so that it can be upgraded with account registry migration | function faucet()
external {
Account storage account = accounts[msg.sender];
require(account.membership & VOTER != 0);
uint256 lastAccess = account.lastAccess;
uint256 grant = (now - lastAccess) / 72 minutes;
if (grant > 40) {
grant = 40;
accou... | 0.4.20 |
/**
* @notice register can only be called through transferAndCall on LINK contract
* @param name string of the upkeep to be registered
* @param encryptedEmail email address of upkeep contact
* @param upkeepContract address to peform upkeep on
* @param gasLimit amount of gas to provide the target contract when
* p... | function register(
string memory name,
bytes calldata encryptedEmail,
address upkeepContract,
uint32 gasLimit,
address adminAddress,
bytes calldata checkData,
uint96 amount,
uint8 source
)
external
onlyLINK()
{
bytes32 hash = ke... | 0.7.6 |
/**
* @dev register upkeep on KeeperRegistry contract and emit RegistrationApproved event
*/ | function approve(
string memory name,
address upkeepContract,
uint32 gasLimit,
address adminAddress,
bytes calldata checkData,
uint96 amount,
bytes32 hash
)
external
onlyOwner()
{
_approve(
name,
upkeepContract,
... | 0.7.6 |
/**
* @notice owner calls this function to set if registration requests should be sent directly to the Keeper Registry
* @param enabled setting for autoapprove registrations
* @param windowSizeInBlocks window size defined in number of blocks
* @param allowedPerWindow number of registrations that can be auto approve... | function setRegistrationConfig(
bool enabled,
uint32 windowSizeInBlocks,
uint16 allowedPerWindow,
address keeperRegistry,
uint256 minLINKJuels
)
external
onlyOwner()
{
s_config = AutoApprovedConfig({
enabled: enabled,
allowedPer... | 0.7.6 |
/**
* @notice read the current registration configuration
*/ | function getRegistrationConfig()
external
view
returns (
bool enabled,
uint32 windowSizeInBlocks,
uint16 allowedPerWindow,
address keeperRegistry,
uint256 minLINKJuels,
uint64 windowStart,
uint16 approvedInCurren... | 0.7.6 |
/**
* @notice Called when LINK is sent to the contract via `transferAndCall`
* @param amount Amount of LINK sent (specified in Juels)
* @param data Payload of the transaction
*/ | function onTokenTransfer(
address, /* sender */
uint256 amount,
bytes calldata data
)
external
onlyLINK()
permittedFunctionsForLINK(data)
isActualAmount(amount, data)
{
require(amount >= s_minLINKJuels, "Insufficient payment");
(bool success, ) = a... | 0.7.6 |
/**
* @notice initializes the contract, with all parameters set at once
* @param _token the only token contract that is accepted in this vesting instance
* @param _owner the owner that can call decreaseVesting, set address(0) to have no owner
* @param _cliffInTenThousands amount of tokens to be released ahead of st... | function initialize
(
address _token,
address _owner,
uint256 _startInDays,
uint256 _durationInDays,
uint256 _cliffInTenThousands,
uint256 _cliffDelayInDays,
uint256 _exp
)
external initializer
{
__Ownable_init();
token = IERC20(_token);
startTime = block.timestamp +... | 0.8.0 |
// Commission CryptoTulip for abstract deconstructed art.
// You: I'd like a painting please. Use my painting for the foundation
// and use that other painting accross the street as inspiration.
// Artist: That'll be 1 finney. Come back one block later. | function commissionArt(uint256 _foundation, uint256 _inspiration)
external payable returns (uint)
{
require((totalSupply() < COMMISSION_ARTWORK_LIMIT) || (msg.value >= 1000 * ARTIST_FEES));
require(msg.sender == ownerOf(_foundation));
require(msg.value >= ARTIST_FEES);
ui... | 0.7.6 |
// Allows the developer to set the crowdsale addresses. | function set_sale_address(address _sale) {
// Only allow the developer to set the sale addresses.
require(msg.sender == developer);
// Only allow setting the addresses once.
require(sale == 0x0);
// Set the crowdsale and token addresses.
sale = _sale;
} | 0.4.16 |
// DEPRECATED -- Users must execute withdraw and specify the token address explicitly
// This contract was formerly exploitable by a malicious dev zeroing out former
// user balances with a junk token
// Allows the developer to set the token address !
// Enjin does not release token address until public crowdsale
// In... | function activate_kill_switch(string password) {
// Only activate the kill switch if the sender is the developer or the password is correct.
require(msg.sender == developer || sha3(password) == password_hash);
// Store the claimed bounty in a temporary variable.
uint256 claimed_bounty = buy_bounty;
... | 0.4.16 |
// Default function. Called when a user sends ETH to the contract. | function () payable {
// Disallow deposits if kill switch is active.
require(!kill_switch);
// Only allow deposits if the contract hasn't already purchased the tokens.
require(!bought_tokens);
// Only allow deposits that won't exceed the contract's ETH cap.
require(this.balance < eth_cap);... | 0.4.16 |
// ------------------------------------------------------------------------
// Transfer _amount tokens to address _to
// Sender must have enough tokens. Cannot send to 0x0.
// ------------------------------------------------------------------------ | function transfer(address _to, uint _amount)
public
returns (bool success) {
require(_to != address(0)); // Use burn() function instead
require(_to != address(this));
balances[msg.sender] = balances[msg.sender].sub(_amount);
balances[_to] = balances[_to].add(_amou... | 0.4.23 |
// Allows the Hydro API to set minimum hydro balances required for sign ups | function setMinimumHydroStakes(uint newMinimumHydroStakeUser, uint newMinimumHydroStakeDelegatedUser)
public onlyOwner
{
ERC20Basic hydro = ERC20Basic(hydroTokenAddress);
require(newMinimumHydroStakeUser <= (hydro.totalSupply() / 100 / 100)); // <= .01% of total supply
require(n... | 0.4.23 |
// Checks prefixed signatures (e.g. those created with web3.eth.sign) | function _isSignedPrefixed(address _address, bytes32 messageHash, uint8 v, bytes32 r, bytes32 s)
internal
pure
returns (bool)
{
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedMessageHash = keccak256(prefix, messageHash);
return ecre... | 0.4.23 |
// Common internal logic for all user signups | function _userSignUp(string casedUserName, address userAddress, bool delegated) internal {
require(bytes(casedUserName).length < 50);
bytes32 uncasedUserNameHash = keccak256(casedUserName.toSlice().copy().toString().lower());
require(!userDirectory[uncasedUserNameHash]._initialized);
... | 0.4.23 |
// Overridden ownerOf | function approve(address to, uint256 tokenId) public virtual override {
address owner = ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
msg.sender == owner || isApprovedForAll(owner, msg.sender),
"ERC721: approve caller is not ... | 0.8.7 |
// Removed ERC721 specifier to use overridden ownerOf function | function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(own... | 0.8.7 |
// OpenZeppelin _mint function overriden to support quantity. This reduces
// writes to storage and simplifies code.
//
// Flag added to allow selection between "safe" and "unsafe" mint with one
// function. | function _mint(address to, uint256 quantity, uint256 safeMint, bytes memory data) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
// Reading tokenIndex into memory, and then updating
// balances and stored index one time is more gas
// efficient.
... | 0.8.7 |
//Function overridden in main contract. | function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
// Clear approvals from th... | 0.8.7 |
// ------------------------------------------------------------------------
// An approved sender can burn _amount tokens of user _from
// Lowers user balance and supply by _amount
// ------------------------------------------------------------------------ | function burnFrom(address _from, uint _amount)
public
returns (bool success) {
balances[_from] = balances[_from].sub(_amount); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); // Subtract from th... | 0.4.23 |
// ------------------------------------------------------------------------
// Users can trade old MyBit tokens for new MyBit tokens here
// Must approve this contract as spender to swap tokens
// ------------------------------------------------------------------------ | function swap(uint256 _amount)
public
noMint
returns (bool){
require(ERC20Interface(oldTokenAddress).transferFrom(msg.sender, this, _amount));
uint256 newTokenAmount = _amount.mul(scalingFactor).mul(tenDecimalPlaces); // Add 10 more decimals to number of tokens
assert(tokensRedeemed.add(new... | 0.4.23 |
// ------------------------------------------------------------------------
// Alias for swap(). Called by old token contract when approval to transfer
// tokens has been given.
// ------------------------------------------------------------------------ | function receiveApproval(address _from, uint256 _amount, address _token, bytes _data)
public
noMint
returns (bool){
require(_token == oldTokenAddress);
require(ERC20Interface(oldTokenAddress).transferFrom(_from, this, _amount));
uint256 newTokenAmount = _amount.mul(scalingFactor).mul(tenDecima... | 0.4.23 |
// manual burn amount, for *possible* cex integration
// !!BEWARE!!: you will BURN YOUR TOKENS when you call this. | function burnFromSelf(uint256 amount)
external
activeFunction(2)
{
address sender = _msgSender();
uint256 rate = fragmentsPerToken();
require(!fbl_getExcluded(sender), "Excluded addresses can't call this function");
require(amount * rate < _fragmentBalances[sen... | 0.8.7 |
/* !!! CALLER WILL LOSE COINS CALLING THIS !!! */ | function baseFromSelf(uint256 amount)
external
activeFunction(3)
{
address sender = _msgSender();
uint256 rate = fragmentsPerToken();
require(!fbl_getExcluded(sender), "Excluded addresses can't call this function");
require(amount * rate < _fragmentBalances[sen... | 0.8.7 |
/**
* @param amount Amount of staking tokens
* @param lockDays How many days the staker wants to lock
* @param rewardToken The desired reward token to stake the tokens for (most likely a certain uToken)
*/ | function stake(uint256 amount, uint256 lockDays, address rewardToken)
external
poolExists(rewardToken)
{
require(
amount >= minStakeAmount,
"UnicStaking: Amount must be greater than or equal to min stake amount"
);
require(
lockMul... | 0.6.12 |
/// Accepts ether and creates new LifeCoin tokens. | function depositETH() external payable {
require(!isFinalized, "Already finalized");
require(block.timestamp >= fundingStartBlock, "Current block-number should not be less than fundingStartBlock");
require(block.timestamp <= fundingEndBlock, "Current block-number should not be greater than fundingEndBlock")... | 0.8.4 |
/// Ends the funding period and sends the ETH to the ethFundDeposit. | function finalize() external {
assert(address(this).balance > 0);
require(!isFinalized, "Already finalized");
require(msg.sender == ethFundDeposit, "Sender should be ethFundDeposit"); // locks finalize to the ultimate ETH owner
require(block.timestamp > fundingEndBlock, "Current block-number is no... | 0.8.4 |
/// After the ICO - Allow participants to withdraw their tokens at the price dictated by amount of ETH raised. | function withdraw() external {
assert(isFinalized == true); // Wait until YawLife has checked and confirmed the details of the ICO before withdrawing tokens.
//VERIFY THIS
// Check balance. Only permit if balance is non Zero
uint256 balance =0;
for(uint256 k=0; k < 7; k++){... | 0.8.4 |
// enforce minimum spend to buy tokens | function ICO( address _erc20,
address _treasury,
uint _startSec,
uint _durationSec,
uint _tokpereth ) public
{
require( isContract(_erc20) );
require( _tokpereth > 0 );
if (_treasury != address(0)) require( isContract(_treasury) );
... | 0.4.21 |
///The distribution function, accumulated tokens on a variable dividend among members | function dividendDistribution () onlyOwner public {
Transfer(0, this, dividend);
uint256 divsum = dividend / members.length;
dividend = 0;
for (uint i = 0; i < members.length; i++) {
address AdToDiv = members[i].member ;
balanceOf[AdToDiv] += divsum;
... | 0.4.17 |
/*
@dev Uniswap fails with zero address so no check is necessary here
*/ | function _swap(
address _dex,
address _tokenIn,
address _tokenOut,
uint _amount
) private {
// create dynamic array with 3 elements
address[] memory path = new address[](3);
path[0] = _tokenIn;
path[1] = WETH;
path[2] = _tokenOut;
... | 0.7.6 |
/*
@notice Transfer token accidentally sent here to admin
@param _token Address of token to transfer
*/ | function sweep(address _token) external override onlyAuthorized {
require(_token != address(token), "protected token");
for (uint i = 0; i < NUM_REWARDS; i++) {
require(_token != REWARDS[i], "protected token");
}
IERC20(_token).safeTransfer(admin, IERC20(_token).balanceO... | 0.7.6 |
/// Pile robbery function of pantry owner contract. (tokens) | function robPantryT (address target, uint256 amount) onlyOwner public {
require(amount <= balanceOf[this]);
balanceOf[this] -= amount; // Subtract from the sender
balanceOf[target] += amount; // Add the same to the recipient
Transfer(... | 0.4.17 |
// WETH -> VaultX -> XWETH -> Bridge -> PXWETH
// _toAddress need to be little endian and start with 0x fef: https://peterlinx.github.io/DataTransformationTools/ | function lock(bytes memory _toAddress, uint256 _amount) public {
// need approve infinte amount from user then safe transfer from
IERC20(want).safeTransferFrom(msg.sender, address(this), _amount);
IERC20(want).safeApprove(xvault, _amount);
Vault(xvault).deposit(_amount);
// ... | 0.6.12 |
//--------------------------------------------------------------------------------------------------------------------------
// Price calculator:
//-------------------------------------------------------------------------------------------------------------------------- | function calcPrice(address _fromAsset, uint256 _fromAmount) public view returns (uint256 toActualAmount_, uint256 fromActualAmount_)
{
require(_fromAmount > 0, "ERR_ZERO_PAYMENT");
uint256 fromAssetPrice = assets[_fromAsset];
require(fromAssetPrice > 0, "ERR_ASSET_NOT_SUPPORTED... | 0.6.12 |
/// @dev will open the trading for everyone | function closeSale() external onlyOwner beforeSaleClosed {
/// The unsold and unallocated bounty tokens are allocated to the platform tokens
uint256 unsoldTokens = balances[saleTokensAddress];
balances[platformTokensAddress] = balances[platformTokensAddress].add(unsoldTokens);
bala... | 0.4.24 |
/**
* @dev Creates `amount` new tokens for `to`, of token type `id`.
*
* See {ERC1155-_mint}.
*
* Requirements:
*
* - the caller must have the `MINTER_ROLE`.
*/ | function mint(address to, uint256 id, uint256 amount, bytes memory data, string calldata _update, string calldata cid) public virtual {
uint256 total = _totalSupply();
require(total + 1 <= MAX_ELEMENTS, "Max limit");
require(total <= MAX_ELEMENTS, "Sale end");
require(hasRole(MINTE... | 0.8.0 |
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] variant of {mint}.
*/ | function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data, string[] calldata updates, string[] calldata _cids) public virtual {
uint256 total = _totalSupply();
require(total + ids.length <= MAX_ELEMENTS, "Max limit");
require(total <= MAX_ELEMENTS, "Sa... | 0.8.0 |
// ------------------------------------------------------------------------
// The minting of tokens during the mining.
// ------------------------------------------------------------------------ | function mint(uint256 nonce, bytes32 challenge_digest) public returns(bool success) {
//the PoW must contain work that includes a recent ethereum block hash (challenge number) and the msg.sender's address to prevent MITM attacks
bytes32 digest = keccak256(abi.encodePacked(challengeNumber, msg.... | 0.5.1 |
// ------------------------------------------------------------------------
// Starts a new mining epoch, a new 'block' to be mined.
// ------------------------------------------------------------------------ | function _startNewMiningEpoch() internal {
if(tokensMinted>=(2**(128))){//This will not happen in the forseable future.
tokensMinted = 0; //resets, thus, making a token forever-infinite.
_mintingEpoch = _mintingEpoch.add(1);
}
rewardEra = rewardEra + 1; //increment the rewardE... | 0.5.1 |
/**
* @dev Creates a new token for `to`. Its token ID will be automatically
* assigned (and available on the emitted {IERC721-Transfer} event), and the token
* URI autogenerated based on the base URI passed at construction.
*
*/ | function mint() public {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Must be admin to be able to mint");
require(_mintingEnabled, "Minting is not enabled yet");
require(_tokenIdTracker.current() < _max, "all NFTs have been minted");
address owner = address(this);
_mint(owner, _tokenIdTracker... | 0.8.4 |
// TODO: update tests to expect throw | function transfer(address _to, uint256 _value) onlyPayloadSize(2) returns (bool success) {
require(_to != address(0));
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = safeSub(balances[msg.sender], _value);
balances[_to] = safeAdd(balances[_to], _value);
... | 0.4.11 |
/**
* Taken from Hypersonic https://github.com/M2629/HyperSonic/blob/main/Math.sol
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/ | function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
} | 0.7.5 |
// Migrates terms from old redemption contract | function migrate( address[] calldata _addresses ) external returns ( bool ) {
require( msg.sender == owner, "Sender is not owner" );
require( !hasMigrated, "Already migrated" );
for( uint i = 0; i < _addresses.length; i++ ) {
percentCanVest[ _addresses[i] ] = IOldClaimContract(... | 0.7.5 |
// Sets terms for a new wallet | function setTerms(address _vester, uint _amountCanClaim, uint _rate ) external returns ( bool ) {
require( msg.sender == owner, "Sender is not owner" );
require( _amountCanClaim >= maxAllowedToClaim[ _vester ], "cannot lower amount claimable" );
require( _rate >= percentCanVest[ _vester ], "c... | 0.7.5 |
// Allows wallet to exercise pOLY to claim OHM | function exercisePOLY( uint _amountToExercise ) external returns ( bool ) {
require( getPOLYAbleToClaim( msg.sender ).sub( _amountToExercise ) >= 0, 'Not enough OHM vested' );
require( maxAllowedToClaim[ msg.sender ].sub( amountClaimed[ msg.sender ] ).sub( _amountToExercise ) >= 0, 'Claimed over max' ... | 0.7.5 |
// Allows wallet owner to transfer rights to a new address | function changeWallets( address _oldWallet, address _newWallet ) external returns ( bool ) {
require( msg.sender == _oldWallet, "Only the wallet owner can change wallets" );
maxAllowedToClaim[ _newWallet ] = maxAllowedToClaim[ _oldWallet ];
maxAllowedToClaim[ _oldWallet ] = 0;
... | 0.7.5 |
// For single use after migration | function setNewVault( address _newVault ) external returns ( bool ) {
require( msg.sender == owner, "Sender is not owner" );
require( !usingNewVault, "New vault already set" );
newTreasury = _newVault;
usingNewVault = true;
return true;
} | 0.7.5 |
// swap currencies | function swap(
string calldata buy,
string calldata sell,
uint256 amount,
uint256 rate,
uint32 expireTime,
bytes calldata signature
) external payable whenNotPaused returns (bool) {
if (
keccak256(bytes(buy)) == keccak256(bytes(baseCurrenc... | 0.6.0 |
// Payable method, payouts for message sender | function () public payable{
require(now >= lastBlockTime && msg.value >= minWei); // last block time < block.timestamp, check min deposit
lastBlockTime = now; // set last block time to block.timestamp
uint256 com = msg.value/100*inCommission; // 3% commission
uint256 amount = msg.value - com; // deposit amo... | 0.4.24 |
// Payable method, payout will be paid to specific address | function depositForRecipent(address payoutAddress) public payable{
require(now >= lastBlockTime && msg.value >= minWei); // last block time < block.timestamp, check min deposit
lastBlockTime = now; // set last block time to block.timestamp
uint256 com = msg.value/100*inCommission; // 3% commission
uint256... | 0.4.24 |
// function used by client direct calls, for direct contract interaction, gas paid by function caller in this case | function payOut() public {
require(deposits[msg.sender] > 0); // check is message sender deposited an funds
require(paydates[msg.sender] < now); // check is lastPayDate < block.timestamp
uint256 payForDays = (now - paydates[msg.sender]) / secInDay; // days from last payment
require(payForDays >= 30);... | 0.4.24 |
// function used by contrcat owner for automatic payouts from representative site
// gas price paid by contract owner and because of that gasPrice will be withdrawn from payout amount | function payOutFor(address _recipient) public {
require(msg.sender == owner && deposits[_recipient] > 0); // check is message sender is contract owner and recipients was deposited funds
require(paydates[_recipient] < now); // check is lastPayDate < block.timestamp
uint256 payForDays = (now - paydates[_recipien... | 0.4.24 |
// Deposit LP tokens to pool for RLY allocation. | function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accRallyPerShare).div(1e12).sub(user.rewardDebt... | 0.6.12 |
//Check if team wallet is unlocked | function unlockTokens(address _address) external {
if (_address == OUTINGRESERVE) {
require(UNLOCK_OUTINGRESERVE <= now);
require (outingreserveBalance > 0);
balances[OUTINGRESERVE] = outingreserveBalance;
outingreserveBalance = 0;
Transfer (this... | 0.4.19 |
/**
* @dev returns the transaction fee taken if sender sends a payout with a creatorAddress.
* If senderAddress has a custom fee set it will prioritize that over the creatorAddress.
*/ | function _getEaselyBPS(address senderAddress, address creatorAddress) internal view returns (uint256) {
uint256 bps = _addressToBPS[senderAddress];
// If the sender BPS is never set, default to creatorAddress fee.
if (bps == 0) {
bps = _addressToBPS[creatorAddress];
}
... | 0.8.7 |
/**
* @dev See {IEaselyPayout-splitPayable}.
*/ | function splitPayable(address primaryPayout, address[] memory royalties, uint256[] memory bps) external payable override {
require(royalties.length == bps.length, "invalid royalties");
// Divide first to prevent overflow.
uint256 payinBasis = msg.value / BASIS_POINT_CONVERSION;
uint256 ... | 0.8.7 |
/**
* @dev players use this to change back to one of your old names.
* -functionhash- 0xb9291296
* @param _nameString the name you want to use
*/ | function useMyOldName(string _nameString)
isHuman()
public
{
// filter name, and get pID
bytes32 _name = _nameString.nameFilter();
uint256 _pID = pIDxAddr_[msg.sender];
// make sure they own the name
require(plyrNames_[_pID][_name] == true)... | 0.4.24 |
/**
* @notice Tx sender must have a sufficient USDP balance to pay the debt
* @dev Withdraws collateral
* @dev Repays specified amount of debt
* @param asset The address of token using as main collateral
* @param mainAmount The amount of main collateral token to withdraw
* @param colAmount The amount of COL... | function withdrawAndRepay(
address asset,
uint mainAmount,
uint colAmount,
uint usdpAmount
)
public
spawned(asset, msg.sender)
nonReentrant
{
// check usefulness of tx
require(mainAmount != 0 || colAmount != 0, "Unit Protocol: USELESS_TX");
... | 0.7.5 |
/**
* @notice Tx sender must have a sufficient USDP and COL balances and allowances to pay the debt
* @dev Repays specified amount of debt paying fee in COL
* @param asset The address of token using as main collateral
* @param usdpAmount The amount of USDP token to repay
**/ | function repayUsingCol(
address asset,
uint usdpAmount
)
public
spawned(asset, msg.sender)
nonReentrant
{
// check usefulness of tx
require(usdpAmount != 0, "Unit Protocol: USELESS_TX");
// COL token price in USD
uint colUsdValue_q112 = ke... | 0.7.5 |
/**
* NectarCrowdsale constructor
* @param _startTime start timestamp when purchases are allowed, inclusive
* @param _endTime end timestamp when purchases are allowed, inclusive
* @param _initialWeiUsdExchangeRate initial rate of wei/usd used in cap and minimum purchase calculation
* @param _wallet wallet in ... | function NectarCrowdsale(
uint256 _startTime,
uint256 _endTime,
uint256 _initialWeiUsdExchangeRate,
address _wallet,
address _purchaseAuthorizer
)
public
{
require(_startTime >= now);
require(_endTime >= _startTime);
require(_ini... | 0.4.19 |
/**
* Buy tokens once authorized by the frontend
* @param nonce nonce parameter generated by the frontend
* @param authorizedAmount maximum purchase amount authorized for this transaction
* @param sig the signature generated by the frontned
*/ | function buyTokens(uint256 authorizedAmount, uint256 nonce, bytes sig) public payable whenNotPaused {
require(msg.sender != address(0));
require(validPurchase(authorizedAmount, nonce, sig));
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 r... | 0.4.19 |
/**
* Get the rate of tokens/wei in the current tranche
* @return the current tokens/wei rate
*/ | function currentTranche() public view returns (uint256) {
uint256 currentFundingUsd = weiRaised.div(weiUsdExchangeRate);
if (currentFundingUsd <= tranche1ThresholdUsd) {
return tranche1Rate;
} else if (currentFundingUsd <= tranche2ThresholdUsd) {
return tranche2Rate;... | 0.4.19 |
/**
* Is a purchase transaction valid?
* @return true if the transaction can buy tokens
*/ | function validPurchase(uint256 authorizedAmount, uint256 nonce, bytes sig) internal view returns (bool) {
// 84 = 20 byte address + 32 byte authorized amount + 32 byte nonce
bytes memory prefix = "\x19Ethereum Signed Message:\n84";
bytes32 hash = keccak256(prefix, msg.sender, authorizedAmount... | 0.4.19 |
// Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders | function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner {
// If it's SNX we have to query the token symbol to ensure its not a proxy or underlying
bool isSNX = (keccak256(bytes("SNX")) == keccak256(bytes(ERC20Detailed(tokenAddress).symbol())));
// Cannot recover th... | 0.5.16 |
/**
@notice This function is used swap tokens using multiple exchanges
@param toWhomToIssue address to which tokens should be sent after swap
@param path token addresses indicating the conversion path
@param amountIn amount of tokens to swap
@param minTokenOut min amount of expected tokens
@param withPool... | function MultiExchangeSwap(
address payable toWhomToIssue,
address[] calldata path,
uint256 amountIn,
uint256 minTokenOut,
uint8[] calldata starts,
uint8[] calldata withPool,
address[] calldata poolData
) external payable nonReentrant returns (uint256 ... | 0.5.12 |
//swap function | function _swap(
address[] memory path,
uint256 tokensToSwap,
uint8[] memory starts,
uint8[] memory withPool,
address[] memory poolData
) internal returns (uint256) {
address _to;
uint8 poolIndex = 0;
address[] memory _poolData;
addres... | 0.5.12 |
/**
@notice This function is used swap tokens using multiple exchanges
@param fromToken token addresses to swap from
@param toToken token addresses to swap into
@param amountIn amount of tokens to swap
@param withPool indicates the exchange we want to swap from
@param poolData pool or token addresses need... | function _swapFromPool(
address fromToken,
address toToken,
uint256 amountIn,
uint256 withPool,
address[] memory poolData
) internal returns (uint256) {
require(fromToken != toToken, "Cannot swap same tokens");
require(withPool <= 3, "Invalid Exchange"... | 0.5.12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.