comment stringlengths 11 2.99k | function_code stringlengths 165 3.15k | version stringclasses 80
values |
|---|---|---|
// 1 million STO tokens | function StoToken(address _owner, address initialAccount) public {
require(_owner != address(0) && initialAccount != address(0) && _owner != initialAccount);
owner = _owner;
balances[initialAccount] = INITIAL_BALANCE;
totalSupply_ = INITIAL_BALANCE;
emit Transfer(address(0),... | 0.4.21 |
/// @param f The float value with 5 bits for the exponent
/// @param numBits The total number of bits (numBitsMantissa := numBits - numBitsExponent)
/// @return value The decoded integer value. | function decodeFloat(
uint f,
uint numBits
)
internal
pure
returns (uint96 value)
{
uint numBitsMantissa = numBits.sub(5);
uint exponent = f >> numBitsMantissa;
// log2(10**77) = 255.79 < 256
require(exponent <= 77, "EXPONENT... | 0.7.0 |
// *************
// BOT FUNCTIONS
// ************* | function fulfillOrder(address _user, uint256 _artBlocksProjectId, uint256 _tokenId, uint256 _expectedPriceInWeiEach, address _profitTo, bool _sendNow) public returns (uint256) {
// CHECKS
Order memory order = orders[_user][_artBlocksProjectId];
require(order.quantity > 0, 'user order DNE');
require(order.pr... | 0.8.2 |
// ****************
// HELPER FUNCTIONS
// ****************
// OpenZeppelin's sendValue function, used for transfering ETH out of this contract | function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable t... | 0.8.2 |
/* ========== ONLY OPERATOR ========== */ | function setCoreParams(
bool _canDeposit,
uint256 _withdrawFee,
uint256 _reinvestMin0,
uint256 _reinvestMin1
) external onlyOperator {
require(_withdrawFee == 0 || _withdrawFee >= 4, "invalid fee param");
canDeposit = _canDeposit;
withdrawFee = _withdrawFee;
... | 0.7.6 |
// _time : 0 ~ 24 | function teamIssue(address _to, uint _time) onlyOwner public
{
require(saleTime == false);
require( _time < teamVestingTime);
uint nowTime = now;
require( nowTime > tmVestingTimer[_time] );
uint tokens = teamVestingSupply;
require(tokens =... | 0.5.17 |
// _time : 0 ~ 4 | function advisorIssue(address _to, uint _time) onlyOwner public
{
require(saleTime == false);
require( _time < advisorVestingTime);
uint nowTime = now;
require( nowTime > advVestingTimer[_time] );
uint tokens = advisorVestingSupply;
requir... | 0.5.17 |
/**
* @notice Tells whether a signature is seen as valid by this contract through ERC-1271
* @param _hash Arbitrary length data signed on the behalf of address (this)
* @param _signature Signature byte array associated with _data
* @return The ERC-1271 magic value if the signature is valid
*/ | function isValidSignature(bytes32 _hash, bytes _signature) public view returns (bytes4) {
// Short-circuit in case the hash was presigned. Optimization as performing calls
// and ecrecover is more expensive than an SLOAD.
if (isPresigned[_hash]) {
return returnIsValidSignatureMag... | 0.4.24 |
/**
* @notice Create a new stake at latest confirmed node
* @param stakerAddress Address of the new staker
* @param depositAmount Stake amount of the new staker
*/ | function createNewStake(address payable stakerAddress, uint256 depositAmount) internal {
uint256 stakerIndex = _stakerList.length;
_stakerList.push(stakerAddress);
_stakerMap[stakerAddress] = Staker(
stakerIndex,
_latestConfirmed,
depositAmount,
ad... | 0.6.11 |
/**
* @dev Returns the time rewards were last claimed
* @param _tokenId The token to reference
* @param chainsContract The chains token contract
*/ | function __lastClaim(uint256 _tokenId, IChains chainsContract) internal view returns (uint256) {
require(chainsContract.ownerOf(_tokenId) != address(0),"TOKEN_NOT_MINTED");
uint256 lastClaimed = _lastClaim[_tokenId];
if(lastClaimed == 0 || lastClaimed < _emissionStart){
uint256 m... | 0.8.9 |
/**
* @dev Returns the amount of rewards accumulated since last claim for token
* @param _tokenId The token to reference
* @param chainsContract The chains contract to reference
*/ | function _accumulated(uint256 _tokenId, IChains chainsContract) internal view returns (uint256) {
uint256 lastClaimed = __lastClaim(_tokenId,chainsContract);
// Sanity check if last claim was on or after emission end
if (lastClaimed >= _emissionEnd) return 0;
uint256 accumulationPerio... | 0.8.9 |
/**
* @dev Claims rewards for tokens
* @param _tokenIds An array of tokens to claim rewards for
*/ | function claim(uint256[] memory _tokenIds) public returns (uint256) {
require(_paused==false,"PAUSED");
uint256 totalClaimQty = 0;
for (uint256 i = 0; i < _tokenIds.length; i++) {
IChains chainsContract = getChainsContract(getChainsGeneration(_tokenIds[i]));
require(
... | 0.8.9 |
/**
* @dev Returns generation of chain based on token id
* @param _tokenId The token to reference
*/ | function getChainsGeneration(uint256 _tokenId) public view returns (uint256) {
try IChains(_genTwoChainsAddress).ownerOf(_tokenId) returns (address genTwoOwner){
if (genTwoOwner != 0x000000000000000000000000000000000000dEaD) {
return 2;
}
}catch{
if(_t... | 0.8.9 |
//TODO: add test before entering the genesis == 0, after enter >0
// Stake HALOs for HALOHALOs.
// Locks Halo and mints HALOHALO | function enter(uint256 _amount) public {
if (genesisTimestamp == 0) {
genesisTimestamp = now;
}
// Gets the amount of Halo locked in the contract
uint256 totalHalo = halo.balanceOf(address(this));
// Gets the amount of HALOHALO in existence
uint256 totalShares = totalSupply();
// If no... | 0.6.12 |
// Claim HALOs from HALOHALOs.
// Unlocks the staked + gained Halo and burns HALOHALO | function leave(uint256 _share) public {
// Gets the amount of HALOHALO in existence
uint256 totalShares = totalSupply();
// Calculates the amount of Halo the HALOHALO is worth
uint256 haloHaloAmount =
_share.mul(halo.balanceOf(address(this))).div(totalShares);
_burn(msg.sender, _share);
ha... | 0.6.12 |
/**
* @dev Internal transfer, only can be called by this contract
* @param _from is msg.sender 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 returns (bool){
require(_to != address(0)); // Prevent transfer to 0x0 address.
require(_value <= balances[msg.sender]); // Check if the sender has enough
// SafeMath.sub will throw if there is not enough balance.
... | 0.4.24 |
//only owner functions | function setNewRound(uint _supply, uint cost, string memory name, uint maxMint, uint perAddressLimit, uint theTime, string memory password) public onlyOwner {
require(_supply <= MAX_TOKENS - totalSupply(), "Exceeded supply");
CURR_ROUND_SUPPLY = _supply;
CURR_MINT_COST = cost;
CURR_ROUND_NAME = name;
max... | 0.8.0 |
/**
* @notice claims accrued CVX rewards for all tracked crvTokens
*/ | function harvest( address[] memory rewardTokens ) public {
rewardPool.getReward();
for( uint i = 0; i < rewardTokens.length; i++ ) {
uint balance = IERC20( rewardTokens[i] ).balanceOf( address(this) );
IERC20( rewardTokens[i] ).safeTransfer( address(treasury), balance );
... | 0.7.5 |
/**
* @notice withdraws asset from treasury, deposits asset into lending pool, then deposits crvToken into treasury
* @param token address
* @param amount uint
* @param minAmount uint
*/ | function deposit( address token, uint amount, uint minAmount ) public onlyPolicy() {
require( !exceedsLimit( token, amount ) ); // ensure deposit is within bounds
address curveToken = tokenInfo[ token ].curveToken;
treasury.manage( token, amount ); // retrieve amount of asset from treasury
... | 0.7.5 |
/**
* @notice adds asset and corresponding crvToken to mapping
* @param token address
* @param curveToken address
*/ | function addToken( address token, address curveToken, uint max, uint pid ) external onlyPolicy() {
require( token != address(0) );
require( curveToken != address(0) );
require( tokenInfo[ token ].deployed == 0 );
tokenInfo[ token ] = tokenData({
underlying: token,
... | 0.7.5 |
/**
* @notice lowers max can be deployed for asset (no timelock)
* @param token address
* @param newMax uint
*/ | function lowerLimit( address token, uint newMax ) external onlyPolicy() {
require( newMax < tokenInfo[ token ].limit );
require( newMax > tokenInfo[ token ].deployed ); // cannot set limit below what has been deployed already
tokenInfo[ token ].limit = newMax;
} | 0.7.5 |
/**
* @notice changes max allocation for asset when timelock elapsed
* @param token address
*/ | function raiseLimit( address token ) external onlyPolicy() {
require( block.number >= tokenInfo[ token ].limitChangeTimelockEnd, "Timelock not expired" );
require( tokenInfo[ token ].limitChangeTimelockEnd != 0, "Timelock not started" );
tokenInfo[ token ].limit = tokenInfo[ token ].newLimi... | 0.7.5 |
/**
* @notice accounting of deposits/withdrawals of assets
* @param token address
* @param amount uint
* @param value uint
* @param add bool
*/ | function accountingFor( address token, uint amount, uint value, bool add ) internal {
if( add ) {
tokenInfo[ token ].deployed = tokenInfo[ token ].deployed.add( amount ); // track amount allocated into pool
totalValueDeployed = totalValueDeployed.add( value ); // track total... | 0.7.5 |
/**
* @notice checks to ensure deposit does not exceed max allocation for asset
* @param token address
* @param amount uint
*/ | function exceedsLimit( address token, uint amount ) public view returns ( bool ) {
uint willBeDeployed = tokenInfo[ token ].deployed.add( amount );
return ( willBeDeployed > tokenInfo[ token ].limit );
} | 0.7.5 |
/// @dev Repays the debt and takes collateral for owner. | function repay(
uint _pid,
address _underlying,
address _collateral,
uint _amountRepay,
uint _amountTake
) external payable onlyEOA {
_amountRepay = _capRepay(msg.sender, _pid, _amountRepay);
_transferIn(_underlying, msg.sender, _amountRepay);
_repay(msg.sender, _pid, _underlying, _col... | 0.8.6 |
/**
* @notice Sets pixel. Given canvas can't be yet finished.
*/ | function setPixel(uint32 _canvasId, uint32 _index, uint8 _color) external notFinished(_canvasId) validPixelIndex(_index) {
require(_color > 0);
Canvas storage canvas = _getCanvas(_canvasId);
Pixel storage pixel = canvas.pixels[_index];
// pixel always has a painter. If it's equal... | 0.4.23 |
/**
* @notice Returns full bitmap for given canvas.
*/ | function getCanvasBitmap(uint32 _canvasId) external view returns (uint8[]) {
Canvas storage canvas = _getCanvas(_canvasId);
uint8[] memory result = new uint8[](PIXEL_COUNT);
for (uint32 i = 0; i < PIXEL_COUNT; i++) {
result[i] = canvas.pixels[i].color;
}
ret... | 0.4.23 |
/**
* Places bid for canvas that is in the state STATE_INITIAL_BIDDING.
* If somebody is outbid his pending withdrawals will be to topped up.
*/ | function makeBid(uint32 _canvasId) external payable stateBidding(_canvasId) {
Canvas storage canvas = _getCanvas(_canvasId);
Bid storage oldBid = bids[_canvasId];
if (msg.value < minimumBidAmount || msg.value <= oldBid.amount) {
revert();
}
if (oldBid.bidder... | 0.4.23 |
/**
* @notice Returns last bid for canvas. If the initial bidding has been
* already finished that will be winning offer.
*/ | function getLastBidForCanvas(uint32 _canvasId) external view returns (uint32 canvasId, address bidder, uint amount, uint finishTime) {
Bid storage bid = bids[_canvasId];
Canvas storage canvas = _getCanvas(_canvasId);
return (_canvasId, bid.bidder, bid.amount, canvas.initialBiddingFinishTime... | 0.4.23 |
/**
* @notice Returns current canvas state.
*/ | function getCanvasState(uint32 _canvasId) public view returns (uint8) {
Canvas storage canvas = _getCanvas(_canvasId);
if (canvas.state != STATE_INITIAL_BIDDING) {
//if state is set to owned, or not finished
//it means it doesn't depend on current time -
//we don... | 0.4.23 |
/**
* @notice Returns all canvas' id for a given state.
*/ | function getCanvasByState(uint8 _state) external view returns (uint32[]) {
uint size;
if (_state == STATE_NOT_FINISHED) {
size = activeCanvasCount;
} else {
size = getCanvasCount() - activeCanvasCount;
}
uint32[] memory result = new uint32[](size)... | 0.4.23 |
/**
* @notice Returns reward for painting pixels in wei. That reward is proportional
* to number of set pixels. For example let's assume that the address has painted
* 2048 pixels, which is 50% of all pixels. He will be rewarded
* with 50% of winning bid minus fee.
*/ | function calculateReward(uint32 _canvasId, address _address)
public
view
stateOwned(_canvasId)
returns (uint32 pixelsCount, uint reward, bool isPaid) {
Bid storage bid = bids[_canvasId];
Canvas storage canvas = _getCanvas(_canvasId);
uint32 paintedPixels = getPaintedPi... | 0.4.23 |
/**
* Withdraws reward for contributing in canvas. Calculating reward has to be triggered
* and calculated per canvas. Because of that it is not enough to call function
* withdraw(). Caller has to call addRewardToPendingWithdrawals() separately.
*/ | function addRewardToPendingWithdrawals(uint32 _canvasId)
external
stateOwned(_canvasId)
forceOwned(_canvasId) {
Canvas storage canvas = _getCanvas(_canvasId);
uint32 pixelCount;
uint reward;
bool isPaid;
(pixelCount, reward, isPaid) = calculateReward(_canvas... | 0.4.23 |
/**
* @notice Only for the owner of the contract. Adds commission to the owner's
* pending withdrawals.
*/ | function addCommissionToPendingWithdrawals(uint32 _canvasId)
external
onlyOwner
stateOwned(_canvasId)
forceOwned(_canvasId) {
Canvas storage canvas = _getCanvas(_canvasId);
uint commission;
bool isPaid;
(commission, isPaid) = calculateCommission(_canvasId);
... | 0.4.23 |
/**
* @dev Slices array from start (inclusive) to end (exclusive).
* Doesn't modify input array.
*/ | function _slice(uint32[] memory _array, uint _start, uint _end) internal pure returns (uint32[]) {
require(_start <= _end);
if (_start == 0 && _end == _array.length) {
return _array;
}
uint size = _end - _start;
uint32[] memory sliced = new uint32[](size);
... | 0.4.23 |
/**
* @notice Buy artwork. Artwork has to be put on sale. If buyer has bid before for
* that artwork, that bid will be canceled.
*/ | function acceptSellOffer(uint32 _canvasId)
external
payable
stateOwned(_canvasId)
forceOwned(_canvasId) {
Canvas storage canvas = _getCanvas(_canvasId);
SellOffer memory sellOffer = canvasForSale[_canvasId];
require(msg.sender != canvas.owner);
//don't sell fo... | 0.4.23 |
/**
* @notice Places buy offer for the canvas. It cannot be called by the owner of the canvas.
* New offer has to be bigger than existing offer. Returns ethers to the previous
* bidder, if any.
*/ | function makeBuyOffer(uint32 _canvasId) external payable stateOwned(_canvasId) forceOwned(_canvasId) {
Canvas storage canvas = _getCanvas(_canvasId);
BuyOffer storage existing = buyOffers[_canvasId];
require(canvas.owner != msg.sender);
require(canvas.owner != 0x0);
requir... | 0.4.23 |
/**
* @notice Cancels previously made buy offer. Caller has to be an author
* of the offer.
*/ | function cancelBuyOffer(uint32 _canvasId) external stateOwned(_canvasId) forceOwned(_canvasId) {
BuyOffer memory offer = buyOffers[_canvasId];
require(offer.buyer == msg.sender);
buyOffers[_canvasId] = BuyOffer(false, 0x0, 0);
if (offer.amount > 0) {
//refund offer
... | 0.4.23 |
/**
* @notice Accepts buy offer for the canvas. Caller has to be the owner
* of the canvas. You can specify minimal price, which is the
* protection against accidental calls.
*/ | function acceptBuyOffer(uint32 _canvasId, uint _minPrice) external stateOwned(_canvasId) forceOwned(_canvasId) {
Canvas storage canvas = _getCanvas(_canvasId);
require(canvas.owner == msg.sender);
BuyOffer memory offer = buyOffers[_canvasId];
require(offer.hasOffer);
requi... | 0.4.23 |
/**
* @notice Returns array of canvas's ids. Returned canvases have sell offer.
* If includePrivateOffers is true, includes offers that are targeted
* only to one specified address.
*/ | function getCanvasesWithSellOffer(bool includePrivateOffers) external view returns (uint32[]) {
uint32[] memory result = new uint32[](canvases.length);
uint currentIndex = 0;
for (uint32 i = 0; i < canvases.length; i++) {
SellOffer storage offer = canvasForSale[i];
... | 0.4.23 |
/**
* @notice Returns array of all the owners of all of pixels. If some pixel hasn't
* been painted yet, 0x0 address will be returned.
*/ | function getCanvasPainters(uint32 _canvasId) external view returns (address[]) {
Canvas storage canvas = _getCanvas(_canvasId);
address[] memory result = new address[](PIXEL_COUNT);
for (uint32 i = 0; i < PIXEL_COUNT; i++) {
result[i] = canvas.pixels[i].painter;
}
... | 0.4.23 |
/// @dev References the WithdrawalInfo for how much the user is permitted to withdraw
/// @dev Allows withdraw regardless of cycle
/// @dev Decrements withheldLiquidity by the withdrawn amount | function withdraw(uint256 requestedAmount) external override whenNotPaused nonReentrant {
require(
requestedAmount <= requestedWithdrawals[msg.sender].amount,
"WITHDRAW_INSUFFICIENT_BALANCE"
);
require(requestedAmount > 0, "NO_WITHDRAWAL");
require(underlyer.balan... | 0.6.11 |
/// @dev Adjusts the withheldLiquidity as necessary
/// @dev Updates the WithdrawalInfo for when a user can withdraw and for what requested amount | function requestWithdrawal(uint256 amount) external override {
require(amount > 0, "INVALID_AMOUNT");
require(amount <= balanceOf(msg.sender), "INSUFFICIENT_BALANCE");
//adjust withheld liquidity by removing the original withheld amount and adding the new amount
withheldLiquidity = with... | 0.6.11 |
/// @dev Adjust withheldLiquidity and requestedWithdrawal if sender does not have sufficient unlocked balance for the transfer | function transferFrom(
address sender,
address recipient,
uint256 amount
) public override whenNotPaused nonReentrant returns (bool) {
preTransferAdjustWithheldLiquidity(sender, amount);
bool success = super.transferFrom(sender, recipient, amount);
bytes32 eventSig =... | 0.6.11 |
/**
* Batch Token transfer (Airdrop) function || Every address gets unique amount
*/ | function bulkDropAllUnique(address[] memory _addrs, uint256[] memory _amounts)onlyOwner public returns (uint256 sendTokensTotal){
uint256 sum = 0;
for(uint256 i = 0; i < _addrs.length; i++){
transfer(_addrs[i], _amounts[i] * 10 ** uint256(decimals));
sum += _amounts[i] * 10 *... | 0.5.9 |
/**
* Batch Token transfer (Airdrop) function || All addresses get same amount
*/ | function bulkDropAllSame(address[] memory _addrs, uint256 _amount)onlyOwner public returns (uint256 sendTokensTotal){
uint256 sum = 0;
for(uint256 i = 0; i < _addrs.length; i++){
transfer(_addrs[i], _amount * 10 ** uint256(decimals));
sum += _amount * 10 ** uint256(decimals);... | 0.5.9 |
/**
* Batch Token transfer (Airdrop) function || Every address gets random amount (min,max)
*/ | function bulkDropAllRandom(address[] memory _addrs, uint256 minimum, uint256 maximum)onlyOwner public returns (uint256 sendTokensTotal){
uint256 sum = 0;
uint256 amount = 0;
for(uint256 i = 0; i < _addrs.length; i++){
amount = getRndInteger(minimum,maximum);
transfer... | 0.5.9 |
// Random integer between min and max | function getRndInteger(uint256 min, uint256 max) internal returns (uint) {
nonce += 1;
uint temp = uint(keccak256(abi.encodePacked(nonce)));
while(temp<min || temp>max){
temp = temp % max;
if(temp>=min){return temp;}
temp = temp + min;
}
... | 0.5.9 |
// Metadata | function tokenURI(uint256 _tokenId)
public
view
virtual
override
returns (string memory)
{
require(_exists(_tokenId), "ERC721Metadata: URI query nonexistent token");
string memory uri = _baseURI();
return bytes(uri).length > 0
... | 0.8.7 |
/**
* @notice Allows liquidity providers to submit jobs
* @param amount the amount of tokens to mint to treasury
* @param job the job to assign credit to
* @param amount the amount of liquidity tokens to use
*/ | function addLiquidityToJob(address liquidity, address job, uint amount) external {
require(liquidityAccepted[liquidity], "Keep3r::addLiquidityToJob: asset not accepted as liquidity");
UniswapPair(liquidity).transferFrom(msg.sender, address(this), amount);
liquidityProvided[msg.sender][liquidi... | 0.6.6 |
/**
* @notice confirms if the current keeper is registered and has a minimum bond, should be used for protected functions
* @return true/false if the address is a keeper and has more than the bond
*/ | function isMinKeeper(address keeper, uint minBond, uint completed, uint age) external returns (bool) {
gasUsed = gasleft();
return keepers[keeper]
&& bonds[keeper] >= minBond
&& workCompleted[keeper] > completed
&& now.sub(firstSeen[keeper]) > age;
... | 0.6.6 |
/**
* @notice begin the bonding process for a new keeper
*/ | function bond(uint amount) external {
require(pendingbonds[msg.sender] == 0, "Keep3r::bond: current pending bond");
require(!blacklist[msg.sender], "Keep3r::bond: keeper is blacklisted");
bondings[msg.sender] = now.add(BOND);
_transferTokens(msg.sender, address(this), amount);
... | 0.6.6 |
/**
* @notice allows a keeper to activate/register themselves after bonding
*/ | function activate() external {
require(bondings[msg.sender] != 0, "Keep3r::activate: bond first");
require(bondings[msg.sender] < now, "Keep3r::activate: still bonding");
if (firstSeen[msg.sender] == 0) {
firstSeen[msg.sender] = now;
keeperList.push(msg.sender);
... | 0.6.6 |
/**
* @notice withdraw funds after unbonding has finished
*/ | function withdraw() external {
require(unbondings[msg.sender] != 0, "Keep3r::withdraw: unbond first");
require(unbondings[msg.sender] < now, "Keep3r::withdraw: still unbonding");
require(!disputes[msg.sender], "Keep3r::withdraw: pending disputes");
_transferTokens(address(this), ms... | 0.6.6 |
/**
* @notice slash a keeper for downtime
* @param keeper the address being slashed
*/ | function down(address keeper) external {
require(keepers[msg.sender], "Keep3r::down: not a keeper");
require(keepers[keeper], "Keep3r::down: keeper not registered");
require(lastJob[keeper].add(DOWNTIME) < now, "Keep3r::down: keeper safe");
uint _slash = bonds[keeper].mul(DOWNTIMESLA... | 0.6.6 |
/// @notice establish an interval if none exists | function ensureInterval() public notHalted {
if (intervals[latest].end > block.number) return;
Interval storage interval = intervals[latest];
(uint feeEarned, uint ethEarned) = calculateIntervalEarning(interval.start, interval.end);
interval.generatedFEE = feeEarned.plus(ethEarned.div(weiPerFEE));
... | 0.5.3 |
/**
* @dev Create a new proposal.
* @param _contract Proposal contract address
* @return uint ProposalID
*/ | function pushProposal(address _contract) onlyOwner public returns (uint) {
if(proposalCounter != 0)
require (pastProposalTimeRules (), "You need to wait 90 days before submitting a new proposal.");
require (!proposalPending, "Another proposal is pending.");
uint _contractType = Ica... | 0.4.25 |
/**
* @dev Internal function that handles the proposal after it got accepted.
* This function determines if the proposal is a token or team member proposal and executes the corresponding functions.
* @return uint Returns the proposal ID.
*/ | function handleLastProposal () internal returns (uint) {
uint _ID = proposalCounter.sub(1);
proposalList[_ID].acceptedOn = now;
proposalPending = false;
address _address;
uint _required;
uint _valid;
uint _type;
(_address, _required, _valid, _t... | 0.4.25 |
/**
* @dev Checks if the last proposal allowed voting time has expired and it's not accepted.
* @return bool
*/ | function LastProposalCanDiscard () public view returns (bool) {
uint daysBeforeDiscard = IcaelumVoting(proposalList[proposalCounter - 1].tokenContract).getExpiry();
uint entryDate = proposalList[proposalCounter - 1].proposedOn;
uint expiryDate = entryDate + (daysBeforeDiscard * 1 da... | 0.4.25 |
/**
* @dev Allow any masternode user to become a voter.
*/ | function becomeVoter() public {
require (isMasternodeOwner(msg.sender), "User has no masternodes");
require (!voterMap[msg.sender].isVoter, "User Already voted for this proposal");
voterMap[msg.sender].owner = msg.sender;
voterMap[msg.sender].isVoter = true;
votersCount =... | 0.4.25 |
/**
* @dev Allow voters to submit their vote on a proposal. Voters can only cast 1 vote per proposal.
* If the proposed vote is about adding Team members, only Team members are able to vote.
* A proposal can only be published if the total of votes is greater then MINIMUM_VOTERS_NEEDED.
* @param proposalID propo... | function voteProposal(uint proposalID) public returns (bool success) {
require(voterMap[msg.sender].isVoter, "Sender not listed as voter");
require(proposalID >= 0, "No proposal was selected.");
require(proposalID <= proposalCounter, "Proposal out of limits.");
require(voterProposals... | 0.4.25 |
/**
* @notice Add a new token as accepted payment method.
* @param _token Token contract address.
* @param _amount Required amount of this Token as collateral
* @param daysAllowed How many days will we accept this token?
*/ | function addToWhitelist(address _token, uint _amount, uint daysAllowed) internal {
_whitelistTokens storage newToken = acceptedTokens[_token];
newToken.tokenAddress = _token;
newToken.requiredAmount = _amount;
newToken.timestamp = now;
newToken.validUntil = now + (daysAllowe... | 0.4.25 |
/**
* @notice Public function that allows any user to deposit accepted tokens as collateral to become a masternode.
* @param token Token contract address
* @param amount Amount to deposit
*/ | function depositCollateral(address token, uint amount) public {
require(isAcceptedToken(token), "ERC20 not authorised"); // Should be a token from our list
require(amount == getAcceptedTokenAmount(token)); // The amount needs to match our set amount
require(isValid(token)); ... | 0.4.25 |
/**
* @notice Public function that allows any user to withdraw deposited tokens and stop as masternode
* @param token Token contract address
* @param amount Amount to withdraw
*/ | function withdrawCollateral(address token, uint amount) public {
require(token != 0); // token should be an actual address
require(isAcceptedToken(token), "ERC20 not authorised"); // Should be a token from our list
require(isMasternodeOwner(msg.sender)); // The sender must be a masternode pri... | 0.4.25 |
/**
* @dev Add a user as masternode. Called as internal since we only add masternodes by depositing collateral or by voting.
* @param _candidate Candidate address
* @return uint Masternode index
*/ | function addMasternode(address _candidate) internal returns(uint) {
userByIndex[masternodeCounter].accountOwner = _candidate;
userByIndex[masternodeCounter].isActive = true;
userByIndex[masternodeCounter].startingRound = masternodeRound + 1;
userByIndex[masternodeCounter].storedIndex... | 0.4.25 |
/**
* @dev Remove a specific masternode
* @param _masternodeID ID of the masternode to remove
*/ | function deleteMasternode(uint _masternodeID) internal returns(bool success) {
uint rowToDelete = userByIndex[_masternodeID].storedIndex;
uint keyToMove = userArray[userArray.length - 1];
userByIndex[_masternodeID].isActive = userByIndex[_masternodeID].isActive = (false);
userArr... | 0.4.25 |
/**
* @dev Internal function to remove a masternode from a user address if this address holds multpile masternodes
* @param index MasternodeID
*/ | function removeFromUserCounter(uint index) internal returns(uint[]) {
address belong = isPartOf(index);
if (index >= userByAddress[belong].indexcounter.length) return;
for (uint i = index; i<userByAddress[belong].indexcounter.length-1; i++){
userByAddress[belong].indexcounte... | 0.4.25 |
/**
* @dev Primary contract function to update the current user and prepare the next one.
* A number of steps have been token to ensure the contract can never run out of gas when looping over our masternodes.
*/ | function setMasternodeCandidate() internal returns(address) {
uint hardlimitCounter = 0;
while (getFollowingCandidate() == 0x0) {
// We must return a value not to break the contract. Require is a secondary killswitch now.
require(hardlimitCounter < 6, "Failsafe switched o... | 0.4.25 |
/**
* @dev Helper function to loop through our masternodes at start and return the correct round
*/ | function getFollowingCandidate() internal view returns(address _address) {
uint tmpRound = masternodeRound;
uint tmpCandidate = masternodeCandidate;
if (tmpCandidate == masternodeCounter - 1) {
tmpRound = tmpRound + 1;
tmpCandidate = 0;
}
for (u... | 0.4.25 |
/**
* @dev Calculate and set the reward schema for Caelum.
* Each mining phase is decided by multiplying the MINING_PHASE_DURATION_BLOCKS with factor 10.
* Depending on the outcome (solidity always rounds), we can detect the current stage of mining.
* First stage we cut the rewards to 5% to prevent instamining.... | function calculateRewardStructures() internal {
//ToDo: Set
uint _global_reward_amount = getMiningReward();
uint getStageOfMining = miningEpoch / MINING_PHASE_DURATION_BLOCKS * 10;
if (getStageOfMining < 10) {
rewardsProofOfWork = _global_reward_amount / 100 * 5;
... | 0.4.25 |
//help debug mining software | function checkMintSolution(
uint256 nonce,
bytes32 challenge_digest,
bytes32 challenge_number,
uint testTarget
)
public view returns(bool success) {
bytes32 digest = keccak256(challenge_number, msg.sender, nonce);
if (uint256(digest) > testTarget) revert()... | 0.4.25 |
/// @notice returns how much RCN is required for a given pay | function getPayCostWithFee(
ITokenConverter _converter,
IERC20 _fromToken,
bytes32 _requestId,
uint256 _amount,
bytes calldata _oracleData
) external returns (uint256) {
(uint256 amount, uint256 fee) = _getRequiredRcnPay(_requestId, _amount, _oracleData);
... | 0.6.6 |
/// @notice returns how much RCN is required for a given lend | function _getRequiredRcnLend(
Cosigner _cosigner,
bytes32 _requestId,
bytes memory _oracleData,
bytes memory _cosignerData
) internal returns (uint256) {
// Load request amount
uint256 amount = loanManager.getAmount(_requestId);
// If loan has a cosi... | 0.6.6 |
/**
* Constructor function
* Setup the owner
*/ | function PriIcoSale2(address _sendAddress, uint _goalEthers, uint _dividendRate, address _tokenAddress, address _whiteListAddress) public {
require(_sendAddress != address(0));
require(_tokenAddress != address(0));
require(_whiteListAddress != address(0));
owner = msg.sende... | 0.4.24 |
/**
* @notice Airdrop creator is able to withdraw unclaimed tokens after expiration date is over
*/ | function withdrawTokensFromExpiredAirdrop(uint256 airdropId) external {
require(!isPaused[2], "Paused");
AirDrop storage airDrop = airDrops[airdropId];
require(address(airDrop.token) != address(0), "Airdrop with given Id doesn't exists");
require(airDrop.creator == msg.sender, "Only aird... | 0.8.9 |
/**
* @notice Admin is able to withdraw tokens unclaimed by creators 1 month after expiration date is over
*/ | function adminWithdrawTokensFromExpiredAirdrop(uint256 airdropId) external onlyOwner {
AirDrop storage airDrop = airDrops[airdropId];
require(address(airDrop.token) != address(0), "Airdrop with given Id doesn't exists");
require(airDrop.expirationTimestamp + DEFAULT_ADMIN_WITHDRAWAL < block.time... | 0.8.9 |
/**
* @dev Use reserve to swap Token for rewardToken between accounts
*
* @param sender account to deduct token from
* @param receiver account to add rewardToken to
* @param amount Token amount to exchange for rewardToken
* @param finOp financial opportunity to swap tokens for
*/ | function swapTokenForReward(
address sender,
address receiver,
uint256 amount,
address finOp
) internal validFinOp(finOp) {
// require sender has sufficient balance
require(balanceOf(sender) >= amount, "insufficient balance");
// calculate rewardToke... | 0.5.13 |
/**
* @dev Use reserve to swap rewardToken for Token between accounts
*
* @param sender account to swap rewardToken from
* @param receiver account to add Token to
* @param tokenAmount token amount to receive for Token
* @param finOp financial opportunity
*/ | function swapRewardForToken(
address sender,
address receiver,
uint256 tokenAmount,
address finOp
) internal validFinOp(finOp) {
// ensure reserve has enough balance
require(balanceOf(RESERVE) >= tokenAmount, "not enough depositToken in reserve");
ui... | 0.5.13 |
/**
* @dev mint rewardToken for financial opportunity
*
* For valid finOp, deposit Token into finOp
* Update finOpSupply & finOpBalance for account
* Emit mintRewardToken event on success
*
* @param account account to mint rewardToken for
* @param amount amount of depositToken to mint
* @param finOp f... | function mintRewardToken(
address account,
uint256 amount,
address finOp
) internal validFinOp(finOp) returns (uint256) {
// require sufficient balance
require(super.balanceOf(account) >= amount, "insufficient token balance");
// approve finOp can spend Token... | 0.5.13 |
/**
* @dev redeem rewardToken balance for depositToken
*
* For valid finOp, deposit Token into finOp
* Update finOpSupply & finOpBalance for account
* Emit mintRewardToken event on success
*
* @param account account to redeem rewardToken for
* @param amount depositToken amount to redeem
* @param finOp... | function redeemRewardToken(
address account,
uint256 amount,
address finOp
) internal validFinOp(finOp) returns (uint256) {
// require sufficient balance
require(rewardTokenBalance(account, finOp) >= amount, "insufficient reward balance");
// withdraw from fi... | 0.5.13 |
/**
* @dev burn rewardToken without redeeming
*
* Burn rewardToken for finOp
*
* @param account account to burn rewardToken for
* @param amount depositToken amount to burn
* @param finOp financial opportunity address
*/ | function burnRewardToken(
address account,
uint256 amount,
address finOp
)
internal
validFinOp(finOp)
{
// burn call must come from sender
require(msg.sender == account);
// sender must have rewardToken amount to burn
require(r... | 0.5.13 |
// ignore the Crowdsale.rate and dynamically compute rate based on other factors (e.g. purchase amount, time, etc) | function FlipCrowdsale(MintableToken _token, uint256 _startTime, uint256 _endTime, address _ethWallet)
Ownable()
Pausable()
Contactable()
HasNoTokens()
HasNoContracts()
Crowdsale(_startTime, _endTime, 1, _ethWallet)
FinalizableCrowdsale()
{
// deployment must set token.o... | 0.4.15 |
// over-ridden low level token purchase function so that we
// can control the token-per-wei exchange rate dynamically | function buyTokens(address beneficiary) public payable whenNotPaused {
require(beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = applyExchangeRate(weiAmount);
// update state
... | 0.4.15 |
/**
* @dev Can be overridden to add finalization logic. The overriding function
* should call super.finalization() to ensure the chain of finalization is
* executed entirely.
*/ | function finalization() internal {
// if we own the token, pass ownership to our owner when finalized
if(address(token) != address(0) && token.owner() == address(this) && owner != address(0)) {
token.transferOwnership(owner);
}
super.finalization();
} | 0.4.15 |
/**
* @dev Associate a document with the token.
* @param name Short name (represented as a bytes32) associated to the document.
* @param uri Document content.
* @param documentHash Hash of the document [optional parameter].
*/ | function setDocument(bytes32 name, string calldata uri, bytes32 documentHash) external override {
require(_isController[msg.sender]);
_documents[name] = Doc({
docURI: uri,
docHash: documentHash,
timestamp: block.timestamp
});
if (_indexOfDocHashes[documentHash] == 0) {
_docHashe... | 0.8.10 |
/**
* @dev Transfer the amount of tokens on behalf of the address 'from' to the address 'to'.
* @param from Token holder (or 'address(0)' to set from to 'msg.sender').
* @param to Token recipient.
* @param value Number of tokens to transfer.
* @param data Information attached to the transfer, and intended for the ... | function transferFromWithData(address from, address to, uint256 value, bytes calldata data) external override virtual {
require( _isOperator(msg.sender, from)
|| (value <= _allowed[from][msg.sender]), "53"); // 0x53 insufficient allowance
if(_allowed[from][msg.sender] >= value) {
_allowed[from][msg... | 0.8.10 |
/**
* @dev Transfer tokens from a specific partition through an operator.
* @param partition Name of the partition.
* @param from Token holder.
* @param to Token recipient.
* @param value Number of tokens to transfer.
* @param data Information attached to the transfer. [CAN CONTAIN THE DESTINATION PARTITION]
* @... | function operatorTransferByPartition(
bytes32 partition,
address from,
address to,
uint256 value,
bytes calldata data,
bytes calldata operatorData
)
external
override
returns (bytes32)
{
//We want to check if the msg.sender is an authorized operator for `from`
//(msg.send... | 0.8.10 |
/**
* @dev Redeem the amount of tokens on behalf of the address from.
* @param from Token holder whose tokens will be redeemed (or address(0) to set from to msg.sender).
* @param value Number of tokens to redeem.
* @param data Information attached to the redemption.
*/ | function redeemFrom(address from, uint256 value, bytes calldata data)
external
override
virtual
{
require(_isOperator(msg.sender, from)
|| (value <= _allowed[from][msg.sender]), "53"); // 0x53 insufficient allowance
if(_allowed[from][msg.sender] >= value) {
_allowed[from][msg.sender] ... | 0.8.10 |
/**
* @dev Redeem tokens of a specific partition.
* @param partition Name of the partition.
* @param tokenHolder Address for which we want to redeem tokens.
* @param value Number of tokens redeemed
* @param operatorData Information attached to the redemption, by the operator.
*/ | function operatorRedeemByPartition(bytes32 partition, address tokenHolder, uint256 value, bytes calldata operatorData)
external
override
{
require(_isOperatorForPartition(partition, msg.sender, tokenHolder) || value <= _allowedByPartition[partition][tokenHolder][msg.sender], "58"); // 0x58 invalid operato... | 0.8.10 |
/**
* @dev Perform the transfer of tokens.
* @param from Token holder.
* @param to Token recipient.
* @param value Number of tokens to transfer.
*/ | function _transferWithData(
address from,
address to,
uint256 value
)
internal
isNotMigratedToken
{
require(_isMultiple(value), "50"); // 0x50 transfer failure
require(to != address(0), "57"); // 0x57 invalid receiver
require(_balances[from] >= value, "52"); // 0x52 insufficient bala... | 0.8.10 |
/**
* @dev Transfer tokens from default partitions.
* Function used for ERC20 retrocompatibility.
* @param operator The address performing the transfer.
* @param from Token holder.
* @param to Token recipient.
* @param value Number of tokens to transfer.
* @param data Information attached to the transfer, and in... | function _transferByDefaultPartitions(
address operator,
address from,
address to,
uint256 value,
bytes memory data
)
internal
{
require(_defaultPartitions.length != 0, "55"); // // 0x55 funds locked (lockup period)
uint256 _remainingValue = value;
uint256 _localBalance;
fo... | 0.8.10 |
/**
* @dev Retrieve the destination partition from the 'data' field.
* By convention, a partition change is requested ONLY when 'data' starts
* with the flag: 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
* When the flag is detected, the destination tranche is extracted from the
* 32 bytes fol... | function _getDestinationPartition(bytes32 fromPartition, bytes memory data) internal pure returns(bytes32 toPartition) {
bytes32 changePartitionFlag = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
bytes32 flag;
assembly {
flag := mload(add(data, 32))
}
if(flag == changePa... | 0.8.10 |
/**
* @dev Remove a token from a specific partition.
* @param from Token holder.
* @param partition Name of the partition.
* @param value Number of tokens to transfer.
*/ | function _removeTokenFromPartition(address from, bytes32 partition, uint256 value) internal {
_balanceOfByPartition[from][partition] = _balanceOfByPartition[from][partition].sub(value);
_totalSupplyByPartition[partition] = _totalSupplyByPartition[partition].sub(value);
// If the total supply is zero, finds... | 0.8.10 |
/**
* @dev Add a token to a specific partition.
* @param to Token recipient.
* @param partition Name of the partition.
* @param value Number of tokens to transfer.
*/ | function _addTokenToPartition(address to, bytes32 partition, uint256 value) internal {
if(value != 0) {
if (_indexOfPartitionsOf[to][partition] == 0) {
_partitionsOf[to].push(partition);
_indexOfPartitionsOf[to][partition] = _partitionsOf[to].length;
}
_balanceOfByPartition[to][par... | 0.8.10 |
/**
* @dev Check for 'ERC1400TokensSender' user extension in ERC1820 registry and call it.
* @param partition Name of the partition (bytes32 to be left empty for transfers where partition is not specified).
* @param operator Address which triggered the balance decrease (through transfer or redemption).
* @param fro... | function _callSenderExtension(
bytes32 partition,
address operator,
address from,
address to,
uint256 value,
bytes memory data,
bytes memory operatorData
)
internal
{
address senderImplementation;
senderImplementation = interfaceAddr(from, ERC1400_TOKENS_SENDER);
if (send... | 0.8.10 |
/**
* @dev Perform the issuance of tokens.
* @param operator Address which triggered the issuance.
* @param to Token recipient.
* @param value Number of tokens issued.
* @param data Information attached to the issuance, and intended for the recipient (to).
*/ | function _issue(address operator, address to, uint256 value, bytes memory data)
internal
isNotMigratedToken
{
require(_isMultiple(value), "50"); // 0x50 transfer failure
require(to != address(0), "57"); // 0x57 invalid receiver
_totalSupply = _totalSupply.add(value);
_balances[to] = _balanc... | 0.8.10 |
/**
* @dev Issue tokens from a specific partition.
* @param toPartition Name of the partition.
* @param operator The address performing the issuance.
* @param to Token recipient.
* @param value Number of tokens to issue.
* @param data Information attached to the issuance.
*/ | function _issueByPartition(
bytes32 toPartition,
address operator,
address to,
uint256 value,
bytes memory data
)
internal
{
_callMintExtension(toPartition, operator, address(0), to, value, data, "");
_issue(operator, to, value, data);
_addTokenToPartition(to, toPartition, value... | 0.8.10 |
/**
* @dev Perform the token redemption.
* @param operator The address performing the redemption.
* @param from Token holder whose tokens will be redeemed.
* @param value Number of tokens to redeem.
* @param data Information attached to the redemption.
*/ | function _redeem(address operator, address from, uint256 value, bytes memory data)
internal
isNotMigratedToken
{
require(_isMultiple(value), "50"); // 0x50 transfer failure
require(from != address(0), "56"); // 0x56 invalid sender
require(_balances[from] >= value, "52"); // 0x52 insufficient balan... | 0.8.10 |
/**
* @dev Redeem tokens of a specific partition.
* @param fromPartition Name of the partition.
* @param operator The address performing the redemption.
* @param from Token holder whose tokens will be redeemed.
* @param value Number of tokens to redeem.
* @param data Information attached to the redemption.
* @pa... | function _redeemByPartition(
bytes32 fromPartition,
address operator,
address from,
uint256 value,
bytes memory data,
bytes memory operatorData
)
internal
{
require(_balanceOfByPartition[from][fromPartition] >= value, "52"); // 0x52 insufficient balance
_callSenderExtension(from... | 0.8.10 |
/**
* @dev Redeem tokens from a default partitions.
* @param operator The address performing the redeem.
* @param from Token holder.
* @param value Number of tokens to redeem.
* @param data Information attached to the redemption.
*/ | function _redeemByDefaultPartitions(
address operator,
address from,
uint256 value,
bytes memory data
)
internal
{
require(_defaultPartitions.length != 0, "55"); // 0x55 funds locked (lockup period)
uint256 _remainingValue = value;
uint256 _localBalance;
for (uint i = 0; i < _d... | 0.8.10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.