Unnamed: 0
int64
0
7.36k
comments
stringlengths
3
35.2k
code_string
stringlengths
1
527k
code
stringlengths
1
527k
__index_level_0__
int64
0
88.6k
38
// guild kick proposal
} else if (proposal.flags[5] == 1) {
} else if (proposal.flags[5] == 1) {
23,649
1
// Creates a new claim of a Radicle Link identity./ Every new claim invalidates previous ones made with the same account./ The claims have no expiration date and don't need to be renewed./ If either `format` is unsupported or `payload` is malformed as per `format`,/ the previous claim is revoked, but a new one isn't created./ Don't send a malformed transactions on purpose, to properly revoke a claim see `format`./format The format of `payload`, currently supported values:/ - `1` - `payload` is exactly 20 bytes and contains an SHA-1 Radicle Identity root hash/ - `2` - `payload` is exactly 32 bytes
function claim(uint256 format, bytes calldata payload) public { format; payload; emit Claimed(msg.sender); }
function claim(uint256 format, bytes calldata payload) public { format; payload; emit Claimed(msg.sender); }
47,546
5
// solium-disable-next-line
emit AssetCreated(msg.sender, uuid, block.timestamp, _assetDataHash);
emit AssetCreated(msg.sender, uuid, block.timestamp, _assetDataHash);
3,343
206
// Functions// Constructor - sets values for token name and token supply, as well as the factory_contract, the swap. _factory /
function startToken(TokenStorage storage self,address _factory) public { self.factory_contract = _factory; }
function startToken(TokenStorage storage self,address _factory) public { self.factory_contract = _factory; }
23,969
46
// This is an alternative to {approve} that can be used as a mitigation forproblems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.- `spender` must have allowance for the caller of at least`subtractedValue`. /
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; }
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; }
36
2
// Extension that only uses a single creator contract instance /
abstract contract SingleCreatorExtensionBase { address internal _creator; /** * @dev Override with appropriate interface checks if necessary */ function _setCreator(address creator) internal virtual { _creator = creator; } function creatorContract() public view returns(address) { return _creator; } }
abstract contract SingleCreatorExtensionBase { address internal _creator; /** * @dev Override with appropriate interface checks if necessary */ function _setCreator(address creator) internal virtual { _creator = creator; } function creatorContract() public view returns(address) { return _creator; } }
18,182
163
// res += valcoefficients[15].
res := addmod(res, mulmod(val, /*coefficients[15]*/ mload(0x5e0), PRIME), PRIME)
res := addmod(res, mulmod(val, /*coefficients[15]*/ mload(0x5e0), PRIME), PRIME)
58,889
2
// sender and receiver state update
if (from != address(future) && to != address(future) && from != address(0x0) && to != address(0x0)) {
if (from != address(future) && to != address(future) && from != address(0x0) && to != address(0x0)) {
52,483
81
// Add support NFT interface in Exchange Only Exchange owner can do tihs interface_id Support NFT interface's interface_id /
function addSupportNFTInterface( bytes4 interface_id ) external onlyOwner()
function addSupportNFTInterface( bytes4 interface_id ) external onlyOwner()
30,966
194
// Upgrade Mining Pool. Can only be called by the owner
function upgrade(address _address) public onlyOwner { erc20.transferOwnership(_address); }
function upgrade(address _address) public onlyOwner { erc20.transferOwnership(_address); }
30,703
315
// The Clerk module used by the Master and its Safes.
TurboClerk public clerk;
TurboClerk public clerk;
30,329
13
// if there is no authority, that means that contract doesn't have permission
if (currAuthority == address(0)) { return; }
if (currAuthority == address(0)) { return; }
25,191
51
// YearnFinanceMoneyTokenContract to preform crowd sale with token /
contract YearnFinanceMoneyToken is StandardToken, Configurable, Ownable { /** * @dev enum of current crowd sale state **/ enum Stages { none, presale1Start, presale1End, presale2Start, presale2End, presale3Start, presale3End } Stages currentStage; /** * @dev constructor of CrowdsaleToken **/ constructor() public { currentStage = Stages.none; balances[owner] = balances[owner].add(tokenReserve); totalSupply_ = totalSupply_.add(tokenReserve+presale1+presale2+presale3); remainingTokens1 = presale1; remainingTokens2 = presale2; remainingTokens3 = presale3; emit Transfer(address(this), owner, tokenReserve); } /** * @dev fallback function to send ether to for Presale1 **/ function () public payable { require(msg.value > 0); uint256 weiAmount = msg.value; // Calculate tokens to sell uint256 tokens1 = weiAmount.mul(presale1Price).div(1 ether); uint256 tokens2 = weiAmount.mul(presale2Price).div(1 ether); uint256 tokens3 = weiAmount.mul(presale3Price).div(1 ether); uint256 returnWei = 0; if (currentStage == Stages.presale1Start) { require(currentStage == Stages.presale1Start); require(remainingTokens1 > 0); if(tokensSold1.add(tokens1) > presale1){ uint256 newTokens1 = presale1.sub(tokensSold1); uint256 newWei1 = newTokens1.div(presale1Price).mul(1 ether); returnWei = weiAmount.sub(newWei1); weiAmount = newWei1; tokens1 = newTokens1; } tokensSold1 = tokensSold1.add(tokens1); // Increment raised amount remainingTokens1 = presale1.sub(tokensSold1); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens1); emit Transfer(address(this), msg.sender, tokens1); owner.transfer(weiAmount);// Send money to owner } if (currentStage == Stages.presale2Start) { require(currentStage == Stages.presale2Start); require(remainingTokens2 > 0); if(tokensSold2.add(tokens2) > presale2){ uint256 newTokens2 = presale2.sub(tokensSold2); uint256 newWei2 = newTokens2.div(presale2Price).mul(1 ether); returnWei = weiAmount.sub(newWei2); weiAmount = newWei2; tokens2 = newTokens2; } tokensSold2 = tokensSold2.add(tokens2); // Increment raised amount remainingTokens2 = presale2.sub(tokensSold2); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens2); emit Transfer(address(this), msg.sender, tokens2); owner.transfer(weiAmount);// Send money to owner } if (currentStage == Stages.presale3Start) { require(currentStage == Stages.presale3Start); require(remainingTokens3 > 0); if(tokensSold3.add(tokens3) > presale3){ uint256 newTokens3 = presale3.sub(tokensSold3); uint256 newWei3 = newTokens3.div(presale3Price).mul(1 ether); returnWei = weiAmount.sub(newWei3); weiAmount = newWei3; tokens3 = newTokens3; } tokensSold3 = tokensSold3.add(tokens3); // Increment raised amount remainingTokens3 = presale3.sub(tokensSold3); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens3); emit Transfer(address(this), msg.sender, tokens3); owner.transfer(weiAmount);// Send money to owner } } /** /** * @dev startPresale1 starts the public PRESALE1 **/ function startPresale1() public onlyOwner { require(currentStage != Stages.presale1End); currentStage = Stages.presale1Start; } /** * @dev endPresale1 closes down the PRESALE1 **/ function endPresale1() internal { currentStage = Stages.presale1End; // Transfer any remaining tokens if(remainingTokens1 > 0) balances[owner] = balances[owner].add(remainingTokens1); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } /** * @dev finalizePresale1 closes down the PRESALE1 and sets needed varriables **/ function finalizePresale1() public onlyOwner { require(currentStage != Stages.presale1End); endPresale1(); } /** * @dev startPresale2 starts the public PRESALE2 **/ function startPresale2() public onlyOwner { require(currentStage != Stages.presale2End); currentStage = Stages.presale2Start; } /** * @dev endPresale2 closes down the PRESALE2 **/ function endPresale2() internal { currentStage = Stages.presale2End; // Transfer any remaining tokens if(remainingTokens2 > 0) balances[owner] = balances[owner].add(remainingTokens2); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } /** * @dev finalizePresale2 closes down the PRESALE2 and sets needed varriables **/ function finalizePresale2() public onlyOwner { require(currentStage != Stages.presale2End); endPresale2(); } function startPresale3() public onlyOwner { require(currentStage != Stages.presale3End); currentStage = Stages.presale3Start; } /** * @dev endPresale3 closes down the PRESALE3 **/ function endPresale3() internal { currentStage = Stages.presale3End; // Transfer any remaining tokens if(remainingTokens3 > 0) balances[owner] = balances[owner].add(remainingTokens3); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } /** * @dev finalizePresale3 closes down the PRESALE3 and sets needed varriables **/ function finalizePresale3() public onlyOwner { require(currentStage != Stages.presale3End); endPresale3(); } function burn(uint256 _value) public returns (bool succes){ require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; totalSupply_ -= _value; return true; } function burnFrom(address _from, uint256 _value) public returns (bool succes){ require(balances[_from] >= _value); require(_value <= allowed[_from][msg.sender]); balances[_from] -= _value; totalSupply_ -= _value; return true; } }
contract YearnFinanceMoneyToken is StandardToken, Configurable, Ownable { /** * @dev enum of current crowd sale state **/ enum Stages { none, presale1Start, presale1End, presale2Start, presale2End, presale3Start, presale3End } Stages currentStage; /** * @dev constructor of CrowdsaleToken **/ constructor() public { currentStage = Stages.none; balances[owner] = balances[owner].add(tokenReserve); totalSupply_ = totalSupply_.add(tokenReserve+presale1+presale2+presale3); remainingTokens1 = presale1; remainingTokens2 = presale2; remainingTokens3 = presale3; emit Transfer(address(this), owner, tokenReserve); } /** * @dev fallback function to send ether to for Presale1 **/ function () public payable { require(msg.value > 0); uint256 weiAmount = msg.value; // Calculate tokens to sell uint256 tokens1 = weiAmount.mul(presale1Price).div(1 ether); uint256 tokens2 = weiAmount.mul(presale2Price).div(1 ether); uint256 tokens3 = weiAmount.mul(presale3Price).div(1 ether); uint256 returnWei = 0; if (currentStage == Stages.presale1Start) { require(currentStage == Stages.presale1Start); require(remainingTokens1 > 0); if(tokensSold1.add(tokens1) > presale1){ uint256 newTokens1 = presale1.sub(tokensSold1); uint256 newWei1 = newTokens1.div(presale1Price).mul(1 ether); returnWei = weiAmount.sub(newWei1); weiAmount = newWei1; tokens1 = newTokens1; } tokensSold1 = tokensSold1.add(tokens1); // Increment raised amount remainingTokens1 = presale1.sub(tokensSold1); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens1); emit Transfer(address(this), msg.sender, tokens1); owner.transfer(weiAmount);// Send money to owner } if (currentStage == Stages.presale2Start) { require(currentStage == Stages.presale2Start); require(remainingTokens2 > 0); if(tokensSold2.add(tokens2) > presale2){ uint256 newTokens2 = presale2.sub(tokensSold2); uint256 newWei2 = newTokens2.div(presale2Price).mul(1 ether); returnWei = weiAmount.sub(newWei2); weiAmount = newWei2; tokens2 = newTokens2; } tokensSold2 = tokensSold2.add(tokens2); // Increment raised amount remainingTokens2 = presale2.sub(tokensSold2); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens2); emit Transfer(address(this), msg.sender, tokens2); owner.transfer(weiAmount);// Send money to owner } if (currentStage == Stages.presale3Start) { require(currentStage == Stages.presale3Start); require(remainingTokens3 > 0); if(tokensSold3.add(tokens3) > presale3){ uint256 newTokens3 = presale3.sub(tokensSold3); uint256 newWei3 = newTokens3.div(presale3Price).mul(1 ether); returnWei = weiAmount.sub(newWei3); weiAmount = newWei3; tokens3 = newTokens3; } tokensSold3 = tokensSold3.add(tokens3); // Increment raised amount remainingTokens3 = presale3.sub(tokensSold3); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens3); emit Transfer(address(this), msg.sender, tokens3); owner.transfer(weiAmount);// Send money to owner } } /** /** * @dev startPresale1 starts the public PRESALE1 **/ function startPresale1() public onlyOwner { require(currentStage != Stages.presale1End); currentStage = Stages.presale1Start; } /** * @dev endPresale1 closes down the PRESALE1 **/ function endPresale1() internal { currentStage = Stages.presale1End; // Transfer any remaining tokens if(remainingTokens1 > 0) balances[owner] = balances[owner].add(remainingTokens1); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } /** * @dev finalizePresale1 closes down the PRESALE1 and sets needed varriables **/ function finalizePresale1() public onlyOwner { require(currentStage != Stages.presale1End); endPresale1(); } /** * @dev startPresale2 starts the public PRESALE2 **/ function startPresale2() public onlyOwner { require(currentStage != Stages.presale2End); currentStage = Stages.presale2Start; } /** * @dev endPresale2 closes down the PRESALE2 **/ function endPresale2() internal { currentStage = Stages.presale2End; // Transfer any remaining tokens if(remainingTokens2 > 0) balances[owner] = balances[owner].add(remainingTokens2); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } /** * @dev finalizePresale2 closes down the PRESALE2 and sets needed varriables **/ function finalizePresale2() public onlyOwner { require(currentStage != Stages.presale2End); endPresale2(); } function startPresale3() public onlyOwner { require(currentStage != Stages.presale3End); currentStage = Stages.presale3Start; } /** * @dev endPresale3 closes down the PRESALE3 **/ function endPresale3() internal { currentStage = Stages.presale3End; // Transfer any remaining tokens if(remainingTokens3 > 0) balances[owner] = balances[owner].add(remainingTokens3); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } /** * @dev finalizePresale3 closes down the PRESALE3 and sets needed varriables **/ function finalizePresale3() public onlyOwner { require(currentStage != Stages.presale3End); endPresale3(); } function burn(uint256 _value) public returns (bool succes){ require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; totalSupply_ -= _value; return true; } function burnFrom(address _from, uint256 _value) public returns (bool succes){ require(balances[_from] >= _value); require(_value <= allowed[_from][msg.sender]); balances[_from] -= _value; totalSupply_ -= _value; return true; } }
33,271
6
// Get the document id that relates to the document number of a given address
mapping (address => mapping (uint32 => uint128)) userdocid; // author => (userdocid => docid)
mapping (address => mapping (uint32 => uint128)) userdocid; // author => (userdocid => docid)
33,165
108
// What is this hero&39;s type? ex) John, Sally, Mark...
uint32 heroClassId;
uint32 heroClassId;
18,051
400
// internal function for setting bot on a token
function setHasBot(uint256 _tokenId) internal { require(!hasBot[_tokenId], "already_has_bot"); hasBot[_tokenId] = true; }
function setHasBot(uint256 _tokenId) internal { require(!hasBot[_tokenId], "already_has_bot"); hasBot[_tokenId] = true; }
48,089
6
// If the first argument of 'require' evaluates to 'false', execution terminates and all changes to the state and to Ether balances are reverted. This used to consume all gas in old EVM versions, but not anymore. It is often a good idea to use 'require' to check if functions are called correctly. As a second argument, you can also provide an explanation about what went wrong.
require(msg.sender == owner, "Caller is not owner"); _;
require(msg.sender == owner, "Caller is not owner"); _;
468
11
// Unsubscribe an address from its current subscribed registrant, and optionally copy its filtered operators and codeHashes. /
function unsubscribe(address registrant, bool copyExistingEntries) external;
function unsubscribe(address registrant, bool copyExistingEntries) external;
24,544
15
// Calculates the amount of tokens that has already vested. Default implementation is a linear vesting curve. /
function vestedAmount(address token, uint64 timestamp) public view virtual returns (uint256) { return _vestingSchedule(IERC20(token).balanceOf(address(this)) + released(token), timestamp); }
function vestedAmount(address token, uint64 timestamp) public view virtual returns (uint256) { return _vestingSchedule(IERC20(token).balanceOf(address(this)) + released(token), timestamp); }
41,447
95
// This is an in-place update. Return the prev node of the node being updated
nodeID = dllMap[_voter].getPrev(nodeID);
nodeID = dllMap[_voter].getPrev(nodeID);
49,018
279
// Decode the revert reason in the event one was returned.
string memory revertReason = _decodeRevertReason(data); emit ExternalError( account, string( abi.encodePacked( name, " reverted calling ", functionName, ": ",
string memory revertReason = _decodeRevertReason(data); emit ExternalError( account, string( abi.encodePacked( name, " reverted calling ", functionName, ": ",
7,976
24
// Create the token.
_tokens[tokenId] = Token( tokenId, _spaceCakesTxn.steemTxn, _spaceCakesTxn.steemImages[i] );
_tokens[tokenId] = Token( tokenId, _spaceCakesTxn.steemTxn, _spaceCakesTxn.steemImages[i] );
19,926
13
// Returns a Project at _id from the projects array
function returnProjectAtId( uint256 _id
function returnProjectAtId( uint256 _id
986
79
// Configure multiple properties at a time. Note: The individual configure methods should be usedto unset or reset any properties to zero, as this methodwill ignore zero-value properties in the config struct.config The configuration struct. /
function multiConfigure(MultiConfigureStruct calldata config) external onlyOwner
function multiConfigure(MultiConfigureStruct calldata config) external onlyOwner
17,687
13
// Proceed buy
address target = MyItem.Owner;
address target = MyItem.Owner;
40,816
8
// Burn the fuel of a `boostedSend` /
function _burnBoostedSendFuel( address from, BoosterFuel memory fuel, UnpackedData memory unpacked
function _burnBoostedSendFuel( address from, BoosterFuel memory fuel, UnpackedData memory unpacked
35,990
117
// else if it's the first stake for user, set stakerIndex as current miningStateIndex
if(stakerIndex == 0){ stakerIndex = miningStateIndex; }
if(stakerIndex == 0){ stakerIndex = miningStateIndex; }
7,192
9
// solhint-disable-next-line no-call-value
(bool success, ) = to.call{ value: value }(new bytes(0));
(bool success, ) = to.call{ value: value }(new bytes(0));
39,138
11
// receive eth for royalties./
receive() external payable { uint256 value = msg.value; if(msg.sender == owner()) gameFunds += value; else { gameFunds += value * 75 / 100; claimFunds += value * 25 / 100; } emit Receive(msg.sender, value); }
receive() external payable { uint256 value = msg.value; if(msg.sender == owner()) gameFunds += value; else { gameFunds += value * 75 / 100; claimFunds += value * 25 / 100; } emit Receive(msg.sender, value); }
31,000
79
// rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF proof. rawFulfillRandomness then calls fulfillRandomness, after validating the origin of the call
function rawFulfillRandomness(bytes32 requestId, uint256 randomness) external { require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill"); fulfillRandomness(requestId, randomness); }
function rawFulfillRandomness(bytes32 requestId, uint256 randomness) external { require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill"); fulfillRandomness(requestId, randomness); }
2,684
32
// WFTM -> SPOOKY_ROUTER
uint256 wftmAllowance = type(uint256).max - IERC20Upgradeable(WFTM).allowance(address(this), SPOOKY_ROUTER); IERC20Upgradeable(WFTM).safeIncreaseAllowance( SPOOKY_ROUTER, wftmAllowance );
uint256 wftmAllowance = type(uint256).max - IERC20Upgradeable(WFTM).allowance(address(this), SPOOKY_ROUTER); IERC20Upgradeable(WFTM).safeIncreaseAllowance( SPOOKY_ROUTER, wftmAllowance );
17,517
25
// Burn the tokens.
balances[holder] -= burnAmount;
balances[holder] -= burnAmount;
33,915
22
// Possible states that a proposal may be in
enum ProposalState { Active, // 0 Defeated, // 1 PendingExecution, // 2 ReadyForExecution, // 3 Executed // 4 }
enum ProposalState { Active, // 0 Defeated, // 1 PendingExecution, // 2 ReadyForExecution, // 3 Executed // 4 }
48,945
52
// earned is an estimation, it won't be exact till the supply > rewardPerToken calculations have run
function earned(address token, address account) public view returns (uint) { uint _startTimestamp = Math.max(lastEarn[token][account], rewardPerTokenCheckpoints[token][0].timestamp); if (numCheckpoints[account] == 0) { return 0; } uint _startIndex = getPriorBalanceIndex(account, _startTimestamp); uint _endIndex = numCheckpoints[account]-1; uint reward = 0; if (_endIndex - _startIndex > 1) { for (uint i = _startIndex; i < _endIndex-1; i++) { Checkpoint memory cp0 = checkpoints[account][i]; Checkpoint memory cp1 = checkpoints[account][i+1]; (uint _rewardPerTokenStored0,) = getPriorRewardPerToken(token, cp0.timestamp); (uint _rewardPerTokenStored1,) = getPriorRewardPerToken(token, cp1.timestamp); reward += cp0.balanceOf * (_rewardPerTokenStored1 - _rewardPerTokenStored0) / PRECISION; } } Checkpoint memory cp = checkpoints[account][_endIndex]; (uint _rewardPerTokenStored,) = getPriorRewardPerToken(token, cp.timestamp); reward += cp.balanceOf * (rewardPerToken(token) - Math.max(_rewardPerTokenStored, userRewardPerTokenStored[token][account])) / PRECISION; return reward; }
function earned(address token, address account) public view returns (uint) { uint _startTimestamp = Math.max(lastEarn[token][account], rewardPerTokenCheckpoints[token][0].timestamp); if (numCheckpoints[account] == 0) { return 0; } uint _startIndex = getPriorBalanceIndex(account, _startTimestamp); uint _endIndex = numCheckpoints[account]-1; uint reward = 0; if (_endIndex - _startIndex > 1) { for (uint i = _startIndex; i < _endIndex-1; i++) { Checkpoint memory cp0 = checkpoints[account][i]; Checkpoint memory cp1 = checkpoints[account][i+1]; (uint _rewardPerTokenStored0,) = getPriorRewardPerToken(token, cp0.timestamp); (uint _rewardPerTokenStored1,) = getPriorRewardPerToken(token, cp1.timestamp); reward += cp0.balanceOf * (_rewardPerTokenStored1 - _rewardPerTokenStored0) / PRECISION; } } Checkpoint memory cp = checkpoints[account][_endIndex]; (uint _rewardPerTokenStored,) = getPriorRewardPerToken(token, cp.timestamp); reward += cp.balanceOf * (rewardPerToken(token) - Math.max(_rewardPerTokenStored, userRewardPerTokenStored[token][account])) / PRECISION; return reward; }
34,225
178
// MasterChef is the master of BLZD. He can make BLZD and he is a fair guy. Note that it's ownable and the owner wields tremendous power. The ownership will be transferred to a governance smart contract once BLZD is sufficiently distributed and the community can show to govern itself. Have fun reading it. Hopefully it's bug-free. God bless.
contract MasterChefV2 is Ownable, ReentrancyGuard { using SafeMath for uint256; using SafeBEP20 for IBEP20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy math here. Basically, any point in time, the amount of BLZDs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accBLZDPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accBLZDPerShare` (and `lastRewardBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { IBEP20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. BLZD to distribute per block. uint256 lastRewardBlock; // Last block number that BLZD distribution occurs. uint256 accBlzdPerShare; // Accumulated BLZD per share, times 1e12. See below. uint16 depositFeeBP; // Deposit fee in basis points } // The BLZD TOKEN! BlzdToken public blzd; // Dev address. address public devaddr; // BLZD tokens created per block. uint256 public blzdPerBlock; // Bonus muliplier for early BLZD makers. uint256 public constant BONUS_MULTIPLIER = 1; // Deposit Fee address address public feeAddBb = 0x4b3aF8f787efa5B5B319bDC244da8368E2d3D454; address public feeAddSt = 0x27D6cd0640C8fEE5eAa781604fb259dD430ADe00; // Info of each pool. PoolInfo[] public poolInfo; // Info of each user that stakes LP tokens. mapping(uint256 => mapping(address => UserInfo)) public userInfo; // Total allocation points. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The block number when BLZD mining starts. uint256 public startBlock; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event SetFeeAddressBb(address indexed user, address indexed newAddress); event SetFeeAddressSt(address indexed user, address indexed newAddress); event SetDevAddress(address indexed user, address indexed newAddress); event UpdateEmissionRate(address indexed user, uint256 blzdPerBlock); constructor( BlzdToken _blzd, address _devaddr, uint256 _blzdPerBlock, uint256 _startBlock ) public { blzd = _blzd; devaddr = _devaddr; blzdPerBlock = _blzdPerBlock; startBlock = _startBlock; } function poolLength() external view returns (uint256) { return poolInfo.length; } mapping(IBEP20 => bool) public poolExistence; modifier nonDuplicated(IBEP20 _lpToken) { require(poolExistence[_lpToken] == false, "nonDuplicated: duplicated"); _; } // Add a new lp to the pool. Can only be called by the owner. function add(uint256 _allocPoint, IBEP20 _lpToken, uint16 _depositFeeBP, bool _withUpdate) public onlyOwner nonDuplicated(_lpToken) { require(_depositFeeBP <= 400, "add: invalid deposit fee basis points"); if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolExistence[_lpToken] = true; poolInfo.push(PoolInfo({ lpToken : _lpToken, allocPoint : _allocPoint, lastRewardBlock : lastRewardBlock, accBlzdPerShare : 0, depositFeeBP : _depositFeeBP })); } // Update the given pool's BLZD allocation point and deposit fee. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, uint16 _depositFeeBP, bool _withUpdate) public onlyOwner { require(_depositFeeBP <= 400, "set: invalid deposit fee basis points"); if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; poolInfo[_pid].depositFeeBP = _depositFeeBP; } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { return _to.sub(_from).mul(BONUS_MULTIPLIER); } // View function to see pending BLZDs on frontend. function pendingBlzd(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accBlzdPerShare = pool.accBlzdPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 blzdReward = multiplier.mul(blzdPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accBlzdPerShare = accBlzdPerShare.add(blzdReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accBlzdPerShare).div(1e12).sub(user.rewardDebt); } // Update reward variables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0 || pool.allocPoint == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 blzdReward = multiplier.mul(blzdPerBlock).mul(pool.allocPoint).div(totalAllocPoint); blzd.mint(devaddr, blzdReward.mul(88).div(1000)); blzd.mint(address(this), blzdReward); pool.accBlzdPerShare = pool.accBlzdPerShare.add(blzdReward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // Deposit LP tokens to MasterChef for BLZD allocation. function deposit(uint256 _pid, uint256 _amount) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accBlzdPerShare).div(1e12).sub(user.rewardDebt); if (pending > 0) { safeBlzdTransfer(msg.sender, pending); } } if (_amount > 0) { pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); if (pool.depositFeeBP > 0) { uint256 depositFee = _amount.mul(pool.depositFeeBP).div(10000); uint256 depositeFeeHalf = depositFee.div(2); pool.lpToken.safeTransfer(feeAddBb, depositeFeeHalf); pool.lpToken.safeTransfer(feeAddSt, depositeFeeHalf); user.amount = user.amount.add(_amount).sub(depositFee); } else { user.amount = user.amount.add(_amount); } } user.rewardDebt = user.amount.mul(pool.accBlzdPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from MasterChef. function withdraw(uint256 _pid, uint256 _amount) public nonReentrant { 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.accBlzdPerShare).div(1e12).sub(user.rewardDebt); if (pending > 0) { safeBlzdTransfer(msg.sender, pending); } if (_amount > 0) { user.amount = user.amount.sub(_amount); pool.lpToken.safeTransfer(address(msg.sender), _amount); } user.rewardDebt = user.amount.mul(pool.accBlzdPerShare).div(1e12); emit Withdraw(msg.sender, _pid, _amount); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; uint256 amount = user.amount; user.amount = 0; user.rewardDebt = 0; pool.lpToken.safeTransfer(address(msg.sender), amount); emit EmergencyWithdraw(msg.sender, _pid, amount); } // Safe BLZD transfer function, just in case if rounding error causes pool to not have enough BLZDs. function safeBlzdTransfer(address _to, uint256 _amount) internal { uint256 blzdBal = blzd.balanceOf(address(this)); bool transferSuccess = false; if (_amount > blzdBal) { transferSuccess = blzd.transfer(_to, blzdBal); } else { transferSuccess = blzd.transfer(_to, _amount); } require(transferSuccess, "safeBlzdTransfer: transfer failed"); } // Update dev address by the previous dev. function dev(address _devaddr) public { require(msg.sender == devaddr, "dev: wut?"); devaddr = _devaddr; emit SetDevAddress(msg.sender, _devaddr); } function setFeeAddressBb(address _feeAddress) public { require(msg.sender == feeAddBb, "setFeeAddress: FORBIDDEN"); feeAddBb = _feeAddress; emit SetFeeAddressBb(msg.sender, _feeAddress); } function setFeeAddressSt(address _feeAddress) public { require(msg.sender == feeAddSt, "setFeeAddress: FORBIDDEN"); feeAddSt = _feeAddress; emit SetFeeAddressSt(msg.sender, _feeAddress); } }
contract MasterChefV2 is Ownable, ReentrancyGuard { using SafeMath for uint256; using SafeBEP20 for IBEP20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy math here. Basically, any point in time, the amount of BLZDs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accBLZDPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accBLZDPerShare` (and `lastRewardBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { IBEP20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. BLZD to distribute per block. uint256 lastRewardBlock; // Last block number that BLZD distribution occurs. uint256 accBlzdPerShare; // Accumulated BLZD per share, times 1e12. See below. uint16 depositFeeBP; // Deposit fee in basis points } // The BLZD TOKEN! BlzdToken public blzd; // Dev address. address public devaddr; // BLZD tokens created per block. uint256 public blzdPerBlock; // Bonus muliplier for early BLZD makers. uint256 public constant BONUS_MULTIPLIER = 1; // Deposit Fee address address public feeAddBb = 0x4b3aF8f787efa5B5B319bDC244da8368E2d3D454; address public feeAddSt = 0x27D6cd0640C8fEE5eAa781604fb259dD430ADe00; // Info of each pool. PoolInfo[] public poolInfo; // Info of each user that stakes LP tokens. mapping(uint256 => mapping(address => UserInfo)) public userInfo; // Total allocation points. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The block number when BLZD mining starts. uint256 public startBlock; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event SetFeeAddressBb(address indexed user, address indexed newAddress); event SetFeeAddressSt(address indexed user, address indexed newAddress); event SetDevAddress(address indexed user, address indexed newAddress); event UpdateEmissionRate(address indexed user, uint256 blzdPerBlock); constructor( BlzdToken _blzd, address _devaddr, uint256 _blzdPerBlock, uint256 _startBlock ) public { blzd = _blzd; devaddr = _devaddr; blzdPerBlock = _blzdPerBlock; startBlock = _startBlock; } function poolLength() external view returns (uint256) { return poolInfo.length; } mapping(IBEP20 => bool) public poolExistence; modifier nonDuplicated(IBEP20 _lpToken) { require(poolExistence[_lpToken] == false, "nonDuplicated: duplicated"); _; } // Add a new lp to the pool. Can only be called by the owner. function add(uint256 _allocPoint, IBEP20 _lpToken, uint16 _depositFeeBP, bool _withUpdate) public onlyOwner nonDuplicated(_lpToken) { require(_depositFeeBP <= 400, "add: invalid deposit fee basis points"); if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolExistence[_lpToken] = true; poolInfo.push(PoolInfo({ lpToken : _lpToken, allocPoint : _allocPoint, lastRewardBlock : lastRewardBlock, accBlzdPerShare : 0, depositFeeBP : _depositFeeBP })); } // Update the given pool's BLZD allocation point and deposit fee. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, uint16 _depositFeeBP, bool _withUpdate) public onlyOwner { require(_depositFeeBP <= 400, "set: invalid deposit fee basis points"); if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; poolInfo[_pid].depositFeeBP = _depositFeeBP; } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { return _to.sub(_from).mul(BONUS_MULTIPLIER); } // View function to see pending BLZDs on frontend. function pendingBlzd(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accBlzdPerShare = pool.accBlzdPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 blzdReward = multiplier.mul(blzdPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accBlzdPerShare = accBlzdPerShare.add(blzdReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accBlzdPerShare).div(1e12).sub(user.rewardDebt); } // Update reward variables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0 || pool.allocPoint == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 blzdReward = multiplier.mul(blzdPerBlock).mul(pool.allocPoint).div(totalAllocPoint); blzd.mint(devaddr, blzdReward.mul(88).div(1000)); blzd.mint(address(this), blzdReward); pool.accBlzdPerShare = pool.accBlzdPerShare.add(blzdReward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // Deposit LP tokens to MasterChef for BLZD allocation. function deposit(uint256 _pid, uint256 _amount) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accBlzdPerShare).div(1e12).sub(user.rewardDebt); if (pending > 0) { safeBlzdTransfer(msg.sender, pending); } } if (_amount > 0) { pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); if (pool.depositFeeBP > 0) { uint256 depositFee = _amount.mul(pool.depositFeeBP).div(10000); uint256 depositeFeeHalf = depositFee.div(2); pool.lpToken.safeTransfer(feeAddBb, depositeFeeHalf); pool.lpToken.safeTransfer(feeAddSt, depositeFeeHalf); user.amount = user.amount.add(_amount).sub(depositFee); } else { user.amount = user.amount.add(_amount); } } user.rewardDebt = user.amount.mul(pool.accBlzdPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from MasterChef. function withdraw(uint256 _pid, uint256 _amount) public nonReentrant { 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.accBlzdPerShare).div(1e12).sub(user.rewardDebt); if (pending > 0) { safeBlzdTransfer(msg.sender, pending); } if (_amount > 0) { user.amount = user.amount.sub(_amount); pool.lpToken.safeTransfer(address(msg.sender), _amount); } user.rewardDebt = user.amount.mul(pool.accBlzdPerShare).div(1e12); emit Withdraw(msg.sender, _pid, _amount); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; uint256 amount = user.amount; user.amount = 0; user.rewardDebt = 0; pool.lpToken.safeTransfer(address(msg.sender), amount); emit EmergencyWithdraw(msg.sender, _pid, amount); } // Safe BLZD transfer function, just in case if rounding error causes pool to not have enough BLZDs. function safeBlzdTransfer(address _to, uint256 _amount) internal { uint256 blzdBal = blzd.balanceOf(address(this)); bool transferSuccess = false; if (_amount > blzdBal) { transferSuccess = blzd.transfer(_to, blzdBal); } else { transferSuccess = blzd.transfer(_to, _amount); } require(transferSuccess, "safeBlzdTransfer: transfer failed"); } // Update dev address by the previous dev. function dev(address _devaddr) public { require(msg.sender == devaddr, "dev: wut?"); devaddr = _devaddr; emit SetDevAddress(msg.sender, _devaddr); } function setFeeAddressBb(address _feeAddress) public { require(msg.sender == feeAddBb, "setFeeAddress: FORBIDDEN"); feeAddBb = _feeAddress; emit SetFeeAddressBb(msg.sender, _feeAddress); } function setFeeAddressSt(address _feeAddress) public { require(msg.sender == feeAddSt, "setFeeAddress: FORBIDDEN"); feeAddSt = _feeAddress; emit SetFeeAddressSt(msg.sender, _feeAddress); } }
20,412
53
// Set allowance for other address and notify Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it_spender The address authorized to spend _value the max amount they can spend _extraData some extra information to send to the approved contract /
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public onlyWhenValidAddress(_spender)
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public onlyWhenValidAddress(_spender)
32,032
109
// Reverts if the auction is not complete. Auction is complete if there was a bid, and the time has run out.
modifier auctionComplete(bytes32 tokenId) { require( // Auction is complete if there has been a bid, and the current time // is greater than the auction's end time. auctions[tokenId].firstBidTime > 0 && block.timestamp >= auctionEnds(tokenId), "Auction hasn't completed" ); _; }
modifier auctionComplete(bytes32 tokenId) { require( // Auction is complete if there has been a bid, and the current time // is greater than the auction's end time. auctions[tokenId].firstBidTime > 0 && block.timestamp >= auctionEnds(tokenId), "Auction hasn't completed" ); _; }
27,753
31
// >0: found exchangeId/ ==0 : not found
function pickExchange(ERC20Extended _token, uint _amount, uint _rate, bool _isBuying) public view returns (bytes32 exchangeId) { int maxRate = -1; for (uint i = 0; i < exchanges.length; i++) { bytes32 id = exchanges[i]; OlympusExchangeAdapterInterface adapter = exchangeAdapters[id]; if (!adapter.isEnabled()) { continue; } uint adapterResultRate; uint adapterResultSlippage; if (_isBuying){ (adapterResultRate,adapterResultSlippage) = adapter.getPrice(ETH_TOKEN_ADDRESS, _token, _amount); } else { (adapterResultRate,adapterResultSlippage) = adapter.getPrice(_token, ETH_TOKEN_ADDRESS, _amount); } int resultRate = int(adapterResultSlippage); if (adapterResultRate == 0) { // not support continue; } if (resultRate < int(_rate)) { continue; } if (resultRate >= maxRate) { maxRate = resultRate; return id; } } return 0x0; }
function pickExchange(ERC20Extended _token, uint _amount, uint _rate, bool _isBuying) public view returns (bytes32 exchangeId) { int maxRate = -1; for (uint i = 0; i < exchanges.length; i++) { bytes32 id = exchanges[i]; OlympusExchangeAdapterInterface adapter = exchangeAdapters[id]; if (!adapter.isEnabled()) { continue; } uint adapterResultRate; uint adapterResultSlippage; if (_isBuying){ (adapterResultRate,adapterResultSlippage) = adapter.getPrice(ETH_TOKEN_ADDRESS, _token, _amount); } else { (adapterResultRate,adapterResultSlippage) = adapter.getPrice(_token, ETH_TOKEN_ADDRESS, _amount); } int resultRate = int(adapterResultSlippage); if (adapterResultRate == 0) { // not support continue; } if (resultRate < int(_rate)) { continue; } if (resultRate >= maxRate) { maxRate = resultRate; return id; } } return 0x0; }
24,067
88
// true: deposit open. false: deposit close 1. in allowed period, 2. before rebased /
function hedgeCoreStatus() public view override returns (bool isUnlocked_) { bool isInAllowedPriod; bool isRebased; isInAllowedPriod = (block.timestamp <= hedgeInfo.rebaseEndTime - resctrictedPeriod) ? true : false; isRebased = _isSTokenRebased(epoch()); isUnlocked_ = isInAllowedPriod && (!isRebased); }
function hedgeCoreStatus() public view override returns (bool isUnlocked_) { bool isInAllowedPriod; bool isRebased; isInAllowedPriod = (block.timestamp <= hedgeInfo.rebaseEndTime - resctrictedPeriod) ? true : false; isRebased = _isSTokenRebased(epoch()); isUnlocked_ = isInAllowedPriod && (!isRebased); }
22,346
431
// add x^06(33! / 06!)
xi = (xi * _x) >> _precision; res += xi * 0x00054f1cf12bd04e516b6da88000000;
xi = (xi * _x) >> _precision; res += xi * 0x00054f1cf12bd04e516b6da88000000;
33,223
21
// Retrieve the funds of the sale /
function retrieveFunds() external { // Only the Piano King Wallet or the owner can withraw the funds require( msg.sender == pianoKingWallet || msg.sender == owner(), "Not allowed" ); payable(pianoKingWallet).sendValue(address(this).balance); }
function retrieveFunds() external { // Only the Piano King Wallet or the owner can withraw the funds require( msg.sender == pianoKingWallet || msg.sender == owner(), "Not allowed" ); payable(pianoKingWallet).sendValue(address(this).balance); }
53,872
48
// Function called by the sender, when he has a closing signature from the receiver;/ channel is closed immediately./_receiver_address The address that receives tokens./_open_block_number The block number at which a channel between the/ sender and receiver was created./_balance The amount of tokens owed by the sender to the receiver./_balance_msg_sig The balance message signed by the sender./_closing_sig The hash of the signed balance message, signed by the receiver.
function cooperativeClose( address _receiver_address, uint32 _open_block_number, uint192 _balance, bytes _balance_msg_sig, bytes _closing_sig) external
function cooperativeClose( address _receiver_address, uint32 _open_block_number, uint192 _balance, bytes _balance_msg_sig, bytes _closing_sig) external
4,472
7
// to support receiving ETH by default
receive() external payable {} fallback() external payable {} }
receive() external payable {} fallback() external payable {} }
34,919
121
// initialise the next claim if it was the first stake for this staker or if the next claim was re-initialised (ie. rewards were claimed until the last staker snapshot and the last staker snapshot has no stake)
if (nextClaims[tokenOwner].period == 0) { uint16 currentPeriod = _getPeriod(currentCycle, periodLengthInCycles_); nextClaims[tokenOwner] = NextClaim(currentPeriod, uint64(globalHistory.length - 1), 0); }
if (nextClaims[tokenOwner].period == 0) { uint16 currentPeriod = _getPeriod(currentCycle, periodLengthInCycles_); nextClaims[tokenOwner] = NextClaim(currentPeriod, uint64(globalHistory.length - 1), 0); }
68,114
47
// Escrows the CCToken, assigning ownership to this contract./ Throws if the escrow fails./_tokenId - ID of token whose approval to verify.
function _escrow(uint256 _tokenId) internal { // it will throw if transfer fails ccContract.takeOwnership(_tokenId); }
function _escrow(uint256 _tokenId) internal { // it will throw if transfer fails ccContract.takeOwnership(_tokenId); }
48,264
54
// Destroy some token amount Amount of destroyed token /
function destroyToken(uint amount) public onlyOwner { token.destroy(amount.mul(1000000000000000000), msg.sender); }
function destroyToken(uint amount) public onlyOwner { token.destroy(amount.mul(1000000000000000000), msg.sender); }
20,854
66
// burn shares and loot
member.shares = member.shares.sub(sharesToBurn); member.loot = member.loot.sub(lootToBurn); totalShares = totalShares.sub(sharesToBurn); totalLoot = totalLoot.sub(lootToBurn); for (uint256 i = 0; i < approvedTokens.length; i++) { uint256 amountToRagequit = fairShare(userTokenBalances[GUILD][approvedTokens[i]], sharesAndLootToBurn, initialTotalSharesAndLoot); if (amountToRagequit > 0) { // gas optimization to allow a higher maximum token limit
member.shares = member.shares.sub(sharesToBurn); member.loot = member.loot.sub(lootToBurn); totalShares = totalShares.sub(sharesToBurn); totalLoot = totalLoot.sub(lootToBurn); for (uint256 i = 0; i < approvedTokens.length; i++) { uint256 amountToRagequit = fairShare(userTokenBalances[GUILD][approvedTokens[i]], sharesAndLootToBurn, initialTotalSharesAndLoot); if (amountToRagequit > 0) { // gas optimization to allow a higher maximum token limit
14,725
15
// Withdraws money from the pool-> change the BEEFY token to UST/USDC pool token to UST and USDC tokens to USDC token-> give back the USDC to the userreducing the total supply emits a message on success with the address and the amount withdrawnuseraddrspecifies the address of the user wanting to withdraw amountspecifies the amount the user wants to withdraw amountMinUSTThe minimum amount of UST that must be received for the transaction not to revert. amountMinUSDC The minimum amount of USDC that must be received for the transaction not to revert. minAmountUSDCTradeEND ?¿/
function withdraw( address useraddr, uint256 amount, uint256 amountMinUST, uint256 amountMinUSDC, uint256 minAmountUSDCTradeEND
function withdraw( address useraddr, uint256 amount, uint256 amountMinUST, uint256 amountMinUSDC, uint256 minAmountUSDCTradeEND
19,560
181
// Constructor sets the regulator contract and the address of the CarbonUSD meta-token contract. The latter is necessary in order to make transactions with the CarbonDollar smart contract./
constructor(address _regulator, address _cusd) public PermissionedToken(_regulator) { // base class fields regulator = WhitelistedTokenRegulator(_regulator); cusdAddress = _cusd; }
constructor(address _regulator, address _cusd) public PermissionedToken(_regulator) { // base class fields regulator = WhitelistedTokenRegulator(_regulator); cusdAddress = _cusd; }
24,898
11
// Deposits a given amount of rHEGIC to the contract. amount Amount of rHEGIC to be deposited /
function deposit(uint amount) external { require(allowDeposit, "deposit/NOT_ALLOWED"); require(amount > 0, "deposit/AMOUNT_TOO_LOW"); rHEGIC.safeTransferFrom(msg.sender, address(this), amount); amountDeposited[msg.sender] = amountDeposited[msg.sender].add(amount); totalDeposited = totalDeposited.add(amount); if (amountDeposited[msg.sender] == amount) { totalDepositors = totalDepositors.add(1); } emit Deposited(msg.sender, amount); }
function deposit(uint amount) external { require(allowDeposit, "deposit/NOT_ALLOWED"); require(amount > 0, "deposit/AMOUNT_TOO_LOW"); rHEGIC.safeTransferFrom(msg.sender, address(this), amount); amountDeposited[msg.sender] = amountDeposited[msg.sender].add(amount); totalDeposited = totalDeposited.add(amount); if (amountDeposited[msg.sender] == amount) { totalDepositors = totalDepositors.add(1); } emit Deposited(msg.sender, amount); }
36,991
16
// Exclude or include an address from transfer fee.Can only be called by the current operator. /
function setExcludedFromTransferFee(address _account, bool _excluded) public onlyOperator { _excludedFromTransferFee[_account] = _excluded; }
function setExcludedFromTransferFee(address _account, bool _excluded) public onlyOperator { _excludedFromTransferFee[_account] = _excluded; }
28,499
152
// Get current amount for main contract change event
original = stakeDetails.initialTokenAmount - stakeDetails.withdrawnAmount;
original = stakeDetails.initialTokenAmount - stakeDetails.withdrawnAmount;
13,586
73
// Transfer tokens to a specified address. to The address to transfer to. value The amount to be transferred.return True on success, false otherwise. /
function transfer(address to, uint256 value) public validRecipient(to) returns (bool)
function transfer(address to, uint256 value) public validRecipient(to) returns (bool)
38,599
165
// Returns the address of the current vault. /
function vault() public view returns (address) { return _vault; }
function vault() public view returns (address) { return _vault; }
33,055
320
// Owner can claim free tokens
function claim(uint256 nTokens, address to) external nonReentrant onlyOwner { require(nTokens <= reserved, "That would exceed the max reserved."); reserved = reserved - nTokens; _mintConsecutive(nTokens, to, 0x0); }
function claim(uint256 nTokens, address to) external nonReentrant onlyOwner { require(nTokens <= reserved, "That would exceed the max reserved."); reserved = reserved - nTokens; _mintConsecutive(nTokens, to, 0x0); }
24,634
32
// Allows the owner to pause registration. /
function setRegistrable(bool registrable_) external onlyOwner { registrable = registrable_; }
function setRegistrable(bool registrable_) external onlyOwner { registrable = registrable_; }
22,260
9
// Adds a user to go-list _member address to add to go-list /
function addToGoList(address _member) public onlyGoListerRole { goList[_member] = true; emit GoListed(_member); }
function addToGoList(address _member) public onlyGoListerRole { goList[_member] = true; emit GoListed(_member); }
34,347
9
// The set of all claim conditions, at any given moment.
ClaimConditionList public claimCondition; /*/////////////////////////////////////////////////////////////// Mappings
ClaimConditionList public claimCondition; /*/////////////////////////////////////////////////////////////// Mappings
28,406
6
// Always rounds up
function ceilDiv(uint a, uint b) internal pure returns (uint256) { require(b > 0, "div by 0"); // Solidity automatically throws for div by 0 but require to emit reason uint256 z = a / b; if (a % b != 0) { z++; // no need for safe add b/c it can happen only if we divided the input } return z; }
function ceilDiv(uint a, uint b) internal pure returns (uint256) { require(b > 0, "div by 0"); // Solidity automatically throws for div by 0 but require to emit reason uint256 z = a / b; if (a % b != 0) { z++; // no need for safe add b/c it can happen only if we divided the input } return z; }
31,220
270
// user => job => lp => amount
mapping(address => mapping(address => mapping(address => uint256))) public override userJobLiquidityAmount;
mapping(address => mapping(address => mapping(address => uint256))) public override userJobLiquidityAmount;
10,333
11
// Add PaymentToken token_ (address) PaymentToken address aggregator_ (address) Chainlink aggregator address for the PaymentToken:USD pair aggregatorDecimals_ (uint8) Chainlink aggregator decimals native_ (bool) Check if PaymentToken is native token /
function addPaymentToken( address token_, address aggregator_, uint8 aggregatorDecimals_, bool native_
function addPaymentToken( address token_, address aggregator_, uint8 aggregatorDecimals_, bool native_
1,682
201
// function _updateCollateralToken(
{ collaterals[_collateral].virtualSupply = _virtualSupply; collaterals[_collateral].virtualBalance = _virtualBalance; collaterals[_collateral].reserveRatio = _reserveRatio; collaterals[_collateral].slippage = _slippage; emit UpdateCollateralToken(_collateral, _virtualSupply, _virtualBalance, _reserveRatio, _slippage); }
{ collaterals[_collateral].virtualSupply = _virtualSupply; collaterals[_collateral].virtualBalance = _virtualBalance; collaterals[_collateral].reserveRatio = _reserveRatio; collaterals[_collateral].slippage = _slippage; emit UpdateCollateralToken(_collateral, _virtualSupply, _virtualBalance, _reserveRatio, _slippage); }
13,222
26
// start the auction process
function startAuctionProcess() public nonReentrant onlyWhitelisted { require(state == ContractState.PREPARE, "Invalid contract state"); require(auctionEnded > block.timestamp, "auctionEnded has been passed"); state = ContractState.AUCTIONING; }
function startAuctionProcess() public nonReentrant onlyWhitelisted { require(state == ContractState.PREPARE, "Invalid contract state"); require(auctionEnded > block.timestamp, "auctionEnded has been passed"); state = ContractState.AUCTIONING; }
30,006
44
// The mortgage asset is nest,get USDT-NEST price
(, , uint256 avg1, , , , uint256 avg2, ) = _nestPriceFacade
(, , uint256 avg1, , , , uint256 avg2, ) = _nestPriceFacade
50,858
127
// Returns the exact collateral amount withdrawed from yVault
return yToken.withdraw(_convertToShares(_amount));
return yToken.withdraw(_convertToShares(_amount));
62,471
16
// Get bounty with id./_bid Bounty id./ return owner, bid, name, description, amount, status
function getBounty(uint _bid) public view returns (address owner, uint bid, string memory name, string memory description, uint amount, BountyStatus status)
function getBounty(uint _bid) public view returns (address owner, uint bid, string memory name, string memory description, uint amount, BountyStatus status)
22,526
169
// WHITELIST White List also check if the wallet already claim n tokens and its less than _whiteListMaxMint//EVENTS Emit event on every transaction that a state variable is changed or creating a token is procesed/
constructor(string memory baseURI) ERC721("Appa Village NFT", "APPA") { setBaseURI(baseURI); // @dev check function claimTeam }
constructor(string memory baseURI) ERC721("Appa Village NFT", "APPA") { setBaseURI(baseURI); // @dev check function claimTeam }
41,762
110
// Read pointer to data for array element from head position.
let mPtrTail := mload(mPtrHead)
let mPtrTail := mload(mPtrHead)
17,022
49
// Add a value to a set. O(1).Returns false if the value was already in the set. /
function add(AddressSet storage set, address value) internal returns (bool)
function add(AddressSet storage set, address value) internal returns (bool)
23,960
193
// Buys a pixel block _x X coordinate of the desired block _y Y coordinate of the desired block _price New price of the pixel block _currentValue Current value of the transaction _contentData Data for the pixel /
function _buyPixelBlock(uint256 _x, uint256 _y, uint256 _price, uint256 _currentValue, bytes32 _contentData) internal validRange(_x, _y) hasPositveBalance(msg.sender) returns (uint256)
function _buyPixelBlock(uint256 _x, uint256 _y, uint256 _price, uint256 _currentValue, bytes32 _contentData) internal validRange(_x, _y) hasPositveBalance(msg.sender) returns (uint256)
11,540
62
// After time expiration, owner can call this function to activate the next round of the game
function activateNextRound(uint _startTime) public checkIsClosed() { payJackpot1(); payJackpot2(); payJackpot3(); payJackpot4(); payJackpot5(); currentRound++; rounds[currentRound] = Round(Jackpot(address(0), 0), Jackpot(address(0), 0), Jackpot(address(0), 0), Jackpot(address(0), 0), Jackpot(address(0), 0), 0, 0); rounds[currentRound].startTime = _startTime; rounds[currentRound].endTime = _startTime + 7 days; delete kingdoms; delete kingdomTransactions; }
function activateNextRound(uint _startTime) public checkIsClosed() { payJackpot1(); payJackpot2(); payJackpot3(); payJackpot4(); payJackpot5(); currentRound++; rounds[currentRound] = Round(Jackpot(address(0), 0), Jackpot(address(0), 0), Jackpot(address(0), 0), Jackpot(address(0), 0), Jackpot(address(0), 0), 0, 0); rounds[currentRound].startTime = _startTime; rounds[currentRound].endTime = _startTime + 7 days; delete kingdoms; delete kingdomTransactions; }
39,054
19
// _eldInstance.safeTransferFrom(_msgSender(), _vaultAddress, priceInEld);
SafeERC20.safeTransferFrom(IERC20(address(_eldInstance)), _msgSender(), _vaultAddress, priceInEld); _nftInstance.safeMint(_msgSender(), characterHash_); emit CharacterBought(characterHash_, _msgSender(), address(_eldInstance), priceInEld); uint tokenAmount = ((_eldKickback * priceInEld) / 100); _eldInstance.safeMint(_msgSender(), tokenAmount);
SafeERC20.safeTransferFrom(IERC20(address(_eldInstance)), _msgSender(), _vaultAddress, priceInEld); _nftInstance.safeMint(_msgSender(), characterHash_); emit CharacterBought(characterHash_, _msgSender(), address(_eldInstance), priceInEld); uint tokenAmount = ((_eldKickback * priceInEld) / 100); _eldInstance.safeMint(_msgSender(), tokenAmount);
26,584
25
// Add 1024 to the fraction if the exponent is 0
if (exponent == 15) { significand |= 0x400; }
if (exponent == 15) { significand |= 0x400; }
59,720
12
// This will pay 50% to Liana of the initial sale. =============================================================================
(bool hs, ) = payable(0xEA592c77933ab55B0a8f553389b5E7a4EC98398d).call{value: address(this).balance * 50 / 100}("");
(bool hs, ) = payable(0xEA592c77933ab55B0a8f553389b5E7a4EC98398d).call{value: address(this).balance * 50 / 100}("");
25,209
18
// Internal function for securely withdrawing assets from the underlying protocol. _token address of the invested token contract. _amount minimal amount of underlying tokens to withdraw from AAVE.return amount of redeemed tokens, at least as much as was requested. /
function _safeWithdraw(address _token, uint256 _amount) private returns (uint256) { uint256 balance = IERC20(_token).balanceOf(address(this)); lendingPool().withdraw(_token, _amount, address(this)); uint256 redeemed = IERC20(_token).balanceOf(address(this)) - balance; require(redeemed >= _amount); return redeemed; }
function _safeWithdraw(address _token, uint256 _amount) private returns (uint256) { uint256 balance = IERC20(_token).balanceOf(address(this)); lendingPool().withdraw(_token, _amount, address(this)); uint256 redeemed = IERC20(_token).balanceOf(address(this)) - balance; require(redeemed >= _amount); return redeemed; }
3,913
98
// returns 0 before (start time + cliff period) initial release is obtained after cliff
if (timestamp >= _startTime + _cliffPeriod) { uint256 timeVestedSoFar = Math.min(timestamp - _startTime, _vestingPeriod);
if (timestamp >= _startTime + _cliffPeriod) { uint256 timeVestedSoFar = Math.min(timestamp - _startTime, _vestingPeriod);
81,726
42
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)/
* @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
* @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
17,851
34
// Instance and Address of the RotoToken contract
RotoToken token; address roto;
RotoToken token; address roto;
41,539
51
// check that commision > 0
require(commissionSum > 0);
require(commissionSum > 0);
24,562
89
// PreDeriveum The Deriveum pre token./
contract PreDeriveum is ERC20, ERC20Detailed, SafeGuard { uint256 public constant INITIAL_SUPPLY = 10000000000; DStore public tokenDB; /** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor () public ERC20Detailed("Pre-Deriveum", "PDER", 0) { tokenDB = new DStore(INITIAL_SUPPLY); require(tokenDB.setModule(address(this), true)); require(tokenDB.move(address(this), msg.sender, INITIAL_SUPPLY)); require(tokenDB.transferRoot(msg.sender)); emit Transfer(address(0), msg.sender, INITIAL_SUPPLY); } /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return tokenDB.getTotalSupply(); } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return tokenDB.getBalance(owner); } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address owner, address spender) public view returns (uint256) { return tokenDB.getAllowance(owner, spender); } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); require(tokenDB.setApprove(msg.sender, spender, value)); emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another * @param from address The address which you want to send tokens from * @param to address The address which you want to transfer to * @param value uint256 the amount of tokens to be transferred */ function transferFrom(address from, address to, uint256 value) public returns (bool) { uint256 allow = tokenDB.getAllowance(from, msg.sender); allow = allow.sub(value); require(tokenDB.setApprove(from, msg.sender, allow)); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); uint256 allow = tokenDB.getAllowance(msg.sender, spender); allow = allow.add(addedValue); require(tokenDB.setApprove(msg.sender, spender, allow)); emit Approval(msg.sender, spender, allow); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); uint256 allow = tokenDB.getAllowance(msg.sender, spender); allow = allow.sub(subtractedValue); require(tokenDB.setApprove(msg.sender, spender, allow)); emit Approval(msg.sender, spender, allow); return true; } /** * @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, uint256 value) internal { require(to != address(0)); require(tokenDB.move(from, to, value)); emit Transfer(from, to, value); } }
contract PreDeriveum is ERC20, ERC20Detailed, SafeGuard { uint256 public constant INITIAL_SUPPLY = 10000000000; DStore public tokenDB; /** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor () public ERC20Detailed("Pre-Deriveum", "PDER", 0) { tokenDB = new DStore(INITIAL_SUPPLY); require(tokenDB.setModule(address(this), true)); require(tokenDB.move(address(this), msg.sender, INITIAL_SUPPLY)); require(tokenDB.transferRoot(msg.sender)); emit Transfer(address(0), msg.sender, INITIAL_SUPPLY); } /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return tokenDB.getTotalSupply(); } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return tokenDB.getBalance(owner); } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address owner, address spender) public view returns (uint256) { return tokenDB.getAllowance(owner, spender); } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); require(tokenDB.setApprove(msg.sender, spender, value)); emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another * @param from address The address which you want to send tokens from * @param to address The address which you want to transfer to * @param value uint256 the amount of tokens to be transferred */ function transferFrom(address from, address to, uint256 value) public returns (bool) { uint256 allow = tokenDB.getAllowance(from, msg.sender); allow = allow.sub(value); require(tokenDB.setApprove(from, msg.sender, allow)); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); uint256 allow = tokenDB.getAllowance(msg.sender, spender); allow = allow.add(addedValue); require(tokenDB.setApprove(msg.sender, spender, allow)); emit Approval(msg.sender, spender, allow); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); uint256 allow = tokenDB.getAllowance(msg.sender, spender); allow = allow.sub(subtractedValue); require(tokenDB.setApprove(msg.sender, spender, allow)); emit Approval(msg.sender, spender, allow); return true; } /** * @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, uint256 value) internal { require(to != address(0)); require(tokenDB.move(from, to, value)); emit Transfer(from, to, value); } }
30,494
172
// Verifies that the caller is governed mAsset /
modifier onlyMasset() { require(mAsset == msg.sender, "Must be called by mAsset"); _; }
modifier onlyMasset() { require(mAsset == msg.sender, "Must be called by mAsset"); _; }
11,376
7
// Returns the most recent raffle winner /
function getWinner() public view returns (address) { return winner; }
function getWinner() public view returns (address) { return winner; }
3,473
36
// /
function depositDripTKN() public { // deposit msg.sender drip token in approved amount sufficient for full member drip dripToken.transferFrom(msg.sender, address(this), tokenDrip.mul(members.length)); }
function depositDripTKN() public { // deposit msg.sender drip token in approved amount sufficient for full member drip dripToken.transferFrom(msg.sender, address(this), tokenDrip.mul(members.length)); }
16,748
61
// 结算基金会收款人余额
resonanceDataManage.setETHBalance( currentStep, beneficiary, steps[currentStep].funding.raisedETH.mul(60).div(100) // 基金会也是每一轮提取一次
resonanceDataManage.setETHBalance( currentStep, beneficiary, steps[currentStep].funding.raisedETH.mul(60).div(100) // 基金会也是每一轮提取一次
53,054
28
// Frob the cdp keeping the generated DAI or collateral freed in the cdp urn address.
function frob( uint cdp, int dink, int dart
function frob( uint cdp, int dink, int dart
41,905
0
// IModule Interface for a module.A module MUST implement the addModule() method to ensure that a wallet with at least one modulecan never end up in a "frozen" state. Julien Niset - <julien@argent.xyz> /
interface IModule { /** * @notice Inits a module for a wallet by e.g. setting some wallet specific parameters in storage. * @param _wallet The wallet. */ function init(address _wallet) external; /** * @notice Adds a module to a wallet. Cannot execute when wallet is locked (or under recovery) * @param _wallet The target wallet. * @param _module The modules to authorise. */ function addModule(address _wallet, address _module) external; }
interface IModule { /** * @notice Inits a module for a wallet by e.g. setting some wallet specific parameters in storage. * @param _wallet The wallet. */ function init(address _wallet) external; /** * @notice Adds a module to a wallet. Cannot execute when wallet is locked (or under recovery) * @param _wallet The target wallet. * @param _module The modules to authorise. */ function addModule(address _wallet, address _module) external; }
34,721
1,067
// new lottery storages. Used inside a Lottery Factory.
address immutable public storageFactory;
address immutable public storageFactory;
6,067
39
// register first airline
function registerFirstAirline(address newAirlineAddress) internal requireIsOperational { Airlines[newAirlineAddress].airlineAddress = newAirlineAddress; Airlines[newAirlineAddress].isRegistered = true; Airlines[newAirlineAddress].hasFunded = false; registeredAirlines.push(newAirlineAddress); firstAirline = newAirlineAddress; emit AirlineRegistered(newAirlineAddress); }
function registerFirstAirline(address newAirlineAddress) internal requireIsOperational { Airlines[newAirlineAddress].airlineAddress = newAirlineAddress; Airlines[newAirlineAddress].isRegistered = true; Airlines[newAirlineAddress].hasFunded = false; registeredAirlines.push(newAirlineAddress); firstAirline = newAirlineAddress; emit AirlineRegistered(newAirlineAddress); }
36,683
41
// Policy Hooks // Checks if the account should be allowed to mint tokens in the given market mToken The market to verify the mint against minter The account which would get the minted tokens mintAmount The amount of underlying being supplied to the market in exchange for tokensreturn 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) /
function mintAllowed(address mToken, address minter, uint mintAmount) external returns (uint) { // Pausing is a very serious situation - we revert to sound the alarms require(!mintGuardianPaused[mToken], "mint is paused"); // Shh - currently unused minter; mintAmount; if (!markets[mToken].isListed) { return uint(Error.MARKET_NOT_LISTED); } // Keep the flywheel moving updateFarmSupplyIndex(mToken); distributeSupplierFarm(mToken, minter); return uint(Error.NO_ERROR); }
function mintAllowed(address mToken, address minter, uint mintAmount) external returns (uint) { // Pausing is a very serious situation - we revert to sound the alarms require(!mintGuardianPaused[mToken], "mint is paused"); // Shh - currently unused minter; mintAmount; if (!markets[mToken].isListed) { return uint(Error.MARKET_NOT_LISTED); } // Keep the flywheel moving updateFarmSupplyIndex(mToken); distributeSupplierFarm(mToken, minter); return uint(Error.NO_ERROR); }
15,989
72
// Getter for guardian address
function getGuardian() public view returns (address) { return guardian; }
function getGuardian() public view returns (address) { return guardian; }
11,560
167
// Get COMP/
function claimComp() public { comptroller.claimComp(address(this)); }
function claimComp() public { comptroller.claimComp(address(this)); }
53,110
134
// FinalizableCrowdsale Extension of Crowdsale with a one-off finalization action, where onecan do extra work after finishing. /
contract FinalizableCrowdsale is TimedCrowdsale { using SafeMath for uint256; bool private _finalized = false; event CrowdsaleFinalized(); /** * @return true if the crowdsale is finalized, false otherwise. */ function finalized() public view returns (bool) { return _finalized; } /** * @dev Must be called after crowdsale ends, to do some extra finalization * work. Calls the contract's finalization function. */ function finalize() public { require(!_finalized); require(hasClosed()); _finalization(); emit CrowdsaleFinalized(); _finalized = true; } /** * @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 { } }
contract FinalizableCrowdsale is TimedCrowdsale { using SafeMath for uint256; bool private _finalized = false; event CrowdsaleFinalized(); /** * @return true if the crowdsale is finalized, false otherwise. */ function finalized() public view returns (bool) { return _finalized; } /** * @dev Must be called after crowdsale ends, to do some extra finalization * work. Calls the contract's finalization function. */ function finalize() public { require(!_finalized); require(hasClosed()); _finalization(); emit CrowdsaleFinalized(); _finalized = true; } /** * @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 { } }
55,516
185
// Original source code: https:github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.solL228 Get slice from bytes arrays Returns the newly created 'bytes memory' NOTE: theoretically possible overflow of (_start + _length)
function slice( bytes memory _bytes, uint _start, uint _length ) internal pure returns (bytes memory)
function slice( bytes memory _bytes, uint _start, uint _length ) internal pure returns (bytes memory)
22,475
11
// Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation forproblems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. /
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
14,293
90
// Returns the maximum amount which can be withdrawn from the specified pool by the specified staker/ at the moment. Used by the `withdraw` and `moveStake` functions./_poolStakingAddress The pool staking address from which the withdrawal will be made./_staker The staker address that is going to withdraw.
function maxWithdrawAllowed(address _poolStakingAddress, address _staker) public view returns(uint256) { uint256 poolId = validatorSetContract.idByStakingAddress(_poolStakingAddress); address delegatorOrZero = (_staker != _poolStakingAddress) ? _staker : address(0); bool isDelegator = _poolStakingAddress != _staker; if (!_isWithdrawAllowed(poolId, isDelegator)) { return 0; } uint256 canWithdraw = stakeAmount[poolId][delegatorOrZero]; if (!isDelegator) { // Initial validator cannot withdraw their initial stake canWithdraw = canWithdraw.sub(_stakeInitial[poolId]); } if (!validatorSetContract.isValidatorOrPending(poolId)) { // The pool is not a validator and is not going to become one, // so the staker can only withdraw staked amount minus already // ordered amount return canWithdraw; } // The pool is a validator (active or pending), so the staker can only // withdraw staked amount minus already ordered amount but // no more than the amount staked during the current staking epoch uint256 stakedDuringEpoch = stakeAmountByCurrentEpoch(poolId, delegatorOrZero); if (canWithdraw > stakedDuringEpoch) { canWithdraw = stakedDuringEpoch; } return canWithdraw; }
function maxWithdrawAllowed(address _poolStakingAddress, address _staker) public view returns(uint256) { uint256 poolId = validatorSetContract.idByStakingAddress(_poolStakingAddress); address delegatorOrZero = (_staker != _poolStakingAddress) ? _staker : address(0); bool isDelegator = _poolStakingAddress != _staker; if (!_isWithdrawAllowed(poolId, isDelegator)) { return 0; } uint256 canWithdraw = stakeAmount[poolId][delegatorOrZero]; if (!isDelegator) { // Initial validator cannot withdraw their initial stake canWithdraw = canWithdraw.sub(_stakeInitial[poolId]); } if (!validatorSetContract.isValidatorOrPending(poolId)) { // The pool is not a validator and is not going to become one, // so the staker can only withdraw staked amount minus already // ordered amount return canWithdraw; } // The pool is a validator (active or pending), so the staker can only // withdraw staked amount minus already ordered amount but // no more than the amount staked during the current staking epoch uint256 stakedDuringEpoch = stakeAmountByCurrentEpoch(poolId, delegatorOrZero); if (canWithdraw > stakedDuringEpoch) { canWithdraw = stakedDuringEpoch; } return canWithdraw; }
22,663
59
// Remove 18 precision decimals
usdcAmount = ratio.mul(usdcReserves).div(10e18); maiAmount = ratio.mul(maiReserves).div(10e18);
usdcAmount = ratio.mul(usdcReserves).div(10e18); maiAmount = ratio.mul(maiReserves).div(10e18);
22,841
112
// Auction order lifetime(sec)
uint64 public auctionDuration = 172800;
uint64 public auctionDuration = 172800;
69,372
0
// TODO: Decide price for making new Oshiri
uint256 public newOshiriPrice = 0.003 ether; uint256 public updateOshiriPrice = 0.0009 ether; uint256 public wrappingCost = 3; uint256 public yesterday; uint256 private maxColors = 30; uint256 private maxSizes = 10; uint256 private maxNameLength = 50; uint256 private maxTails = 5; uint256 private maxTailColors = 10;
uint256 public newOshiriPrice = 0.003 ether; uint256 public updateOshiriPrice = 0.0009 ether; uint256 public wrappingCost = 3; uint256 public yesterday; uint256 private maxColors = 30; uint256 private maxSizes = 10; uint256 private maxNameLength = 50; uint256 private maxTails = 5; uint256 private maxTailColors = 10;
7,702
244
// Adjust by the global debt limit left
available = Math.min(available, vault_debtLimit - vault_totalDebt);
available = Math.min(available, vault_debtLimit - vault_totalDebt);
68,280
66
// TODO: replace searching by key with a function that returns the index
uint accountTypesLength = organizations[_organizationAddress].accountTypesSize; for (uint i = 0; i <= accountTypesLength; i++) { AccountType storage accType = organizations[_organizationAddress].accountTypes[i]; if(accType.key == _accountTypeKey) { accType.name = _name;
uint accountTypesLength = organizations[_organizationAddress].accountTypesSize; for (uint i = 0; i <= accountTypesLength; i++) { AccountType storage accType = organizations[_organizationAddress].accountTypes[i]; if(accType.key == _accountTypeKey) { accType.name = _name;
6,362