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
172
// if assets are greater than debt, things are working great! loss will be 0 by default
if (assets > debt) { _profit = _balanceOfWant(); } else {
if (assets > debt) { _profit = _balanceOfWant(); } else {
31,711
80
// multiplied by 10000
uint8 dogecity; uint8 bonus; uint8 tokenLPBurn; uint8 inflate; uint8 buyCounter; uint8 tx; uint8 dogeitpayout; uint256 dogeify;
uint8 dogecity; uint8 bonus; uint8 tokenLPBurn; uint8 inflate; uint8 buyCounter; uint8 tx; uint8 dogeitpayout; uint256 dogeify;
49,257
52
// See {ERC20-approve}. Requirements: - `spender` cannot be the zero address. /
function approve(address spender, uint256 amount) external override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
function approve(address spender, uint256 amount) external override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
38,092
25
// Cast a vote with a reason Emits a {VoteCast} event. /
function castVoteWithReason(
function castVoteWithReason(
6,582
14
// Public set migration manager administrative functions /
function tokenSetMigrationManager(address _token, address _mgr) public ownerExists(msg.sender)
function tokenSetMigrationManager(address _token, address _mgr) public ownerExists(msg.sender)
41,493
8
// This technically doesn't work with all ERC20s The decimals method is optional, hence the custom interface That said, it is in almost every ERC20, a requirement for this, and needed for feasible operations with wrapped coins
uint256 decimals = IDecimals(currency).decimals(); if (decimals <= DECIMAL_ACCURACY) { return 1; }
uint256 decimals = IDecimals(currency).decimals(); if (decimals <= DECIMAL_ACCURACY) { return 1; }
9,355
33
// reputationBalance[candidate] -= candidateReputation;
reputationBalance[candidate] = reputationBalance[candidate].sub(candidateReputation); delegatedReputation[_delegate].distributedReputation[candidate] = 0;
reputationBalance[candidate] = reputationBalance[candidate].sub(candidateReputation); delegatedReputation[_delegate].distributedReputation[candidate] = 0;
18,148
264
// Calculate the amount of shares to issue with the investment amount
uint256 sharePrice = __calcGrossShareValue( gav, ERC20(vaultProxyCopy).totalSupply(), 10**uint256(ERC20(getDenominationAsset()).decimals()) ); uint256 sharesIssued = receivedInvestmentAmount.mul(SHARES_UNIT).div(sharePrice);
uint256 sharePrice = __calcGrossShareValue( gav, ERC20(vaultProxyCopy).totalSupply(), 10**uint256(ERC20(getDenominationAsset()).decimals()) ); uint256 sharesIssued = receivedInvestmentAmount.mul(SHARES_UNIT).div(sharePrice);
38,743
21
// Fills margin limit orders.
function fillMarginOrder(FillMarginOrderArgs calldata args) external returns (uint256 principalAmount, uint256 collateralAmount);
function fillMarginOrder(FillMarginOrderArgs calldata args) external returns (uint256 principalAmount, uint256 collateralAmount);
2,697
43
// Returns the address associated to a user-id _uid The user-id /
function getAddress( string _uid ) external constant returns (address)
function getAddress( string _uid ) external constant returns (address)
48,839
8
// Remove erc-20 token from whitelist
function removeTokensFromWhitelist(address[] memory tokens) external onlyOwner
function removeTokensFromWhitelist(address[] memory tokens) external onlyOwner
38,489
499
// Sets the `implementer` contract as ``account``'s implementer for`interfaceHash`. `account` being the zero address is an alias for the caller's address.The zero address can also be used in `implementer` to remove an old one. See {interfaceHash} to learn how these are created. Emits an {InterfaceImplementerSet} event. Requirements: - the caller must be the current manager for `account`.- `interfaceHash` must not be an {IERC165} interface id (i.e. it must notend in 28 zeroes).- `implementer` must implement {IERC1820Implementer} and return true whenqueried for support, unless `implementer` is the caller. See{IERC1820Implementer-canImplementInterfaceForAddress}. /
function setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer) external;
function setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer) external;
16,529
510
// transferPoint(): transfer _point to _target, clearing all permissions data and keys if _reset is trueNote: the _reset flag is useful when transferring the point toa recipient who doesn't trust the previous owner.Requirements:- :msg.sender must be either _point's current owner, authorizedto transfer _point, or authorized to transfer the currentowner's points (as in ERC721's operator)- _target must not be the zero address
function transferPoint(uint32 _point, address _target, bool _reset) public
function transferPoint(uint32 _point, address _target, bool _reset) public
15,029
213
// Helper to set config and enable policies for a fund
function __enablePolicyForFund( address _comptrollerProxy, address _policy, bytes memory _settingsData
function __enablePolicyForFund( address _comptrollerProxy, address _policy, bytes memory _settingsData
44,059
34
// 获取价格
function getprice() public view returns(uint256 bprice, uint256 spice, uint256 sprice, uint256 sper) { bprice = buyPrice; spice = sellPrice; sprice = sysPrice; sper = sysPer; }
function getprice() public view returns(uint256 bprice, uint256 spice, uint256 sprice, uint256 sper) { bprice = buyPrice; spice = sellPrice; sprice = sysPrice; sper = sysPer; }
77,447
28
// Amount of wei raised
uint256 private _weiRaised;
uint256 private _weiRaised;
777
48
// Update system snapshots
_updateSystemSnapshots_excludeCollRemainder(contractsCache.activePool, totals.totalCollGasCompensation); vars.liquidatedDebt = totals.totalDebtInSequence; vars.liquidatedColl = totals.totalCollInSequence.sub(totals.totalCollGasCompensation).sub(totals.totalCollSurplus); emit Liquidation(vars.liquidatedDebt, vars.liquidatedColl, totals.totalCollGasCompensation, totals.totalLUSDGasCompensation);
_updateSystemSnapshots_excludeCollRemainder(contractsCache.activePool, totals.totalCollGasCompensation); vars.liquidatedDebt = totals.totalDebtInSequence; vars.liquidatedColl = totals.totalCollInSequence.sub(totals.totalCollGasCompensation).sub(totals.totalCollSurplus); emit Liquidation(vars.liquidatedDebt, vars.liquidatedColl, totals.totalCollGasCompensation, totals.totalLUSDGasCompensation);
9,105
6
// Reverts if called by anyone other than the contract owner./
modifier onlyOwner() { require(msg.sender == ownerAddr, "Only callable by owner"); _; }
modifier onlyOwner() { require(msg.sender == ownerAddr, "Only callable by owner"); _; }
24,958
146
// Internal function to invoke `onTransferReceived` on a target address The call is not executed if the target address is not a contract from address Representing the previous owner of the given token value to address Target address that will receive the tokens value uint256 The amount mount of tokens to be transferred data bytes Optional data to send along with the callreturn whether the call correctly returned the expected magic value /
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) { if (!to.isContract()) { return false; } bytes4 retval = IERC1363Receiver(to).onTransferReceived( _msgSender(), from, value, data ); return (retval == _ERC1363_RECEIVED); }
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) { if (!to.isContract()) { return false; } bytes4 retval = IERC1363Receiver(to).onTransferReceived( _msgSender(), from, value, data ); return (retval == _ERC1363_RECEIVED); }
2,061
227
// helper, dispatches the Conversion event _fromToken ERC20 token to convert from_toToken ERC20 token to convert to_amountamount purchased/sold (in the source token)_returnAmountamount returned (in the target token)/
function dispatchConversionEvent(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _returnAmount, uint256 _feeAmount) private { // fee amount is converted to 255 bits - // negative amount means the fee is taken from the source token, positive amount means its taken from the target token // currently the fee is always taken from the target token // since we convert it to a signed number, we first ensure that it's capped at 255 bits to prevent overflow assert(_feeAmount < 2 ** 255); emit Conversion(_fromToken, _toToken, msg.sender, _amount, _returnAmount, int256(_feeAmount)); }
function dispatchConversionEvent(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _returnAmount, uint256 _feeAmount) private { // fee amount is converted to 255 bits - // negative amount means the fee is taken from the source token, positive amount means its taken from the target token // currently the fee is always taken from the target token // since we convert it to a signed number, we first ensure that it's capped at 255 bits to prevent overflow assert(_feeAmount < 2 ** 255); emit Conversion(_fromToken, _toToken, msg.sender, _amount, _returnAmount, int256(_feeAmount)); }
23,776
62
// Set or reaffirm the approved address for an NFT. This function can be changed to payable. The zero address indicates there is no approved address. Throws unless `msg.sender` isthe current NFT owner, or an authorized operator of the current owner. _approved Address to be approved for the given NFT ID. _tokenId ID of the token to be approved. /
function approve(address _approved, uint256 _tokenId) external override canOperate(_tokenId) validNFToken(_tokenId)
function approve(address _approved, uint256 _tokenId) external override canOperate(_tokenId) validNFToken(_tokenId)
5,336
44
// @PapyChancla
newUser.userShare = 3000; newUser.userAddress = 0x8AE18353fFA561be14f5c6012BF53C194dFDFAA7; user.push(newUser);
newUser.userShare = 3000; newUser.userAddress = 0x8AE18353fFA561be14f5c6012BF53C194dFDFAA7; user.push(newUser);
13,104
3
// Adding or promoting an address on the registry. An address(record) to add or promote can be organization address or any contract address. Adding a record is done by paying at least the minimum required by the registry params. Promoting a record is done by paying(adding)amount of token to the registry beneficiary. _avatar The _avatar of the organization which own the registry. _record The address to add or promote. _amount amount to pay for adding or promoting /
function addOrPromoteAddress(Avatar _avatar, address _record, uint256 _amount) public
function addOrPromoteAddress(Avatar _avatar, address _record, uint256 _amount) public
5,666
9
// Update buffer length if we're extending it
if gt(newCapacity, buflen) { mstore(bufptr, newCapacity) }
if gt(newCapacity, buflen) { mstore(bufptr, newCapacity) }
32,021
6
// Mapping of token ID to player traits
mapping(uint16 => Traits) private tokenTraits;
mapping(uint16 => Traits) private tokenTraits;
26,175
109
// _summoner,
_shaman, _approvedTokens, _periodDuration, _votingPeriodLength, _gracePeriodLength, _proposalDeposit, _dilutionBound, _processingReward );
_shaman, _approvedTokens, _periodDuration, _votingPeriodLength, _gracePeriodLength, _proposalDeposit, _dilutionBound, _processingReward );
7,617
40
// Buys NFT from a trading pool by depositing WETH and specifying the NFT ids and maximum price to pay./pool The address of the trading pool./nftIds The array of NFT ids to buy./maximumPrice The maximum amount of ETH to pay for the purchase.
function buy( address pool, uint256[] calldata nftIds, uint256 maximumPrice
function buy( address pool, uint256[] calldata nftIds, uint256 maximumPrice
7,677
408
// ========================= Public Parameter Getter ===========================
function rewardToken() external view returns (IERC20);
function rewardToken() external view returns (IERC20);
31,179
3
// Deploy a new ERC20 bond token for an (underlying, expiry) pair and return its address/ ERC20 used for fixed-expiry/ If a bond token exists for the (underlying, expiry) pair, it returns that address/underlying_ERC20 token redeemable when the bond token vests/expiry_Timestamp at which the bond token can be redeemed for the underlying token/ return Address of the ERC20 bond token being created
function deploy(ERC20 underlying_, uint48 expiry_) external returns (ERC20BondToken);
function deploy(ERC20 underlying_, uint48 expiry_) external returns (ERC20BondToken);
5,611
53
// Private //Computes the Realitio answerer, of a specified question, that should win. This function is needed to avoid the "stack too deep error"._questionID The ID of the question._lastAnswerOrCommitmentID The last answer given, or its commitment ID if it was a commitment, to the question in the Realitio contract._lastBond The bond paid for the last answer to the question in the Realitio contract._lastAnswerer The last answerer to the question in the Realitio contract._isCommitment Whether the last answer to the question in the Realitio contract used commit or reveal or not. True if it did, false otherwise. return winner The computed winner.
function computeWinner( uint256 _questionID, bytes32 _lastAnswerOrCommitmentID, uint256 _lastBond, address _lastAnswerer, bool _isCommitment
function computeWinner( uint256 _questionID, bytes32 _lastAnswerOrCommitmentID, uint256 _lastBond, address _lastAnswerer, bool _isCommitment
22,972
9
// Rum speed[0] = 10[1] = 8[2] = 7[3] = 6[4] = 4[5] = 3[6] = 2
mapping(uint16 => uint16) public rumSpeedMapping;
mapping(uint16 => uint16) public rumSpeedMapping;
59,765
58
// 30 days
uint256 period = 2592000; uint256 levelUpCount = (block.timestamp - _transactionTimestamp[tokenId]) / period; if(levelUpCount > 0){ uint32 oldLevel = _characterLevels[tokenId].Energy; _characterLevels[tokenId].Energy += uint32(levelUpCount); if(_characterLevels[tokenId].Energy > 10){ _characterLevels[tokenId].Energy = 10; }
uint256 period = 2592000; uint256 levelUpCount = (block.timestamp - _transactionTimestamp[tokenId]) / period; if(levelUpCount > 0){ uint32 oldLevel = _characterLevels[tokenId].Energy; _characterLevels[tokenId].Energy += uint32(levelUpCount); if(_characterLevels[tokenId].Energy > 10){ _characterLevels[tokenId].Energy = 10; }
72,617
0
// The address of the contract owner.
Owner, AppointedOwner, Paused, PauseGuardian, ReentrancyStatus, RouterFunctionPaused, AmmSwapsLiquidators, AmmPoolsAppointedToRebalance, AmmPoolsParams
Owner, AppointedOwner, Paused, PauseGuardian, ReentrancyStatus, RouterFunctionPaused, AmmSwapsLiquidators, AmmPoolsAppointedToRebalance, AmmPoolsParams
42,910
8
// mapping of user to their orders
mapping(address => uint[]) public userOrders;
mapping(address => uint[]) public userOrders;
26,115
61
// return 100..00.999e8 / 1e8 = 1e18
return ceil.div(RATIO_SCALE);
return ceil.div(RATIO_SCALE);
33,892
120
// first time init
if(tokenInfo.token == address(0)){ setToken(); }
if(tokenInfo.token == address(0)){ setToken(); }
18,546
17
// Adds a new stablecoin/There can be no duplicate entries for same stablecoin symbol/_symbol Stablecoin symbol/_contractAddress Stablecoin contract address on chain/_pipeAddress Pipe address associated with the stablecoin
function addStableCoin( bytes32 _symbol, address _contractAddress, address _pipeAddress
function addStableCoin( bytes32 _symbol, address _contractAddress, address _pipeAddress
33,778
168
// Internal function for adding a new reward address to the linked list._addr new reward account./
function _addRewardAddress(address _addr) internal { require(_addr != address(0) && _addr != F_ADDR); require(!isRewardAddress(_addr)); address nextAddr = getNextRewardAddress(F_ADDR); require(nextAddr != address(0)); _setNextRewardAddress(_addr, nextAddr); _setNextRewardAddress(F_ADDR, _addr); _setRewardAddressCount(rewardAddressCount().add(1)); }
function _addRewardAddress(address _addr) internal { require(_addr != address(0) && _addr != F_ADDR); require(!isRewardAddress(_addr)); address nextAddr = getNextRewardAddress(F_ADDR); require(nextAddr != address(0)); _setNextRewardAddress(_addr, nextAddr); _setNextRewardAddress(F_ADDR, _addr); _setRewardAddressCount(rewardAddressCount().add(1)); }
42,547
34
// we will require that the request in process is not completed yet
require(!request.complete);
require(!request.complete);
79,055
5
// Make sure that we create the offset the first time a generation is revealed
if(generation.offset == 0) { generation.offset = _getOffset(_layerId); }
if(generation.offset == 0) { generation.offset = _getOffset(_layerId); }
21,057
250
// 3. Payout to bonded
if (totalBonded() == 0) { newSupply = 0; }
if (totalBonded() == 0) { newSupply = 0; }
4,819
5
// Details for the targetChain in the encoding scheme.
uint256 private constant TARGET_CHAIN_OFFSET = INDEX_OFFSET + INDEX_SIZE; uint256 private constant TARGET_CHAIN_SIZE = 2;
uint256 private constant TARGET_CHAIN_OFFSET = INDEX_OFFSET + INDEX_SIZE; uint256 private constant TARGET_CHAIN_SIZE = 2;
18,753
90
// Recover the signer address of the `_attestation`. _attestation The attestation structreturn Signer address /
function _recoverAttestationSigner(Attestation memory _attestation) private view returns (address)
function _recoverAttestationSigner(Attestation memory _attestation) private view returns (address)
38,601
76
// it's not expired, return amount of margin required based on vault type
if (_vaultDetails.vaultType == 1) {
if (_vaultDetails.vaultType == 1) {
26,265
6
// Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. /
function mul_ScalarTruncateAddUInt( Exp memory a, uint256 scalar, uint256 addend
function mul_ScalarTruncateAddUInt( Exp memory a, uint256 scalar, uint256 addend
21,770
238
// This event MUST emit when an address withdraws their dividend./to The address which withdraws ether from this contract./weiAmount The amount of withdrawn ether in wei.
event DividendWithdrawn(address indexed to, uint256 weiAmount);
event DividendWithdrawn(address indexed to, uint256 weiAmount);
8,523
43
// handle approvals of tokens that require approving from a base of 0 token - the token we're approving spender - entity the owner (sender) is approving to spend his tokens amount - number of tokens being approved /
function safeApprove(IERC20 token, address spender, uint amount) internal returns (bool) { uint currentAllowance = token.allowance(address(this), spender); // Do nothing if allowance is already set to this value if(currentAllowance == amount) { return true; } // If approval is not zero reset it to zero first if(currentAllowance != 0) { return token.approve(spender, 0); } // do the actual approval return token.approve(spender, amount); }
function safeApprove(IERC20 token, address spender, uint amount) internal returns (bool) { uint currentAllowance = token.allowance(address(this), spender); // Do nothing if allowance is already set to this value if(currentAllowance == amount) { return true; } // If approval is not zero reset it to zero first if(currentAllowance != 0) { return token.approve(spender, 0); } // do the actual approval return token.approve(spender, amount); }
79,719
12
// 100%
uint public hundredPercent = 100;
uint public hundredPercent = 100;
28,530
359
// set max send limit
uint256 unit_ = 1e18; tradeInfo.sendQuantityMax = exactSendQuantity.mul(unit_).div(unit_.sub(_slippage));
uint256 unit_ = 1e18; tradeInfo.sendQuantityMax = exactSendQuantity.mul(unit_).div(unit_.sub(_slippage));
49,366
5
// define an address array that will store all of the instructor addresses
address[] public clientsDatabase;
address[] public clientsDatabase;
25,657
91
// Constructor inherits VRFConsumerBaseNetwork: KovanChainlink VRF Coordinator address: 0xdD3782915140c8f3b190B5D67eAc6dc5760C46E9LINK token address:0xa36085F69e2889c224210F603D836748e7dC0088Key Hash: 0x6c3699283bda56ad74f6b855546325b68d482e983852a7a82979cc4807b641f4 /
constructor() VRFConsumerBase( 0xdD3782915140c8f3b190B5D67eAc6dc5760C46E9, // VRF Coordinator 0xa36085F69e2889c224210F603D836748e7dC0088 // LINK Token ) public
constructor() VRFConsumerBase( 0xdD3782915140c8f3b190B5D67eAc6dc5760C46E9, // VRF Coordinator 0xa36085F69e2889c224210F603D836748e7dC0088 // LINK Token ) public
6,820
238
// oldRoyaltyBPS
royaltyBPS,
royaltyBPS,
19,933
150
// Retrieve the available collateral worth, the worth of collateral which can used for buy options, priced in USD./
function getAvailableCollateral()public view returns(uint256){ delegateToViewAndReturn(); }
function getAvailableCollateral()public view returns(uint256){ delegateToViewAndReturn(); }
22,251
21
// 1000 is the sum of the rarities
uint16 random10k = uint16(randomNumber % 1000); uint16 lowerBound; for (uint16 i = 1; i <= 9; i++) { uint16 percentage = attributeRarities[i]; if (random10k < percentage + lowerBound && random10k >= lowerBound) { return i; }
uint16 random10k = uint16(randomNumber % 1000); uint16 lowerBound; for (uint16 i = 1; i <= 9; i++) { uint16 percentage = attributeRarities[i]; if (random10k < percentage + lowerBound && random10k >= lowerBound) { return i; }
23,877
132
// Get tokens remaining on token sale balance
function _remainingTokens() private view returns (uint256) { return _getInitialSupplyPercentInWei(percentSale) .sub(purchased) .sub(transferredToTokenAcceptor); }
function _remainingTokens() private view returns (uint256) { return _getInitialSupplyPercentInWei(percentSale) .sub(purchased) .sub(transferredToTokenAcceptor); }
10,010
0
// whitelist tracking
mapping (address => uint256) public minted;
mapping (address => uint256) public minted;
47,007
254
// Removes Liquidity and either distributes liquidity BNB to stakers, oradds them to marketing BalanceToken will be convertedto Liquidity and Staking BNB again
uint256 initialBNBBalance = address(this).balance; _pancakeRouter.removeLiquidityETHSupportingFeeOnTransferTokens( address(this), amount, 0, 0, address(this), block.timestamp ); uint256 newBNBBalance = address(this).balance-initialBNBBalance;
uint256 initialBNBBalance = address(this).balance; _pancakeRouter.removeLiquidityETHSupportingFeeOnTransferTokens( address(this), amount, 0, 0, address(this), block.timestamp ); uint256 newBNBBalance = address(this).balance-initialBNBBalance;
31,230
4
// Update the chain ID Useful for updating once a hard fork has been mitigated chainId EVM chain ID to use /
function setChainId(uint256 chainId) external;
function setChainId(uint256 chainId) external;
21,591
11
// Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. /
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
11,062
20
// Returns the ratio of which the given token consider for collateral value.
function getCollFactor(address token) external view returns (uint);
function getCollFactor(address token) external view returns (uint);
73,930
108
// Constructor, takes token wallet address. tokenWallet Address holding the tokens, which has approved allowance to the crowdsale. /
constructor(address tokenWallet) public { require( tokenWallet != address(0), "AllowanceCrowdsale: token wallet is the zero address" ); _tokenWallet = tokenWallet; }
constructor(address tokenWallet) public { require( tokenWallet != address(0), "AllowanceCrowdsale: token wallet is the zero address" ); _tokenWallet = tokenWallet; }
72,503
0
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
mapping(uint256 => mapping(address => uint256)) private _balances;
13
19
// Emit when the budget allocated to a module is changed
event ModuleBudgetChanged(uint8[] _moduleTypes, address _module, uint256 _oldBudget, uint256 _budget);
event ModuleBudgetChanged(uint8[] _moduleTypes, address _module, uint256 _oldBudget, uint256 _budget);
17,912
406
// Ge contributor power error
uint256 internal constant CONTRIBUTOR_POWER_CHECK_WINDOW = 65;
uint256 internal constant CONTRIBUTOR_POWER_CHECK_WINDOW = 65;
15,764
51
// address public erc20_token_addr;
event withdraw_token(address token, address to, uint256 amount); event issue_token(address token, address to, uint256 amount); event RecvETH(uint256 v);
event withdraw_token(address token, address to, uint256 amount); event issue_token(address token, address to, uint256 amount); event RecvETH(uint256 v);
31,809
37
// Sets a new cap for deposits newCap is the new cap for deposits /
function setCap(uint256 newCap) external onlyManager { uint256 oldCap = cap; cap = newCap; emit CapSet(oldCap, newCap, msg.sender); }
function setCap(uint256 newCap) external onlyManager { uint256 oldCap = cap; cap = newCap; emit CapSet(oldCap, newCap, msg.sender); }
32,286
12
// SPDX-License-Identifier: MIT//
contract WallStBullsInterns is ERC721EnumerableV2, Ownable { uint256 public constant RESERVED_INTERNS = 100; mapping(address => uint256) public totalMinted; string public baseURI; bool public baseURIFinal; bool public saleActive; bytes32 private _eligibilityMerkleRoot; event BaseURIChanged(string baseURI); event PermanentURI(string _value, uint256 indexed _id); constructor(string memory _initialBaseURI) ERC721("Wall Street Bulls Interns", "WSBI") { baseURI = _initialBaseURI; } function setBaseURI(string memory _newBaseURI) external onlyOwner { require(!baseURIFinal, "Base URL is unchangeable"); baseURI = _newBaseURI; emit BaseURIChanged(baseURI); } function finalizeBaseURI() external onlyOwner { baseURIFinal = true; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function emitPermanent(uint256 tokenId) external onlyOwner { require(baseURIFinal, "Base URL must be finalized first"); emit PermanentURI(tokenURI(tokenId), tokenId); } function toggleSaleActive() external onlyOwner { saleActive = !saleActive; } function setEligibilityMerkleRoot(bytes32 _merkleRoot) external onlyOwner { _eligibilityMerkleRoot = _merkleRoot; } function mintReserved(address _to, uint256 _internCount) external onlyOwner { require(totalMinted[msg.sender] + _internCount <= RESERVED_INTERNS, "All Reserved Interns have been minted"); _mintIntern(_to, _internCount); } function withdraw(address _to, uint256 _amount) external onlyOwner { (bool success,) = _to.call{value : _amount}(""); require(success, "Failed to withdraw Ether"); } function _verifyInternEligible(address _account, uint8 _maxAllowed, bytes32[] calldata _merkleProof) private view returns (bool) { bytes32 node = keccak256(abi.encodePacked(_account, _maxAllowed)); return MerkleProof.verify(_merkleProof, _eligibilityMerkleRoot, node); } function mintIntern(uint256 _internCount, uint8 _maxAllowed, bytes32[] calldata _merkleProof) external payable { require(saleActive, "Sale is not active"); require(_verifyInternEligible(msg.sender, _maxAllowed, _merkleProof), "Address not found in eligibility allow list"); require(totalMinted[msg.sender] + _internCount <= uint256(_maxAllowed), "Purchase exceeds max mint count"); _mintIntern(msg.sender, _internCount); } function _mintIntern(address _to, uint256 _internCount) private { uint256 totalSupply = totalSupply(); require(_internCount > 0, "Must mint at least one Intern"); for (uint256 i = 1; i <= _internCount; i++) { totalMinted[msg.sender] += 1; _safeMint(_to, totalSupply + i); } } }
contract WallStBullsInterns is ERC721EnumerableV2, Ownable { uint256 public constant RESERVED_INTERNS = 100; mapping(address => uint256) public totalMinted; string public baseURI; bool public baseURIFinal; bool public saleActive; bytes32 private _eligibilityMerkleRoot; event BaseURIChanged(string baseURI); event PermanentURI(string _value, uint256 indexed _id); constructor(string memory _initialBaseURI) ERC721("Wall Street Bulls Interns", "WSBI") { baseURI = _initialBaseURI; } function setBaseURI(string memory _newBaseURI) external onlyOwner { require(!baseURIFinal, "Base URL is unchangeable"); baseURI = _newBaseURI; emit BaseURIChanged(baseURI); } function finalizeBaseURI() external onlyOwner { baseURIFinal = true; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function emitPermanent(uint256 tokenId) external onlyOwner { require(baseURIFinal, "Base URL must be finalized first"); emit PermanentURI(tokenURI(tokenId), tokenId); } function toggleSaleActive() external onlyOwner { saleActive = !saleActive; } function setEligibilityMerkleRoot(bytes32 _merkleRoot) external onlyOwner { _eligibilityMerkleRoot = _merkleRoot; } function mintReserved(address _to, uint256 _internCount) external onlyOwner { require(totalMinted[msg.sender] + _internCount <= RESERVED_INTERNS, "All Reserved Interns have been minted"); _mintIntern(_to, _internCount); } function withdraw(address _to, uint256 _amount) external onlyOwner { (bool success,) = _to.call{value : _amount}(""); require(success, "Failed to withdraw Ether"); } function _verifyInternEligible(address _account, uint8 _maxAllowed, bytes32[] calldata _merkleProof) private view returns (bool) { bytes32 node = keccak256(abi.encodePacked(_account, _maxAllowed)); return MerkleProof.verify(_merkleProof, _eligibilityMerkleRoot, node); } function mintIntern(uint256 _internCount, uint8 _maxAllowed, bytes32[] calldata _merkleProof) external payable { require(saleActive, "Sale is not active"); require(_verifyInternEligible(msg.sender, _maxAllowed, _merkleProof), "Address not found in eligibility allow list"); require(totalMinted[msg.sender] + _internCount <= uint256(_maxAllowed), "Purchase exceeds max mint count"); _mintIntern(msg.sender, _internCount); } function _mintIntern(address _to, uint256 _internCount) private { uint256 totalSupply = totalSupply(); require(_internCount > 0, "Must mint at least one Intern"); for (uint256 i = 1; i <= _internCount; i++) { totalMinted[msg.sender] += 1; _safeMint(_to, totalSupply + i); } } }
58,656
113
// check if amount transfered is correct
_sendNFTToVending(_erc1155, _tokenId, _amount);
_sendNFTToVending(_erc1155, _tokenId, _amount);
51,296
85
// address of token that users need to hold to contribute address(0) if party is not token gated
IERC20 public gatedToken;
IERC20 public gatedToken;
49,654
6
// Calculates the starting timestamp of the given period. This function is used for time-scaling a pool's weight. periodIndex index of the period.return (uint256) timestamp at which the period started. /
function getStartOfPeriod(uint256 periodIndex) external view returns (uint256);
function getStartOfPeriod(uint256 periodIndex) external view returns (uint256);
2,174
22
// player vars/
uint public rngId; mapping (uint => address) playerAddress; mapping (uint => uint) playerBetId; mapping (uint => uint) playerBetValue; mapping (uint => uint) playerDieResult; mapping (uint => uint) playerNumber; mapping (uint => uint) playerProfit;
uint public rngId; mapping (uint => address) playerAddress; mapping (uint => uint) playerBetId; mapping (uint => uint) playerBetValue; mapping (uint => uint) playerDieResult; mapping (uint => uint) playerNumber; mapping (uint => uint) playerProfit;
86,362
176
// get trades for a specific order /
function getOrderTrades(LibValidator.Order memory order) public view returns (Trade[] memory)
function getOrderTrades(LibValidator.Order memory order) public view returns (Trade[] memory)
28,363
26
// claim rewards for a specific token at a specific epoch
function getReward(address _account, address _token) public { //get claimable tokens (uint256 claimableTokens, uint256 index) = _allClaimableRewards(_account, _token); if (claimableTokens > 0) { //set claim checkpoint userClaims[_token][_account] = index; //send IERC20(_token).safeTransfer(_account, claimableTokens); //event emit RewardPaid(_account, _token, claimableTokens); } }
function getReward(address _account, address _token) public { //get claimable tokens (uint256 claimableTokens, uint256 index) = _allClaimableRewards(_account, _token); if (claimableTokens > 0) { //set claim checkpoint userClaims[_token][_account] = index; //send IERC20(_token).safeTransfer(_account, claimableTokens); //event emit RewardPaid(_account, _token, claimableTokens); } }
25,123
37
// Derive a private key from a provided mnenomic string (or mnenomic file path) at the derivation path {path}{index}
function deriveKey(string calldata, string calldata, uint32) external pure returns (uint256);
function deriveKey(string calldata, string calldata, uint32) external pure returns (uint256);
26,077
11
// 7. Refund crv
doRefund(crv);
doRefund(crv);
42,334
117
// Out weth is in 2 branches We give credit to user contributing
coreUnitsCredit = outWETH.mul(coreTokenPer1ETH).div(1e18);
coreUnitsCredit = outWETH.mul(coreTokenPer1ETH).div(1e18);
17,769
95
// Vote on a proposalproposalId The proposal IDvote The yes/no vote/
function voteOn(uint256 proposalId, bool vote) external;
function voteOn(uint256 proposalId, bool vote) external;
47,821
110
// recalculate the amount of LINK available for payouts /
function updateAvailableFunds() public
function updateAvailableFunds() public
65,845
79
// Tracks last 5 sale price of gen0 property sales
uint256 public saleCount; uint256[5] public lastSalePrices;
uint256 public saleCount; uint256[5] public lastSalePrices;
2,259
244
// This is where we actually mint tokens:
tokenSupply = tokenSupply.add(tokensBought); divTokenSupply = divTokenSupply.add(dividendTokensBought);
tokenSupply = tokenSupply.add(tokensBought); divTokenSupply = divTokenSupply.add(dividendTokensBought);
33,214
4
// Token id to wallet (owner) address map. /
mapping(uint256 => address) private _tokenOwner;
mapping(uint256 => address) private _tokenOwner;
45,881
48
// Address of Monetha Vault for fee collection /
address public monethaVault;
address public monethaVault;
16,808
36
// issue new coins
function issue(uint amount) onlyOwner public { totalSupply = totalSupply.add(amount); balances[this] = balances[this].add(amount); }
function issue(uint amount) onlyOwner public { totalSupply = totalSupply.add(amount); balances[this] = balances[this].add(amount); }
39,647
66
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH());
11,712
6
// input sanitization
if (address(_vault) == address(0)) revert R_ZeroAddress("vault"); if (address(_opContracts.loanCoreV2) == address(0)) revert R_ZeroAddress("loanCoreV2"); if (address(_opContracts.borrowerNoteV2) == address(0)) revert R_ZeroAddress("borrowerNoteV2"); if (address(_opContracts.repaymentControllerV2) == address(0)) revert R_ZeroAddress("repaymentControllerV2"); if (address(_opContracts.feeControllerV3) == address(0)) revert R_ZeroAddress("feeControllerV3"); if (address(_opContracts.originationControllerV3) == address(0)) revert R_ZeroAddress("originationControllerV3"); if (address(_opContracts.loanCoreV3) == address(0)) revert R_ZeroAddress("loanCoreV3"); if (address(_opContracts.borrowerNoteV3) == address(0)) revert R_ZeroAddress("borrowerNoteV3");
if (address(_vault) == address(0)) revert R_ZeroAddress("vault"); if (address(_opContracts.loanCoreV2) == address(0)) revert R_ZeroAddress("loanCoreV2"); if (address(_opContracts.borrowerNoteV2) == address(0)) revert R_ZeroAddress("borrowerNoteV2"); if (address(_opContracts.repaymentControllerV2) == address(0)) revert R_ZeroAddress("repaymentControllerV2"); if (address(_opContracts.feeControllerV3) == address(0)) revert R_ZeroAddress("feeControllerV3"); if (address(_opContracts.originationControllerV3) == address(0)) revert R_ZeroAddress("originationControllerV3"); if (address(_opContracts.loanCoreV3) == address(0)) revert R_ZeroAddress("loanCoreV3"); if (address(_opContracts.borrowerNoteV3) == address(0)) revert R_ZeroAddress("borrowerNoteV3");
42,566
248
// It adds a list of account as signers for an asset market. See {SignerFacet._addSigner} asset Token address to add signers for. accounts addresses to add. Requirements: - Sender must have the role ADMIN /
function addSigners(address asset, address[] calldata accounts) external authorized(ADMIN, msg.sender) { for (uint256 i; i < accounts.length; i++) { _addSigner(asset, accounts[i]);
function addSigners(address asset, address[] calldata accounts) external authorized(ADMIN, msg.sender) { for (uint256 i; i < accounts.length; i++) { _addSigner(asset, accounts[i]);
44,318
64
// PRESALE
uint256 public sPrice; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); //event fire min token liquidity fee collected before swapandLiquify event SwapAndLiquifyEnabledUpdated(bool enabled); // event fire set auto swap to ETH and liquify collected liquidity fee event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqiudity ); // fire event how many tokens were swapedandLiquified
uint256 public sPrice; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); //event fire min token liquidity fee collected before swapandLiquify event SwapAndLiquifyEnabledUpdated(bool enabled); // event fire set auto swap to ETH and liquify collected liquidity fee event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqiudity ); // fire event how many tokens were swapedandLiquified
22,551
39
// minting tokens for investors
mint(_to, _tokens); // _tokens in wei rounds[_currentRound].soldCoins = rounds[_currentRound].soldCoins.add(_tokens); tokensBought[_to] = tokensBought[_to].add(_tokens); // tokens in wei uint256 _soldInETH = _tokens.div( rate ); _sold = _sold.add(_tokens); // in wei _soldOutside = _soldOutside.add(_soldInETH); // eth _soldOutsidePMZ = _soldOutsidePMZ.add(_tokens); // in PMZ
mint(_to, _tokens); // _tokens in wei rounds[_currentRound].soldCoins = rounds[_currentRound].soldCoins.add(_tokens); tokensBought[_to] = tokensBought[_to].add(_tokens); // tokens in wei uint256 _soldInETH = _tokens.div( rate ); _sold = _sold.add(_tokens); // in wei _soldOutside = _soldOutside.add(_soldInETH); // eth _soldOutsidePMZ = _soldOutsidePMZ.add(_tokens); // in PMZ
79,668
312
// expmods_and_points.points[57] = -(g^262z).
mstore(add(expmodsAndPoints, 0x9c0), point)
mstore(add(expmodsAndPoints, 0x9c0), point)
63,513
62
// Withdraw all deposit from escrow for msg.sender/
function withdraw() external whenNotPaused { (bool success,) = instructionsProviderContractRef.call( abi.encodeWithSignature( "withdraw(address)", msg.sender ) ); require(success,"Proxy: Unable to get withdraw deposits of caller from Escrow!"); }
function withdraw() external whenNotPaused { (bool success,) = instructionsProviderContractRef.call( abi.encodeWithSignature( "withdraw(address)", msg.sender ) ); require(success,"Proxy: Unable to get withdraw deposits of caller from Escrow!"); }
29,311
3
// Sets the values for {name}, {symbol}, {totalsupply} and {deciamls}. {name}, {symbol} and {decimals} are immutable: they can only be set once duringconstruction. {totalsupply} may be changed by using mint and burn functions./
constructor(address account) { _name = "Index20"; _symbol = "I20"; _decimals = 18; _transferOwnership(account); addAdmin(account); _mint(_msgSender(), 50000000000000000000000000); }
constructor(address account) { _name = "Index20"; _symbol = "I20"; _decimals = 18; _transferOwnership(account); addAdmin(account); _mint(_msgSender(), 50000000000000000000000000); }
20,848
163
// getEscapeRequests(): get the points _sponsor has received escape requests fromNote: only useful for clients, as Solidity does not currentlysupport returning dynamic arrays.
function getEscapeRequests(uint32 _sponsor) view external returns (uint32[] requests)
function getEscapeRequests(uint32 _sponsor) view external returns (uint32[] requests)
51,148
73
// Gets the token ID at a given index of the tokens list of the requested owner owner address owning the tokens list to be accessed index uint256 representing the index to be accessed of the requested tokens listreturn uint256 token ID at the given index of the tokens list owned by the requested address /
function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { require(index < balanceOf(owner)); return _ownedTokens[owner][index]; }
function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { require(index < balanceOf(owner)); return _ownedTokens[owner][index]; }
38,522
10
// update total number of requests
trackId++;
trackId++;
30,733
21
// Emitted when the allowance of a `spender` for an `owner` is set bya call to {approve}. `value` is the new allowance. /
event Approval(address indexed owner, address indexed spender, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
32,766
119
// pragma solidity ^0.6.2; // import "../../lib/erc20.sol"; // import "../../lib/safe-math.sol"; // import "../../interfaces/curve.sol"; /
contract CRVLocker { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public constant mintr = 0xd061D61a4d941c39E5453435B6345Dc261C2fcE0; address public constant crv = 0xD533a949740bb3306d119CC777fa900bA034cd52; address public constant escrow = 0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2; address public governance; mapping(address => bool) public voters; constructor(address _governance) public { governance = _governance; } function getName() external pure returns (string memory) { return "CRVLocker"; } function addVoter(address _voter) external { require(msg.sender == governance, "!governance"); voters[_voter] = true; } function removeVoter(address _voter) external { require(msg.sender == governance, "!governance"); voters[_voter] = false; } function withdraw(address _asset) external returns (uint256 balance) { require(voters[msg.sender], "!voter"); balance = IERC20(_asset).balanceOf(address(this)); IERC20(_asset).safeTransfer(msg.sender, balance); } function createLock(uint256 _value, uint256 _unlockTime) external { require(voters[msg.sender] || msg.sender == governance, "!authorized"); IERC20(crv).safeApprove(escrow, 0); IERC20(crv).safeApprove(escrow, _value); ICurveVotingEscrow(escrow).create_lock(_value, _unlockTime); } function increaseAmount(uint256 _value) external { require(voters[msg.sender] || msg.sender == governance, "!authorized"); IERC20(crv).safeApprove(escrow, 0); IERC20(crv).safeApprove(escrow, _value); ICurveVotingEscrow(escrow).increase_amount(_value); } function increaseUnlockTime(uint256 _unlockTime) external { require(voters[msg.sender] || msg.sender == governance, "!authorized"); ICurveVotingEscrow(escrow).increase_unlock_time(_unlockTime); } function release() external { require(voters[msg.sender] || msg.sender == governance, "!authorized"); ICurveVotingEscrow(escrow).withdraw(); } function setGovernance(address _governance) external { require(msg.sender == governance, "!governance"); governance = _governance; } function execute( address to, uint256 value, bytes calldata data ) external returns (bool, bytes memory) { require(voters[msg.sender] || msg.sender == governance, "!governance"); (bool success, bytes memory result) = to.call{value: value}(data); require(success, "!execute-success"); return (success, result); } }
contract CRVLocker { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public constant mintr = 0xd061D61a4d941c39E5453435B6345Dc261C2fcE0; address public constant crv = 0xD533a949740bb3306d119CC777fa900bA034cd52; address public constant escrow = 0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2; address public governance; mapping(address => bool) public voters; constructor(address _governance) public { governance = _governance; } function getName() external pure returns (string memory) { return "CRVLocker"; } function addVoter(address _voter) external { require(msg.sender == governance, "!governance"); voters[_voter] = true; } function removeVoter(address _voter) external { require(msg.sender == governance, "!governance"); voters[_voter] = false; } function withdraw(address _asset) external returns (uint256 balance) { require(voters[msg.sender], "!voter"); balance = IERC20(_asset).balanceOf(address(this)); IERC20(_asset).safeTransfer(msg.sender, balance); } function createLock(uint256 _value, uint256 _unlockTime) external { require(voters[msg.sender] || msg.sender == governance, "!authorized"); IERC20(crv).safeApprove(escrow, 0); IERC20(crv).safeApprove(escrow, _value); ICurveVotingEscrow(escrow).create_lock(_value, _unlockTime); } function increaseAmount(uint256 _value) external { require(voters[msg.sender] || msg.sender == governance, "!authorized"); IERC20(crv).safeApprove(escrow, 0); IERC20(crv).safeApprove(escrow, _value); ICurveVotingEscrow(escrow).increase_amount(_value); } function increaseUnlockTime(uint256 _unlockTime) external { require(voters[msg.sender] || msg.sender == governance, "!authorized"); ICurveVotingEscrow(escrow).increase_unlock_time(_unlockTime); } function release() external { require(voters[msg.sender] || msg.sender == governance, "!authorized"); ICurveVotingEscrow(escrow).withdraw(); } function setGovernance(address _governance) external { require(msg.sender == governance, "!governance"); governance = _governance; } function execute( address to, uint256 value, bytes calldata data ) external returns (bool, bytes memory) { require(voters[msg.sender] || msg.sender == governance, "!governance"); (bool success, bytes memory result) = to.call{value: value}(data); require(success, "!execute-success"); return (success, result); } }
62,112
101
// 下一个检查点
Checkpoint memory cp1 = checkpoints[account][i + 1];
Checkpoint memory cp1 = checkpoints[account][i + 1];
28,258
11
// Current number of votes in opposition to this proposal
uint256 againstVotes;
uint256 againstVotes;
29,052
7
// The delay before voting on a proposal may take place, once proposed
function votingDelay() public pure returns (uint) { return 1; } // 1 block
function votingDelay() public pure returns (uint) { return 1; } // 1 block
376
63
// Adds a yield token to the system.//`msg.sender` must be the admin or this call will revert with an {Unauthorized} error.//Emits a {AddYieldToken} event./Emits a {TokenAdapterUpdated} event./Emits a {MaximumLossUpdated} event.//yieldToken The address of the yield token to add./config The initial yield token configuration.
function addYieldToken(address yieldToken, YieldTokenConfig calldata config) external;
function addYieldToken(address yieldToken, YieldTokenConfig calldata config) external;
39,778