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
|
---|---|---|---|---|
67 | // @solidity memory-safe-assembly | assembly {
revert(add(32, reason), mload(reason))
}
| assembly {
revert(add(32, reason), mload(reason))
}
| 20,940 |
18 | // Get all active token payment idsreturn the payment ids / | function allActivePaymentIds() external view returns(uint256[] memory){
uint256 activeCount;
// Get number of active payments
for (uint256 i; i < numPayments; i++) {
if(claimableBalance(i) > 0) {
activeCount++;
}
}
// Create result array of length `activeCount`
uint256[] memory result = new uint256[](activeCount);
uint256 j;
// Populate result array
for (uint256 i; i < numPayments; i++) {
if(claimableBalance(i) > 0) {
result[j] = i;
j++;
}
}
return result;
}
| function allActivePaymentIds() external view returns(uint256[] memory){
uint256 activeCount;
// Get number of active payments
for (uint256 i; i < numPayments; i++) {
if(claimableBalance(i) > 0) {
activeCount++;
}
}
// Create result array of length `activeCount`
uint256[] memory result = new uint256[](activeCount);
uint256 j;
// Populate result array
for (uint256 i; i < numPayments; i++) {
if(claimableBalance(i) > 0) {
result[j] = i;
j++;
}
}
return result;
}
| 76,596 |
2 | // Super User functions | function receiveToken(address spender, uint256 amount)
ifSuperUser
| function receiveToken(address spender, uint256 amount)
ifSuperUser
| 41,888 |
4 | // Contract constructor define initial administrator/ | function admined() internal {
admin = msg.sender; //Set initial admin to contract creator
emit Admined(admin);
}
| function admined() internal {
admin = msg.sender; //Set initial admin to contract creator
emit Admined(admin);
}
| 3,607 |
6 | // assert(b > 0);Solidity automatically throws when dividing by 0 | uint256 c = a / b;
| uint256 c = a / b;
| 24,677 |
26 | // transfer the token to the redeemer | _mint(msg.sender, voucher.tokens[i].tokenId);
| _mint(msg.sender, voucher.tokens[i].tokenId);
| 24,198 |
20 | // Get the current price./ return The current price or 0 if we are outside milestone period | function getCurrentPrice() public constant returns (uint result) {
return getCurrentMilestone().price;
}
| function getCurrentPrice() public constant returns (uint result) {
return getCurrentMilestone().price;
}
| 50,554 |
36 | // return requested section | return((((_input / _start).mul(_start)).sub((_input / _end).mul(_end))) / _start);
| return((((_input / _start).mul(_start)).sub((_input / _end).mul(_end))) / _start);
| 16,922 |
18 | // at this point we know that array.length > info.index >= 0 | uint256 last = array[array.length - 1]; // will never underflow
table[last].index = info.index;
array[info.index] = last;
array.length -= 1; // will never underflow
delete table[_id];
| uint256 last = array[array.length - 1]; // will never underflow
table[last].index = info.index;
array[info.index] = last;
array.length -= 1; // will never underflow
delete table[_id];
| 31,633 |
4 | // Emitted when a DiamondCut takes place | event DiamondCut(IDiamond.FacetCut[] _diamondCut, address _init, bytes _calldata);
| event DiamondCut(IDiamond.FacetCut[] _diamondCut, address _init, bytes _calldata);
| 32,890 |
11 | // search a book by its isbn | function searchByISBN(bytes10 _isbn) public view returns(Book memory) {
require(_isbn10Check(_isbn), "Invalid ISBN-10");
return store[_isbn];
}
| function searchByISBN(bytes10 _isbn) public view returns(Book memory) {
require(_isbn10Check(_isbn), "Invalid ISBN-10");
return store[_isbn];
}
| 26,466 |
28 | // Returns the vesting schedule information for a given holder and index.return the vesting schedule structure information / | function getVestingScheduleByAddressAndIndex(
address holder,
uint256 index
| function getVestingScheduleByAddressAndIndex(
address holder,
uint256 index
| 15,898 |
33 | // END OF LIFE | function contractOwnerDestroyContract() external onlyOwner() {
address payable _owner = payable(this.owner());
selfdestruct(_owner);
}
| function contractOwnerDestroyContract() external onlyOwner() {
address payable _owner = payable(this.owner());
selfdestruct(_owner);
}
| 12,482 |
3 | // whitelist entry with a discount | struct WhitelistTicket {
// this also overrides maximum ticket
uint128 discountAmountEurUlps;
// a percentage of full price to be paid (1 - discount)
uint128 fullTokenPriceFrac;
}
| struct WhitelistTicket {
// this also overrides maximum ticket
uint128 discountAmountEurUlps;
// a percentage of full price to be paid (1 - discount)
uint128 fullTokenPriceFrac;
}
| 38,348 |
3 | // 5% of payment amount is collected as process fees | uint256 fees = (5 * amount)/100;
manager.transfer(fees);
| uint256 fees = (5 * amount)/100;
manager.transfer(fees);
| 48,725 |
20 | // ====================================GETTER FUNCTIONS TO GET DETAILS ABOUT A PRODUCT======================== | function returnList() public returns(string memory){
string memory storelist;
for (uint i = 0 ; i < ProductsList.length; i++){
storelist = strConcat(storelist,getGeneralInfo(ProductsList[i]));
}
return storelist;
}
| function returnList() public returns(string memory){
string memory storelist;
for (uint i = 0 ; i < ProductsList.length; i++){
storelist = strConcat(storelist,getGeneralInfo(ProductsList[i]));
}
return storelist;
}
| 49,098 |
133 | // This function allows users to retireve all information about a staker_staker address of staker inquiring about return uint current state of staker return uint startDate of staking/ | function getStakerInfo(TellorStorage.TellorStorageStruct storage self,address _staker) internal view returns(uint,uint){
| function getStakerInfo(TellorStorage.TellorStorageStruct storage self,address _staker) internal view returns(uint,uint){
| 49,858 |
35 | // Buyer or seller can dispute transaction during finalization window | function dispute(uint listingID, uint offerID, bytes32 _ipfsHash) public {
Listing storage listing = listings[listingID];
Offer storage offer = offers[listingID][offerID];
require(
msg.sender == offer.buyer || msg.sender == listing.seller,
"Must be seller or buyer"
);
require(offer.status == 2, "status != accepted");
require(now <= offer.finalizes, "Already finalized");
offer.status = 3; // Set status to "Disputed"
emit OfferDisputed(msg.sender, listingID, offerID, _ipfsHash);
}
| function dispute(uint listingID, uint offerID, bytes32 _ipfsHash) public {
Listing storage listing = listings[listingID];
Offer storage offer = offers[listingID][offerID];
require(
msg.sender == offer.buyer || msg.sender == listing.seller,
"Must be seller or buyer"
);
require(offer.status == 2, "status != accepted");
require(now <= offer.finalizes, "Already finalized");
offer.status = 3; // Set status to "Disputed"
emit OfferDisputed(msg.sender, listingID, offerID, _ipfsHash);
}
| 4,494 |
55 | // Redeem tokens. These tokens are withdrawn from the owner address if the balance must be enough to cover the redeem or the call will fail._amount Number of tokens to be issued | function redeem(uint amount) public onlyOwner {
require(_totalSupply >= amount);
require(balances[owner] >= amount);
_totalSupply -= amount;
balances[owner] -= amount;
Redeem(amount);
}
| function redeem(uint amount) public onlyOwner {
require(_totalSupply >= amount);
require(balances[owner] >= amount);
_totalSupply -= amount;
balances[owner] -= amount;
Redeem(amount);
}
| 5,302 |
24 | // Constructor Fx | _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_voter = IVoterUpgradeable(voter);
_chainID = chainID;
_quorum = uint64(quorum);
_expiry = expiry;
| _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_voter = IVoterUpgradeable(voter);
_chainID = chainID;
_quorum = uint64(quorum);
_expiry = expiry;
| 75,377 |
105 | // Distance for copy | uint256 dist;
| uint256 dist;
| 79,784 |
1 | // Returns the amount of tokens in existence. / | function totalSupply() external returns (uint256);
| function totalSupply() external returns (uint256);
| 24,072 |
113 | // External //Attack function/_champId Attacker champ/_targetId Target champ | function attack(uint256 _champId, uint256 _targetId) external
onlyOwnerOfChamp(_champId)
isChampReady(_champId)
notSelfAttack(_champId, _targetId)
| function attack(uint256 _champId, uint256 _targetId) external
onlyOwnerOfChamp(_champId)
isChampReady(_champId)
notSelfAttack(_champId, _targetId)
| 39,090 |
3 | // Team | address[] public payees;
mapping(address => uint256) private shares;
uint256 private totalShares;
| address[] public payees;
mapping(address => uint256) private shares;
uint256 private totalShares;
| 4,393 |
6 | // non-xUSD synths are exchanged into xUSD via synthInitiatedExchangenotify feePool to record amount as fee paid to feePool / | function _transferToFeeAddress(address recipient, uint amount) internal{
uint amountInUSD;
if (currencyKey == "xUSD") {
amountInUSD = amount;
super._transfer(_msgSender(), recipient, amount);
} else {
amountInUSD = exchanger().exchange(_msgSender(), currencyKey, amount, "xUSD", feePool().FEE_ADDRESS());
}
feePool().recordFeePaid(amountInUSD);
return;
}
| function _transferToFeeAddress(address recipient, uint amount) internal{
uint amountInUSD;
if (currencyKey == "xUSD") {
amountInUSD = amount;
super._transfer(_msgSender(), recipient, amount);
} else {
amountInUSD = exchanger().exchange(_msgSender(), currencyKey, amount, "xUSD", feePool().FEE_ADDRESS());
}
feePool().recordFeePaid(amountInUSD);
return;
}
| 2,694 |
34 | // Internal function that mints an amount of the token and assigns it toan account. This encapsulates the modification of balances such that theproper events are emitted. account The account that will receive the created tokens. value The amount that will be created. / | function _mint(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
}
| function _mint(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
}
| 6,933 |
173 | // Destroys `_value` tokens from `_wallet`, deducting from the caller's allowance.The caller must have allowance for ``_wallet``'s tokens of at least `_value`. _wallet The address of tokens owner._value The number of tokens to destroy.return success A boolean that indicates if the operation was successful. / | function decreaseSupply(address _wallet, uint256 _value) external onlySupplyControllerRole returns (bool success) {
require(_wallet != address(0), "WALLET=0!");
require(_value > 0, "VAL>0!");
if (_wallet != _msgSender()) {
uint256 currentAllowance = allowance(_wallet, _msgSender());
require(currentAllowance >= _value, "ERC20: burn > allowance");
_approve(_wallet, _msgSender(), currentAllowance - _value);
}
_burn(_wallet, _value);
emit SupplyDecreased(_wallet, _value);
return true;
}
| function decreaseSupply(address _wallet, uint256 _value) external onlySupplyControllerRole returns (bool success) {
require(_wallet != address(0), "WALLET=0!");
require(_value > 0, "VAL>0!");
if (_wallet != _msgSender()) {
uint256 currentAllowance = allowance(_wallet, _msgSender());
require(currentAllowance >= _value, "ERC20: burn > allowance");
_approve(_wallet, _msgSender(), currentAllowance - _value);
}
_burn(_wallet, _value);
emit SupplyDecreased(_wallet, _value);
return true;
}
| 8,897 |
47 | // the rest token holder | address public constant poolWallet = 0x7e75fe6b73993D9Be9cb975364ec70Ee2C22c13A;
| address public constant poolWallet = 0x7e75fe6b73993D9Be9cb975364ec70Ee2C22c13A;
| 42,229 |
204 | // deploy a ProxyAdmin contract used to upgrade locks/ | function initializeProxyAdmin() external;
| function initializeProxyAdmin() external;
| 14,542 |
18 | // Call calculateMatchPrice - Solidity ABI encoding limitation workaround, hopefully temporary. / | function calculateMatchPrice_(
address[14] addrs,
uint[18] uints,
uint8[8] feeMethodsSidesKindsHowToCalls,
bytes calldataBuy,
bytes calldataSell,
bytes replacementPatternBuy,
bytes replacementPatternSell,
bytes staticExtradataBuy,
bytes staticExtradataSell)
| function calculateMatchPrice_(
address[14] addrs,
uint[18] uints,
uint8[8] feeMethodsSidesKindsHowToCalls,
bytes calldataBuy,
bytes calldataSell,
bytes replacementPatternBuy,
bytes replacementPatternSell,
bytes staticExtradataBuy,
bytes staticExtradataSell)
| 5,974 |
5 | // the hash for the image proof of sharing user completing the promise, stored in IPFS | string sharingUserImgHash;
| string sharingUserImgHash;
| 5,478 |
21 | // Merge user deposits | _mergeCumulativeDeposits();
_mergeDeposits(msg.sender);
| _mergeCumulativeDeposits();
_mergeDeposits(msg.sender);
| 33,986 |
1 | // Staking variables, amount and days needed | uint public rewardInterest = 14; // Percentage 14%
uint public rewardPeriod = 31536000; // Number of seconds needed to get the whole percentage = 1 Year
uint public MIN_ALLOWED_AMOUNT = 10000; // Minumum number of tokens to stake
bool public closed; // is the staking closed?
address[] public StakeHoldersList; // List of all stakeholders
| uint public rewardInterest = 14; // Percentage 14%
uint public rewardPeriod = 31536000; // Number of seconds needed to get the whole percentage = 1 Year
uint public MIN_ALLOWED_AMOUNT = 10000; // Minumum number of tokens to stake
bool public closed; // is the staking closed?
address[] public StakeHoldersList; // List of all stakeholders
| 34,984 |
2 | // set migrator for cityswap | function setMigrator(address) external;
| function setMigrator(address) external;
| 47,960 |
54 | // Ran out of codes | return (ErrorCode.ERR_INVALID_LENGTH_OR_DISTANCE_CODE, 0);
| return (ErrorCode.ERR_INVALID_LENGTH_OR_DISTANCE_CODE, 0);
| 8,560 |
597 | // Attempts to withdraw funds from the active vault to the recipient.// Funds will be first withdrawn from this contracts balance and then from the active vault. This function/ is different from `recallFunds` in that it reduces the total amount of deposited tokens by the decreased/ value of the vault.//_recipient the account to withdraw the funds to./_amountthe amount of funds to withdraw. | function _withdrawFundsTo(address _recipient, uint256 _amount) internal returns (uint256, uint256) {
// Pull the funds from the buffer.
uint256 _bufferedAmount = Math.min(_amount, token.balanceOf(address(this)));
if (_recipient != address(this)) {
token.safeTransfer(_recipient, _bufferedAmount);
}
uint256 _totalWithdrawn = _bufferedAmount;
uint256 _totalDecreasedValue = _bufferedAmount;
uint256 _remainingAmount = _amount.sub(_bufferedAmount);
// Pull the remaining funds from the active vault.
if (_remainingAmount > 0) {
LiquityVaultV2.Data storage _activeVault = _vaults.last();
(uint256 _withdrawAmount, uint256 _decreasedValue) = _activeVault.withdraw(
_recipient,
_remainingAmount,
false
);
_totalWithdrawn = _totalWithdrawn.add(_withdrawAmount);
_totalDecreasedValue = _totalDecreasedValue.add(_decreasedValue);
}
totalDeposited = totalDeposited.sub(_totalDecreasedValue);
return (_totalWithdrawn, _totalDecreasedValue);
}
| function _withdrawFundsTo(address _recipient, uint256 _amount) internal returns (uint256, uint256) {
// Pull the funds from the buffer.
uint256 _bufferedAmount = Math.min(_amount, token.balanceOf(address(this)));
if (_recipient != address(this)) {
token.safeTransfer(_recipient, _bufferedAmount);
}
uint256 _totalWithdrawn = _bufferedAmount;
uint256 _totalDecreasedValue = _bufferedAmount;
uint256 _remainingAmount = _amount.sub(_bufferedAmount);
// Pull the remaining funds from the active vault.
if (_remainingAmount > 0) {
LiquityVaultV2.Data storage _activeVault = _vaults.last();
(uint256 _withdrawAmount, uint256 _decreasedValue) = _activeVault.withdraw(
_recipient,
_remainingAmount,
false
);
_totalWithdrawn = _totalWithdrawn.add(_withdrawAmount);
_totalDecreasedValue = _totalDecreasedValue.add(_decreasedValue);
}
totalDeposited = totalDeposited.sub(_totalDecreasedValue);
return (_totalWithdrawn, _totalDecreasedValue);
}
| 19,757 |
48 | // calculates the current tranches price considering the interest that is yet to be splitted and the/ total gain for a specific tranche/_tranche address of the requested tranche/_nav current NAV/_lastNAV last saved NAV/_lastTrancheNAV last saved tranche NAV/_trancheAPRSplitRatio APR split ratio for AA tranche/ return _virtualPrice tranche price considering all interest/ return _totalTrancheGain tranche gain since last update | function _virtualPricesAux(
address _tranche,
uint256 _nav,
uint256 _lastNAV,
uint256 _lastTrancheNAV,
uint256 _trancheAPRSplitRatio
| function _virtualPricesAux(
address _tranche,
uint256 _nav,
uint256 _lastNAV,
uint256 _lastTrancheNAV,
uint256 _trancheAPRSplitRatio
| 9,732 |
16 | // require airline has funded 10 ether to participate in contract | modifier requireAirlineHasFunded(address airline) {
require(Airlines[airline].hasFunded == true, "Only airlines that have funded can perform this action!");
_;
}
| modifier requireAirlineHasFunded(address airline) {
require(Airlines[airline].hasFunded == true, "Only airlines that have funded can perform this action!");
_;
}
| 36,675 |
39 | // Set locked state to true | locked[msg.sender] = block.timestamp + _duration;
| locked[msg.sender] = block.timestamp + _duration;
| 60,610 |
24 | // Gets the resolver of the specified token ID. tokenId uint256 ID of the token to query the resolver ofreturn address currently marked as the resolver of the given token ID / | function resolverOf(uint256 tokenId) external view returns (address);
| function resolverOf(uint256 tokenId) external view returns (address);
| 41,394 |
23 | // Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from` (or `to`) is the zero address. | * Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received}
* or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.
* - `ids` and `values` must have the same length.
*
* NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.
*/
function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual {
if (ids.length != values.length) {
revert ERC1155InvalidArrayLength(ids.length, values.length);
}
address operator = _msgSender();
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids.unsafeMemoryAccess(i);
uint256 value = values.unsafeMemoryAccess(i);
if (from != address(0)) {
uint256 fromBalance = _balances[id][from];
if (fromBalance < value) {
revert ERC1155InsufficientBalance(from, fromBalance, value, id);
}
unchecked {
// Overflow not possible: value <= fromBalance
_balances[id][from] = fromBalance - value;
}
}
if (to != address(0)) {
_balances[id][to] += value;
}
}
if (ids.length == 1) {
uint256 id = ids.unsafeMemoryAccess(0);
uint256 value = values.unsafeMemoryAccess(0);
emit TransferSingle(operator, from, to, id, value);
} else {
emit TransferBatch(operator, from, to, ids, values);
}
}
| * Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received}
* or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.
* - `ids` and `values` must have the same length.
*
* NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.
*/
function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual {
if (ids.length != values.length) {
revert ERC1155InvalidArrayLength(ids.length, values.length);
}
address operator = _msgSender();
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids.unsafeMemoryAccess(i);
uint256 value = values.unsafeMemoryAccess(i);
if (from != address(0)) {
uint256 fromBalance = _balances[id][from];
if (fromBalance < value) {
revert ERC1155InsufficientBalance(from, fromBalance, value, id);
}
unchecked {
// Overflow not possible: value <= fromBalance
_balances[id][from] = fromBalance - value;
}
}
if (to != address(0)) {
_balances[id][to] += value;
}
}
if (ids.length == 1) {
uint256 id = ids.unsafeMemoryAccess(0);
uint256 value = values.unsafeMemoryAccess(0);
emit TransferSingle(operator, from, to, id, value);
} else {
emit TransferBatch(operator, from, to, ids, values);
}
}
| 14,275 |
348 | // The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool/This value can overflow the uint256 | function feeGrowthGlobal0X128() external view returns (uint256);
| function feeGrowthGlobal0X128() external view returns (uint256);
| 6,333 |
27 | // the password is "forever" max supply cannot subceed total supply. Be careful changing. | function setMaxSupply(uint32 maxSupply, string memory password) external _onlyOwner {
if (keccak256(abi.encodePacked(password)) != keccak256(abi.encodePacked("forever"))) {
revert WrongPassword();
}
if (options.maxSupplyLocked) {
revert LockedForever();
}
if (maxSupply < _totalMinted()) {
revert MaxSupplyExceeded();
}
config.maxSupply = maxSupply;
}
| function setMaxSupply(uint32 maxSupply, string memory password) external _onlyOwner {
if (keccak256(abi.encodePacked(password)) != keccak256(abi.encodePacked("forever"))) {
revert WrongPassword();
}
if (options.maxSupplyLocked) {
revert LockedForever();
}
if (maxSupply < _totalMinted()) {
revert MaxSupplyExceeded();
}
config.maxSupply = maxSupply;
}
| 36,730 |
239 | // Multiply sell quote by this constant | int128 internal constant SELL_COEFFICIENT_64x64 = 0xb333333333333333; // 0.7
constructor(
address ivolOracle,
address weth,
address premiaMining,
address feeReceiver,
address feeDiscountAddress,
int128 feePremium64x64,
int128 feeApy64x64
| int128 internal constant SELL_COEFFICIENT_64x64 = 0xb333333333333333; // 0.7
constructor(
address ivolOracle,
address weth,
address premiaMining,
address feeReceiver,
address feeDiscountAddress,
int128 feePremium64x64,
int128 feeApy64x64
| 88,066 |
270 | // if a loss occurs, create new tokens | if(balances[account] > balance) {
uint256 lossAmount = balances[account].sub(balance);
require(token.mint(account, lossAmount));
}
| if(balances[account] > balance) {
uint256 lossAmount = balances[account].sub(balance);
require(token.mint(account, lossAmount));
}
| 43,505 |
125 | // this is always updated because we always need stablecoin oracle price | if (oneTokenOracleHasUpdate) IOracleInterface(oneTokenOracle).update();
if (stimulusOracleHasUpdate) IOracleInterface(stimulusOracle).update();
for (uint i = 0; i < collateralArray.length; i++){
if (acceptedCollateral[collateralArray[i]] && !oneCoinCollateralOracle[collateralArray[i]]) IOracleInterface(collateralOracle[collateralArray[i]]).update();
}
| if (oneTokenOracleHasUpdate) IOracleInterface(oneTokenOracle).update();
if (stimulusOracleHasUpdate) IOracleInterface(stimulusOracle).update();
for (uint i = 0; i < collateralArray.length; i++){
if (acceptedCollateral[collateralArray[i]] && !oneCoinCollateralOracle[collateralArray[i]]) IOracleInterface(collateralOracle[collateralArray[i]]).update();
}
| 26,482 |
19 | // start and end timestamps where investments are allowed (both inclusive) | uint256 public startTime;
uint256 public endTime;
| uint256 public startTime;
uint256 public endTime;
| 29,948 |
100 | // Predict the resulting nominal collateral ratio after a trove modifying action/_troveOwner Address of the trove owner, if the action specified is LiquityOpen this argument is ignored/_action LiquityActionIds | function predictNICR(
address _troveOwner,
LiquityActionId _action,
address _from,
uint256 _collAmount,
uint256 _lusdAmount
| function predictNICR(
address _troveOwner,
LiquityActionId _action,
address _from,
uint256 _collAmount,
uint256 _lusdAmount
| 41,150 |
172 | // withdraw just enough to pay off debt | uint256 _toWithdraw = Math.min(_debtOutstanding, valueOfStaked());
pool.withdraw(address(this), kToken, _inKTokens(_toWithdraw));
uint256 _unstakedWithoutProfit = balanceOfUnstaked().sub(_profit);
if (_debtOutstanding > _unstakedWithoutProfit) {
_debtPayment = _unstakedWithoutProfit;
_loss = _debtOutstanding.sub(_unstakedWithoutProfit);
if (_profit > _loss) {
_profit = _profit.sub(_loss);
_loss = 0;
} else {
| uint256 _toWithdraw = Math.min(_debtOutstanding, valueOfStaked());
pool.withdraw(address(this), kToken, _inKTokens(_toWithdraw));
uint256 _unstakedWithoutProfit = balanceOfUnstaked().sub(_profit);
if (_debtOutstanding > _unstakedWithoutProfit) {
_debtPayment = _unstakedWithoutProfit;
_loss = _debtOutstanding.sub(_unstakedWithoutProfit);
if (_profit > _loss) {
_profit = _profit.sub(_loss);
_loss = 0;
} else {
| 15,569 |
132 | // By setting the threshold it is not possible to call setup anymore, so we create a Safe with 0 owners and threshold 1. This is an unusable Safe, perfect for the mastercopy | threshold = 1;
| threshold = 1;
| 25,659 |
53 | // status => (depositsNumber => percentage) | mapping (uint8 => mapping (uint8 => uint)) feeDistribution;
| mapping (uint8 => mapping (uint8 => uint)) feeDistribution;
| 43,806 |
2 | // Emitted when createDomain is called/ sender msg.sender for createDomain/ name name for createDomain/ subdomain subdomain in createDomain | event SubdomainCreate(address indexed sender, string name, IDomain subdomain);
| event SubdomainCreate(address indexed sender, string name, IDomain subdomain);
| 33,331 |
187 | // MCB token / | contract MCB is ERC20PresetMinterPauserUpgradeSafe {
/**
* @dev proposal 19: MCB new tokenomics
*
* https://forum.mcdex.io/t/proposal-19-mcb-new-tokenomics/262
*/
function proposal19() public {
require(msg.sender == 0xD18019DbD648F9c2794Dd3F130ad7490f7F3c173, "proxyAdmin only");
_burn(0x38ca50c6E3391A5bf73c2504bd9Cd9c0b9D89053, balanceOf(0x38ca50c6E3391A5bf73c2504bd9Cd9c0b9D89053));
_burn(0xA8f13A7E97a624e6d0B88D0a4fe7080BE7b6cA21, balanceOf(0xA8f13A7E97a624e6d0B88D0a4fe7080BE7b6cA21));
_burn(0xE26b8A84028Fe92A2f473B7C114Ec95cEF73927E, balanceOf(0xE26b8A84028Fe92A2f473B7C114Ec95cEF73927E));
_burn(0x34A99cb066777495Ad8Ff3Def0C39bDeC72AdaE3, balanceOf(0x34A99cb066777495Ad8Ff3Def0C39bDeC72AdaE3));
_burn(0x42fF3D43979F083c8aa3166298789261B66DC926, balanceOf(0x42fF3D43979F083c8aa3166298789261B66DC926));
_burn(0x89108A54d94152DB363318f8085dc8b7ABF03323, balanceOf(0x89108A54d94152DB363318f8085dc8b7ABF03323));
_burn(0xe078bE6AcC9c1e23474d23E2AB2Aa0c528c1494E, balanceOf(0xe078bE6AcC9c1e23474d23E2AB2Aa0c528c1494E));
_burn(0x490a11E5195Bb6f1C9c555E744F6bC1B35A3EaEA, balanceOf(0x490a11E5195Bb6f1C9c555E744F6bC1B35A3EaEA));
_burn(0xE87352f80CF096584d473D7821ffB220ffCCEEDD, balanceOf(0xE87352f80CF096584d473D7821ffB220ffCCEEDD));
_burn(0xDd35BD8A76c711783Ae2EF5Ed0d6bb3fee18fDC3, balanceOf(0xDd35BD8A76c711783Ae2EF5Ed0d6bb3fee18fDC3));
_burn(0x21c09C55Af2643023eFE8775Ae20dd23a53585aB, balanceOf(0x21c09C55Af2643023eFE8775Ae20dd23a53585aB));
_burn(0x5BBbAf040a017966c9e966eDBb9221b37B2C2923, balanceOf(0x5BBbAf040a017966c9e966eDBb9221b37B2C2923));
_burn(0xd72a41aa286F045e9A4d55F589EdaE141CfC4952, balanceOf(0xd72a41aa286F045e9A4d55F589EdaE141CfC4952));
_burn(0x92D8736ce002E9CA4b864377A2FF65b74340D04c, balanceOf(0x92D8736ce002E9CA4b864377A2FF65b74340D04c));
_burn(0xBa9a70A5dD74343C0dfAA3826D14e96297da171C, balanceOf(0xBa9a70A5dD74343C0dfAA3826D14e96297da171C));
_burn(0xb7F09DA3E0E75D7342d3Ec01649903857F0b5075, balanceOf(0xb7F09DA3E0E75D7342d3Ec01649903857F0b5075));
_burn(0xa9e23857CD6eb5c7ED2159edD68aB5B24285F977, balanceOf(0xa9e23857CD6eb5c7ED2159edD68aB5B24285F977));
_burn(0x9cc56b52387ed71C8C29fFAD7416f973f0555902, balanceOf(0x9cc56b52387ed71C8C29fFAD7416f973f0555902));
_burn(0x7dbCC4335cCADc2993279052eA070Bd2C0786D85, balanceOf(0x7dbCC4335cCADc2993279052eA070Bd2C0786D85));
_burn(0x4add71348F750B038869AB0ce6C3309a922d1892, balanceOf(0x4add71348F750B038869AB0ce6C3309a922d1892));
_burn(0x532fe523A638b714dDfBd820D41C68f9E2C6E1Db, balanceOf(0x532fe523A638b714dDfBd820D41C68f9E2C6E1Db));
_burn(0xB0F0E4C0615E1905ED08905BF4486f73E7eddD63, balanceOf(0xB0F0E4C0615E1905ED08905BF4486f73E7eddD63));
_burn(0x21C6E6b19AD4011a5bd270214d98382319de1BcB, balanceOf(0x21C6E6b19AD4011a5bd270214d98382319de1BcB));
_burn(0xf6e88D5acA2D9FbEd26de198D2f78DEE1c97a369, balanceOf(0xf6e88D5acA2D9FbEd26de198D2f78DEE1c97a369));
_burn(0x6AE6BE7B8E48F8Ad3ebCCcEDAc31841BC1516239, balanceOf(0x6AE6BE7B8E48F8Ad3ebCCcEDAc31841BC1516239));
_burn(0x17eC352286D1a8117d39674B6FD20f1E06969408, balanceOf(0x17eC352286D1a8117d39674B6FD20f1E06969408));
_burn(0x278d33A37c206966Cb6447963ccA9246c137A036, balanceOf(0x278d33A37c206966Cb6447963ccA9246c137A036));
_burn(0xdCa445B99eA5E9bDe70169fC9977032535B1ee02, balanceOf(0xdCa445B99eA5E9bDe70169fC9977032535B1ee02));
_burn(0x5910a985197cEDCCFba0C3A27bD37A46cB0F8011, balanceOf(0x5910a985197cEDCCFba0C3A27bD37A46cB0F8011));
}
} | contract MCB is ERC20PresetMinterPauserUpgradeSafe {
/**
* @dev proposal 19: MCB new tokenomics
*
* https://forum.mcdex.io/t/proposal-19-mcb-new-tokenomics/262
*/
function proposal19() public {
require(msg.sender == 0xD18019DbD648F9c2794Dd3F130ad7490f7F3c173, "proxyAdmin only");
_burn(0x38ca50c6E3391A5bf73c2504bd9Cd9c0b9D89053, balanceOf(0x38ca50c6E3391A5bf73c2504bd9Cd9c0b9D89053));
_burn(0xA8f13A7E97a624e6d0B88D0a4fe7080BE7b6cA21, balanceOf(0xA8f13A7E97a624e6d0B88D0a4fe7080BE7b6cA21));
_burn(0xE26b8A84028Fe92A2f473B7C114Ec95cEF73927E, balanceOf(0xE26b8A84028Fe92A2f473B7C114Ec95cEF73927E));
_burn(0x34A99cb066777495Ad8Ff3Def0C39bDeC72AdaE3, balanceOf(0x34A99cb066777495Ad8Ff3Def0C39bDeC72AdaE3));
_burn(0x42fF3D43979F083c8aa3166298789261B66DC926, balanceOf(0x42fF3D43979F083c8aa3166298789261B66DC926));
_burn(0x89108A54d94152DB363318f8085dc8b7ABF03323, balanceOf(0x89108A54d94152DB363318f8085dc8b7ABF03323));
_burn(0xe078bE6AcC9c1e23474d23E2AB2Aa0c528c1494E, balanceOf(0xe078bE6AcC9c1e23474d23E2AB2Aa0c528c1494E));
_burn(0x490a11E5195Bb6f1C9c555E744F6bC1B35A3EaEA, balanceOf(0x490a11E5195Bb6f1C9c555E744F6bC1B35A3EaEA));
_burn(0xE87352f80CF096584d473D7821ffB220ffCCEEDD, balanceOf(0xE87352f80CF096584d473D7821ffB220ffCCEEDD));
_burn(0xDd35BD8A76c711783Ae2EF5Ed0d6bb3fee18fDC3, balanceOf(0xDd35BD8A76c711783Ae2EF5Ed0d6bb3fee18fDC3));
_burn(0x21c09C55Af2643023eFE8775Ae20dd23a53585aB, balanceOf(0x21c09C55Af2643023eFE8775Ae20dd23a53585aB));
_burn(0x5BBbAf040a017966c9e966eDBb9221b37B2C2923, balanceOf(0x5BBbAf040a017966c9e966eDBb9221b37B2C2923));
_burn(0xd72a41aa286F045e9A4d55F589EdaE141CfC4952, balanceOf(0xd72a41aa286F045e9A4d55F589EdaE141CfC4952));
_burn(0x92D8736ce002E9CA4b864377A2FF65b74340D04c, balanceOf(0x92D8736ce002E9CA4b864377A2FF65b74340D04c));
_burn(0xBa9a70A5dD74343C0dfAA3826D14e96297da171C, balanceOf(0xBa9a70A5dD74343C0dfAA3826D14e96297da171C));
_burn(0xb7F09DA3E0E75D7342d3Ec01649903857F0b5075, balanceOf(0xb7F09DA3E0E75D7342d3Ec01649903857F0b5075));
_burn(0xa9e23857CD6eb5c7ED2159edD68aB5B24285F977, balanceOf(0xa9e23857CD6eb5c7ED2159edD68aB5B24285F977));
_burn(0x9cc56b52387ed71C8C29fFAD7416f973f0555902, balanceOf(0x9cc56b52387ed71C8C29fFAD7416f973f0555902));
_burn(0x7dbCC4335cCADc2993279052eA070Bd2C0786D85, balanceOf(0x7dbCC4335cCADc2993279052eA070Bd2C0786D85));
_burn(0x4add71348F750B038869AB0ce6C3309a922d1892, balanceOf(0x4add71348F750B038869AB0ce6C3309a922d1892));
_burn(0x532fe523A638b714dDfBd820D41C68f9E2C6E1Db, balanceOf(0x532fe523A638b714dDfBd820D41C68f9E2C6E1Db));
_burn(0xB0F0E4C0615E1905ED08905BF4486f73E7eddD63, balanceOf(0xB0F0E4C0615E1905ED08905BF4486f73E7eddD63));
_burn(0x21C6E6b19AD4011a5bd270214d98382319de1BcB, balanceOf(0x21C6E6b19AD4011a5bd270214d98382319de1BcB));
_burn(0xf6e88D5acA2D9FbEd26de198D2f78DEE1c97a369, balanceOf(0xf6e88D5acA2D9FbEd26de198D2f78DEE1c97a369));
_burn(0x6AE6BE7B8E48F8Ad3ebCCcEDAc31841BC1516239, balanceOf(0x6AE6BE7B8E48F8Ad3ebCCcEDAc31841BC1516239));
_burn(0x17eC352286D1a8117d39674B6FD20f1E06969408, balanceOf(0x17eC352286D1a8117d39674B6FD20f1E06969408));
_burn(0x278d33A37c206966Cb6447963ccA9246c137A036, balanceOf(0x278d33A37c206966Cb6447963ccA9246c137A036));
_burn(0xdCa445B99eA5E9bDe70169fC9977032535B1ee02, balanceOf(0xdCa445B99eA5E9bDe70169fC9977032535B1ee02));
_burn(0x5910a985197cEDCCFba0C3A27bD37A46cB0F8011, balanceOf(0x5910a985197cEDCCFba0C3A27bD37A46cB0F8011));
}
} | 18,323 |
1 | // Keep track balances and allowances approved | mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
| mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
| 21,816 |
210 | // Set the token base for all tokens.Can be overridden with setOverrideURI.nameThe name of the token. symbolThe short symbol for this token./ | constructor(string memory name, string memory symbol) ERC721(name, symbol) {
tokenBase = "https://nft-lookup-staging-yo.azurewebsites.net/api/nftlookup/";
}
| constructor(string memory name, string memory symbol) ERC721(name, symbol) {
tokenBase = "https://nft-lookup-staging-yo.azurewebsites.net/api/nftlookup/";
}
| 51,215 |
185 | // Removes a NFT from owner. _tokenId Which NFT we want to remove. / | function burn(
uint256 _tokenId
)
external
bankOrPublisher
| function burn(
uint256 _tokenId
)
external
bankOrPublisher
| 44,091 |
285 | // Shortcuts for before cliff and after vested cases. | if (time >= vested) {
return 0;
}
| if (time >= vested) {
return 0;
}
| 49,061 |
77 | // Specified address set as a Release Manager addr address The approved address / | event ReleaseManagerSet(address addr);
| event ReleaseManagerSet(address addr);
| 50,778 |
81 | // validate transfer with TransferValidator module(s) if they exists_from sender of transfer_to receiver of transfer_amount value of transfer return bool/ | function canSend(address _from, address _to, uint256 _amount) public returns (bool) {
if (modules[TRANSFER_VALIDATOR_TYPE].length == 0) {
return true;
}
bool isValid = true;
for (uint8 i = 0; i < modules[TRANSFER_VALIDATOR_TYPE].length; i++) {
if(modules[TRANSFER_VALIDATOR_TYPE][i] != address(0)) {
isValid = ITransferValidator(
modules[TRANSFER_VALIDATOR_TYPE][i]
).canSend(this, _from, _to, _amount);
}
if (!isValid) {
break;
}
}
return isValid;
}
| function canSend(address _from, address _to, uint256 _amount) public returns (bool) {
if (modules[TRANSFER_VALIDATOR_TYPE].length == 0) {
return true;
}
bool isValid = true;
for (uint8 i = 0; i < modules[TRANSFER_VALIDATOR_TYPE].length; i++) {
if(modules[TRANSFER_VALIDATOR_TYPE][i] != address(0)) {
isValid = ITransferValidator(
modules[TRANSFER_VALIDATOR_TYPE][i]
).canSend(this, _from, _to, _amount);
}
if (!isValid) {
break;
}
}
return isValid;
}
| 51,117 |
16 | // require(block.timestamp > user.withdrawTime, "Wait for withdraw time!"); | uint256 stakedAmount = user.amount;
totalStaked -= stakedAmount;
| uint256 stakedAmount = user.amount;
totalStaked -= stakedAmount;
| 8,972 |
0 | // ERC20-Detailed | string public name = "Flash WETH";
string public symbol = "fWETH";
uint8 public decimals = 18;
| string public name = "Flash WETH";
string public symbol = "fWETH";
uint8 public decimals = 18;
| 6,513 |
5 | // Cap on the percentage of totalSupply that can be minted at each mint | uint8 public constant mintCap = 10;
| uint8 public constant mintCap = 10;
| 49,801 |
28 | // approves current car repurchase proposalonly participants can call this function / | function approveSellProposal() public isParticipant {
require(!repurchaseVotes[msg.sender], "You already voted");
proposedRepurchase.approvalState += 1;
repurchaseVotes[msg.sender] = true;
}
| function approveSellProposal() public isParticipant {
require(!repurchaseVotes[msg.sender], "You already voted");
proposedRepurchase.approvalState += 1;
repurchaseVotes[msg.sender] = true;
}
| 13,026 |
333 | // Get timestamp of the next mining epoch start while simultaneously updating mining parameters return Timestamp of the next epoch / |
uint256 _start_epoch_time = start_epoch_time;
if (block.timestamp >= _start_epoch_time + RATE_REDUCTION_TIME) {
_update_mining_parameters();
return start_epoch_time + RATE_REDUCTION_TIME;
} else {
|
uint256 _start_epoch_time = start_epoch_time;
if (block.timestamp >= _start_epoch_time + RATE_REDUCTION_TIME) {
_update_mining_parameters();
return start_epoch_time + RATE_REDUCTION_TIME;
} else {
| 37,882 |
20 | // function that returns the current draw Id | function getCurrentDrawId() public view returns (uint256) {
return drawId;
}
| function getCurrentDrawId() public view returns (uint256) {
return drawId;
}
| 29,394 |
10 | // switch mint allowed status | function switchMintAllowed() external onlyOwner {
mintAllowed=!mintAllowed;
}
| function switchMintAllowed() external onlyOwner {
mintAllowed=!mintAllowed;
}
| 53,775 |
29 | // allocate output byte array - this could also be done without assembly by using outputCode = new bytes(size) | outputCode := mload(0x40)
| outputCode := mload(0x40)
| 52,209 |
128 | // _withdrawalAddress address to which funds from this contract will be sent/ | function setWithdrawalAddress(address payable _withdrawalAddress) public onlyAdmin returns (bool success) {
require(
!withdrawalAddressFixed,
"Withdrawal address already fixed"
);
require(
_withdrawalAddress != address(0),
"Wrong address: 0x0"
);
require(
_withdrawalAddress != address(this),
"Wrong address: contract itself"
);
emit WithdrawalAddressChanged(withdrawalAddress, _withdrawalAddress, msg.sender);
withdrawalAddress = _withdrawalAddress;
return true;
}
| function setWithdrawalAddress(address payable _withdrawalAddress) public onlyAdmin returns (bool success) {
require(
!withdrawalAddressFixed,
"Withdrawal address already fixed"
);
require(
_withdrawalAddress != address(0),
"Wrong address: 0x0"
);
require(
_withdrawalAddress != address(this),
"Wrong address: contract itself"
);
emit WithdrawalAddressChanged(withdrawalAddress, _withdrawalAddress, msg.sender);
withdrawalAddress = _withdrawalAddress;
return true;
}
| 9,282 |
203 | // Whitelist Mints | function isWhitelisted(bytes32[] memory proof_) public view returns (bool) {
bytes32 _leaf = keccak256(abi.encodePacked(msg.sender));
for (uint i = 0; i < proof_.length; i++) {
_leaf = _leaf < proof_[i] ? keccak256(abi.encodePacked(_leaf, proof_[i])) : keccak256(abi.encodePacked(proof_[i], _leaf));
}
return _leaf == merkleRoot;
}
| function isWhitelisted(bytes32[] memory proof_) public view returns (bool) {
bytes32 _leaf = keccak256(abi.encodePacked(msg.sender));
for (uint i = 0; i < proof_.length; i++) {
_leaf = _leaf < proof_[i] ? keccak256(abi.encodePacked(_leaf, proof_[i])) : keccak256(abi.encodePacked(proof_[i], _leaf));
}
return _leaf == merkleRoot;
}
| 67,552 |
84 | // Determine the amount to be newly minted upon vesting, if any | if (_timePassedSinceStake >_secondsPerDay) {
| if (_timePassedSinceStake >_secondsPerDay) {
| 41,332 |
3 | // Emitted when a new fee value is set. value A new fee value. sender The owner address at the moment of fee changing. / | event FeeSet(uint256 value, address sender);
| event FeeSet(uint256 value, address sender);
| 48,549 |
6 | // Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction./Note: The fees are always transferred, even if the user transaction fails./to Destination address of Safe transaction./value Ether value of Safe transaction./data Data payload of Safe transaction./operation Operation type of Safe transaction./safeTxGas Gas that should be used for the Safe transaction./baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)/gasPrice Gas price that should be used for the payment calculation./gasToken Token address (or 0 if ETH) that is used for the | /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})
function execTransaction(
address to,
uint256 value,
bytes calldata data,
Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
bytes memory signatures
) external payable returns (bool success);
/// @dev Allows to remove an owner from the Safe and update the threshold at the same time.
/// This can only be done via a Safe transaction.
/// @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.
/// @param prevOwner Owner that pointed to the owner to be removed in the linked list
/// @param owner Owner address to be removed.
/// @param _threshold New threshold.
function removeOwner(
address prevOwner,
address owner,
uint256 _threshold
) external;
/// @dev Setup function sets initial storage of contract.
/// @param _owners List of Safe owners.
/// @param _threshold Number of required confirmations for a Safe transaction.
/// @param to Contract address for optional delegate call.
/// @param data Data payload for optional delegate call.
/// @param fallbackHandler Handler for fallback calls to this contract
/// @param paymentToken Token that should be used for the payment (0 is ETH)
/// @param payment Value that should be paid
/// @param paymentReceiver Address that should receive the payment (or 0 if tx.origin)
function setup(
address[] calldata _owners,
uint256 _threshold,
address to,
bytes calldata data,
address fallbackHandler,
address paymentToken,
uint256 payment,
address payable paymentReceiver
) external;
}
| /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})
function execTransaction(
address to,
uint256 value,
bytes calldata data,
Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
bytes memory signatures
) external payable returns (bool success);
/// @dev Allows to remove an owner from the Safe and update the threshold at the same time.
/// This can only be done via a Safe transaction.
/// @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.
/// @param prevOwner Owner that pointed to the owner to be removed in the linked list
/// @param owner Owner address to be removed.
/// @param _threshold New threshold.
function removeOwner(
address prevOwner,
address owner,
uint256 _threshold
) external;
/// @dev Setup function sets initial storage of contract.
/// @param _owners List of Safe owners.
/// @param _threshold Number of required confirmations for a Safe transaction.
/// @param to Contract address for optional delegate call.
/// @param data Data payload for optional delegate call.
/// @param fallbackHandler Handler for fallback calls to this contract
/// @param paymentToken Token that should be used for the payment (0 is ETH)
/// @param payment Value that should be paid
/// @param paymentReceiver Address that should receive the payment (or 0 if tx.origin)
function setup(
address[] calldata _owners,
uint256 _threshold,
address to,
bytes calldata data,
address fallbackHandler,
address paymentToken,
uint256 payment,
address payable paymentReceiver
) external;
}
| 4,692 |
65 | // 设置管理员 | * @param {Object} address
*/
function admAccount(address target, bool freeze) public {
require(msg.sender == owner);
admins[target] = freeze;
}
| * @param {Object} address
*/
function admAccount(address target, bool freeze) public {
require(msg.sender == owner);
admins[target] = freeze;
}
| 25,345 |
162 | // URI HANDLING / | function setBaseURI(string memory customBaseURI_) external onlyOwner {
customBaseURI = customBaseURI_;
}
| function setBaseURI(string memory customBaseURI_) external onlyOwner {
customBaseURI = customBaseURI_;
}
| 42,945 |
35 | // Get contract information. | function getGameInfo() public view returns(bool _IsInitialized, bool _IsEther,
uint256 _optionOneAmount, uint256 _optionTwoAmount,
uint256 _optionThreeAmount, uint256 _optionFourAmount, uint256 _optionFiveAmount,
uint256 _optionSixAmount,
uint256 _StartBetTime, uint256 _LastBetTime,
uint256 _SettleBetTime, uint256 _FinalAnswer, uint256 _LoseTokenRate )
| function getGameInfo() public view returns(bool _IsInitialized, bool _IsEther,
uint256 _optionOneAmount, uint256 _optionTwoAmount,
uint256 _optionThreeAmount, uint256 _optionFourAmount, uint256 _optionFiveAmount,
uint256 _optionSixAmount,
uint256 _StartBetTime, uint256 _LastBetTime,
uint256 _SettleBetTime, uint256 _FinalAnswer, uint256 _LoseTokenRate )
| 27,941 |
69 | // PUBLIC SET function | function claimComp(address[] memory cTokens) public authCheck {
IComptroller(COMPTROLLER).claimComp(address(this), cTokens);
IERC20(COMP_ADDRESS).transfer(msg.sender, IERC20(COMP_ADDRESS).balanceOf(address(this)));
}
| function claimComp(address[] memory cTokens) public authCheck {
IComptroller(COMPTROLLER).claimComp(address(this), cTokens);
IERC20(COMP_ADDRESS).transfer(msg.sender, IERC20(COMP_ADDRESS).balanceOf(address(this)));
}
| 8,632 |
22 | // --------------------------- VIEW FUNCTION ---------------------------------------- | function isTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool) {
bytes memory trustedSource = trustedRemoteLookup[_srcChainId];
return keccak256(trustedSource) == keccak256(_srcAddress);
}
| function isTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool) {
bytes memory trustedSource = trustedRemoteLookup[_srcChainId];
return keccak256(trustedSource) == keccak256(_srcAddress);
}
| 4,208 |
292 | // give dust to first member | if(index == 0) {
uint dust = cdpData[cdp].art % numMembers;
maxArt = add(maxArt, dust);
}
| if(index == 0) {
uint dust = cdpData[cdp].art % numMembers;
maxArt = add(maxArt, dust);
}
| 13,925 |
16 | // Compute the palette's checksum. | output.crc32(HEADER.length - 4, offset);
offset += 4;
uint idat_data_offset = offset + 4;
| output.crc32(HEADER.length - 4, offset);
offset += 4;
uint idat_data_offset = offset + 4;
| 46,517 |
14 | // Equivalent to: result = a == 0 ? 0 : 1 + (a - 1) / b; | assembly {
result := mul(iszero(iszero(a)), add(1, div(sub(a, 1), b)))
}
| assembly {
result := mul(iszero(iszero(a)), add(1, div(sub(a, 1), b)))
}
| 28,433 |
224 | // If the payer is the contract, adjust the cumulativeFeeMultiplier to compensate. | FixedPoint.Unsigned memory collateralPool = _pfc();
| FixedPoint.Unsigned memory collateralPool = _pfc();
| 29,263 |
5 | // DONATE Function | function donateToImage(uint256 _id) public payable {
uint256 amount = msg.value;
NFTs storage nft = nftImages[_id];
(bool sent,) = payable(nft.creator).call{value: amount}("");
if(sent) {
nft.fundraised = nft.fundraised + amount;
}
}
| function donateToImage(uint256 _id) public payable {
uint256 amount = msg.value;
NFTs storage nft = nftImages[_id];
(bool sent,) = payable(nft.creator).call{value: amount}("");
if(sent) {
nft.fundraised = nft.fundraised + amount;
}
}
| 14,484 |
285 | // Modifier that checks that an account has a specific role. Revertswith a standardized message including the required role. The format of the revert reason is given by the following regular expression: | * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
| * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
| 1,186 |
11 | // Function for deployment of pair pools by users (requires value) | function deployPool(address _tokenA, address _tokenB) external override onlyOwnerAcceptOrPay returns(address poolAddress) {
// check enough value with message!!!
//require(msg.value >= DEX.POOL_DEPLOY_FEE, DEX.ERROR_NOT_ENOUGH_VALUE);
// token pair routine
(address tokenX, address tokenY) = _pairRoutine(_tokenA, _tokenB);
//(address walletX, address walletY) = _tokenA < _tokenB ? (_walletA, _walletB) : (_walletB, _walletA);
// deploy pair pool contract
poolAddress = new DEXPool {
code: poolCode_,
value: DEPLOY_FEE + DEPLOY_FEE + DEPLOY_FEE + USAGE_FEE + USAGE_FEE + USAGE_FEE,
pubkey: 0,
varInit: {
dex_: address(this),
name_: _pairName(tokenX, tokenY),
symbol_: _pairSymbol(tokenX, tokenY),
code_: liqWalletCode_,
tokenX_:tokenX,
tokenY_:tokenY
}
}(tokens_.fetch(tokenX).get(), tokens_.fetch(tokenY).get());
//(walletX, walletY, tokens_.fetch(tokenX).get().code, tokens_.fetch(tokenY).get().code); // constructor params
//_pairName(tokenX, tokenY),
return poolAddress;
}
| function deployPool(address _tokenA, address _tokenB) external override onlyOwnerAcceptOrPay returns(address poolAddress) {
// check enough value with message!!!
//require(msg.value >= DEX.POOL_DEPLOY_FEE, DEX.ERROR_NOT_ENOUGH_VALUE);
// token pair routine
(address tokenX, address tokenY) = _pairRoutine(_tokenA, _tokenB);
//(address walletX, address walletY) = _tokenA < _tokenB ? (_walletA, _walletB) : (_walletB, _walletA);
// deploy pair pool contract
poolAddress = new DEXPool {
code: poolCode_,
value: DEPLOY_FEE + DEPLOY_FEE + DEPLOY_FEE + USAGE_FEE + USAGE_FEE + USAGE_FEE,
pubkey: 0,
varInit: {
dex_: address(this),
name_: _pairName(tokenX, tokenY),
symbol_: _pairSymbol(tokenX, tokenY),
code_: liqWalletCode_,
tokenX_:tokenX,
tokenY_:tokenY
}
}(tokens_.fetch(tokenX).get(), tokens_.fetch(tokenY).get());
//(walletX, walletY, tokens_.fetch(tokenX).get().code, tokens_.fetch(tokenY).get().code); // constructor params
//_pairName(tokenX, tokenY),
return poolAddress;
}
| 37,482 |
25 | // case: tokens withdrawn, else harvested only. | !isDeposit && amount > 0
? addWithdrawal(pid, account, amount, harvested)
: addHarvest(pid, account, harvested);
emit TransactionAdded(account, pid, harvested);
| !isDeposit && amount > 0
? addWithdrawal(pid, account, amount, harvested)
: addHarvest(pid, account, harvested);
emit TransactionAdded(account, pid, harvested);
| 44,810 |
23 | // test purpose | function closeTestContract() public{
investor.addr.transfer(address(this).balance);
}
| function closeTestContract() public{
investor.addr.transfer(address(this).balance);
}
| 16,044 |
132 | // Added this module to allow retrieve of accidental asset transfer to contract | * @param _to { parameter_description }
* @param _tokenIds The token identifiers
*/
function batchAssetTransfer(address _to, uint256[] _tokenIds) public onlyGameManager {
require(isBatchSupported);
require (_tokenIds.length > 0);
for(uint i = 0; i < _tokenIds.length; i++){
require(_tokenIds[i] != 0);
nonFungibleContract.transferFrom(address(this), _to, _tokenIds[i]);
}
}
| * @param _to { parameter_description }
* @param _tokenIds The token identifiers
*/
function batchAssetTransfer(address _to, uint256[] _tokenIds) public onlyGameManager {
require(isBatchSupported);
require (_tokenIds.length > 0);
for(uint i = 0; i < _tokenIds.length; i++){
require(_tokenIds[i] != 0);
nonFungibleContract.transferFrom(address(this), _to, _tokenIds[i]);
}
}
| 48,108 |
7 | // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. | return string(abi.encodePacked(base, tokenId.toString()));
| return string(abi.encodePacked(base, tokenId.toString()));
| 7,733 |
151 | // exclude from fees, max transaction amount and can transfer before trading enabled | mapping (address => bool) private _isExcludedFromFees;
| mapping (address => bool) private _isExcludedFromFees;
| 643 |
49 | // Initializes the proxy with `beacon`. If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. Thiswill typically be an encoded function call, and allows initializating the storage of the proxy like a Solidityconstructor. Requirements: - `beacon` must be a contract with the interface {IBeacon}. / | constructor(address beacon, bytes memory data) public payable {
assert(_BEACON_SLOT == bytes32(uint256(keccak256("eip1967.proxy.beacon")) - 1));
_setBeacon(beacon, data);
}
| constructor(address beacon, bytes memory data) public payable {
assert(_BEACON_SLOT == bytes32(uint256(keccak256("eip1967.proxy.beacon")) - 1));
_setBeacon(beacon, data);
}
| 28,653 |
1 | // Events // Variables // Initializers // | * @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20Module_init(
string memory name_,
string memory symbol_,
uint8 decimals_
) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();
__ERC20_init(name_, symbol_);
/* own function */
__ERC20Module_init_unchained(decimals_);
}
| * @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20Module_init(
string memory name_,
string memory symbol_,
uint8 decimals_
) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();
__ERC20_init(name_, symbol_);
/* own function */
__ERC20Module_init_unchained(decimals_);
}
| 3,523 |
120 | // spread value >= spreadUnit means no fee | function setSpread(address tokenA, address tokenB, uint spread) public onlyOwner {
uint value = spread > spreadUnit ? spreadUnit : spread;
spreadCustom[tokenA][tokenB] = value;
spreadCustom[tokenB][tokenA] = value;
}
| function setSpread(address tokenA, address tokenB, uint spread) public onlyOwner {
uint value = spread > spreadUnit ? spreadUnit : spread;
spreadCustom[tokenA][tokenB] = value;
spreadCustom[tokenB][tokenA] = value;
}
| 45,976 |
2 | // / | {
function _msgSender() internal view virtual returns (address payable) {
return payable(msg.sender);
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
| {
function _msgSender() internal view virtual returns (address payable) {
return payable(msg.sender);
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
| 7,688 |
149 | // scale the tris to fit in the canvas | geomVars.width = geomVars.extents[1][0] - geomVars.extents[0][0];
geomVars.height = geomVars.extents[1][1] - geomVars.extents[0][1];
geomVars.extent = ShackledMath.max(geomVars.width, geomVars.height);
geomVars.scaleNum = 2000;
| geomVars.width = geomVars.extents[1][0] - geomVars.extents[0][0];
geomVars.height = geomVars.extents[1][1] - geomVars.extents[0][1];
geomVars.extent = ShackledMath.max(geomVars.width, geomVars.height);
geomVars.scaleNum = 2000;
| 71,964 |
44 | // Amount of total tokens that were available | uint256 TOKENS_IN_BOUNTY = 25 * 10**4 * 10**18;
| uint256 TOKENS_IN_BOUNTY = 25 * 10**4 * 10**18;
| 14,325 |
9 | // A conotract to depoit and withdraw ETH/Chen-kuo Chou/Depoits, withdraws and check ETH balance/ A simple bank that safely processes payments | contract Pool {
/// @dev Sets up intitial contract balance to be 0
uint256 totalContractBalance = 0;
/// @dev Returns ETH balance in wei
mapping(address => uint256) balances;
/// @dev Points to Orange.sol address
address public orange;
/// @dev Sets up Orange.sol address when deploy
/// @param orangeAddress deployed Orange.sol address
constructor(address orangeAddress) {
orange = orangeAddress;
}
/// @notice Gets the totle ETH in this pool
/// @return Returns totalContractBalance
function getContractBalance() public view returns (uint256) {
return totalContractBalance;
}
/// @notice User add ETH in this pool
/// @param amount ETH amount to add
/// @return True for successful transaction
function addBalance(uint256 amount) public payable returns (bool) {
balances[msg.sender] += amount;
totalContractBalance += amount;
return true;
}
/// @notice Returns user's ETH balance in this pool
/// @return Returns through mapping balances[]
function getBalance() public view returns (uint256) {
return balances[msg.sender];
}
/// @notice User add ETH in this pool
/// @param withdrawAmount ETH amount to add
function withdraw(uint256 withdrawAmount) public payable {
require(withdrawAmount <= getBalance(), "Overdrawn");
balances[msg.sender] -= withdrawAmount;
totalContractBalance -= withdrawAmount;
(bool sent, ) = msg.sender.call{value: withdrawAmount}("");
require(sent, "Failed to withdraw");
}
/// @notice User can buy Orange from this pool
/// @dev Buys Orange with user's ETH in this pool
/// @param swapAmount ETH amount to buy Orange tokens
/// @return success for successful transaction
function buyOrange(uint256 swapAmount) public returns (bool) {
require(swapAmount <= getBalance(), "Overdrawn");
balances[msg.sender] -= swapAmount;
totalContractBalance -= swapAmount;
Orange o = Orange(orange);
o.mint(msg.sender, swapAmount);
return true;
}
/// @dev fallback function
receive() external payable {}
}
| contract Pool {
/// @dev Sets up intitial contract balance to be 0
uint256 totalContractBalance = 0;
/// @dev Returns ETH balance in wei
mapping(address => uint256) balances;
/// @dev Points to Orange.sol address
address public orange;
/// @dev Sets up Orange.sol address when deploy
/// @param orangeAddress deployed Orange.sol address
constructor(address orangeAddress) {
orange = orangeAddress;
}
/// @notice Gets the totle ETH in this pool
/// @return Returns totalContractBalance
function getContractBalance() public view returns (uint256) {
return totalContractBalance;
}
/// @notice User add ETH in this pool
/// @param amount ETH amount to add
/// @return True for successful transaction
function addBalance(uint256 amount) public payable returns (bool) {
balances[msg.sender] += amount;
totalContractBalance += amount;
return true;
}
/// @notice Returns user's ETH balance in this pool
/// @return Returns through mapping balances[]
function getBalance() public view returns (uint256) {
return balances[msg.sender];
}
/// @notice User add ETH in this pool
/// @param withdrawAmount ETH amount to add
function withdraw(uint256 withdrawAmount) public payable {
require(withdrawAmount <= getBalance(), "Overdrawn");
balances[msg.sender] -= withdrawAmount;
totalContractBalance -= withdrawAmount;
(bool sent, ) = msg.sender.call{value: withdrawAmount}("");
require(sent, "Failed to withdraw");
}
/// @notice User can buy Orange from this pool
/// @dev Buys Orange with user's ETH in this pool
/// @param swapAmount ETH amount to buy Orange tokens
/// @return success for successful transaction
function buyOrange(uint256 swapAmount) public returns (bool) {
require(swapAmount <= getBalance(), "Overdrawn");
balances[msg.sender] -= swapAmount;
totalContractBalance -= swapAmount;
Orange o = Orange(orange);
o.mint(msg.sender, swapAmount);
return true;
}
/// @dev fallback function
receive() external payable {}
}
| 47,288 |
55 | // _newAdmin Address of new admin/ | function addAdmin(address _newAdmin) public onlyAdmin returns (bool success){
require(
cryptonomicaVerification.keyCertificateValidUntil(_newAdmin) > now,
"New admin has to be verified on Cryptonomica.net"
);
// revokedOn returns uint256 (unix time), it's 0 if verification is not revoked
require(
cryptonomicaVerification.revokedOn(_newAdmin) == 0,
"Verification for this address was revoked, can not add"
);
isAdmin[_newAdmin] = true;
emit AdminAdded(_newAdmin, msg.sender);
return true;
}
| function addAdmin(address _newAdmin) public onlyAdmin returns (bool success){
require(
cryptonomicaVerification.keyCertificateValidUntil(_newAdmin) > now,
"New admin has to be verified on Cryptonomica.net"
);
// revokedOn returns uint256 (unix time), it's 0 if verification is not revoked
require(
cryptonomicaVerification.revokedOn(_newAdmin) == 0,
"Verification for this address was revoked, can not add"
);
isAdmin[_newAdmin] = true;
emit AdminAdded(_newAdmin, msg.sender);
return true;
}
| 26,832 |
101 | // Reward | uint256 public rewardPerBlock;
uint256 public rewardPerBlockLP;
| uint256 public rewardPerBlock;
uint256 public rewardPerBlockLP;
| 31,199 |
258 | // Auction did not meet reserve price./Return committed funds back to user. | require(block.timestamp > uint256(marketInfo.endTime), "DutchAuction: auction has not finished yet");
uint256 fundsCommitted = commitments[beneficiary];
commitments[beneficiary] = 0; // Stop multiple withdrawals and free some gas
_safeTokenPayment(paymentCurrency, beneficiary, fundsCommitted);
| require(block.timestamp > uint256(marketInfo.endTime), "DutchAuction: auction has not finished yet");
uint256 fundsCommitted = commitments[beneficiary];
commitments[beneficiary] = 0; // Stop multiple withdrawals and free some gas
_safeTokenPayment(paymentCurrency, beneficiary, fundsCommitted);
| 29,121 |
17 | // Lottery Ether lotery that transfer contract amount to winner/ | contract Lottery {
//list of players registered in lotery
address payable[] public players;
address public admin;
/**
* @dev makes 'admin' of the account at point of deployement
*/
constructor() {
admin = msg.sender;
//automatically adds admin on deployment
// players.push(payable(admin));
}
modifier onlyOwner() {
require(admin == msg.sender, "You are not the owner");
_;
}
/**
* @dev requires the deposit of 0.1 ether and if met pushes on address on list
*/
receive() external payable {
//require that the transaction value to the contract is 0.1 ether
require(msg.value == 1 ether , "Must send 0.01 Matic amount");
//makes sure that the admin can not participate in lottery
require(msg.sender != admin);
// pushing the account conducting the transaction onto the players array as a payable address
players.push(payable(msg.sender));
}
/**
* @dev gets the contracts balance
* @return contract balance
*/
function getBalance() public view returns(uint){
// returns the contract balance
return address(this).balance;
}
/**
* @dev generates random int *WARNING* -> Not safe for public use, vulnerbility detected
* @return random uint
*/
function random() internal view returns(uint){
return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, players.length)));
}
/**
* @dev picks a winner from the lottery, and grants winner the balance of contract
*/
function pickWinner() public onlyOwner {
//makes sure that we have enough players in the lottery
require(players.length >= 10 , "Not enough players in the lottery");
address payable winner;
//selects the winner with random number
winner = players[random() % players.length];
//transfers balance to winner
winner.transfer( (getBalance() * 90) / 100); //gets only 90% of funds in contract
payable(admin).transfer( (getBalance() * 10) / 100); //gets remaining amount AKA 10% -> must make admin a payable account
//resets the plays array once someone is picked
resetLottery();
}
/**
* @dev resets the lottery
*/
function resetLottery() internal {
players = new address payable[](0);
}
}
| contract Lottery {
//list of players registered in lotery
address payable[] public players;
address public admin;
/**
* @dev makes 'admin' of the account at point of deployement
*/
constructor() {
admin = msg.sender;
//automatically adds admin on deployment
// players.push(payable(admin));
}
modifier onlyOwner() {
require(admin == msg.sender, "You are not the owner");
_;
}
/**
* @dev requires the deposit of 0.1 ether and if met pushes on address on list
*/
receive() external payable {
//require that the transaction value to the contract is 0.1 ether
require(msg.value == 1 ether , "Must send 0.01 Matic amount");
//makes sure that the admin can not participate in lottery
require(msg.sender != admin);
// pushing the account conducting the transaction onto the players array as a payable address
players.push(payable(msg.sender));
}
/**
* @dev gets the contracts balance
* @return contract balance
*/
function getBalance() public view returns(uint){
// returns the contract balance
return address(this).balance;
}
/**
* @dev generates random int *WARNING* -> Not safe for public use, vulnerbility detected
* @return random uint
*/
function random() internal view returns(uint){
return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, players.length)));
}
/**
* @dev picks a winner from the lottery, and grants winner the balance of contract
*/
function pickWinner() public onlyOwner {
//makes sure that we have enough players in the lottery
require(players.length >= 10 , "Not enough players in the lottery");
address payable winner;
//selects the winner with random number
winner = players[random() % players.length];
//transfers balance to winner
winner.transfer( (getBalance() * 90) / 100); //gets only 90% of funds in contract
payable(admin).transfer( (getBalance() * 10) / 100); //gets remaining amount AKA 10% -> must make admin a payable account
//resets the plays array once someone is picked
resetLottery();
}
/**
* @dev resets the lottery
*/
function resetLottery() internal {
players = new address payable[](0);
}
}
| 30,406 |