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
26
// Burn `_role` in `_app`, so no modification can be made to it (grant, revoke, permission manager)_app Address of the app in which the permission is being burned_role Identifier for the group of actions being burned/
function burnPermissionManager(address _app, bytes32 _role) external onlyPermissionManager(_app, _role)
function burnPermissionManager(address _app, bytes32 _role) external onlyPermissionManager(_app, _role)
16,330
84
// Returns true if the reentrancy guard is currently set to "entered", which indicates there is a`nonReentrant` function in the call stack. /
function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; }
function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; }
2,779
16
// Executes a given list of functions/_marketplaceCallData List of marketplace calldata
function executeFunctions( FunctionCallData[] memory _marketplaceCallData
function executeFunctions( FunctionCallData[] memory _marketplaceCallData
39,526
150
// Ok, if we're here and 'remainingToFulfill' isn't zero, then we need to refund the remainder of their ETH back to them.
if (remainingToFulfill > 0) { msg.sender.transfer( remainingToFulfill.divideDecimal( exchangeRates().rateForCurrency(ETH) ) ); }
if (remainingToFulfill > 0) { msg.sender.transfer( remainingToFulfill.divideDecimal( exchangeRates().rateForCurrency(ETH) ) ); }
15,381
217
// percentage > 0, data.tAmount > 0
assert (distributingAmount > 0); require( distributingAmount <= saleToken.balanceOf(address(this)), "Distribute: not enough token to distribute" );
assert (distributingAmount > 0); require( distributingAmount <= saleToken.balanceOf(address(this)), "Distribute: not enough token to distribute" );
12,303
64
// Fire the event
MintToken(msg.sender, _to, _amount);
MintToken(msg.sender, _to, _amount);
51,193
46
// burnable
event Burn(address indexed burner, uint256 value);
event Burn(address indexed burner, uint256 value);
21,952
342
// ecrecover takes the signature parameters, and the only way to get them currently is to use assembly. solhint-disable-next-line no-inline-assembly
assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) }
assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) }
12,988
33
// Get user's token, it'll revert if user doesn't hold the asset We're importing ERC721Holder, we don't need safeTransferFrom Convert token URI of token to uint256 array
string memory _tokenURI = _onlyTokenIdUri(tokenId); uint256 lucky = getLucky(tokenId); uint256 earn_tm = getLastEarnTm(tokenId); _burn(tokenId);
string memory _tokenURI = _onlyTokenIdUri(tokenId); uint256 lucky = getLucky(tokenId); uint256 earn_tm = getLastEarnTm(tokenId); _burn(tokenId);
9,282
3
// Array of addresses of price-feed contracts for fiat/fiat pairs: [0] - USD / USD priceFeed = '0x0000000000000000000000000000000000000000' !!! [1] - EUR / USD
address[2] fiatPriceFeedList = [ 0x0000000000000000000000000000000000000000, 0x0bf79F617988C472DcA68ff41eFe1338955b9A80 // EUR / USD (BSC Mainnet) ];
address[2] fiatPriceFeedList = [ 0x0000000000000000000000000000000000000000, 0x0bf79F617988C472DcA68ff41eFe1338955b9A80 // EUR / USD (BSC Mainnet) ];
3,807
144
// EVENTS
event StakeDeposited(address indexed account, uint256 amount); event WithdrawInitiated(address indexed account, uint256 amount, uint256 initiateDate); event WithdrawExecuted(address indexed account, uint256 amount, uint256 reward); event RewardsWithdrawn(address indexed account, uint256 reward); event RewardsDistributed(uint256 amount);
event StakeDeposited(address indexed account, uint256 amount); event WithdrawInitiated(address indexed account, uint256 amount, uint256 initiateDate); event WithdrawExecuted(address indexed account, uint256 amount, uint256 reward); event RewardsWithdrawn(address indexed account, uint256 reward); event RewardsDistributed(uint256 amount);
40,740
122
// when there are a lots of loans to be collected then/
uint totalLoanAmountCollected; uint totalCollateralToCollect; uint totalDefaultingFee; for (uint i = 0; i < loanIds.length; i++) { require(i < loans.length, "invalid loanId"); // next line would revert but require to emit reason LoanData storage loan = loans[loanIds[i]]; require(loan.state == LoanState.Open, "loan state must be Open"); require(now >= loan.maturity, "current time must be later than maturity"); LoanProduct storage product = products[loan.productId];
uint totalLoanAmountCollected; uint totalCollateralToCollect; uint totalDefaultingFee; for (uint i = 0; i < loanIds.length; i++) { require(i < loans.length, "invalid loanId"); // next line would revert but require to emit reason LoanData storage loan = loans[loanIds[i]]; require(loan.state == LoanState.Open, "loan state must be Open"); require(now >= loan.maturity, "current time must be later than maturity"); LoanProduct storage product = products[loan.productId];
4,557
85
// transfer tnxAmount (tokens) that had been approved by user (msg.sender) to the merchant(address(this))
erc20.transferFrom(msg.sender, merchantWalletAddress, tnxAmount); if (totalTnxFee > 0) {
erc20.transferFrom(msg.sender, merchantWalletAddress, tnxAmount); if (totalTnxFee > 0) {
23,123
38
// Note we do not check whether the keyHash is valid to save gas. The consequence for users is that they can send requests for invalid keyHashes which will simply not be fulfilled.
uint64 nonce = currentNonce + 1; (uint256 requestId, uint256 preSeed) = computeRequestId(keyHash, msg.sender, subId, nonce); s_requestCommitments[requestId] = keccak256( abi.encode(requestId, block.number, subId, callbackGasLimit, numWords, msg.sender) ); emit RandomWordsRequested( keyHash, requestId, preSeed,
uint64 nonce = currentNonce + 1; (uint256 requestId, uint256 preSeed) = computeRequestId(keyHash, msg.sender, subId, nonce); s_requestCommitments[requestId] = keccak256( abi.encode(requestId, block.number, subId, callbackGasLimit, numWords, msg.sender) ); emit RandomWordsRequested( keyHash, requestId, preSeed,
1,847
17
// update reveal strategy before starting index is set - only callable by owner/_revealStrategy new state of revealStrategy - possible values: (1: auto reveal) - (2: restricted manual reveal) - (3: unrestricted manual reveal)
function setRevealStrategy(uint256 _revealStrategy) external onlyOwner { if(startingIndex != 0) revert StartingIndexSet(); if(_revealStrategy < AUTO_REVEAL_STRATEGY || _revealStrategy > UNRESTRICTED_MANUAL_REVEAL_STRATEGY) revert InvalidParameter(); revealStrategy = _revealStrategy; eventhub.emitSetActionEvent(); }
function setRevealStrategy(uint256 _revealStrategy) external onlyOwner { if(startingIndex != 0) revert StartingIndexSet(); if(_revealStrategy < AUTO_REVEAL_STRATEGY || _revealStrategy > UNRESTRICTED_MANUAL_REVEAL_STRATEGY) revert InvalidParameter(); revealStrategy = _revealStrategy; eventhub.emitSetActionEvent(); }
9,415
90
// Remove investor from the whitelist /
function blacklistInvestor(address investor) public onlyKycProvider { require(investorWhitelist[investor] == true, "Investor not on whitelist"); investorWhitelist[investor] = false; uint256 arrayLen = investorWhitelistLUT.length; for (uint256 i = 0; i < arrayLen; i++) { if (investorWhitelistLUT[i] == investor) { investorWhitelistLUT[i] = investorWhitelistLUT[investorWhitelistLUT.length - 1]; delete investorWhitelistLUT[investorWhitelistLUT.length - 1]; break; } } emit InvestorBlacklisted(investor); }
function blacklistInvestor(address investor) public onlyKycProvider { require(investorWhitelist[investor] == true, "Investor not on whitelist"); investorWhitelist[investor] = false; uint256 arrayLen = investorWhitelistLUT.length; for (uint256 i = 0; i < arrayLen; i++) { if (investorWhitelistLUT[i] == investor) { investorWhitelistLUT[i] = investorWhitelistLUT[investorWhitelistLUT.length - 1]; delete investorWhitelistLUT[investorWhitelistLUT.length - 1]; break; } } emit InvestorBlacklisted(investor); }
34,355
47
// Allow user to sell CDRT tokens and destroy them. Can not be executed until 1539561600_qty amount to sell and destroy/
function execBuyBack(uint256 _qty) public{ require(now > 1539561600); uint256 toPay = _qty*buyBackPrice; require(balanceOf[msg.sender] >= _qty); // check if user has enough CDRT Tokens require(buyBackPrice > 0); // check if sale price set require(bbBalance >= toPay); require(frozenAccount[msg.sender] < now); // Check if sender is frozen msg.sender.transfer(toPay); bbBalance -= toPay; burn(_qty); }
function execBuyBack(uint256 _qty) public{ require(now > 1539561600); uint256 toPay = _qty*buyBackPrice; require(balanceOf[msg.sender] >= _qty); // check if user has enough CDRT Tokens require(buyBackPrice > 0); // check if sale price set require(bbBalance >= toPay); require(frozenAccount[msg.sender] < now); // Check if sender is frozen msg.sender.transfer(toPay); bbBalance -= toPay; burn(_qty); }
53,252
10
// Update the nextEarliestUpdate to previous nextEarliestUpdate plus updateInterval
nextEarliestUpdate = nextEarliestUpdate.add(updateInterval);
nextEarliestUpdate = nextEarliestUpdate.add(updateInterval);
38,673
333
// Helper function wrapped around totalStakedFor. Checks whether _accountAddress _accountAddress - Account requesting forreturn Boolean indicating whether account is a staker /
function isStaker(address _accountAddress) external view returns (bool) { _requireIsInitialized(); return totalStakedFor(_accountAddress) > 0; }
function isStaker(address _accountAddress) external view returns (bool) { _requireIsInitialized(); return totalStakedFor(_accountAddress) > 0; }
25,969
69
// Allows owner, factory or permissioned delegate
modifier withPerm(bytes32 _perm) { bool isOwner = msg.sender == Ownable(securityToken).owner(); bool isFactory = msg.sender == factory; require(isOwner||isFactory||ISecurityToken(securityToken).checkPermission(msg.sender, address(this), _perm), "Permission check failed"); _; }
modifier withPerm(bytes32 _perm) { bool isOwner = msg.sender == Ownable(securityToken).owner(); bool isFactory = msg.sender == factory; require(isOwner||isFactory||ISecurityToken(securityToken).checkPermission(msg.sender, address(this), _perm), "Permission check failed"); _; }
6,667
164
// Returns status code of latest update request posted to the Witnet Request Board:/Status codes:/- 200: update request was succesfully solved with no errors/- 400: update request was solved with errors/- 404: update request was not solved yet
function latestUpdateStatus() external view returns (uint256);
function latestUpdateStatus() external view returns (uint256);
38,114
39
// Make a new offer to a specific person
function makeOfferTo(uint256 tokenId, uint256 price, address to) external { _makeOffer(tokenId, price, to); }
function makeOfferTo(uint256 tokenId, uint256 price, address to) external { _makeOffer(tokenId, price, to); }
47,355
27
// Returns the max amount to hold the token. /
function maxWalletSize() external view returns(uint256) { return _maxWalletSize; }
function maxWalletSize() external view returns(uint256) { return _maxWalletSize; }
26,891
16
// Create a reference to the corresponding cToken contract, like cDAI
CErc20 cToken = CErc20(cErc20Contract);
CErc20 cToken = CErc20(cErc20Contract);
8,472
16
// Sets external NFT for display tokenIdBy default NFT is rendered using our internal metadata Throws if not called from MINTER role /
function setExternalNft(
function setExternalNft(
30,817
104
// Owner can set the offered token conversion rate. Receiver tokens = tradeTokenstokenRate / 10etherConversionRateDecimals _decimals Fixed number of decimals /
function setOfferedCurrencyDecimals(address _token, uint256 _decimals) external onlyOwner { require(offeredCurrencies[_token].decimals != _decimals, "POOL::RATE_INVALID"); offeredCurrencies[_token].decimals = _decimals; emit PoolStatsChanged(); }
function setOfferedCurrencyDecimals(address _token, uint256 _decimals) external onlyOwner { require(offeredCurrencies[_token].decimals != _decimals, "POOL::RATE_INVALID"); offeredCurrencies[_token].decimals = _decimals; emit PoolStatsChanged(); }
25,663
3
// len == 0
if (l1 == address(0)) { return userReferrals; }
if (l1 == address(0)) { return userReferrals; }
37,486
1
// Batch transfer of tokens, real quantities /
function batchTransfer( address _token, TransferInfo[] calldata transferArray
function batchTransfer( address _token, TransferInfo[] calldata transferArray
38,008
323
// Emergency withdraw withdraws funds without claiming rewards. This should only be used in emergencies. /
function emergencyWithdraw(uint256 poolId) public { PoolInfo storage pool = poolInfo[poolId]; UserInfo storage user = userInfo[poolId][msg.sender]; require( user.amountInPool > 0, "ToshiCoinFarm: User has no funds to withdraw from this pool" ); uint256 amount = user.amountInPool; user.amountInPool = 0; user.coinsReceivedToDate = 0; safePoolTransfer(msg.sender, amount, pool); emit EmergencyWithdraw(msg.sender, poolId, amount); }
function emergencyWithdraw(uint256 poolId) public { PoolInfo storage pool = poolInfo[poolId]; UserInfo storage user = userInfo[poolId][msg.sender]; require( user.amountInPool > 0, "ToshiCoinFarm: User has no funds to withdraw from this pool" ); uint256 amount = user.amountInPool; user.amountInPool = 0; user.coinsReceivedToDate = 0; safePoolTransfer(msg.sender, amount, pool); emit EmergencyWithdraw(msg.sender, poolId, amount); }
13,366
63
// Increase the amount of tokens that an owner allowed to a spender. approve should be called when allowed[_spender] == 0. To incrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.sol _spender The address which will spend the funds. _addedValue The amount of tokens to increase the allowance by. /
function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
2,055
0
// ============ EVENTS: ============
event _VoteCommitted(uint indexed id, uint numTokens, address indexed voter); event _VoteRevealed(uint indexed id, uint numTokens, uint votesFor, uint votesAgainst, uint indexed choice, address indexed voter); event _PollCreated(uint voteQuorum, uint commitEndDate, uint revealEndDate, uint indexed id, address indexed creator); event _VotingRightsGranted(uint numTokens, address indexed voter); event _VotingRightsWithdrawn(uint numTokens, address indexed voter); event _TokensRescued(uint indexed id, address indexed voter);
event _VoteCommitted(uint indexed id, uint numTokens, address indexed voter); event _VoteRevealed(uint indexed id, uint numTokens, uint votesFor, uint votesAgainst, uint indexed choice, address indexed voter); event _PollCreated(uint voteQuorum, uint commitEndDate, uint revealEndDate, uint indexed id, address indexed creator); event _VotingRightsGranted(uint numTokens, address indexed voter); event _VotingRightsWithdrawn(uint numTokens, address indexed voter); event _TokensRescued(uint indexed id, address indexed voter);
10,731
4
//
mapping (uint=>address) employeesVoted; uint employeesVotedCount = 0; mapping (address=>bool) votes;
mapping (uint=>address) employeesVoted; uint employeesVotedCount = 0; mapping (address=>bool) votes;
10,470
1
// Migrates an amount of legacy token (MADToken) to ALCA tokens amount the amount of legacy token to migrate. /
function migrate(uint256 amount) public returns (uint256) { return _migrate(msg.sender, amount); }
function migrate(uint256 amount) public returns (uint256) { return _migrate(msg.sender, amount); }
31,646
242
// ================== VARAIBLES =======================
string private uriPrefix = ""; string private uriSuffix = ".json"; string private hiddenMetadataUri; bool public paused = true; bool public revealed = true; uint256 public salePrice = 0.0022 ether; uint256 public maxFree = 2; uint256 public maxTx = 5;
string private uriPrefix = ""; string private uriSuffix = ".json"; string private hiddenMetadataUri; bool public paused = true; bool public revealed = true; uint256 public salePrice = 0.0022 ether; uint256 public maxFree = 2; uint256 public maxTx = 5;
12,031
26
// the time when newly minted bro claiming starts
uint256 public newMintStartTime; /*////////////////////////////////////////////////////////////// MODIFIERS
uint256 public newMintStartTime; /*////////////////////////////////////////////////////////////// MODIFIERS
40,101
16
// We define which bet sum is the Loser one and which one is the winner
if ( teamWinner == 1){ LoserBet = totalBetsTwo; WinnerBet = totalBetsOne; }
if ( teamWinner == 1){ LoserBet = totalBetsTwo; WinnerBet = totalBetsOne; }
25,733
59
// emitted for all price changes/
event PricePosted(address asset, uint previousPriceMantissa, uint requestedPriceMantissa, uint newPriceMantissa);
event PricePosted(address asset, uint previousPriceMantissa, uint requestedPriceMantissa, uint newPriceMantissa);
19,392
122
// Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. The call is not executed if the target address is not a contract.from address representing the previous owner of the given token IDto target address that will receive the tokenstokenId uint256 ID of the token to be transferred_data bytes optional data to send along with the call return bool whether the call correctly returned the expected magic value/
function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) {
function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) {
50,428
29
// information of product
struct ProductInfo
struct ProductInfo
27,857
9
// Sync a rewards rate change automatically using pre-approved map
function autoDecreaseRewards() external update { require(isRewardDecreaseAvailable(), "time not passed"); uint256 tribePerBlock = nextRewardsRate(); tribalChief.updateBlockReward(tribePerBlock); rewardsArray.pop(); }
function autoDecreaseRewards() external update { require(isRewardDecreaseAvailable(), "time not passed"); uint256 tribePerBlock = nextRewardsRate(); tribalChief.updateBlockReward(tribePerBlock); rewardsArray.pop(); }
58,335
21
// Constructor _owner The account which controls this contract. /
constructor(address _owner) Owned(_owner) public
constructor(address _owner) Owned(_owner) public
28,512
41
// PUBLIC /
function Treasury(address _token) public { require(address(_token) != 0x0); token = _token; periodsCount = 1; }
function Treasury(address _token) public { require(address(_token) != 0x0); token = _token; periodsCount = 1; }
71,755
78
// Obtain the next schedule entry that will vest for a given user.return A pair of uints: (timestamp, synthetix quantity). /
{ uint index = getNextVestingIndex(account); if (index == numVestingEntries(account)) { return [uint(0), 0]; } return getVestingScheduleEntry(account, index); }
{ uint index = getNextVestingIndex(account); if (index == numVestingEntries(account)) { return [uint(0), 0]; } return getVestingScheduleEntry(account, index); }
25,040
7
// Return the current amp value, which will be an interpolation if there is an ongoing amp update. Also return a flag indicating whether there is an ongoing update.
function _getAmplificationParameter() internal view returns (uint256 value, bool isUpdating) { (uint256 startValue, uint256 endValue, uint256 startTime, uint256 endTime) = _getAmplificationData(); // Note that block.timestamp >= startTime, since startTime is set to the current time when an update starts if (block.timestamp < endTime) { isUpdating = true; // We can skip checked arithmetic as: // - block.timestamp is always larger or equal to startTime // - endTime is always larger than startTime // - the value delta is bounded by the largest amplification parameter, which never causes the // multiplication to overflow. // This also means that the following computation will never revert nor yield invalid results. if (endValue > startValue) { value = startValue + ((endValue - startValue) * (block.timestamp - startTime)) / (endTime - startTime); } else { value = startValue - ((startValue - endValue) * (block.timestamp - startTime)) / (endTime - startTime); } } else { isUpdating = false; value = endValue; } }
function _getAmplificationParameter() internal view returns (uint256 value, bool isUpdating) { (uint256 startValue, uint256 endValue, uint256 startTime, uint256 endTime) = _getAmplificationData(); // Note that block.timestamp >= startTime, since startTime is set to the current time when an update starts if (block.timestamp < endTime) { isUpdating = true; // We can skip checked arithmetic as: // - block.timestamp is always larger or equal to startTime // - endTime is always larger than startTime // - the value delta is bounded by the largest amplification parameter, which never causes the // multiplication to overflow. // This also means that the following computation will never revert nor yield invalid results. if (endValue > startValue) { value = startValue + ((endValue - startValue) * (block.timestamp - startTime)) / (endTime - startTime); } else { value = startValue - ((startValue - endValue) * (block.timestamp - startTime)) / (endTime - startTime); } } else { isUpdating = false; value = endValue; } }
10,055
35
// To claim the vesting amountAsserts the vesting condition is metAsserts callee to be valid vested user Claims as per Vesting Schedule and remaining eligible balance /
function claimAmount() internal whenContractIsActive whenClaimable checkValidUser{ uint256 amount = 0; uint256 periodAmount = 0; if(now>firstDueDate){ periodAmount = ownersMapFirstPeriod[msg.sender]; if(periodAmount > 0){ ownersMapFirstPeriod[msg.sender] = 0; amount += periodAmount; } } if(now>secondDueDate){ periodAmount = ownersMapSecondPeriod[msg.sender]; if(periodAmount > 0){ ownersMapSecondPeriod[msg.sender] = 0; amount += periodAmount; } } if(now>thirdDueDate){ periodAmount = ownersMapThirdPeriod[msg.sender]; if(periodAmount > 0){ ownersMapThirdPeriod[msg.sender] = 0; amount += periodAmount; } } require(amount>0); ownersMap[msg.sender]= ownersMap[msg.sender]-amount; token.transfer(msg.sender, amount); totalCommitted -= amount; }
function claimAmount() internal whenContractIsActive whenClaimable checkValidUser{ uint256 amount = 0; uint256 periodAmount = 0; if(now>firstDueDate){ periodAmount = ownersMapFirstPeriod[msg.sender]; if(periodAmount > 0){ ownersMapFirstPeriod[msg.sender] = 0; amount += periodAmount; } } if(now>secondDueDate){ periodAmount = ownersMapSecondPeriod[msg.sender]; if(periodAmount > 0){ ownersMapSecondPeriod[msg.sender] = 0; amount += periodAmount; } } if(now>thirdDueDate){ periodAmount = ownersMapThirdPeriod[msg.sender]; if(periodAmount > 0){ ownersMapThirdPeriod[msg.sender] = 0; amount += periodAmount; } } require(amount>0); ownersMap[msg.sender]= ownersMap[msg.sender]-amount; token.transfer(msg.sender, amount); totalCommitted -= amount; }
47,473
29
// send 1% to the pooled ledger
uint256 burned_amount = value.div(5); //BURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRN
uint256 burned_amount = value.div(5); //BURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRN
2,544
24
// add asset to list of assets in transfer
assetsInTransfer[_aid] = _receiver; emitActionSuccess("asset-set-in-transfer-success: asset set in transfer successfully");
assetsInTransfer[_aid] = _receiver; emitActionSuccess("asset-set-in-transfer-success: asset set in transfer successfully");
14,812
0
// IMintingStation/Simon Fremaux (@dievardump)
interface IMintingStation { /// @notice helper to know if an address can mint or not /// @param operator the address to check function canMint(address operator) external returns (bool); /// @notice helper to know if everyone can mint or only minters /// @return if minting is open to all or not function isMintingOpenToAll() external returns (bool); /// @notice Toggle minting open to all state /// @param isOpen if the new state is open or not function setMintingOpenToAll(bool isOpen) external; /// @notice Mint one token for msg.sender /// @param tokenURI_ the token URI /// @param feeRecipient the recipient of royalties /// @param feeAmount the royalties amount. From 0 to 10000 /// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50% /// @return the minted tokenId function mint( string memory tokenURI_, address feeRecipient, uint256 feeAmount ) external returns (uint256); /// @notice Mint one token to user `to` /// @param to the token recipient /// @param tokenURI_ the token URI /// @param feeRecipient the recipient of royalties /// @param feeAmount the royalties amount. From 0 to 10000 /// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50% /// @return tokenId the minted tokenId function mintTo( address to, string memory tokenURI_, address feeRecipient, uint256 feeAmount ) external returns (uint256 tokenId); /// @notice Mint several tokens for msg.sender /// @param tokenURIs_ the token URI for each id /// @param feeRecipients the recipients of royalties for each id /// @param feeAmounts the royalties amounts for each id. From 0 to 10000 /// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50% /// @return all minted tokenIds function mintBatch( string[] memory tokenURIs_, address[] memory feeRecipients, uint256[] memory feeAmounts ) external returns (uint256[] memory); /// @notice Mint one token to user `to` /// @param to the token recipient /// @param tokenURIs_ the token URI for each id /// @param feeRecipients the recipients of royalties for each id /// @param feeAmounts the royalties amounts for each id. From 0 to 10000 /// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50% /// @return all minted tokenIds function mintBatchTo( address to, string[] memory tokenURIs_, address[] memory feeRecipients, uint256[] memory feeAmounts ) external returns (uint256[] memory); /// @notice Mint one token to user `to` /// @param to the token recipient /// @param tokenURIs_ the token URI for each id /// @param feeRecipients the recipients of royalties for each id /// @param feeAmounts the royalties amounts for each id. From 0 to 10000 /// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50% /// @return tokenIds all minted tokenIds function mintBatchToMore( address[] memory to, string[] memory tokenURIs_, address[] memory feeRecipients, uint256[] memory feeAmounts ) external returns (uint256[] memory tokenIds); }
interface IMintingStation { /// @notice helper to know if an address can mint or not /// @param operator the address to check function canMint(address operator) external returns (bool); /// @notice helper to know if everyone can mint or only minters /// @return if minting is open to all or not function isMintingOpenToAll() external returns (bool); /// @notice Toggle minting open to all state /// @param isOpen if the new state is open or not function setMintingOpenToAll(bool isOpen) external; /// @notice Mint one token for msg.sender /// @param tokenURI_ the token URI /// @param feeRecipient the recipient of royalties /// @param feeAmount the royalties amount. From 0 to 10000 /// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50% /// @return the minted tokenId function mint( string memory tokenURI_, address feeRecipient, uint256 feeAmount ) external returns (uint256); /// @notice Mint one token to user `to` /// @param to the token recipient /// @param tokenURI_ the token URI /// @param feeRecipient the recipient of royalties /// @param feeAmount the royalties amount. From 0 to 10000 /// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50% /// @return tokenId the minted tokenId function mintTo( address to, string memory tokenURI_, address feeRecipient, uint256 feeAmount ) external returns (uint256 tokenId); /// @notice Mint several tokens for msg.sender /// @param tokenURIs_ the token URI for each id /// @param feeRecipients the recipients of royalties for each id /// @param feeAmounts the royalties amounts for each id. From 0 to 10000 /// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50% /// @return all minted tokenIds function mintBatch( string[] memory tokenURIs_, address[] memory feeRecipients, uint256[] memory feeAmounts ) external returns (uint256[] memory); /// @notice Mint one token to user `to` /// @param to the token recipient /// @param tokenURIs_ the token URI for each id /// @param feeRecipients the recipients of royalties for each id /// @param feeAmounts the royalties amounts for each id. From 0 to 10000 /// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50% /// @return all minted tokenIds function mintBatchTo( address to, string[] memory tokenURIs_, address[] memory feeRecipients, uint256[] memory feeAmounts ) external returns (uint256[] memory); /// @notice Mint one token to user `to` /// @param to the token recipient /// @param tokenURIs_ the token URI for each id /// @param feeRecipients the recipients of royalties for each id /// @param feeAmounts the royalties amounts for each id. From 0 to 10000 /// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50% /// @return tokenIds all minted tokenIds function mintBatchToMore( address[] memory to, string[] memory tokenURIs_, address[] memory feeRecipients, uint256[] memory feeAmounts ) external returns (uint256[] memory tokenIds); }
16,177
79
// return the number of decimals of the token. /
function decimals() public view returns(uint8) { return _decimals; }
function decimals() public view returns(uint8) { return _decimals; }
4,437
32
// Update the given pool's allocation points Can only be called by the owner pid The RewardManager pool id allocPoint New number of allocation points for pool withUpdate if specified, update all pools before setting allocation points /
function set( uint256 pid, uint256 allocPoint, bool withUpdate
function set( uint256 pid, uint256 allocPoint, bool withUpdate
10,173
465
// Safely mints `tokenId` and transfers it to `to`. Requirements:- `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); }
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); }
14,043
8
// Trigger Sell Event
emit Sell(msg.sender, _numberOfTokens);
emit Sell(msg.sender, _numberOfTokens);
22,349
27
// Destroy tokens from other account Remove `_value` tokens from the system irreversibly on behalf of `_from`._from the address of the sender _value the amount of money to burn /
function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; }
function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; }
16,162
24
// 进行投票
for(uint256 i = 0;i < voteOptions.length;i = i + 1) { options[eventId][voteOptions[i]].votePool += 1; }
for(uint256 i = 0;i < voteOptions.length;i = i + 1) { options[eventId][voteOptions[i]].votePool += 1; }
18,634
27
// method to claim the reward amount
function claim_reward() afterRace { require(!rewardIndex[msg.sender].rewarded); calculate_reward(msg.sender); uint transfer_amount = rewardIndex[msg.sender].amount; rewardIndex[msg.sender].rewarded = true; require(this.balance > transfer_amount); msg.sender.transfer(transfer_amount); Withdraw(msg.sender, transfer_amount); }
function claim_reward() afterRace { require(!rewardIndex[msg.sender].rewarded); calculate_reward(msg.sender); uint transfer_amount = rewardIndex[msg.sender].amount; rewardIndex[msg.sender].rewarded = true; require(this.balance > transfer_amount); msg.sender.transfer(transfer_amount); Withdraw(msg.sender, transfer_amount); }
16,855
93
// Burn liquidity from the sender and account tokens owed for the liquidity to the position/Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0/Fees must be collected separately via a call to collect/tickLower The lower tick of the position for which to burn liquidity/tickUpper The upper tick of the position for which to burn liquidity/amount How much liquidity to burn/ return amount0 The amount of token0 sent to the recipient/ return amount1 The amount of token1 sent to the recipient
function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1);
function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1);
1,055
79
// PRIVATE
function contractFallback( address to, uint value, bytes memory data ) private
function contractFallback( address to, uint value, bytes memory data ) private
26,961
54
// Check that enough current validators have signed off on the new validator set
bytes32 newCheckpoint = makeCheckpoint(_newValset, state_gravityId); checkValidatorSignatures(_currentValset, _sigs, newCheckpoint, constant_powerThreshold);
bytes32 newCheckpoint = makeCheckpoint(_newValset, state_gravityId); checkValidatorSignatures(_currentValset, _sigs, newCheckpoint, constant_powerThreshold);
38,770
14
// This function updates the base range mutiplier _baseTicks: a mutiplier value to decide the spread of base range /
function setBaseTicks(int24 _baseTicks) external onlyGovernance { require(_baseTicks > 0, "IBM"); emit BaseTicksUpdated(baseTicks, baseTicks = _baseTicks); }
function setBaseTicks(int24 _baseTicks) external onlyGovernance { require(_baseTicks > 0, "IBM"); emit BaseTicksUpdated(baseTicks, baseTicks = _baseTicks); }
29,609
2
// Events//Public Functions// initialize the L1StandardBridge with the address of the messenger in the same domain /
function initialize(address payable _messenger) public { _initialize(_messenger, payable(Lib_PredeployAddresses.L2_STANDARD_BRIDGE)); }
function initialize(address payable _messenger) public { _initialize(_messenger, payable(Lib_PredeployAddresses.L2_STANDARD_BRIDGE)); }
22,425
1,066
// payback debt in one token
paybackDebt(_debtAmountOld, _cBorrowAddrOld, getUnderlyingAddr(_cBorrowAddrOld), tx.origin);
paybackDebt(_debtAmountOld, _cBorrowAddrOld, getUnderlyingAddr(_cBorrowAddrOld), tx.origin);
49,529
164
// Returns the normalized weight of a bound token. token Token contract address.return Bound token normalized weight. /
function getNormalizedWeight(address token) external view _viewlock_ returns (uint)
function getNormalizedWeight(address token) external view _viewlock_ returns (uint)
10,675
11
// Return the amount of tokens that were pre-minted plus the amount unlocked for minting
return SafeMath.add(totalSupplyPreMinted, supplyUnlockedForMinting);
return SafeMath.add(totalSupplyPreMinted, supplyUnlockedForMinting);
30,653
262
// Mint new xSNX tokens from the contract by sending SNX Won't run without ERC20 approval: Calculates overall fund NAV in ETH terms, using ETH/SNX price (via SNX oracle): Mints/distributes new xSNX tokens based on contribution to NAV: snxAmount: SNX to contribute /
function mintWithSnx(uint256 snxAmount) external whenNotPaused notLocked(msg.sender) { require(snxAmount > 0, "Must send SNX"); lock(msg.sender); uint256 snxBalanceBefore = tradeAccounting.getSnxBalance(); uint256 fee = calculateFee(snxAmount, feeDivisors.mintFee); uint256 snxContribution = snxAmount.sub(fee); require( IERC20(snxAddress).transferFrom(msg.sender, address(this), fee), "Transfer failed" ); require( IERC20(snxAddress).transferFrom( msg.sender, xsnxAdmin, snxContribution ), "Transfer failed" ); uint256 mintAmount = tradeAccounting.calculateTokensToMintWithSnx( snxBalanceBefore, snxContribution, totalSupply() ); emit Mint( msg.sender, block.timestamp, snxContribution, mintAmount, false ); return super._mint(msg.sender, mintAmount); }
function mintWithSnx(uint256 snxAmount) external whenNotPaused notLocked(msg.sender) { require(snxAmount > 0, "Must send SNX"); lock(msg.sender); uint256 snxBalanceBefore = tradeAccounting.getSnxBalance(); uint256 fee = calculateFee(snxAmount, feeDivisors.mintFee); uint256 snxContribution = snxAmount.sub(fee); require( IERC20(snxAddress).transferFrom(msg.sender, address(this), fee), "Transfer failed" ); require( IERC20(snxAddress).transferFrom( msg.sender, xsnxAdmin, snxContribution ), "Transfer failed" ); uint256 mintAmount = tradeAccounting.calculateTokensToMintWithSnx( snxBalanceBefore, snxContribution, totalSupply() ); emit Mint( msg.sender, block.timestamp, snxContribution, mintAmount, false ); return super._mint(msg.sender, mintAmount); }
39,007
81
// Returns xy, reverts if overflows/x The multiplicand/y The multiplier/ return z The product of x and y
function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(x == 0 || (z = x * y) / x == y); }
function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(x == 0 || (z = x * y) / x == y); }
24,132
214
// The block number when MILK2 mining starts.
uint256 public startBlock; uint256 internal milkPerBlock = 100; // 1
uint256 public startBlock; uint256 internal milkPerBlock = 100; // 1
21,671
48
// Store new nonce
state_lastValsetNonce = _newValset.valsetNonce;
state_lastValsetNonce = _newValset.valsetNonce;
2,668
100
// Mint the items.
items[_itemIndex].mintBatch(_msgSender(), itemIds, amounts, ""); emit ItemPurchased(_msgSender(), _id, itemIds, amounts);
items[_itemIndex].mintBatch(_msgSender(), itemIds, amounts, ""); emit ItemPurchased(_msgSender(), _id, itemIds, amounts);
12,971
17
// checks if the role exists for the given org or master org_roleId - unique identifier for the role being added_orgId - org id to which the role belongs_ultParent - master org id return true or false/
function roleExists(string memory _roleId, string memory _orgId,
function roleExists(string memory _roleId, string memory _orgId,
24,548
274
// Sanity check that allows us to ensure that we are pointing to theright auction in our setSiringAuctionAddress() call.
bool public isSiringClockAuction = true;
bool public isSiringClockAuction = true;
15,230
111
// sets tokenURI for the given currency, can be used during the sell only/_token address address of the token to update/_tokenURI string the URI may point to a JSON file that conforms to the "Metadata JSON Schema".
function setTokenURI(address _token, string _tokenURI) public tokenIssuerOnly(_token, msg.sender) marketClosed(_token)
function setTokenURI(address _token, string _tokenURI) public tokenIssuerOnly(_token, msg.sender) marketClosed(_token)
30,053
20
// unused blanks
contract Accessories2 { string public constant accessories1 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories2 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories6 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories3 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories7 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories10 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories11 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories12 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories13 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories14 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories17 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories18 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories19 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories20 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories21 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; }
contract Accessories2 { string public constant accessories1 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories2 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories6 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories3 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories7 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories10 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories11 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories12 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories13 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories14 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories17 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories18 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories19 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories20 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; string public constant accessories21 = "iVBORw0KGgoAAAANSUhEUgAAAKAAAACgAQMAAACxAfVuAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAZSURBVHic7cEBDQAAAMKg90/t7AEUAAAANw0gAAFn2WgjAAAAAElFTkSuQmCC"; }
38,261
200
// Reset DT state for token
_owners[collection][tokenId] = address(0); _lastPurchasePrices[collection][tokenId] = 0; _forSalePrices[collection][tokenId] = 0; _lastPurchaseTimes[collection][tokenId] = 0; _sendFees(collection, pricePaid / _feeRate, msg.value);
_owners[collection][tokenId] = address(0); _lastPurchasePrices[collection][tokenId] = 0; _forSalePrices[collection][tokenId] = 0; _lastPurchaseTimes[collection][tokenId] = 0; _sendFees(collection, pricePaid / _feeRate, msg.value);
1,094
31
// Whitelist the target app for app composition for the source app (msg.sender) targetApp The target super app address /
function allowCompositeApp(ISuperApp targetApp) external;
function allowCompositeApp(ISuperApp targetApp) external;
25,622
94
// Compute the slot.
mstore(0x00, tokenId) mstore(0x20, tokenApprovalsPtr.slot) approvedAddressSlot := keccak256(0x00, 0x40)
mstore(0x00, tokenId) mstore(0x20, tokenApprovalsPtr.slot) approvedAddressSlot := keccak256(0x00, 0x40)
7,042
11
// Allows the upgradeability owner to upgrade the current version of the proxy._newVersion representing the version name of the new implementation to be set._newImplementation representing the address of the new implementation to be set./
function upgradeTo(string _newVersion, address _newImplementation) external ifOwner { _upgradeTo(_newVersion, _newImplementation); }
function upgradeTo(string _newVersion, address _newImplementation) external ifOwner { _upgradeTo(_newVersion, _newImplementation); }
50,851
53
// LookBack into historical sale data
SellHistories[] public _sellHistories; bool public _isAutoBuyBack = true; uint256 public _buyBackDivisor = 10; uint256 public _buyBackTimeInterval = 5 minutes; uint256 public _buyBackMaxTimeForHistories = 24 * 60 minutes; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify;
SellHistories[] public _sellHistories; bool public _isAutoBuyBack = true; uint256 public _buyBackDivisor = 10; uint256 public _buyBackTimeInterval = 5 minutes; uint256 public _buyBackMaxTimeForHistories = 24 * 60 minutes; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify;
48,911
0
// See https:eips.ethereum.org/EIPS/eip-191
string private constant EIP191_PREFIX_FOR_EIP712_STRUCTURED_DATA = "\x19\x01";
string private constant EIP191_PREFIX_FOR_EIP712_STRUCTURED_DATA = "\x19\x01";
59,759
65
// e
test = (block.number.sub(roundownables[round].villages[e].lastcollect)).mul((roundvars[round].nextVillageId.sub(e))); if(roundvars[round].GOTCHatcontract < test ) { roundvars[round].GOTCHatcontract = roundvars[round].GOTCHatcontract.add(test); roundvars[round].totalsupplyGOTCH = roundvars[round].totalsupplyGOTCH.add(test); }
test = (block.number.sub(roundownables[round].villages[e].lastcollect)).mul((roundvars[round].nextVillageId.sub(e))); if(roundvars[round].GOTCHatcontract < test ) { roundvars[round].GOTCHatcontract = roundvars[round].GOTCHatcontract.add(test); roundvars[round].totalsupplyGOTCH = roundvars[round].totalsupplyGOTCH.add(test); }
3,111
35
// Returns the current per-block borrow interest rate for this cToken/ return The borrow interest rate per block, scaled by 1e18
function borrowRatePerBlock() external override view returns (uint) { return getBorrowRateInternal(getCashPrior(), totalBorrows, totalReserves); }
function borrowRatePerBlock() external override view returns (uint) { return getBorrowRateInternal(getCashPrior(), totalBorrows, totalReserves); }
20,784
7
// Gets the list of addresses on the network
function getAddresses() external view returns (address[] memory) { return addresses; }
function getAddresses() external view returns (address[] memory) { return addresses; }
1,329
6
// stake must be undelegated in current and next epoch to be withdrawn
uint256 currentWithdrawableStake = LibSafeMath.min256( undelegatedBalance.currentEpochBalance, undelegatedBalance.nextEpochBalance ); if (amount > currentWithdrawableStake) { revert(); }
uint256 currentWithdrawableStake = LibSafeMath.min256( undelegatedBalance.currentEpochBalance, undelegatedBalance.nextEpochBalance ); if (amount > currentWithdrawableStake) { revert(); }
42,215
68
// Burns a specific amount of tokens. value The amount of token to be burned. /
function burn(uint256 value) public { _burn(msg.sender, value); }
function burn(uint256 value) public { _burn(msg.sender, value); }
8,837
9
// Withdraw locked original tokens triggered by a burn at a remote chain's PeggedTokenBridge. _request The serialized Withdraw protobuf. _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by+2/3 of the bridge's current signing power to be delivered. _signers The sorted list of signers. _powers The signing powers of the signers. /
function withdraw( bytes calldata _request, bytes[] calldata _sigs, address[] calldata _signers, uint256[] calldata _powers
function withdraw( bytes calldata _request, bytes[] calldata _sigs, address[] calldata _signers, uint256[] calldata _powers
31,135
69
// Function to only summon a minion to be attached to an existing safe/_moloch Already deployed Moloch to instruct minion/_avatar Already deployed safe/_details Optional metadata to store/_minQuorum Optional quorum settings, set 0 to disable/_saltNonce Number used to calculate the address of the new minion
function summonMinion( address _moloch, address _avatar, string memory _details, uint256 _minQuorum, uint256 _saltNonce
function summonMinion( address _moloch, address _avatar, string memory _details, uint256 _minQuorum, uint256 _saltNonce
16,668
112
// for small src quantities dest qty might be 0, then returned rate is zero. for backward compatibility we would like to return non zero rate (correct one) for small src qty
function expectedRateSmallQty(ERC20 src, ERC20 dest, uint srcQty, bool usePermissionless) internal view returns(uint)
function expectedRateSmallQty(ERC20 src, ERC20 dest, uint srcQty, bool usePermissionless) internal view returns(uint)
24,020
33
// need 6 health gem score more to to expected score
hpLostOnBattle[loser] = hpLostOnBattle[loser].add( healthGemScore * 6 );
hpLostOnBattle[loser] = hpLostOnBattle[loser].add( healthGemScore * 6 );
19,476
64
// IUniswapV2Pair(pair2).swap(0,uint(amount1Delta)+amount2,address(this),new bytes(0));
wethTransfer(msg.sender,uint(amount1Delta));
wethTransfer(msg.sender,uint(amount1Delta));
694
15
// Transfer collateral to Vault
_permit(loanTerms.collateral, loanTerms.borrower, collateralPermit); _pull(loanTerms.collateral, loanTerms.borrower);
_permit(loanTerms.collateral, loanTerms.borrower, collateralPermit); _pull(loanTerms.collateral, loanTerms.borrower);
10,899
61
// The amount of Y token to send is (reserveY_before - reserveY_after)
return out ? reserveY.sub(yAfter) : yAfter.sub(reserveY);
return out ? reserveY.sub(yAfter) : yAfter.sub(reserveY);
20,305
200
// {RoleAdminChanged} not being emitted signaling this. _Available since v3.1._ /
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
3,067
4
// Receive profits from contract
function recoverERC20(address token) public { require(msg.sender == user, "shoo"); IERC20(token).safeTransfer( msg.sender, IERC20(token).balanceOf(address(this)) ); }
function recoverERC20(address token) public { require(msg.sender == user, "shoo"); IERC20(token).safeTransfer( msg.sender, IERC20(token).balanceOf(address(this)) ); }
2,608
62
// ba
contract SwapFactory is Ownable, CallerPermission, ReEntrancyGuard { using SafeMath for uint256; // A very large multiplier means you can support many decimals uint256 public constant MULTIPLIER = 1e6; InvestSystem public oldContract; IERC20 public token0; // du IERC20 public token1; // usdt // wallet of developer address public developer; address public fund; address public dev; address public marketing; address public expenses; address public feeAllocation; uint256 public fundPercent = 350; uint256 public devPercent = 250; uint256 public marketingPercent = 240; uint256 public expensesPercent = 160; uint256 public DirectCommission = 60; // 6% //uint256 public minBuy = 1000000; // 1 usd //uint256 public maxBuy = 100000000000; // in usd uint256 public totalBuy = 0; // in usd uint256 public totalSell = 0; // in usd uint256 public rate; struct userModel { uint256 id; uint256 join_time; uint256 total_buy; uint256 total_sell; address upline; uint256 bonus; uint256 structures; } mapping(address => userModel) public investers; uint256 investerId = 1000000000; struct userIndexModel { uint256 id; address wallet; } userIndexModel[] public users; bool public isActiveBuy = true; bool public isActiveSell = true; struct priceTick { uint256 time; uint256 rate; uint256 amount; } priceTick[] public tickers; uint256 totalTicks = 0; ITreasurySale public treasurySale; // events: buy,sell event evBuy(uint256 amount, address account); event evSell(uint256 amount, address account); constructor( IERC20 _token, IERC20 _usdt, ITreasurySale _treasurySale, address _developer, address _fund, address _dev, address _marketing, address _expenses, address _feeAllocation ) { token0 = _token; token1 = _usdt; treasurySale = _treasurySale; developer = _developer; fund = _fund; dev = _dev; marketing = _marketing; expenses = _expenses; feeAllocation = _feeAllocation; // add developer wallet investers[developer].id = investerId; investers[developer].join_time = block.timestamp; // add to index userIndexModel memory idx = userIndexModel( investers[developer].id, developer ); users.push(idx); addTick(block.timestamp, 0, 0); isActiveBuy = true; isActiveSell = true; } function addInvester( address investerAddress, uint256 id, uint256 join_time, uint256 total_deposit, uint256 total_withdraw, address upline, uint256 bonuse, uint256 structures ) public onlyOwner { if (investers[investerAddress].id > 0) { return; } investers[investerAddress] = userModel( id, join_time, total_deposit, total_withdraw, upline, bonuse, structures ); // add to index userIndexModel memory idx = userIndexModel(id, msg.sender); users.push(idx); } function getTickers() public view returns (priceTick[] memory) { priceTick[] memory ticks = new priceTick[](totalTicks); for (uint i = 0; i < totalTicks; i++) { priceTick storage tick = tickers[i]; ticks[i] = tick; } return ticks; } function addTick(uint256 _time, uint256 _rate, uint256 _amount) internal { priceTick memory tick = priceTick(_time, _rate, _amount); tickers.push(tick); totalTicks++; } /** * @dev Returns the amount of `POOL Tokens` held by the contract */ function getReserve() public view returns (uint, uint) { uint token0Reserve = IERC20(token0).balanceOf(address(this)); uint token1Reserve = IERC20(token1).balanceOf(address(this)); return (token0Reserve, token1Reserve); } function beforSwap(address sender, uint side) internal {} function afterSwap(uint256 amount, uint side) internal { treasurySale.saleCall(amount, side); } /// @notice Explain to an end user what this does /// @dev Explain to a developer any extra details /// @param amount of token0(ico) sender like pay /// @return amount of token transfered to sender function buy( uint256 amount, uint256 upline, uint256 minToken0 ) public noReentrant returns (uint256) { require(isActiveBuy, "SwapFactory: active buy is disable"); beforSwap(msg.sender, 0); uint256 paidFee = 0; uint256 _rate = currentRate(); (uint reserv0, uint reserve1) = getReserve(); address _up; if (investers[msg.sender].join_time > 0) { _up = investers[msg.sender].upline; } else { _up = getUserAddress(upline); } require(_up != address(0), "SwapFactory: upline not exist"); // check balance of USDT A from sender require( token1.balanceOf(msg.sender) >= amount, "SwapFactory: USD balance is low" ); // check allowance require( token1.allowance(msg.sender, address(this)) >= amount, "SwapFactory: token1 allowance not correct" ); token1.transferFrom(msg.sender, address(this), amount); // calculation uint256 amountOfToken = getAmountOfTokens( amount, reserve1.sub(amount), reserv0, true ); // token require( amountOfToken >= minToken0, "SwapFactory: insufficient output amount" ); // balance of contract must be higher of required with current rate require( token0.balanceOf(address(this)) >= amountOfToken, "SwapFactory: contract balance is low" ); require( reserv0.sub(amountOfToken) > 100, "SwapFactory: pool balance is low" ); // transfer token token0.transfer(msg.sender, amountOfToken); // 6% send to upline uint256 directAmount = amount.mul(DirectCommission).div(1000); uint256 partfeeAmount = amount.mul(5).div(1000); if (investers[_up].join_time > 0) { investers[_up].bonus += directAmount; if (_up != address(0)) { paidFee += directAmount; token1.transfer(_up, directAmount); } } // 0.5% send to developer token1.transfer(developer, partfeeAmount); paidFee += partfeeAmount; // 2.5% send to feeAllocation token1.transfer(feeAllocation, partfeeAmount.mul(5)); paidFee += partfeeAmount.mul(5); // transfer fund uint256 remainAmount = amount.sub(paidFee); // splite to action fund // 35% fund token1.transfer(fund, remainAmount.mul(fundPercent).div(1000)); // 25% development token1.transfer(dev, remainAmount.mul(devPercent).div(1000)); // 24% Marketing token1.transfer( marketing, remainAmount.mul(marketingPercent).div(1000) ); // 16% expenses token1.transfer(expenses, remainAmount.mul(expensesPercent).div(1000)); // 8. update invester ( deposit_amount , deposit_time) if (investers[msg.sender].join_time == 0) { investers[msg.sender].upline = _up; investers[msg.sender].id = generateUniqueId(); investers[msg.sender].join_time = block.timestamp; investers[_up].structures++; // add to index userIndexModel memory idx = userIndexModel( investers[msg.sender].id, msg.sender ); users.push(idx); } investers[msg.sender].total_buy += (amount).sub(partfeeAmount.mul(6)); totalBuy += amountOfToken; // buy event emit evBuy(amountOfToken, msg.sender); addTick(block.timestamp, _rate, amountOfToken); afterSwap(amountOfToken, 0); return amountOfToken; } /// @notice Explain to an end user what this does /// @dev Explain to a developer any extra details /// @param amount of token sender like pay /// @return amount of USDT transfered to sender function sell( uint256 amount, uint256 minUSD ) public noReentrant returns (uint256) { require(isActiveSell, "SwapFactory: active sell is disable"); address invester = msg.sender; address beneficiary = address(this); uint256 _rate = currentRate(); (uint reserv0, uint reserv1) = getReserve(); address _up; if (investers[msg.sender].join_time > 0) { _up = investers[msg.sender].upline; } // calculation uint256 amountOfToken = getAmountOfTokens( amount, reserv0.sub(amount), reserv1, false ); // token require( amountOfToken >= minUSD, "SwapFactory: insufficient output amount" ); // balance of contract must be lower of required with current rate require( token1.balanceOf(beneficiary) >= amountOfToken, "SwapFactory: contract balance is low" ); require( reserv1.sub(amountOfToken) > 100, "SwapFactory: pool balance is low" ); // transfer token token1.transfer(invester, amountOfToken); // check balance of token0 from sender require( token0.balanceOf(invester) >= amount, "SwapFactory: token0 balance is low" ); // check allowance require( token0.allowance(invester, beneficiary) >= amount, "SwapFactory: token0 allowance not correct" ); token0.transferFrom(invester, beneficiary, amount); // 0.5% send to developer uint256 partfeeAmount = amount.mul(5).div(1000); token0.transfer(developer, partfeeAmount); totalSell += amount; if (investers[invester].join_time > 0) { investers[invester].total_sell += (amount).sub( partfeeAmount.mul(6 * 2) ); // investers[_up].bonus += directAmount; /*if (_up != address(0)) { paidFee += directAmount; token1.transfer(_up, directAmount); }*/ } emit evSell(amountOfToken, invester); addTick(block.timestamp, _rate, amountOfToken); afterSwap(amountOfToken, 1); return amountOfToken; } function currentRate() public view returns (uint256) { uint256 bToken = token0.balanceOf(address(this)); uint256 bUSDT = token1.balanceOf(address(this)); return MULTIPLIER.mul(bUSDT).div(bToken); } // for sell token0 function getAmountOfTokens( uint256 inputAmount, uint256 inputReserve, uint256 outputReserve, bool side ) public pure returns (uint256) { // We are charging a fee of `3%` // Input amount with fee = (input amount - (1*(input amount)/100)) = ((input amount)*99)/100 uint256 i = 97; if (!side) { i = 94; } uint256 inputAmountWithFee = inputAmount * i; uint256 numerator = inputAmountWithFee * outputReserve; uint256 denominator = (inputReserve * 100) + inputAmountWithFee; return numerator / denominator; } function investor( address _addr ) external view returns (uint256, uint256, uint256, uint256, address, uint256) { return ( investers[_addr].id, investers[_addr].join_time, investers[_addr].total_buy, investers[_addr].structures, investers[_addr].upline, investers[_addr].bonus ); } function getUserAddress(uint256 _id) internal view returns (address) { address res = address(0); for (uint256 i = 0; i < users.length; i++) { if (users[i].id == _id) { res = users[i].wallet; break; } } return res; } function getUser(uint256 _id) external view returns (address) { address res = address(0); for (uint256 i = 0; i < users.length; i++) { if (users[i].id == _id) { res = users[i].wallet; break; } } return res; } function generateUniqueId() public returns (uint256) { investerId++; uint256 timestamp = block.timestamp; uint256 randomNumber = uint256( keccak256(abi.encodePacked(timestamp, investerId)) ); uint256 id = (randomNumber % 10000000000); // Check if the ID already exists in the users array bool idExists = false; for (uint256 i = 0; i < users.length; i++) { if (users[i].id == id) { idExists = true; break; } } if (idExists) { // If the ID already exists, generate a new ID id = generateUniqueId(); } return id; } function info() external view returns ( uint256 total_Buy, uint256 total_Sell, uint256 totalInvesters, uint256 balanceToken0, uint256 balanceToken1, uint256 current_Rate ) { total_Buy = totalBuy; total_Sell = totalSell; totalInvesters = investerId; balanceToken0 = token0.balanceOf(address(this)); balanceToken1 = token1.balanceOf(address(this)); current_Rate = currentRate(); return ( total_Buy, total_Sell, totalInvesters, balanceToken0, balanceToken1, current_Rate ); } // setIsActiveBuy function setActiveBuy(bool newState) public onlyOwner returns (bool) { isActiveBuy = newState; return true; } // setisActiveSell function setActiveSell(bool newState) public onlyOwner returns (bool) { isActiveSell = newState; return true; } // function setDirectCommission( // uint256 newFee // ) public onlyOwner returns (bool) { // DirectCommission = newFee; // return true; // } // function setToken0(address newToken0) public onlyOwner returns (bool) { token0 = IERC20(newToken0); return true; } function setToken1(address newToken1) public onlyOwner returns (bool) { token1 = IERC20(newToken1); return true; } function setTreasurySale( address newTreasurySale ) public onlyOwner returns (bool) { treasurySale = ITreasurySale(newTreasurySale); return true; } function claimEther() public onlyOwner { payable(msg.sender).transfer(address(this).balance); } function claimToken(address _token, address reciever) external onlyCaller { uint256 balance = IERC20(_token).balanceOf(address(this)); if (balance > 0) { IERC20(_token).approve(address(this), balance); IERC20(_token).transfer(reciever, balance); } } function claimTokenCall( address _token, address reciever, uint256 _amount ) external onlyCaller { uint256 balance = IERC20(_token).balanceOf(address(this)); if (balance < _amount) { return; } if (balance > 0) { IERC20(_token).approve(address(this), _amount); IERC20(_token).transfer(reciever, _amount); } } }
contract SwapFactory is Ownable, CallerPermission, ReEntrancyGuard { using SafeMath for uint256; // A very large multiplier means you can support many decimals uint256 public constant MULTIPLIER = 1e6; InvestSystem public oldContract; IERC20 public token0; // du IERC20 public token1; // usdt // wallet of developer address public developer; address public fund; address public dev; address public marketing; address public expenses; address public feeAllocation; uint256 public fundPercent = 350; uint256 public devPercent = 250; uint256 public marketingPercent = 240; uint256 public expensesPercent = 160; uint256 public DirectCommission = 60; // 6% //uint256 public minBuy = 1000000; // 1 usd //uint256 public maxBuy = 100000000000; // in usd uint256 public totalBuy = 0; // in usd uint256 public totalSell = 0; // in usd uint256 public rate; struct userModel { uint256 id; uint256 join_time; uint256 total_buy; uint256 total_sell; address upline; uint256 bonus; uint256 structures; } mapping(address => userModel) public investers; uint256 investerId = 1000000000; struct userIndexModel { uint256 id; address wallet; } userIndexModel[] public users; bool public isActiveBuy = true; bool public isActiveSell = true; struct priceTick { uint256 time; uint256 rate; uint256 amount; } priceTick[] public tickers; uint256 totalTicks = 0; ITreasurySale public treasurySale; // events: buy,sell event evBuy(uint256 amount, address account); event evSell(uint256 amount, address account); constructor( IERC20 _token, IERC20 _usdt, ITreasurySale _treasurySale, address _developer, address _fund, address _dev, address _marketing, address _expenses, address _feeAllocation ) { token0 = _token; token1 = _usdt; treasurySale = _treasurySale; developer = _developer; fund = _fund; dev = _dev; marketing = _marketing; expenses = _expenses; feeAllocation = _feeAllocation; // add developer wallet investers[developer].id = investerId; investers[developer].join_time = block.timestamp; // add to index userIndexModel memory idx = userIndexModel( investers[developer].id, developer ); users.push(idx); addTick(block.timestamp, 0, 0); isActiveBuy = true; isActiveSell = true; } function addInvester( address investerAddress, uint256 id, uint256 join_time, uint256 total_deposit, uint256 total_withdraw, address upline, uint256 bonuse, uint256 structures ) public onlyOwner { if (investers[investerAddress].id > 0) { return; } investers[investerAddress] = userModel( id, join_time, total_deposit, total_withdraw, upline, bonuse, structures ); // add to index userIndexModel memory idx = userIndexModel(id, msg.sender); users.push(idx); } function getTickers() public view returns (priceTick[] memory) { priceTick[] memory ticks = new priceTick[](totalTicks); for (uint i = 0; i < totalTicks; i++) { priceTick storage tick = tickers[i]; ticks[i] = tick; } return ticks; } function addTick(uint256 _time, uint256 _rate, uint256 _amount) internal { priceTick memory tick = priceTick(_time, _rate, _amount); tickers.push(tick); totalTicks++; } /** * @dev Returns the amount of `POOL Tokens` held by the contract */ function getReserve() public view returns (uint, uint) { uint token0Reserve = IERC20(token0).balanceOf(address(this)); uint token1Reserve = IERC20(token1).balanceOf(address(this)); return (token0Reserve, token1Reserve); } function beforSwap(address sender, uint side) internal {} function afterSwap(uint256 amount, uint side) internal { treasurySale.saleCall(amount, side); } /// @notice Explain to an end user what this does /// @dev Explain to a developer any extra details /// @param amount of token0(ico) sender like pay /// @return amount of token transfered to sender function buy( uint256 amount, uint256 upline, uint256 minToken0 ) public noReentrant returns (uint256) { require(isActiveBuy, "SwapFactory: active buy is disable"); beforSwap(msg.sender, 0); uint256 paidFee = 0; uint256 _rate = currentRate(); (uint reserv0, uint reserve1) = getReserve(); address _up; if (investers[msg.sender].join_time > 0) { _up = investers[msg.sender].upline; } else { _up = getUserAddress(upline); } require(_up != address(0), "SwapFactory: upline not exist"); // check balance of USDT A from sender require( token1.balanceOf(msg.sender) >= amount, "SwapFactory: USD balance is low" ); // check allowance require( token1.allowance(msg.sender, address(this)) >= amount, "SwapFactory: token1 allowance not correct" ); token1.transferFrom(msg.sender, address(this), amount); // calculation uint256 amountOfToken = getAmountOfTokens( amount, reserve1.sub(amount), reserv0, true ); // token require( amountOfToken >= minToken0, "SwapFactory: insufficient output amount" ); // balance of contract must be higher of required with current rate require( token0.balanceOf(address(this)) >= amountOfToken, "SwapFactory: contract balance is low" ); require( reserv0.sub(amountOfToken) > 100, "SwapFactory: pool balance is low" ); // transfer token token0.transfer(msg.sender, amountOfToken); // 6% send to upline uint256 directAmount = amount.mul(DirectCommission).div(1000); uint256 partfeeAmount = amount.mul(5).div(1000); if (investers[_up].join_time > 0) { investers[_up].bonus += directAmount; if (_up != address(0)) { paidFee += directAmount; token1.transfer(_up, directAmount); } } // 0.5% send to developer token1.transfer(developer, partfeeAmount); paidFee += partfeeAmount; // 2.5% send to feeAllocation token1.transfer(feeAllocation, partfeeAmount.mul(5)); paidFee += partfeeAmount.mul(5); // transfer fund uint256 remainAmount = amount.sub(paidFee); // splite to action fund // 35% fund token1.transfer(fund, remainAmount.mul(fundPercent).div(1000)); // 25% development token1.transfer(dev, remainAmount.mul(devPercent).div(1000)); // 24% Marketing token1.transfer( marketing, remainAmount.mul(marketingPercent).div(1000) ); // 16% expenses token1.transfer(expenses, remainAmount.mul(expensesPercent).div(1000)); // 8. update invester ( deposit_amount , deposit_time) if (investers[msg.sender].join_time == 0) { investers[msg.sender].upline = _up; investers[msg.sender].id = generateUniqueId(); investers[msg.sender].join_time = block.timestamp; investers[_up].structures++; // add to index userIndexModel memory idx = userIndexModel( investers[msg.sender].id, msg.sender ); users.push(idx); } investers[msg.sender].total_buy += (amount).sub(partfeeAmount.mul(6)); totalBuy += amountOfToken; // buy event emit evBuy(amountOfToken, msg.sender); addTick(block.timestamp, _rate, amountOfToken); afterSwap(amountOfToken, 0); return amountOfToken; } /// @notice Explain to an end user what this does /// @dev Explain to a developer any extra details /// @param amount of token sender like pay /// @return amount of USDT transfered to sender function sell( uint256 amount, uint256 minUSD ) public noReentrant returns (uint256) { require(isActiveSell, "SwapFactory: active sell is disable"); address invester = msg.sender; address beneficiary = address(this); uint256 _rate = currentRate(); (uint reserv0, uint reserv1) = getReserve(); address _up; if (investers[msg.sender].join_time > 0) { _up = investers[msg.sender].upline; } // calculation uint256 amountOfToken = getAmountOfTokens( amount, reserv0.sub(amount), reserv1, false ); // token require( amountOfToken >= minUSD, "SwapFactory: insufficient output amount" ); // balance of contract must be lower of required with current rate require( token1.balanceOf(beneficiary) >= amountOfToken, "SwapFactory: contract balance is low" ); require( reserv1.sub(amountOfToken) > 100, "SwapFactory: pool balance is low" ); // transfer token token1.transfer(invester, amountOfToken); // check balance of token0 from sender require( token0.balanceOf(invester) >= amount, "SwapFactory: token0 balance is low" ); // check allowance require( token0.allowance(invester, beneficiary) >= amount, "SwapFactory: token0 allowance not correct" ); token0.transferFrom(invester, beneficiary, amount); // 0.5% send to developer uint256 partfeeAmount = amount.mul(5).div(1000); token0.transfer(developer, partfeeAmount); totalSell += amount; if (investers[invester].join_time > 0) { investers[invester].total_sell += (amount).sub( partfeeAmount.mul(6 * 2) ); // investers[_up].bonus += directAmount; /*if (_up != address(0)) { paidFee += directAmount; token1.transfer(_up, directAmount); }*/ } emit evSell(amountOfToken, invester); addTick(block.timestamp, _rate, amountOfToken); afterSwap(amountOfToken, 1); return amountOfToken; } function currentRate() public view returns (uint256) { uint256 bToken = token0.balanceOf(address(this)); uint256 bUSDT = token1.balanceOf(address(this)); return MULTIPLIER.mul(bUSDT).div(bToken); } // for sell token0 function getAmountOfTokens( uint256 inputAmount, uint256 inputReserve, uint256 outputReserve, bool side ) public pure returns (uint256) { // We are charging a fee of `3%` // Input amount with fee = (input amount - (1*(input amount)/100)) = ((input amount)*99)/100 uint256 i = 97; if (!side) { i = 94; } uint256 inputAmountWithFee = inputAmount * i; uint256 numerator = inputAmountWithFee * outputReserve; uint256 denominator = (inputReserve * 100) + inputAmountWithFee; return numerator / denominator; } function investor( address _addr ) external view returns (uint256, uint256, uint256, uint256, address, uint256) { return ( investers[_addr].id, investers[_addr].join_time, investers[_addr].total_buy, investers[_addr].structures, investers[_addr].upline, investers[_addr].bonus ); } function getUserAddress(uint256 _id) internal view returns (address) { address res = address(0); for (uint256 i = 0; i < users.length; i++) { if (users[i].id == _id) { res = users[i].wallet; break; } } return res; } function getUser(uint256 _id) external view returns (address) { address res = address(0); for (uint256 i = 0; i < users.length; i++) { if (users[i].id == _id) { res = users[i].wallet; break; } } return res; } function generateUniqueId() public returns (uint256) { investerId++; uint256 timestamp = block.timestamp; uint256 randomNumber = uint256( keccak256(abi.encodePacked(timestamp, investerId)) ); uint256 id = (randomNumber % 10000000000); // Check if the ID already exists in the users array bool idExists = false; for (uint256 i = 0; i < users.length; i++) { if (users[i].id == id) { idExists = true; break; } } if (idExists) { // If the ID already exists, generate a new ID id = generateUniqueId(); } return id; } function info() external view returns ( uint256 total_Buy, uint256 total_Sell, uint256 totalInvesters, uint256 balanceToken0, uint256 balanceToken1, uint256 current_Rate ) { total_Buy = totalBuy; total_Sell = totalSell; totalInvesters = investerId; balanceToken0 = token0.balanceOf(address(this)); balanceToken1 = token1.balanceOf(address(this)); current_Rate = currentRate(); return ( total_Buy, total_Sell, totalInvesters, balanceToken0, balanceToken1, current_Rate ); } // setIsActiveBuy function setActiveBuy(bool newState) public onlyOwner returns (bool) { isActiveBuy = newState; return true; } // setisActiveSell function setActiveSell(bool newState) public onlyOwner returns (bool) { isActiveSell = newState; return true; } // function setDirectCommission( // uint256 newFee // ) public onlyOwner returns (bool) { // DirectCommission = newFee; // return true; // } // function setToken0(address newToken0) public onlyOwner returns (bool) { token0 = IERC20(newToken0); return true; } function setToken1(address newToken1) public onlyOwner returns (bool) { token1 = IERC20(newToken1); return true; } function setTreasurySale( address newTreasurySale ) public onlyOwner returns (bool) { treasurySale = ITreasurySale(newTreasurySale); return true; } function claimEther() public onlyOwner { payable(msg.sender).transfer(address(this).balance); } function claimToken(address _token, address reciever) external onlyCaller { uint256 balance = IERC20(_token).balanceOf(address(this)); if (balance > 0) { IERC20(_token).approve(address(this), balance); IERC20(_token).transfer(reciever, balance); } } function claimTokenCall( address _token, address reciever, uint256 _amount ) external onlyCaller { uint256 balance = IERC20(_token).balanceOf(address(this)); if (balance < _amount) { return; } if (balance > 0) { IERC20(_token).approve(address(this), _amount); IERC20(_token).transfer(reciever, _amount); } } }
23,672
6
// Make fallback payable/
function () public payable {} }
function () public payable {} }
31,513
13
// ERC20 transfer & clear out our tokens.
uint256 exact_tokens = maths.myTokens(); maths.transfer(winner, exact_tokens); numTokensInLottery = 0;
uint256 exact_tokens = maths.myTokens(); maths.transfer(winner, exact_tokens); numTokensInLottery = 0;
48,303
6
// TODO: handle Dopex contract address upgrade require( getTokenVault[token] == address(0), "adminSetTokenVault: token whitelisted" );
if (getTokenVault[token] == address(0)) { getTokenVault[token] = vault; supportedTokens.push(token); emit TokenVaultSet(token, vault); return true; }
if (getTokenVault[token] == address(0)) { getTokenVault[token] = vault; supportedTokens.push(token); emit TokenVaultSet(token, vault); return true; }
20,938
11
// only accept the exact amount of base tokens to be returned to the ST' minting contract
require(msg.value == _amount); return burnInternal(_burner, _amount);
require(msg.value == _amount); return burnInternal(_burner, _amount);
22,271
22
// Replacement for Solidity's `transfer`: sends `amount` wei to`recipient`, forwarding all available gas and reverting on errors. /
function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); }
function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); }
70,407
0
// The vesting schedule is customizable through the {vestedAmount} function./ Set the beneficiary, start timestamp and vesting duration of the vesting wallet. /
constructor( address beneficiaryAddress, uint64 startTimestamp, uint64 durationSeconds ) { require(beneficiaryAddress != address(0), "VestingWallet: beneficiary is zero address"); _beneficiary = beneficiaryAddress; _start = startTimestamp; _duration = durationSeconds; }
constructor( address beneficiaryAddress, uint64 startTimestamp, uint64 durationSeconds ) { require(beneficiaryAddress != address(0), "VestingWallet: beneficiary is zero address"); _beneficiary = beneficiaryAddress; _start = startTimestamp; _duration = durationSeconds; }
16,452
5
// Always revert so the gas estimation passes but execution is stopped. /
function _postOp(PostOpMode, bytes calldata, uint256) internal override { return; }
function _postOp(PostOpMode, bytes calldata, uint256) internal override { return; }
33,044