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
54
// presale start and end blocks
uint256 public presaleStart; uint256 public presaleEnd;
uint256 public presaleStart; uint256 public presaleEnd;
47,836
19
// 根据合约记录的上一次种子生产一个随机数/ return 返回一个随机数
function _rand() internal returns (uint256) { _seed = uint256(keccak256(_seed, block.blockhash(block.number - 1), block.coinbase, block.difficulty)); return _seed; }
function _rand() internal returns (uint256) { _seed = uint256(keccak256(_seed, block.blockhash(block.number - 1), block.coinbase, block.difficulty)); return _seed; }
45,447
12
// Token storage Token storageCyril Lapinte - <[email protected]>SPDX-License-Identifier: MIT /
contract TokenStorage is ITokenStorage, OperableStorage { struct LockData { uint64 startAt; uint64 endAt; } struct TokenData { string name; string symbol; uint256 decimals; uint256 totalSupply; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowances; bool mintingFinished; uint256 allTimeMinted; uint256 allTimeBurned; uint256 allTimeSeized; mapping (address => uint256) frozenUntils; address[] locks; IRule[] rules; } struct AuditData { uint64 createdAt; uint64 lastTransactionAt; uint256 cumulatedEmission; uint256 cumulatedReception; } struct AuditStorage { address currency; AuditData sharedData; mapping(uint256 => AuditData) userData; mapping(address => AuditData) addressData; } struct AuditConfiguration { uint256 scopeId; uint256[] senderKeys; uint256[] receiverKeys; IRatesProvider ratesProvider; mapping (address => mapping(address => AuditTriggerMode)) triggers; } // AuditConfigurationId => AuditConfiguration mapping (uint256 => AuditConfiguration) internal auditConfigurations; // DelegateId => AuditConfigurationId[] mapping (uint256 => uint256[]) internal delegatesConfigurations_; mapping (address => TokenData) internal tokens; // Scope x ScopeId => AuditStorage mapping (address => mapping (uint256 => AuditStorage)) internal audits; // Prevents operator to act on behalf mapping (address => bool) internal selfManaged; // Proxy x Sender x Receiver x LockData mapping (address => mapping (address => mapping(address => LockData))) internal locks; IUserRegistry internal userRegistry_; IRatesProvider internal ratesProvider_; address internal currency_; string internal name_; /** * @dev currentTime() */ function currentTime() internal view returns (uint64) { // solhint-disable-next-line not-rely-on-time return uint64(block.timestamp); } }
contract TokenStorage is ITokenStorage, OperableStorage { struct LockData { uint64 startAt; uint64 endAt; } struct TokenData { string name; string symbol; uint256 decimals; uint256 totalSupply; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowances; bool mintingFinished; uint256 allTimeMinted; uint256 allTimeBurned; uint256 allTimeSeized; mapping (address => uint256) frozenUntils; address[] locks; IRule[] rules; } struct AuditData { uint64 createdAt; uint64 lastTransactionAt; uint256 cumulatedEmission; uint256 cumulatedReception; } struct AuditStorage { address currency; AuditData sharedData; mapping(uint256 => AuditData) userData; mapping(address => AuditData) addressData; } struct AuditConfiguration { uint256 scopeId; uint256[] senderKeys; uint256[] receiverKeys; IRatesProvider ratesProvider; mapping (address => mapping(address => AuditTriggerMode)) triggers; } // AuditConfigurationId => AuditConfiguration mapping (uint256 => AuditConfiguration) internal auditConfigurations; // DelegateId => AuditConfigurationId[] mapping (uint256 => uint256[]) internal delegatesConfigurations_; mapping (address => TokenData) internal tokens; // Scope x ScopeId => AuditStorage mapping (address => mapping (uint256 => AuditStorage)) internal audits; // Prevents operator to act on behalf mapping (address => bool) internal selfManaged; // Proxy x Sender x Receiver x LockData mapping (address => mapping (address => mapping(address => LockData))) internal locks; IUserRegistry internal userRegistry_; IRatesProvider internal ratesProvider_; address internal currency_; string internal name_; /** * @dev currentTime() */ function currentTime() internal view returns (uint64) { // solhint-disable-next-line not-rely-on-time return uint64(block.timestamp); } }
45,467
0
// contract administrator
address public owner;
address public owner;
57,840
2
// token i multiplier to reach POOL_TOKEN_COMMON_DECIMALS
uint256[] public baseMultipliers;
uint256[] public baseMultipliers;
15,078
88
// cant send it to a non existing petition
require (keccak256(petitions[_petitionId].name) != keccak256("")); require (ownerPetitionSignerArrayCreated[msg.sender][_petitionId] == 0);
require (keccak256(petitions[_petitionId].name) != keccak256("")); require (ownerPetitionSignerArrayCreated[msg.sender][_petitionId] == 0);
43,222
3
// An enum of the transaction types. either deposit or withdrawal. /
enum TransactionType { DEPOSIT, WITHDRAWAL } /** * An enum of all the states of a transaction. * AWAITING_AGENT :- transaction initialized and waitning for agent pairing. * AWAITING_CONFIRMATIONS :- agent paired awaiting for approval by the agent and client. * CONFIRMED :- transactions confirmed by both client and aagent. * DONE :- transaction completed, currency moved from escrow to destination addess. */ enum Status { AWAITING_AGENT, AWAITING_CONFIRMATIONS, CONFIRMED, CANCELED, DONE } /** * Object of escrow transactions. **/ struct WakalaTransaction { uint id; TransactionType txType; address clientAddress; address agentAddress; Status status; uint256 amount; uint256 agentFee; uint256 wakalaFee; uint256 grossAmount; bool agentApproval; bool clientApproval; string agentPhoneNumber; string clientPhoneNumber; }
enum TransactionType { DEPOSIT, WITHDRAWAL } /** * An enum of all the states of a transaction. * AWAITING_AGENT :- transaction initialized and waitning for agent pairing. * AWAITING_CONFIRMATIONS :- agent paired awaiting for approval by the agent and client. * CONFIRMED :- transactions confirmed by both client and aagent. * DONE :- transaction completed, currency moved from escrow to destination addess. */ enum Status { AWAITING_AGENT, AWAITING_CONFIRMATIONS, CONFIRMED, CANCELED, DONE } /** * Object of escrow transactions. **/ struct WakalaTransaction { uint id; TransactionType txType; address clientAddress; address agentAddress; Status status; uint256 amount; uint256 agentFee; uint256 wakalaFee; uint256 grossAmount; bool agentApproval; bool clientApproval; string agentPhoneNumber; string clientPhoneNumber; }
22,011
54
// allowed percentage to mitigate failure for min/max vest
uint256 public allowedPercentage;
uint256 public allowedPercentage;
18,316
63
// realize $CARROT earnings for a single Fox and optionally unstake itfoxes earn $CARROT proportional to their Alpha rank tokenId the ID of the Fox to claim earnings from unstake whether or not to unstake the Fox time currnet block timereturn reward - the amount of $CARROT earned /
function _claimHunterFromCabin(uint16 tokenId, bool unstake, uint48 time) internal returns (uint128 reward) { require(foxNFT.ownerOf(tokenId) == address(this), "must be staked to claim rewards"); uint8 marksman = _getAdvantagePoints(tokenId); EarningStake memory earningStake = hunterStakeByMarksman[marksman][hunterHierarchy[tokenId]]; require(earningStake.owner == msg.sender, "only token owners can unstake"); // Calculate advantage-based rewards reward = (marksman) * (carrotPerMarksmanPoint - earningStake.earningRate); if (unstake) { totalMarksmanPointsStaked -= marksman; // Remove Alpha from total staked EarningStake memory lastStake = hunterStakeByMarksman[marksman][hunterStakeByMarksman[marksman].length - 1]; hunterStakeByMarksman[marksman][hunterHierarchy[tokenId]] = lastStake; // Shuffle last Fox to current position hunterHierarchy[lastStake.tokenId] = hunterHierarchy[tokenId]; hunterStakeByMarksman[marksman].pop(); // Remove duplicate delete hunterHierarchy[tokenId]; // Delete old mapping } else { // Update earning rate hunterStakeByMarksman[marksman][hunterHierarchy[tokenId]] = EarningStake({ owner: msg.sender, tokenId: tokenId, earningRate: carrotPerMarksmanPoint }); } // Calcuate time-based rewards TimeStake memory timeStake = hunterStakeByToken[tokenId]; require(timeStake.owner == msg.sender, "only token owners can unstake"); if (totalCarrotEarned < MAXIMUM_GLOBAL_CARROT) { reward += (time - timeStake.time) * HUNTER_EARNING_RATE; } else if (timeStake.time <= lastClaimTimestamp) { // stop earning additional $CARROT if it's all been earned reward += (lastClaimTimestamp - timeStake.time) * HUNTER_EARNING_RATE; } if (unstake) { delete hunterStakeByToken[tokenId]; totalHuntersStaked -= 1; // Unstake to owner foxNFT.safeTransferFrom(address(this), msg.sender, tokenId, ""); } else { // Update last earned time hunterStakeByToken[tokenId] = TimeStake({ owner: msg.sender, tokenId: tokenId, time: time }); } emit TokenUnstaked("HUNTER", tokenId, earningStake.owner, reward); }
function _claimHunterFromCabin(uint16 tokenId, bool unstake, uint48 time) internal returns (uint128 reward) { require(foxNFT.ownerOf(tokenId) == address(this), "must be staked to claim rewards"); uint8 marksman = _getAdvantagePoints(tokenId); EarningStake memory earningStake = hunterStakeByMarksman[marksman][hunterHierarchy[tokenId]]; require(earningStake.owner == msg.sender, "only token owners can unstake"); // Calculate advantage-based rewards reward = (marksman) * (carrotPerMarksmanPoint - earningStake.earningRate); if (unstake) { totalMarksmanPointsStaked -= marksman; // Remove Alpha from total staked EarningStake memory lastStake = hunterStakeByMarksman[marksman][hunterStakeByMarksman[marksman].length - 1]; hunterStakeByMarksman[marksman][hunterHierarchy[tokenId]] = lastStake; // Shuffle last Fox to current position hunterHierarchy[lastStake.tokenId] = hunterHierarchy[tokenId]; hunterStakeByMarksman[marksman].pop(); // Remove duplicate delete hunterHierarchy[tokenId]; // Delete old mapping } else { // Update earning rate hunterStakeByMarksman[marksman][hunterHierarchy[tokenId]] = EarningStake({ owner: msg.sender, tokenId: tokenId, earningRate: carrotPerMarksmanPoint }); } // Calcuate time-based rewards TimeStake memory timeStake = hunterStakeByToken[tokenId]; require(timeStake.owner == msg.sender, "only token owners can unstake"); if (totalCarrotEarned < MAXIMUM_GLOBAL_CARROT) { reward += (time - timeStake.time) * HUNTER_EARNING_RATE; } else if (timeStake.time <= lastClaimTimestamp) { // stop earning additional $CARROT if it's all been earned reward += (lastClaimTimestamp - timeStake.time) * HUNTER_EARNING_RATE; } if (unstake) { delete hunterStakeByToken[tokenId]; totalHuntersStaked -= 1; // Unstake to owner foxNFT.safeTransferFrom(address(this), msg.sender, tokenId, ""); } else { // Update last earned time hunterStakeByToken[tokenId] = TimeStake({ owner: msg.sender, tokenId: tokenId, time: time }); } emit TokenUnstaked("HUNTER", tokenId, earningStake.owner, reward); }
40,139
165
// Deposit tokens into pos portal When `depositor` deposits tokens into pos portal, tokens get locked into predicate contract. depositor Address who wants to deposit tokens depositReceiver Address (address) who wants to receive tokens on side chain rootToken Token which gets deposited depositData Extra data for deposit (amount for ERC20, token id for ERC721 etc.) [ABI encoded] /
function lockTokens( address depositor, address depositReceiver, address rootToken, bytes calldata depositData ) external;
function lockTokens( address depositor, address depositReceiver, address rootToken, bytes calldata depositData ) external;
51,863
206
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
2,347
5
// update functions callable on Diamond proxy l storage layout facetCuts array of structured Diamond facet update data target optional recipient of initialization delegatecall data optional initialization call data /
function diamondCut( Layout storage l, IDiamondWritable.FacetCut[] memory facetCuts, address target, bytes memory data
function diamondCut( Layout storage l, IDiamondWritable.FacetCut[] memory facetCuts, address target, bytes memory data
20,910
62
// View offering ETH span
function checkOfferSpan() public view returns(uint256) { return _offerSpan; }
function checkOfferSpan() public view returns(uint256) { return _offerSpan; }
53,387
30
// INTRODUCING ADVANCE FUNCTIONALITIES/
{ //generate a public event on the blockchain function _transfer(address _from, address _to,uint256 _value) internal { //prevent transfer to 0x0 address. require(_to != 0x0); //check if sender has enough tokens require(balances[_from] >= _value); //check for overflows require(balances[_to] + _value > balances[_to]); //subtract value from sender balances[_from] -= _value; //add value to receiver balances[_to] += _value; Transfer(_from,_to,_value); } }
{ //generate a public event on the blockchain function _transfer(address _from, address _to,uint256 _value) internal { //prevent transfer to 0x0 address. require(_to != 0x0); //check if sender has enough tokens require(balances[_from] >= _value); //check for overflows require(balances[_to] + _value > balances[_to]); //subtract value from sender balances[_from] -= _value; //add value to receiver balances[_to] += _value; Transfer(_from,_to,_value); } }
24,477
59
// Verify whether strategy can be executed
require(executionManager.isStrategyWhitelisted(makerOrder.strategy), "Strategy: Not whitelisted");
require(executionManager.isStrategyWhitelisted(makerOrder.strategy), "Strategy: Not whitelisted");
17,963
30
// set a new owner.
function changeOwner(address _newFundDeposit) isOwner() external { if (_newFundDeposit == address(0x0)) throw; ethFundDeposit = _newFundDeposit; }
function changeOwner(address _newFundDeposit) isOwner() external { if (_newFundDeposit == address(0x0)) throw; ethFundDeposit = _newFundDeposit; }
2,159
14
// Reservation contract Forword ether to pre-ico address /
contract ReservationContract { // Keep track of who invested mapping(address => bool) public invested; // Minimum investment for reservation contract uint public MIN_INVESTMENT = 1 ether; // address of the pre-ico PreIcoContract public preIcoAddr; // start and end time of the pre-ico uint public preIcoStart; uint public preIcoEnd; /** * @dev Constructor * @notice Initialize reservation contract * @param _preIcoAddr Pre ico address */ function ReservationContract(address _preIcoAddr) public { require(_preIcoAddr != 0x0); require(isContract(_preIcoAddr) == true); // load pre-ico contract instance preIcoAddr = PreIcoContract(_preIcoAddr); // get and set start and end time preIcoStart = preIcoAddr.startTime(); preIcoEnd = preIcoAddr.endTime(); require(preIcoStart != 0 && preIcoEnd != 0 && now <= preIcoEnd); } /** * @dev Fallback function * @notice This function will record your investment in * this reservation contract and forward eths to the pre-ico, * please note, you need to invest at least MIN_INVESTMENT and * you must invest directly from your address, contracts are not * allowed */ function() public payable { require(msg.value >= MIN_INVESTMENT); require(now >= preIcoStart && now <= preIcoEnd); // check if it's a contract require(isContract(msg.sender) == false); // update records (used for reference only) if (invested[msg.sender] == false) { invested[msg.sender] = true; } // buy tokens preIcoAddr.buyTokens.value(msg.value)(msg.sender); } /** * @dev Check if an address is a contract * @param addr Address to check * @return True if is a contract */ function isContract(address addr) public constant returns (bool) { uint size; assembly { size := extcodesize(addr) } return size > 0; } }
contract ReservationContract { // Keep track of who invested mapping(address => bool) public invested; // Minimum investment for reservation contract uint public MIN_INVESTMENT = 1 ether; // address of the pre-ico PreIcoContract public preIcoAddr; // start and end time of the pre-ico uint public preIcoStart; uint public preIcoEnd; /** * @dev Constructor * @notice Initialize reservation contract * @param _preIcoAddr Pre ico address */ function ReservationContract(address _preIcoAddr) public { require(_preIcoAddr != 0x0); require(isContract(_preIcoAddr) == true); // load pre-ico contract instance preIcoAddr = PreIcoContract(_preIcoAddr); // get and set start and end time preIcoStart = preIcoAddr.startTime(); preIcoEnd = preIcoAddr.endTime(); require(preIcoStart != 0 && preIcoEnd != 0 && now <= preIcoEnd); } /** * @dev Fallback function * @notice This function will record your investment in * this reservation contract and forward eths to the pre-ico, * please note, you need to invest at least MIN_INVESTMENT and * you must invest directly from your address, contracts are not * allowed */ function() public payable { require(msg.value >= MIN_INVESTMENT); require(now >= preIcoStart && now <= preIcoEnd); // check if it's a contract require(isContract(msg.sender) == false); // update records (used for reference only) if (invested[msg.sender] == false) { invested[msg.sender] = true; } // buy tokens preIcoAddr.buyTokens.value(msg.value)(msg.sender); } /** * @dev Check if an address is a contract * @param addr Address to check * @return True if is a contract */ function isContract(address addr) public constant returns (bool) { uint size; assembly { size := extcodesize(addr) } return size > 0; } }
9,659
13
// Indicator that this is a BController contract (for inspection)
bool public constant isBController = true;
bool public constant isBController = true;
3,236
79
// This is where we actually mint tokens:
tokenSupply = tokenSupply.add(tokensBought); divTokenSupply = divTokenSupply.add(dividendTokensBought);
tokenSupply = tokenSupply.add(tokensBought); divTokenSupply = divTokenSupply.add(dividendTokensBought);
16,566
6
// Returns the subtraction of two signed integers, reverting on overflow. /
function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; _require((b >= 0 && c <= a) || (b < 0 && c > a), Errors.SUB_OVERFLOW); return c; }
function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; _require((b >= 0 && c <= a) || (b < 0 && c > a), Errors.SUB_OVERFLOW); return c; }
28,020
16
// Publicly callable function that takes all ETH in this contract, wraps it to WETH and sends it to thebridge pool contract. Function is called by fallback functions to automatically wrap ETH to WETH and send at theconclusion of a canonical ETH bridging action. /
function wrapAndTransfer() public payable { weth.deposit{ value: address(this).balance }(); weth.transfer(bridgePool, weth.balanceOf(address(this))); }
function wrapAndTransfer() public payable { weth.deposit{ value: address(this).balance }(); weth.transfer(bridgePool, weth.balanceOf(address(this))); }
33,444
176
// Reverts if the `tokenId` has not been minted yet. /
function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); }
function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); }
25,362
13
// This version does not have any devfees eggsBought=SafeMath.sub(eggsBought,devFee(eggsBought));
reinvest();
reinvest();
76,839
30
// Used when rolling funds into a new round
struct NAVDetails { // Collaterals of the vault Collateral[] collaterals; // Collateral balances at the start of the round uint256[] startingBalances; // Current collateral balances uint256[] currentBalances; // Used to calculate NAV address oracleAddr; // Expiry of the round uint256 expiry; // Pending deposits uint256 totalPending; }
struct NAVDetails { // Collaterals of the vault Collateral[] collaterals; // Collateral balances at the start of the round uint256[] startingBalances; // Current collateral balances uint256[] currentBalances; // Used to calculate NAV address oracleAddr; // Expiry of the round uint256 expiry; // Pending deposits uint256 totalPending; }
16,793
154
// Override this to add all tokens/tokenized positions this contractmanages on a persistent basis (e.g. not just for swapping back towant ephemerally). NOTE: Do not include `want`, already included in `sweep` below. Example:
* function protectedTokens() internal override view returns (address[] memory) { * address[] memory protected = new address[](3); * protected[0] = tokenA; * protected[1] = tokenB; * protected[2] = tokenC; * return protected; * }
* function protectedTokens() internal override view returns (address[] memory) { * address[] memory protected = new address[](3); * protected[0] = tokenA; * protected[1] = tokenB; * protected[2] = tokenC; * return protected; * }
7,428
31
// original: 62%, 70%, 91, 31 hoi an sky: 528fcb, 004b9e); hoi an sunset background: linear-gradient(0deg, fed2a8, 6393d6);
if(suffix == 0){ return string.concat('hsl(', Strings.toString(hue), ', 54%, 56%)'); } else {
if(suffix == 0){ return string.concat('hsl(', Strings.toString(hue), ', 54%, 56%)'); } else {
14,480
138
// emit an improved atomic approve event
emit Approved(_from, msg.sender, _allowance + _value, _allowance);
emit Approved(_from, msg.sender, _allowance + _value, _allowance);
50,547
28
// modifier to scope access to admins /
modifier onlyAdmin()
modifier onlyAdmin()
6,197
1
// Constructor to create an ERC20 token/_initialAmount Amount of the new token/_tokenName Name of the new token/_decimalUnits Number of decimals of the new token/_tokenSymbol Token Symbol for the new token
constructor( string memory _tokenName, string memory _tokenSymbol, uint256 _initialAmount, uint8 _decimalUnits
constructor( string memory _tokenName, string memory _tokenSymbol, uint256 _initialAmount, uint8 _decimalUnits
21,287
31
// get LQTY rewards from SP return uint /
function getLQTYRewards() public view returns (uint256) { return lusdStabilityPool.getDepositorLQTYGain(address(this)); }
function getLQTYRewards() public view returns (uint256) { return lusdStabilityPool.getDepositorLQTYGain(address(this)); }
51,546
77
// l_beneficiary account that will receive the conversion result or 0x0 to send the result to the sender accountl если след UNI/SUSHI, то в качестве получателя назначаем пару, иначе address(0), тогда результат вернётся sender-у (контракту)
address beneficiary = (i < swapSequence.length - 1) && swapSequence[i + 1] == 0 ? path[index] : address(0);
address beneficiary = (i < swapSequence.length - 1) && swapSequence[i + 1] == 0 ? path[index] : address(0);
2,234
10
// this contract is the dealer who recive "OnFlashLoan" callack
address dealer = address(this);
address dealer = address(this);
19,084
232
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal whenNotPaused override(ERC721, ERC721Enumerable)
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal whenNotPaused override(ERC721, ERC721Enumerable)
23,923
185
// Mapping from marble NFT source uri hash TO NFT ID . /
mapping (uint256 => uint256) public sourceUriHashToId; constructor() public
mapping (uint256 => uint256) public sourceUriHashToId; constructor() public
12,954
216
// cant drain glp
require(_token != address(fsGLP), "no glp draining"); IERC20(_token).safeTransfer(msg.sender, _amount);
require(_token != address(fsGLP), "no glp draining"); IERC20(_token).safeTransfer(msg.sender, _amount);
19,660
216
// Hack to get things to work automatically on OpenSea.Use isApprovedForAll so the frontend doesn't have to worry about different method names. /
function ownerOf(uint256 _tokenId) public view returns (address _owner) { return owner(); }
function ownerOf(uint256 _tokenId) public view returns (address _owner) { return owner(); }
42,958
143
// Price Ratios, to x decimal places hencedecimals, dependent on the size of the denominator. Ratios are relative to eth, amount of ether for a single token, ie. ETH / GNO == 0.2 Ether per 1 Gnosis
uint256 orderPrice; // The price the maker is willing to accept uint256 offeredPrice; // The offer the taker has given uint256 decimals = _makerOrder.offerToken_ == address(0) ? __flooredLog10__(_makerOrder.wantTokenTotal_) : __flooredLog10__(_makerOrder.offerTokenTotal_);
uint256 orderPrice; // The price the maker is willing to accept uint256 offeredPrice; // The offer the taker has given uint256 decimals = _makerOrder.offerToken_ == address(0) ? __flooredLog10__(_makerOrder.wantTokenTotal_) : __flooredLog10__(_makerOrder.offerTokenTotal_);
14,040
54
// low level token purchase function caution: tokens must be redeemed by beneficiary address
function buyTokens(address beneficiary) payable { require(beneficiary != 0x0); require(validPurchase()); // calculate token amount to be purchased uint256 weiAmount = msg.value; uint256 tokens = weiAmount.mul(rate); // update state weiRaised = weiRaised.add(weiAmount); // allocate tokens to purchaser allocations[beneficiary] = tokens; TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); }
function buyTokens(address beneficiary) payable { require(beneficiary != 0x0); require(validPurchase()); // calculate token amount to be purchased uint256 weiAmount = msg.value; uint256 tokens = weiAmount.mul(rate); // update state weiRaised = weiRaised.add(weiAmount); // allocate tokens to purchaser allocations[beneficiary] = tokens; TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); }
43,570
81
// Gets the total amount the issuer has to pay by the end of the contract/
function getTotalPayment() public view returns (uint256) { return nTotalInputInterest; }
function getTotalPayment() public view returns (uint256) { return nTotalInputInterest; }
8,052
65
// rawReceiveData - Called by the Router's fulfillRequest functionin order to fulfil a data request. Data providers call the Router's fulfillRequest functionThe request is validated to ensure it has indeed been sent via the Router. The Router will only call rawReceiveData once it has validated the origin of the data fulfillment.rawReceiveData then calls the user defined receiveData function to finalise the fulfilment.Contract developers will need to override the abstract receiveData function defined below._price uint256 result being sent _requestId bytes32 request ID of the request being fulfilledhas sent the data /
function rawReceiveData( uint256 _price, bytes32 _requestId) external
function rawReceiveData( uint256 _price, bytes32 _requestId) external
61,910
31
// Event emitted when the TokenRecoverer changes/previousEthereum address of previous token recoverer/current Ethereum address of new token recoverer
event TokenRecovererChange(address indexed previous, address indexed current);
event TokenRecovererChange(address indexed previous, address indexed current);
4,975
55
// Retrieves the exchange rates (sUSD per unit) for a list of currency keys /
function getRates(bytes32[] memory currencyKeys) public view returns (uint[] memory)
function getRates(bytes32[] memory currencyKeys) public view returns (uint[] memory)
13,710
2
// If true, payout addresses and basis points are permanently frozen and can never be updated
bool public payoutAddressesFrozen;
bool public payoutAddressesFrozen;
21,268
1
// Address of stable token.
ERC20 public stableToken;
ERC20 public stableToken;
37,421
47
// check that token's owner should be equal to the caller of the function
require(tokenOwner == msg.sender);
require(tokenOwner == msg.sender);
10,027
57
// The current inbox message was read
afterInboxCount++;
afterInboxCount++;
33,856
2
// Allows the current owner to add a new owner to the owners group. owner The address to add to the owners group. /
function addOwner(address owner) public onlyOwner { require(owner != address(0), "Invalid address"); owners[owner] = true; }
function addOwner(address owner) public onlyOwner { require(owner != address(0), "Invalid address"); owners[owner] = true; }
10,816
172
// Calculates returned BPT Tokens from Pool given In Token amount _inAmount Amount of In Tokens /
function calcBpPoolIn(uint256 _inAmount) external view returns (uint256)
function calcBpPoolIn(uint256 _inAmount) external view returns (uint256)
32,700
23
// This contract is abstract, and thus cannot be instantiated directly
require(owner != address(0), "Owner must be set");
require(owner != address(0), "Owner must be set");
6,286
0
// Function to verify linkdrop signer's signature_weiAmount Amount of wei to be claimed_tokenAddress Token address_tokenAmount Amount of tokens to be claimed (in atomic value)_expiration Unix timestamp of link expiration time_version Linkdrop contract version_chainId Network id_linkId Address corresponding to link key_signature ECDSA signature of linkdrop signer return True if signed with linkdrop signer's private key/
function verifyLinkdropSignerSignature ( uint _weiAmount, address _tokenAddress, uint _tokenAmount, uint _expiration, uint _version, uint _chainId, address _linkId, bytes memory _signature
function verifyLinkdropSignerSignature ( uint _weiAmount, address _tokenAddress, uint _tokenAmount, uint _expiration, uint _version, uint _chainId, address _linkId, bytes memory _signature
22,462
33
// Lookup data at an index
function lookup(EvalX memory eval_x, uint256 index) internal trace_mod('eval_x_lookup') returns (uint256) { return fpow(eval_x.eval_domain_generator, index); } // Returns a memory object which allows lookups function init_eval(uint8 log_eval_domain_size) internal returns (EvalX memory) { return EvalX( PrimeField.generator_power(log_eval_domain_size), log_eval_domain_size, uint64(2)**(log_eval_domain_size) ); } uint256 constant MODULUS_SUB_2 = 0x0800000000000010ffffffffffffffffffffffffffffffffffffffffffffffff; // This is a pure assembly optiomized version of a batch inversion // If the batch inversion input data array contains a zero, the batch // inversion will fail. // TODO - Inplace version/ version without output array? function batch_invert(uint256[] memory input_data, uint256[] memory output_data) internal { require(input_data.length == output_data.length); assembly { // Uses the fact that data^p = data => data^(p-2) * data = 1 // to calculate the multiplicative inverse in the field function invert(data) -> invert_result { let p := mload(0x40) mstore(p, 0x20) // Length of Base mstore(add(p, 0x20), 0x20) // Length of Exponent mstore(add(p, 0x40), 0x20) // Length of Modulus mstore(add(p, 0x60), data) // Base mstore(add(p, 0x80), MODULUS_SUB_2) // Exponent mstore(add(p, 0xa0), MODULUS) // Modulus // call modexp precompile if iszero(call(not(0), 0x05, 0, p, 0xc0, p, 0x20)) { revert(0, 0) } invert_result := mload(p) }
function lookup(EvalX memory eval_x, uint256 index) internal trace_mod('eval_x_lookup') returns (uint256) { return fpow(eval_x.eval_domain_generator, index); } // Returns a memory object which allows lookups function init_eval(uint8 log_eval_domain_size) internal returns (EvalX memory) { return EvalX( PrimeField.generator_power(log_eval_domain_size), log_eval_domain_size, uint64(2)**(log_eval_domain_size) ); } uint256 constant MODULUS_SUB_2 = 0x0800000000000010ffffffffffffffffffffffffffffffffffffffffffffffff; // This is a pure assembly optiomized version of a batch inversion // If the batch inversion input data array contains a zero, the batch // inversion will fail. // TODO - Inplace version/ version without output array? function batch_invert(uint256[] memory input_data, uint256[] memory output_data) internal { require(input_data.length == output_data.length); assembly { // Uses the fact that data^p = data => data^(p-2) * data = 1 // to calculate the multiplicative inverse in the field function invert(data) -> invert_result { let p := mload(0x40) mstore(p, 0x20) // Length of Base mstore(add(p, 0x20), 0x20) // Length of Exponent mstore(add(p, 0x40), 0x20) // Length of Modulus mstore(add(p, 0x60), data) // Base mstore(add(p, 0x80), MODULUS_SUB_2) // Exponent mstore(add(p, 0xa0), MODULUS) // Modulus // call modexp precompile if iszero(call(not(0), 0x05, 0, p, 0xc0, p, 0x20)) { revert(0, 0) } invert_result := mload(p) }
27,266
34
// Public function that clears out an address's white list ID/addressToRemove The address removed from a white list
function removeFromWhitelist(address addressToRemove) external onlyWhitelister
function removeFromWhitelist(address addressToRemove) external onlyWhitelister
54,093
26
// Adds a new project and mints a batch of tokens for it. to Address to mint the tokens to. num Number of tokens to mint. royaltyReceiver Address to receive royalties. royaltyBasisPoints Royalty fraction in basis points (0.01%).
* @param baseTokenURI Base token URI used as a prefix by {tokenURI}. */ function mintNewProject( address to, uint16 num, address royaltyReceiver, uint16 royaltyBasisPoints, string calldata baseTokenURI ) external onlyRole(OPERATOR_ROLE) onlyValidRoyaltySettings(royaltyReceiver, royaltyBasisPoints) { _projects.push( Project({ locked: false, numMinted: 0, numBurned: 0, royaltyBasisPoints: royaltyBasisPoints, royaltyReceiver: royaltyReceiver, baseTokenURI: baseTokenURI }) ); uint32 projectId = SafeCast.toUint32(_projects.length - 1); emit NewProject(projectId); _mintProject(to, projectId, num); }
* @param baseTokenURI Base token URI used as a prefix by {tokenURI}. */ function mintNewProject( address to, uint16 num, address royaltyReceiver, uint16 royaltyBasisPoints, string calldata baseTokenURI ) external onlyRole(OPERATOR_ROLE) onlyValidRoyaltySettings(royaltyReceiver, royaltyBasisPoints) { _projects.push( Project({ locked: false, numMinted: 0, numBurned: 0, royaltyBasisPoints: royaltyBasisPoints, royaltyReceiver: royaltyReceiver, baseTokenURI: baseTokenURI }) ); uint32 projectId = SafeCast.toUint32(_projects.length - 1); emit NewProject(projectId); _mintProject(to, projectId, num); }
15,598
128
// Returns the amount contributed so far by a specific beneficiary. beneficiary Address of contributorreturn Beneficiary contribution so far /
function getContribution(address beneficiary) public view returns (uint256)
function getContribution(address beneficiary) public view returns (uint256)
5,071
16
// Prepay the next subsequent transfer
if(leftover >= (lastSoldFor[_tokenId] * 15 /100)){ leftover = leftover - (lastSoldFor[_tokenId] * 15 /100); transferFeePrepaid[_tokenId] = true; }
if(leftover >= (lastSoldFor[_tokenId] * 15 /100)){ leftover = leftover - (lastSoldFor[_tokenId] * 15 /100); transferFeePrepaid[_tokenId] = true; }
32,134
32
// This error is thrown whenever a report has a duplicate/ signature
error NonUniqueSignatures();
error NonUniqueSignatures();
26,262
1
// Transfers part of an account's balance in the old token to thiscontract, and mints the same amount of new tokens for that account. token The legacy token to migrate from, should be registered under this token account whose tokens will be migrated amount amount of tokens to be migrated /
function migrate(address token, address account, uint256 amount) public { require(_legacyTokens[token]); StandardBurnableToken legacyToken = StandardBurnableToken(token); legacyToken.burnFrom(account, amount); _mint(account, amount); }
function migrate(address token, address account, uint256 amount) public { require(_legacyTokens[token]); StandardBurnableToken legacyToken = StandardBurnableToken(token); legacyToken.burnFrom(account, amount); _mint(account, amount); }
36,048
137
// ========== EVENTS ==========
event CrossDomainMessageGasLimitChanged(CrossDomainMessageGasLimits gasLimitType, uint newLimit); event TradingRewardsEnabled(bool enabled); event WaitingPeriodSecsUpdated(uint waitingPeriodSecs); event PriceDeviationThresholdUpdated(uint threshold); event IssuanceRatioUpdated(uint newRatio); event FeePeriodDurationUpdated(uint newFeePeriodDuration); event TargetThresholdUpdated(uint newTargetThreshold); event LiquidationDelayUpdated(uint newDelay); event LiquidationRatioUpdated(uint newRatio); event LiquidationPenaltyUpdated(uint newPenalty);
event CrossDomainMessageGasLimitChanged(CrossDomainMessageGasLimits gasLimitType, uint newLimit); event TradingRewardsEnabled(bool enabled); event WaitingPeriodSecsUpdated(uint waitingPeriodSecs); event PriceDeviationThresholdUpdated(uint threshold); event IssuanceRatioUpdated(uint newRatio); event FeePeriodDurationUpdated(uint newFeePeriodDuration); event TargetThresholdUpdated(uint newTargetThreshold); event LiquidationDelayUpdated(uint newDelay); event LiquidationRatioUpdated(uint newRatio); event LiquidationPenaltyUpdated(uint newPenalty);
11,134
9
// define function modifier restricting to landlord only
modifier onlyLandlord() { if (msg.sender != lease.landlord) revert(); _; }
modifier onlyLandlord() { if (msg.sender != lease.landlord) revert(); _; }
31,794
228
// Counters Matt Condon (@shrugs) Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the numberof elements in a mapping, issuing ERC721 ids, or counting request ids. Include with `using Counters for Counters.Counter;` /
library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } }
library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } }
29,893
326
// X1 - X5: OK
(uint256 amount0, uint256 amount1) = pair.burn(address(this)); if (token0 != pair.token0()) { (amount0, amount1) = (amount1, amount0); }
(uint256 amount0, uint256 amount1) = pair.burn(address(this)); if (token0 != pair.token0()) { (amount0, amount1) = (amount1, amount0); }
37,064
190
// Close sale if open, open sale if closed
function flipSaleState() external onlyOwner { saleOpen = !saleOpen; }
function flipSaleState() external onlyOwner { saleOpen = !saleOpen; }
11,666
13
// max per tx
uint256 public constant MAX_TOKENS_PER_TX = 10; uint256 public MINT_GENESIS_PRICE = .06942 ether; uint256 public MINT_PRICE = 70000;
uint256 public constant MAX_TOKENS_PER_TX = 10; uint256 public MINT_GENESIS_PRICE = .06942 ether; uint256 public MINT_PRICE = 70000;
21,848
15
// Verify that the caller is mapped to a given identifier. _identifier The identifier. /
modifier only(bytes32 _identifier) { require(msg.sender == getContractAddress(_identifier), "caller is illegal"); _; }
modifier only(bytes32 _identifier) { require(msg.sender == getContractAddress(_identifier), "caller is illegal"); _; }
56,243
0
// An operation with an ERC20 token failed. /
error SafeERC20FailedOperation(address token);
error SafeERC20FailedOperation(address token);
16,381
2
// this event is emitted when the IdentityRegistry has been set for the token the event is emitted by the token constructor and by the setIdentityRegistry function `_identityRegistry` is the address of the Identity Registry of the token /
event IdentityRegistryAdded(address indexed _identityRegistry);
event IdentityRegistryAdded(address indexed _identityRegistry);
1,212
70
// Mint the token with the id from claimedMemes array
_mint(msg.sender, id);
_mint(msg.sender, id);
36,885
28
// Return information about the swap at swapIndex. swapIndex Index of swap to be retrieve info for.return Total swap cap.return Per-user cap.return Bonus multiplier.return Number of tokens alreaduy claimed. /
function swapInfo(uint256 swapIndex) internal view returns (uint256, uint256, uint256, uint256) { Swap storage activeSwap = swaps[swapIndex]; require(activeSwap.totalCap > 0, "No swap exists at this index."); return( activeSwap.totalCap, activeSwap.userCap, activeSwap.bonusMultiplier, activeSwap.totalClaimed ); }
function swapInfo(uint256 swapIndex) internal view returns (uint256, uint256, uint256, uint256) { Swap storage activeSwap = swaps[swapIndex]; require(activeSwap.totalCap > 0, "No swap exists at this index."); return( activeSwap.totalCap, activeSwap.userCap, activeSwap.bonusMultiplier, activeSwap.totalClaimed ); }
21,492
139
// This is the address where the Mastercontract initializedERC20 is deployed to address payable public masterContract = 0xEb4c4f701cb50c8dDF7B0CEd051CeB25Aed9f3CA;master contract for bsc testnet placido factory
address payable public masterContract = 0x8bcE416dDc68c7DF920a5EdeFe8445F63330DC86; // PROD ETH MasterContract for kovan.eth testnet jacinto factory
address payable public masterContract = 0x8bcE416dDc68c7DF920a5EdeFe8445F63330DC86; // PROD ETH MasterContract for kovan.eth testnet jacinto factory
33,311
54
// lock +10% to referrer
LockRefTokens(refBonus, ref);
LockRefTokens(refBonus, ref);
13,618
99
// return the best offer for a token pairthe best offer is the lowest one if it's an ask,and highest one if it's a bid offer
function getBestOffer(ERC20 sell_gem, ERC20 buy_gem) public view returns (uint256)
function getBestOffer(ERC20 sell_gem, ERC20 buy_gem) public view returns (uint256)
8,563
203
// Reflection
uint256 public reflectionBalance; uint256 public totalDividend;
uint256 public reflectionBalance; uint256 public totalDividend;
17,951
12
// Starts the sale
function start() external onlyOwner { require(!started, "Sale has already started"); started = true; emit SaleStarted(block.number); }
function start() external onlyOwner { require(!started, "Sale has already started"); started = true; emit SaleStarted(block.number); }
10,043
3
// Callback function used by VRF Coordinator to return the random numberto this contract. Some action on the contract state should be taken here, like storing the result. WARNING: take care to avoid having multiple VRF requests in flight if their order of arrival would resultin contract states with different outcomes. Otherwise miners or the VRF operator would could take advantageby controlling the order. The VRF Coordinator will only send this function verified responses, and the parent VRFConsumerBasecontract ensures that this method only receives randomness from the designated VRFCoordinator._requestId bytes32 _randomness The random result returned by the oracle /
function fulfillRandomness(bytes32 _requestId, uint256 _randomness) internal override { result = _randomness % BIG_PRIME; if (result == 0) result += 1; emit DiceLanded(_requestId, _randomness); }
function fulfillRandomness(bytes32 _requestId, uint256 _randomness) internal override { result = _randomness % BIG_PRIME; if (result == 0) result += 1; emit DiceLanded(_requestId, _randomness); }
80,168
374
// Exchange remaining CVX for bveCVX
uint256 cvxToDistribute = cvxToken.balanceOf(address(this)); uint256 minbveCVXOut = cvxToDistribute .mul(MAX_FEE.sub(stableSwapSlippageTolerance)) .div(MAX_FEE);
uint256 cvxToDistribute = cvxToken.balanceOf(address(this)); uint256 minbveCVXOut = cvxToDistribute .mul(MAX_FEE.sub(stableSwapSlippageTolerance)) .div(MAX_FEE);
23,404
1
// address of the AvoForwarder (proxy) that is allowed to forward tx with valid/ signatures to this contract/ immutable but could be updated in the logic contract when a new version of AvoWallet is deployed
address public immutable avoForwarder;
address public immutable avoForwarder;
25,423
18
// Returns the current incognito proxy.
* NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x6c1fc16c781d41e11abf5619c272a94b10ccafab380060da4bd63325467b854e` */ function incognito() external ifAdmin returns (address) { return _incognito(); }
* NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x6c1fc16c781d41e11abf5619c272a94b10ccafab380060da4bd63325467b854e` */ function incognito() external ifAdmin returns (address) { return _incognito(); }
34,719
127
// Transfer stablecoins back to the sender
IERC20(underlyingCoin).safeTransfer(_msgSender(), underlyingCoinAmount);
IERC20(underlyingCoin).safeTransfer(_msgSender(), underlyingCoinAmount);
57,920
154
// Make sure we are not over debt ceiling (line) or under debt floor (dust)
if ( vatDebt >= line || (desiredAmount.add(debtBalance) <= dust.div(RAY)) ) { return 0; }
if ( vatDebt >= line || (desiredAmount.add(debtBalance) <= dust.div(RAY)) ) { return 0; }
3,335
13
// L'Owner peut réinitialiser le contract
function Reset() public onlyOwner(){ delete winningProposalId; delete Propositions; Etat = WorkflowStatus.RegisteringVoters; uint i; uint len= ListAddress.length; for(i=0; i<len; i++){ delete Whitelist[ListAddress[i]]; } delete ListAddress; }
function Reset() public onlyOwner(){ delete winningProposalId; delete Propositions; Etat = WorkflowStatus.RegisteringVoters; uint i; uint len= ListAddress.length; for(i=0; i<len; i++){ delete Whitelist[ListAddress[i]]; } delete ListAddress; }
14,280
1
// Mint multiple boards_to The owners to receive the assets _level The level of each board /
function mintMultiple( address[] memory _to, uint8[] memory _level ) public onlyMinters(msg.sender)
function mintMultiple( address[] memory _to, uint8[] memory _level ) public onlyMinters(msg.sender)
47,696
402
// Parse an address from the view at `_index`. Requires that the view have >= 20 bytes following that index. memView The view _indexThe indexreturnaddress - The address /
function indexAddress(bytes29 memView, uint256 _index) internal pure returns (address) { return address(uint160(indexUint(memView, _index, 20))); }
function indexAddress(bytes29 memView, uint256 _index) internal pure returns (address) { return address(uint160(indexUint(memView, _index, 20))); }
22,475
4
// This contract extends the NitroAdjudicator contract to enable it to be more easily unit-tested. It exposes public or external functions that set storage variables or wrap otherwise internal functions. It should not be deployed in a production environment. /
contract TESTNitroAdjudicator is NitroAdjudicator, TESTForceMove { /** * @dev Manually set the holdings mapping to a given amount for a given channelId. Shortcuts the deposit workflow (ONLY USE IN A TESTING ENVIRONMENT) * @param channelId Unique identifier for a state channel. * @param amount The number of assets that should now be "escrowed: against channelId */ function setHoldings( address asset, bytes32 channelId, uint256 amount ) external { holdings[asset][channelId] = amount; } /** * @dev Wrapper for otherwise internal function. Checks if a given destination is external (and can therefore have assets transferred to it) or not. * @param destination Destination to be checked. * @return True if the destination is external, false otherwise. */ function isExternalDestination(bytes32 destination) public pure returns (bool) { return _isExternalDestination(destination); } /** * @dev Wrapper for otherwise internal function. Converts an ethereum address to a nitro external destination. * @param participant The address to be converted. * @return The input address left-padded with zeros. */ function addressToBytes32(address participant) public pure returns (bytes32) { return _addressToBytes32(participant); } }
contract TESTNitroAdjudicator is NitroAdjudicator, TESTForceMove { /** * @dev Manually set the holdings mapping to a given amount for a given channelId. Shortcuts the deposit workflow (ONLY USE IN A TESTING ENVIRONMENT) * @param channelId Unique identifier for a state channel. * @param amount The number of assets that should now be "escrowed: against channelId */ function setHoldings( address asset, bytes32 channelId, uint256 amount ) external { holdings[asset][channelId] = amount; } /** * @dev Wrapper for otherwise internal function. Checks if a given destination is external (and can therefore have assets transferred to it) or not. * @param destination Destination to be checked. * @return True if the destination is external, false otherwise. */ function isExternalDestination(bytes32 destination) public pure returns (bool) { return _isExternalDestination(destination); } /** * @dev Wrapper for otherwise internal function. Converts an ethereum address to a nitro external destination. * @param participant The address to be converted. * @return The input address left-padded with zeros. */ function addressToBytes32(address participant) public pure returns (bytes32) { return _addressToBytes32(participant); } }
39,359
28
// calculate token amount to be sent
uint256 tokens = ((weiAmount) * price); weiRaised = weiRaised.add(weiAmount);
uint256 tokens = ((weiAmount) * price); weiRaised = weiRaised.add(weiAmount);
31,665
89
// Otherwise, we can fill the order entirely, so make the tokens and put them in the specified account.
totalSupply = newTotalSupply; balances[recipient] = balances[recipient].add(tokens);
totalSupply = newTotalSupply; balances[recipient] = balances[recipient].add(tokens);
50,806
118
// Stores a valid AMB bridge contract address. _bridgeContract the address of the bridge contract. /
function _setBridgeContract(address _bridgeContract) internal { require(Address.isContract(_bridgeContract)); addressStorage[BRIDGE_CONTRACT] = _bridgeContract; }
function _setBridgeContract(address _bridgeContract) internal { require(Address.isContract(_bridgeContract)); addressStorage[BRIDGE_CONTRACT] = _bridgeContract; }
8,934
58
// Allows seller to cancel a request _id request id /
function cancelRequest(bytes32 _id) public { require(requests[_id].seller == msg.sender, "This request id does not belong to the message sender"); require(requests[_id].status == RequestStatus.AWAIT || requests[_id].status == RequestStatus.ACCEPTED, "Invalid request status"); address arbitrator = requests[_id].arbitrator; requests[_id].status = RequestStatus.CLOSED; requests[_id].date = block.timestamp; address _arbitrator = requests[_id].arbitrator; permissions[_arbitrator][msg.sender] = false; emit RequestCanceled(_id, arbitrator, requests[_id].seller); }
function cancelRequest(bytes32 _id) public { require(requests[_id].seller == msg.sender, "This request id does not belong to the message sender"); require(requests[_id].status == RequestStatus.AWAIT || requests[_id].status == RequestStatus.ACCEPTED, "Invalid request status"); address arbitrator = requests[_id].arbitrator; requests[_id].status = RequestStatus.CLOSED; requests[_id].date = block.timestamp; address _arbitrator = requests[_id].arbitrator; permissions[_arbitrator][msg.sender] = false; emit RequestCanceled(_id, arbitrator, requests[_id].seller); }
13,682
16
// add balance
_itokenBalances[to] = _itokenBalances[to].add(itokenValue);
_itokenBalances[to] = _itokenBalances[to].add(itokenValue);
10,818
149
// Checks if two receivers fulfil the sortedness requirement of the receivers list./prev The previous receiver/next The next receiver
function _isOrdered(StreamReceiver memory prev, StreamReceiver memory next) private pure returns (bool)
function _isOrdered(StreamReceiver memory prev, StreamReceiver memory next) private pure returns (bool)
21,676
190
// ensure than as a result of running a function,balance of `token` increases by at least `expectedGain` /
modifier exchangeProtector(uint256 expectedGain, IERC20 _token) { uint256 balanceBefore = _token.balanceOf(address(this)); _; uint256 balanceDiff = _token.balanceOf(address(this)).sub(balanceBefore); require(balanceDiff >= conservativePriceEstimation(expectedGain), "TrueFiPool: Not optimal exchange"); }
modifier exchangeProtector(uint256 expectedGain, IERC20 _token) { uint256 balanceBefore = _token.balanceOf(address(this)); _; uint256 balanceDiff = _token.balanceOf(address(this)).sub(balanceBefore); require(balanceDiff >= conservativePriceEstimation(expectedGain), "TrueFiPool: Not optimal exchange"); }
19,489
6
// error InsufficientFunds(uint _currentAccountSerialNumber,uint _balanceRequested,uint _balanceAvailable,string _transactionType);
event AccountCreated( uint256 _serialNumber, bytes32 _name, bytes32 _location, uint256 _createdAt, uint256 _balance ); event TransactionCompleted(
event AccountCreated( uint256 _serialNumber, bytes32 _name, bytes32 _location, uint256 _createdAt, uint256 _balance ); event TransactionCompleted(
23,879
58
// Contract RESTO token ERC20 compatible token contract /
contract RESTOToken is ERC20Pausable { string public constant name = "RESTO"; string public constant symbol = "RESTO"; uint32 public constant decimals = 18; uint256 public INITIAL_SUPPLY = 1100000000 * 1 ether; // 1 100 000 000 address public CrowdsaleAddress; uint64 crowdSaleEndTime = 1544745600; // 14.12.2018 mapping (address => bool) internal kyc; constructor(address _CrowdsaleAddress) public { CrowdsaleAddress = _CrowdsaleAddress; _mint(_CrowdsaleAddress, INITIAL_SUPPLY); } modifier kyc_passed(address _investor) { if (_investor != CrowdsaleAddress){ require(kyc[_investor],"For transfer tokens you need to go through the procedure KYC"); } _; } modifier onlyOwner() { require(msg.sender == CrowdsaleAddress,"Only CrowdSale contract can run this"); _; } modifier validDestination( address to ) { require(to != address(0x0),"Empty address"); require(to != address(this),"RESTO Token address"); _; } modifier isICOover { if (msg.sender != CrowdsaleAddress){ require(now > crowdSaleEndTime,"Transfer of tokens is prohibited until the end of the ICO"); } _; } /** * @dev Override for testing address destination */ function transfer(address _to, uint256 _value) public validDestination(_to) kyc_passed(msg.sender) isICOover returns (bool) { return super.transfer(_to, _value); } /** * @dev Override for testing address destination */ function transferFrom(address _from, address _to, uint256 _value) public validDestination(_to) kyc_passed(msg.sender) isICOover returns (bool) { return super.transferFrom(_from, _to, _value); } /** * @dev function set kyc bool to true * can run only from crowdsale contract * @param _investor The investor who passed the procedure KYC */ function kycPass(address _investor) public onlyOwner { kyc[_investor] = true; } /** * @dev function transfer tokens from special address to users * can run only from crowdsale contract * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromSpecialAddress(address _from, address _to, uint256 _value) public onlyOwner whenNotPaused returns (bool){ uint256 value = _value; require (value >= 1,"Min value is 1"); value = value.mul(1 ether); require (balances_[_from] >= value,"Decrease value"); balances_[_from] = balances_[_from].sub(value); balances_[_to] = balances_[_to].add(value); emit Transfer(_from, _to, value); return true; } /** * @dev called from crowdsale contract to pause, triggers stopped state * can run only from crowdsale contract */ function pause() public onlyOwner whenNotPaused { paused = true; emit Paused(); } /** * @dev called from crowdsale contract to unpause, returns to normal state * can run only from crowdsale contract */ function unpause() public onlyOwner whenPaused { paused = false; emit Unpaused(); } function() external payable { revert("The token contract don`t receive ether"); } }
contract RESTOToken is ERC20Pausable { string public constant name = "RESTO"; string public constant symbol = "RESTO"; uint32 public constant decimals = 18; uint256 public INITIAL_SUPPLY = 1100000000 * 1 ether; // 1 100 000 000 address public CrowdsaleAddress; uint64 crowdSaleEndTime = 1544745600; // 14.12.2018 mapping (address => bool) internal kyc; constructor(address _CrowdsaleAddress) public { CrowdsaleAddress = _CrowdsaleAddress; _mint(_CrowdsaleAddress, INITIAL_SUPPLY); } modifier kyc_passed(address _investor) { if (_investor != CrowdsaleAddress){ require(kyc[_investor],"For transfer tokens you need to go through the procedure KYC"); } _; } modifier onlyOwner() { require(msg.sender == CrowdsaleAddress,"Only CrowdSale contract can run this"); _; } modifier validDestination( address to ) { require(to != address(0x0),"Empty address"); require(to != address(this),"RESTO Token address"); _; } modifier isICOover { if (msg.sender != CrowdsaleAddress){ require(now > crowdSaleEndTime,"Transfer of tokens is prohibited until the end of the ICO"); } _; } /** * @dev Override for testing address destination */ function transfer(address _to, uint256 _value) public validDestination(_to) kyc_passed(msg.sender) isICOover returns (bool) { return super.transfer(_to, _value); } /** * @dev Override for testing address destination */ function transferFrom(address _from, address _to, uint256 _value) public validDestination(_to) kyc_passed(msg.sender) isICOover returns (bool) { return super.transferFrom(_from, _to, _value); } /** * @dev function set kyc bool to true * can run only from crowdsale contract * @param _investor The investor who passed the procedure KYC */ function kycPass(address _investor) public onlyOwner { kyc[_investor] = true; } /** * @dev function transfer tokens from special address to users * can run only from crowdsale contract * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromSpecialAddress(address _from, address _to, uint256 _value) public onlyOwner whenNotPaused returns (bool){ uint256 value = _value; require (value >= 1,"Min value is 1"); value = value.mul(1 ether); require (balances_[_from] >= value,"Decrease value"); balances_[_from] = balances_[_from].sub(value); balances_[_to] = balances_[_to].add(value); emit Transfer(_from, _to, value); return true; } /** * @dev called from crowdsale contract to pause, triggers stopped state * can run only from crowdsale contract */ function pause() public onlyOwner whenNotPaused { paused = true; emit Paused(); } /** * @dev called from crowdsale contract to unpause, returns to normal state * can run only from crowdsale contract */ function unpause() public onlyOwner whenPaused { paused = false; emit Unpaused(); } function() external payable { revert("The token contract don`t receive ether"); } }
51,572
221
// set our newItemID do the current counter uint
uint256 newItemId = _tokenIds.current();
uint256 newItemId = _tokenIds.current();
35,682
2
// start block height of the chain element
uint256 start_height;
uint256 start_height;
760
32
// Casts a vote with a reason/proposalId The proposal id/support The support value (0 = Against, 1 = For, 2 = Abstain)/reason The vote reason
function castVoteWithReason( bytes32 proposalId, uint256 support, string memory reason ) external returns (uint256);
function castVoteWithReason( bytes32 proposalId, uint256 support, string memory reason ) external returns (uint256);
17,881
251
// solhint-disable-next-line max-line-length
address internal constant L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000007; address internal constant LIB_ADDRESS_MANAGER = 0x4200000000000000000000000000000000000008; address internal constant PROXY_EOA = 0x4200000000000000000000000000000000000009; address internal constant L2_STANDARD_BRIDGE = 0x4200000000000000000000000000000000000010; address internal constant SEQUENCER_FEE_WALLET = 0x4200000000000000000000000000000000000011;
address internal constant L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000007; address internal constant LIB_ADDRESS_MANAGER = 0x4200000000000000000000000000000000000008; address internal constant PROXY_EOA = 0x4200000000000000000000000000000000000009; address internal constant L2_STANDARD_BRIDGE = 0x4200000000000000000000000000000000000010; address internal constant SEQUENCER_FEE_WALLET = 0x4200000000000000000000000000000000000011;
37,295
37
// IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; setSellFee(3,9); setBuyFee(9,3); setTxSettings(1,100,2,100,5,1000,true);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; setSellFee(3,9); setBuyFee(9,3); setTxSettings(1,100,2,100,5,1000,true);
2,031
45
// PRIVILEGED GOVERNANCE FUNCTION. Allows governance to edit the curve meta registry_curveMetaRegistryAddress of the new curve meta registry /
function editCurveMetaRegistry(address _curveMetaRegistry) external override { _onlyGovernanceOrEmergency(); require(_curveMetaRegistry != address(0), 'Address must not be 0'); curveMetaRegistry = _curveMetaRegistry; }
function editCurveMetaRegistry(address _curveMetaRegistry) external override { _onlyGovernanceOrEmergency(); require(_curveMetaRegistry != address(0), 'Address must not be 0'); curveMetaRegistry = _curveMetaRegistry; }
72,379
44
// private function to claim rewards for multiple pids/_pids array pids, pools to claim
function _multiClaim( uint256[] memory _pids
function _multiClaim( uint256[] memory _pids
39,878
200
// Safe GrowDeFi transfer function, just in case if rounding error causes pool to not have enough growdefis.
function safeGrowDeFiTransfer(address _to, uint256 _amount) internal { uint256 growdefiBal = GrowDeFi.balanceOf(address(this)); if (_amount > growdefiBal) { GrowDeFi.transfer(_to, growdefiBal); } else { GrowDeFi.transfer(_to, _amount); } }
function safeGrowDeFiTransfer(address _to, uint256 _amount) internal { uint256 growdefiBal = GrowDeFi.balanceOf(address(this)); if (_amount > growdefiBal) { GrowDeFi.transfer(_to, growdefiBal); } else { GrowDeFi.transfer(_to, _amount); } }
41,240