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
34
// Kam Amini <kam@arteq.io> <kam@2b.team> <kam.cpp@gmail.com>// Reviewed and revised by: Masoud Khosravi <masoud_at_2b.team> <mkh_at_arteq.io>/Ali Jafari <ali_at_2b.team> <aj_at_arteq.io>//The admin contract managing all other artèQ contracts// We achieve the followings by using this contract as the admin/ account of any other artèQ contract:// 1) If one or two of the admin private keys are leaked out, other/admins can remove or replace the affected admin accounts.// 2) The contract having this account set as its admin account/cannot perform any adminitrative task without gathering/enough approvals from all admins (more than 50% of the admins/must approve a task).//3) With enough events emitted by this contract, any
contract arteQAdmin is IarteQAdmin { uint public MAX_NR_OF_ADMINS = 10; uint public MIN_NR_OF_ADMINS = 5; mapping (address => uint) private _admins; mapping (address => uint) private _finalizers; mapping (uint256 => uint) private _tasks; mapping (uint256 => mapping(address => uint)) private _taskApprovals; mapping (uint256 => uint) private _taskApprovalsCount; mapping (uint256 => string) private _taskURIs; uint private _nrOfAdmins; uint private _minRequiredNrOfApprovals; uint256 private _taskIdCounter; modifier onlyOneOfAdmins() { require(_admins[msg.sender] == 1, "arteQAdmin: not an admin account"); _; } modifier onlyFinalizer() { require(_finalizers[msg.sender] == 1, "arteQAdmin: not a finalizer account"); _; } modifier taskMustExist(uint256 taskId) { require(_tasks[taskId] == 1, "arteQAdmin: task does not exist"); _; } modifier mustBeOneOfAdmins(address account) { require(_admins[account] == 1, "arteQAdmin: not an admin account"); _; } modifier taskMustBeApproved(uint256 taskId) { require(_taskApprovalsCount[taskId] >= _minRequiredNrOfApprovals, "arteQAdmin: task is not approved"); _; } constructor(address[] memory initialAdmins) { require(initialAdmins.length >= MIN_NR_OF_ADMINS, "arteQAdmin: not enough inital admins"); require(initialAdmins.length <= MAX_NR_OF_ADMINS, "arteQAdmin: max nr of admins exceeded"); _nrOfAdmins = 0; for (uint i = 0; i < initialAdmins.length; i++) { address admin = initialAdmins[i]; _admins[admin] = 1; _nrOfAdmins++; emit AdminAdded(msg.sender, admin); } _minRequiredNrOfApprovals = 1 + uint(initialAdmins.length) / uint(2); emit NewMinRequiredNrOfApprovalsSet(msg.sender, _minRequiredNrOfApprovals); _taskIdCounter = 1; } function minNrOfAdmins() external view virtual override returns (uint) { return MIN_NR_OF_ADMINS; } function maxNrOfAdmins() external view virtual override returns (uint) { return MAX_NR_OF_ADMINS; } function nrOfAdmins() external view virtual override returns (uint) { return _nrOfAdmins; } function minRequiredNrOfApprovals() external view virtual override returns (uint) { return _minRequiredNrOfApprovals; } function isFinalizer(address account) external view virtual override onlyOneOfAdmins returns (bool) { return _finalizers[account] == 1; } function addFinalizer(uint256 taskId, address toBeAdded) external virtual override onlyOneOfAdmins taskMustExist(taskId) taskMustBeApproved(taskId) { require(_finalizers[toBeAdded] == 0, "arteQAdmin: already a finalizer account"); _finalizers[toBeAdded] = 1; emit FinalizerAdded(msg.sender, toBeAdded); // finalize task _tasks[taskId] = 0; emit TaskFinalized(msg.sender, msg.sender, taskId); } function removeFinalizer(uint256 taskId, address toBeRemoved) external virtual override onlyOneOfAdmins taskMustExist(taskId) taskMustBeApproved(taskId) { require(_finalizers[toBeRemoved] == 1, "arteQAdmin: not a finalizer account"); _finalizers[toBeRemoved] = 0; emit FinalizerRemoved(msg.sender, toBeRemoved); // finalize task _tasks[taskId] = 0; emit TaskFinalized(msg.sender, msg.sender, taskId); } function createTask(string memory detailsURI) external virtual override onlyOneOfAdmins { uint256 taskId = _taskIdCounter; _taskIdCounter++; _tasks[taskId] = 1; _taskApprovalsCount[taskId] = 0; _taskURIs[taskId] = detailsURI; emit TaskCreated(msg.sender, taskId, detailsURI); } function taskURI(uint256 taskId) external view virtual override onlyOneOfAdmins taskMustExist(taskId) returns (string memory) { return _taskURIs[taskId]; } function approveTask(uint256 taskId) external virtual override onlyOneOfAdmins taskMustExist(taskId) { require(_taskApprovals[taskId][msg.sender] == 0, "arteQAdmin: already approved"); _taskApprovals[taskId][msg.sender] = 1; _taskApprovalsCount[taskId]++; emit TaskApproved(msg.sender, taskId); } function cancelTaskApproval(uint256 taskId) external virtual override onlyOneOfAdmins taskMustExist(taskId) { require(_taskApprovals[taskId][msg.sender] == 1, "arteQAdmin: no approval to cancel"); _taskApprovals[taskId][msg.sender] = 0; _taskApprovalsCount[taskId]--; emit TaskApprovalCancelled(msg.sender, taskId); } function nrOfApprovals(uint256 taskId) external view virtual override onlyOneOfAdmins taskMustExist(taskId) returns (uint) { return _taskApprovalsCount[taskId]; } function finalizeTask(address origin, uint256 taskId) external virtual override onlyFinalizer mustBeOneOfAdmins(origin) taskMustExist(taskId) taskMustBeApproved(taskId) { _tasks[taskId] = 0; emit TaskFinalized(msg.sender, origin, taskId); } function isAdmin(address account) external view virtual override onlyOneOfAdmins returns (bool) { return _admins[account] == 1; } function addAdmin(uint256 taskId, address toBeAdded) external virtual override onlyOneOfAdmins taskMustExist(taskId) taskMustBeApproved(taskId) { require(_nrOfAdmins < MAX_NR_OF_ADMINS, "arteQAdmin: cannot have more admin accounts"); require(_admins[toBeAdded] == 0, "arteQAdmin: already an admin account"); _admins[toBeAdded] = 1; _nrOfAdmins++; emit AdminAdded(msg.sender, toBeAdded); // adjust min required nr of approvals if (_minRequiredNrOfApprovals < (1 + uint(_nrOfAdmins) / uint(2))) { _minRequiredNrOfApprovals = 1 + uint(_nrOfAdmins) / uint(2); emit NewMinRequiredNrOfApprovalsSet(msg.sender, _minRequiredNrOfApprovals); } // finalize task _tasks[taskId] = 0; emit TaskFinalized(msg.sender, msg.sender, taskId); } function replaceAdmin(uint256 taskId, address toBeRemoved, address toBeReplaced) external virtual override onlyOneOfAdmins taskMustExist(taskId) taskMustBeApproved(taskId) { require(_admins[toBeRemoved] == 1, "arteQAdmin: no admin account found"); require(_admins[toBeReplaced] == 0, "arteQAdmin: already an admin account"); _admins[toBeRemoved] = 0; _admins[toBeReplaced] = 1; emit AdminReplaced(msg.sender, toBeRemoved, toBeReplaced); // finalize task _tasks[taskId] = 0; emit TaskFinalized(msg.sender, msg.sender, taskId); } function removeAdmin(uint256 taskId, address toBeRemoved) external virtual override onlyOneOfAdmins taskMustExist(taskId) taskMustBeApproved(taskId) { require(_nrOfAdmins > MIN_NR_OF_ADMINS, "arteQAdmin: cannot have fewer admin accounts"); require(_admins[toBeRemoved] == 1, "arteQAdmin: no admin account found"); _admins[toBeRemoved] = 0; _nrOfAdmins--; emit AdminRemoved(msg.sender, toBeRemoved); // adjust min required nr of approvals if (_minRequiredNrOfApprovals > _nrOfAdmins) { _minRequiredNrOfApprovals = _nrOfAdmins; emit NewMinRequiredNrOfApprovalsSet(msg.sender, _minRequiredNrOfApprovals); } // finalize task _tasks[taskId] = 0; emit TaskFinalized(msg.sender, msg.sender, taskId); } function setMinRequiredNrOfApprovals(uint256 taskId, uint newMinRequiredNrOfApprovals) external virtual override onlyOneOfAdmins taskMustExist(taskId) taskMustBeApproved(taskId) { require(newMinRequiredNrOfApprovals != _minRequiredNrOfApprovals , "arteQAdmin: same value"); require(newMinRequiredNrOfApprovals > uint(_nrOfAdmins) / uint(2) , "arteQAdmin: value is too low"); require(newMinRequiredNrOfApprovals <= _nrOfAdmins, "arteQAdmin: value is too high"); _minRequiredNrOfApprovals = newMinRequiredNrOfApprovals; emit NewMinRequiredNrOfApprovalsSet(msg.sender, _minRequiredNrOfApprovals); // finalize task _tasks[taskId] = 0; emit TaskFinalized(msg.sender, msg.sender, taskId); } receive() external payable { revert("arteQAdmin: cannot accept ether"); } fallback() external payable { revert("arteQAdmin: cannot accept ether"); } }
contract arteQAdmin is IarteQAdmin { uint public MAX_NR_OF_ADMINS = 10; uint public MIN_NR_OF_ADMINS = 5; mapping (address => uint) private _admins; mapping (address => uint) private _finalizers; mapping (uint256 => uint) private _tasks; mapping (uint256 => mapping(address => uint)) private _taskApprovals; mapping (uint256 => uint) private _taskApprovalsCount; mapping (uint256 => string) private _taskURIs; uint private _nrOfAdmins; uint private _minRequiredNrOfApprovals; uint256 private _taskIdCounter; modifier onlyOneOfAdmins() { require(_admins[msg.sender] == 1, "arteQAdmin: not an admin account"); _; } modifier onlyFinalizer() { require(_finalizers[msg.sender] == 1, "arteQAdmin: not a finalizer account"); _; } modifier taskMustExist(uint256 taskId) { require(_tasks[taskId] == 1, "arteQAdmin: task does not exist"); _; } modifier mustBeOneOfAdmins(address account) { require(_admins[account] == 1, "arteQAdmin: not an admin account"); _; } modifier taskMustBeApproved(uint256 taskId) { require(_taskApprovalsCount[taskId] >= _minRequiredNrOfApprovals, "arteQAdmin: task is not approved"); _; } constructor(address[] memory initialAdmins) { require(initialAdmins.length >= MIN_NR_OF_ADMINS, "arteQAdmin: not enough inital admins"); require(initialAdmins.length <= MAX_NR_OF_ADMINS, "arteQAdmin: max nr of admins exceeded"); _nrOfAdmins = 0; for (uint i = 0; i < initialAdmins.length; i++) { address admin = initialAdmins[i]; _admins[admin] = 1; _nrOfAdmins++; emit AdminAdded(msg.sender, admin); } _minRequiredNrOfApprovals = 1 + uint(initialAdmins.length) / uint(2); emit NewMinRequiredNrOfApprovalsSet(msg.sender, _minRequiredNrOfApprovals); _taskIdCounter = 1; } function minNrOfAdmins() external view virtual override returns (uint) { return MIN_NR_OF_ADMINS; } function maxNrOfAdmins() external view virtual override returns (uint) { return MAX_NR_OF_ADMINS; } function nrOfAdmins() external view virtual override returns (uint) { return _nrOfAdmins; } function minRequiredNrOfApprovals() external view virtual override returns (uint) { return _minRequiredNrOfApprovals; } function isFinalizer(address account) external view virtual override onlyOneOfAdmins returns (bool) { return _finalizers[account] == 1; } function addFinalizer(uint256 taskId, address toBeAdded) external virtual override onlyOneOfAdmins taskMustExist(taskId) taskMustBeApproved(taskId) { require(_finalizers[toBeAdded] == 0, "arteQAdmin: already a finalizer account"); _finalizers[toBeAdded] = 1; emit FinalizerAdded(msg.sender, toBeAdded); // finalize task _tasks[taskId] = 0; emit TaskFinalized(msg.sender, msg.sender, taskId); } function removeFinalizer(uint256 taskId, address toBeRemoved) external virtual override onlyOneOfAdmins taskMustExist(taskId) taskMustBeApproved(taskId) { require(_finalizers[toBeRemoved] == 1, "arteQAdmin: not a finalizer account"); _finalizers[toBeRemoved] = 0; emit FinalizerRemoved(msg.sender, toBeRemoved); // finalize task _tasks[taskId] = 0; emit TaskFinalized(msg.sender, msg.sender, taskId); } function createTask(string memory detailsURI) external virtual override onlyOneOfAdmins { uint256 taskId = _taskIdCounter; _taskIdCounter++; _tasks[taskId] = 1; _taskApprovalsCount[taskId] = 0; _taskURIs[taskId] = detailsURI; emit TaskCreated(msg.sender, taskId, detailsURI); } function taskURI(uint256 taskId) external view virtual override onlyOneOfAdmins taskMustExist(taskId) returns (string memory) { return _taskURIs[taskId]; } function approveTask(uint256 taskId) external virtual override onlyOneOfAdmins taskMustExist(taskId) { require(_taskApprovals[taskId][msg.sender] == 0, "arteQAdmin: already approved"); _taskApprovals[taskId][msg.sender] = 1; _taskApprovalsCount[taskId]++; emit TaskApproved(msg.sender, taskId); } function cancelTaskApproval(uint256 taskId) external virtual override onlyOneOfAdmins taskMustExist(taskId) { require(_taskApprovals[taskId][msg.sender] == 1, "arteQAdmin: no approval to cancel"); _taskApprovals[taskId][msg.sender] = 0; _taskApprovalsCount[taskId]--; emit TaskApprovalCancelled(msg.sender, taskId); } function nrOfApprovals(uint256 taskId) external view virtual override onlyOneOfAdmins taskMustExist(taskId) returns (uint) { return _taskApprovalsCount[taskId]; } function finalizeTask(address origin, uint256 taskId) external virtual override onlyFinalizer mustBeOneOfAdmins(origin) taskMustExist(taskId) taskMustBeApproved(taskId) { _tasks[taskId] = 0; emit TaskFinalized(msg.sender, origin, taskId); } function isAdmin(address account) external view virtual override onlyOneOfAdmins returns (bool) { return _admins[account] == 1; } function addAdmin(uint256 taskId, address toBeAdded) external virtual override onlyOneOfAdmins taskMustExist(taskId) taskMustBeApproved(taskId) { require(_nrOfAdmins < MAX_NR_OF_ADMINS, "arteQAdmin: cannot have more admin accounts"); require(_admins[toBeAdded] == 0, "arteQAdmin: already an admin account"); _admins[toBeAdded] = 1; _nrOfAdmins++; emit AdminAdded(msg.sender, toBeAdded); // adjust min required nr of approvals if (_minRequiredNrOfApprovals < (1 + uint(_nrOfAdmins) / uint(2))) { _minRequiredNrOfApprovals = 1 + uint(_nrOfAdmins) / uint(2); emit NewMinRequiredNrOfApprovalsSet(msg.sender, _minRequiredNrOfApprovals); } // finalize task _tasks[taskId] = 0; emit TaskFinalized(msg.sender, msg.sender, taskId); } function replaceAdmin(uint256 taskId, address toBeRemoved, address toBeReplaced) external virtual override onlyOneOfAdmins taskMustExist(taskId) taskMustBeApproved(taskId) { require(_admins[toBeRemoved] == 1, "arteQAdmin: no admin account found"); require(_admins[toBeReplaced] == 0, "arteQAdmin: already an admin account"); _admins[toBeRemoved] = 0; _admins[toBeReplaced] = 1; emit AdminReplaced(msg.sender, toBeRemoved, toBeReplaced); // finalize task _tasks[taskId] = 0; emit TaskFinalized(msg.sender, msg.sender, taskId); } function removeAdmin(uint256 taskId, address toBeRemoved) external virtual override onlyOneOfAdmins taskMustExist(taskId) taskMustBeApproved(taskId) { require(_nrOfAdmins > MIN_NR_OF_ADMINS, "arteQAdmin: cannot have fewer admin accounts"); require(_admins[toBeRemoved] == 1, "arteQAdmin: no admin account found"); _admins[toBeRemoved] = 0; _nrOfAdmins--; emit AdminRemoved(msg.sender, toBeRemoved); // adjust min required nr of approvals if (_minRequiredNrOfApprovals > _nrOfAdmins) { _minRequiredNrOfApprovals = _nrOfAdmins; emit NewMinRequiredNrOfApprovalsSet(msg.sender, _minRequiredNrOfApprovals); } // finalize task _tasks[taskId] = 0; emit TaskFinalized(msg.sender, msg.sender, taskId); } function setMinRequiredNrOfApprovals(uint256 taskId, uint newMinRequiredNrOfApprovals) external virtual override onlyOneOfAdmins taskMustExist(taskId) taskMustBeApproved(taskId) { require(newMinRequiredNrOfApprovals != _minRequiredNrOfApprovals , "arteQAdmin: same value"); require(newMinRequiredNrOfApprovals > uint(_nrOfAdmins) / uint(2) , "arteQAdmin: value is too low"); require(newMinRequiredNrOfApprovals <= _nrOfAdmins, "arteQAdmin: value is too high"); _minRequiredNrOfApprovals = newMinRequiredNrOfApprovals; emit NewMinRequiredNrOfApprovalsSet(msg.sender, _minRequiredNrOfApprovals); // finalize task _tasks[taskId] = 0; emit TaskFinalized(msg.sender, msg.sender, taskId); } receive() external payable { revert("arteQAdmin: cannot accept ether"); } fallback() external payable { revert("arteQAdmin: cannot accept ether"); } }
47,525
24
// Allows batched call to self (this contract)./calls An array of inputs for each call./revertOnFail If True, reverts after a failed call and stops further calls.
function batch(bytes[] calldata calls, bool revertOnFail) external { for (uint256 i = 0; i < calls.length; i++) { (bool success, bytes memory result) = address(this).delegatecall(calls[i]); if (!success && revertOnFail) { revert(_getRevertMsg(result)); } } }
function batch(bytes[] calldata calls, bool revertOnFail) external { for (uint256 i = 0; i < calls.length; i++) { (bool success, bytes memory result) = address(this).delegatecall(calls[i]); if (!success && revertOnFail) { revert(_getRevertMsg(result)); } } }
71,568
2
// Slice of methods of MasterChefV2 contract used in StakingRewardsSushi contract
interface IMasterChefV2 { function lpToken(uint256 pid) external view returns (IERC20 _lpToken); }
interface IMasterChefV2 { function lpToken(uint256 pid) external view returns (IERC20 _lpToken); }
40,602
197
// no votes, no rewards
if (numVotes == 0) { return 0; }
if (numVotes == 0) { return 0; }
13,880
6,522
// 3263
entry "vandalically" : ENG_ADVERB
entry "vandalically" : ENG_ADVERB
24,099
206
// Wildcard bonus
if (maxIndex < 4) { maxCount += _clanCounter[5]; }
if (maxIndex < 4) { maxCount += _clanCounter[5]; }
67,277
119
// Changes the value of `performanceFee`./ Should set this value below the maximum strategist performance fee./ This may only be called by `governance`./fee The new performance fee to use.
function setPerformanceFee( uint256 fee
function setPerformanceFee( uint256 fee
68,244
6
// Increment product count
productCount ++;
productCount ++;
51,146
20
// change the funding end block
function changeEndBlock(uint256 _newFundingEndBlock) onlyOwner{ fundingEndBlock = _newFundingEndBlock; }
function changeEndBlock(uint256 _newFundingEndBlock) onlyOwner{ fundingEndBlock = _newFundingEndBlock; }
26,235
85
// Read the bytes4 from array memory
assembly { result := mload(add(b, index)) // Solidity does not require us to clean the trailing bytes. // We do it anyway result := and(result, 0xFFFFFFFF00000000000000000000000000000000000000000000000000000000) }
assembly { result := mload(add(b, index)) // Solidity does not require us to clean the trailing bytes. // We do it anyway result := and(result, 0xFFFFFFFF00000000000000000000000000000000000000000000000000000000) }
23,761
223
// Distribute any reward shares earned by the strategy on this report
distributeRewards();
distributeRewards();
26,266
136
// This function include a new blockchain in the list of allowed blockchains used in the bridge. Only owner can call it. Can not be called if the Bridge is paused. Parameters:- string name of blockchain to be added- minGasPrice- minTokenAmount- check address EVM compatible Returns: index of blockchain. Important:- index start in 1, not 0.- index 0 means that the blockchain does no exist.- index 1 means that it is the position 0 in the array. Requirements:- blockchain not exists.- onlyOwner- whenNotPaused /
function addBlockchain( string memory name, uint256 minGasPrice, uint256 minTokenAmount, bool checkAddress
function addBlockchain( string memory name, uint256 minGasPrice, uint256 minTokenAmount, bool checkAddress
43,493
126
// Calls {_authorizeUpgrade}. Emits an {Upgraded} event. @custom:oz-upgrades-unsafe-allow-reachable delegatecall /
function upgradeTo(address newImplementation) public virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); }
function upgradeTo(address newImplementation) public virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); }
28,090
50
// Calculate the amount that is expected to be swapped
swapAmountIn = _calculateAmountToSwapForRebalancing( _token0AmountIn, _token1AmountIn, reserveA, reserveB, sellToken0 );
swapAmountIn = _calculateAmountToSwapForRebalancing( _token0AmountIn, _token1AmountIn, reserveA, reserveB, sellToken0 );
11,818
207
// Protected function that can only be called from`simulateActionWithAtomicBatchCalls` on this contract. It will attempt toperform each specified call, populating the array of results as it goes,unless a failure occurs, at which point it will revert and "return" thearray of results as revert data. Regardless, it will roll back all calls atthe end of execution — in other words, this call always reverts. calls Call[] A struct containing the target, value, and calldata toprovide when making each call.return An array of structs signifying the status of each call, as well asany data returned from that call. Calls that are not executed
function _simulateActionWithAtomicBatchCallsAtomic( Call[] memory calls
function _simulateActionWithAtomicBatchCallsAtomic( Call[] memory calls
7,935
264
// proposal.stakes[NO] cannot be zero as the dao downstake > 0 for each proposal.
return uint216(proposal.stakes[YES]).fraction(uint216(proposal.stakes[NO]));
return uint216(proposal.stakes[YES]).fraction(uint216(proposal.stakes[NO]));
11,015
189
//
contract OpticalIllusion is ERC721Enumerable, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenId; uint256 public maxOPI = 1111; uint256 public price = 150000000000000000; //0.15 Ether string baseTokenURI; bool public isSaleOpen = false; event OpticalIllusionMinted(uint256 totalMinted); constructor(string memory baseURI) ERC721("Optical Illusion", "OPI") { setBaseURI(baseURI); } //Get token Ids of all tokens owned by _owner function walletOfOwner(address _owner) external view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); uint256[] memory tokensId = new uint256[](tokenCount); for (uint256 i = 0; i < tokenCount; i++) { tokensId[i] = tokenOfOwnerByIndex(_owner, i); } return tokensId; } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } function changePrice(uint256 _newPrice) external onlyOwner { price = _newPrice; } function changeMaxOPI(uint256 _maxOPI) external onlyOwner { maxOPI += _maxOPI; } //Close sale if open, open sale if closed function toggleSale() external onlyOwner { isSaleOpen = !isSaleOpen; } function withdrawETH() external onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success, "Transfer failed."); } //mint OpticalIllusion function mintOpticalIllusion(address _to, uint256 _count) external payable { require( totalSupply() + _count <= maxOPI, "Exceeds maximum supply of Optical Illusion" ); if (msg.sender != owner()) { require(isSaleOpen, "Sale is not open yet"); require( _count > 0 && _count <= 5, "Minimum 1 & Maximum 5 Optical Illusions can be minted per transaction" ); require( msg.value >= price * _count, "Ether sent with this transaction is not correct" ); } for (uint256 i = 0; i < _count; i++) { _mint(_to); } } function _mint(address _to) private { _tokenId.increment(); uint256 tokenId = _tokenId.current(); _safeMint(_to, tokenId); emit OpticalIllusionMinted(tokenId); } function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } }
contract OpticalIllusion is ERC721Enumerable, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenId; uint256 public maxOPI = 1111; uint256 public price = 150000000000000000; //0.15 Ether string baseTokenURI; bool public isSaleOpen = false; event OpticalIllusionMinted(uint256 totalMinted); constructor(string memory baseURI) ERC721("Optical Illusion", "OPI") { setBaseURI(baseURI); } //Get token Ids of all tokens owned by _owner function walletOfOwner(address _owner) external view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); uint256[] memory tokensId = new uint256[](tokenCount); for (uint256 i = 0; i < tokenCount; i++) { tokensId[i] = tokenOfOwnerByIndex(_owner, i); } return tokensId; } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } function changePrice(uint256 _newPrice) external onlyOwner { price = _newPrice; } function changeMaxOPI(uint256 _maxOPI) external onlyOwner { maxOPI += _maxOPI; } //Close sale if open, open sale if closed function toggleSale() external onlyOwner { isSaleOpen = !isSaleOpen; } function withdrawETH() external onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success, "Transfer failed."); } //mint OpticalIllusion function mintOpticalIllusion(address _to, uint256 _count) external payable { require( totalSupply() + _count <= maxOPI, "Exceeds maximum supply of Optical Illusion" ); if (msg.sender != owner()) { require(isSaleOpen, "Sale is not open yet"); require( _count > 0 && _count <= 5, "Minimum 1 & Maximum 5 Optical Illusions can be minted per transaction" ); require( msg.value >= price * _count, "Ether sent with this transaction is not correct" ); } for (uint256 i = 0; i < _count; i++) { _mint(_to); } } function _mint(address _to) private { _tokenId.increment(); uint256 tokenId = _tokenId.current(); _safeMint(_to, tokenId); emit OpticalIllusionMinted(tokenId); } function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } }
1,487
28
// Moves tokens `amount` from `sender` to `recipient`. This is internal function is equivalent to `transfer`, and can be used toe.g. implement automatic token fees, slashing mechanisms, etc. Emits a `Transfer` event. Requirements: - `sender` cannot be the zero address.- `recipient` cannot be the zero address.- `sender` must have a balance of at least `amount`. /
function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); }
function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); }
2,636
1,396
// Following variable set upon a resolution of a dispute:
FixedPoint.Unsigned settlementPrice; // Final price as determined by an Oracle following a dispute FixedPoint.Unsigned finalFee;
FixedPoint.Unsigned settlementPrice; // Final price as determined by an Oracle following a dispute FixedPoint.Unsigned finalFee;
2,020
313
// xy. If any of the operators is higher than maxFixedMul() it might overflow. Test multiply(0,0) returns 0Test multiply(maxFixedMul(),0) returns 0Test multiply(0,maxFixedMul()) returns 0Test multiply(maxFixedMul(),fixed1()) returns maxFixedMul()Test multiply(fixed1(),maxFixedMul()) returns maxFixedMul()Test all combinations of (2,-2), (2, 2.5), (2, -2.5) and (0.5, -0.5)Test multiply(fixed1()/mulPrecision(),fixed1()mulPrecision())Test multiply(maxFixedMul()-1,maxFixedMul()) equals multiply(maxFixedMul(),maxFixedMul()-1)Test multiply(maxFixedMul()+1,maxFixedMul()) failsTest multiply(maxFixedMul(),maxFixedMul()+1) fails /
function multiply(int256 x, int256 y) public pure returns (int256) { if (x == 0 || y == 0) return 0; if (y == fixed1()) return x; if (x == fixed1()) return y; // Separate into integer and fractional parts // x = x1 + x2, y = y1 + y2 int256 x1 = integer(x) / fixed1(); int256 x2 = fractional(x); int256 y1 = integer(y) / fixed1(); int256 y2 = fractional(y); // (x1 + x2) * (y1 + y2) = (x1 * y1) + (x1 * y2) + (x2 * y1) + (x2 * y2) int256 x1y1 = x1 * y1; if (x1 != 0) assert(x1y1 / x1 == y1); // Overflow x1y1 // x1y1 needs to be multiplied back by fixed1 // solium-disable-next-line mixedcase int256 fixed_x1y1 = x1y1 * fixed1(); if (x1y1 != 0) assert(fixed_x1y1 / x1y1 == fixed1()); // Overflow x1y1 * fixed1 x1y1 = fixed_x1y1; int256 x2y1 = x2 * y1; if (x2 != 0) assert(x2y1 / x2 == y1); // Overflow x2y1 int256 x1y2 = x1 * y2; if (x1 != 0) assert(x1y2 / x1 == y2); // Overflow x1y2 x2 = x2 / mulPrecision(); y2 = y2 / mulPrecision(); int256 x2y2 = x2 * y2; if (x2 != 0) assert(x2y2 / x2 == y2); // Overflow x2y2 // result = fixed1() * x1 * y1 + x1 * y2 + x2 * y1 + x2 * y2 / fixed1(); int256 result = x1y1; result = add(result, x2y1); // Add checks for overflow result = add(result, x1y2); // Add checks for overflow result = add(result, x2y2); // Add checks for overflow return result; }
function multiply(int256 x, int256 y) public pure returns (int256) { if (x == 0 || y == 0) return 0; if (y == fixed1()) return x; if (x == fixed1()) return y; // Separate into integer and fractional parts // x = x1 + x2, y = y1 + y2 int256 x1 = integer(x) / fixed1(); int256 x2 = fractional(x); int256 y1 = integer(y) / fixed1(); int256 y2 = fractional(y); // (x1 + x2) * (y1 + y2) = (x1 * y1) + (x1 * y2) + (x2 * y1) + (x2 * y2) int256 x1y1 = x1 * y1; if (x1 != 0) assert(x1y1 / x1 == y1); // Overflow x1y1 // x1y1 needs to be multiplied back by fixed1 // solium-disable-next-line mixedcase int256 fixed_x1y1 = x1y1 * fixed1(); if (x1y1 != 0) assert(fixed_x1y1 / x1y1 == fixed1()); // Overflow x1y1 * fixed1 x1y1 = fixed_x1y1; int256 x2y1 = x2 * y1; if (x2 != 0) assert(x2y1 / x2 == y1); // Overflow x2y1 int256 x1y2 = x1 * y2; if (x1 != 0) assert(x1y2 / x1 == y2); // Overflow x1y2 x2 = x2 / mulPrecision(); y2 = y2 / mulPrecision(); int256 x2y2 = x2 * y2; if (x2 != 0) assert(x2y2 / x2 == y2); // Overflow x2y2 // result = fixed1() * x1 * y1 + x1 * y2 + x2 * y1 + x2 * y2 / fixed1(); int256 result = x1y1; result = add(result, x2y1); // Add checks for overflow result = add(result, x1y2); // Add checks for overflow result = add(result, x2y2); // Add checks for overflow return result; }
9,637
11
// mint _nbNft NFTs of each level for owner/_nbNft number of mint of each level
function mintOwner(uint256 _nbNft) public onlyOwner { require(_nbNft > 0, "LeafNFT : must be greater than 0"); require( _nbNft + firstLevelSupply <= 10000, "LeafNFT : must be less than 10000" ); for (uint256 i = 1; i <= _nbNft; i++) { firstLevelSupply++; _safeMint(msg.sender, firstLevelSupply); _safeMint(msg.sender, LEVEL_1 + firstLevelSupply); _safeMint(msg.sender, LEVEL_2 + firstLevelSupply); _safeMint(msg.sender, LEVEL_3 + firstLevelSupply); idsNft[msg.sender].push(firstLevelSupply); idsNft[msg.sender].push(LEVEL_1 + firstLevelSupply); idsNft[msg.sender].push(LEVEL_2 + firstLevelSupply); idsNft[msg.sender].push(LEVEL_3 + firstLevelSupply); } }
function mintOwner(uint256 _nbNft) public onlyOwner { require(_nbNft > 0, "LeafNFT : must be greater than 0"); require( _nbNft + firstLevelSupply <= 10000, "LeafNFT : must be less than 10000" ); for (uint256 i = 1; i <= _nbNft; i++) { firstLevelSupply++; _safeMint(msg.sender, firstLevelSupply); _safeMint(msg.sender, LEVEL_1 + firstLevelSupply); _safeMint(msg.sender, LEVEL_2 + firstLevelSupply); _safeMint(msg.sender, LEVEL_3 + firstLevelSupply); idsNft[msg.sender].push(firstLevelSupply); idsNft[msg.sender].push(LEVEL_1 + firstLevelSupply); idsNft[msg.sender].push(LEVEL_2 + firstLevelSupply); idsNft[msg.sender].push(LEVEL_3 + firstLevelSupply); } }
15,047
2
// Get reward manager address/_index index of instance/ return address of instance's RewardManager
function getRewardManagerAddress(uint256 _index) external view returns (address);
function getRewardManagerAddress(uint256 _index) external view returns (address);
15,552
228
// The total remaining vested balance, for verifying the actual havven balance of this contract against.
uint public totalVestedBalance;
uint public totalVestedBalance;
35,834
33
// Claim tokens that have been sent to contract mistakenly/_token Token address that we want to claim
function claimTokens(address _token) public onlyOwner { if (_token == address(0)) { owner.transfer(this.balance); return; } ERC20 token = ERC20(_token); uint balance = token.balanceOf(this); token.transfer(owner, balance); ClaimedTokens(_token, owner, balance); }
function claimTokens(address _token) public onlyOwner { if (_token == address(0)) { owner.transfer(this.balance); return; } ERC20 token = ERC20(_token); uint balance = token.balanceOf(this); token.transfer(owner, balance); ClaimedTokens(_token, owner, balance); }
20,973
75
// Revoke the attribute of the type with ID `attributeTypeID` from `account` if `message.caller.address()` is the issuing validator.account address The account to issue the attribute on.attributeTypeID uint256 The ID of the attribute type to issue.Validators may still revoke issued attributes even after they have been removed or had their approval to issue the attribute type removed - this enables them to address any objectionable issuances before being reinstated./
function revokeAttribute( address account, uint256 attributeTypeID
function revokeAttribute( address account, uint256 attributeTypeID
34,652
5
// if time has elapsed since the last update on the pair, mock the accumulated price values
(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); priceCumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * (blockTimestamp - blockTimestampLast); // overflows ok
(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); priceCumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * (blockTimestamp - blockTimestampLast); // overflows ok
31,210
44
// ETH 750$ 13.12.2017 token price 1.5$ TODO: set actual price before deploy
uint256 public constant tokenPrice = uint256(15 * 1 ether).div(etherCost * 10); RefundVault public refundVault; KeeppetToken public keeppetToken;
uint256 public constant tokenPrice = uint256(15 * 1 ether).div(etherCost * 10); RefundVault public refundVault; KeeppetToken public keeppetToken;
50,243
39
// Get `Exchange` contract address/ return exchange The address of `Exchange` contract
function getExchange() external view returns (address exchange);
function getExchange() external view returns (address exchange);
10,908
40
// Check if a pair of nodes is a valid insertion point for a new node with the given NICR _NICR Node's NICR _prevId Id of previous node for the insert position _nextId Id of next node for the insert position /
function validInsertPosition(uint256 _NICR, address _prevId, address _nextId) external view override returns (bool) { return _validInsertPosition(troveManager, _NICR, _prevId, _nextId); }
function validInsertPosition(uint256 _NICR, address _prevId, address _nextId) external view override returns (bool) { return _validInsertPosition(troveManager, _NICR, _prevId, _nextId); }
16,108
281
// Query if an address is an authorized operator for another address/_owner The address that owns the NFTs/_operator The address that acts on behalf of the owner/ return True if `_operator` is an approved operator for `_owner`, false otherwise
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
3,730
43
// Withdraw _amount of stakeToken from pool _pid, also harvest reward for the sender /
function _withdraw(uint256 _pid, uint256 _amount) internal { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, 'withdraw: insufficient amount'); // update pool reward and harvest updatePoolRewards(_pid); _updateUserReward(msg.sender, _pid, true); user.amount = user.amount.sub(_amount); pool.totalStake = pool.totalStake.sub(_amount); IERC20Ext(pool.stakeToken).safeTransfer(msg.sender, _amount); emit Withdraw(msg.sender, _pid, block.number, user.amount); }
function _withdraw(uint256 _pid, uint256 _amount) internal { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, 'withdraw: insufficient amount'); // update pool reward and harvest updatePoolRewards(_pid); _updateUserReward(msg.sender, _pid, true); user.amount = user.amount.sub(_amount); pool.totalStake = pool.totalStake.sub(_amount); IERC20Ext(pool.stakeToken).safeTransfer(msg.sender, _amount); emit Withdraw(msg.sender, _pid, block.number, user.amount); }
43,853
165
// OPERATOR ONLY: Update the operator address_newOperator New operator address /
function updateOperator(address _newOperator) external onlyOperator { operator = _newOperator; }
function updateOperator(address _newOperator) external onlyOperator { operator = _newOperator; }
41,433
48
// See {IERC721CreatorCore-mintExtensionBatch}. /
function mintExtensionBatch(address to, uint16 count) public virtual override nonReentrant returns(uint256[] memory tokenIds) { requireExtension(); tokenIds = new uint256[](count); uint256 firstTokenId = _tokenCount+1; _tokenCount += count; for (uint i; i < count;) { tokenIds[i] = _mintExtension(to, "", 0, firstTokenId+i); unchecked { ++i; }
function mintExtensionBatch(address to, uint16 count) public virtual override nonReentrant returns(uint256[] memory tokenIds) { requireExtension(); tokenIds = new uint256[](count); uint256 firstTokenId = _tokenCount+1; _tokenCount += count; for (uint i; i < count;) { tokenIds[i] = _mintExtension(to, "", 0, firstTokenId+i); unchecked { ++i; }
13,154
204
// First option based on fraction of total veFXS supply, with an added scale factor
uint256 mult_optn_1 = (vefxs_bal_to_use * vefxs_max_multiplier * vefxs_boost_scale_factor) / (veFXS.totalSupply() * MULTIPLIER_PRECISION);
uint256 mult_optn_1 = (vefxs_bal_to_use * vefxs_max_multiplier * vefxs_boost_scale_factor) / (veFXS.totalSupply() * MULTIPLIER_PRECISION);
50,406
111
// Returns the address of the current Recovery owner. /
function recoveryOwner() public view returns (address) { return _recoveryOwner; }
function recoveryOwner() public view returns (address) { return _recoveryOwner; }
33,596
0
// ! "name": "main",! "input": [
//! { //! "entry": "main", //! "calldata": [ //! "42" //! ], //! "storage": [ //! "20", "15", "10", "5" //! ] //! }
//! { //! "entry": "main", //! "calldata": [ //! "42" //! ], //! "storage": [ //! "20", "15", "10", "5" //! ] //! }
13,097
197
// oracle used for calculating the avgAPR with gov tokens
address public oracle;
address public oracle;
35,187
453
// round 44
ark(i, q, 4945579503584457514844595640661884835097077318604083061152997449742124905548); sbox_partial(i, q); mix(i, q);
ark(i, q, 4945579503584457514844595640661884835097077318604083061152997449742124905548); sbox_partial(i, q); mix(i, q);
44,116
212
// return Total earnings for a user /
function getClaimedRewards(address user) public view returns (uint256) { return userClaimedRewards[user]; }
function getClaimedRewards(address user) public view returns (uint256) { return userClaimedRewards[user]; }
13,416
7
// deposit token to guard, waiting to claim, only allowed depositorid the id of the operation, should be siged later by guardstoken the erc20 token addressrecipient the recipient of the tokenamount the amount of the token/
function deposit(uint256 id, address token, address recipient, uint256 amount) public onlyDepositor whenNotPaused { require(depositors[id].amount == 0, "Guard: the asset exist"); uint256 balanceBefore = IERC20(token).balanceOf(address(this)); require(IERC20(token).transferFrom(msg.sender, address(this), amount), "AssetStore: deposit transfer failed"); uint256 balanceAfter = IERC20(token).balanceOf(address(this)); require(balanceBefore.add(amount) == balanceAfter, "Guard:Transfer amount is invalid"); depositors[id] = DepositInfo(token, recipient, amount, block.timestamp); emit TokenDeposit(id, token, recipient, amount); }
function deposit(uint256 id, address token, address recipient, uint256 amount) public onlyDepositor whenNotPaused { require(depositors[id].amount == 0, "Guard: the asset exist"); uint256 balanceBefore = IERC20(token).balanceOf(address(this)); require(IERC20(token).transferFrom(msg.sender, address(this), amount), "AssetStore: deposit transfer failed"); uint256 balanceAfter = IERC20(token).balanceOf(address(this)); require(balanceBefore.add(amount) == balanceAfter, "Guard:Transfer amount is invalid"); depositors[id] = DepositInfo(token, recipient, amount, block.timestamp); emit TokenDeposit(id, token, recipient, amount); }
47,514
275
// Provenance hash of 8893 unique artworks
string public BAI_PROVENANCE;
string public BAI_PROVENANCE;
51,408
251
// To deactivate flash loan provider if needed
bool public DyDxActive = true; bool public forceMigrate; // default is false uint256 public dyDxMarketId;
bool public DyDxActive = true; bool public forceMigrate; // default is false uint256 public dyDxMarketId;
38,134
38
// Disable authentication /
function disableAuthentication() public;
function disableAuthentication() public;
32,873
21
// Id definitions for bancor contract featuresCan be used to query the ContractFeatures contract to check whether a certain feature is supported by a contract/
contract FeatureIds { // converter features uint256 public constant CONVERTER_CONVERSION_WHITELIST = 1 << 0; }
contract FeatureIds { // converter features uint256 public constant CONVERTER_CONVERSION_WHITELIST = 1 << 0; }
23,689
37
// Default standard vesting status: Active
standardVestingStatus public current_standard_vesting_status = standardVestingStatus.standardVestingActive;
standardVestingStatus public current_standard_vesting_status = standardVestingStatus.standardVestingActive;
39,568
0
// RSA public parameter N
uint240 public constant N = 0x19502e64b3deff07b8378ff53d5799d9843c63cb871640c11196b500001; address[25] public jury; string public caseDescription; string public judgeArguments;
uint240 public constant N = 0x19502e64b3deff07b8378ff53d5799d9843c63cb871640c11196b500001; address[25] public jury; string public caseDescription; string public judgeArguments;
2,153
90
// withdraw both tokens
_unstake(unstakeAmount0, unstakeAmount1);
_unstake(unstakeAmount0, unstakeAmount1);
3,348
4
// They are drought tolerant and slow-growing.
entry slow : ENG_COMPOUND_PREVERB {}
entry slow : ENG_COMPOUND_PREVERB {}
12,843
3
// operator-filter-registry
function setApprovalForAll(address operator, bool approved) public override(ERC721A, IERC721A) onlyAllowedOperatorApproval(operator)
function setApprovalForAll(address operator, bool approved) public override(ERC721A, IERC721A) onlyAllowedOperatorApproval(operator)
27,349
11
// Handles repayment of flashloaned assets + premium Will pull the amount + premium from the receiver, so must have approved pool reserve The state of the flashloaned reserve params The additional parameters needed to execute the repayment function /
function _handleFlashLoanRepayment( DataTypes.ReserveData storage reserve, DataTypes.FlashLoanRepaymentParams memory params
function _handleFlashLoanRepayment( DataTypes.ReserveData storage reserve, DataTypes.FlashLoanRepaymentParams memory params
33,820
30
// Increase the shares of a shareholder/_account The shareholder address/_shares The shares of the holder/_token The updated token
function _addShares( address _account, uint256 _shares, address _token
function _addShares( address _account, uint256 _shares, address _token
56,288
8
// Get votes
function getVotes() public view returns(uint256[20] memory) { return _votes; }
function getVotes() public view returns(uint256[20] memory) { return _votes; }
434
17
// Hashing the signed message
signedHash := keccak256(add(signedMessage, BYTES_ARR_LEN_VAR_BS), signedMessageBytesCount)
signedHash := keccak256(add(signedMessage, BYTES_ARR_LEN_VAR_BS), signedMessageBytesCount)
29,175
97
// Add an `address` to the black list.This `address` will no longer be able to transfer funds to anyone. Can only be called by the current owner. /
function addBlackList (address _evilUser) public onlyOwner { _isBlackListed[_evilUser] = true; emit AddedBlackList(_evilUser); }
function addBlackList (address _evilUser) public onlyOwner { _isBlackListed[_evilUser] = true; emit AddedBlackList(_evilUser); }
79,245
39
// Save bettor's bet
matchBets[_matchId][matchResultBetOn].push(smartAssetId); emit BetPlacedEvent(bettor, _matchId, amountBet, block.timestamp); return smartAssetId;
matchBets[_matchId][matchResultBetOn].push(smartAssetId); emit BetPlacedEvent(bettor, _matchId, amountBet, block.timestamp); return smartAssetId;
7,508
137
// Extension of ERC1155 that adds tracking of total supply per id. Useful for scenarios where Fungible and Non-fungible tokens have to beclearly identified. Note: While a totalSupply of 1 might mean thecorresponding is an NFT, there is no guarantees that no other token with thesame id are not going to be minted. /
abstract contract ERC1155Supply is ERC1155 { mapping(uint256 => uint256) private _totalSupply; /** * @dev Total amount of tokens in with a given id. */ function totalSupply(uint256 id) public view virtual returns (uint256) { return _totalSupply[id]; } /** * @dev Indicates whether any token exist with a given id, or not. */ function exists(uint256 id) public view virtual returns (bool) { return ERC1155Supply.totalSupply(id) > 0; } /** * @dev See {ERC1155-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); if (from == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] += amounts[i]; } } if (to == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] -= amounts[i]; } } } }
abstract contract ERC1155Supply is ERC1155 { mapping(uint256 => uint256) private _totalSupply; /** * @dev Total amount of tokens in with a given id. */ function totalSupply(uint256 id) public view virtual returns (uint256) { return _totalSupply[id]; } /** * @dev Indicates whether any token exist with a given id, or not. */ function exists(uint256 id) public view virtual returns (bool) { return ERC1155Supply.totalSupply(id) > 0; } /** * @dev See {ERC1155-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); if (from == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] += amounts[i]; } } if (to == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] -= amounts[i]; } } } }
28,372
200
// Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good.
function migrate(uint256 _pid) public { require(address(migrator) != address(0), "migrate: no migrator"); PoolInfo storage pool = poolInfo[_pid]; IBEP20 lpToken = pool.lpToken; uint256 bal = lpToken.balanceOf(address(this)); lpToken.safeApprove(address(migrator), bal); IBEP20 newLpToken = migrator.migrate(lpToken); require(bal == newLpToken.balanceOf(address(this)), "migrate: bad"); pool.lpToken = newLpToken; }
function migrate(uint256 _pid) public { require(address(migrator) != address(0), "migrate: no migrator"); PoolInfo storage pool = poolInfo[_pid]; IBEP20 lpToken = pool.lpToken; uint256 bal = lpToken.balanceOf(address(this)); lpToken.safeApprove(address(migrator), bal); IBEP20 newLpToken = migrator.migrate(lpToken); require(bal == newLpToken.balanceOf(address(this)), "migrate: bad"); pool.lpToken = newLpToken; }
4,155
27
// Get the number of rewards used in the old contract
tme tmeContract=tme(0xEe22430595aE400a30FFBA37883363Fbf293e24e); uint256 numRewardsUsed=tmeContract.numRewardsUsed(addressToSet); numRewardsAvailable[addressToSet]=10-numRewardsUsed; numRewardsAvailableSetForChildAddress[addressToSet]=true;
tme tmeContract=tme(0xEe22430595aE400a30FFBA37883363Fbf293e24e); uint256 numRewardsUsed=tmeContract.numRewardsUsed(addressToSet); numRewardsAvailable[addressToSet]=10-numRewardsUsed; numRewardsAvailableSetForChildAddress[addressToSet]=true;
55,569
27
// create immutable split
split = Clones.cloneDeterministic(walletImplementation, splitHash);
split = Clones.cloneDeterministic(walletImplementation, splitHash);
22,541
7
// 2. Check signed msg integrety
bytes32 actualMsg = getMsgForSign( msg.sender, _pid, _amount, _type, _rewardToken ); require(actualMsg.toEthSignedMessageHash() == _msgForSign,"integrety check failed"); userPositions[msg.sender][_getPositionIndexByPid(msg.sender, _pid)].closed = block.timestamp;
bytes32 actualMsg = getMsgForSign( msg.sender, _pid, _amount, _type, _rewardToken ); require(actualMsg.toEthSignedMessageHash() == _msgForSign,"integrety check failed"); userPositions[msg.sender][_getPositionIndexByPid(msg.sender, _pid)].closed = block.timestamp;
35,901
9
// Reverts if the address doesn't have this role/
modifier onlyRole(string _role) { roleCheck(_role, msg.sender); _; }
modifier onlyRole(string _role) { roleCheck(_role, msg.sender); _; }
42,993
33
// reduce eligible pools only if done by user actions
if (pool.totalStaked == 0 && pool.allocPoint > 0) { totalEligiblePools = totalEligiblePools.sub(1); }
if (pool.totalStaked == 0 && pool.allocPoint > 0) { totalEligiblePools = totalEligiblePools.sub(1); }
44,884
15
// Return the index of the given token address. Reverts if no matchingtoken is found. tokenAddress address of the tokenreturn the index of the given token address /
function getTokenIndex(address tokenAddress) public view virtual returns (uint8)
function getTokenIndex(address tokenAddress) public view virtual returns (uint8)
6,474
155
// https:docs.pynthetix.io/contracts/source/libraries/math
library Math { using SafeMath for uint; using SafeDecimalMath for uint; /** * @dev Uses "exponentiation by squaring" algorithm where cost is 0(logN) * vs 0(N) for naive repeated multiplication. * Calculates x^n with x as fixed-point and n as regular unsigned int. * Calculates to 18 digits of precision with SafeDecimalMath.unit() */ function powDecimal(uint x, uint n) internal pure returns (uint) { // https://mpark.github.io/programming/2014/08/18/exponentiation-by-squaring/ uint result = SafeDecimalMath.unit(); while (n > 0) { if (n % 2 != 0) { result = result.multiplyDecimal(x); } x = x.multiplyDecimal(x); n /= 2; } return result; } }
library Math { using SafeMath for uint; using SafeDecimalMath for uint; /** * @dev Uses "exponentiation by squaring" algorithm where cost is 0(logN) * vs 0(N) for naive repeated multiplication. * Calculates x^n with x as fixed-point and n as regular unsigned int. * Calculates to 18 digits of precision with SafeDecimalMath.unit() */ function powDecimal(uint x, uint n) internal pure returns (uint) { // https://mpark.github.io/programming/2014/08/18/exponentiation-by-squaring/ uint result = SafeDecimalMath.unit(); while (n > 0) { if (n % 2 != 0) { result = result.multiplyDecimal(x); } x = x.multiplyDecimal(x); n /= 2; } return result; } }
32,396
103
// Issues an {amount} new shares to {recipient}. /
function issue(address recipient, uint256 amount) public onlyOwner returns (bool) { _mint(recipient, amount); return true; }
function issue(address recipient, uint256 amount) public onlyOwner returns (bool) { _mint(recipient, amount); return true; }
63,830
57
// Allows token holders to vote_disputeId is the dispute id_supportsDispute is the vote (true=the dispute has basis false = vote against dispute)/
function vote(TellorStorage.TellorStorageStruct storage self, uint256 _disputeId, bool _supportsDispute) public { TellorStorage.Dispute storage disp = self.disputesById[_disputeId]; //Get the voteWeight or the balance of the user at the time/blockNumber the disupte began uint256 voteWeight = TellorTransfer.balanceOfAt(self, msg.sender, disp.disputeUintVars[keccak256("blockNumber")]); //Require that the msg.sender has not voted require(disp.voted[msg.sender] != true, "Sender has already voted"); //Requre that the user had a balance >0 at time/blockNumber the disupte began require(voteWeight != 0, "User balance is 0"); //ensures miners that are under dispute cannot vote require(self.stakerDetails[msg.sender].currentStatus != 3, "Miner is under dispute"); //Update user voting status to true disp.voted[msg.sender] = true; //Update the number of votes for the dispute disp.disputeUintVars[keccak256("numberOfVotes")] += 1; //If the user supports the dispute increase the tally for the dispute by the voteWeight //otherwise decrease it if (_supportsDispute) { disp.tally = disp.tally.add(int256(voteWeight)); } else { disp.tally = disp.tally.sub(int256(voteWeight)); } //Let the network know the user has voted on the dispute and their casted vote emit Voted(_disputeId, _supportsDispute, msg.sender, voteWeight); }
function vote(TellorStorage.TellorStorageStruct storage self, uint256 _disputeId, bool _supportsDispute) public { TellorStorage.Dispute storage disp = self.disputesById[_disputeId]; //Get the voteWeight or the balance of the user at the time/blockNumber the disupte began uint256 voteWeight = TellorTransfer.balanceOfAt(self, msg.sender, disp.disputeUintVars[keccak256("blockNumber")]); //Require that the msg.sender has not voted require(disp.voted[msg.sender] != true, "Sender has already voted"); //Requre that the user had a balance >0 at time/blockNumber the disupte began require(voteWeight != 0, "User balance is 0"); //ensures miners that are under dispute cannot vote require(self.stakerDetails[msg.sender].currentStatus != 3, "Miner is under dispute"); //Update user voting status to true disp.voted[msg.sender] = true; //Update the number of votes for the dispute disp.disputeUintVars[keccak256("numberOfVotes")] += 1; //If the user supports the dispute increase the tally for the dispute by the voteWeight //otherwise decrease it if (_supportsDispute) { disp.tally = disp.tally.add(int256(voteWeight)); } else { disp.tally = disp.tally.sub(int256(voteWeight)); } //Let the network know the user has voted on the dispute and their casted vote emit Voted(_disputeId, _supportsDispute, msg.sender, voteWeight); }
26,738
198
// Make sure it does nothing if the new and old weights are the same (saves gas) It's a degenerate case if they're all the same, but you certainly could have a plan where you only change some of the weights in the set
if (gradualUpdate.startWeights[i] != gradualUpdate.endWeights[i]) { if ( gradualUpdate.endWeights[i] < gradualUpdate.startWeights[i] ) {
if (gradualUpdate.startWeights[i] != gradualUpdate.endWeights[i]) { if ( gradualUpdate.endWeights[i] < gradualUpdate.startWeights[i] ) {
23,363
46
// random number generation
uint256 public randomNumber; // for debugging bytes32 public lastRequestId; uint256 public lastRequestAt; uint256 public launchCount = 0; uint256 private maxBuybackAmount; uint256 private buybackAmount; uint256 private remainingSessionEth; bool public rocketFueled; bool private buybackInProgress;
uint256 public randomNumber; // for debugging bytes32 public lastRequestId; uint256 public lastRequestAt; uint256 public launchCount = 0; uint256 private maxBuybackAmount; uint256 private buybackAmount; uint256 private remainingSessionEth; bool public rocketFueled; bool private buybackInProgress;
37,898
8
// Investors get 45M tokens linearly over the first year
uint investorsProgress = _min(((block.timestamp - emissionsStart) * 1e12) / ONE_YEAR, 1e12); uint investorsUnlocked = (investorsProgress * INVESTORS_EMISSIONS_HALF1) / 1e12; uint investorsAmount = _min(investorsUnlocked - sentToInvestors, amount); if (investorsAmount > 0) { sentToInvestorsNow += investorsAmount; sentToInvestors += investorsAmount; amount -= investorsAmount; token.safeApprove(investors, investorsAmount); IEmissionsPrivateDispenser(investors).deposit(investorsAmount); }
uint investorsProgress = _min(((block.timestamp - emissionsStart) * 1e12) / ONE_YEAR, 1e12); uint investorsUnlocked = (investorsProgress * INVESTORS_EMISSIONS_HALF1) / 1e12; uint investorsAmount = _min(investorsUnlocked - sentToInvestors, amount); if (investorsAmount > 0) { sentToInvestorsNow += investorsAmount; sentToInvestors += investorsAmount; amount -= investorsAmount; token.safeApprove(investors, investorsAmount); IEmissionsPrivateDispenser(investors).deposit(investorsAmount); }
6,141
329
// if greater than zero, this is a percentage fee applied to exchange operations with HolyWing proxy
uint256 public exchangeFee;
uint256 public exchangeFee;
14,552
343
// Adds the staking amount of the protocol total. /
function addAllValue(uint256 _value) private { uint256 value = getStorageAllValue(); value = value.add(_value); setStorageAllValue(value); }
function addAllValue(uint256 _value) private { uint256 value = getStorageAllValue(); value = value.add(_value); setStorageAllValue(value); }
30,175
46
// STORAGE commit the genesis block hash header to storage as Zero block..
blockCommitments[GenesisBlockHeight] = genesisBlockHash;
blockCommitments[GenesisBlockHeight] = genesisBlockHash;
21,394
91
// delete register
contract BAC002 is IssuerRole, Suspendable { using SafeMath for uint256; using Address for address; using Counters for Counters.Counter; // Equals to `bytes4(keccak256("onBAC002Received(address,address,uint256,bytes)"))` bytes4 private constant _BAC002_RECEIVED = 0x31f6f50e; // Mapping from asset ID to owner mapping(uint256 => address) private _assetOwner; // Mapping from asset ID to approved address mapping(uint256 => address) private _assetApprovals; // Mapping from owner to number of owned asset mapping(address => Counters.Counter) private _ownedAssetsCount; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; string private _description; string private _shortName; // Optional mapping for asset URIs mapping(uint256 => string) private _assetURIs; // Mapping from owner to list of owned asset IDs mapping(address => uint256[]) private _ownedAssets; // Mapping from asset ID to index of the owner assets list mapping(uint256 => uint256) private _ownedAssetsIndex; // Array with all asset ids, used for enumeration uint256[] private _allAssets; // Mapping from asset id to position in the allAssets array mapping(uint256 => uint256) private _allAssetsIndex; event Send(address indexed operator, address indexed from, address indexed to, uint256 assetId, bytes data); event Approval( address indexed owner, address approved, uint256 assetId); event ApprovalForAll( address indexed owner, address indexed operator, bool approved); // constructor constructor(string description, string shortName) public { _description = description; _shortName = shortName; } /** * @dev Gets the balance of the specified address. */ function balance(address owner) public view returns (uint256) { require(owner != address(0), "BAC002: balance query for the zero address"); return _ownedAssetsCount[owner].current(); } /** * @dev Gets the owner of the specified asset ID. */ function ownerOf(uint256 assetId) public view returns (address) { address owner = _assetOwner[assetId]; require(owner != address(0), "BAC002: owner query for nonexistent asset"); return owner; } function assetOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { require(index < balance(owner), "BAC002Enumerable: owner index out of bounds"); return _ownedAssets[owner][index]; } function assetOfOwner(address owner) public view returns (uint256[]) { return _ownedAssets[owner]; } function assetByIndex(uint256 index) public view returns (uint256) { require(index < totalSupply(), "BAC002Enumerable: global index out of bounds"); return _allAssets[index]; } /** * @dev Approves another address to send the given asset ID */ function approve(address to, uint256 assetId) public whenNotSuspended { address owner = ownerOf(assetId); require(to != owner, "BAC002: approval to current owner"); require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "BAC002: approve caller is not owner nor approved for all" ); _assetApprovals[assetId] = to; emit Approval( owner, to, assetId); } /** * @dev Gets the approved address for a asset ID, or zero if no address set */ function getApproved(uint256 assetId) public view returns (address) { require(_exists(assetId), "BAC002: approved query for nonexistent asset"); return _assetApprovals[assetId]; } /** * @dev Sets or unsets the approval of a given operator */ function setApprovalForAll(address to, bool approved) public whenNotSuspended { require(to != msg.sender, "BAC002: approve to caller"); _operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll( msg.sender, to, approved); } /** * @dev Tells whether an operator is approved by a given owner. */ function isApprovedForAll(address owner, address operator) public view returns (bool) { return _operatorApprovals[owner][operator]; } // /** // * @dev Sends the ownership of a given asset ID to another address. // */ // function sendFrom(address from, address to, uint256 assetId, bytes memory data) public whenNotSuspended { // //solhint-disable-next-line max-line-length // require(_isApprovedOrOwner(msg.sender, assetId), "BAC002: send caller is not owner nor approved"); // _sendFrom(from, to, assetId, data); // } // /** // * @dev Safely sends the ownership of a given asset ID to another address // */ // function safeSendFrom(address from, address to, uint256 assetId) public whenNotSuspended { // safeSendFrom(from, to, assetId, ""); // } /** * @dev Safely sends the ownership of a given asset ID to another address */ function sendFrom(address from, address to, uint256 assetId, bytes memory data) public whenNotSuspended { require(_isApprovedOrOwner(msg.sender, assetId), "BAC002: send caller is not owner nor approved"); _sendFrom(from, to, assetId, data); require(_checkOnBAC002Received(from, to, assetId, data), "BAC002: send to non BAC002Receiver implementer"); } function batchSendFrom(address from, address[] to, uint256[] assetId, bytes memory data) public whenNotSuspended { require(to.length == assetId.length, "to and assetId array lenght must match."); for (uint256 i = 0; i < to.length; ++i) { require(to[i] != address(0x0), "destination address must be non-zero."); sendFrom(from, to[i], assetId[i], data); } } function destroy(uint256 assetId, bytes data) public { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(msg.sender, assetId), "BAC002Burnable: caller is not owner nor approved"); _destroy(assetId, data); } //add issuerAddress function issueWithAssetURI(address to, uint256 assetId, string memory assetURI, bytes data) public onlyIssuer returns (bool) { _issue( to, assetId, data); _setAssetURI(assetId, assetURI); return true; } function description() external view returns (string memory) { return _description; } function shortName() external view returns (string memory) { return _shortName; } /** * @dev Returns an URI for a given asset ID. */ function assetURI(uint256 assetId) external view returns (string memory) { require(_exists(assetId), "BAC002Metadata: URI query for nonexistent asset"); return _assetURIs[assetId]; } /** * @dev Internal function to set the asset URI for a given asset. */ function _setAssetURI(uint256 assetId, string memory uri) internal { require(_exists(assetId), "BAC002Metadata: URI set of nonexistent asset"); _assetURIs[assetId] = uri; } /** * @dev Returns whether the specified asset exists. */ function _exists(uint256 assetId) internal view returns (bool) { address owner = _assetOwner[assetId]; return owner != address(0); } /** * @dev Returns whether the given spender can send a given asset ID. */ function _isApprovedOrOwner(address spender, uint256 assetId) internal view returns (bool) { require(_exists(assetId), "BAC002: operator query for nonexistent asset"); address owner = ownerOf(assetId); return (spender == owner || getApproved(assetId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Internal function to mint a new asset. */ function _issue( address to, uint256 assetId, bytes data) internal { require(to != address(0), "BAC002: mint to the zero address"); require(!_exists(assetId), "BAC002: asset already minted"); _assetOwner[assetId] = to; _ownedAssetsCount[to].increment(); emit Send(msg.sender, address(0), to, assetId, data); _addAssetToOwnerEnumeration(to, assetId); _addAssetToAllAssetsEnumeration(assetId); } /** * @dev Internal function to destroy a specific asset. * Reverts if the asset does not exist. */ function _destroy(address owner, uint256 assetId, bytes data) internal { require(ownerOf(assetId) == owner, "BAC002: destroy of asset that is not own"); _clearApproval(assetId); _ownedAssetsCount[owner].decrement(); _assetOwner[assetId] = address(0); if (bytes(_assetURIs[assetId]).length != 0) { delete _assetURIs[assetId]; } emit Send(this, owner, address(0), assetId, data); _removeAssetFromOwnerEnumeration(owner, assetId); // Since assetId will be deleted, we can clear its slot in _ownedAssetsIndex to trigger a gas refund _ownedAssetsIndex[assetId] = 0; _removeAssetFromAllAssetsEnumeration(assetId); } /** * @dev Gets the total amount of assets stored by the contract. * @return uint256 representing the total amount of assets */ function totalSupply() public view returns (uint256) { return _allAssets.length; } function _assetsOfOwner(address owner) internal view returns (uint256[] storage) { return _ownedAssets[owner]; } /** * @dev Private function to add a asset to this extension's ownership-tracking data structures. */ function _addAssetToOwnerEnumeration(address to, uint256 assetId) private { _ownedAssetsIndex[assetId] = _ownedAssets[to].length; _ownedAssets[to].push(assetId); } /** * @dev Private function to add a asset to this extension's asset tracking data structures. */ function _addAssetToAllAssetsEnumeration(uint256 assetId) private { _allAssetsIndex[assetId] = _allAssets.length; _allAssets.push(assetId); } /** * @dev Private function to remove a asset from this extension's ownership-tracking data structures. Note that */ function _removeAssetFromOwnerEnumeration(address from, uint256 assetId) private { // To prevent a gap in from's assets array, we store the last asset in the index of the asset to delete, and // then delete the last slot (swap and pop). uint256 lastAssetIndex = _ownedAssets[from].length.sub(1); uint256 assetIndex = _ownedAssetsIndex[assetId]; // When the asset to delete is the last asset, the swap operation is unnecessary if (assetIndex != lastAssetIndex) { uint256 lastAssetId = _ownedAssets[from][lastAssetIndex]; _ownedAssets[from][assetIndex] = lastAssetId; // Move the last asset to the slot of the to-delete asset _ownedAssetsIndex[lastAssetId] = assetIndex; // Update the moved asset's index } // This also deletes the contents at the last position of the array _ownedAssets[from].length--; // Note that _ownedAssetsIndex[assetId] hasn't been cleared: it still points to the old slot (now occupied by // lastAssetId, or just over the end of the array if the asset was the last one). } /** * @dev Private function to remove a asset from this extension's asset tracking data structures. */ function _removeAssetFromAllAssetsEnumeration(uint256 assetId) private { // To prevent a gap in the assets array, we store the last asset in the index of the asset to delete, and // then delete the last slot (swap and pop). uint256 lastAssetIndex = _allAssets.length.sub(1); uint256 assetIndex = _allAssetsIndex[assetId]; // When the asset to delete is the last asset, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted asset is destroyt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeAssetFromOwnerEnumeration) uint256 lastAssetId = _allAssets[lastAssetIndex]; _allAssets[assetIndex] = lastAssetId; // Move the last asset to the slot of the to-delete asset _allAssetsIndex[lastAssetId] = assetIndex; // Update the moved asset's index // This also deletes the contents at the last position of the array _allAssets.length--; _allAssetsIndex[assetId] = 0; } /** * @dev Internal function to destroy a specific asset. */ function _destroy(uint256 assetId, bytes data) internal { _destroy(ownerOf(assetId), assetId, data); } /** * @dev Internal function to send ownership of a given asset ID to another address. */ function _sendFrom(address from, address to, uint256 assetId, bytes data) internal { require(ownerOf(assetId) == from, "BAC002: send of asset that is not own"); require(to != address(0), "BAC002: send to the zero address"); _clearApproval(assetId); _ownedAssetsCount[from].decrement(); _ownedAssetsCount[to].increment(); _assetOwner[assetId] = to; emit Send(msg.sender, from, to, assetId, data); _removeAssetFromOwnerEnumeration(from, assetId); _addAssetToOwnerEnumeration(to, assetId); } /** * @dev Internal function to invoke `onBAC002Received` on a target address. */ function _checkOnBAC002Received(address from, address to, uint256 assetId, bytes memory _data) internal returns (bool) { if (!to.isContract()) { return true; } bytes4 retval = IBAC002Receiver(to).onBAC002Received(msg.sender, from, assetId, _data); return (retval == _BAC002_RECEIVED); } /** * @dev Private function to clear current approval of a given asset ID. */ function _clearApproval(uint256 assetId) private { if (_assetApprovals[assetId] != address(0)) { _assetApprovals[assetId] = address(0); } } }
contract BAC002 is IssuerRole, Suspendable { using SafeMath for uint256; using Address for address; using Counters for Counters.Counter; // Equals to `bytes4(keccak256("onBAC002Received(address,address,uint256,bytes)"))` bytes4 private constant _BAC002_RECEIVED = 0x31f6f50e; // Mapping from asset ID to owner mapping(uint256 => address) private _assetOwner; // Mapping from asset ID to approved address mapping(uint256 => address) private _assetApprovals; // Mapping from owner to number of owned asset mapping(address => Counters.Counter) private _ownedAssetsCount; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; string private _description; string private _shortName; // Optional mapping for asset URIs mapping(uint256 => string) private _assetURIs; // Mapping from owner to list of owned asset IDs mapping(address => uint256[]) private _ownedAssets; // Mapping from asset ID to index of the owner assets list mapping(uint256 => uint256) private _ownedAssetsIndex; // Array with all asset ids, used for enumeration uint256[] private _allAssets; // Mapping from asset id to position in the allAssets array mapping(uint256 => uint256) private _allAssetsIndex; event Send(address indexed operator, address indexed from, address indexed to, uint256 assetId, bytes data); event Approval( address indexed owner, address approved, uint256 assetId); event ApprovalForAll( address indexed owner, address indexed operator, bool approved); // constructor constructor(string description, string shortName) public { _description = description; _shortName = shortName; } /** * @dev Gets the balance of the specified address. */ function balance(address owner) public view returns (uint256) { require(owner != address(0), "BAC002: balance query for the zero address"); return _ownedAssetsCount[owner].current(); } /** * @dev Gets the owner of the specified asset ID. */ function ownerOf(uint256 assetId) public view returns (address) { address owner = _assetOwner[assetId]; require(owner != address(0), "BAC002: owner query for nonexistent asset"); return owner; } function assetOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { require(index < balance(owner), "BAC002Enumerable: owner index out of bounds"); return _ownedAssets[owner][index]; } function assetOfOwner(address owner) public view returns (uint256[]) { return _ownedAssets[owner]; } function assetByIndex(uint256 index) public view returns (uint256) { require(index < totalSupply(), "BAC002Enumerable: global index out of bounds"); return _allAssets[index]; } /** * @dev Approves another address to send the given asset ID */ function approve(address to, uint256 assetId) public whenNotSuspended { address owner = ownerOf(assetId); require(to != owner, "BAC002: approval to current owner"); require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "BAC002: approve caller is not owner nor approved for all" ); _assetApprovals[assetId] = to; emit Approval( owner, to, assetId); } /** * @dev Gets the approved address for a asset ID, or zero if no address set */ function getApproved(uint256 assetId) public view returns (address) { require(_exists(assetId), "BAC002: approved query for nonexistent asset"); return _assetApprovals[assetId]; } /** * @dev Sets or unsets the approval of a given operator */ function setApprovalForAll(address to, bool approved) public whenNotSuspended { require(to != msg.sender, "BAC002: approve to caller"); _operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll( msg.sender, to, approved); } /** * @dev Tells whether an operator is approved by a given owner. */ function isApprovedForAll(address owner, address operator) public view returns (bool) { return _operatorApprovals[owner][operator]; } // /** // * @dev Sends the ownership of a given asset ID to another address. // */ // function sendFrom(address from, address to, uint256 assetId, bytes memory data) public whenNotSuspended { // //solhint-disable-next-line max-line-length // require(_isApprovedOrOwner(msg.sender, assetId), "BAC002: send caller is not owner nor approved"); // _sendFrom(from, to, assetId, data); // } // /** // * @dev Safely sends the ownership of a given asset ID to another address // */ // function safeSendFrom(address from, address to, uint256 assetId) public whenNotSuspended { // safeSendFrom(from, to, assetId, ""); // } /** * @dev Safely sends the ownership of a given asset ID to another address */ function sendFrom(address from, address to, uint256 assetId, bytes memory data) public whenNotSuspended { require(_isApprovedOrOwner(msg.sender, assetId), "BAC002: send caller is not owner nor approved"); _sendFrom(from, to, assetId, data); require(_checkOnBAC002Received(from, to, assetId, data), "BAC002: send to non BAC002Receiver implementer"); } function batchSendFrom(address from, address[] to, uint256[] assetId, bytes memory data) public whenNotSuspended { require(to.length == assetId.length, "to and assetId array lenght must match."); for (uint256 i = 0; i < to.length; ++i) { require(to[i] != address(0x0), "destination address must be non-zero."); sendFrom(from, to[i], assetId[i], data); } } function destroy(uint256 assetId, bytes data) public { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(msg.sender, assetId), "BAC002Burnable: caller is not owner nor approved"); _destroy(assetId, data); } //add issuerAddress function issueWithAssetURI(address to, uint256 assetId, string memory assetURI, bytes data) public onlyIssuer returns (bool) { _issue( to, assetId, data); _setAssetURI(assetId, assetURI); return true; } function description() external view returns (string memory) { return _description; } function shortName() external view returns (string memory) { return _shortName; } /** * @dev Returns an URI for a given asset ID. */ function assetURI(uint256 assetId) external view returns (string memory) { require(_exists(assetId), "BAC002Metadata: URI query for nonexistent asset"); return _assetURIs[assetId]; } /** * @dev Internal function to set the asset URI for a given asset. */ function _setAssetURI(uint256 assetId, string memory uri) internal { require(_exists(assetId), "BAC002Metadata: URI set of nonexistent asset"); _assetURIs[assetId] = uri; } /** * @dev Returns whether the specified asset exists. */ function _exists(uint256 assetId) internal view returns (bool) { address owner = _assetOwner[assetId]; return owner != address(0); } /** * @dev Returns whether the given spender can send a given asset ID. */ function _isApprovedOrOwner(address spender, uint256 assetId) internal view returns (bool) { require(_exists(assetId), "BAC002: operator query for nonexistent asset"); address owner = ownerOf(assetId); return (spender == owner || getApproved(assetId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Internal function to mint a new asset. */ function _issue( address to, uint256 assetId, bytes data) internal { require(to != address(0), "BAC002: mint to the zero address"); require(!_exists(assetId), "BAC002: asset already minted"); _assetOwner[assetId] = to; _ownedAssetsCount[to].increment(); emit Send(msg.sender, address(0), to, assetId, data); _addAssetToOwnerEnumeration(to, assetId); _addAssetToAllAssetsEnumeration(assetId); } /** * @dev Internal function to destroy a specific asset. * Reverts if the asset does not exist. */ function _destroy(address owner, uint256 assetId, bytes data) internal { require(ownerOf(assetId) == owner, "BAC002: destroy of asset that is not own"); _clearApproval(assetId); _ownedAssetsCount[owner].decrement(); _assetOwner[assetId] = address(0); if (bytes(_assetURIs[assetId]).length != 0) { delete _assetURIs[assetId]; } emit Send(this, owner, address(0), assetId, data); _removeAssetFromOwnerEnumeration(owner, assetId); // Since assetId will be deleted, we can clear its slot in _ownedAssetsIndex to trigger a gas refund _ownedAssetsIndex[assetId] = 0; _removeAssetFromAllAssetsEnumeration(assetId); } /** * @dev Gets the total amount of assets stored by the contract. * @return uint256 representing the total amount of assets */ function totalSupply() public view returns (uint256) { return _allAssets.length; } function _assetsOfOwner(address owner) internal view returns (uint256[] storage) { return _ownedAssets[owner]; } /** * @dev Private function to add a asset to this extension's ownership-tracking data structures. */ function _addAssetToOwnerEnumeration(address to, uint256 assetId) private { _ownedAssetsIndex[assetId] = _ownedAssets[to].length; _ownedAssets[to].push(assetId); } /** * @dev Private function to add a asset to this extension's asset tracking data structures. */ function _addAssetToAllAssetsEnumeration(uint256 assetId) private { _allAssetsIndex[assetId] = _allAssets.length; _allAssets.push(assetId); } /** * @dev Private function to remove a asset from this extension's ownership-tracking data structures. Note that */ function _removeAssetFromOwnerEnumeration(address from, uint256 assetId) private { // To prevent a gap in from's assets array, we store the last asset in the index of the asset to delete, and // then delete the last slot (swap and pop). uint256 lastAssetIndex = _ownedAssets[from].length.sub(1); uint256 assetIndex = _ownedAssetsIndex[assetId]; // When the asset to delete is the last asset, the swap operation is unnecessary if (assetIndex != lastAssetIndex) { uint256 lastAssetId = _ownedAssets[from][lastAssetIndex]; _ownedAssets[from][assetIndex] = lastAssetId; // Move the last asset to the slot of the to-delete asset _ownedAssetsIndex[lastAssetId] = assetIndex; // Update the moved asset's index } // This also deletes the contents at the last position of the array _ownedAssets[from].length--; // Note that _ownedAssetsIndex[assetId] hasn't been cleared: it still points to the old slot (now occupied by // lastAssetId, or just over the end of the array if the asset was the last one). } /** * @dev Private function to remove a asset from this extension's asset tracking data structures. */ function _removeAssetFromAllAssetsEnumeration(uint256 assetId) private { // To prevent a gap in the assets array, we store the last asset in the index of the asset to delete, and // then delete the last slot (swap and pop). uint256 lastAssetIndex = _allAssets.length.sub(1); uint256 assetIndex = _allAssetsIndex[assetId]; // When the asset to delete is the last asset, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted asset is destroyt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeAssetFromOwnerEnumeration) uint256 lastAssetId = _allAssets[lastAssetIndex]; _allAssets[assetIndex] = lastAssetId; // Move the last asset to the slot of the to-delete asset _allAssetsIndex[lastAssetId] = assetIndex; // Update the moved asset's index // This also deletes the contents at the last position of the array _allAssets.length--; _allAssetsIndex[assetId] = 0; } /** * @dev Internal function to destroy a specific asset. */ function _destroy(uint256 assetId, bytes data) internal { _destroy(ownerOf(assetId), assetId, data); } /** * @dev Internal function to send ownership of a given asset ID to another address. */ function _sendFrom(address from, address to, uint256 assetId, bytes data) internal { require(ownerOf(assetId) == from, "BAC002: send of asset that is not own"); require(to != address(0), "BAC002: send to the zero address"); _clearApproval(assetId); _ownedAssetsCount[from].decrement(); _ownedAssetsCount[to].increment(); _assetOwner[assetId] = to; emit Send(msg.sender, from, to, assetId, data); _removeAssetFromOwnerEnumeration(from, assetId); _addAssetToOwnerEnumeration(to, assetId); } /** * @dev Internal function to invoke `onBAC002Received` on a target address. */ function _checkOnBAC002Received(address from, address to, uint256 assetId, bytes memory _data) internal returns (bool) { if (!to.isContract()) { return true; } bytes4 retval = IBAC002Receiver(to).onBAC002Received(msg.sender, from, assetId, _data); return (retval == _BAC002_RECEIVED); } /** * @dev Private function to clear current approval of a given asset ID. */ function _clearApproval(uint256 assetId) private { if (_assetApprovals[assetId] != address(0)) { _assetApprovals[assetId] = address(0); } } }
33,253
31
// Get the custom indicator for a Loan Fund fund The Id of a Loan Fundreturn The indicator of whether a Loan Fund is custom or not /
function custom(bytes32 fund) public view returns (bool) { return bools[fund].custom; }
function custom(bytes32 fund) public view returns (bool) { return bools[fund].custom; }
45,199
11
// triggered when the rate between two tokens in the converter changesnote that the event might be dispatched for rate updates between any two tokens in the converter _token1 address of the first token_token2 address of the second token_rateNrate of 1 unit of `_token1` in `_token2` (numerator)_rateDrate of 1 unit of `_token1` in `_token2` (denominator) /
event TokenRateUpdate(IERC20Token indexed _token1, IERC20Token indexed _token2, uint256 _rateN, uint256 _rateD);
event TokenRateUpdate(IERC20Token indexed _token1, IERC20Token indexed _token2, uint256 _rateN, uint256 _rateD);
25,375
10
// Cast a vote without revealing the vote by posting a commitment/commitment Commitment to A or B, by commit-reveal scheme
function castHiddenVote(bytes32 commitment) external payable {
function castHiddenVote(bytes32 commitment) external payable {
53,433
99
// Record the changed point into history
point_history[_epoch] = last_point; if (_tokenId != 0) {
point_history[_epoch] = last_point; if (_tokenId != 0) {
25,759
79
// optional booster module for calculating virtual balances on strategies
IFlywheelBooster public flywheelBooster; constructor( ERC20 _rewardToken, IFlywheelRewards _flywheelRewards, IFlywheelBooster _flywheelBooster, address _owner, Authority _authority
IFlywheelBooster public flywheelBooster; constructor( ERC20 _rewardToken, IFlywheelRewards _flywheelRewards, IFlywheelBooster _flywheelBooster, address _owner, Authority _authority
46,375
43
// removes a smart token from the registry _smartToken smart token/
function removeSmartToken(IBancorConverterRegistryData _converterRegistryData, address _smartToken) internal { _converterRegistryData.removeSmartToken(_smartToken); emit SmartTokenRemoved(_smartToken); }
function removeSmartToken(IBancorConverterRegistryData _converterRegistryData, address _smartToken) internal { _converterRegistryData.removeSmartToken(_smartToken); emit SmartTokenRemoved(_smartToken); }
2,207
68
// Performs work on the contract. Executed by the keepers, via the registry. performData is the data which was passed back from the checkDatasimulation. /
function performUpkeep(bytes calldata performData) external;
function performUpkeep(bytes calldata performData) external;
50,549
17
// systemOnly/
function mintUnwrappedResources(uint _resourceId, address _to, uint _value, bool _mintUnwrappedResources) override public systemOnly { resource(_resourceId).mint(_to, _value, _mintUnwrappedResources); }
function mintUnwrappedResources(uint _resourceId, address _to, uint _value, bool _mintUnwrappedResources) override public systemOnly { resource(_resourceId).mint(_to, _value, _mintUnwrappedResources); }
11,320
16
// if you don&39;t have approval, throw
if(_approvals[from][msg.sender] < value) revert(); if(!safeToAdd(_balances[to], value)) revert();
if(_approvals[from][msg.sender] < value) revert(); if(!safeToAdd(_balances[to], value)) revert();
57,543
8
// Mapping of pending Wei
mapping(address => uint256) public pending_wei;
mapping(address => uint256) public pending_wei;
4,551
35
// Retuns wallet role indexwallet Wallet address/
function getWalletRoleIndex(address wallet) public view returns (uint8) { return walletRolesIndex[wallet]; }
function getWalletRoleIndex(address wallet) public view returns (uint8) { return walletRolesIndex[wallet]; }
18,212
6,438
// 3221
entry "lockingly" : ENG_ADVERB
entry "lockingly" : ENG_ADVERB
24,057
16
// 更新聯絡人資訊
_contact.name = _name; _contact.phone = _phone;
_contact.name = _name; _contact.phone = _phone;
17,406
35
// contract balances /
function cBalances() public view returns (uint, uint, uint, uint) { return (address(this).balance, _balanceReflections, _balanceLotteryPot, _balanceTeam); }
function cBalances() public view returns (uint, uint, uint, uint) { return (address(this).balance, _balanceReflections, _balanceLotteryPot, _balanceTeam); }
5,014
147
// send to arbitrator
address arb = IDeposit(operator).rewardArbitrator(); if(arb != address(0)){ IERC20(token).safeTransfer(arb, newbalance); }
address arb = IDeposit(operator).rewardArbitrator(); if(arb != address(0)){ IERC20(token).safeTransfer(arb, newbalance); }
8,704
106
// To change the starting tokenId, please override this function./
function _startTokenId() internal view virtual returns (uint256) { return 1; }
function _startTokenId() internal view virtual returns (uint256) { return 1; }
7,847
38
// Interface declaration /
function isToken() public constant returns (bool weAre) { return true; }
function isToken() public constant returns (bool weAre) { return true; }
3,619
312
// add eth to pot
round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot);
round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot);
59,111
266
// user functions // getter functions // pure functions //Geyser/Reward distribution contract with time multiplier/Security contact: [email protected]/ Access Control/ - Power controller:/ Can power off / shutdown the geyser/ Can withdraw rewards from reward pool once shutdown/ - Proxy owner:/ Can change arbitrary logic / state by upgrading the geyser/ Is unable to operate on user funds due to UniversalVault/ Is unable to operate on reward pool funds when reward pool is offline / shutdown/ - Geyser admin:/ Can add funds to the geyser, register bonus tokens, and whitelist new vault factories/ Is a subset of proxy owner permissions/ -
contract Geyser is IGeyser, Powered, OwnableUpgradeable { using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; /* constants */ // An upper bound on the number of active stakes per vault is required to prevent // calls to rageQuit() from reverting. // With 30 stakes in a vault, ragequit costs 432811 gas which is conservatively lower // than the hardcoded limit of 500k gas on the vault. // This limit is configurable and could be increased in a future deployment. // Ultimately, to avoid a need for fixed upper bounds, the EVM would need to provide // an error code that allows for reliably catching out-of-gas errors on remote calls. uint256 public constant MAX_STAKES_PER_VAULT = 30; uint256 public constant MAX_REWARD_TOKENS = 50; uint256 public constant BASE_SHARES_PER_WEI = 1000000; /* storage */ GeyserData private _geyser; mapping(address => VaultData) private _vaults; EnumerableSet.AddressSet private _bonusTokenSet; EnumerableSet.AddressSet private _vaultFactorySet; /* initializer */ function initializeLock() external initializer {} /// @notice Initizalize geyser /// access control: only proxy constructor /// state machine: can only be called once /// state scope: set initialization variables /// token transfer: none /// @param ownerAddress address The admin address /// @param rewardPoolFactory address The factory to use for deploying the RewardPool /// @param powerSwitchFactory address The factory to use for deploying the PowerSwitch /// @param stakingToken address The address of the staking token for this geyser /// @param rewardToken address The address of the reward token for this geyser /// @param rewardScaling RewardScaling The config for reward scaling floor, ceiling, and time function initialize( address ownerAddress, address rewardPoolFactory, address powerSwitchFactory, address stakingToken, address rewardToken, RewardScaling calldata rewardScaling ) external initializer { // the scaling floor must be smaller than ceiling require(rewardScaling.floor <= rewardScaling.ceiling, "Geyser: floor above ceiling"); // setting rewardScalingTime to 0 would cause divide by zero error // to disable reward scaling, use rewardScalingFloor == rewardScalingCeiling require(rewardScaling.time != 0, "Geyser: scaling time cannot be zero"); // deploy power switch address powerSwitch = IFactory(powerSwitchFactory).create(abi.encode(ownerAddress)); // deploy reward pool address rewardPool = IFactory(rewardPoolFactory).create(abi.encode(powerSwitch)); // set internal configs OwnableUpgradeable.__Ownable_init(); OwnableUpgradeable.transferOwnership(ownerAddress); Powered._setPowerSwitch(powerSwitch); // commit to storage _geyser.stakingToken = stakingToken; _geyser.rewardToken = rewardToken; _geyser.rewardPool = rewardPool; _geyser.rewardScaling = rewardScaling; // emit event emit GeyserCreated(rewardPool, powerSwitch); }
contract Geyser is IGeyser, Powered, OwnableUpgradeable { using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; /* constants */ // An upper bound on the number of active stakes per vault is required to prevent // calls to rageQuit() from reverting. // With 30 stakes in a vault, ragequit costs 432811 gas which is conservatively lower // than the hardcoded limit of 500k gas on the vault. // This limit is configurable and could be increased in a future deployment. // Ultimately, to avoid a need for fixed upper bounds, the EVM would need to provide // an error code that allows for reliably catching out-of-gas errors on remote calls. uint256 public constant MAX_STAKES_PER_VAULT = 30; uint256 public constant MAX_REWARD_TOKENS = 50; uint256 public constant BASE_SHARES_PER_WEI = 1000000; /* storage */ GeyserData private _geyser; mapping(address => VaultData) private _vaults; EnumerableSet.AddressSet private _bonusTokenSet; EnumerableSet.AddressSet private _vaultFactorySet; /* initializer */ function initializeLock() external initializer {} /// @notice Initizalize geyser /// access control: only proxy constructor /// state machine: can only be called once /// state scope: set initialization variables /// token transfer: none /// @param ownerAddress address The admin address /// @param rewardPoolFactory address The factory to use for deploying the RewardPool /// @param powerSwitchFactory address The factory to use for deploying the PowerSwitch /// @param stakingToken address The address of the staking token for this geyser /// @param rewardToken address The address of the reward token for this geyser /// @param rewardScaling RewardScaling The config for reward scaling floor, ceiling, and time function initialize( address ownerAddress, address rewardPoolFactory, address powerSwitchFactory, address stakingToken, address rewardToken, RewardScaling calldata rewardScaling ) external initializer { // the scaling floor must be smaller than ceiling require(rewardScaling.floor <= rewardScaling.ceiling, "Geyser: floor above ceiling"); // setting rewardScalingTime to 0 would cause divide by zero error // to disable reward scaling, use rewardScalingFloor == rewardScalingCeiling require(rewardScaling.time != 0, "Geyser: scaling time cannot be zero"); // deploy power switch address powerSwitch = IFactory(powerSwitchFactory).create(abi.encode(ownerAddress)); // deploy reward pool address rewardPool = IFactory(rewardPoolFactory).create(abi.encode(powerSwitch)); // set internal configs OwnableUpgradeable.__Ownable_init(); OwnableUpgradeable.transferOwnership(ownerAddress); Powered._setPowerSwitch(powerSwitch); // commit to storage _geyser.stakingToken = stakingToken; _geyser.rewardToken = rewardToken; _geyser.rewardPool = rewardPool; _geyser.rewardScaling = rewardScaling; // emit event emit GeyserCreated(rewardPool, powerSwitch); }
46,021
84
// This function initializes the piecemeal function. If it is already initialized, it will continue and return the currentFunctionStep of the status.
function initializeOrContinue(bytes32 _category) external returns (uint _currentFunctionStep);
function initializeOrContinue(bytes32 _category) external returns (uint _currentFunctionStep);
41,555
16
// Ownable has an owner address and provides basic authorization control functions./ This contract is modified version of the MIT OpenZepplin Ownable contract/ This contract allows for the transferOwnership operation to be made impossible/ https:github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/ownership/Ownable.sol
contract Ownable { event TransferredOwnership(address _from, address _to); event LockedOwnership(address _locked); address payable private _owner; bool private _isTransferable; /// @notice Constructor sets the original owner of the contract and whether or not it is one time transferable. constructor(address payable _account_, bool _transferable_) internal { _owner = _account_; _isTransferable = _transferable_; // Emit the LockedOwnership event if no longer transferable. if (!_isTransferable) { emit LockedOwnership(_account_); } emit TransferredOwnership(address(0), _account_); } /// @notice Reverts if called by any account other than the owner. modifier onlyOwner() { require(_isOwner(msg.sender), "sender is not an owner"); _; } /// @notice Allows the current owner to transfer control of the contract to a new address. /// @param _account address to transfer ownership to. /// @param _transferable indicates whether to keep the ownership transferable. function transferOwnership(address payable _account, bool _transferable) external onlyOwner { // Require that the ownership is transferable. require(_isTransferable, "ownership is not transferable"); // Require that the new owner is not the zero address. require(_account != address(0), "owner cannot be set to zero address"); // Set the transferable flag to the value _transferable passed in. _isTransferable = _transferable; // Emit the LockedOwnership event if no longer transferable. if (!_transferable) { emit LockedOwnership(_account); } // Emit the ownership transfer event. emit TransferredOwnership(_owner, _account); // Set the owner to the provided address. _owner = _account; } /// @notice check if the ownership is transferable. /// @return true if the ownership is transferable. function isTransferable() external view returns (bool) { return _isTransferable; } /// @notice Allows the current owner to relinquish control of the contract. /// @dev Renouncing to ownership will leave the contract without an owner and unusable. /// @dev It will not be possible to call the functions with the `onlyOwner` modifier anymore. function renounceOwnership() external onlyOwner { // Require that the ownership is transferable. require(_isTransferable, "ownership is not transferable"); // note that this could be terminal _owner = address(0); emit TransferredOwnership(_owner, address(0)); } /// @notice Find out owner address /// @return address of the owner. function owner() public view returns (address payable) { return _owner; } /// @notice Check if owner address /// @return true if sender is the owner of the contract. function _isOwner(address _address) internal view returns (bool) { return _address == _owner; } }
contract Ownable { event TransferredOwnership(address _from, address _to); event LockedOwnership(address _locked); address payable private _owner; bool private _isTransferable; /// @notice Constructor sets the original owner of the contract and whether or not it is one time transferable. constructor(address payable _account_, bool _transferable_) internal { _owner = _account_; _isTransferable = _transferable_; // Emit the LockedOwnership event if no longer transferable. if (!_isTransferable) { emit LockedOwnership(_account_); } emit TransferredOwnership(address(0), _account_); } /// @notice Reverts if called by any account other than the owner. modifier onlyOwner() { require(_isOwner(msg.sender), "sender is not an owner"); _; } /// @notice Allows the current owner to transfer control of the contract to a new address. /// @param _account address to transfer ownership to. /// @param _transferable indicates whether to keep the ownership transferable. function transferOwnership(address payable _account, bool _transferable) external onlyOwner { // Require that the ownership is transferable. require(_isTransferable, "ownership is not transferable"); // Require that the new owner is not the zero address. require(_account != address(0), "owner cannot be set to zero address"); // Set the transferable flag to the value _transferable passed in. _isTransferable = _transferable; // Emit the LockedOwnership event if no longer transferable. if (!_transferable) { emit LockedOwnership(_account); } // Emit the ownership transfer event. emit TransferredOwnership(_owner, _account); // Set the owner to the provided address. _owner = _account; } /// @notice check if the ownership is transferable. /// @return true if the ownership is transferable. function isTransferable() external view returns (bool) { return _isTransferable; } /// @notice Allows the current owner to relinquish control of the contract. /// @dev Renouncing to ownership will leave the contract without an owner and unusable. /// @dev It will not be possible to call the functions with the `onlyOwner` modifier anymore. function renounceOwnership() external onlyOwner { // Require that the ownership is transferable. require(_isTransferable, "ownership is not transferable"); // note that this could be terminal _owner = address(0); emit TransferredOwnership(_owner, address(0)); } /// @notice Find out owner address /// @return address of the owner. function owner() public view returns (address payable) { return _owner; } /// @notice Check if owner address /// @return true if sender is the owner of the contract. function _isOwner(address _address) internal view returns (bool) { return _address == _owner; } }
35,540
192
// The block number when CAKE 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); constructor( SahiSwapToken _Sahi, SyrupBar _syrup, address _devaddr,
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); constructor( SahiSwapToken _Sahi, SyrupBar _syrup, address _devaddr,
2,323
9
// Get the amount of tokens that an entity has for sale in the marketplace. _entityIdUnique platform ID of the entity. _tokenId The ID assigned to an external token.return amount of tokens that the entity has for sale in the marketplace. /
function getLockedBalance(bytes32 _entityId, bytes32 _tokenId) external view returns (uint256 amount);
function getLockedBalance(bytes32 _entityId, bytes32 _tokenId) external view returns (uint256 amount);
20,314
269
// Sets a new token price. /
function setTokenPrice(uint256 newPrice) external onlyOwner { _tokenPrice = newPrice; }
function setTokenPrice(uint256 newPrice) external onlyOwner { _tokenPrice = newPrice; }
16,055
231
// ERAContract/
contract ERAContract is BaseContract { /** * Initializer function */ function initialize() public initializer { init('ERA Equity Token', 'ERA', 0, 48425000, 0x1cCA38991Ff68BbE73e89973019ca28b2352A7ed, 0x1cCA38991Ff68BbE73e89973019ca28b2352A7ed); } /** * Payable function */ fallback() external payable { buy(msg.sender, msg.value); } }
contract ERAContract is BaseContract { /** * Initializer function */ function initialize() public initializer { init('ERA Equity Token', 'ERA', 0, 48425000, 0x1cCA38991Ff68BbE73e89973019ca28b2352A7ed, 0x1cCA38991Ff68BbE73e89973019ca28b2352A7ed); } /** * Payable function */ fallback() external payable { buy(msg.sender, msg.value); } }
21,135
2
// the value `StakingRewards.accumulatedRewardsPerToken()` at the last checkpoint
uint256 accumulatedRewardsPerTokenAtLastCheckpoint;
uint256 accumulatedRewardsPerTokenAtLastCheckpoint;
26,771
19
// when farming was started with 1y and 12tokens and we want to finish after 4 months, we need to end up with situation like we were starting with 4mo and 4 tokens.
function finishFarming() external whenActive onlyOwner { require(block.timestamp < periodFinish, "can't stop if not started or already finished"); stopped = true; uint256 tokensToBurn; if (_totalSupply == 0) { tokensToBurn = rewardsToken.balanceOf(address(this)); } else { uint256 remaining = periodFinish.sub(block.timestamp); tokensToBurn = rewardRate.mul(remaining); rewardsDuration = rewardsDuration - remaining; } periodFinish = block.timestamp; IBurnableToken(address(rewardsToken)).burn(tokensToBurn); emit FarmingFinished(tokensToBurn); }
function finishFarming() external whenActive onlyOwner { require(block.timestamp < periodFinish, "can't stop if not started or already finished"); stopped = true; uint256 tokensToBurn; if (_totalSupply == 0) { tokensToBurn = rewardsToken.balanceOf(address(this)); } else { uint256 remaining = periodFinish.sub(block.timestamp); tokensToBurn = rewardRate.mul(remaining); rewardsDuration = rewardsDuration - remaining; } periodFinish = block.timestamp; IBurnableToken(address(rewardsToken)).burn(tokensToBurn); emit FarmingFinished(tokensToBurn); }
5,666