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
28
// Called by a security token to notify the registry it is using a module _moduleFactory is the address of the relevant module factory /
function useModule(address _moduleFactory) external;
function useModule(address _moduleFactory) external;
26,111
17
// See {IOperatorDelegation-updateOperatorName}. /
function updateOperatorName( address operator, string memory newName ) external onlyOwner { require( _allowedOperators.contains(operator), "operator not in allowed list" ); string memory oldName = _operatorName[operator];
function updateOperatorName( address operator, string memory newName ) external onlyOwner { require( _allowedOperators.contains(operator), "operator not in allowed list" ); string memory oldName = _operatorName[operator];
21,664
15
// Address of the ACO factory contract. /
IACOFactory public acoFactory;
IACOFactory public acoFactory;
16,575
91
// Myobu Lottery Interface Myobu Devs /
interface IFountainOfFortune { /** * @dev Event emmited when tickets are bought * @param buyer: The address of the buyer * @param amount: The amount of tickets bought * @param price: The price of each ticket * */ event TicketsBought(address buyer, uint256 amount, uint256 price); /** * @dev Event emmited when fees are claimed * @param amountClaimed: The amount of fees claimed in ETH * @param claimer: The address that claimed the fees */ event FeesClaimed(uint256 amountClaimed, address claimer); /** * @dev Event emmited when a lottery is created * @param lotteryID: The ID of the lottery created * @param lotteryLength: How long the lottery will be in seconds * @param ticketPrice: The price of a ticket in ETH * @param ticketFee: The percentage of the ticket price that is sent to the fee receiver * @param minimumMyobuBalance: The minimum amount of Myobu someone needs to buy tickets or get rewarded * @param percentageToKeepForNextLottery: The percentage that will be kept as reward for the next lottery * @param myobuNeededForEachTicket: The amount of myobu that someone needs to hold for each ticket they buy * @param percentageToKeepOnNotEnoughMyobu: If someone doesn't have myobu at the time of winning, this will define the * percentage of the reward that will be kept in the contract for the next lottery */ event LotteryCreated( uint256 lotteryID, uint256 lotteryLength, uint256 ticketPrice, uint256 ticketFee, uint256 minimumMyobuBalance, uint256 percentageToKeepForNextLottery, uint256 myobuNeededForEachTicket, uint256 percentageToKeepOnNotEnoughMyobu ); /** * @dev Event emmited when the someone wins the lottery * @param winner: The address of the the lottery winner * @param amountWon: The amount of ETH won * @param tokenID: The winning tokenID */ event LotteryWon(address winner, uint256 amountWon, uint256 tokenID); /** * @dev Event emitted when the lottery is extended * @param extendedBy: The amount of seconds the lottery is extended by */ event LotteryExtended(uint256 extendedBy); /** * @dev Struct of a lottery * @param startingTokenID: The token ID that the lottery starts at * @param startTimestamp: A timestamp of when the lottery started * @param endTimestamp: A timestamp of when the lottery will end * @param ticketPrice: The price of a ticket in ETH * @param ticketFee: The percentage of ticket sales that go to the _feeReceiver * @param minimumMyobuBalance: The minimum amount of myobu you need to buy tickets * @param percentageToKeepForNextLottery: The percentage of the jackpot to keep for the next lottery * @param myobuNeededForEachTicket: The amount of myobu that someone needs to hold for each ticket they buy * @param percentageToKeepOnNotEnoughMyobu: If someone doesn't have myobu at the time of winning, this will define the * percentage of the reward that will be kept in the contract for the next lottery */ struct Lottery { uint256 startingTokenID; uint256 startTimestamp; uint256 endTimestamp; uint256 ticketPrice; uint256 ticketFee; uint256 minimumMyobuBalance; uint256 percentageToKeepForNextLottery; uint256 myobuNeededForEachTicket; uint256 percentageToKeepOnNotEnoughMyobu; } /** * @dev Buys lottery tickets with ETH */ function buyTickets() external payable; function ticketsBought(address user, uint256 lotteryID) external view returns (uint256); /** * @return The amount of unclaimed fees, can be claimed using claimFees() */ function unclaimedFees() external view returns (uint256); /** * @return The amount of fees claimed for the current lottery */ function claimedFees() external view returns (uint256); /** * @dev Function to calculate the fees that will be taken * @return The amount of fees that will be taken * @param currentTokenID: The latest tokenID * @param ticketPrice: The price of 1 ticket * @param ticketFee: The percentage of the ticket to take as a fee * @param lastClaimedTokenID_: The last token ID that fees have been claimed for */ function calculateFees( uint256 currentTokenID, uint256 ticketPrice, uint256 ticketFee, uint256 lastClaimedTokenID_ ) external pure returns (uint256); /** * @dev Function that claims fees and sends to _feeReceiver. */ function claimFees() external; /** * @return The amount of myobu that someone needs to hold to buy lottery tickets * @param user: The address * @param amount: The amount of tickets */ function myobuNeededForTickets(address user, uint256 amount) external view returns (uint256); /** * @dev Function that gets a random winner and sends the reward */ function claimReward() external returns (bytes32 requestId); /** * @dev Returns the amount of tokens to keep for the next lottery */ function toNextLottery() external view returns (uint256); /** * @return The current jackpot */ function jackpot() external view returns (uint256); /** * @return The current token being used */ function myobu() external view returns (IERC20); /** * @return The amount of link to pay */ function chainlinkFee() external view returns (uint256); /** * @return Where all the ticket sale fees will be sent to */ function feeReceiver() external view returns (address); /** * @return A counter of how much lotteries there have been, increases by 1 each new lottery. */ function currentLotteryID() external view returns (uint256); /** * @return The current token ID */ function tokenID() external view returns (uint256); /** * @return The info of a lottery (The Lottery Struct) */ function lottery(uint256 lotteryID) external view returns (Lottery memory); /** * @return Returns if the reward has been claimed for the current lottery */ function rewardClaimed() external view returns (bool); /** * @return The last tokenID that fees have been claimed on for the current lottery */ function lastClaimedTokenID() external view returns (uint256); }
interface IFountainOfFortune { /** * @dev Event emmited when tickets are bought * @param buyer: The address of the buyer * @param amount: The amount of tickets bought * @param price: The price of each ticket * */ event TicketsBought(address buyer, uint256 amount, uint256 price); /** * @dev Event emmited when fees are claimed * @param amountClaimed: The amount of fees claimed in ETH * @param claimer: The address that claimed the fees */ event FeesClaimed(uint256 amountClaimed, address claimer); /** * @dev Event emmited when a lottery is created * @param lotteryID: The ID of the lottery created * @param lotteryLength: How long the lottery will be in seconds * @param ticketPrice: The price of a ticket in ETH * @param ticketFee: The percentage of the ticket price that is sent to the fee receiver * @param minimumMyobuBalance: The minimum amount of Myobu someone needs to buy tickets or get rewarded * @param percentageToKeepForNextLottery: The percentage that will be kept as reward for the next lottery * @param myobuNeededForEachTicket: The amount of myobu that someone needs to hold for each ticket they buy * @param percentageToKeepOnNotEnoughMyobu: If someone doesn't have myobu at the time of winning, this will define the * percentage of the reward that will be kept in the contract for the next lottery */ event LotteryCreated( uint256 lotteryID, uint256 lotteryLength, uint256 ticketPrice, uint256 ticketFee, uint256 minimumMyobuBalance, uint256 percentageToKeepForNextLottery, uint256 myobuNeededForEachTicket, uint256 percentageToKeepOnNotEnoughMyobu ); /** * @dev Event emmited when the someone wins the lottery * @param winner: The address of the the lottery winner * @param amountWon: The amount of ETH won * @param tokenID: The winning tokenID */ event LotteryWon(address winner, uint256 amountWon, uint256 tokenID); /** * @dev Event emitted when the lottery is extended * @param extendedBy: The amount of seconds the lottery is extended by */ event LotteryExtended(uint256 extendedBy); /** * @dev Struct of a lottery * @param startingTokenID: The token ID that the lottery starts at * @param startTimestamp: A timestamp of when the lottery started * @param endTimestamp: A timestamp of when the lottery will end * @param ticketPrice: The price of a ticket in ETH * @param ticketFee: The percentage of ticket sales that go to the _feeReceiver * @param minimumMyobuBalance: The minimum amount of myobu you need to buy tickets * @param percentageToKeepForNextLottery: The percentage of the jackpot to keep for the next lottery * @param myobuNeededForEachTicket: The amount of myobu that someone needs to hold for each ticket they buy * @param percentageToKeepOnNotEnoughMyobu: If someone doesn't have myobu at the time of winning, this will define the * percentage of the reward that will be kept in the contract for the next lottery */ struct Lottery { uint256 startingTokenID; uint256 startTimestamp; uint256 endTimestamp; uint256 ticketPrice; uint256 ticketFee; uint256 minimumMyobuBalance; uint256 percentageToKeepForNextLottery; uint256 myobuNeededForEachTicket; uint256 percentageToKeepOnNotEnoughMyobu; } /** * @dev Buys lottery tickets with ETH */ function buyTickets() external payable; function ticketsBought(address user, uint256 lotteryID) external view returns (uint256); /** * @return The amount of unclaimed fees, can be claimed using claimFees() */ function unclaimedFees() external view returns (uint256); /** * @return The amount of fees claimed for the current lottery */ function claimedFees() external view returns (uint256); /** * @dev Function to calculate the fees that will be taken * @return The amount of fees that will be taken * @param currentTokenID: The latest tokenID * @param ticketPrice: The price of 1 ticket * @param ticketFee: The percentage of the ticket to take as a fee * @param lastClaimedTokenID_: The last token ID that fees have been claimed for */ function calculateFees( uint256 currentTokenID, uint256 ticketPrice, uint256 ticketFee, uint256 lastClaimedTokenID_ ) external pure returns (uint256); /** * @dev Function that claims fees and sends to _feeReceiver. */ function claimFees() external; /** * @return The amount of myobu that someone needs to hold to buy lottery tickets * @param user: The address * @param amount: The amount of tickets */ function myobuNeededForTickets(address user, uint256 amount) external view returns (uint256); /** * @dev Function that gets a random winner and sends the reward */ function claimReward() external returns (bytes32 requestId); /** * @dev Returns the amount of tokens to keep for the next lottery */ function toNextLottery() external view returns (uint256); /** * @return The current jackpot */ function jackpot() external view returns (uint256); /** * @return The current token being used */ function myobu() external view returns (IERC20); /** * @return The amount of link to pay */ function chainlinkFee() external view returns (uint256); /** * @return Where all the ticket sale fees will be sent to */ function feeReceiver() external view returns (address); /** * @return A counter of how much lotteries there have been, increases by 1 each new lottery. */ function currentLotteryID() external view returns (uint256); /** * @return The current token ID */ function tokenID() external view returns (uint256); /** * @return The info of a lottery (The Lottery Struct) */ function lottery(uint256 lotteryID) external view returns (Lottery memory); /** * @return Returns if the reward has been claimed for the current lottery */ function rewardClaimed() external view returns (bool); /** * @return The last tokenID that fees have been claimed on for the current lottery */ function lastClaimedTokenID() external view returns (uint256); }
58,575
1
// Token detais
string public constant name = " ERPV2 Token"; string public constant symbol = "ERPV2"; uint8 public constant decimals = 18;
string public constant name = " ERPV2 Token"; string public constant symbol = "ERPV2"; uint8 public constant decimals = 18;
18,644
159
// Checks if specified address is included into the registered rewards receivers list._addr address to verify. return true, if specified address is associated with one of the registered reward accounts./
function isRewardAddress(address _addr) public view returns (bool) { return _addr != F_ADDR && getNextRewardAddress(_addr) != address(0); }
function isRewardAddress(address _addr) public view returns (bool) { return _addr != F_ADDR && getNextRewardAddress(_addr) != address(0); }
47,643
6
// Returns the token balances in Ethers by multiplying each token balance with its price in ethers. /
function getEthBalances() internal view returns (uint256[] memory) { uint256[] memory ethBalances = new uint256[](tokens.length); (, uint256[] memory balances, ) = vault.getPoolTokens(poolId); for (uint256 index; index < tokens.length; index++) { uint256 pi = isPeggedToEth[index] ? BONE : uint256(priceOracle.getAssetPrice(tokens[index])); require(pi > 0, 'ERR_NO_ORACLE_PRICE'); uint256 missingDecimals = 18 - decimals[index]; uint256 bi = bmul(balances[index], BONE * 10**(missingDecimals)); ethBalances[index] = bmul(bi, pi); } return ethBalances; }
function getEthBalances() internal view returns (uint256[] memory) { uint256[] memory ethBalances = new uint256[](tokens.length); (, uint256[] memory balances, ) = vault.getPoolTokens(poolId); for (uint256 index; index < tokens.length; index++) { uint256 pi = isPeggedToEth[index] ? BONE : uint256(priceOracle.getAssetPrice(tokens[index])); require(pi > 0, 'ERR_NO_ORACLE_PRICE'); uint256 missingDecimals = 18 - decimals[index]; uint256 bi = bmul(balances[index], BONE * 10**(missingDecimals)); ethBalances[index] = bmul(bi, pi); } return ethBalances; }
34,784
1
// Structure Getter
function getProject( address _org, uint256 _project
function getProject( address _org, uint256 _project
44,451
351
// Returns if private sale is open or not. 15 second rule passed
function isPrivateSaleOpen() public view returns (bool) { return block.timestamp >= PRIVATE_SALE_OPEN && block.timestamp < PRIVATE_SALE_OPEN.add(PRIVATE_SALE_WINDOW); }
function isPrivateSaleOpen() public view returns (bool) { return block.timestamp >= PRIVATE_SALE_OPEN && block.timestamp < PRIVATE_SALE_OPEN.add(PRIVATE_SALE_WINDOW); }
70,785
27
// flag to enable/disable swapout vs vault.burn so multiple events are triggered
bool private _vaultOnly;
bool private _vaultOnly;
26,136
146
// Send all token to pair
if(fromPerson) { safeTransferFrom(_token, msg.sender, pairWithWETH, _amountTransfer); // re } else {
if(fromPerson) { safeTransferFrom(_token, msg.sender, pairWithWETH, _amountTransfer); // re } else {
18,838
10
// ========== CONSTRUCTOR ========== / Dependencies
address _weth, address _bank, address _float, address _basket, address _monetaryPolicy, address _gov, address _bankEthOracle, address _floatEthOracle,
address _weth, address _bank, address _float, address _basket, address _monetaryPolicy, address _gov, address _bankEthOracle, address _floatEthOracle,
13,470
2
// Constructor code is only run when the contract is created
constructor() public { banker = msg.sender; bank = new Bank(); bank.mint(banker, 100000); assetManager = new AssetManager(); publishProperties(); }
constructor() public { banker = msg.sender; bank = new Bank(); bank.mint(banker, 100000); assetManager = new AssetManager(); publishProperties(); }
38,933
58
// Notifies Fragments contract about a new rebase cycle. supplyDelta The number of new fragment tokens to add into circulation via expansion.return The total number of fragments after the supply adjustment. /
function rebase(uint256 epoch, int256 supplyDelta) external onlyMonetaryPolicy returns (uint256)
function rebase(uint256 epoch, int256 supplyDelta) external onlyMonetaryPolicy returns (uint256)
27,107
155
// We know for sure that investment came from specified investor (see AnalyticProxy).
iaOnInvested(investor, value, true);
iaOnInvested(investor, value, true);
38,777
373
// Reset all any calldataMocks
bytes4 nextAnyMock = methodIdMocks[SENTINEL_ANY_MOCKS]; while(nextAnyMock != SENTINEL_ANY_MOCKS) { bytes4 currentAnyMock = nextAnyMock; methodIdMockTypes[currentAnyMock] = MockType.Return; methodIdExpectations[currentAnyMock] = hex""; methodIdRevertMessages[currentAnyMock] = ""; nextAnyMock = methodIdMocks[currentAnyMock];
bytes4 nextAnyMock = methodIdMocks[SENTINEL_ANY_MOCKS]; while(nextAnyMock != SENTINEL_ANY_MOCKS) { bytes4 currentAnyMock = nextAnyMock; methodIdMockTypes[currentAnyMock] = MockType.Return; methodIdExpectations[currentAnyMock] = hex""; methodIdRevertMessages[currentAnyMock] = ""; nextAnyMock = methodIdMocks[currentAnyMock];
3,146
84
// Option is Active (can still be written or exercised) - if it hasn't expired nor hasn't been exercised. Option is not Active (and the collateral can be withdrawn) - if it has expired or has been exercised.
function isActive() public view returns (bool active) { return (!isAfterExpirationDate() && !hasBeenExercised()); }
function isActive() public view returns (bool active) { return (!isAfterExpirationDate() && !hasBeenExercised()); }
47,585
26
// Admin function end // Anyone can call /
function getAmountsOut( uint256 amountIn, address router0, address router1, address[] calldata token0Path, address[] calldata token1Path
function getAmountsOut( uint256 amountIn, address router0, address router1, address[] calldata token0Path, address[] calldata token1Path
6,206
45
// Instantly withdraws assets from a strategy, bypassing shares mechanism. Requirements:- caller must have role ROLE_EMERGENCY_WITHDRAWAL_EXECUTOR strategies Addresses of strategies. withdrawalSlippages Slippages to guard withdrawal. removeStrategies Whether to remove strategies from the system after withdrawal. /
function emergencyWithdraw( address[] calldata strategies, uint256[][] calldata withdrawalSlippages, bool removeStrategies ) external;
function emergencyWithdraw( address[] calldata strategies, uint256[][] calldata withdrawalSlippages, bool removeStrategies ) external;
30,973
2
// Return the number of Land owned by an address owner The address to look forreturn The number of Land token owned by the address /
function balanceOf(address owner) external view returns (uint256) { require(owner != address(0), "owner is zero address"); return _numNFTPerAddress[owner]; }
function balanceOf(address owner) external view returns (uint256) { require(owner != address(0), "owner is zero address"); return _numNFTPerAddress[owner]; }
46,410
10
// Set a new bridge frontend. frontend_ Address of the new bridge frontend. title Keccack256 hash of the frontend title. /
function setBridgeFrontend( address frontend_, string calldata title
function setBridgeFrontend( address frontend_, string calldata title
39,850
169
// Creates a new token type and assigns _initialSupply to an address _maxSupply max supply allowed _initialSupply Optional amount to supply the first owner _uri Optional URI for this token type _data Optional data to pass if receiver is contractreturn The newly created token ID /
function create( uint256 _maxSupply, uint256 _initialSupply, string calldata _uri, bytes calldata _data
function create( uint256 _maxSupply, uint256 _initialSupply, string calldata _uri, bytes calldata _data
1,277
17
// 기존 소유주로부터 요정 제거
uint256 index = fairyIdToFairyIdsIndex[fairyId]; uint256 lastIndex = balanceOf(from).sub(1); uint256 lastFairyId = masterToFairyIds[from][lastIndex]; masterToFairyIds[from][index] = lastFairyId; delete masterToFairyIds[from][lastIndex]; masterToFairyIds[from].length -= 1; fairyIdToFairyIdsIndex[lastFairyId] = index;
uint256 index = fairyIdToFairyIdsIndex[fairyId]; uint256 lastIndex = balanceOf(from).sub(1); uint256 lastFairyId = masterToFairyIds[from][lastIndex]; masterToFairyIds[from][index] = lastFairyId; delete masterToFairyIds[from][lastIndex]; masterToFairyIds[from].length -= 1; fairyIdToFairyIdsIndex[lastFairyId] = index;
43,544
40
// Send nex certification request Send nex certification request (emits a RequestCertification event) _tokenID ID of document _tokenURI URI of document _certifying recipent of request /
function requestCertification(uint256 _tokenID, string memory _tokenURI, address _certifying) isMyToken(_tokenID) external userExist(_certifying) requestNotExist(_certifying, _tokenID)
function requestCertification(uint256 _tokenID, string memory _tokenURI, address _certifying) isMyToken(_tokenID) external userExist(_certifying) requestNotExist(_certifying, _tokenID)
15,834
498
// Create reference to the ERC20 contract
IERC20 erc20token = IERC20(_asset);
IERC20 erc20token = IERC20(_asset);
38,922
67
// return estimated KTY and SDAO rewards for the for the months following the starting month until the end month This function is only used for estimating rewards only /
function estimateYields_part_2(uint256 startMonth, uint256 endMonth, uint256 lockedLP, uint256 adjustedMonthlyDeposit) internal view returns (uint256 yieldsKTY_part_2, uint256 yieldsSDAO_part_2)
function estimateYields_part_2(uint256 startMonth, uint256 endMonth, uint256 lockedLP, uint256 adjustedMonthlyDeposit) internal view returns (uint256 yieldsKTY_part_2, uint256 yieldsSDAO_part_2)
21,087
170
// Returns the number of elements in the map. O(1). /
function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); }
function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); }
6,987
0
// should access position of caller using delegatecall
function shouldBuy(Position memory position, uint _reserve0, uint _reserve1) external pure override returns(uint){ return 0 ;//position.blockTimestamp == 0 ? position.amount : 0 ; }
function shouldBuy(Position memory position, uint _reserve0, uint _reserve1) external pure override returns(uint){ return 0 ;//position.blockTimestamp == 0 ? position.amount : 0 ; }
12,232
5
// return if order is already included order struct to check hashes list of hashed ordersreturn containDuplicate if hashes already contain a same order type. /
function containDuplicateOrderType( IGammaRedeemerV1.Order memory order, bytes32[] memory hashes
function containDuplicateOrderType( IGammaRedeemerV1.Order memory order, bytes32[] memory hashes
77,533
104
// setInitialBidPriceWithRange// set _bidAmount uint256 value in wei to bid. _startTime end time of bid _endTime end time of bid _owner address of the token owner _tokenId uint256 ID of the token /
function setInitialBidPriceWithRange(uint256 _bidAmount, uint256 _startTime, uint256 _endTime, address _owner, uint256 _tokenId) external override { require(_bidAmount > 0, "setInitialBidPriceWithRange::Cannot bid 0 Wei."); senderMustBeTokenOwner(_tokenId); activeBid[_tokenId][_owner] = ActiveBid( payable(_owner), nafter.getServiceFee(_tokenId), _bidAmount ); _setBidRange(_startTime, _endTime, _tokenId, _owner); emit SetInitialBidPriceWithRange(_bidAmount, _startTime, _endTime, _owner, _tokenId); }
function setInitialBidPriceWithRange(uint256 _bidAmount, uint256 _startTime, uint256 _endTime, address _owner, uint256 _tokenId) external override { require(_bidAmount > 0, "setInitialBidPriceWithRange::Cannot bid 0 Wei."); senderMustBeTokenOwner(_tokenId); activeBid[_tokenId][_owner] = ActiveBid( payable(_owner), nafter.getServiceFee(_tokenId), _bidAmount ); _setBidRange(_startTime, _endTime, _tokenId, _owner); emit SetInitialBidPriceWithRange(_bidAmount, _startTime, _endTime, _owner, _tokenId); }
55,171
3
// TRAIT STRUCTS /
struct Material { MaterialId id; string name; string[2] vals; }
struct Material { MaterialId id; string name; string[2] vals; }
36,836
6
// Abort the purchase and reclaim the ether./ Can only be called by the seller before/ the contract is locked.
function abort() public onlySeller inState(State.Created)
function abort() public onlySeller inState(State.Created)
6,505
23
// Remove the candidate by setting the voterId to 0
candidate.voterId = 0;
candidate.voterId = 0;
27,598
61
// there is an existing snapshot
snapshotIndex = historyLength - 1; Snapshot storage snapshot = history[snapshotIndex]; snapshotStake = uint256(int256(snapshot.stake).add(stakeDelta)).toUint128(); if (snapshot.startCycle == currentCycle) {
snapshotIndex = historyLength - 1; Snapshot storage snapshot = history[snapshotIndex]; snapshotStake = uint256(int256(snapshot.stake).add(stakeDelta)).toUint128(); if (snapshot.startCycle == currentCycle) {
31,208
7
// 5. withdraw the loaned tokens again and repay the loaner pool
rewarderPool.withdraw(amount); liquidityToken.transfer(msg.sender, amount);
rewarderPool.withdraw(amount); liquidityToken.transfer(msg.sender, amount);
15,304
17
// Add a child to an item. The child must not exist yet. itemId itemId of the parent. childItemStore The ItemStore contract that will contain the child. childNonce The nonce that will be used to create the child. /
function addChild(bytes32 itemId, AcuityItemStoreInterface childItemStore, bytes32 childNonce) virtual external { // Ensure the parent exists. require (itemStoreRegistry.getItemStore(itemId).getInUse(itemId), "Parent does not exist."); // Get the child itemId. Ensure it does not exist. bytes32 childId = childItemStore.getNewItemId(msg.sender, childNonce); // Ensure the child doesn't have a parent already. require (itemParentId[childId] == 0, "Child already has a parent."); // Get the index of the new child. uint i = itemChildCount[itemId]; // Store the childId. itemChildIds[itemId][i] = childId; // Increment the child count. itemChildCount[itemId] = i + 1; // Log the new child. emit AddChild(itemId, msg.sender, childId, i); // Store the parentId. itemParentId[childId] = itemId; }
function addChild(bytes32 itemId, AcuityItemStoreInterface childItemStore, bytes32 childNonce) virtual external { // Ensure the parent exists. require (itemStoreRegistry.getItemStore(itemId).getInUse(itemId), "Parent does not exist."); // Get the child itemId. Ensure it does not exist. bytes32 childId = childItemStore.getNewItemId(msg.sender, childNonce); // Ensure the child doesn't have a parent already. require (itemParentId[childId] == 0, "Child already has a parent."); // Get the index of the new child. uint i = itemChildCount[itemId]; // Store the childId. itemChildIds[itemId][i] = childId; // Increment the child count. itemChildCount[itemId] = i + 1; // Log the new child. emit AddChild(itemId, msg.sender, childId, i); // Store the parentId. itemParentId[childId] = itemId; }
7,779
58
// copy 32 bytes into scratch space
returndatacopy(0x0, 0x0, 0x20)
returndatacopy(0x0, 0x0, 0x20)
34,161
123
// e.g. 138145381104e17 + 9.99...e17 = 138145381113.99...e17
uint256 ceil = scaled + FULL_SCALE - 1;
uint256 ceil = scaled + FULL_SCALE - 1;
46,663
20
// Method for listing NFT bundle/_bundleID Bundle ID/_nftAddresses Addresses of NFT contract/_tokenIds Token IDs of NFT/_quantities token amounts to list (needed for ERC-1155 NFTs, set as 1 for ERC-721)/_price sale price for bundle/_startingTime scheduling for a future sale
function listItem( string memory _bundleID, address[] calldata _nftAddresses, uint256[] calldata _tokenIds, uint256[] calldata _quantities, address _payToken, uint256 _price, uint256 _startingTime
function listItem( string memory _bundleID, address[] calldata _nftAddresses, uint256[] calldata _tokenIds, uint256[] calldata _quantities, address _payToken, uint256 _price, uint256 _startingTime
2,386
53
// Internal function to add a token ID to the list of a given address _to address representing the new owner of the given token ID _tokenId uint256 ID of the token to be added to the tokens list of the given address /
function addTokenTo(address _to, uint256 _tokenId) internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); }
function addTokenTo(address _to, uint256 _tokenId) internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); }
7,020
24
// Transfer tokens from msg.sender to this contract on this blockchain,and request tokens on the remote blockchain be given to the requestedaccount on the destination blockchain. NOTE: msg.sender must have called approve() on the token contract._srcTokenContract Address of ERC 20 contract on this blockchain. _recipientAddress of account to transfer tokens to on the destination blockchain. _amount The number of tokens to transfer. /
function transferToOtherBlockchain( uint256 _destBcId, address _srcTokenContract, address _recipient, uint256 _amount
function transferToOtherBlockchain( uint256 _destBcId, address _srcTokenContract, address _recipient, uint256 _amount
14,622
407
// When a valid snapshot is queried, there are three possibilities:a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was nevercreated for this id, and all stored snapshot ids are smaller than the requested one. The value that correspondsto this id is the current one.b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with therequested id, and its value is the one to return.c) More snapshots were created after the requested one, and the queried value was later modified. There will beno entry for the requested
uint256 index = snapshots.ids.findUpperBound(snapshotId); if (index == snapshots.ids.length) { return (false, 0); } else {
uint256 index = snapshots.ids.findUpperBound(snapshotId); if (index == snapshots.ids.length) { return (false, 0); } else {
3,080
10
// only system wallet can send oracle response
modifier onlySystem() { require(isSystemAddress[msg.sender],"Not System"); _; }
modifier onlySystem() { require(isSystemAddress[msg.sender],"Not System"); _; }
3,300
256
// Get current IdleToken price
uint256 idlePrice = tokenPrice();
uint256 idlePrice = tokenPrice();
31,243
93
// Convert uint to string. _i - uint256 to be converted to string.return uint in string /
function uintToString(uint _i) internal pure returns (string memory _uintAsString) { uint i = _i; if (i == 0) { return "0"; } uint j = i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (i != 0) { bstr[k--] = byte(uint8(48 + i % 10)); i /= 10; } return string(bstr); }
function uintToString(uint _i) internal pure returns (string memory _uintAsString) { uint i = _i; if (i == 0) { return "0"; } uint j = i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (i != 0) { bstr[k--] = byte(uint8(48 + i % 10)); i /= 10; } return string(bstr); }
23,532
77
// Approve tokens for transfer to the Uniswap V2 Router
_approve(address(this), address(_uniswapV2Router), tokenAmount);
_approve(address(this), address(_uniswapV2Router), tokenAmount);
42,328
154
// Harvests token yield from the Aave lending pool
function harvestYield() external;
function harvestYield() external;
70,536
8
// Event to register each Payment
event PaymentEvent(uint256 idInvestment, string USDCPaymentTransaction);
event PaymentEvent(uint256 idInvestment, string USDCPaymentTransaction);
15,039
55
// Initializer a new MPond token account The initial account to grant all the tokens /
function initialize( address account, address bridge, address dropBridgeAddress
function initialize( address account, address bridge, address dropBridgeAddress
41,782
8
// This contracts calculates interface id of Xcert contracts as described in EIP165: See test folder for usage examples. /
contract Selector { /** * @dev Calculates and returns interface ID for the Xcert smart contract. */ function calculateXcertSelector() public pure returns (bytes4) { Xcert i; return ( i.mint.selector ^ i.conventionId.selector ^ i.tokenProof.selector ^ i.setTokenDataValue.selector ^ i.tokenDataValue.selector ^ i.tokenExpirationTime.selector ^ i.setMintAuthorizedAddress.selector ^ i.isMintAuthorizedAddress.selector ); } /** * @dev Calculates and returns interface ID for the BurnableXcert smart contract. */ function calculateBurnableXcertSelector() public pure returns (bytes4) { BurnableXcert i; return i.burn.selector; } /** * @dev Calculates and returns interface ID for the PausableXcert smart contract. */ function calculatePausableXcertSelector() public pure returns (bytes4) { PausableXcert i; return i.setPause.selector; } /** * @dev Calculates and returns interface ID for the RevokableXcert smart contract. */ function calculateRevokableXcertSelector() public pure returns (bytes4) { RevokableXcert i; return i.revoke.selector; } }
contract Selector { /** * @dev Calculates and returns interface ID for the Xcert smart contract. */ function calculateXcertSelector() public pure returns (bytes4) { Xcert i; return ( i.mint.selector ^ i.conventionId.selector ^ i.tokenProof.selector ^ i.setTokenDataValue.selector ^ i.tokenDataValue.selector ^ i.tokenExpirationTime.selector ^ i.setMintAuthorizedAddress.selector ^ i.isMintAuthorizedAddress.selector ); } /** * @dev Calculates and returns interface ID for the BurnableXcert smart contract. */ function calculateBurnableXcertSelector() public pure returns (bytes4) { BurnableXcert i; return i.burn.selector; } /** * @dev Calculates and returns interface ID for the PausableXcert smart contract. */ function calculatePausableXcertSelector() public pure returns (bytes4) { PausableXcert i; return i.setPause.selector; } /** * @dev Calculates and returns interface ID for the RevokableXcert smart contract. */ function calculateRevokableXcertSelector() public pure returns (bytes4) { RevokableXcert i; return i.revoke.selector; } }
36,451
47
// Withdrawtokens from HAL9KVault.
function withdraw(uint256 _pid, uint256 _amount) public { _withdraw(_pid, _amount, msg.sender, msg.sender); }
function withdraw(uint256 _pid, uint256 _amount) public { _withdraw(_pid, _amount, msg.sender, msg.sender); }
39,860
130
// get pending reward of user
function getUserPendingReward(uint256 _pool, address _user) public view returns(uint256) { return users[_pool][_user].pendingReward; }
function getUserPendingReward(uint256 _pool, address _user) public view returns(uint256) { return users[_pool][_user].pendingReward; }
37,602
5
// Tokens reserved for pre- and post- ICO Bounty / 50,000,000 (5%) tokens will be spent on various bounty campaigns These tokens are available immediately, without vesting
address public bountyAllocation = address(0x3333333333333333333333333333333333333333); uint256 public bountyTotal = 50000000e8;
address public bountyAllocation = address(0x3333333333333333333333333333333333333333); uint256 public bountyTotal = 50000000e8;
34,013
552
// File: EXO/NEW/EXO.sol
pragma solidity >=0.6.0;
pragma solidity >=0.6.0;
18,544
62
// uint256 excess = SafeMath.sub(senderBid, proposal.fairAmount);
int256 balance = postedFunds[_taxee];
int256 balance = postedFunds[_taxee];
37,184
19
// Converts all of caller&39;s dividends to tokens. /
function reinvest() onlyDividendPositive() onlyNonOwner() public
function reinvest() onlyDividendPositive() onlyNonOwner() public
42,322
53
// Batch mint NFTs to an array of addresses, require enough supply left.return the minted token ids /
function batchMint(address[] memory addresses_, uint16 amount_) public onlyOwner returns (uint256[] memory)
function batchMint(address[] memory addresses_, uint16 amount_) public onlyOwner returns (uint256[] memory)
59,613
9
// withdraw native chain currency from the contract address NOTE: only for authorized users/
function withdrawNative(address payable to, uint256 amount, string calldata withdrawalId) external _isAuthorized _withUniqueWithdrawalId(withdrawalId)
function withdrawNative(address payable to, uint256 amount, string calldata withdrawalId) external _isAuthorized _withUniqueWithdrawalId(withdrawalId)
14,165
150
// require( IERC1155(_nftAddress).isApprovedForAll(_msgSender(), address(this)), "NFT not approved for the staking contract" ); IERC1155(_nftAddress).safeTransferFrom( _msgSender(), address(this), _nftTokenId, 1, "" );
NftInfo memory _nftInfo; _nftInfo.nftAddress = _nftAddress; _nftInfo.nftTokenId = _nftTokenId; _nftInfo.amountDeposited = _amount; bool newNft = true; for (uint256 index = 0; index < user.nftItems.length; index++) { if ( user.nftItems[index].nftTokenId == _nftTokenId &&
NftInfo memory _nftInfo; _nftInfo.nftAddress = _nftAddress; _nftInfo.nftTokenId = _nftTokenId; _nftInfo.amountDeposited = _amount; bool newNft = true; for (uint256 index = 0; index < user.nftItems.length; index++) { if ( user.nftItems[index].nftTokenId == _nftTokenId &&
2,564
33
// Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with`errorMessage` as a fallback revert reason when `target` reverts. _Available since v3.1._ /
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); }
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); }
1,121
113
// Calculate amount of shares to be burned
uint256 r = shares.mul(p).div(1e18);
uint256 r = shares.mul(p).div(1e18);
50,186
7
// get count
uint256 count = numberInscribedTokens[inscriptionsContract]; address data = SSTORE2.write(abi.encode(newInscriptions)); InscriptionChunk memory newChunk = InscriptionChunk({ fromToken: count + 1, size: newInscriptions.length, dataContract: data });
uint256 count = numberInscribedTokens[inscriptionsContract]; address data = SSTORE2.write(abi.encode(newInscriptions)); InscriptionChunk memory newChunk = InscriptionChunk({ fromToken: count + 1, size: newInscriptions.length, dataContract: data });
37,936
202
// ========== MODIFIERS ========== / Contracts directly interacting with multiCollateralSynth to issue and burn
modifier onlyInternalContracts() { bool isFeePool = msg.sender == address(feePool()); bool isExchanger = msg.sender == address(exchanger()); bool isIssuer = msg.sender == address(issuer()); bool isEtherWrapper = msg.sender == address(etherWrapper()); bool isMultiCollateral = collateralManager().hasCollateral(msg.sender); require( isFeePool || isExchanger || isIssuer || isEtherWrapper || isMultiCollateral, "Only FeePool, Exchanger, Issuer, MultiCollateral contracts allowed" ); _; }
modifier onlyInternalContracts() { bool isFeePool = msg.sender == address(feePool()); bool isExchanger = msg.sender == address(exchanger()); bool isIssuer = msg.sender == address(issuer()); bool isEtherWrapper = msg.sender == address(etherWrapper()); bool isMultiCollateral = collateralManager().hasCollateral(msg.sender); require( isFeePool || isExchanger || isIssuer || isEtherWrapper || isMultiCollateral, "Only FeePool, Exchanger, Issuer, MultiCollateral contracts allowed" ); _; }
79,588
94
// we know _preBytes_offset is 0
let fslot := sload(_preBytes_slot)
let fslot := sload(_preBytes_slot)
20,904
19
// In the specific case of a Lock, each owner can own only at most 1 key.return The number of NFTs owned by `_keyOwner`, either 0 or 1./
function balanceOf( address _keyOwner ) public view returns (uint)
function balanceOf( address _keyOwner ) public view returns (uint)
47,089
11
// RedPacket with zk-proof. /
contract RedPacket is Verifier { using SafeERC20 for IERC20; enum BonusType { AVERAGE, RANDOM } struct RedPacketInfo { uint256 passcodeHash; // passcode hash of red packet uint256 amount; // amount of token uint256 amountLeft; // mutable: balance of token address creator; // creator address address token; // token address address condition; // condition contract address uint32 total; // total number of address uint32 totalLeft; // mutable: current number of address that can withdraw BonusType bonusType; } address constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; uint256 internal nextId; mapping(uint256 => RedPacketInfo) internal redPackets; mapping(bytes32 => bool) internal withdrawedMap; event Create( uint256 redPacketId, address indexed creator, address indexed token, uint256 amount, uint32 total, BonusType bonusType ); event Withdraw( uint256 redPacketId, address indexed to, address indexed token, uint256 bonus, uint256 bonusLeft, uint32 totalLeft ); function getRedPacket(uint256 id) public view returns (RedPacketInfo memory) { RedPacketInfo memory p = redPackets[id]; require(p.token != address(0), "Not exist"); return p; } function create( address token, uint256 amount, uint32 total, BonusType bonusType, uint256 passcodeHash, address condition ) public payable returns (uint256) { require(token != address(0), "Invalid token address"); require(total > 0, "Invalid total"); require(amount >= total, "Invalid amount"); // transfer token into contract: if (token == ETH) { require(msg.value == amount, "Invalid value"); } else { (IERC20(token)).safeTransferFrom(msg.sender, address(this), amount); } nextId++; uint256 id = nextId; RedPacketInfo storage p = redPackets[id]; p.passcodeHash = passcodeHash; p.amount = amount; p.amountLeft = amount; p.condition = condition; p.creator = msg.sender; p.token = token; p.total = total; p.totalLeft = total; p.bonusType = bonusType; emit Create(id, msg.sender, token, amount, total, bonusType); return id; } function isOpened(uint256 id, address addr) public view returns (bool) { bytes32 withdrawedHash = keccak256(abi.encodePacked(id, addr)); return withdrawedMap[withdrawedHash]; } function open( uint256 id, // zk proof: uint256[] memory proof ) public returns (uint256) { RedPacketInfo storage p = redPackets[id]; require(p.token != address(0), "Not exist"); address condition = p.condition; if (condition != address(0)) { require( ICondition(condition).check(address(this), id, msg.sender), "Address rejected" ); } require(p.totalLeft > 0, "Red packet is empty"); // can only withdraw once for same red packet: bytes32 withdrawedHash = keccak256(abi.encodePacked(id, msg.sender)); require(!withdrawedMap[withdrawedHash], "Already opened"); withdrawedMap[withdrawedHash] = true; // verify zk-proof require(proof.length == 8, "Invalid proof"); uint256[2] memory a = [proof[0], proof[1]]; uint256[2][2] memory b = [[proof[2], proof[3]], [proof[4], proof[5]]]; uint256[2] memory c = [proof[6], proof[7]]; uint256[2] memory input = [ p.passcodeHash, uint256(uint160(msg.sender)) ]; require(verifyProof(a, b, c, input), "Failed verify proof"); uint256 bonus = getBonus( p.amount, p.amountLeft, p.total, p.totalLeft, p.bonusType ); uint256 bonusLeft = p.amountLeft - bonus; p.amountLeft = bonusLeft; p.totalLeft = p.totalLeft - 1; if (p.token == ETH) { (bool sent, bytes memory _data) = payable(msg.sender).call{ value: bonus }(""); require(sent, "Failed to send Ether"); } else { (IERC20(p.token)).safeTransfer(msg.sender, bonus); } emit Withdraw(id, msg.sender, p.token, bonus, bonusLeft, p.totalLeft); return bonus; } function getBonus( uint256 amount, uint256 amountLeft, uint32 total, uint32 totalLeft, BonusType bonusType ) internal view returns (uint256) { if (totalLeft == 1) { return amountLeft; // last one picks all } if (bonusType == BonusType.AVERAGE) { return amount / total; } if (bonusType == BonusType.RANDOM) { uint256 up = amountLeft - totalLeft + 1; uint256 rnd = uint256( keccak256( abi.encodePacked(msg.sender, amountLeft, block.timestamp) ) ) % ((amount << 1) / total); if (rnd < 1) { return 1; } if (rnd > up) { return up; } return rnd; } revert("Invalid bonus type"); } }
contract RedPacket is Verifier { using SafeERC20 for IERC20; enum BonusType { AVERAGE, RANDOM } struct RedPacketInfo { uint256 passcodeHash; // passcode hash of red packet uint256 amount; // amount of token uint256 amountLeft; // mutable: balance of token address creator; // creator address address token; // token address address condition; // condition contract address uint32 total; // total number of address uint32 totalLeft; // mutable: current number of address that can withdraw BonusType bonusType; } address constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; uint256 internal nextId; mapping(uint256 => RedPacketInfo) internal redPackets; mapping(bytes32 => bool) internal withdrawedMap; event Create( uint256 redPacketId, address indexed creator, address indexed token, uint256 amount, uint32 total, BonusType bonusType ); event Withdraw( uint256 redPacketId, address indexed to, address indexed token, uint256 bonus, uint256 bonusLeft, uint32 totalLeft ); function getRedPacket(uint256 id) public view returns (RedPacketInfo memory) { RedPacketInfo memory p = redPackets[id]; require(p.token != address(0), "Not exist"); return p; } function create( address token, uint256 amount, uint32 total, BonusType bonusType, uint256 passcodeHash, address condition ) public payable returns (uint256) { require(token != address(0), "Invalid token address"); require(total > 0, "Invalid total"); require(amount >= total, "Invalid amount"); // transfer token into contract: if (token == ETH) { require(msg.value == amount, "Invalid value"); } else { (IERC20(token)).safeTransferFrom(msg.sender, address(this), amount); } nextId++; uint256 id = nextId; RedPacketInfo storage p = redPackets[id]; p.passcodeHash = passcodeHash; p.amount = amount; p.amountLeft = amount; p.condition = condition; p.creator = msg.sender; p.token = token; p.total = total; p.totalLeft = total; p.bonusType = bonusType; emit Create(id, msg.sender, token, amount, total, bonusType); return id; } function isOpened(uint256 id, address addr) public view returns (bool) { bytes32 withdrawedHash = keccak256(abi.encodePacked(id, addr)); return withdrawedMap[withdrawedHash]; } function open( uint256 id, // zk proof: uint256[] memory proof ) public returns (uint256) { RedPacketInfo storage p = redPackets[id]; require(p.token != address(0), "Not exist"); address condition = p.condition; if (condition != address(0)) { require( ICondition(condition).check(address(this), id, msg.sender), "Address rejected" ); } require(p.totalLeft > 0, "Red packet is empty"); // can only withdraw once for same red packet: bytes32 withdrawedHash = keccak256(abi.encodePacked(id, msg.sender)); require(!withdrawedMap[withdrawedHash], "Already opened"); withdrawedMap[withdrawedHash] = true; // verify zk-proof require(proof.length == 8, "Invalid proof"); uint256[2] memory a = [proof[0], proof[1]]; uint256[2][2] memory b = [[proof[2], proof[3]], [proof[4], proof[5]]]; uint256[2] memory c = [proof[6], proof[7]]; uint256[2] memory input = [ p.passcodeHash, uint256(uint160(msg.sender)) ]; require(verifyProof(a, b, c, input), "Failed verify proof"); uint256 bonus = getBonus( p.amount, p.amountLeft, p.total, p.totalLeft, p.bonusType ); uint256 bonusLeft = p.amountLeft - bonus; p.amountLeft = bonusLeft; p.totalLeft = p.totalLeft - 1; if (p.token == ETH) { (bool sent, bytes memory _data) = payable(msg.sender).call{ value: bonus }(""); require(sent, "Failed to send Ether"); } else { (IERC20(p.token)).safeTransfer(msg.sender, bonus); } emit Withdraw(id, msg.sender, p.token, bonus, bonusLeft, p.totalLeft); return bonus; } function getBonus( uint256 amount, uint256 amountLeft, uint32 total, uint32 totalLeft, BonusType bonusType ) internal view returns (uint256) { if (totalLeft == 1) { return amountLeft; // last one picks all } if (bonusType == BonusType.AVERAGE) { return amount / total; } if (bonusType == BonusType.RANDOM) { uint256 up = amountLeft - totalLeft + 1; uint256 rnd = uint256( keccak256( abi.encodePacked(msg.sender, amountLeft, block.timestamp) ) ) % ((amount << 1) / total); if (rnd < 1) { return 1; } if (rnd > up) { return up; } return rnd; } revert("Invalid bonus type"); } }
36,873
129
// 销毁当前合约内的流动性数量
_burn(address(this), liquidity);
_burn(address(this), liquidity);
822
116
// Potentially dangerous assumption about the type of the token.
require( TheraSeeding(address(token())).mint(beneficiary, tokenAmount), "MintedCrowdsale: minting failed" );
require( TheraSeeding(address(token())).mint(beneficiary, tokenAmount), "MintedCrowdsale: minting failed" );
25,360
55
// Sets `amount` as the allowance of `spender` over the `owner`s tokens. This is internal function is equivalent to `approve`, and can be used toe.g. set automatic allowances for certain subsystems, etc.
* Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), 'ERC20: approve from the zero address'); require(spender != address(0), 'ERC20: approve to the zero address'); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
* Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), 'ERC20: approve from the zero address'); require(spender != address(0), 'ERC20: approve to the zero address'); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
5,158
118
// Auction is complete if there has been a bid, and the current time is greater than the auction's end time.
auctions[tokenId].firstBidTime > 0 && block.timestamp >= auctionEnds(tokenId), "Auction hasn't completed" ); _;
auctions[tokenId].firstBidTime > 0 && block.timestamp >= auctionEnds(tokenId), "Auction hasn't completed" ); _;
24,465
263
// Purchase token_nftAddress address token EIP721 contract address_tokenId uint256 token ID/
function purchaseToken(address _nftAddress, uint256 _tokenId) public payable whenNotPaused { require(msg.sender != address(0) && msg.sender != address(this)); require(msg.value >= currentPrice); ERC721 eip721 = ERC721(_nftAddress); address tokenSeller = eip721.ownerOf(_tokenId); eip721.safeTransferFrom(tokenSeller, msg.sender, _tokenId); msg.sender.send(msg.value - currentPrice); currentPrice = currentPrice + priceStep; emit TokenPurchase(msg.sender, _nftAddress, _tokenId, msg.value); }
function purchaseToken(address _nftAddress, uint256 _tokenId) public payable whenNotPaused { require(msg.sender != address(0) && msg.sender != address(this)); require(msg.value >= currentPrice); ERC721 eip721 = ERC721(_nftAddress); address tokenSeller = eip721.ownerOf(_tokenId); eip721.safeTransferFrom(tokenSeller, msg.sender, _tokenId); msg.sender.send(msg.value - currentPrice); currentPrice = currentPrice + priceStep; emit TokenPurchase(msg.sender, _nftAddress, _tokenId, msg.value); }
50,960
12
// The minimum setable quorum threshold./500,000 = 0.5% of Shibui.
uint256 public constant MIN_QUORUM_VOTES = 500_000e18;
uint256 public constant MIN_QUORUM_VOTES = 500_000e18;
25,195
1
// Pangolin Token /
IERC20 internal constant PNG = IERC20(0x60781C2586D68229fde47564546784ab3fACA982);
IERC20 internal constant PNG = IERC20(0x60781C2586D68229fde47564546784ab3fACA982);
45,590
84
// function to get tokens contract hold /
function totalTokenBalance(address contractAddress) public view returns(uint)
function totalTokenBalance(address contractAddress) public view returns(uint)
6,370
10
// this is the winning label. let's get the winners and loosers
address[] _winners; address[] _loosers; for (uint j = 0; j < img.votes.length; j++) { Vote v = img.votes[j]; uint index = 0; if (v.label == j) {
address[] _winners; address[] _loosers; for (uint j = 0; j < img.votes.length; j++) { Vote v = img.votes[j]; uint index = 0; if (v.label == j) {
25,345
80
// The bond is the amount of REN submitted as a bond by the Darknode. This amount is reduced when the Darknode is slashed for malicious behavior.
uint256 bond;
uint256 bond;
12,354
238
// retrieve names of tokens by owner
function retrieveTokenNames(address owner) external view returns (string[] memory tokens) { uint256 iterator = balanceOf(owner); string[] memory tokenlist = new string[](iterator); for (uint256 i = 0; i < iterator; i++){ tokenlist[i] = check_bone_ID_name(tokenOfOwnerByIndex(owner, i)); } return tokenlist; }
function retrieveTokenNames(address owner) external view returns (string[] memory tokens) { uint256 iterator = balanceOf(owner); string[] memory tokenlist = new string[](iterator); for (uint256 i = 0; i < iterator; i++){ tokenlist[i] = check_bone_ID_name(tokenOfOwnerByIndex(owner, i)); } return tokenlist; }
2,988
2
// _allowances is used to manage and control allownace An allowance is the right to use another accounts balance, or part of it /
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => mapping (address => uint256)) private _allowances;
51,194
24
// it is register message, if result is true, need to save the token
if (registerToken != address(0)) { delete registerMessages[messageId]; if (result) { registeredTokens[registerToken] = true; }
if (registerToken != address(0)) { delete registerMessages[messageId]; if (result) { registeredTokens[registerToken] = true; }
51,840
60
// ========== RESTRICTED FUNCTIONS ========== /
function addOwner(address _newOwner) external isAnOwner { addOwnerShip(_newOwner); }
function addOwner(address _newOwner) external isAnOwner { addOwnerShip(_newOwner); }
39,815
10
// In this 1st option for ownership transfer `proposeOwnership()` must/be called first by the current `owner` then `acceptOwnership()` must be/called by the `newOwnerCandidate`/`onlyOwner` Proposes to transfer control of the contract to a/new owner/_newOwnerCandidate The address being proposed as the new owner
function proposeOwnership(address _newOwnerCandidate) public onlyOwner { newOwnerCandidate = _newOwnerCandidate; OwnershipRequested(msg.sender, newOwnerCandidate); }
function proposeOwnership(address _newOwnerCandidate) public onlyOwner { newOwnerCandidate = _newOwnerCandidate; OwnershipRequested(msg.sender, newOwnerCandidate); }
13,811
38
// Return if purchase would be autherized at current prices /
function canPurchase(address _client) public view returns (bool)
function canPurchase(address _client) public view returns (bool)
18,866
141
// GOV
event Initialized(address indexed executor, uint256 at); event Migration(address indexed target); event ContributionPoolChanged(address indexed operator, address newFund); event ContributionPoolRateChanged( address indexed operator, uint256 newRate ); event MaxInflationRateChanged(address indexed operator, uint256 newRate); event DebtAddRateChanged(address indexed operator, uint256 newRate); event MaxDebtRateChanged(address indexed operator, uint256 newRate);
event Initialized(address indexed executor, uint256 at); event Migration(address indexed target); event ContributionPoolChanged(address indexed operator, address newFund); event ContributionPoolRateChanged( address indexed operator, uint256 newRate ); event MaxInflationRateChanged(address indexed operator, uint256 newRate); event DebtAddRateChanged(address indexed operator, uint256 newRate); event MaxDebtRateChanged(address indexed operator, uint256 newRate);
43,011
6
// Lets us use nicer syntax.
using Lib_EIP155Tx for EIP155Tx;
using Lib_EIP155Tx for EIP155Tx;
3,802
386
// updateDocumentPoll(): check whether the _proposal has achieved majority,updating the state and sending an event if it hasthis can be called by anyone, because the ecliptic does notneed to be aware of the result
function updateDocumentPoll(bytes32 _proposal) public returns (bool majority)
function updateDocumentPoll(bytes32 _proposal) public returns (bool majority)
2,159
167
// get rough estimate of how much TUSD we'll get back from curve
uint256 amountToWithdraw = expectedAmount.sub(currencyBalance()); uint256 roughCurveTokenAmount = calcTokenAmount(amountToWithdraw).mul(1005).div(1000); require( roughCurveTokenAmount <= yTokenBalance(), "CurvePool: Not enough Curve y tokens in pool to cover borrow" );
uint256 amountToWithdraw = expectedAmount.sub(currencyBalance()); uint256 roughCurveTokenAmount = calcTokenAmount(amountToWithdraw).mul(1005).div(1000); require( roughCurveTokenAmount <= yTokenBalance(), "CurvePool: Not enough Curve y tokens in pool to cover borrow" );
27,936
5
// Determine what wallet can update claim conditions
function _canSetClaimConditions() internal override returns (bool){ return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); }
function _canSetClaimConditions() internal override returns (bool){ return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); }
11,404
0
// keeping addresses who allowed to@knownIssue "private" modifier don't make it invisible/
address[] private managers; mapping (address => bool) private isManager;
address[] private managers; mapping (address => bool) private isManager;
29,706
359
// CancelAndRefund will return funds based on time remaining minus this penalty. This is calculated as `proRatedRefundrefundPenaltyBasisPoints / BASIS_POINTS_DEN`.
uint public refundPenaltyBasisPoints; uint public freeTrialLength;
uint public refundPenaltyBasisPoints; uint public freeTrialLength;
32,351
111
// Refund a particular participant, by moving the sliders of stages he participated in
function refundParticipant(StageStorage storage self, uint256 stage1, uint256 stage2, uint256 stage3, uint256 stage4) internal { self.stages[1].tokensSold = self.stages[1].tokensSold.sub(stage1); self.stages[2].tokensSold = self.stages[2].tokensSold.sub(stage2); self.stages[3].tokensSold = self.stages[3].tokensSold.sub(stage3); self.stages[4].tokensSold = self.stages[4].tokensSold.sub(stage4); }
function refundParticipant(StageStorage storage self, uint256 stage1, uint256 stage2, uint256 stage3, uint256 stage4) internal { self.stages[1].tokensSold = self.stages[1].tokensSold.sub(stage1); self.stages[2].tokensSold = self.stages[2].tokensSold.sub(stage2); self.stages[3].tokensSold = self.stages[3].tokensSold.sub(stage3); self.stages[4].tokensSold = self.stages[4].tokensSold.sub(stage4); }
30,960
33
// Returns true if the index has been marked accepted.
function isGrantAccepted(uint256 index) external view returns (bool);
function isGrantAccepted(uint256 index) external view returns (bool);
33,600
5
// Team addresses for withdrawals
address public a1; address public a2; address public a3; address public a4; address public a5;
address public a1; address public a2; address public a3; address public a4; address public a5;
20,389
115
// Mapping from tokenId to index of the tokens list
mapping (uint256 => uint256) public tokenIdsIndex;
mapping (uint256 => uint256) public tokenIdsIndex;
16,902
4
// Returns the total amount of tokens bought by the specified _investor /
function getTotalBought(address _investor) external view returns (uint256);
function getTotalBought(address _investor) external view returns (uint256);
17,170
34
// External function called by the Aave governance to set or replace sources of assets/assets The addresses of the assets/sources The address of the source of each asset
function setAssetSources(address[] calldata assets, address[] calldata sources) external;
function setAssetSources(address[] calldata assets, address[] calldata sources) external;
19,164
201
// Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],but performing a static call. _Available since v3.3._ /
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); }
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); }
32,373
160
// Topup the borrowed position of this Avatar by repaying borrows from the pool Only Pool contract allowed to call the topup. cToken CToken address to use to RepayBorrows topupAmount Amount of tokens to Topup /
function topup(ICErc20 cToken, uint256 topupAmount) external onlyPool { _ensureUserNotQuitB(); // when already topped bool _isToppedUp = isToppedUp(); if(_isToppedUp) { require(toppedUpCToken == cToken, "already-topped-other-cToken"); } // 1. Transfer funds from the Pool contract IERC20 underlying = cToken.underlying(); underlying.safeTransferFrom(pool(), address(this), topupAmount); underlying.safeApprove(address(cToken), topupAmount); // 2. Repay borrows from Pool to topup require(cToken.repayBorrow(topupAmount) == 0, "RepayBorrow-fail"); // 3. Store Topped-up details if(! _isToppedUp) toppedUpCToken = cToken; toppedUpAmount = add_(toppedUpAmount, topupAmount); }
function topup(ICErc20 cToken, uint256 topupAmount) external onlyPool { _ensureUserNotQuitB(); // when already topped bool _isToppedUp = isToppedUp(); if(_isToppedUp) { require(toppedUpCToken == cToken, "already-topped-other-cToken"); } // 1. Transfer funds from the Pool contract IERC20 underlying = cToken.underlying(); underlying.safeTransferFrom(pool(), address(this), topupAmount); underlying.safeApprove(address(cToken), topupAmount); // 2. Repay borrows from Pool to topup require(cToken.repayBorrow(topupAmount) == 0, "RepayBorrow-fail"); // 3. Store Topped-up details if(! _isToppedUp) toppedUpCToken = cToken; toppedUpAmount = add_(toppedUpAmount, topupAmount); }
32,700
51
// if estimated index isnt correct, look one above and one below arrays can change, so index may be off, worst case tx fails and user has to repeat
if (_positions.length > _estimatedIndexInList) { if (_positions[_estimatedIndexInList.add(1)].id == _positionId) { return _estimatedIndexInList + 1; }
if (_positions.length > _estimatedIndexInList) { if (_positions[_estimatedIndexInList.add(1)].id == _positionId) { return _estimatedIndexInList + 1; }
51,009
63
// method to pay registration fee
function payRegistrationFee(address airlineAddress) external;
function payRegistrationFee(address airlineAddress) external;
44,207
612
// Vending Machine Authority./Contract to secure function calls to the Vending Machine./ Secured by setting the VendingMachine address and using the/ onlyVendingMachine modifier on functions requiring restriction.
contract VendingMachineAuthority { address internal VendingMachine; constructor(address _vendingMachine) public { VendingMachine = _vendingMachine; }
contract VendingMachineAuthority { address internal VendingMachine; constructor(address _vendingMachine) public { VendingMachine = _vendingMachine; }
31,777