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
45
// This percent of a transaction will be redistribute to all holders.
uint32 private _taxReward;
uint32 private _taxReward;
55,845
0
// Storage for Community For future upgrades, do not change CommunityStorageV2. Create a newcontract which implements CommunityStorageV2 and following the naming conventionCommunityStorageVX. /
abstract contract CommunityStorageV2 is CommunityStorageV1 { IERC20 public _token; uint256 public override maxBeneficiaries; }
abstract contract CommunityStorageV2 is CommunityStorageV1 { IERC20 public _token; uint256 public override maxBeneficiaries; }
23,540
23
// Remove minter minter minter /
function removeMinter(address minter) external returns (bool)
function removeMinter(address minter) external returns (bool)
19,815
18
// swap fromToken to endToken
address[] memory path = new address[](2); path[0] = address(startToken); path[1] = address(endToken);
address[] memory path = new address[](2); path[0] = address(startToken); path[1] = address(endToken);
46,326
60
// exlcusions
mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public _isExcludedMaxTx; event ExcludeFromFees(address indexed account, bool isExcluded); event hostileBankUpdated(address indexed newWallet, address indexed oldWallet); event liqOwnerUpdated(address indexed newWallet, address indexed oldWallet); event EndedBoughtEarly(bool boughtEarly); event SwapAndLiquify(
mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public _isExcludedMaxTx; event ExcludeFromFees(address indexed account, bool isExcluded); event hostileBankUpdated(address indexed newWallet, address indexed oldWallet); event liqOwnerUpdated(address indexed newWallet, address indexed oldWallet); event EndedBoughtEarly(bool boughtEarly); event SwapAndLiquify(
38,159
14
// contract states
uint256 private constant divider = 100; uint256 private interestPercentage = 25; uint256 private withDrawalTimes = 12; uint256 private monthlyPercentage = 8; uint256 private minimumDays = 28 days; uint256 private lockTime = 30 days; uint256 public _totalStakedTokens; uint256 public _totalStakedUsers;
uint256 private constant divider = 100; uint256 private interestPercentage = 25; uint256 private withDrawalTimes = 12; uint256 private monthlyPercentage = 8; uint256 private minimumDays = 28 days; uint256 private lockTime = 30 days; uint256 public _totalStakedTokens; uint256 public _totalStakedUsers;
30,755
12
// ERCSFTMockThis mock just provides a public burn functions for testing purposes /
contract ERCSFTMock is SFT { constructor(string memory name, string memory symbol) SFT(name, symbol) {} function setSemiBaseURI(string memory baseUri) public { _setSemiBaseURI(baseUri); } function SemiBaseURI() public view returns (string memory) { return _semiBaseURI(); } function setSemiURI(uint256 _tokenType, string memory _uri) public { _setSemiURI(_tokenType, _uri); } function setSemiName(uint256 _tokenType, string memory name) public { _setSemiName(_tokenType, name); } function setSemiSymbol(uint256 _tokenType, string memory symbol) public { _setSemiSymbol(_tokenType, symbol); } function semiTypeBurn( address _from, uint256 _tokenType, uint256 _value ) public { _semiTypeBurn(_from, _tokenType, _value); } /* ERC721 mock */ function baseURI() public view returns (string memory) { return _baseURI(); } function exists(uint256 tokenId) public view returns (bool) { return _exists(tokenId); } function mint(address to, uint256 tokenId) public { _mint(to, tokenId); } function safeMint(address to, uint256 tokenId) public { _safeMint(to, tokenId); } function safeMint( address to, uint256 tokenId, bytes memory _data ) public { _safeMint(to, tokenId, _data); } function burn(uint256 tokenId) public { _burn(tokenId); } }
contract ERCSFTMock is SFT { constructor(string memory name, string memory symbol) SFT(name, symbol) {} function setSemiBaseURI(string memory baseUri) public { _setSemiBaseURI(baseUri); } function SemiBaseURI() public view returns (string memory) { return _semiBaseURI(); } function setSemiURI(uint256 _tokenType, string memory _uri) public { _setSemiURI(_tokenType, _uri); } function setSemiName(uint256 _tokenType, string memory name) public { _setSemiName(_tokenType, name); } function setSemiSymbol(uint256 _tokenType, string memory symbol) public { _setSemiSymbol(_tokenType, symbol); } function semiTypeBurn( address _from, uint256 _tokenType, uint256 _value ) public { _semiTypeBurn(_from, _tokenType, _value); } /* ERC721 mock */ function baseURI() public view returns (string memory) { return _baseURI(); } function exists(uint256 tokenId) public view returns (bool) { return _exists(tokenId); } function mint(address to, uint256 tokenId) public { _mint(to, tokenId); } function safeMint(address to, uint256 tokenId) public { _safeMint(to, tokenId); } function safeMint( address to, uint256 tokenId, bytes memory _data ) public { _safeMint(to, tokenId, _data); } function burn(uint256 tokenId) public { _burn(tokenId); } }
21,972
42
// return i-th tranche data /
function getTrancheData(uint256) external view returns (TrancheData memory);
function getTrancheData(uint256) external view returns (TrancheData memory);
5,647
23
// Make a fee contribution._moderation The moderation to contribute to._side The side to contribute to._contributor The contributor._amount The amount contributed._totalRequired The total amount required for this side. return The amount of fees contributed. /
function contribute( Moderation storage _moderation, Party _side, address payable _contributor, uint256 _amount, uint256 _totalRequired
function contribute( Moderation storage _moderation, Party _side, address payable _contributor, uint256 _amount, uint256 _totalRequired
16,463
105
// % bound away from TWAP price
uint256 internal constant TWAP_BOUNDS = 5 * 10**15; function quote(uint256 purchaseAmount, uint256 saleAmount) internal view returns (uint256)
uint256 internal constant TWAP_BOUNDS = 5 * 10**15; function quote(uint256 purchaseAmount, uint256 saleAmount) internal view returns (uint256)
4,887
302
// Checks whether an identifier is on the whitelist. identifier bytes32 encoding of the string identifier. Eg: BTC/USD.return bool if the identifier is supported (or not). /
function isIdentifierSupported(bytes32 identifier) external view returns (bool);
function isIdentifierSupported(bytes32 identifier) external view returns (bool);
12,047
269
// The faster the rise and the larger the negative rebase, the more that is bought
uint256 sellPercent = changedDiggPercent.mul(wbtcSupplyChangeFactor.add(uint256(percentChange).mul(wbtcSellAmplificationFactor))).div( DIVISION_FACTOR ); if (sellPercent > maxWBTCSellPercent) { sellPercent = maxWBTCSellPercent; }
uint256 sellPercent = changedDiggPercent.mul(wbtcSupplyChangeFactor.add(uint256(percentChange).mul(wbtcSellAmplificationFactor))).div( DIVISION_FACTOR ); if (sellPercent > maxWBTCSellPercent) { sellPercent = maxWBTCSellPercent; }
78,515
0
// statera.solSTA V3 deflationary index token smart contract2020-05-29/
interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); }
interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); }
29,253
65
// Restricts each bet to a maximum profit of 20% contractBalance
require(newMaxProfitAsPercent <= 200000); maxProfitAsPercentOfHouse = newMaxProfitAsPercent; setMaxProfit();
require(newMaxProfitAsPercent <= 200000); maxProfitAsPercentOfHouse = newMaxProfitAsPercent; setMaxProfit();
28,396
305
// Increase totalAmountStaked
totalAmountStaked += (amount + pendingRewards); emit Deposit(msg.sender, amount, pendingRewards);
totalAmountStaked += (amount + pendingRewards); emit Deposit(msg.sender, amount, pendingRewards);
68,501
19
// Blacklist an extension /
function _blacklistExtension(address extension) internal { require(extension != address(0) && extension != address(this), "Cannot blacklist yourself"); if (_extensions.contains(extension)) { emit ExtensionUnregistered(extension, msg.sender); _extensions.remove(extension); } if (!_blacklistedExtensions.contains(extension)) { emit ExtensionBlacklisted(extension, msg.sender); _blacklistedExtensions.add(extension); } }
function _blacklistExtension(address extension) internal { require(extension != address(0) && extension != address(this), "Cannot blacklist yourself"); if (_extensions.contains(extension)) { emit ExtensionUnregistered(extension, msg.sender); _extensions.remove(extension); } if (!_blacklistedExtensions.contains(extension)) { emit ExtensionBlacklisted(extension, msg.sender); _blacklistedExtensions.add(extension); } }
22,352
8
// TODO: Implement
// function replaceAdapter(address oldAddress, address newAddress) public {} function removeAdapter(address adapterAddress) external onlyManagers { bool adapterExists = adapterIdxByAddress[adapterAddress] != 0; if (adapterExists) { uint256 adapterIndex = adapterIdxByAddress[adapterAddress]; delete adapterAddressByIdx[adapterIndex]; delete adapterIdxByAddress[adapterAddress]; adaptersLength -= 1; } }
// function replaceAdapter(address oldAddress, address newAddress) public {} function removeAdapter(address adapterAddress) external onlyManagers { bool adapterExists = adapterIdxByAddress[adapterAddress] != 0; if (adapterExists) { uint256 adapterIndex = adapterIdxByAddress[adapterAddress]; delete adapterAddressByIdx[adapterIndex]; delete adapterIdxByAddress[adapterAddress]; adaptersLength -= 1; } }
50,724
179
// Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is neverdirectly accessed. /
library Counters { using SafeMath for uint256; struct Counter {
library Counters { using SafeMath for uint256; struct Counter {
31,180
5
// constructor( address _registryAddress, address _oracleAddress,
// ) Adapter(_registryAddress, _oracleAddress) {} // /** // * Common code shared by v1 vaults, v2 vaults and earn // */ // function positionsOf( // address accountAddress, // address[] memory _assetsAddresses // ) public view returns (Position[] memory) { // uint256 numberOfAssets = _assetsAddresses.length; // Position[] memory positions = new Position[](numberOfAssets); // for (uint256 assetIdx = 0; assetIdx < numberOfAssets; assetIdx++) { // address assetAddress = _assetsAddresses[assetIdx]; // Position memory position = positionOf(accountAddress, assetAddress); // positions[assetIdx] = position; // } // return positions; // }
// ) Adapter(_registryAddress, _oracleAddress) {} // /** // * Common code shared by v1 vaults, v2 vaults and earn // */ // function positionsOf( // address accountAddress, // address[] memory _assetsAddresses // ) public view returns (Position[] memory) { // uint256 numberOfAssets = _assetsAddresses.length; // Position[] memory positions = new Position[](numberOfAssets); // for (uint256 assetIdx = 0; assetIdx < numberOfAssets; assetIdx++) { // address assetAddress = _assetsAddresses[assetIdx]; // Position memory position = positionOf(accountAddress, assetAddress); // positions[assetIdx] = position; // } // return positions; // }
52,251
14
// Initializes contract to be a Filtered Minter for`_minterFilter`, integrated with Art Blocks core contractat address `_genArt721Address`. _genArt721Address Art Blocks core contract for which thiscontract will be a minter. _minterFilter Minter filter for whichthis will a filtered minter. _delegationRegistryAddress Delegation registry contract address. /
constructor( address _genArt721Address, address _minterFilter, address _delegationRegistryAddress
constructor( address _genArt721Address, address _minterFilter, address _delegationRegistryAddress
8,742
126
// swap tokens for ETH
swapTokensForEth(half);
swapTokensForEth(half);
55,969
6
// Forwards a batch commit to Voting. commits struct to encapsulate an `identifier`, `time`, `hash` and optional `encryptedVote`. /
function batchCommit(VotingAncillaryInterface.CommitmentAncillary[] calldata commits) external onlyRoleHolder(uint256(Roles.Voter))
function batchCommit(VotingAncillaryInterface.CommitmentAncillary[] calldata commits) external onlyRoleHolder(uint256(Roles.Voter))
16,866
1,118
// 561
entry "praisingly" : ENG_ADVERB
entry "praisingly" : ENG_ADVERB
21,397
122
// Hash(current computed hash + current element of the proof)
computedHash = _efficientHash(computedHash, proofElement);
computedHash = _efficientHash(computedHash, proofElement);
11,004
26
// Action Functions /
function swap(uint256 _amount) external payable whenNotPaused isFunded isSaleOpen onlyWhitelisted blockReentrancy { /* Confirm Amount is positive */ require(_amount > 0, "Amount has to be positive"); /* Confirm Amount is less than tokens available */ require(_amount <= tokensLeft(), "Amount is less than tokens available"); /* Confirm the user has funds for the transfer, confirm the value is equal */ require(msg.value == cost(_amount), "User swap amount has to equal to cost of token in ETH"); /* Confirm Amount is bigger than minimum Amount */ require(_amount >= individualMinimumAmount, "Amount is bigger than minimum amount"); /* Confirm Amount is smaller than maximum Amount */ require(_amount <= individualMaximumAmount, "Amount is smaller than maximum amount"); /* Verify all user purchases, loop thru them */ uint256[] memory _purchases = getMyPurchases(msg.sender); uint256 purchaserTotalAmountPurchased = 0; for (uint i = 0; i < _purchases.length; i++) { Purchase memory _purchase = purchases[_purchases[i]]; purchaserTotalAmountPurchased = purchaserTotalAmountPurchased.add(_purchase.amount); } require(purchaserTotalAmountPurchased.add(_amount) <= individualMaximumAmount, "Address has already passed the max amount of swap"); if (isTokenSwapAtomic) { /* Confirm transfer */ TransferHelper.safeTransfer(address(erc20), msg.sender, _amount); } uint256 purchase_id = increment; increment = increment.add(1); /* Create new purchase */ Purchase memory purchase = Purchase( _amount, msg.sender, msg.value, block.timestamp, isTokenSwapAtomic, /* If Atomic Swap */ false ); purchases[purchase_id] = purchase; purchaseIds.push(purchase_id); myPurchases[msg.sender].push(purchase_id); buyers.push(msg.sender); tokensAllocated = tokensAllocated.add(_amount); emit PurchaseEvent(purchase_id, _amount, msg.sender, msg.value, block.timestamp, isTokenSwapAtomic); }
function swap(uint256 _amount) external payable whenNotPaused isFunded isSaleOpen onlyWhitelisted blockReentrancy { /* Confirm Amount is positive */ require(_amount > 0, "Amount has to be positive"); /* Confirm Amount is less than tokens available */ require(_amount <= tokensLeft(), "Amount is less than tokens available"); /* Confirm the user has funds for the transfer, confirm the value is equal */ require(msg.value == cost(_amount), "User swap amount has to equal to cost of token in ETH"); /* Confirm Amount is bigger than minimum Amount */ require(_amount >= individualMinimumAmount, "Amount is bigger than minimum amount"); /* Confirm Amount is smaller than maximum Amount */ require(_amount <= individualMaximumAmount, "Amount is smaller than maximum amount"); /* Verify all user purchases, loop thru them */ uint256[] memory _purchases = getMyPurchases(msg.sender); uint256 purchaserTotalAmountPurchased = 0; for (uint i = 0; i < _purchases.length; i++) { Purchase memory _purchase = purchases[_purchases[i]]; purchaserTotalAmountPurchased = purchaserTotalAmountPurchased.add(_purchase.amount); } require(purchaserTotalAmountPurchased.add(_amount) <= individualMaximumAmount, "Address has already passed the max amount of swap"); if (isTokenSwapAtomic) { /* Confirm transfer */ TransferHelper.safeTransfer(address(erc20), msg.sender, _amount); } uint256 purchase_id = increment; increment = increment.add(1); /* Create new purchase */ Purchase memory purchase = Purchase( _amount, msg.sender, msg.value, block.timestamp, isTokenSwapAtomic, /* If Atomic Swap */ false ); purchases[purchase_id] = purchase; purchaseIds.push(purchase_id); myPurchases[msg.sender].push(purchase_id); buyers.push(msg.sender); tokensAllocated = tokensAllocated.add(_amount); emit PurchaseEvent(purchase_id, _amount, msg.sender, msg.value, block.timestamp, isTokenSwapAtomic); }
24,708
8
// This function will issue the certificate for the multiple courses on nextgen technologies/_userId is the unique ID of student/_name inputs the name of student/_course inputs the course for which the certificate is issued/_belt inputs the belt level of each course in integer/_percentile inputs the percentage which student scored in the exam/ return certificate number
function issueCertificate( uint256 _userId, string memory _name, string memory _course, uint256 _belt, uint256 _percentile
function issueCertificate( uint256 _userId, string memory _name, string memory _course, uint256 _belt, uint256 _percentile
14,030
172
// _payoutDistributionHash the payout distribution hash being checkedreturn uint256 indicating the REP stake in a single outcome for a particular payout hash /
function getStakeInOutcome(bytes32 _payoutDistributionHash) public view returns (uint256) { uint256 _sum; // Participants is implicitly bounded by the floor of the initial report REP cost to be no more than 21 for (uint256 i = 0; i < participants.length; ++i) { IReportingParticipant _reportingParticipant = participants[i]; if (_reportingParticipant.getPayoutDistributionHash() != _payoutDistributionHash) { continue; } _sum = _sum.add(_reportingParticipant.getStake()); } return _sum; }
function getStakeInOutcome(bytes32 _payoutDistributionHash) public view returns (uint256) { uint256 _sum; // Participants is implicitly bounded by the floor of the initial report REP cost to be no more than 21 for (uint256 i = 0; i < participants.length; ++i) { IReportingParticipant _reportingParticipant = participants[i]; if (_reportingParticipant.getPayoutDistributionHash() != _payoutDistributionHash) { continue; } _sum = _sum.add(_reportingParticipant.getStake()); } return _sum; }
4,347
1
// strategy
function register(address _cashMachine, address _token, uint256 _amount) external {}
function register(address _cashMachine, address _token, uint256 _amount) external {}
13,233
30
// Implementation of the standard transferFrom method that takes into account the finalize flag
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
51,645
11
// 2. 取得用戶想要存入的以太幣數量
uint256 depositAmount = msg.value;
uint256 depositAmount = msg.value;
12,379
5
// We want to refund everything except the specified cost.
if (_cost < gasUsed) { transactionRecord.ovmGasRefund += gasUsed - _cost; }
if (_cost < gasUsed) { transactionRecord.ovmGasRefund += gasUsed - _cost; }
45,455
147
// Add the new guardian
Data.Guardian memory g = Data.Guardian( guardianAddr, group.toUint16(), validSince.toUint40(), uint40(0) ); w.guardians.push(g); w.guardianIdx[guardianAddr] = w.guardians.length;
Data.Guardian memory g = Data.Guardian( guardianAddr, group.toUint16(), validSince.toUint40(), uint40(0) ); w.guardians.push(g); w.guardianIdx[guardianAddr] = w.guardians.length;
52,592
10
// recoveredAddress verified
validatorIndexVisited[validatorIndex] = true; verifiedNum++; if (verifiedNum >= threshold) { return; }
validatorIndexVisited[validatorIndex] = true; verifiedNum++; if (verifiedNum >= threshold) { return; }
37,699
25
// Returns the discounted price in paymentTokens for a given amount of options tokens/_amount The amount of options tokens to exercise/ return The amount of payment tokens to pay to purchase the underlying tokens
function getDiscountedPrice(uint256 _amount) public view returns (uint256) { return (getTimeWeightedAveragePrice(_amount) * discount) / 100; }
function getDiscountedPrice(uint256 _amount) public view returns (uint256) { return (getTimeWeightedAveragePrice(_amount) * discount) / 100; }
14,430
20
// Check if there are any existing tokens.
if (tokenAddresses.length == 0) {
if (tokenAddresses.length == 0) {
38,750
36
// Stop re-initialization.
if (address(store) != address(0)) revert();
if (address(store) != address(0)) revert();
30,532
26
// normal quote
toTokenFee = idealToAmount.wmul(haircutRate); actualToAmount = idealToAmount - toTokenFee;
toTokenFee = idealToAmount.wmul(haircutRate); actualToAmount = idealToAmount - toTokenFee;
30,237
58
// Function to get available and claimed rewards for an address
function getAvailableAndClaimedReward(address _address) public view returns (uint256, uint256) { uint256 totalRewardPossible = 0; uint256 effectiveBalancePossible; uint256 effectiveBalanceCurrent; // Iterate over periods starting from the last claimed snapshot for (uint256 i = lastClaimedSnapshot[_address]; i < periods.length; i++) { // Check if the address held tokens during this period if(wasHoldingDuringPeriod(_address, i)) { effectiveBalancePossible = balanceOfAt(_address, periods[i].snapshotId); effectiveBalanceCurrent = balanceOfAt(_address, periods[i].snapshotId); uint256 totalSupplySnapshot = periods[i].totalSupply; // Calculate holder's rewards based on their balance uint256 rewardForHolderPossible = periods[i].totalHoldersReward * effectiveBalancePossible / totalSupplySnapshot; // Update total possible reward totalRewardPossible += rewardForHolderPossible; } } // Return total possible reward, and total claimed reward return (totalRewardPossible, totalClaimedFeeRewards[_address] > 0 ? totalClaimedFeeRewards[_address] : 0); }
function getAvailableAndClaimedReward(address _address) public view returns (uint256, uint256) { uint256 totalRewardPossible = 0; uint256 effectiveBalancePossible; uint256 effectiveBalanceCurrent; // Iterate over periods starting from the last claimed snapshot for (uint256 i = lastClaimedSnapshot[_address]; i < periods.length; i++) { // Check if the address held tokens during this period if(wasHoldingDuringPeriod(_address, i)) { effectiveBalancePossible = balanceOfAt(_address, periods[i].snapshotId); effectiveBalanceCurrent = balanceOfAt(_address, periods[i].snapshotId); uint256 totalSupplySnapshot = periods[i].totalSupply; // Calculate holder's rewards based on their balance uint256 rewardForHolderPossible = periods[i].totalHoldersReward * effectiveBalancePossible / totalSupplySnapshot; // Update total possible reward totalRewardPossible += rewardForHolderPossible; } } // Return total possible reward, and total claimed reward return (totalRewardPossible, totalClaimedFeeRewards[_address] > 0 ? totalClaimedFeeRewards[_address] : 0); }
5,729
306
// Creates an asset with its parameters owner, initial owner of asset mainId, unique identifier of asset price, asset price to sell dueDate, end date for calculating rewards apr, annual percentage rate for calculating rewards Needs marketplace access to create an asset /
function createAsset(
function createAsset(
12,239
43
// Ensure that exactly one 721 item is being transferred.
if (item.amount != 1) { revert InvalidERC721TransferAmount(item.amount); }
if (item.amount != 1) { revert InvalidERC721TransferAmount(item.amount); }
14,319
57
// 修改token兑换比率,1eth兑换多少代币 /
function changeTokensPerEther(uint256 _newRate) onlyController public { tokensPerEther = _newRate; }
function changeTokensPerEther(uint256 _newRate) onlyController public { tokensPerEther = _newRate; }
47,553
3
// Add this to a function that might reequire involved actors to be whitelisted in the future /
modifier mayNeedWhitelisting(address sender, address recipient) { if (needWhitelisting) { require(_whitelisted[sender], "A5"); //Transfer Blocked - Sender not eligible require(_whitelisted[recipient], "A6"); //Transfer Blocked - Receiver not eligible } _; }
modifier mayNeedWhitelisting(address sender, address recipient) { if (needWhitelisting) { require(_whitelisted[sender], "A5"); //Transfer Blocked - Sender not eligible require(_whitelisted[recipient], "A6"); //Transfer Blocked - Receiver not eligible } _; }
48,828
2
// transactor is a smart contract address able to only add transactions/ to retrieve a transaction id and able to revoke all confirmations too./ The transactor is not an owner and cannot confirm transactions./ An example for this existing is when the minting admin role contract/ needs to add a multisig transaction to retrieve a trasaction id so that/ minting admin' can begin to vote on it. We require a transaction id in/ in this case immediately rather than requiring the multisig to submit the transaction because it would require majority vote which is not what/ we want in this case./
address public transactor;
address public transactor;
7,394
95
// AtivoToken with Governance.
contract AtivoToken is ERC20("Ativo Finance", "ATIVO"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping(address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping(address => mapping(uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping(address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256( "EIP712Domain(string name,uint256 chainId,address verifyingContract)" ); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping(address => uint256) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged( address indexed delegator, address indexed fromDelegate, address indexed toDelegate ); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged( address indexed delegate, uint256 previousBalance, uint256 newBalance ); /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry) ); bytes32 digest = keccak256( abi.encodePacked("\x19\x01", domainSeparator, structHash) ); address signatory = ecrecover(digest, v, r, s); require( signatory != address(0), "ATIVO::delegateBySig: invalid signature" ); require( nonce == nonces[signatory]++, "ATIVO::delegateBySig: invalid nonce" ); require(now <= expiry, "ATIVO::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) { require( blockNumber < block.number, "ATIVO::getPriorVotes: not yet determined" ); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying ATIVOs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates( address srcRep, address dstRep, uint256 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32( block.number, "ATIVO::_writeCheckpoint: block number exceeds 32 bits" ); if ( nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber ) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint( blockNumber, newVotes ); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
contract AtivoToken is ERC20("Ativo Finance", "ATIVO"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping(address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping(address => mapping(uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping(address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256( "EIP712Domain(string name,uint256 chainId,address verifyingContract)" ); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping(address => uint256) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged( address indexed delegator, address indexed fromDelegate, address indexed toDelegate ); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged( address indexed delegate, uint256 previousBalance, uint256 newBalance ); /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry) ); bytes32 digest = keccak256( abi.encodePacked("\x19\x01", domainSeparator, structHash) ); address signatory = ecrecover(digest, v, r, s); require( signatory != address(0), "ATIVO::delegateBySig: invalid signature" ); require( nonce == nonces[signatory]++, "ATIVO::delegateBySig: invalid nonce" ); require(now <= expiry, "ATIVO::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) { require( blockNumber < block.number, "ATIVO::getPriorVotes: not yet determined" ); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying ATIVOs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates( address srcRep, address dstRep, uint256 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32( block.number, "ATIVO::_writeCheckpoint: block number exceeds 32 bits" ); if ( nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber ) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint( blockNumber, newVotes ); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
15,379
1
// Constructor function of XDISCO Token set name, symbol and decimal of token mint hardcap to deployer /
constructor() public ERC20("XDISCO", "XDISCO")
constructor() public ERC20("XDISCO", "XDISCO")
20,767
168
// A reward pool that does not mint/The rewards are transferred to the pool by calling `notifyRewardAmount`./Only the reward distributor can notify.
contract RewardPool is IRewardDistributor, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for IERC20; using SafeERC20 for DraculaToken; DraculaToken public dracula; IERC20 public rewardToken; uint256 public rewardsDuration; uint256 public periodFinish; uint256 public rewardRate; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; uint256 public burnRate = 1; // default 1% uint256 public totalStaked; mapping(address => uint256) private stakedBalances; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } constructor( address _rewardToken, DraculaToken _dracula, uint256 _rewardsDuration, address _rewardDistributor) public IRewardDistributor(_rewardDistributor) { rewardToken = IERC20(_rewardToken); dracula = _dracula; rewardsDuration = _rewardsDuration; } function balanceOf(address account) external view returns (uint256) { return stakedBalances[account]; } function setBurnRate(uint256 _burnRate) external onlyOwner { require(_burnRate <= 10, "Invalid burn rate value"); burnRate = _burnRate; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (totalStaked == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(1e18) .div(totalStaked) ); } function rewardForDuration() external view returns (uint256) { return rewardRate.mul(rewardsDuration); } /// @notice Calculate the earned rewards for an account /// @return amount earned by specified account function earned(address account) public view returns (uint256) { return stakedBalances[account] .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } /// @notice Stake specified amount function stake(uint256 amount) external nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); totalStaked = totalStaked.add(amount); stakedBalances[msg.sender] = stakedBalances[msg.sender].add(amount); dracula.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } /// @notice Withdraw specified amount and collect rewards function unstake(uint256 amount) external { withdraw(amount); getReward(); } /// @notice Claims reward for the sender account function getReward() public nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; rewardToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } /// @notice Withdraw specified amount /// @dev A configurable percentage is burnt on withdrawal function withdraw(uint256 amount) internal nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot withdraw 0"); uint256 amount_send = amount; if (burnRate > 0) { uint256 amount_burn = amount.mul(burnRate).div(100); amount_send = amount.sub(amount_burn); require(amount == amount_send + amount_burn, "Burn value invalid"); dracula.burn(amount_burn); } totalStaked = totalStaked.sub(amount); stakedBalances[msg.sender] = stakedBalances[msg.sender].sub(amount); dracula.safeTransfer(msg.sender, amount_send); emit Withdrawn(msg.sender, amount_send); } /// @notice Transfers reward amount to pool and updates reward rate /// @dev Should be called by external mechanism function notifyRewardAmount(uint256 reward) external override onlyRewardDistributor updateReward(address(0)) { // overflow fix according to https://sips.synthetix.io/sips/sip-77 require(reward < uint(-1) / 1e18, "the notified reward cannot invoke multiplication overflow"); rewardToken.safeTransferFrom(msg.sender, address(this), reward); if (block.timestamp >= periodFinish) { rewardRate = reward.div(rewardsDuration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(rewardsDuration); } // Ensure the provided reward amount is not more than the balance in the contract uint256 balance = rewardToken.balanceOf(address(this)); require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high"); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward); } }
contract RewardPool is IRewardDistributor, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for IERC20; using SafeERC20 for DraculaToken; DraculaToken public dracula; IERC20 public rewardToken; uint256 public rewardsDuration; uint256 public periodFinish; uint256 public rewardRate; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; uint256 public burnRate = 1; // default 1% uint256 public totalStaked; mapping(address => uint256) private stakedBalances; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } constructor( address _rewardToken, DraculaToken _dracula, uint256 _rewardsDuration, address _rewardDistributor) public IRewardDistributor(_rewardDistributor) { rewardToken = IERC20(_rewardToken); dracula = _dracula; rewardsDuration = _rewardsDuration; } function balanceOf(address account) external view returns (uint256) { return stakedBalances[account]; } function setBurnRate(uint256 _burnRate) external onlyOwner { require(_burnRate <= 10, "Invalid burn rate value"); burnRate = _burnRate; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (totalStaked == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(1e18) .div(totalStaked) ); } function rewardForDuration() external view returns (uint256) { return rewardRate.mul(rewardsDuration); } /// @notice Calculate the earned rewards for an account /// @return amount earned by specified account function earned(address account) public view returns (uint256) { return stakedBalances[account] .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } /// @notice Stake specified amount function stake(uint256 amount) external nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); totalStaked = totalStaked.add(amount); stakedBalances[msg.sender] = stakedBalances[msg.sender].add(amount); dracula.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } /// @notice Withdraw specified amount and collect rewards function unstake(uint256 amount) external { withdraw(amount); getReward(); } /// @notice Claims reward for the sender account function getReward() public nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; rewardToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } /// @notice Withdraw specified amount /// @dev A configurable percentage is burnt on withdrawal function withdraw(uint256 amount) internal nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot withdraw 0"); uint256 amount_send = amount; if (burnRate > 0) { uint256 amount_burn = amount.mul(burnRate).div(100); amount_send = amount.sub(amount_burn); require(amount == amount_send + amount_burn, "Burn value invalid"); dracula.burn(amount_burn); } totalStaked = totalStaked.sub(amount); stakedBalances[msg.sender] = stakedBalances[msg.sender].sub(amount); dracula.safeTransfer(msg.sender, amount_send); emit Withdrawn(msg.sender, amount_send); } /// @notice Transfers reward amount to pool and updates reward rate /// @dev Should be called by external mechanism function notifyRewardAmount(uint256 reward) external override onlyRewardDistributor updateReward(address(0)) { // overflow fix according to https://sips.synthetix.io/sips/sip-77 require(reward < uint(-1) / 1e18, "the notified reward cannot invoke multiplication overflow"); rewardToken.safeTransferFrom(msg.sender, address(this), reward); if (block.timestamp >= periodFinish) { rewardRate = reward.div(rewardsDuration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(rewardsDuration); } // Ensure the provided reward amount is not more than the balance in the contract uint256 balance = rewardToken.balanceOf(address(this)); require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high"); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward); } }
32,451
160
// Retrieve the current exchange rate palToken:underlying
uint _exchRate = _exchangeRate();
uint _exchRate = _exchangeRate();
74,979
50
// Reentrancy appears
string public constant REENTRANCY = "IPOR_016";
string public constant REENTRANCY = "IPOR_016";
42,953
33
// Approves the token to the spender address with allowance amount. Approves the token to the spender address with allowance amount. token_ token for which allowance is to be given. spender_ the address to which the allowance is to be given. amount_ amount of token. /
function approve( address token_, address spender_, uint256 amount_
function approve( address token_, address spender_, uint256 amount_
77,812
64
// Do the callback after everything is done to avoid reentrancy attack
uint256 codeSize;
uint256 codeSize;
6,881
27
// [DIRECT-TX] revokeInvitationtransaction function to directly revoke an invitationtransaction is submitted directly by msg.sender; not a meta-tx_groupId group id the invitation belongs to_secretHash hash generated by backend return bool upon successful transaction /
function revokeInvitation( uint256 _groupId, bytes32 _secretHash ) external returns (bool)
function revokeInvitation( uint256 _groupId, bytes32 _secretHash ) external returns (bool)
40,657
47
// update new variables based on the number of farmers paid
if (totalWinnersPerTX <= pool.minerCutoff) { if (pool.maxWinnersPerBlock > 2) pool.maxWinnersPerBlock = pool.maxWinnersPerBlock.sub(1); if (pool.maxWinnersPerBlock > 20) pool.maxTransactionLoop = pool.maxTransactionLoop.sub(1); pool.ichiPerLoop = pool.ichiPerLoop.sub(pool.ichiPerLoop.mul(5 * 10 ** 6).div(10 ** 9)); // 0.5% } else {
if (totalWinnersPerTX <= pool.minerCutoff) { if (pool.maxWinnersPerBlock > 2) pool.maxWinnersPerBlock = pool.maxWinnersPerBlock.sub(1); if (pool.maxWinnersPerBlock > 20) pool.maxTransactionLoop = pool.maxTransactionLoop.sub(1); pool.ichiPerLoop = pool.ichiPerLoop.sub(pool.ichiPerLoop.mul(5 * 10 ** 6).div(10 ** 9)); // 0.5% } else {
33,656
16
// Requires a fresh price and then returns the current value.
function read() external view returns (bytes32);
function read() external view returns (bytes32);
43,476
17
// Returns boolean whether an address is ambassador of a given community._ambassador Address of the ambassador _community Address of the communityreturn Boolean whether an address is ambassador of a given community or not /
function isAmbassadorOf(address _ambassador, address _community) public view override returns (bool)
function isAmbassadorOf(address _ambassador, address _community) public view override returns (bool)
29,252
11
// Determine which deposits we will modifiy
for (uint256 end = 0; end < ds.length; end++) { if (ds[end].blockNumber <= latest_block) { if (ds[end].value >= remaining) { ds[end].value = ds[end].value.sub(remaining); if (ds[end].value == 0) { end++; }
for (uint256 end = 0; end < ds.length; end++) { if (ds[end].blockNumber <= latest_block) { if (ds[end].value >= remaining) { ds[end].value = ds[end].value.sub(remaining); if (ds[end].value == 0) { end++; }
3,067
4
// Mints 1 ORBITAL to contract creator for initial pool setup
_mint(msg.sender, 1e18);
_mint(msg.sender, 1e18);
33,255
63
// General function to update the implementation of a proxy registered withcertain `id`. If there is no proxy registered, it will instantiate one andset as implementation the `implementationAddress`IMPORTANT Use this function carefully, only for ids that don't have an explicitsetter function, in order to avoid unexpected consequences id The id implementationAddress The address of the new implementation /
function setAddressAsProxy(bytes32 id, address implementationAddress) external override onlyOwner
function setAddressAsProxy(bytes32 id, address implementationAddress) external override onlyOwner
5,966
32
// send the specified amount to the treasury
transferUSDCs(revenueWallet, totalFeeSum); emit FeeTransfer(msg.sender, revenueWallet, totalFeeSum, _batchId);
transferUSDCs(revenueWallet, totalFeeSum); emit FeeTransfer(msg.sender, revenueWallet, totalFeeSum, _batchId);
31,652
73
// define midtoken address, ETH -> WETH address
uint256 curTotalAmount = IERC20(midToken[i]).tokenBalanceOf(assetFrom[i-1]); uint256 curTotalWeight = totalWeight[i-1]; for(uint256 j = splitNumber[i-1]; j < splitNumber[i]; j++) { PoolInfo memory curPoolInfo; { (address pool, address adapter, uint256 mixPara, bytes memory moreInfo) = abi.decode(swapSequence[j], (address, address, uint256, bytes)); curPoolInfo.direction = mixPara >> 17; curPoolInfo.weight = (0xffff & mixPara) >> 9;
uint256 curTotalAmount = IERC20(midToken[i]).tokenBalanceOf(assetFrom[i-1]); uint256 curTotalWeight = totalWeight[i-1]; for(uint256 j = splitNumber[i-1]; j < splitNumber[i]; j++) { PoolInfo memory curPoolInfo; { (address pool, address adapter, uint256 mixPara, bytes memory moreInfo) = abi.decode(swapSequence[j], (address, address, uint256, bytes)); curPoolInfo.direction = mixPara >> 17; curPoolInfo.weight = (0xffff & mixPara) >> 9;
47,394
148
// Check that no mint has been made in the same block from the same EOA
require(keccak256(abi.encodePacked(tx.origin, block.number)) != _minterBlock, "REENTR MINT-BURN"); _output_amount = (balance().mul(_shares)).div(totalSupply()); _burn(msg.sender, _shares); uint _withdrawalProtectionFee = vaultMaster.withdrawalProtectionFee(); if (_withdrawalProtectionFee > 0) { uint _withdrawalProtection = _output_amount.mul(_withdrawalProtectionFee).div(10000); _output_amount = _output_amount.sub(_withdrawalProtection); }
require(keccak256(abi.encodePacked(tx.origin, block.number)) != _minterBlock, "REENTR MINT-BURN"); _output_amount = (balance().mul(_shares)).div(totalSupply()); _burn(msg.sender, _shares); uint _withdrawalProtectionFee = vaultMaster.withdrawalProtectionFee(); if (_withdrawalProtectionFee > 0) { uint _withdrawalProtection = _output_amount.mul(_withdrawalProtectionFee).div(10000); _output_amount = _output_amount.sub(_withdrawalProtection); }
17,555
74
// Finalizes the sale. /
function finalize() external onlyOwner { require(weiTotalReceived >= softCap); require(now > startTime.add(period) || weiTotalReceived >= hardCap); if (state == State.PRESALE) { require(this.balance > 0); walletEtherPresale.transfer(this.balance); pause(); } else if (state == State.CROWDSALE) { uint256 tokenTotalUnsold = tokenIcoAllocated.sub(tokenTotalSold); tokenReservationAllocated = tokenReservationAllocated.add(tokenTotalUnsold); require(token.transferFrom(token.owner(), walletTokenBounty, tokenBountyAllocated)); require(token.transferFrom(token.owner(), walletTokenReservation, tokenReservationAllocated)); require(token.transferFrom(token.owner(), walletTokenTeam, tokenTeamAllocated)); token.lock(walletTokenReservation, now + 0.5 years); token.lock(walletTokenTeam, now + 1 years); uint256 tokenAdvisor = tokenAdvisorsAllocated.div(walletTokenAdvisors.length); for (uint256 i = 0; i < walletTokenAdvisors.length; i++) { require(token.transferFrom(token.owner(), walletTokenAdvisors[i], tokenAdvisor)); token.lock(walletTokenAdvisors[i], now + 0.5 years); } token.release(); state = State.CLOSED; } else { revert(); } }
function finalize() external onlyOwner { require(weiTotalReceived >= softCap); require(now > startTime.add(period) || weiTotalReceived >= hardCap); if (state == State.PRESALE) { require(this.balance > 0); walletEtherPresale.transfer(this.balance); pause(); } else if (state == State.CROWDSALE) { uint256 tokenTotalUnsold = tokenIcoAllocated.sub(tokenTotalSold); tokenReservationAllocated = tokenReservationAllocated.add(tokenTotalUnsold); require(token.transferFrom(token.owner(), walletTokenBounty, tokenBountyAllocated)); require(token.transferFrom(token.owner(), walletTokenReservation, tokenReservationAllocated)); require(token.transferFrom(token.owner(), walletTokenTeam, tokenTeamAllocated)); token.lock(walletTokenReservation, now + 0.5 years); token.lock(walletTokenTeam, now + 1 years); uint256 tokenAdvisor = tokenAdvisorsAllocated.div(walletTokenAdvisors.length); for (uint256 i = 0; i < walletTokenAdvisors.length; i++) { require(token.transferFrom(token.owner(), walletTokenAdvisors[i], tokenAdvisor)); token.lock(walletTokenAdvisors[i], now + 0.5 years); } token.release(); state = State.CLOSED; } else { revert(); } }
40,652
8
// - Creates a deterministic hash id for a credit line provided by a single Lender for a given token on a Line of Credit facility line - The Line of Credit facility concerned lender - The address managing the credit line concerned token- The token being lent out on the credit line concernedreturn id /
function computeId(address line, address lender, address token) external pure returns (bytes32) {
function computeId(address line, address lender, address token) external pure returns (bytes32) {
37,746
34
// The time test in the standard contract around line 154 needs to be commentedout to test this function, this tests denying more than one bid from an account/
function testDepositFunctionDenyBid(){ //Test multiple bid denial mechanisim in standard contract address testDeploy = new StandardICOAuction(10000000000000000000000, 1000000000000000000000, 10000000000000000000, 10000000000000000, 1000000000000000, 1000000000000000, 90, t); testConstruct = StandardICOAuction(testDeploy); bResult = testConstruct.deposit.value(10000000000000000000)(2000000000000000); bResult = testConstruct.deposit.value(10000000000000000000)(3000000000000000); Assert.isFalse(bResult, "Deposit should be rejected if already bid"); }
function testDepositFunctionDenyBid(){ //Test multiple bid denial mechanisim in standard contract address testDeploy = new StandardICOAuction(10000000000000000000000, 1000000000000000000000, 10000000000000000000, 10000000000000000, 1000000000000000, 1000000000000000, 90, t); testConstruct = StandardICOAuction(testDeploy); bResult = testConstruct.deposit.value(10000000000000000000)(2000000000000000); bResult = testConstruct.deposit.value(10000000000000000000)(3000000000000000); Assert.isFalse(bResult, "Deposit should be rejected if already bid"); }
49,693
106
// - `index` must be strictly less than {length}./
function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint256(_at(set._inner, index))); }
function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint256(_at(set._inner, index))); }
33,653
29
// Wraps ERC20 tokens as ERC1155 reward tokens.
function wrapERC20( address _tokenContract, uint256 _tokenAmount, uint256 _numOfRewardsToMint, string calldata _rewardURI
function wrapERC20( address _tokenContract, uint256 _tokenAmount, uint256 _numOfRewardsToMint, string calldata _rewardURI
18,110
13
// sender => _allowed
mapping(address => bool) public callers;
mapping(address => bool) public callers;
27,499
7
// only owner can able to see balance
require(msg.sender == owner, "Only owner can able to see the balance."); return address(this).balance;
require(msg.sender == owner, "Only owner can able to see the balance."); return address(this).balance;
42,295
1
// the unit is Szabo = 0.001 finney
function setCompensationFee(uint _compensationFee) public
function setCompensationFee(uint _compensationFee) public
40,577
213
// Remove an address from the whitelist_addressAddress to remove from the whitelist /
function removeAddress( address _address ) external onlyOwner
function removeAddress( address _address ) external onlyOwner
44,736
0
// This is the reward token per second Which will be multiplied by the tokens the user staked divided by the total This ensures a steady reward rate of the platform So the more users stake, the less for everyone who is staking.
uint256 public constant REWARD_RATE = 100; uint256 public s_lastUpdateTime; uint256 public s_rewardPerTokenStored; mapping(address => uint256) public s_userRewardPerTokenPaid; mapping(address => uint256) public s_rewards; uint256 private s_totalSupply; mapping(address => uint256) public s_balances;
uint256 public constant REWARD_RATE = 100; uint256 public s_lastUpdateTime; uint256 public s_rewardPerTokenStored; mapping(address => uint256) public s_userRewardPerTokenPaid; mapping(address => uint256) public s_rewards; uint256 private s_totalSupply; mapping(address => uint256) public s_balances;
16,964
7
// The current stable borrow rate. Expressed in ray.
uint128 currentStableBorrowRate;
uint128 currentStableBorrowRate;
40,639
158
// register distribution
registeredDistributions[receiver] = distribution; registrations.push(receiver);
registeredDistributions[receiver] = distribution; registrations.push(receiver);
42,310
50
// Since transfer throws an exception on failure and cannot call back here, there should be no way for us to still have half of the money.
assert(this.balance == balanceBeforeTransfer - msg.value / 2); return this.balance;
assert(this.balance == balanceBeforeTransfer - msg.value / 2); return this.balance;
19,512
13
// burns L2 tokens in order to release escrowed L1 tokens
IArbToken(_l2Token).bridgeBurn(_from, _amount);
IArbToken(_l2Token).bridgeBurn(_from, _amount);
9,437
8
// mark token name as taken, avoid same line minted twice
myTokenName[_line] = 1;
myTokenName[_line] = 1;
9,539
0
// LIBRARIES /
using FlagHelper for uint256; using SafeMath for uint256;
using FlagHelper for uint256; using SafeMath for uint256;
40,817
99
// See {ERC20-_beforeTokenTransfer}. Requirements: - the sender or the receiver must not be freezed. /
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); require(!freezed(from), "ERC20Freezable: sender freezed"); require(!freezed(to), "ERC20Freezable: receiver freezed"); }
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); require(!freezed(from), "ERC20Freezable: sender freezed"); require(!freezed(to), "ERC20Freezable: receiver freezed"); }
56,260
7
// Pay the Royalty
currency.transfer(root, royalty);
currency.transfer(root, royalty);
22,981
1
// solium-disable-next-line security/no-inline-assembly
assembly { if eq(call(gas, proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) { revert(0, 0) }
assembly { if eq(call(gas, proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) { revert(0, 0) }
41,409
93
// Removes a darknode from the store and transfers its bond to the/ owner of this contract.
function removeDarknode(address darknodeID) external onlyOwner { uint256 bond = darknodeRegistry[darknodeID].bond; delete darknodeRegistry[darknodeID]; LinkedList.remove(darknodes, darknodeID); require(ren.transfer(owner, bond), "bond transfer failed"); }
function removeDarknode(address darknodeID) external onlyOwner { uint256 bond = darknodeRegistry[darknodeID].bond; delete darknodeRegistry[darknodeID]; LinkedList.remove(darknodes, darknodeID); require(ren.transfer(owner, bond), "bond transfer failed"); }
3,944
8
// Updates a token to a new TokenURI. _blockNumber block number of the block _blockHash bytes32 of the blockHash _ipfsHash ipfsHash of the token URI /
function updateToken( uint256 _blockNumber, bytes32 _blockHash, string memory _ipfsHash
function updateToken( uint256 _blockNumber, bytes32 _blockHash, string memory _ipfsHash
24,186
155
// todo if there's more than one mint request in one block the quoted fee might be lowerthan what the artist expects, (when using a bonded price strategy)return fee the fee required to mint splices of that style /
function quoteFee( uint32 styleTokenId, IERC721[] memory originCollections, uint256[] memory originTokenIds
function quoteFee( uint32 styleTokenId, IERC721[] memory originCollections, uint256[] memory originTokenIds
76,591
58
// Emit {LogCancelVouch} eventstaker Staker addressborrower borrower address /
function cancelVouch(address staker, address borrower) external override onlyMember(msg.sender) whenNotPaused { if (msg.sender != staker && msg.sender != borrower) revert AuthFailed(); if (getLockedStake(staker, borrower) != 0) revert LockedStakeNonZero(); uint256 stakerCount = members[borrower].creditLine.stakerAddresses.length; bool stakerExist = false; uint256 stakerIndex = 0; for (uint256 i = 0; i < stakerCount; i++) { if (members[borrower].creditLine.stakerAddresses[i] == staker) { stakerExist = true; stakerIndex = i;
function cancelVouch(address staker, address borrower) external override onlyMember(msg.sender) whenNotPaused { if (msg.sender != staker && msg.sender != borrower) revert AuthFailed(); if (getLockedStake(staker, borrower) != 0) revert LockedStakeNonZero(); uint256 stakerCount = members[borrower].creditLine.stakerAddresses.length; bool stakerExist = false; uint256 stakerIndex = 0; for (uint256 i = 0; i < stakerCount; i++) { if (members[borrower].creditLine.stakerAddresses[i] == staker) { stakerExist = true; stakerIndex = i;
21,695
45
// if target is newer than last timepoint
if (target == currentTime || _lteConsideringOverflow(lastTimepointTimestamp, target, currentTime)) { return (lastTimepoint, lastTimepoint, true, lastIndex); }
if (target == currentTime || _lteConsideringOverflow(lastTimepointTimestamp, target, currentTime)) { return (lastTimepoint, lastTimepoint, true, lastIndex); }
27,166
17
// Contract authorization functuons!!!
function authorizeCaller(address dataContract) external requireContractOwner{ authorizedContracts[dataContract] = 1; }
function authorizeCaller(address dataContract) external requireContractOwner{ authorizedContracts[dataContract] = 1; }
44,615
46
// Swap tokenA into tokenB using univ3_router.ExactInputSingle() Uni V3 only
function swap(address _tokenA, address _tokenB, uint24 _fee_tier, uint256 _amountAtoB, uint256 _amountOutMinimum, uint160 _sqrtPriceLimitX96) public onlyByOwnGov returns (uint256) { // Make sure the collateral is allowed require(allowed_collaterals[_tokenA] || _tokenA == address(FRAX), "TokenA not allowed"); require(allowed_collaterals[_tokenB] || _tokenB == address(FRAX), "TokenB not allowed"); ISwapRouter.ExactInputSingleParams memory swap_params = ISwapRouter.ExactInputSingleParams( _tokenA, _tokenB, _fee_tier, address(this), 2105300114, // Expiration: a long time from now _amountAtoB, _amountOutMinimum, _sqrtPriceLimitX96 ); // Approval TransferHelper.safeApprove(_tokenA, address(univ3_router), _amountAtoB); uint256 amountOut = univ3_router.exactInputSingle(swap_params); return amountOut; }
function swap(address _tokenA, address _tokenB, uint24 _fee_tier, uint256 _amountAtoB, uint256 _amountOutMinimum, uint160 _sqrtPriceLimitX96) public onlyByOwnGov returns (uint256) { // Make sure the collateral is allowed require(allowed_collaterals[_tokenA] || _tokenA == address(FRAX), "TokenA not allowed"); require(allowed_collaterals[_tokenB] || _tokenB == address(FRAX), "TokenB not allowed"); ISwapRouter.ExactInputSingleParams memory swap_params = ISwapRouter.ExactInputSingleParams( _tokenA, _tokenB, _fee_tier, address(this), 2105300114, // Expiration: a long time from now _amountAtoB, _amountOutMinimum, _sqrtPriceLimitX96 ); // Approval TransferHelper.safeApprove(_tokenA, address(univ3_router), _amountAtoB); uint256 amountOut = univ3_router.exactInputSingle(swap_params); return amountOut; }
74,980
27
// Gov Functions //Begins transfer of gov rights. The newPendingGov must call `_acceptGov` to finalize the transfer.Gov function to begin change of gov. The newPendingGov must call `_acceptGov` to finalize the transfer.newPendingGov New pending gov./
function _setPendingGov(address newPendingGov) external
function _setPendingGov(address newPendingGov) external
16,659
24
// update an Issue with transaction tokens owned2nd step(optional) /
function updateIssue(uint256 _issueId, uint256 _newTokenAmount) public whenNotPaused { require(issues[_issueId].tokensStaked != 0, "Issue has to exist"); require(issues[_issueId].issueGenerator == msg.sender, "Has to be the issue creator"); require(isIssueInDraft(_issueId), "Draft Issue Time has already passed"); uint256 previousAmount = issues[_issueId].tokensStaked; // Update Issue issues[_issueId].tokensStaked = _newTokenAmount; // Lock Transaction Tokens if(_newTokenAmount > previousAmount){ require(transactionToken.transferFrom(msg.sender, address(this), _newTokenAmount.sub(previousAmount)), "Needs Allowance"); totalStaked = totalStaked.add(_newTokenAmount.sub(previousAmount)); }else{ totalStaked = totalStaked.sub(previousAmount.sub(_newTokenAmount)); require(transactionToken.transfer(msg.sender, previousAmount.sub(_newTokenAmount)), "Transfer not sucessful"); } }
function updateIssue(uint256 _issueId, uint256 _newTokenAmount) public whenNotPaused { require(issues[_issueId].tokensStaked != 0, "Issue has to exist"); require(issues[_issueId].issueGenerator == msg.sender, "Has to be the issue creator"); require(isIssueInDraft(_issueId), "Draft Issue Time has already passed"); uint256 previousAmount = issues[_issueId].tokensStaked; // Update Issue issues[_issueId].tokensStaked = _newTokenAmount; // Lock Transaction Tokens if(_newTokenAmount > previousAmount){ require(transactionToken.transferFrom(msg.sender, address(this), _newTokenAmount.sub(previousAmount)), "Needs Allowance"); totalStaked = totalStaked.add(_newTokenAmount.sub(previousAmount)); }else{ totalStaked = totalStaked.sub(previousAmount.sub(_newTokenAmount)); require(transactionToken.transfer(msg.sender, previousAmount.sub(_newTokenAmount)), "Transfer not sucessful"); } }
45,505
24
// write sourceChainId
mstore(chainIds, and(mload(add(_data, srcdataptr)), mask))
mstore(chainIds, and(mload(add(_data, srcdataptr)), mask))
18,625
59
// Propose a new cold wallet address/_newColdWallet The address of the new cold wallet
function proposeColdWallet(address _newColdWallet) external onlyOwner { _tempWallet = _newColdWallet; adminFeelsOK = true; }
function proposeColdWallet(address _newColdWallet) external onlyOwner { _tempWallet = _newColdWallet; adminFeelsOK = true; }
13,082
64
// if a taker has been specified (peer-to-peer offer - i.e. direct trade between two users)
else{ if(checkIds){
else{ if(checkIds){
26,783
8
// Set up variables for checking the contract's membership status.
bool private isMember_; uint8 private memberId_;
bool private isMember_; uint8 private memberId_;
10,694
247
// Revokes `role` from the calling account.
* Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); }
* Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); }
185
20
// collateralRatioDecimalsCorrection represents the value to be used to adjust result decimals after applying ratio to a value calculation.
function collateralRatioDecimalsCorrection() public pure returns (uint256) { return 10000; }
function collateralRatioDecimalsCorrection() public pure returns (uint256) { return 10000; }
6,267
102
// 0: Water, 1: Fire, 2: Nature, 3: Light, 4: Darkness.
uint8 aura;
uint8 aura;
57,791
8
// See {ERC721Pausable} and {Pausable-_unpause}. Requirements: - the caller must have the `PAUSER_ROLE`. /
function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have pauser role to unpause"); _unpause(); }
function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have pauser role to unpause"); _unpause(); }
6,258
165
// Private function to add a token to this extension's ownership-tracking data structures. to address representing the new owner of the given token ID tokenId uint ID of the token to be added to the tokens list of the given address /
function _addTokenToOwnerEnumeration(address to, uint tokenId) private { uint length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; }
function _addTokenToOwnerEnumeration(address to, uint tokenId) private { uint length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; }
40,318
115
// Handles Minting Logic To Create New Tokens/
) private returns (bool) { // fee exempt bool takeFee = !isFeeExempt[msg.sender]; // find the number of tokens we should mint to keep up with the current price uint256 tokensToMintNoTax = _totalSupply.mul(received).div( prevTokenAmount ); // apply fee to minted tokens to inflate price relative to total supply uint256 tokensToMint = takeFee ? tokensToMintNoTax.mul(mintFee).div(feeDenominator) : tokensToMintNoTax.sub(100, "100 Asset Minimum For Fee Exemption"); // revert if under 1 require(tokensToMint > 0, "Must Purchase At Least One Climb Token"); if (takeFee) { // difference uint256 taxTaken = tokensToMintNoTax.sub(tokensToMint); // allocate dev share uint256 allocation = taxTaken.mul(devShare).div( devShare.add(liquidityShare) ); // mint to dev _mint(dev, allocation); } // mint to Buyer _mint(recipient, tokensToMint); // Requires The Price of CLIMB to Increase in order to complete the transaction _requirePriceRises(oldPrice); return true; }
) private returns (bool) { // fee exempt bool takeFee = !isFeeExempt[msg.sender]; // find the number of tokens we should mint to keep up with the current price uint256 tokensToMintNoTax = _totalSupply.mul(received).div( prevTokenAmount ); // apply fee to minted tokens to inflate price relative to total supply uint256 tokensToMint = takeFee ? tokensToMintNoTax.mul(mintFee).div(feeDenominator) : tokensToMintNoTax.sub(100, "100 Asset Minimum For Fee Exemption"); // revert if under 1 require(tokensToMint > 0, "Must Purchase At Least One Climb Token"); if (takeFee) { // difference uint256 taxTaken = tokensToMintNoTax.sub(tokensToMint); // allocate dev share uint256 allocation = taxTaken.mul(devShare).div( devShare.add(liquidityShare) ); // mint to dev _mint(dev, allocation); } // mint to Buyer _mint(recipient, tokensToMint); // Requires The Price of CLIMB to Increase in order to complete the transaction _requirePriceRises(oldPrice); return true; }
29,656
26
// assert(a == bc + a % b);There is no case in which this doesn't hold
return c;
return c;
17,113
80
// is a is less than b a FixedPointInt b FixedPointIntreturn True if a < b, False if not /
function isLessThan(FixedPointInt memory a, FixedPointInt memory b) internal pure returns (bool) { return a.value < b.value; }
function isLessThan(FixedPointInt memory a, FixedPointInt memory b) internal pure returns (bool) { return a.value < b.value; }
48,520