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
29
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument. mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. success := and(
mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument. mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. success := and(
2,848
100
// Fees 30% in total - 0% devFundFee for development fund - 0% comFundFee for community fund - 30% used to burn/repurchase btfs which will be sent to profit pool
uint256 public devFundFee = 0; uint256 public constant devFundMax = 10000; uint256 public comFundFee = 0; uint256 public constant comFundMax = 10000; uint256 public burnFee = 3000; uint256 public constant burnMax = 10000;
uint256 public devFundFee = 0; uint256 public constant devFundMax = 10000; uint256 public comFundFee = 0; uint256 public constant comFundMax = 10000; uint256 public burnFee = 3000; uint256 public constant burnMax = 10000;
25,818
3
// GraphCurationToken contract This is the implementation of the Curation ERC20 token (GCS). GCS are created for each subgraph deployment curated in the Curation contract.The Curation contract is the owner of GCS tokens and the only one allowed to mint orburn them. GCS tokens are transferrable and their holders can do any action allowedin a standard ERC20 token implementation except for burning them. This contract is meant to be used as the implementation for Minimal Proxy clones forgas-saving purposes. /
contract GraphCurationToken is ERC20Upgradeable, Governed { /** * @dev Graph Curation Token Contract initializer. * @param _owner Address of the contract issuing this token */ function initialize(address _owner) external initializer { Governed._initialize(_owner); ERC20Upgradeable.__ERC20_init("Graph Curation Share", "GCS"); } /** * @dev Mint new tokens. * @param _to Address to send the newly minted tokens * @param _amount Amount of tokens to mint */ function mint(address _to, uint256 _amount) public onlyGovernor { _mint(_to, _amount); } /** * @dev Burn tokens from an address. * @param _account Address from where tokens will be burned * @param _amount Amount of tokens to burn */ function burnFrom(address _account, uint256 _amount) public onlyGovernor { _burn(_account, _amount); } }
contract GraphCurationToken is ERC20Upgradeable, Governed { /** * @dev Graph Curation Token Contract initializer. * @param _owner Address of the contract issuing this token */ function initialize(address _owner) external initializer { Governed._initialize(_owner); ERC20Upgradeable.__ERC20_init("Graph Curation Share", "GCS"); } /** * @dev Mint new tokens. * @param _to Address to send the newly minted tokens * @param _amount Amount of tokens to mint */ function mint(address _to, uint256 _amount) public onlyGovernor { _mint(_to, _amount); } /** * @dev Burn tokens from an address. * @param _account Address from where tokens will be burned * @param _amount Amount of tokens to burn */ function burnFrom(address _account, uint256 _amount) public onlyGovernor { _burn(_account, _amount); } }
1,608
149
// Random DS Proof Step 1: The prefix has to match 'LP\x01' (Ledger Proof version 1)
if ((_proof[0] != "L") || (_proof[1] != "P") || (uint8(_proof[2]) != uint8(1))) { return 1; }
if ((_proof[0] != "L") || (_proof[1] != "P") || (uint8(_proof[2]) != uint8(1))) { return 1; }
1,557
14
// Fallback function for receiving payments
function() public payable { // Don't need to do anything }
function() public payable { // Don't need to do anything }
9,014
40
// Trade start check
if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); }
if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); }
38,720
61
// 获得token直接给V2
mstore(ptr,0x022c0d9f) mstore(add(ptr,0x20),div(calldataload(0xc4),0x100000000000000000000000000000000)) mstore(add(ptr,0x40),and(calldataload(0xc4),0xffffffffffffffffffffffffffffffff)) mstore(add(ptr,0x60),nextAddr) mstore(add(ptr,0x80),0x80) mstore(add(ptr,0xa0),0x0) result := call(gas(), addr, 0, funcPtr, 0xa4, ptr, 0x0)
mstore(ptr,0x022c0d9f) mstore(add(ptr,0x20),div(calldataload(0xc4),0x100000000000000000000000000000000)) mstore(add(ptr,0x40),and(calldataload(0xc4),0xffffffffffffffffffffffffffffffff)) mstore(add(ptr,0x60),nextAddr) mstore(add(ptr,0x80),0x80) mstore(add(ptr,0xa0),0x0) result := call(gas(), addr, 0, funcPtr, 0xa4, ptr, 0x0)
19,613
7
// maps dna to bool if claimed to avoid duplicates
mapping (uint256 => bool) public DnaToClaimedMap;
mapping (uint256 => bool) public DnaToClaimedMap;
17,322
2
// Returns staked amount by wallet address /
function balanceOf( address _walletAddress ) external view returns (uint256)
function balanceOf( address _walletAddress ) external view returns (uint256)
29,567
73
// The maximum value of a uint256 contains 78 digits (1 byte per digit), but we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned. We will need 1 word for the trailing zeros padding, 1 word for the length, and 3 words for a maximum of 78 digits.
str := add(mload(0x40), 0x80)
str := add(mload(0x40), 0x80)
14,433
59
// true if (cEth APR - cDai APR) >= (aEth APR - aDai APR), otherwise, false
function findBestRate() public view returns (bool) { return AaveDaiAPR().mul(targetRatio).div(1e18).add(CompoundEthAPR()) > CompoundDaiAPR().mul(targetRatio).div(1e18).add(AaveEthAPR()); }
function findBestRate() public view returns (bool) { return AaveDaiAPR().mul(targetRatio).div(1e18).add(CompoundEthAPR()) > CompoundDaiAPR().mul(targetRatio).div(1e18).add(AaveEthAPR()); }
3,725
20
// approve a contract to be used during harvesting
function allowHarvester(address target, bool allowed) public onlyOwner { if (allowed) { _allHarvesters.push(target); } allowedHarvesters[target] = allowed; emit UpdateAllowedHarvester(target, allowed); }
function allowHarvester(address target, bool allowed) public onlyOwner { if (allowed) { _allHarvesters.push(target); } allowedHarvesters[target] = allowed; emit UpdateAllowedHarvester(target, allowed); }
19,874
44
// Modifier to allow function calls only from the Manager. /
modifier onlyManager() { require(msg.sender == _manager(), "Only manager can execute"); _; }
modifier onlyManager() { require(msg.sender == _manager(), "Only manager can execute"); _; }
15,444
15
// See {ITrustedIssuersRegistry-hasClaimTopic}. /
function hasClaimTopic(address _issuer, uint256 _claimTopic) external view override returns (bool) { uint256 length = _trustedIssuerClaimTopics[_issuer].length; uint256[] memory claimTopics = _trustedIssuerClaimTopics[_issuer]; for (uint256 i = 0; i < length; i++) { if (claimTopics[i] == _claimTopic) { return true; }
function hasClaimTopic(address _issuer, uint256 _claimTopic) external view override returns (bool) { uint256 length = _trustedIssuerClaimTopics[_issuer].length; uint256[] memory claimTopics = _trustedIssuerClaimTopics[_issuer]; for (uint256 i = 0; i < length; i++) { if (claimTopics[i] == _claimTopic) { return true; }
4,144
40
// view balanceOfStaged (amount that is staged)
function getBalanceOfStaged() external view returns (uint256) { return esds.balanceOfStaged(address(this)); }
function getBalanceOfStaged() external view returns (uint256) { return esds.balanceOfStaged(address(this)); }
10,741
21
// Delegates the current call to nftImplementation. This function does not return to its internall call site, it will return directly to the external caller. /
function _fallback() internal virtual { address impl = address(nftImplementation); assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), impl, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } }
function _fallback() internal virtual { address impl = address(nftImplementation); assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), impl, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } }
29,461
7
// length
function ln_() external view isOwnerOrManager returns (uint) { return mediators.length; }
function ln_() external view isOwnerOrManager returns (uint) { return mediators.length; }
35,257
6
// 28 first epochs (1 week) with 4.5% expansion regardless of PegToken price
uint256 public bootstrapEpochs; uint256 public bootstrapSupplyExpansionPercent;
uint256 public bootstrapEpochs; uint256 public bootstrapSupplyExpansionPercent;
8,812
50
// Exclude the owner and this contract from fees
_isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true;
5,219
46
// Transfers the StakeAmount from the reporded miner to the reporting party
TellorTransfer.doTransfer(self, disp.reportedMiner, disp.reportingParty, self.uintVars[keccak256("stakeAmount")]);
TellorTransfer.doTransfer(self, disp.reportedMiner, disp.reportingParty, self.uintVars[keccak256("stakeAmount")]);
15,316
3
// Maximum integer (used for managing allowance)
uint256 public constant MAX_INT = 2 ** 256 - 1;
uint256 public constant MAX_INT = 2 ** 256 - 1;
10,458
0
// Structs /
struct MintData
struct MintData
8,478
48
// call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)it is assumed that when does this that the call should succeed, otherwise one would use vanilla approve instead.if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { revert(); }
ApprovalReceiver(_spender).receiveApproval(msg.sender, _value, this, _extraData); return true;
ApprovalReceiver(_spender).receiveApproval(msg.sender, _value, this, _extraData); return true;
22,544
1
// --- Events ---
event OrumTokenAddressSet(address _orumTokenAddress); event StabilityPoolAddressSet(address _stabilityPoolAddress); event TotalOrumIssuedUpdated(uint _totalOrumIssued);
event OrumTokenAddressSet(address _orumTokenAddress); event StabilityPoolAddressSet(address _stabilityPoolAddress); event TotalOrumIssuedUpdated(uint _totalOrumIssued);
2,054
28
// Validating mint passes
for (uint256 index = 0; index < guids.length; index++) {
for (uint256 index = 0; index < guids.length; index++) {
36,796
4
// It checks if token is stable coin
mapping(address => bool) public isStableToken; address[] public allStableTokens;
mapping(address => bool) public isStableToken; address[] public allStableTokens;
36,339
54
// ERC20 token address
address public immutable token;
address public immutable token;
19,147
35
// De-list token on transfer.
function _beforeTokenTransfer(
function _beforeTokenTransfer(
1,171
0
// Le mot clé "public" rend ces variables/ Structure Utilisateur /
struct User { /* Adresse (hash) de l'utilisateur (deprecated) */ bytes32 userAddress; /* Montant de QC que possède l'utilisateur */ uint coins; /* Adresses des transactions de l'utilisateur */ mapping (uint => uint) transactions; /* Nombre de transactions */ uint userNumberOfTransactionsInLedger; }
struct User { /* Adresse (hash) de l'utilisateur (deprecated) */ bytes32 userAddress; /* Montant de QC que possède l'utilisateur */ uint coins; /* Adresses des transactions de l'utilisateur */ mapping (uint => uint) transactions; /* Nombre de transactions */ uint userNumberOfTransactionsInLedger; }
34,899
27
// should be safe because a team can't be killed if there are 0 teams to kill.
Battleboards[battleboardId].numTeams1 -= 1;
Battleboards[battleboardId].numTeams1 -= 1;
10,871
236
// Returns the amount of votes that `account` had at the end of a past block (`blockNumber`). Requirements: - `blockNumber` must have been already mined /
function getPastVotes(address account, uint256 blockNumber) public view virtual override returns (uint256)
function getPastVotes(address account, uint256 blockNumber) public view virtual override returns (uint256)
20,018
9
// Map a token to enable its movement via the PoS Portal, callable only by mappers rootToken address of token on root chain /
function mapToken(address rootToken) public { // check if token is already mapped require(rootToChildTokens[rootToken] == address(0x0), "FxERC721RootTunnel: ALREADY_MAPPED"); // name, symbol ERC721 rootTokenContract = ERC721(rootToken); string memory name = rootTokenContract.name(); string memory symbol = rootTokenContract.symbol(); // MAP_TOKEN, encode(rootToken, name, symbol) bytes memory message = abi.encode(MAP_TOKEN, abi.encode(rootToken, name, symbol)); _sendMessageToChild(message); // compute child token address before deployment using create2 bytes32 salt = keccak256(abi.encodePacked(rootToken)); address childToken = computedCreate2Address(salt, childTokenTemplateCodeHash, fxChildTunnel); // add into mapped tokens rootToChildTokens[rootToken] = childToken; emit TokenMappedERC721(rootToken, childToken); }
function mapToken(address rootToken) public { // check if token is already mapped require(rootToChildTokens[rootToken] == address(0x0), "FxERC721RootTunnel: ALREADY_MAPPED"); // name, symbol ERC721 rootTokenContract = ERC721(rootToken); string memory name = rootTokenContract.name(); string memory symbol = rootTokenContract.symbol(); // MAP_TOKEN, encode(rootToken, name, symbol) bytes memory message = abi.encode(MAP_TOKEN, abi.encode(rootToken, name, symbol)); _sendMessageToChild(message); // compute child token address before deployment using create2 bytes32 salt = keccak256(abi.encodePacked(rootToken)); address childToken = computedCreate2Address(salt, childTokenTemplateCodeHash, fxChildTunnel); // add into mapped tokens rootToChildTokens[rootToken] = childToken; emit TokenMappedERC721(rootToken, childToken); }
55,822
46
// called by the owner of the contract to rescue the token from the contract/ amount amount of token to withdraw
function withdrawToken(uint256 amount) external onlyOwner{ IERC20(token).transfer(msg.sender, amount); }
function withdrawToken(uint256 amount) external onlyOwner{ IERC20(token).transfer(msg.sender, amount); }
3,965
471
// allows the owner to set the oracle address to use for value conversionssetting the _oracleAddress to address(0) removes support for the token This will also call update to ensure at least one datapoint has been recorded. /
function setOracle( address _tokenAddress, address _oracleAddress ) external;
function setOracle( address _tokenAddress, address _oracleAddress ) external;
27,038
268
// res += valcoefficients[40].
res := addmod(res, mulmod(val, /*coefficients[40]*/ mload(0xa40), PRIME), PRIME)
res := addmod(res, mulmod(val, /*coefficients[40]*/ mload(0xa40), PRIME), PRIME)
33,815
76
// Gets the current votes balance for `account` account The address to get votes balancereturn The number of current votes for `account` /
function getCurrentVotes(address account) external view returns (uint96) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; }
function getCurrentVotes(address account) external view returns (uint96) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; }
4,587
181
// ===== Permissioned Actions: Governance =====
function setFarmPerformanceFeeGovernance(uint256 _fee) external { _onlyGovernance(); farmPerformanceFeeGovernance = _fee; }
function setFarmPerformanceFeeGovernance(uint256 _fee) external { _onlyGovernance(); farmPerformanceFeeGovernance = _fee; }
25,103
94
// raised when an address is zero
error NonZeroAddress(address addr);
error NonZeroAddress(address addr);
32,149
26
// send tokens
function transfer(address _to, uint256 _value) public returns (bool success) { require(_balanceOf[msg.sender] >= _value); _transfer(msg.sender, _to, _value); return true; }
function transfer(address _to, uint256 _value) public returns (bool success) { require(_balanceOf[msg.sender] >= _value); _transfer(msg.sender, _to, _value); return true; }
32,298
15
// dezasociaza contul curent de compania ei veche (daca era asociat inainte cu o alta companie)
if (bytes(companies[msg.sender]).length != 0) { companyAddresses[companies[msg.sender]] = address(0); companies[msg.sender] = ""; }
if (bytes(companies[msg.sender]).length != 0) { companyAddresses[companies[msg.sender]] = address(0); companies[msg.sender] = ""; }
18,957
11
// Owner of this contract
address public owner; uint public perTokenPrice = 0; uint256 public owner_balance = 12000000 * 10 **10; uint256 public one_ether_usd_price = 0; uint256 public bonus_percentage = 0; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value);
address public owner; uint public perTokenPrice = 0; uint256 public owner_balance = 12000000 * 10 **10; uint256 public one_ether_usd_price = 0; uint256 public bonus_percentage = 0; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value);
41,441
185
// calculate amount of FHM available for claim by depositor_depositor addressindex uint return pendingPayout_ uint /
function pendingPayoutFor( address _depositor, uint index ) external view returns ( uint pendingPayout_ ) { uint percentVested = percentVestedFor( _depositor, index ); uint percentVestedBlocks = percentVestedBlocksFor( _depositor, index ); uint payout = depositors.get(_depositor, index).payout; if ( percentVested >= 10000 && percentVestedBlocks >= 10000) { pendingPayout_ = payout; } else { pendingPayout_ = 0; } }
function pendingPayoutFor( address _depositor, uint index ) external view returns ( uint pendingPayout_ ) { uint percentVested = percentVestedFor( _depositor, index ); uint percentVestedBlocks = percentVestedBlocksFor( _depositor, index ); uint payout = depositors.get(_depositor, index).payout; if ( percentVested >= 10000 && percentVestedBlocks >= 10000) { pendingPayout_ = payout; } else { pendingPayout_ = 0; } }
19,093
48
// See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is notrequired by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address.- `sender` must have a balance of at least `amount`.- the caller must have allowance for ``sender``'s tokens of at least`amount`. /
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); _transfer(sender, recipient, amount); return true; }
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); _transfer(sender, recipient, amount); return true; }
1,036
4
// The last active operator
address lastActiveOperator;
address lastActiveOperator;
8,775
791
// Add a new LP to the pool. Can only be called by the owner./ DO NOT add the same LP token more than once. Rewards will be messed up if you do./allocPoint AP of the new pool./_lpToken Address of the LP ERC-20 token./_rewarder Address of the rewarder delegate.
function add( uint256 allocPoint, IERC20 _lpToken, IRewarder _rewarder
function add( uint256 allocPoint, IERC20 _lpToken, IRewarder _rewarder
38,565
76
// Deposits funds into the vault.//_amountthe amount of funds to deposit.
function deposit(uint256 _amount) external;
function deposit(uint256 _amount) external;
3,677
0
// token vars
uint256 public tokenIds;
uint256 public tokenIds;
18,176
22
// returns token value in terms of ETH if the pool contains ETH. if the pool does not contain ETH, the value is returned in terms of the 0 index coin.
function getTokenValue(uint8 _index)public view returns(uint){ if(hasEth == 0){ Coin _coin = Coin(payable(address(uint160(tokenData[0])))); uint256 primaryBalance = _coin.balanceOf(address(this)); return bmul(primaryBalance, bdiv(uint256(tokenData[_index]>>160),uint256(tokenData[0]>>160))); } else { return bmul(address(this).balance, bdiv(uint256(tokenData[_index]>>160),uint256(tokenData[0]>>160))); } }
function getTokenValue(uint8 _index)public view returns(uint){ if(hasEth == 0){ Coin _coin = Coin(payable(address(uint160(tokenData[0])))); uint256 primaryBalance = _coin.balanceOf(address(this)); return bmul(primaryBalance, bdiv(uint256(tokenData[_index]>>160),uint256(tokenData[0]>>160))); } else { return bmul(address(this).balance, bdiv(uint256(tokenData[_index]>>160),uint256(tokenData[0]>>160))); } }
26,823
53
// Check the specified wallet whether it is in the whitelist._wallet The address of wallet to check./
function isWhitelisted(address _wallet) constant public returns (bool) { return whitelist[_wallet]; }
function isWhitelisted(address _wallet) constant public returns (bool) { return whitelist[_wallet]; }
49,535
23
// Trait ids start from 1 and are defined in a sequential order. Zero trait id is possible - it means that generating NFT won't have such attribute. But it's possible only for those attributes, which were added after deployment, i.e. whose ids >= `minAttributesAmount`
if ((i < minAttributesAmount && seed[i] == 0) || seed[i] > maxTraitIdInAttribute) { return false; }
if ((i < minAttributesAmount && seed[i] == 0) || seed[i] > maxTraitIdInAttribute) { return false; }
6,105
1
// Using up all of the gas you send causes transaction to fail. State changes are undone GFas spent are not refunded
function forever() public { // Loop until all gas is spent and transaction fails while (true) { i += 1; } }
function forever() public { // Loop until all gas is spent and transaction fails while (true) { i += 1; } }
13,074
14
// register an organization address with the hub and join the trust graph/signup is permanent for organizations too, there's no way to unsignup
function organizationSignup() public { // can't register as an organization if you have a token require(address(userToToken[msg.sender]) == address(0), "Normal users cannot signup as organizations"); // can't register as an organization twice require(organizations[msg.sender] == false, "You can't sign up as an organization twice"); organizations[msg.sender] = true; emit OrganizationSignup(msg.sender); }
function organizationSignup() public { // can't register as an organization if you have a token require(address(userToToken[msg.sender]) == address(0), "Normal users cannot signup as organizations"); // can't register as an organization twice require(organizations[msg.sender] == false, "You can't sign up as an organization twice"); organizations[msg.sender] = true; emit OrganizationSignup(msg.sender); }
21,462
17
// Lender depends
address navFeed = borrowerDeployer.feed(); DependLike_3(reserve_).depend("shelf", shelf_); DependLike_3(lenderDeployer.assessor()).depend("navFeed", navFeed);
address navFeed = borrowerDeployer.feed(); DependLike_3(reserve_).depend("shelf", shelf_); DependLike_3(lenderDeployer.assessor()).depend("navFeed", navFeed);
7,220
51
// See {IERC721-setApprovalForAll}. /
function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); }
function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); }
2,128
42
// Vote for proj. using id: _id
function vote(uint _id) public onlyVoter returns(bool success){ updateAccount(msg.sender); require(frozen == false); for (uint p = 0; p < projects.length; p++){ if(projects[p].id == _id && projects[p].active == true){ projects[p].votesWeight += sqrt(accounts[msg.sender].balance); accounts[msg.sender].lastVotedBallotId = curentBallotId; } } emit Vote(msg.sender, _id, accounts[msg.sender].balance, curentBallotId); return true; }
function vote(uint _id) public onlyVoter returns(bool success){ updateAccount(msg.sender); require(frozen == false); for (uint p = 0; p < projects.length; p++){ if(projects[p].id == _id && projects[p].active == true){ projects[p].votesWeight += sqrt(accounts[msg.sender].balance); accounts[msg.sender].lastVotedBallotId = curentBallotId; } } emit Vote(msg.sender, _id, accounts[msg.sender].balance, curentBallotId); return true; }
40,053
140
// power-up old campaign
if (payRate > 0) { require(payRate > brand.payRate, "!expired: increasing pay rate only"); require(payRate < 1<<192, "payRate overflow"); brand.payRate = uint192(payRate); }
if (payRate > 0) { require(payRate > brand.payRate, "!expired: increasing pay rate only"); require(payRate < 1<<192, "payRate overflow"); brand.payRate = uint192(payRate); }
22,792
102
// last cumulative price;
uint256 internal price_cumulative_last;
uint256 internal price_cumulative_last;
68,846
295
// https:docs.synthetix.io/contracts/source/contracts/proxyable
contract Proxyable is Owned { // This contract should be treated like an abstract contract /* The proxy this contract exists behind. */ Proxy public proxy; /* The caller of the proxy, passed through to this contract. * Note that every function using this member must apply the onlyProxy or * optionalProxy modifiers, otherwise their invocations can use stale values. */ address public messageSender; constructor(address payable _proxy) internal { // This contract is abstract, and thus cannot be instantiated directly require(owner != address(0), "Owner must be set"); proxy = Proxy(_proxy); emit ProxyUpdated(_proxy); } function setProxy(address payable _proxy) external onlyOwner { proxy = Proxy(_proxy); emit ProxyUpdated(_proxy); } function setMessageSender(address sender) external onlyProxy { messageSender = sender; } modifier onlyProxy { _onlyProxy(); _; } function _onlyProxy() private view { require(Proxy(msg.sender) == proxy, "Only the proxy can call"); } modifier optionalProxy { _optionalProxy(); _; } function _optionalProxy() private { if (Proxy(msg.sender) != proxy && messageSender != msg.sender) { messageSender = msg.sender; } } modifier optionalProxy_onlyOwner { _optionalProxy_onlyOwner(); _; } // solhint-disable-next-line func-name-mixedcase function _optionalProxy_onlyOwner() private { if (Proxy(msg.sender) != proxy && messageSender != msg.sender) { messageSender = msg.sender; } require(messageSender == owner, "Owner only function"); } event ProxyUpdated(address proxyAddress); }
contract Proxyable is Owned { // This contract should be treated like an abstract contract /* The proxy this contract exists behind. */ Proxy public proxy; /* The caller of the proxy, passed through to this contract. * Note that every function using this member must apply the onlyProxy or * optionalProxy modifiers, otherwise their invocations can use stale values. */ address public messageSender; constructor(address payable _proxy) internal { // This contract is abstract, and thus cannot be instantiated directly require(owner != address(0), "Owner must be set"); proxy = Proxy(_proxy); emit ProxyUpdated(_proxy); } function setProxy(address payable _proxy) external onlyOwner { proxy = Proxy(_proxy); emit ProxyUpdated(_proxy); } function setMessageSender(address sender) external onlyProxy { messageSender = sender; } modifier onlyProxy { _onlyProxy(); _; } function _onlyProxy() private view { require(Proxy(msg.sender) == proxy, "Only the proxy can call"); } modifier optionalProxy { _optionalProxy(); _; } function _optionalProxy() private { if (Proxy(msg.sender) != proxy && messageSender != msg.sender) { messageSender = msg.sender; } } modifier optionalProxy_onlyOwner { _optionalProxy_onlyOwner(); _; } // solhint-disable-next-line func-name-mixedcase function _optionalProxy_onlyOwner() private { if (Proxy(msg.sender) != proxy && messageSender != msg.sender) { messageSender = msg.sender; } require(messageSender == owner, "Owner only function"); } event ProxyUpdated(address proxyAddress); }
3,657
13
// Claim accumulated rewards for a set of tokens at a given cycle number
function claim( address[] calldata tokens, uint256[] calldata cumulativeAmounts, uint256 index, uint256 cycle, bytes32[] calldata merkleProof
function claim( address[] calldata tokens, uint256[] calldata cumulativeAmounts, uint256 index, uint256 cycle, bytes32[] calldata merkleProof
1,307
22
// maybe add a delay between them, 12 hrs?
function applyAddToken() external; function updateWeightsGradually( uint[] calldata newWeights, uint startBlock, uint endBlock ) external;
function applyAddToken() external; function updateWeightsGradually( uint[] calldata newWeights, uint startBlock, uint endBlock ) external;
35,410
158
// 计算用户有多少奖金可以领取
function pendingWithdrawWithBetRound(address user,uint256 _betRound) public view returns (uint256 withdrawAmount,uint256 winAmount){ require(oracle.isBetRoundWinOpen(_betRound),'bet round win not open'); PlayerInfo storage player = players[msg.sender]; require(players[msg.sender].registerTimeStamp > 0,'user not register'); BetInfo storage userBet = userBets[user][_betRound]; uint256 betTeamLength = userBet.betTeams.length; if(!userBet.withdrawed){ for(uint256 i=0;i<betTeamLength;i++){ uint256 _betTeamID=userBet.betTeams[i]; uint256 teamWinAmount = oracle.calcWinAmount(_betRound,_betTeamID,userBet.teamBetAmount[_betTeamID]); if(teamWinAmount>0){ winAmount = winAmount.add(teamWinAmount); } } } withdrawAmount = player.winAmount.add(winAmount).sub(player.withdrawAmount); }
function pendingWithdrawWithBetRound(address user,uint256 _betRound) public view returns (uint256 withdrawAmount,uint256 winAmount){ require(oracle.isBetRoundWinOpen(_betRound),'bet round win not open'); PlayerInfo storage player = players[msg.sender]; require(players[msg.sender].registerTimeStamp > 0,'user not register'); BetInfo storage userBet = userBets[user][_betRound]; uint256 betTeamLength = userBet.betTeams.length; if(!userBet.withdrawed){ for(uint256 i=0;i<betTeamLength;i++){ uint256 _betTeamID=userBet.betTeams[i]; uint256 teamWinAmount = oracle.calcWinAmount(_betRound,_betTeamID,userBet.teamBetAmount[_betTeamID]); if(teamWinAmount>0){ winAmount = winAmount.add(teamWinAmount); } } } withdrawAmount = player.winAmount.add(winAmount).sub(player.withdrawAmount); }
80,316
75
// Admin Functions // Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. newPendingAdmin New pending admin.return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) /
function _setPendingAdmin(address payable newPendingAdmin) external returns (uint256) { // Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint256(Error.NO_ERROR); }
function _setPendingAdmin(address payable newPendingAdmin) external returns (uint256) { // Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint256(Error.NO_ERROR); }
50,942
38
// do nothing
} catch (bytes memory reason) {
} catch (bytes memory reason) {
33,781
69
// Argument validations
_validateLockParameters(beneficiary, amount, releaseTime); require(!_isLockExists(id), "Token lock already exists");
_validateLockParameters(beneficiary, amount, releaseTime); require(!_isLockExists(id), "Token lock already exists");
19,475
22
// If true, no changes can be made
function unchangeable() public view returns (bool){ return _unchangeable; }
function unchangeable() public view returns (bool){ return _unchangeable; }
8,244
14
// Interface for the optional metadata functions from the ERC20 standard. _Available since v4.1._ /
interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
447
35
// multipliying tonnes with decimals
uint256 cap = totalVintageQuantity * 10**decimals();
uint256 cap = totalVintageQuantity * 10**decimals();
25,191
2
// Address of ICHI contract.
IERC20 private immutable ICHI;
IERC20 private immutable ICHI;
40,092
96
// See {IERC721Enumerable-tokenOfOwnerByIndex}.This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. /
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0);
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0);
71,710
58
// Convert current token to COT via ETH help
else {
else {
21,970
59
// function to get total token stake in contract
function getTotalTokenStakesInContract() public view returns(uint256){ return totalTokenStakesInContract; }
function getTotalTokenStakesInContract() public view returns(uint256){ return totalTokenStakesInContract; }
75,240
63
// And the specified start time has not yet come If initialization return an error, check the start date!
require(now <= startTime); initialization(); emit Initialized(); renewal = 0; isInitialized = true;
require(now <= startTime); initialization(); emit Initialized(); renewal = 0; isInitialized = true;
9,173
3
// users[users.length-1].userAddress = horce_image; users[users.length-1].salary = _salary;
return users.length;
return users.length;
2,662
2
// Creation code
bytes memory creationCode = _PROXY_CHILD_BYTECODE;
bytes memory creationCode = _PROXY_CHILD_BYTECODE;
30,037
36
// Fallback function to receive Ether
receive() external payable {} // Function to set an address Exempt From TxFee function setExemptFromTxFee(address _address, bool _exempt) public onlyOwner { isExemptFromTxFee[_address] = _exempt; emit ExemptionStatusChanged(_address, _exempt); }
receive() external payable {} // Function to set an address Exempt From TxFee function setExemptFromTxFee(address _address, bool _exempt) public onlyOwner { isExemptFromTxFee[_address] = _exempt; emit ExemptionStatusChanged(_address, _exempt); }
5,707
82
// Withdraw LP tokens from Amplify.
function withdrawLP(uint256 _pid, uint256 _amount) public whenNotPaused { massUpdatePools(); _withdrawInternal(_pid, _amount, true); }
function withdrawLP(uint256 _pid, uint256 _amount) public whenNotPaused { massUpdatePools(); _withdrawInternal(_pid, _amount, true); }
40,569
216
// Convert a real to an integer. Preserves sign. /
function fromReal(int256 realValue) internal pure returns (int216) { return int216(realValue / REAL_ONE); }
function fromReal(int256 realValue) internal pure returns (int216) { return int216(realValue / REAL_ONE); }
37,085
13
// Ensure there are enough tokens to be burned
uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "Burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount);
uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "Burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount);
14,541
583
// res += val(coefficients[256] + coefficients[257]adjustments[19]).
res := addmod(res, mulmod(val, add(/*coefficients[256]*/ mload(0x2440), mulmod(/*coefficients[257]*/ mload(0x2460),
res := addmod(res, mulmod(val, add(/*coefficients[256]*/ mload(0x2440), mulmod(/*coefficients[257]*/ mload(0x2460),
20,873
2
// owner The address from which the balance will be retrieved/ return The balance
function balanceOf(address owner) public view returns (uint256 balance);
function balanceOf(address owner) public view returns (uint256 balance);
6,118
305
// Call initialize on the transaction request clone.
TransactionRequestCore(transactionRequest).initialize.value(msg.value)( [ msg.sender, // Created by _addressArgs[0], // meta.owner _addressArgs[1], // paymentData.feeRecipient _addressArgs[2] // txnData.toAddress ], _uintArgs, //uint[12] _callData );
TransactionRequestCore(transactionRequest).initialize.value(msg.value)( [ msg.sender, // Created by _addressArgs[0], // meta.owner _addressArgs[1], // paymentData.feeRecipient _addressArgs[2] // txnData.toAddress ], _uintArgs, //uint[12] _callData );
16,080
241
// Construct the contractaddressRegistry Registry containing our system addresses Note: Pause operation in this context. Only calls from Proxy allowed. /
constructor( IAddressRegistry addressRegistry, OpenSeaProxyRegistry openSeaProxyRegistry
constructor( IAddressRegistry addressRegistry, OpenSeaProxyRegistry openSeaProxyRegistry
38,803
24
// 新增這個活動票券的 Host。
function setHost(address host) external onlyHost { hosts[host] = true; }
function setHost(address host) external onlyHost { hosts[host] = true; }
30,244
171
// assign top bidder and bid time
highestBid.bidder = _msgSender(); highestBid.bid = bidAmount; highestBid.lastBidTime = _getNow(); emit BidPlaced(_garmentTokenId, _msgSender(), bidAmount);
highestBid.bidder = _msgSender(); highestBid.bid = bidAmount; highestBid.lastBidTime = _getNow(); emit BidPlaced(_garmentTokenId, _msgSender(), bidAmount);
34,006
448
// When LQTYToken deployed, it should have transferred CommunityIssuance's LQTY entitlement
uint LQTYBalance = lqtyToken.balanceOf(address(this)); assert(LQTYBalance >= LQTYSupplyCap); emit LQTYTokenAddressSet(_lqtyTokenAddress); emit StabilityPoolAddressSet(_stabilityPoolAddress); _renounceOwnership();
uint LQTYBalance = lqtyToken.balanceOf(address(this)); assert(LQTYBalance >= LQTYSupplyCap); emit LQTYTokenAddressSet(_lqtyTokenAddress); emit StabilityPoolAddressSet(_stabilityPoolAddress); _renounceOwnership();
21,356
4
// Proxy Basic proxy that delegates all calls to a fixed implementing contract.The implementing contract cannot be upgraded. /
contract Proxy is Ownable { address public implementation; event Received(uint256 indexed value, address indexed sender, bytes data); event ChangedImplementationContract(address implementation); constructor(address _implementation) public { implementation = _implementation; } function() external payable { address target = implementation; // solhint-disable-next-line no-inline-assembly assembly { calldatacopy(0, 0, calldatasize) let result := call(gas, target, callvalue, 0, calldatasize, 0, 0) returndatacopy(0, 0, returndatasize) switch result case 0 { revert(0, returndatasize) } default { return(0, returndatasize) } } } function setImplementation(address _implementation) external onlyOwner { require(_implementation != address(0), "Can't set zero address"); implementation = _implementation; emit ChangedImplementationContract(_implementation); } }
contract Proxy is Ownable { address public implementation; event Received(uint256 indexed value, address indexed sender, bytes data); event ChangedImplementationContract(address implementation); constructor(address _implementation) public { implementation = _implementation; } function() external payable { address target = implementation; // solhint-disable-next-line no-inline-assembly assembly { calldatacopy(0, 0, calldatasize) let result := call(gas, target, callvalue, 0, calldatasize, 0, 0) returndatacopy(0, 0, returndatasize) switch result case 0 { revert(0, returndatasize) } default { return(0, returndatasize) } } } function setImplementation(address _implementation) external onlyOwner { require(_implementation != address(0), "Can't set zero address"); implementation = _implementation; emit ChangedImplementationContract(_implementation); } }
47,215
255
// Decodes MultiAsset assetData and recursively transfers assets to sender./assetData Byte array encoded for the respective asset proxy./from Address to transfer asset from./to Address to transfer asset to./amount Amount of asset to transfer to sender.
function transferMultiAsset( bytes memory assetData, address from, address to, uint256 amount ) internal
function transferMultiAsset( bytes memory assetData, address from, address to, uint256 amount ) internal
49,095
2
// Set file info and associate it with the sender address_fileName Name of the file_ipfsHash Hash of file on IPFS_tags String with tags/
function insertFile(string _fileName, string _ipfsHash, string _tags) public whenNotPaused inputIsValid(_fileName,_ipfsHash,_tags)
function insertFile(string _fileName, string _ipfsHash, string _tags) public whenNotPaused inputIsValid(_fileName,_ipfsHash,_tags)
11,807
9
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
uint previousBalances = balanceOf[_from] + balanceOf[_to];
1,055
3
// Initializes the debt token. pool The address of the lending pool where this oToken will be used underlyingAsset The address of the underlying asset of this oToken (E.g. WETH for aWETH) incentivesController The smart contract managing potential incentives distribution debtTokenDecimals The decimals of the debtToken, same as the underlying asset's debtTokenName The name of the token debtTokenSymbol The symbol of the token /
function initialize( ILendingPool pool, address underlyingAsset, IOmniDexIncentivesController incentivesController, uint8 debtTokenDecimals, string memory debtTokenName, string memory debtTokenSymbol, bytes calldata params
function initialize( ILendingPool pool, address underlyingAsset, IOmniDexIncentivesController incentivesController, uint8 debtTokenDecimals, string memory debtTokenName, string memory debtTokenSymbol, bytes calldata params
26,087
43
// they approve the slammertime contract to take the token away from them
require(approve(slammerTime,_id)); require(approve(slammerTime,_id2)); require(approve(slammerTime,_id3)); require(approve(slammerTime,_id4)); require(approve(slammerTime,_id5)); bytes32 stack = keccak256(nonce++,msg.sender); uint256[5] memory ids = [_id,_id2,_id3,_id4,_id5]; stacks[stack] = Stack(ids,msg.sender,uint32(block.number));
require(approve(slammerTime,_id)); require(approve(slammerTime,_id2)); require(approve(slammerTime,_id3)); require(approve(slammerTime,_id4)); require(approve(slammerTime,_id5)); bytes32 stack = keccak256(nonce++,msg.sender); uint256[5] memory ids = [_id,_id2,_id3,_id4,_id5]; stacks[stack] = Stack(ids,msg.sender,uint32(block.number));
65,290
123
// Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
* {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
966
42
// Failsafe to restart auction with params in case of failure /
function restartAuction( uint256 _seconds, uint256 _startingPrice, uint256 _priceDeduction
function restartAuction( uint256 _seconds, uint256 _startingPrice, uint256 _priceDeduction
43,719
46
// Erc智能合约
contract ERC20 is ERC20Interface, BobbyERC20Base { using BobbySafeMath for uint256; uint private _Thousand = 1000; uint private _Billion = _Thousand * _Thousand * _Thousand; //代币基本信息 string private _name = "BOBBY"; //代币名称 string private _symbol = "BOBBY"; //代币标识 uint8 private _decimals = 9; //小数点后位数 uint256 private _totalSupply = 10 * _Billion * (10 ** uint256(_decimals)); //解封用户代币结构 struct UserToken { uint index; //放在数组中的下标 address addr; //用户账号 uint256 tokens; //通证数量 uint256 unlockUnit; // 每次解锁数量 uint256 unlockPeriod; // 解锁时间间隔 uint256 unlockLeft; // 未解锁通证数量 uint256 unlockLastTime; // 上次解锁时间 } mapping(address=>UserToken) private _balancesMap; //用户可用代币映射 address[] private _balancesArray; //用户可用代币数组,from 1 uint32 private actionTransfer = 0; uint32 private actionGrant = 1; uint32 private actionUnlock = 2; struct LogEntry { uint256 time; uint32 action; // 0 转账 1 发放 2 解锁 address from; address to; uint256 v1; uint256 v2; uint256 v3; } LogEntry[] private _logs; //构造方法,将代币的初始总供给都分配给合约的部署账户。合约的构造方法只在合约部署时执行一次 constructor(address cfoAddr) BobbyERC20Base(cfoAddr) public { //placeholder _balancesArray.push(address(0)); //此处需要注意,请使用CEO的地址,因为初始化后,将会使用这个地址作为CEO地址 //注意,一定要使用memory类型,否则,后面的赋值会影响其它成员变量 UserToken memory userCFO; userCFO.index = _balancesArray.length; userCFO.addr = cfoAddr; userCFO.tokens = _totalSupply; userCFO.unlockUnit = 0; userCFO.unlockPeriod = 0; userCFO.unlockLeft = 0; userCFO.unlockLastTime = 0; _balancesArray.push(cfoAddr); _balancesMap[cfoAddr] = userCFO; } //返回合约名称。view关键子表示函数只查询状态变量,而不写入 function name() public view returns (string n){ n = _name; } //返回合约标识符 function symbol() public view returns (string s){ s = _symbol; } //返回合约小数位 function decimals() public view returns (uint8 d){ d = _decimals; } //返回合约总供给额 function totalSupply() public view returns (uint256 t){ t = _totalSupply; } //查询账户_owner的账户余额 function balanceOf(address _owner) public view returns (uint256 balance){ UserToken storage user = _balancesMap[_owner]; balance = user.tokens.add(user.unlockLeft); } //从代币合约的调用者地址上转移_value的数量token到的地址_to,并且必须触发Transfer事件 function transfer(address _to, uint256 _value) public returns (bool success){ require(!paused); require(msg.sender != cfoAddress); require(msg.sender != _to); //先判断是否有可以解禁 if(_balancesMap[msg.sender].unlockLeft > 0){ UserToken storage sender = _balancesMap[msg.sender]; uint256 diff = now.sub(sender.unlockLastTime); uint256 round = diff.div(sender.unlockPeriod); if(round > 0) { uint256 unlocked = sender.unlockUnit.mul(round); if (unlocked > sender.unlockLeft) { unlocked = sender.unlockLeft; } sender.unlockLeft = sender.unlockLeft.sub(unlocked); sender.tokens = sender.tokens.add(unlocked); sender.unlockLastTime = sender.unlockLastTime.add(sender.unlockPeriod.mul(round)); emit Unlock(msg.sender, unlocked); log(actionUnlock, msg.sender, 0, unlocked, 0, 0); } } require(_balancesMap[msg.sender].tokens >= _value); _balancesMap[msg.sender].tokens = _balancesMap[msg.sender].tokens.sub(_value); uint index = _balancesMap[_to].index; if(index == 0){ UserToken memory user; user.index = _balancesArray.length; user.addr = _to; user.tokens = _value; user.unlockUnit = 0; user.unlockPeriod = 0; user.unlockLeft = 0; user.unlockLastTime = 0; _balancesMap[_to] = user; _balancesArray.push(_to); } else{ _balancesMap[_to].tokens = _balancesMap[_to].tokens.add(_value); } emit Transfer(msg.sender, _to, _value); log(actionTransfer, msg.sender, _to, _value, 0, 0); success = true; } function transferFrom(address, address, uint256) public returns (bool success){ require(!paused); success = true; } function approve(address, uint256) public returns (bool success){ require(!paused); success = true; } function allowance(address, address) public view returns (uint256 remaining){ require(!paused); remaining = 0; } function grant(address _to, uint256 _value, uint256 _duration, uint256 _periods) public returns (bool success){ require(msg.sender != _to); require(_balancesMap[msg.sender].tokens >= _value); require(_balancesMap[_to].unlockLastTime == 0); _balancesMap[msg.sender].tokens = _balancesMap[msg.sender].tokens.sub(_value); if(_balancesMap[_to].index == 0){ UserToken memory user; user.index = _balancesArray.length; user.addr = _to; user.tokens = 0; user.unlockUnit = _value.div(_periods); user.unlockPeriod = _duration.mul(30).mul(1 days).div(_periods); /* user.unlockPeriod = _period; //for test */ user.unlockLeft = _value; user.unlockLastTime = now; _balancesMap[_to] = user; _balancesArray.push(_to); } else{ _balancesMap[_to].unlockUnit = _value.div(_periods); _balancesMap[_to].unlockPeriod = _duration.mul(30).mul(1 days).div(_periods); /* _balancesMap[_to].unlockPeriod = _period; //for test */ _balancesMap[_to].unlockLeft = _value; _balancesMap[_to].unlockLastTime = now; } emit Grant(msg.sender, _to, _value); log(actionGrant, msg.sender, _to, _value, _duration, _periods); success = true; } function getBalanceAddr(uint256 _index) public view returns(address addr){ require(_index < _balancesArray.length); require(_index >= 0); addr = _balancesArray[_index]; } function getBalanceSize() public view returns(uint256 size){ size = _balancesArray.length; } function getLockInfo(address addr) public view returns (uint256 unlocked, uint256 unit, uint256 period, uint256 last) { UserToken storage user = _balancesMap[addr]; unlocked = user.unlockLeft; unit = user.unlockUnit; period = user.unlockPeriod; last = user.unlockLastTime; } function log(uint32 action, address from, address to, uint256 _v1, uint256 _v2, uint256 _v3) private { LogEntry memory entry; entry.action = action; entry.time = now; entry.from = from; entry.to = to; entry.v1 = _v1; entry.v2 = _v2; entry.v3 = _v3; _logs.push(entry); } function getLogSize() public view returns(uint256 size){ size = _logs.length; } function getLog(uint256 _index) public view returns(uint time, uint32 action, address from, address to, uint256 _v1, uint256 _v2, uint256 _v3){ require(_index < _logs.length); require(_index >= 0); LogEntry storage entry = _logs[_index]; action = entry.action; time = entry.time; from = entry.from; to = entry.to; _v1 = entry.v1; _v2 = entry.v2; _v3 = entry.v3; } }
contract ERC20 is ERC20Interface, BobbyERC20Base { using BobbySafeMath for uint256; uint private _Thousand = 1000; uint private _Billion = _Thousand * _Thousand * _Thousand; //代币基本信息 string private _name = "BOBBY"; //代币名称 string private _symbol = "BOBBY"; //代币标识 uint8 private _decimals = 9; //小数点后位数 uint256 private _totalSupply = 10 * _Billion * (10 ** uint256(_decimals)); //解封用户代币结构 struct UserToken { uint index; //放在数组中的下标 address addr; //用户账号 uint256 tokens; //通证数量 uint256 unlockUnit; // 每次解锁数量 uint256 unlockPeriod; // 解锁时间间隔 uint256 unlockLeft; // 未解锁通证数量 uint256 unlockLastTime; // 上次解锁时间 } mapping(address=>UserToken) private _balancesMap; //用户可用代币映射 address[] private _balancesArray; //用户可用代币数组,from 1 uint32 private actionTransfer = 0; uint32 private actionGrant = 1; uint32 private actionUnlock = 2; struct LogEntry { uint256 time; uint32 action; // 0 转账 1 发放 2 解锁 address from; address to; uint256 v1; uint256 v2; uint256 v3; } LogEntry[] private _logs; //构造方法,将代币的初始总供给都分配给合约的部署账户。合约的构造方法只在合约部署时执行一次 constructor(address cfoAddr) BobbyERC20Base(cfoAddr) public { //placeholder _balancesArray.push(address(0)); //此处需要注意,请使用CEO的地址,因为初始化后,将会使用这个地址作为CEO地址 //注意,一定要使用memory类型,否则,后面的赋值会影响其它成员变量 UserToken memory userCFO; userCFO.index = _balancesArray.length; userCFO.addr = cfoAddr; userCFO.tokens = _totalSupply; userCFO.unlockUnit = 0; userCFO.unlockPeriod = 0; userCFO.unlockLeft = 0; userCFO.unlockLastTime = 0; _balancesArray.push(cfoAddr); _balancesMap[cfoAddr] = userCFO; } //返回合约名称。view关键子表示函数只查询状态变量,而不写入 function name() public view returns (string n){ n = _name; } //返回合约标识符 function symbol() public view returns (string s){ s = _symbol; } //返回合约小数位 function decimals() public view returns (uint8 d){ d = _decimals; } //返回合约总供给额 function totalSupply() public view returns (uint256 t){ t = _totalSupply; } //查询账户_owner的账户余额 function balanceOf(address _owner) public view returns (uint256 balance){ UserToken storage user = _balancesMap[_owner]; balance = user.tokens.add(user.unlockLeft); } //从代币合约的调用者地址上转移_value的数量token到的地址_to,并且必须触发Transfer事件 function transfer(address _to, uint256 _value) public returns (bool success){ require(!paused); require(msg.sender != cfoAddress); require(msg.sender != _to); //先判断是否有可以解禁 if(_balancesMap[msg.sender].unlockLeft > 0){ UserToken storage sender = _balancesMap[msg.sender]; uint256 diff = now.sub(sender.unlockLastTime); uint256 round = diff.div(sender.unlockPeriod); if(round > 0) { uint256 unlocked = sender.unlockUnit.mul(round); if (unlocked > sender.unlockLeft) { unlocked = sender.unlockLeft; } sender.unlockLeft = sender.unlockLeft.sub(unlocked); sender.tokens = sender.tokens.add(unlocked); sender.unlockLastTime = sender.unlockLastTime.add(sender.unlockPeriod.mul(round)); emit Unlock(msg.sender, unlocked); log(actionUnlock, msg.sender, 0, unlocked, 0, 0); } } require(_balancesMap[msg.sender].tokens >= _value); _balancesMap[msg.sender].tokens = _balancesMap[msg.sender].tokens.sub(_value); uint index = _balancesMap[_to].index; if(index == 0){ UserToken memory user; user.index = _balancesArray.length; user.addr = _to; user.tokens = _value; user.unlockUnit = 0; user.unlockPeriod = 0; user.unlockLeft = 0; user.unlockLastTime = 0; _balancesMap[_to] = user; _balancesArray.push(_to); } else{ _balancesMap[_to].tokens = _balancesMap[_to].tokens.add(_value); } emit Transfer(msg.sender, _to, _value); log(actionTransfer, msg.sender, _to, _value, 0, 0); success = true; } function transferFrom(address, address, uint256) public returns (bool success){ require(!paused); success = true; } function approve(address, uint256) public returns (bool success){ require(!paused); success = true; } function allowance(address, address) public view returns (uint256 remaining){ require(!paused); remaining = 0; } function grant(address _to, uint256 _value, uint256 _duration, uint256 _periods) public returns (bool success){ require(msg.sender != _to); require(_balancesMap[msg.sender].tokens >= _value); require(_balancesMap[_to].unlockLastTime == 0); _balancesMap[msg.sender].tokens = _balancesMap[msg.sender].tokens.sub(_value); if(_balancesMap[_to].index == 0){ UserToken memory user; user.index = _balancesArray.length; user.addr = _to; user.tokens = 0; user.unlockUnit = _value.div(_periods); user.unlockPeriod = _duration.mul(30).mul(1 days).div(_periods); /* user.unlockPeriod = _period; //for test */ user.unlockLeft = _value; user.unlockLastTime = now; _balancesMap[_to] = user; _balancesArray.push(_to); } else{ _balancesMap[_to].unlockUnit = _value.div(_periods); _balancesMap[_to].unlockPeriod = _duration.mul(30).mul(1 days).div(_periods); /* _balancesMap[_to].unlockPeriod = _period; //for test */ _balancesMap[_to].unlockLeft = _value; _balancesMap[_to].unlockLastTime = now; } emit Grant(msg.sender, _to, _value); log(actionGrant, msg.sender, _to, _value, _duration, _periods); success = true; } function getBalanceAddr(uint256 _index) public view returns(address addr){ require(_index < _balancesArray.length); require(_index >= 0); addr = _balancesArray[_index]; } function getBalanceSize() public view returns(uint256 size){ size = _balancesArray.length; } function getLockInfo(address addr) public view returns (uint256 unlocked, uint256 unit, uint256 period, uint256 last) { UserToken storage user = _balancesMap[addr]; unlocked = user.unlockLeft; unit = user.unlockUnit; period = user.unlockPeriod; last = user.unlockLastTime; } function log(uint32 action, address from, address to, uint256 _v1, uint256 _v2, uint256 _v3) private { LogEntry memory entry; entry.action = action; entry.time = now; entry.from = from; entry.to = to; entry.v1 = _v1; entry.v2 = _v2; entry.v3 = _v3; _logs.push(entry); } function getLogSize() public view returns(uint256 size){ size = _logs.length; } function getLog(uint256 _index) public view returns(uint time, uint32 action, address from, address to, uint256 _v1, uint256 _v2, uint256 _v3){ require(_index < _logs.length); require(_index >= 0); LogEntry storage entry = _logs[_index]; action = entry.action; time = entry.time; from = entry.from; to = entry.to; _v1 = entry.v1; _v2 = entry.v2; _v3 = entry.v3; } }
31,025
256
// We call doTransferIn for the payer and the repayAmount Note: The cToken must handle variations between ERC-20 and ETH underlying. On success, the cToken holds an additional repayAmount of cash. doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.it returns the amount actually transferred, in case of a fee. /
vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount, isNative);
vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount, isNative);
33,205
36
// Wraps ETH into WETH and make a collateral deposit in the BalanceSheet contract./This is a payable function so it can receive ETH transfers./weth The address of the WETH contract./balanceSheet The address of the BalanceSheet contract.
function wrapEthAndDepositCollateral(WethInterface weth, IBalanceSheetV2 balanceSheet) external payable;
function wrapEthAndDepositCollateral(WethInterface weth, IBalanceSheetV2 balanceSheet) external payable;
41,060
120
// sell -> the quote is the wanted token by the maker
return mustSkipFee[makerOrder.offerToken_][makerOrder.wantToken_] ? 0 : toMakerAmount.mul(feeEdoPerQuote[makerOrder.wantToken_]).div(10**feeEdoPerQuoteDecimals[makerOrder.wantToken_]);
return mustSkipFee[makerOrder.offerToken_][makerOrder.wantToken_] ? 0 : toMakerAmount.mul(feeEdoPerQuote[makerOrder.wantToken_]).div(10**feeEdoPerQuoteDecimals[makerOrder.wantToken_]);
22,702
74
// Internal function that burns an amount of the token of a given account.account The account whose tokens will be burnt.amount The amount that will be burnt./
function _burn(address account, uint256 amount) internal { require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); }
function _burn(address account, uint256 amount) internal { require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); }
22,803
185
// mint MaskMan
function mintMaskMan(address _to, uint256 _count) external payable { require( totalSupply() + _count <= MAX_MM, "Exceeds maximum supply of Mask Man" ); if (msg.sender != owner()) { require(saleOpen, "Sale is not open yet"); require( _count > 0 && _count <= 20, "Minimum 1 & Maximum 20 Mask Man can be minted per transaction" ); require( msg.value >= price * _count, "Ether sent with this transaction is not correct" ); } for (uint256 i = 0; i < _count; i++) { _mint(_to); } }
function mintMaskMan(address _to, uint256 _count) external payable { require( totalSupply() + _count <= MAX_MM, "Exceeds maximum supply of Mask Man" ); if (msg.sender != owner()) { require(saleOpen, "Sale is not open yet"); require( _count > 0 && _count <= 20, "Minimum 1 & Maximum 20 Mask Man can be minted per transaction" ); require( msg.value >= price * _count, "Ether sent with this transaction is not correct" ); } for (uint256 i = 0; i < _count; i++) { _mint(_to); } }
64,965
34
// ERC20 精度,推荐是 8 /
function decimals() public view returns (uint8){ return tokenStore.decimals(); }
function decimals() public view returns (uint8){ return tokenStore.decimals(); }
33,996