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
3
// 签名存储
zaccounts[msg.sender] = accountsig(r,e,s,Utils.G1Point(0,0)); return r;
zaccounts[msg.sender] = accountsig(r,e,s,Utils.G1Point(0,0)); return r;
17,085
122
// Update interest rate
uint256 utilization = uint256(_totalBorrow.elastic).mul(UTILIZATION_PRECISION) / fullAssetAmount; if (utilization < MINIMUM_TARGET_UTILIZATION) { uint256 underFactor = MINIMUM_TARGET_UTILIZATION.sub(utilization).mul(FACTOR_PRECISION) / MINIMUM_TARGET_UTILIZATION; uint256 scale = INTEREST_ELASTICITY.add(underFactor.mul(underFactor).mul(elapsedTime)); _accrueInfo.interestPerSecond = uint64(uint256(_accrueInfo.interestPerSecond).mul(INTEREST_ELASTICITY) / scale); if (_accrueInfo.interestPerSecond < MINIMUM_INTEREST_PER_SECOND) { _accrueInfo.interestPerSecond = MINIMUM_INTEREST_PER_SECOND; // 0.25% APR minimum }
uint256 utilization = uint256(_totalBorrow.elastic).mul(UTILIZATION_PRECISION) / fullAssetAmount; if (utilization < MINIMUM_TARGET_UTILIZATION) { uint256 underFactor = MINIMUM_TARGET_UTILIZATION.sub(utilization).mul(FACTOR_PRECISION) / MINIMUM_TARGET_UTILIZATION; uint256 scale = INTEREST_ELASTICITY.add(underFactor.mul(underFactor).mul(elapsedTime)); _accrueInfo.interestPerSecond = uint64(uint256(_accrueInfo.interestPerSecond).mul(INTEREST_ELASTICITY) / scale); if (_accrueInfo.interestPerSecond < MINIMUM_INTEREST_PER_SECOND) { _accrueInfo.interestPerSecond = MINIMUM_INTEREST_PER_SECOND; // 0.25% APR minimum }
9,178
3
// Users pending withdrawals
mapping(address => uint) public pendingWithdrawals; mapping(uint8 => Card) public cardStructs; // random access by card key uint8[] public cardList; // list of announce keys so we can enumerate them mapping(uint8 => CardDetails) public cardDetailsStructs; // random access by card details key uint8[] public cardDetailsList; // list of cards details keys so we can enumerate them
mapping(address => uint) public pendingWithdrawals; mapping(uint8 => Card) public cardStructs; // random access by card key uint8[] public cardList; // list of announce keys so we can enumerate them mapping(uint8 => CardDetails) public cardDetailsStructs; // random access by card details key uint8[] public cardDetailsList; // list of cards details keys so we can enumerate them
7,729
88
// Calculate token amount to be purchased
uint256 tokens = amount.mul(rate);
uint256 tokens = amount.mul(rate);
6,795
232
// name and ticker
constructor() ERC721("Basels", "Basels") {} // mapping to track claims for a given address mapping(address => uint256) private _claims; // keep track of tokens minted uint256 public tokensMinted = 0; // keep track of tokens claimed, to make sure a user doesn't claim say 3 when only 2 are left uint256 public tokensClaimed = 0; // function used to build an image as a string, which modern browsers can use to show an image. // Marketplaces can use this in place of an actual image file // which isn't possible to store onchain function svgToImageURI(string memory _source) public pure returns (string memory) { string memory baseURL = "data:image/svg+xml;base64,"; string memory svgBase64Encoded = Base64.encode(bytes(string(abi.encodePacked(_source)))); return string(abi.encodePacked(baseURL, svgBase64Encoded)); }
constructor() ERC721("Basels", "Basels") {} // mapping to track claims for a given address mapping(address => uint256) private _claims; // keep track of tokens minted uint256 public tokensMinted = 0; // keep track of tokens claimed, to make sure a user doesn't claim say 3 when only 2 are left uint256 public tokensClaimed = 0; // function used to build an image as a string, which modern browsers can use to show an image. // Marketplaces can use this in place of an actual image file // which isn't possible to store onchain function svgToImageURI(string memory _source) public pure returns (string memory) { string memory baseURL = "data:image/svg+xml;base64,"; string memory svgBase64Encoded = Base64.encode(bytes(string(abi.encodePacked(_source)))); return string(abi.encodePacked(baseURL, svgBase64Encoded)); }
16,893
30
// Emitted when a delegation is complete:
event DelegationComplete(uint64 indexed delegationId);
event DelegationComplete(uint64 indexed delegationId);
8,199
139
// Ensure the caller or the supplied signature is valid and increment nonce.
_validateActionAndIncrementNonce( ActionType.Cancel, abi.encode(), minimumActionGas, signature, signature );
_validateActionAndIncrementNonce( ActionType.Cancel, abi.encode(), minimumActionGas, signature, signature );
31,324
8
// ---------------------------------------------------------------------------- Contract function to receive approval and execute function in one call Borrowed from MiniMeToken ----------------------------------------------------------------------------
contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; }
contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; }
1,387
4
// Initializes a StableTokenV2.It keeps the same signature as the original initialize() functionin legacy/StableToken.sol _name The name of the stable token (English) _symbol A short symbol identifying the token (e.g. "cUSD")deprecated-param decimals Tokens are divisible to this many decimal places.deprecated-param registryAddress Address of the Registry contract.deprecated-param inflationRate Weekly inflation rate.deprecated-param inflationFactorUpdatePeriod How often the inflation factor is updated, in seconds. initialBalanceAddresses Array of addresses with an initial balance. initialBalanceValues Array of balance values corresponding to initialBalanceAddresses.deprecated-param exchangeIdentifier String identifier of exchange in registry (for specific fiat pairs) /
function initialize( string calldata _name, string calldata _symbol, uint8, // deprecated: decimals address, // deprecated: registryAddress, uint256, // deprecated: inflationRate, uint256, // deprecated: inflationFactorUpdatePeriod, address[] calldata initialBalanceAddresses, uint256[] calldata initialBalanceValues, string calldata // deprecated: exchangeIdentifier
function initialize( string calldata _name, string calldata _symbol, uint8, // deprecated: decimals address, // deprecated: registryAddress, uint256, // deprecated: inflationRate, uint256, // deprecated: inflationFactorUpdatePeriod, address[] calldata initialBalanceAddresses, uint256[] calldata initialBalanceValues, string calldata // deprecated: exchangeIdentifier
9,425
8
// (amountinwei/weiperethhash/eth)( (100 + bonuspercent)/100 ) = amountinweihashpereth/weipereth(bonus+100)/100
uint qty = div(mul(div(mul(msg.value, HASHPERETH),1000000000000000000),(bonus()+100)),100); if (qty > tokenSC.balanceOf(address(this)) || qty < 1) revert(); tokenSC.transfer( msg.sender, qty );
uint qty = div(mul(div(mul(msg.value, HASHPERETH),1000000000000000000),(bonus()+100)),100); if (qty > tokenSC.balanceOf(address(this)) || qty < 1) revert(); tokenSC.transfer( msg.sender, qty );
36,795
59
// For paying out balance on contract
function _payout(address _to) private { if (_to == address(0)) { ceoAddress.transfer(this.balance); } else { _to.transfer(this.balance); } }
function _payout(address _to) private { if (_to == address(0)) { ceoAddress.transfer(this.balance); } else { _to.transfer(this.balance); } }
35,506
18
// Ensure the admin address is valid.
require(_admin != 0x0);
require(_admin != 0x0);
32,767
28
// Verify whether an account is a bearer of a role _account The account to verify. _role The role to look into.return Whether the account is a bearer of the role. /
function hasRole(address _account, uint256 _role) public view returns(bool)
function hasRole(address _account, uint256 _role) public view returns(bool)
26,174
160
// assume timestamps will not cause overflow
tCampaignStart = tNow; t_1st_StageEnd += tNow; t_2nd_StageEnd += tNow; tCampaignEnd += tNow; CampaignOpen(now);
tCampaignStart = tNow; t_1st_StageEnd += tNow; t_2nd_StageEnd += tNow; tCampaignEnd += tNow; CampaignOpen(now);
77,285
7
// Signature for the first validator set update.
Signature[] memory sigs = new Signature[](1); bytes32 digest_eip191 = ECDSA.toEthSignedMessageHash(newCheckpoint); (uint8 v, bytes32 r, bytes32 s) = cheats.sign(testPriv1, digest_eip191); sigs[0] = Signature(v, r, s); bridge.updateValidatorSet(newNonce, newPowerThreshold, newVSHash, oldVS, sigs); assertEq(bridge.state_eventNonce(), newNonce); assertEq(bridge.state_powerThreshold(), newPowerThreshold); assertEq(bridge.state_lastValidatorSetCheckpoint(), newCheckpoint);
Signature[] memory sigs = new Signature[](1); bytes32 digest_eip191 = ECDSA.toEthSignedMessageHash(newCheckpoint); (uint8 v, bytes32 r, bytes32 s) = cheats.sign(testPriv1, digest_eip191); sigs[0] = Signature(v, r, s); bridge.updateValidatorSet(newNonce, newPowerThreshold, newVSHash, oldVS, sigs); assertEq(bridge.state_eventNonce(), newNonce); assertEq(bridge.state_powerThreshold(), newPowerThreshold); assertEq(bridge.state_lastValidatorSetCheckpoint(), newCheckpoint);
18,287
13
// Add multiple vesting to contract by arrays of data _users[] addresses of holders _startTokens[] tokens that can be withdrawn at startDate _totalTokens[] total tokens in vesting _startDate date from when tokens can be claimed _endDate date after which all tokens can be claimed /
function massAddHolders( address[] calldata _users, uint256[] calldata _startTokens, uint256[] calldata _totalTokens, uint256 _startDate, uint256 _endDate
function massAddHolders( address[] calldata _users, uint256[] calldata _startTokens, uint256[] calldata _totalTokens, uint256 _startDate, uint256 _endDate
45,954
112
// reservoirReward = times_reporterDepositreservoirSlashingRewardPct / HUNDRED_PCT;
reservoirReward = product.mul(protocolSlashingRewardPct) / HUNDRED_PCT;
reservoirReward = product.mul(protocolSlashingRewardPct) / HUNDRED_PCT;
42,084
18
// Gets a balance of the credit/including the claimable credit and the imposed credit you have to pay./account address of the user
function balanceOf(address account) public view override returns (uint256) { return _credit().balanceOf(account) + claimableCredit(account) - burnableCredit(account); }
function balanceOf(address account) public view override returns (uint256) { return _credit().balanceOf(account) + claimableCredit(account) - burnableCredit(account); }
4,074
31
// indicates if hard-liquidation was activated
function glad() external view returns(bool);
function glad() external view returns(bool);
22,274
82
// No of days for which the complete crowdsale will run- presale+ crowdsale
uint public durationCrowdSale;
uint public durationCrowdSale;
3,577
30
// calculate what is really leaving the contract, basically _eth - _fee -devfee
_eth = _eth - _fee - _devfee; contractValue = contractValue.sub( _eth ); if (tokenSupply>magnitude) { tokenPrice = (contractValue.mul( magnitude)) / tokenSupply; }
_eth = _eth - _fee - _devfee; contractValue = contractValue.sub( _eth ); if (tokenSupply>magnitude) { tokenPrice = (contractValue.mul( magnitude)) / tokenSupply; }
28,766
44
// gets VANILLA tokens from user to contract address
require(transfer(address(this), _tokens), "In sufficient tokens in user wallet");
require(transfer(address(this), _tokens), "In sufficient tokens in user wallet");
38,113
162
// Transfers a name from one node to another!! -------- to be used with great caution and only as a result of community governance action -----------Designed to remedy brand infringement issues. This breaks decentralization and must eventually be givenover to some kind of governance contract.Destination node must have content adressable storage Set to 0xFFF...../
function transferName( uint32 _fromNode, uint32 _toNode, string calldata _name ) external;
function transferName( uint32 _fromNode, uint32 _toNode, string calldata _name ) external;
5,412
17
// ICO is not active and not started
Inactive,
Inactive,
20,866
2
// summon a new Superfluid Minion//moloch Moloch DAO address/_sfApp App to interact with Superfluid protocol contracts/details Minion details
function summonMinion(address moloch, address _sfApp,
function summonMinion(address moloch, address _sfApp,
7,001
119
// returns player earnings per vaults -functionhash- 0x63066434return winnings vaultreturn general vault /
function getPlayerVaults(uint256 _pID) public view returns(uint256, uint256)
function getPlayerVaults(uint256 _pID) public view returns(uint256, uint256)
16,107
1,208
// Checks if currency balances are active in the account returns them if true/ return cash balance, nTokenBalance
function _getCurrencyBalances(address account, bytes2 currencyBytes) private view returns (int256, int256)
function _getCurrencyBalances(address account, bytes2 currencyBytes) private view returns (int256, int256)
63,531
149
// Transfer tokens from one address to anotherfrom address The address which you want to send tokens fromto address The address which you want to transfer tovalue uint256 the amount of tokens to be transferred/
function transferFrom(address from, address to, uint256 value) public returns (bool) { _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; }
function transferFrom(address from, address to, uint256 value) public returns (bool) { _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; }
35,881
114
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
uint256 tokens = _getTokenAmount(weiAmount);
12,289
60
// Otherwise increase owners count
ownersCount += 1;
ownersCount += 1;
11,290
46
// Retrieve the current conduit key from the accumulator.
bytes32 accumulatorConduitKey = _getAccumulatorConduitKey(accumulator);
bytes32 accumulatorConduitKey = _getAccumulatorConduitKey(accumulator);
17,049
1,190
// 596
entry "pin-eyed" : ENG_ADJECTIVE
entry "pin-eyed" : ENG_ADJECTIVE
17,208
36
// Exchange tokens for ether. Invest type two /
function buybackTypeTwo() public { uint256 allowanceToken = token.allowance(msg.sender,this); require(allowanceToken != uint256(0)); require(isInvestTypeTwo(msg.sender)); require(isBuyBackTwo()); require(balancesICOToken[msg.sender] >= allowanceToken); uint256 accumulated = percentBuyBackTypeTwo.mul(allowanceToken).div(100).mul(5).add(allowanceToken); // ~ 67% of tokens purchased in 5 year uint256 forTransfer = accumulated.mul(buyPrice).div(1e18); //calculation Eth require(totalFundsAvailable >= forTransfer); msg.sender.transfer(forTransfer); totalFundsAvailable = totalFundsAvailable.sub(forTransfer); balancesICOToken[msg.sender] = balancesICOToken[msg.sender].sub(allowanceToken); token.transferFrom(msg.sender, this, allowanceToken); }
function buybackTypeTwo() public { uint256 allowanceToken = token.allowance(msg.sender,this); require(allowanceToken != uint256(0)); require(isInvestTypeTwo(msg.sender)); require(isBuyBackTwo()); require(balancesICOToken[msg.sender] >= allowanceToken); uint256 accumulated = percentBuyBackTypeTwo.mul(allowanceToken).div(100).mul(5).add(allowanceToken); // ~ 67% of tokens purchased in 5 year uint256 forTransfer = accumulated.mul(buyPrice).div(1e18); //calculation Eth require(totalFundsAvailable >= forTransfer); msg.sender.transfer(forTransfer); totalFundsAvailable = totalFundsAvailable.sub(forTransfer); balancesICOToken[msg.sender] = balancesICOToken[msg.sender].sub(allowanceToken); token.transferFrom(msg.sender, this, allowanceToken); }
28,295
74
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ VANITY FUNCTIONS^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returns a hashed version of msg.data sent by original signer for any given function
function checkMsgData (Data storage self, bytes32 _whatFunction) internal view returns (bytes32 msg_data)
function checkMsgData (Data storage self, bytes32 _whatFunction) internal view returns (bytes32 msg_data)
23,632
4
// Returns the balance of an address. who Address to lookup.return Number of units. /
function getBalance(address who) external view returns (uint) { return tokenStorage.getBalance(who); }
function getBalance(address who) external view returns (uint) { return tokenStorage.getBalance(who); }
8,479
65
// Transfers tokens from one account to another on their behalf Any transaction fees will be applied and any fees reflected to holders This requires the sender to have approved an allowance prior to it being sent on their behalf
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; }
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; }
36,042
139
// Get the hero&39;s class id.
function getHeroClassId(uint256 _tokenId) external view returns (uint32)
function getHeroClassId(uint256 _tokenId) external view returns (uint32)
18,076
2
// timestamp that rewards start vesting
uint256 constant public override vestingStart = 1638316800; // midnight UTC before December 1, 2021
uint256 constant public override vestingStart = 1638316800; // midnight UTC before December 1, 2021
37,224
20
// counterfactual
price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;
price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;
8,618
345
// votereputation
mapping(uint => uint ) preBoostedVotes;
mapping(uint => uint ) preBoostedVotes;
37,163
4
// Returns the size of the code on a given address _addr Address that may or may not contain codereturn size of the code on the given `_addr` /
function codeSize(address _addr) internal view returns (uint256 size) { assembly { size := extcodesize(_addr) } }
function codeSize(address _addr) internal view returns (uint256 size) { assembly { size := extcodesize(_addr) } }
23,770
23
// Event is broadcast whenever a chest is purchased./
event ChestPurchased( uint16 _chestType, uint16 _chestAmount, address indexed _buyer, address indexed _referrer, uint256 _referralReward );
event ChestPurchased( uint16 _chestType, uint16 _chestAmount, address indexed _buyer, address indexed _referrer, uint256 _referralReward );
43,757
50
// Attributes
string memory metadata_attr = string( abi.encodePacked( 'attributes": [{"trait_type": "Voyage Distance", "value": ', toString(rp.voyage_distance), "},",
string memory metadata_attr = string( abi.encodePacked( 'attributes": [{"trait_type": "Voyage Distance", "value": ', toString(rp.voyage_distance), "},",
416
160
// Emitted when an account withdraws funds from `RelayHub`. /
event Withdrawn(address indexed account, address indexed dest, uint256 amount);
event Withdrawn(address indexed account, address indexed dest, uint256 amount);
5,454
89
// return Computes in % how far off market is from peg /
function computeOffPegPerc(uint256 rate) private view returns (uint256, bool)
function computeOffPegPerc(uint256 rate) private view returns (uint256, bool)
4,061
12
// Sets a new insignificantLoanThreshold RESTRICTION: Timelock only /
function setInsignificantLoanThreshold(uint256 newValue_) external;
function setInsignificantLoanThreshold(uint256 newValue_) external;
37,353
25
// Update the merkle root for a mint id mintIdThe mint id to update _merkleRoot The new merkle root /
function updateMintMerkleRoot(uint256 mintId, bytes32 _merkleRoot) external onlyOwner { if (mintId >= nextMintId) revert Preseller__MintIdInvalid(); emit MerkleRootUpdated(mintId, _merkleRoot, mintInfos[mintId].merkleRoot); mintInfos[mintId].merkleRoot = _merkleRoot; }
function updateMintMerkleRoot(uint256 mintId, bytes32 _merkleRoot) external onlyOwner { if (mintId >= nextMintId) revert Preseller__MintIdInvalid(); emit MerkleRootUpdated(mintId, _merkleRoot, mintInfos[mintId].merkleRoot); mintInfos[mintId].merkleRoot = _merkleRoot; }
35,296
351
// Normalize decimals in case equivalent asset uses different decimals from internal unit
uint sourceAmountInEquivalent = (sourceAmount.mul(10**uint(sourceEquivalent.decimals()))).div(SafeDecimalMath.unit()); require(address(dexAggregator) != address(0), "dex aggregator address is 0"); require(twapWindow != 0, "Uninitialized atomic twap window"); uint twapValueInEquivalent = dexAggregator.assetToAsset( address(sourceEquivalent),
uint sourceAmountInEquivalent = (sourceAmount.mul(10**uint(sourceEquivalent.decimals()))).div(SafeDecimalMath.unit()); require(address(dexAggregator) != address(0), "dex aggregator address is 0"); require(twapWindow != 0, "Uninitialized atomic twap window"); uint twapValueInEquivalent = dexAggregator.assetToAsset( address(sourceEquivalent),
24,665
27
// 5_l'administrateur let fin a la session du vote
function gVotingSessionEndeded()public onlyOwner() votingSessionOpen()
function gVotingSessionEndeded()public onlyOwner() votingSessionOpen()
17,848
6
// Remove last element from array This will decrease the array length by 1
arr.pop();
arr.pop();
7,575
206
// Gets a reference of the potential yin.
Kydy storage yin = kydys[_yinId];
Kydy storage yin = kydys[_yinId];
71,326
14
// Assigned relayer maker fee
uint256 makerFee;
uint256 makerFee;
4,295
24
// 触发更换开发贡献者奖金池事件
emit ContributionPoolChanged(msg.sender, newFund);
emit ContributionPoolChanged(msg.sender, newFund);
11,085
28
// Restore the part of the free memory pointer that was overwritten, which is guaranteed to be zero, if less than 8tb of memory is used.
mstore(0x3a, 0)
mstore(0x3a, 0)
13,936
576
// Calculate denominator for row 993: x - g^993z.
let denominator := add(shiftedEvalPoint, mload(add(expmodsAndPoints, 0xf40))) mstore(add(productsPtr, 0xc00), partialProduct) mstore(add(valuesPtr, 0xc00), denominator) partialProduct := mulmod(partialProduct, denominator, PRIME)
let denominator := add(shiftedEvalPoint, mload(add(expmodsAndPoints, 0xf40))) mstore(add(productsPtr, 0xc00), partialProduct) mstore(add(valuesPtr, 0xc00), denominator) partialProduct := mulmod(partialProduct, denominator, PRIME)
29,208
5
// Get the amount of Hal9K token representing equivalent value to weth amount
uint256 optimalHal9kAmount = UniswapV2Library.quote( wethAmount, wethReserve, hal9kReserve ); uint256 optimalWETHAmount; if (optimalHal9kAmount > hal9kAmount) { optimalWETHAmount = UniswapV2Library.quote(
uint256 optimalHal9kAmount = UniswapV2Library.quote( wethAmount, wethReserve, hal9kReserve ); uint256 optimalWETHAmount; if (optimalHal9kAmount > hal9kAmount) { optimalWETHAmount = UniswapV2Library.quote(
32,201
159
// Is minter. /
// function isMinter(address minter) external view returns (bool) { // return _minters[minter]; // }
// function isMinter(address minter) external view returns (bool) { // return _minters[minter]; // }
15,687
5
// Ownable Base contract with an owner.Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner. /
contract OwnableService { address payable public owner; address payable public serviceContract; event UnderlyingAssetDeposited( address payable user, uint256 underlyingAmount, uint256 derivativeAmount, uint256 balance ); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event ContractOwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor(address payable _serviceContract) internal { owner = msg.sender; serviceContract = _serviceContract; } modifier onlyOwner() { require(msg.sender == owner, "Unauthorized access to contract"); _; } modifier onlyOwnerAndServiceContract() { require( msg.sender == owner || msg.sender == serviceContract, "Unauthorized access to contract" ); _; } function transferOwnership(address payable newOwner) public onlyOwner { address oldOwner = owner; require(newOwner != address(0), "address cannot be zero"); owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } function transferContractOwnership(address payable newServiceContract) public onlyOwnerAndServiceContract { address oldServiceContract = serviceContract; require(newServiceContract != address(0), "address cannot be zero"); serviceContract = newServiceContract; emit ContractOwnershipTransferred(oldServiceContract, newServiceContract); } }
contract OwnableService { address payable public owner; address payable public serviceContract; event UnderlyingAssetDeposited( address payable user, uint256 underlyingAmount, uint256 derivativeAmount, uint256 balance ); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event ContractOwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor(address payable _serviceContract) internal { owner = msg.sender; serviceContract = _serviceContract; } modifier onlyOwner() { require(msg.sender == owner, "Unauthorized access to contract"); _; } modifier onlyOwnerAndServiceContract() { require( msg.sender == owner || msg.sender == serviceContract, "Unauthorized access to contract" ); _; } function transferOwnership(address payable newOwner) public onlyOwner { address oldOwner = owner; require(newOwner != address(0), "address cannot be zero"); owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } function transferContractOwnership(address payable newServiceContract) public onlyOwnerAndServiceContract { address oldServiceContract = serviceContract; require(newServiceContract != address(0), "address cannot be zero"); serviceContract = newServiceContract; emit ContractOwnershipTransferred(oldServiceContract, newServiceContract); } }
5,619
16
// allows one time setting of admin for deployment purposes
if (admin_initialized) { require(msg.sender == address(this), "Timelock::setPendingAdmin: Call must come from Timelock."); } else {
if (admin_initialized) { require(msg.sender == address(this), "Timelock::setPendingAdmin: Call must come from Timelock."); } else {
17,229
14
// Return the ruling of a dispute._disputeID ID of the dispute to rule. return ruling The ruling which would or has been given. /
function currentRuling(uint256 _disputeID) public view override returns (uint256 ruling)
function currentRuling(uint256 _disputeID) public view override returns (uint256 ruling)
31,226
209
// before the first pool swap, contract call _deposit to get ERC20 token through DODOApprove/transfer ETH to WETH
function _deposit( address from, address to, address token, uint256 amount, bool isETH
function _deposit( address from, address to, address token, uint256 amount, bool isETH
19,729
24
// keccak256("SavingsManager");1.0
bytes32 internal constant KEY_SAVINGS_MANAGER = 0x12fe936c77a1e196473c4314f3bed8eeac1d757b319abb85bdda70df35511bf1;
bytes32 internal constant KEY_SAVINGS_MANAGER = 0x12fe936c77a1e196473c4314f3bed8eeac1d757b319abb85bdda70df35511bf1;
25,919
4
// Returns the amount of tokens owned by `account`./
function balanceOf(address account) external view returns(uint256);
function balanceOf(address account) external view returns(uint256);
1,035
201
// Update dev address by the owner.
function dev(address _devaddr) public onlyOwner { devaddr = _devaddr; }
function dev(address _devaddr) public onlyOwner { devaddr = _devaddr; }
13,186
12
// shows the price that the address purchased tokens at
mapping (address => uint256) pricePurchasedAt;
mapping (address => uint256) pricePurchasedAt;
13,299
37
// Retrieves various contract information. configKeys An array of configuration keys to retrieve.return lastUpdateTime The value of lastUpdateTime state variable.return lastNodeId The value of lastNodeId state variable.return configValues An array of configuration values corresponding to the keys. /
function getInfo( string[] memory configKeys
function getInfo( string[] memory configKeys
28,961
44
// Transfer amount of tokens from own wallet to someone else
function transfer(address _to, uint256 _value) returns (bool success) { assert(msg.sender != address(0)); assert(_to != address(0)); require(!frozenAccount[msg.sender]); require(!frozenAccount[_to]); require(tokenBalanceOf[msg.sender] >= _value); require(tokenBalanceOf[msg.sender] - _value < tokenBalanceOf[msg.sender]); require(tokenBalanceOf[_to] + _value > tokenBalanceOf[_to]); require(_value > 0); _transfer(msg.sender, _to, _value); return true; }
function transfer(address _to, uint256 _value) returns (bool success) { assert(msg.sender != address(0)); assert(_to != address(0)); require(!frozenAccount[msg.sender]); require(!frozenAccount[_to]); require(tokenBalanceOf[msg.sender] >= _value); require(tokenBalanceOf[msg.sender] - _value < tokenBalanceOf[msg.sender]); require(tokenBalanceOf[_to] + _value > tokenBalanceOf[_to]); require(_value > 0); _transfer(msg.sender, _to, _value); return true; }
27,538
15
// validations
require(oPremium != 0, "Option not found in options provider!");
require(oPremium != 0, "Option not found in options provider!");
2,811
802
// https:etherscan.io/address/0x57Ab1E02fEE23774580C119740129eAC7081e9D3
Proxy public constant proxysusd_i = Proxy(0x57Ab1E02fEE23774580C119740129eAC7081e9D3);
Proxy public constant proxysusd_i = Proxy(0x57Ab1E02fEE23774580C119740129eAC7081e9D3);
29,627
25
// External Constant functions // /
function getGeneralSetting(bytes32 settingName) external view returns (uint256) { return generalSettings[settingName]; }
function getGeneralSetting(bytes32 settingName) external view returns (uint256) { return generalSettings[settingName]; }
39,573
0
// The signing name that is used in the domain separator.
string public constant SIGNING_NAME = "CYOP_DATA_VALIDATOR";
string public constant SIGNING_NAME = "CYOP_DATA_VALIDATOR";
23,660
4
// The total stake held by this contract for a node, which will be the sum of all addStake and unlockStake calls
uint256 totalManagedStake;
uint256 totalManagedStake;
16,494
19
// swap tokens UNI-V2
function swapTokensV2(address routerAddress, address[] calldata path, address[] calldata reversePath, uint amountIn, uint amountOutMin, uint tipAmount)
function swapTokensV2(address routerAddress, address[] calldata path, address[] calldata reversePath, uint amountIn, uint amountOutMin, uint tipAmount)
15,069
233
// Ownership transfer: TIME_LOCK
transferOwnership(TIME_LOCK);
transferOwnership(TIME_LOCK);
14,220
6
// Creates a new snapshot and emits a Snapshot event with the snapshotid. /
function snapshot() external onlyRole(SNAPSHOTTER_ROLE) { super._snapshot(); }
function snapshot() external onlyRole(SNAPSHOTTER_ROLE) { super._snapshot(); }
23,716
13
// Emitted when `indexer` claimed a rebate on `subgraphDeploymentID` during `epoch`related to the `forEpoch` rebate pool.The rebate is for `tokens` amount and `unclaimedAllocationsCount` are left for claimin the rebate pool. `delegationFees` collected and sent to delegation pool. /
event RebateClaimed(
event RebateClaimed(
12,460
2
// ! ],! "expected": [! "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"! ]
//! }, { //! "name": "descending", //! "input": [ //! { //! "entry": "main", //! "calldata": [ //! "7", "2", "1", "8", "10", "3", "5", "4", "9", "6", "2" //! ] //! }
//! }, { //! "name": "descending", //! "input": [ //! { //! "entry": "main", //! "calldata": [ //! "7", "2", "1", "8", "10", "3", "5", "4", "9", "6", "2" //! ] //! }
12,819
61
// Initially set the upgrade master same as owner
upgradeMaster = owner; name = _name; decimals = _decimals; symbol = _symbol; version = _version; totalSupply = _initialSupply; balances[msg.sender] = totalSupply;
upgradeMaster = owner; name = _name; decimals = _decimals; symbol = _symbol; version = _version; totalSupply = _initialSupply; balances[msg.sender] = totalSupply;
32,355
370
// Create position/Repeated creation of the same position will cause an error, you need to change tickLower Or tickUpper/token0 Liquidity pool token 0 contract address/token1 Liquidity pool token 1 contract address/fee Target liquidity pool rate/tickLower Expect to place the lower price boundary of the target liquidity pool/tickUpper Expect to place the upper price boundary of the target liquidity pool/amount0Desired Desired token 0 amount/amount1Desired Desired token 1 amount
function mint( address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 amount0Desired, uint256 amount1Desired ) public onlyAuthorize
function mint( address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 amount0Desired, uint256 amount1Desired ) public onlyAuthorize
10,658
24
// Assigns a new address to act as the Admin. Only available to the current Admin. /_newAdmin The address of the new Admin
function setAdmin(address _newAdmin) external { require(msg.sender == adminAddress || msg.sender == bankAddress); require(_newAdmin != address(0)); adminAddress = _newAdmin; }
function setAdmin(address _newAdmin) external { require(msg.sender == adminAddress || msg.sender == bankAddress); require(_newAdmin != address(0)); adminAddress = _newAdmin; }
24,001
60
// Checks if elements in array are ordered and unique /
function isOrderedSet(uint256[] memory numbers) internal pure returns (bool)
function isOrderedSet(uint256[] memory numbers) internal pure returns (bool)
25,065
33
// owners are same, so decrement their balance as we are merging
_balances[owner] -= 1; tokenIdDead = _merge(tokenIdRcvr, tokenIdSndr);
_balances[owner] -= 1; tokenIdDead = _merge(tokenIdRcvr, tokenIdSndr);
7,336
50
// Maximum wei contribution for non-whitelisted addresses
uint256 public threshold;
uint256 public threshold;
73,946
71
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; balancer = address(new Balancer()); isExcludedFromFee[_msgSender()] = true; isExcludedFromFee[address(this)] = true;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; balancer = address(new Balancer()); isExcludedFromFee[_msgSender()] = true; isExcludedFromFee[address(this)] = true;
7,398
93
// The BACE token exchange rate for PreIco stage. /
uint256 public exchangeRatePreIco;
uint256 public exchangeRatePreIco;
2,807
75
// Only retrieve rewards for votes resolved in same round
require(priceRequest.lastVotingRound == roundId, "Retrieve for votes same round"); _resolvePriceRequest(priceRequest, voteInstance); if (voteInstance.voteSubmissions[voterAddress].revealHash == 0) { continue; } else if (isExpired) {
require(priceRequest.lastVotingRound == roundId, "Retrieve for votes same round"); _resolvePriceRequest(priceRequest, voteInstance); if (voteInstance.voteSubmissions[voterAddress].revealHash == 0) { continue; } else if (isExpired) {
18,911
50
// update storage with the modified slot
ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;
ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;
47,502
135
// See {IERC721-getApproved}. /
function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId];
function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId];
7,835
13
// increase questionCount after event is emitted
questionCount += 1; return true;
questionCount += 1; return true;
30,018
2
// Mapping of string hash to its index in the _values array
mapping(bytes32 => uint256) _indexes;
mapping(bytes32 => uint256) _indexes;
29,452
705
// ERC20 decimals function. Returns the same number of decimals as the position's owedToken returnThe number of decimal places, or revert if the baseToken has no such function. /
function decimals() external view returns (uint8);
function decimals() external view returns (uint8);
67,430
82
// Leave the bar. Claim back your SUSHIs.
function leave(uint256 _share) public { uint256 totalShares = totalSupply(); uint256 what = _share.mul(sushi.balanceOf(address(this))).div(totalShares); _burn(msg.sender, _share); sushi.transfer(msg.sender, what); }
function leave(uint256 _share) public { uint256 totalShares = totalSupply(); uint256 what = _share.mul(sushi.balanceOf(address(this))).div(totalShares); _burn(msg.sender, _share); sushi.transfer(msg.sender, what); }
1,177
1
// Creates a new pool if it does not exist, then initializes if not initialized/This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool/token0 The contract address of token0 of the pool/token1 The contract address of token1 of the pool/fee The fee amount of the v3 pool for the specified token pair/sqrtPriceX96 The initial square root price of the pool as a Q64.96 value/ return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary
function createAndInitializePoolIfNecessary( address token0, address token1, uint24 fee, uint160 sqrtPriceX96 ) external payable returns (address pool);
function createAndInitializePoolIfNecessary( address token0, address token1, uint24 fee, uint160 sqrtPriceX96 ) external payable returns (address pool);
4,400
121
// Compare amounts and add/remove shares
if (newRewardAmount > exitingRewardAmount) {
if (newRewardAmount > exitingRewardAmount) {
66,382
182
// Register new liquidity added to the future _amount the liquidity amount added must be called from the future contract /
function registerNewFutureLiquidity(uint256 _amount) external;
function registerNewFutureLiquidity(uint256 _amount) external;
41,320
27
// A joinswap decreases the price of the token entering the Pool and increases the price of all other tokens. ManagedPool's circuit breakers prevent the tokens' prices from leaving certain bounds so we mustcheck that we haven't tripped a breaker as a result of the joinswap.
_checkCircuitBreakersOnJoinOrExitSwap(request, actualSupply, amountCalculated, true);
_checkCircuitBreakersOnJoinOrExitSwap(request, actualSupply, amountCalculated, true);
8,909
42
// This function returns proposal count/ return uint256 Number of proposals
function proposalCount() public view returns (uint256) { return proposalsCounter; }
function proposalCount() public view returns (uint256) { return proposalsCounter; }
221
11
// Contract module which provides an authorisation control mechanism, wherethere is an 'owner' that can grant access to a specific 'reader'.The 'reader' can request access to an 'owner'. /
contract Authorisation is Ownable { using SafeMath for uint256; using SafeMath32 for uint32; using SafeMath16 for uint16; event AuthorisationGranted( uint256 authorisationId, address _owner, address _reader ); event AuthorisationRequested( address indexed _reader, address indexed _owner ); event AuthorisationRemoved(address indexed _owner, address indexed _reader); struct AuthorisationStruct { address owner; mapping(address => bool) allowed; } struct RequestAuthorisationStruct { address reader; mapping(address => bool) requested; } mapping(address => AuthorisationStruct) authorisationStructs; mapping(address => RequestAuthorisationStruct) requestAuthorisationStructs; /** * @dev Gives authorisation to the '_reader'. */ function giveAuthorisation(address _reader) public { _authorise(_msgSender(), _reader); } /** * @dev Removes authorisation to the '_reader'. */ function removeAuthorisation(address _reader) public { authorisationStructs[_msgSender()].allowed[_reader] = false; } /** * @dev Check authorisation of the '_reader' for the '_owner'. */ function isAuthorised(address _owner, address _reader) public view returns (bool) { return _isAuthorised(_owner, _reader); } /** * @dev Request auhtorisation of the sender to the '_owner'. */ function requestAuthorisation(address _owner) public { requestAuthorisationStructs[_msgSender()].reader = _msgSender(); requestAuthorisationStructs[_msgSender()].requested[_owner] = true; } /** * @dev Approves authorisation by the sender to the '_reader'. */ function approveAuthorisation(address _reader) public { requestAuthorisationStructs[_reader].requested[_msgSender()] = false; _authorise(_msgSender(), _reader); } /** * @dev Gives authorisation to the '_reader'. Only the '_owner' can execute it. */ function _authorise(address _owner, address _reader) private { if (!_isAuthorised(_owner, _reader)) { authorisationStructs[_owner].owner = _owner; authorisationStructs[_owner].allowed[_reader] = true; } } /** * @dev Gives authorisation to the '_reader'. Only the '_owner' can execute it. */ function _isAuthorised(address _owner, address _reader) private view returns (bool) { return authorisationStructs[_owner].allowed[_reader]; } }
contract Authorisation is Ownable { using SafeMath for uint256; using SafeMath32 for uint32; using SafeMath16 for uint16; event AuthorisationGranted( uint256 authorisationId, address _owner, address _reader ); event AuthorisationRequested( address indexed _reader, address indexed _owner ); event AuthorisationRemoved(address indexed _owner, address indexed _reader); struct AuthorisationStruct { address owner; mapping(address => bool) allowed; } struct RequestAuthorisationStruct { address reader; mapping(address => bool) requested; } mapping(address => AuthorisationStruct) authorisationStructs; mapping(address => RequestAuthorisationStruct) requestAuthorisationStructs; /** * @dev Gives authorisation to the '_reader'. */ function giveAuthorisation(address _reader) public { _authorise(_msgSender(), _reader); } /** * @dev Removes authorisation to the '_reader'. */ function removeAuthorisation(address _reader) public { authorisationStructs[_msgSender()].allowed[_reader] = false; } /** * @dev Check authorisation of the '_reader' for the '_owner'. */ function isAuthorised(address _owner, address _reader) public view returns (bool) { return _isAuthorised(_owner, _reader); } /** * @dev Request auhtorisation of the sender to the '_owner'. */ function requestAuthorisation(address _owner) public { requestAuthorisationStructs[_msgSender()].reader = _msgSender(); requestAuthorisationStructs[_msgSender()].requested[_owner] = true; } /** * @dev Approves authorisation by the sender to the '_reader'. */ function approveAuthorisation(address _reader) public { requestAuthorisationStructs[_reader].requested[_msgSender()] = false; _authorise(_msgSender(), _reader); } /** * @dev Gives authorisation to the '_reader'. Only the '_owner' can execute it. */ function _authorise(address _owner, address _reader) private { if (!_isAuthorised(_owner, _reader)) { authorisationStructs[_owner].owner = _owner; authorisationStructs[_owner].allowed[_reader] = true; } } /** * @dev Gives authorisation to the '_reader'. Only the '_owner' can execute it. */ function _isAuthorised(address _owner, address _reader) private view returns (bool) { return authorisationStructs[_owner].allowed[_reader]; } }
5,320
27
// 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
IUniswapV2Router02 _router; address public uniswapV2Pair;
IUniswapV2Router02 _router; address public uniswapV2Pair;
8,963
22
// Increase the amount of tokens that an owner allowed to a spender. approve should be called when allowed[_spender] == 0. To incrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.sol _spender The address which will spend the funds. _addedValue The amount of tokens to increase the allowance by. /
function increaseApproval( address _spender, uint _addedValue ) public returns (bool)
function increaseApproval( address _spender, uint _addedValue ) public returns (bool)
1,784