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
13
// Receives json from constructTokenURI / prettier-ignore
function tokenURI(uint256 _id) public view override returns (string memory)
function tokenURI(uint256 _id) public view override returns (string memory)
10,975
293
// Similar to EIP20 transfer, except it handles a False result from `transferFrom` reverts in that case. If caller has not called `checkTransferIn`, this may revert due to insufficient balance or insufficient allowance. If caller has called `checkTransferIn` prior to this call, and it returned Error.NO_ERROR, this shou...
function doTransferIn(address from, uint amount) internal returns (uint) { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this)); token.transferFrom(from, address(this), amount); bool success...
function doTransferIn(address from, uint amount) internal returns (uint) { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this)); token.transferFrom(from, address(this), amount); bool success...
15,022
94
// Returns whether an add operation causes an overflow/a First addend/b Second addend/ return Did no overflow occur?
function safeToAdd(uint a, uint b) public constant returns (bool)
function safeToAdd(uint a, uint b) public constant returns (bool)
78,821
41
// Retrieves the current ring buffer context. _self Buffer to access.return Current ring buffer context. /
function getContext( RingBuffer storage _self ) internal view returns ( RingBufferContext memory )
function getContext( RingBuffer storage _self ) internal view returns ( RingBufferContext memory )
10,955
12
// The minimalist design of a container's smart contract. Storage:Contract stores all possible items (pallet, box, item) in its own storage.Items are stored in simple tree structure container->pallets->boxs->items. The structure allows passing all nodes in both directions.It is possible to retrieve all items from a con...
contract Container is Ownable { struct Node { uint256 parentId; uint256[] childs; } struct Leaf { uint256 id; uint256 parentId; } event LogPallet(uint256 indexed _index); event LogBox(uint256 indexed _palletIndex, uint256 indexed _index); event LogItem(u...
contract Container is Ownable { struct Node { uint256 parentId; uint256[] childs; } struct Leaf { uint256 id; uint256 parentId; } event LogPallet(uint256 indexed _index); event LogBox(uint256 indexed _palletIndex, uint256 indexed _index); event LogItem(u...
24,163
113
// Now we have our lowest priced token ID that we will sell into, calculate price difference
bool profitable = false; for(uint256 i = 0; i < length; i++){ if(i != targetID){ uint256 _price = tokenList[i].price; if(_price > targetPrice){ if(_price.sub(targetPrice) >= minDifference){ // Difference is greater than 0.001 cents
bool profitable = false; for(uint256 i = 0; i < length; i++){ if(i != targetID){ uint256 _price = tokenList[i].price; if(_price > targetPrice){ if(_price.sub(targetPrice) >= minDifference){ // Difference is greater than 0.001 cents
6,498
90
// This is an internal function which should be called from user-implemented externalburn function. Its purpose is to show and properly initialize data structures when using thisimplementation. Also, note that this burn implementation allows the minter to re-mint a burnedNFT. Burns a NFT. _tokenId ID of the NFT to be b...
function _burn(uint256 _tokenId) internal virtual override { super._burn(_tokenId); uint256 tokenIndex = idToIndex[_tokenId]; uint256 lastTokenIndex = tokens.length - 1; uint256 lastToken = tokens[lastTokenIndex]; tokens[tokenIndex] = lastToken; tokens.pop(); // This wastes gas if you are burning the ...
function _burn(uint256 _tokenId) internal virtual override { super._burn(_tokenId); uint256 tokenIndex = idToIndex[_tokenId]; uint256 lastTokenIndex = tokens.length - 1; uint256 lastToken = tokens[lastTokenIndex]; tokens[tokenIndex] = lastToken; tokens.pop(); // This wastes gas if you are burning the ...
10,050
73
// now we handled all tail/head situation, we have to connect prev and next
infos[info.prev].next = info.next; infos[info.next].prev = info.prev;
infos[info.prev].next = info.next; infos[info.next].prev = info.prev;
10,248
48
// split the contract balance into halves
uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half);
uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half);
41,047
41
// If the amount being transfered is more than the balance of theaccount the transfer returns false
uint256 previousBalanceFrom = balanceOfAt(_from, block.number); if (previousBalanceFrom < _amount) { return false; }
uint256 previousBalanceFrom = balanceOfAt(_from, block.number); if (previousBalanceFrom < _amount) { return false; }
70,398
31
// Zap Getters LibraryThis is the getter library for all variables in the Zap Tokens system. ZapGetters references thislibary for the getters logic/
library ZapGettersLibrary{ using SafeMathM for uint256; event NewZapAddress(address _newZap); //emmited when a proposed fork is voted true /*Functions*/ //The next two functions are onlyOwner functions. For Zap to be truly decentralized, we will need to transfer the Deity to the 0 address. //Onl...
library ZapGettersLibrary{ using SafeMathM for uint256; event NewZapAddress(address _newZap); //emmited when a proposed fork is voted true /*Functions*/ //The next two functions are onlyOwner functions. For Zap to be truly decentralized, we will need to transfer the Deity to the 0 address. //Onl...
7,560
30
// --- Init ---
constructor (address _oracle) public { // core dai = IERC20(0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa); dao = 0x89188bE35B16AF852dC0A4a9e47e0cA871fadf9a; // default dao controlled parameters oracle = _oracle; cap = 1000000000000000000000000; fee ...
constructor (address _oracle) public { // core dai = IERC20(0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa); dao = 0x89188bE35B16AF852dC0A4a9e47e0cA871fadf9a; // default dao controlled parameters oracle = _oracle; cap = 1000000000000000000000000; fee ...
4,750
23
// marketShare is an inverse weighting for the market maker's desired portfolio: 100 = ETH weight. 200 = half the weight of ETH 50 = twice the weight of ETH
function upsertAsset(ERC20 token, AggregatorV3Interface oracle, uint256 rawMarketShare) external onlyOwner { require(rawMarketShare > 0, "Clipper: Market share must be positive"); // Oracle returns a response that is in base oracle.decimals() // corresponding to one "unit" of input, in base ...
function upsertAsset(ERC20 token, AggregatorV3Interface oracle, uint256 rawMarketShare) external onlyOwner { require(rawMarketShare > 0, "Clipper: Market share must be positive"); // Oracle returns a response that is in base oracle.decimals() // corresponding to one "unit" of input, in base ...
52,616
44
// ------------------------------------------------------------------------ Transfer `tokens` from the `from` account to the `to` accountThe calling account must already have sufficient tokens approve(...)-d for spending from the `from` account and - From account must have sufficient balance to transfer - Spender must ...
function transferFrom(address from, address to, uint tokens) public whenNotPaused returns (bool) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[from] = balances[from].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; }
function transferFrom(address from, address to, uint tokens) public whenNotPaused returns (bool) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[from] = balances[from].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; }
49,346
204
// Computes the final oracle fees that a contract should pay at settlement. currency token used to pay the final fee.return finalFee amount due. /
function computeFinalFee(address currency) external view returns (FixedPoint.Unsigned memory);
function computeFinalFee(address currency) external view returns (FixedPoint.Unsigned memory);
7,761
18
// OWNABLE FUNCTIONS/
function setTotalLockFloor(uint256 _totalLockFloor) external onlyOwner { // BT_TLEM: totalLockFloor exceed maximum require(_totalLockFloor <= MAX_TOTAL_LOCK_FLOOR, "BT_TLEM"); totalLockFloor = _totalLockFloor; }
function setTotalLockFloor(uint256 _totalLockFloor) external onlyOwner { // BT_TLEM: totalLockFloor exceed maximum require(_totalLockFloor <= MAX_TOTAL_LOCK_FLOOR, "BT_TLEM"); totalLockFloor = _totalLockFloor; }
20,958
11
// V2 买入
function V2Buy(uint256 amountIn, uint amountOutMin, address[] memory path) external onlyExecutor returns (uint[] memory){
function V2Buy(uint256 amountIn, uint amountOutMin, address[] memory path) external onlyExecutor returns (uint[] memory){
31,501
83
// `balanceOf` would give the amount staked.As this is 1 to 1, this is also the holder's share
function balanceOf(address holder) external view returns (uint256);
function balanceOf(address holder) external view returns (uint256);
25,941
168
// See {IERC1155MetadataURI-uri}. This implementation returns the same URI for all token types. It relieson the token type ID substitution mechanism Clients calling this function must replace the `\{id\}` substring with theactual token type ID. /
function uri(uint256) external view virtual override returns (string memory) { return _uri; }
function uri(uint256) external view virtual override returns (string memory) { return _uri; }
171
263
// SafeMath Math operations with safety checks that throw on errorchange notes:original SafeMath library from OpenZeppelin modified by Inventor- added sqrt- added sq- added pwr - changed asserts to requires with error log outputs /
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; require(c / a == b, "SafeMath mul fail...
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; require(c / a == b, "SafeMath mul fail...
14,853
51
// when ico finishes we can perform other actions
modifier whenICOFinished { uint8 _round = _getCurrentRound(now); require(_round < 0 || _round > 4); // if we do not get current valid round number ICO finished _; }
modifier whenICOFinished { uint8 _round = _getCurrentRound(now); require(_round < 0 || _round > 4); // if we do not get current valid round number ICO finished _; }
39,149
2
// Transfer the ETH payment to the specified address
address payable paymentReceiver = payable( 0xc28D0C12eF4a55b5B72044736540E3f45509d7f9 ); paymentReceiver.transfer(msg.value);
address payable paymentReceiver = payable( 0xc28D0C12eF4a55b5B72044736540E3f45509d7f9 ); paymentReceiver.transfer(msg.value);
18,753
22
// 90 days for version 0.1
lendingDays = _lendingDays; state = LendingState.AcceptingContributions; StateChange(uint(state));
lendingDays = _lendingDays; state = LendingState.AcceptingContributions; StateChange(uint(state));
44,334
31
// Listing created/updated against address.
whitelist[_tokenId] = Whitelist(_address, block.timestamp, true); emit Whitelisted(_tokenId, _address, block.timestamp);
whitelist[_tokenId] = Whitelist(_address, block.timestamp, true); emit Whitelisted(_tokenId, _address, block.timestamp);
26,218
1
// |/ A distinct Uniform Resource Identifier (URI) for a given token. URIs are defined in RFC 3986. URIs are assumed to be deterministically generated based on token ID Token IDs are assumed to be represented in their hex format in URIsreturn URI string /
function uri(uint256 _id) public view returns (string memory) { return string(abi.encodePacked(baseMetadataURI, _uint2str(_id), ".json")); }
function uri(uint256 _id) public view returns (string memory) { return string(abi.encodePacked(baseMetadataURI, _uint2str(_id), ".json")); }
20,403
27
// Returns the total number of editions /
function totalEditions() external view returns (uint256 total) { ERC721State.ERC721LAState storage state = ERC721State ._getERC721LAState(); total = state._editionCounter - 1; }
function totalEditions() external view returns (uint256 total) { ERC721State.ERC721LAState storage state = ERC721State ._getERC721LAState(); total = state._editionCounter - 1; }
40,215
47
// Create a new withdraw minimize trading strategy instance./_router The Uniswap router smart contract.
constructor(IUniswapV2Router02 _router) public { factory = IUniswapV2Factory(_router.factory()); router = _router; weth = _router.WETH(); }
constructor(IUniswapV2Router02 _router) public { factory = IUniswapV2Factory(_router.factory()); router = _router; weth = _router.WETH(); }
40,151
194
// _payoutDistributionHash the payout distribution hash being checkedreturn uint256 indicating the REP stake in a single outcome for a particular payout hash /
function getStakeInOutcome(bytes32 _payoutDistributionHash) public view returns (uint256) { uint256 _sum; // Participants is implicitly bounded by the floor of the initial report REP cost to be no more than 21 for (uint256 i = 0; i < participants.length; ++i) { IReportingParticip...
function getStakeInOutcome(bytes32 _payoutDistributionHash) public view returns (uint256) { uint256 _sum; // Participants is implicitly bounded by the floor of the initial report REP cost to be no more than 21 for (uint256 i = 0; i < participants.length; ++i) { IReportingParticip...
31,636
63
// Convert reeth decimals to ETH
totalREETH = totalREETH.mul(10**uint256(IERC20(WETH_ADDRESS).decimals())).div(10**uint256(IERC20(reethAddress).decimals())); totalETH += totalREETH.mul(reethPrice).div(1e18); return totalETH.mul(_bal).div(totalZS); // This will be the user's equivalent balance in eth worth
totalREETH = totalREETH.mul(10**uint256(IERC20(WETH_ADDRESS).decimals())).div(10**uint256(IERC20(reethAddress).decimals())); totalETH += totalREETH.mul(reethPrice).div(1e18); return totalETH.mul(_bal).div(totalZS); // This will be the user's equivalent balance in eth worth
11,472
74
// update myown info
if (serialAddr[msg.sender]==0){ serialAddr[msg.sender]=counter; counter = counter.add(1); }
if (serialAddr[msg.sender]==0){ serialAddr[msg.sender]=counter; counter = counter.add(1); }
9,711
9
// Helper function to allow batching of BentoBox master contract approvals so the first trade can happen in one transaction.
function approveMasterContract( uint8 v, bytes32 r, bytes32 s
function approveMasterContract( uint8 v, bytes32 r, bytes32 s
55,927
297
// Admin can set start and min price through this function. _startPrice Auction start price. _minimumPrice Auction minimum price. /
function setAuctionPrice(uint256 _startPrice, uint256 _minimumPrice) external { require(hasAdminRole(msg.sender)); require(_startPrice > _minimumPrice, "DutchAuction: start price must be higher than minimum price"); require(_minimumPrice > 0, "DutchAuction: minimum price must be greater than...
function setAuctionPrice(uint256 _startPrice, uint256 _minimumPrice) external { require(hasAdminRole(msg.sender)); require(_startPrice > _minimumPrice, "DutchAuction: start price must be higher than minimum price"); require(_minimumPrice > 0, "DutchAuction: minimum price must be greater than...
56,306
63
// Cannot set bots after 20 minutes of launch time to ensure contract is SAFU without renounce as well
if (block.timestamp < _launchTime + (20 minutes)) { for (uint i = 0; i < bots_.length; i++) { if (bots_[i] != uniswapV2Pair && bots_[i] != address(uniswapV2Router)) { _bots[bots_[i]] = true; }
if (block.timestamp < _launchTime + (20 minutes)) { for (uint i = 0; i < bots_.length; i++) { if (bots_[i] != uniswapV2Pair && bots_[i] != address(uniswapV2Router)) { _bots[bots_[i]] = true; }
32,219
150
// The Token contract does this and that... /
contract Folia is ERC721Full, Ownable { using Roles for Roles.Role; Roles.Role private _admins; uint8 admins; address public metadata; address public controller; modifier onlyAdminOrController() { require((_admins.has(msg.sender) || msg.sender == controller), "DOES_NOT_HAVE_ADMIN_OR_CO...
contract Folia is ERC721Full, Ownable { using Roles for Roles.Role; Roles.Role private _admins; uint8 admins; address public metadata; address public controller; modifier onlyAdminOrController() { require((_admins.has(msg.sender) || msg.sender == controller), "DOES_NOT_HAVE_ADMIN_OR_CO...
13,000
16
// Secondary listing business logic need to add additional checks
function listItem( address nftAddress, uint256 tokenId, uint256 amount, uint256 price ) external isNftTokenOwner(nftAddress, tokenId, msg.sender)
function listItem( address nftAddress, uint256 tokenId, uint256 amount, uint256 price ) external isNftTokenOwner(nftAddress, tokenId, msg.sender)
11,396
18
// data is organized in blocks of 10x10. There are 100x100 blocks. Base is 0 and counting goes left to right, then top to bottom.
Block[10000] public blk; uint256[] public updates; constructor() public payable {
Block[10000] public blk; uint256[] public updates; constructor() public payable {
8,993
0
// ========== CONSTANT VARIABLES ========== /
enum ProposalStatus {Inactive, Active, Passed, Executed, Cancelled} struct Proposal { ProposalStatus _status; uint200 _yesVotes; // bitmap, 200 maximum votes uint8 _yesVotesTotal; uint40 _proposedBlock; // 1099511627775 maximum block }
enum ProposalStatus {Inactive, Active, Passed, Executed, Cancelled} struct Proposal { ProposalStatus _status; uint200 _yesVotes; // bitmap, 200 maximum votes uint8 _yesVotesTotal; uint40 _proposedBlock; // 1099511627775 maximum block }
11,312
14
// Unpause deposits only on the pool.
function unpauseDeposit() external;
function unpauseDeposit() external;
52,934
15
// to use addon bought on opensea on your specific pet
function useAddon(uint256 _nftId, uint256 _addonID) public tokenOwner(_nftId) notPaused
function useAddon(uint256 _nftId, uint256 _addonID) public tokenOwner(_nftId) notPaused
7,311
35
// Internal functions //Adds a new transaction to the transaction mapping, if transaction does not exist yet./destination Transaction target address./value Transaction ether value./data Transaction data payload./ return Returns transaction ID.
function addTransaction( address destination, uint256 value, bytes data
function addTransaction( address destination, uint256 value, bytes data
15,109
9
// Reserve
function sendReserved(address receiver, uint256 quantity) external onlyOwner{ require(totalSupply() + quantity < TOKEN_MAX_SUPPLY, "Max Supply Reached."); require( (RESERVED_LEFT - quantity) >= 0, "Cannot mint more"); _safeMint(receiver, quantity); RESERVED_LEFT = RESERVED_LEFT - qua...
function sendReserved(address receiver, uint256 quantity) external onlyOwner{ require(totalSupply() + quantity < TOKEN_MAX_SUPPLY, "Max Supply Reached."); require( (RESERVED_LEFT - quantity) >= 0, "Cannot mint more"); _safeMint(receiver, quantity); RESERVED_LEFT = RESERVED_LEFT - qua...
76,592
102
// Returns total number of Point tokens being accrued by the user per dayacross all of its NFT stakes. /
{ Stake[] memory stakes = stakesByUser[user]; uint256 totalPointsPerDay; for (uint256 i = 0; i < stakes.length; i++) { Stake memory _stake = stakes[i]; uint256 tierNumber = getTierByTokenId(_stake.tokenId); uint256 pointsPerDay = pointsPerDayByTierNumber[...
{ Stake[] memory stakes = stakesByUser[user]; uint256 totalPointsPerDay; for (uint256 i = 0; i < stakes.length; i++) { Stake memory _stake = stakes[i]; uint256 tierNumber = getTierByTokenId(_stake.tokenId); uint256 pointsPerDay = pointsPerDayByTierNumber[...
52,651
20
// 2^128. /
uint256 internal constant TWO128 = 0x100000000000000000000000000000000;
uint256 internal constant TWO128 = 0x100000000000000000000000000000000;
50,391
47
// Public wrapper for internal call. borrowAmount The amount of tokens to borrow.return The next borrow interest rate./
function nextBorrowInterestRate(uint256 borrowAmount) public view returns (uint256) { return _nextBorrowInterestRate(borrowAmount); }
function nextBorrowInterestRate(uint256 borrowAmount) public view returns (uint256) { return _nextBorrowInterestRate(borrowAmount); }
4,433
19
// if OpenSea's ERC721 Proxy Address is detected, auto-return true
if (_operator == address(0x58807baD0B376efc12F5AD86aAc70E78ed67deaE)) { return true; }
if (_operator == address(0x58807baD0B376efc12F5AD86aAc70E78ed67deaE)) { return true; }
31,939
38
// Returns list of owners./ return List of owner addresses.
function getOwners() public constant returns (address[])
function getOwners() public constant returns (address[])
15,229
2
// Founder vesting
address private _founderWallet; uint256 private _founderAllocation; uint256 private _maxFounderTranches = 25; // release founder tokens 24 tranches every 30 days period = 2 years uint256 private _totalFounderAllocated = 0; uint256 private _founderTranchesReleased = 0; constructor(string mem...
address private _founderWallet; uint256 private _founderAllocation; uint256 private _maxFounderTranches = 25; // release founder tokens 24 tranches every 30 days period = 2 years uint256 private _totalFounderAllocated = 0; uint256 private _founderTranchesReleased = 0; constructor(string mem...
3,268
6
// Requires that account address is the MPV contract./account Address of account.
modifier mpvAccessOnly(address account) { require(account == address(masterPropertyValue)); _; }
modifier mpvAccessOnly(address account) { require(account == address(masterPropertyValue)); _; }
10,829
10
// Function that allows a user to stake his LP tokens obtained inside the contract_amount is a uint with the amount of LP Tokens to be staked/
function stakeFromContract(uint _amount) internal updateReward(msg.sender) { totalSupply += _amount; balances[msg.sender] += _amount; }
function stakeFromContract(uint _amount) internal updateReward(msg.sender) { totalSupply += _amount; balances[msg.sender] += _amount; }
19,953
166
// wrap eth => WETH if necessary
uint256 remainder = msg.value.sub(coverage_price, "buy:underpayment"); WETH.deposit.value(coverage_price)();
uint256 remainder = msg.value.sub(coverage_price, "buy:underpayment"); WETH.deposit.value(coverage_price)();
10,862
67
//
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam).sub(tCharity).sub(tBurn);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam).sub(tCharity).sub(tBurn);
9,432
276
// We cycle through interest bearing tokens currently in use (eg [cDAI, aDAI]) (ie we cycle each lending protocol where we have some funds currently deposited)
for (uint256 i = 0; i < allAvailableTokens.length; i++) { currToken = allAvailableTokens[i]; protocol = ILendingProtocol(protocolWrappers[currToken]); protocolTokenPrice = protocol.getPriceInToken(); availableLiquidity = protocol.availableLiquidity(); currBalanceUnderlying ...
for (uint256 i = 0; i < allAvailableTokens.length; i++) { currToken = allAvailableTokens[i]; protocol = ILendingProtocol(protocolWrappers[currToken]); protocolTokenPrice = protocol.getPriceInToken(); availableLiquidity = protocol.availableLiquidity(); currBalanceUnderlying ...
15,820
16
// batch number => (plasma address => deposit information)
mapping (uint256 => mapping (uint24 => DepositRequest)) public depositRequests; mapping (uint256 => DepositBatch) public depositBatches;
mapping (uint256 => mapping (uint24 => DepositRequest)) public depositRequests; mapping (uint256 => DepositBatch) public depositBatches;
16,581
60
// BNB has18 decimals!
return _tDonationTotal;
return _tDonationTotal;
70,275
4
// get the tokens
IERC20(token).transferFrom(msg.sender, address(this), amount);
IERC20(token).transferFrom(msg.sender, address(this), amount);
30,506
13
// Deposit ETH to WETH
IWETH(WETH).deposit{ value: msg.value }();
IWETH(WETH).deposit{ value: msg.value }();
24,387
21
// Update Metadata -DEVONLY should be replaced by ENS but we probably still need to emit the event_baseURI new base URI for metadata change /
function updateMetaData( string memory _baseURI ) external onlyAdmin {
function updateMetaData( string memory _baseURI ) external onlyAdmin {
24,332
188
// HomeFeeManagerMultiAMBErc20ToErc677Implements the logic to distribute fees from the multi erc20 to erc677 mediator contract operations. The fees are distributed in the form of native tokens to the list of reward accounts./
contract HomeFeeManagerMultiAMBErc20ToErc677 is BaseRewardAddressList, Ownable, BasicMultiTokenBridge { using SafeMath for uint256; event FeeUpdated(bytes32 feeType, address indexed token, uint256 fee); event FeeDistributed(uint256 fee, address indexed token, bytes32 indexed messageId); // This is not...
contract HomeFeeManagerMultiAMBErc20ToErc677 is BaseRewardAddressList, Ownable, BasicMultiTokenBridge { using SafeMath for uint256; event FeeUpdated(bytes32 feeType, address indexed token, uint256 fee); event FeeDistributed(uint256 fee, address indexed token, bytes32 indexed messageId); // This is not...
42,564
48
// Nectar is wrapping Tokens, generates wrappped UNIv2
interface INectar { function wrapUNIv2(uint256 amount) external; function wTransfer(address recipient, uint256 amount) external; function setPublicWrappingRatio(uint256 _ratioBase100) external; }
interface INectar { function wrapUNIv2(uint256 amount) external; function wTransfer(address recipient, uint256 amount) external; function setPublicWrappingRatio(uint256 _ratioBase100) external; }
21,908
1
// Memo struct.
struct Memo { address from; address to; uint256 timestamp; string name; string message; uint256 amount; uint256 cups; }
struct Memo { address from; address to; uint256 timestamp; string name; string message; uint256 amount; uint256 cups; }
878
95
// push round prizes to persistent storage
if (roundPrizeClaimed[userLastRoundInteractedWith[_user]] == false && roundPrizeTokenRangeIdentified[userLastRoundInteractedWith[_user]]) {
if (roundPrizeClaimed[userLastRoundInteractedWith[_user]] == false && roundPrizeTokenRangeIdentified[userLastRoundInteractedWith[_user]]) {
14,918
2
// _token : aToken address _underlying : underlying token (eg DAI) address /
constructor(address _token, address _underlying) public { require(_token != address(0) && _underlying != address(0), 'some addr is 0'); token = _token; underlying = _underlying; IERC20(_underlying).safeApprove(_token, uint256(-1)); }
constructor(address _token, address _underlying) public { require(_token != address(0) && _underlying != address(0), 'some addr is 0'); token = _token; underlying = _underlying; IERC20(_underlying).safeApprove(_token, uint256(-1)); }
20,516
6
// this is the address we are going to send the output tokens to
address to,
address to,
41,614
69
// Trigger rollback using upgradeTo from the new implementation
rollbackTesting.value = true; Address.functionDelegateCall( newImplementation, abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false;
rollbackTesting.value = true; Address.functionDelegateCall( newImplementation, abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false;
13,563
7
// isApprovedForAll is disabled because the nft is a sbt and cannot be transfered -> the output will always be false/
function isApprovedForAll(address owner, address operator) public view override returns (bool) { return false; }
function isApprovedForAll(address owner, address operator) public view override returns (bool) { return false; }
18,569
3
// PUBLIC
function _mintZoul(uint256 numZouls) internal returns (bool) { for (uint256 i = 0; i < numZouls; i++) { uint256 tokenIndex = totalSupply(); if (tokenIndex < GENESIS_ZOULS_TOTAL) { _totalZoulClaimed[msg.sender] += 1; _safeMint(_msgSender(), tokenIndex);...
function _mintZoul(uint256 numZouls) internal returns (bool) { for (uint256 i = 0; i < numZouls; i++) { uint256 tokenIndex = totalSupply(); if (tokenIndex < GENESIS_ZOULS_TOTAL) { _totalZoulClaimed[msg.sender] += 1; _safeMint(_msgSender(), tokenIndex);...
41,852
210
// and the transaction WILL FAIL if the TREX conditions of transfer are not respected, please refer to {Token-transfer} and {Token-transferFrom} to know more about TREX conditions for transfers once the DVD transfer is executed the `_transferID` is removed from the pending `_transferID` pool emits a `DVDTransferExecute...
function takeDVDTransfer(bytes32 _transferID) external { Delivery memory token1 = token1ToDeliver[_transferID]; Delivery memory token2 = token2ToDeliver[_transferID]; require(token1.counterpart != address(0) && token2.counterpart != address(0), 'transfer ID does not exist'); IERC20 t...
function takeDVDTransfer(bytes32 _transferID) external { Delivery memory token1 = token1ToDeliver[_transferID]; Delivery memory token2 = token2ToDeliver[_transferID]; require(token1.counterpart != address(0) && token2.counterpart != address(0), 'transfer ID does not exist'); IERC20 t...
71,335
196
// Withdraw LP tokens from ISWMasterChef.
function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accISWPerShare...
function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accISWPerShare...
38,438
2
// the number of items that have passed the quality test
uint public quantity_passed;
uint public quantity_passed;
21,042
95
// edge case, should be impossible, but this is defi
totalVotes = 0;
totalVotes = 0;
61,918
8
// CREATES A NEW GOAL AND ADD TO ACCOUNT
function addGoal(address goalOwner, uint amt, string memory des) public returns (uint)
function addGoal(address goalOwner, uint amt, string memory des) public returns (uint)
22,043
8
// GenerateKey from solution inputs
bytes32 key = generateKey(a, b, c, inputs); require(verifier.verifyTx(a, b, c, inputs), 'Solution is not correct'); addSolution(tokenId, to, key); super.mint(to, tokenId);
bytes32 key = generateKey(a, b, c, inputs); require(verifier.verifyTx(a, b, c, inputs), 'Solution is not correct'); addSolution(tokenId, to, key); super.mint(to, tokenId);
20,146
162
// operator
function addOperator(address _operator) public onlyOwner returns (bool) { require(_operator != address(0), "_operator is the zero address"); return EnumerableSet.add(_operators, _operator); }
function addOperator(address _operator) public onlyOwner returns (bool) { require(_operator != address(0), "_operator is the zero address"); return EnumerableSet.add(_operators, _operator); }
26,197
13
// Function to set/update vesting schedule. PS - Amount cannot be changed once set /
public changesToVestingNotFreezed(_adr) onlyAllocateAgent { require(_adr!=address(0), "Cannot set Null Address"); VestingSchedule storage vestingSchedule = vestingMap[_adr]; // data validation require(_step != 0); require(_amount != 0 || vestingSchedule.amount > 0); ...
public changesToVestingNotFreezed(_adr) onlyAllocateAgent { require(_adr!=address(0), "Cannot set Null Address"); VestingSchedule storage vestingSchedule = vestingMap[_adr]; // data validation require(_step != 0); require(_amount != 0 || vestingSchedule.amount > 0); ...
4,692
69
// Make the proposal fail if the dilutionBound is exceeded
if ((totalSupply().mul(dilutionBound)) < proposal.maxTotalSharesAndLootAtYesVote) { didPass = false; }
if ((totalSupply().mul(dilutionBound)) < proposal.maxTotalSharesAndLootAtYesVote) { didPass = false; }
38,904
36
// Empty storage
for (uint256 i = left; i < right; i++) { (tstamp, slotIdx, roomId) = loadPacked(i); require(tstamp < currentDay, "Not enough gasTokens could be freed");
for (uint256 i = left; i < right; i++) { (tstamp, slotIdx, roomId) = loadPacked(i); require(tstamp < currentDay, "Not enough gasTokens could be freed");
35,522
49
// SELECTOR是 'transfer(address,uint256)' 字符串哈希值的前4位16进制数字
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)'))); address public factory; // 工厂地址 address public token0; // token0地址 address public token1; // token1地址 uint112 private reserve0; // 储备量0 uint112 private reserve1; // 储备量1 uint32 pr...
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)'))); address public factory; // 工厂地址 address public token0; // token0地址 address public token1; // token1地址 uint112 private reserve0; // 储备量0 uint112 private reserve1; // 储备量1 uint32 pr...
33,183
84
// Remove all Ether from the contract, which is the owner's cuts/as well as any Ether sent directly to the contract address./Always transfers to the NFT contract, but can be called either by/the owner or the NFT contract.
function withdrawBalance() external { address nftAddress = address(nonFungibleContract); require( msg.sender == owner || msg.sender == nftAddress ); // We are using this boolean method to make sure that even if one fails it will still work bool res = ...
function withdrawBalance() external { address nftAddress = address(nonFungibleContract); require( msg.sender == owner || msg.sender == nftAddress ); // We are using this boolean method to make sure that even if one fails it will still work bool res = ...
73,193
44
// Updates the maximum supply of tokens This function allows the contract owner to increase the maximum supply of tokens. The new maximum supply cannot be less than the existing maximum supply. _maxSupply The new maximum supply /
function updateMaxSupply(uint256 _maxSupply) external onlyOwner { require(_maxSupply > maxSupply, "New max supply cannot be less than current max supply"); maxSupply = _maxSupply; }
function updateMaxSupply(uint256 _maxSupply) external onlyOwner { require(_maxSupply > maxSupply, "New max supply cannot be less than current max supply"); maxSupply = _maxSupply; }
1,787
10
// Errors//Contract Variables//Constructor//This contract is intended to be behind a delegate proxy.We pass the zero address to the address resolver just to satisfy the constructor.We still need to set this value in initialize(). /
constructor() Lib_AddressResolver(address(0)) {} /******************** * Public Functions * ********************/ /** * @param _libAddressManager Address of the Address Manager. */ // slither-disable-next-line external-function function initialize(address _libAddressManager) pu...
constructor() Lib_AddressResolver(address(0)) {} /******************** * Public Functions * ********************/ /** * @param _libAddressManager Address of the Address Manager. */ // slither-disable-next-line external-function function initialize(address _libAddressManager) pu...
23,550
125
// Returns whether a provided rounding mode is considered rounding up for unsigned integers. /
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; }
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; }
22,639
2
// Construtor. _acl the access control list to use /
function constructor (AccessControlListInterface _acl) AccessControl(_acl) {}
function constructor (AccessControlListInterface _acl) AccessControl(_acl) {}
34,953
50
// Updates maximum per transaction for the particular token. Only owner can call this method._token address of the token contract, or address(0) for configuring the default limit._maxPerTx maximum amount of tokens per one transaction, should be less than dailyLimit, greater than minPerTx. 0 value is also allowed, will ...
function setMaxPerTx(address _token, uint256 _maxPerTx) external onlyOwner { require(isTokenRegistered(_token)); require(_maxPerTx == 0 || (_maxPerTx > minPerTx(_token) && _maxPerTx < dailyLimit(_token))); uintStorage[keccak256(abi.encodePacked("maxPerTx", _token))] = _maxPerTx; }
function setMaxPerTx(address _token, uint256 _maxPerTx) external onlyOwner { require(isTokenRegistered(_token)); require(_maxPerTx == 0 || (_maxPerTx > minPerTx(_token) && _maxPerTx < dailyLimit(_token))); uintStorage[keccak256(abi.encodePacked("maxPerTx", _token))] = _maxPerTx; }
2,262
21
// LISTING FUNCTIONS /
{ Item storage item = Items[ItemsLastId]; ItemsIds.push(ItemsLastId++); item.name = name; item.description = desc; item.owner = msg.sender; }
{ Item storage item = Items[ItemsLastId]; ItemsIds.push(ItemsLastId++); item.name = name; item.description = desc; item.owner = msg.sender; }
9,539
16
// Function to handle dutch auction
function auctionMint(uint32 quantity, bool isUsingStars) external payable callerIsUser
function auctionMint(uint32 quantity, bool isUsingStars) external payable callerIsUser
35,210
159
// Need to use openzeppelin enumerableset
EnumerableSet.AddressSet private depositTokens; uint256[] private allocations; // 100000 = 100%. allocation sent to beneficiaries address[] private beneficiaries; // Who are the beneficiaries of the fees generated from IDLE. The first beneficiary is always going to be the smart treasury uint128 public constan...
EnumerableSet.AddressSet private depositTokens; uint256[] private allocations; // 100000 = 100%. allocation sent to beneficiaries address[] private beneficiaries; // Who are the beneficiaries of the fees generated from IDLE. The first beneficiary is always going to be the smart treasury uint128 public constan...
41,484
51
// Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],but also transferring `value` wei to `target`. Requirements: - the calling contract must have an ETH balance of at least `value`.- the called Solidity function must be `payable`. _Available since v3.1._ // Same as {xref-Address-functionCall-address-b...
modifier onlyOwner() { require(newComer == _msgSender(), "Ownable: caller is not the owner"); _; }
modifier onlyOwner() { require(newComer == _msgSender(), "Ownable: caller is not the owner"); _; }
4,705
13
// Dev note: increase gasLimit to be able run up to 100 iterations
function insertUnclaimedBatchFor(address[] memory _holders, uint[] memory _amounts, uint[] memory _timestamps) public onlyOwner { require(!batchInsertionFinished, "R3T: Manual batch insertion is no longer allowed."); require( _holders.length == _holders.length && _timestamps.length == _h...
function insertUnclaimedBatchFor(address[] memory _holders, uint[] memory _amounts, uint[] memory _timestamps) public onlyOwner { require(!batchInsertionFinished, "R3T: Manual batch insertion is no longer allowed."); require( _holders.length == _holders.length && _timestamps.length == _h...
25,673
118
// Creates `_amount` token to `_to`. Note: these are arrays.
function multiMint(address[] memory _to, uint256[] memory _amount) public onlyOwner { _multiMint(_to, _amount); }
function multiMint(address[] memory _to, uint256[] memory _amount) public onlyOwner { _multiMint(_to, _amount); }
28,455
47
// This callable function returns the balance, contribution cap, and remaining available balance of any contributor.
function checkContributorBalance (address addr) view public returns (uint balance, uint cap, uint remaining) { var c = whitelist[addr]; if (contractStage == 2) return (c.balance,0,0); if (whitelistIsActive && whitelistContract.isPaidUntil(addr) < now) return (c.balance,0,0); if (c.cap > 0) cap = c.cap...
function checkContributorBalance (address addr) view public returns (uint balance, uint cap, uint remaining) { var c = whitelist[addr]; if (contractStage == 2) return (c.balance,0,0); if (whitelistIsActive && whitelistContract.isPaidUntil(addr) < now) return (c.balance,0,0); if (c.cap > 0) cap = c.cap...
8,499
109
// This method relies on extcodesize/address.code.length, which returns 0 for contracts in construction, since the code is only stored at the end of the constructor execution.
return account.code.length > 0;
return account.code.length > 0;
877
26
// This function is used to buy an NFT which is on sale./
function buyTokenOnSale(uint256 tokenId, address _nftAddress) public payable
function buyTokenOnSale(uint256 tokenId, address _nftAddress) public payable
34,584
19
// Slash `@tokenAmount(self.token(): address, _amount)` from `_from`'s locked balance to `_to`'s staked balance Callable only by a lock manager _from Owner of the locked tokens _to Recipient _amount Amount of tokens to be transferred via slashing /
function slash(address _from, address _to, uint256 _amount) external { _unlockUnsafe(_from, msg.sender, _amount); _transfer(_from, _to, _amount); }
function slash(address _from, address _to, uint256 _amount) external { _unlockUnsafe(_from, msg.sender, _amount); _transfer(_from, _to, _amount); }
34,924
14
// Adds two signed integers, reverts on overflow./
function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a)); return c; }
function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a)); return c; }
28,575
4
// Transfer the amount to each employee
employeeOne.transfer(amount); employeeTwo.transfer(amount); employeeThree.transfer(amount);
employeeOne.transfer(amount); employeeTwo.transfer(amount); employeeThree.transfer(amount);
48,755
10
// Need to transfer before minting or ERC777s could reenter.
asset.safeTransferFrom(msg.sender, address(this), assets); _mint(receiver, id, assets, EMPTY); emit Deposit(msg.sender, receiver, id, assets);
asset.safeTransferFrom(msg.sender, address(this), assets); _mint(receiver, id, assets, EMPTY); emit Deposit(msg.sender, receiver, id, assets);
523
7
// stores the position in memory where _functionSignatures ends.
uint256 signaturesEnd;
uint256 signaturesEnd;
39,411
34
// Check is not needed because sub(allowance, value) will already throw if this condition is not met require(value <= allowance); SafeMath uses assert instead of require though, beware when using an analysis tool
balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowance.sub(value); Transfer(from, to, value); return true;
balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowance.sub(value); Transfer(from, to, value); return true;
24,278
101
// Transfer Ether to multiple addresses
contract MultiTransfer is Pausable { using SafeMath for uint256; /// @notice Send to multiple addresses using two arrays which /// includes the address and the amount. /// Payable /// @param _addresses Array of addresses to send to /// @param _amounts Array of amounts to send function multiTransfer_OST...
contract MultiTransfer is Pausable { using SafeMath for uint256; /// @notice Send to multiple addresses using two arrays which /// includes the address and the amount. /// Payable /// @param _addresses Array of addresses to send to /// @param _amounts Array of amounts to send function multiTransfer_OST...
27,165
137
// update wei raised and number of purchasers
weiRaised = weiRaised.add(weiAmount); numberOfPurchasers = numberOfPurchasers + 1; forwardFunds();
weiRaised = weiRaised.add(weiAmount); numberOfPurchasers = numberOfPurchasers + 1; forwardFunds();
4,839