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
5
// reference to the $GP contract for minting $GP earnings
IGP public gpToken;
IGP public gpToken;
32,163
4
// pool contract can destory tokens if pooler withdraws /
function burn(address account, uint256 amount) external override onlyPool { _burn(account, amount); }
function burn(address account, uint256 amount) external override onlyPool { _burn(account, amount); }
13,373
71
// Constructor, takes maximum amount of wei accepted in the crowdsale. cap Max amount of wei to be contributed /
constructor (uint256 cap) public { require(cap > 0, "CappedCrowdsale: cap is 0"); _cap = cap; }
constructor (uint256 cap) public { require(cap > 0, "CappedCrowdsale: cap is 0"); _cap = cap; }
18,033
76
// hldAdmin functions
function updateHldAdmin(address newAdmin) public virtual onlyHldAdmin { hldAdmin = newAdmin; }
function updateHldAdmin(address newAdmin) public virtual onlyHldAdmin { hldAdmin = newAdmin; }
46,830
68
// Minting new ERC1155 tokens
IERC1155CreatorCore(_tokenContract).mintExtensionExisting( to, tokenId, amounts );
IERC1155CreatorCore(_tokenContract).mintExtensionExisting( to, tokenId, amounts );
6,526
395
// Check parameters existence.
bytes32 paramsHash = getParametersFromController(Avatar(_avatar)); require(parameters[paramsHash].preBoostedVoteRequiredPercentage > 0);
bytes32 paramsHash = getParametersFromController(Avatar(_avatar)); require(parameters[paramsHash].preBoostedVoteRequiredPercentage > 0);
35,480
80
// Emitted by successful `confirmCustodianChange` calls.
event CustodianChangeConfirmed(bytes32 _lockId, address _newCustodian);
event CustodianChangeConfirmed(bytes32 _lockId, address _newCustodian);
58,885
29
// require(1 == 2, string(abi.encodePacked("id is ", newId.toString())));_tokenData[newId][from].forSale -= amount;
return newId;
return newId;
23,287
174
// Emitted when a collateral's custom fee percentage is updated./collateral The collateral who's custom fee percentage was updated./newFeePercentage The new custom fee percentage.
event CustomFeePercentageUpdatedForCollateral( address indexed user, ERC20 indexed collateral, uint256 newFeePercentage );
event CustomFeePercentageUpdatedForCollateral( address indexed user, ERC20 indexed collateral, uint256 newFeePercentage );
80,654
51
// A descriptive name for a collection of NFTs in this contract
function name() external view returns (string _name);
function name() external view returns (string _name);
18,995
83
// Address of Opium.OracleAggregator contract
address private oracleAggregator;
address private oracleAggregator;
34,223
18
// Set the caller as the owner of this contract.
_owner = msg.sender;
_owner = msg.sender;
16,495
202
// calculates the next token ID based on value of Counter _tokenSupplyreturn uint256 for the next token ID /
function _getNextTokenId() private view returns (uint256) { return _tokenSupply.current() + 1; }
function _getNextTokenId() private view returns (uint256) { return _tokenSupply.current() + 1; }
26,203
304
// Downcast to a uint16, reverting on overflow. /
function toUint16( uint256 a ) internal pure returns (uint16)
function toUint16( uint256 a ) internal pure returns (uint16)
43,909
130
// Sets base uriToken./
function setURIToken(string _uriToken) public onlyOwner { URIToken = _uriToken; }
function setURIToken(string _uriToken) public onlyOwner { URIToken = _uriToken; }
39,995
163
// increment lottery identifier and create a fresh, empty one
lottoIdentifier++; _createLottery();
lottoIdentifier++; _createLottery();
36,063
222
// 0.01 :: 1% ( 11016)
rebaseUpPriceUpVolRate = 1 * 10 ** 16;
rebaseUpPriceUpVolRate = 1 * 10 ** 16;
21,045
15
// EXTERNAL // mint a token - 90% Wizard, 10% DragonsThe first 25% are claimed with eth, the remaining cost $GP /
function mint(uint256 amount, bool stake) external payable whenNotPaused nonReentrant { require(tx.origin == _msgSender(), "Only EOA"); uint16 minted = wndNFT.minted(); uint256 maxTokens = wndNFT.getMaxTokens(); uint256 paidTokens = wndNFT.getPaidTokens(); require(minted + amount <= maxTokens, "All tokens minted"); require(amount > 0 && amount <= 10, "Invalid mint amount"); if (minted < paidTokens) { require(minted + amount <= paidTokens, "All tokens on-sale already sold"); if(hasPublicSaleStarted) { require(msg.value >= amount * currentPriceToMint(), "Invalid payment amount"); } else { require(amount * presalePrice == msg.value, "Invalid payment amount"); require(_whitelistAddresses[_msgSender()].isWhitelisted, "Not on whitelist"); require(_whitelistAddresses[_msgSender()].numMinted + amount <= 2, "too many mints"); _whitelistAddresses[_msgSender()].numMinted += uint16(amount); } } else { require(msg.value == 0); } LastWrite storage lw = _lastWrite[tx.origin]; uint256 totalGpCost = 0; uint16[] memory tokenIds = new uint16[](amount); uint256 seed = 0; for (uint i = 0; i < amount; i++) { minted++; seed = randomizer.random(); address recipient = selectRecipient(seed, minted, paidTokens); if(recipient != _msgSender() && alter.balanceOf(_msgSender(), treasureChestTypeId) > 0) { // If the mint is going to be stolen, there's a 50% chance // a dragon will prefer a treasure chest over it if(seed & 1 == 1) { alter.safeTransferFrom(_msgSender(), recipient, treasureChestTypeId, 1, ""); recipient = _msgSender(); } } tokenIds[i] = minted; if (!stake || recipient != _msgSender()) { wndNFT.mint(recipient, seed); } else { wndNFT.mint(address(tower), seed); } totalGpCost += mintCost(minted, maxTokens, paidTokens); } wndNFT.updateOriginAccess(tokenIds); if (totalGpCost > 0) { gpToken.burn(_msgSender(), totalGpCost); gpToken.updateOriginAccess(); } if (stake) { tower.addManyToTowerAndFlight(_msgSender(), tokenIds); } lw.time = uint64(block.timestamp); lw.blockNum = uint64(block.number); }
function mint(uint256 amount, bool stake) external payable whenNotPaused nonReentrant { require(tx.origin == _msgSender(), "Only EOA"); uint16 minted = wndNFT.minted(); uint256 maxTokens = wndNFT.getMaxTokens(); uint256 paidTokens = wndNFT.getPaidTokens(); require(minted + amount <= maxTokens, "All tokens minted"); require(amount > 0 && amount <= 10, "Invalid mint amount"); if (minted < paidTokens) { require(minted + amount <= paidTokens, "All tokens on-sale already sold"); if(hasPublicSaleStarted) { require(msg.value >= amount * currentPriceToMint(), "Invalid payment amount"); } else { require(amount * presalePrice == msg.value, "Invalid payment amount"); require(_whitelistAddresses[_msgSender()].isWhitelisted, "Not on whitelist"); require(_whitelistAddresses[_msgSender()].numMinted + amount <= 2, "too many mints"); _whitelistAddresses[_msgSender()].numMinted += uint16(amount); } } else { require(msg.value == 0); } LastWrite storage lw = _lastWrite[tx.origin]; uint256 totalGpCost = 0; uint16[] memory tokenIds = new uint16[](amount); uint256 seed = 0; for (uint i = 0; i < amount; i++) { minted++; seed = randomizer.random(); address recipient = selectRecipient(seed, minted, paidTokens); if(recipient != _msgSender() && alter.balanceOf(_msgSender(), treasureChestTypeId) > 0) { // If the mint is going to be stolen, there's a 50% chance // a dragon will prefer a treasure chest over it if(seed & 1 == 1) { alter.safeTransferFrom(_msgSender(), recipient, treasureChestTypeId, 1, ""); recipient = _msgSender(); } } tokenIds[i] = minted; if (!stake || recipient != _msgSender()) { wndNFT.mint(recipient, seed); } else { wndNFT.mint(address(tower), seed); } totalGpCost += mintCost(minted, maxTokens, paidTokens); } wndNFT.updateOriginAccess(tokenIds); if (totalGpCost > 0) { gpToken.burn(_msgSender(), totalGpCost); gpToken.updateOriginAccess(); } if (stake) { tower.addManyToTowerAndFlight(_msgSender(), tokenIds); } lw.time = uint64(block.timestamp); lw.blockNum = uint64(block.number); }
50,280
30
// Logic for creating container mapping entry _serialNo bytes32 Serial of container _update bytes32 Serial of container /
function _updateContainer(bytes32 _serialNo, Container memory _update) internal { bool replaced = containerData.insert(_serialNo, _update); require(replaced == true, 'Problem updating container record...'); }
function _updateContainer(bytes32 _serialNo, Container memory _update) internal { bool replaced = containerData.insert(_serialNo, _update); require(replaced == true, 'Problem updating container record...'); }
29,083
25
// setup the defaults linkPrice = 2_000 ether;we use "ether" suffix instead of "e18" iNFT ID space up to 0xFFFF_FFFF (uint32 max) is reserved for the sales iNFT ID space up to 0x1_FFFF_FFFF is reserved for IntelliLinker (v1, non-upgradeable)
nextId = 0x2_0000_0000;
nextId = 0x2_0000_0000;
40,591
98
// This is public function is equivalent to {transfer}, and can be used toe.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. Requirements: - `sender` cannot be the zero address.- `recipient` cannot be the zero address.- `sender` must have a balance of at least `amount`. /
function _transfer(ShellStorage.Shell storage shell, address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); shell.balances[sender] = sub(shell.balances[sender], amount, "Shell/insufficient-balance"); shell.balances[recipient] = add(shell.balances[recipient], amount, "Shell/transfer-overflow"); emit Transfer(sender, recipient, amount); }
function _transfer(ShellStorage.Shell storage shell, address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); shell.balances[sender] = sub(shell.balances[sender], amount, "Shell/insufficient-balance"); shell.balances[recipient] = add(shell.balances[recipient], amount, "Shell/transfer-overflow"); emit Transfer(sender, recipient, amount); }
22,044
63
// set compValue
role.compValues[ keyForCompValues(targetAddress, functionSig, index) ] = compressCompValue(paramType, compValue); emit ScopeParameter( roleId, targetAddress, functionSig, index, paramType,
role.compValues[ keyForCompValues(targetAddress, functionSig, index) ] = compressCompValue(paramType, compValue); emit ScopeParameter( roleId, targetAddress, functionSig, index, paramType,
28,190
0
// https:solidity-by-example.org/structs/
contract Todos { Todo[] public todos; }
contract Todos { Todo[] public todos; }
48,934
14
// Borrow max from cyToken with current price cy The cyToken /
function borrowMax(ICToken cy) external nonReentrant onlyBorrower marketAllowed(address(cy)) { (, , uint256 borrowBalance, ) = cy.getAccountSnapshot(address(this)); IPriceOracle oracle = IPriceOracle(comptroller.oracle()); uint256 maxBorrowAmount = (this.collateralUSD() * 1e18) / oracle.getUnderlyingPrice(address(cy)); require(maxBorrowAmount > borrowBalance, "undercollateralized"); borrowInternal(cy, maxBorrowAmount - borrowBalance); }
function borrowMax(ICToken cy) external nonReentrant onlyBorrower marketAllowed(address(cy)) { (, , uint256 borrowBalance, ) = cy.getAccountSnapshot(address(this)); IPriceOracle oracle = IPriceOracle(comptroller.oracle()); uint256 maxBorrowAmount = (this.collateralUSD() * 1e18) / oracle.getUnderlyingPrice(address(cy)); require(maxBorrowAmount > borrowBalance, "undercollateralized"); borrowInternal(cy, maxBorrowAmount - borrowBalance); }
22,204
12
// require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]);
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); balances[_to] += _value;//接收账户增加token数量_value balances[_from] -= _value;//支出账户_from减去token数量_value allowed[_from][msg.sender] -= _value;//消息发送者可以从账户_from中转出的数量减少_value Transfer(_from, _to, _value);//触发转币交易事件 return true;
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); balances[_to] += _value;//接收账户增加token数量_value balances[_from] -= _value;//支出账户_from减去token数量_value allowed[_from][msg.sender] -= _value;//消息发送者可以从账户_from中转出的数量减少_value Transfer(_from, _to, _value);//触发转币交易事件 return true;
2,597
10
// Internal function that calls onTokenTransfer callback on the receiver after the successful transfer.Since it is not present in the original ERC677 standard, the callback is only called on the bridge contract,in order to simplify UX. In other cases, this token complies with the ERC677/ERC20 standard. _from tokens sender address. _to tokens receiver address. _value amount of sent tokens. /
function callAfterTransfer(address _from, address _to, uint256 _value) internal { if (isBridge(_to)) { require(contractFallback(_from, _to, _value, new bytes(0))); } }
function callAfterTransfer(address _from, address _to, uint256 _value) internal { if (isBridge(_to)) { require(contractFallback(_from, _to, _value, new bytes(0))); } }
11,731
0
// Add liquidity to the poolUser will need to approve this proxy to spend their at least"amountDFIDesired" amount first amountDFIDesired maximum amount of DFI to be deposited into DFI-ETH pool (required by UniswapV2Router02) amountDFIMin minimum amount of DFI to be deposited into DFI-ETH pool (required by UniswapV2Router02) amountETHMin minimum amount of ETH/WETH to be deposited into DFI-ETH pool (required by UniswapV2Router02) deadline the deadline required by UniswapV2Router02 /
function addLiquidityETH( uint256 amountDFIDesired, uint256 amountDFIMin, uint256 amountETHMin, uint256 deadline ) external payable nonReentrant returns (
function addLiquidityETH( uint256 amountDFIDesired, uint256 amountDFIMin, uint256 amountETHMin, uint256 deadline ) external payable nonReentrant returns (
26,943
27
// Claim all unclaimed tokens Given a merkle proof of (index, account, totalEarned), claim allunclaimed tokens. Unclaimed tokens are the difference between the totalearned tokens (provided in the merkle tree) and those that have beeneither claimed or slashed. Note: it is possible for the claimed and slashed tokens to exceeedthe total earned tokens, particularly when a slashing has occured.In this case no tokens are claimable until total earned has exceededthe sum of the claimed and slashed. If no tokens are claimable, this function will revert. index Claim index account Account for claim totalEarned Total lifetime amount of tokens earned by account
function claim(uint256 index, address account, uint256 totalEarned, bytes32[] calldata merkleProof) external override { require(governance != address(0), "MerkleDistributor: Governance not set"); // Verify caller is authorized and select beneficiary address beneficiary = msg.sender; if (msg.sender != account) { address collector = IGovernance(governance).rewardCollector(account); if (!hasRole(DISTRIBUTOR_ROLE, msg.sender)) { require(msg.sender == collector, "MerkleDistributor: Cannot collect rewards"); } else { beneficiary = collector == address(0) ? account : collector; } } // Verify the merkle proof. bytes32 node = keccak256(abi.encodePacked(index, account, totalEarned)); require(MerkleProof.verify(merkleProof, merkleRoot, node), "MerkleDistributor: Invalid proof"); // Calculate the claimable balance uint256 alreadyDistributed = accountState[account].totalClaimed + accountState[account].totalSlashed; require(totalEarned > alreadyDistributed, "MerkleDistributor: Nothing claimable"); uint256 claimable = totalEarned - alreadyDistributed; emit Claimed(index, totalEarned, account, claimable); // Apply account changes and transfer unclaimed tokens _increaseAccount(account, claimable, 0); require(token.mint(beneficiary, claimable), "MerkleDistributor: Mint failed"); }
function claim(uint256 index, address account, uint256 totalEarned, bytes32[] calldata merkleProof) external override { require(governance != address(0), "MerkleDistributor: Governance not set"); // Verify caller is authorized and select beneficiary address beneficiary = msg.sender; if (msg.sender != account) { address collector = IGovernance(governance).rewardCollector(account); if (!hasRole(DISTRIBUTOR_ROLE, msg.sender)) { require(msg.sender == collector, "MerkleDistributor: Cannot collect rewards"); } else { beneficiary = collector == address(0) ? account : collector; } } // Verify the merkle proof. bytes32 node = keccak256(abi.encodePacked(index, account, totalEarned)); require(MerkleProof.verify(merkleProof, merkleRoot, node), "MerkleDistributor: Invalid proof"); // Calculate the claimable balance uint256 alreadyDistributed = accountState[account].totalClaimed + accountState[account].totalSlashed; require(totalEarned > alreadyDistributed, "MerkleDistributor: Nothing claimable"); uint256 claimable = totalEarned - alreadyDistributed; emit Claimed(index, totalEarned, account, claimable); // Apply account changes and transfer unclaimed tokens _increaseAccount(account, claimable, 0); require(token.mint(beneficiary, claimable), "MerkleDistributor: Mint failed"); }
22,308
96
// ICallee dYdX Interface that Callees for Solo must implement in order to ingest data. /
abstract contract ICallee { // ============ Public Functions ============ /** * Allows users to send this contract arbitrary data. * * @param sender The msg.sender to Solo * @param accountInfo The account from which the data is being sent * @param data Arbitrary data given by the sender */ function callFunction( address sender, Account.Info memory accountInfo, bytes memory data ) public virtual; }
abstract contract ICallee { // ============ Public Functions ============ /** * Allows users to send this contract arbitrary data. * * @param sender The msg.sender to Solo * @param accountInfo The account from which the data is being sent * @param data Arbitrary data given by the sender */ function callFunction( address sender, Account.Info memory accountInfo, bytes memory data ) public virtual; }
25,060
24
// Set the last updated
lastUpdateTime = block.timestamp; startTime = block.timestamp;
lastUpdateTime = block.timestamp; startTime = block.timestamp;
63,809
77
// Getter for the wallet balance for a given asset _assetAddress - Asset to check balancereturn Balance /
function getBalance(address _assetAddress) public view returns (uint256) { MBDAAsset mbda2 = MBDAAsset(_assetAddress); return mbda2.balanceOf(address(this)); }
function getBalance(address _assetAddress) public view returns (uint256) { MBDAAsset mbda2 = MBDAAsset(_assetAddress); return mbda2.balanceOf(address(this)); }
41,946
413
// Places a bet. Callable only by token bankrolls_player The player that is placing the bet_tokenCount The total number of tokens bet_tier The div rate tier the player falls in_data The game-specific data, encoded in bytes-form/
function execute(address _player, uint _tokenCount, uint _tier, bytes _data)
function execute(address _player, uint _tokenCount, uint _tier, bytes _data)
24,517
32
// Withdraw full unlocked balance and claim pending rewards
function emergencyWithdraw() external updateReward(msg.sender) { (uint256 amount, uint256 penaltyAmount) = withdrawableBalance(msg.sender); delete userEarnings[msg.sender]; Balances storage bal = balances[msg.sender]; bal.total = bal.total.sub(bal.unlocked).sub(bal.earned); bal.unlocked = 0; bal.earned = 0; totalSupply = totalSupply.sub(amount.add(penaltyAmount)); stakingToken.safeTransfer(msg.sender, amount); if (penaltyAmount > 0) { _notifyReward(address(stakingToken), penaltyAmount); } getReward(); }
function emergencyWithdraw() external updateReward(msg.sender) { (uint256 amount, uint256 penaltyAmount) = withdrawableBalance(msg.sender); delete userEarnings[msg.sender]; Balances storage bal = balances[msg.sender]; bal.total = bal.total.sub(bal.unlocked).sub(bal.earned); bal.unlocked = 0; bal.earned = 0; totalSupply = totalSupply.sub(amount.add(penaltyAmount)); stakingToken.safeTransfer(msg.sender, amount); if (penaltyAmount > 0) { _notifyReward(address(stakingToken), penaltyAmount); } getReward(); }
16,304
43
// refound ETH
needRefoundETH(_user, _refoundETH); officialAddress.transfer(safeSub(_ether, _refoundETH)); return true;
needRefoundETH(_user, _refoundETH); officialAddress.transfer(safeSub(_ether, _refoundETH)); return true;
62,724
55
// Creates a new channel between a sender and a receiver, only callable by the Token contract./_sender The address that receives tokens./_receiver The address that receives tokens./_deposit The amount of tokens that the sender escrows.
function createChannelPrivate( address _sender, address _receiver, uint192 _deposit) private
function createChannelPrivate( address _sender, address _receiver, uint192 _deposit) private
17,555
823
// MIGRATION Import all new contracts into the address resolver;
addressresolver_importAddresses_0();
addressresolver_importAddresses_0();
29,641
53
// Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); }
function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); }
55,954
78
// Returns the token collection symbol. /
function symbol() external view returns (string memory);
function symbol() external view returns (string memory);
31,373
233
// Return all tokenIds owned by account /
function getTokenIds(address account)
function getTokenIds(address account)
38,432
23
// Check that the valset nonce is greater than the old one
require( _newValsetNonce > _currentValsetNonce, "New valset nonce must be greater than the current nonce" );
require( _newValsetNonce > _currentValsetNonce, "New valset nonce must be greater than the current nonce" );
28,172
210
// calculates rewards based on released amountuser - user whose rewards are being calculated return amount of tokens for reward. Excludes team members who are not part of reward program. /
function calculateRewardsTotal(address user) public view returns (uint256) { TokenHolder memory tokenHolder = tokenHolders[user]; if (!tokenHolder.notStaked ) return tokenHolder.tokensToSend.sub(tokenHolder.releasedAmount).mul(stakingRatio).div(10000); else return 0; }
function calculateRewardsTotal(address user) public view returns (uint256) { TokenHolder memory tokenHolder = tokenHolders[user]; if (!tokenHolder.notStaked ) return tokenHolder.tokensToSend.sub(tokenHolder.releasedAmount).mul(stakingRatio).div(10000); else return 0; }
10,248
14
// Percentage.
uint arbitration_fee = (TransactionInfo[_transactionID].arbitrator_fee / 100) * TransactionInfo[_transactionID].totalValue; TransactionInfo[_transactionID].totalValue -= arbitration_fee; TransactionInfo[_transactionID].arbitrator.transfer(arbitration_fee);
uint arbitration_fee = (TransactionInfo[_transactionID].arbitrator_fee / 100) * TransactionInfo[_transactionID].totalValue; TransactionInfo[_transactionID].totalValue -= arbitration_fee; TransactionInfo[_transactionID].arbitrator.transfer(arbitration_fee);
34,982
2
// A snapshot of data that can be used to validate order fulfillment.
function orderData(uint256 DIN, address buyer) constant returns (bytes32);
function orderData(uint256 DIN, address buyer) constant returns (bytes32);
18,015
59
// require(hasRole(ASSET_ROLE, address(0)) || hasRole(ASSET_ROLE, _params.assetContract), "!ASSET");임시로 콤멘트 아웃
uint256 startTime = _params.startTime;
uint256 startTime = _params.startTime;
26,412
64
// Set new token sale controller.May only be called by sale controller._newSaleController new token sale controller. /
function setSaleController(address _newSaleController) { require(msg.sender == saleController); assert(_newSaleController != 0x0); saleController = _newSaleController; }
function setSaleController(address _newSaleController) { require(msg.sender == saleController); assert(_newSaleController != 0x0); saleController = _newSaleController; }
25,410
30
// Get price per itemreturn price in wei /
function getPrice() external view returns (uint256) { return _price; }
function getPrice() external view returns (uint256) { return _price; }
25,932
12
// Set new fee recipient._setToken Address of SetToken _newFeeRecipientNew fee recipient /
function updateFeeRecipient(ISetToken _setToken, address _newFeeRecipient) external onlySetManager(_setToken, msg.sender) onlyValidAndInitializedSet(_setToken)
function updateFeeRecipient(ISetToken _setToken, address _newFeeRecipient) external onlySetManager(_setToken, msg.sender) onlyValidAndInitializedSet(_setToken)
26,649
25
// update the state variables used to calculate ubi, then mint
inflationOffset = findInflationOffset(); lastTouched = time(); currentIssuance = HubI(hub).issuance(); _mint(owner, gift);
inflationOffset = findInflationOffset(); lastTouched = time(); currentIssuance = HubI(hub).issuance(); _mint(owner, gift);
21,533
42
// constuctor(<other arguments>, address _vrfCoordinator, address _link)
* @dev VRFConsumerBase(_vrfCoordinator) public { * @dev <initialization with other arguments goes here> * @dev }
* @dev VRFConsumerBase(_vrfCoordinator) public { * @dev <initialization with other arguments goes here> * @dev }
8,500
43
// public methods /
function transfer(address _to, uint256 _value) public returns (bool) { require(locked == false); return super.transfer(_to, _value); }
function transfer(address _to, uint256 _value) public returns (bool) { require(locked == false); return super.transfer(_to, _value); }
14,028
58
// change the lockup periods (only Owner).------------------------------------------------------------------------------------ _firstTerm - _fourthTerm --> the new term periods.----------------------------------------------returns whether successfully changed or not. /
function changeTermPeriods( uint32 _firstTerm, uint32 _secondTerm, uint32 _thirdTerm, uint32 _fourthTerm
function changeTermPeriods( uint32 _firstTerm, uint32 _secondTerm, uint32 _thirdTerm, uint32 _fourthTerm
75,678
204
// If LONG, exchanged base amount should be more than _baseAssetAmountLimit, otherwise(SHORT), exchanged base amount should be less than _baseAssetAmountLimit. In SHORT case, more position means more debt so should not be larger than _baseAssetAmountLimit
if (_baseAssetAmountLimit.toUint() != 0) { if (_dir == Dir.ADD_TO_AMM) { require(baseAssetAmount.toUint() >= _baseAssetAmountLimit.toUint(), "Less than minimal base token"); } else {
if (_baseAssetAmountLimit.toUint() != 0) { if (_dir == Dir.ADD_TO_AMM) { require(baseAssetAmount.toUint() >= _baseAssetAmountLimit.toUint(), "Less than minimal base token"); } else {
2,483
200
// If this is an ETH bid, ensure they sent enough and convert it to WETH under the hood
if(currency == address(0)) { require(msg.value == amount, "Sent ETH Value does not match specified bid amount"); IWETH(wethAddress).deposit{value: amount}(); } else { // We must check the balance that was actually transferred to the auction, // as some tokens impose a transfer fee and would not actually transfer the // full amount to the market, resulting in potentally locked funds IERC20 token = IERC20(currency); uint256 beforeBalance = token.balanceOf(address(this)); token.safeTransferFrom(msg.sender, address(this), amount); uint256 afterBalance = token.balanceOf(address(this)); require(beforeBalance.add(amount) == afterBalance, "Token transfer call did not transfer expected amount"); }
if(currency == address(0)) { require(msg.value == amount, "Sent ETH Value does not match specified bid amount"); IWETH(wethAddress).deposit{value: amount}(); } else { // We must check the balance that was actually transferred to the auction, // as some tokens impose a transfer fee and would not actually transfer the // full amount to the market, resulting in potentally locked funds IERC20 token = IERC20(currency); uint256 beforeBalance = token.balanceOf(address(this)); token.safeTransferFrom(msg.sender, address(this), amount); uint256 afterBalance = token.balanceOf(address(this)); require(beforeBalance.add(amount) == afterBalance, "Token transfer call did not transfer expected amount"); }
60,036
52
// Excludes Contract From Fees /
function setFeeExemption(address wallet, bool exempt) external onlyOwner { require(wallet != address(0)); isFeeExempt[wallet] = exempt; emit SetFeeExemption(wallet, exempt); }
function setFeeExemption(address wallet, bool exempt) external onlyOwner { require(wallet != address(0)); isFeeExempt[wallet] = exempt; emit SetFeeExemption(wallet, exempt); }
25,900
78
// Interface constant for ERC721, to check values in constructor.
bytes4 private constant ERC721_INTERFACE_ID = 0x80ac58cd;
bytes4 private constant ERC721_INTERFACE_ID = 0x80ac58cd;
23,109
3
// @inheritdoc ILayerZeroReceiver
function lzReceive( uint16 _srcChainId, bytes calldata _srcAddress, uint64, bytes calldata _payload
function lzReceive( uint16 _srcChainId, bytes calldata _srcAddress, uint64, bytes calldata _payload
19,445
1
// Set a value against a key._keyA key which should conform to the format described above./
function setValue(uint256 _key, bytes calldata _value) external; function deleteValue(uint256 _key) external; function getValue(uint256 _key) external view returns(bytes memory); function getVersion() external pure returns (uint16);
function setValue(uint256 _key, bytes calldata _value) external; function deleteValue(uint256 _key) external; function getValue(uint256 _key) external view returns(bytes memory); function getVersion() external pure returns (uint16);
43,641
40
// called by the owner to pause, triggers stopped state /
function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(msg.sender); }
function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(msg.sender); }
3,639
15
// Available amount for an account account uint256 /
function available(address account) external view returns (uint256);
function available(address account) external view returns (uint256);
36,622
84
// calculate gas used during execution
uint256 remainingGasEnd = gasleft(); uint256 usedGas = remainingGasStart.sub(remainingGasEnd).add(31221);
uint256 remainingGasEnd = gasleft(); uint256 usedGas = remainingGasStart.sub(remainingGasEnd).add(31221);
53,726
15
// Reward addresses, rates, and managers
mapping(address => address) public rewardManagers; // token addr -> manager addr address[] public rewardTokens; uint256[] public rewardRates; string[] public rewardSymbols; mapping(address => uint256) public rewardTokenAddrToIdx; // token addr -> token index
mapping(address => address) public rewardManagers; // token addr -> manager addr address[] public rewardTokens; uint256[] public rewardRates; string[] public rewardSymbols; mapping(address => uint256) public rewardTokenAddrToIdx; // token addr -> token index
5,103
126
// The Ledger smart contract reference
Ledger public ledgerContract;
Ledger public ledgerContract;
5,791
24
// mintNFT, external function/mint new NFTs
function mintNFT() external payable whenNotPaused onlyWhenNotMaxSupplyReached { require(msg.value >= nftPrice, "Lynchs Locks: Ether value sent is not correct"); _mintNFT(msg.sender, totalSupply()); }
function mintNFT() external payable whenNotPaused onlyWhenNotMaxSupplyReached { require(msg.value >= nftPrice, "Lynchs Locks: Ether value sent is not correct"); _mintNFT(msg.sender, totalSupply()); }
31,889
205
// Transfer proceeds to seller (if there are any!)
if (price > 0) {
if (price > 0) {
22,089
107
// Read loan oracle
return getCurrencyToToken(address(oracle), amount, _oracleData);
return getCurrencyToToken(address(oracle), amount, _oracleData);
37,645
14
// users redeem already allocated tokens manuallyquantity -> number of tokens to redeem/
function redeem(uint256 quantity) external{ uint256 baseUnits = quantity * 10**18; uint256 senderEligibility = redeemBalanceOf[msg.sender]; uint256 tokensAvailable = token.balanceOf(this); require(senderEligibility >= baseUnits); require( tokensAvailable >= baseUnits); if(token.transferFrom(owner, msg.sender,baseUnits)){ redeemBalanceOf[msg.sender] -= baseUnits; Redeemed(msg.sender,quantity); } }
function redeem(uint256 quantity) external{ uint256 baseUnits = quantity * 10**18; uint256 senderEligibility = redeemBalanceOf[msg.sender]; uint256 tokensAvailable = token.balanceOf(this); require(senderEligibility >= baseUnits); require( tokensAvailable >= baseUnits); if(token.transferFrom(owner, msg.sender,baseUnits)){ redeemBalanceOf[msg.sender] -= baseUnits; Redeemed(msg.sender,quantity); } }
15,966
2
// remove an account's access to this role /
function remove(Role storage role, address account) internal { require(account != address(0)); require(has(role, account)); role.bearer[account] = false; }
function remove(Role storage role, address account) internal { require(account != address(0)); require(has(role, account)); role.bearer[account] = false; }
14,397
13
// External function to end the battle. This function can be called only by owner. _winnerTokenId Winner token Id in battle /
function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BattleState.RUNNING, "Battle is not started"); battleState = BattleState.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); _setTokenURI(_winnerTokenId, tokenURI); emit BattleEnded(address(this), _winnerTokenId, tokenURI); }
function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BattleState.RUNNING, "Battle is not started"); battleState = BattleState.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); _setTokenURI(_winnerTokenId, tokenURI); emit BattleEnded(address(this), _winnerTokenId, tokenURI); }
81,192
76
// Reference to the J8TToken contract
J8TToken public tokenContract;
J8TToken public tokenContract;
5,756
77
// Finalize the crowdsale/
function finalize() public onlyUnlocked onlyOwner { //Make sure Sale is not running //If sale is running, then check if the hard cap has been reached or not assert(!isSaleRunning() || (HARD_CAP.Sub(totalSupply)) <= 1e18); endTime = now; //enable transferring of tokens among token holders locked = false; //Emit event when crowdsale state changes emit StateChanged(true); }
function finalize() public onlyUnlocked onlyOwner { //Make sure Sale is not running //If sale is running, then check if the hard cap has been reached or not assert(!isSaleRunning() || (HARD_CAP.Sub(totalSupply)) <= 1e18); endTime = now; //enable transferring of tokens among token holders locked = false; //Emit event when crowdsale state changes emit StateChanged(true); }
46,997
86
// Transferring available dividends to the investor. Перевод доступных к выводу средств на кошелек инвестора;
token.transfer(msg.sender, amountToWithdraw);
token.transfer(msg.sender, amountToWithdraw);
28,565
201
// ========== PUBLIC FUNCTIONS ========== / There needs to be a time interval that this can be called. Otherwise it can be called multiple times per expansion.
uint256 public last_call_time; // Last time the refreshCollateralRatio function was called
uint256 public last_call_time; // Last time the refreshCollateralRatio function was called
12,801
1
// Total amount deposited
uint256 lpSupply;
uint256 lpSupply;
61,006
22
// See {IDigitalReserve-withdrawDrc}. /
function withdrawDrc(uint256 drcAmount, uint32 deadline) external override { require(balanceOf(msg.sender) > 0, "Vault balance is 0"); address[] memory path = new address[](2); path[0] = uniswapRouter.WETH(); path[1] = drcAddress; uint256 ethNeeded = uniswapRouter.getAmountsIn(drcAmount, path)[0]; uint256 ethNeededPlusFee = ethNeeded.mul(_feeBase + _feeFraction).div(_feeBase);
function withdrawDrc(uint256 drcAmount, uint32 deadline) external override { require(balanceOf(msg.sender) > 0, "Vault balance is 0"); address[] memory path = new address[](2); path[0] = uniswapRouter.WETH(); path[1] = drcAddress; uint256 ethNeeded = uniswapRouter.getAmountsIn(drcAmount, path)[0]; uint256 ethNeededPlusFee = ethNeeded.mul(_feeBase + _feeFraction).div(_feeBase);
71,882
278
// indexDelta =(rate - targetRate) / targetRate
if (rate > targetRate) { return (rate.sub(targetRate).mul(BASE).div(targetRate), true); } else {
if (rate > targetRate) { return (rate.sub(targetRate).mul(BASE).div(targetRate), true); } else {
12,799
33
// If, for any reason, betting needs to be paused (very unlikely), this will freeze all bets.
function pauseGame() public onlyOwner { gameActive = false; }
function pauseGame() public onlyOwner { gameActive = false; }
43,475
122
// Transfers a Position's collateral and debt balances to another Position/Checks that the sender is delegated by `src` and `dst` Position owners,/ that the `src` and `dst` Positions are still safe after the transfer,/ and that the `src` and `dst` Positions' debt exceed the vault's debt floor/vault Address of the Vault/tokenId ERC1155 or ERC721 style TokenId (leave at 0 for ERC20)/src Address of the `src` Positions owner/dst Address of the `dst` Positions owner/deltaCollateral Amount of collateral to send to (+) or from (-) the `src` Position [wad]/deltaNormalDebt Amount of normalized debt (gross, before rate is applied) to send to (+) or/
function transferCollateralAndDebt( address vault, uint256 tokenId, address src, address dst, int256 deltaCollateral, int256 deltaNormalDebt
function transferCollateralAndDebt( address vault, uint256 tokenId, address src, address dst, int256 deltaCollateral, int256 deltaNormalDebt
22,507
147
// Safely transfers `tokenId` token from `from` to `to`. Requirements: - `from` cannot be the zero address.- `to` cannot be the zero address.- `tokenId` token must exist and be owned by `from`.- If the caller is not `from`, it must be approved to move this token
* by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public payable virtual override { transferFrom(from, to, tokenId); if (to.code.length != 0) if (!_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } }
* by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public payable virtual override { transferFrom(from, to, tokenId); if (to.code.length != 0) if (!_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } }
6,288
29
// add token parameters
ERC20 addTokenToken; uint addTokenMinimalResolution; // can be roughly 1 cent uint addTokenMaxPerBlockImbalance; // in twei resolution uint addTokenMaxTotalImbalance; address[] addTokenApproveSignatures; address[] addTokenResetSignatures;
ERC20 addTokenToken; uint addTokenMinimalResolution; // can be roughly 1 cent uint addTokenMaxPerBlockImbalance; // in twei resolution uint addTokenMaxTotalImbalance; address[] addTokenApproveSignatures; address[] addTokenResetSignatures;
56,837
21
// Attempts to rebalance the portfolio if the conditions are correct. /
function tryRebalance(Data storage self, PortfolioLib.Data storage portfolioLib, AccountLib.Data storage accountLib, PrismLogger logger, uint nonce) internal { if(!verifyRebalance(self, accountLib, nonce)) return; /* Rebalance Fees == fixedFee + (percentageFee1 + percentageFee2 + ... + percentageFeeN) where percentageFee == ((((amountChanged * price) / 1 ether) * feePercentage) / fixedPrecision) and N is the number of coins in the rebalance proposal uints array necessary to prevent solidity `stack depth exceeded` error uints[0] = fixed rebalance fee to seller / total fees to seller uints[1] = fixed rebalance fee to owner / total fees to owner uints[2] = percentage rebalance fee to seller uints[3] = percentage rebalance fee to owner uints[4] = number of coins in proposal uints[5] = number of coins in current portfolio uints[6] = amount changed (newAmount - oldAmount) uints[7] = price of each coin in proposal */ uint[] memory uints = new uint[](8); uints[0] = portfolioLib.rebalanceFeeFixedToSeller; uints[1] = portfolioLib.rebalanceFeeFixedToOwner; uints[2] = portfolioLib.rebalanceFeePercentToSeller; uints[3] = portfolioLib.rebalanceFeePercentToOwner; uints[4] = self.proposal.numCoins(); uints[5] = portfolioLib.coinsHeld.length; // get tickers and amounts from proposal bytes8[] memory tickers = new bytes8[](uints[4]); uint[] memory amounts = new uint[](uints[4]); // calculate fee for new and changed coins for (uint i=0; i < uints[4]; i++) { // each new coin tickers[i] = self.proposal.tickers(i); amounts[i] = self.proposal.amounts(i); // old (current) coin uint oldCoinAmount = portfolioLib.coins[tickers[i]]; uints[6] = SafeMath.absoluteDifference(amounts[i], oldCoinAmount); if (uints[6] > 0) { (uints[7],,) = CerberusOracle(Registrar(portfolioLib.registrar).registry('oracle')).get(tickers[i]); // fee calculation uints[0] = SafeMath.add(uints[0], calculateRebalanceFee(uints[6], uints[7], uints[2])); uints[1] = SafeMath.add(uints[1], calculateRebalanceFee(uints[6], uints[7], uints[3])); } // resets coin value to zero portfolioLib.deleteCoin(tickers[i]); } // calculate fee for removed coins for (i=0; i < uints[5]; i++) { // old (current) coin uints[6] = portfolioLib.coins[portfolioLib.coinsHeld[i]]; // because we zero-out the existing amount for each coin in the Rebalance Proposal above, // we can safely assume that any coin left with an amount > 0 has been removed and // calculate fee based on existing amount. if (uints[6] > 0) { (uints[7],,) = CerberusOracle(Registrar(portfolioLib.registrar).registry('oracle')).get(portfolioLib.coinsHeld[i]); // fee calculation uints[0] = SafeMath.add(uints[0], calculateRebalanceFee(uints[6], uints[7], uints[2])); uints[1] = SafeMath.add(uints[1], calculateRebalanceFee(uints[6], uints[7], uints[3])); // resets old coin value to zero portfolioLib.deleteCoin(portfolioLib.coinsHeld[i]); } } // transfer owner fees first if (uints[1] > 0) { accountLib.transfer(accountLib.buyer, accountLib.owner, uints[1]); } if (uints[0] > 0) { accountLib.transfer(accountLib.buyer, accountLib.seller, uints[0]); } portfolioLib.rebalancePortfolio(self.proposal.principal(), self.proposal.buyerCollateralRatio(), self.proposal.sellerCollateralRatio()); portfolioLib.initPortInternal(tickers, amounts, self.proposal.registrar()); self.timeLastRebalanced = now; logger.logRebalance(amounts, tickers, uints[0], uints[1], nonce); }
function tryRebalance(Data storage self, PortfolioLib.Data storage portfolioLib, AccountLib.Data storage accountLib, PrismLogger logger, uint nonce) internal { if(!verifyRebalance(self, accountLib, nonce)) return; /* Rebalance Fees == fixedFee + (percentageFee1 + percentageFee2 + ... + percentageFeeN) where percentageFee == ((((amountChanged * price) / 1 ether) * feePercentage) / fixedPrecision) and N is the number of coins in the rebalance proposal uints array necessary to prevent solidity `stack depth exceeded` error uints[0] = fixed rebalance fee to seller / total fees to seller uints[1] = fixed rebalance fee to owner / total fees to owner uints[2] = percentage rebalance fee to seller uints[3] = percentage rebalance fee to owner uints[4] = number of coins in proposal uints[5] = number of coins in current portfolio uints[6] = amount changed (newAmount - oldAmount) uints[7] = price of each coin in proposal */ uint[] memory uints = new uint[](8); uints[0] = portfolioLib.rebalanceFeeFixedToSeller; uints[1] = portfolioLib.rebalanceFeeFixedToOwner; uints[2] = portfolioLib.rebalanceFeePercentToSeller; uints[3] = portfolioLib.rebalanceFeePercentToOwner; uints[4] = self.proposal.numCoins(); uints[5] = portfolioLib.coinsHeld.length; // get tickers and amounts from proposal bytes8[] memory tickers = new bytes8[](uints[4]); uint[] memory amounts = new uint[](uints[4]); // calculate fee for new and changed coins for (uint i=0; i < uints[4]; i++) { // each new coin tickers[i] = self.proposal.tickers(i); amounts[i] = self.proposal.amounts(i); // old (current) coin uint oldCoinAmount = portfolioLib.coins[tickers[i]]; uints[6] = SafeMath.absoluteDifference(amounts[i], oldCoinAmount); if (uints[6] > 0) { (uints[7],,) = CerberusOracle(Registrar(portfolioLib.registrar).registry('oracle')).get(tickers[i]); // fee calculation uints[0] = SafeMath.add(uints[0], calculateRebalanceFee(uints[6], uints[7], uints[2])); uints[1] = SafeMath.add(uints[1], calculateRebalanceFee(uints[6], uints[7], uints[3])); } // resets coin value to zero portfolioLib.deleteCoin(tickers[i]); } // calculate fee for removed coins for (i=0; i < uints[5]; i++) { // old (current) coin uints[6] = portfolioLib.coins[portfolioLib.coinsHeld[i]]; // because we zero-out the existing amount for each coin in the Rebalance Proposal above, // we can safely assume that any coin left with an amount > 0 has been removed and // calculate fee based on existing amount. if (uints[6] > 0) { (uints[7],,) = CerberusOracle(Registrar(portfolioLib.registrar).registry('oracle')).get(portfolioLib.coinsHeld[i]); // fee calculation uints[0] = SafeMath.add(uints[0], calculateRebalanceFee(uints[6], uints[7], uints[2])); uints[1] = SafeMath.add(uints[1], calculateRebalanceFee(uints[6], uints[7], uints[3])); // resets old coin value to zero portfolioLib.deleteCoin(portfolioLib.coinsHeld[i]); } } // transfer owner fees first if (uints[1] > 0) { accountLib.transfer(accountLib.buyer, accountLib.owner, uints[1]); } if (uints[0] > 0) { accountLib.transfer(accountLib.buyer, accountLib.seller, uints[0]); } portfolioLib.rebalancePortfolio(self.proposal.principal(), self.proposal.buyerCollateralRatio(), self.proposal.sellerCollateralRatio()); portfolioLib.initPortInternal(tickers, amounts, self.proposal.registrar()); self.timeLastRebalanced = now; logger.logRebalance(amounts, tickers, uints[0], uints[1], nonce); }
21,359
55
// Checks whether the message is coming from the other messenger. Implemented by child/ contracts because the logic for this depends on the network where the messenger is/ being deployed./ return Whether the message is coming from the other messenger.
function _isOtherMessenger() internal view virtual returns (bool);
function _isOtherMessenger() internal view virtual returns (bool);
12,354
43
// color blending algorithm/in colors.js file the color ranges are: red 9-24 orange 25-39 yellow 40-54 green 55-69 blue 70-84 purple 85-98 //if parent is in red range & other parent in blue range, child color will be purple
if((mColor > 9 && mColor < 25 && dColor > 69 && dColor < 85) || (dColor > 9 && dColor < 25 && mColor > 69 && mColor < 85)) { colorCode = 92; }
if((mColor > 9 && mColor < 25 && dColor > 69 && dColor < 85) || (dColor > 9 && dColor < 25 && mColor > 69 && mColor < 85)) { colorCode = 92; }
18,074
88
// Token transfer function
function safeTransferFrom (address from, address to, uint256 _tokenId) override public { require(isApproved(msg.sender)); addressTokenHolder[_tokenId] = to; emit Transfer(from, to, _tokenId); }
function safeTransferFrom (address from, address to, uint256 _tokenId) override public { require(isApproved(msg.sender)); addressTokenHolder[_tokenId] = to; emit Transfer(from, to, _tokenId); }
14,701
34
// Gets the approved address for a token ID, or zero if no address set _tokenId uint256 ID of the token to query the approval ofreturn address currently approved for the given token ID /
function getApproved(uint256 _tokenId) public view returns (address) { return tokenApprovals[_tokenId]; }
function getApproved(uint256 _tokenId) public view returns (address) { return tokenApprovals[_tokenId]; }
14,330
7
// redeems base tokens based on amount of shares to be burned tokenOut address of the base token to be redeemed amountSharesToRedeem amount of shares to be burnedreturn amountTokenOut amount of base tokens redeemed /
function _redeem( address receiver, address tokenOut, uint256 amountSharesToRedeem ) internal virtual returns (uint256 amountTokenOut);
function _redeem( address receiver, address tokenOut, uint256 amountSharesToRedeem ) internal virtual returns (uint256 amountTokenOut);
28,384
48
// Migrate tokens to the new token contract
function migrate() public { require(migrationAgent != 0); uint value = balances[msg.sender]; balances[msg.sender] = balances[msg.sender].sub(value); totalSupply = totalSupply.sub(value); MigrationAgent(migrationAgent).migrateFrom(msg.sender, value); emit Upgrade(msg.sender, migrationAgent, value); }
function migrate() public { require(migrationAgent != 0); uint value = balances[msg.sender]; balances[msg.sender] = balances[msg.sender].sub(value); totalSupply = totalSupply.sub(value); MigrationAgent(migrationAgent).migrateFrom(msg.sender, value); emit Upgrade(msg.sender, migrationAgent, value); }
10,144
58
// Fallback payable function used to top up the bank roll.
fallback() external payable { cumulativeDeposit += msg.value; }
fallback() external payable { cumulativeDeposit += msg.value; }
24,853
3
// grows too big for a single call of {ERC721AQueryable-tokensOfOwner}. Requirements: - `start < stop` /
function tokensOfOwnerIn( address owner, uint256 start, uint256 stop ) external view virtual override returns (uint256[] memory) { unchecked { if (start >= stop) revert InvalidQueryRange(); uint256 tokenIdsIdx; uint256 stopLimit = _nextTokenId();
function tokensOfOwnerIn( address owner, uint256 start, uint256 stop ) external view virtual override returns (uint256[] memory) { unchecked { if (start >= stop) revert InvalidQueryRange(); uint256 tokenIdsIdx; uint256 stopLimit = _nextTokenId();
17,848
115
// Sets `amount` as the allowance of `spender` over the `owner`s tokens. This is internal function is equivalent to `approve`, and can be used toe.g. set aumatic allowances for certain subsystems, etc.
* Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve fromm the zero address"); require(spender != address(0), "ERC20: approvee to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
* Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve fromm the zero address"); require(spender != address(0), "ERC20: approvee to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
34,008
105
// modifier for functions only the team can call
modifier onlyTeam() { require(_isTeam(msg.sender), "Caller not in Team"); _; }
modifier onlyTeam() { require(_isTeam(msg.sender), "Caller not in Team"); _; }
13,553
8
// valid percentlimt is range of 1-100
modifier onlyPercentLimit(uint256 _percent) { require(_percent>0 && _percent<100,'Vsn Network:The consensus percentage is not in the specified wreath'); _; }
modifier onlyPercentLimit(uint256 _percent) { require(_percent>0 && _percent<100,'Vsn Network:The consensus percentage is not in the specified wreath'); _; }
29,402
15
// Event indicating minting of reputation to an address.
event Mint(address indexed _to, uint256 _amount);
event Mint(address indexed _to, uint256 _amount);
35,280
38
// - - -
bytes memory targetMessageData = abi.encode( TargetMessage({ actionId: actionId, sourceSender: msg.sender, vaultType: _action.vaultType, targetTokenAddress: _action.targetTokenAddress, targetSwapInfo: targetSwapInfo, targetRecipient: _action.targetRecipient == address(0) ? msg.sender
bytes memory targetMessageData = abi.encode( TargetMessage({ actionId: actionId, sourceSender: msg.sender, vaultType: _action.vaultType, targetTokenAddress: _action.targetTokenAddress, targetSwapInfo: targetSwapInfo, targetRecipient: _action.targetRecipient == address(0) ? msg.sender
37,111
7
// require(tknv.balanceOf(msg.sender) >= tknvRequired, 'membership required');
require(id <= currentid, 'invalid id'); if(inaddress[id] == address(0)){ require(path[0] == uniswapRouter.WETH(), 'invalid path'); require(outaddress[id] == path[path.length - 1], 'invalid path'); require(paymentBalance[id] == flatcost + inamt[id], 'request cancelled');
require(id <= currentid, 'invalid id'); if(inaddress[id] == address(0)){ require(path[0] == uniswapRouter.WETH(), 'invalid path'); require(outaddress[id] == path[path.length - 1], 'invalid path'); require(paymentBalance[id] == flatcost + inamt[id], 'request cancelled');
36,412
50
// Attach the token contract, can only be done once
function setTokenAddress(address _tokenAddress) external onlyOwner nonZeroAddress(_tokenAddress) { require(isTokenDeployed == false); token = NOLLYCOIN(_tokenAddress); isTokenDeployed = true; }
function setTokenAddress(address _tokenAddress) external onlyOwner nonZeroAddress(_tokenAddress) { require(isTokenDeployed == false); token = NOLLYCOIN(_tokenAddress); isTokenDeployed = true; }
8,873
11
// Skips a token + fee element from the buffer and returns the remainder/path The swap path/ return The remaining token + fee elements in the path
function skipToken(bytes memory path) internal pure returns (bytes memory) { return path.slice(NEXT_OFFSET, path.length - NEXT_OFFSET); }
function skipToken(bytes memory path) internal pure returns (bytes memory) { return path.slice(NEXT_OFFSET, path.length - NEXT_OFFSET); }
7,259
29
// Creates a new delegator contract that delegates all votes to delegatee_delegatee_ address that will be receiving all votesonly one delegator contract pointing to the same delegatee can exist/
function createDelegator(address delegatee_) external { require(delegatee_ != address(0), "Delegatee can't be 0"); require( delegateeToDelegator[delegatee_] == address(0), "Delegator already created" ); Delegator delegator = new Delegator(delegatee_, stakingToken); delegateeToDelegator[delegatee_] = address(delegator); delegatorToDelegatee[address(delegator)] = delegatee_; delegators[address(delegator)] = true; emit DelegatorCreated(address(delegator), delegatee_); }
function createDelegator(address delegatee_) external { require(delegatee_ != address(0), "Delegatee can't be 0"); require( delegateeToDelegator[delegatee_] == address(0), "Delegator already created" ); Delegator delegator = new Delegator(delegatee_, stakingToken); delegateeToDelegator[delegatee_] = address(delegator); delegatorToDelegatee[address(delegator)] = delegatee_; delegators[address(delegator)] = true; emit DelegatorCreated(address(delegator), delegatee_); }
12,843
120
// Distributes ether to token holders as dividends./It reverts if the total supply of tokens is 0./ It emits the `DividendsDistributed` event if the amount of received ether is greater than 0./ About undistributed ether:/ In each distribution, there is a small amount of ether not distributed,/ the magnified amount of which is/ `(msg.valuemagnitude) % totalSupply()`./ With a well-chosen `magnitude`, the amount of undistributed ether/ (de-magnified) in a distribution can be less than 1 wei./ We can actually keep track of the undistributed ether in a distribution/ and try to distribute it in the next distribution,/ but keeping track of such
function distributeDividends() public override payable { require(totalSupply() > 0); if (msg.value > 0) { magnifiedDividendPerShare = magnifiedDividendPerShare.add( (msg.value).mul(magnitude) / totalSupply() ); emit DividendsDistributed(msg.sender, msg.value); totalDividendsDistributed = totalDividendsDistributed.add(msg.value); } }
function distributeDividends() public override payable { require(totalSupply() > 0); if (msg.value > 0) { magnifiedDividendPerShare = magnifiedDividendPerShare.add( (msg.value).mul(magnitude) / totalSupply() ); emit DividendsDistributed(msg.sender, msg.value); totalDividendsDistributed = totalDividendsDistributed.add(msg.value); } }
53,736
12
// If this address has that method, this will work
underlyingAsset = zaToken(_address).underlyingAsset();
underlyingAsset = zaToken(_address).underlyingAsset();
74,139
55
// Bird's BDelegation Storage/
contract BDelegationStorage { /** * @notice Implementation address for this contract */ address public implementation; }
contract BDelegationStorage { /** * @notice Implementation address for this contract */ address public implementation; }
13,506