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
25
// when the escrow is created by seller
require( msg.sender == escrowTransactions[escrowID].seller, "Only owner can access the transaction" );
require( msg.sender == escrowTransactions[escrowID].seller, "Only owner can access the transaction" );
12,126
213
// ========== RESTRICTED FUNCTIONS, GOVERNANCE ONLY ========== / Add an AMO Minter
function addAMOMinter(address amo_minter_addr) external onlyByOwnGov { require(amo_minter_addr != address(0), "Zero address detected"); // Make sure the AMO Minter has collatDollarBalance() uint256 collat_val_e18 = IFraxAMOMinter(amo_minter_addr).collatDollarBalance(); require(collat_val_e18 >= 0, "Invalid AMO"); amo_minter_addresses[amo_minter_addr] = true; emit AMOMinterAdded(amo_minter_addr); }
function addAMOMinter(address amo_minter_addr) external onlyByOwnGov { require(amo_minter_addr != address(0), "Zero address detected"); // Make sure the AMO Minter has collatDollarBalance() uint256 collat_val_e18 = IFraxAMOMinter(amo_minter_addr).collatDollarBalance(); require(collat_val_e18 >= 0, "Invalid AMO"); amo_minter_addresses[amo_minter_addr] = true; emit AMOMinterAdded(amo_minter_addr); }
29,534
107
// Adjust claimed state
_wallets[beneficiary].claimed = true;
_wallets[beneficiary].claimed = true;
27,596
3
// Mouth N°4 => Poker
function item_4() public pure returns (string memory) { return base( string( abi.encodePacked( '<line id="Poker" fill="none" stroke="#000000" stroke-linecap="round" stroke-miterlimit="10" x1="180" y1="263" x2="226" y2="263"/>' ) ) ); }
function item_4() public pure returns (string memory) { return base( string( abi.encodePacked( '<line id="Poker" fill="none" stroke="#000000" stroke-linecap="round" stroke-miterlimit="10" x1="180" y1="263" x2="226" y2="263"/>' ) ) ); }
40,876
11
// Function that allows users, owners or with permissions, to burn NFT
function burn(uint256 _tokenId) public virtual checkBurn() { require( _isApprovedOrOwner(_msgSender(), _tokenId), "Error: caller is not token owner nor approved" ); _burn(_tokenId); emit Burn(msg.sender, _tokenId); }
function burn(uint256 _tokenId) public virtual checkBurn() { require( _isApprovedOrOwner(_msgSender(), _tokenId), "Error: caller is not token owner nor approved" ); _burn(_tokenId); emit Burn(msg.sender, _tokenId); }
9,578
6
// Returns the number of decimals used to get its user representation.For example, if `decimals` equals `2`, a balance of `505` tokens shouldbe displayed to a user as `5.05` (`505 / 102`). Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; }
* Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; }
1,770
52
// trusted reward token contract address (UNOS)
address public constant trustedRewardTokenAddress = 0xd18A8abED9274eDBEace4B12D86A8633283435Da;
address public constant trustedRewardTokenAddress = 0xd18A8abED9274eDBEace4B12D86A8633283435Da;
63,624
54
// A contract that can be destroyed by its owner after a delay elapses. /
contract SelfDestructible is Owned { uint public initiationTime; bool public selfDestructInitiated; address public selfDestructBeneficiary; uint public constant SELFDESTRUCT_DELAY = 4 weeks; /** * @dev Constructor * @param _owner The account which controls this contract. */ constructor(address _owner) Owned(_owner) public { require(_owner != address(0), "Owner must not be zero"); selfDestructBeneficiary = _owner; emit SelfDestructBeneficiaryUpdated(_owner); } /** * @notice Set the beneficiary address of this contract. * @dev Only the contract owner may call this. The provided beneficiary must be non-null. * @param _beneficiary The address to pay any eth contained in this contract to upon self-destruction. */ function setSelfDestructBeneficiary(address _beneficiary) external onlyOwner { require(_beneficiary != address(0), "Beneficiary must not be zero"); selfDestructBeneficiary = _beneficiary; emit SelfDestructBeneficiaryUpdated(_beneficiary); } /** * @notice Begin the self-destruction counter of this contract. * Once the delay has elapsed, the contract may be self-destructed. * @dev Only the contract owner may call this. */ function initiateSelfDestruct() external onlyOwner { initiationTime = now; selfDestructInitiated = true; emit SelfDestructInitiated(SELFDESTRUCT_DELAY); } /** * @notice Terminate and reset the self-destruction timer. * @dev Only the contract owner may call this. */ function terminateSelfDestruct() external onlyOwner { initiationTime = 0; selfDestructInitiated = false; emit SelfDestructTerminated(); } /** * @notice If the self-destruction delay has elapsed, destroy this contract and * remit any ether it owns to the beneficiary address. * @dev Only the contract owner may call this. */ function selfDestruct() external onlyOwner { require(selfDestructInitiated, "Self Destruct not yet initiated"); require(initiationTime + SELFDESTRUCT_DELAY < now, "Self destruct delay not met"); address beneficiary = selfDestructBeneficiary; emit SelfDestructed(beneficiary); selfdestruct(beneficiary); } event SelfDestructTerminated(); event SelfDestructed(address beneficiary); event SelfDestructInitiated(uint selfDestructDelay); event SelfDestructBeneficiaryUpdated(address newBeneficiary); }
contract SelfDestructible is Owned { uint public initiationTime; bool public selfDestructInitiated; address public selfDestructBeneficiary; uint public constant SELFDESTRUCT_DELAY = 4 weeks; /** * @dev Constructor * @param _owner The account which controls this contract. */ constructor(address _owner) Owned(_owner) public { require(_owner != address(0), "Owner must not be zero"); selfDestructBeneficiary = _owner; emit SelfDestructBeneficiaryUpdated(_owner); } /** * @notice Set the beneficiary address of this contract. * @dev Only the contract owner may call this. The provided beneficiary must be non-null. * @param _beneficiary The address to pay any eth contained in this contract to upon self-destruction. */ function setSelfDestructBeneficiary(address _beneficiary) external onlyOwner { require(_beneficiary != address(0), "Beneficiary must not be zero"); selfDestructBeneficiary = _beneficiary; emit SelfDestructBeneficiaryUpdated(_beneficiary); } /** * @notice Begin the self-destruction counter of this contract. * Once the delay has elapsed, the contract may be self-destructed. * @dev Only the contract owner may call this. */ function initiateSelfDestruct() external onlyOwner { initiationTime = now; selfDestructInitiated = true; emit SelfDestructInitiated(SELFDESTRUCT_DELAY); } /** * @notice Terminate and reset the self-destruction timer. * @dev Only the contract owner may call this. */ function terminateSelfDestruct() external onlyOwner { initiationTime = 0; selfDestructInitiated = false; emit SelfDestructTerminated(); } /** * @notice If the self-destruction delay has elapsed, destroy this contract and * remit any ether it owns to the beneficiary address. * @dev Only the contract owner may call this. */ function selfDestruct() external onlyOwner { require(selfDestructInitiated, "Self Destruct not yet initiated"); require(initiationTime + SELFDESTRUCT_DELAY < now, "Self destruct delay not met"); address beneficiary = selfDestructBeneficiary; emit SelfDestructed(beneficiary); selfdestruct(beneficiary); } event SelfDestructTerminated(); event SelfDestructed(address beneficiary); event SelfDestructInitiated(uint selfDestructDelay); event SelfDestructBeneficiaryUpdated(address newBeneficiary); }
15,356
29
// Check if the new Buyer has sufficient Balance in their ERC account/ IMP!! Fee is charged again as a New Token Minting Fee additionally Check if the seller is not the buyer
require(sellerOwner != msg.sender, "EA");
require(sellerOwner != msg.sender, "EA");
905
282
// coupons have not expired
decrementBalanceOfCoupons(msg.sender, couponEpoch, couponUnderlying, "Market: Insufficient coupon balance");
decrementBalanceOfCoupons(msg.sender, couponEpoch, couponUnderlying, "Market: Insufficient coupon balance");
4,229
35
// Check if an asset is supported. _assetAddress of the assetreturn bool Whether asset is supported /
function supportsAsset(address _asset) external view virtual returns (bool);
function supportsAsset(address _asset) external view virtual returns (bool);
34,628
125
// Claimer claim status.
bool claimedStatus = claimed[address(this)][msg.sender];
bool claimedStatus = claimed[address(this)][msg.sender];
27,998
304
// Royalty manager is responsible for managing the EIP2981 royalty infoRole ROLE_ROYALTY_MANAGER allows updating the royalty information (executing `setRoyaltyInfo` function) /
uint32 public constant ROLE_ROYALTY_MANAGER = 0x0008_0000;
uint32 public constant ROLE_ROYALTY_MANAGER = 0x0008_0000;
8,766
3
// Allows batched call to self (this contract)./calls An array of inputs for each call./revertOnFail If True then reverts after a failed call and stops doing further calls./ return successes An array indicating the success of a call, mapped one-to-one to `calls`./ return results An array with the returned data of each function call, mapped one-to-one to `calls`. F1: External is ok here because this is the batch function, adding it to a batch makes no sense F2: Calls in the batch may be payable, delegatecall operates in the same context, so each call in the batch has access to msg.value
function batch(bytes[] calldata calls, bool revertOnFail) external payable returns (bool[] memory successes, bytes[] memory results) { successes = new bool[](calls.length); results = new bytes[](calls.length); for (uint256 i = 0; i < calls.length; i++) { (bool success, bytes memory result) = address(this).delegatecall(calls[i]); require(success || !revertOnFail, _getRevertMsg(result)); successes[i] = success; results[i] = result; } }
function batch(bytes[] calldata calls, bool revertOnFail) external payable returns (bool[] memory successes, bytes[] memory results) { successes = new bool[](calls.length); results = new bytes[](calls.length); for (uint256 i = 0; i < calls.length; i++) { (bool success, bytes memory result) = address(this).delegatecall(calls[i]); require(success || !revertOnFail, _getRevertMsg(result)); successes[i] = success; results[i] = result; } }
36,797
90
// Internal initialize function, to set up initial internal state _platformAddress jGeneric platform address _vaultAddress Address of the Vault _rewardTokenAddress Address of reward token for platform _assets Addresses of initial supported assets _pTokens Platform Token corresponding addresses /
function initialize( address _platformAddress, address _vaultAddress, address _rewardTokenAddress, address[] calldata _assets, address[] calldata _pTokens
function initialize( address _platformAddress, address _vaultAddress, address _rewardTokenAddress, address[] calldata _assets, address[] calldata _pTokens
73,275
110
// Move the miner to the next halving
miner.block = miner.block.add(subsidyHalvingInterval);
miner.block = miner.block.add(subsidyHalvingInterval);
45,588
24
// Check if the token is a wrapped asset._tokenAddress is the address of the token./
function isTokenWrapped(address _tokenAddress) public returns (bool) { require(_tokenAddress != 0, "An empty token address was passed"); return address(_tokenAddress) == address(wrappedEther); }
function isTokenWrapped(address _tokenAddress) public returns (bool) { require(_tokenAddress != 0, "An empty token address was passed"); return address(_tokenAddress) == address(wrappedEther); }
3,736
89
// user=>staked
mapping(address => uint256) public yflStaked;
mapping(address => uint256) public yflStaked;
23,300
172
// Increase amount
function increaseAmount(uint256 _lockId, uint256 _value) external;
function increaseAmount(uint256 _lockId, uint256 _value) external;
33,087
66
// Construct a new BountyRegistry_token address of NCT token to use /
constructor(address _token, address _arbiterStaking, uint256 _arbiterVoteWindow) Ownable() public { owner = msg.sender; token = NectarToken(_token); staking = ArbiterStaking(_arbiterStaking); arbiterVoteWindow = _arbiterVoteWindow; }
constructor(address _token, address _arbiterStaking, uint256 _arbiterVoteWindow) Ownable() public { owner = msg.sender; token = NectarToken(_token); staking = ArbiterStaking(_arbiterStaking); arbiterVoteWindow = _arbiterVoteWindow; }
30,000
184
// Returns if an account is excluded from fees./Checks packed flag/account the account to check
function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFromFee[account]; }
function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFromFee[account]; }
12,597
34
// add via to this contract's balance first (aka issue them first)
balances[address(this)].add(via);
balances[address(this)].add(via);
20,444
280
// Method used if the creator wants to keep their collection hidden untila later release date. On reveal, a creator can decide if they want to lock the unminted tokens or enable them for on-chain randomness minting.IMPORTANT - this function can only be called ONCE, if a wrong IPFS hashis submitted by the owner, it cannot ever be switched to a different one. /
function lockTokenURI(string calldata revealIPFSHash, bool lockOnReveal) external onlyOwner { require(!isRevealed, "The token URI has already been set"); offset = _random(maxSupply); ipfsHash = revealIPFSHash; isRevealed = true; if (!lockOnReveal) { // so we know what index to start generating random numbers from randOffset = totalSupply(); } else { // This will lock the unminted tokens at reveal time maxSupply = totalSupply(); } emit IpfsRevealed(revealIPFSHash, lockOnReveal); }
function lockTokenURI(string calldata revealIPFSHash, bool lockOnReveal) external onlyOwner { require(!isRevealed, "The token URI has already been set"); offset = _random(maxSupply); ipfsHash = revealIPFSHash; isRevealed = true; if (!lockOnReveal) { // so we know what index to start generating random numbers from randOffset = totalSupply(); } else { // This will lock the unminted tokens at reveal time maxSupply = totalSupply(); } emit IpfsRevealed(revealIPFSHash, lockOnReveal); }
32,886
124
// Require msg.sender to own more than 0 of the token id /
modifier ownersOnly(uint256 _id) { require(balances[msg.sender][_id] > 0, "ERC1155Tradable#ownersOnly: ONLY_OWNERS_ALLOWED"); _; }
modifier ownersOnly(uint256 _id) { require(balances[msg.sender][_id] > 0, "ERC1155Tradable#ownersOnly: ONLY_OWNERS_ALLOWED"); _; }
14,063
15
// Converts all incoming ethereum to tokens for the caller, and passes down the referral address /
function buy(address referredyBy) onlyFoundersIfNotPublic() public payable returns(uint256)
function buy(address referredyBy) onlyFoundersIfNotPublic() public payable returns(uint256)
42,320
178
// Approve `to` to operate on `tokenId` Emits a {Approval} event. /
function _approve(address to, uint256 tokenId) internal virtual {
function _approve(address to, uint256 tokenId) internal virtual {
17,592
38
// calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
uint finalAmount = _amount.sub(registrationTax);
9,749
88
// prevent overly large contract sells.
if(contractBalance >= minimumTokensBeforeSwap * 20){ contractBalance = minimumTokensBeforeSwap * 20; }
if(contractBalance >= minimumTokensBeforeSwap * 20){ contractBalance = minimumTokensBeforeSwap * 20; }
30,800
52
// Note the zero'th game is marked Invalid to ensure it can't be initialised
if (self.state > State.Unknown) revert Transcript_IsInitialised();
if (self.state > State.Unknown) revert Transcript_IsInitialised();
11,770
76
// Transfer with signed proofs instead of onchain voting
function quickTransfer(bytes[] memory signatures, bytes memory txData) external onlyListedOwner returns (bool) { uint256 totalSigned = 0; address[] memory signedAddresses = new address[](signatures.length); for (uint256 i = 0; i < signatures.length; i += 1) { address signer = txData.verifySerialized(signatures[i]); // Each signer only able to be counted once if (isOwner(signer) && _isNotInclude(signedAddresses, signer)) { signedAddresses[totalSigned] = signer; totalSigned += 1; } } require(_calculatePercent(int256(totalSigned)) >= 70, 'MultiSig: Total signed was not greater than 70%'); uint256 nonce = txData.readUint256(0); address target = txData.readAddress(32); bytes memory data = txData.readBytes(52, txData.length - 52); require(nonce - _nonce == 1, 'MultiSign: Invalid nonce value'); _nonce = nonce; target.functionCallWithValue(data, 0); return true; }
function quickTransfer(bytes[] memory signatures, bytes memory txData) external onlyListedOwner returns (bool) { uint256 totalSigned = 0; address[] memory signedAddresses = new address[](signatures.length); for (uint256 i = 0; i < signatures.length; i += 1) { address signer = txData.verifySerialized(signatures[i]); // Each signer only able to be counted once if (isOwner(signer) && _isNotInclude(signedAddresses, signer)) { signedAddresses[totalSigned] = signer; totalSigned += 1; } } require(_calculatePercent(int256(totalSigned)) >= 70, 'MultiSig: Total signed was not greater than 70%'); uint256 nonce = txData.readUint256(0); address target = txData.readAddress(32); bytes memory data = txData.readBytes(52, txData.length - 52); require(nonce - _nonce == 1, 'MultiSign: Invalid nonce value'); _nonce = nonce; target.functionCallWithValue(data, 0); return true; }
29,483
3
// Constructor. Reverts if `symbol_` is not valid Reverts if `name_` is not valid Reverts if `tokenURI_` is not valid Reverts if `holder_` is an invalid address Reverts if `totalSupply_` is equal to zero symbol_ Symbol of the token. name_ Name of the token. holder_ Holder account of the token initial supply. totalSupply_ Total supply amount /
constructor ( string memory symbol_, string memory name_, string memory tokenURI_,
constructor ( string memory symbol_, string memory name_, string memory tokenURI_,
40,123
39
// Stolen!
if(tokenTraits[minted].isWizard) { emit WizardStolen(minted); }
if(tokenTraits[minted].isWizard) { emit WizardStolen(minted); }
39,234
75
// unsuccess:
success := 0
success := 0
40,431
35
// Helper function wrapped around totalStakedFor. Checks whether _accountAddress _accountAddress - Account requesting forreturn Boolean indicating whether account is a staker /
function isStaker(address _accountAddress) external view returns (bool) { _requireIsInitialized(); return totalStakedFor(_accountAddress) > 0; }
function isStaker(address _accountAddress) external view returns (bool) { _requireIsInitialized(); return totalStakedFor(_accountAddress) > 0; }
36,470
3
// Returns if a contract is allowed to lock/unlock tokens. /
function approvedContract(address _contract) external view returns(bool);
function approvedContract(address _contract) external view returns(bool);
8,280
10
// Revokes a prior confirmation of the given operation
function revoke(bytes32 _operation) external onlyOwner { emit Revoke(msg.sender, _operation); delete m_pending[_operation]; }
function revoke(bytes32 _operation) external onlyOwner { emit Revoke(msg.sender, _operation); delete m_pending[_operation]; }
50,536
0
// Only authorized addresses can invoke functions with this modifier.
modifier onlyAuthorized() { _assertSenderIsAuthorized(); _; }
modifier onlyAuthorized() { _assertSenderIsAuthorized(); _; }
11,289
72
// AppState //halt the app. this action is irreversible./ (the only option at this point is have a proposal that will get to approval, then activated.)/ should be called by an app-owner when the app has been compromised.// Note the constraint that all apps but Registry & Stake must be halted first!
function switchOff() external onlyOwner { uint32 totalAppsCount = GluonView(gluon).totalAppsCount(); for (uint32 i = 2; i < totalAppsCount; i++) { AppState appState = AppState(GluonView(gluon).current(i)); require(!appState.isOn(), "One of the apps is still ON"); }
function switchOff() external onlyOwner { uint32 totalAppsCount = GluonView(gluon).totalAppsCount(); for (uint32 i = 2; i < totalAppsCount; i++) { AppState appState = AppState(GluonView(gluon).current(i)); require(!appState.isOn(), "One of the apps is still ON"); }
823
15
// Stores `amount` of `tokenAddress` tokens for the `user` into the vault /
function deposit(address tokenAddress, uint256 amount) public nonReentrant { require(amount > 0, "Staking: Amount must be > 0"); IERC20 token = IERC20(tokenAddress); uint256 allowance = token.allowance(msg.sender, address(this)); require(allowance >= amount, "Staking: Token allowance too small"); balances[msg.sender][tokenAddress] = balances[msg.sender][tokenAddress].add(amount); token.transferFrom(msg.sender, address(this), amount); // epoch logic uint128 currentEpoch = getCurrentEpoch(); uint128 currentMultiplier = currentEpochMultiplier(); if (!epochIsInitialized(tokenAddress, currentEpoch)) { address[] memory tokens = new address[](1); tokens[0] = tokenAddress; manualEpochInit(tokens, currentEpoch); } // update the next epoch pool size Pool storage pNextEpoch = poolSize[tokenAddress][currentEpoch + 1]; pNextEpoch.size = token.balanceOf(address(this)); pNextEpoch.set = true; Checkpoint[] storage checkpoints = balanceCheckpoints[msg.sender][tokenAddress]; uint256 balanceBefore = getEpochUserBalance(msg.sender, tokenAddress, currentEpoch); // if there's no checkpoint yet, it means the user didn't have any activity // we want to store checkpoints both for the current epoch and next epoch because // if a user does a withdraw, the current epoch can also be modified and // we don't want to insert another checkpoint in the middle of the array as that could be expensive if (checkpoints.length == 0) { checkpoints.push(Checkpoint(currentEpoch, currentMultiplier, 0, amount)); // next epoch => multiplier is 1, epoch deposits is 0 checkpoints.push(Checkpoint(currentEpoch + 1, BASE_MULTIPLIER, amount, 0)); } else { uint256 last = checkpoints.length - 1; // the last action happened in an older epoch (e.g. a deposit in epoch 3, current epoch is >=5) if (checkpoints[last].epochId < currentEpoch) { uint128 multiplier = computeNewMultiplier( getCheckpointBalance(checkpoints[last]), BASE_MULTIPLIER, amount, currentMultiplier ); checkpoints.push(Checkpoint(currentEpoch, multiplier, getCheckpointBalance(checkpoints[last]), amount)); checkpoints.push(Checkpoint(currentEpoch + 1, BASE_MULTIPLIER, balances[msg.sender][tokenAddress], 0)); } // the last action happened in the previous epoch else if (checkpoints[last].epochId == currentEpoch) { checkpoints[last].multiplier = computeNewMultiplier( getCheckpointBalance(checkpoints[last]), checkpoints[last].multiplier, amount, currentMultiplier ); checkpoints[last].newDeposits = checkpoints[last].newDeposits.add(amount); checkpoints.push(Checkpoint(currentEpoch + 1, BASE_MULTIPLIER, balances[msg.sender][tokenAddress], 0)); } // the last action happened in the current epoch else { if (last >= 1 && checkpoints[last - 1].epochId == currentEpoch) { checkpoints[last - 1].multiplier = computeNewMultiplier( getCheckpointBalance(checkpoints[last - 1]), checkpoints[last - 1].multiplier, amount, currentMultiplier ); checkpoints[last - 1].newDeposits = checkpoints[last - 1].newDeposits.add(amount); } checkpoints[last].startBalance = balances[msg.sender][tokenAddress]; } } uint256 balanceAfter = getEpochUserBalance(msg.sender, tokenAddress, currentEpoch); poolSize[tokenAddress][currentEpoch].size = poolSize[tokenAddress][currentEpoch].size.add(balanceAfter.sub(balanceBefore)); emit Deposit(msg.sender, tokenAddress, amount); }
function deposit(address tokenAddress, uint256 amount) public nonReentrant { require(amount > 0, "Staking: Amount must be > 0"); IERC20 token = IERC20(tokenAddress); uint256 allowance = token.allowance(msg.sender, address(this)); require(allowance >= amount, "Staking: Token allowance too small"); balances[msg.sender][tokenAddress] = balances[msg.sender][tokenAddress].add(amount); token.transferFrom(msg.sender, address(this), amount); // epoch logic uint128 currentEpoch = getCurrentEpoch(); uint128 currentMultiplier = currentEpochMultiplier(); if (!epochIsInitialized(tokenAddress, currentEpoch)) { address[] memory tokens = new address[](1); tokens[0] = tokenAddress; manualEpochInit(tokens, currentEpoch); } // update the next epoch pool size Pool storage pNextEpoch = poolSize[tokenAddress][currentEpoch + 1]; pNextEpoch.size = token.balanceOf(address(this)); pNextEpoch.set = true; Checkpoint[] storage checkpoints = balanceCheckpoints[msg.sender][tokenAddress]; uint256 balanceBefore = getEpochUserBalance(msg.sender, tokenAddress, currentEpoch); // if there's no checkpoint yet, it means the user didn't have any activity // we want to store checkpoints both for the current epoch and next epoch because // if a user does a withdraw, the current epoch can also be modified and // we don't want to insert another checkpoint in the middle of the array as that could be expensive if (checkpoints.length == 0) { checkpoints.push(Checkpoint(currentEpoch, currentMultiplier, 0, amount)); // next epoch => multiplier is 1, epoch deposits is 0 checkpoints.push(Checkpoint(currentEpoch + 1, BASE_MULTIPLIER, amount, 0)); } else { uint256 last = checkpoints.length - 1; // the last action happened in an older epoch (e.g. a deposit in epoch 3, current epoch is >=5) if (checkpoints[last].epochId < currentEpoch) { uint128 multiplier = computeNewMultiplier( getCheckpointBalance(checkpoints[last]), BASE_MULTIPLIER, amount, currentMultiplier ); checkpoints.push(Checkpoint(currentEpoch, multiplier, getCheckpointBalance(checkpoints[last]), amount)); checkpoints.push(Checkpoint(currentEpoch + 1, BASE_MULTIPLIER, balances[msg.sender][tokenAddress], 0)); } // the last action happened in the previous epoch else if (checkpoints[last].epochId == currentEpoch) { checkpoints[last].multiplier = computeNewMultiplier( getCheckpointBalance(checkpoints[last]), checkpoints[last].multiplier, amount, currentMultiplier ); checkpoints[last].newDeposits = checkpoints[last].newDeposits.add(amount); checkpoints.push(Checkpoint(currentEpoch + 1, BASE_MULTIPLIER, balances[msg.sender][tokenAddress], 0)); } // the last action happened in the current epoch else { if (last >= 1 && checkpoints[last - 1].epochId == currentEpoch) { checkpoints[last - 1].multiplier = computeNewMultiplier( getCheckpointBalance(checkpoints[last - 1]), checkpoints[last - 1].multiplier, amount, currentMultiplier ); checkpoints[last - 1].newDeposits = checkpoints[last - 1].newDeposits.add(amount); } checkpoints[last].startBalance = balances[msg.sender][tokenAddress]; } } uint256 balanceAfter = getEpochUserBalance(msg.sender, tokenAddress, currentEpoch); poolSize[tokenAddress][currentEpoch].size = poolSize[tokenAddress][currentEpoch].size.add(balanceAfter.sub(balanceBefore)); emit Deposit(msg.sender, tokenAddress, amount); }
54,503
289
// Returns pending bonded stake for a delegator from its lastClaimRound through an end round _delegator Address of delegator _endRound The last round to compute pending stake fromreturn Pending bonded stake for '_delegator' since last claiming rewards /
function pendingStake(address _delegator, uint256 _endRound) public view returns (uint256) { // _endRound should be equal to the current round because after LIP-36 using a past _endRound can result // in incorrect cumulative factor values used for the _endRound in pendingStakeAndFees(). // The exception is when calculating stake through an _endRound before the LIP-36 upgrade round because cumulative factor // values will not be used in pendingStakeAndFees() before the LIP-36 upgrade round. uint256 endRound = _endRound; if (endRound >= roundsManager().lipUpgradeRound(36)) { endRound = roundsManager().currentRound(); } ( uint256 stake, ) = pendingStakeAndFees(_delegator, endRound); return stake; }
function pendingStake(address _delegator, uint256 _endRound) public view returns (uint256) { // _endRound should be equal to the current round because after LIP-36 using a past _endRound can result // in incorrect cumulative factor values used for the _endRound in pendingStakeAndFees(). // The exception is when calculating stake through an _endRound before the LIP-36 upgrade round because cumulative factor // values will not be used in pendingStakeAndFees() before the LIP-36 upgrade round. uint256 endRound = _endRound; if (endRound >= roundsManager().lipUpgradeRound(36)) { endRound = roundsManager().currentRound(); } ( uint256 stake, ) = pendingStakeAndFees(_delegator, endRound); return stake; }
23,713
7
// 13
function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] memory path, address to, uint deadline, uint repeat
function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] memory path, address to, uint deadline, uint repeat
9,848
10
// the addresses of the various Augur binary markets. One market for each token. Initiated in the constructor and does not change.
address[numberOfTokens] public marketAddresses;
address[numberOfTokens] public marketAddresses;
28,508
39
// Remove excess stake tokens earned by reflect fees
function skimStakeTokenFees(address _to) external onlyOwner { uint256 stakeTokenFeeBalance = getStakeTokenFeeBalance(); STAKE_TOKEN.safeTransfer(_to, stakeTokenFeeBalance); emit SkimStakeTokenFees(_to, stakeTokenFeeBalance); }
function skimStakeTokenFees(address _to) external onlyOwner { uint256 stakeTokenFeeBalance = getStakeTokenFeeBalance(); STAKE_TOKEN.safeTransfer(_to, stakeTokenFeeBalance); emit SkimStakeTokenFees(_to, stakeTokenFeeBalance); }
24,999
69
// add to cumulative amounts
locked = locked.add(locks[i].amount);
locked = locked.add(locks[i].amount);
33,160
6
// Called by the vault to update a user claimable reward after deposit or withdraw. This call should never revert._user The user address to updare rewards for_sharesChange The user of shared the user deposited or withdrew_isDeposit Whether user deposited or withdrew/
function commitUserBalance(address _user, uint256 _sharesChange, bool _isDeposit) external;
function commitUserBalance(address _user, uint256 _sharesChange, bool _isDeposit) external;
14,736
11
// Balance of the DAO's treasury. Fed by portion of the opening and income fees set by the DAO
uint256 treasury;
uint256 treasury;
7,479
117
// ERC20 compliant token decimals/this can be only zero, since ERC721 token is non-fungible
uint8 public constant decimals = 0;
uint8 public constant decimals = 0;
29,383
604
// Returns whether the contract has been registered with the registry. If it is registered, it is an authorized participant in the UMA system. contractAddress address of the contract.return bool indicates whether the contract is registered. /
function isContractRegistered(address contractAddress) external view returns (bool);
function isContractRegistered(address contractAddress) external view returns (bool);
10,065
6
// Event
event TokenPurchase(address indexed purchaser, uint256 value, uint256 amount); event PreICOTokenPushed(address indexed buyer, uint256 amount); event UserIDChanged(address owner, bytes32 user_id);
event TokenPurchase(address indexed purchaser, uint256 value, uint256 amount); event PreICOTokenPushed(address indexed buyer, uint256 amount); event UserIDChanged(address owner, bytes32 user_id);
39,804
26
// ============================================================================== _ ___|. |`. __ _.| | |(_)(_||~|~|(/_| _\.(these are safety checks)==============================================================================/ used to make sure no one can interact with contract until it has been activated./
modifier isActivated() { require(activated_ == true, "its not ready yet. check ?eta in discord"); _; }
modifier isActivated() { require(activated_ == true, "its not ready yet. check ?eta in discord"); _; }
24,135
19
// raised when the decimals are not in the range 0 - 18
error InvalidDecimals(uint8 decimals);
error InvalidDecimals(uint8 decimals);
5,663
66
// Events to log controller actions
event SetController(address indexed _oldController, address indexed _newController);
event SetController(address indexed _oldController, address indexed _newController);
47,777
40
// Enable or disable approval for `operator` to manage all of the caller's tokens./operator address which will be granted rights to transfer all tokens of the caller./approved whether to approve or revoke
function setApprovalForAll(address operator, bool approved) external { _setApprovalForAll(msg.sender, operator, approved); }
function setApprovalForAll(address operator, bool approved) external { _setApprovalForAll(msg.sender, operator, approved); }
2,688
53
// total reflection supply
uint256 private _totalReflection = (MAX - (MAX % _totalSupply));
uint256 private _totalReflection = (MAX - (MAX % _totalSupply));
42,772
63
// Refund the operator by transferring REN
require( ren.transfer(darknodeOperator, amount), "DarknodeRegistry: bond transfer failed" );
require( ren.transfer(darknodeOperator, amount), "DarknodeRegistry: bond transfer failed" );
31,932
8
// check usefulness of tx
require(assetAmount != 0 || usdpAmount != 0, "Unit Protocol: USELESS_TX"); uint debt = vault.debts(asset, msg.sender);
require(assetAmount != 0 || usdpAmount != 0, "Unit Protocol: USELESS_TX"); uint debt = vault.debts(asset, msg.sender);
83,555
29
// 转换单位时间到秒
function toSecond(uint unitType, uint value) internal pure returns (uint256 Seconds) { uint _seconds; if (unitType == 5){ _seconds = value.mul(1 years); }else if(unitType == 4){ _seconds = value.mul(1 days); }else if (unitType == 3){ _seconds = value.mul(1 hours); }else if (unitType == 2){ _seconds = value.mul(1 minutes); }else if (unitType == 1){ _seconds = value; }else{ revert(); } return _seconds; }
function toSecond(uint unitType, uint value) internal pure returns (uint256 Seconds) { uint _seconds; if (unitType == 5){ _seconds = value.mul(1 years); }else if(unitType == 4){ _seconds = value.mul(1 days); }else if (unitType == 3){ _seconds = value.mul(1 hours); }else if (unitType == 2){ _seconds = value.mul(1 minutes); }else if (unitType == 1){ _seconds = value; }else{ revert(); } return _seconds; }
41,485
8
// curve pool interface
interface Curve { function exchange(int128, int128, uint256, uint256) external returns (uint256); }
interface Curve { function exchange(int128, int128, uint256, uint256) external returns (uint256); }
64,519
57
// This is an alternative to {approve} that can be used as a mitigation forproblems described in {BEP20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. /
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; }
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; }
19,581
179
// Calculate the amount of base a user would get for certain amount of fyToken. baseReserves base reserves amount fyTokenReserves fyToken reserves amount fyTokenAmount fyToken amount to be traded timeTillMaturity time till maturity in seconds ts time till maturity coefficient, multiplied by 2^64 g fee coefficient, multiplied by 2^64return the amount of Base a user would get for given amount of fyToken /
function baseOutForFYTokenIn( uint128 baseReserves, uint128 fyTokenReserves, uint128 fyTokenAmount, uint128 timeTillMaturity, int128 ts, int128 g)
function baseOutForFYTokenIn( uint128 baseReserves, uint128 fyTokenReserves, uint128 fyTokenAmount, uint128 timeTillMaturity, int128 ts, int128 g)
38,763
9
// {token_id}:{blueprint}
function split(bytes calldata blob) internal pure returns (uint256, bytes memory) { int256 index = Bytes.indexOf(blob, ":", 0); require(index >= 0, "Separator must exist");
function split(bytes calldata blob) internal pure returns (uint256, bytes memory) { int256 index = Bytes.indexOf(blob, ":", 0); require(index >= 0, "Separator must exist");
24,152
3
// Accept transferOwnership. /
function acceptOwnership() public { if (msg.sender == newOwner) { emit OwnershipTransferred(owner, newOwner); owner = newOwner; } }
function acceptOwnership() public { if (msg.sender == newOwner) { emit OwnershipTransferred(owner, newOwner); owner = newOwner; } }
4,603
7
// Mints `tokenId` and transfers it to `to`./
function _mint(address to, uint256 tokenId) internal virtual override { super._mint(to, tokenId); unchecked { _tokenSupply++; } }
function _mint(address to, uint256 tokenId) internal virtual override { super._mint(to, tokenId); unchecked { _tokenSupply++; } }
13,510
121
// Potentially dangerous assumption about the type of the token.
require( ERC20Mintable(address(token())).mint(beneficiary, tokenAmount), "MintedCrowdsale: minting failed" );
require( ERC20Mintable(address(token())).mint(beneficiary, tokenAmount), "MintedCrowdsale: minting failed" );
8,125
18
// close LP NFT and get Weth and WPowerPerp amounts
(uint256 wPowerPerpAmountInLp, ) = ControllerHelperUtil.closeUniLp( nonfungiblePositionManager, ControllerHelperDataType.CloseUniLpParams({ tokenId: _params.tokenId, liquidity: _params.liquidity, liquidityPercentage: _params.liquidityPercentage, amount0Min: uint128(_params.amount0Min), amount1Min: uint128(_params.amount1Min) }),
(uint256 wPowerPerpAmountInLp, ) = ControllerHelperUtil.closeUniLp( nonfungiblePositionManager, ControllerHelperDataType.CloseUniLpParams({ tokenId: _params.tokenId, liquidity: _params.liquidity, liquidityPercentage: _params.liquidityPercentage, amount0Min: uint128(_params.amount0Min), amount1Min: uint128(_params.amount1Min) }),
32,237
5
// Return InstaEvent Address. /
function getEventAddr() internal pure returns (address) { return 0x2af7ea6Cb911035f3eb1ED895Cb6692C39ecbA97; // InstaEvent Address }
function getEventAddr() internal pure returns (address) { return 0x2af7ea6Cb911035f3eb1ED895Cb6692C39ecbA97; // InstaEvent Address }
47,885
24
// Decimals, because we care about the little rings as much as the big ones!
uint8 private constant _decimals = 9; uint256 private constant _tTotal = 1212121212 * 10**_decimals; string private constant _name = unicode"HermioneMichelleObamaAmyRose10Inu"; string private constant _symbol = unicode"AMY"; uint256 public _maxTxAmount = 24242424 * 10**_decimals; // ~2% of tTotal uint256 public _maxWalletSize = 24242424 * 10**_decimals; // ~2% of tTotal uint256 public _taxSwapThreshold = 1212121 * 10**_decimals; uint256 public _maxTaxSwap = 1212121 * 10**_decimals; IUniswapV2Router02 private uniswapV2Router;
uint8 private constant _decimals = 9; uint256 private constant _tTotal = 1212121212 * 10**_decimals; string private constant _name = unicode"HermioneMichelleObamaAmyRose10Inu"; string private constant _symbol = unicode"AMY"; uint256 public _maxTxAmount = 24242424 * 10**_decimals; // ~2% of tTotal uint256 public _maxWalletSize = 24242424 * 10**_decimals; // ~2% of tTotal uint256 public _taxSwapThreshold = 1212121 * 10**_decimals; uint256 public _maxTaxSwap = 1212121 * 10**_decimals; IUniswapV2Router02 private uniswapV2Router;
33,713
84
// term(k) = numer / denom= (product(a - i - 1, i = 1--> k)x ^ k) / (k!) Each iteration, multiply previous term by (a - (k - 1))x / k continue until term is less than precision
for (uint256 i = 1; term >= precision; i++) { uint256 bigK = i * BONE; (uint256 c, bool cneg) = rsubSign(a, rsub(bigK, BONE)); term = rmul(term, rmul(c, x)); term = rdiv(term, bigK); if (term == 0) break;
for (uint256 i = 1; term >= precision; i++) { uint256 bigK = i * BONE; (uint256 c, bool cneg) = rsubSign(a, rsub(bigK, BONE)); term = rmul(term, rmul(c, x)); term = rdiv(term, bigK); if (term == 0) break;
40,540
102
// No more synths may be issued than the value of SNX backing them.
uint public constant MAX_ISSUANCE_RATIO = 1e18;
uint public constant MAX_ISSUANCE_RATIO = 1e18;
9,887
29
// Get main data of deal deal - uniq id from priviate array deals/
function getDealById(uint deal) onlyAgency constant public returns ( address buyer, address sender, address agency, uint sum, uint atCreated, statuses status, uint objectType,
function getDealById(uint deal) onlyAgency constant public returns ( address buyer, address sender, address agency, uint sum, uint atCreated, statuses status, uint objectType,
23,290
23
// Make sure locations were visited in order
require(hunters[msg.sender][i].block > lastBlock); lastBlock = hunters[msg.sender][i].block;
require(hunters[msg.sender][i].block > lastBlock); lastBlock = hunters[msg.sender][i].block;
7,041
0
// bytes32 public constant EIP712DOMAIN_TYPEHASH = keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'); bytes32 public constant APPORDER_TYPEHASH = keccak256('AppOrder(address app,uint256 appprice,uint256 volume,bytes32 tag,address datasetrestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); bytes32 public constant DATASETORDER_TYPEHASH = keccak256('DatasetOrder(address dataset,uint256 datasetprice,uint256 volume,bytes32 tag,address apprestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); bytes32 public constantWORKERPOOLORDER_TYPEHASH = keccak256('WorkerpoolOrder(address workerpool,uint256 workerpoolprice,uint256 volume,bytes32 tag,uint256 category,uint256 trust,address apprestrict,address datasetrestrict,address requesterrestrict,bytes32 salt)'); bytes32 public constant REQUESTORDER_TYPEHASH = keccak256('RequestOrder(address app,uint256 appmaxprice,address dataset,uint256 datasetmaxprice,address workerpool,uint256 workerpoolmaxprice,address requester,uint256 volume,bytes32 tag,uint256 category,uint256 trust,address beneficiary,address callback,string params,bytes32 salt)'); bytes32 public constantAPPORDEROPERATION_TYPEHASH = keccak256('AppOrderOperation(AppOrder order,uint256 operation)AppOrder(address app,uint256 appprice,uint256 volume,bytes32 tag,address datasetrestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); bytes32 public constantDATASETORDEROPERATION_TYPEHASH = keccak256('DatasetOrderOperation(DatasetOrder order,uint256 operation)DatasetOrder(address dataset,uint256 datasetprice,uint256 volume,bytes32 tag,address
bytes32 public constant EIP712DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f; bytes32 public constant APPORDER_TYPEHASH = 0x60815a0eeec47dddf1615fe53b31d016c31444e01b9d796db365443a6445d008; bytes32 public constant DATASETORDER_TYPEHASH = 0x6cfc932a5a3d22c4359295b9f433edff52b60703fa47690a04a83e40933dd47c; bytes32 public constant WORKERPOOLORDER_TYPEHASH = 0xaa3429fb281b34691803133d3d978a75bb77c617ed6bc9aa162b9b30920022bb; bytes32 public constant REQUESTORDER_TYPEHASH = 0xf24e853034a3a450aba845a82914fbb564ad85accca6cf62be112a154520fae0; bytes32 public constant APPORDEROPERATION_TYPEHASH = 0x0638bb0702457e2b4b01be8a202579b8bf97e587fb4f2cc4d4aad01f21a06ee0; bytes32 public constant DATASETORDEROPERATION_TYPEHASH = 0x075eb6f7578ff4292c241bd2484cd5c1d5e6ecc2ddd3317e1d8176b5a45865ec; bytes32 public constant WORKERPOOLORDEROPERATION_TYPEHASH = 0x322d980b7d7a6a1f7c39ff0c5445da6ae1d8e0393ff0dd468c8be3e2c8644388; bytes32 public constant REQUESTORDEROPERATION_TYPEHASH = 0x0ded7b52c2d77595a40d242eca751df172b18e686326dbbed3f4748828af77c7;
bytes32 public constant EIP712DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f; bytes32 public constant APPORDER_TYPEHASH = 0x60815a0eeec47dddf1615fe53b31d016c31444e01b9d796db365443a6445d008; bytes32 public constant DATASETORDER_TYPEHASH = 0x6cfc932a5a3d22c4359295b9f433edff52b60703fa47690a04a83e40933dd47c; bytes32 public constant WORKERPOOLORDER_TYPEHASH = 0xaa3429fb281b34691803133d3d978a75bb77c617ed6bc9aa162b9b30920022bb; bytes32 public constant REQUESTORDER_TYPEHASH = 0xf24e853034a3a450aba845a82914fbb564ad85accca6cf62be112a154520fae0; bytes32 public constant APPORDEROPERATION_TYPEHASH = 0x0638bb0702457e2b4b01be8a202579b8bf97e587fb4f2cc4d4aad01f21a06ee0; bytes32 public constant DATASETORDEROPERATION_TYPEHASH = 0x075eb6f7578ff4292c241bd2484cd5c1d5e6ecc2ddd3317e1d8176b5a45865ec; bytes32 public constant WORKERPOOLORDEROPERATION_TYPEHASH = 0x322d980b7d7a6a1f7c39ff0c5445da6ae1d8e0393ff0dd468c8be3e2c8644388; bytes32 public constant REQUESTORDEROPERATION_TYPEHASH = 0x0ded7b52c2d77595a40d242eca751df172b18e686326dbbed3f4748828af77c7;
43,484
8
// The fundamental unit of storage for a reporter source
struct Datum { uint64 timestamp; uint64 value; }
struct Datum { uint64 timestamp; uint64 value; }
18,257
14
// Set the owner of this contract. This function can only be called by/ the current owner.//_newOwner The new owner of this contract.
function setOwner(address payable _newOwner) external onlyOwner { owner = _newOwner; }
function setOwner(address payable _newOwner) external onlyOwner { owner = _newOwner; }
5,222
17
// Returns the latest implementation given a contract type.
function getLatestImplementation(bytes32 _type) external view returns (address) { return implementation[_type][currentVersion[_type]]; }
function getLatestImplementation(bytes32 _type) external view returns (address) { return implementation[_type][currentVersion[_type]]; }
18,024
16
// Modifiers ==========================================================================================================================================
modifier Owner() { require(msg.sender == _owner, "OMS: NOT_OWNER"); _; }
modifier Owner() { require(msg.sender == _owner, "OMS: NOT_OWNER"); _; }
46,246
260
// For checking whether the player is in the leaderboard.
mapping(address => bool) public addressToIsInLeaderboard;
mapping(address => bool) public addressToIsInLeaderboard;
12,052
7
// @See https:etherscan.io/address/0xEF68e7C694F40c8202821eDF525dE3782458639freadContract
totalSupply = 14000000000000000000000; balanceOf[msg.sender] = totalSupply;
totalSupply = 14000000000000000000000; balanceOf[msg.sender] = totalSupply;
40,631
307
// Apply the penaltyPercentagePerSecond to the payment period.
latePenalty = pfc.mul(timeDiff).mul(penaltyPercentagePerSecond);
latePenalty = pfc.mul(timeDiff).mul(penaltyPercentagePerSecond);
51,761
73
// Converts the Ether accrued as dividends back into Staking tokens without having to withdraw it first. Saves on gas and potential price spike loss.
function processReinvest(address forWho,uint256 cR,uint256 cG,uint256 cB) internal{ // Retrieve the dividends associated with the address the request came from. uint256 balance = dividends(msg.sender); // Update the payouts array, incrementing the request address by `balance`. // Since this is essentially a shortcut to withdrawing and reinvesting, this step still holds. payouts[msg.sender] += (int256) (balance * scaleFactor); // Increase the total amount that&#39;s been paid out to maintain invariance. totalPayouts += (int256) (balance * scaleFactor); // Assign balance to a new variable. uint256 pocketETH = pocket[msg.sender]; uint value_ = (uint) (balance + pocketETH); pocket[msg.sender] = 0; // If your dividends are worth less than 1 szabo, or more than a million Ether // (in which case, why are you even here), abort. if (value_ < 0.000001 ether || value_ > 1000000 ether) revert(); uint256 fee = 0; uint256 trickle = 0; if(holdings[forWho] != totalBondSupply){ fee = fluxFeed(value_, true,false );// reinvestment fees are lower than regular ones. trickle = fee/ trickTax; fee = fee - trickle; tricklingPass[forWho] += trickle; } // A temporary reserve variable used for calculating the reward the holder gets for buying tokens. // (Yes, the buyer receives a part of the distribution as well!) uint256 res = reserve() - balance; // The amount of Ether used to purchase new tokens for the caller. uint256 numEther = value_ - (fee+trickle); // The number of tokens which can be purchased for numEther. uint256 numTokens = calculateDividendTokens(numEther, balance); buyCalcAndPayout( forWho, fee, numTokens, numEther, res ); addPigment(forWho, numTokens,cR,cG,cB); if(forWho != msg.sender){//make sure you&#39;re not yourself //if forWho doesn&#39;t have a reff, then reset it address reffOfWho = reff[forWho]; if(reffOfWho == 0x0000000000000000000000000000000000000000 || (holdings[reffOfWho] < stakingRequirement) ) reff[forWho] = msg.sender; emit onReinvestFor(msg.sender,forWho,numEther,numTokens,reff[forWho]); }else{ emit onReinvestment(forWho,numEther,numTokens,reff[forWho]); } trickleUp(forWho); trickleSum += trickle - pocketETH; }
function processReinvest(address forWho,uint256 cR,uint256 cG,uint256 cB) internal{ // Retrieve the dividends associated with the address the request came from. uint256 balance = dividends(msg.sender); // Update the payouts array, incrementing the request address by `balance`. // Since this is essentially a shortcut to withdrawing and reinvesting, this step still holds. payouts[msg.sender] += (int256) (balance * scaleFactor); // Increase the total amount that&#39;s been paid out to maintain invariance. totalPayouts += (int256) (balance * scaleFactor); // Assign balance to a new variable. uint256 pocketETH = pocket[msg.sender]; uint value_ = (uint) (balance + pocketETH); pocket[msg.sender] = 0; // If your dividends are worth less than 1 szabo, or more than a million Ether // (in which case, why are you even here), abort. if (value_ < 0.000001 ether || value_ > 1000000 ether) revert(); uint256 fee = 0; uint256 trickle = 0; if(holdings[forWho] != totalBondSupply){ fee = fluxFeed(value_, true,false );// reinvestment fees are lower than regular ones. trickle = fee/ trickTax; fee = fee - trickle; tricklingPass[forWho] += trickle; } // A temporary reserve variable used for calculating the reward the holder gets for buying tokens. // (Yes, the buyer receives a part of the distribution as well!) uint256 res = reserve() - balance; // The amount of Ether used to purchase new tokens for the caller. uint256 numEther = value_ - (fee+trickle); // The number of tokens which can be purchased for numEther. uint256 numTokens = calculateDividendTokens(numEther, balance); buyCalcAndPayout( forWho, fee, numTokens, numEther, res ); addPigment(forWho, numTokens,cR,cG,cB); if(forWho != msg.sender){//make sure you&#39;re not yourself //if forWho doesn&#39;t have a reff, then reset it address reffOfWho = reff[forWho]; if(reffOfWho == 0x0000000000000000000000000000000000000000 || (holdings[reffOfWho] < stakingRequirement) ) reff[forWho] = msg.sender; emit onReinvestFor(msg.sender,forWho,numEther,numTokens,reff[forWho]); }else{ emit onReinvestment(forWho,numEther,numTokens,reff[forWho]); } trickleUp(forWho); trickleSum += trickle - pocketETH; }
59,125
137
// Require msg.sender to be the creator of the token id /
modifier creatorOnly(uint256 _id) { require(creators[_id] == msg.sender, "ERC1155Tradable#creatorOnly: ONLY_CREATOR_ALLOWED"); _; }
modifier creatorOnly(uint256 _id) { require(creators[_id] == msg.sender, "ERC1155Tradable#creatorOnly: ONLY_CREATOR_ALLOWED"); _; }
2,769
78
// MarketAuctionStores information about token market auction./
struct MarketAuction { bool isAuction; address highestBidder; uint256 highestBid; uint256 initPrice; uint endTime; }
struct MarketAuction { bool isAuction; address highestBidder; uint256 highestBid; uint256 initPrice; uint endTime; }
52,080
10
// in case we are whitelisting on a new chain an already whitelisted account, we need to make sure it expires at the same time
if (dateAuthenticated > 0) { identities[account].dateAuthenticated = dateAuthenticated; }
if (dateAuthenticated > 0) { identities[account].dateAuthenticated = dateAuthenticated; }
17,778
41
// Return address' authorization status /
function isAuthorized(address adr) public view returns (bool) { return authorizations[adr]; }
function isAuthorized(address adr) public view returns (bool) { return authorizations[adr]; }
16,615
183
// fallback function can be used to buy tokens
function () payable { buyTokens(msg.sender); }
function () payable { buyTokens(msg.sender); }
11,561
230
// Pending Governance address
address public pendingGov;
address public pendingGov;
2,971
31
// Updates strategist. Both governance and strategists can update strategist. /
function setStrategist(address _strategist, bool _allowed) external onlyStrategist { require(_strategist != address(0x0), "strategist not set"); strategists[_strategist] = _allowed; emit StrategistUpdated(_strategist, _allowed); }
function setStrategist(address _strategist, bool _allowed) external onlyStrategist { require(_strategist != address(0x0), "strategist not set"); strategists[_strategist] = _allowed; emit StrategistUpdated(_strategist, _allowed); }
61,323
275
// Try to find already existent proper old sub stake
uint16 previousPeriod = _currentPeriod - 1; for (uint256 i = 0; i < _info.subStakes.length; i++) { SubStakeInfo storage subStake = _info.subStakes[i]; if (subStake.lastPeriod == previousPeriod && ((crosscurrentCommittedPeriod == (oldCurrentCommittedPeriod && _info.currentCommittedPeriod >= subStake.firstPeriod)) && (crossnextCommittedPeriod == (oldnextCommittedPeriod && _info.nextCommittedPeriod >= subStake.firstPeriod)))) { subStake.lockedValue += uint128(_lockedValue);
uint16 previousPeriod = _currentPeriod - 1; for (uint256 i = 0; i < _info.subStakes.length; i++) { SubStakeInfo storage subStake = _info.subStakes[i]; if (subStake.lastPeriod == previousPeriod && ((crosscurrentCommittedPeriod == (oldCurrentCommittedPeriod && _info.currentCommittedPeriod >= subStake.firstPeriod)) && (crossnextCommittedPeriod == (oldnextCommittedPeriod && _info.nextCommittedPeriod >= subStake.firstPeriod)))) { subStake.lockedValue += uint128(_lockedValue);
50,106
39
// each byte takes two characters
uint256 shift = i * 2;
uint256 shift = i * 2;
33,114
7
// require(!voters[msg.sender]); require(!votePassed);
value = value.add(step); Increment(msg.sender, step); if(value >= goal) { votePassed = true; VotePass();
value = value.add(step); Increment(msg.sender, step); if(value >= goal) { votePassed = true; VotePass();
9,953
0
// fallback function /
constructor(address[] memory _addresses, uint8 _threshold) public DelegateSig(_addresses, _threshold)
constructor(address[] memory _addresses, uint8 _threshold) public DelegateSig(_addresses, _threshold)
48,678
88
// the last fomo buy user
if (canAddWaiting) { haveLastFomoBuy = true; lastFomoBuyUser = WaitingFomoWinner(to, calculateAnyFee(currentFomoPool(), 40), fomoTime); }
if (canAddWaiting) { haveLastFomoBuy = true; lastFomoBuyUser = WaitingFomoWinner(to, calculateAnyFee(currentFomoPool(), 40), fomoTime); }
20,130
4
// Emitted upon collateral withdrawaltoAddress where the USDC token withdrawal is directed collateralAmountThe number of USDC tokens withdrawn tokenAmountThe number of PE tokens burnt /
event Withdrawal(address indexed to, UsdcQuantity collateralAmount, PeQuantity tokenAmount);
event Withdrawal(address indexed to, UsdcQuantity collateralAmount, PeQuantity tokenAmount);
31,112
143
// calculate amount of SNOOP available for claim by depositor_depositor address return pendingPayout_ uint /
function pendingPayoutFor( address _depositor ) external view returns ( uint pendingPayout_ ) { uint percentVested = percentVestedFor( _depositor ); uint payout = bondInfo[ _depositor ].payout; if ( percentVested >= 10000 ) { pendingPayout_ = payout; } else { pendingPayout_ = payout.mul( percentVested ).div( 10000 ); } }
function pendingPayoutFor( address _depositor ) external view returns ( uint pendingPayout_ ) { uint percentVested = percentVestedFor( _depositor ); uint payout = bondInfo[ _depositor ].payout; if ( percentVested >= 10000 ) { pendingPayout_ = payout; } else { pendingPayout_ = payout.mul( percentVested ).div( 10000 ); } }
6,251
16
// 修改代数
function upgradeGeneration( uint256 _tokenId, address _owner, uint256 _generation
function upgradeGeneration( uint256 _tokenId, address _owner, uint256 _generation
5,611
21
// Returns the amount which _spender is still allowed to withdraw from _owner. _owner The address of the account owning tokens. _spender The address of the account able to transfer the tokens. /
function allowance(address _owner,address _spender) external view returns (uint256 _remaining){ _remaining = allowed[_owner][_spender]; }
function allowance(address _owner,address _spender) external view returns (uint256 _remaining){ _remaining = allowed[_owner][_spender]; }
17,296
35
// _authorityAddress of the Olympus Authority contract
constructor(IOlympusAuthority _authority) OlympusAccessControlled(_authority) { OHMV1BackingInDAIRemaining = OHMV1.totalSupply() * 1e9; }
constructor(IOlympusAuthority _authority) OlympusAccessControlled(_authority) { OHMV1BackingInDAIRemaining = OHMV1.totalSupply() * 1e9; }
30,751
19
// Returns _destory function
function destroy(uint256 amount) external { _destroy(msg.sender, amount); }
function destroy(uint256 amount) external { _destroy(msg.sender, amount); }
19,495
193
// 0.75% of sold tokens go to BS account:
uint bsTokens = tokensE18.mul(75).div(10000); token.sell(bsWallet, bsTokens);
uint bsTokens = tokensE18.mul(75).div(10000); token.sell(bsWallet, bsTokens);
44,637
132
// Locks WETH amount into the CDP and generates debt
frob(manager, cdp, toInt(msg.value), _getDrawDart(vat, jug, urn, ilk, wadD));
frob(manager, cdp, toInt(msg.value), _getDrawDart(vat, jug, urn, ilk, wadD));
9,688