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
101
// uint256 zzzMultiplier = multiplier.getTotalMultiplier(account);
uint256 napsMultiplier = 0; if(NAPSlevel[account] == 1) { napsMultiplier = TenPercentBonus; }else if(NAPSlevel[account] == 2) {
uint256 napsMultiplier = 0; if(NAPSlevel[account] == 1) { napsMultiplier = TenPercentBonus; }else if(NAPSlevel[account] == 2) {
10,624
229
// SIP-65: Decentralized Circuit Breaker mutative call to suspend system if the rate is invalid
if ( _suspendIfRateInvalid(sourceCurrencyKey, entry.sourceRate) || _suspendIfRateInvalid(destinationCurrencyKey, entry.destinationRate) ) { return (0, 0, IVirtualSynth(0)); }
if ( _suspendIfRateInvalid(sourceCurrencyKey, entry.sourceRate) || _suspendIfRateInvalid(destinationCurrencyKey, entry.destinationRate) ) { return (0, 0, IVirtualSynth(0)); }
24,432
218
// generate the Enodi pair path of token -> weth
address[] memory path = new address[](2); path[0] = address(this); path[1] = _router.WETH(); _approve(address(this), address(_router), tokenAmount);
address[] memory path = new address[](2); path[0] = address(this); path[1] = _router.WETH(); _approve(address(this), address(_router), tokenAmount);
38,773
333
// Creates a new token for `to`. Its token ID will be automatically
* assigned (and available on the emitted {IERC721-Transfer} event), and the token * URI autogenerated based on the base URI passed at construction. * * See {ERC721-_mint}. * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mint(address to) public virtual { require(hasRole(MINTER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have minter role to mint"); // We cannot just use balanceOf to create the new tokenId because tokens // can be burned (destroyed), so we need a separate counter. _mint(to, _tokenIdTracker.current()); _tokenIdTracker.increment(); }
* assigned (and available on the emitted {IERC721-Transfer} event), and the token * URI autogenerated based on the base URI passed at construction. * * See {ERC721-_mint}. * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mint(address to) public virtual { require(hasRole(MINTER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have minter role to mint"); // We cannot just use balanceOf to create the new tokenId because tokens // can be burned (destroyed), so we need a separate counter. _mint(to, _tokenIdTracker.current()); _tokenIdTracker.increment(); }
10,817
24
// Burns BONE to the default BONE pool amount the amount of BONE to be burnt/
function burnBone(uint256 amount) external { burnToken(boneAddress, amount); }
function burnBone(uint256 amount) external { burnToken(boneAddress, amount); }
19,479
65
// Transfers tokens from one address to another. If 'from' has releasable tokens, this part of the token will be released automatically. If the target address of transferring isBDR contract, the operation of changing BDR tokens will be executed. from The address which you want to send tokens from to The address which you want to transfer to value The amount of tokens to be transferred /
function transferFrom(address from, address to, uint value) public returns (bool) { if(releasableAmount(from) > 0) { release(from); // Calls the 'release' function } super.transferFrom(from, to, value); // Transfers token to address 'to' if(to == address(BDRInstance)) { BDRInstance.tokenFallback(from, value, bytes("")); // Calls 'tokenFallback' function in BDR contract to exchange tokens emit ExchangeBDR(from, value); } return true; }
function transferFrom(address from, address to, uint value) public returns (bool) { if(releasableAmount(from) > 0) { release(from); // Calls the 'release' function } super.transferFrom(from, to, value); // Transfers token to address 'to' if(to == address(BDRInstance)) { BDRInstance.tokenFallback(from, value, bytes("")); // Calls 'tokenFallback' function in BDR contract to exchange tokens emit ExchangeBDR(from, value); } return true; }
5,313
409
// The time when this funding cycle will become active.
uint256 start;
uint256 start;
21,027
11
// For the case where `proof.length + leafs.length == 1`.
if iszero(flags.length) {
if iszero(flags.length) {
40,864
9
// Returns the total funds raised by project `projectId` /
function totalRaised(uint256 projectId) external view returns (uint256) { Project storage project = projects[projectId]; return project.totalRaised; }
function totalRaised(uint256 projectId) external view returns (uint256) { Project storage project = projects[projectId]; return project.totalRaised; }
667
0
// 1、众筹项目名 2、众筹资金 3、众筹每笔资金 4、众筹项目截至时间 5、投资人数组 6、投资人字典 7、花费申请数组
address public manager; string public projectName; uint256 public totalCapital; uint256 public singleCapital; uint256 public endTimestamp; address[] public voters; mapping(address => bool) public investors; VoteCrowdPros votingCrowdpros;
address public manager; string public projectName; uint256 public totalCapital; uint256 public singleCapital; uint256 public endTimestamp; address[] public voters; mapping(address => bool) public investors; VoteCrowdPros votingCrowdpros;
21,317
34
// pragma solidity 0.6.11; // import "lib/dss-interfaces/src/dapp/DSPauseAbstract.sol"; // import "lib/dss-interfaces/src/dapp/DSTokenAbstract.sol"; // import "lib/dss-interfaces/src/dss/ChainlogAbstract.sol"; // import "lib/dss-interfaces/src/dss/VatAbstract.sol"; // import "lib/dss-interfaces/src/dss/SpotAbstract.sol"; // import "lib/dss-interfaces/src/dss/FlipAbstract.sol"; // import "lib/dss-interfaces/src/dss/FlipperMomAbstract.sol"; // import "lib/dss-interfaces/src/dss/JugAbstract.sol"; // import "lib/dss-interfaces/src/dss/CatAbstract.sol"; // import "lib/dss-interfaces/src/dss/IlkRegistryAbstract.sol"; // import "lib/dss-interfaces/src/dss/FaucetAbstract.sol"; // import "lib/dss-interfaces/src/dss/GemJoinAbstract.sol"; // import "lib/dss-interfaces/src/dss/OsmAbstract.sol"; // import "lib/dss-interfaces/src/dss/OsmMomAbstract.sol"; // import "lib/dss-interfaces/src/dss/MedianAbstract.sol"; // import "lib/dss-interfaces/src/dss/DssAutoLineAbstract.sol"; /
interface PsmAbstract { function wards(address) external returns (uint256); function vat() external returns (address); function gemJoin() external returns (address); function dai() external returns (address); function daiJoin() external returns (address); function ilk() external returns (bytes32); function vow() external returns (address); function tin() external returns (uint256); function tout() external returns (uint256); function file(bytes32 what, uint256 data) external; function sellGem(address usr, uint256 gemAmt) external; function buyGem(address usr, uint256 gemAmt) external; }
interface PsmAbstract { function wards(address) external returns (uint256); function vat() external returns (address); function gemJoin() external returns (address); function dai() external returns (address); function daiJoin() external returns (address); function ilk() external returns (bytes32); function vow() external returns (address); function tin() external returns (uint256); function tout() external returns (uint256); function file(bytes32 what, uint256 data) external; function sellGem(address usr, uint256 gemAmt) external; function buyGem(address usr, uint256 gemAmt) external; }
1,569
61
// Checks that a call pushing a storage value to the buffer is expected and valid
function validStoreVal() private pure { // Ensure that the next function expected pushes a storage value - if ( expected() != NextFunction.VAL_SET && expected() != NextFunction.VAL_INC && expected() != NextFunction.VAL_DEC ) revert('Unexpected function order - expected storage value to be pushed'); // Ensure that the current buffer is pushing STORES actions - isStoring(); }
function validStoreVal() private pure { // Ensure that the next function expected pushes a storage value - if ( expected() != NextFunction.VAL_SET && expected() != NextFunction.VAL_INC && expected() != NextFunction.VAL_DEC ) revert('Unexpected function order - expected storage value to be pushed'); // Ensure that the current buffer is pushing STORES actions - isStoring(); }
60,694
0
// Faciliating the needed functionality for the presale
mapping(address => bool) addressToPreSaleEntry;
mapping(address => bool) addressToPreSaleEntry;
26,709
0
// 登録事業者の一覧
mapping(address => bool) private registered;
mapping(address => bool) private registered;
17,599
163
// initial amount of mine
uint256 public initReward = 1120 * 1e18; bool public haveStarted = false;
uint256 public initReward = 1120 * 1e18; bool public haveStarted = false;
8,369
161
// Namable
mapping(uint256 => string) public zenApeName; mapping(uint256 => string) public zenApeBio;
mapping(uint256 => string) public zenApeName; mapping(uint256 => string) public zenApeBio;
53,507
299
// Stakes more LRC for an exchange./ exchangeAddr The address of the exchange/ amountLRC The amount of LRC to stake/ return stakedLRC The total amount of LRC staked for the exchange
function depositExchangeStake( address exchangeAddr, uint amountLRC ) external virtual returns (uint stakedLRC);
function depositExchangeStake( address exchangeAddr, uint amountLRC ) external virtual returns (uint stakedLRC);
29,130
42
// Update stored rewardPerToken values without the last one snapshot/If the contract will get "out of gas" error on users actions this will be helpful
function batchUpdateRewardPerToken(address token, uint maxRuns) external { ( rewardPerTokenStored[token], lastUpdateTime[token] ) = _updateRewardPerToken(token, maxRuns, false); }
function batchUpdateRewardPerToken(address token, uint maxRuns) external { ( rewardPerTokenStored[token], lastUpdateTime[token] ) = _updateRewardPerToken(token, maxRuns, false); }
28,429
341
// function returns the hash of the fully encoded EIP712 message for this domain.
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return keccak256(abi.encodePacked('\x19\x01', _domainSeparatorV4(), structHash)); }
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return keccak256(abi.encodePacked('\x19\x01', _domainSeparatorV4(), structHash)); }
15,534
0
// 0xa9059cbb - keccack("transfer(address,uint256)")
bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);
bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);
22,480
65
// Burn the fuel of a `boostedBurn` /
function _burnBoostedBurnFuel( address from, BoosterFuel memory fuel, UnpackedData memory unpacked
function _burnBoostedBurnFuel( address from, BoosterFuel memory fuel, UnpackedData memory unpacked
5,145
40
// 当调用setHarvestPath时触发
event SetHarvestPath(address indexed token, bytes path);
event SetHarvestPath(address indexed token, bytes path);
26,944
22
// Double check if user owns the nft
require(stakerAddress[_tokenId] == msg.sender, "You are not the owner");
require(stakerAddress[_tokenId] == msg.sender, "You are not the owner");
17,915
37
// returns the current phase's ID. /
function phaseId() external view returns (uint16)
function phaseId() external view returns (uint16)
66,090
78
// Checks a trade input validity, including correct src amounts/input Trade input structure
function validateTradeInput(TradeInput memory input) internal view
function validateTradeInput(TradeInput memory input) internal view
47,506
74
// calculate how many blocks they can claim a stake for
uint256 currentBlock = calculateCurrentBlock(_stakeNumber);
uint256 currentBlock = calculateCurrentBlock(_stakeNumber);
47,147
15
// Interface of the optional ERC1155MetadataExtension interface, as defined _Available since v3.1._ /
interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
2,364
21
// Convert an unsigned integer to a unsigned fixed-point decimal.Throw an exception if the result would be out of range. /
function intToDec(uint i) internal pure returns (uint) { return safeMul(i, UNIT); }
function intToDec(uint i) internal pure returns (uint) { return safeMul(i, UNIT); }
52,576
257
// Here we calc the pool share one can withdraw given the amount of IdleToken they want to burnWARNING: if elements in the `_skipGovTokenRedeem` are set to `true` then the rewards will be GIFTED to the pool_amount : amount of IdleTokens to be burned _skipGovTokenRedeem : array of flags whether to redeem or not specific gov tokensreturn redeemedTokens : amount of underlying tokens redeemed /
function redeemIdleTokenSkipGov(uint256 _amount, bool[] calldata _skipGovTokenRedeem) external
function redeemIdleTokenSkipGov(uint256 _amount, bool[] calldata _skipGovTokenRedeem) external
35,228
16
// assign ticket to user.
ticketRecord_[_user].hasTicket = true; ticketRecord_[_user].expirationTime = now + 30 minutes; ticketRecord_[_user].ticketPrice = _ticketPrice; emit BuyTicket(_user, _ticketPrice);
ticketRecord_[_user].hasTicket = true; ticketRecord_[_user].expirationTime = now + 30 minutes; ticketRecord_[_user].ticketPrice = _ticketPrice; emit BuyTicket(_user, _ticketPrice);
11,966
12
// 100 needed for masternode activation
uint256 public stakingRequirement = 100e18;
uint256 public stakingRequirement = 100e18;
45,279
256
// randomly pick a new token id (that has not been minted)
uint256 newTokenId = nextToken(); require( !_exists(newTokenId), "Warcat: One of the tokens already got minted by someone else..." ); _safeMint(msg.sender, newTokenId); if (!_mintOnly){ _burn(newTokenId); }
uint256 newTokenId = nextToken(); require( !_exists(newTokenId), "Warcat: One of the tokens already got minted by someone else..." ); _safeMint(msg.sender, newTokenId); if (!_mintOnly){ _burn(newTokenId); }
62,278
114
// individual uri per type
mapping (uint256 => string) public typeToUri;
mapping (uint256 => string) public typeToUri;
29,634
2
// allowanceId => Allowance
mapping(bytes32 => Allowance) private allowances; uint256 private allowanceCount;
mapping(bytes32 => Allowance) private allowances; uint256 private allowanceCount;
11,144
156
// computes a reduced-scalar ratio_n ratio numerator_d ratio denominator_max maximum desired scalar return ratio's numerator and denominator/
function reducedRatio(uint256 _n, uint256 _d, uint256 _max) internal pure returns (uint256, uint256) { if (_n > _max || _d > _max) return normalizedRatio(_n, _d, _max); return (_n, _d); }
function reducedRatio(uint256 _n, uint256 _d, uint256 _max) internal pure returns (uint256, uint256) { if (_n > _max || _d > _max) return normalizedRatio(_n, _d, _max); return (_n, _d); }
45,548
44
// Destroys `amount` tokens from `account`, reducing the total supply.
* Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function burn(uint256 amount) public { address sender = _msgSender(); _beforeTokenTransfer(sender, address(0), amount); uint256 senderBalance = balanceOf(sender); require(senderBalance >= amount, "BEP20: burn amount exceeds balance"); uint256 senderReward = senderBalance - _stakingBalance[sender]; _stakingBalance[sender] = senderBalance - amount; _rewardsRecieved[sender] += senderReward; _totalSupply += senderReward; _totalSupply -= amount; if (stakingActivated == true) { uint256 stakingPool = currentStakingPool(); _stakingPool[sender] = stakingPool; _blocks.push(block.number); _stakingFromBlock[sender] = _blocks.length - 1; } emit Transfer(sender, address(0), amount); }
* Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function burn(uint256 amount) public { address sender = _msgSender(); _beforeTokenTransfer(sender, address(0), amount); uint256 senderBalance = balanceOf(sender); require(senderBalance >= amount, "BEP20: burn amount exceeds balance"); uint256 senderReward = senderBalance - _stakingBalance[sender]; _stakingBalance[sender] = senderBalance - amount; _rewardsRecieved[sender] += senderReward; _totalSupply += senderReward; _totalSupply -= amount; if (stakingActivated == true) { uint256 stakingPool = currentStakingPool(); _stakingPool[sender] = stakingPool; _blocks.push(block.number); _stakingFromBlock[sender] = _blocks.length - 1; } emit Transfer(sender, address(0), amount); }
38,356
48
// Approves a proposal in the approval stage. proposalId The ID of the proposal to approve. index The index of the proposal ID in `dequeued`.return Whether or not the approval was made successfully. /
function approve(uint256 proposalId, uint256 index) external onlyApprover returns (bool) { dequeueProposalsIfReady(); (Proposals.Proposal storage proposal, Proposals.Stage stage) = requireDequeuedAndDeleteExpired( proposalId, index ); if (!proposal.exists()) { return false; } require(!proposal.isApproved(), "Proposal already approved"); require(stage == Proposals.Stage.Approval, "Proposal not in approval stage"); proposal.approved = true; // Ensures networkWeight is set by the end of the Referendum stage, even if 0 votes are cast. proposal.networkWeight = getLockedGold().getTotalLockedGold(); emit ProposalApproved(proposalId); return true; }
function approve(uint256 proposalId, uint256 index) external onlyApprover returns (bool) { dequeueProposalsIfReady(); (Proposals.Proposal storage proposal, Proposals.Stage stage) = requireDequeuedAndDeleteExpired( proposalId, index ); if (!proposal.exists()) { return false; } require(!proposal.isApproved(), "Proposal already approved"); require(stage == Proposals.Stage.Approval, "Proposal not in approval stage"); proposal.approved = true; // Ensures networkWeight is set by the end of the Referendum stage, even if 0 votes are cast. proposal.networkWeight = getLockedGold().getTotalLockedGold(); emit ProposalApproved(proposalId); return true; }
10,645
20
// readable
function APYtoPercentage(uint256 apy, uint256 duration) public pure returns(uint256){ return apy.mul(duration).div(365); }
function APYtoPercentage(uint256 apy, uint256 duration) public pure returns(uint256){ return apy.mul(duration).div(365); }
9,546
109
// Max of 1000 (10%), as 10000/10 is 1000
_reflectAmt = ratio.div(10);
_reflectAmt = ratio.div(10);
18,376
18
// 撤销某笔pending交易的签名/This function can only be called by owner/txId 交易号
function revoke(uint txId) external;
function revoke(uint txId) external;
78,606
23
// Dynamically invoke the targeting contract, and trigger executation of cross chain tx on Ethereum side _toContract The targeting contract that will be invoked by the Ethereum Cross Chain Manager contract _method At which method will be invoked within the targeting contract _args The parameter that will be passed into the targeting contract _fromContractAddr From chain smart contract address _fromChainIdIndicate from which chain current cross chain tx comes returntrue or false/
function _executeCrossChainTx(address _toContract, bytes memory _method, bytes memory _args, bytes memory _fromContractAddr, uint64 _fromChainId) internal returns (bool){
function _executeCrossChainTx(address _toContract, bytes memory _method, bytes memory _args, bytes memory _fromContractAddr, uint64 _fromChainId) internal returns (bool){
16,257
100
// Internal Functions
function _transferOwnership( address __owner )
function _transferOwnership( address __owner )
830
65
// {IERC20-approve}, and its usage is discouraged. Whenever possible, use {safeIncreaseAllowance} and{safeDecreaseAllowance} instead. /
function safeApprove( IERC20 token, address spender, uint256 value ) internal {
function safeApprove( IERC20 token, address spender, uint256 value ) internal {
11,509
2
// This function is an initialize at deployment, and will be initialize info like :- NFT detail- Meta-tx trust forwardername_ is nft did name symbol_ id nft did symbol /
function initialize( string memory name_, string memory symbol_
function initialize( string memory name_, string memory symbol_
22,725
113
// Get the current STFactory Address /
function getSTFactoryAddress() external view returns(address stFactoryAddress);
function getSTFactoryAddress() external view returns(address stFactoryAddress);
46,778
31
// Checks if the "other token" is the correct pair token for the KromaMintableERC20._mintableToken KromaMintableERC20 to check against. _otherTokenPair token to check. return True if the other token is the correct pair token for the KromaMintableERC20. /
function _isCorrectTokenPair(address _mintableToken, address _otherToken) internal view returns (bool)
function _isCorrectTokenPair(address _mintableToken, address _otherToken) internal view returns (bool)
43,872
20
// Update total fees, this is just a counter provided for visibility
_totalFeesPooled += feeAmount; emit Transfer(sender, recipient, transferAmount); onTransfer(sender, recipient, amount);
_totalFeesPooled += feeAmount; emit Transfer(sender, recipient, transferAmount); onTransfer(sender, recipient, amount);
24,443
164
// Function to stop minting new tokens. WARNING: it allows everyone to finish minting. Access controls MUST be defined in derived contracts. /
function finishMinting() public canMint { _finishMinting(); }
function finishMinting() public canMint { _finishMinting(); }
1,634
6
// get log2 size of epoch output drive
function getEpochOutputLog2Size() external pure returns (uint256);
function getEpochOutputLog2Size() external pure returns (uint256);
40,006
112
// Implemented by jobs to show that a keeper performend work keeper address of the keeper that performed the work amount the reward that should be allocated /
function workReceipt(address keeper, uint amount) external { require(jobs[msg.sender], "Keep3r::workReceipt: only jobs can approve work"); gasUsed = gasUsed.sub(gasleft()); require(amount < KPRH.getQuoteLimit(gasUsed), "Keep3r::workReceipt: spending over max limit"); lastJob[keeper] = now; credits[msg.sender] = credits[msg.sender].sub(amount, "Keep3r::workReceipt: insuffient funds to pay keeper"); bonds[keeper] = bonds[keeper].add(amount); _moveDelegates(address(0), delegates[keeper], amount); workCompleted[keeper] = workCompleted[keeper].add(amount); emit KeeperWorked(msg.sender, keeper, block.number); }
function workReceipt(address keeper, uint amount) external { require(jobs[msg.sender], "Keep3r::workReceipt: only jobs can approve work"); gasUsed = gasUsed.sub(gasleft()); require(amount < KPRH.getQuoteLimit(gasUsed), "Keep3r::workReceipt: spending over max limit"); lastJob[keeper] = now; credits[msg.sender] = credits[msg.sender].sub(amount, "Keep3r::workReceipt: insuffient funds to pay keeper"); bonds[keeper] = bonds[keeper].add(amount); _moveDelegates(address(0), delegates[keeper], amount); workCompleted[keeper] = workCompleted[keeper].add(amount); emit KeeperWorked(msg.sender, keeper, block.number); }
49,747
142
// Returns whether the SetToken has an external position for a given component (ifof position modules is > 0) /
function hasExternalPosition(ISetToken _setToken, address _component) internal view returns(bool) { return _setToken.getExternalPositionModules(_component).length > 0; }
function hasExternalPosition(ISetToken _setToken, address _component) internal view returns(bool) { return _setToken.getExternalPositionModules(_component).length > 0; }
32,839
1
// Constant for locked guard state
uint private constant REENTRANCY_GUARD_LOCKED = 2;
uint private constant REENTRANCY_GUARD_LOCKED = 2;
33,802
120
// get the amount accumulated for liquidty provision
uint256 contractTokenBalance =_liquidtyTokens; bool overMinTokenBalance = contractTokenBalance >= liquidityThreshold; if (overMinTokenBalance && !inLiquidityProvision && from != pancakeSwapV2Pair && LiquidityProvisionEnabled ) //LIVE ENABLE { contractTokenBalance = liquidityThreshold;
uint256 contractTokenBalance =_liquidtyTokens; bool overMinTokenBalance = contractTokenBalance >= liquidityThreshold; if (overMinTokenBalance && !inLiquidityProvision && from != pancakeSwapV2Pair && LiquidityProvisionEnabled ) //LIVE ENABLE { contractTokenBalance = liquidityThreshold;
49,167
179
// Construct a WaterPalette instance name Name of the token symbol Symbol of the token openPaletteAddress Address of the OpenPalette instance pAddress Address of the P instance /
constructor( string memory name, string memory symbol, address openPaletteAddress, address pAddress, string memory baseUri
constructor( string memory name, string memory symbol, address openPaletteAddress, address pAddress, string memory baseUri
76,701
106
// Emits {Approval} event to reflect reduced allowance `value` for caller account to spend from account (`from`),/ unless allowance is set to `type(uint256).max`/ Emits {Transfer} event./ Returns boolean value indicating whether operation succeeded./ Requirements:/ - `from` account must have at least `value` balance of WETH10 token./ - `from` account must have approved caller to spend at least `value` of WETH10 token, unless `from` and caller are the same account.
function transferFrom(address from, address to, uint256 value) external override returns (bool) { if (from != msg.sender) {
function transferFrom(address from, address to, uint256 value) external override returns (bool) { if (from != msg.sender) {
6,684
65
// How many reward tokens a user has earned but not claimed at present/ account The target account/ return The amount of reward tokens a user earned
function earned(address account) external view returns (uint256);
function earned(address account) external view returns (uint256);
34,258
113
// The unstaking function. amount The amount to be unstaked. /
function unstake(uint256 amount) external nonReentrant { _unstakeInternal(msg.sender, amount); }
function unstake(uint256 amount) external nonReentrant { _unstakeInternal(msg.sender, amount); }
36,846
107
// SHOULD TRANSFERS BE ENABLED? -- NO
false){ controller = msg.sender; mayGenerateAddr = controller; }
false){ controller = msg.sender; mayGenerateAddr = controller; }
2,720
243
// `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. _Available since v4.7._ /
function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; }
function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; }
7,036
15
// /A function to get the array of all staking players. return An array containing all staking players' addresses./
function _getStakePlayers() internal view returns (address[] memory) { return StakePlayers; }
function _getStakePlayers() internal view returns (address[] memory) { return StakePlayers; }
2,399
1
// how much the fishmonger is selling fillets forland xland yland tile
mapping(uint16 => mapping(uint16 => mapping(uint8 => uint256))) public filletPrice; function onPurchase(uint16 _x,uint16 _y,uint8 _tile,address _owner,uint _amount) public returns (bool) { require(super.onPurchase(_x,_y,_tile,_owner,_amount));
mapping(uint16 => mapping(uint16 => mapping(uint8 => uint256))) public filletPrice; function onPurchase(uint16 _x,uint16 _y,uint8 _tile,address _owner,uint _amount) public returns (bool) { require(super.onPurchase(_x,_y,_tile,_owner,_amount));
22,830
3
// The Eternal treasury interface
IEternalTreasury private eternalTreasury;
IEternalTreasury private eternalTreasury;
18,434
22
// Load the rune into the MSBs of b
assembly { word:= mload(mload(add(self, 32))) }
assembly { word:= mload(mload(add(self, 32))) }
7,916
29
// Internal function that burn2s an amount of the token and assigns it toan account. This encapsulates the modification of balances such that theproper events are emitted. account The account that will receive the created tokens. value The amount that will be created. /
function _burn2(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); }
function _burn2(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); }
25,489
2
// Allows L1 Token contract to trustlessly register its gateway. _gateway l1 gateway address _maxGas max gas for L2 retryable exrecution _gasPriceBid gas price for L2 retryable ticket_maxSubmissionCost base submission costL2 retryable tick3et _creditBackAddress address for crediting back overpayment of _maxSubmissionCostreturn Retryable ticket ID /
function setGateway(
function setGateway(
22,359
218
// leverage uniswap returns want amount
liquidated = liquidated.add(amounts[path.length-1]);
liquidated = liquidated.add(amounts[path.length-1]);
20,246
26
// ----------------- personal counts ----------------- /
function getStakeInfo(address stakerAddress) public view returns(uint _total, uint _staking, uint _rewardable_1, uint _rewardable_2, uint _rewards_1, uint _rewards_2) { _total = totalStakingAmount; _staking = stakers[stakerAddress].stakingAmount; (_rewardable_1, _rewardable_2) = countReward(stakerAddress); _rewards_1 = stakers[stakerAddress].rewards_1; _rewards_2 = stakers[stakerAddress].rewards_2; }
function getStakeInfo(address stakerAddress) public view returns(uint _total, uint _staking, uint _rewardable_1, uint _rewardable_2, uint _rewards_1, uint _rewards_2) { _total = totalStakingAmount; _staking = stakers[stakerAddress].stakingAmount; (_rewardable_1, _rewardable_2) = countReward(stakerAddress); _rewards_1 = stakers[stakerAddress].rewards_1; _rewards_2 = stakers[stakerAddress].rewards_2; }
27,934
123
// if poolState is enabled, then go on. caution: be careful when adding new pool
address vaultForTrader = ICoFiXFactory(factory).getVaultForTrader(); if (vaultForTrader != address(0)) { // if equal, means vaultForTrader is not set yet address pair = ICoFiXStakingRewards(msg.sender).stakingToken(); require(pair != address(0), "CVaultForTrader: invalid pair"); uint256 pending = ICoFiXVaultForTrader(vaultForTrader).getPendingRewardOfLP(pair); if (pending > 0) { ICoFiXVaultForTrader(vaultForTrader).clearPendingRewardOfLP(pair); }
address vaultForTrader = ICoFiXFactory(factory).getVaultForTrader(); if (vaultForTrader != address(0)) { // if equal, means vaultForTrader is not set yet address pair = ICoFiXStakingRewards(msg.sender).stakingToken(); require(pair != address(0), "CVaultForTrader: invalid pair"); uint256 pending = ICoFiXVaultForTrader(vaultForTrader).getPendingRewardOfLP(pair); if (pending > 0) { ICoFiXVaultForTrader(vaultForTrader).clearPendingRewardOfLP(pair); }
47,665
42
// Check if we're ok to receive contributions, have we started?
assert(block.number > salesAgents[msg.sender].startBlock);
assert(block.number > salesAgents[msg.sender].startBlock);
51,175
46
// Calculate sqrt (x) rounding down.Revert if x < 0.x signed 64.64-bit fixed point numberreturn signed 64.64-bit fixed point number /
function sqrt (int128 x) internal pure returns (int128) { require (x >= 0); return int128 (sqrtu (uint256 (x) << 64, 0x10000000000000000)); }
function sqrt (int128 x) internal pure returns (int128) { require (x >= 0); return int128 (sqrtu (uint256 (x) << 64, 0x10000000000000000)); }
2,550
86
// Returns the total amount of tokens burned.return The latest value. /
function totalBurned() external view returns (uint256);
function totalBurned() external view returns (uint256);
42,650
719
// If the asset in is ETH, then `amountIn` ETH was wrapped into WETH.
_handleRemainingEth(_isETH(singleSwap.assetIn) ? amountIn : 0);
_handleRemainingEth(_isETH(singleSwap.assetIn) ? amountIn : 0);
32,461
89
// transfer goodwill
uint256 goodwillPortion = _transferGoodwill( _ToBalancerPoolAddress, balancerTokens ); emit Zapin( _toWhomToIssue, _ToBalancerPoolAddress, SafeMath.sub(balancerTokens, goodwillPortion) );
uint256 goodwillPortion = _transferGoodwill( _ToBalancerPoolAddress, balancerTokens ); emit Zapin( _toWhomToIssue, _ToBalancerPoolAddress, SafeMath.sub(balancerTokens, goodwillPortion) );
20,366
62
// Calculate $y = x2^{-n}$.
uint256 y = xUint >> n;
uint256 y = xUint >> n;
27,688
2
// This library provides functions to convert short memory stringsinto a `ShortString` type that can be used as an immutable variable. Strings of arbitrary length can be optimized using this library ifthey are short enough (up to 31 bytes) by packing them with theirlength (1 byte) in a single EVM word (32 bytes). Additionally, afallback mechanism can be used for every other case. Usage example: ```solidity
* contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * }
* contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * }
1,910
118
// Emitting address of owner who shut down curve permanently
emit shutDownOccurred(msg.sender);
emit shutDownOccurred(msg.sender);
12,564
343
// Returns current Optimizer's position in pool
function position() external view returns (uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1) { bytes32 positionKey = PositionKey.compute(address(this), tickLower, tickUpper); (liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1) = pool.positions(positionKey); }
function position() external view returns (uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1) { bytes32 positionKey = PositionKey.compute(address(this), tickLower, tickUpper); (liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1) = pool.positions(positionKey); }
20,628
58
// take fees
uint256 _proportionToContract = proportionFeeAmount - proportionReflected; if (_proportionToContract > 0) { _rOwned[address(this)] = _rOwned[address(this)] + _proportionToContract; emit Transfer(sender, address(this), tokenFromReflection(_proportionToContract)); }
uint256 _proportionToContract = proportionFeeAmount - proportionReflected; if (_proportionToContract > 0) { _rOwned[address(this)] = _rOwned[address(this)] + _proportionToContract; emit Transfer(sender, address(this), tokenFromReflection(_proportionToContract)); }
15,269
24
// Adds an address to the LP allowlist. Will fail if the address is already allowlisted.Emits the AllowlistAddressAdded event. This is a permissioned function._poolAddress - Address of pool being worked on. _member - The address to be added to the allowlist. /
function addAllowedAddress( address _poolAddress,
function addAllowedAddress( address _poolAddress,
24,851
6
// Buyer's interface, delivers to a specified address
function buy(uint256 dropId_, address deliverTo_) external payable whenNotPaused nonReentrant { _buy(dropId_, deliverTo_); }
function buy(uint256 dropId_, address deliverTo_) external payable whenNotPaused nonReentrant { _buy(dropId_, deliverTo_); }
14,740
41
// See {IRadRouter-setRevenueSplits}. /
function setRevenueSplits(address _ledger, address payable[] calldata _stakeholders, uint256[] calldata _shares, bool _retail) public virtual override returns (bool success) { require(_stakeholders.length == _shares.length, 'Stakeholders and shares must have equal length'); require(_stakeholders.length <= 5, 'Cannot split revenue more than 5 ways.'); if (_retail) { Ledgers[_ledger].RetailSplits.clear(); } else {
function setRevenueSplits(address _ledger, address payable[] calldata _stakeholders, uint256[] calldata _shares, bool _retail) public virtual override returns (bool success) { require(_stakeholders.length == _shares.length, 'Stakeholders and shares must have equal length'); require(_stakeholders.length <= 5, 'Cannot split revenue more than 5 ways.'); if (_retail) { Ledgers[_ledger].RetailSplits.clear(); } else {
85,250
8
// Initialises our MidniteWolfPack contract. _preSaleStart Unix timestamp of when the presale starts _preSaleEnd Unix timestamp of when the presale ends _publicSaleStart Unix timestamp of when the public sale starts _initialBaseURI Set the base URI for metadata /
constructor( uint _preSaleStart, uint _preSaleEnd, uint _publicSaleStart, string memory _initialBaseURI
constructor( uint _preSaleStart, uint _preSaleEnd, uint _publicSaleStart, string memory _initialBaseURI
40,267
3
// Registers a new version with its implementation addressversion representing the version name of the new implementation to be registeredimplementation representing the address of the new implementation to be registered/
function addVersion(string _contractName, string version, address implementation) public;
function addVersion(string _contractName, string version, address implementation) public;
34,779
15
// This contract extends the ForceMove contract to enable it to be more easily unit-tested. It exposes public or external functions that set storage variables or wrap otherwise internal functions. It should not be deployed in a production environment. /
contract TESTForceMove is ForceMove { // Public wrappers for internal methods: /** * @dev Wrapper for otherwise internal function. Tests whether a given address is in a given array of addresses. * @param suspect A single address of interest. * @param addresses A line-up of possible perpetrators. * @return true if the address is in the array, false otherwise */ function isAddressInArray(address suspect, address[] memory addresses) public pure returns (bool) { return _isAddressInArray(suspect, addresses); } /** * @dev Wrapper for otherwise internal function. Given an array of state hashes, checks the validity of the supplied signatures. Valid means there is a signature for each participant, either on the hash of the state for which they are a mover, or on the hash of a state that appears after that state in the array. * @param largestTurnNum The largest turn number of the submitted states; will overwrite the stored value of `turnNumRecord`. * @param participants A list of addresses representing the participants of a channel. * @param stateHashes Array of keccak256(State) submitted in support of a state, * @param sigs Array of Signatures, one for each participant * @param whoSignedWhat participant[i] signed stateHashes[whoSignedWhat[i]] * @return true if the signatures are valid, false otherwise */ function validSignatures( uint48 largestTurnNum, address[] memory participants, bytes32[] memory stateHashes, Signature[] memory sigs, uint8[] memory whoSignedWhat // whoSignedWhat[i] is the index of the state in stateHashes that was signed by participants[i] ) public pure returns (bool) { return _validSignatures(largestTurnNum, participants, stateHashes, sigs, whoSignedWhat); } /** * @dev Wrapper for otherwise internal function. Given a declaration of which state in the support proof was signed by which participant, check if this declaration is acceptable. Acceptable means there is a signature for each participant, either on the hash of the state for which they are a mover, or on the hash of a state that appears after that state in the array. * @param whoSignedWhat participant[i] signed stateHashes[whoSignedWhat[i]] * @param largestTurnNum Largest turnNum of the support proof * @param nParticipants Number of participants in the channel * @param nStates Number of states in the support proof * @return true if whoSignedWhat is acceptable, false otherwise */ function acceptableWhoSignedWhat( uint8[] memory whoSignedWhat, uint48 largestTurnNum, uint256 nParticipants, uint256 nStates ) public pure returns (bool) { return _acceptableWhoSignedWhat(whoSignedWhat, largestTurnNum, nParticipants, nStates); } /** * @dev Wrapper for otherwise internal function. Given a digest and digital signature, recover the signer * @param _d message digest * @param sig ethereum digital signature * @return signer */ function recoverSigner(bytes32 _d, Signature memory sig) public pure returns (address) { return _recoverSigner(_d, sig); } // public setter for statusOf /** * @dev Manually set the fingerprint for a given channelId. Shortcuts the public methods (ONLY USE IN A TESTING ENVIRONMENT). * @param channelId Unique identifier for a state channel. * @param channelData The channelData to be formatted and stored against the channelId */ function setStatusFromChannelData(bytes32 channelId, ChannelData memory channelData) public { if (channelData.finalizesAt == 0) { require( channelData.stateHash == bytes32(0) && channelData.outcomeHash == bytes32(0), 'Invalid open channel' ); } statusOf[channelId] = _generateStatus(channelData); } /** * @dev Manually set the fingerprint for a given channelId. Shortcuts the public methods (ONLY USE IN A TESTING ENVIRONMENT). * @param channelId Unique identifier for a state channel. * @param f The fingerprint to store against the channelId */ function setStatus(bytes32 channelId, bytes32 f) public { statusOf[channelId] = f; } /** * @dev Wrapper for otherwise internal function. Hashes the input data and formats it for on chain storage. * @param channelData ChannelData data. */ function generateStatus(ChannelData memory channelData) public pure returns (bytes32 newStatus) { return _generateStatus(channelData); } /** * @dev Wrapper for otherwise internal function. Checks that a given ChannelData struct matches a supplied bytes32 when formatted for storage. * @param cs A given ChannelData data structure. * @param f Some data in on-chain storage format. */ function matchesStatus(ChannelData memory cs, bytes32 f) public pure returns (bool) { return _matchesStatus(cs, f); } /** * @dev Wrapper for otherwise internal function. Checks that a given channel is in the Challenge mode. * @param channelId Unique identifier for a channel. */ function requireChannelOpen(bytes32 channelId) public view { _requireChannelOpen(channelId); } }
contract TESTForceMove is ForceMove { // Public wrappers for internal methods: /** * @dev Wrapper for otherwise internal function. Tests whether a given address is in a given array of addresses. * @param suspect A single address of interest. * @param addresses A line-up of possible perpetrators. * @return true if the address is in the array, false otherwise */ function isAddressInArray(address suspect, address[] memory addresses) public pure returns (bool) { return _isAddressInArray(suspect, addresses); } /** * @dev Wrapper for otherwise internal function. Given an array of state hashes, checks the validity of the supplied signatures. Valid means there is a signature for each participant, either on the hash of the state for which they are a mover, or on the hash of a state that appears after that state in the array. * @param largestTurnNum The largest turn number of the submitted states; will overwrite the stored value of `turnNumRecord`. * @param participants A list of addresses representing the participants of a channel. * @param stateHashes Array of keccak256(State) submitted in support of a state, * @param sigs Array of Signatures, one for each participant * @param whoSignedWhat participant[i] signed stateHashes[whoSignedWhat[i]] * @return true if the signatures are valid, false otherwise */ function validSignatures( uint48 largestTurnNum, address[] memory participants, bytes32[] memory stateHashes, Signature[] memory sigs, uint8[] memory whoSignedWhat // whoSignedWhat[i] is the index of the state in stateHashes that was signed by participants[i] ) public pure returns (bool) { return _validSignatures(largestTurnNum, participants, stateHashes, sigs, whoSignedWhat); } /** * @dev Wrapper for otherwise internal function. Given a declaration of which state in the support proof was signed by which participant, check if this declaration is acceptable. Acceptable means there is a signature for each participant, either on the hash of the state for which they are a mover, or on the hash of a state that appears after that state in the array. * @param whoSignedWhat participant[i] signed stateHashes[whoSignedWhat[i]] * @param largestTurnNum Largest turnNum of the support proof * @param nParticipants Number of participants in the channel * @param nStates Number of states in the support proof * @return true if whoSignedWhat is acceptable, false otherwise */ function acceptableWhoSignedWhat( uint8[] memory whoSignedWhat, uint48 largestTurnNum, uint256 nParticipants, uint256 nStates ) public pure returns (bool) { return _acceptableWhoSignedWhat(whoSignedWhat, largestTurnNum, nParticipants, nStates); } /** * @dev Wrapper for otherwise internal function. Given a digest and digital signature, recover the signer * @param _d message digest * @param sig ethereum digital signature * @return signer */ function recoverSigner(bytes32 _d, Signature memory sig) public pure returns (address) { return _recoverSigner(_d, sig); } // public setter for statusOf /** * @dev Manually set the fingerprint for a given channelId. Shortcuts the public methods (ONLY USE IN A TESTING ENVIRONMENT). * @param channelId Unique identifier for a state channel. * @param channelData The channelData to be formatted and stored against the channelId */ function setStatusFromChannelData(bytes32 channelId, ChannelData memory channelData) public { if (channelData.finalizesAt == 0) { require( channelData.stateHash == bytes32(0) && channelData.outcomeHash == bytes32(0), 'Invalid open channel' ); } statusOf[channelId] = _generateStatus(channelData); } /** * @dev Manually set the fingerprint for a given channelId. Shortcuts the public methods (ONLY USE IN A TESTING ENVIRONMENT). * @param channelId Unique identifier for a state channel. * @param f The fingerprint to store against the channelId */ function setStatus(bytes32 channelId, bytes32 f) public { statusOf[channelId] = f; } /** * @dev Wrapper for otherwise internal function. Hashes the input data and formats it for on chain storage. * @param channelData ChannelData data. */ function generateStatus(ChannelData memory channelData) public pure returns (bytes32 newStatus) { return _generateStatus(channelData); } /** * @dev Wrapper for otherwise internal function. Checks that a given ChannelData struct matches a supplied bytes32 when formatted for storage. * @param cs A given ChannelData data structure. * @param f Some data in on-chain storage format. */ function matchesStatus(ChannelData memory cs, bytes32 f) public pure returns (bool) { return _matchesStatus(cs, f); } /** * @dev Wrapper for otherwise internal function. Checks that a given channel is in the Challenge mode. * @param channelId Unique identifier for a channel. */ function requireChannelOpen(bytes32 channelId) public view { _requireChannelOpen(channelId); } }
2,907
0
// Adding events for logging and interacting better with dapps/
event logDepositMade(address indexed comeFromAddress, uint indexed amount); // Logging deposit made event logWithdrawMade(uint indexed amount); // Logging withdrawal made
event logDepositMade(address indexed comeFromAddress, uint indexed amount); // Logging deposit made event logWithdrawMade(uint indexed amount); // Logging withdrawal made
10,876
7
// ret := mload(x)no return value ever written :/
mstore(0x40,add(x,0x4)) // just in case, roll the tape
mstore(0x40,add(x,0x4)) // just in case, roll the tape
41,145
8
// we don't check matching super token because the nft token id is generated based on the superToken
uint256 newTokenId = _getTokenId(address(superToken), flowSender, flowReceiver); if (_flowDataByTokenId[newTokenId].flowSender == address(0)) { _mint(address(superToken), flowSender, flowReceiver, newTokenId); CONSTANT_INFLOW_NFT.mint(flowReceiver, newTokenId); }
uint256 newTokenId = _getTokenId(address(superToken), flowSender, flowReceiver); if (_flowDataByTokenId[newTokenId].flowSender == address(0)) { _mint(address(superToken), flowSender, flowReceiver, newTokenId); CONSTANT_INFLOW_NFT.mint(flowReceiver, newTokenId); }
29,965
5
// Do not allow the oracle to submit times any further forward into the future than this constant.
uint private constant ORACLE_FUTURE_LIMIT = 10 minutes;
uint private constant ORACLE_FUTURE_LIMIT = 10 minutes;
19,141
8
// Holds the owner address
address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
74,528
55
// See {ERC20-_burn} and {ERC20-allowance}. Requirements: - the caller must have allowance for ``accounts``'s tokens of at least`amount`. /
function burnFrom(address account, uint256 amount) public virtual { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); unchecked { _approve(account, _msgSender(), currentAllowance - amount); }
function burnFrom(address account, uint256 amount) public virtual { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); unchecked { _approve(account, _msgSender(), currentAllowance - amount); }
2,715
12
// Accrues the interest on the borrowed tokens and handles the accumulation of fees.
function accrue() public { AccrueInfo memory _accrueInfo = accrueInfo; // Number of seconds since accrue was called uint256 elapsedTime = block.timestamp - _accrueInfo.lastAccrued; if (elapsedTime == 0) { return; } _accrueInfo.lastAccrued = uint64(block.timestamp); Rebase memory _totalBorrow = totalBorrow; if (_totalBorrow.base == 0) { accrueInfo = _accrueInfo; return; } // Accrue interest uint128 extraAmount = (uint256(_totalBorrow.elastic).mul(INTEREST_PER_SECOND).mul(elapsedTime) / 1e18).to128(); _totalBorrow.elastic = _totalBorrow.elastic.add(extraAmount); _accrueInfo.feesEarned = _accrueInfo.feesEarned.add(extraAmount); totalBorrow = _totalBorrow; accrueInfo = _accrueInfo; emit LogAccrue(extraAmount); }
function accrue() public { AccrueInfo memory _accrueInfo = accrueInfo; // Number of seconds since accrue was called uint256 elapsedTime = block.timestamp - _accrueInfo.lastAccrued; if (elapsedTime == 0) { return; } _accrueInfo.lastAccrued = uint64(block.timestamp); Rebase memory _totalBorrow = totalBorrow; if (_totalBorrow.base == 0) { accrueInfo = _accrueInfo; return; } // Accrue interest uint128 extraAmount = (uint256(_totalBorrow.elastic).mul(INTEREST_PER_SECOND).mul(elapsedTime) / 1e18).to128(); _totalBorrow.elastic = _totalBorrow.elastic.add(extraAmount); _accrueInfo.feesEarned = _accrueInfo.feesEarned.add(extraAmount); totalBorrow = _totalBorrow; accrueInfo = _accrueInfo; emit LogAccrue(extraAmount); }
6,211
37
// State variables // Delegation /
struct Delegation { address receiver; uint256 delegatedAmount; }
struct Delegation { address receiver; uint256 delegatedAmount; }
58,871
159
// TokenRecover Allow to recover any ERC20 sent into the contract for error /
contract TokenRecover is Ownable { /** * @dev Remember that only owner can call so be careful when use on contracts generated from other contracts. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } }
contract TokenRecover is Ownable { /** * @dev Remember that only owner can call so be careful when use on contracts generated from other contracts. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } }
10,725
20
// F1 - F10: OK C1- C24: OK
function _convert(address token0, address token1) internal { // Interactions // S1 - S4: OK IUniswapV2Pair pair = IUniswapV2Pair(factory.getPair(token0, token1)); require(address(pair) != address(0), "Jeweler: Invalid pair"); // balanceOf: S1 - S4: OK // transfer: X1 - X5: OK IERC20(address(pair)).safeTransfer(address(pair), pair.balanceOf(address(this))); // X1 - X5: OK (uint256 amount0, uint256 amount1) = pair.burn(address(this)); if (token0 != pair.token0()) { (amount0, amount1) = (amount1, amount0); } emit LogConvert(msg.sender, token0, token1, amount0, amount1, _convertStep(token0, token1, amount0, amount1)); }
function _convert(address token0, address token1) internal { // Interactions // S1 - S4: OK IUniswapV2Pair pair = IUniswapV2Pair(factory.getPair(token0, token1)); require(address(pair) != address(0), "Jeweler: Invalid pair"); // balanceOf: S1 - S4: OK // transfer: X1 - X5: OK IERC20(address(pair)).safeTransfer(address(pair), pair.balanceOf(address(this))); // X1 - X5: OK (uint256 amount0, uint256 amount1) = pair.burn(address(this)); if (token0 != pair.token0()) { (amount0, amount1) = (amount1, amount0); } emit LogConvert(msg.sender, token0, token1, amount0, amount1, _convertStep(token0, token1, amount0, amount1)); }
13,001
50
// uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
owner = msg.sender; admins[owner] = true; admins[msg.sender] = true;
owner = msg.sender; admins[owner] = true; admins[msg.sender] = true;
8,445
7
// maximum transferring per function
uint public constant MAX_TRANSFER = 80;
uint public constant MAX_TRANSFER = 80;
43,850
452
// Solidity generates reverts with reason that look as follows: 1. 4 bytes with the constant 0x08c379a0 (== Keccak256(b'Error(string)')[:4]). 2. 32 bytes offset bytes (always 0x20 as far as i can tell). 3. 32 bytes with the length of the revert reason. 4. Revert reason string.
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000) mstore(0x4, 0x20) mstore(0x24, 0x1e) mstore(0x44, "Batch inverse product is zero.") revert(0, 0x62)
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000) mstore(0x4, 0x20) mstore(0x24, 0x1e) mstore(0x44, "Batch inverse product is zero.") revert(0, 0x62)
63,636
11
// Returns the strategy's token price return uint Strategy's token price/
function tokenPrice() external view returns (uint);
function tokenPrice() external view returns (uint);
24,565
218
// When true, a proposal would be executed on timelockV1 instead of the current timelock
bool executeOnTimelockV1;
bool executeOnTimelockV1;
4,959
7
// The 0 currency is ETH itself.
if (_currency == 0) return 10**targetDecimals;
if (_currency == 0) return 10**targetDecimals;
3,107