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
41
// Transfer the specified amounts of tokens to the specified addresses.Be aware that there is no check for duplicate recipients._toAddresses Receiver addresses._amounts Amounts of tokens that will be transferred./
function multiTransfer(address[] _toAddresses, uint256[] _amounts) public whenNotPaused returns (bool) { /* Ensures _toAddresses array is less than or equal to 255 */ require(_toAddresses.length <= 255); /* Ensures _toAddress and _amounts have the same number of entries. */ require(_toAddresses.length == _amounts.length); for (uint8 i = 0; i < _toAddresses.length; i++) { transfer(_toAddresses[i], _amounts[i]); } }
function multiTransfer(address[] _toAddresses, uint256[] _amounts) public whenNotPaused returns (bool) { /* Ensures _toAddresses array is less than or equal to 255 */ require(_toAddresses.length <= 255); /* Ensures _toAddress and _amounts have the same number of entries. */ require(_toAddresses.length == _amounts.length); for (uint8 i = 0; i < _toAddresses.length; i++) { transfer(_toAddresses[i], _amounts[i]); } }
28,900
31
// To implement this library for multiple types with as little code repetition as possible, we write it in terms of a generic Set type with bytes32 values. The Set implementation uses private functions, and user-facing implementations (such as AddressSet) are just wrappers around the underlying Set. This means that we can only create new EnumerableSets for types that fit in bytes32.
struct Set {
struct Set {
23,474
2
// FFDefiInvestors[msg.sender]
investorStruct memory investorD = investorStruct({ addressInvestor: msg.sender, linkToSlackImage: _linkToSlackImage, isRegistered: true, timestamp: block.timestamp });
investorStruct memory investorD = investorStruct({ addressInvestor: msg.sender, linkToSlackImage: _linkToSlackImage, isRegistered: true, timestamp: block.timestamp });
44,373
9
// The number as string has length 78, so you do some aritmetic operaions to divide the random number into 2 random dice values
function calcDiceValues() private returns (uint8, uint8) { uint8 dice1value = (uint8) ((lastRandom % (10**39)) % 6) + 1; uint8 dice2value = (uint8) ((lastRandom - dice1value)/(10**39) % 6) + 1; emit DicesForRandomNumber(lastRandom, dice1value, dice2value); timesRolledTheDices++; return (dice1value, dice2value); }
function calcDiceValues() private returns (uint8, uint8) { uint8 dice1value = (uint8) ((lastRandom % (10**39)) % 6) + 1; uint8 dice2value = (uint8) ((lastRandom - dice1value)/(10**39) % 6) + 1; emit DicesForRandomNumber(lastRandom, dice1value, dice2value); timesRolledTheDices++; return (dice1value, dice2value); }
37,356
508
// approve 3crv for deposit into pickle
IDetailedERC20(_token).safeApprove(address(vault), uint256(-1));
IDetailedERC20(_token).safeApprove(address(vault), uint256(-1));
27,775
27
// Performs division where if there is a modulo, the value is rounded up/
function divCeil(uint256 a, uint256 b) internal pure returns(uint256)
function divCeil(uint256 a, uint256 b) internal pure returns(uint256)
44,108
26
// This function is called by a anyone to repay a loan. It can be called at any time after the loan hasbegun and before loan expiry.. The caller will pay a pro-rata portion of their interest if the loan is paid offearly and the loan is pro-rated type, but the complete repayment amount if it is fixed type.The the borrower (current owner of the obligation note) will get the collaterl NFT back. This function is purposefully not pausable in order to prevent an attack where the contract admin's pause thecontract and hold hostage the NFT's that are still within it._loanIdA
function payBackLoan(uint256 _loanId) external nonReentrant { LoanChecksAndCalculations.payBackChecks(_loanId, hub); ( address borrower, address lender, LoanTerms memory loan, IDirectLoanCoordinator loanCoordinator ) = _getPartiesAndData(_loanId); _payBackLoan(_loanId, borrower, lender, loan); _resolveLoan(_loanId, borrower, loan, loanCoordinator); // Delete the loan from storage in order to achieve a substantial gas savings and to lessen the burden of // storage on Ethereum nodes, since we will never access this loan's details again, and the details are still // available through event data. delete loanIdToLoan[_loanId]; delete loanIdToLoanExtras[_loanId]; }
function payBackLoan(uint256 _loanId) external nonReentrant { LoanChecksAndCalculations.payBackChecks(_loanId, hub); ( address borrower, address lender, LoanTerms memory loan, IDirectLoanCoordinator loanCoordinator ) = _getPartiesAndData(_loanId); _payBackLoan(_loanId, borrower, lender, loan); _resolveLoan(_loanId, borrower, loan, loanCoordinator); // Delete the loan from storage in order to achieve a substantial gas savings and to lessen the burden of // storage on Ethereum nodes, since we will never access this loan's details again, and the details are still // available through event data. delete loanIdToLoan[_loanId]; delete loanIdToLoanExtras[_loanId]; }
40,276
93
// PUBS
contract PubToken is ERC20("PUB.finance","PUBS"), Ownable { using BasisPoints for uint; using SafeMath for uint; uint public burnBP; uint public taxBP; Bartender private bartender; mapping(address => bool) public taxExempt; mapping(address => bool) public fromOnlyTaxExempt; mapping(address => bool) public toOnlyTaxExempt; constructor(uint _taxBP, uint _burnBP, address _bartender, address owner) public { bartender = Bartender(_bartender); taxBP = _taxBP; burnBP = _burnBP; setTaxExemptStatus(address(bartender), true); transferOwnership(owner); } modifier onlyBartender { require(msg.sender == address(bartender), "Can only be called by Bartender contract."); _; } /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (Bartender). function mint(address _to, uint256 _amount) public onlyBartender { _mint(_to, _amount); } function setFromOnlyTaxExemptStatus(address account, bool status) external onlyOwner { fromOnlyTaxExempt[account] = status; } function setToOnlyTaxExemptStatus(address account, bool status) external onlyOwner { fromOnlyTaxExempt[account] = status; } function setTaxExemptStatus(address account, bool status) public onlyOwner { taxExempt[account] = status; } function transfer(address recipient, uint amount) public override returns (bool) { ( !taxExempt[msg.sender] && !taxExempt[recipient] && !toOnlyTaxExempt[recipient] && !fromOnlyTaxExempt[msg.sender] ) ? _transferWithTax(msg.sender, recipient, amount) : _transfer(msg.sender, recipient, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public override returns (bool) { ( !taxExempt[sender] && !taxExempt[recipient] && !toOnlyTaxExempt[recipient] && !fromOnlyTaxExempt[sender] ) ? _transferWithTax(sender, recipient, amount) : _transfer(sender, recipient, amount); approve( msg.sender, allowance( sender, msg.sender ).sub(amount, "Transfer amount exceeds allowance") ); return true; } function findTaxAmount(uint value) public view returns (uint tax, uint devTax) { tax = value.mulBP(taxBP); devTax = value.mulBP(burnBP); } function _transferWithTax(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); (uint tax, uint devTax) = findTaxAmount(amount); uint tokensToTransfer = amount.sub(tax).sub(devTax); _transfer(sender, address(bartender), tax); _transfer(sender, address(bartender), devTax); _transfer(sender, recipient, tokensToTransfer); bartender.handleTaxDistribution(tax, devTax); } }
contract PubToken is ERC20("PUB.finance","PUBS"), Ownable { using BasisPoints for uint; using SafeMath for uint; uint public burnBP; uint public taxBP; Bartender private bartender; mapping(address => bool) public taxExempt; mapping(address => bool) public fromOnlyTaxExempt; mapping(address => bool) public toOnlyTaxExempt; constructor(uint _taxBP, uint _burnBP, address _bartender, address owner) public { bartender = Bartender(_bartender); taxBP = _taxBP; burnBP = _burnBP; setTaxExemptStatus(address(bartender), true); transferOwnership(owner); } modifier onlyBartender { require(msg.sender == address(bartender), "Can only be called by Bartender contract."); _; } /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (Bartender). function mint(address _to, uint256 _amount) public onlyBartender { _mint(_to, _amount); } function setFromOnlyTaxExemptStatus(address account, bool status) external onlyOwner { fromOnlyTaxExempt[account] = status; } function setToOnlyTaxExemptStatus(address account, bool status) external onlyOwner { fromOnlyTaxExempt[account] = status; } function setTaxExemptStatus(address account, bool status) public onlyOwner { taxExempt[account] = status; } function transfer(address recipient, uint amount) public override returns (bool) { ( !taxExempt[msg.sender] && !taxExempt[recipient] && !toOnlyTaxExempt[recipient] && !fromOnlyTaxExempt[msg.sender] ) ? _transferWithTax(msg.sender, recipient, amount) : _transfer(msg.sender, recipient, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public override returns (bool) { ( !taxExempt[sender] && !taxExempt[recipient] && !toOnlyTaxExempt[recipient] && !fromOnlyTaxExempt[sender] ) ? _transferWithTax(sender, recipient, amount) : _transfer(sender, recipient, amount); approve( msg.sender, allowance( sender, msg.sender ).sub(amount, "Transfer amount exceeds allowance") ); return true; } function findTaxAmount(uint value) public view returns (uint tax, uint devTax) { tax = value.mulBP(taxBP); devTax = value.mulBP(burnBP); } function _transferWithTax(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); (uint tax, uint devTax) = findTaxAmount(amount); uint tokensToTransfer = amount.sub(tax).sub(devTax); _transfer(sender, address(bartender), tax); _transfer(sender, address(bartender), devTax); _transfer(sender, recipient, tokensToTransfer); bartender.handleTaxDistribution(tax, devTax); } }
70,250
14
// mkusd/fraxbp fee, normalized to 1e18
uint256 fee = (MKUSD_FRAXP.fee() + 1e10) * 1e8;
uint256 fee = (MKUSD_FRAXP.fee() + 1e10) * 1e8;
38,549
74
// Node details
nodeDetails.nodeAddress = _nodeAddress; nodeDetails.withdrawalAddress = rocketStorage.getNodeWithdrawalAddress(_nodeAddress); nodeDetails.pendingWithdrawalAddress = rocketStorage.getNodePendingWithdrawalAddress(_nodeAddress); nodeDetails.exists = getNodeExists(_nodeAddress); nodeDetails.registrationTime = getNodeRegistrationTime(_nodeAddress); nodeDetails.timezoneLocation = getNodeTimezoneLocation(_nodeAddress); nodeDetails.feeDistributorInitialised = getFeeDistributorInitialised(_nodeAddress); nodeDetails.rewardNetwork = getRewardNetwork(_nodeAddress);
nodeDetails.nodeAddress = _nodeAddress; nodeDetails.withdrawalAddress = rocketStorage.getNodeWithdrawalAddress(_nodeAddress); nodeDetails.pendingWithdrawalAddress = rocketStorage.getNodePendingWithdrawalAddress(_nodeAddress); nodeDetails.exists = getNodeExists(_nodeAddress); nodeDetails.registrationTime = getNodeRegistrationTime(_nodeAddress); nodeDetails.timezoneLocation = getNodeTimezoneLocation(_nodeAddress); nodeDetails.feeDistributorInitialised = getFeeDistributorInitialised(_nodeAddress); nodeDetails.rewardNetwork = getRewardNetwork(_nodeAddress);
34,754
26
// Return the data from the delegate call.
return returnedData;
return returnedData;
37,442
104
// forwardd ether to vault /
function forwardFunds(uint256 toFund) internal { vault.deposit.value(toFund)(msg.sender); }
function forwardFunds(uint256 toFund) internal { vault.deposit.value(toFund)(msg.sender); }
81,317
43
// Load the assets we have in this vault
uint256 holdings = position.balanceOfUnderlying(address(this));
uint256 holdings = position.balanceOfUnderlying(address(this));
11,983
224
// Transforms the paramMapping value to the index in sub array value/_type Indicated the type of the input
function getSubIndex(uint8 _type) internal pure returns (uint8) { if (_type < SUB_MIN_INDEX_VALUE){ revert ReturnIndexValueError(); } return (_type - SUB_MIN_INDEX_VALUE); }
function getSubIndex(uint8 _type) internal pure returns (uint8) { if (_type < SUB_MIN_INDEX_VALUE){ revert ReturnIndexValueError(); } return (_type - SUB_MIN_INDEX_VALUE); }
3,868
334
// Inserts `_node` into merkle tree Reverts if tree is full _node Element to insert into tree /
function insert(Tree storage _tree, bytes32 _node) internal { require(_tree.count < MAX_LEAVES, "merkle tree full"); _tree.count += 1; uint256 size = _tree.count; for (uint256 i = 0; i < TREE_DEPTH; i++) { if ((size & 1) == 1) { _tree.branch[i] = _node; return; } _node = keccak256(abi.encodePacked(_tree.branch[i], _node)); size /= 2; } // As the loop should always end prematurely with the `return` statement, // this code should be unreachable. We assert `false` just to be safe. assert(false); }
function insert(Tree storage _tree, bytes32 _node) internal { require(_tree.count < MAX_LEAVES, "merkle tree full"); _tree.count += 1; uint256 size = _tree.count; for (uint256 i = 0; i < TREE_DEPTH; i++) { if ((size & 1) == 1) { _tree.branch[i] = _node; return; } _node = keccak256(abi.encodePacked(_tree.branch[i], _node)); size /= 2; } // As the loop should always end prematurely with the `return` statement, // this code should be unreachable. We assert `false` just to be safe. assert(false); }
19,147
8
// Clear approvalNote that if 0 is not a valid value it will be set to 1. _token erc20 The address of the ERC20 contract _spender The address which will spend the funds. /
function clearApprove(IERC20 _token, address _spender) internal returns (bool) { bool success = safeApprove(_token, _spender, 0); if (!success) { success = safeApprove(_token, _spender, 1); } return success; }
function clearApprove(IERC20 _token, address _spender) internal returns (bool) { bool success = safeApprove(_token, _spender, 0); if (!success) { success = safeApprove(_token, _spender, 1); } return success; }
21,992
3
// This function will start the attack on the vulnerable contract
function attack() external payable { require(msg.value >= 1 ether); vulnerableContract.deposit{value: 1 ether}(); vulnerableContract.withdraw(); }
function attack() external payable { require(msg.value >= 1 ether); vulnerableContract.deposit{value: 1 ether}(); vulnerableContract.withdraw(); }
5,527
9
// Logs a Sell Drago event./_who Address of who is selling/_targetDrago Address of the target drago/_amount Number of shares purchased/_revenue Value of the transaction in Ether/ return Bool the transaction executed successfully
function sellDrago( address _who, address _targetDrago, uint _amount, uint _revenue, bytes _name, bytes _symbol) external approvedDragoOnly(msg.sender) returns(bool success)
function sellDrago( address _who, address _targetDrago, uint _amount, uint _revenue, bytes _name, bytes _symbol) external approvedDragoOnly(msg.sender) returns(bool success)
34,015
3
// Function signature for encoding ERC1155 assetData./tokenAddress Address of ERC1155 token contract./tokenIds Array of ids of tokens to be transferred./values Array of values that correspond to each token id to be transferred./Note that each value will be multiplied by the amount being filled in the order before transferring./callbackData Extra data to be passed to receiver's `onERC1155Received` callback function.
function ERC1155Assets( address tokenAddress, uint256[] calldata tokenIds, uint256[] calldata values, bytes calldata callbackData ) external;
function ERC1155Assets( address tokenAddress, uint256[] calldata tokenIds, uint256[] calldata values, bytes calldata callbackData ) external;
49,062
145
// claim the tokens
IStaker(staker).withdraw(token); uint256 activeCount = IRewardFactory(rewardFactory).activeRewardCount(token); if(activeCount > 1){
IStaker(staker).withdraw(token); uint256 activeCount = IRewardFactory(rewardFactory).activeRewardCount(token); if(activeCount > 1){
36,826
397
// When blacklist is updated
event AddedToBlacklist(uint EIN, uint recipientEIN); event RemovedFromBlacklist(uint EIN, uint recipientEIN);
event AddedToBlacklist(uint EIN, uint recipientEIN); event RemovedFromBlacklist(uint EIN, uint recipientEIN);
24,717
1
// Token supply
uint256 public supply = 2358;
uint256 public supply = 2358;
60,318
23
// totalstaked = totalstaked.sub(userStakes.stakedAmount);
total = total.sub(userStakes.stakedAmount); k = initialAmount; counter++;
total = total.sub(userStakes.stakedAmount); k = initialAmount; counter++;
13,311
89
// return true if HarborPresale event has ended
function hasEnded() public constant returns (bool) { bool capReached = weiRaised >= cap; return (now > endTime) || capReached ; }
function hasEnded() public constant returns (bool) { bool capReached = weiRaised >= cap; return (now > endTime) || capReached ; }
29,496
96
// Mint token(s) for public sales /
function mint( bytes memory signature, uint256 nonce, uint256 numberOfTokens, uint256 maxMintsPerWallet, address recipient
function mint( bytes memory signature, uint256 nonce, uint256 numberOfTokens, uint256 maxMintsPerWallet, address recipient
26,049
143
// withdraw everything from the strategy to accurately check the share value
if (numberOfShares == totalSupply) { strategy.withdrawAllToVault(); } else {
if (numberOfShares == totalSupply) { strategy.withdrawAllToVault(); } else {
54,754
4
// Derived from @openzeppelin-contracts/contracts/access/Roles.sol/ Roles Library for managing addresses assigned to a Role. /
library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } }
library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } }
29,834
177
// .add(balanceFulcrumInToken()).add(balanceDydx()).add(balanceAave())
.add(balance());
.add(balance());
8,016
17
// Whether Flash mint is active
bool isFlashMintActive;
bool isFlashMintActive;
19,769
32
// n.b. DAI can only go to the output conduit
function draw(uint256 wad) external operator { require(outputConduit != address(0)); bytes32 ilk = gemJoin.ilk(); jug.drip(ilk); (,uint256 rate,,,) = vat.ilks(ilk); uint256 dart = divup(mul(RAY, wad), rate); require(dart <= 2**255 - 1, "RwaUrn/overflow"); vat.frob(ilk, address(this), address(this), address(this), 0, int(dart)); daiJoin.exit(outputConduit, wad); emit Draw(msg.sender, wad); }
function draw(uint256 wad) external operator { require(outputConduit != address(0)); bytes32 ilk = gemJoin.ilk(); jug.drip(ilk); (,uint256 rate,,,) = vat.ilks(ilk); uint256 dart = divup(mul(RAY, wad), rate); require(dart <= 2**255 - 1, "RwaUrn/overflow"); vat.frob(ilk, address(this), address(this), address(this), 0, int(dart)); daiJoin.exit(outputConduit, wad); emit Draw(msg.sender, wad); }
61,035
29
// Sets the management fee for the token _managementFee is the management fee (18 decimals). ex: 21018 = 2% /
function setManagementFee(uint256 _managementFee) external { _checkOwner(); if (_managementFee > 100 * FEE_MULTIPLIER) revert BadFee(); emit ManagementFeeSet(managementFee, _managementFee); managementFee = _managementFee; }
function setManagementFee(uint256 _managementFee) external { _checkOwner(); if (_managementFee > 100 * FEE_MULTIPLIER) revert BadFee(); emit ManagementFeeSet(managementFee, _managementFee); managementFee = _managementFee; }
8,616
14
// mapping(owner address => mapping(channelId uint => nonce uint256))) public canceled;
mapping(address => mapping(uint256 => uint)) public canceled; string public constant version = '2.0.0'; uint public applyWait = 1 days; uint public feeRate = 10; bool public withdrawEnabled = false; bool public stop = false; uint256 private DEFAULT_CHANNEL_ID = 0; bool public depositToEnabled = true; bool public transferEnabled = false; bool public changeChannelEnabled = false;
mapping(address => mapping(uint256 => uint)) public canceled; string public constant version = '2.0.0'; uint public applyWait = 1 days; uint public feeRate = 10; bool public withdrawEnabled = false; bool public stop = false; uint256 private DEFAULT_CHANNEL_ID = 0; bool public depositToEnabled = true; bool public transferEnabled = false; bool public changeChannelEnabled = false;
7,595
417
// Implements the permit function as specified in EIP-2612. owner Address of the token owner.spender Address of the spender.value Amount of allowance.deadlineExpiration timestamp for the signature.v Signature param.r Signature param.s Signature param. /
function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external
function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external
36,461
12
// NFTSalesUSDX - NFT sale by stablecoins one type
contract NFTSalesUSDX is ERC1155Holder, Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; struct Token { bool resolved; uint256 price; } struct Collectible { uint256 price; // in usd } IERC1155Collectible public immutable collection; address public immutable vesting; address public immutable refRegistry; bool public salesEnabled; uint256 public minBuy = 1e18; // @dev collections - list of resolved for sell stablecoins mapping(address => Token) public tokenInfo; // token id -> data mapping(uint256 => Collectible) public collectibleInfo; event Bought(address token, address from, uint256 tokenId, uint256 amount); event Deposited(address token, address from, uint256 amount); // `_collectionToken` - erc1155 token constructor( IERC1155Collectible _collectionToken, address _vesting, address _refRegistry ) { require( address(_collectionToken) != address(0) && address(_vesting) != address(0) && address(_refRegistry) != address(0), "Token sell: wrong constructor arguments" ); collection = _collectionToken; vesting = _vesting; refRegistry = _refRegistry; Token storage usdt = tokenInfo[ 0x55d398326f99059fF775485246999027B3197955 ]; usdt.resolved = true; usdt.price = 1e18; Token storage busd = tokenInfo[ 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56 ]; busd.resolved = true; busd.price = 1e18; Token storage usdc = tokenInfo[ 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d ]; usdc.resolved = true; usdc.price = 1e18; Token storage dai = tokenInfo[ 0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3 ]; dai.resolved = true; dai.price = 1e18; collectibleInfo[1].price = 1e18; collectibleInfo[2].price = 769e14; collectibleInfo[3].price = 336e13; collectibleInfo[4].price = 541e12; collectibleInfo[5].price = 2086e10; } function buy( address _token, uint256 _amount, uint256 _tokenId, uint256 _items, address _to, address _sponsor ) external payable isSellApproved { require(_token != address(0), "Token sell: zero token"); require(_to != address(0), "Token sell: buy for vitalik?"); require(_items > 0, "Token sell: zero items, really?"); require( tokenInfo[_token].resolved, "Token sell: token is not accepted" ); if (!IPartner(refRegistry).isUser(msg.sender)) { IPartner(refRegistry).register(msg.sender, _sponsor); } _buy(_token, _amount, _tokenId, _items, _to); } function sellSwitcher(bool _status) external onlyOwner { salesEnabled = _status; } function countBuyAmount( address _buyToken, uint256 _tokenId, uint256 _amount ) external view returns (uint256 price) { require(_amount > 0, "Token sell: zero items, really?"); require( tokenInfo[_buyToken].resolved, "Token sell: token is not accepted" ); price = _amount.mul( collectibleInfo[_tokenId].price.mul(tokenInfo[_buyToken].price).div( 1e18 ) ); } function setMinBuy(uint256 _minBuy) external onlyOwner { minBuy = _minBuy; } function _buy( address _token, uint256 _amount, uint256 _tokenId, uint256 _items, address _to ) internal { require(msg.value == 0, "Ether value not zero"); uint256 price = _items.mul( collectibleInfo[_tokenId].price.mul(tokenInfo[_token].price).div( 1e18 ) ); require(_amount >= minBuy, "Token sell: min buy, not enough to buy"); require(_amount >= price, "Token sell: not enough to buy, low amount"); IERC20(_token).safeTransferFrom(_msgSender(), vesting, _amount); collection.mint(_to, _tokenId, _items, ""); emit Deposited(_token, msg.sender, _amount); emit Bought(_token, _to, _tokenId, _items); } modifier isSellApproved() { require(salesEnabled, "Sales disabled"); _; } }
contract NFTSalesUSDX is ERC1155Holder, Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; struct Token { bool resolved; uint256 price; } struct Collectible { uint256 price; // in usd } IERC1155Collectible public immutable collection; address public immutable vesting; address public immutable refRegistry; bool public salesEnabled; uint256 public minBuy = 1e18; // @dev collections - list of resolved for sell stablecoins mapping(address => Token) public tokenInfo; // token id -> data mapping(uint256 => Collectible) public collectibleInfo; event Bought(address token, address from, uint256 tokenId, uint256 amount); event Deposited(address token, address from, uint256 amount); // `_collectionToken` - erc1155 token constructor( IERC1155Collectible _collectionToken, address _vesting, address _refRegistry ) { require( address(_collectionToken) != address(0) && address(_vesting) != address(0) && address(_refRegistry) != address(0), "Token sell: wrong constructor arguments" ); collection = _collectionToken; vesting = _vesting; refRegistry = _refRegistry; Token storage usdt = tokenInfo[ 0x55d398326f99059fF775485246999027B3197955 ]; usdt.resolved = true; usdt.price = 1e18; Token storage busd = tokenInfo[ 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56 ]; busd.resolved = true; busd.price = 1e18; Token storage usdc = tokenInfo[ 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d ]; usdc.resolved = true; usdc.price = 1e18; Token storage dai = tokenInfo[ 0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3 ]; dai.resolved = true; dai.price = 1e18; collectibleInfo[1].price = 1e18; collectibleInfo[2].price = 769e14; collectibleInfo[3].price = 336e13; collectibleInfo[4].price = 541e12; collectibleInfo[5].price = 2086e10; } function buy( address _token, uint256 _amount, uint256 _tokenId, uint256 _items, address _to, address _sponsor ) external payable isSellApproved { require(_token != address(0), "Token sell: zero token"); require(_to != address(0), "Token sell: buy for vitalik?"); require(_items > 0, "Token sell: zero items, really?"); require( tokenInfo[_token].resolved, "Token sell: token is not accepted" ); if (!IPartner(refRegistry).isUser(msg.sender)) { IPartner(refRegistry).register(msg.sender, _sponsor); } _buy(_token, _amount, _tokenId, _items, _to); } function sellSwitcher(bool _status) external onlyOwner { salesEnabled = _status; } function countBuyAmount( address _buyToken, uint256 _tokenId, uint256 _amount ) external view returns (uint256 price) { require(_amount > 0, "Token sell: zero items, really?"); require( tokenInfo[_buyToken].resolved, "Token sell: token is not accepted" ); price = _amount.mul( collectibleInfo[_tokenId].price.mul(tokenInfo[_buyToken].price).div( 1e18 ) ); } function setMinBuy(uint256 _minBuy) external onlyOwner { minBuy = _minBuy; } function _buy( address _token, uint256 _amount, uint256 _tokenId, uint256 _items, address _to ) internal { require(msg.value == 0, "Ether value not zero"); uint256 price = _items.mul( collectibleInfo[_tokenId].price.mul(tokenInfo[_token].price).div( 1e18 ) ); require(_amount >= minBuy, "Token sell: min buy, not enough to buy"); require(_amount >= price, "Token sell: not enough to buy, low amount"); IERC20(_token).safeTransferFrom(_msgSender(), vesting, _amount); collection.mint(_to, _tokenId, _items, ""); emit Deposited(_token, msg.sender, _amount); emit Bought(_token, _to, _tokenId, _items); } modifier isSellApproved() { require(salesEnabled, "Sales disabled"); _; } }
11,113
18
// Managing permissions // Getting the current role of the sender in the contractreturn The enum value of Roles associated with the sender of the message A no privileged user is considered a buyer. Owner is not a role in the contract /
function getRole() public view returns(Roles) { return privilegedUsers[msg.sender] ? roles[msg.sender] : Roles.BUYER; }
function getRole() public view returns(Roles) { return privilegedUsers[msg.sender] ? roles[msg.sender] : Roles.BUYER; }
22,106
201
// Gets the managers./ return The list of managers.
function managers() public view returns (address[] memory) { return addressesInSet(MANAGER); }
function managers() public view returns (address[] memory) { return addressesInSet(MANAGER); }
9,548
73
// Returns The Total Bid Volume Of The Auction SaleIndex The Sale Index To View /
function ViewTotalBidVolume(uint SaleIndex) public view returns (uint)
function ViewTotalBidVolume(uint SaleIndex) public view returns (uint)
19,877
3
// snapshotHistory This array records the number of users synchronized for each snapshot
uint32[] snapshotHistory;
uint32[] snapshotHistory;
2,809
15
// Revert with an error when attempting to fill a basic order that has been partially filled.orderHash The hash of the partially used order. /
error OrderPartiallyFilled(bytes32 orderHash);
error OrderPartiallyFilled(bytes32 orderHash);
22,335
38
// Get ETH able to be committed
if(readAndAgreedToMarketParticipationAgreement == false) { revertBecauseUserDidNotProvideAgreement(); }
if(readAndAgreedToMarketParticipationAgreement == false) { revertBecauseUserDidNotProvideAgreement(); }
25,649
33
// Constructor - instantiates token supply and allocates balance ofto the admin (msg.sender)./
function QuintToken(address _creator) public { // Mint all tokens to creator balances[msg.sender] = INITIAL_SUPPLY; totalSupply_ = INITIAL_SUPPLY; // Set creator address creatorAddress = _creator; }
function QuintToken(address _creator) public { // Mint all tokens to creator balances[msg.sender] = INITIAL_SUPPLY; totalSupply_ = INITIAL_SUPPLY; // Set creator address creatorAddress = _creator; }
39,602
511
// ERC721 Burnable Token ERC721 Token that can be irreversibly burned (destroyed). /
abstract contract ERC721Burnable is Context, ERC721 { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); } }
abstract contract ERC721Burnable is Context, ERC721 { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); } }
2,884
8
// only owner can switch on public sale
function switchOnPublicSale() external onlyOwner { isPublicSaleActive = !isPublicSaleActive; }
function switchOnPublicSale() external onlyOwner { isPublicSaleActive = !isPublicSaleActive; }
36,198
84
// buy
removeAllFee(); if(from == uniswapV2Pair){ _taxFee = _addressFees[to]._buyTaxFee; _liquidityFee = _addressFees[to]._buyLiquidityFee; }
removeAllFee(); if(from == uniswapV2Pair){ _taxFee = _addressFees[to]._buyTaxFee; _liquidityFee = _addressFees[to]._buyLiquidityFee; }
23,284
63
// https:docs.synthetix.io/contracts/source/contracts/mixinresolver
contract MixinResolver { AddressResolver public resolver; mapping(bytes32 => address) private addressCache; constructor(address _resolver) internal { resolver = AddressResolver(_resolver); } /* ========== INTERNAL FUNCTIONS ========== */ function combineArrays(bytes32[] memory first, bytes32[] memory second) internal pure returns (bytes32[] memory combination) { combination = new bytes32[](first.length + second.length); for (uint i = 0; i < first.length; i++) { combination[i] = first[i]; } for (uint j = 0; j < second.length; j++) { combination[first.length + j] = second[j]; } } /* ========== PUBLIC FUNCTIONS ========== */ // Note: this function is public not external in order for it to be overridden and invoked via super in subclasses function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {} function rebuildCache() public { bytes32[] memory requiredAddresses = resolverAddressesRequired(); // The resolver must call this function whenver it updates its state for (uint i = 0; i < requiredAddresses.length; i++) { bytes32 name = requiredAddresses[i]; // Note: can only be invoked once the resolver has all the targets needed added address destination = resolver.requireAndGetAddress(name, string(abi.encodePacked("Resolver missing target: ", name))); addressCache[name] = destination; emit CacheUpdated(name, destination); } } /* ========== VIEWS ========== */ function isResolverCached() external view returns (bool) { bytes32[] memory requiredAddresses = resolverAddressesRequired(); for (uint i = 0; i < requiredAddresses.length; i++) { bytes32 name = requiredAddresses[i]; // false if our cache is invalid or if the resolver doesn't have the required address if (resolver.getAddress(name) != addressCache[name] || addressCache[name] == address(0)) { return false; } } return true; } /* ========== INTERNAL FUNCTIONS ========== */ function requireAndGetAddress(bytes32 name) internal view returns (address) { address _foundAddress = addressCache[name]; require(_foundAddress != address(0), string(abi.encodePacked("Missing address: ", name))); return _foundAddress; } /* ========== EVENTS ========== */ event CacheUpdated(bytes32 name, address destination); }
contract MixinResolver { AddressResolver public resolver; mapping(bytes32 => address) private addressCache; constructor(address _resolver) internal { resolver = AddressResolver(_resolver); } /* ========== INTERNAL FUNCTIONS ========== */ function combineArrays(bytes32[] memory first, bytes32[] memory second) internal pure returns (bytes32[] memory combination) { combination = new bytes32[](first.length + second.length); for (uint i = 0; i < first.length; i++) { combination[i] = first[i]; } for (uint j = 0; j < second.length; j++) { combination[first.length + j] = second[j]; } } /* ========== PUBLIC FUNCTIONS ========== */ // Note: this function is public not external in order for it to be overridden and invoked via super in subclasses function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {} function rebuildCache() public { bytes32[] memory requiredAddresses = resolverAddressesRequired(); // The resolver must call this function whenver it updates its state for (uint i = 0; i < requiredAddresses.length; i++) { bytes32 name = requiredAddresses[i]; // Note: can only be invoked once the resolver has all the targets needed added address destination = resolver.requireAndGetAddress(name, string(abi.encodePacked("Resolver missing target: ", name))); addressCache[name] = destination; emit CacheUpdated(name, destination); } } /* ========== VIEWS ========== */ function isResolverCached() external view returns (bool) { bytes32[] memory requiredAddresses = resolverAddressesRequired(); for (uint i = 0; i < requiredAddresses.length; i++) { bytes32 name = requiredAddresses[i]; // false if our cache is invalid or if the resolver doesn't have the required address if (resolver.getAddress(name) != addressCache[name] || addressCache[name] == address(0)) { return false; } } return true; } /* ========== INTERNAL FUNCTIONS ========== */ function requireAndGetAddress(bytes32 name) internal view returns (address) { address _foundAddress = addressCache[name]; require(_foundAddress != address(0), string(abi.encodePacked("Missing address: ", name))); return _foundAddress; } /* ========== EVENTS ========== */ event CacheUpdated(bytes32 name, address destination); }
26,039
299
// Check that the router isnt accidentally locking funds in the contract
require(msg.value == 0, "#P:017"); stableAmount = amount; amount = 0;
require(msg.value == 0, "#P:017"); stableAmount = amount; amount = 0;
15,714
53
// Configure a category _categoryCategory to configure _price Price of this category _startingTokenId Starting token ID of the category _supplyNumber of tokens in this category /
function setCategoryDetail( Category _category, uint256 _price, uint256 _startingTokenId, uint256 _supply
function setCategoryDetail( Category _category, uint256 _price, uint256 _startingTokenId, uint256 _supply
58,229
116
// RikoToken with Governance.
contract RikoToken is ERC20("RIKO", "RKO"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode( DELEGATION_TYPEHASH, delegatee, nonce, expiry ) ); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, structHash ) ); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "RIKO::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "RIKO::delegateBySig: invalid nonce"); require(now <= expiry, "RIKO::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "RIKO::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying RIKOs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "RIKO::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
contract RikoToken is ERC20("RIKO", "RKO"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode( DELEGATION_TYPEHASH, delegatee, nonce, expiry ) ); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, structHash ) ); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "RIKO::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "RIKO::delegateBySig: invalid nonce"); require(now <= expiry, "RIKO::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "RIKO::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying RIKOs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "RIKO::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
9,810
159
// now is to lock into staking pool
Utils.swapTokensForEth(address(pancakeRouter), tokenAmountToBeSwapped);
Utils.swapTokensForEth(address(pancakeRouter), tokenAmountToBeSwapped);
5,666
14
// ===== Permissioned Actions: Governance =====/Delete if you don't need!
function setKeepReward(uint256 _setKeepReward) external { _onlyGovernance(); }
function setKeepReward(uint256 _setKeepReward) external { _onlyGovernance(); }
47,684
59
// If the current deadline hasn't expired yet then add the delay to it
swappableReservoirLimitReachesMaxDeadline = uint120(_swappableReservoirLimitReachesMaxDeadline + delay);
swappableReservoirLimitReachesMaxDeadline = uint120(_swappableReservoirLimitReachesMaxDeadline + delay);
35,547
5
// already deposited before
UserInfo storage user = userInfo[msg.sender]; if (user.amount != 0) { user.pointsDebt = pointsBalance(msg.sender); }
UserInfo storage user = userInfo[msg.sender]; if (user.amount != 0) { user.pointsDebt = pointsBalance(msg.sender); }
37,836
85
// Called by the Prize-Strategy to award external ERC20 prizes/Used to award any arbitrary tokens held by the Prize Pool/to The address of the winner that receives the award/amount The amount of external assets to be awarded/externalToken The address of the external asset token being awarded
function awardExternalERC20( address to, address externalToken, uint256 amount ) external override onlyPrizeStrategy
function awardExternalERC20( address to, address externalToken, uint256 amount ) external override onlyPrizeStrategy
14,374
142
// And send them the SNX.
synthetix().transfer(msg.sender, synthetixToSend); emit Exchange("ETH", msg.value, "SNX", synthetixToSend); return synthetixToSend;
synthetix().transfer(msg.sender, synthetixToSend); emit Exchange("ETH", msg.value, "SNX", synthetixToSend); return synthetixToSend;
21,069
62
// Merkle root describing the distribution.
bytes32 merkleRoot;
bytes32 merkleRoot;
70,349
67
// Implements bitcoin's hash256 (double sha2) memView A view of the preimagereturndigest - the Digest /
function hash256(bytes29 memView) internal view returns (bytes32 digest) { uint256 _loc = loc(memView); uint256 _len = len(memView); assembly { // solium-disable-previous-line security/no-inline-assembly let ptr := mload(0x40) pop(staticcall(gas(), 2, _loc, _len, ptr, 0x20)) // sha2 #1 pop(staticcall(gas(), 2, ptr, 0x20, ptr, 0x20)) // sha2 #2 digest := mload(ptr) } }
function hash256(bytes29 memView) internal view returns (bytes32 digest) { uint256 _loc = loc(memView); uint256 _len = len(memView); assembly { // solium-disable-previous-line security/no-inline-assembly let ptr := mload(0x40) pop(staticcall(gas(), 2, _loc, _len, ptr, 0x20)) // sha2 #1 pop(staticcall(gas(), 2, ptr, 0x20, ptr, 0x20)) // sha2 #2 digest := mload(ptr) } }
38,469
124
// Saves the latest cumulative sum of the holder reward price.By subtracting this value when calculating the next rewards, always withdrawal the difference from the previous time. /
setStorageLastWithdrawnReward(_property, msg.sender, lastPrice);
setStorageLastWithdrawnReward(_property, msg.sender, lastPrice);
34,975
37
// Internal implementation of distribute logic./gaugeAddr Address of the gauge to distribute rewards to
function _distribute(address gaugeAddr) internal { require(distributionsOn, "not allowed"); (bool success, bytes memory result) = address(controller).call( abi.encodeWithSignature("gauge_types(address)", gaugeAddr) ); if (!success || killedGauges[gaugeAddr]) { return; } int128 gaugeType = abi.decode(result, (int128)); // Rounded to beginning of the day -> 00:00 UTC uint256 roundedTimestamp = (block.timestamp / 1 days) * 1 days; uint256 totalDistribute; if (block.timestamp > lastMasterchefPull + timePeriod) { uint256 sdtBefore = rewardToken.balanceOf(address(this)); _pullSDT(); pulls[roundedTimestamp] = rewardToken.balanceOf(address(this)) - sdtBefore; lastMasterchefPull = roundedTimestamp; } // check past n days for (uint256 i; i < lookPastDays; i++) { uint256 currentTimestamp = roundedTimestamp - (i * 86_400); if (pulls[currentTimestamp] > 0) { bool isPaid = isGaugePaid[currentTimestamp][gaugeAddr]; if (isPaid) { break; } // Retrieve the amount pulled from Masterchef at the given timestamp. uint256 sdtBalance = pulls[currentTimestamp]; uint256 gaugeRelativeWeight; if (i == 0) { // Makes sure the weight is checkpointed. Also returns the weight. gaugeRelativeWeight = controller.gauge_relative_weight_write(gaugeAddr, currentTimestamp); } else { gaugeRelativeWeight = controller.gauge_relative_weight(gaugeAddr, currentTimestamp); } uint256 sdtDistributed = (sdtBalance * gaugeRelativeWeight) / 1e18; totalDistribute += sdtDistributed; isGaugePaid[currentTimestamp][gaugeAddr] = true; } } if (totalDistribute > 0) { if (gaugeType == 1) { rewardToken.safeTransfer(gaugeAddr, totalDistribute); IStakingRewards(gaugeAddr).notifyRewardAmount(totalDistribute); } else if (gaugeType >= 2) { // If it is defined, we use the specific delegate attached to the gauge address delegate = delegateGauges[gaugeAddr]; if (delegate == address(0)) { // If not, we check if a delegate common to all gauges with type >= 2 can be used delegate = delegateGauge; } if (delegate != address(0)) { // In the case where the gauge has a delegate (specific or not), then rewards are transferred to this gauge rewardToken.safeTransfer(delegate, totalDistribute); // If this delegate supports a specific interface, then rewards sent are notified through this // interface if (isInterfaceKnown[delegate]) { ISdtMiddlemanGauge(delegate).notifyReward(gaugeAddr, totalDistribute); } } else { rewardToken.safeTransfer(gaugeAddr, totalDistribute); } } else { ILiquidityGauge(gaugeAddr).deposit_reward_token(address(rewardToken), totalDistribute); } emit RewardDistributed(gaugeAddr, totalDistribute, lastMasterchefPull); } }
function _distribute(address gaugeAddr) internal { require(distributionsOn, "not allowed"); (bool success, bytes memory result) = address(controller).call( abi.encodeWithSignature("gauge_types(address)", gaugeAddr) ); if (!success || killedGauges[gaugeAddr]) { return; } int128 gaugeType = abi.decode(result, (int128)); // Rounded to beginning of the day -> 00:00 UTC uint256 roundedTimestamp = (block.timestamp / 1 days) * 1 days; uint256 totalDistribute; if (block.timestamp > lastMasterchefPull + timePeriod) { uint256 sdtBefore = rewardToken.balanceOf(address(this)); _pullSDT(); pulls[roundedTimestamp] = rewardToken.balanceOf(address(this)) - sdtBefore; lastMasterchefPull = roundedTimestamp; } // check past n days for (uint256 i; i < lookPastDays; i++) { uint256 currentTimestamp = roundedTimestamp - (i * 86_400); if (pulls[currentTimestamp] > 0) { bool isPaid = isGaugePaid[currentTimestamp][gaugeAddr]; if (isPaid) { break; } // Retrieve the amount pulled from Masterchef at the given timestamp. uint256 sdtBalance = pulls[currentTimestamp]; uint256 gaugeRelativeWeight; if (i == 0) { // Makes sure the weight is checkpointed. Also returns the weight. gaugeRelativeWeight = controller.gauge_relative_weight_write(gaugeAddr, currentTimestamp); } else { gaugeRelativeWeight = controller.gauge_relative_weight(gaugeAddr, currentTimestamp); } uint256 sdtDistributed = (sdtBalance * gaugeRelativeWeight) / 1e18; totalDistribute += sdtDistributed; isGaugePaid[currentTimestamp][gaugeAddr] = true; } } if (totalDistribute > 0) { if (gaugeType == 1) { rewardToken.safeTransfer(gaugeAddr, totalDistribute); IStakingRewards(gaugeAddr).notifyRewardAmount(totalDistribute); } else if (gaugeType >= 2) { // If it is defined, we use the specific delegate attached to the gauge address delegate = delegateGauges[gaugeAddr]; if (delegate == address(0)) { // If not, we check if a delegate common to all gauges with type >= 2 can be used delegate = delegateGauge; } if (delegate != address(0)) { // In the case where the gauge has a delegate (specific or not), then rewards are transferred to this gauge rewardToken.safeTransfer(delegate, totalDistribute); // If this delegate supports a specific interface, then rewards sent are notified through this // interface if (isInterfaceKnown[delegate]) { ISdtMiddlemanGauge(delegate).notifyReward(gaugeAddr, totalDistribute); } } else { rewardToken.safeTransfer(gaugeAddr, totalDistribute); } } else { ILiquidityGauge(gaugeAddr).deposit_reward_token(address(rewardToken), totalDistribute); } emit RewardDistributed(gaugeAddr, totalDistribute, lastMasterchefPull); } }
1,446
0
// Store CandidateRead Candidate
string public candidate;
string public candidate;
11,669
63
// Counter underflow is impossible as _currentIndex does not decrement, and it is initialized to `_startTokenId()`
unchecked { return _currentIndex - _startTokenId(); }
unchecked { return _currentIndex - _startTokenId(); }
27,084
81
// safe uint256
using SafeMath for uint256;
using SafeMath for uint256;
36,220
107
// Token information AaveProvider address on Mainnet: 0x24a42fD28C976A61Df5D00D0599C34c4f90748c8 Kovan Testnet: 0x506B0B2CF20FAA8f38a4E2B524EE43e1f4458Cc5
address public aaveProviderAddress = 0x24a42fD28C976A61Df5D00D0599C34c4f90748c8; LendingPoolAddressesProvider aaveProvider; IERC20 private _underlyingAsset; // Token of the deposited asset aTokenContract private _aToken; // The aToken returned to this contract by depositing address public treasuryAddress;
address public aaveProviderAddress = 0x24a42fD28C976A61Df5D00D0599C34c4f90748c8; LendingPoolAddressesProvider aaveProvider; IERC20 private _underlyingAsset; // Token of the deposited asset aTokenContract private _aToken; // The aToken returned to this contract by depositing address public treasuryAddress;
11,230
281
// Maps hash of unique request params {identifier, timestamp, ancillary data} to customizable variables such as reward and bond amounts.
mapping(bytes32 => bytes32) public requests;
mapping(bytes32 => bytes32) public requests;
32,581
57
// Remove minting rights after it has transferred the cDAI funds to `_avatar`Only the Avatar can execute this method /
function end() public { _onlyAvatar(); // remaining cDAI tokens in the current reserve contract if (ERC20(cDaiAddress).balanceOf(address(this)) > 0) { require( ERC20(cDaiAddress).transfer( address(avatar), ERC20(cDaiAddress).balanceOf(address(this)) ), "recover transfer failed" ); } //restore minting to avatar, so he can re-delegate it IGoodDollar gd = IGoodDollar(nameService.getAddress("GOODDOLLAR")); if (gd.isMinter(address(avatar)) == false) gd.addMinter(address(avatar)); IGoodDollar(nameService.getAddress("GOODDOLLAR")).renounceMinter(); }
function end() public { _onlyAvatar(); // remaining cDAI tokens in the current reserve contract if (ERC20(cDaiAddress).balanceOf(address(this)) > 0) { require( ERC20(cDaiAddress).transfer( address(avatar), ERC20(cDaiAddress).balanceOf(address(this)) ), "recover transfer failed" ); } //restore minting to avatar, so he can re-delegate it IGoodDollar gd = IGoodDollar(nameService.getAddress("GOODDOLLAR")); if (gd.isMinter(address(avatar)) == false) gd.addMinter(address(avatar)); IGoodDollar(nameService.getAddress("GOODDOLLAR")).renounceMinter(); }
4,882
13
// 最高价的地址
address private hightAddress; address owenr;
address private hightAddress; address owenr;
27,709
1
// 증가하는 카운터의 객체를 만들어서 작동
function incrementCounter() public { counter++; }
function incrementCounter() public { counter++; }
17,710
104
// Amount of USDC received in presale
uint256 usdcReceived = 0; uint256 HardCap = 85000 * 10 ** 18; // 85,000 event TokenBuy(address user, uint256 tokens); event TokenClaim(address user, uint256 tokens); constructor( address _ARBI, address _USDC
uint256 usdcReceived = 0; uint256 HardCap = 85000 * 10 ** 18; // 85,000 event TokenBuy(address user, uint256 tokens); event TokenClaim(address user, uint256 tokens); constructor( address _ARBI, address _USDC
20,959
668
// 336
entry "giustamente" : ENG_ADVERB
entry "giustamente" : ENG_ADVERB
21,172
72
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) {
uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) {
20,988
26
// Reset token on market - remove
delete market[tokenId];
delete market[tokenId];
27,689
12
// Wrong Send Various Tokens
function returnVariousTokenFromContract(address tokenAddress) public returns (bool success) { require(msg.sender == owner); ERC20 tempToken = ERC20(tokenAddress); tempToken.transfer(msg.sender, tempToken.balanceOf(address(this))); return true; }
function returnVariousTokenFromContract(address tokenAddress) public returns (bool success) { require(msg.sender == owner); ERC20 tempToken = ERC20(tokenAddress); tempToken.transfer(msg.sender, tempToken.balanceOf(address(this))); return true; }
56,996
37
// Delphy token total supply
uint public constant TOTAL_TOKENS = 100000000 * 10**18; // 1e
uint public constant TOTAL_TOKENS = 100000000 * 10**18; // 1e
30,879
208
// modify the fees applied to a parity of tokens (tokens can be TREX or ERC20)_token1 the address of the base token for the parity `_token1`/`_token2`_token2 the address of the counterpart token for the parity `_token1`/`_token2`_fee1 the fee to apply on `_token1` leg of the DVD transfer per 10^`_feeBase`_fee2 the fee to apply on `_token2` leg of the DVD transfer per 10^`_feeBase`_feeBase the precision of the fee setting, e.g. if `_feeBase` == 2 then `_fee1` and `_fee2` are in % (fee/10^`_feeBase`)_fee1Wallet the wallet address receiving fees applied on `_token1`_fee2Wallet the wallet address receiving fees applied on `_token2` `_token1` and `_token2` need
function modifyFee(address _token1, address _token2, uint _fee1, uint _fee2, uint _feeBase, address _fee1Wallet, address _fee2Wallet) external { require(msg.sender == owner() || isTREXOwner(_token1, msg.sender) || isTREXOwner(_token2, msg.sender), 'Ownable: only owner can call'); require(IERC20(_token1).totalSupply() != 0 && IERC20(_token2).totalSupply() != 0, 'invalid address : address is not an ERC20'); require(_fee1 <= 10**_feeBase && _fee1 >= 0 && _fee2 <= 10**_feeBase && _fee2 >= 0 && _feeBase <= 5 && _feeBase >= 2, 'invalid fee settings'); if (_fee1 > 0) { require(_fee1Wallet != address(0), 'fee wallet 1 cannot be zero address'); } if (_fee2 > 0) { require(_fee2Wallet != address(0), 'fee wallet 2 cannot be zero address'); } bytes32 _parity = calculateParity(_token1, _token2); Fee memory parityFee; parityFee.token1Fee = _fee1; parityFee.token2Fee = _fee2; parityFee.feeBase = _feeBase; parityFee.fee1Wallet = _fee1Wallet; parityFee.fee2Wallet = _fee2Wallet; fee[_parity] = parityFee; emit FeeModified(_parity, _token1, _token2, _fee1, _fee2, _feeBase, _fee1Wallet, _fee2Wallet); bytes32 _reflectParity = calculateParity(_token2, _token1); Fee memory reflectParityFee; reflectParityFee.token1Fee = _fee2; reflectParityFee.token2Fee = _fee1; reflectParityFee.feeBase = _feeBase; reflectParityFee.fee1Wallet = _fee2Wallet; reflectParityFee.fee2Wallet = _fee1Wallet; fee[_reflectParity] = reflectParityFee; emit FeeModified(_reflectParity, _token2, _token1, _fee2, _fee1, _feeBase, _fee2Wallet, _fee1Wallet); }
function modifyFee(address _token1, address _token2, uint _fee1, uint _fee2, uint _feeBase, address _fee1Wallet, address _fee2Wallet) external { require(msg.sender == owner() || isTREXOwner(_token1, msg.sender) || isTREXOwner(_token2, msg.sender), 'Ownable: only owner can call'); require(IERC20(_token1).totalSupply() != 0 && IERC20(_token2).totalSupply() != 0, 'invalid address : address is not an ERC20'); require(_fee1 <= 10**_feeBase && _fee1 >= 0 && _fee2 <= 10**_feeBase && _fee2 >= 0 && _feeBase <= 5 && _feeBase >= 2, 'invalid fee settings'); if (_fee1 > 0) { require(_fee1Wallet != address(0), 'fee wallet 1 cannot be zero address'); } if (_fee2 > 0) { require(_fee2Wallet != address(0), 'fee wallet 2 cannot be zero address'); } bytes32 _parity = calculateParity(_token1, _token2); Fee memory parityFee; parityFee.token1Fee = _fee1; parityFee.token2Fee = _fee2; parityFee.feeBase = _feeBase; parityFee.fee1Wallet = _fee1Wallet; parityFee.fee2Wallet = _fee2Wallet; fee[_parity] = parityFee; emit FeeModified(_parity, _token1, _token2, _fee1, _fee2, _feeBase, _fee1Wallet, _fee2Wallet); bytes32 _reflectParity = calculateParity(_token2, _token1); Fee memory reflectParityFee; reflectParityFee.token1Fee = _fee2; reflectParityFee.token2Fee = _fee1; reflectParityFee.feeBase = _feeBase; reflectParityFee.fee1Wallet = _fee2Wallet; reflectParityFee.fee2Wallet = _fee1Wallet; fee[_reflectParity] = reflectParityFee; emit FeeModified(_reflectParity, _token2, _token1, _fee2, _fee1, _feeBase, _fee2Wallet, _fee1Wallet); }
71,333
463
// Returns the rate scalar scaled by time to maturity. The rate scalar multiplies/ the ln() portion of the liquidity curve as an inverse so it increases with time to/ maturity. The effect of the rate scalar on slippage must decrease with time to maturity.
function getRateScalar( CashGroupParameters memory cashGroup, uint256 marketIndex, uint256 timeToMaturity
function getRateScalar( CashGroupParameters memory cashGroup, uint256 marketIndex, uint256 timeToMaturity
64,977
70
// Transfer the tokens from the crowdsale supply to the sender
if (tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens)) { FundTransfer(msg.sender, amount, true); uint balanceToSend = this.balance; beneficiary.transfer(balanceToSend); FundTransfer(beneficiary, balanceToSend, false);
if (tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens)) { FundTransfer(msg.sender, amount, true); uint balanceToSend = this.balance; beneficiary.transfer(balanceToSend); FundTransfer(beneficiary, balanceToSend, false);
5,667
250
// Returns the number of decimals used for the token /
function decimals() external view returns (uint8);
function decimals() external view returns (uint8);
19,483
125
// reject buy tokens requestnonce request recorded at this particular noncereason reason for rejection/
function rejectMint(uint256 nonce, uint256 reason) external onlyValidator checkIsAddressValid(pendingMints[nonce].to)
function rejectMint(uint256 nonce, uint256 reason) external onlyValidator checkIsAddressValid(pendingMints[nonce].to)
30,428
2
// the function to verify merkle leaf tokenDataLeaf_ the abi encoded token parameters bundle_ the encoded transaction bundle with encoded salt originHash_ the keccak256 hash of abi.encodePacked(origin chain name . origin tx hash . event nonce) receiver_ the address who will receive tokens proof_ the abi encoded merkle path with the signature of a merkle root the signer signed /
function verifyMerkleLeaf( bytes memory tokenDataLeaf_, IBundler.Bundle calldata bundle_, bytes32 originHash_, address receiver_, bytes calldata proof_ ) external;
function verifyMerkleLeaf( bytes memory tokenDataLeaf_, IBundler.Bundle calldata bundle_, bytes32 originHash_, address receiver_, bytes calldata proof_ ) external;
32,998
34
// Publish restore request to the blockchain. Pass swarm link to the video which will be used to identify requester as owner of this (lost) account./ Pass along with the function call some ether, the amount should be greater then price for a single escrows' vote.
function restoreAccess(string bzzVideo) payable public { /// Check that passed money is greater than price for a single escrow's vote require(msg.value >= restoreAccessPrice); /// Set calling address as restore address to which funds will be transfered upon successful restore. restoreAddress = msg.sender; /// Set start timer for escrows to be able to vote and unlock money. Part of fraud protection mechanism. restoreRequestTime = now; /// Publish event that contains address for restoring funds and video for decentralized identification /// Escrows are watching for this event on their client apps and use the data supplied with this event to participate in the identification NYXDecentralizedIdentificationRequest(msg.sender, bzzVideo); }
function restoreAccess(string bzzVideo) payable public { /// Check that passed money is greater than price for a single escrow's vote require(msg.value >= restoreAccessPrice); /// Set calling address as restore address to which funds will be transfered upon successful restore. restoreAddress = msg.sender; /// Set start timer for escrows to be able to vote and unlock money. Part of fraud protection mechanism. restoreRequestTime = now; /// Publish event that contains address for restoring funds and video for decentralized identification /// Escrows are watching for this event on their client apps and use the data supplied with this event to participate in the identification NYXDecentralizedIdentificationRequest(msg.sender, bzzVideo); }
12,659
25
// Numero aleatorio
uint randNonce = 0;
uint randNonce = 0;
2,146
246
// This function must be called when the ENS Manager contract is replacedand the address of the new Manager should be provided. _newOwner The address of the new ENS manager that will manage the root node. /
function changeRootnodeOwner(address _newOwner) external override onlyOwner { getENSRegistry().setOwner(rootNode, _newOwner); emit RootnodeOwnerChange(rootNode, _newOwner); }
function changeRootnodeOwner(address _newOwner) external override onlyOwner { getENSRegistry().setOwner(rootNode, _newOwner); emit RootnodeOwnerChange(rootNode, _newOwner); }
16,031
245
// Claim all the COMP accrued by holder in all markets
function claimComp(address holder) external;
function claimComp(address holder) external;
18,773
191
// Backup
let temp1 := mload(pos1) let temp2 := mload(pos2) let temp3 := mload(pos3) let temp4 := mload(pos4) let temp5 := mload(pos5)
let temp1 := mload(pos1) let temp2 := mload(pos2) let temp3 := mload(pos3) let temp4 := mload(pos4) let temp5 := mload(pos5)
28,675
48
// Note that the owner doesn't get to claim a fee until the game is won.
ownerFee = this.balance - prizePool;
ownerFee = this.balance - prizePool;
11,438
469
// If the position has more than the required collateral it is solvent and the dispute is valid(liquidation is invalid) Note that this check uses the liquidatedCollateral not the lockedCollateral as this considers withdrawals.
bool disputeSucceeded = liquidation.liquidatedCollateral.isGreaterThanOrEqual(requiredCollateral); liquidation.state = disputeSucceeded ? Status.DisputeSucceeded : Status.DisputeFailed; emit DisputeSettled( msg.sender, sponsor, liquidation.liquidator, liquidation.disputer, liquidationId, disputeSucceeded
bool disputeSucceeded = liquidation.liquidatedCollateral.isGreaterThanOrEqual(requiredCollateral); liquidation.state = disputeSucceeded ? Status.DisputeSucceeded : Status.DisputeFailed; emit DisputeSettled( msg.sender, sponsor, liquidation.liquidator, liquidation.disputer, liquidationId, disputeSucceeded
12,075
22
// Save the updated NFT back to storage after packing
_poolNFTs[nftAddress][nftId] = fromBigPoolNFT(bigPoolNFT);
_poolNFTs[nftAddress][nftId] = fromBigPoolNFT(bigPoolNFT);
9,082
42
// only by Goldmint contract
function finishIco() public onlyIcoContract { icoIsFinishedDate = uint64(now); }
function finishIco() public onlyIcoContract { icoIsFinishedDate = uint64(now); }
21,908
4
// lib/dss-interfaces/src/dss/VatAbstract.sol/ pragma solidity >=0.5.12; / https:github.com/makerdao/dss/blob/master/src/vat.sol
interface VatAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function can(address, address) external view returns (uint256); function hope(address) external; function nope(address) external; function ilks(bytes32) external view returns (uint256, uint256, uint256, uint256, uint256); function urns(bytes32, address) external view returns (uint256, uint256); function gem(bytes32, address) external view returns (uint256); function dai(address) external view returns (uint256); function sin(address) external view returns (uint256); function debt() external view returns (uint256); function vice() external view returns (uint256); function Line() external view returns (uint256); function live() external view returns (uint256); function init(bytes32) external; function file(bytes32, uint256) external; function file(bytes32, bytes32, uint256) external; function cage() external; function slip(bytes32, address, int256) external; function flux(bytes32, address, address, uint256) external; function move(address, address, uint256) external; function frob(bytes32, address, address, address, int256, int256) external; function fork(bytes32, address, address, int256, int256) external; function grab(bytes32, address, address, address, int256, int256) external; function heal(uint256) external; function suck(address, address, uint256) external; function fold(bytes32, address, int256) external; }
interface VatAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function can(address, address) external view returns (uint256); function hope(address) external; function nope(address) external; function ilks(bytes32) external view returns (uint256, uint256, uint256, uint256, uint256); function urns(bytes32, address) external view returns (uint256, uint256); function gem(bytes32, address) external view returns (uint256); function dai(address) external view returns (uint256); function sin(address) external view returns (uint256); function debt() external view returns (uint256); function vice() external view returns (uint256); function Line() external view returns (uint256); function live() external view returns (uint256); function init(bytes32) external; function file(bytes32, uint256) external; function file(bytes32, bytes32, uint256) external; function cage() external; function slip(bytes32, address, int256) external; function flux(bytes32, address, address, uint256) external; function move(address, address, uint256) external; function frob(bytes32, address, address, address, int256, int256) external; function fork(bytes32, address, address, int256, int256) external; function grab(bytes32, address, address, address, int256, int256) external; function heal(uint256) external; function suck(address, address, uint256) external; function fold(bytes32, address, int256) external; }
9,882
1
// Add scene
function addScene(address _scene) public returns (bool) { if (!AddressArray.exist(_scene, scenes)) scenes.push(_scene); return true; }
function addScene(address _scene) public returns (bool) { if (!AddressArray.exist(_scene, scenes)) scenes.push(_scene); return true; }
2,468
112
// Verify merkle proof for address and address minting limit /
function verifyMerkleAddress( bytes32[] calldata merkleProof, bytes32 _merkleRoot, address minterAddress, uint256 walletLimit
function verifyMerkleAddress( bytes32[] calldata merkleProof, bytes32 _merkleRoot, address minterAddress, uint256 walletLimit
26,064
182
// Price calculation when price is decreased linearly in proportion to time:/`duration` The number of seconds after the start of the auction where the price will hit 0/ Note the internal call to mul multiples by WAD, thereby ensuring that the wmul calculation/ which utilizes startPrice and duration (WAD values) is also a WAD value./startPrice: Initial price [wad]/time Current seconds since the start of the auction [seconds]/ return Returns y = startPrice((duration - time) / duration)
function price(uint256 startPrice, uint256 time) external view override returns (uint256) { if (time >= duration) return 0; return wmul(startPrice, wdiv(sub(duration, time), duration)); }
function price(uint256 startPrice, uint256 time) external view override returns (uint256) { if (time >= duration) return 0; return wmul(startPrice, wdiv(sub(duration, time), duration)); }
44,445
63
// Freezable token Add ability froze accounts /
contract FreezableToken is MintableToken { mapping(address => bool) public frozenAccounts; event FrozenFunds(address target, bool frozen); /** * @dev Freze account */ function freezeAccount(address target, bool freeze) public onlyOwnerOrAdmin { frozenAccounts[target] = freeze; emit FrozenFunds(target, freeze); } /** * @dev Ovveride base method _transfer from base ERC20 contract */ function _transfer(address _from, address _to, uint256 value) internal { require(_to != address(0x0), "FreezableToken: transfer to the zero address"); require(_balances[_from] >= value, "FreezableToken: balance _from must br bigger than value"); require(_balances[_to] + value >= _balances[_to], "FreezableToken: balance to must br bigger than current balance"); require(!frozenAccounts[_from], "FreezableToken: account _from is frozen"); require(!frozenAccounts[_to], "FreezableToken: account _to is frozen"); _balances[_from] = _balances[_from].sub(value); _balances[_to] = _balances[_to].add(value); emit Transfer(_from, _to, value); } }
contract FreezableToken is MintableToken { mapping(address => bool) public frozenAccounts; event FrozenFunds(address target, bool frozen); /** * @dev Freze account */ function freezeAccount(address target, bool freeze) public onlyOwnerOrAdmin { frozenAccounts[target] = freeze; emit FrozenFunds(target, freeze); } /** * @dev Ovveride base method _transfer from base ERC20 contract */ function _transfer(address _from, address _to, uint256 value) internal { require(_to != address(0x0), "FreezableToken: transfer to the zero address"); require(_balances[_from] >= value, "FreezableToken: balance _from must br bigger than value"); require(_balances[_to] + value >= _balances[_to], "FreezableToken: balance to must br bigger than current balance"); require(!frozenAccounts[_from], "FreezableToken: account _from is frozen"); require(!frozenAccounts[_to], "FreezableToken: account _to is frozen"); _balances[_from] = _balances[_from].sub(value); _balances[_to] = _balances[_to].add(value); emit Transfer(_from, _to, value); } }
5,178
7
// per currency, an array of historical balances
mapping(address => Utils.Balance[]) historicalBalance;
mapping(address => Utils.Balance[]) historicalBalance;
30,470
17
// Withdraw ETH to Layer 1 - register withdrawal and transfer ether to sender/_amount Ether amount to withdraw
function withdrawETH(uint128 _amount) external nonReentrant { registerWithdrawal(0, _amount, msg.sender); (bool success, ) = msg.sender.call.value(_amount)(""); require(success, "fwe11"); // ETH withdraw failed }
function withdrawETH(uint128 _amount) external nonReentrant { registerWithdrawal(0, _amount, msg.sender); (bool success, ) = msg.sender.call.value(_amount)(""); require(success, "fwe11"); // ETH withdraw failed }
7,084
313
// Wrapper around {_mintRandomIndex} that incrementally if the collection has not been revealed yet, which also checks the buyer has not exceeded maxMint count/
function _mintRandom(address buyer, uint256 amount) internal { require(maxMint == 0 || mintCount[buyer] + amount <= maxMint, "Buyer over mint maximum"); mintCount[buyer] += amount; if (isRevealed) { _mintRandomIndex(buyer, amount); return; }
function _mintRandom(address buyer, uint256 amount) internal { require(maxMint == 0 || mintCount[buyer] + amount <= maxMint, "Buyer over mint maximum"); mintCount[buyer] += amount; if (isRevealed) { _mintRandomIndex(buyer, amount); return; }
38,541
16
// randYish Description: Kind-of-random number generator. Seed based on blockchain conditions: - difficulty - miner's address - gas limit - sender's address - block number - `puppersRemaining` Notes: - https:stackoverflow.com/questions/58188832/solidity-generate-unpredictable-random-number-that-does-not-depend-on-input
function randYish() public view returns (uint256 ret) { uint256 seed = uint256(keccak256(abi.encodePacked( block.timestamp + block.difficulty + ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (block.timestamp)) + block.gaslimit + ((uint256(keccak256(abi.encodePacked(_msgSender())))) / (block.timestamp)) + block.number + puppersRemaining ))); ret = seed; }
function randYish() public view returns (uint256 ret) { uint256 seed = uint256(keccak256(abi.encodePacked( block.timestamp + block.difficulty + ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (block.timestamp)) + block.gaslimit + ((uint256(keccak256(abi.encodePacked(_msgSender())))) / (block.timestamp)) + block.number + puppersRemaining ))); ret = seed; }
66,935
13
// EIP2981 standard Interface return. Adds to ERC721 and ERC165 Interface returns.
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, IERC165) returns (bool)
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, IERC165) returns (bool)
22,586
55
// Indicating if unstaking early is allowed or not This is used to upgrade liquidity to uniswap v3
bool public override unstakeEarlyAllowed;
bool public override unstakeEarlyAllowed;
10,321
0
// the following variables need to be here for scoping to properly freeze normal transfers after migration has started migrationStart flag
bool public migrationStart;
bool public migrationStart;
46,129
118
// Validates the fallback withdrawal data and updates state to reflect the transfer _partition Source partition of the withdrawal _operator Address that is invoking the transfer _value Number of tokens to be transferred _operatorData Contains the fallback withdrawal authorization data /
function _executeFallbackWithdrawal( bytes32 _partition, address _operator, uint256 _value, bytes memory _operatorData
function _executeFallbackWithdrawal( bytes32 _partition, address _operator, uint256 _value, bytes memory _operatorData
9,183