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
23
// convert to lower case a-z
_temp[i] = byte(uint(_temp[i]) + 32);
_temp[i] = byte(uint(_temp[i]) + 32);
14,867
1
// Approve tokens for use in Strategy Restricted to avoid griefing attacks /
function setAllowances() public override onlyOwner { depositToken.approve(address(conversionContract), MAX_UINT); sBamboo.approve(address(stakingContract), MAX_UINT); }
function setAllowances() public override onlyOwner { depositToken.approve(address(conversionContract), MAX_UINT); sBamboo.approve(address(stakingContract), MAX_UINT); }
34,046
44
// Set the address of the sale contract.`saleContract` can make token transferseven when the token contract state is locked.Transfer lock serves the purpose of preventingthe creation of fake Uniswap pools. Added by WorkQuest Team./
function setSaleContract(address saleContract) public { require(msg.sender == _owner && _saleContract == address(0), "Caller must be owner and _saleContract yet unset"); _saleContract = saleContract; }
function setSaleContract(address saleContract) public { require(msg.sender == _owner && _saleContract == address(0), "Caller must be owner and _saleContract yet unset"); _saleContract = saleContract; }
25,986
5
// Returns whether all relevant permission and other checks are met before any upgrade.
function isAuthorizedCallToUpgrade() internal view virtual override returns (bool) { return hasRole(keccak256("EXTENSION_ROLE"), msg.sender); }
function isAuthorizedCallToUpgrade() internal view virtual override returns (bool) { return hasRole(keccak256("EXTENSION_ROLE"), msg.sender); }
30,993
5
// Fee paid to HeyMint per NFT minted
uint256 public heymintFeePerToken; uint256 public publicMintsAllowedPerAddress = 444; uint256 public publicMintsAllowedPerTransaction = 444; uint256 public publicPrice = 0.02 ether;
uint256 public heymintFeePerToken; uint256 public publicMintsAllowedPerAddress = 444; uint256 public publicMintsAllowedPerTransaction = 444; uint256 public publicPrice = 0.02 ether;
20,471
30
// while designing plan make sure _buyPrice must be a cetrain minimum to fulfill platform fee and payouts sum total, else platform provider will not reaponsible for any buy failwhenever Your EtherInPlan will create/start a new tree structure,platform fee will be deducted, so calculate this while designing plan A check list also be released to manually verify if your plan is correct or not some of the input data validation is intentionally not done which is done on DAPP level, so plan must be entered via dedicated UI to avoid wrong plan entryfor example you must be careful for the settings
event addEtherInPlanEv(uint256 timeNow, uint256 indexed _networkId, bytes16 indexed _name,uint128 _buyPrice,uint128 _planExpiry, uint8 _maxChild,bool _autoPlaceInTree,bool _allowJoinAgain, uint8 _etheroutPlanId,bool[] _triggerSubTree, bool indexed _triggerExternalContract ); function addEtherInPlan(uint256 _networkId, bytes16 _name,uint128 _buyPrice,uint128 _planExpiry, uint8 _maxChild,bool _autoPlaceInTree,bool _allowJoinAgain, uint8 _etheroutPlanId,bool[] memory _triggerSubTree, bool _triggerExternalContract ) public returns(bool)
event addEtherInPlanEv(uint256 timeNow, uint256 indexed _networkId, bytes16 indexed _name,uint128 _buyPrice,uint128 _planExpiry, uint8 _maxChild,bool _autoPlaceInTree,bool _allowJoinAgain, uint8 _etheroutPlanId,bool[] _triggerSubTree, bool indexed _triggerExternalContract ); function addEtherInPlan(uint256 _networkId, bytes16 _name,uint128 _buyPrice,uint128 _planExpiry, uint8 _maxChild,bool _autoPlaceInTree,bool _allowJoinAgain, uint8 _etheroutPlanId,bool[] memory _triggerSubTree, bool _triggerExternalContract ) public returns(bool)
913
35
// Update the `pool.totalBoostedAmount`
uint256 boostedLiquidityBefore = getBoostedLiquidity(_pid, msg.sender); user.amount = user.amount.add(receivedAmount); uint256 boostedLiquidityAfter = getBoostedLiquidity(_pid, msg.sender); pool.totalBoostedAmount = pool.totalBoostedAmount.add(boostedLiquidityAfter).sub(boostedLiquidityBefore);
uint256 boostedLiquidityBefore = getBoostedLiquidity(_pid, msg.sender); user.amount = user.amount.add(receivedAmount); uint256 boostedLiquidityAfter = getBoostedLiquidity(_pid, msg.sender); pool.totalBoostedAmount = pool.totalBoostedAmount.add(boostedLiquidityAfter).sub(boostedLiquidityBefore);
14,480
17
// Copy over character data (situated right after a 32-bit length prefix)
assembly {
assembly {
37,590
47
// Map from transaction ID to the transaction's location+1 in the `pendingTransactions` array.
mapping(uint => uint) private pendingTransactionMap;
mapping(uint => uint) private pendingTransactionMap;
42,973
89
// File: .deps/MultiAuction 6/interfaces/IDelegationRegistry.sol
pragma solidity ^0.8.17;
pragma solidity ^0.8.17;
2,658
155
// gets billingAccessControllerreturn address of billingAccessController contract /
function billingAccessController() external view returns (AccessControllerInterface)
function billingAccessController() external view returns (AccessControllerInterface)
25,973
105
// Set blacklisted status for the account. account address to set blacklist flag for _isBlacklisted blacklist flag value Requirements: - `msg.sender` should be owner. /
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner { require(uint256(account) >= REDEMPTION_ADDRESS_COUNT, "TrueCurrency: blacklisting of redemption address is not allowed"); isBlacklisted[account] = _isBlacklisted; emit Blacklisted(account, _isBlacklisted); }
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner { require(uint256(account) >= REDEMPTION_ADDRESS_COUNT, "TrueCurrency: blacklisting of redemption address is not allowed"); isBlacklisted[account] = _isBlacklisted; emit Blacklisted(account, _isBlacklisted); }
39,606
35
// Returns the prior number of `votes` for `account` as of `timeStamp`./account The user to check `votes` for./timeStamp The unix time to check `votes` for./ return votes Prior `votes` delegated to `account`.
function getPriorVotes(address account, uint timeStamp) public view returns (uint96 votes) { require(timeStamp < block.timestamp,'!determined'); uint nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) return 0; unchecked { if (checkpoints[account][nCheckpoints - 1].fromTimeStamp <= timeStamp) return checkpoints[account][nCheckpoints - 1].votes; if (checkpoints[account][0].fromTimeStamp > timeStamp) return 0; uint lower = 0; uint upper = nCheckpoints - 1; while (upper > lower) { uint center = upper - (upper - lower) / 2; Checkpoint memory cp = checkpoints[account][center]; if (cp.fromTimeStamp == timeStamp) return cp.votes; else if (cp.fromTimeStamp < timeStamp) lower = center; else upper = center - 1; } votes = checkpoints[account][lower].votes; } }
function getPriorVotes(address account, uint timeStamp) public view returns (uint96 votes) { require(timeStamp < block.timestamp,'!determined'); uint nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) return 0; unchecked { if (checkpoints[account][nCheckpoints - 1].fromTimeStamp <= timeStamp) return checkpoints[account][nCheckpoints - 1].votes; if (checkpoints[account][0].fromTimeStamp > timeStamp) return 0; uint lower = 0; uint upper = nCheckpoints - 1; while (upper > lower) { uint center = upper - (upper - lower) / 2; Checkpoint memory cp = checkpoints[account][center]; if (cp.fromTimeStamp == timeStamp) return cp.votes; else if (cp.fromTimeStamp < timeStamp) lower = center; else upper = center - 1; } votes = checkpoints[account][lower].votes; } }
20,999
16
// Configure so transfers of tokens created by the caller (must be extension) gets approvalfrom the extension before transferring /
function setApproveTransferExtension(bool enabled) external;
function setApproveTransferExtension(bool enabled) external;
24,415
55
// A token upgrade mechanism where users can opt-in amount of tokens to the next smart contract revision. First envisioned by Golem and Lunyr projects. /
contract UpgradeableToken is StandardToken { /** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */ address public upgradeMaster; /** The next contract where the tokens will be migrated. */ UpgradeAgent public upgradeAgent; /** How many tokens we have upgraded by now. */ uint256 public totalUpgraded; /** * Upgrade states. * * - NotAllowed: The child contract has not reached a condition where the upgrade can bgun * - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet * - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet * - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens * */ enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading} /** * Somebody has upgraded some of his tokens. */ event Upgrade(address indexed _from, address indexed _to, uint256 _value); /** * New upgrade agent available. */ event UpgradeAgentSet(address agent); /** * Do not allow construction without upgrade master set. */ function UpgradeableToken(address _upgradeMaster) public { upgradeMaster = _upgradeMaster; } /** * Allow the token holder to upgrade some of their tokens to a new contract. */ function upgrade(uint256 value) public { UpgradeState state = getUpgradeState(); if(!(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading)) { // Called in a bad state revert(); } // Validate input value. if (value == 0) revert(); balances[msg.sender] = safeSub(balances[msg.sender], value); // Take tokens out from circulation totalSupply = safeSub(totalSupply, value); totalUpgraded = safeAdd(totalUpgraded, value); // Upgrade agent reissues the tokens upgradeAgent.upgradeFrom(msg.sender, value); Upgrade(msg.sender, upgradeAgent, value); } /** * Set an upgrade agent that handles */ function setUpgradeAgent(address agent) external { if(!canUpgrade()) { // The token is not yet in a state that we could think upgrading revert(); } if (agent == 0x0) revert(); // Only a master can designate the next agent if (msg.sender != upgradeMaster) revert(); // Upgrade has already begun for an agent if (getUpgradeState() == UpgradeState.Upgrading) revert(); upgradeAgent = UpgradeAgent(agent); // Bad interface if(!upgradeAgent.isUpgradeAgent()) revert(); // Make sure that token supplies match in source and target if (upgradeAgent.originalSupply() != totalSupply) revert(); UpgradeAgentSet(upgradeAgent); } /** * Get the state of the token upgrade. */ function getUpgradeState() public constant returns(UpgradeState) { if(!canUpgrade()) return UpgradeState.NotAllowed; else if(address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent; else if(totalUpgraded == 0) return UpgradeState.ReadyToUpgrade; else return UpgradeState.Upgrading; } /** * Change the upgrade master. * * This allows us to set a new owner for the upgrade mechanism. */ function setUpgradeMaster(address master) public { if (master == 0x0) revert(); if (msg.sender != upgradeMaster) revert(); upgradeMaster = master; } /** * Child contract can enable to provide the condition when the upgrade can begun. */ function canUpgrade() public constant returns(bool) { return true; } }
contract UpgradeableToken is StandardToken { /** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */ address public upgradeMaster; /** The next contract where the tokens will be migrated. */ UpgradeAgent public upgradeAgent; /** How many tokens we have upgraded by now. */ uint256 public totalUpgraded; /** * Upgrade states. * * - NotAllowed: The child contract has not reached a condition where the upgrade can bgun * - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet * - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet * - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens * */ enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading} /** * Somebody has upgraded some of his tokens. */ event Upgrade(address indexed _from, address indexed _to, uint256 _value); /** * New upgrade agent available. */ event UpgradeAgentSet(address agent); /** * Do not allow construction without upgrade master set. */ function UpgradeableToken(address _upgradeMaster) public { upgradeMaster = _upgradeMaster; } /** * Allow the token holder to upgrade some of their tokens to a new contract. */ function upgrade(uint256 value) public { UpgradeState state = getUpgradeState(); if(!(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading)) { // Called in a bad state revert(); } // Validate input value. if (value == 0) revert(); balances[msg.sender] = safeSub(balances[msg.sender], value); // Take tokens out from circulation totalSupply = safeSub(totalSupply, value); totalUpgraded = safeAdd(totalUpgraded, value); // Upgrade agent reissues the tokens upgradeAgent.upgradeFrom(msg.sender, value); Upgrade(msg.sender, upgradeAgent, value); } /** * Set an upgrade agent that handles */ function setUpgradeAgent(address agent) external { if(!canUpgrade()) { // The token is not yet in a state that we could think upgrading revert(); } if (agent == 0x0) revert(); // Only a master can designate the next agent if (msg.sender != upgradeMaster) revert(); // Upgrade has already begun for an agent if (getUpgradeState() == UpgradeState.Upgrading) revert(); upgradeAgent = UpgradeAgent(agent); // Bad interface if(!upgradeAgent.isUpgradeAgent()) revert(); // Make sure that token supplies match in source and target if (upgradeAgent.originalSupply() != totalSupply) revert(); UpgradeAgentSet(upgradeAgent); } /** * Get the state of the token upgrade. */ function getUpgradeState() public constant returns(UpgradeState) { if(!canUpgrade()) return UpgradeState.NotAllowed; else if(address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent; else if(totalUpgraded == 0) return UpgradeState.ReadyToUpgrade; else return UpgradeState.Upgrading; } /** * Change the upgrade master. * * This allows us to set a new owner for the upgrade mechanism. */ function setUpgradeMaster(address master) public { if (master == 0x0) revert(); if (msg.sender != upgradeMaster) revert(); upgradeMaster = master; } /** * Child contract can enable to provide the condition when the upgrade can begun. */ function canUpgrade() public constant returns(bool) { return true; } }
25,118
9
// ============ State Variables ============ // ============ Constructor ============ //Instantiate addresses, methodology parameters, execution parameters, and incentive parameters._managerAddress of IBaseManager contract _strategy Struct of contract addresses _methodologyStruct containing methodology parameters _executionStruct containing execution parameters _incentiveStruct containing incentive parameters for ripcord _exchangeNamesList of initial exchange names _exchangeSettings List of structs containing exchange parameters for the initial exchanges /
constructor( IBaseManager _manager, ContractSettings memory _strategy, MethodologySettings memory _methodology, ExecutionSettings memory _execution, IncentiveSettings memory _incentive, string[] memory _exchangeNames, ExchangeSettings[] memory _exchangeSettings ) public
constructor( IBaseManager _manager, ContractSettings memory _strategy, MethodologySettings memory _methodology, ExecutionSettings memory _execution, IncentiveSettings memory _incentive, string[] memory _exchangeNames, ExchangeSettings[] memory _exchangeSettings ) public
29,316
25
// update UserEarn info for a legacy (cleared during swap) limit order./an limit order we call it 'legacy' if it together with other limit order of same/direction and same point on the pool is cleared during one time of exchanging./if an limit order is convinced to be 'legacy', we should mark it as 'sold out',/etc, transform all its remained selling token to earned token./self UserEarn storage object of target limit order/addDelta addition of selling amount/currAccEarn 'accEarn' value of corresponding point order on swap pool./accumulate amount of earned token /sqrtPrice_96 describe price of limit order/totalLegacyEarn remained(undistributed) amount of earned token of legacy
function updateLegacyOrder( UserEarn.Data storage self, uint128 addDelta, uint256 currAccEarn, uint160 sqrtPrice_96, uint128 totalLegacyEarn, bool isEarnY
function updateLegacyOrder( UserEarn.Data storage self, uint128 addDelta, uint256 currAccEarn, uint160 sqrtPrice_96, uint128 totalLegacyEarn, bool isEarnY
18,851
201
// mint settings
uint256 public maxSupply = 5000; uint256 public maxPerMint = 20; uint256 public pricePerToken = 50000000000000000; uint256 public tokenfyPrice = 18300000000000000000000;
uint256 public maxSupply = 5000; uint256 public maxPerMint = 20; uint256 public pricePerToken = 50000000000000000; uint256 public tokenfyPrice = 18300000000000000000000;
9,639
12
// Reset recipient and fee with newly data
for (uint i = 0; i < recipientCount; i++) { recipient[i] = _recipient[i]; fee[i] = _fee[i]; }
for (uint i = 0; i < recipientCount; i++) { recipient[i] = _recipient[i]; fee[i] = _fee[i]; }
28,898
5
// Timestamp of start of campaign
uint32 startAt;
uint32 startAt;
1,755
13
// Mapping from a bridge token into a whitelisted liquidity pool for the token./ Could be used for swaps on both origin and destination chains./ For swaps on destination chains, this is the only pool that could be used for swaps for the given token.
mapping(address => TypedPool) internal _bridgePools;
mapping(address => TypedPool) internal _bridgePools;
8,150
14
// Getters
function getChainId() external view returns (uint256); function getStoredChainId() external view returns (uint256);
function getChainId() external view returns (uint256); function getStoredChainId() external view returns (uint256);
8,521
286
// expmodsAndPoints.expmods[14] = traceGenerator^23.
mstore(add(expmodsAndPoints, 0x1c0), mulmod(mload(add(expmodsAndPoints, 0x1a0)), // traceGenerator^22 traceGenerator, // traceGenerator^1 PRIME))
mstore(add(expmodsAndPoints, 0x1c0), mulmod(mload(add(expmodsAndPoints, 0x1a0)), // traceGenerator^22 traceGenerator, // traceGenerator^1 PRIME))
63,891
171
// called when token is deposited on root chain Should be callable only by ChildChainManagerShould handle deposit by minting the required amount for userMake sure minting is done only by this function user user address for whom deposit is being done depositData abi encoded amount /
function deposit(address user, bytes calldata depositData) external override only(DEPOSITOR_ROLE)
function deposit(address user, bytes calldata depositData) external override only(DEPOSITOR_ROLE)
22,571
0
// Constant state/Constant state used by the swap router
library Constants { /// @dev Used for identifying cases when this contract's balance of a token is to be used uint256 internal constant CONTRACT_BALANCE = 0; /// @dev Used as a flag for identifying msg.sender, saves gas by sending more 0 bytes address internal constant MSG_SENDER = address(1); /// @dev Used as a flag for identifying address(this), saves gas by sending more 0 bytes address internal constant ADDRESS_THIS = address(2); }
library Constants { /// @dev Used for identifying cases when this contract's balance of a token is to be used uint256 internal constant CONTRACT_BALANCE = 0; /// @dev Used as a flag for identifying msg.sender, saves gas by sending more 0 bytes address internal constant MSG_SENDER = address(1); /// @dev Used as a flag for identifying address(this), saves gas by sending more 0 bytes address internal constant ADDRESS_THIS = address(2); }
7,114
14
// Gets the maximum age that the oracle price can be before the call is routed to fallback/ return the max age in seconds
function getMaxPriceAgeLimit() external view returns (uint256) { return maxPriceAgeLimit; }
function getMaxPriceAgeLimit() external view returns (uint256) { return maxPriceAgeLimit; }
26,389
244
// Returns true if the two slices contain the same text. self The first slice to compare. self The second slice to compare.return True if the slices are equal, false otherwise. /
function equals(slice memory self, slice memory other) internal pure returns (bool) { return compare(self, other) == 0; }
function equals(slice memory self, slice memory other) internal pure returns (bool) { return compare(self, other) == 0; }
27,508
1
// Error messages
string public constant MINT_BEFORE_START = "Sale not started"; string public constant INCORRECT_AMOUNT = "Incorrect amount sent"; string public constant PURCHACE_TOO_MANY = "Quantity was greater than 20"; string public constant NO_CHARACTERS = "No characters are available"; string public constant INVALID_CHARACTER = "Non-existent character"; string public constant MAIN_SALE_ENDED = "Main sale has ended";
string public constant MINT_BEFORE_START = "Sale not started"; string public constant INCORRECT_AMOUNT = "Incorrect amount sent"; string public constant PURCHACE_TOO_MANY = "Quantity was greater than 20"; string public constant NO_CHARACTERS = "No characters are available"; string public constant INVALID_CHARACTER = "Non-existent character"; string public constant MAIN_SALE_ENDED = "Main sale has ended";
54,085
0
// Counters to regulate the current amount of NFT Tokens minted
using Counters for Counters.Counter; Counters.Counter private supply;
using Counters for Counters.Counter; Counters.Counter private supply;
19,210
25
// Send commission to marketplace member address /
function handleIncomingPayment(address member) private
function handleIncomingPayment(address member) private
19,426
32
// PhotochainMarketplace Marketplace to make and accept offers using PhotonToken /
contract PhotochainMarketplace is Ownable { /** * Event for offer creation logging * @param id Generated unique offer id * @param seller Addess of seller of the photo * @param licenseType Which license is applied on the offer * @param photoDigest 256-bit hash of the photo * @param price How many tokens to pay to accept the offer */ event OfferAdded( bytes32 indexed id, address indexed seller, uint8 licenseType, bytes32 photoDigest, uint256 price ); /** * Event for offer acceptance logging * @param id Offer id to accept * @param licensee Address of the account that bought license */ event OfferAccepted(bytes32 indexed id, address indexed licensee); /** * Event for offer price change * @param id Offer id to update * @param oldPrice Previous price in tokens * @param newPrice New price in tokens */ event OfferPriceChanged(bytes32 indexed id, uint256 oldPrice, uint256 newPrice); /** * Event for offer cancellation * @param id Offer id to cancel */ event OfferCancelled(bytes32 indexed id); struct Offer { address seller; uint8 licenseType; bool isCancelled; bytes32 photoDigest; uint256 price; } ERC20 public token; // List of the offers mapping(bytes32 => Offer) public offers; // List of offer ids by seller mapping(address => bytes32[]) public offersBySeller; // List of offer ids by licensee mapping(address => bytes32[]) public offersByLicensee; modifier onlyValidAddress(address _addr) { require(_addr != address(0), "Invalid address"); _; } modifier onlyActiveOffer(bytes32 _id) { require(offers[_id].seller != address(0), "Offer does not exists"); require(!offers[_id].isCancelled, "Offer is cancelled"); _; } /** * @param _token Address of the PhotonToken contract */ constructor(ERC20 _token) public onlyValidAddress(address(_token)) { token = _token; } /** @dev Sets accounting token address * @param _token Address of the PhotonToken contract */ function setToken(ERC20 _token) external onlyOwner onlyValidAddress(address(_token)) { token = _token; } /** * @dev Add an offer to the marketplace * @param _seller Address of the photo author * @param _licenseType License type for the offer * @param _photoDigest 256-bit hash of the photo * @param _price Price of the offer */ function addOffer( address _seller, uint8 _licenseType, bytes32 _photoDigest, uint256 _price ) external onlyOwner onlyValidAddress(_seller) { bytes32 _id = keccak256( abi.encodePacked( _seller, _licenseType, _photoDigest ) ); require(offers[_id].seller == address(0), "Offer already exists"); offersBySeller[_seller].push(_id); offers[_id] = Offer({ seller: _seller, licenseType: _licenseType, isCancelled: false, photoDigest: _photoDigest, price: _price }); emit OfferAdded(_id, _seller, _licenseType, _photoDigest, _price); } /** * @dev Accept an offer on the marketplace * @param _id Offer id * @param _licensee Address of the licensee that is buying the photo */ function acceptOffer(bytes32 _id, address _licensee) external onlyOwner onlyValidAddress(_licensee) onlyActiveOffer(_id) { Offer storage offer = offers[_id]; if (offer.price > 0) { require( token.transferFrom(_licensee, address(this), offer.price), "Token transfer to contract failed" ); require( token.transfer(offer.seller, offer.price), "Token transfer to seller failed" ); } offersByLicensee[_licensee].push(_id); emit OfferAccepted(_id, _licensee); } /** * @dev Change price of the offer * @param _id Offer id * @param _price Price of the offer in tokens */ function setOfferPrice(bytes32 _id, uint256 _price) external onlyOwner onlyActiveOffer(_id) { uint256 oldPrice = offers[_id].price; offers[_id].price = _price; emit OfferPriceChanged(_id, oldPrice, _price); } /** * @dev Cancel offer * @param _id Offer id */ function cancelOffer(bytes32 _id) external onlyOwner onlyActiveOffer(_id) { offers[_id].isCancelled = true; emit OfferCancelled(_id); } /** * @dev Get list of offers id from a seller * @param _seller The address of the seller to find its offers * @return Offer ids */ function getOffers(address _seller) external view returns (bytes32[] memory) { return offersBySeller[_seller]; } /** * @dev Get the offer by id * @param _id The offer id * @return Offer details */ function getOfferById(bytes32 _id) external view returns ( address seller, uint8 licenseType, bool isCancelled, bytes32 photoDigest, uint256 price ) { Offer storage offer = offers[_id]; seller = offer.seller; licenseType = offer.licenseType; isCancelled = offer.isCancelled; photoDigest = offer.photoDigest; price = offer.price; } /** * @dev Get the list of the offers id by a licensee * @param _licensee Address of a licensee of offers */ function getLicenses(address _licensee) external view returns (bytes32[] memory) { return offersByLicensee[_licensee]; } }
contract PhotochainMarketplace is Ownable { /** * Event for offer creation logging * @param id Generated unique offer id * @param seller Addess of seller of the photo * @param licenseType Which license is applied on the offer * @param photoDigest 256-bit hash of the photo * @param price How many tokens to pay to accept the offer */ event OfferAdded( bytes32 indexed id, address indexed seller, uint8 licenseType, bytes32 photoDigest, uint256 price ); /** * Event for offer acceptance logging * @param id Offer id to accept * @param licensee Address of the account that bought license */ event OfferAccepted(bytes32 indexed id, address indexed licensee); /** * Event for offer price change * @param id Offer id to update * @param oldPrice Previous price in tokens * @param newPrice New price in tokens */ event OfferPriceChanged(bytes32 indexed id, uint256 oldPrice, uint256 newPrice); /** * Event for offer cancellation * @param id Offer id to cancel */ event OfferCancelled(bytes32 indexed id); struct Offer { address seller; uint8 licenseType; bool isCancelled; bytes32 photoDigest; uint256 price; } ERC20 public token; // List of the offers mapping(bytes32 => Offer) public offers; // List of offer ids by seller mapping(address => bytes32[]) public offersBySeller; // List of offer ids by licensee mapping(address => bytes32[]) public offersByLicensee; modifier onlyValidAddress(address _addr) { require(_addr != address(0), "Invalid address"); _; } modifier onlyActiveOffer(bytes32 _id) { require(offers[_id].seller != address(0), "Offer does not exists"); require(!offers[_id].isCancelled, "Offer is cancelled"); _; } /** * @param _token Address of the PhotonToken contract */ constructor(ERC20 _token) public onlyValidAddress(address(_token)) { token = _token; } /** @dev Sets accounting token address * @param _token Address of the PhotonToken contract */ function setToken(ERC20 _token) external onlyOwner onlyValidAddress(address(_token)) { token = _token; } /** * @dev Add an offer to the marketplace * @param _seller Address of the photo author * @param _licenseType License type for the offer * @param _photoDigest 256-bit hash of the photo * @param _price Price of the offer */ function addOffer( address _seller, uint8 _licenseType, bytes32 _photoDigest, uint256 _price ) external onlyOwner onlyValidAddress(_seller) { bytes32 _id = keccak256( abi.encodePacked( _seller, _licenseType, _photoDigest ) ); require(offers[_id].seller == address(0), "Offer already exists"); offersBySeller[_seller].push(_id); offers[_id] = Offer({ seller: _seller, licenseType: _licenseType, isCancelled: false, photoDigest: _photoDigest, price: _price }); emit OfferAdded(_id, _seller, _licenseType, _photoDigest, _price); } /** * @dev Accept an offer on the marketplace * @param _id Offer id * @param _licensee Address of the licensee that is buying the photo */ function acceptOffer(bytes32 _id, address _licensee) external onlyOwner onlyValidAddress(_licensee) onlyActiveOffer(_id) { Offer storage offer = offers[_id]; if (offer.price > 0) { require( token.transferFrom(_licensee, address(this), offer.price), "Token transfer to contract failed" ); require( token.transfer(offer.seller, offer.price), "Token transfer to seller failed" ); } offersByLicensee[_licensee].push(_id); emit OfferAccepted(_id, _licensee); } /** * @dev Change price of the offer * @param _id Offer id * @param _price Price of the offer in tokens */ function setOfferPrice(bytes32 _id, uint256 _price) external onlyOwner onlyActiveOffer(_id) { uint256 oldPrice = offers[_id].price; offers[_id].price = _price; emit OfferPriceChanged(_id, oldPrice, _price); } /** * @dev Cancel offer * @param _id Offer id */ function cancelOffer(bytes32 _id) external onlyOwner onlyActiveOffer(_id) { offers[_id].isCancelled = true; emit OfferCancelled(_id); } /** * @dev Get list of offers id from a seller * @param _seller The address of the seller to find its offers * @return Offer ids */ function getOffers(address _seller) external view returns (bytes32[] memory) { return offersBySeller[_seller]; } /** * @dev Get the offer by id * @param _id The offer id * @return Offer details */ function getOfferById(bytes32 _id) external view returns ( address seller, uint8 licenseType, bool isCancelled, bytes32 photoDigest, uint256 price ) { Offer storage offer = offers[_id]; seller = offer.seller; licenseType = offer.licenseType; isCancelled = offer.isCancelled; photoDigest = offer.photoDigest; price = offer.price; } /** * @dev Get the list of the offers id by a licensee * @param _licensee Address of a licensee of offers */ function getLicenses(address _licensee) external view returns (bytes32[] memory) { return offersByLicensee[_licensee]; } }
39,117
37
// The rank contract allows you to assign a rank to users./Nethny/Allows you to assign different parameters to users/By default, the first created rank is used for users./ This rank can be changed using various parameter change functions./ Ranks are 2 arrays (name array, value array), they are extensible/ and provide flexibility to the rank system./ (Don't forget about memory allocation and overuse)// EXAMPLE ==================/ "First", ["1 param", "2 param", "3 param", "4 param"],[1,2,3,4], True/ "Second", ["A", "B", "C", "D"],[4,3,2,1], True/ EXAMPLE ==================
contract Ranking is Ownable { struct Rank { string Name; string[] pNames; uint256[] pValues; bool isChangeable; } //List of ranks Rank[] public _ranks; mapping(string => uint256) public _rankSequence; uint256 _ranksHead; //Table of ranks assigned to users mapping(address => uint256) public _rankTable; /// @notice Give a users the rank /// @dev To make it easier to change the ranks of a large number of users /// For the admin only /// @param users - an array of users to assign a rank to, rank - the name of the title to be awarded /// @return bool (On successful execution returns true) function giveRanks(address[] memory users, string memory rank) public onlyOwner returns (bool) { uint256 index = searchRank(rank); for (uint256 i = 0; i < users.length; i++) { _rankTable[users[i]] = index; } return true; } /// @notice Give a user the rank /// @dev For the admin only /// @param user - the address of the user to whom you want to assign a rank, rank - the name of the title to be awarded /// @return bool (On successful execution returns true) function giveRank(address user, string memory rank) public onlyOwner returns (bool) { uint256 index = searchRank(rank); _rankTable[user] = index; return true; } /// @notice Сreate the rank /// @dev For the admin only /// @param Name - Unique rank identifier /// @param pNames[] - An array of parameter names /// @param pValues[] - An array of parameter values /// @param isChangeable - Flag of rank variability /// @return bool (On successful execution returns true) function createRank( string memory Name, string[] memory pNames, uint256[] memory pValues, bool isChangeable ) public onlyOwner returns (bool) { require( pNames.length == pValues.length, "RANK: Each parameter must have a value!" ); Rank memory rank = Rank(Name, pNames, pValues, isChangeable); _rankSequence[Name] = _ranksHead; _ranks.push(rank); _ranksHead++; return true; } /// @notice Сhange the rank /// @dev For the admin only /// @param Name - Unique rank identifier /// @param pNames[] - An array of parameter names /// @param pValues[] - An array of parameter values /// @param isChangeable - Flag of rank variability /// @return bool (On successful execution returns true) function changeRank( string memory Name, string[] memory pNames, uint256[] memory pValues, bool isChangeable ) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); require( pNames.length == pValues.length, "RANK: Each parameter must have a value!" ); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); _ranks[index] = Rank(Name, pNames, pValues, isChangeable); return true; } /// @notice Сhange only the names of the rank parameters /// @dev For the admin only /// If the rank is variable /// @param Name - Unique rank identifier /// @param pNames[] - An array of parameter names /// @return bool (On successful execution returns true) function changeRankParNames(string memory Name, string[] memory pNames) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); require( pNames.length == _ranks[index].pNames.length, "RANK: Each parameter must have a value!" ); _ranks[index].pNames = pNames; return true; } /// @notice Сhange only the values of the rank parameters /// @dev For the admin only /// If the rank is variable /// @param Name - Unique rank identifier /// @param pValues[] - An array of parameter values /// @return bool (On successful execution returns true) function changeRankParValues(string memory Name, uint256[] memory pValues) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); require( pValues.length == _ranks[index].pValues.length, "RANK: Each parameter must have a value!" ); _ranks[index].pValues = pValues; return true; } /// @notice Blocks rank variability /// @dev For the admin only /// If the rank is variable /// @param Name - Unique rank identifier /// @return bool (On successful execution returns true) function lockRank(string memory Name) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); _ranks[index].isChangeable = false; return true; } /// @notice Renames the rank parameter /// @dev For the admin only /// If the rank is variable /// @param Name - Unique rank identifier /// @param NewParName - New parameter name /// @param NumberPar - The number of the parameter you want to change /// @return bool (On successful execution returns true) function renameRankParam( string memory Name, string memory NewParName, uint256 NumberPar ) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); require( _ranks[index].pNames.length > NumberPar, "RANK: There is no such parameter!" ); _ranks[index].pNames[NumberPar] = NewParName; return true; } /// @notice Change the rank parameter /// @dev For the admin only /// If the rank is variable /// @param Name - Unique rank identifier /// @param NewValue - New parameter value /// @param NumberPar - The number of the parameter you want to change /// @return bool (On successful execution returns true) function changeRankParam( string memory Name, uint32 NewValue, uint256 NumberPar ) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); require( _ranks[index].pNames.length > NumberPar, "RANK: There is no such parameter!" ); _ranks[index].pValues[NumberPar] = NewValue; return true; } /// @notice Renames the rank /// @dev For the admin only /// If the rank is variable /// @param Name - Unique rank identifier /// @param NewName - New rank name /// @return bool (On successful execution returns true) function renameRank(string memory Name, string memory NewName) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); _ranks[index].Name = NewName; _rankSequence[Name] = 0; _rankSequence[NewName] = index; return true; } /// @notice Searches for a rank by its name /// @dev For internal calls only /// @param Name - Unique rank identifier /// @return uint256 (Returns the number of the title you are looking for, or discards Rank not found) function searchRank(string memory Name) internal view returns (uint256) { uint256 temp = _rankSequence[Name]; if (temp < _ranksHead) { return temp; } revert("RANK: There is no such rank!"); } //View Functions /// @notice Shows the ranks /// @dev Read-only calls /// @return Rank[] function showRanks() public view returns (Rank[] memory) { require(_ranks.length > 0, "RANK: There are no ranks."); return _ranks; } /// @notice Shows the ranks parameters /// @dev Read-only calls /// @param Name - Rank name /// @return string Name /// string[] Parameters names /// uint32[] Parameters values /// bool - is Changeable? function showRank(string memory Name) public view returns ( string memory, string[] memory, uint256[] memory, bool ) { return ( _ranks[searchRank(Name)].Name, _ranks[searchRank(Name)].pNames, _ranks[searchRank(Name)].pValues, _ranks[searchRank(Name)].isChangeable ); } /// @notice Shows the ranks parameters /// @dev Read-only calls /// Saves gas by not using rank names /// @param Number - Rank number in the ranks array /// @return string Name /// string[] Parameters names /// uint32[] Parameters values /// bool - is Changeable? function showRankOfNumber(uint256 Number) public view returns ( string memory, string[] memory, uint256[] memory, bool ) { require(_ranks.length > Number, "RANK: There are no ranks."); return ( _ranks[Number].Name, _ranks[Number].pNames, _ranks[Number].pValues, _ranks[Number].isChangeable ); } /// @notice Returns the user's rank /// @dev Read-only calls /// @param user - User address /// @return string Name /// string[] Parameters names /// uint32[] Parameters values /// bool - is Changeable? function getRank(address user) public view returns ( string memory, string[] memory, uint256[] memory, bool ) { return ( _ranks[_rankTable[user]].Name, _ranks[_rankTable[user]].pNames, _ranks[_rankTable[user]].pValues, _ranks[_rankTable[user]].isChangeable ); } /// @notice Returns the names of the rank parameters /// @dev Read-only calls /// @param Name - Rank name /// @return string Name /// string[] Parameters names function getNameParRank(string memory Name) public view returns (string[] memory) { return _ranks[searchRank(Name)].pNames; } /// @notice Returns the values of the rank parameters /// @dev Read-only calls /// @param Name - Rank name /// @return string Name /// uint23[] Parameters values function getParRank(string memory Name) public view returns (uint256[] memory) { return _ranks[searchRank(Name)].pValues; } /// @notice Returns the current user parameters /// @dev Read-only calls /// @param user - User address /// @return uint32[] Parameters values function getParRankOfUser(address user) public view returns (uint256[] memory) { return _ranks[_rankTable[user]].pValues; } }
contract Ranking is Ownable { struct Rank { string Name; string[] pNames; uint256[] pValues; bool isChangeable; } //List of ranks Rank[] public _ranks; mapping(string => uint256) public _rankSequence; uint256 _ranksHead; //Table of ranks assigned to users mapping(address => uint256) public _rankTable; /// @notice Give a users the rank /// @dev To make it easier to change the ranks of a large number of users /// For the admin only /// @param users - an array of users to assign a rank to, rank - the name of the title to be awarded /// @return bool (On successful execution returns true) function giveRanks(address[] memory users, string memory rank) public onlyOwner returns (bool) { uint256 index = searchRank(rank); for (uint256 i = 0; i < users.length; i++) { _rankTable[users[i]] = index; } return true; } /// @notice Give a user the rank /// @dev For the admin only /// @param user - the address of the user to whom you want to assign a rank, rank - the name of the title to be awarded /// @return bool (On successful execution returns true) function giveRank(address user, string memory rank) public onlyOwner returns (bool) { uint256 index = searchRank(rank); _rankTable[user] = index; return true; } /// @notice Сreate the rank /// @dev For the admin only /// @param Name - Unique rank identifier /// @param pNames[] - An array of parameter names /// @param pValues[] - An array of parameter values /// @param isChangeable - Flag of rank variability /// @return bool (On successful execution returns true) function createRank( string memory Name, string[] memory pNames, uint256[] memory pValues, bool isChangeable ) public onlyOwner returns (bool) { require( pNames.length == pValues.length, "RANK: Each parameter must have a value!" ); Rank memory rank = Rank(Name, pNames, pValues, isChangeable); _rankSequence[Name] = _ranksHead; _ranks.push(rank); _ranksHead++; return true; } /// @notice Сhange the rank /// @dev For the admin only /// @param Name - Unique rank identifier /// @param pNames[] - An array of parameter names /// @param pValues[] - An array of parameter values /// @param isChangeable - Flag of rank variability /// @return bool (On successful execution returns true) function changeRank( string memory Name, string[] memory pNames, uint256[] memory pValues, bool isChangeable ) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); require( pNames.length == pValues.length, "RANK: Each parameter must have a value!" ); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); _ranks[index] = Rank(Name, pNames, pValues, isChangeable); return true; } /// @notice Сhange only the names of the rank parameters /// @dev For the admin only /// If the rank is variable /// @param Name - Unique rank identifier /// @param pNames[] - An array of parameter names /// @return bool (On successful execution returns true) function changeRankParNames(string memory Name, string[] memory pNames) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); require( pNames.length == _ranks[index].pNames.length, "RANK: Each parameter must have a value!" ); _ranks[index].pNames = pNames; return true; } /// @notice Сhange only the values of the rank parameters /// @dev For the admin only /// If the rank is variable /// @param Name - Unique rank identifier /// @param pValues[] - An array of parameter values /// @return bool (On successful execution returns true) function changeRankParValues(string memory Name, uint256[] memory pValues) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); require( pValues.length == _ranks[index].pValues.length, "RANK: Each parameter must have a value!" ); _ranks[index].pValues = pValues; return true; } /// @notice Blocks rank variability /// @dev For the admin only /// If the rank is variable /// @param Name - Unique rank identifier /// @return bool (On successful execution returns true) function lockRank(string memory Name) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); _ranks[index].isChangeable = false; return true; } /// @notice Renames the rank parameter /// @dev For the admin only /// If the rank is variable /// @param Name - Unique rank identifier /// @param NewParName - New parameter name /// @param NumberPar - The number of the parameter you want to change /// @return bool (On successful execution returns true) function renameRankParam( string memory Name, string memory NewParName, uint256 NumberPar ) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); require( _ranks[index].pNames.length > NumberPar, "RANK: There is no such parameter!" ); _ranks[index].pNames[NumberPar] = NewParName; return true; } /// @notice Change the rank parameter /// @dev For the admin only /// If the rank is variable /// @param Name - Unique rank identifier /// @param NewValue - New parameter value /// @param NumberPar - The number of the parameter you want to change /// @return bool (On successful execution returns true) function changeRankParam( string memory Name, uint32 NewValue, uint256 NumberPar ) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); require( _ranks[index].pNames.length > NumberPar, "RANK: There is no such parameter!" ); _ranks[index].pValues[NumberPar] = NewValue; return true; } /// @notice Renames the rank /// @dev For the admin only /// If the rank is variable /// @param Name - Unique rank identifier /// @param NewName - New rank name /// @return bool (On successful execution returns true) function renameRank(string memory Name, string memory NewName) public onlyOwner returns (bool) { require(_ranks.length > 0, "RANK: There are no ranks."); uint256 index = searchRank(Name); require( _ranks[index].isChangeable, "RANK: This rank cannot be changed!" ); _ranks[index].Name = NewName; _rankSequence[Name] = 0; _rankSequence[NewName] = index; return true; } /// @notice Searches for a rank by its name /// @dev For internal calls only /// @param Name - Unique rank identifier /// @return uint256 (Returns the number of the title you are looking for, or discards Rank not found) function searchRank(string memory Name) internal view returns (uint256) { uint256 temp = _rankSequence[Name]; if (temp < _ranksHead) { return temp; } revert("RANK: There is no such rank!"); } //View Functions /// @notice Shows the ranks /// @dev Read-only calls /// @return Rank[] function showRanks() public view returns (Rank[] memory) { require(_ranks.length > 0, "RANK: There are no ranks."); return _ranks; } /// @notice Shows the ranks parameters /// @dev Read-only calls /// @param Name - Rank name /// @return string Name /// string[] Parameters names /// uint32[] Parameters values /// bool - is Changeable? function showRank(string memory Name) public view returns ( string memory, string[] memory, uint256[] memory, bool ) { return ( _ranks[searchRank(Name)].Name, _ranks[searchRank(Name)].pNames, _ranks[searchRank(Name)].pValues, _ranks[searchRank(Name)].isChangeable ); } /// @notice Shows the ranks parameters /// @dev Read-only calls /// Saves gas by not using rank names /// @param Number - Rank number in the ranks array /// @return string Name /// string[] Parameters names /// uint32[] Parameters values /// bool - is Changeable? function showRankOfNumber(uint256 Number) public view returns ( string memory, string[] memory, uint256[] memory, bool ) { require(_ranks.length > Number, "RANK: There are no ranks."); return ( _ranks[Number].Name, _ranks[Number].pNames, _ranks[Number].pValues, _ranks[Number].isChangeable ); } /// @notice Returns the user's rank /// @dev Read-only calls /// @param user - User address /// @return string Name /// string[] Parameters names /// uint32[] Parameters values /// bool - is Changeable? function getRank(address user) public view returns ( string memory, string[] memory, uint256[] memory, bool ) { return ( _ranks[_rankTable[user]].Name, _ranks[_rankTable[user]].pNames, _ranks[_rankTable[user]].pValues, _ranks[_rankTable[user]].isChangeable ); } /// @notice Returns the names of the rank parameters /// @dev Read-only calls /// @param Name - Rank name /// @return string Name /// string[] Parameters names function getNameParRank(string memory Name) public view returns (string[] memory) { return _ranks[searchRank(Name)].pNames; } /// @notice Returns the values of the rank parameters /// @dev Read-only calls /// @param Name - Rank name /// @return string Name /// uint23[] Parameters values function getParRank(string memory Name) public view returns (uint256[] memory) { return _ranks[searchRank(Name)].pValues; } /// @notice Returns the current user parameters /// @dev Read-only calls /// @param user - User address /// @return uint32[] Parameters values function getParRankOfUser(address user) public view returns (uint256[] memory) { return _ranks[_rankTable[user]].pValues; } }
41,465
13
// Allows _spender to withdraw the _allowance amount form sender /
function approve(address _spender, uint256 _allowance) returns (bool success) { if (balances[msg.sender] >= _allowance) { allowed[msg.sender][_spender] = _allowance; Approval(msg.sender, _spender, _allowance); return true; } else { return false; } }
function approve(address _spender, uint256 _allowance) returns (bool success) { if (balances[msg.sender] >= _allowance) { allowed[msg.sender][_spender] = _allowance; Approval(msg.sender, _spender, _allowance); return true; } else { return false; } }
12,855
191
// to admin
(bool success2, ) = admin.call.value(amount4admin)(""); require(success2, "Transfer failed.");
(bool success2, ) = admin.call.value(amount4admin)(""); require(success2, "Transfer failed.");
83,089
383
// deposits WETH into the reserve, using native ETH. A corresponding amount of the overlying asset (aTokens)is minted. onBehalfOf address of the user who will receive the aTokens representing the deposit referralCode integrators are assigned a referral code and can potentially receive rewards. /
function depositETH(address onBehalfOf, uint16 referralCode) external payable override { WETH.deposit{value: msg.value}(); POOL.deposit(address(WETH), msg.value, onBehalfOf, referralCode); }
function depositETH(address onBehalfOf, uint16 referralCode) external payable override { WETH.deposit{value: msg.value}(); POOL.deposit(address(WETH), msg.value, onBehalfOf, referralCode); }
25,048
6
// Record the time the contract bought the tokens.
uint256 public time_bought;
uint256 public time_bought;
47,619
16
// NoteRegistry creation method. Takes an id of the factory to use._linkedTokenAddress - address of any erc20 linked token (can not be 0x0 if canConvert is true)_scalingFactor - defines the number of tokens that an AZTEC note value of 1 maps to._canAdjustSupply - whether the noteRegistry can make use of minting and burning_canConvert - whether the noteRegistry can transfer value from private to public_factoryId - uint24 which contains 3 uint8s representing (epoch, cryptoSystem, assetType)/
function createNoteRegistry( address _linkedTokenAddress, uint256 _scalingFactor, bool _canAdjustSupply, bool _canConvert, uint24 _factoryId
function createNoteRegistry( address _linkedTokenAddress, uint256 _scalingFactor, bool _canAdjustSupply, bool _canConvert, uint24 _factoryId
30,062
23
// Token state
enum Phase { Created, Running, Paused, Migrating, Migrated }
enum Phase { Created, Running, Paused, Migrating, Migrated }
54,187
26
// IERC20Metadata/Alchemix Finance
interface IERC20Metadata { /// @notice Gets the name of the token. /// /// @return The name. function name() external view returns (string memory); /// @notice Gets the symbol of the token. /// /// @return The symbol. function symbol() external view returns (string memory); /// @notice Gets the number of decimals that the token has. /// /// @return The number of decimals. function decimals() external view returns (uint8); }
interface IERC20Metadata { /// @notice Gets the name of the token. /// /// @return The name. function name() external view returns (string memory); /// @notice Gets the symbol of the token. /// /// @return The symbol. function symbol() external view returns (string memory); /// @notice Gets the number of decimals that the token has. /// /// @return The number of decimals. function decimals() external view returns (uint8); }
55,662
3
// Gets balance of third party ERC20 token/
function getBalanceOfExternalERC20(address _erc20Address) external view returns (uint256)
function getBalanceOfExternalERC20(address _erc20Address) external view returns (uint256)
55,331
48
// called by the manager to pause, triggers stopped state /
function pauseContract() external onlyAllowedManager('pause_contract') whenContractNotPaused { paused = true; PauseEvent(); }
function pauseContract() external onlyAllowedManager('pause_contract') whenContractNotPaused { paused = true; PauseEvent(); }
49,911
13
// Returns true if an address has configurator rights/account Address to check
function isConfigurator(address account) external view override returns (bool)
function isConfigurator(address account) external view override returns (bool)
22,657
52
// operator
DependLike_3(seniorOperator).depend("tranche", seniorTranche); DependLike_3(juniorOperator).depend("tranche", juniorTranche); DependLike_3(seniorOperator).depend("token", seniorToken); DependLike_3(juniorOperator).depend("token", juniorToken);
DependLike_3(seniorOperator).depend("tranche", seniorTranche); DependLike_3(juniorOperator).depend("tranche", juniorTranche); DependLike_3(seniorOperator).depend("token", seniorToken); DependLike_3(juniorOperator).depend("token", juniorToken);
36,109
4
// permanently lock the first MINIMUM_LIQUIDITY tokens
mintTokens = mintTokens.sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY);
mintTokens = mintTokens.sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY);
36,222
31
// Current number of votes in opposition to this proposal
uint256 againstVotes;
uint256 againstVotes;
9,634
29
// Sets the final sum of user stakes for history and profit computation. Callable only once per cycle.The token balance of the contract may not be set as final stake, because there might have occurred unapproved deposits. value the number of EDG tokens that were transfered from the bankroll/
function closeCycle(uint value) public onlyAuthorized bankrollPhase { require(tokenBalance() >= value); finalStakes[cycle] = safeSub(value, safeMul(updateGasCost, numHolders)/100);//updateGasCost is using 2 decimals }
function closeCycle(uint value) public onlyAuthorized bankrollPhase { require(tokenBalance() >= value); finalStakes[cycle] = safeSub(value, safeMul(updateGasCost, numHolders)/100);//updateGasCost is using 2 decimals }
7,492
81
// Actually unpause the contract.
super.unpause();
super.unpause();
13,036
15
// 给接收者加上相同的量
balanceOf[_to] += _value;
balanceOf[_to] += _value;
25,097
47
// contributor reward update
function updateContribReward(address _from) external { // require(msg.sender == address(metaGeckosContract)); uint256 time = min(block.timestamp, ends[_from]); uint256 timerFrom = lastUpdate[_from]; if (timerFrom > 0) rewards[_from] += rates[_from].mul((time.sub(timerFrom))).div(86400); if (timerFrom != ends[_from]) lastUpdate[_from] = time; }
function updateContribReward(address _from) external { // require(msg.sender == address(metaGeckosContract)); uint256 time = min(block.timestamp, ends[_from]); uint256 timerFrom = lastUpdate[_from]; if (timerFrom > 0) rewards[_from] += rates[_from].mul((time.sub(timerFrom))).div(86400); if (timerFrom != ends[_from]) lastUpdate[_from] = time; }
38,746
6
// Returns the number of terms to maturity./
function Maturity() public override pure returns (uint256) { return 6; }
function Maturity() public override pure returns (uint256) { return 6; }
3,686
29
// Fallback function for funding smart contract./
function() external payable
function() external payable
6,292
81
// Enable the {transfer}, {mint} and {burn} functions of contract. Can only be called by the current owner.The contract must be paused. /
function unfreeze() public onlyOwner { _unpause(); }
function unfreeze() public onlyOwner { _unpause(); }
79,238
146
// then we shift left by the difference
amount = amount * 10**(decimalsAfter - decimalsBefore);
amount = amount * 10**(decimalsAfter - decimalsBefore);
34,400
47
// Mint new tokens./account Address to send newly minted tokens to./value Amount of tokens to mint.
function mint(address account, uint value) public onlyMintingAdmin whitelistedAddress(account) mpvNotPaused
function mint(address account, uint value) public onlyMintingAdmin whitelistedAddress(account) mpvNotPaused
10,853
78
// The Declaration constructor to define some constants /
constructor() public { setFeeDistributionsAndStatusThresholds(); }
constructor() public { setFeeDistributionsAndStatusThresholds(); }
72,132
13
// Verify if address is allowed to mint on project. _proof Merkle proof for address. _address Address to check.return inAllowlist true only if address is allowed to mint and validMerkle proof was provided /
function _verifyAddress( address _address, bytes32[] memory _proof
function _verifyAddress( address _address, bytes32[] memory _proof
22,394
0
// Concat Appends two strings together and returns a new value_base When being used for a data type this is the extended object otherwise this is the string which will be the concatenated prefix _value The value to be the concatenated suffixreturn string The resulting string from combining the base and value /
function concat(string memory _base, string memory _value) internal pure returns (string memory)
function concat(string memory _base, string memory _value) internal pure returns (string memory)
16,387
147
// acceptanceBudget - Paymaster expected gas budget to accept (or reject) a request This a gas required by any calculations that might need to reject the transaction, by preRelayedCall, forwarder and recipient. See value in BasePaymaster.PAYMASTER_ACCEPTANCE_BUDGET Transaction that gets rejected above that gas usage is on the paymaster's expense. As long this value is above preRelayedCallGasLimit (see defaults in BasePaymaster), the Paymaster is guaranteed it will never pay for rejected transactions. If this value is below preRelayedCallGasLimt, it might might make Paymaster open to a "griefing" attack.Specifying value too high might make the call rejected by some relayers.From a Relay's point
struct GasAndDataLimits { uint256 acceptanceBudget; uint256 preRelayedCallGasLimit; uint256 postRelayedCallGasLimit; uint256 calldataSizeLimit; }
struct GasAndDataLimits { uint256 acceptanceBudget; uint256 preRelayedCallGasLimit; uint256 postRelayedCallGasLimit; uint256 calldataSizeLimit; }
11,198
1
// slither-disable-next-line unused-return
Address.functionCall(deployedProxy, _data);
Address.functionCall(deployedProxy, _data);
18,217
1,028
// Transfer funds to the beneficiary
if (address(0) == currencyCt && 0 == currencyId) beneficiary.receiveEthersTo.value(uint256(value))(destWallet, ""); else {
if (address(0) == currencyCt && 0 == currencyId) beneficiary.receiveEthersTo.value(uint256(value))(destWallet, ""); else {
35,890
70
// See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on`transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address. /
function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; }
function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; }
31,408
32
// /
function freezeWithTimestamp( address _target, uint256 _timestamp ) public
function freezeWithTimestamp( address _target, uint256 _timestamp ) public
50,414
2
// ----- VIEWS -----
function getStoreAddress() external view returns (address) { return _storeAddress; }
function getStoreAddress() external view returns (address) { return _storeAddress; }
49,615
14
// mapping(owner address => mapping(channelId uint => nonce uint256))) public canceled;
mapping(address => mapping(uint256 => uint)) public canceled; string public constant version = '2.0.0'; uint public applyWait = 1 days; uint public feeRate = 10; bool public withdrawEnabled = false; bool public stop = false; uint256 private DEFAULT_CHANNEL_ID = 0; bool public depositToEnabled = true; bool public transferEnabled = false; bool public changeChannelEnabled = false;
mapping(address => mapping(uint256 => uint)) public canceled; string public constant version = '2.0.0'; uint public applyWait = 1 days; uint public feeRate = 10; bool public withdrawEnabled = false; bool public stop = false; uint256 private DEFAULT_CHANNEL_ID = 0; bool public depositToEnabled = true; bool public transferEnabled = false; bool public changeChannelEnabled = false;
17,867
78
// solhint-disable // Wrappers over Solidity's arithmetic operations with added overflowchecks. Arithmetic operations in Solidity wrap on overflow. This can easily resultin bugs, because programmers usually assume that an overflow raises anerror, which is the standard behavior in high level programming languages.`SafeMath` restores this intuition by reverting the transaction when anoperation overflows. Using this library instead of the unchecked operations eliminates an entireclass of bugs, so it's recommended to use it always. /
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
63,927
25
// Internal function that stores the new proxy admin address to the corresponding storage slot./
function _setAdmin(address newAdmin) internal { bytes32 slot = _ADMIN_SLOT; assembly { sstore(slot, newAdmin) } }
function _setAdmin(address newAdmin) internal { bytes32 slot = _ADMIN_SLOT; assembly { sstore(slot, newAdmin) } }
40,346
156
// Flag indicating if Custom Token burning has been permanently finished or not.
bool public burningFinished;
bool public burningFinished;
5,349
5
// Function to withdraw all Ether from this contract.
function withdraw() public onlyOwner { // get the amount of Ether stored in this contract uint amount = address(this).balance; // send all Ether to owner // Owner can receive Ether since the address of owner is payable (bool success, ) = _owner.call{value: amount}(""); require(success, "Failed to send Ether"); }
function withdraw() public onlyOwner { // get the amount of Ether stored in this contract uint amount = address(this).balance; // send all Ether to owner // Owner can receive Ether since the address of owner is payable (bool success, ) = _owner.call{value: amount}(""); require(success, "Failed to send Ether"); }
9,120
17
// Removes the special transfer right, before transfers are enabled _from The address that the transfer grant is removed from /
function cancelTransferRight(address _from) onlyOwner public { require(!transferable); require(transferGrants[_from]); transferGrants[_from] = false; TransferRightCancelled(_from); }
function cancelTransferRight(address _from) onlyOwner public { require(!transferable); require(transferGrants[_from]); transferGrants[_from] = false; TransferRightCancelled(_from); }
22,482
267
// Ensure sufficient balance.
require(address(this).balance >= amount, "insufficient balance");
require(address(this).balance >= amount, "insufficient balance");
19,957
67
// See {IBEP20-transfer}. Requirements: - `recipient` cannot be the zero address.- the caller must have a balance of at least `amount`. /
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
52,750
24
// Returns true if `account` is a contract. [IMPORTANT]====It is unsafe to assume that an address for which this function returnsfalse is an externally-owned account (EOA) and not a contract. Among others, `isContract` will return false for the followingtypes of addresses:- an externally-owned account - a contract in construction - an address where a contract will be created - an address where a contract lived, but was destroyed==== [IMPORTANT]====You shouldn't rely on `isContract` to protect against flash loan attacks! Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart walletslike Gnosis Safe, and does not provide security
function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; }
function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; }
28,656
121
// address of the interest rate strategy
address interestRateStrategyAddress;
address interestRateStrategyAddress;
22,680
86
// Mapping owner address to token count
mapping(address => uint256) private _balances;
mapping(address => uint256) private _balances;
57,976
100
// Once verified, set the token allowance to tokenQty
require(token.approve(_kyberProxy, tokenQty));
require(token.approve(_kyberProxy, tokenQty));
34,639
20
// BlackList
contract BlackList is Ownable { function getBlackListStatus(address _address) external view returns (bool) { return isBlackListed[_address]; } mapping (address => bool) public isBlackListed; function addBlackList(address _evilUser) public onlyOwnerAdmin { isBlackListed[_evilUser] = true; emit AddedBlackList(_evilUser); } function removeBlackList (address _clearedUser) public onlyOwnerAdmin { isBlackListed[_clearedUser] = false; emit RemovedBlackList(_clearedUser); } event AddedBlackList(address _user); event RemovedBlackList(address _user); }
contract BlackList is Ownable { function getBlackListStatus(address _address) external view returns (bool) { return isBlackListed[_address]; } mapping (address => bool) public isBlackListed; function addBlackList(address _evilUser) public onlyOwnerAdmin { isBlackListed[_evilUser] = true; emit AddedBlackList(_evilUser); } function removeBlackList (address _clearedUser) public onlyOwnerAdmin { isBlackListed[_clearedUser] = false; emit RemovedBlackList(_clearedUser); } event AddedBlackList(address _user); event RemovedBlackList(address _user); }
15,955
21
// Returns array list of registered `members` accounts in Baal.
function getMemberList() external view returns (address[] memory membership) { membership = memberList; }
function getMemberList() external view returns (address[] memory membership) { membership = memberList; }
9,341
80
// offer id has been done by swapper
event Swapped(address indexed swapper, uint256 indexed offerId);
event Swapped(address indexed swapper, uint256 indexed offerId);
7,016
257
// tokenBalance here has already _newAmount counted
uint256 tokenBalance = IERC20(token).balanceOf(address(this)); if (tokenBalance == 0) { return false; }
uint256 tokenBalance = IERC20(token).balanceOf(address(this)); if (tokenBalance == 0) { return false; }
37,632
91
// Math library for computing sqrt prices from ticks and vice versa/Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports/ prices between 2-128 and 2128
library TickMath { /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); require(absTick <= uint256(MAX_TICK), 'T'); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // 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)); } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { // second inequality must be < because the price can never reach the price at the max tick require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R'); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } }
library TickMath { /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); require(absTick <= uint256(MAX_TICK), 'T'); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // 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)); } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { // second inequality must be < because the price can never reach the price at the max tick require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R'); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } }
1,061
55
// Destroys `amount` tokens from `account`, reducing thetotal supply.
* Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); }
* Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); }
186
4
// - Directly repays a Lender using unused tokens already held by Line with no trading amount - amount of unused tokens to use to repay Lenderreturn - if function executed successfully /
function useAndRepay(uint256 amount) external returns (bool);
function useAndRepay(uint256 amount) external returns (bool);
27,985
91
// ============ Modifiers ============ //Throws if the sender is not the SetToken manager contract owner /
modifier onlyOwner(ISetToken _setToken) { require(msg.sender == _manager(_setToken).owner(), "Must be owner"); _; }
modifier onlyOwner(ISetToken _setToken) { require(msg.sender == _manager(_setToken).owner(), "Must be owner"); _; }
71,684
17
// Provides a safe ERC20.transfer version for different ERC-20 implementations./ Reverts on a failed transfer./token The address of the ERC-20 token./to Transfer tokens to./amount The token amount.
function safeTransfer( IERC20 token, address to, uint256 amount
function safeTransfer( IERC20 token, address to, uint256 amount
6,587
12
// namehash('eth')
bytes32 constant public TLD_NODE = 0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae; bool public stopped = false; address public registrarOwner; address public migration; address public registrar; ENS public ens;
bytes32 constant public TLD_NODE = 0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae; bool public stopped = false; address public registrarOwner; address public migration; address public registrar; ENS public ens;
28,562
112
// Gets the segment corresponding to the first pool in the path/path The bytes encoded swap path/ return The segment containing all data necessary to target the first pool in the path
function getFirstPool(bytes memory path) internal pure returns (bytes memory) { return path.slice(0, POP_OFFSET); }
function getFirstPool(bytes memory path) internal pure returns (bytes memory) { return path.slice(0, POP_OFFSET); }
37,379
4
// remove a operator role from an address _operator address /
function removeOperator(address _operator) public onlyOwner { removeRole(_operator, ROLE_OPERATOR); }
function removeOperator(address _operator) public onlyOwner { removeRole(_operator, ROLE_OPERATOR); }
28,925
27
// if first investment or investment after emergenct withdraw
if(!investors[msg.sender].isInvestor){ allInvestors.push(msg.sender); investors[msg.sender].isInvestor = true; investors[msg.sender].isLast = true; if(allInvestors.length > 3) { doublePercentsEnd[allInvestors[allInvestors.length.sub(4)]].push(block.timestamp); investors[allInvestors[allInvestors.length.sub(4)]].isLast = false; }
if(!investors[msg.sender].isInvestor){ allInvestors.push(msg.sender); investors[msg.sender].isInvestor = true; investors[msg.sender].isLast = true; if(allInvestors.length > 3) { doublePercentsEnd[allInvestors[allInvestors.length.sub(4)]].push(block.timestamp); investors[allInvestors[allInvestors.length.sub(4)]].isLast = false; }
42,454
48
// Add a delegate through an encoded signature
function addDelegateBySignature(address user, address delegate, uint deadline, uint8 v, bytes32 r, bytes32 s) public override { require(deadline >= block.timestamp, 'Delegable: Signature expired'); bytes32 hashStruct = keccak256( abi.encode( SIGNATURE_TYPEHASH, user, delegate, signatureCount[user]++, deadline ) ); bytes32 digest = keccak256( abi.encodePacked( '\x19\x01', DELEGABLE_DOMAIN, hashStruct ) ); address signer = ecrecover(digest, v, r, s); require( signer != address(0) && signer == user, 'Delegable: Invalid signature' ); _addDelegate(user, delegate); }
function addDelegateBySignature(address user, address delegate, uint deadline, uint8 v, bytes32 r, bytes32 s) public override { require(deadline >= block.timestamp, 'Delegable: Signature expired'); bytes32 hashStruct = keccak256( abi.encode( SIGNATURE_TYPEHASH, user, delegate, signatureCount[user]++, deadline ) ); bytes32 digest = keccak256( abi.encodePacked( '\x19\x01', DELEGABLE_DOMAIN, hashStruct ) ); address signer = ecrecover(digest, v, r, s); require( signer != address(0) && signer == user, 'Delegable: Invalid signature' ); _addDelegate(user, delegate); }
45,448
94
// sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() { dailyROI = _dailyROI; }
function setDailyROI(uint _dailyROI) external onlyOwner() { dailyROI = _dailyROI; }
27,660
320
// Extends and/or updates the current component set and its target units with new components and targets,Validates inputs, requiring that that new components and new target units arrays are the same size, andthat the number of old components target units matches the number of current components. Throws ifa duplicate component has been added. _currentComponents Complete set of current CKToken components _newComponentsArray of new components to add to allocation _newComponentsTargetUnits Array of target units at end of rebalance for new components, maps to same index of _newComponents array _oldComponentsTargetUnits Array of target units at end of rebalance for old component, maps to
function _getAggregateComponentsAndUnits( address[] memory _currentComponents, address[] calldata _newComponents, uint256[] calldata _newComponentsTargetUnits, uint256[] calldata _oldComponentsTargetUnits ) internal pure returns (address[] memory aggregateComponents, uint256[] memory aggregateTargetUnits)
function _getAggregateComponentsAndUnits( address[] memory _currentComponents, address[] calldata _newComponents, uint256[] calldata _newComponentsTargetUnits, uint256[] calldata _oldComponentsTargetUnits ) internal pure returns (address[] memory aggregateComponents, uint256[] memory aggregateTargetUnits)
8,975
59
// [LEGACY] Creates a new orderassetId - ID of the published NFTpriceInWei - Price in Wei for the supported coinexpiresAt - Duration of the order (in hours)/
function createOrder( uint256 assetId, uint256 priceInWei, uint256 expiresAt ) public whenNotPaused
function createOrder( uint256 assetId, uint256 priceInWei, uint256 expiresAt ) public whenNotPaused
43,224
53
// Deploys a new proxy for some version, with some initialization arguments, using `create` (i.e. factory's nonce determines the address).
function _newInstance(uint256 version_, bytes memory arguments_) internal virtual returns (bool success_, address proxy_) { address implementation = _implementationOf[version_]; if (implementation == address(0)) return (false, address(0)); proxy_ = address(new Proxy(address(this), implementation)); success_ = _initializeInstance(proxy_, version_, arguments_); }
function _newInstance(uint256 version_, bytes memory arguments_) internal virtual returns (bool success_, address proxy_) { address implementation = _implementationOf[version_]; if (implementation == address(0)) return (false, address(0)); proxy_ = address(new Proxy(address(this), implementation)); success_ = _initializeInstance(proxy_, version_, arguments_); }
3,073
62
// token_amount -= (referralAmount + bonus);
uint256 tokens = token_amount / 10; uint256 balanceAmount = token_amount - tokens; tokens += bonus;
uint256 tokens = token_amount / 10; uint256 balanceAmount = token_amount - tokens; tokens += bonus;
32,825
18
// give winnings for a bet to the player - can be triggered only by player _betId - the bet idreturn uint256 - returns the claimed amount /
function claimWinnings(uint256 _betId) external returns (uint256 amount);
function claimWinnings(uint256 _betId) external returns (uint256 amount);
49,989
216
// mint for user and the first level referrer.
rose.mint(msg.sender, _amount.div(100)); rose.mint(referrer, _amount.mul(2).div(100));
rose.mint(msg.sender, _amount.div(100)); rose.mint(referrer, _amount.mul(2).div(100));
14,478
34
// Gets an owner by 0-indexed position (using numOwners as the count)
function getOwner(uint ownerIndex) external constant returns (address) { return address(owners[ownerIndex + 1]); }
function getOwner(uint ownerIndex) external constant returns (address) { return address(owners[ownerIndex + 1]); }
24,364
210
// Set the mapping entry for this lottery address.
lotteryGasConfigs[ lotteryAddr ] = gasConfig;
lotteryGasConfigs[ lotteryAddr ] = gasConfig;
5,916
75
// This way the claimant either gets the balance because he sniped the team Or he initiates the transfer to the rightful owner
teams[_teamId].owner.transfer(teams[_teamId].balance); emit TeamOwnerPaid(_teamId, teams[_teamId].balance); teams[_teamId].balance = 0;
teams[_teamId].owner.transfer(teams[_teamId].balance); emit TeamOwnerPaid(_teamId, teams[_teamId].balance); teams[_teamId].balance = 0;
54,790
56
// See {IERC1417-revokeVote}. /
function revokeVote() public virtual override { Voter storage sender = _voters[_msgSender()]; require(sender.voted, "ERC1417: voter has not yet voted."); uint256 proposalId = sender.vote; uint256 voteWeight = sender.weight; sender.voted = false; _proposals[sender.vote].voteWeight = _proposals[sender.vote].voteWeight.sub(sender.weight);
function revokeVote() public virtual override { Voter storage sender = _voters[_msgSender()]; require(sender.voted, "ERC1417: voter has not yet voted."); uint256 proposalId = sender.vote; uint256 voteWeight = sender.weight; sender.voted = false; _proposals[sender.vote].voteWeight = _proposals[sender.vote].voteWeight.sub(sender.weight);
48,294