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
20
// This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address.
function withdraw() public payable onlyOwner { require(payable(teamWallet).send(address(this).balance)); }
function withdraw() public payable onlyOwner { require(payable(teamWallet).send(address(this).balance)); }
14,025
5
// get the high byte which stores the length of the string when unpacked
uint256 len = uint256(packed >> 248);
uint256 len = uint256(packed >> 248);
9,776
70
// Option type the vault is selling
bool isPut;
bool isPut;
64,913
76
// Retrieve the dividends owned by the caller. /
function myDividends(bool _includeReferralBonus) public view returns (uint256)
function myDividends(bool _includeReferralBonus) public view returns (uint256)
18,667
0
// A data structure to store data of members for a given role. indexCurrent index in the list of accounts that have a role.membersmap from index => address of account that has a roleindexOfmap from address => index which the account has. /
struct RoleMembers { uint256 index; mapping(uint256 => address) members; mapping(address => uint256) indexOf; }
struct RoleMembers { uint256 index; mapping(uint256 => address) members; mapping(address => uint256) indexOf; }
591
130
// If we've reached the maximum burn point, send half the profits to the treasury to reward holders
uint256 retirementYeld = stakingProfits;
uint256 retirementYeld = stakingProfits;
8,008
2
// Advanced Token
res[30] = this.approve.selector;
res[30] = this.approve.selector;
7,675
44
//
_addBeneficiary(development, 8000000, 25); _addBeneficiary(teamReserved, 8000000, 25); _addBeneficiary(LockedAndReserved, 6000000, 25);
_addBeneficiary(development, 8000000, 25); _addBeneficiary(teamReserved, 8000000, 25); _addBeneficiary(LockedAndReserved, 6000000, 25);
22,429
6
// --- Public view functions
function getNext( Data storage self, address current ) internal view returns (address)
function getNext( Data storage self, address current ) internal view returns (address)
31,176
16
// Proceed with execution of proposal.
if (proposals[index].isMint) { reserve.mint(addr, value); } else {
if (proposals[index].isMint) { reserve.mint(addr, value); } else {
9,347
35
// Checks whether it can transfer or otherwise throws. /
modifier canTransfer(address _sender, uint256 _value) { require(_value <= transferableTokens(_sender, uint64(now))); _; }
modifier canTransfer(address _sender, uint256 _value) { require(_value <= transferableTokens(_sender, uint64(now))); _; }
1,253
159
// whitelist
function toggle_whitelist(bool change) external onlyOwner { _is_whitelist_only = change; }
function toggle_whitelist(bool change) external onlyOwner { _is_whitelist_only = change; }
16,587
2
// Internal Out Of Gas/Throw: revert this transaction too; Call Stack Depth Limit reached: revert this transaction too; Recursive Call: safe, no any changes applied yet, we are inside of modifier.
_safeSend(msg.sender, msg.value);
_safeSend(msg.sender, msg.value);
53,680
24
// Setup the channel on storage
channels[newChannel.id] = newChannel;
channels[newChannel.id] = newChannel;
45,157
7
// the auction stage
AuctionStage stage; // 1 byte
AuctionStage stage; // 1 byte
2,934
50
// Overwrite due to lockup_from address The address which you want to send tokens from_to address The address which you want to transfer to_value uint256 the amount of tokens to be transferred/
function transferFrom(address _from, address _to, uint256 _value) public isValidTransfer() returns (bool) { return super.transferFrom(_from, _to, _value); }
function transferFrom(address _from, address _to, uint256 _value) public isValidTransfer() returns (bool) { return super.transferFrom(_from, _to, _value); }
55,593
5
// Transfers `amount` tokens to `receiver` address/Only Signer or Owner can execute this function
function transferTo(address receiver, uint256 amount) external{ require((msg.sender == owner()) || (msg.sender == singer), "TokenDisributor: Only singer role"); token.transfer(receiver, amount); }
function transferTo(address receiver, uint256 amount) external{ require((msg.sender == owner()) || (msg.sender == singer), "TokenDisributor: Only singer role"); token.transfer(receiver, amount); }
35,576
112
// Autonomous Converter contract for MET <=> ETH exchange
contract AutonomousConverter is Formula, Owned { SmartToken public smartToken; METToken public reserveToken; Auctions public auctions; enum WhichToken { Eth, Met } bool internal initialized = false; event LogFundsIn(address indexed from, uint value); event ConvertEthToMet(address indexed from, uint eth, uint met); event ConvertMetToEth(address indexed from, uint eth, uint met); function init(address _reserveToken, address _smartToken, address _auctions) public onlyOwner payable { require(!initialized); auctions = Auctions(_auctions); reserveToken = METToken(_reserveToken); smartToken = SmartToken(_smartToken); initialized = true; } function handleFund() public payable { require(msg.sender == address(auctions.proceeds())); emit LogFundsIn(msg.sender, msg.value); } function getMetBalance() public view returns (uint) { return balanceOf(WhichToken.Met); } function getEthBalance() public view returns (uint) { return balanceOf(WhichToken.Eth); } /// @notice return the expected MET for ETH /// @param _depositAmount ETH. /// @return expected MET value for ETH function getMetForEthResult(uint _depositAmount) public view returns (uint256) { return convertingReturn(WhichToken.Eth, _depositAmount); } /// @notice return the expected ETH for MET /// @param _depositAmount MET. /// @return expected ETH value for MET function getEthForMetResult(uint _depositAmount) public view returns (uint256) { return convertingReturn(WhichToken.Met, _depositAmount); } /// @notice send ETH and get MET /// @param _mintReturn execute conversion only if return is equal or more than _mintReturn /// @return returnedMet MET retured after conversion function convertEthToMet(uint _mintReturn) public payable returns (uint returnedMet) { returnedMet = convert(WhichToken.Eth, _mintReturn, msg.value); emit ConvertEthToMet(msg.sender, msg.value, returnedMet); } /// @notice send MET and get ETH /// @dev Caller will be required to approve the AutonomousConverter to initiate the transfer /// @param _amount MET amount /// @param _mintReturn execute conversion only if return is equal or more than _mintReturn /// @return returnedEth ETh returned after conversion function convertMetToEth(uint _amount, uint _mintReturn) public returns (uint returnedEth) { returnedEth = convert(WhichToken.Met, _mintReturn, _amount); emit ConvertMetToEth(msg.sender, returnedEth, _amount); } function balanceOf(WhichToken which) internal view returns (uint) { if (which == WhichToken.Eth) return address(this).balance; if (which == WhichToken.Met) return reserveToken.balanceOf(this); revert(); } function convertingReturn(WhichToken whichFrom, uint _depositAmount) internal view returns (uint256) { WhichToken to = WhichToken.Met; if (whichFrom == WhichToken.Met) { to = WhichToken.Eth; } uint reserveTokenBalanceFrom = balanceOf(whichFrom).add(_depositAmount); uint mintRet = returnForMint(smartToken.totalSupply(), _depositAmount, reserveTokenBalanceFrom); uint newSmartTokenSupply = smartToken.totalSupply().add(mintRet); uint reserveTokenBalanceTo = balanceOf(to); return returnForRedemption( newSmartTokenSupply, mintRet, reserveTokenBalanceTo); } function convert(WhichToken whichFrom, uint _minReturn, uint amnt) internal returns (uint) { WhichToken to = WhichToken.Met; if (whichFrom == WhichToken.Met) { to = WhichToken.Eth; require(reserveToken.transferFrom(msg.sender, this, amnt)); } uint mintRet = mint(whichFrom, amnt, 1); return redeem(to, mintRet, _minReturn); } function mint(WhichToken which, uint _depositAmount, uint _minReturn) internal returns (uint256 amount) { require(_minReturn > 0); amount = mintingReturn(which, _depositAmount); require(amount >= _minReturn); require(smartToken.mint(msg.sender, amount)); } function mintingReturn(WhichToken which, uint _depositAmount) internal view returns (uint256) { uint256 smartTokenSupply = smartToken.totalSupply(); uint256 reserveBalance = balanceOf(which); return returnForMint(smartTokenSupply, _depositAmount, reserveBalance); } function redeem(WhichToken which, uint _amount, uint _minReturn) internal returns (uint redeemable) { require(_amount <= smartToken.balanceOf(msg.sender)); require(_minReturn > 0); redeemable = redemptionReturn(which, _amount); require(redeemable >= _minReturn); uint256 reserveBalance = balanceOf(which); require(reserveBalance >= redeemable); uint256 tokenSupply = smartToken.totalSupply(); require(_amount < tokenSupply); smartToken.destroy(msg.sender, _amount); if (which == WhichToken.Eth) { msg.sender.transfer(redeemable); } else { require(reserveToken.transfer(msg.sender, redeemable)); } } function redemptionReturn(WhichToken which, uint smartTokensSent) internal view returns (uint256) { uint smartTokenSupply = smartToken.totalSupply(); uint reserveTokenBalance = balanceOf(which); return returnForRedemption( smartTokenSupply, smartTokensSent, reserveTokenBalance); } }
contract AutonomousConverter is Formula, Owned { SmartToken public smartToken; METToken public reserveToken; Auctions public auctions; enum WhichToken { Eth, Met } bool internal initialized = false; event LogFundsIn(address indexed from, uint value); event ConvertEthToMet(address indexed from, uint eth, uint met); event ConvertMetToEth(address indexed from, uint eth, uint met); function init(address _reserveToken, address _smartToken, address _auctions) public onlyOwner payable { require(!initialized); auctions = Auctions(_auctions); reserveToken = METToken(_reserveToken); smartToken = SmartToken(_smartToken); initialized = true; } function handleFund() public payable { require(msg.sender == address(auctions.proceeds())); emit LogFundsIn(msg.sender, msg.value); } function getMetBalance() public view returns (uint) { return balanceOf(WhichToken.Met); } function getEthBalance() public view returns (uint) { return balanceOf(WhichToken.Eth); } /// @notice return the expected MET for ETH /// @param _depositAmount ETH. /// @return expected MET value for ETH function getMetForEthResult(uint _depositAmount) public view returns (uint256) { return convertingReturn(WhichToken.Eth, _depositAmount); } /// @notice return the expected ETH for MET /// @param _depositAmount MET. /// @return expected ETH value for MET function getEthForMetResult(uint _depositAmount) public view returns (uint256) { return convertingReturn(WhichToken.Met, _depositAmount); } /// @notice send ETH and get MET /// @param _mintReturn execute conversion only if return is equal or more than _mintReturn /// @return returnedMet MET retured after conversion function convertEthToMet(uint _mintReturn) public payable returns (uint returnedMet) { returnedMet = convert(WhichToken.Eth, _mintReturn, msg.value); emit ConvertEthToMet(msg.sender, msg.value, returnedMet); } /// @notice send MET and get ETH /// @dev Caller will be required to approve the AutonomousConverter to initiate the transfer /// @param _amount MET amount /// @param _mintReturn execute conversion only if return is equal or more than _mintReturn /// @return returnedEth ETh returned after conversion function convertMetToEth(uint _amount, uint _mintReturn) public returns (uint returnedEth) { returnedEth = convert(WhichToken.Met, _mintReturn, _amount); emit ConvertMetToEth(msg.sender, returnedEth, _amount); } function balanceOf(WhichToken which) internal view returns (uint) { if (which == WhichToken.Eth) return address(this).balance; if (which == WhichToken.Met) return reserveToken.balanceOf(this); revert(); } function convertingReturn(WhichToken whichFrom, uint _depositAmount) internal view returns (uint256) { WhichToken to = WhichToken.Met; if (whichFrom == WhichToken.Met) { to = WhichToken.Eth; } uint reserveTokenBalanceFrom = balanceOf(whichFrom).add(_depositAmount); uint mintRet = returnForMint(smartToken.totalSupply(), _depositAmount, reserveTokenBalanceFrom); uint newSmartTokenSupply = smartToken.totalSupply().add(mintRet); uint reserveTokenBalanceTo = balanceOf(to); return returnForRedemption( newSmartTokenSupply, mintRet, reserveTokenBalanceTo); } function convert(WhichToken whichFrom, uint _minReturn, uint amnt) internal returns (uint) { WhichToken to = WhichToken.Met; if (whichFrom == WhichToken.Met) { to = WhichToken.Eth; require(reserveToken.transferFrom(msg.sender, this, amnt)); } uint mintRet = mint(whichFrom, amnt, 1); return redeem(to, mintRet, _minReturn); } function mint(WhichToken which, uint _depositAmount, uint _minReturn) internal returns (uint256 amount) { require(_minReturn > 0); amount = mintingReturn(which, _depositAmount); require(amount >= _minReturn); require(smartToken.mint(msg.sender, amount)); } function mintingReturn(WhichToken which, uint _depositAmount) internal view returns (uint256) { uint256 smartTokenSupply = smartToken.totalSupply(); uint256 reserveBalance = balanceOf(which); return returnForMint(smartTokenSupply, _depositAmount, reserveBalance); } function redeem(WhichToken which, uint _amount, uint _minReturn) internal returns (uint redeemable) { require(_amount <= smartToken.balanceOf(msg.sender)); require(_minReturn > 0); redeemable = redemptionReturn(which, _amount); require(redeemable >= _minReturn); uint256 reserveBalance = balanceOf(which); require(reserveBalance >= redeemable); uint256 tokenSupply = smartToken.totalSupply(); require(_amount < tokenSupply); smartToken.destroy(msg.sender, _amount); if (which == WhichToken.Eth) { msg.sender.transfer(redeemable); } else { require(reserveToken.transfer(msg.sender, redeemable)); } } function redemptionReturn(WhichToken which, uint smartTokensSent) internal view returns (uint256) { uint smartTokenSupply = smartToken.totalSupply(); uint reserveTokenBalance = balanceOf(which); return returnForRedemption( smartTokenSupply, smartTokensSent, reserveTokenBalance); } }
36,881
16
// A record of balance checkpoints for each token, by index
mapping (uint => SupplyCheckpoint) public supplyCheckpoints;
mapping (uint => SupplyCheckpoint) public supplyCheckpoints;
33,169
63
// bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))
bytes4 internal constant _ERC1155_RECEIVED = 0xf23a6e61;
bytes4 internal constant _ERC1155_RECEIVED = 0xf23a6e61;
31,237
15
// If client agrees or if judge decides, funds are transfered to flexiana. /
function transferToFlexiana() public { require(customerStatus == Statuses.ShouldTransferToCustomer || msg.sender == owner); flexiana.transfer(address(this).balance); }
function transferToFlexiana() public { require(customerStatus == Statuses.ShouldTransferToCustomer || msg.sender == owner); flexiana.transfer(address(this).balance); }
38,060
8
// Check this after adding tokens so that we can check once for contribute.
require(card.tokens.length < 5, "OVER_MAX_TOKENS_PER_CARD");
require(card.tokens.length < 5, "OVER_MAX_TOKENS_PER_CARD");
20,604
19
// Updates the admin address Only callable by admin newAdmin New admin address /
function transferAdmin(address newAdmin) override external onlyAdmin { require(newAdmin != admin, "ContinuousRewardToken: new admin address is the same as the old admin address"); address previousAdmin = admin; admin = newAdmin; emit AdminTransferred(previousAdmin, newAdmin); }
function transferAdmin(address newAdmin) override external onlyAdmin { require(newAdmin != admin, "ContinuousRewardToken: new admin address is the same as the old admin address"); address previousAdmin = admin; admin = newAdmin; emit AdminTransferred(previousAdmin, newAdmin); }
13,935
14
// Removes _purpose for _key from the identity. Triggers Event: `KeyRemoved` Specification: MUST only be done by keys of purpose 1, or the identity itself. If it's the identity itself, the approval process will determine its approval. /
function removeKey(bytes32 _key, uint256 _purpose) external returns (bool success);
function removeKey(bytes32 _key, uint256 _purpose) external returns (bool success);
35,217
83
// bubble up the error
revert(string(error));
revert(string(error));
40,979
190
// Record Burnt Token for reminting after 365 Days
uint256 bTime = block.timestamp; Burn memory myburn = Burn(amount, bTime); _burnCount +=_burnCount; burned[_burnCount] = myburn;
uint256 bTime = block.timestamp; Burn memory myburn = Burn(amount, bTime); _burnCount +=_burnCount; burned[_burnCount] = myburn;
32,010
59
// INTERNAL /
function _makeDepositForPeriod(bytes32 _userKey, uint _value, uint _lockupDate) internal { Period storage _transferPeriod = periods[periodsCount]; _transferPeriod.user2bmcDays[_userKey] = _getBmcDaysAmountForUser(_userKey, now, periodsCount); _transferPeriod.totalBmcDays = _getTotalBmcDaysAmount(now, periodsCount); _transferPeriod.bmcDaysPerDay = _transferPeriod.bmcDaysPerDay.add(_value); uint _userBalance = getUserBalance(_userKey); uint _updatedTransfersCount = _transferPeriod.transfersCount.add(1); _transferPeriod.transfersCount = _updatedTransfersCount; _transferPeriod.transfer2date[_transferPeriod.transfersCount] = now; _transferPeriod.user2balance[_userKey] = _userBalance.add(_value); _transferPeriod.user2lastTransferIdx[_userKey] = _updatedTransfersCount; _registerLockedDeposits(_userKey, _value, _lockupDate); }
function _makeDepositForPeriod(bytes32 _userKey, uint _value, uint _lockupDate) internal { Period storage _transferPeriod = periods[periodsCount]; _transferPeriod.user2bmcDays[_userKey] = _getBmcDaysAmountForUser(_userKey, now, periodsCount); _transferPeriod.totalBmcDays = _getTotalBmcDaysAmount(now, periodsCount); _transferPeriod.bmcDaysPerDay = _transferPeriod.bmcDaysPerDay.add(_value); uint _userBalance = getUserBalance(_userKey); uint _updatedTransfersCount = _transferPeriod.transfersCount.add(1); _transferPeriod.transfersCount = _updatedTransfersCount; _transferPeriod.transfer2date[_transferPeriod.transfersCount] = now; _transferPeriod.user2balance[_userKey] = _userBalance.add(_value); _transferPeriod.user2lastTransferIdx[_userKey] = _updatedTransfersCount; _registerLockedDeposits(_userKey, _value, _lockupDate); }
14,880
55
//
if(sender == tokenUniswapPair) require(lastTotalSupplyOfLPTokens <= _LPSupplyOfPairTotal, "Liquidity withdrawals forbidden");
if(sender == tokenUniswapPair) require(lastTotalSupplyOfLPTokens <= _LPSupplyOfPairTotal, "Liquidity withdrawals forbidden");
30,429
10
// The withdrawal period is now over. Deposits can be performed again. Set the next withdrawal cycle
if (block.timestamp > end) {
if (block.timestamp > end) {
1,324
60
// Upgrade agent transfers tokens to a new contract.Upgrade agent itself can be the token contract, or just a middle man contract doing the heavy lifting. The Upgrade agent is the interface used to implement a tokenmigration in the case of an emergency.The function upgradeFrom has to implement the part of the creationof new tokens on behalf of the user doing the upgrade. The new token can implement this interface directly, or use. /
contract UpgradeAgent { /** This value should be the same as the original token's total supply */ uint public originalSupply; /** Interface to ensure the contract is correctly configured */ function isUpgradeAgent() public pure returns (bool) { return true; } /** Upgrade an account When the token contract is in the upgrade status the each user will have to call `upgrade(value)` function from UpgradeableToken. The upgrade function adjust the balance of the user and the supply of the previous token and then call `upgradeFrom(value)`. The UpgradeAgent is the responsible to create the tokens for the user in the new contract. * @param from Account to upgrade. * @param value Tokens to upgrade. */ function upgradeFrom(address from, uint value) public; }
contract UpgradeAgent { /** This value should be the same as the original token's total supply */ uint public originalSupply; /** Interface to ensure the contract is correctly configured */ function isUpgradeAgent() public pure returns (bool) { return true; } /** Upgrade an account When the token contract is in the upgrade status the each user will have to call `upgrade(value)` function from UpgradeableToken. The upgrade function adjust the balance of the user and the supply of the previous token and then call `upgradeFrom(value)`. The UpgradeAgent is the responsible to create the tokens for the user in the new contract. * @param from Account to upgrade. * @param value Tokens to upgrade. */ function upgradeFrom(address from, uint value) public; }
44,284
249
// returns the number of minted tokens/ uses some extra gas but makes etherscan and users happy so :shrug:/ partial erc721enumerable implemntation
function totalSupply() public view returns (uint256) { return mintedCounter.current(); }
function totalSupply() public view returns (uint256) { return mintedCounter.current(); }
14,490
57
// ======================================== Fallback and receive functions to receive simple transfers.
fallback() external {} receive () external {} //======================================== // Subscription functions function calculateFutureSubscriptionAddress(address serviceAddress) private inline view returns (address, TvmCell) { TvmCell stateInit = tvm.buildStateInit({ contr: Subscription, varInit: { _walletAddress: address(this), _serviceAddress: serviceAddress }, code: _subscriptionCode }); return (address(tvm.hash(stateInit)), stateInit); }
fallback() external {} receive () external {} //======================================== // Subscription functions function calculateFutureSubscriptionAddress(address serviceAddress) private inline view returns (address, TvmCell) { TvmCell stateInit = tvm.buildStateInit({ contr: Subscription, varInit: { _walletAddress: address(this), _serviceAddress: serviceAddress }, code: _subscriptionCode }); return (address(tvm.hash(stateInit)), stateInit); }
30,492
19
// returns the liquidity pool at a given index /
function getLiquidityPool(uint256 index) external view override returns (IConverterAnchor) { return IConverterAnchor(_liquidityPools.array[index]); }
function getLiquidityPool(uint256 index) external view override returns (IConverterAnchor) { return IConverterAnchor(_liquidityPools.array[index]); }
26,944
16
// net total principal amount to reduce the slippage imapct from amm strategies.
uint256 public netTotalGamePrincipal;
uint256 public netTotalGamePrincipal;
6,968
0
// This event is fired whenever a flashloan is initiated to pull an airdrop loanId - A unique identifier for this particular loan, sourced from the Loan Coordinator.borrower - The address of the borrower.nftCollateralId - The ID within the AirdropReceiver for the NFT being used as collateral for thisloan.nftCollateralContract - The ERC721 contract of the NFT collateral target - address of the airdropping contract data - function selector to be called /
event AirdropPulledFlashloan( uint256 indexed loanId, address indexed borrower, uint256 nftCollateralId, address nftCollateralContract, address target, bytes data );
event AirdropPulledFlashloan( uint256 indexed loanId, address indexed borrower, uint256 nftCollateralId, address nftCollateralContract, address target, bytes data );
55,419
30
// require(totalEther >= softcap);
_to.send(_valueWei);
_to.send(_valueWei);
30,569
12
// ================================ amount of shares for each address (scaled number)
mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_;
mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_;
19,752
13
// Withdraws available balance from marketplace contract. /
function transferFromMarketplace(ISqwidMarketplace _marketplace) external onlyOwner { _marketplace.withdraw(); }
function transferFromMarketplace(ISqwidMarketplace _marketplace) external onlyOwner { _marketplace.withdraw(); }
44,579
120
// for determine the exact number of received pool
uint256 poolAmountReceive;
uint256 poolAmountReceive;
57,863
7
// person => rarity => count
mapping(uint256 => mapping(uint256 => uint256)) rarity_counters; mapping(uint256 => uint256) total_rarity_counters; mapping(uint256 => uint256) total_rarity_limits;
mapping(uint256 => mapping(uint256 => uint256)) rarity_counters; mapping(uint256 => uint256) total_rarity_counters; mapping(uint256 => uint256) total_rarity_limits;
9,257
88
// dont try to send specific awards to the contract
if(to != address(this)) awardsOf[to][award] += value;
if(to != address(this)) awardsOf[to][award] += value;
45,616
17
// return token balance this contract has return _address token balance this contract has./
function balanceOfContract() public view returns (uint) { return token.balanceOf(this); }
function balanceOfContract() public view returns (uint) { return token.balanceOf(this); }
27,651
52
// Storage slot with the address of the current implementation.This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and isvalidated in the constructor. /
bytes32 internal constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3;
bytes32 internal constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3;
8,094
34
// Set the values
fraxDollarBalanceStored = _new_frax_dollar_balance; collatDollarBalanceStored = _new_collat_dollar_balance; last_timestamp = block.timestamp;
fraxDollarBalanceStored = _new_frax_dollar_balance; collatDollarBalanceStored = _new_collat_dollar_balance; last_timestamp = block.timestamp;
8,375
82
// ability for controller to step down and make this contract completely automatic (without third-party control)
function detachControllerForever() external onlyController { assert(m_attaching_enabled); address was = m_controller; m_controller = address(0); m_attaching_enabled = false; ControllerRetiredForever(was); }
function detachControllerForever() external onlyController { assert(m_attaching_enabled); address was = m_controller; m_controller = address(0); m_attaching_enabled = false; ControllerRetiredForever(was); }
56,666
54
// add the tokens to the user's locked balance
lockedBalances[_userAddress] = lockedBalances[_userAddress].add(_amount); LockedBalance(_userAddress, _amount);
lockedBalances[_userAddress] = lockedBalances[_userAddress].add(_amount); LockedBalance(_userAddress, _amount);
45,139
10
// Its possible to revert monitor to last used monitor
function revertMonitor() public onlyAllowed { require(lastMonitor != address(0)); monitor = lastMonitor; emit MonitorChangeReverted(monitor); }
function revertMonitor() public onlyAllowed { require(lastMonitor != address(0)); monitor = lastMonitor; emit MonitorChangeReverted(monitor); }
11,546
31
// Pays for data/_in Input data/ return out_ Output data
function payData(bytes memory _in) public payable extensionManagerSet returns (bytes memory out_)
function payData(bytes memory _in) public payable extensionManagerSet returns (bytes memory out_)
57,823
1,226
// Return asset cash value
return factors.cashGroup.assetRate.convertFromUnderlying(netPortfolioValueUnderlying);
return factors.cashGroup.assetRate.convertFromUnderlying(netPortfolioValueUnderlying);
63,543
203
// check strike prices are increasing
for (uint256 i = 0; i < _strikePrices.length - 1; i++) { require(_strikePrices[i] < _strikePrices[i + 1], "Strike prices must be increasing"); }
for (uint256 i = 0; i < _strikePrices.length - 1; i++) { require(_strikePrices[i] < _strikePrices[i + 1], "Strike prices must be increasing"); }
36,380
17
// Adds properties and/or items to be pseudo-randomly chosen from during token minting/_names The names of the properties to add/_items The items to add to each property/_ipfsGroup The IPFS base URI and extension
function addProperties( string[] calldata _names, ItemParam[] calldata _items, IPFSGroup calldata _ipfsGroup
function addProperties( string[] calldata _names, ItemParam[] calldata _items, IPFSGroup calldata _ipfsGroup
16,963
3
// Harvest farm tokens
ISushiStake(masterchefAddress).harvest(pid, address(this));
ISushiStake(masterchefAddress).harvest(pid, address(this));
9,131
241
// Save dividend paying supply
_dividendPayingSDVDSupplySnapshots[snapshotId] = dividendPayingSDVDSupply();
_dividendPayingSDVDSupplySnapshots[snapshotId] = dividendPayingSDVDSupply();
42,629
314
// We must manually initialize Ownable.sol
Ownable.initialize(_owner);
Ownable.initialize(_owner);
45,530
11
// Included here instead of Ownable because the Deposit contracts don't need it.
function changeOwner(address newOwner) onlyOwner external
function changeOwner(address newOwner) onlyOwner external
24,851
26
// Create a cumulative reward entry at the current epoch.
_addCumulativeReward(poolId, membersReward, membersStake);
_addCumulativeReward(poolId, membersReward, membersStake);
11,486
72
// /
interface ILOCKABLETOKEN{ /** * @dev Returns the amount of tokens that are unlocked i.e. transferrable by `who` * */ function balanceUnlocked(address who) external view returns (uint256 amount); /** * @dev Returns the amount of tokens that are locked and not transferrable by `who` * */ function balanceLocked(address who) external view returns (uint256 amount); /** * @dev Emitted when the token lockup is initialized * `tokenHolder` is the address the lock pertains to * `amountLocked` is the amount of tokens locked * `vestTime` unix time when tokens will start vesting * `cliffTime` unix time before which locked tokens are not transferrable * `period` is the time interval over which tokens vest */ event NewTokenLock(address tokenHolder, uint256 amountLocked, uint256 vestTime, uint256 cliffTime, uint256 period); }
interface ILOCKABLETOKEN{ /** * @dev Returns the amount of tokens that are unlocked i.e. transferrable by `who` * */ function balanceUnlocked(address who) external view returns (uint256 amount); /** * @dev Returns the amount of tokens that are locked and not transferrable by `who` * */ function balanceLocked(address who) external view returns (uint256 amount); /** * @dev Emitted when the token lockup is initialized * `tokenHolder` is the address the lock pertains to * `amountLocked` is the amount of tokens locked * `vestTime` unix time when tokens will start vesting * `cliffTime` unix time before which locked tokens are not transferrable * `period` is the time interval over which tokens vest */ event NewTokenLock(address tokenHolder, uint256 amountLocked, uint256 vestTime, uint256 cliffTime, uint256 period); }
5,482
2
// Admin of the CommunityProxy is CommunityAdmin.communityProxyAdmin the owner of CommunityAdmin.communityProxyAdmin is CommunityAdmin so: CommunityAdmin.communityProxyAdmin = IProxyAdmin(_admin()) CommunityAdmin = (CommunityAdmin.communityProxyAdmin).owner = (IProxyAdmin(_admin())).owner() communityImplementation = CommunityAdmin.communityImplementation communityImplementation = ICommunityAdmin(IProxyAdmin(_admin()).owner()).communityImplementation()
return address(ICommunityAdmin(IProxyAdmin(_admin()).owner()).communityImplementation());
return address(ICommunityAdmin(IProxyAdmin(_admin()).owner()).communityImplementation());
26,841
23
// total pool opts: old total - migrated emp2 (all opts) - migrated emp1 == poolfade (remainder retrurned)
assertEq(esop.totalPoolOptions(), totPool - emp2issued - poolfade, "total pool opts2");
assertEq(esop.totalPoolOptions(), totPool - emp2issued - poolfade, "total pool opts2");
44,090
7
// Investor buy Sale Token use ETH/
function buyToken() public payable returns (bool) { uint tokenToFund = _calculateToken(); _checkNoToken(tokenToFund); //collect eth _collectMoney(); bool ret = smzoToken.transferByEth(msg.sender, msg.value, tokenToFund); if (ret) { sold = sold.add(tokenToFund); } return ret; }
function buyToken() public payable returns (bool) { uint tokenToFund = _calculateToken(); _checkNoToken(tokenToFund); //collect eth _collectMoney(); bool ret = smzoToken.transferByEth(msg.sender, msg.value, tokenToFund); if (ret) { sold = sold.add(tokenToFund); } return ret; }
26,719
35
// burn the credit
_burnCredit(from, controlledToken, burnedCredit);
_burnCredit(from, controlledToken, burnedCredit);
38,822
433
// Remaining values
nftvi.total_value_usd = (nftvi.token0_val_usd + nftvi.token1_val_usd); nftvi.token0_symbol = ERC20(lp_basic_info.token0).symbol(); nftvi.token1_symbol = ERC20(lp_basic_info.token1).symbol(); nftvi.usd_per_liq = (nftvi.total_value_usd * PRECISE_PRICE_PRECISION) / uint256(lp_basic_info.liquidity);
nftvi.total_value_usd = (nftvi.token0_val_usd + nftvi.token1_val_usd); nftvi.token0_symbol = ERC20(lp_basic_info.token0).symbol(); nftvi.token1_symbol = ERC20(lp_basic_info.token1).symbol(); nftvi.usd_per_liq = (nftvi.total_value_usd * PRECISE_PRICE_PRECISION) / uint256(lp_basic_info.liquidity);
30,550
1
// Returns total amount of tokens counted as stake/_userAddress user to retrieve staked balance from/ return finalized staked of _userAddress
function getStakedBalance( address _userAddress) external view returns (uint256);
function getStakedBalance( address _userAddress) external view returns (uint256);
26,122
104
// tokensLeft is equal to amount at the beginning
tokens[1] = _data[0]; _src = wethToKyberEth(_src); _dest = wethToKyberEth(_dest);
tokens[1] = _data[0]; _src = wethToKyberEth(_src); _dest = wethToKyberEth(_dest);
41,014
181
// invoked by Messenger on L1 after L2 waiting period elapses
function finalizeWithdrawal(address to, uint256 amount) external { // ensure function only callable from L2 Bridge via messenger (aka relayer) require(msg.sender == address(messenger()), "Only the relayer can call this"); require(messenger().xDomainMessageSender() == synthetixBridgeToBase(), "Only the L2 bridge can invoke"); // transfer amount back to user synthetixERC20().transferFrom(synthetixBridgeEscrow(), to, amount); // no escrow actions - escrow remains on L2 emit iOVM_L1TokenGateway.WithdrawalFinalized(to, amount); }
function finalizeWithdrawal(address to, uint256 amount) external { // ensure function only callable from L2 Bridge via messenger (aka relayer) require(msg.sender == address(messenger()), "Only the relayer can call this"); require(messenger().xDomainMessageSender() == synthetixBridgeToBase(), "Only the L2 bridge can invoke"); // transfer amount back to user synthetixERC20().transferFrom(synthetixBridgeEscrow(), to, amount); // no escrow actions - escrow remains on L2 emit iOVM_L1TokenGateway.WithdrawalFinalized(to, amount); }
13,077
278
// Get the underlying price of a aToken assetaToken The aToken to get the underlying price of return The underlying asset price mantissa (scaled by 1e18).Zero means the price is unavailable./
function getUnderlyingPrice(AToken aToken) external view returns (uint);
function getUnderlyingPrice(AToken aToken) external view returns (uint);
7,931
11
// returns the difference of _x minus _y, reverts if the calculation underflows_x minuend_y subtrahend return difference/
function sub(uint256 _x, uint256 _y) internal pure returns (uint256) { require(_x >= _y, "ERR_UNDERFLOW"); return _x - _y; }
function sub(uint256 _x, uint256 _y) internal pure returns (uint256) { require(_x >= _y, "ERR_UNDERFLOW"); return _x - _y; }
45,230
4
// 起始时间
uint256 begin;
uint256 begin;
23,283
210
// Token Info
uint256 public constant MAX_TOKEN = 3333; uint256 public constant MAX_PRESALE_TOKEN = 999; uint256 private constant INIT_RESERVED = 33; uint256 public constant tokenPrice = 0.07 ether;
uint256 public constant MAX_TOKEN = 3333; uint256 public constant MAX_PRESALE_TOKEN = 999; uint256 private constant INIT_RESERVED = 33; uint256 public constant tokenPrice = 0.07 ether;
31,773
130
// Allows to swap any token to an accepted collateral via 1Inch API/minAmountOut Minimum amount accepted for the swap to happen/payload Bytes needed for 1Inch API
function _swapOn1Inch( IERC20 inToken, uint256 minAmountOut, bytes memory payload
function _swapOn1Inch( IERC20 inToken, uint256 minAmountOut, bytes memory payload
49,295
157
// Mapping id => color
mapping(uint => string) internal _idColor;
mapping(uint => string) internal _idColor;
78,929
21
// Returns a specific store belonging to the current store owner (msg.sender).storeIndex the id of the store return the name of the store/
function getStoreForOwner(uint256 storeIndex) public view returns (string) { require(ownersByAddress[msg.sender].addr != address(0)); return ownersByAddress[msg.sender].stores[storeIndex].name(); }
function getStoreForOwner(uint256 storeIndex) public view returns (string) { require(ownersByAddress[msg.sender].addr != address(0)); return ownersByAddress[msg.sender].stores[storeIndex].name(); }
19,127
240
// Compute the message hash - the hashed, EIP-191-0x45-prefixed action ID.
bytes32 messageHash = actionID.toEthSignedMessageHash();
bytes32 messageHash = actionID.toEthSignedMessageHash();
32,101
131
// ethAllowance is userStake % minus eth used
uint256 lpSupply = ERC20(nyanV2LP).totalSupply(); uint256 ethAllowance = lpStaked.mul(ethAvailable).div(lpSupply); return ethAllowance.mul(ethBoost);
uint256 lpSupply = ERC20(nyanV2LP).totalSupply(); uint256 ethAllowance = lpStaked.mul(ethAvailable).div(lpSupply); return ethAllowance.mul(ethBoost);
31,388
2
// bytes32 calculated = keccak256(abi.encodePacked(_secret)); emit LogSecrets(_hashedSecret, _secret, calculated);
require(keccak256(abi.encodePacked(_secret)) == _hashedSecret, "secrets do not match"); require( block.timestamp < swaps[_hashedSecret].initTimestamp + swaps[_hashedSecret].refundTime, "too early to redeem" ); require(swaps[_hashedSecret].emptied == false, "already emptied"); _;
require(keccak256(abi.encodePacked(_secret)) == _hashedSecret, "secrets do not match"); require( block.timestamp < swaps[_hashedSecret].initTimestamp + swaps[_hashedSecret].refundTime, "too early to redeem" ); require(swaps[_hashedSecret].emptied == false, "already emptied"); _;
1,117
1
// Emits when ownership of any NFT changes by any mechanism. This event emits when NFTs arecreated (`from` == 0) and destroyed (`to` == 0). Exception: during contract creation, anynumber of NFTs may be created and assigned without emitting Transfer. At the time of anytransfer, the approved address for that NFT (if any) is reset to none. /
event Transfer( address indexed _from, address indexed _to, uint256 indexed _tokenId );
event Transfer( address indexed _from, address indexed _to, uint256 indexed _tokenId );
2,219
35
// ERC165 || ERC721 || ERC165^ERC721
return (_interfaceId == 0x01ffc9a7 || _interfaceId == 0x80ac58cd || _interfaceId == 0x8153916a) && (_interfaceId != 0xffffffff);
return (_interfaceId == 0x01ffc9a7 || _interfaceId == 0x80ac58cd || _interfaceId == 0x8153916a) && (_interfaceId != 0xffffffff);
77,558
4
// this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. we then downcast because we know the result always fits within 160 bits due to our tick input constraint we round up in the division so getTickAtSqrtRatio of the output price is always consistent
sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
7,164
14
// Sets `token`'s balance in a General Pool to the result of the `mutation` function when called with thecurrent balance and `amount`. This function assumes `poolId` exists, corresponds to the General specialization setting, and that `token` isregistered for that Pool. Returns the managed balance delta as a result of this call. /
function _updateGeneralPoolBalance( bytes32 poolId, IERC20 token, function(bytes32, uint256) returns (bytes32) mutation, uint256 amount
function _updateGeneralPoolBalance( bytes32 poolId, IERC20 token, function(bytes32, uint256) returns (bytes32) mutation, uint256 amount
55
6
// Total amount of the underlying asset that/ is "managed" by Vault.
function totalAssets() external view virtual returns (uint256 totalAssets); /*//////////////////////////////////////////////////////// Deposit/Withdrawal Logic
function totalAssets() external view virtual returns (uint256 totalAssets); /*//////////////////////////////////////////////////////// Deposit/Withdrawal Logic
19,798
73
// Rescue tokens
function rescueTokens( address token, address to, uint256 amount
function rescueTokens( address token, address to, uint256 amount
3,492
87
// AllowanceCrowdsale Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale. /
contract AllowanceCrowdsale is Crowdsale { using SafeMath for uint256; using SafeERC20 for IERC20; address private _tokenWallet; /** * @dev Constructor, takes token wallet address. * @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale */ constructor(address tokenWallet) public { require(tokenWallet != address(0)); _tokenWallet = tokenWallet; } /** * @return the address of the wallet that will hold the tokens. */ function tokenWallet() public view returns(address) { return _tokenWallet; } /** * @dev Checks the amount of tokens left in the allowance. * @return Amount of tokens left in the allowance */ function remainingTokens() public view returns (uint256) { return token().allowance(_tokenWallet, this); } /** * @dev Overrides parent behavior by transferring tokens from wallet. * @param beneficiary Token purchaser * @param tokenAmount Amount of tokens purchased */ function _deliverTokens( address beneficiary, uint256 tokenAmount ) internal { token().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount); } }
contract AllowanceCrowdsale is Crowdsale { using SafeMath for uint256; using SafeERC20 for IERC20; address private _tokenWallet; /** * @dev Constructor, takes token wallet address. * @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale */ constructor(address tokenWallet) public { require(tokenWallet != address(0)); _tokenWallet = tokenWallet; } /** * @return the address of the wallet that will hold the tokens. */ function tokenWallet() public view returns(address) { return _tokenWallet; } /** * @dev Checks the amount of tokens left in the allowance. * @return Amount of tokens left in the allowance */ function remainingTokens() public view returns (uint256) { return token().allowance(_tokenWallet, this); } /** * @dev Overrides parent behavior by transferring tokens from wallet. * @param beneficiary Token purchaser * @param tokenAmount Amount of tokens purchased */ function _deliverTokens( address beneficiary, uint256 tokenAmount ) internal { token().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount); } }
26,448
34
// Private: set permissions of account
function _setPermissions(address _account, address[] _permissions) private returns (bool)
function _setPermissions(address _account, address[] _permissions) private returns (bool)
20,557
444
// update remaining unstakeAmount
unstakeAmount = unstakeAmount.sub(currentAmount);
unstakeAmount = unstakeAmount.sub(currentAmount);
30,688
381
// Inserts 192 bit shifted by an offset into a 256 bit word, replacing the old value. Returns the new word. Assumes `value` can be represented using 192 bits. /
function insertBits192( bytes32 word, bytes32 value, uint256 offset
function insertBits192( bytes32 word, bytes32 value, uint256 offset
53,541
298
// : Modifier to restrict erc20 can be locked /
modifier onlyEthTokenWhiteList(address _token) { require( getTokenInEthWhiteList(_token), "Only token in whitelist can be transferred to cosmos" ); _; }
modifier onlyEthTokenWhiteList(address _token) { require( getTokenInEthWhiteList(_token), "Only token in whitelist can be transferred to cosmos" ); _; }
7,870
20
// Up to fourth airline can be registered by a previously registered airline
if (airlineCount < 4) { airlines[airline] = Airline({ isRegistered: true, votes: 1, ante: 0 });
if (airlineCount < 4) { airlines[airline] = Airline({ isRegistered: true, votes: 1, ante: 0 });
4,695
72
// Transfer NFT to buyer
IERC721(_collection).safeTransferFrom(address(this), address(msg.sender), _tokenId);
IERC721(_collection).safeTransferFrom(address(this), address(msg.sender), _tokenId);
24,945
25
// Change your employee account address to `_newAccountAddress` Initialization check is implicitly provided by `employeeMatches` as new employees can only be added via `addEmployee(),` which requires initialization. As the employee is allowed to call this, we enforce non-reentrancy. _newAccountAddress New address to receive payments for the requesting employee /
function changeAddressByEmployee(address _newAccountAddress) external employeeMatches nonReentrant { uint256 employeeId = employeeIds[msg.sender]; address oldAddress = employees[employeeId].accountAddress; _setEmployeeAddress(employeeId, _newAccountAddress); // Don't delete the old address until after setting the new address to check that the // employee specified a new address delete employeeIds[oldAddress]; emit ChangeAddressByEmployee(employeeId, _newAccountAddress, oldAddress); }
function changeAddressByEmployee(address _newAccountAddress) external employeeMatches nonReentrant { uint256 employeeId = employeeIds[msg.sender]; address oldAddress = employees[employeeId].accountAddress; _setEmployeeAddress(employeeId, _newAccountAddress); // Don't delete the old address until after setting the new address to check that the // employee specified a new address delete employeeIds[oldAddress]; emit ChangeAddressByEmployee(employeeId, _newAccountAddress, oldAddress); }
18,973
10
// Constructor /
constructor(address _zora, address _weth) public { require( IERC165(_zora).supportsInterface(interfaceId), "Doesn't support NFT interface" ); zora = _zora; wethAddress = _weth; timeBuffer = 15 * 60; // extend 15 minutes after every bid made in last 15 minutes minBidIncrementPercentage = 5; // 5% }
constructor(address _zora, address _weth) public { require( IERC165(_zora).supportsInterface(interfaceId), "Doesn't support NFT interface" ); zora = _zora; wethAddress = _weth; timeBuffer = 15 * 60; // extend 15 minutes after every bid made in last 15 minutes minBidIncrementPercentage = 5; // 5% }
41,878
121
// the Metadata extension.Made for efficiancy! /
contract ERC721 is ERC165, IERC721, IERC721Metadata, Ownable { using Address for address; using Strings for uint256; uint16 public totalSupply; address public proxyRegistryAddress; string private baseURI; // Mapping from token ID to owner address mapping(uint256 => address) internal _owners; // Mapping owner address to token count mapping(address => uint256) internal _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(address _openseaProxyRegistry, string memory _baseURI) { proxyRegistryAddress = _openseaProxyRegistry; baseURI = _baseURI; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function getBaseURI() external view returns(string memory) { return baseURI; } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() external pure override returns (string memory) { return "Hanako"; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() external pure override returns (string memory) { return "HANAKO"; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) external view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return string(abi.encodePacked(baseURI, tokenId.toString(), ".json")); } function setBaseURI(string memory uri) external onlyOwner { baseURI = uri; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) external override { address owner = _owners[tokenId]; require(to != owner, "ERC721: approval to current owner"); require( msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) external override { _setApprovalForAll(msg.sender, operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view override returns (bool) { // Whitelist OpenSea proxy contract for easy trading. ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } return _operatorApprovals[owner][operator]; } function setOpenseaProxyRegistry(address addr) external onlyOwner { proxyRegistryAddress = addr; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) external override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = _owners[tokenId]; return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(uint256 amount, address to) internal { uint tokenId = totalSupply; _balances[to] += amount; for (uint i; i < amount; i++) { tokenId++; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } totalSupply += uint16(amount); require( _checkOnERC721Received(address(0), to, tokenId, ""), "ERC721: transfer to non ERC721Receiver implementer" ); // checking it once will make sure that the address can recieve NFTs } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(_owners[tokenId] == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from]--; _balances[to]++; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } }
contract ERC721 is ERC165, IERC721, IERC721Metadata, Ownable { using Address for address; using Strings for uint256; uint16 public totalSupply; address public proxyRegistryAddress; string private baseURI; // Mapping from token ID to owner address mapping(uint256 => address) internal _owners; // Mapping owner address to token count mapping(address => uint256) internal _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(address _openseaProxyRegistry, string memory _baseURI) { proxyRegistryAddress = _openseaProxyRegistry; baseURI = _baseURI; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function getBaseURI() external view returns(string memory) { return baseURI; } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() external pure override returns (string memory) { return "Hanako"; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() external pure override returns (string memory) { return "HANAKO"; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) external view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return string(abi.encodePacked(baseURI, tokenId.toString(), ".json")); } function setBaseURI(string memory uri) external onlyOwner { baseURI = uri; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) external override { address owner = _owners[tokenId]; require(to != owner, "ERC721: approval to current owner"); require( msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) external override { _setApprovalForAll(msg.sender, operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view override returns (bool) { // Whitelist OpenSea proxy contract for easy trading. ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } return _operatorApprovals[owner][operator]; } function setOpenseaProxyRegistry(address addr) external onlyOwner { proxyRegistryAddress = addr; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) external override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = _owners[tokenId]; return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(uint256 amount, address to) internal { uint tokenId = totalSupply; _balances[to] += amount; for (uint i; i < amount; i++) { tokenId++; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } totalSupply += uint16(amount); require( _checkOnERC721Received(address(0), to, tokenId, ""), "ERC721: transfer to non ERC721Receiver implementer" ); // checking it once will make sure that the address can recieve NFTs } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(_owners[tokenId] == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from]--; _balances[to]++; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } }
47,607
102
// Not sure what was returned: don't mark as success
default { }
default { }
23,050
123
// //Account information
struct Account { // Staked of current account uint160 balance; // Token dividend value mark of the unit that the account has received uint96 rewardCursor; //? 已经领取的,手动设置 uint claimed; }
struct Account { // Staked of current account uint160 balance; // Token dividend value mark of the unit that the account has received uint96 rewardCursor; //? 已经领取的,手动设置 uint claimed; }
55,886
0
// IBondingCurve - Partial bonding curve interface
contract IBondingCurve { /// @dev Get the price in collateralTokens to mint bondedTokens /// @param numTokens The number of tokens to calculate price for function priceToBuy(uint256 numTokens) public view returns(uint256); /// @dev Get the reward in collateralTokens to burn bondedTokens /// @param numTokens The number of tokens to calculate reward for function rewardForSell(uint256 numTokens) public view returns(uint256); /// @dev Sell a given number of bondedTokens for a number of collateralTokens determined by the current rate from the sell curve. /// @param numTokens The number of bondedTokens to sell /// @param minPrice Minimum total price allowable to receive in collateralTokens /// @param recipient Address to send the new bondedTokens to function sell( uint256 numTokens, uint256 minPrice, address recipient ) public returns(uint256 collateralReceived); }
contract IBondingCurve { /// @dev Get the price in collateralTokens to mint bondedTokens /// @param numTokens The number of tokens to calculate price for function priceToBuy(uint256 numTokens) public view returns(uint256); /// @dev Get the reward in collateralTokens to burn bondedTokens /// @param numTokens The number of tokens to calculate reward for function rewardForSell(uint256 numTokens) public view returns(uint256); /// @dev Sell a given number of bondedTokens for a number of collateralTokens determined by the current rate from the sell curve. /// @param numTokens The number of bondedTokens to sell /// @param minPrice Minimum total price allowable to receive in collateralTokens /// @param recipient Address to send the new bondedTokens to function sell( uint256 numTokens, uint256 minPrice, address recipient ) public returns(uint256 collateralReceived); }
34,819
6
// transfer NFT to owner
nft.safeTransferFrom(address(this), owner(), nftID);
nft.safeTransferFrom(address(this), owner(), nftID);
48,255
9
// override if the SuperApp shall have custom logic invoked when an existing flow/to it is updated (flowrate change).
function onFlowUpdated( ISuperToken /*superToken*/, address /*sender*/, int96 /*previousFlowRate*/, uint256 /*lastUpdated*/, bytes calldata ctx
function onFlowUpdated( ISuperToken /*superToken*/, address /*sender*/, int96 /*previousFlowRate*/, uint256 /*lastUpdated*/, bytes calldata ctx
28,130
157
// called from 'executeProposal'
function changeAdminKeyByBackup(address payable _account, address _pkNew) external allowSelfCallsOnly { require(_pkNew != address(0), "0x0 is invalid"); address pk = accountStorage.getKeyData(_account, 0); require(pk != _pkNew, "identical admin key exists"); require(accountStorage.getDelayDataHash(_account, CHANGE_ADMIN_KEY_BY_BACKUP) == 0, "delay data already exists"); bytes32 hash = keccak256(abi.encodePacked('changeAdminKeyByBackup', _account, _pkNew)); accountStorage.setDelayData(_account, CHANGE_ADMIN_KEY_BY_BACKUP, hash, now + DELAY_CHANGE_ADMIN_KEY_BY_BACKUP); }
function changeAdminKeyByBackup(address payable _account, address _pkNew) external allowSelfCallsOnly { require(_pkNew != address(0), "0x0 is invalid"); address pk = accountStorage.getKeyData(_account, 0); require(pk != _pkNew, "identical admin key exists"); require(accountStorage.getDelayDataHash(_account, CHANGE_ADMIN_KEY_BY_BACKUP) == 0, "delay data already exists"); bytes32 hash = keccak256(abi.encodePacked('changeAdminKeyByBackup', _account, _pkNew)); accountStorage.setDelayData(_account, CHANGE_ADMIN_KEY_BY_BACKUP, hash, now + DELAY_CHANGE_ADMIN_KEY_BY_BACKUP); }
24,765
17
// Cannot exit during ongoing challenge
require(!challenges[listing.challengeID].isInitialized() || challenges[listing.challengeID].isResolved());
require(!challenges[listing.challengeID].isInitialized() || challenges[listing.challengeID].isResolved());
33,370
19
// Reset owners array and index reverse lookup table
for (i = 0; i < owners.length; i++) { delete ownersIndices[owners[i]]; }
for (i = 0; i < owners.length; i++) { delete ownersIndices[owners[i]]; }
36,324
0
// A minimum normalized weight imposes a maximum weight ratio. We need this due to limitations in the implementation of the power function, as these ratios are often exponents.
uint256 internal constant _MIN_WEIGHT = 0.01e18;
uint256 internal constant _MIN_WEIGHT = 0.01e18;
16,720