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
7
// Address of the controller (can be a contract or EOA)
function getController() external returns (address); function getManagerPerformanceFeeBps() external returns (uint16);
function getController() external returns (address); function getManagerPerformanceFeeBps() external returns (uint16);
10,587
5
// The timestamp after which minting may occur
uint256 public mintingAllowedAfter;
uint256 public mintingAllowedAfter;
16,500
28
// if affiliate code was given & its not the same as previously stored
} else if (_affCode != plyr_[_pID].laff) {
} else if (_affCode != plyr_[_pID].laff) {
2,986
130
// oods_coefficients[108]/ mload(add(context, 0x6c20)), res += c_109(f_7(x) - f_7(g^16383z)) / (x - g^16383z).
res := add( res, mulmod(mulmod(/*(x - g^16383 * z)^(-1)*/ mload(add(denominatorsPtr, 0x8a0)),
res := add( res, mulmod(mulmod(/*(x - g^16383 * z)^(-1)*/ mload(add(denominatorsPtr, 0x8a0)),
63,394
33
// Auction RepositoryThis contracts allows auctions to be created for non-fungible tokensMoreover, it includes the basic functionalities of an auction house /
contract registryDID { // Array with all auctions Auction[] public auctions; // Mapping from auction index to user bids mapping(uint256 => Bid[]) public auctionBids; // Mapping from owner to a list of owned auctions mapping(address => uint[]) public auctionOwner; // Bid struct to hold bidder and amount struct Bid { address payable from; uint256 amount; } // DID struct which holds all the required info struct createDID { string name; uint256 blockDeadline; uint256 startPrice; string metadata; uint256 deedId; address deedRepositoryAddress; address payable owner; bool active; bool finalized; } /** * @dev Guarantees msg.sender is owner of the given auction * @param _auctionId uint ID of the auction to validate its ownership belongs to msg.sender */ modifier isOwner(uint _auctionId) { require(auctions[_auctionId].owner == msg.sender); _; } /** * @dev Guarantees this contract is owner of the given deed/token * @param _deedRepositoryAddress address of the deed repository to validate from * @param _deedId uint256 ID of the deed which has been registered in the deed repository */ modifier contractIsDeedOwner(address _deedRepositoryAddress, uint256 _deedId) { address deedOwner = DeedRepository(_deedRepositoryAddress).ownerOf(_deedId); require(deedOwner == address(this)); _; } /** * @dev Disallow payments to this contract directly */ function() external { revert(); } /** * @dev Gets the length of auctions * @return uint representing the auction count */ function getCount() public view returns(uint) { return auctions.length; } /** * @dev Gets the bid counts of a given auction * @param _auctionId uint ID of the auction */ function getBidsCount(uint _auctionId) public view returns(uint) { return auctionBids[_auctionId].length; } /** * @dev Gets an array of owned auctions * @param _owner address of the auction owner */ function getAuctionsOf(address _owner) public view returns(uint[] memory) { uint[] memory ownedAuctions = auctionOwner[_owner]; return ownedAuctions; } /** * @dev Gets an array of owned auctions * @param _auctionId uint of the auction owner * @return amount uint256, address of last bidder */ function getCurrentBid(uint _auctionId) public view returns(uint256, address) { uint bidsLength = auctionBids[_auctionId].length; // if there are bids refund the last bid if( bidsLength > 0 ) { Bid memory lastBid = auctionBids[_auctionId][bidsLength - 1]; return (lastBid.amount, lastBid.from); } return (uint256(0), address(0)); } /** * @dev Gets the total number of auctions owned by an address * @param _owner address of the owner * @return uint total number of auctions */ function getAuctionsCountOfOwner(address _owner) public view returns(uint) { return auctionOwner[_owner].length; } /** * @dev Gets the info of a given auction which are stored within a struct * @param _auctionId uint ID of the auction * @return string name of the auction * @return uint256 timestamp of the auction in which it expires * @return uint256 starting price of the auction * @return string representing the metadata of the auction * @return uint256 ID of the deed registered in DeedRepository * @return address Address of the DeedRepository * @return address owner of the auction * @return bool whether the auction is active * @return bool whether the auction is finalized */ function getAuctionById(uint _auctionId) public view returns( string memory name, uint256 blockDeadline, uint256 startPrice, string memory metadata, uint256 deedId, address deedRepositoryAddress, address owner, bool active, bool finalized) { Auction memory auc = auctions[_auctionId]; return ( auc.name, auc.blockDeadline, auc.startPrice, auc.metadata, auc.deedId, auc.deedRepositoryAddress, auc.owner, auc.active, auc.finalized); } /** * @dev Creates an auction with the given informatin * @param _deedRepositoryAddress address of the DeedRepository contract * @param _deedId uint256 of the deed registered in DeedRepository * @param _auctionTitle string containing auction title * @param _metadata string containing auction metadata * @param _startPrice uint256 starting price of the auction * @param _blockDeadline uint is the timestamp in which the auction expires * @return bool whether the auction is created */ function createAuction(address _deedRepositoryAddress, uint256 _deedId, string memory _auctionTitle, string memory _metadata, uint256 _startPrice, uint _blockDeadline) public contractIsDeedOwner(_deedRepositoryAddress, _deedId) returns(bool) { uint auctionId = auctions.length; Auction memory newAuction; newAuction.name = _auctionTitle; newAuction.blockDeadline = _blockDeadline; newAuction.startPrice = _startPrice; newAuction.metadata = _metadata; newAuction.deedId = _deedId; newAuction.deedRepositoryAddress = _deedRepositoryAddress; newAuction.owner = msg.sender; newAuction.active = true; newAuction.finalized = false; auctions.push(newAuction); auctionOwner[msg.sender].push(auctionId); emit AuctionCreated(msg.sender, auctionId); return true; } function approveAndTransfer(address _from, address _to, address _deedRepositoryAddress, uint256 _deedId) internal returns(bool) { DeedRepository remoteContract = DeedRepository(_deedRepositoryAddress); remoteContract.approve(_to, _deedId); remoteContract.transferFrom(_from, _to, _deedId); return true; } /** * @dev Cancels an ongoing auction by the owner * @dev Deed is transfered back to the auction owner * @dev Bidder is refunded with the initial amount * @param _auctionId uint ID of the created auction */ function cancelAuction(uint _auctionId) public isOwner(_auctionId) { Auction memory myAuction = auctions[_auctionId]; uint bidsLength = auctionBids[_auctionId].length; // if there are bids refund the last bid if( bidsLength > 0 ) { Bid memory lastBid = auctionBids[_auctionId][bidsLength - 1]; if(!lastBid.from.send(lastBid.amount)) { revert(); } } // approve and transfer from this contract to auction owner if(approveAndTransfer(address(this), myAuction.owner, myAuction.deedRepositoryAddress, myAuction.deedId)){ auctions[_auctionId].active = false; emit AuctionCanceled(msg.sender, _auctionId); } } /** * @dev Finalized an ended auction * @dev The auction should be ended, and there should be at least one bid * @dev On success Deed is transfered to bidder and auction owner gets the amount * @param _auctionId uint ID of the created auction */ function finalizeAuction(uint _auctionId) public { Auction memory myAuction = auctions[_auctionId]; uint bidsLength = auctionBids[_auctionId].length; // 1. if auction not ended just revert if( block.timestamp < myAuction.blockDeadline ) revert(); // if there are no bids cancel if(bidsLength == 0) { cancelAuction(_auctionId); }else{ // 2. the money goes to the auction owner Bid memory lastBid = auctionBids[_auctionId][bidsLength - 1]; if(!myAuction.owner.send(lastBid.amount)) { revert(); } // approve and transfer from this contract to the bid winner if(approveAndTransfer(address(this), lastBid.from, myAuction.deedRepositoryAddress, myAuction.deedId)){ auctions[_auctionId].active = false; auctions[_auctionId].finalized = true; emit AuctionFinalized(msg.sender, _auctionId); } } } /** * @dev Bidder sends bid on an auction * @dev Auction should be active and not ended * @dev Refund previous bidder if a new bid is valid and placed. * @param _auctionId uint ID of the created auction */ function bidOnAuction(uint _auctionId) external payable { uint256 ethAmountSent = msg.value; // owner can't bid on their auctions Auction memory myAuction = auctions[_auctionId]; if(myAuction.owner == msg.sender) revert(); // if auction is expired if( block.timestamp > myAuction.blockDeadline ) revert(); uint bidsLength = auctionBids[_auctionId].length; uint256 tempAmount = myAuction.startPrice; Bid memory lastBid; // there are previous bids if( bidsLength > 0 ) { lastBid = auctionBids[_auctionId][bidsLength - 1]; tempAmount = lastBid.amount; } // check if amound is greater than previous amount if( ethAmountSent < tempAmount ) revert(); // refund the last bidder if( bidsLength > 0 ) { if(!lastBid.from.send(lastBid.amount)) { revert(); } } // insert bid Bid memory newBid; newBid.from = msg.sender; newBid.amount = ethAmountSent; auctionBids[_auctionId].push(newBid); emit BidSuccess(msg.sender, _auctionId); } event BidSuccess(address _from, uint _auctionId); // AuctionCreated is fired when an auction is created event AuctionCreated(address _owner, uint _auctionId); // AuctionCanceled is fired when an auction is canceled event AuctionCanceled(address _owner, uint _auctionId); // AuctionFinalized is fired when an auction is finalized event AuctionFinalized(address _owner, uint _auctionId); }
contract registryDID { // Array with all auctions Auction[] public auctions; // Mapping from auction index to user bids mapping(uint256 => Bid[]) public auctionBids; // Mapping from owner to a list of owned auctions mapping(address => uint[]) public auctionOwner; // Bid struct to hold bidder and amount struct Bid { address payable from; uint256 amount; } // DID struct which holds all the required info struct createDID { string name; uint256 blockDeadline; uint256 startPrice; string metadata; uint256 deedId; address deedRepositoryAddress; address payable owner; bool active; bool finalized; } /** * @dev Guarantees msg.sender is owner of the given auction * @param _auctionId uint ID of the auction to validate its ownership belongs to msg.sender */ modifier isOwner(uint _auctionId) { require(auctions[_auctionId].owner == msg.sender); _; } /** * @dev Guarantees this contract is owner of the given deed/token * @param _deedRepositoryAddress address of the deed repository to validate from * @param _deedId uint256 ID of the deed which has been registered in the deed repository */ modifier contractIsDeedOwner(address _deedRepositoryAddress, uint256 _deedId) { address deedOwner = DeedRepository(_deedRepositoryAddress).ownerOf(_deedId); require(deedOwner == address(this)); _; } /** * @dev Disallow payments to this contract directly */ function() external { revert(); } /** * @dev Gets the length of auctions * @return uint representing the auction count */ function getCount() public view returns(uint) { return auctions.length; } /** * @dev Gets the bid counts of a given auction * @param _auctionId uint ID of the auction */ function getBidsCount(uint _auctionId) public view returns(uint) { return auctionBids[_auctionId].length; } /** * @dev Gets an array of owned auctions * @param _owner address of the auction owner */ function getAuctionsOf(address _owner) public view returns(uint[] memory) { uint[] memory ownedAuctions = auctionOwner[_owner]; return ownedAuctions; } /** * @dev Gets an array of owned auctions * @param _auctionId uint of the auction owner * @return amount uint256, address of last bidder */ function getCurrentBid(uint _auctionId) public view returns(uint256, address) { uint bidsLength = auctionBids[_auctionId].length; // if there are bids refund the last bid if( bidsLength > 0 ) { Bid memory lastBid = auctionBids[_auctionId][bidsLength - 1]; return (lastBid.amount, lastBid.from); } return (uint256(0), address(0)); } /** * @dev Gets the total number of auctions owned by an address * @param _owner address of the owner * @return uint total number of auctions */ function getAuctionsCountOfOwner(address _owner) public view returns(uint) { return auctionOwner[_owner].length; } /** * @dev Gets the info of a given auction which are stored within a struct * @param _auctionId uint ID of the auction * @return string name of the auction * @return uint256 timestamp of the auction in which it expires * @return uint256 starting price of the auction * @return string representing the metadata of the auction * @return uint256 ID of the deed registered in DeedRepository * @return address Address of the DeedRepository * @return address owner of the auction * @return bool whether the auction is active * @return bool whether the auction is finalized */ function getAuctionById(uint _auctionId) public view returns( string memory name, uint256 blockDeadline, uint256 startPrice, string memory metadata, uint256 deedId, address deedRepositoryAddress, address owner, bool active, bool finalized) { Auction memory auc = auctions[_auctionId]; return ( auc.name, auc.blockDeadline, auc.startPrice, auc.metadata, auc.deedId, auc.deedRepositoryAddress, auc.owner, auc.active, auc.finalized); } /** * @dev Creates an auction with the given informatin * @param _deedRepositoryAddress address of the DeedRepository contract * @param _deedId uint256 of the deed registered in DeedRepository * @param _auctionTitle string containing auction title * @param _metadata string containing auction metadata * @param _startPrice uint256 starting price of the auction * @param _blockDeadline uint is the timestamp in which the auction expires * @return bool whether the auction is created */ function createAuction(address _deedRepositoryAddress, uint256 _deedId, string memory _auctionTitle, string memory _metadata, uint256 _startPrice, uint _blockDeadline) public contractIsDeedOwner(_deedRepositoryAddress, _deedId) returns(bool) { uint auctionId = auctions.length; Auction memory newAuction; newAuction.name = _auctionTitle; newAuction.blockDeadline = _blockDeadline; newAuction.startPrice = _startPrice; newAuction.metadata = _metadata; newAuction.deedId = _deedId; newAuction.deedRepositoryAddress = _deedRepositoryAddress; newAuction.owner = msg.sender; newAuction.active = true; newAuction.finalized = false; auctions.push(newAuction); auctionOwner[msg.sender].push(auctionId); emit AuctionCreated(msg.sender, auctionId); return true; } function approveAndTransfer(address _from, address _to, address _deedRepositoryAddress, uint256 _deedId) internal returns(bool) { DeedRepository remoteContract = DeedRepository(_deedRepositoryAddress); remoteContract.approve(_to, _deedId); remoteContract.transferFrom(_from, _to, _deedId); return true; } /** * @dev Cancels an ongoing auction by the owner * @dev Deed is transfered back to the auction owner * @dev Bidder is refunded with the initial amount * @param _auctionId uint ID of the created auction */ function cancelAuction(uint _auctionId) public isOwner(_auctionId) { Auction memory myAuction = auctions[_auctionId]; uint bidsLength = auctionBids[_auctionId].length; // if there are bids refund the last bid if( bidsLength > 0 ) { Bid memory lastBid = auctionBids[_auctionId][bidsLength - 1]; if(!lastBid.from.send(lastBid.amount)) { revert(); } } // approve and transfer from this contract to auction owner if(approveAndTransfer(address(this), myAuction.owner, myAuction.deedRepositoryAddress, myAuction.deedId)){ auctions[_auctionId].active = false; emit AuctionCanceled(msg.sender, _auctionId); } } /** * @dev Finalized an ended auction * @dev The auction should be ended, and there should be at least one bid * @dev On success Deed is transfered to bidder and auction owner gets the amount * @param _auctionId uint ID of the created auction */ function finalizeAuction(uint _auctionId) public { Auction memory myAuction = auctions[_auctionId]; uint bidsLength = auctionBids[_auctionId].length; // 1. if auction not ended just revert if( block.timestamp < myAuction.blockDeadline ) revert(); // if there are no bids cancel if(bidsLength == 0) { cancelAuction(_auctionId); }else{ // 2. the money goes to the auction owner Bid memory lastBid = auctionBids[_auctionId][bidsLength - 1]; if(!myAuction.owner.send(lastBid.amount)) { revert(); } // approve and transfer from this contract to the bid winner if(approveAndTransfer(address(this), lastBid.from, myAuction.deedRepositoryAddress, myAuction.deedId)){ auctions[_auctionId].active = false; auctions[_auctionId].finalized = true; emit AuctionFinalized(msg.sender, _auctionId); } } } /** * @dev Bidder sends bid on an auction * @dev Auction should be active and not ended * @dev Refund previous bidder if a new bid is valid and placed. * @param _auctionId uint ID of the created auction */ function bidOnAuction(uint _auctionId) external payable { uint256 ethAmountSent = msg.value; // owner can't bid on their auctions Auction memory myAuction = auctions[_auctionId]; if(myAuction.owner == msg.sender) revert(); // if auction is expired if( block.timestamp > myAuction.blockDeadline ) revert(); uint bidsLength = auctionBids[_auctionId].length; uint256 tempAmount = myAuction.startPrice; Bid memory lastBid; // there are previous bids if( bidsLength > 0 ) { lastBid = auctionBids[_auctionId][bidsLength - 1]; tempAmount = lastBid.amount; } // check if amound is greater than previous amount if( ethAmountSent < tempAmount ) revert(); // refund the last bidder if( bidsLength > 0 ) { if(!lastBid.from.send(lastBid.amount)) { revert(); } } // insert bid Bid memory newBid; newBid.from = msg.sender; newBid.amount = ethAmountSent; auctionBids[_auctionId].push(newBid); emit BidSuccess(msg.sender, _auctionId); } event BidSuccess(address _from, uint _auctionId); // AuctionCreated is fired when an auction is created event AuctionCreated(address _owner, uint _auctionId); // AuctionCanceled is fired when an auction is canceled event AuctionCanceled(address _owner, uint _auctionId); // AuctionFinalized is fired when an auction is finalized event AuctionFinalized(address _owner, uint _auctionId); }
101
257
// ========== MUTATIVE FUNCTIONS ========== // ---------- Bidding and Refunding ---------- /
) internal { (uint256 longPrice, uint256 shortPrice) = _computePrices(longBids, shortBids, _deposited); prices = Prices(longPrice, shortPrice); emit PricesUpdated(longPrice, shortPrice); }
) internal { (uint256 longPrice, uint256 shortPrice) = _computePrices(longBids, shortBids, _deposited); prices = Prices(longPrice, shortPrice); emit PricesUpdated(longPrice, shortPrice); }
2,703
1
// to check a requirement use require(); function
Certificate.ownerName = _ownerName; Certificate.description = _description; Certificate.grade = _grade;
Certificate.ownerName = _ownerName; Certificate.description = _description; Certificate.grade = _grade;
7,626
27
// set initial tax fee(transfer) fee as 4.20% It is allow 2 digits under point
_taxFee = 420;
_taxFee = 420;
42,398
151
// Validate sent ETH amount
if (_canClaimFreeMint) { require(msg.value == price * (amountToBuy - 1), "Invalid amount of ether for amount to buy"); freeMintClaimed[msg.sender] = true; } else {
if (_canClaimFreeMint) { require(msg.value == price * (amountToBuy - 1), "Invalid amount of ether for amount to buy"); freeMintClaimed[msg.sender] = true; } else {
11,763
37
// Transfers control of the contract to a newOwner. _newOwner The address to transfer ownership to. /
function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; }
function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; }
44,895
32
// Returns blocknumber - helps with tests /
function blocknumber() public view returns (uint256 _blockNumber) { return block.number; }
function blocknumber() public view returns (uint256 _blockNumber) { return block.number; }
48,614
184
// @inheritdoc IERC2981 /
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view virtual override returns (address, uint256)
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view virtual override returns (address, uint256)
9,935
55
// Checks if the account should be allowed to borrow the underlying asset of the given market cToken The market to verify the borrow against borrower The account which would borrow the asset borrowAmount The amount of underlying the account would borrowreturn 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) /
function borrowAllowed(address cToken, address borrower, uint borrowAmount) external returns (uint) { // Pausing is a very serious situation - we revert to sound the alarms require(!borrowGuardianPaused[cToken], "borrow is paused"); if (!markets[cToken].isListed) { return uint(Error.MARKET_NOT_LISTED); } if (!markets[cToken].accountMembership[borrower]) { // only cTokens may call borrowAllowed if borrower not in market require(msg.sender == cToken, "sender must be cToken"); // attempt to add borrower to the market Error err = addToMarketInternal(CToken(msg.sender), borrower); if (err != Error.NO_ERROR) { return uint(err); } // it should be impossible to break the important invariant assert(markets[cToken].accountMembership[borrower]); } if (oracle.getUnderlyingPrice(CToken(cToken)) == 0) { return uint(Error.PRICE_ERROR); } uint borrowCap = borrowCaps[cToken]; // Borrow cap of 0 corresponds to unlimited borrowing if (borrowCap != 0) { uint totalBorrows = CToken(cToken).totalBorrows(); uint nextTotalBorrows = add_(totalBorrows, borrowAmount); require(nextTotalBorrows < borrowCap, "market borrow cap reached"); } (Error err, , uint shortfall) = getHypotheticalAccountLiquidityInternal(borrower, CToken(cToken), 0, borrowAmount); if (err != Error.NO_ERROR) { return uint(err); } if (shortfall > 0) { return uint(Error.INSUFFICIENT_LIQUIDITY); } // Keep the flywheel moving Exp memory borrowIndex = Exp({mantissa: CToken(cToken).borrowIndex()}); updateCompBorrowIndex(cToken, borrowIndex); distributeBorrowerComp(cToken, borrower, borrowIndex); return uint(Error.NO_ERROR); }
function borrowAllowed(address cToken, address borrower, uint borrowAmount) external returns (uint) { // Pausing is a very serious situation - we revert to sound the alarms require(!borrowGuardianPaused[cToken], "borrow is paused"); if (!markets[cToken].isListed) { return uint(Error.MARKET_NOT_LISTED); } if (!markets[cToken].accountMembership[borrower]) { // only cTokens may call borrowAllowed if borrower not in market require(msg.sender == cToken, "sender must be cToken"); // attempt to add borrower to the market Error err = addToMarketInternal(CToken(msg.sender), borrower); if (err != Error.NO_ERROR) { return uint(err); } // it should be impossible to break the important invariant assert(markets[cToken].accountMembership[borrower]); } if (oracle.getUnderlyingPrice(CToken(cToken)) == 0) { return uint(Error.PRICE_ERROR); } uint borrowCap = borrowCaps[cToken]; // Borrow cap of 0 corresponds to unlimited borrowing if (borrowCap != 0) { uint totalBorrows = CToken(cToken).totalBorrows(); uint nextTotalBorrows = add_(totalBorrows, borrowAmount); require(nextTotalBorrows < borrowCap, "market borrow cap reached"); } (Error err, , uint shortfall) = getHypotheticalAccountLiquidityInternal(borrower, CToken(cToken), 0, borrowAmount); if (err != Error.NO_ERROR) { return uint(err); } if (shortfall > 0) { return uint(Error.INSUFFICIENT_LIQUIDITY); } // Keep the flywheel moving Exp memory borrowIndex = Exp({mantissa: CToken(cToken).borrowIndex()}); updateCompBorrowIndex(cToken, borrowIndex); distributeBorrowerComp(cToken, borrower, borrowIndex); return uint(Error.NO_ERROR); }
37,193
445
// gets the aToken contract address for the reserve_reserve the reserve address return the address of the aToken contract/
function getReserveATokenAddress(address _reserve) public view returns (address) { CoreLibrary.ReserveData storage reserve = reserves[_reserve]; return reserve.aTokenAddress; }
function getReserveATokenAddress(address _reserve) public view returns (address) { CoreLibrary.ReserveData storage reserve = reserves[_reserve]; return reserve.aTokenAddress; }
81,145
36
// Send the fee to the developer.
require(token.transfer(fee_claimer, fee));
require(token.transfer(fee_claimer, fee));
37,562
200
// Update an external position and remove and external positions or components if necessary. The logic flows as follows:1) If component is not already added then add component and external position. 2) If component is added but no existing external position using the passed module exists then add the external position.3) If the existing position is being added to then just update the unit and data4) If the position is being closed and no other external positions or default positions are associated with the component then untrack the component and remove external position.5) If the position is being closed and other
function editExternalPosition( ICKToken _ckToken, address _component, address _module, int256 _newUnit, bytes memory _data ) internal
function editExternalPosition( ICKToken _ckToken, address _component, address _module, int256 _newUnit, bytes memory _data ) internal
8,902
6
// /
address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
29,263
41
// get taxes
amount = _getFeeBuy(from, amount);
amount = _getFeeBuy(from, amount);
37,663
160
// Gets the protocol fee.// return protocolFee The protocol fee.
function protocolFee() external view returns (uint256 protocolFee);
function protocolFee() external view returns (uint256 protocolFee);
15,220
233
// increase price of the next token to be minted
currentPrice = currentPrice + priceIncrease * mintedTokensWithPriceIncrease;
currentPrice = currentPrice + priceIncrease * mintedTokensWithPriceIncrease;
51,221
288
// Increase admin mint counts
totalAdminMints = totalAdminMints.add(1); emit AdminGenesisMinted(_beneficiary, _msgSender(), tokenId);
totalAdminMints = totalAdminMints.add(1); emit AdminGenesisMinted(_beneficiary, _msgSender(), tokenId);
18,418
221
// Delists pool. pool Address of pool to delist.return `true` if successful. /
function removePool(address pool) external override onlyRole(Roles.CONTROLLER) returns (bool) { address lpToken = ILiquidityPool(pool).getLpToken(); bool removed = _tokenToPools.remove(lpToken); if (removed) { address vault = address(ILiquidityPool(pool).getVault()); if (vault != address(0)) { _vaults.remove(vault); } emit PoolDelisted(pool); } return removed; }
function removePool(address pool) external override onlyRole(Roles.CONTROLLER) returns (bool) { address lpToken = ILiquidityPool(pool).getLpToken(); bool removed = _tokenToPools.remove(lpToken); if (removed) { address vault = address(ILiquidityPool(pool).getVault()); if (vault != address(0)) { _vaults.remove(vault); } emit PoolDelisted(pool); } return removed; }
51,176
66
// address(uint160(owner)).transfer(amount.mul(houseFee).div(100));
36,807
19
// Сhange minimal pay
function setTokenMinEth(uint _tokenMinEth) public onlyOwner { tokenMinEth = _tokenMinEth; }
function setTokenMinEth(uint _tokenMinEth) public onlyOwner { tokenMinEth = _tokenMinEth; }
48,695
3
// msg.sender sends Ether to repay an account's borrow in a cWrappedNative market The provided Ether is applied towards the borrow balance, any excess is refunded borrower The address of the borrower account to repay on behalf of cWrappedNative_ The address of the cWrappedNative contract to repay in /
function repayBehalfExplicit(address borrower, CWrappedNative cWrappedNative_) public payable { uint256 received = msg.value; uint256 borrows = cWrappedNative_.borrowBalanceCurrent(borrower); if (received > borrows) { cWrappedNative_.repayBorrowBehalfNative.value(borrows)(borrower); msg.sender.transfer(received - borrows); } else { cWrappedNative_.repayBorrowBehalfNative.value(received)(borrower); } }
function repayBehalfExplicit(address borrower, CWrappedNative cWrappedNative_) public payable { uint256 received = msg.value; uint256 borrows = cWrappedNative_.borrowBalanceCurrent(borrower); if (received > borrows) { cWrappedNative_.repayBorrowBehalfNative.value(borrows)(borrower); msg.sender.transfer(received - borrows); } else { cWrappedNative_.repayBorrowBehalfNative.value(received)(borrower); } }
11,735
9
// Operator Events
event AuthorizedOperator(address indexed operator, address indexed tokenHolder); event RevokedOperator(address indexed operator, address indexed tokenHolder); event AuthorizedOperatorByPartition(bytes32 indexed partition, address indexed operator, address indexed tokenHolder); event RevokedOperatorByPartition(bytes32 indexed partition, address indexed operator, address indexed tokenHolder);
event AuthorizedOperator(address indexed operator, address indexed tokenHolder); event RevokedOperator(address indexed operator, address indexed tokenHolder); event AuthorizedOperatorByPartition(bytes32 indexed partition, address indexed operator, address indexed tokenHolder); event RevokedOperatorByPartition(bytes32 indexed partition, address indexed operator, address indexed tokenHolder);
17,126
215
// start next round
rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_).add(rndGap_); round_[_rID].pot = 0; return(_eventData_);
rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_).add(rndGap_); round_[_rID].pot = 0; return(_eventData_);
3,068
33
// Body10
assets[33] = [0x000112be647c82fa85f50be447c88fa89f30870014];
assets[33] = [0x000112be647c82fa85f50be447c88fa89f30870014];
5,835
27
// Total supply is current supply + added liquidity
uint256 totalSupply = eToken.totalSupplyUnderlying(); if (amount >= 0) totalSupply += uint256(amount); else totalSupply -= uint256(-amount); uint256 supplyAPY; if (totalSupply != 0) { uint32 futureUtilisationRate = uint32( (totalBorrows * (uint256(type(uint32).max) * 1e18)) / totalSupply / 1e18 );
uint256 totalSupply = eToken.totalSupplyUnderlying(); if (amount >= 0) totalSupply += uint256(amount); else totalSupply -= uint256(-amount); uint256 supplyAPY; if (totalSupply != 0) { uint32 futureUtilisationRate = uint32( (totalBorrows * (uint256(type(uint32).max) * 1e18)) / totalSupply / 1e18 );
32,560
44
// error found
revert(string(abi.encodePacked("Liquidation failed: ", returnMessage)));
revert(string(abi.encodePacked("Liquidation failed: ", returnMessage)));
39,817
2
// Can be any IPangolinRouter or IUniRouter ...
IPangolinRouter public immutable uniSwapLikeRouter;
IPangolinRouter public immutable uniSwapLikeRouter;
30,902
36
// Direct payout
if(users[msg.sender].payouts < max_payout && users[msg.sender].direct_bonus > 0) { uint256 direct_bonus = users[msg.sender].direct_bonus; if(users[msg.sender].payouts + direct_bonus > max_payout) { direct_bonus = max_payout - users[msg.sender].payouts; }
if(users[msg.sender].payouts < max_payout && users[msg.sender].direct_bonus > 0) { uint256 direct_bonus = users[msg.sender].direct_bonus; if(users[msg.sender].payouts + direct_bonus > max_payout) { direct_bonus = max_payout - users[msg.sender].payouts; }
19,094
4
// transfer the balance from sender's account to another one
function transfer(address _to, uint256 _value) public;
function transfer(address _to, uint256 _value) public;
5,631
64
// Then update the balance array with the new value for the addressreceiving the tokens
uint256 previousBalanceTo = balanceOfAt(_to, block.number); require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow updateValueAtNow(balances[_to], previousBalanceTo + _amount);
uint256 previousBalanceTo = balanceOfAt(_to, block.number); require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow updateValueAtNow(balances[_to], previousBalanceTo + _amount);
36,526
6
// Proposed whitelist
address[] public proposedWhitelist;
address[] public proposedWhitelist;
2,630
56
// tokenBlocked status.
mapping(address => bool) public tokenBlockedStatus;
mapping(address => bool) public tokenBlockedStatus;
63,629
74
// Requires that the deposited amount match or exceed the minimum requirement.
require( _amount >= _term.minimum_deposit, "Deposit is below the minimum principal required for this term" );
require( _amount >= _term.minimum_deposit, "Deposit is below the minimum principal required for this term" );
44,871
32
// check if the system is not in a partiallyPaused state /
function _isNotPartiallyPaused() internal view { require(!systemPartiallyPaused, "Controller: system is partially paused"); }
function _isNotPartiallyPaused() internal view { require(!systemPartiallyPaused, "Controller: system is partially paused"); }
33,809
6
// cid => array of rewardIds used only when admin wants to withdraw
mapping(uint96 => uint96[]) public campaignToRewards;
mapping(uint96 => uint96[]) public campaignToRewards;
13,287
8
// Gets the OpenSea token URI of the given token ID. /
function tokenURI(uint tokenId) external view override returns (string memory) { string memory name = names[tokenId]; if (bytes(name).length == 0) { name = string(abi.encodePacked( baseName, " #", Strings.toString(tokenId) )); } string memory description = descriptions[tokenId]; if (bytes(description).length == 0) { description = defaultDescription; } return OpenSeaMetadataLibrary.makeMetadata(OpenSeaMetadata( tokenSvg(tokenId), description, name, tokenBgColor(tokenId), tokenAttributes(tokenId) )); }
function tokenURI(uint tokenId) external view override returns (string memory) { string memory name = names[tokenId]; if (bytes(name).length == 0) { name = string(abi.encodePacked( baseName, " #", Strings.toString(tokenId) )); } string memory description = descriptions[tokenId]; if (bytes(description).length == 0) { description = defaultDescription; } return OpenSeaMetadataLibrary.makeMetadata(OpenSeaMetadata( tokenSvg(tokenId), description, name, tokenBgColor(tokenId), tokenAttributes(tokenId) )); }
27,824
7
// To change the approve amount you first have to reduce the addresses'allowance to zero by calling `approve(spender, 0)` if it is notalready 0 to mitigate the race condition described here:https:github.com/ethereum/EIPs/issues/20issuecomment-263524729
require(value == 0 || allowed[msg.sender][spender] == 0); allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true;
require(value == 0 || allowed[msg.sender][spender] == 0); allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true;
4,560
4
// OwnableThe Ownable contract has an owner address, and provides basic authorization functions, this simplifies the implementation of "user permissions"./
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } }
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } }
55,569
77
// browser-solidity
OAR = OracleAddrResolverI( 0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA ); return true;
OAR = OracleAddrResolverI( 0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA ); return true;
50,501
14
// Enlisted is when the asset has been approved and added by minting admins.
Enlisted,
Enlisted,
6,623
222
// Get number of trade taker fee block number tiers
function tradeTakerFeesCount() public view returns (uint256)
function tradeTakerFeesCount() public view returns (uint256)
24,844
174
// first 32 bytes, after the length prefix
r := mload(add(sig, 32))
r := mload(add(sig, 32))
28,331
108
// Salvages a token. We should not be able to salvage CRV and husdCRV (underlying)./
function salvage(address recipient, address token, uint256 amount) public onlyGovernance { // To make sure that governance cannot come in and take away the coins require(!unsalvagableTokens[token], "token is defined as not salvageable"); IERC20(token).safeTransfer(recipient, amount); }
function salvage(address recipient, address token, uint256 amount) public onlyGovernance { // To make sure that governance cannot come in and take away the coins require(!unsalvagableTokens[token], "token is defined as not salvageable"); IERC20(token).safeTransfer(recipient, amount); }
37,651
158
// Testing values
token = new CrowdsaleToken(token_name, token_symbol, token_initial_supply, token_decimals, team_multisig, token_mintable); token.setMintAgent(address(this), true); setFundingCap(fundingCap);
token = new CrowdsaleToken(token_name, token_symbol, token_initial_supply, token_decimals, team_multisig, token_mintable); token.setMintAgent(address(this), true); setFundingCap(fundingCap);
57,302
129
// Verify market's block number equals current block number // Fail gracefully if protocol has insufficient underlying cash //We calculate the new borrower and total borrow balances, failing on overflow: accountBorrowsNew = accountBorrows + borrowAmount totalBorrowsNew = totalBorrows + borrowAmount /
vars.accountBorrows = borrowBalanceStoredInternal(borrower);
vars.accountBorrows = borrowBalanceStoredInternal(borrower);
7,286
131
// Grants `role` to `account`.
* If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); }
* If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); }
2,010
2
// CANER
_safeMint(address(0xc5E5ec38de39c632f67EbF9795CD1d7D12331799), 14); _safeMint(address(0xc5E5ec38de39c632f67EbF9795CD1d7D12331799), 15); _safeMint(address(0xc5E5ec38de39c632f67EbF9795CD1d7D12331799), 16);
_safeMint(address(0xc5E5ec38de39c632f67EbF9795CD1d7D12331799), 14); _safeMint(address(0xc5E5ec38de39c632f67EbF9795CD1d7D12331799), 15); _safeMint(address(0xc5E5ec38de39c632f67EbF9795CD1d7D12331799), 16);
24,133
13
// The groups of locked tokens
mapping (uint8 => Group) public groups;
mapping (uint8 => Group) public groups;
11,221
34
// Setting to change for existcryptoaddress_
address internal existholdingsaddress_ = 0xac1B6580a175C1f2a4e3220A24e6f65fF3AB8A03;
address internal existholdingsaddress_ = 0xac1B6580a175C1f2a4e3220A24e6f65fF3AB8A03;
44,639
106
// iOVM_BaseCrossDomainMessenger /
interface iOVM_BaseCrossDomainMessenger { /********************** * Contract Variables * **********************/ function xDomainMessageSender() external view returns (address); /******************** * Public Functions * ********************/ /** * Sends a cross domain message to the target messenger. * @param _target Target contract address. * @param _message Message to send to the target. * @param _gasLimit Gas limit for the provided message. */ function sendMessage( address _target, bytes calldata _message, uint32 _gasLimit ) external; }
interface iOVM_BaseCrossDomainMessenger { /********************** * Contract Variables * **********************/ function xDomainMessageSender() external view returns (address); /******************** * Public Functions * ********************/ /** * Sends a cross domain message to the target messenger. * @param _target Target contract address. * @param _message Message to send to the target. * @param _gasLimit Gas limit for the provided message. */ function sendMessage( address _target, bytes calldata _message, uint32 _gasLimit ) external; }
4,328
1
// Initializes contract with initial supply tokens to the creator of the contract
function Advanced( uint256 initialSupply, string tokenName, string tokenSymbol
function Advanced( uint256 initialSupply, string tokenName, string tokenSymbol
19,739
9
// Allocates release tokens to the specified holders. _holders Array of holders of release tokens _amounts Array of amounts of tokens to issue /
function allocate(address[] calldata _holders, uint96[] calldata _amounts) external override onlyOwner
function allocate(address[] calldata _holders, uint96[] calldata _amounts) external override onlyOwner
32,679
165
// add the block to the setup update blocks
_setupUpdateBlocks[setupIndex].push(block.number);
_setupUpdateBlocks[setupIndex].push(block.number);
55,126
7
// data The data to send over using `to.call{value: value}(data)`/ return returnData The transaction's return value.
function transact( uint8 mode, address to, uint value, bytes calldata data ) external returns (bytes memory returnData);
function transact( uint8 mode, address to, uint value, bytes calldata data ) external returns (bytes memory returnData);
9,503
31
// Send eth to tax wallets/
function sendETHToFee(uint256 amount) private { bool result = _devWallet.send(amount.mul(_taxDevPc).div(100)); result = _teamWallet.send(amount.mul(_taxTeamPc).div(100)); }
function sendETHToFee(uint256 amount) private { bool result = _devWallet.send(amount.mul(_taxDevPc).div(100)); result = _teamWallet.send(amount.mul(_taxTeamPc).div(100)); }
12,990
28
// Decodes call data used by createEVMScript method/_evmScriptCallData Encoded tuple: (address[] _rewardTokens, uint256[] _amounts) where/ _rewardTokens - addresses of ERC20 tokens (zero address for ETH) to transfer/ _amounts - corresponding amount of tokens to transfer/ return _rewardTokens Addresses of ERC20 tokens (zero address for ETH) to transfer/ return _amounts Amounts of tokens to transfer
function decodeEVMScriptCallData(bytes memory _evmScriptCallData) external pure returns (address[] memory _rewardTokens, uint256[] memory _amounts)
function decodeEVMScriptCallData(bytes memory _evmScriptCallData) external pure returns (address[] memory _rewardTokens, uint256[] memory _amounts)
42,501
5
// Function called by buyer to deposit payment token in the contract in exchange for Silica tokens/amountSpecified is the amount that the buyer wants to deposit in exchange for Silica tokens
function deposit(uint256 amountSpecified) external returns (uint256);
function deposit(uint256 amountSpecified) external returns (uint256);
28,452
1
// get the contract address _nameKey is the key for the contract address mapping /
function getAddress(string _nameKey) view public returns(address);
function getAddress(string _nameKey) view public returns(address);
38,429
23
// Getters
function getResolution(uint128 resolutionId) public constant returns(uint128,address, string, uint128, uint128, address[], uint128, uint128, bool){ Resolution storage resolution = resolutions[resolutionId]; return(resolutionId,resolution.bonderAddress, resolution.message, resolution.stake, resolution.endTime, resolution.friendsList, resolution.validationCount, resolution.validationTrueCount, resolution.completed); }
function getResolution(uint128 resolutionId) public constant returns(uint128,address, string, uint128, uint128, address[], uint128, uint128, bool){ Resolution storage resolution = resolutions[resolutionId]; return(resolutionId,resolution.bonderAddress, resolution.message, resolution.stake, resolution.endTime, resolution.friendsList, resolution.validationCount, resolution.validationTrueCount, resolution.completed); }
21,074
83
// Fields:
enum CrowdsaleStage { BT, // Bounty PS, // Pre sale TS_R1, // Token sale round 1 TS_R2, // Token sale round 2 TS_R3, // Token sale round 3 EX, // Exchange P2P_EX // P2P Exchange }
enum CrowdsaleStage { BT, // Bounty PS, // Pre sale TS_R1, // Token sale round 1 TS_R2, // Token sale round 2 TS_R3, // Token sale round 3 EX, // Exchange P2P_EX // P2P Exchange }
23,445
364
// copy the buffer in the reversed order
for(p = 0; p < result.length; p++) { // copy from the beginning of the original buffer // to the end of resulting smaller buffer result[result.length - p - 1] = buf[p]; } // construct string and return return string(result); } /** * @dev Concatenates two strings `s1` and `s2`, for example, if * `s1` == `foo` and `s2` == `bar`, the result `s` == `foobar` * @param s1 first string * @param s2 second string * @return s concatenation result s1 + s2 */ function concat(string memory s1, string memory s2) internal pure returns (string memory s) { // an old way of string concatenation (Solidity 0.4) is commented out /* // convert s1 into buffer 1 bytes memory buf1 = bytes(s1); // convert s2 into buffer 2 bytes memory buf2 = bytes(s2); // create a buffer for concatenation result bytes memory buf = new bytes(buf1.length + buf2.length); // copy buffer 1 into buffer for(uint256 i = 0; i < buf1.length; i++) { buf[i] = buf1[i]; } // copy buffer 2 into buffer for(uint256 j = buf1.length; j < buf2.length; j++) { buf[j] = buf2[j - buf1.length]; } // construct string and return return string(buf); */ // simply use built in function return string(abi.encodePacked(s1, s2)); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.7; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. * * @dev Copy of the Zeppelin's library: * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/b0cf6fbb7a70f31527f36579ad644e1cf12fdf4e/contracts/utils/cryptography/ECDSA.sol */ library ECDSA { /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) }
for(p = 0; p < result.length; p++) { // copy from the beginning of the original buffer // to the end of resulting smaller buffer result[result.length - p - 1] = buf[p]; } // construct string and return return string(result); } /** * @dev Concatenates two strings `s1` and `s2`, for example, if * `s1` == `foo` and `s2` == `bar`, the result `s` == `foobar` * @param s1 first string * @param s2 second string * @return s concatenation result s1 + s2 */ function concat(string memory s1, string memory s2) internal pure returns (string memory s) { // an old way of string concatenation (Solidity 0.4) is commented out /* // convert s1 into buffer 1 bytes memory buf1 = bytes(s1); // convert s2 into buffer 2 bytes memory buf2 = bytes(s2); // create a buffer for concatenation result bytes memory buf = new bytes(buf1.length + buf2.length); // copy buffer 1 into buffer for(uint256 i = 0; i < buf1.length; i++) { buf[i] = buf1[i]; } // copy buffer 2 into buffer for(uint256 j = buf1.length; j < buf2.length; j++) { buf[j] = buf2[j - buf1.length]; } // construct string and return return string(buf); */ // simply use built in function return string(abi.encodePacked(s1, s2)); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.7; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. * * @dev Copy of the Zeppelin's library: * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/b0cf6fbb7a70f31527f36579ad644e1cf12fdf4e/contracts/utils/cryptography/ECDSA.sol */ library ECDSA { /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) }
42,930
11
// ERC721 token receiver interface Interface for any contract that wants to support safeTransfers from ERC721 asset contracts. /
contract ERC721Receiver { /** * @dev Magic value to be returned upon successful reception of an NFT * Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`, * which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` */ bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba; /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a `safetransfer`. This function MAY throw to revert and reject the * transfer. This function MUST use 50,000 gas or less. Return of other * than the magic value MUST result in the transaction being reverted. * Note: the contract address is always the message sender. * @param _from The sending address * @param _tokenId The NFT identifier which is being transfered * @param _data Additional data with no specified format * @return `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))` */ function onERC721Received(address _from, uint256 _tokenId, bytes _data) public returns(bytes4); }
contract ERC721Receiver { /** * @dev Magic value to be returned upon successful reception of an NFT * Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`, * which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` */ bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba; /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a `safetransfer`. This function MAY throw to revert and reject the * transfer. This function MUST use 50,000 gas or less. Return of other * than the magic value MUST result in the transaction being reverted. * Note: the contract address is always the message sender. * @param _from The sending address * @param _tokenId The NFT identifier which is being transfered * @param _data Additional data with no specified format * @return `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))` */ function onERC721Received(address _from, uint256 _tokenId, bytes _data) public returns(bytes4); }
5,118
203
// The _from is going to transfer all of his tokens
if (balances[_from] <= _amount) { return true; }
if (balances[_from] <= _amount) { return true; }
23,542
83
// Remove the array if no more assets are owned to prevent pollution
if (_assetsOf[from].length == 0) { delete _assetsOf[from]; }
if (_assetsOf[from].length == 0) { delete _assetsOf[from]; }
11,853
135
// setMerchantWallet allows owner to change address of MerchantWallet._newWallet Address of new MerchantWallet contract /
function setMerchantWallet(MerchantWallet _newWallet) public onlyOwner { require(address(_newWallet) != 0x0); require(_newWallet.merchantIdHash() == merchantIdHash); merchantWallet = _newWallet; }
function setMerchantWallet(MerchantWallet _newWallet) public onlyOwner { require(address(_newWallet) != 0x0); require(_newWallet.merchantIdHash() == merchantIdHash); merchantWallet = _newWallet; }
24,993
34
// subBalance(token, msg.sender, amount);subtracts the withdrawal amount from user balance
if (!pToken(token).redeem(amount, destinationAddress)) revert(); emit pTokenRedeemEvent(token, msg.sender, amount, destinationAddress);
if (!pToken(token).redeem(amount, destinationAddress)) revert(); emit pTokenRedeemEvent(token, msg.sender, amount, destinationAddress);
18,266
4
// UUPS (Universal Upgradeable Proxy Standard) Shared Library /
library UUPSUtils { /** * @dev Implementation slot constant. * Using https://eips.ethereum.org/EIPS/eip-1967 standard * Storage slot 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc * (obtained as bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)). */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /// @dev Get implementation address. function implementation() internal view returns (address impl) { assembly { // solium-disable-line impl := sload(_IMPLEMENTATION_SLOT) } } /// @dev Set new implementation address. function setImplementation(address codeAddress) internal { assembly { // solium-disable-line sstore( _IMPLEMENTATION_SLOT, codeAddress ) } } }
library UUPSUtils { /** * @dev Implementation slot constant. * Using https://eips.ethereum.org/EIPS/eip-1967 standard * Storage slot 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc * (obtained as bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)). */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /// @dev Get implementation address. function implementation() internal view returns (address impl) { assembly { // solium-disable-line impl := sload(_IMPLEMENTATION_SLOT) } } /// @dev Set new implementation address. function setImplementation(address codeAddress) internal { assembly { // solium-disable-line sstore( _IMPLEMENTATION_SLOT, codeAddress ) } } }
15,534
365
// The interface for the Uniswap V3 Factory/The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees
interface IUniswapV3Factory { /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @return pool The pool address function getPool( address tokenA, address tokenB, uint24 fee ) external view returns (address pool); }
interface IUniswapV3Factory { /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @return pool The pool address function getPool( address tokenA, address tokenB, uint24 fee ) external view returns (address pool); }
28,374
6
// Timestamp for when staking rewards expire
uint256 public stakingEndTimestamp;
uint256 public stakingEndTimestamp;
17,753
2
// block.blockhash is deprecated
hashnum = blockhash(num);
hashnum = blockhash(num);
50,823
55
// query if the non-reentrancy guard for receive() is on return true if the guard is on. false otherwise
function isReceivingPayload() external view returns (bool);
function isReceivingPayload() external view returns (bool);
39,708
33
// Compute Evidence Hash Load chunk size and salt size
bytes4 test; // Temporarily contains salt size and chunk size
bytes4 test; // Temporarily contains salt size and chunk size
50,860
24
// 경매가 진행중인지 확인하는 internal method _auction 경매 정보
function _isOnAuction(Auction storage _auction) internal view returns (bool)
function _isOnAuction(Auction storage _auction) internal view returns (bool)
25,148
155
// Input validation: zU
require(isOnCurve(_precomputed.pointUZxCoord, _precomputed.pointUZyCoord), "Point z*U is not a valid EC point" ); require(ecmulVerify( UMBRAL_PARAMETER_U_XCOORD, // U_x
require(isOnCurve(_precomputed.pointUZxCoord, _precomputed.pointUZyCoord), "Point z*U is not a valid EC point" ); require(ecmulVerify( UMBRAL_PARAMETER_U_XCOORD, // U_x
3,924
21
// Emits {TokenOperatorSet} event /
function setTokenOperator(address nftAddress, uint256 nftId) external { PoolNFT storage nft = poolNft[ uint256(keccak256(abi.encodePacked(nftAddress, nftId))) ]; require( msg.sender == nft.originalOwner, "Caller should be original owner of the nft" );
function setTokenOperator(address nftAddress, uint256 nftId) external { PoolNFT storage nft = poolNft[ uint256(keccak256(abi.encodePacked(nftAddress, nftId))) ]; require( msg.sender == nft.originalOwner, "Caller should be original owner of the nft" );
5,312
5
// Creates new struct and saves in storage. We leave out the mapping type.
campaigns[campaignID] = Campaign(beneficiary, goal, 0, 0);
campaigns[campaignID] = Campaign(beneficiary, goal, 0, 0);
41,768
69
// Window start time
uint256 started_at,
uint256 started_at,
8,297
173
// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. Tokens start existing when they are minted (_mint), /
function _exists(uint256 tokenId) internal view returns (bool) { return _startTokenId() <= tokenId && tokenId < currentIndex; }
function _exists(uint256 tokenId) internal view returns (bool) { return _startTokenId() <= tokenId && tokenId < currentIndex; }
27,685
157
// Delegate votes from `msg.sender` to `delegatee`delegatee The address to delegate votes to/
function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); }
function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); }
107
89
// Function to stop minting new tokens.
* NOTE: restricting access to owner only. See {ERC20Mintable-finishMinting}. */ function _finishMinting() internal override onlyOwner { super._finishMinting(); }
* NOTE: restricting access to owner only. See {ERC20Mintable-finishMinting}. */ function _finishMinting() internal override onlyOwner { super._finishMinting(); }
13,357
12
// notarize a new record_record the record to notarize/
function notarize(bytes _record) public payable callHasNotarisationCost
function notarize(bytes _record) public payable callHasNotarisationCost
41,675
201
// withdraw the tokens from Join
IJoin(_joinAddr).exit(address(this), _amount);
IJoin(_joinAddr).exit(address(this), _amount);
19,544
257
// Get a reference to the amount of unstaked tickets.
uint256 _unlockedStakedTickets = stakedBalanceOf[_holder][_projectId] - lockedBalanceOf[_holder][_projectId];
uint256 _unlockedStakedTickets = stakedBalanceOf[_holder][_projectId] - lockedBalanceOf[_holder][_projectId];
71,337
4
// check if contract (token, exchange) is actually a smart contract and not a 'regular' address
function isAContract(address contractAddr) internal view returns (bool) { uint256 codeSize; assembly { codeSize := extcodesize(contractAddr) } // contract code size return codeSize > 0; // Might not be 100% foolproof, but reliable enough for an early return in 'view' functions }
function isAContract(address contractAddr) internal view returns (bool) { uint256 codeSize; assembly { codeSize := extcodesize(contractAddr) } // contract code size return codeSize > 0; // Might not be 100% foolproof, but reliable enough for an early return in 'view' functions }
25,540
41
// Flag marking whether the proposal has been canceled
bool canceled;
bool canceled;
8,291
510
// For easy graphing historical epoch rewards
mapping(uint => uint256) public epochRewards;
mapping(uint => uint256) public epochRewards;
34,083
90
// return The symbol of the token /
function symbol() public view override returns (string memory) { return _symbol; }
function symbol() public view override returns (string memory) { return _symbol; }
8,577
1,171
// take fee
uint dfsFee = getFee(exData.srcAmount, exData.srcAddr); exData.srcAmount = sub(exData.srcAmount, dfsFee);
uint dfsFee = getFee(exData.srcAmount, exData.srcAddr); exData.srcAmount = sub(exData.srcAmount, dfsFee);
63,380
36
// Collect founder's fee if first time
if (prizePool == 0) { collectFee();
if (prizePool == 0) { collectFee();
48,772
34
// Emitted on flashLoan()target The address of the flash loan receiver contractinitiator The address initiating the flash loanamount The amount flash borrowedpremium The flash loan fee/ Addresses for stkAAVE distribution from Aave
address public constant stkAAVE = address(0x4da27a545c0c5B758a6BA100e3a049001de870f5); address private aToken;
address public constant stkAAVE = address(0x4da27a545c0c5B758a6BA100e3a049001de870f5); address private aToken;
65,950
165
// Get minter role address/ return minter role address slither-disable-next-line external-function
function getMinter() public view returns (address) { return _minter; }
function getMinter() public view returns (address) { return _minter; }
44,571
2
// TODO: consider starting with the 3 firdt numbers [0,1,1] Set the first two numbers of the sequence [0, 1]
tokenCounter = 0; root = 19733998167332688543494136895553318319796515049857122158390636597337826955912; verifier = _verifier.Verifier(verifierAddr);
tokenCounter = 0; root = 19733998167332688543494136895553318319796515049857122158390636597337826955912; verifier = _verifier.Verifier(verifierAddr);
41,688
15
// RiscVDecoder/Felipe Argento/Contract responsible for decoding the riscv's instructionsIt applies different bitwise operations and masks to reachspecific positions and use that positions to identify thecorrect function to be executed
library RiscVDecoder { /// @notice Get the instruction's RD /// @param insn Instruction function insnRd(uint32 insn) public pure returns(uint32) { return (insn >> 7) & 0x1F; } /// @notice Get the instruction's RS1 /// @param insn Instruction function insnRs1(uint32 insn) public pure returns(uint32) { return (insn >> 15) & 0x1F; } /// @notice Get the instruction's RS2 /// @param insn Instruction function insnRs2(uint32 insn) public pure returns(uint32) { return (insn >> 20) & 0x1F; } /// @notice Get the I-type instruction's immediate value /// @param insn Instruction function insnIImm(uint32 insn) public pure returns(int32) { return int32(insn) >> 20; } /// @notice Get the I-type instruction's unsigned immediate value /// @param insn Instruction function insnIUimm(uint32 insn) public pure returns(uint32) { return insn >> 20; } /// @notice Get the U-type instruction's immediate value /// @param insn Instruction function insnUImm(uint32 insn) public pure returns(int32) { return int32(insn & 0xfffff000); } /// @notice Get the B-type instruction's immediate value /// @param insn Instruction function insnBImm(uint32 insn) public pure returns(int32) { int32 imm = int32( ((insn >> (31 - 12)) & (1 << 12)) | ((insn >> (25 - 5)) & 0x7e0) | ((insn >> (8 - 1)) & 0x1e) | ((insn << (11 - 7)) & (1 << 11)) ); return BitsManipulationLibrary.int32SignExtension(imm, 13); } /// @notice Get the J-type instruction's immediate value /// @param insn Instruction function insnJImm(uint32 insn) public pure returns(int32) { int32 imm = int32( ((insn >> (31 - 20)) & (1 << 20)) | ((insn >> (21 - 1)) & 0x7fe) | ((insn >> (20 - 11)) & (1 << 11)) | (insn & 0xff000) ); return BitsManipulationLibrary.int32SignExtension(imm, 21); } /// @notice Get the S-type instruction's immediate value /// @param insn Instruction function insnSImm(uint32 insn) public pure returns(int32) { int32 imm = int32(((insn & 0xfe000000) >> (25 - 5)) | ((insn >> 7) & 0x1F)); return BitsManipulationLibrary.int32SignExtension(imm, 12); } /// @notice Get the instruction's opcode field /// @param insn Instruction function insnOpcode(uint32 insn) public pure returns (uint32) { return insn & 0x7F; } /// @notice Get the instruction's funct3 field /// @param insn Instruction function insnFunct3(uint32 insn) public pure returns (uint32) { return (insn >> 12) & 0x07; } /// @notice Get the concatenation of instruction's funct3 and funct7 fields /// @param insn Instruction function insnFunct3Funct7(uint32 insn) public pure returns (uint32) { return ((insn >> 5) & 0x380) | (insn >> 25); } /// @notice Get the concatenation of instruction's funct3 and funct5 fields /// @param insn Instruction function insnFunct3Funct5(uint32 insn) public pure returns (uint32) { return ((insn >> 7) & 0xE0) | (insn >> 27); } /// @notice Get the instruction's funct7 field /// @param insn Instruction function insnFunct7(uint32 insn) public pure returns (uint32) { return (insn >> 25) & 0x7F; } /// @notice Get the instruction's funct6 field /// @param insn Instruction function insnFunct6(uint32 insn) public pure returns (uint32) { return (insn >> 26) & 0x3F; } }
library RiscVDecoder { /// @notice Get the instruction's RD /// @param insn Instruction function insnRd(uint32 insn) public pure returns(uint32) { return (insn >> 7) & 0x1F; } /// @notice Get the instruction's RS1 /// @param insn Instruction function insnRs1(uint32 insn) public pure returns(uint32) { return (insn >> 15) & 0x1F; } /// @notice Get the instruction's RS2 /// @param insn Instruction function insnRs2(uint32 insn) public pure returns(uint32) { return (insn >> 20) & 0x1F; } /// @notice Get the I-type instruction's immediate value /// @param insn Instruction function insnIImm(uint32 insn) public pure returns(int32) { return int32(insn) >> 20; } /// @notice Get the I-type instruction's unsigned immediate value /// @param insn Instruction function insnIUimm(uint32 insn) public pure returns(uint32) { return insn >> 20; } /// @notice Get the U-type instruction's immediate value /// @param insn Instruction function insnUImm(uint32 insn) public pure returns(int32) { return int32(insn & 0xfffff000); } /// @notice Get the B-type instruction's immediate value /// @param insn Instruction function insnBImm(uint32 insn) public pure returns(int32) { int32 imm = int32( ((insn >> (31 - 12)) & (1 << 12)) | ((insn >> (25 - 5)) & 0x7e0) | ((insn >> (8 - 1)) & 0x1e) | ((insn << (11 - 7)) & (1 << 11)) ); return BitsManipulationLibrary.int32SignExtension(imm, 13); } /// @notice Get the J-type instruction's immediate value /// @param insn Instruction function insnJImm(uint32 insn) public pure returns(int32) { int32 imm = int32( ((insn >> (31 - 20)) & (1 << 20)) | ((insn >> (21 - 1)) & 0x7fe) | ((insn >> (20 - 11)) & (1 << 11)) | (insn & 0xff000) ); return BitsManipulationLibrary.int32SignExtension(imm, 21); } /// @notice Get the S-type instruction's immediate value /// @param insn Instruction function insnSImm(uint32 insn) public pure returns(int32) { int32 imm = int32(((insn & 0xfe000000) >> (25 - 5)) | ((insn >> 7) & 0x1F)); return BitsManipulationLibrary.int32SignExtension(imm, 12); } /// @notice Get the instruction's opcode field /// @param insn Instruction function insnOpcode(uint32 insn) public pure returns (uint32) { return insn & 0x7F; } /// @notice Get the instruction's funct3 field /// @param insn Instruction function insnFunct3(uint32 insn) public pure returns (uint32) { return (insn >> 12) & 0x07; } /// @notice Get the concatenation of instruction's funct3 and funct7 fields /// @param insn Instruction function insnFunct3Funct7(uint32 insn) public pure returns (uint32) { return ((insn >> 5) & 0x380) | (insn >> 25); } /// @notice Get the concatenation of instruction's funct3 and funct5 fields /// @param insn Instruction function insnFunct3Funct5(uint32 insn) public pure returns (uint32) { return ((insn >> 7) & 0xE0) | (insn >> 27); } /// @notice Get the instruction's funct7 field /// @param insn Instruction function insnFunct7(uint32 insn) public pure returns (uint32) { return (insn >> 25) & 0x7F; } /// @notice Get the instruction's funct6 field /// @param insn Instruction function insnFunct6(uint32 insn) public pure returns (uint32) { return (insn >> 26) & 0x3F; } }
20,524
7
// SafeMath Math operations with safety checks that throw on error /
library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function ceil(uint a, uint m) internal pure returns (uint r) { return (a + m - 1) / m * m; } }
library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function ceil(uint a, uint m) internal pure returns (uint r) { return (a + m - 1) / m * m; } }
32,913
11
// if proposal passes and its an erc721 token - use NFT Extension
if (voteResult == IVoting.VotingState.PASS) { BankExtension bank = BankExtension(dao.getExtensionAddress(DaoHelper.BANK)); require( bank.isInternalToken(DaoHelper.UNITS), "UNITS token is not an internal token" ); bank.addToBalance( proposal.applicant,
if (voteResult == IVoting.VotingState.PASS) { BankExtension bank = BankExtension(dao.getExtensionAddress(DaoHelper.BANK)); require( bank.isInternalToken(DaoHelper.UNITS), "UNITS token is not an internal token" ); bank.addToBalance( proposal.applicant,
8,061
2
// Nombre total de campagnes de crowdfunding créées (0 au départ)
uint256 public numberOfCampaigns = 0;
uint256 public numberOfCampaigns = 0;
30,816