comment stringlengths 11 2.99k | function_code stringlengths 165 3.15k | version stringclasses 80
values |
|---|---|---|
/// Migrates the rewards balance to a new FeesAndBootstrap contract
/// @dev The new rewards contract is determined according to the contracts registry
/// @dev No impact of the calling contract if the currently configured contract in the registry
/// @dev may be called also while the contract is locked
/// @param guar... | function migrateRewardsBalance(address[] calldata guardians) external override {
require(!settings.rewardAllocationActive, "Reward distribution must be deactivated for migration");
IFeesAndBootstrapRewards currentRewardsContract = IFeesAndBootstrapRewards(getFeesAndBootstrapRewardsContract());
... | 0.6.12 |
/// Accepts guardian's balance migration from a previous rewards contract
/// @dev the function may be called by any caller that approves the amounts provided for transfer
/// @param guardians is the list of migrated guardians
/// @param fees is the list of received guardian fees balance
/// @param totalFees is the tot... | function acceptRewardsBalanceMigration(address[] memory guardians, uint256[] memory fees, uint256 totalFees, uint256[] memory bootstrap, uint256 totalBootstrap) external override {
uint256 _totalFees = 0;
uint256 _totalBootstrap = 0;
for (uint i = 0; i < guardians.length; i++) {
... | 0.6.12 |
/// Returns the current global Fees and Bootstrap rewards state
/// @dev receives the relevant committee and general state data
/// @param generalCommitteeSize is the current number of members in the certified committee
/// @param certifiedCommitteeSize is the current number of members in the general committee
/// @pa... | function _getFeesAndBootstrapState(uint generalCommitteeSize, uint certifiedCommitteeSize, uint256 collectedGeneralFees, uint256 collectedCertifiedFees, uint256 currentTime, Settings memory _settings) private view returns (FeesAndBootstrapState memory _feesAndBootstrapState, uint256 allocatedGeneralBootstrap, uint256 a... | 0.6.12 |
/// Updates the global Fees and Bootstrap rewards state
/// @dev utilizes _getFeesAndBootstrapState to calculate the global state
/// @param generalCommitteeSize is the current number of members in the certified committee
/// @param certifiedCommitteeSize is the current number of members in the general committee
/// @... | function _updateFeesAndBootstrapState(uint generalCommitteeSize, uint certifiedCommitteeSize) private returns (FeesAndBootstrapState memory _feesAndBootstrapState) {
Settings memory _settings = settings;
if (!_settings.rewardAllocationActive) {
return feesAndBootstrapState;
}
... | 0.6.12 |
/// Returns the current guardian Fees and Bootstrap rewards state
/// @dev receives the relevant guardian committee membership data and the global state
/// @param guardian is the guardian to query
/// @param inCommittee indicates whether the guardian is currently in the committee
/// @param isCertified indicates whet... | function _getGuardianFeesAndBootstrap(address guardian, bool inCommittee, bool isCertified, bool nextCertification, FeesAndBootstrapState memory _feesAndBootstrapState) private view returns (FeesAndBootstrap memory guardianFeesAndBootstrap, uint256 addedBootstrapAmount, uint256 addedFeesAmount) {
guardianFeesA... | 0.6.12 |
/// Updates a guardian Fees and Bootstrap rewards state
/// @dev receives the relevant guardian committee membership data
/// @dev updates the global Fees and Bootstrap state prior to calculating the guardian's
/// @dev utilizes _getGuardianFeesAndBootstrap
/// @param guardian is the guardian to update
/// @param inCom... | function _updateGuardianFeesAndBootstrap(address guardian, bool inCommittee, bool isCertified, bool nextCertification, uint generalCommitteeSize, uint certifiedCommitteeSize) private {
uint256 addedBootstrapAmount;
uint256 addedFeesAmount;
FeesAndBootstrapState memory _feesAndBootstrapState... | 0.6.12 |
/// Returns the guardian Fees and Bootstrap rewards state for a given time
/// @dev if the time to estimate is in the future, estimates the fees and rewards for the given time
/// @dev for future time estimation assumes no change in the guardian committee membership and certification
/// @param guardian is the guardian... | function getGuardianFeesAndBootstrap(address guardian, uint256 currentTime) private view returns (FeesAndBootstrap memory guardianFeesAndBootstrap, bool certified) {
ICommittee _committeeContract = committeeContract;
(uint generalCommitteeSize, uint certifiedCommitteeSize, ) = _committeeContract.getCo... | 0.6.12 |
/*
Vivamus egestas neque eget ultrices hendrerit.
Donec elementum odio nec ex malesuada cursus.
Curabitur condimentum ante id ipsum porta ullamcorper.
Vivamus ut est elementum, interdum eros vitae, laoreet neque.
Pellentesque elementum risus tincidunt erat viverra hendrerit.
Donec nec velit ut lectus fringi... | function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_t... | 0.6.6 |
// Constructor function - init core params on deploy | function SwarmVotingMVP(uint256 _startTime, uint256 _endTime, bytes32 _encPK, bool enableTesting) public {
owner = msg.sender;
startTime = _startTime;
endTime = _endTime;
ballotEncryptionPubkey = _encPK;
bannedAddresses[swarmFundAddress] = true;
if (enableTest... | 0.4.18 |
// airdrop NFT | function airdropNFTFixed(address[] calldata _address, uint256 num)
external
onlyOwner
{
require(
(_address.length * num) <= 1000,
"Maximum 1000 tokens per transaction"
);
require(
totalSupply() + (_address.length * num) <= MAX_SUPPLY,
... | 0.8.4 |
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/ | function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
// We read and store the key's index to prevent multiple reads from the same storage slot
uint256 keyIndex = map._indexes[key];
if (keyIndex == 0) { // Equivalent to !contains(map, key)
map._ent... | 0.7.3 |
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/ | function _get(Map storage map, bytes32 key) private view returns (bytes32) {
uint256 keyIndex = map._indexes[key];
require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key)
return map._entries[keyIndex - 1]._value; // All indexes are 1-based
} | 0.7.3 |
/**
* @dev Same as {_get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {_tryGet}.
*/ | function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
uint256 keyIndex = map._indexes[key];
require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
return map._entries[keyIndex - 1]._value; // All indexes are 1-based
} | 0.7.3 |
// Deposit token on stake contract for WETH 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.accWETHPerShare).div(1e12).sub(user.reward... | 0.6.12 |
// ONLY TEST TOKENS MINT | function testTokensSupply_beta(address _address, uint256 _amount, uint256 _currencyId) public onlyOwner {
if(_currencyId==0)
{
xweth.mint(_address, _amount);
}
if(_currencyId==1)
{
cxeth.mint(_address, _amount);
}
if(_currencyI... | 0.6.12 |
// ONLY TEST TOKENS BURN | function testTokensBurn_beta(address _address, uint256 _amount, uint256 _currencyId) public onlyOwner {
if(_currencyId==0)
{
xweth.burn(_address, _amount);
}
if(_currencyId==1)
{
cxeth.burn(_address, _amount);
}
if(_currencyId=... | 0.6.12 |
// Create a function to mint/create the NFT | function mintCuriousAxolotl(uint numberOfTokens) public payable {
require(saleIsActive, "Sale must be active to mint Axolotl");
require(numberOfTokens > 0 && numberOfTokens <= maxAxolotlPurchase, "Can only mint 20 tokens at a time");
require(totalSupply().add(numberOfTokens) <= MAX_AXOLOTL, "... | 0.7.3 |
// GET ALL AXOLOTL OF A WALLET AS AN ARRAY OF STRINGS. | function axolotlNamesOfOwner(address _owner) external view returns(string[] memory ) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new string[](0);
} else {
string[] memory result = new string[](tokenCou... | 0.7.3 |
/**
* @notice Claim random reward
* @param _tokenId - msg.sender's nft id
*/ | function claim(uint256 _tokenId) external virtual {
require(
claimed[_tokenId] == 0,
"claim: reward has already been received"
);
require(
_tokenId >= tokenIdFrom && _tokenId <= tokenIdTo,
"claim: tokenId out of range"
);
address s... | 0.8.6 |
// override | function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes memory _data) public {
require(_to != address(0x0), "ERC1155: cannot send to zero address");
require(_from == msg.sender || operatorApproval[_from][msg.sender] == true, "ERC1155: need operator approval for 3rd party... | 0.5.8 |
/**
* @dev Returns true if `account` is a contract.
*
* This test is non-exhaustive, and there may be false-negatives: during the
* execution of a contract's constructor, its address will be reported as
* not containing a contract.
*
* > It is unsafe to assume that an address for which this function retur... | function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line ... | 0.5.10 |
/**
* @return return the balance of multiple tokens for certain `user`
*/ | function getBalances(
address user,
address[] memory token
)
public
view
returns(uint256[] memory balanceArray)
{
balanceArray = new uint256[](token.length);
for(uint256 index = 0; index < token.length; index++) {
balanceArray[index... | 0.5.10 |
/**
* @return return the filled amount of multple orders specified by `orderHash` array
*/ | function getFills(
bytes32[] memory orderHash
)
public
view
returns (uint256[] memory filledArray)
{
filledArray = new uint256[](orderHash.length);
for(uint256 index = 0; index < orderHash.length; index++) {
filledArray[index] = filled[order... | 0.5.10 |
/**
* @dev Transfer token when proxy contract transfer is called
* @param _from address representing the previous owner of the given token ID
* @param _to address representing the new owner of the given token ID
* @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address
* @pa... | function proxyTransfer721(address _from, address _to, uint256 _tokenId, bytes calldata _data) external {
uint256 nftType = getNFTType(_tokenId);
ERC721 proxy = proxy721[nftType];
require(msg.sender == address(proxy), "ERC1155-ERC721: caller is not token contract");
require(_ownerOf(_tok... | 0.5.8 |
/**
* @dev Compute the status of an order.
* Should be called before a contract execution is performet in order to not waste gas.
* @return OrderStatus.FILLABLE if the order is valid for taking.
* Note: See LibOrder.sol to see all statuses
*/ | function getOrderInfo(
uint256 partialAmount,
Order memory order
)
public
view
returns (OrderInfo memory orderInfo)
{
// Compute the order hash
orderInfo.hash = getPrefixedHash(order);
// Fetch filled amount
orderInfo.filledAmo... | 0.5.10 |
/**
* @dev Execute a trade based on the input order and signature.
* If the order is valid returns true.
*/ | function _trade(
Order memory order,
bytes memory signature
)
internal
returns(bool)
{
order.taker = msg.sender;
uint256 takerReceivedAmount = getPartialAmount(
order.makerSellAmount,
order.makerBuyAmount,
order.tak... | 0.5.10 |
/**
* @dev Cancel an order if msg.sender is the order signer.
*/ | function cancelSingleOrder(
Order memory order,
bytes memory signature
)
public
{
bytes32 orderHash = getPrefixedHash(order);
require(
recover(orderHash, signature) == msg.sender,
"INVALID_SIGNER"
);
require(
... | 0.5.10 |
/**
* @dev Computation of the following properties based on the order input:
* takerFillAmount -> amount of assets received by the taker
* makerFillAmount -> amount of assets received by the maker
* takerFeePaid -> amount of fee paid by the taker (0.2% of takerFillAmount)
* makerFeeReceived -> amount of fee r... | function getOrderFillResult(
uint256 takerReceivedAmount,
Order memory order
)
internal
view
returns (OrderFill memory orderFill)
{
orderFill.takerFillAmount = takerReceivedAmount;
orderFill.makerFillAmount = order.takerSellAmount;
//... | 0.5.10 |
/**
* @dev Throws when the order status is invalid or the signer is not valid.
*/ | function assertTakeOrder(
bytes32 orderHash,
uint8 status,
address signer,
bytes memory signature
)
internal
pure
returns(uint8)
{
uint8 result = uint8(OrderStatus.FILLABLE);
if(recover(orderHash, signature) != signer) {
... | 0.5.10 |
/**
* @dev Updates the contract state i.e. user balances
*/ | function executeTrade(
Order memory order,
OrderFill memory orderFill
)
private
{
uint256 makerGiveAmount = orderFill.takerFillAmount.sub(orderFill.makerFeeReceived);
uint256 takerFillAmount = orderFill.takerFillAmount.sub(orderFill.takerFeePaid);
addres... | 0.5.10 |
/**
* @dev Swaps ETH/TOKEN, TOKEN/ETH or TOKEN/TOKEN using KyberNetwork reserves.
*/ | function kyberSwap(
uint256 givenAmount,
address givenToken,
address receivedToken,
bytes32 hash
)
public
payable
{
address taker = msg.sender;
KyberData memory kyberData = getSwapInfo(
givenAmount,
givenToken,... | 0.5.10 |
/**
* @dev Exchange ETH/TOKEN, TOKEN/ETH or TOKEN/TOKEN using the internal
* balance mapping that keeps track of user's balances. It requires user to first invoke deposit function.
* The function relies on KyberNetworkProxy contract.
*/ | function kyberTrade(
uint256 givenAmount,
address givenToken,
address receivedToken,
bytes32 hash
)
public
{
address taker = msg.sender;
KyberData memory kyberData = getTradeInfo(
givenAmount,
givenToken,
r... | 0.5.10 |
/**
* @dev Helper function to determine what is being swapped.
*/ | function getSwapInfo(
uint256 givenAmount,
address givenToken,
address receivedToken,
address taker
)
private
returns(KyberData memory)
{
KyberData memory kyberData;
uint256 givenTokenDecimals;
uint256 receivedTokenDecimals;
... | 0.5.10 |
/**
* @dev Helper function to determines what is being
swapped using the internal balance mapping.
*/ | function getTradeInfo(
uint256 givenAmount,
address givenToken,
address receivedToken
)
private
returns(KyberData memory)
{
KyberData memory kyberData;
uint256 givenTokenDecimals;
uint256 receivedTokenDecimals;
if(givenToken ==... | 0.5.10 |
/**
* @dev Updates the level 2 map `balances` based on the input
* Note: token address is (0x0) when the deposit is for ETH
*/ | function deposit(
address token,
uint256 amount,
address beneficiary,
address referral
)
public
payable
{
uint256 value = amount;
address user = msg.sender;
if(token == address(0x0)) {
value = msg.value;
}... | 0.5.10 |
//owner reserves the right to change the price | function setMaxSupplyPerID(
uint256 id,
uint256 newMaxSupplyPresale,
uint256 newMaxSupply
) external onlyOwner {
if (id == 1) {
require(newMaxSupply < 1010, "no more than 1010");
require(newMaxSupplyPresale < 1010, "no more than 1010");
}
maxSuppliesPresale[id] = newMaxSupplyPresale;
maxSupplies[id... | 0.8.13 |
/**
* @dev Transfer assets between two users inside the exchange. Updates the level 2 map `balances`
*/ | function transfer(
address token,
address to,
uint256 amount
)
external
payable
{
address user = msg.sender;
require(
balances[token][user] >= amount,
"INVALID_TRANSFER"
);
balances[token][user] = ba... | 0.5.10 |
/**
* @dev Helper function to migrate user's tokens. Should be called in migrateFunds() function.
*/ | function migrateTokens(address[] memory tokens) private {
address user = msg.sender;
address exchange = newExchange;
for (uint256 index = 0; index < tokens.length; index++) {
address tokenAddress = tokens[index];
uint256 tokenAmount = balances[tokenAddress][user]... | 0.5.10 |
/**
* @dev Helper function to migrate user's Ethers. Should be called only from the new exchange contract.
*/ | function importEthers(address user)
external
payable
{
require(
false != migrationAllowed,
"MIGRATION_DISALLOWED"
);
require(
user != address(0x0),
"INVALID_USER"
);
require(
msg.valu... | 0.5.10 |
/// For creating Movie | function _createMovie(string _name, address _owner, uint256 _price) private {
Movie memory _movie = Movie({
name: _name
});
uint256 newMovieId = movies.push(_movie) - 1;
// It's probably never going to happen, 4 billion tokens are A LOT, but
// let's just be 100% sure we never let this... | 0.4.20 |
/**
* @dev Swaps ETH/TOKEN, TOKEN/ETH or TOKEN/TOKEN using off-chain signed messages.
* The flow of the function is Deposit -> Trade -> Withdraw to allow users to directly
* take liquidity without the need of deposit and withdraw.
*/ | function swapFill(
Order[] memory orders,
bytes[] memory signatures,
uint256 givenAmount,
address givenToken,
address receivedToken,
address referral
)
public
payable
{
address taker = msg.sender;
uint256 balanceGivenB... | 0.5.10 |
/// @dev Assigns ownership of a specific Movie to an address. | function _transfer(address _from, address _to, uint256 _tokenId) private {
// Since the number of movies is capped to 2^32 we can't overflow this
ownershipTokenCount[_to]++;
// transfer ownership
movieIndexToOwner[_tokenId] = _to;
// When creating new movies _from is 0x0, but we can't account... | 0.4.20 |
/**
* Split Signature
*
* Validation utility
*/ | function _splitSignature(bytes memory sig) private pure returns (bytes32 r, bytes32 s, uint8 v) {
require(sig.length == 65, "Invalid signature length.");
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
v := byte(0, mload(add(sig, 96)))
}
} | 0.8.7 |
/**
* Verify
*
* Validation utility.
*/ | function _verify(
address _to,
string memory _key,
bytes memory _proof
) private view returns (bool) {
bytes32 msgHash = _getMessageHash(_to, _key);
bytes32 signedMsgHash = _signedMsgHash(msgHash);
return _recoverSigner(signedMsgHash, _proof) == _verificationSigner;
} | 0.8.7 |
/**
* Mint whitelisted
*
* Waives the mintFee if the received is whitelisted.
*/ | function mintWhitelisted(address _receiver, uint _amount, bytes memory _proof) public payable returns (uint[] memory) {
require(_verify(msg.sender, _KEY, _proof), "Unauthorized.");
require(_amount <= _MINTABLE_PER_TX, "Exceeds mintable per tx limit.");
require(_mintedWhitelist[_receiver] + _amount <= _white... | 0.8.7 |
/**
* Mint a token to an address.
*
* Requires payment of _mintFee.
*/ | function mintTo(address _receiver, uint _amount) public payable returns (uint[] memory) {
require(block.timestamp >= _launchTimestamp, "Project hasn't launched.");
require(msg.value >= _mintFee * _amount, "Requires minimum fee.");
require(_amount <= _MINTABLE_PER_TX, "Exceeds mintable per tx limit.");
... | 0.8.7 |
/**
* Admin function: Remove funds.
*
* Removes the distribution of funds out of the smart contract.
*/ | function removeFunds() external onlyOwner {
uint256 funds = address(this).balance;
uint256 aShare = funds * 33 / 100;
(bool success1, ) = 0xB24dC90a223Bb190cD28594a1fE65029d4aF5b42.call{
value: aShare
}("");
uint256 bShare = funds * 33 / 100;
(bool success2, ) = 0x1589a76943f74241320a002C... | 0.8.7 |
/**
* @dev helper to redeem rewards for a proposal
* It calls execute on the proposal if it is not yet executed.
* It tries to redeem reputation and stake from the GenesisProtocol.
* It tries to redeem proposal rewards from the contribution rewards scheme.
* This function does not emit events.
* A client should l... | function redeem(bytes32 _proposalId, Avatar _avatar, address _beneficiary)
external
returns(uint[3] memory gpRewards,
uint[2] memory gpDaoBountyReward,
bool executed,
uint256 winningVote,
int256 crReputationReward,
uint256 crNativeTokenReward,
... | 0.5.4 |
// View function to see pending ROSEs on frontend. | function pendingRose1(uint256 _pid, address _user)
public
view
returns (uint256)
{
PoolInfo1 storage pool = poolInfo1[_pid];
UserInfo storage user = userInfo1[_pid][_user];
uint256 accRosePerShare = pool.accRosePerShare;
uint256 lpSupply = pool.totalAm... | 0.6.12 |
// Deposit LP tokens to RoseMain for ROSE allocation. | function deposit1(uint256 _pid, uint256 _amount) public {
PoolInfo1 storage pool = poolInfo1[_pid];
UserInfo storage user = userInfo1[_pid][msg.sender];
updatePool1(_pid);
if (user.amount > 0) {
uint256 pending = user.amount
.mul(pool.accRosePerShare)
... | 0.6.12 |
// Deposit LP tokens to MrBanker for BOOB allocation. | function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (block.number < startBlock) {
user.earlyRewardMultiplier = 110;
} else {
user.e... | 0.6.12 |
// Withdraw LP tokens from MrBanker. | function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accSushiPerSh... | 0.6.12 |
// Withdraw LP tokens from RoseMain. | function withdraw1(uint256 _pid, uint256 _amount) public {
PoolInfo1 storage pool = poolInfo1[_pid];
UserInfo storage user = userInfo1[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool1(_pid);
uint256 pending = user.amount.mul(pool.accRoseP... | 0.6.12 |
// Fill _user in as referrer. | function refer(address _user) external {
require(_user != msg.sender && referrers[_user] != address(0));
// No modification.
require(referrers[msg.sender] == address(0));
referrers[msg.sender] = _user;
// Record two levels of refer relationship。
referreds1[_user].pu... | 0.6.12 |
// Query the first referred user. | function getReferreds1(address addr, uint256 startPos)
external
view
returns (uint256 length, address[] memory data)
{
address[] memory referreds = referreds1[addr];
length = referreds.length;
data = new address[](length);
for (uint256 i = 0; i < 5 && ... | 0.6.12 |
/**
* @dev fallback function to send ether to for Crowd sale
**/ | function () public payable {
require(currentStage == Stages.icoStart);
require(msg.value > 0);
require(remainingTokens > 0);
uint256 weiAmount = msg.value; // Calculate tokens to sell
uint256 tokens = weiAmount.mul(basePrice).div(1 ether);
uint25... | 0.4.24 |
/**
* @dev endIco closes down the ICO
**/ | function endIco() internal {
currentStage = Stages.icoEnd;
// Transfer any remaining tokens
if(remainingTokens > 0)
balances[owner] = balances[owner].add(remainingTokens);
// transfer any remaining ETH balance in the contract to the owner
owner.transfer(address(... | 0.4.24 |
// Query the second referred user. | function getReferreds2(address addr, uint256 startPos)
external
view
returns (uint256 length, address[] memory data)
{
address[] memory referreds = referreds2[addr];
length = referreds.length;
data = new address[](length);
for (uint256 i = 0; i < 5 && ... | 0.6.12 |
// Query user all rewards | function allPendingRose(address _user)
external
view
returns (uint256 pending)
{
for (uint256 i = 0; i < poolInfo1.length; i++) {
pending = pending.add(pendingRose1(i, _user));
}
for (uint256 i = 0; i < poolInfo2.length; i++) {
pending... | 0.6.12 |
// Mint for referrers. | function mintReferralReward(uint256 _amount) internal {
address referrer = referrers[msg.sender];
// no referrer.
if (address(0) == referrer) {
return;
}
// mint for user and the first level referrer.
rose.mint(msg.sender, _amount.div(100));
ro... | 0.6.12 |
// Update the locked amount that meet the conditions | function updateLockedAmount(PoolInfo2 storage pool) internal {
uint256 passedBlock = block.number - pool.lastUnlockedBlock;
if (passedBlock >= pool.unlockIntervalBlock) {
// case 2 and more than 2 period have passed.
pool.lastUnlockedBlock = pool.lastUnlockedBlock.add(
... | 0.6.12 |
// Allocate tokens to the users
// @param _owners The owners list of the token
// @param _values The value list of the token | function allocateTokens(address[] _owners, uint256[] _values) public onlyOwner {
require(_owners.length == _values.length, "data length mismatch");
address from = msg.sender;
for(uint256 i = 0; i < _owners.length ; i++){
address to = _owners[i];
uint256 value = _... | 0.4.24 |
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/ | function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a / b + (a % b == 0 ? 0 : 1);
} | 0.8.7 |
/**
* @notice retrieve price for multiple NFTs
*
* @param amount the amount of NFTs to get price for
*/ | function getPrice(uint256 amount) public view returns (uint256){
uint256 supply = totalSupply(ARTWORK) - _reserved;
uint totalCost = 0;
for (uint i = 0; i < amount; i++) {
totalCost += getCurrentPriceAtPosition(supply + i);
}
return totalCost;
} | 0.8.7 |
/**
* @notice global mint function used in early access and public sale
*
* @param amount the amount of tokens to mint
*/ | function mint(uint256 amount) private {
require(amount > 0, "Need to request at least 1 NFT");
require(totalSupply(ARTWORK) + amount <= _maxSupply, "Exceeds maximum supply");
require(msg.value >= getPrice(amount), "Not enough ETH sent, check price");
purchaseTxs[msg.sender] += amou... | 0.8.7 |
// Using feeAmount to buy back ROSE and share every holder. | function convert(uint256 _pid) external {
PoolInfo2 storage pool = poolInfo2[_pid];
uint256 lpSupply = pool.freeAmount.add(pool.lockedAmount);
if (address(sfr2rose) != address(0) && pool.feeAmount > 0) {
uint256 amountOut = swapSFRForROSE(pool.feeAmount);
if (amountO... | 0.6.12 |
/// @param _reserve underlying token address | function getReserveData(address _reserve)
external virtual
view
returns (
uint256 totalLiquidity, // reserve total liquidity
uint256 availableLiquidity, // reserve available liquidity for borrowing
uint256 totalBorrowsStable, ... | 0.6.12 |
/// @param _user users address | function getUserAccountData(address _user)
external virtual
view
returns (
uint256 totalLiquidityETH, // user aggregated deposits across all the reserves. In Wei
uint256 totalCollateralETH, // user aggregated collateral across all the reserves. In Wei... | 0.6.12 |
/// @param _reserve underlying token address
/// @param _user users address | function getUserReserveData(address _reserve, address _user)
external virtual
view
returns (
uint256 currentATokenBalance, // user current reserve aToken balance
uint256 currentBorrowBalance, // user current reserve outstanding borrow balance
u... | 0.6.12 |
/// @dev mint up to `punks` tokens | function mint(uint256 punks) public payable {
_enforceNotPaused();
_enforceSale();
uint256 ts = totalSupply();
uint256 sl = MAX_WP_SUPPLY;
require(ts < MAX_WP_SUPPLY, "WantedPunksSoldOut");
require(punks > 0, "ZeroWantedPunksRequested");
require(punks <= WP_PACK_L... | 0.8.7 |
//
// Point writing
//
// activatePoint(): activate a point, register it as spawned by its prefix
// | function activatePoint(uint32 _point)
onlyOwner
external
{
// make a point active, setting its sponsor to its prefix
//
Point storage point = points[_point];
require(!point.active);
point.active = true;
registerSponsor(_point, true, getPrefix(_point));
... | 0.4.24 |
// setKeys(): set network public keys of _point to _encryptionKey and
// _authenticationKey, with the specified _cryptoSuiteVersion
// | function setKeys(uint32 _point,
bytes32 _encryptionKey,
bytes32 _authenticationKey,
uint32 _cryptoSuiteVersion)
onlyOwner
external
{
Point storage point = points[_point];
if ( point.encryptionKey == _encryptionKey &&
... | 0.4.24 |
// registerSpawn(): add a point to its prefix's list of spawned points
// | function registerSpawned(uint32 _point)
onlyOwner
external
{
// if a point is its own prefix (a galaxy) then don't register it
//
uint32 prefix = getPrefix(_point);
if (prefix == _point)
{
return;
}
// register a new spawned point for the ... | 0.4.24 |
// canManage(): true if _who is the owner or manager of _point
// | function canManage(uint32 _point, address _who)
view
external
returns (bool result)
{
Deed storage deed = rights[_point];
return ( (0x0 != _who) &&
( (_who == deed.owner) ||
(_who == deed.managementProxy) ) );
} | 0.4.24 |
// canSpawnAs(): true if _who is the owner or spawn proxy of _point
// | function canSpawnAs(uint32 _point, address _who)
view
external
returns (bool result)
{
Deed storage deed = rights[_point];
return ( (0x0 != _who) &&
( (_who == deed.owner) ||
(_who == deed.spawnProxy) ) );
} | 0.4.24 |
/// @dev buy function allows to buy ether. for using optional data | function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;... | 0.4.18 |
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit) | function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000... | 0.4.18 |
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status | function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_... | 0.4.18 |
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account h... | function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount... | 0.4.18 |
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations. | function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
... | 0.4.18 |
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner. | function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
... | 0.4.18 |
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner. | function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
... | 0.4.18 |
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status. | function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
r... | 0.4.18 |
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID. | function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: val... | 0.4.18 |
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses. | function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations... | 0.4.18 |
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs. | function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
... | 0.4.18 |
/// @notice Takes a feePercentage and sends it to wallet
/// @param _amount Dai amount of the whole trade
/// @param _user Address of the user
/// @param _token Address of the token
/// @param _dfsFeeDivider Dfs fee divider
/// @return feeAmount Amount in Dai owner earned on the fee | function getFee(uint256 _amount, address _user, address _token, uint256 _dfsFeeDivider) internal returns (uint256 feeAmount) {
if (_dfsFeeDivider != 0 && Discount(DISCOUNT_ADDRESS).isCustomFeeSet(_user)) {
_dfsFeeDivider = Discount(DISCOUNT_ADDRESS).getCustomServiceFee(_user);
}
if ... | 0.6.12 |
// addClaim(): register a claim as _point
// | function addClaim(uint32 _point,
string _protocol,
string _claim,
bytes _dossier)
external
activePointManager(_point)
{
// cur: index + 1 of the claim if it already exists, 0 otherwise
//
uint8 cur = findClaim(_point, _protocol,... | 0.4.24 |
// removeClaim(): unregister a claim as _point
// | function removeClaim(uint32 _point, string _protocol, string _claim)
external
activePointManager(_point)
{
// i: current index + 1 in _point's list of claims
//
uint256 i = findClaim(_point, _protocol, _claim);
// we store index + 1, because 0 is the eth default value
// can o... | 0.4.24 |
/**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_fr... | 0.4.24 |
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/ | function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721) {
super._beforeTokenTransfer(from, to, tokenId);
Molecule memory mol = allMolecules[tokenId];
require(mol.bonded == false,"Molecule is bonded!");
... | 0.8.7 |
// upgrade contract to allow OXG Nodes to | function bondMolecule(address account,uint256 _tokenId, uint256 nodeCreationTime) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == account, "not owner");
Molecule memory mol = allMolecules[_tokenId]... | 0.8.7 |
// ownerOf(): get the current owner of point _tokenId
// | function ownerOf(uint256 _tokenId)
public
view
validPointId(_tokenId)
returns (address owner)
{
uint32 id = uint32(_tokenId);
// this will throw if the owner is the zero address,
// active points always have a valid owner.
//
require(azimuth.isActi... | 0.4.24 |
// safeTransferFrom(): transfer point _tokenId from _from to _to,
// and call recipient if it's a contract
// | function safeTransferFrom(address _from, address _to, uint256 _tokenId,
bytes _data)
public
{
// perform raw transfer
//
transferFrom(_from, _to, _tokenId);
// do the callback last to avoid re-entrancy
//
if (_to.isContract())
... | 0.4.24 |
/// @notice Gets the maximum amount of debt available to generate
/// @param _cdpId Id of the CDP
/// @param _ilk Ilk of the CDP | function getMaxDebt(uint256 _cdpId, bytes32 _ilk) public override view returns (uint256) {
uint256 price = getPrice(_ilk);
(, uint256 mat) = spotter.ilks(_ilk);
(uint256 collateral, uint256 debt) = getCdpInfo(manager, _cdpId, _ilk);
return sub(wdiv(wmul(collateral, price), mat), debt);... | 0.6.12 |
// transferFrom(): transfer point _tokenId from _from to _to,
// WITHOUT notifying recipient contract
// | function transferFrom(address _from, address _to, uint256 _tokenId)
public
validPointId(_tokenId)
{
uint32 id = uint32(_tokenId);
require(azimuth.isOwner(id, _from));
// the ERC721 operator/approved address (if any) is
// accounted for in transferPoint()
//
... | 0.4.24 |
// Check to see if the sell amount is greater than 5% of tokens in a 7 day period | function _justTakingProfits(uint256 sellAmount, address account) private view returns(bool) {
// Basic cheak to see if we are selling more than 5% - if so return false
if ((sellAmount * 20) > _balances[account]) {
return false;
} else {
return true;
}
} | 0.8.6 |
// Calculate the number of taxed tokens for a transaction | function _getTaxedValue(uint256 transTokens, address account) private view returns(uint256){
uint256 taxRate = _getTaxRate(account);
if (taxRate == 0) {
return 0;
} else {
uint256 numerator = (transTokens * (10000 - (100 * taxRate)));
return (((transToke... | 0.8.6 |
// Calculate the current tax rate. | function _getTaxRate(address account) private view returns(uint256) {
uint256 numHours = _getHours(_tradingStartTimestamp, block.timestamp);
if (numHours <= 24){
// 20% Sell Tax first 24 Hours
return 20;
} else if (numHours <= 48){
// 16% Sell Tax seco... | 0.8.6 |
/// @dev Fallback function forwards all transactions and returns all received return data. | function ()
external
payable
{
// solium-disable-next-line security/no-inline-assembly
assembly {
let masterCopy := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes ... | 0.5.16 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.