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 |
|---|---|---|---|---|
3 | // tokens staked on each paper by each user | mapping(uint256 => mapping(address => uint256)) private userTokensStaked;
| mapping(uint256 => mapping(address => uint256)) private userTokensStaked;
| 20,402 |
206 | // bytes4(keccak256("Error(string)")) | bytes4 internal constant STANDARD_ERROR_SELECTOR =
0x08c379a0;
| bytes4 internal constant STANDARD_ERROR_SELECTOR =
0x08c379a0;
| 14,303 |
4 | // Donor Functions /// | function deposit(uint256 amount_, address recipient_) external override returns (uint256 depositId) {
depositId = _createDeposit(amount_, recipient_);
IERC20(gEXO).safeTransferFrom(msg.sender, address(this), amount_);
}
| function deposit(uint256 amount_, address recipient_) external override returns (uint256 depositId) {
depositId = _createDeposit(amount_, recipient_);
IERC20(gEXO).safeTransferFrom(msg.sender, address(this), amount_);
}
| 27,151 |
16 | // Shares available balance (if any) among all the owners and increments their balances.Withdraws balance of the caller. / | function withdraw() external onlyOwner {
uint256 availableBalance = getAvailableBalance();
if (availableBalance >= owners.length) {
uint256 share = availableBalance / owners.length;
for (uint256 i; i < owners.length; i++) {
addressBalance[owners[i]] += share;
}
}
uint256 amount = addressBalance[msg.sender];
require(amount > 0, "Governance: No Reef to be claimed");
addressBalance[msg.sender] = 0;
(bool success, ) = msg.sender.call{ value: amount }("");
require(success, "Governance: Error sending REEF");
}
| function withdraw() external onlyOwner {
uint256 availableBalance = getAvailableBalance();
if (availableBalance >= owners.length) {
uint256 share = availableBalance / owners.length;
for (uint256 i; i < owners.length; i++) {
addressBalance[owners[i]] += share;
}
}
uint256 amount = addressBalance[msg.sender];
require(amount > 0, "Governance: No Reef to be claimed");
addressBalance[msg.sender] = 0;
(bool success, ) = msg.sender.call{ value: amount }("");
require(success, "Governance: Error sending REEF");
}
| 44,581 |
29 | // the strings below are the buffers for a voxel's vertex data.every node refers to a mesh described by this same buffer.initially I had a single buffer and applied a scale transform to every node depdnding on stylebut this was inefficient and caused a 4x bigger payload and longer execution time.when the "exploded" style is chosen the buffer is modified to be a smaller voxel.index and normal buffers are the same regardless of style. | if(voxelStyle < 2){
gltfAccumulator = strConcat(gltfAccumulator, 'AAAAvwAAAL8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAL8AAAA/AAAAPwAAAL8AAAC/AAAAvwAAAL8AAAC/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAPwAAAD8AAAC/AAAAPwAAAL8AAAC/AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAD8AAAA/AAAAvwAAAL8AAAC/AAAAvwAAAD8AAAC/AAAAvwAAAL8AAAC/AAAAvwAAAD8AAAC/AAAAPwAAAL8AAAC/AAAAPwAAAD8AAAC/');
} else {
| if(voxelStyle < 2){
gltfAccumulator = strConcat(gltfAccumulator, 'AAAAvwAAAL8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAL8AAAA/AAAAPwAAAL8AAAC/AAAAvwAAAL8AAAC/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAPwAAAD8AAAC/AAAAPwAAAL8AAAC/AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAD8AAAA/AAAAvwAAAL8AAAC/AAAAvwAAAD8AAAC/AAAAvwAAAL8AAAC/AAAAvwAAAD8AAAC/AAAAPwAAAL8AAAC/AAAAPwAAAD8AAAC/');
} else {
| 45,163 |
385 | // hit stack too deep error when using more variables, so we use sessionsIds.length in multiple places instead of creating new variables | uint256[] memory ids = new uint256[](sessionIds.length);
for (uint256 i = 0; i < sessionIds.length; i++) {
require(bytes(properties[i].definition).length > 0, "Definition is required");
require(sessionIds[i] > 0, "Valid sessionId is required");
require(properties[i].supply > 0, "Minimum supply is 1");
uint256 id = generateId(_msgSender(), sessionIds[i], properties[i].operatingAgreement);
for (uint256 j = 0; j < recipients.length; j++) {
address to = recipients[j];
require(to != address(0), "ERC1155: mint to the zero address");
uint256 amount = amounts[j];
| uint256[] memory ids = new uint256[](sessionIds.length);
for (uint256 i = 0; i < sessionIds.length; i++) {
require(bytes(properties[i].definition).length > 0, "Definition is required");
require(sessionIds[i] > 0, "Valid sessionId is required");
require(properties[i].supply > 0, "Minimum supply is 1");
uint256 id = generateId(_msgSender(), sessionIds[i], properties[i].operatingAgreement);
for (uint256 j = 0; j < recipients.length; j++) {
address to = recipients[j];
require(to != address(0), "ERC1155: mint to the zero address");
uint256 amount = amounts[j];
| 18,501 |
1 | // Unpack the proof and extract the execution outcome. | Borsh.Data memory borshData = Borsh.from(proofData);
ProofDecoder.FullOutcomeProof memory fullOutcomeProof = borshData.decodeFullOutcomeProof();
require(borshData.finished(), 'Argument should be exact borsh serialization');
bytes32 receiptId = fullOutcomeProof.outcome_proof.outcome_with_id.outcome.receipt_ids[0];
require(!usedEvents_[receiptId], 'The burn event cannot be reused');
if (isUsing) {
usedEvents_[receiptId] = true;
}
| Borsh.Data memory borshData = Borsh.from(proofData);
ProofDecoder.FullOutcomeProof memory fullOutcomeProof = borshData.decodeFullOutcomeProof();
require(borshData.finished(), 'Argument should be exact borsh serialization');
bytes32 receiptId = fullOutcomeProof.outcome_proof.outcome_with_id.outcome.receipt_ids[0];
require(!usedEvents_[receiptId], 'The burn event cannot be reused');
if (isUsing) {
usedEvents_[receiptId] = true;
}
| 8,535 |
73 | // Multiplies two `Signed`s and "ceil's" the product, reverting on overflow. a a FixedPoint.Signed. b a FixedPoint.Signed.return the product of `a` and `b`. / | function mulAwayFromZero(Signed memory a, Signed memory b) internal pure returns (Signed memory) {
int256 mulRaw = a.rawValue.mul(b.rawValue);
int256 mulTowardsZero = mulRaw / SFP_SCALING_FACTOR;
// Manual mod because SignedSafeMath doesn't support it.
int256 mod = mulRaw % SFP_SCALING_FACTOR;
if (mod != 0) {
bool isResultPositive = isLessThan(a, 0) == isLessThan(b, 0);
int256 valueToAdd = isResultPositive ? int256(1) : int256(-1);
return Signed(mulTowardsZero.add(valueToAdd));
} else {
return Signed(mulTowardsZero);
}
}
| function mulAwayFromZero(Signed memory a, Signed memory b) internal pure returns (Signed memory) {
int256 mulRaw = a.rawValue.mul(b.rawValue);
int256 mulTowardsZero = mulRaw / SFP_SCALING_FACTOR;
// Manual mod because SignedSafeMath doesn't support it.
int256 mod = mulRaw % SFP_SCALING_FACTOR;
if (mod != 0) {
bool isResultPositive = isLessThan(a, 0) == isLessThan(b, 0);
int256 valueToAdd = isResultPositive ? int256(1) : int256(-1);
return Signed(mulTowardsZero.add(valueToAdd));
} else {
return Signed(mulTowardsZero);
}
}
| 21,231 |
4 | // dev state variable indicating whether the contract has been upgraded / | bool public upgraded = false;
| bool public upgraded = false;
| 31,983 |
54 | // if any account belongs to _isExcludedFromFee account then remove the fee | if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
| if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
| 55,763 |
40 | // Emit NewController(oldController, newController) | emit NewController(oldController, newController);
| emit NewController(oldController, newController);
| 49,111 |
127 | // A descriptive name for a collection of NFTs. / | string internal nftName;
| string internal nftName;
| 20,151 |
166 | // AddressArrayUtils Set Protocol Utility functions to handle Address Arrays / | library AddressArrayUtils {
/**
* Finds the index of the first occurrence of the given element.
* @param A The input array to search
* @param a The value to find
* @return Returns (index and isIn) for the first occurrence starting from index 0
*/
function indexOf(address[] memory A, address a) internal pure returns (uint256, bool) {
uint256 length = A.length;
for (uint256 i = 0; i < length; i++) {
if (A[i] == a) {
return (i, true);
}
}
return (uint256(-1), false);
}
/**
* Returns true if the value is present in the list. Uses indexOf internally.
* @param A The input array to search
* @param a The value to find
* @return Returns isIn for the first occurrence starting from index 0
*/
function contains(address[] memory A, address a) internal pure returns (bool) {
(, bool isIn) = indexOf(A, a);
return isIn;
}
/**
* Returns true if there are 2 elements that are the same in an array
* @param A The input array to search
* @return Returns boolean for the first occurrence of a duplicate
*/
function hasDuplicate(address[] memory A) internal pure returns(bool) {
require(A.length > 0, "A is empty");
for (uint256 i = 0; i < A.length - 1; i++) {
address current = A[i];
for (uint256 j = i + 1; j < A.length; j++) {
if (current == A[j]) {
return true;
}
}
}
return false;
}
/**
* @param A The input array to search
* @param a The address to remove
* @return Returns the array with the object removed.
*/
function remove(address[] memory A, address a)
internal
pure
returns (address[] memory)
{
(uint256 index, bool isIn) = indexOf(A, a);
if (!isIn) {
revert("Address not in array.");
} else {
(address[] memory _A,) = pop(A, index);
return _A;
}
}
/**
* Removes specified index from array
* @param A The input array to search
* @param index The index to remove
* @return Returns the new array and the removed entry
*/
function pop(address[] memory A, uint256 index)
internal
pure
returns (address[] memory, address)
{
uint256 length = A.length;
require(index < A.length, "Index must be < A length");
address[] memory newAddresses = new address[](length - 1);
for (uint256 i = 0; i < index; i++) {
newAddresses[i] = A[i];
}
for (uint256 j = index + 1; j < length; j++) {
newAddresses[j - 1] = A[j];
}
return (newAddresses, A[index]);
}
}
| library AddressArrayUtils {
/**
* Finds the index of the first occurrence of the given element.
* @param A The input array to search
* @param a The value to find
* @return Returns (index and isIn) for the first occurrence starting from index 0
*/
function indexOf(address[] memory A, address a) internal pure returns (uint256, bool) {
uint256 length = A.length;
for (uint256 i = 0; i < length; i++) {
if (A[i] == a) {
return (i, true);
}
}
return (uint256(-1), false);
}
/**
* Returns true if the value is present in the list. Uses indexOf internally.
* @param A The input array to search
* @param a The value to find
* @return Returns isIn for the first occurrence starting from index 0
*/
function contains(address[] memory A, address a) internal pure returns (bool) {
(, bool isIn) = indexOf(A, a);
return isIn;
}
/**
* Returns true if there are 2 elements that are the same in an array
* @param A The input array to search
* @return Returns boolean for the first occurrence of a duplicate
*/
function hasDuplicate(address[] memory A) internal pure returns(bool) {
require(A.length > 0, "A is empty");
for (uint256 i = 0; i < A.length - 1; i++) {
address current = A[i];
for (uint256 j = i + 1; j < A.length; j++) {
if (current == A[j]) {
return true;
}
}
}
return false;
}
/**
* @param A The input array to search
* @param a The address to remove
* @return Returns the array with the object removed.
*/
function remove(address[] memory A, address a)
internal
pure
returns (address[] memory)
{
(uint256 index, bool isIn) = indexOf(A, a);
if (!isIn) {
revert("Address not in array.");
} else {
(address[] memory _A,) = pop(A, index);
return _A;
}
}
/**
* Removes specified index from array
* @param A The input array to search
* @param index The index to remove
* @return Returns the new array and the removed entry
*/
function pop(address[] memory A, uint256 index)
internal
pure
returns (address[] memory, address)
{
uint256 length = A.length;
require(index < A.length, "Index must be < A length");
address[] memory newAddresses = new address[](length - 1);
for (uint256 i = 0; i < index; i++) {
newAddresses[i] = A[i];
}
for (uint256 j = index + 1; j < length; j++) {
newAddresses[j - 1] = A[j];
}
return (newAddresses, A[index]);
}
}
| 44,312 |
28 | // Redeem the entire balance of aToken from Aave | function redeemAll() external onlyOwner
| function redeemAll() external onlyOwner
| 29,850 |
78 | // register the supported interface to conform to ERC721Enumerable via ERC165 | _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
| _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
| 18,011 |
18 | // Mint the ERC 721 ladybug token, transfer it to the recipient. This is a very simple distribution of the bugs, they're not part of a great reveal,we're not looking to game anyone, they simply want a good home with someone that'llappreciate them. The goal is to mint the ladybugs in a non-sequential order.To do so, I'm adding alittle "randomness" on each mint.It's by no means perfect or unpredicatable, butthat's the scope of this project. Perhaps my next project, with a larger budget, will merit a more challenging andsophisticted mint.That would be a lot of fun to work on. Until then, | function _mintInternal(address recipient) internal returns (uint) {
// the tokens are 1.._MAX_LADYBUGS (i.e. not zero-based)
uint16 _index = uint16(_currentSupplyIndex() + 1);
uint newItemId;
// check if this index is part of the mapping
if (_randomized[_index] != 0) {
newItemId = _randomized[_index];
// it would be nice to remove the entry from _randomized after retrieving the value,
// but the gas was too expensive and so i chose not not, on behalf of the minter
} else {
uint16 n = uint16(_index + uint256(keccak256(abi.encodePacked(block.timestamp))) % (_MAX_LADYBUGS - _currentSupplyIndex()));
// if the random number is not already holding a swap, use it ...
if (_randomized[n] == 0 && _index != n) {
_randomized[n] = _index;
newItemId = n;
} else {
// ... else just use the index, the random swap (n) already has a value
newItemId = _index;
}
}
_mint(recipient, newItemId);
// increment the supply counter
_incrementCurrentSupplyIndex();
return newItemId;
}
| function _mintInternal(address recipient) internal returns (uint) {
// the tokens are 1.._MAX_LADYBUGS (i.e. not zero-based)
uint16 _index = uint16(_currentSupplyIndex() + 1);
uint newItemId;
// check if this index is part of the mapping
if (_randomized[_index] != 0) {
newItemId = _randomized[_index];
// it would be nice to remove the entry from _randomized after retrieving the value,
// but the gas was too expensive and so i chose not not, on behalf of the minter
} else {
uint16 n = uint16(_index + uint256(keccak256(abi.encodePacked(block.timestamp))) % (_MAX_LADYBUGS - _currentSupplyIndex()));
// if the random number is not already holding a swap, use it ...
if (_randomized[n] == 0 && _index != n) {
_randomized[n] = _index;
newItemId = n;
} else {
// ... else just use the index, the random swap (n) already has a value
newItemId = _index;
}
}
_mint(recipient, newItemId);
// increment the supply counter
_incrementCurrentSupplyIndex();
return newItemId;
}
| 64,529 |
28 | // ========== MUTATIVE FUNCTIONS ========== / Stake tokens to receive rewards Locked tokens cannot be withdrawn for lockDuration and are eligible to receive stakingReward rewards | function stake(uint256 amount, bool lock) external nonReentrant updateReward(msg.sender) {
require(amount > 0, "MultiFeeDistribution::stake: Cannot stake 0");
totalSupply = totalSupply.add(amount);
Balances storage bal = balances[msg.sender];
bal.total = bal.total.add(amount);
if (lock) {
lockedSupply = lockedSupply.add(amount);
bal.locked = bal.locked.add(amount);
uint256 unlockTime = block.timestamp.div(rewardsDuration).mul(rewardsDuration).add(lockDuration);
uint256 idx = userLocks[msg.sender].length;
if (idx == 0 || userLocks[msg.sender][idx - 1].unlockTime < unlockTime) {
userLocks[msg.sender].push(LockedBalance({amount: amount, unlockTime: unlockTime}));
} else {
userLocks[msg.sender][idx - 1].amount = userLocks[msg.sender][idx - 1].amount.add(amount);
}
} else {
bal.unlocked = bal.unlocked.add(amount);
}
stakingToken.safeTransferFrom(msg.sender, address(this), amount);
emit Staked(msg.sender, amount);
}
| function stake(uint256 amount, bool lock) external nonReentrant updateReward(msg.sender) {
require(amount > 0, "MultiFeeDistribution::stake: Cannot stake 0");
totalSupply = totalSupply.add(amount);
Balances storage bal = balances[msg.sender];
bal.total = bal.total.add(amount);
if (lock) {
lockedSupply = lockedSupply.add(amount);
bal.locked = bal.locked.add(amount);
uint256 unlockTime = block.timestamp.div(rewardsDuration).mul(rewardsDuration).add(lockDuration);
uint256 idx = userLocks[msg.sender].length;
if (idx == 0 || userLocks[msg.sender][idx - 1].unlockTime < unlockTime) {
userLocks[msg.sender].push(LockedBalance({amount: amount, unlockTime: unlockTime}));
} else {
userLocks[msg.sender][idx - 1].amount = userLocks[msg.sender][idx - 1].amount.add(amount);
}
} else {
bal.unlocked = bal.unlocked.add(amount);
}
stakingToken.safeTransferFrom(msg.sender, address(this), amount);
emit Staked(msg.sender, amount);
}
| 16,300 |
10 | // Transfers the ownership of an NFT from one address to another address/This works identically to the other function with an extra data parameter,/except this function just sets data to ""./_from The current owner of the NFT/_to The new owner/_tokenId The NFT to transfer | function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId
| function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId
| 15,827 |
28 | // check if sender has balance and for oveflow | require(_to != address(0));
require(_amount <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_amount);
balances[_to] = balances[_to].add(_amount);
emit Transfer(msg.sender, _to, _amount);
return true;
| require(_to != address(0));
require(_amount <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_amount);
balances[_to] = balances[_to].add(_amount);
emit Transfer(msg.sender, _to, _amount);
return true;
| 45,759 |
21 | // Burn used tokens | _burnBatch(
_msgSender(),
ids,
amounts
);
| _burnBatch(
_msgSender(),
ids,
amounts
);
| 11,899 |
24 | // Mapping of user addresses to mappings of epochs to delegated/ voting power of individual users. This includes self-delegation, and is/ a direct representation of voting power. | mapping(address => mapping(uint256 => uint256)) internal delegatedAtEpoch;
| mapping(address => mapping(uint256 => uint256)) internal delegatedAtEpoch;
| 17,225 |
64 | // Update investor | investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);
| investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);
| 13,856 |
27 | // Determine how many tokens to distribute based on cumulativeAmount/Parse share values for rebasing tokens according to their logic/Return normal ERC20 values directly/Currently handles the DIGG special case | function _parseValue(address token, uint256 amount) internal view returns (uint256) {
if (token == DIGG_ADDRESS) {
return IDigg(token).sharesToFragments(amount);
} else {
return amount;
}
}
| function _parseValue(address token, uint256 amount) internal view returns (uint256) {
if (token == DIGG_ADDRESS) {
return IDigg(token).sharesToFragments(amount);
} else {
return amount;
}
}
| 1,315 |
3 | // dForce's lending MockAggregator Contract dForce / | contract MockAggregator {
uint8 public decimals = 8;
int256 public latestAnswer;
/**
* @notice Construct an aggregator
*/
constructor() public {}
/**
* @dev Set a int256 value for the latest answer.
*/
function setLatestAnswer(int256 _latestAnswer) external {
latestAnswer = _latestAnswer;
}
/**
* @dev Set a uint8 value for the decimals.
*/
function setDecimals(uint8 _decimals) external {
decimals = _decimals;
}
}
| contract MockAggregator {
uint8 public decimals = 8;
int256 public latestAnswer;
/**
* @notice Construct an aggregator
*/
constructor() public {}
/**
* @dev Set a int256 value for the latest answer.
*/
function setLatestAnswer(int256 _latestAnswer) external {
latestAnswer = _latestAnswer;
}
/**
* @dev Set a uint8 value for the decimals.
*/
function setDecimals(uint8 _decimals) external {
decimals = _decimals;
}
}
| 46,718 |
25 | // address provider | IAddressProvider public addressProvider;
| IAddressProvider public addressProvider;
| 22,697 |
14 | // ensure token is mintable | require(tokenId > 0 && tokenId <= highestTokenId, 'invalid tokenId');
| require(tokenId > 0 && tokenId <= highestTokenId, 'invalid tokenId');
| 22,933 |
23 | // Copyright 2018 BurzNest LLC. All rights reserved. The contents of this file are provided for reviewand educational purposes ONLY. You MAY NOT use,copy, distribute, or modify this software withoutexplicit written permission from BurzNest LLC.//King of Eth: Auctions Abstract Interface/Anthony Burzillo <burz@burznest.com>/Abstract interface contract for auctions of houses | contract KingOfEthAuctionsAbstractInterface {
/// @dev Determines if there is an auction at a particular location
/// @param _x The x coordinate of the auction
/// @param _y The y coordinate of the auction
/// @return true if there is an existing auction
function existingAuction(uint _x, uint _y) public view returns(bool);
}
| contract KingOfEthAuctionsAbstractInterface {
/// @dev Determines if there is an auction at a particular location
/// @param _x The x coordinate of the auction
/// @param _y The y coordinate of the auction
/// @return true if there is an existing auction
function existingAuction(uint _x, uint _y) public view returns(bool);
}
| 1,274 |
6 | // by 0xAA | pragma solidity ^0.8.1;
import "./ERCN1155.sol";
| pragma solidity ^0.8.1;
import "./ERCN1155.sol";
| 24,477 |
107 | // View your available load limit | function loadLimitAvailable() external view returns (uint256) {
return _loadLimit._getAvailableLimit();
}
| function loadLimitAvailable() external view returns (uint256) {
return _loadLimit._getAvailableLimit();
}
| 16,947 |
23 | // Used by an operator to de-register itself from providing service to the middleware. pkToRemove is the sender's pubkey in affine coordinates index is the sender's location in the dynamic array `operatorList` / | function deregisterOperator(BN254.G1Point memory pkToRemove, uint32 index) external virtual returns (bool) {
require(
permissionManager.getOperatorDeregisterPermission(msg.sender) == true,
"BLSRegistry.deregisterOperator: Operator should apply deregister permission first and then can deregister"
);
_deregisterOperator(msg.sender, pkToRemove, index);
return true;
}
| function deregisterOperator(BN254.G1Point memory pkToRemove, uint32 index) external virtual returns (bool) {
require(
permissionManager.getOperatorDeregisterPermission(msg.sender) == true,
"BLSRegistry.deregisterOperator: Operator should apply deregister permission first and then can deregister"
);
_deregisterOperator(msg.sender, pkToRemove, index);
return true;
}
| 34,189 |
18 | // Initializes main contract variables and transfers funds for the sale. Init function. _funder The address that funds the token for crowdsale. _token Address of the token being sold. _paymentCurrency The currency the crowdsale accepts for payment. Can be ETH or token address. _totalTokens The total number of tokens to sell in crowdsale. _startTime Crowdsale start time. _endTime Crowdsale end time. _rate Number of token units a buyer gets per wei or token. _goal Minimum amount of funds to be raised in weis or tokens. _admin Address that can finalize auction. _pointList Address that will manage auction approvals. _wallet Address where | function initCrowdsale(
address _funder,
address _token,
address _paymentCurrency,
uint256 _totalTokens,
uint256 _startTime,
uint256 _endTime,
uint256 _rate,
| function initCrowdsale(
address _funder,
address _token,
address _paymentCurrency,
uint256 _totalTokens,
uint256 _startTime,
uint256 _endTime,
uint256 _rate,
| 14,748 |
7 | // assert(b > 0);Solidity automatically throws when dividing by 0 | uint256 c = a / b;
| uint256 c = a / b;
| 47,945 |
9 | // Minor Stake Fine getter/setter | function minorStakeFine() external view returns (uint256) {
return StakingLibrary.stakingStorage().minorStakeFine;
}
| function minorStakeFine() external view returns (uint256) {
return StakingLibrary.stakingStorage().minorStakeFine;
}
| 22,995 |
1 | // Can only bisect assertion in response to a challenge | string private constant BIS_STATE = "BIS_STATE";
| string private constant BIS_STATE = "BIS_STATE";
| 9,293 |
18 | // Emitted when a cToken market is determined to be manually burnt or not / | event MarketManualBurn(
| event MarketManualBurn(
| 35,993 |
61 | // eg. WBTC - DSD - and bridgeFor(DSD) = WBTC | RipOut = _convertStep(token0, bridge1, amount0, _swap(token1, bridge1, amount1, address(this)));
| RipOut = _convertStep(token0, bridge1, amount0, _swap(token1, bridge1, amount1, address(this)));
| 26,982 |
51 | // Emits an {Upgraded} event. / | function _upgradeTo(address newImplementation) internal virtual {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
| function _upgradeTo(address newImplementation) internal virtual {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
| 8,445 |
355 | // Getter for the BalancerSafeMath contract Convenience function to get the address of the BalancerSafeMath library (so clients can check version)return address of the BalancerSafeMath library / | function getBalancerSafeMathVersion() external pure returns (address) {
return address(BalancerSafeMath);
}
| function getBalancerSafeMathVersion() external pure returns (address) {
return address(BalancerSafeMath);
}
| 40,411 |
31 | // 如果之前的路径上 推荐满了3个用户,则新开分支 | if (refcount>0 && refcount%3==0) {
node.parent = referalLink;
_nodes[referalLink].children.push(sender);
} else {
| if (refcount>0 && refcount%3==0) {
node.parent = referalLink;
_nodes[referalLink].children.push(sender);
} else {
| 24,071 |
53 | // Update the swap fee to be applied on swaps newSwapFee new swap fee to be applied on future transactions / | function setSwapFee(uint256 newSwapFee) external onlyOwner {
swapStorage.setSwapFee(newSwapFee);
}
| function setSwapFee(uint256 newSwapFee) external onlyOwner {
swapStorage.setSwapFee(newSwapFee);
}
| 20,969 |
2 | // Make sure the call is from old token contract | require(msg.sender == oldTokenAddr);
| require(msg.sender == oldTokenAddr);
| 32,628 |
11 | // ---------------------------------------------------------------------------- Safe maths ---------------------------------------------------------------------------- | library SafeMath {
function add(uint a, uint b) internal pure returns (uint c) {
c = a + b;
require(c >= a);
}
function sub(uint a, uint b) internal pure returns (uint c) {
require(b <= a);
c = a - b;
}
function mul(uint a, uint b) internal pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function div(uint a, uint b) internal pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
| library SafeMath {
function add(uint a, uint b) internal pure returns (uint c) {
c = a + b;
require(c >= a);
}
function sub(uint a, uint b) internal pure returns (uint c) {
require(b <= a);
c = a - b;
}
function mul(uint a, uint b) internal pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function div(uint a, uint b) internal pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
| 2,457 |
6 | // Allows the owner of a tournament to specify an administrator responsible for executingthe actual matches of the tournament.newAdminaddress to assign administrative rights to / | function setAdmin(address newAdmin) public onlyOwner {
admin = newAdmin;
}
| function setAdmin(address newAdmin) public onlyOwner {
admin = newAdmin;
}
| 38,725 |
30 | // Returns total value locked of all stakers/ return Total amount staked in wei | function getTotalStaked() external view returns (uint256);
| function getTotalStaked() external view returns (uint256);
| 1,256 |
22 | // get a pseudo random number within the range NOTE: This is not a real random number, and anyone can check what this function generates.This means players can see who they will kill on their `move()` transaction Two benefits by hack this contract: 1. Users can avoid kill him/her self 2. Users can use multiple accounts to make their main account go forward with less risks. We can solve this issue by using VRF, or an external oracle (a.k.a centralization),but that becomes too complicated and cost inefficient for this small event project.I will leave these edge cases as a part of | function _getRandom(uint256 range) private view returns (uint256) {
return uint256(keccak256(abi.encodePacked(_msgSender(), block.number, block.timestamp, accMoveCount))) % range;
}
| function _getRandom(uint256 range) private view returns (uint256) {
return uint256(keccak256(abi.encodePacked(_msgSender(), block.number, block.timestamp, accMoveCount))) % range;
}
| 5,956 |
3 | // Different variables, but bts0 was assigned to bts1, so they point to the same area in memory. | assert(bts0.equalsRef(bts1));
| assert(bts0.equalsRef(bts1));
| 25,075 |
46 | // The vault request to harvest the profit | function harvest(uint256 _bankPoolId) external; // IStrategy
function harvest(uint256 _bankPoolId, uint256 _poolId) external; // IStrategyV2
| function harvest(uint256 _bankPoolId) external; // IStrategy
function harvest(uint256 _bankPoolId, uint256 _poolId) external; // IStrategyV2
| 49,215 |
459 | // Changes the existing Short Term Load (STL) value. | function _changeSTL(uint _stl) internal {
stl = _stl;
}
| function _changeSTL(uint _stl) internal {
stl = _stl;
}
| 22,402 |
46 | // Check if the sender has enough tokens | require(balances[msg.sender] >= _value);
| require(balances[msg.sender] >= _value);
| 27,754 |
18 | // Next token needs to be greater than the current one to prevent duplicates | require(currentToken < tokens[j], "duplicate token");
| require(currentToken < tokens[j], "duplicate token");
| 33,441 |
4 | // Multiplies two factors, returns the product factorA the first factor factorB the second factorreturn product the product of the equation (e.g. factorAfactorB) / | function mul(
uint256 factorA,
uint256 factorB
| function mul(
uint256 factorA,
uint256 factorB
| 35,470 |
15 | // Ensure that the spender has enough allowance. | uint256 remaining = _allowances[from][msg.sender];
require(remaining >= amt, ERROR_INSUFFICIENT);
| uint256 remaining = _allowances[from][msg.sender];
require(remaining >= amt, ERROR_INSUFFICIENT);
| 33,135 |
29 | // returns current EAA Rate / | function getCurrentEAAR() external view returns (uint256) {
return _calculateEAARate();
}
| function getCurrentEAAR() external view returns (uint256) {
return _calculateEAARate();
}
| 15,687 |
27 | // Returns the current total borrows plus accrued interestreturn The total borrows with interest / | function totalBorrowsCurrent() external override returns (uint256) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature("totalBorrowsCurrent()"));
return abi.decode(data, (uint256));
}
| function totalBorrowsCurrent() external override returns (uint256) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature("totalBorrowsCurrent()"));
return abi.decode(data, (uint256));
}
| 26,340 |
12 | // `wad` amount of the gem was locked in the contract by `usr`. usr The operator address. wad The amount locked. / | event Lock(address indexed usr, uint256 wad);
| event Lock(address indexed usr, uint256 wad);
| 32,818 |
11 | // ensure no zero address | require(_txAddress != address(0));
uint _requestId = _numRequests++;
TransferRequest memory req = TransferRequest(
_toAddress,
_txAddress,
_amount,
false,
_requestId
);
| require(_txAddress != address(0));
uint _requestId = _numRequests++;
TransferRequest memory req = TransferRequest(
_toAddress,
_txAddress,
_amount,
false,
_requestId
);
| 30,538 |
337 | // round 27 | ark(i, q, 20162517328110570500010831422938033120419484532231241180224283481905744633719);
sbox_partial(i, q);
mix(i, q);
| ark(i, q, 20162517328110570500010831422938033120419484532231241180224283481905744633719);
sbox_partial(i, q);
mix(i, q);
| 24,128 |
428 | // function {_autoSwap} Automate the swap of accumulated tax fees to native tokenfrom_ The sender of the token / | function _autoSwap(address from_, address to_) internal {
if (tokenHasTax) {
uint256 taxBalance = balanceOf(address(this));
if (_eligibleForSwap(from_, to_, taxBalance)) {
| function _autoSwap(address from_, address to_) internal {
if (tokenHasTax) {
uint256 taxBalance = balanceOf(address(this));
if (_eligibleForSwap(from_, to_, taxBalance)) {
| 7,614 |
28 | // If the signature is valid (and not malleable), return the signer address | address signer = ecrecover(hash, v, r, s);
require(signer != address(0), "ECDSA: invalid signature");
return signer;
| address signer = ecrecover(hash, v, r, s);
require(signer != address(0), "ECDSA: invalid signature");
return signer;
| 13,371 |
32 | // OTHER FUNCTIONS // Retrieves lastest version number of a given market / | function getCurVersionNumber(uint _marketId) public view validMarketId(_marketId)
returns (uint)
| function getCurVersionNumber(uint _marketId) public view validMarketId(_marketId)
returns (uint)
| 18,370 |
10 | // Returns total number of scheduled unlocks / | function unlocksCount() public constant returns(uint256) {
return unlockDates.length;
}
| function unlocksCount() public constant returns(uint256) {
return unlockDates.length;
}
| 31,087 |
4 | // Log the event. Don't pass controller state variable or deployment will revert. | emit SetController(msg.sender);
| emit SetController(msg.sender);
| 50,877 |
22 | // write 3 bytes | let output := add(
add(
shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)),
shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))),
add(
shl( 6, and(mload(add(tablePtr, and(shr( 8, input), 0xFF))), 0xFF)),
and(mload(add(tablePtr, and( input , 0xFF))), 0xFF)
)
)
mstore(resultPtr, shl(232, output))
| let output := add(
add(
shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)),
shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))),
add(
shl( 6, and(mload(add(tablePtr, and(shr( 8, input), 0xFF))), 0xFF)),
and(mload(add(tablePtr, and( input , 0xFF))), 0xFF)
)
)
mstore(resultPtr, shl(232, output))
| 22,867 |
1 | // IronBankPrime ERC827 Token, where all tokens are pre-assigned to the creator. / | contract IronBankPrime is IronBankToken {
string public constant name = "Iron Bank prime"; // solium-disable-line uppercase
string public constant symbol = "IRON"; // solium-disable-line uppercase
uint8 public constant decimals = 18; // solium-disable-line uppercase
uint256 public constant INITIAL_SUPPLY = 1000000000 * (10 ** uint256(decimals));
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
function IronBankPrime() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
}
| contract IronBankPrime is IronBankToken {
string public constant name = "Iron Bank prime"; // solium-disable-line uppercase
string public constant symbol = "IRON"; // solium-disable-line uppercase
uint8 public constant decimals = 18; // solium-disable-line uppercase
uint256 public constant INITIAL_SUPPLY = 1000000000 * (10 ** uint256(decimals));
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
function IronBankPrime() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
}
| 1,004 |
20 | // /withdraw protocol token (BZRX) from vesting contract vBZRX/receiver address of BZRX tokens claimed/amount of BZRX token to be claimed. max is claimed if amount is greater than balance./ return rewardToken reward token address/ return withdrawAmount amount | function withdrawProtocolToken(address receiver, uint256 amount)
external
returns (address rewardToken, uint256 withdrawAmount);
| function withdrawProtocolToken(address receiver, uint256 amount)
external
returns (address rewardToken, uint256 withdrawAmount);
| 5,425 |
252 | // Pitch 32 | index |= 32;
| index |= 32;
| 37,118 |
29 | // We can mint up to a balance of SUPPLY_PER_TOKEN_ID | return SUPPLY_PER_TOKEN_ID.sub(currentSupply);
| return SUPPLY_PER_TOKEN_ID.sub(currentSupply);
| 1,248 |
6 | // Set the new Governance Gnosis Safe multisig address / | function setGovernance(address _governance) external onlyGovernance {
require(_governance != address(0), "zero address");
governance = _governance;
emit SetGovernance(_governance);
}
| function setGovernance(address _governance) external onlyGovernance {
require(_governance != address(0), "zero address");
governance = _governance;
emit SetGovernance(_governance);
}
| 50,908 |
329 | // Get reserve asset decimals | uint256 reserveAssetDecimals = ERC20(_reserveAsset).decimals();
uint256 normalizedTotalReserveQuantityNetFees = _netReserveFlows.preciseDiv(10 ** reserveAssetDecimals);
uint256 normalizedTotalReserveQuantityNetFeesAndPremium = _netReserveFlows.sub(premiumValue).preciseDiv(10 ** reserveAssetDecimals);
| uint256 reserveAssetDecimals = ERC20(_reserveAsset).decimals();
uint256 normalizedTotalReserveQuantityNetFees = _netReserveFlows.preciseDiv(10 ** reserveAssetDecimals);
uint256 normalizedTotalReserveQuantityNetFeesAndPremium = _netReserveFlows.sub(premiumValue).preciseDiv(10 ** reserveAssetDecimals);
| 27,650 |
124 | // Returns proposed next asset implementation contract address. return asset implementation contract address. / | function getPendingVersion() constant returns(address) {
return pendingVersion;
}
| function getPendingVersion() constant returns(address) {
return pendingVersion;
}
| 21,932 |
6 | // Start the value stack with the function call ABI for the entrypoint | Value[] memory startingValues = new Value[](3);
startingValues[0] = ValueLib.newRefNull();
startingValues[1] = ValueLib.newI32(0);
startingValues[2] = ValueLib.newI32(0);
| Value[] memory startingValues = new Value[](3);
startingValues[0] = ValueLib.newRefNull();
startingValues[1] = ValueLib.newI32(0);
startingValues[2] = ValueLib.newI32(0);
| 80 |
548 | // If the rate oracle is not set, the asset is not interest bearing and has an oracle rate of zero. | if (address(ar.rateOracle) == address(0)) return 0;
uint256 rate = ar.rateOracle.getAnnualizedSupplyRate();
| if (address(ar.rateOracle) == address(0)) return 0;
uint256 rate = ar.rateOracle.getAnnualizedSupplyRate();
| 6,112 |
8 | // Sends the corresponding ether to each winner depending on the total bets | function distributePrizes(uint256 numberWinner) public {
address[100] memory winners; // We have to create a temporary in memory array with fixed size
uint256 count = 0; // This is the count for the array of winners
for(uint256 i = 0; i < players.length; i++){
address playerAddress = players[i];
if(playerInfo[playerAddress].numberSelected == numberWinner){
winners[count] = playerAddress;
count++;
}
delete playerInfo[playerAddress]; // Delete all the players
}
delete players; // Delete all the players array
uint256 winnerEtherAmount = totalBet / winners.length; // How much each winner gets
for(uint256 j = 0; j < count; j++){
// Check that the address in this fixed array is not empty
if(winners[j] != address(0)){
payable(address(winners[j])).transfer(winnerEtherAmount);
}
}
}
| function distributePrizes(uint256 numberWinner) public {
address[100] memory winners; // We have to create a temporary in memory array with fixed size
uint256 count = 0; // This is the count for the array of winners
for(uint256 i = 0; i < players.length; i++){
address playerAddress = players[i];
if(playerInfo[playerAddress].numberSelected == numberWinner){
winners[count] = playerAddress;
count++;
}
delete playerInfo[playerAddress]; // Delete all the players
}
delete players; // Delete all the players array
uint256 winnerEtherAmount = totalBet / winners.length; // How much each winner gets
for(uint256 j = 0; j < count; j++){
// Check that the address in this fixed array is not empty
if(winners[j] != address(0)){
payable(address(winners[j])).transfer(winnerEtherAmount);
}
}
}
| 919 |
21 | // Returns x on uint80 and check that it does not overflow/x The value as an uint256/ return y The value as an uint80 | function safe80(uint256 x) internal pure returns (uint80 y) {
if ((y = uint80(x)) != x) revert SafeCast__Exceeds80Bits(x);
}
| function safe80(uint256 x) internal pure returns (uint80 y) {
if ((y = uint80(x)) != x) revert SafeCast__Exceeds80Bits(x);
}
| 9,954 |
33 | // LXL `client` or `clientOracle` can release milestone `amount` to `provider` up to `sum` or until `lock()`.registration Registered LXL index. / | function release(uint256 registration) external nonReentrant {
Locker storage locker = lockers[registration];
require(_msgSender() == locker.client || _msgSender() == locker.clientOracle, "!client/oracle");
require(locker.confirmed == 1, "!confirmed");
require(locker.locked == 0, "locked");
require(locker.released < locker.sum, "released");
uint256 milestone = locker.currentMilestone-1;
uint256 payment = locker.amount[milestone];
IERC20(locker.token).safeTransfer(locker.provider, payment);
locker.released = locker.released.add(payment);
if (locker.released < locker.sum) {locker.currentMilestone++;}
emit Release(milestone+1, registration);
}
| function release(uint256 registration) external nonReentrant {
Locker storage locker = lockers[registration];
require(_msgSender() == locker.client || _msgSender() == locker.clientOracle, "!client/oracle");
require(locker.confirmed == 1, "!confirmed");
require(locker.locked == 0, "locked");
require(locker.released < locker.sum, "released");
uint256 milestone = locker.currentMilestone-1;
uint256 payment = locker.amount[milestone];
IERC20(locker.token).safeTransfer(locker.provider, payment);
locker.released = locker.released.add(payment);
if (locker.released < locker.sum) {locker.currentMilestone++;}
emit Release(milestone+1, registration);
}
| 38,942 |
26 | // Waitlist mint Waitlist minting of token by paying price. A new token will be minted by calling mint function of NFT contract. quantity Number of tokens to mint. / | function mintWaitlist(uint256 quantity, bytes32[] calldata proof)
external
payable
whenNotPaused
validatPhaseTwoPurchase(quantity, proof)
| function mintWaitlist(uint256 quantity, bytes32[] calldata proof)
external
payable
whenNotPaused
validatPhaseTwoPurchase(quantity, proof)
| 23,055 |
206 | // Supply the magic number for the required ERC-1155 interface. | bytes4 private constant INTERFACE_ERC1155 = 0xd9b67a26;
| bytes4 private constant INTERFACE_ERC1155 = 0xd9b67a26;
| 46,470 |
10 | // xy >= k | return metadata.reserve0 * metadata.reserve1;
| return metadata.reserve0 * metadata.reserve1;
| 28,387 |
14 | // Name must only include upper and lowercase English letters,/ numbers, and certain characters: ! ( ) - . _ SPACE/ Function will return false if the name is not valid/ or if it&39;s too similar to a name that&39;s already taken. | function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
| function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
| 31,018 |
15 | // Multiplies three exponentials, returning a new exponential. / | function mulExp3(Exp memory a, Exp memory b, Exp memory c) pure internal returns (MathError, Exp memory) {
(MathError err, Exp memory ab) = mulExp(a, b);
if (err != MathError.NO_ERROR) {
return (err, ab);
}
return mulExp(ab, c);
}
| function mulExp3(Exp memory a, Exp memory b, Exp memory c) pure internal returns (MathError, Exp memory) {
(MathError err, Exp memory ab) = mulExp(a, b);
if (err != MathError.NO_ERROR) {
return (err, ab);
}
return mulExp(ab, c);
}
| 12,358 |
23 | // Frozen account._target The address to being frozen._flag The status of the frozen/ | function setFrozen(address _target,bool _flag) onlyAdmin public {
frozen[_target]=_flag;
emit FrozenStatus(_target,_flag);
}
| function setFrozen(address _target,bool _flag) onlyAdmin public {
frozen[_target]=_flag;
emit FrozenStatus(_target,_flag);
}
| 65,676 |
117 | // Resolve governance address from Vault contract, used to make assertionson protected functions in the Strategy. / | function governance() internal view returns (address) {
return vault.governance();
}
| function governance() internal view returns (address) {
return vault.governance();
}
| 1,483 |
3 | // Settle Trader/this function in the fcm let's traders settle with the MarginEngine based on their settlement cashflows which is a functon of their fixed and variable token balances | function settleTrader() external returns (int256);
| function settleTrader() external returns (int256);
| 27,271 |
86 | // A method to the aggregated stakes from all stakeholders. return uint256 The aggregated stakes from all stakeholders./ | function totalStakes()
external
view
returns(uint256)
| function totalStakes()
external
view
returns(uint256)
| 33,604 |
124 | // 把给定地址从私募代理人数组中删除 | uint256 agentIndex = privateSaleAgentsIndex[_addr];
uint256 lastAgentIndex = privateSaleAgents.length.sub(1);
address lastAgent = privateSaleAgents[lastAgentIndex];
privateSaleAgents[agentIndex] = lastAgent;
delete privateSaleAgents[lastAgentIndex];
privateSaleAgents.length--;
privateSaleAgentsIndex[_addr] = 0;
privateSaleAgentsIndex[lastAgent] = agentIndex;
| uint256 agentIndex = privateSaleAgentsIndex[_addr];
uint256 lastAgentIndex = privateSaleAgents.length.sub(1);
address lastAgent = privateSaleAgents[lastAgentIndex];
privateSaleAgents[agentIndex] = lastAgent;
delete privateSaleAgents[lastAgentIndex];
privateSaleAgents.length--;
privateSaleAgentsIndex[_addr] = 0;
privateSaleAgentsIndex[lastAgent] = agentIndex;
| 48,875 |
17 | // OpenZeppelin Erc20 implementation without _burn private method and with cap mechanism / | contract ERC20Unburnable is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor (string memory nameGiven, string memory symbolGiven) {
_name = nameGiven;
_symbol = symbolGiven;
_decimals = 18;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20Unburnable: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20Unburnable: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20Unburnable: transfer from the zero address");
require(recipient != address(0), "ERC20Unburnable: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20Unburnable: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20Unburnable: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20Unburnable: approve from the zero address");
require(spender != address(0), "ERC20Unburnable: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {
}
}
| contract ERC20Unburnable is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor (string memory nameGiven, string memory symbolGiven) {
_name = nameGiven;
_symbol = symbolGiven;
_decimals = 18;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20Unburnable: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20Unburnable: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20Unburnable: transfer from the zero address");
require(recipient != address(0), "ERC20Unburnable: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20Unburnable: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20Unburnable: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20Unburnable: approve from the zero address");
require(spender != address(0), "ERC20Unburnable: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {
}
}
| 12,331 |
17 | // This event is emitted when a lease is approved by the current lessee or owner to a future lessee/_from is the address that is approving the lease for a specific address/_to is the specific address that is approved for the lease/_tokenId is the tokenid of the asset for which lease is being approved/_start is the start time for the lease approved/_end is the end time for the lease approved | event LeaseApproval(
address indexed _from,
address indexed _to,
uint256 indexed _tokenId,
uint256 _start,
uint256 _end
);
| event LeaseApproval(
address indexed _from,
address indexed _to,
uint256 indexed _tokenId,
uint256 _start,
uint256 _end
);
| 6,341 |
18 | // check a state | modifier inState(State _state) {
require (state == _state);
_;
}
| modifier inState(State _state) {
require (state == _state);
_;
}
| 52,881 |
11 | // Safe Token // Gets balance of this contract in terms of the underlying This excludes the value of the current message, if anyreturn The quantity of underlying tokens owned by this contract / | function getCashPrior() internal override view returns (uint) {
ERC20Burnable token = ERC20Burnable(underlying);
return token.balanceOf(address(this));
}
| function getCashPrior() internal override view returns (uint) {
ERC20Burnable token = ERC20Burnable(underlying);
return token.balanceOf(address(this));
}
| 6,375 |
192 | // defines if a specific deposit should or not be used as a collateral in borrows | bool useAsCollateral;
| bool useAsCollateral;
| 24,246 |
66 | // Update records of deposited ETH to include the received amount. | balances[msg.sender] += msg.value;
| balances[msg.sender] += msg.value;
| 23,611 |
27 | // overall burned KRK - skipped! | totalMintedKRK = totalMintedKRK.add(krks);
totalDepositedEth = totalDepositedEth.add(weiAmount);
totalFeesPaid = totalFeesPaid.add(fee);
totalKrakintEarnings = totalKrakintEarnings.add(krakintFee);
totalInvestorsEarnings = totalInvestorsEarnings.add(investorFee);
totalDepositAfterFees = totalDepositAfterFees.add(afterFees);
| totalMintedKRK = totalMintedKRK.add(krks);
totalDepositedEth = totalDepositedEth.add(weiAmount);
totalFeesPaid = totalFeesPaid.add(fee);
totalKrakintEarnings = totalKrakintEarnings.add(krakintFee);
totalInvestorsEarnings = totalInvestorsEarnings.add(investorFee);
totalDepositAfterFees = totalDepositAfterFees.add(afterFees);
| 31,548 |
58 | // return The token users receive as they unstake. / | function getDistributionToken() public view returns (IERC20) {
assert(_unlockedPool.token() == _lockedPool.token());
return _unlockedPool.token();
}
| function getDistributionToken() public view returns (IERC20) {
assert(_unlockedPool.token() == _lockedPool.token());
return _unlockedPool.token();
}
| 11,365 |
621 | // Gets the owner of this contract/ return owner_ The owner/Ownership is deferred to the owner of the Dispatcher contract | function getOwner() public view returns (address owner_) {
return IDispatcher(DISPATCHER).getOwner();
}
| function getOwner() public view returns (address owner_) {
return IDispatcher(DISPATCHER).getOwner();
}
| 82,913 |
11 | // Contract that handles auctions for surplus stability fees | SurplusAuctionHouseLike public surplusAuctionHouse;
| SurplusAuctionHouseLike public surplusAuctionHouse;
| 12,784 |
24 | // Return Curve Vesting Address/ | function getCurveVestingAddr() internal pure returns (address) {
return 0x575CCD8e2D300e2377B43478339E364000318E2c;
}
| function getCurveVestingAddr() internal pure returns (address) {
return 0x575CCD8e2D300e2377B43478339E364000318E2c;
}
| 273 |
40 | // Helper function for choosing the correct value (`value1` or `value2`) depending on `inNum`. | function _num(
int256 inNum,
uint256 value1,
uint256 value2
| function _num(
int256 inNum,
uint256 value1,
uint256 value2
| 52,286 |
344 | // Return the pending stake and fees for a delegator _delegator Address of a delegator _endRound The last round to claim earnings for when calculating the pending stake and feesreturn (stake, fees) where stake is the delegator's pending stake and fees is the delegator's pending fees / | function pendingStakeAndFees(address _delegator, uint256 _endRound) internal view returns (uint256 stake, uint256 fees) {
Delegator storage del = delegators[_delegator];
Transcoder storage t = transcoders[del.delegateAddress];
fees = del.fees;
stake = del.bondedAmount;
uint256 startRound = del.lastClaimRound.add(1);
address delegateAddr = del.delegateAddress;
bool isTranscoder = _delegator == delegateAddr;
uint256 lip36Round = roundsManager().lipUpgradeRound(36);
while (startRound <= _endRound && startRound <= lip36Round) {
EarningsPool.Data storage earningsPool = t.earningsPoolPerRound[startRound];
// If earningsPool.hasTranscoderRewardFeePool is not set during lip36Round then the transcoder did not call
// reward during lip36Round before the upgrade. In this case, if the transcoder calls reward in lip36Round
// the delegator can use the LIP-36 earnings claiming algorithm to claim for lip36Round
if (startRound == lip36Round && !earningsPool.hasTranscoderRewardFeePool) {
break;
}
if (earningsPool.hasClaimableShares()) {
// Calculate and add fee pool share from this round
fees = fees.add(earningsPool.feePoolShare(stake, isTranscoder));
// Calculate new bonded amount with rewards from this round. Updated bonded amount used
// to calculate fee pool share in next round
stake = stake.add(earningsPool.rewardPoolShare(stake, isTranscoder));
}
startRound = startRound.add(1);
}
// If the transcoder called reward during lip36Round the upgrade, then startRound = lip36Round
// Otherwise, startRound = lip36Round + 1
// If the start round is greater than the end round, we've already claimed for the end round so we do not
// need to execute the LIP-36 earnings claiming algorithm. This could be the case if:
// - _endRound < lip36Round i.e. we are not claiming through the lip36Round
// - _endRound == lip36Round AND startRound = lip36Round + 1 i.e we already claimed through the lip36Round
// The LIP-36 earnings claiming algorithm uses the cumulative factors from the delegator's lastClaimRound i.e. startRound - 1
// and from the specified _endRound
// We only need to execute this algorithm if the end round >= lip36Round
if (_endRound >= lip36Round) {
// Make sure there is a round to claim i.e. end round - (start round - 1) > 0
if (startRound <= _endRound) {
(
stake,
fees
) = delegatorCumulativeStakeAndFees(t, startRound.sub(1), _endRound, stake, fees);
}
// cumulativeRewards and cumulativeFees will track *all* rewards/fees earned by the transcoder
// so it is important that this is only executed with the end round as the current round or else
// the returned stake and fees will reflect rewards/fees earned in the future relative to the end round
if (isTranscoder) {
stake = stake.add(t.cumulativeRewards);
fees = fees.add(t.cumulativeFees);
}
}
return (stake, fees);
}
| function pendingStakeAndFees(address _delegator, uint256 _endRound) internal view returns (uint256 stake, uint256 fees) {
Delegator storage del = delegators[_delegator];
Transcoder storage t = transcoders[del.delegateAddress];
fees = del.fees;
stake = del.bondedAmount;
uint256 startRound = del.lastClaimRound.add(1);
address delegateAddr = del.delegateAddress;
bool isTranscoder = _delegator == delegateAddr;
uint256 lip36Round = roundsManager().lipUpgradeRound(36);
while (startRound <= _endRound && startRound <= lip36Round) {
EarningsPool.Data storage earningsPool = t.earningsPoolPerRound[startRound];
// If earningsPool.hasTranscoderRewardFeePool is not set during lip36Round then the transcoder did not call
// reward during lip36Round before the upgrade. In this case, if the transcoder calls reward in lip36Round
// the delegator can use the LIP-36 earnings claiming algorithm to claim for lip36Round
if (startRound == lip36Round && !earningsPool.hasTranscoderRewardFeePool) {
break;
}
if (earningsPool.hasClaimableShares()) {
// Calculate and add fee pool share from this round
fees = fees.add(earningsPool.feePoolShare(stake, isTranscoder));
// Calculate new bonded amount with rewards from this round. Updated bonded amount used
// to calculate fee pool share in next round
stake = stake.add(earningsPool.rewardPoolShare(stake, isTranscoder));
}
startRound = startRound.add(1);
}
// If the transcoder called reward during lip36Round the upgrade, then startRound = lip36Round
// Otherwise, startRound = lip36Round + 1
// If the start round is greater than the end round, we've already claimed for the end round so we do not
// need to execute the LIP-36 earnings claiming algorithm. This could be the case if:
// - _endRound < lip36Round i.e. we are not claiming through the lip36Round
// - _endRound == lip36Round AND startRound = lip36Round + 1 i.e we already claimed through the lip36Round
// The LIP-36 earnings claiming algorithm uses the cumulative factors from the delegator's lastClaimRound i.e. startRound - 1
// and from the specified _endRound
// We only need to execute this algorithm if the end round >= lip36Round
if (_endRound >= lip36Round) {
// Make sure there is a round to claim i.e. end round - (start round - 1) > 0
if (startRound <= _endRound) {
(
stake,
fees
) = delegatorCumulativeStakeAndFees(t, startRound.sub(1), _endRound, stake, fees);
}
// cumulativeRewards and cumulativeFees will track *all* rewards/fees earned by the transcoder
// so it is important that this is only executed with the end round as the current round or else
// the returned stake and fees will reflect rewards/fees earned in the future relative to the end round
if (isTranscoder) {
stake = stake.add(t.cumulativeRewards);
fees = fees.add(t.cumulativeFees);
}
}
return (stake, fees);
}
| 42,722 |
65 | // 権限チェック用関数のoverridesrc 実行者アドレス sig 実行関数の識別子 return 実行が許可されていればtrue、そうでなければfalse / | function isAuthorized(address src, bytes4 sig) internal view returns (bool) {
sig; // #HACK
return src == address(this) ||
src == owner ||
src == tokenAddress ||
src == authorityAddress ||
src == multiSigAddress;
}
| function isAuthorized(address src, bytes4 sig) internal view returns (bool) {
sig; // #HACK
return src == address(this) ||
src == owner ||
src == tokenAddress ||
src == authorityAddress ||
src == multiSigAddress;
}
| 19,770 |
171 | // Get debt, currentValue (want+idle), only want | uint256 debt = vault.strategies(address(this)).totalDebt;
uint256 currentValue = estimatedTotalAssets();
uint256 wantBalance = balanceOfWant();
| uint256 debt = vault.strategies(address(this)).totalDebt;
uint256 currentValue = estimatedTotalAssets();
uint256 wantBalance = balanceOfWant();
| 56,087 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.