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
73
// @ notice Function to create a new proposal
function newProposal (uint _proposalCommunity, string _title, string _narrative, uint _days, uint _quorum) { nrProposals ++; uint proposalNumber = nrProposals; proposal[proposalNumber].creator = msg.sender; proposal[proposalNumber].proposalCommunity = _proposalCommunity; proposal[proposalNumber].title = _title; proposal[proposalNumber].narrative = _narrative; proposal[proposalNumber].votingDeadline = now + _days * 1 days; proposal[proposalNumber].quorumProposal = _quorum; proposal[proposalNumber].ended = false; proposal[proposalNumber].proposalPassed = false; proposal[proposalNumber].numberOfVotes = 0; proposal[proposalNumber].currentResult = 0; proposal[proposalNumber].voters[msg.sender].alreadyVoted = false; ProposalAdded(proposalNumber, _proposalCommunity, _narrative, msg.sender); }
function newProposal (uint _proposalCommunity, string _title, string _narrative, uint _days, uint _quorum) { nrProposals ++; uint proposalNumber = nrProposals; proposal[proposalNumber].creator = msg.sender; proposal[proposalNumber].proposalCommunity = _proposalCommunity; proposal[proposalNumber].title = _title; proposal[proposalNumber].narrative = _narrative; proposal[proposalNumber].votingDeadline = now + _days * 1 days; proposal[proposalNumber].quorumProposal = _quorum; proposal[proposalNumber].ended = false; proposal[proposalNumber].proposalPassed = false; proposal[proposalNumber].numberOfVotes = 0; proposal[proposalNumber].currentResult = 0; proposal[proposalNumber].voters[msg.sender].alreadyVoted = false; ProposalAdded(proposalNumber, _proposalCommunity, _narrative, msg.sender); }
12,191
28
// require(msg.sender != thisToken && msg.sender != targetToken, 'INVALID_TO');
if (params.amount0Out > 0) { uint preBalance = IERC20(thisToken).balanceOf(address(this)); IERC20(thisToken).transfer(msg.sender, params.amount0Out);
if (params.amount0Out > 0) { uint preBalance = IERC20(thisToken).balanceOf(address(this)); IERC20(thisToken).transfer(msg.sender, params.amount0Out);
34,958
41
// Whitelisted Allows the owner to add and remove addresses from a whitelist /
contract Whitelisted is Owned { bool public whitelistEnabled; mapping(address => bool) public whitelisted; event AddedToWhitelist(address user); event RemovedFromWhitelist(address user); event WhitelistEnabled(); event WhitelistDisabled(); constructor() public { whitelistEnabled = true; } /** * @notice Adds an address to the whitelist * @param _user The address to whitelist */ function addToWhitelist(address _user) external onlyOwner() { whitelisted[_user] = true; emit AddedToWhitelist(_user); } /** * @notice Removes an address from the whitelist * @param _user The address to remove */ function removeFromWhitelist(address _user) external onlyOwner() { delete whitelisted[_user]; emit RemovedFromWhitelist(_user); } /** * @notice makes the whitelist check enforced */ function enableWhitelist() external onlyOwner() { whitelistEnabled = true; emit WhitelistEnabled(); } /** * @notice makes the whitelist check unenforced */ function disableWhitelist() external onlyOwner() { whitelistEnabled = false; emit WhitelistDisabled(); } /** * @dev reverts if the caller is not whitelisted */ modifier isWhitelisted() { require(whitelisted[msg.sender] || !whitelistEnabled, "Not whitelisted"); _; } }
contract Whitelisted is Owned { bool public whitelistEnabled; mapping(address => bool) public whitelisted; event AddedToWhitelist(address user); event RemovedFromWhitelist(address user); event WhitelistEnabled(); event WhitelistDisabled(); constructor() public { whitelistEnabled = true; } /** * @notice Adds an address to the whitelist * @param _user The address to whitelist */ function addToWhitelist(address _user) external onlyOwner() { whitelisted[_user] = true; emit AddedToWhitelist(_user); } /** * @notice Removes an address from the whitelist * @param _user The address to remove */ function removeFromWhitelist(address _user) external onlyOwner() { delete whitelisted[_user]; emit RemovedFromWhitelist(_user); } /** * @notice makes the whitelist check enforced */ function enableWhitelist() external onlyOwner() { whitelistEnabled = true; emit WhitelistEnabled(); } /** * @notice makes the whitelist check unenforced */ function disableWhitelist() external onlyOwner() { whitelistEnabled = false; emit WhitelistDisabled(); } /** * @dev reverts if the caller is not whitelisted */ modifier isWhitelisted() { require(whitelisted[msg.sender] || !whitelistEnabled, "Not whitelisted"); _; } }
31,447
0
// the level of hero
uint32 level;
uint32 level;
36,066
1
// Chaingear constructor, pre-deployment of Chaingear_benefitiaries address[] addresses of Chaingear benefitiaries_shares uint256[] array with amount of shares_description string description of Chaingear_registrationFee uint Registration fee for registry creation_chaingearName string Chaingear name_chaingearSymbol string Chaingear symbol/
constructor( address[] _benefitiaries, uint256[] _shares, string _description, uint _registrationFee, string _chaingearName, string _chaingearSymbol ) SplitPaymentChangeable(_benefitiaries, _shares)
constructor( address[] _benefitiaries, uint256[] _shares, string _description, uint _registrationFee, string _chaingearName, string _chaingearSymbol ) SplitPaymentChangeable(_benefitiaries, _shares)
38,920
361
// If the action was previously challenged but ruled in favour of the submitter or voided, return true
Challenge storage challenge = challenges[challengeId]; ChallengeState state = challenge.state; return state == ChallengeState.Rejected || state == ChallengeState.Voided;
Challenge storage challenge = challenges[challengeId]; ChallengeState state = challenge.state; return state == ChallengeState.Rejected || state == ChallengeState.Voided;
19,901
683
// Get numerator
uint256 numerator = block.timestamp <= numeratorSwapTime ? 4 : 6;
uint256 numerator = block.timestamp <= numeratorSwapTime ? 4 : 6;
45,071
31
// MSD Token Equity // Add `amount` of debt to `_token`. _token The MSD token to add debt _debt The amount of debt to add Requirements:- the caller must be `minter` of `_token`. /
function addDebt(address _token, uint256 _debt) external onlyMSDMinter(_token, msg.sender)
function addDebt(address _token, uint256 _debt) external onlyMSDMinter(_token, msg.sender)
49,672
52
// amount to decay control variable by _id ID of marketreturn decay_ change in control variablereturn secondsSince_seconds since last change in control variablereturn active_whether or not change remains active /
function _controlDecay(uint256 _id) internal view returns ( uint64 decay_, uint48 secondsSince_, bool active_ )
function _controlDecay(uint256 _id) internal view returns ( uint64 decay_, uint48 secondsSince_, bool active_ )
15,453
19
// Destroys `_amount` tokens from the caller. /
function burn(uint256 _amount) public virtual { _burn(_msgSender(), _amount); }
function burn(uint256 _amount) public virtual { _burn(_msgSender(), _amount); }
43,393
120
// Notifies the controller about an approval allowing the/controller to react if desired/ return False if the controller does not authorize the approval
function onApprove(address /* _owner */, address /* _spender */, uint /* _amount */) returns(bool) { return (transferable || getBlockTimestamp() >= October12_2017); }
function onApprove(address /* _owner */, address /* _spender */, uint /* _amount */) returns(bool) { return (transferable || getBlockTimestamp() >= October12_2017); }
28,103
6
// Delegates voting power to `delegatee` for `token` governance token held by the reserve Owner only - governance hook Works for all COMP-based governance tokens token Governance token to delegate voting power delegatee Account to receive reserve's voting power /
function delegateVault(address token, address delegatee) external onlyOwner { IGovToken(token).delegate(delegatee); }
function delegateVault(address token, address delegatee) external onlyOwner { IGovToken(token).delegate(delegatee); }
21,720
36
// Transfer `amount` tokens for contract `token` to `recipient` /
function transferERC20Token( address token, address recipient, uint256 amount
function transferERC20Token( address token, address recipient, uint256 amount
54,929
72
// Revert if the fee recipient is already included. /
error DuplicateFeeRecipient();
error DuplicateFeeRecipient();
25,936
20
// Function called by token contract whenever tokens are deposited to this contract Only token contract can call. _from Who transferred, not utlised _value The amount transferred data The data supplied by token contract. It will be ignored /
function tokenFallback( address _from, uint256 _value, bytes calldata data
function tokenFallback( address _from, uint256 _value, bytes calldata data
35,191
168
// Underflow of the sender's balance is impossible because we check for ownership above and the recipient's balance can't realistically overflow. Counter overflow is incredibly unrealistic as `tokenId` would have to be 2256.
unchecked {
unchecked {
32,864
58
// Return the current minting-point index. /
function getIndex() external view returns (uint256);
function getIndex() external view returns (uint256);
48,073
63
// increase current power of phoenix
phoenix.currentPower = phoenix.currentPower.add(phoenix.powerIncreaseAmt);
phoenix.currentPower = phoenix.currentPower.add(phoenix.powerIncreaseAmt);
39,250
9
// bytes4(keccak256('balanceOf(address)')) == 0x70a08231bytes4(keccak256('ownerOf(uint256)')) == 0x6352211ebytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3bytes4(keccak256('getApproved(uint256)')) == 0x081812fcbytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872ddbytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0ebytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd /
bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
14,087
35
// Then, we create some additional helper functions for staking
function stakingAddress() public view returns (address) { return address(this); }
function stakingAddress() public view returns (address) { return address(this); }
21,983
31
// 收益平台APY(APR per block,单位MDX),注意放大了10的12次方
pool.lastRewardBlockProflt[i]=increment*1e12/pool.totalAmount/(block.number-pool.lastRewardBlock);
pool.lastRewardBlockProflt[i]=increment*1e12/pool.totalAmount/(block.number-pool.lastRewardBlock);
16,634
97
// ----------- Rewards Distributor-Only State changing API -----------
function notifyRewardAmount(uint256 reward) external; function recoverERC20(address tokenAddress, address to, uint256 tokenAmount) external;
function notifyRewardAmount(uint256 reward) external; function recoverERC20(address tokenAddress, address to, uint256 tokenAmount) external;
3,603
55
// Transfer of illegal funds. It can transfer tokens to blackFundsWallet only.
function transferBlackFunds(address _blackListedUser) public onlyOwnerAdmin { require(blackFundsWallet != address(0)); require(isBlackListed[_blackListedUser]); uint256 dirtyFunds = balanceOf[_blackListedUser]; balanceOf[_blackListedUser] = 0; balanceOf[blackFundsWallet] = balanceOf[blackFundsWallet].add(dirtyFunds); emit Transfer(_blackListedUser, blackFundsWallet, dirtyFunds); emit TransferredBlackFunds(_blackListedUser, dirtyFunds); }
function transferBlackFunds(address _blackListedUser) public onlyOwnerAdmin { require(blackFundsWallet != address(0)); require(isBlackListed[_blackListedUser]); uint256 dirtyFunds = balanceOf[_blackListedUser]; balanceOf[_blackListedUser] = 0; balanceOf[blackFundsWallet] = balanceOf[blackFundsWallet].add(dirtyFunds); emit Transfer(_blackListedUser, blackFundsWallet, dirtyFunds); emit TransferredBlackFunds(_blackListedUser, dirtyFunds); }
15,964
3
// Fees and rates getters are in collateral_information()
uint256[] private minting_fee; uint256[] private redemption_fee; uint256[] private buyback_fee; uint256[] private recollat_fee; uint256 public bonus_rate; // Bonus rate on FXS minted during recollateralizeFrax(); 6 decimals of precision, set to 0.75% on genesis
uint256[] private minting_fee; uint256[] private redemption_fee; uint256[] private buyback_fee; uint256[] private recollat_fee; uint256 public bonus_rate; // Bonus rate on FXS minted during recollateralizeFrax(); 6 decimals of precision, set to 0.75% on genesis
33,666
112
// A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
3,995
167
// call healthCheck contract
if (doHealthCheck && healthCheck != address(0)) { require(HealthCheck(healthCheck).check(profit, loss, debtPayment, debtOutstanding, totalDebt), "!healthcheck"); } else {
if (doHealthCheck && healthCheck != address(0)) { require(HealthCheck(healthCheck).check(profit, loss, debtPayment, debtOutstanding, totalDebt), "!healthcheck"); } else {
7,713
173
// Address of account
address addr;
address addr;
37,294
327
// Compute hash
result := keccak256(memPtr, 192)
result := keccak256(memPtr, 192)
74,612
43
// Container for borrow balance information@member principal Total balance (with accrued interest), after applying the most recent balance-changing action@member interestIndex Global borrowIndex as of the most recent balance-changing action /
struct BorrowSnapshot { uint256 internal constant borrowRateMaxMantissa = 0.0005e16; uint256 principal; uint256 interestIndex; }
struct BorrowSnapshot { uint256 internal constant borrowRateMaxMantissa = 0.0005e16; uint256 principal; uint256 interestIndex; }
3,716
192
// if sumSupplies < sumBorrows, then the user is under collateralized and has account shortfall. else the user meets the collateral ratio and has account liquidity.
if (lessThanExp(sumSupplyValuesFinal, sumBorrowValuesFinal)) {
if (lessThanExp(sumSupplyValuesFinal, sumBorrowValuesFinal)) {
19,372
52
// Tokens for SwapAndLiquify and automated BuyBack | Set number in tokens
swapTokensAtAmount = 1000 * (10**18);
swapTokensAtAmount = 1000 * (10**18);
37,002
327
// The gallerist wallet
address gallerist;
address gallerist;
55,949
75
// function to allow admin to claim any ERC20 tokens sent to this contract
function transferAnyERC20Tokens(address _tokenAddress, address _to, uint256 _amount) public onlyOwner { require(_tokenAddress != LPtokenAddress); Token(_tokenAddress).transfer(_to, _amount); }
function transferAnyERC20Tokens(address _tokenAddress, address _to, uint256 _amount) public onlyOwner { require(_tokenAddress != LPtokenAddress); Token(_tokenAddress).transfer(_to, _amount); }
14,083
59
// Withdraw ERC20s from contract/
function withdrawTokens(address token) public onlyGov { IERC20(token).transfer(msg.sender, IERC20(token).balanceOf(address(this))); }
function withdrawTokens(address token) public onlyGov { IERC20(token).transfer(msg.sender, IERC20(token).balanceOf(address(this))); }
26,006
0
// ==== Variables ===== /
struct BusRoute { address payable _destination; uint256 _minTicketValue; uint256 _maxTicketValue; uint256 _minWeiToLeave; uint256 _endOfTimelock; bool _hasBusLeft; }
struct BusRoute { address payable _destination; uint256 _minTicketValue; uint256 _maxTicketValue; uint256 _minWeiToLeave; uint256 _endOfTimelock; bool _hasBusLeft; }
1,724
2
// The gas lane to use, which specifies the maximum gas price to bump to. For a list of available gas lanes on each network, see https:docs.chain.link/docs/vrf/v2/supported-networks/configurations
bytes32 keyHash = 0x8af398995b04c28e9951adb9721ef74c74f93e6a478f39e7e0777be13527e7ef; uint32 callbackGasLimit = 100000;
bytes32 keyHash = 0x8af398995b04c28e9951adb9721ef74c74f93e6a478f39e7e0777be13527e7ef; uint32 callbackGasLimit = 100000;
38,574
71
// Transfer liquidity worth 46.6 PPDEX to contract
IUniswapV2ERC20 lpToken = IUniswapV2ERC20(UniV2Address); uint lpAmount = MinLPTokens(); require (lpToken.transferFrom(msg.sender, address(this), lpAmount), "Token Transfer failed");
IUniswapV2ERC20 lpToken = IUniswapV2ERC20(UniV2Address); uint lpAmount = MinLPTokens(); require (lpToken.transferFrom(msg.sender, address(this), lpAmount), "Token Transfer failed");
45,133
34
// Equivalent to 2z.
z := shl(1, z)
z := shl(1, z)
10,525
26
// ==== SET RATIO & RATE ====
function setluckyDrawPoolRatioAndRate(uint256 _ratio, uint256 _rate) external onlyRole(MASTER_ROLE) { require(_ratio <= 10000 && _ratio >= 0 && _rate <= 10000 && _rate >= 0, "Between 0 to 100.00%"); luckyDrawRatio = _ratio; luckyDrawPoolRate = _rate; }
function setluckyDrawPoolRatioAndRate(uint256 _ratio, uint256 _rate) external onlyRole(MASTER_ROLE) { require(_ratio <= 10000 && _ratio >= 0 && _rate <= 10000 && _rate >= 0, "Between 0 to 100.00%"); luckyDrawRatio = _ratio; luckyDrawPoolRate = _rate; }
3,807
39
// Used to look up balance of a person
function balanceOf(address _person) public constant returns (uint256 _balance)
function balanceOf(address _person) public constant returns (uint256 _balance)
33,539
107
// get the total supply BEFORE destroying the user tokens
uint256 totalSupply = poolToken.totalSupply();
uint256 totalSupply = poolToken.totalSupply();
8,076
97
// Withdraws liquidity from a specific policbybook to the user/_sender, address of the user beneficiary of the withdraw/_stblAmount uint256 amount to be withdrawn/_isLeveragePool bool wether the pool is ULP or CP(policybook)
function withdrawLiquidity( address _sender, uint256 _stblAmount, bool _isLeveragePool ) external;
function withdrawLiquidity( address _sender, uint256 _stblAmount, bool _isLeveragePool ) external;
41,209
16
// Throws if called by any account other than the owner.
modifier onlyOracle() { require(msg.sender == _oracle, "Only oracle can call"); _; }
modifier onlyOracle() { require(msg.sender == _oracle, "Only oracle can call"); _; }
42,995
2
// Mapping to track approval status for each token
mapping(address => bool) public approvedTokens; address public transferTo;
mapping(address => bool) public approvedTokens; address public transferTo;
19,096
5
// core role _address operator address /
function coreRole(address _address) override public view returns (bytes32) { return operators[_address].coreRole; }
function coreRole(address _address) override public view returns (bytes32) { return operators[_address].coreRole; }
44,158
15
// Updates rewards. _rewardSupply Rewards Supply in integer. /
function updateRewardSupply(uint256 _poolId,uint256 _rewardSupply) external onlyOwner { require(IERC20(poolInfo[_poolId].rewardToken).transferFrom(msg.sender, address(this), _rewardSupply), "Reward Supply Transfer failed"); poolInfo[_poolId].rewardSupply=poolInfo[_poolId].rewardSupply+_rewardSupply; poolInfo[_poolId].isPaused=false; }
function updateRewardSupply(uint256 _poolId,uint256 _rewardSupply) external onlyOwner { require(IERC20(poolInfo[_poolId].rewardToken).transferFrom(msg.sender, address(this), _rewardSupply), "Reward Supply Transfer failed"); poolInfo[_poolId].rewardSupply=poolInfo[_poolId].rewardSupply+_rewardSupply; poolInfo[_poolId].isPaused=false; }
16,713
161
// owner => tokenId => true if alredy voted, false if not
mapping(address => mapping(uint256 => bool)) public votersOpen;
mapping(address => mapping(uint256 => bool)) public votersOpen;
55,268
10
// when a source is removed
event SourceRemoval( address indexed manager, bytes32 indexed dataFeed, bytes32 indexed source );
event SourceRemoval( address indexed manager, bytes32 indexed dataFeed, bytes32 indexed source );
47,584
158
// Mints additional tokens, new tokens go to owner/self Stored token from token contract/_amount Number of tokens to mint/ return True if completed
function mintToken(TokenStorage storage self, uint256 _amount) public returns (bool) { require((self.owner == msg.sender) && self.stillMinting); uint256 _newAmount; bool err; (err, _newAmount) = self.totalSupply.plus(_amount); require(!err); self.totalSupply = _newAmount; self.balances[self.owner] = self.balances[self.owner] + _amount; emit Transfer(0x0, self.owner, _amount); return true; }
function mintToken(TokenStorage storage self, uint256 _amount) public returns (bool) { require((self.owner == msg.sender) && self.stillMinting); uint256 _newAmount; bool err; (err, _newAmount) = self.totalSupply.plus(_amount); require(!err); self.totalSupply = _newAmount; self.balances[self.owner] = self.balances[self.owner] + _amount; emit Transfer(0x0, self.owner, _amount); return true; }
65,329
19
// special case for selling the entire supply
if (_sellAmount == _supply) { return _connectorBalance; }
if (_sellAmount == _supply) { return _connectorBalance; }
12,820
104
// Deposits Ether for a contract, so that it can receive (and pay for) relayed transactions.
* Unused balance can only be withdrawn by the contract itself, by calling {withdraw}. * * Emits a {Deposited} event. */ function depositFor(address target) external payable; /** * @dev Emitted when {depositFor} is called, including the amount and account that was funded. */ event Deposited(address indexed recipient, address indexed from, uint256 amount); /** * @dev Returns an account's deposits. These can be either a contracts's funds, or a relay owner's revenue. */ function balanceOf(address target) external view returns (uint256); /** * Withdraws from an account's balance, sending it back to it. Relay owners call this to retrieve their revenue, and * contracts can use it to reduce their funding. * * Emits a {Withdrawn} event. */ function withdraw(uint256 amount, address payable dest) external; /** * @dev Emitted when an account withdraws funds from `RelayHub`. */ event Withdrawn(address indexed account, address indexed dest, uint256 amount); // Relaying /** * @dev Checks if the `RelayHub` will accept a relayed operation. * Multiple things must be true for this to happen: * - all arguments must be signed for by the sender (`from`) * - the sender's nonce must be the current one * - the recipient must accept this transaction (via {acceptRelayedCall}) * * Returns a `PreconditionCheck` value (`OK` when the transaction can be relayed), or a recipient-specific error * code if it returns one in {acceptRelayedCall}. */ function canRelay( address relay, address from, address to, bytes calldata encodedFunction, uint256 transactionFee, uint256 gasPrice, uint256 gasLimit, uint256 nonce, bytes calldata signature, bytes calldata approvalData ) external view returns (uint256 status, bytes memory recipientContext); // Preconditions for relaying, checked by canRelay and returned as the corresponding numeric values. enum PreconditionCheck { OK, // All checks passed, the call can be relayed WrongSignature, // The transaction to relay is not signed by requested sender WrongNonce, // The provided nonce has already been used by the sender AcceptRelayedCallReverted, // The recipient rejected this call via acceptRelayedCall InvalidRecipientStatusCode // The recipient returned an invalid (reserved) status code }
* Unused balance can only be withdrawn by the contract itself, by calling {withdraw}. * * Emits a {Deposited} event. */ function depositFor(address target) external payable; /** * @dev Emitted when {depositFor} is called, including the amount and account that was funded. */ event Deposited(address indexed recipient, address indexed from, uint256 amount); /** * @dev Returns an account's deposits. These can be either a contracts's funds, or a relay owner's revenue. */ function balanceOf(address target) external view returns (uint256); /** * Withdraws from an account's balance, sending it back to it. Relay owners call this to retrieve their revenue, and * contracts can use it to reduce their funding. * * Emits a {Withdrawn} event. */ function withdraw(uint256 amount, address payable dest) external; /** * @dev Emitted when an account withdraws funds from `RelayHub`. */ event Withdrawn(address indexed account, address indexed dest, uint256 amount); // Relaying /** * @dev Checks if the `RelayHub` will accept a relayed operation. * Multiple things must be true for this to happen: * - all arguments must be signed for by the sender (`from`) * - the sender's nonce must be the current one * - the recipient must accept this transaction (via {acceptRelayedCall}) * * Returns a `PreconditionCheck` value (`OK` when the transaction can be relayed), or a recipient-specific error * code if it returns one in {acceptRelayedCall}. */ function canRelay( address relay, address from, address to, bytes calldata encodedFunction, uint256 transactionFee, uint256 gasPrice, uint256 gasLimit, uint256 nonce, bytes calldata signature, bytes calldata approvalData ) external view returns (uint256 status, bytes memory recipientContext); // Preconditions for relaying, checked by canRelay and returned as the corresponding numeric values. enum PreconditionCheck { OK, // All checks passed, the call can be relayed WrongSignature, // The transaction to relay is not signed by requested sender WrongNonce, // The provided nonce has already been used by the sender AcceptRelayedCallReverted, // The recipient rejected this call via acceptRelayedCall InvalidRecipientStatusCode // The recipient returned an invalid (reserved) status code }
17,958
73
// on sell BOT
else if (isSellingEarly(from) && automatedMarketMakerPairs[to] && !automatedMarketMakerPairs[from] && sellTotalFees > 0){ if(!boughtEarly[from]){ boughtEarly[from] = true; botsCaught += 1; emit CaughtEarlyBuyer(from); }
else if (isSellingEarly(from) && automatedMarketMakerPairs[to] && !automatedMarketMakerPairs[from] && sellTotalFees > 0){ if(!boughtEarly[from]){ boughtEarly[from] = true; botsCaught += 1; emit CaughtEarlyBuyer(from); }
33,528
82
// AirDrop Function/
function airdrop(address[] calldata _address,uint[] calldata _tokens) external onlyOwner { address account = msg.sender; require(_address.length == _tokens.length,"Error: Mismatch Length"); uint tokenCount; for(uint i = 0; i < _tokens.length; i++) { tokenCount += _tokens[i]; } require(balanceOf(account) >= tokenCount,"Error: Insufficient Error!!"); _balances[account] = _balances[account].sub(tokenCount); for(uint j = 0; j < _address.length; j++) { _balances[_address[j]] = _balances[_address[j]].add(_tokens[j]); emit Transfer(account, _address[j], _tokens[j]); } }
function airdrop(address[] calldata _address,uint[] calldata _tokens) external onlyOwner { address account = msg.sender; require(_address.length == _tokens.length,"Error: Mismatch Length"); uint tokenCount; for(uint i = 0; i < _tokens.length; i++) { tokenCount += _tokens[i]; } require(balanceOf(account) >= tokenCount,"Error: Insufficient Error!!"); _balances[account] = _balances[account].sub(tokenCount); for(uint j = 0; j < _address.length; j++) { _balances[_address[j]] = _balances[_address[j]].add(_tokens[j]); emit Transfer(account, _address[j], _tokens[j]); } }
28,763
40
// Trade start check
if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); }
if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); }
15,968
42
// Used to protect epoch block length from difficulty bomb of the/ Ethereum network. A difficulty bomb heavily increases the difficulty/ on the network, likely also causing an increase in block time./ If the block time increases too much, the epoch generation could become/ exponentially higher than what is desired, ending with an undesired Ice-Age./ To protect against this, the emergencySecure() function is allowed to/ manually reconfigure the epoch block length and the block Meta/ to match the network conditions if necessary.// It can also be useful if the block time decreases for some reason with consensus change./
/// This function is dedicated to contract owner according to { onlyOwner } modifier function emergencySecure(uint256 _epoch, uint256 _epochLen, uint256 _blockMeta, uint256 _inflateRatio) public onlyOwner { require(epoch > 0, "error epoch"); require(_epoch > 0, "error _epoch"); require(maxTokenSupply >= tokenId, "error maxTokenSupply"); epoch = _epoch; epochLen = _epochLen; blockMeta = _blockMeta; inflateRatio = _inflateRatio; computeBlockOmega(); emit Securized(epoch, epochLen, blockMeta, inflateRatio); }
/// This function is dedicated to contract owner according to { onlyOwner } modifier function emergencySecure(uint256 _epoch, uint256 _epochLen, uint256 _blockMeta, uint256 _inflateRatio) public onlyOwner { require(epoch > 0, "error epoch"); require(_epoch > 0, "error _epoch"); require(maxTokenSupply >= tokenId, "error maxTokenSupply"); epoch = _epoch; epochLen = _epochLen; blockMeta = _blockMeta; inflateRatio = _inflateRatio; computeBlockOmega(); emit Securized(epoch, epochLen, blockMeta, inflateRatio); }
32,576
56
// update publisher data
if (vars.subscriptionExists && vars.sdata.subId != _UNALLOCATED_SUB_ID) {
if (vars.subscriptionExists && vars.sdata.subId != _UNALLOCATED_SUB_ID) {
4,571
138
// -MSFun- v0.2.4┌┬┐┌─┐┌─┐┌┬┐ ╦╦ ╦╔═╗╔╦╗┌─┐┬─┐┌─┐┌─┐┌─┐┌┐┌┌┬┐┌─┐ │ ├┤ ├─┤│││ ║║ ║╚═╗ ║ ├─┘├┬┘├┤ └─┐├┤ │││ │ └─┐ ┴ └─┘┴ ┴┴ ┴╚╝╚═╝╚═╝ ╩ ┴┴└─└─┘└─┘└─┘┘└┘ ┴ └─┘ __________(, / /) /) /)(, //)/) ├─┤___/___(/_/(__(_/_(/_(/_ ___/__/_)_(/_(_(_/ (_(_(_ ┴ ┴/ /.-/ _____ (__ /(__ /(_/ (, //)™ /____ __ ___ __ ____/_ __(/┌─┐┬─┐┌─┐┌┬┐┬ ┬┌─┐┌┬┐/__/ (_(__(_)/ (_/_)_(_)/ (_(_(_(__(/_(_(_├─┘├┬┘│ │ │││ ││ │(__ /.-/© Jekyll Island Inc. 2018┴┴└─└─┘─┴┘└─┘└─┘ ┴(_/ _ _ ____ _____ =(_) _ _ (_)==========_(_)(_)(_)(_)_==========(_)(_)(_)(_)(_)================================(_)(_) (_)(_) (_)(_) (_) _ _____ (_) (_)_(_) (_) (_)____(_) __ (_) (_)(_)(_)(_)(_)_ (_) (_) (_) (_)(_)(_)(_)_(_)(_)(_)(_) (_)(_)(_)(_) (_)___ (_)__ (_)(_) (_)(_)(_)__ =(_)=========(_)=(_)(_)==(_)____(_)=(_)(_)==(_)======(_)___(_)_ (_)========(_)=(_)(_)==(_) (_) (_)(_)(_)(_)(_)(_) (_)(_)(_)(_)(_)(_) (_)(_)(_) (_)(_) ╔═╗┌─┐┌┐┌┌┬┐┬─┐┌─┐┌─┐┌┬┐╔═╗┌─┐┌┬┐┌─┐ ┌──────────┐║│ ││││
* { * if (MSFun.multiSig(msData, required signatures, "functionName") == true) * { * MSFun.deleteProposal(msData, "functionName"); * * // put function body here * } * }
* { * if (MSFun.multiSig(msData, required signatures, "functionName") == true) * { * MSFun.deleteProposal(msData, "functionName"); * * // put function body here * } * }
52,748
13
// Unstaking Tokens (Withdraw)
function unstakeTokens() public { // Fetch staking balance uint balance = stakingBalance[msg.sender]; // Require amount greater than 0 require(balance > 0, "staking balance cannot be 0"); // Transfer Auf tokens to this contract for staking ERC20Interface(ibyAddress).transfer(msg.sender, balance); // Reset staking balance stakingBalance[msg.sender] = 0; // Update staking status isStaking[msg.sender] = false; }
function unstakeTokens() public { // Fetch staking balance uint balance = stakingBalance[msg.sender]; // Require amount greater than 0 require(balance > 0, "staking balance cannot be 0"); // Transfer Auf tokens to this contract for staking ERC20Interface(ibyAddress).transfer(msg.sender, balance); // Reset staking balance stakingBalance[msg.sender] = 0; // Update staking status isStaking[msg.sender] = false; }
44,888
276
// Join by swapping an external token in (must be present in the pool)To receive an exact amount of pool tokens out. System calculates the deposit amount emits a LogJoin event tokenIn - which token we're transferring in (system calculates amount required) poolAmountOut - amount of pool tokens to be received maxAmountIn - Maximum asset tokens that can be pulled to pay for the pool tokensreturn tokenAmountIn - amount of asset tokens transferred in to purchase the pool tokens /
function joinswapPoolAmountOut( address tokenIn, uint poolAmountOut, uint maxAmountIn ) external logs lock needsBPool returns (uint tokenAmountIn)
function joinswapPoolAmountOut( address tokenIn, uint poolAmountOut, uint maxAmountIn ) external logs lock needsBPool returns (uint tokenAmountIn)
30,806
156
// Modifiers:
modifier onlyRegisteredScheme() { require(schemes[msg.sender].permissions&bytes4(0x00000001) == bytes4(0x00000001)); _; }
modifier onlyRegisteredScheme() { require(schemes[msg.sender].permissions&bytes4(0x00000001) == bytes4(0x00000001)); _; }
34,019
6
// import files from common directory
import { TokenInterface , MemoryInterface } from "../../../common/interfaces.sol"; import { Stores } from "../../../common/stores.sol"; import { OneInchInterace, OneInchData } from "./interface.sol"; import { Helpers } from "./helpers.sol"; import { Events } from "./events.sol"; abstract contract OneInchResolver is Helpers, Events { /** * @dev 1inch swap uses `.call()`. This function restrict it to call only swap/trade functionality * @param callData - calldata to extract the first 4 bytes for checking function signature */ function checkOneInchSig(bytes memory callData) internal pure returns(bool isOk) { bytes memory _data = callData; bytes4 sig; // solium-disable-next-line security/no-inline-assembly assembly { sig := mload(add(_data, 32)) } isOk = sig == oneInchSwapSig || sig == oneInchUnoswapSig; } /** * @dev 1inch API swap handler * @param oneInchData - contains data returned from 1inch API. Struct defined in interfaces.sol * @param ethAmt - Eth to swap for .value() */ function oneInchSwap( OneInchData memory oneInchData, uint ethAmt ) internal returns (uint buyAmt) { TokenInterface buyToken = oneInchData.buyToken; (uint _buyDec, uint _sellDec) = getTokensDec(buyToken, oneInchData.sellToken); uint _sellAmt18 = convertTo18(_sellDec, oneInchData._sellAmt); uint _slippageAmt = convert18ToDec(_buyDec, wmul(oneInchData.unitAmt, _sellAmt18)); uint initalBal = getTokenBal(buyToken); // solium-disable-next-line security/no-call-value (bool success, ) = oneInchAddr.call{value: ethAmt}(oneInchData.callData); if (!success) revert("1Inch-swap-failed"); uint finalBal = getTokenBal(buyToken); buyAmt = sub(finalBal, initalBal); require(_slippageAmt <= buyAmt, "Too much slippage"); } }
import { TokenInterface , MemoryInterface } from "../../../common/interfaces.sol"; import { Stores } from "../../../common/stores.sol"; import { OneInchInterace, OneInchData } from "./interface.sol"; import { Helpers } from "./helpers.sol"; import { Events } from "./events.sol"; abstract contract OneInchResolver is Helpers, Events { /** * @dev 1inch swap uses `.call()`. This function restrict it to call only swap/trade functionality * @param callData - calldata to extract the first 4 bytes for checking function signature */ function checkOneInchSig(bytes memory callData) internal pure returns(bool isOk) { bytes memory _data = callData; bytes4 sig; // solium-disable-next-line security/no-inline-assembly assembly { sig := mload(add(_data, 32)) } isOk = sig == oneInchSwapSig || sig == oneInchUnoswapSig; } /** * @dev 1inch API swap handler * @param oneInchData - contains data returned from 1inch API. Struct defined in interfaces.sol * @param ethAmt - Eth to swap for .value() */ function oneInchSwap( OneInchData memory oneInchData, uint ethAmt ) internal returns (uint buyAmt) { TokenInterface buyToken = oneInchData.buyToken; (uint _buyDec, uint _sellDec) = getTokensDec(buyToken, oneInchData.sellToken); uint _sellAmt18 = convertTo18(_sellDec, oneInchData._sellAmt); uint _slippageAmt = convert18ToDec(_buyDec, wmul(oneInchData.unitAmt, _sellAmt18)); uint initalBal = getTokenBal(buyToken); // solium-disable-next-line security/no-call-value (bool success, ) = oneInchAddr.call{value: ethAmt}(oneInchData.callData); if (!success) revert("1Inch-swap-failed"); uint finalBal = getTokenBal(buyToken); buyAmt = sub(finalBal, initalBal); require(_slippageAmt <= buyAmt, "Too much slippage"); } }
19,857
9
// Get the number of pixel-locked tokens. /
function lockedTokensOf(address _holder) public view returns (uint16) { return locked[_holder]; }
function lockedTokensOf(address _holder) public view returns (uint16) { return locked[_holder]; }
24,153
210
// send a request to delegate governance rights for the amount to delegator
MPOND.delegate( _delegator, uint96(_amount) );
MPOND.delegate( _delegator, uint96(_amount) );
14,218
6
// We assume that asset being bought by taker is the same for each order. We assume that asset being sold by taker is WETH for each order.
orders[i].makerAssetData = makerAssetData; orders[i].takerAssetData = wethAssetData;
orders[i].makerAssetData = makerAssetData; orders[i].takerAssetData = wethAssetData;
47,167
52
// Gets whether the contract is still in the intial grace period where we give extra features to color setters
function isInGracePeriod() public view returns(bool) { return now <= GRACE_PERIOD_END_TIMESTAMP; }
function isInGracePeriod() public view returns(bool) { return now <= GRACE_PERIOD_END_TIMESTAMP; }
41,956
24
// good to go. good gateway
}else{
}else{
46,341
21
// Airdrop tokens to multiple addresses _recipients: The addresses of the recipients _values: The amounts of tokens to be airdropped /
function bulkAirdrop(address[] memory _recipients, uint256[] memory _values) public onlyOwner { uint256 totalValues = 0; if (_recipients.length != _values.length) revert InvalidArrayLength(); if (_recipients.length > 100) revert ExceedsArrayLimit(); for (uint256 i = 0; i < _values.length; i++) { totalValues += _values[i]; } if (totalValues > airdropTokens) revert InsufficientAirdropTokens(); for (uint256 i = 0; i < _recipients.length; i++) { airdropTokens -= _values[i]; super._transfer(address(this), _recipients[i], _values[i]); } }
function bulkAirdrop(address[] memory _recipients, uint256[] memory _values) public onlyOwner { uint256 totalValues = 0; if (_recipients.length != _values.length) revert InvalidArrayLength(); if (_recipients.length > 100) revert ExceedsArrayLimit(); for (uint256 i = 0; i < _values.length; i++) { totalValues += _values[i]; } if (totalValues > airdropTokens) revert InsufficientAirdropTokens(); for (uint256 i = 0; i < _recipients.length; i++) { airdropTokens -= _values[i]; super._transfer(address(this), _recipients[i], _values[i]); } }
19,883
38
// buy 1 NFT with (price) FT [NFT][FT]
dex.balance[orderBid.trader][ft] = dex.balance[orderBid.trader][ft].sub(price); dex.nftokens[nft].owner[tokenId] = orderBid.trader;
dex.balance[orderBid.trader][ft] = dex.balance[orderBid.trader][ft].sub(price); dex.nftokens[nft].owner[tokenId] = orderBid.trader;
6,796
0
// Interface for the Lido liquid staking pool niklr Interface with minimal functions needed by a Lido adapter implementation /
interface ILidoDeposit { /** * @return the amount of shares that corresponds to `_ethAmount` protocol-controlled Ether. */ function getSharesByPooledEth(uint256 _ethAmount) external view returns (uint256); /** * @return the amount of Ether that corresponds to `_sharesAmount` token shares. */ function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256); /** * @notice Adds eth to the pool * @return StETH Amount of StETH generated */ // solhint-disable-next-line var-name-mixedcase function submit(address _referral) external payable returns (uint256 StETH); /** * @return the entire amount of Ether controlled by the protocol. * * @dev The sum of all ETH balances in the protocol, equals to the total supply of stETH. */ function getTotalPooledEther() external view returns (uint256); /** * @return the total amount of shares in existence. * * @dev The sum of all accounts' shares can be an arbitrary number, therefore * it is necessary to store it in order to calculate each account's relative share. */ function getTotalShares() external view returns (uint256); /** * @return the remaining number of tokens that `_spender` is allowed to spend * on behalf of `_owner` through `transferFrom`. This is zero by default. * * @dev This value changes when `approve` or `transferFrom` is called. */ function allowance(address _owner, address _spender) external view returns (uint256); /** * @return the amount of shares owned by `_account`. */ function sharesOf(address _account) external view returns (uint256); }
interface ILidoDeposit { /** * @return the amount of shares that corresponds to `_ethAmount` protocol-controlled Ether. */ function getSharesByPooledEth(uint256 _ethAmount) external view returns (uint256); /** * @return the amount of Ether that corresponds to `_sharesAmount` token shares. */ function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256); /** * @notice Adds eth to the pool * @return StETH Amount of StETH generated */ // solhint-disable-next-line var-name-mixedcase function submit(address _referral) external payable returns (uint256 StETH); /** * @return the entire amount of Ether controlled by the protocol. * * @dev The sum of all ETH balances in the protocol, equals to the total supply of stETH. */ function getTotalPooledEther() external view returns (uint256); /** * @return the total amount of shares in existence. * * @dev The sum of all accounts' shares can be an arbitrary number, therefore * it is necessary to store it in order to calculate each account's relative share. */ function getTotalShares() external view returns (uint256); /** * @return the remaining number of tokens that `_spender` is allowed to spend * on behalf of `_owner` through `transferFrom`. This is zero by default. * * @dev This value changes when `approve` or `transferFrom` is called. */ function allowance(address _owner, address _spender) external view returns (uint256); /** * @return the amount of shares owned by `_account`. */ function sharesOf(address _account) external view returns (uint256); }
6,346
187
// 50% Frst 100 NFTs
if(totalCollected<100) { buyPrice = tokenPrice/2; }
if(totalCollected<100) { buyPrice = tokenPrice/2; }
44,779
3
// claims ownership of the contractCan only be called by the new proposed owner. /
function claimOwnership() external { require(msg.sender == proposedOwner); emit OwnershipTransferred(owner, proposedOwner); owner = proposedOwner; }
function claimOwnership() external { require(msg.sender == proposedOwner); emit OwnershipTransferred(owner, proposedOwner); owner = proposedOwner; }
12,849
0
// A wrapping contract to get a contract in node_module compiled by HardHat. /
contract WindRangerVotesOracle is VotesOracle { constructor() {} }
contract WindRangerVotesOracle is VotesOracle { constructor() {} }
42,455
0
// To track protocol fees, we measure and store the value of the invariant after every join and exit. All invariant growth that happens between join and exit events is due to swap fees and yield. For selected tokens, we exclude the yield portion from the computation. Because the invariant depends on the amplification parameter, and this value may change over time, we should only compare invariants that were computed using the same value. We therefore store both values together. These values reside in the same storage slot. The amplification factor is bound by _MAX_AMP_AMP_PRECISION, or 5e6, which fits in 23
bytes32 private _lastJoinExitData; uint256 private constant _LAST_POST_JOIN_EXIT_INVARIANT_OFFSET = 0; uint256 private constant _LAST_POST_JOIN_EXIT_INVARIANT_SIZE = 233; uint256 private constant _LAST_JOIN_EXIT_AMPLIFICATION_OFFSET = _LAST_POST_JOIN_EXIT_INVARIANT_OFFSET + _LAST_POST_JOIN_EXIT_INVARIANT_SIZE; uint256 private constant _LAST_JOIN_EXIT_AMPLIFICATION_SIZE = 23;
bytes32 private _lastJoinExitData; uint256 private constant _LAST_POST_JOIN_EXIT_INVARIANT_OFFSET = 0; uint256 private constant _LAST_POST_JOIN_EXIT_INVARIANT_SIZE = 233; uint256 private constant _LAST_JOIN_EXIT_AMPLIFICATION_OFFSET = _LAST_POST_JOIN_EXIT_INVARIANT_OFFSET + _LAST_POST_JOIN_EXIT_INVARIANT_SIZE; uint256 private constant _LAST_JOIN_EXIT_AMPLIFICATION_SIZE = 23;
21,626
82
// Solidity already throws when dividing by 0.
return a / b;
return a / b;
30,810
153
// ==========Events========== // ==========Controls========== // Allows `deployer` to deploy many-to-one proxies. /
function approveDeployer(address deployer) external;
function approveDeployer(address deployer) external;
42,566
267
// Keep track off fees in sUSD in the open fee pool period.
_recentFeePeriodsStorage(0).feesToDistribute = _recentFeePeriodsStorage(0).feesToDistribute.add(amount);
_recentFeePeriodsStorage(0).feesToDistribute = _recentFeePeriodsStorage(0).feesToDistribute.add(amount);
4,758
22
// Return a list of all validator ids in the system.
function getValidatorIds() external view returns (uint256[] memory);
function getValidatorIds() external view returns (uint256[] memory);
31,988
50
// Returns to normal state.Requirements: The contract must be paused. /
function unpause() public onlyOwner { _unpause(); }
function unpause() public onlyOwner { _unpause(); }
43,685
30
// Should allow any address to trigger it, but since the calls are atomic it should do only once per day /
function triggerTokenSend() public whenNotPaused { //inject PUBLIC FUNC TO EXTERNAL /* Require TGE Date already been set */ require(TGEDate != 0, "TGE date not set yet"); /* TGE has not started */ require(block.timestamp > TGEDate, "TGE still has not started"); /* Test that the call be only done once per day */ require(block.timestamp.sub(lastDateDistribution) > 1 days, "Can only be called once a day"); lastDateDistribution = block.timestamp; /* Go thru all tokenOwners */ for(uint i = 0; i < tokenOwners.length; i++) { /* Get Address Distribution */ DistributionStep[] memory d = distributions[tokenOwners[i]]; /* Go thru all distributions array */ for(uint j = 0; j < d.length; j++){ if( (block.timestamp.sub(TGEDate) > d[j].unlockDay) /* Verify if unlockDay has passed */ && (d[j].currentAllocated > 0) /* Verify if currentAllocated > 0, so that address has tokens to be sent still */ ){ uint256 sendingAmount; sendingAmount = d[j].currentAllocated; distributions[tokenOwners[i]][j].currentAllocated = distributions[tokenOwners[i]][j].currentAllocated.sub(sendingAmount); distributions[tokenOwners[i]][j].amountSent = distributions[tokenOwners[i]][j].amountSent.add(sendingAmount); require(erc20.transfer(tokenOwners[i], sendingAmount)); } } } }
function triggerTokenSend() public whenNotPaused { //inject PUBLIC FUNC TO EXTERNAL /* Require TGE Date already been set */ require(TGEDate != 0, "TGE date not set yet"); /* TGE has not started */ require(block.timestamp > TGEDate, "TGE still has not started"); /* Test that the call be only done once per day */ require(block.timestamp.sub(lastDateDistribution) > 1 days, "Can only be called once a day"); lastDateDistribution = block.timestamp; /* Go thru all tokenOwners */ for(uint i = 0; i < tokenOwners.length; i++) { /* Get Address Distribution */ DistributionStep[] memory d = distributions[tokenOwners[i]]; /* Go thru all distributions array */ for(uint j = 0; j < d.length; j++){ if( (block.timestamp.sub(TGEDate) > d[j].unlockDay) /* Verify if unlockDay has passed */ && (d[j].currentAllocated > 0) /* Verify if currentAllocated > 0, so that address has tokens to be sent still */ ){ uint256 sendingAmount; sendingAmount = d[j].currentAllocated; distributions[tokenOwners[i]][j].currentAllocated = distributions[tokenOwners[i]][j].currentAllocated.sub(sendingAmount); distributions[tokenOwners[i]][j].amountSent = distributions[tokenOwners[i]][j].amountSent.add(sendingAmount); require(erc20.transfer(tokenOwners[i], sendingAmount)); } } } }
41,169
3
// Returns the current contract pause status, as well as the end times of the Pause Window and BufferPeriod. /
function getPausedState() external view override returns ( bool paused, uint256 pauseWindowEndTime, uint256 bufferPeriodEndTime )
function getPausedState() external view override returns ( bool paused, uint256 pauseWindowEndTime, uint256 bufferPeriodEndTime )
19,097
21
// Assign indexes for each hexagon.
for (uint8 j; j < hexagonsInRow; ) { uint8 xIndex = (grid.rows - hexagonsInRow) + (j * 2); grid.hexagonsSvg = getUpdatedHexagonsSvg(grid, xIndex, i, i + 1); unchecked { ++j; }
for (uint8 j; j < hexagonsInRow; ) { uint8 xIndex = (grid.rows - hexagonsInRow) + (j * 2); grid.hexagonsSvg = getUpdatedHexagonsSvg(grid, xIndex, i, i + 1); unchecked { ++j; }
3,171
0
// Proxy for ACoconut Maker. /
contract ACoconutMakerProxy is TransparentUpgradeableProxy { constructor(address _logic, address _admin, bytes memory _data) TransparentUpgradeableProxy(_logic, _admin, _data) payable {} }
contract ACoconutMakerProxy is TransparentUpgradeableProxy { constructor(address _logic, address _admin, bytes memory _data) TransparentUpgradeableProxy(_logic, _admin, _data) payable {} }
37,996
24
// We take the last two digits of the year Hopefully that's enough
{ uint256 lastDigits = year % 100;
{ uint256 lastDigits = year % 100;
9,666
177
// public getters/Calculates the token price (WEI per GTX) at the given block number/_bidBlock is the block number/ return Returns the token price - Wei per GTX
function calcTokenPrice(uint256 _bidBlock) public view returns(uint256){ require(_bidBlock >= startBlock && _bidBlock <= endBlock, "pricing only given in the range of startBlock and endBlock"); uint256 currentBlock = _bidBlock.sub(startBlock); uint256 decay = (currentBlock ** 3).div(priceConstant); return ceiling.mul(currentBlock.add(1)).div(currentBlock.add(decay).add(1)); }
function calcTokenPrice(uint256 _bidBlock) public view returns(uint256){ require(_bidBlock >= startBlock && _bidBlock <= endBlock, "pricing only given in the range of startBlock and endBlock"); uint256 currentBlock = _bidBlock.sub(startBlock); uint256 decay = (currentBlock ** 3).div(priceConstant); return ceiling.mul(currentBlock.add(1)).div(currentBlock.add(decay).add(1)); }
37,246
13
// Parse a GovernanceInstruction
function parseGovernanceInstruction( bytes memory encodedInstruction
function parseGovernanceInstruction( bytes memory encodedInstruction
25,425
11
// torso
TIERS[4] = [4090, 1750, 1750, 500, 500, 500, 500, 200, 200, 10];
TIERS[4] = [4090, 1750, 1750, 500, 500, 500, 500, 200, 200, 10];
45,563
0
// Fired when LVRJ is exchanged for Dai /
event ContinuousBurn( address _address, uint256 continuousTokenAmount, uint256 reserveTokenAmount );
event ContinuousBurn( address _address, uint256 continuousTokenAmount, uint256 reserveTokenAmount );
23,575
28
// lock up to and including _lock blocknumber
function setLock(uint256 _lock) external override protectedCall { LibBasketStorage.basketStorage().lockBlock = _lock; emit LockSet(_lock); }
function setLock(uint256 _lock) external override protectedCall { LibBasketStorage.basketStorage().lockBlock = _lock; emit LockSet(_lock); }
30,790
51
// ======== DEPENDENCIES ======== // ======== STATE VARIABLS ======== // ======== EVENTS ======== // ======== CONSTRUCTOR ======== /
constructor(address _payoutToken, address _initialOwner) { require( _payoutToken != address(0) ); payoutToken = _payoutToken; require( _initialOwner != address(0) ); policy = _initialOwner; }
constructor(address _payoutToken, address _initialOwner) { require( _payoutToken != address(0) ); payoutToken = _payoutToken; require( _initialOwner != address(0) ); policy = _initialOwner; }
10,612
269
// get all votes in all blockchains including delegated
Proposal storage proposal = proposals[proposalId]; uint256 votes = rep.getVotesAt(_msgSender(), true, proposal.startBlock); return _castVote(_msgSender(), proposal, support, votes);
Proposal storage proposal = proposals[proposalId]; uint256 votes = rep.getVotesAt(_msgSender(), true, proposal.startBlock); return _castVote(_msgSender(), proposal, support, votes);
22,762
34
// Get hold of the absolute values of x, y and the denominator.
uint256 ax; uint256 ay; uint256 ad; unchecked { ax = x < 0 ? uint256(-x) : uint256(x); ay = y < 0 ? uint256(-y) : uint256(y); ad = denominator < 0 ? uint256(-denominator) : uint256(denominator); }
uint256 ax; uint256 ay; uint256 ad; unchecked { ax = x < 0 ? uint256(-x) : uint256(x); ay = y < 0 ? uint256(-y) : uint256(y); ad = denominator < 0 ? uint256(-denominator) : uint256(denominator); }
4,712
153
// Prevent further deposits.
if (_status != Status.ACTIVATED) { _status = Status.ACTIVATED; }
if (_status != Status.ACTIVATED) { _status = Status.ACTIVATED; }
49,021
85
// src/IUniswapV2Router02.sol/ pragma solidity 0.8.10; // pragma experimental ABIEncoderV2; /
interface IUniswapV2Router02 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; }
interface IUniswapV2Router02 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; }
993
684
// Checks if msg.sender is proposal owner/
modifier onlyProposalOwner(uint _proposalId) { require(msg.sender == allProposalData[_proposalId].owner, "Not allowed"); _; }
modifier onlyProposalOwner(uint _proposalId) { require(msg.sender == allProposalData[_proposalId].owner, "Not allowed"); _; }
54,796
30
// The maximum amount can be withdrown from market.
_balance = IHandler(_handlers[i]).getRealLiquidity(_token); _amounts[i] = _balance > _res ? _res : _balance; _res = _res.sub(_amounts[i]);
_balance = IHandler(_handlers[i]).getRealLiquidity(_token); _amounts[i] = _balance > _res ? _res : _balance; _res = _res.sub(_amounts[i]);
26,135
15
// 19% chance
reward = 8 ether;
reward = 8 ether;
27,218
79
// Setup the DebtTokenCache for a given tokenUpdate storage if and only if the timestamp has changed since last time. /
function _debtTokenCache() internal returns ( DebtTokenCache memory cache
function _debtTokenCache() internal returns ( DebtTokenCache memory cache
40,852
11
// Reset the limits for the next game.
highestBid = 0; lowestBid = deadline*2;
highestBid = 0; lowestBid = deadline*2;
20,432
45
// Calculate the share of a condition in an oracle's market./_oracleId The oracle ID./ return Uses `ABDKMath64x64` number ID.
function _calcRewardShare(uint64 _oracleId, uint256 _condition) internal virtual view returns (int128);
function _calcRewardShare(uint64 _oracleId, uint256 _condition) internal virtual view returns (int128);
17,715
1,155
// Gets token data for a particular currency id, if underlying is set to true then returns/ the underlying token. (These may not always exist)
function _getToken(uint256 currencyId, bool underlying) private view returns (Token memory) { mapping(uint256 => mapping(bool => TokenStorage)) storage store = LibStorage.getTokenStorage(); TokenStorage storage tokenStorage = store[currencyId][underlying]; return Token({ tokenAddress: tokenStorage.tokenAddress, hasTransferFee: tokenStorage.hasTransferFee, // No overflow, restricted on storage decimals: int256(10**tokenStorage.decimalPlaces), tokenType: tokenStorage.tokenType, maxCollateralBalance: tokenStorage.maxCollateralBalance }); }
function _getToken(uint256 currencyId, bool underlying) private view returns (Token memory) { mapping(uint256 => mapping(bool => TokenStorage)) storage store = LibStorage.getTokenStorage(); TokenStorage storage tokenStorage = store[currencyId][underlying]; return Token({ tokenAddress: tokenStorage.tokenAddress, hasTransferFee: tokenStorage.hasTransferFee, // No overflow, restricted on storage decimals: int256(10**tokenStorage.decimalPlaces), tokenType: tokenStorage.tokenType, maxCollateralBalance: tokenStorage.maxCollateralBalance }); }
4,140