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
|
---|---|---|---|---|
14 | // Internal Out Of Gas/Throw: revert this transaction too; Call Stack Depth Limit reached: revert this transaction too; Recursive Call: safe, no any changes applied yet, we are inside of modifier. | _safeSend(msg.sender, msg.value);
| _safeSend(msg.sender, msg.value);
| 56,994 |
256 | // Set whether an account can open/close streams. Only callable by the current gov contract account The account to set permissions for. _isSubGov Whether or not this account can manage streams / | function setSubGov(address account, bool _isSubGov)
public
onlyGov
| function setSubGov(address account, bool _isSubGov)
public
onlyGov
| 87,511 |
81 | // 24 hours rewards halving | uint256 public _poolHalvingIntervalMinutes = 1440;
uint256 public _poolRewardDistributionIntervalMinutes = 5;
| uint256 public _poolHalvingIntervalMinutes = 1440;
uint256 public _poolRewardDistributionIntervalMinutes = 5;
| 71,289 |
155 | // 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 uint256 ID of the token to be added to the tokens list of the given address / | function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
| function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
| 39,231 |
0 | // VARIABLES / | enum State {
PRIVATE,
PUBLIC
}
| enum State {
PRIVATE,
PUBLIC
}
| 40,357 |
378 | // Proposed whitelist | address[] public proposedWhitelist;
| address[] public proposedWhitelist;
| 29,468 |
87 | // swap tokens to eth | function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
| function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
| 25,685 |
26 | // Donate to the developer! | function developerDonate() external payable {
payable(DEV_DONATE).transfer(msg.value);
}
| function developerDonate() external payable {
payable(DEV_DONATE).transfer(msg.value);
}
| 15,784 |
52 | // Burns veto priviledges Vetoer function destroying veto power forever / | function _burnVetoPower() public {
// Check caller is pendingAdmin and pendingAdmin ≠ address(0)
require(msg.sender == vetoer, 'NounsDAO::_burnVetoPower: vetoer only');
_setVetoer(address(0));
}
| function _burnVetoPower() public {
// Check caller is pendingAdmin and pendingAdmin ≠ address(0)
require(msg.sender == vetoer, 'NounsDAO::_burnVetoPower: vetoer only');
_setVetoer(address(0));
}
| 9,375 |
217 | // calculate vested portion of reward pool | uint256 unlockedRewards =
calculateUnlockedRewards(
_aludel.rewardSchedules,
remainingRewards,
_aludel.rewardSharesOutstanding,
block.timestamp
);
| uint256 unlockedRewards =
calculateUnlockedRewards(
_aludel.rewardSchedules,
remainingRewards,
_aludel.rewardSharesOutstanding,
block.timestamp
);
| 12,130 |
119 | // =================================================================================================================Constants ================================================================================================================= Max amount of known addresses of which will get SRN by 'Grant' method. grantees addresses will be SirinLabs wallets addresses. these wallets will contain SRN tokens that will be used for 2 purposes only - 1. SRN tokens against raised fiat money 2. SRN tokens for presale bonus. we set the value to 10 (and not to 2) because we want to allow some flexibility for cases like fiat money that is raised close to the crowdsale. we limit the value to 10 (and not larger) to limit the run time of the function that process the grantees | uint8 public constant MAX_TOKEN_GRANTEES = 10;
| uint8 public constant MAX_TOKEN_GRANTEES = 10;
| 29,224 |
236 | // Validates a swap of borrow rate mode. reserve The reserve state on which the user is swapping the rate userConfig The user reserves configuration stableDebt The stable debt of the user variableDebt The variable debt of the user currentRateMode The rate mode of the borrow / | function validateSwapRateMode(
DataTypes.ReserveData storage reserve,
DataTypes.UserConfigurationMap storage userConfig,
uint256 stableDebt,
uint256 variableDebt,
DataTypes.InterestRateMode currentRateMode
| function validateSwapRateMode(
DataTypes.ReserveData storage reserve,
DataTypes.UserConfigurationMap storage userConfig,
uint256 stableDebt,
uint256 variableDebt,
DataTypes.InterestRateMode currentRateMode
| 53,307 |
27 | // allows dev to set mapping contract for valueFor (EIP2362) _addy address of mapping contract / | function setIdMappingContract(address _addy) external{
require(address(idMappingContract) == address(0));
idMappingContract = IMappingContract(_addy);
}
| function setIdMappingContract(address _addy) external{
require(address(idMappingContract) == address(0));
idMappingContract = IMappingContract(_addy);
}
| 31,704 |
111 | // ADMIN //enables owner to pause / unpause contract / | function setPaused(bool _paused) external requireContractsSet onlyOwner {
if (_paused) _pause();
else _unpause();
}
| function setPaused(bool _paused) external requireContractsSet onlyOwner {
if (_paused) _pause();
else _unpause();
}
| 65,520 |
0 | // solidly contracts | IVotingEscrow public votingEscrow;
IBaseV1Voter public solidlyVoter;
| IVotingEscrow public votingEscrow;
IBaseV1Voter public solidlyVoter;
| 36,898 |
30 | // Overrides the `tokenURI()` function from ERC721A to return just the base URI if it is implied to not be a directory.This is to help with ERC721 contracts in which the same token URI is desired for each token, such as when the tokenURI is 'unrevealed'. / | function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
| function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
| 20,338 |
515 | // invariantD = invariantD^(n+1) A = amplification coefficientAn^n S + D = A D n^n + -----------S = sum of balances n^n PP = product of balancesn = number of tokensx/ We support rounding up or down. |
uint256 sum = 0;
uint256 numTokens = balances.length;
for (uint256 i = 0; i < numTokens; i++) {
sum = sum.add(balances[i]);
}
|
uint256 sum = 0;
uint256 numTokens = balances.length;
for (uint256 i = 0; i < numTokens; i++) {
sum = sum.add(balances[i]);
}
| 5,800 |
153 | // ------------------------------------------------------------------------ Get the total owed for an entire api for all nonzero buyers ------------------------------------------------------------------------ | function totalOwedForApi(uint apiId) public view returns (uint) {
APIBalance storage apiBalance = owed[apiId];
uint totalOwed = 0;
for (uint i = 0; i < apiBalance.nonzeroAddresses.length; i++) {
address buyerAddress = apiBalance.nonzeroAddresses[i];
uint buyerOwes = apiBalance.amounts[buyerAddress];
totalOwed = totalOwed.add(buyerOwes);
}
return totalOwed;
}
| function totalOwedForApi(uint apiId) public view returns (uint) {
APIBalance storage apiBalance = owed[apiId];
uint totalOwed = 0;
for (uint i = 0; i < apiBalance.nonzeroAddresses.length; i++) {
address buyerAddress = apiBalance.nonzeroAddresses[i];
uint buyerOwes = apiBalance.amounts[buyerAddress];
totalOwed = totalOwed.add(buyerOwes);
}
return totalOwed;
}
| 1,929 |
15 | // For auto liquidity, liquidate half tokens and put in the remaining ones for liquidity. | uint autoLiquidityTokens = tokensForLiquidation * ((transferFees.buyAutoLiquidity + transferFees.sellAutoLiquidity)) / (transferFees.buyTotal + transferFees.sellTotal);
uint autoLiquidityTokensToLiquidate = autoLiquidityTokens / 2;
| uint autoLiquidityTokens = tokensForLiquidation * ((transferFees.buyAutoLiquidity + transferFees.sellAutoLiquidity)) / (transferFees.buyTotal + transferFees.sellTotal);
uint autoLiquidityTokensToLiquidate = autoLiquidityTokens / 2;
| 22,502 |
157 | // Send any remaining balance to the foundation wallet / | function empty() returns (bool) {
return foundationWallet.call.value(this.balance)();
}
| function empty() returns (bool) {
return foundationWallet.call.value(this.balance)();
}
| 37,411 |
116 | // If not burned. | if (packed & _BITMASK_BURNED == 0) {
| if (packed & _BITMASK_BURNED == 0) {
| 11,036 |
3,812 | // 1907 | entry "nonmatured" : ENG_ADJECTIVE
| entry "nonmatured" : ENG_ADJECTIVE
| 18,519 |
27 | // Emitted when the connected Ante Test's invariant gets verified/checker The address of challenger who called the verification | event TestChecked(address indexed checker);
| event TestChecked(address indexed checker);
| 8,595 |
49 | // Step 4. of IETF draft section 5.3 (pk corresponds to Y, seed to alpha_string) | uint256[2] memory hash = hashToCurve(pk, seed);
| uint256[2] memory hash = hashToCurve(pk, seed);
| 30,392 |
106 | // There are two caveats with this computation: 1. Max value for the number dividend `a` represents is ~10^41, otherwise an intermediate value overflows. 10^41 is stored internally as an int256 10^59. 2. Results that can't be represented exactly are truncated not rounded. E.g., 2 / 3 = 0.6 repeating, which would round to 0.666666666666666667, but this computation produces the result 0.666666666666666666. | return Signed(a.rawValue.mul(SFP_SCALING_FACTOR).div(b.rawValue));
| return Signed(a.rawValue.mul(SFP_SCALING_FACTOR).div(b.rawValue));
| 26,862 |
26 | // Throws if called by any account other than the owner. / | modifier onlyFabric() {
require(fabrics[msg.sender].isActive);
_;
}
| modifier onlyFabric() {
require(fabrics[msg.sender].isActive);
_;
}
| 22,589 |
23 | // Emit the appropriate event | emit Harvested(_upc);
| emit Harvested(_upc);
| 43,297 |
49 | // 0x500 = compressed note coordinate gamma | mstore(
0x500,
or(
mload(0x20),
mul(
and(mload(0x40), 0x01),
0x8000000000000000000000000000000000000000000000000000000000000000
)
)
)
| mstore(
0x500,
or(
mload(0x20),
mul(
and(mload(0x40), 0x01),
0x8000000000000000000000000000000000000000000000000000000000000000
)
)
)
| 29,438 |
39 | // If opponent has supply | if (op.totalSupply() > 0) {
| if (op.totalSupply() > 0) {
| 35,767 |
14 | // user is already on the leaderboard, remove them first | removeFromLeaderboard(_user, _market, _card);
| removeFromLeaderboard(_user, _market, _card);
| 28,327 |
45 | // Disable the renounceOwnership function | function renounceOwnership() public view override onlyOwner {
revert("Disabled!");
}
| function renounceOwnership() public view override onlyOwner {
revert("Disabled!");
}
| 56,159 |
10 | // increases liquidity by token amounts desired/ return liquidity new liquidity amount | function _uniSupply(Params memory _uniData)
internal
returns (
uint128 liquidity,
uint256 amount0,
uint256 amount1
)
| function _uniSupply(Params memory _uniData)
internal
returns (
uint128 liquidity,
uint256 amount0,
uint256 amount1
)
| 22,838 |
0 | // Mined address | address addr;
| address addr;
| 35,480 |
0 | // RLP encoding library | RLPEncode rlp;
| RLPEncode rlp;
| 624 |
5 | // ElasticSupplyERC20 Token ERC20 with an elastic supplyCyril Lapinte - <[email protected]>SPDX-License-Identifier: MIT Error messagesES01: Elasticity cannot be 0ES02: Address is invalidES03: Approval too lowES04: Not enougth tokens/ | contract ElasticSupplyERC20 is IElasticSupplyERC20, Ownable, MintableTokenERC20 {
uint256 internal constant ELASTICITY_PRECISION = 10**9;
uint256 internal elasticity_ = ELASTICITY_PRECISION;
constructor(
string memory _name,
string memory _symbol,
uint256 _decimals,
address _initialAccount,
uint256 _initialSupply
) MintableTokenERC20(_name, _symbol, _decimals, _initialAccount, _initialSupply)
{}
function totalSupply() external override view returns (uint256) {
return totalSupply_ * elasticity() / ELASTICITY_PRECISION;
}
function balanceOf(address _owner) external override view returns (uint256) {
return balances[_owner] * elasticity() / ELASTICITY_PRECISION;
}
function elasticity() public override virtual view returns (uint256) {
return elasticity_;
}
function defineElasticity(uint256 _elasticity) external override onlyOwner returns (bool) {
require(_elasticity / ELASTICITY_PRECISION != 0, "ES01");
elasticity_ = _elasticity;
emit ElasticityUpdate(_elasticity);
return true;
}
function transferFromInternal(address _from, address _to, uint256 _value)
internal override virtual returns (bool)
{
require(_to != address(0), "ES02");
if(_from != msg.sender) {
require(_from == msg.sender || _value <= allowed[_from][msg.sender], "ES03");
allowed[_from][msg.sender] = allowed[_from][msg.sender] - _value;
}
uint256 currentElasticity = elasticity();
uint256 baseValue = _value * ELASTICITY_PRECISION / currentElasticity;
require(baseValue <= balances[_from], "ES04");
balances[_from] = balances[_from] - baseValue;
balances[_to] = balances[_to] + baseValue;
emit Transfer(_from, _to, _value);
return true;
}
}
| contract ElasticSupplyERC20 is IElasticSupplyERC20, Ownable, MintableTokenERC20 {
uint256 internal constant ELASTICITY_PRECISION = 10**9;
uint256 internal elasticity_ = ELASTICITY_PRECISION;
constructor(
string memory _name,
string memory _symbol,
uint256 _decimals,
address _initialAccount,
uint256 _initialSupply
) MintableTokenERC20(_name, _symbol, _decimals, _initialAccount, _initialSupply)
{}
function totalSupply() external override view returns (uint256) {
return totalSupply_ * elasticity() / ELASTICITY_PRECISION;
}
function balanceOf(address _owner) external override view returns (uint256) {
return balances[_owner] * elasticity() / ELASTICITY_PRECISION;
}
function elasticity() public override virtual view returns (uint256) {
return elasticity_;
}
function defineElasticity(uint256 _elasticity) external override onlyOwner returns (bool) {
require(_elasticity / ELASTICITY_PRECISION != 0, "ES01");
elasticity_ = _elasticity;
emit ElasticityUpdate(_elasticity);
return true;
}
function transferFromInternal(address _from, address _to, uint256 _value)
internal override virtual returns (bool)
{
require(_to != address(0), "ES02");
if(_from != msg.sender) {
require(_from == msg.sender || _value <= allowed[_from][msg.sender], "ES03");
allowed[_from][msg.sender] = allowed[_from][msg.sender] - _value;
}
uint256 currentElasticity = elasticity();
uint256 baseValue = _value * ELASTICITY_PRECISION / currentElasticity;
require(baseValue <= balances[_from], "ES04");
balances[_from] = balances[_from] - baseValue;
balances[_to] = balances[_to] + baseValue;
emit Transfer(_from, _to, _value);
return true;
}
}
| 52,182 |
10 | // change pass price | function setPassPrice(uint256 price) public onlyOwner {
passPrice = price;
}
| function setPassPrice(uint256 price) public onlyOwner {
passPrice = price;
}
| 19,795 |
10 | // requires that the token does not already exist. | require(!_exists(tokenId), "token already minted!");
| require(!_exists(tokenId), "token already minted!");
| 47,164 |
22 | // In this event we are returning underlyiing() which can be used to compute the actual interest generated. | emit Rebased(_oldIndex, _newIndex, _underlying.div(WAD));
| emit Rebased(_oldIndex, _newIndex, _underlying.div(WAD));
| 61,319 |
139 | // Burn the tokens. | _burn(msg.sender, backstopTokenAmount);
| _burn(msg.sender, backstopTokenAmount);
| 49,008 |
98 | // Changes unirouter factory address / | function changeUniRouter(address _router) external onlyAdmin {
require(_router != address(0), "Router address cannot be 0");
uniRouter = _router;
}
| function changeUniRouter(address _router) external onlyAdmin {
require(_router != address(0), "Router address cannot be 0");
uniRouter = _router;
}
| 43,991 |
48 | // set the 721 contract address | function set721ContractAddress(WildNFT _nft) public onlyAdmin {
nft = _nft;
}
| function set721ContractAddress(WildNFT _nft) public onlyAdmin {
nft = _nft;
}
| 1,952 |
399 | // In case win. | goldRewardGiven = goldReward;
expRewardGiven = expReward;
| goldRewardGiven = goldReward;
expRewardGiven = expReward;
| 42,712 |
383 | // Active loan that has entered a new period, so return the next newNextDueTime. But never return something after the termEndTime | if (balance > 0 && curTimestamp >= newNextDueTime) {
uint256 secondsToAdvance = (curTimestamp.sub(newNextDueTime).div(secondsPerPeriod)).add(1).mul(secondsPerPeriod);
newNextDueTime = newNextDueTime.add(secondsToAdvance);
return Math.min(newNextDueTime, termEndTime);
}
| if (balance > 0 && curTimestamp >= newNextDueTime) {
uint256 secondsToAdvance = (curTimestamp.sub(newNextDueTime).div(secondsPerPeriod)).add(1).mul(secondsPerPeriod);
newNextDueTime = newNextDueTime.add(secondsToAdvance);
return Math.min(newNextDueTime, termEndTime);
}
| 61,897 |
4 | // Enables a trusted router contract to override the usual msg.sender address. HardlyDifficult / | abstract contract RouterContext is Context {
using AddressUpgradeable for address;
address private immutable approvedRouter;
constructor(address router) {
if (!router.isContract()) {
revert RouterContext_Not_A_Contract();
}
approvedRouter = router;
}
/**
* @notice Returns the router contract which is able to override the msg.sender address.
* @return router The address of the trusted router.
*/
function getApprovedRouterAddress() external view returns (address router) {
router = approvedRouter;
}
/**
* @notice Returns the sender of the transaction.
* @dev If the msg.sender is the trusted router contract, then the last 20 bytes of the calldata is the authorized
* sender.
*/
function _msgSender() internal view virtual override returns (address sender) {
sender = super._msgSender();
if (sender == approvedRouter) {
assembly {
// The router appends the msg.sender to the end of the calldata
// source: https://github.com/opengsn/gsn/blob/v3.0.0-beta.3/packages/contracts/src/ERC2771Recipient.sol#L48
sender := shr(96, calldataload(sub(calldatasize(), 20)))
}
}
}
}
| abstract contract RouterContext is Context {
using AddressUpgradeable for address;
address private immutable approvedRouter;
constructor(address router) {
if (!router.isContract()) {
revert RouterContext_Not_A_Contract();
}
approvedRouter = router;
}
/**
* @notice Returns the router contract which is able to override the msg.sender address.
* @return router The address of the trusted router.
*/
function getApprovedRouterAddress() external view returns (address router) {
router = approvedRouter;
}
/**
* @notice Returns the sender of the transaction.
* @dev If the msg.sender is the trusted router contract, then the last 20 bytes of the calldata is the authorized
* sender.
*/
function _msgSender() internal view virtual override returns (address sender) {
sender = super._msgSender();
if (sender == approvedRouter) {
assembly {
// The router appends the msg.sender to the end of the calldata
// source: https://github.com/opengsn/gsn/blob/v3.0.0-beta.3/packages/contracts/src/ERC2771Recipient.sol#L48
sender := shr(96, calldataload(sub(calldatasize(), 20)))
}
}
}
}
| 20,125 |
27 | // fired when `holder` transitions `originalAsset` to `newAsset` | event Transitioned(
address holder,
address originalAsset,
address newAsset,
uint256[] tokenIds
);
mapping(address => address) public transitionMap;
| event Transitioned(
address holder,
address originalAsset,
address newAsset,
uint256[] tokenIds
);
mapping(address => address) public transitionMap;
| 46,358 |
509 | // Determines whether the pool should rebalance given the provided balances / | function shouldRebalance(uint256 cash, uint256 managed) external view returns (bool);
| function shouldRebalance(uint256 cash, uint256 managed) external view returns (bool);
| 53,552 |
11 | // transfer from l1: tokenSupplyOnL1 -= amount totalSupllyOnL2 += amount globalSupply stay unchanged | tokenSupplyOnL1 = tokenSupplyOnL1.sub(amount);
_mint(account, amount);
emit BridgeMint(account, amount);
| tokenSupplyOnL1 = tokenSupplyOnL1.sub(amount);
_mint(account, amount);
emit BridgeMint(account, amount);
| 14,830 |
164 | // Safe xeti transfer function, just in case if rounding error causes pool to not have enough XETIs. | function safeXetiTransfer(address _to, uint256 _amount) internal {
uint256 xetiBal = xeti.balanceOf(address(this));
if (_amount > xetiBal) {
xeti.transfer(_to, xetiBal);
} else {
xeti.transfer(_to, _amount);
}
}
| function safeXetiTransfer(address _to, uint256 _amount) internal {
uint256 xetiBal = xeti.balanceOf(address(this));
if (_amount > xetiBal) {
xeti.transfer(_to, xetiBal);
} else {
xeti.transfer(_to, _amount);
}
}
| 17,918 |
91 | // Returns whether the specified token exists. tokenId uint256 ID of the token to query the existence ofreturn bool whether the token exists / | function _exists(uint256 tokenId) internal view returns (bool) {
address owner = _tokenOwner[tokenId];
return owner != address(0);
}
| function _exists(uint256 tokenId) internal view returns (bool) {
address owner = _tokenOwner[tokenId];
return owner != address(0);
}
| 7,873 |
279 | // Reward committer | incentivize(msg.sender, Constants.getAdvanceIncentive());
| incentivize(msg.sender, Constants.getAdvanceIncentive());
| 47,736 |
168 | // Disburse liquidity stake attacks | function disburseLiqStakeAttacks(address[] memory liquidatedAccounts)
external
| function disburseLiqStakeAttacks(address[] memory liquidatedAccounts)
external
| 74,206 |
18 | // PUBLIC FUNCTIONS / | function mint(uint256 _amount) public payable nonReentrant {
require(
block.timestamp > publicStart && isPublicLive == true,
"Public mint not open yet"
);
uint256 total = totalSupply();
require(total + _amount <= MAX_ELEMENTS, "Sold Out!");
require(msg.value >= price(_amount), "Value below price");
_mintAmount(_amount, msg.sender);
}
| function mint(uint256 _amount) public payable nonReentrant {
require(
block.timestamp > publicStart && isPublicLive == true,
"Public mint not open yet"
);
uint256 total = totalSupply();
require(total + _amount <= MAX_ELEMENTS, "Sold Out!");
require(msg.value >= price(_amount), "Value below price");
_mintAmount(_amount, msg.sender);
}
| 10,069 |
159 | // Update the fee percentage. | feePercent = newFeePercent;
emit FeePercentUpdated(msg.sender, newFeePercent);
| feePercent = newFeePercent;
emit FeePercentUpdated(msg.sender, newFeePercent);
| 55,401 |
182 | // Returns whether the specified token is minted _id uint256 ID of the token to query the existence ofreturn bool whether the token exists / | function exists(uint256 _id) public view returns (bool) {
return _supply[_id] > 0;
}
| function exists(uint256 _id) public view returns (bool) {
return _supply[_id] > 0;
}
| 12,155 |
152 | // should mint 00001, 00002 | _mintHero(1);
_safeMint(OWNER1_ADDRESS, 1);
_mintHero(2);
_safeMint(OWNER1_ADDRESS, 2);
| _mintHero(1);
_safeMint(OWNER1_ADDRESS, 1);
_mintHero(2);
_safeMint(OWNER1_ADDRESS, 2);
| 58,284 |
225 | // Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in | * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* _Available since v3.4._
*/
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping(address => Counters.Counter) private _nonces;
// solhint-disable-next-line var-name-mixedcase
bytes32 private constant _PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
/**
* @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
* However, to ensure consistency with the upgradeable transpiler, we will continue
* to reserve a slot.
* @custom:oz-renamed-from _PERMIT_TYPEHASH
*/
// solhint-disable-next-line var-name-mixedcase
bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;
/**
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
*
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
*/
constructor(string memory name) EIP712(name, "1") {}
/**
* @dev See {IERC20Permit-permit}.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, v, r, s);
require(signer == owner, "ERC20Permit: invalid signature");
_approve(owner, spender, value);
}
/**
* @dev See {IERC20Permit-nonces}.
*/
function nonces(address owner) public view virtual override returns (uint256) {
return _nonces[owner].current();
}
/**
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
}
/**
* @dev "Consume a nonce": return the current value and increment.
*
* _Available since v4.1._
*/
function _useNonce(address owner) internal virtual returns (uint256 current) {
Counters.Counter storage nonce = _nonces[owner];
current = nonce.current();
nonce.increment();
}
}
| * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* _Available since v3.4._
*/
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping(address => Counters.Counter) private _nonces;
// solhint-disable-next-line var-name-mixedcase
bytes32 private constant _PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
/**
* @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
* However, to ensure consistency with the upgradeable transpiler, we will continue
* to reserve a slot.
* @custom:oz-renamed-from _PERMIT_TYPEHASH
*/
// solhint-disable-next-line var-name-mixedcase
bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;
/**
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
*
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
*/
constructor(string memory name) EIP712(name, "1") {}
/**
* @dev See {IERC20Permit-permit}.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, v, r, s);
require(signer == owner, "ERC20Permit: invalid signature");
_approve(owner, spender, value);
}
/**
* @dev See {IERC20Permit-nonces}.
*/
function nonces(address owner) public view virtual override returns (uint256) {
return _nonces[owner].current();
}
/**
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
}
/**
* @dev "Consume a nonce": return the current value and increment.
*
* _Available since v4.1._
*/
function _useNonce(address owner) internal virtual returns (uint256 current) {
Counters.Counter storage nonce = _nonces[owner];
current = nonce.current();
nonce.increment();
}
}
| 36,281 |
36 | // make sure that the seller still has that amount to sell | require(getBalance(contractAddress, seller) >= amount);
| require(getBalance(contractAddress, seller) >= amount);
| 48,359 |
0 | // uint public patientCount; | mapping(address => Patient) public patients;
| mapping(address => Patient) public patients;
| 9,339 |
172 | // Abstract function that must be implemented.Calculate the minimumBid allowed for the rebalance._auctionAuction object _currentSet The Set to rebalance from _nextSetThe Set to rebalance toreturnMinimum bid amount / | function calculateMinimumBid(
Setup storage _auction,
ISetToken _currentSet,
ISetToken _nextSet
)
internal
view
returns (uint256);
| function calculateMinimumBid(
Setup storage _auction,
ISetToken _currentSet,
ISetToken _nextSet
)
internal
view
returns (uint256);
| 39,544 |
6 | // Determines how BNB is stored/forwarded on purchases. / | function _forwardFunds() internal {
wallet.transfer(msg.value);
}
| function _forwardFunds() internal {
wallet.transfer(msg.value);
}
| 14,382 |
115 | // 투자자의 자산을 업데이트한다 | fundersProperty[_beneficiary].reservedFunds += amountFunds;
fundersProperty[_beneficiary].reservedApis += reservedApis;
fundersProperty[_beneficiary].purchaseTime = now;
| fundersProperty[_beneficiary].reservedFunds += amountFunds;
fundersProperty[_beneficiary].reservedApis += reservedApis;
fundersProperty[_beneficiary].purchaseTime = now;
| 49,884 |
230 | // Get currently used protocol tokens (cDAI, aDAI, ...) return : array of protocol tokens supported/ | function getAllAvailableTokens() external view returns (address[] memory) {
return allAvailableTokens;
}
| function getAllAvailableTokens() external view returns (address[] memory) {
return allAvailableTokens;
}
| 19,623 |
3 | // Minimum and Maximun fee deductible for swaps | uint256 public minFee;
uint256 public maxFee;
| uint256 public minFee;
uint256 public maxFee;
| 29,536 |
224 | // Get all market reward speed info. cTokens The market addressesreturn The list of reward speed info / | function getAllMarketRewardSpeeds(address[] memory cTokens) public view returns (MarketRewardSpeed[] memory) {
MarketRewardSpeed[] memory allRewardSpeeds = new MarketRewardSpeed[](cTokens.length);
for (uint i = 0; i < cTokens.length; i++) {
allRewardSpeeds[i] = getMarketRewardSpeeds(cTokens[i]);
}
return allRewardSpeeds;
}
| function getAllMarketRewardSpeeds(address[] memory cTokens) public view returns (MarketRewardSpeed[] memory) {
MarketRewardSpeed[] memory allRewardSpeeds = new MarketRewardSpeed[](cTokens.length);
for (uint i = 0; i < cTokens.length; i++) {
allRewardSpeeds[i] = getMarketRewardSpeeds(cTokens[i]);
}
return allRewardSpeeds;
}
| 28,930 |
26 | // Send rewards to the winners. / | function verdict(uint256 random) public payable onlyVFRC {
//check bets from latest betting round, one by one
for(uint256 i=lastGameId; i<gameId; i++){
//reset winAmount for current user
uint256 winAmount = 0;
//if user wins, then receives 2x of their betting amount
if((random>=half && games[i].bet==1) || (random<half && games[i].bet==0)){
winAmount = games[i].amount*2;
games[i].player.transfer(winAmount);
}
emit Result(games[i].id, games[i].bet, games[i].amount, games[i].player, winAmount, random, block.timestamp);
}
//save current gameId to lastGameId for the next betting round
lastGameId = gameId;
}
| function verdict(uint256 random) public payable onlyVFRC {
//check bets from latest betting round, one by one
for(uint256 i=lastGameId; i<gameId; i++){
//reset winAmount for current user
uint256 winAmount = 0;
//if user wins, then receives 2x of their betting amount
if((random>=half && games[i].bet==1) || (random<half && games[i].bet==0)){
winAmount = games[i].amount*2;
games[i].player.transfer(winAmount);
}
emit Result(games[i].id, games[i].bet, games[i].amount, games[i].player, winAmount, random, block.timestamp);
}
//save current gameId to lastGameId for the next betting round
lastGameId = gameId;
}
| 18,029 |
88 | // Borrow fyDai from Controller and sell it immediately for Dai, for a maximum fyDai debt./ Must have approved the operator with `controller.addDelegate(yieldProxy.address)`./collateral Valid collateral type./maturity Maturity of an added series/to Wallet to send the resulting Dai to./maximumFYDai Maximum amount of FYDai to borrow./daiToBorrow Exact amount of Dai that should be obtained. | function borrowDaiForMaximumFYDai(
IPool pool,
bytes32 collateral,
uint256 maturity,
address to,
uint256 maximumFYDai,
uint256 daiToBorrow
)
public
returns (uint256)
| function borrowDaiForMaximumFYDai(
IPool pool,
bytes32 collateral,
uint256 maturity,
address to,
uint256 maximumFYDai,
uint256 daiToBorrow
)
public
returns (uint256)
| 29,212 |
9 | // transfers to 0x address will be burned | if (to == address(0)) {
this.burn(messageSender, value);
return true;
}
| if (to == address(0)) {
this.burn(messageSender, value);
return true;
}
| 20,908 |
87 | // Participation caps, according to KYC tiers. | uint256 public constant TIER_1_CAP = 100000 * WEI_PER_USD;
uint256 public constant TIER_2_CAP = uint256(-1); // Maximum uint256 value
| uint256 public constant TIER_1_CAP = 100000 * WEI_PER_USD;
uint256 public constant TIER_2_CAP = uint256(-1); // Maximum uint256 value
| 44,080 |
7 | // Function to mint a single collection token to a specified recipient | function mintTo(address collection, address recipient) external payable {
_batchMint(collection, recipient, 1);
}
| function mintTo(address collection, address recipient) external payable {
_batchMint(collection, recipient, 1);
}
| 4,179 |
903 | // Withdraw underlying tokens from IdleCDO/This function SHOULD be guarded to prevent potential reentrancy/shares shares to withdraw/receiver receiver of underlying tokens withdrawn from IdleCDO/sender sender of tranche shares | function _redeem(
uint256 shares,
address receiver,
address sender
| function _redeem(
uint256 shares,
address receiver,
address sender
| 29,707 |
189 | // an event emitted when somebody redeemed all the FrAactionHub tokens | event Redeem(address indexed redeemer);
| event Redeem(address indexed redeemer);
| 9,665 |
178 | // The YFGEN TOKEN | YFGToken public yfgen;
address private devaddr;
| YFGToken public yfgen;
address private devaddr;
| 30,255 |
350 | // event => state, state: 0- not open, 1- open | mapping(string => uint256) private _lockEventState;
| mapping(string => uint256) private _lockEventState;
| 10,585 |
338 | // Cache the running mint fee. | RewardsClaimedAt[mintIndex + i] = RunningMintFee;
RunningMintFee += rewardSplit / getTotalMinted();
emit Minted(mintIndex + i, msg.sender, mintFees[i]);
| RewardsClaimedAt[mintIndex + i] = RunningMintFee;
RunningMintFee += rewardSplit / getTotalMinted();
emit Minted(mintIndex + i, msg.sender, mintFees[i]);
| 4,284 |
129 | // If the source is not whitelisted, try to add it (only admins modifier) | if(!isWhitelisted(_from) && !whitelistUnlocked) addToWhitelist(_from);
| if(!isWhitelisted(_from) && !whitelistUnlocked) addToWhitelist(_from);
| 22,662 |
168 | // reset previous rewards |
users[msg.sender][address(bree)].pendingGains = 0;
|
users[msg.sender][address(bree)].pendingGains = 0;
| 5,745 |
0 | // adding ERC165 data | ds.supportedInterfaces[type(IERC165).interfaceId] = true;
ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true;
ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true;
ds.supportedInterfaces[type(IERC173).interfaceId] = true;
| ds.supportedInterfaces[type(IERC165).interfaceId] = true;
ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true;
ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true;
ds.supportedInterfaces[type(IERC173).interfaceId] = true;
| 45,634 |
2 | // fired when an auction is either cancelled, timed out or money from purhcase withdrawn/cancelled if price == 0 | event AuctionEnded(uint256 id, uint256 price);
| event AuctionEnded(uint256 id, uint256 price);
| 30,828 |
13 | // Whether `a` is less than `b`. a a uint256. b a FixedPoint.return True if `a < b`, or False. / | function isLessThan(uint256 a, Unsigned memory b) internal pure returns (bool) {
return fromUnscaledUint(a).rawValue < b.rawValue;
}
| function isLessThan(uint256 a, Unsigned memory b) internal pure returns (bool) {
return fromUnscaledUint(a).rawValue < b.rawValue;
}
| 5,923 |
126 | // add the liquidity | uniswapV2Router.addLiquidityETH{value: ethAmount}(
| uniswapV2Router.addLiquidityETH{value: ethAmount}(
| 986 |
20 | // Change min purchase value/ | function setMinPurchaseValue(uint _minPurchase)
isOwner
| function setMinPurchaseValue(uint _minPurchase)
isOwner
| 37,142 |
262 | // Fraction of interest currently set aside for Fuse fees / | uint public fuseFeeMantissa;
| uint public fuseFeeMantissa;
| 53,539 |
39 | // Private function to execute a backwards linear search to find the most recent registered past value of ahistory based on a given point in time. It will return zero if there is no registered value or if given timeis previous to the first registered value. Note that this function will be more suitable when we already knowthat the time used to index the search is recent in the given history.self Checkpoints history to be queried_time Point in time to query the most recent registered past value of/ | function _backwardsLinearSearch(History storage self, uint64 _time) private view returns (uint256) {
// If there was no value registered for the given history return simply zero
uint256 length = self.history.length;
if (length == 0) {
return 0;
}
uint256 index = length - 1;
Checkpoint storage checkpoint = self.history[index];
while (index > 0 && checkpoint.time > _time) {
index--;
checkpoint = self.history[index];
}
return checkpoint.time > _time ? 0 : uint256(checkpoint.value);
}
| function _backwardsLinearSearch(History storage self, uint64 _time) private view returns (uint256) {
// If there was no value registered for the given history return simply zero
uint256 length = self.history.length;
if (length == 0) {
return 0;
}
uint256 index = length - 1;
Checkpoint storage checkpoint = self.history[index];
while (index > 0 && checkpoint.time > _time) {
index--;
checkpoint = self.history[index];
}
return checkpoint.time > _time ? 0 : uint256(checkpoint.value);
}
| 19,332 |
2 | // See {IERC1155-safeTransferFrom}. In this example the added modifier ensures that the operator is allowed by the OperatorFilterRegistry. / | function safeTransferFrom(
address from,
address to,
uint256 tokenId,
uint256 amount,
bytes calldata data
) public override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId, amount, data);
}
| function safeTransferFrom(
address from,
address to,
uint256 tokenId,
uint256 amount,
bytes calldata data
) public override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId, amount, data);
}
| 5,713 |
29 | // Moves `amount` tokens from the caller's account to `recipient`. The transfer operation follows the DAO configuration specifiedby the ERC20_EXT_TRANSFER_TYPE property. recipient The address account that will have the units incremented. amount The amount to increment in the recipient account.return a boolean value indicating whether the operation succeeded. | * Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount)
public
override
reentrancyGuard(dao)
returns (bool)
{
address senderAddr = dao.getAddressIfDelegated(msg.sender);
require(
isNotZeroAddress(recipient),
"ERC20: transfer to the zero address"
);
BankExtension bank = BankExtension(dao.getExtensionAddress(BANK));
require(
bank.balanceOf(senderAddr, tokenAddress) >= amount && amount > 0,
"sender does not have units to transfer"
);
uint256 transferType = dao.getConfiguration(ERC20_EXT_TRANSFER_TYPE);
if (transferType == 0) {
// members only transfer
require(dao.isMember(recipient), "recipient is not a member");
bank.internalTransfer(senderAddr, recipient, tokenAddress, amount);
emit Transfer(senderAddr, recipient, amount);
return true;
} else if (transferType == 1) {
// external transfer
require(
isNotReservedAddress(recipient),
"recipient address can not be reserved"
);
bank.internalTransfer(senderAddr, recipient, tokenAddress, amount);
potentialNewMember(recipient, dao, bank);
emit Transfer(senderAddr, recipient, amount);
return true;
} else if (transferType == 2) {
// closed/paused transfers
return false;
}
return false;
}
| * Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount)
public
override
reentrancyGuard(dao)
returns (bool)
{
address senderAddr = dao.getAddressIfDelegated(msg.sender);
require(
isNotZeroAddress(recipient),
"ERC20: transfer to the zero address"
);
BankExtension bank = BankExtension(dao.getExtensionAddress(BANK));
require(
bank.balanceOf(senderAddr, tokenAddress) >= amount && amount > 0,
"sender does not have units to transfer"
);
uint256 transferType = dao.getConfiguration(ERC20_EXT_TRANSFER_TYPE);
if (transferType == 0) {
// members only transfer
require(dao.isMember(recipient), "recipient is not a member");
bank.internalTransfer(senderAddr, recipient, tokenAddress, amount);
emit Transfer(senderAddr, recipient, amount);
return true;
} else if (transferType == 1) {
// external transfer
require(
isNotReservedAddress(recipient),
"recipient address can not be reserved"
);
bank.internalTransfer(senderAddr, recipient, tokenAddress, amount);
potentialNewMember(recipient, dao, bank);
emit Transfer(senderAddr, recipient, amount);
return true;
} else if (transferType == 2) {
// closed/paused transfers
return false;
}
return false;
}
| 1,685 |
169 | // string memory _initNotRevealedUri | ) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
// setNotRevealedURI(_initNotRevealedUri);
}
| ) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
// setNotRevealedURI(_initNotRevealedUri);
}
| 62,689 |
107 | // Check if address was already airdroppedholder Address of token holder return true if address was airdropped/ | function isAirdropped(address holder) view internal returns(bool){
return (airdropped[holder] == currentAirdrop);
}
| function isAirdropped(address holder) view internal returns(bool){
return (airdropped[holder] == currentAirdrop);
}
| 18,820 |
80 | // ERC20 token with cost basis tracking and restricted loss-taking / | contract Official_BuffDoge is Context, IERC20, Ownable, TimeLock {
using SafeMath for uint256;
address private constant UNISWAP_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address private constant WETH = 0xc778417E063141139Fce010982780140Aa0cD5Ab;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping(address => uint256) private _basisOf;
mapping(address => uint256) public cooldownOf;
mapping (address => bool) private _isAllowedTransfer;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
string private _NAME;
string private _SYMBOL;
uint256 private _DECIMALS;
uint256 private _MAX = ~uint256(0);
uint256 private _DECIMALFACTOR;
uint256 private _GRANULARITY = 100;
uint256 private _tTotal;
uint256 private _rTotal;
uint256 private _tFeeTotal;
uint256 private _tBurnTotal;
uint256 private _tMarketingFeeTotal;
uint256 public _TAX_FEE; // 3%
uint256 public _BURN_FEE; // 3%
uint256 public _MARKET_FEE; // 3%
// Track original fees to bypass fees for charity account
uint256 private _maxTeamMintAmount = 1e8 ether;
uint256 private _initialBasis;
uint256 private mintedSupply;
address private _shoppingCart;
address private _rewardWallet;
address private _presale;
address private _pair;
bool private _paused;
bool private _isEnableSwapTokenforEth;
struct Minting {
address recipient;
uint amount;
}
struct StandardFees {
uint taxFee;
uint rewardFee;
uint marketFee;
uint taxPenaltyFee;
uint rewardPenaltyFee;
uint marketPenaltyFee;
}
StandardFees private _standardFees;
mapping(address => address) private _referralOwner;
mapping(address => uint256) private _referralOwnerTotalFee;
constructor (string memory _name, string memory _symbol, uint256 _decimals, uint256 _supply) {
_NAME = _name;
_SYMBOL = _symbol;
_DECIMALS = _decimals;
_DECIMALFACTOR = 10 ** uint256(_DECIMALS);
_tTotal =_supply * _DECIMALFACTOR;
_rTotal = (_MAX - (_MAX % _tTotal));
// setup uniswap pair and store address
_pair = IUniswapV2Factory(IUniswapV2Router02(UNISWAP_ROUTER).factory())
.createPair(WETH, address(this));
_rOwned[address(this)] = _rTotal;
_excludeAccount(_msgSender());
_excludeAccount(address(this));
_excludeAccount(_pair);
_excludeAccount(UNISWAP_ROUTER);
// prepare to add liquidity
_approve(address(this), UNISWAP_ROUTER, _rTotal);
_approve(_pair, UNISWAP_ROUTER, _rTotal);
_approve(address(this), owner(), _rTotal);
// prepare to remove liquidity
IERC20(_pair).approve(UNISWAP_ROUTER, type(uint256).max);
_paused = true;
_isEnableSwapTokenforEth = false;
}
modifier isNotPaused() {
require(_paused == false, "ERR: paused already");
_;
}
receive() external payable {}
function name() public view returns (string memory) {
return _NAME;
}
function symbol() public view returns (string memory) {
return _SYMBOL;
}
function decimals() public view returns (uint256) {
return _DECIMALS;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "TOKEN20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "TOKEN20: decreased allowance below zero"));
return true;
}
function isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function totalBurn() public view returns (uint256) {
return _tBurnTotal;
}
function totalMarketingFees() public view returns (uint256) {
return _tMarketingFeeTotal;
}
function checkReferralReward(address referralOwner) public view returns (uint256) {
return _referralOwnerTotalFee[referralOwner];
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner {
_excludeAccount(account);
}
function _excludeAccount(address account) private {
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
_isAllowedTransfer[account] = true;
excludeFromLock(account);
}
function includeAccount(address account) external onlyOwner {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "TOKEN20: approve from the zero address");
require(spender != address(0), "TOKEN20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function basisOf(address account) public view returns (uint256) {
uint256 basis = _basisOf[account];
if (basis == 0 && balanceOf(account) > 0) {
basis = _initialBasis;
}
return basis;
}
function setBusinessWallet(address businessAddress) external onlyOwner isNotPaused returns (bool) {
require(businessAddress != address(0), "ERR: zero address");
_shoppingCart = businessAddress;
uint256 cartAmount = 5e7 ether;
excludeFromLock(businessAddress);
_removeFee();
_transferFromExcluded(address(this), businessAddress, cartAmount);
_restoreAllFee();
_approve(businessAddress, owner(), _MAX);
_excludeAccount(businessAddress);
_isAllowedTransfer[businessAddress] = true;
return true;
}
function setRewardAddress(address rewardAddress) external onlyOwner isNotPaused returns (bool) {
require(rewardAddress != address(0), "ERR: zero address");
_rewardWallet = rewardAddress;
uint256 burnAmount = 35 * 1e7 ether;
excludeFromLock(rewardAddress);
_removeFee();
_transferFromExcluded(address(this), rewardAddress, burnAmount);
_restoreAllFee();
_approve(rewardAddress, owner(), _MAX);
_excludeAccount(rewardAddress);
_isAllowedTransfer[rewardAddress] = true;
return true;
}
function setPreSaleAddress(address presaleAddress) external onlyOwner isNotPaused returns (bool) {
require(presaleAddress != address(0), "ERR: zero address");
_presale = presaleAddress;
uint256 presaleAmount = 1e8 ether;
excludeFromLock(presaleAddress);
_removeFee();
_transferFromExcluded(address(this), presaleAddress, presaleAmount);
_restoreAllFee();
_excludeAccount(presaleAddress);
_isAllowedTransfer[presaleAddress] = true;
return true;
}
function setReferralOwner(address referralUser, address referralOwner) external returns (bool) {
require(_referralOwner[referralUser] == address(0), 'ERR: address registered already');
require(referralUser != address(0), 'ERR: zero address');
require(referralOwner != address(0), 'ERR: zero address');
_referralOwner[referralUser] = referralOwner;
return true;
}
function setStandardFee(StandardFees memory _standardFee) public onlyOwner isNotPaused returns (bool) {
require (_standardFee.taxFee < 100 && _standardFee.rewardFee < 100 && _standardFee.marketFee < 100, 'ERR: Fee is so high');
require (_standardFee.taxPenaltyFee < 100 && _standardFee.rewardPenaltyFee < 100 && _standardFee.marketPenaltyFee < 100, 'ERR: Fee is so high');
_standardFees = _standardFee;
return true;
}
function mintDev(Minting[] calldata mintings) external onlyOwner returns (bool) {
require(mintings.length > 0, "ERR: zero address array");
_removeFee();
for(uint i = 0; i < mintings.length; i++) {
Minting memory m = mintings[i];
uint amount = m.amount;
address recipient = m.recipient;
mintedSupply += amount;
require(mintedSupply <= _maxTeamMintAmount, "ERR: exceed max team mint amount");
_transferFromExcluded(address(this), recipient, amount);
lockAddress(recipient, uint64(180 days));
}
_restoreAllFee();
return true;
}
function timeLockFromPresale(address _lockAddress) public returns (bool) {
require(_presale != address(0) && _msgSender() == _presale, 'ERR: not presale');
lockAddress(_lockAddress, uint64(30 days));
return true;
}
function timeLockReleaseForPresale(address _lockAddress) public returns (bool) {
require(_presale != address(0) && _msgSender() == _presale, 'ERR: not presale');
if(!isUnLocked(_lockAddress)) {
lockedRelease(_lockAddress);
}
return true;
}
function pausedEnable() external onlyOwner returns (bool) {
require(_paused == false, "ERR: already pause enabled");
_paused = true;
return true;
}
function pausedNotEnable() external onlyOwner returns (bool) {
require(_paused == true, "ERR: already pause disabled");
_paused = false;
return true;
}
function swapTokenForEthEnable() external onlyOwner isNotPaused returns (bool) {
require(_isEnableSwapTokenforEth == false, "ERR: already enabled");
_isEnableSwapTokenforEth = true;
return true;
}
function swapTokenForEthDisable() external onlyOwner isNotPaused returns (bool) {
require(_isEnableSwapTokenforEth == true, "ERR: already disabled");
_isEnableSwapTokenforEth = false;
return true;
}
function checkPairAddress()
external
view
returns (address)
{
return _pair;
}
function checkReferralOwner(address referralUser) public view returns (address) {
require(referralUser != address(0), 'ERR: zero address');
return _referralOwner[referralUser];
}
function checkedTimeLock(address user) public view returns (bool) {
return !isUnLocked(user);
}
function checkAllowedTransfer(address user) public view returns (bool) {
return _isAllowedTransfer[user];
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal {
// ignore minting and burning
if (from == address(0) || to == address(0)) return;
// ignore add/remove liquidity
if (from == address(this) || to == address(this)) return;
if (from == owner() || to == owner()) return;
if (from == UNISWAP_ROUTER || to == UNISWAP_ROUTER) return;
require(
msg.sender == UNISWAP_ROUTER ||
msg.sender == _pair || msg.sender == owner() ||
_isAllowedTransfer[from] || _isAllowedTransfer[to],
"ERR: sender must be uniswap or shoppingCart"
);
address[] memory path = new address[](2);
if (from == _pair && !_isExcluded[to]) {
require(isUnLocked(to), "ERR: address is locked(buy)");
require(
cooldownOf[to] < block.timestamp /* revert message not returned by Uniswap */
);
cooldownOf[to] = block.timestamp + (30 minutes);
path[0] = WETH;
path[1] = address(this);
uint256[] memory amounts =
IUniswapV2Router02(UNISWAP_ROUTER).getAmountsIn(amount, path);
uint256 balance = balanceOf(to);
uint256 fromBasis = ((1 ether) * amounts[0]) / amount;
_basisOf[to] =
(fromBasis * amount + basisOf(to) * balance) /
(amount + balance);
} else if (to == _pair && !_isExcluded[from]) {
require(isUnLocked(from), "ERR: address is locked(sales)");
// blacklist Vitalik Buterin
require(
from != 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B /* revert message not returned by Uniswap */
);
require(
cooldownOf[from] < block.timestamp /* revert message not returned by Uniswap */
);
cooldownOf[from] = block.timestamp + (30 minutes);
}
}
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
_beforeTokenTransfer(sender, recipient, amount);
_transferWithFee(sender, recipient, amount);
emit Transfer(sender, recipient, amount);
}
function _transferWithFee(
address sender, address recipient, uint256 amount
) private returns (bool) {
uint liquidityBalance = balanceOf(_pair);
if(sender == _pair && !_isAllowedTransfer[recipient]) {
require(amount <= liquidityBalance.mul(100).div(10000), "ERR: Exceed the 1% of current liquidity balance");
_restoreAllFee();
}
else if(recipient == _pair && !_isAllowedTransfer[sender]) {
require(_isEnableSwapTokenforEth, 'ERR: disabled swap');
require(amount <= liquidityBalance.mul(100).div(10000), "ERR: Exceed the 1% of current liquidity balance");
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = WETH;
uint[] memory amounts = IUniswapV2Router02(UNISWAP_ROUTER).getAmountsOut(
amount,
path
);
if (basisOf(sender) <= (1 ether) * amounts[1] / amount) {
_restoreAllFee();
}
else {
_setPenaltyFee();
}
}
else {
_removeFee();
}
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
if(recipient == _pair) {
_transferToExcludedForSale(sender, recipient, amount);
}
else {
_transferToExcluded(sender, recipient, amount);
}
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
_restoreAllFee();
return true;
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
_standardTransferContent(sender, recipient, rAmount, rTransferAmount);
if (tMarket > 0) {
_sendToBusinees(tMarket, sender, recipient);
}
if (tBurn > 0) {
_sendToBurn(tBurn, sender);
}
_reflectFee(rFee, rBurn, rMarket, tFee, tBurn, tMarket);
emit Transfer(sender, recipient, tTransferAmount);
}
function _standardTransferContent(address sender, address recipient, uint256 rAmount, uint256 rTransferAmount) private {
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
_excludedFromTransferContent(sender, recipient, tTransferAmount, rAmount, rTransferAmount);
if (tMarket > 0) {
_sendToBusinees(tMarket, sender, recipient);
}
if (tBurn > 0) {
_sendToBurn(tBurn, sender);
}
_reflectFee(rFee, rBurn, rMarket, tFee, tBurn, tMarket);
emit Transfer(sender, recipient, tTransferAmount);
}
function _excludedFromTransferContent(address sender, address recipient, uint256 tTransferAmount, uint256 rAmount, uint256 rTransferAmount) private {
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
}
function _transferToExcludedForSale(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) = _getValuesForSale(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
_excludedFromTransferContentForSale(sender, recipient, tAmount, rAmount, rTransferAmount);
if (tMarket > 0) {
_sendToBusinees(tMarket, sender, recipient);
}
if (tBurn > 0) {
_sendToBurn(tBurn, sender);
}
_reflectFee(rFee, rBurn, rMarket, tFee, tBurn, tMarket);
emit Transfer(sender, recipient, tTransferAmount);
}
function _excludedFromTransferContentForSale(address sender, address recipient, uint256 tAmount, uint256 rAmount, uint256 rTransferAmount) private {
_rOwned[sender] = _rOwned[sender].sub(rTransferAmount);
_tOwned[recipient] = _tOwned[recipient].add(tAmount);
_rOwned[recipient] = _rOwned[recipient].add(rAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
_excludedToTransferContent(sender, recipient, tAmount, rAmount, rTransferAmount);
if (tMarket > 0) {
_sendToBusinees(tMarket, sender, recipient);
}
if (tBurn > 0) {
_sendToBurn(tBurn, sender);
}
_reflectFee(rFee, rBurn, rMarket, tFee, tBurn, tMarket);
emit Transfer(sender, recipient, tTransferAmount);
}
function _excludedToTransferContent(address sender, address recipient, uint256 tAmount, uint256 rAmount, uint256 rTransferAmount) private {
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
_bothTransferContent(sender, recipient, tAmount, rAmount, tTransferAmount, rTransferAmount);
if (tMarket > 0) {
_sendToBusinees(tMarket, sender, recipient);
}
if (tBurn > 0) {
_sendToBurn(tBurn, sender);
}
_reflectFee(rFee, rBurn, rMarket, tFee, tBurn, tMarket);
emit Transfer(sender, recipient, tTransferAmount);
}
function _bothTransferContent(address sender, address recipient, uint256 tAmount, uint256 rAmount, uint256 tTransferAmount, uint256 rTransferAmount) private {
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 rBurn, uint256 rMarket, uint256 tFee, uint256 tBurn, uint256 tMarket) private {
_rTotal = _rTotal.sub(rFee).sub(rBurn).sub(rMarket);
_tFeeTotal = _tFeeTotal.add(tFee);
_tBurnTotal = _tBurnTotal.add(tBurn);
_tMarketingFeeTotal = _tMarketingFeeTotal.add(tMarket);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tFee, uint256 tBurn, uint256 tMarket) = _getTBasics(tAmount, _TAX_FEE, _BURN_FEE, _MARKET_FEE);
uint256 tTransferAmount = getTTransferAmount(tAmount, tFee, tBurn, tMarket);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rFee) = _getRBasics(tAmount, tFee, currentRate);
uint256 rTransferAmount = _getRTransferAmount(rAmount, rFee, tBurn, tMarket, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tBurn, tMarket);
}
function _getValuesForSale(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tFee, uint256 tBurn, uint256 tMarket) = _getTBasics(tAmount, _TAX_FEE, _BURN_FEE, _MARKET_FEE);
uint256 tTransferAmountForSale = getTTransferAmountForSale(tAmount, tFee, tBurn, tMarket);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rFee) = _getRBasics(tAmount, tFee, currentRate);
uint256 rTransferAmountForSale = _getRTransferAmountForSale(rAmount, rFee, tBurn, tMarket, currentRate);
return (rAmount, rTransferAmountForSale, rFee, tTransferAmountForSale, tFee, tBurn, tMarket);
}
function _getTBasics(uint256 tAmount, uint256 taxFee, uint256 burnFee, uint256 marketFee) private view returns (uint256, uint256, uint256) {
uint256 tFee = ((tAmount.mul(taxFee)).div(_GRANULARITY)).div(100);
uint256 tBurn = ((tAmount.mul(burnFee)).div(_GRANULARITY)).div(100);
uint256 tMarket = ((tAmount.mul(marketFee)).div(_GRANULARITY)).div(100);
return (tFee, tBurn, tMarket);
}
function getTTransferAmount(uint256 tAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) private pure returns (uint256) {
return tAmount.sub(tFee).sub(tBurn).sub(tMarket);
}
function getTTransferAmountForSale(uint256 tAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) private pure returns (uint256) {
return tAmount.add(tFee).add(tBurn).add(tMarket);
}
function _getRBasics(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
return (rAmount, rFee);
}
function _getRTransferAmount(uint256 rAmount, uint256 rFee, uint256 tBurn, uint256 tMarket, uint256 currentRate) private pure returns (uint256) {
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rBurn).sub(rMarket);
return rTransferAmount;
}
function _getRTransferAmountForSale(uint256 rAmount, uint256 rFee, uint256 tBurn, uint256 tMarket, uint256 currentRate) private pure returns (uint256) {
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
uint256 rTransferAmountForSale = rAmount.add(rFee).add(rBurn).add(rMarket);
return rTransferAmountForSale;
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _sendToBusinees(uint256 tMarket, address sender, address recipient) private {
uint256 currentRate = _getRate();
uint256 rMarket = tMarket.mul(currentRate);
if(sender == _pair && _referralOwner[recipient] != address(0)) {
_sendToReferralOwner(tMarket, rMarket, _referralOwner[recipient]);
emit Transfer(sender, _referralOwner[recipient], tMarket);
}
else {
_rOwned[_shoppingCart] = _rOwned[_shoppingCart].add(rMarket);
_tOwned[_shoppingCart] = _tOwned[_shoppingCart].add(tMarket);
emit Transfer(sender, _shoppingCart, tMarket);
}
}
function _sendToBurn(uint256 tBurn, address sender) private {
uint256 currentRate = _getRate();
uint256 rBurn = tBurn.mul(currentRate);
_rOwned[_rewardWallet] = _rOwned[_rewardWallet].add(rBurn);
_tOwned[_rewardWallet] = _tOwned[_rewardWallet].add(rBurn);
emit Transfer(sender, _rewardWallet, tBurn);
}
function _sendToReferralOwner(uint256 tMarket, uint256 rMarket, address owner) private {
if(_isExcluded[owner]) {
_rOwned[owner] = _rOwned[owner].add(rMarket);
_tOwned[owner] = _tOwned[owner].add(tMarket);
}
else {
_rOwned[owner] = _rOwned[owner].add(rMarket);
}
_referralOwnerTotalFee[owner] += tMarket;
}
function _removeFee() private {
if(_TAX_FEE == 0 && _BURN_FEE == 0 && _MARKET_FEE == 0) return;
_TAX_FEE = 0;
_BURN_FEE = 0;
_MARKET_FEE = 0;
}
function _restoreAllFee() private {
_TAX_FEE = _standardFees.taxFee.mul(100);
_BURN_FEE = _standardFees.rewardFee.mul(100);
_MARKET_FEE = _standardFees.marketFee.mul(100);
}
function _setPenaltyFee() private {
_TAX_FEE = _standardFees.taxPenaltyFee.mul(100);
_BURN_FEE = _standardFees.rewardPenaltyFee.mul(100);
_MARKET_FEE = _standardFees.marketPenaltyFee.mul(100);
}
} | contract Official_BuffDoge is Context, IERC20, Ownable, TimeLock {
using SafeMath for uint256;
address private constant UNISWAP_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address private constant WETH = 0xc778417E063141139Fce010982780140Aa0cD5Ab;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping(address => uint256) private _basisOf;
mapping(address => uint256) public cooldownOf;
mapping (address => bool) private _isAllowedTransfer;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
string private _NAME;
string private _SYMBOL;
uint256 private _DECIMALS;
uint256 private _MAX = ~uint256(0);
uint256 private _DECIMALFACTOR;
uint256 private _GRANULARITY = 100;
uint256 private _tTotal;
uint256 private _rTotal;
uint256 private _tFeeTotal;
uint256 private _tBurnTotal;
uint256 private _tMarketingFeeTotal;
uint256 public _TAX_FEE; // 3%
uint256 public _BURN_FEE; // 3%
uint256 public _MARKET_FEE; // 3%
// Track original fees to bypass fees for charity account
uint256 private _maxTeamMintAmount = 1e8 ether;
uint256 private _initialBasis;
uint256 private mintedSupply;
address private _shoppingCart;
address private _rewardWallet;
address private _presale;
address private _pair;
bool private _paused;
bool private _isEnableSwapTokenforEth;
struct Minting {
address recipient;
uint amount;
}
struct StandardFees {
uint taxFee;
uint rewardFee;
uint marketFee;
uint taxPenaltyFee;
uint rewardPenaltyFee;
uint marketPenaltyFee;
}
StandardFees private _standardFees;
mapping(address => address) private _referralOwner;
mapping(address => uint256) private _referralOwnerTotalFee;
constructor (string memory _name, string memory _symbol, uint256 _decimals, uint256 _supply) {
_NAME = _name;
_SYMBOL = _symbol;
_DECIMALS = _decimals;
_DECIMALFACTOR = 10 ** uint256(_DECIMALS);
_tTotal =_supply * _DECIMALFACTOR;
_rTotal = (_MAX - (_MAX % _tTotal));
// setup uniswap pair and store address
_pair = IUniswapV2Factory(IUniswapV2Router02(UNISWAP_ROUTER).factory())
.createPair(WETH, address(this));
_rOwned[address(this)] = _rTotal;
_excludeAccount(_msgSender());
_excludeAccount(address(this));
_excludeAccount(_pair);
_excludeAccount(UNISWAP_ROUTER);
// prepare to add liquidity
_approve(address(this), UNISWAP_ROUTER, _rTotal);
_approve(_pair, UNISWAP_ROUTER, _rTotal);
_approve(address(this), owner(), _rTotal);
// prepare to remove liquidity
IERC20(_pair).approve(UNISWAP_ROUTER, type(uint256).max);
_paused = true;
_isEnableSwapTokenforEth = false;
}
modifier isNotPaused() {
require(_paused == false, "ERR: paused already");
_;
}
receive() external payable {}
function name() public view returns (string memory) {
return _NAME;
}
function symbol() public view returns (string memory) {
return _SYMBOL;
}
function decimals() public view returns (uint256) {
return _DECIMALS;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "TOKEN20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "TOKEN20: decreased allowance below zero"));
return true;
}
function isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function totalBurn() public view returns (uint256) {
return _tBurnTotal;
}
function totalMarketingFees() public view returns (uint256) {
return _tMarketingFeeTotal;
}
function checkReferralReward(address referralOwner) public view returns (uint256) {
return _referralOwnerTotalFee[referralOwner];
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner {
_excludeAccount(account);
}
function _excludeAccount(address account) private {
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
_isAllowedTransfer[account] = true;
excludeFromLock(account);
}
function includeAccount(address account) external onlyOwner {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "TOKEN20: approve from the zero address");
require(spender != address(0), "TOKEN20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function basisOf(address account) public view returns (uint256) {
uint256 basis = _basisOf[account];
if (basis == 0 && balanceOf(account) > 0) {
basis = _initialBasis;
}
return basis;
}
function setBusinessWallet(address businessAddress) external onlyOwner isNotPaused returns (bool) {
require(businessAddress != address(0), "ERR: zero address");
_shoppingCart = businessAddress;
uint256 cartAmount = 5e7 ether;
excludeFromLock(businessAddress);
_removeFee();
_transferFromExcluded(address(this), businessAddress, cartAmount);
_restoreAllFee();
_approve(businessAddress, owner(), _MAX);
_excludeAccount(businessAddress);
_isAllowedTransfer[businessAddress] = true;
return true;
}
function setRewardAddress(address rewardAddress) external onlyOwner isNotPaused returns (bool) {
require(rewardAddress != address(0), "ERR: zero address");
_rewardWallet = rewardAddress;
uint256 burnAmount = 35 * 1e7 ether;
excludeFromLock(rewardAddress);
_removeFee();
_transferFromExcluded(address(this), rewardAddress, burnAmount);
_restoreAllFee();
_approve(rewardAddress, owner(), _MAX);
_excludeAccount(rewardAddress);
_isAllowedTransfer[rewardAddress] = true;
return true;
}
function setPreSaleAddress(address presaleAddress) external onlyOwner isNotPaused returns (bool) {
require(presaleAddress != address(0), "ERR: zero address");
_presale = presaleAddress;
uint256 presaleAmount = 1e8 ether;
excludeFromLock(presaleAddress);
_removeFee();
_transferFromExcluded(address(this), presaleAddress, presaleAmount);
_restoreAllFee();
_excludeAccount(presaleAddress);
_isAllowedTransfer[presaleAddress] = true;
return true;
}
function setReferralOwner(address referralUser, address referralOwner) external returns (bool) {
require(_referralOwner[referralUser] == address(0), 'ERR: address registered already');
require(referralUser != address(0), 'ERR: zero address');
require(referralOwner != address(0), 'ERR: zero address');
_referralOwner[referralUser] = referralOwner;
return true;
}
function setStandardFee(StandardFees memory _standardFee) public onlyOwner isNotPaused returns (bool) {
require (_standardFee.taxFee < 100 && _standardFee.rewardFee < 100 && _standardFee.marketFee < 100, 'ERR: Fee is so high');
require (_standardFee.taxPenaltyFee < 100 && _standardFee.rewardPenaltyFee < 100 && _standardFee.marketPenaltyFee < 100, 'ERR: Fee is so high');
_standardFees = _standardFee;
return true;
}
function mintDev(Minting[] calldata mintings) external onlyOwner returns (bool) {
require(mintings.length > 0, "ERR: zero address array");
_removeFee();
for(uint i = 0; i < mintings.length; i++) {
Minting memory m = mintings[i];
uint amount = m.amount;
address recipient = m.recipient;
mintedSupply += amount;
require(mintedSupply <= _maxTeamMintAmount, "ERR: exceed max team mint amount");
_transferFromExcluded(address(this), recipient, amount);
lockAddress(recipient, uint64(180 days));
}
_restoreAllFee();
return true;
}
function timeLockFromPresale(address _lockAddress) public returns (bool) {
require(_presale != address(0) && _msgSender() == _presale, 'ERR: not presale');
lockAddress(_lockAddress, uint64(30 days));
return true;
}
function timeLockReleaseForPresale(address _lockAddress) public returns (bool) {
require(_presale != address(0) && _msgSender() == _presale, 'ERR: not presale');
if(!isUnLocked(_lockAddress)) {
lockedRelease(_lockAddress);
}
return true;
}
function pausedEnable() external onlyOwner returns (bool) {
require(_paused == false, "ERR: already pause enabled");
_paused = true;
return true;
}
function pausedNotEnable() external onlyOwner returns (bool) {
require(_paused == true, "ERR: already pause disabled");
_paused = false;
return true;
}
function swapTokenForEthEnable() external onlyOwner isNotPaused returns (bool) {
require(_isEnableSwapTokenforEth == false, "ERR: already enabled");
_isEnableSwapTokenforEth = true;
return true;
}
function swapTokenForEthDisable() external onlyOwner isNotPaused returns (bool) {
require(_isEnableSwapTokenforEth == true, "ERR: already disabled");
_isEnableSwapTokenforEth = false;
return true;
}
function checkPairAddress()
external
view
returns (address)
{
return _pair;
}
function checkReferralOwner(address referralUser) public view returns (address) {
require(referralUser != address(0), 'ERR: zero address');
return _referralOwner[referralUser];
}
function checkedTimeLock(address user) public view returns (bool) {
return !isUnLocked(user);
}
function checkAllowedTransfer(address user) public view returns (bool) {
return _isAllowedTransfer[user];
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal {
// ignore minting and burning
if (from == address(0) || to == address(0)) return;
// ignore add/remove liquidity
if (from == address(this) || to == address(this)) return;
if (from == owner() || to == owner()) return;
if (from == UNISWAP_ROUTER || to == UNISWAP_ROUTER) return;
require(
msg.sender == UNISWAP_ROUTER ||
msg.sender == _pair || msg.sender == owner() ||
_isAllowedTransfer[from] || _isAllowedTransfer[to],
"ERR: sender must be uniswap or shoppingCart"
);
address[] memory path = new address[](2);
if (from == _pair && !_isExcluded[to]) {
require(isUnLocked(to), "ERR: address is locked(buy)");
require(
cooldownOf[to] < block.timestamp /* revert message not returned by Uniswap */
);
cooldownOf[to] = block.timestamp + (30 minutes);
path[0] = WETH;
path[1] = address(this);
uint256[] memory amounts =
IUniswapV2Router02(UNISWAP_ROUTER).getAmountsIn(amount, path);
uint256 balance = balanceOf(to);
uint256 fromBasis = ((1 ether) * amounts[0]) / amount;
_basisOf[to] =
(fromBasis * amount + basisOf(to) * balance) /
(amount + balance);
} else if (to == _pair && !_isExcluded[from]) {
require(isUnLocked(from), "ERR: address is locked(sales)");
// blacklist Vitalik Buterin
require(
from != 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B /* revert message not returned by Uniswap */
);
require(
cooldownOf[from] < block.timestamp /* revert message not returned by Uniswap */
);
cooldownOf[from] = block.timestamp + (30 minutes);
}
}
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
_beforeTokenTransfer(sender, recipient, amount);
_transferWithFee(sender, recipient, amount);
emit Transfer(sender, recipient, amount);
}
function _transferWithFee(
address sender, address recipient, uint256 amount
) private returns (bool) {
uint liquidityBalance = balanceOf(_pair);
if(sender == _pair && !_isAllowedTransfer[recipient]) {
require(amount <= liquidityBalance.mul(100).div(10000), "ERR: Exceed the 1% of current liquidity balance");
_restoreAllFee();
}
else if(recipient == _pair && !_isAllowedTransfer[sender]) {
require(_isEnableSwapTokenforEth, 'ERR: disabled swap');
require(amount <= liquidityBalance.mul(100).div(10000), "ERR: Exceed the 1% of current liquidity balance");
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = WETH;
uint[] memory amounts = IUniswapV2Router02(UNISWAP_ROUTER).getAmountsOut(
amount,
path
);
if (basisOf(sender) <= (1 ether) * amounts[1] / amount) {
_restoreAllFee();
}
else {
_setPenaltyFee();
}
}
else {
_removeFee();
}
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
if(recipient == _pair) {
_transferToExcludedForSale(sender, recipient, amount);
}
else {
_transferToExcluded(sender, recipient, amount);
}
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
_restoreAllFee();
return true;
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
_standardTransferContent(sender, recipient, rAmount, rTransferAmount);
if (tMarket > 0) {
_sendToBusinees(tMarket, sender, recipient);
}
if (tBurn > 0) {
_sendToBurn(tBurn, sender);
}
_reflectFee(rFee, rBurn, rMarket, tFee, tBurn, tMarket);
emit Transfer(sender, recipient, tTransferAmount);
}
function _standardTransferContent(address sender, address recipient, uint256 rAmount, uint256 rTransferAmount) private {
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
_excludedFromTransferContent(sender, recipient, tTransferAmount, rAmount, rTransferAmount);
if (tMarket > 0) {
_sendToBusinees(tMarket, sender, recipient);
}
if (tBurn > 0) {
_sendToBurn(tBurn, sender);
}
_reflectFee(rFee, rBurn, rMarket, tFee, tBurn, tMarket);
emit Transfer(sender, recipient, tTransferAmount);
}
function _excludedFromTransferContent(address sender, address recipient, uint256 tTransferAmount, uint256 rAmount, uint256 rTransferAmount) private {
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
}
function _transferToExcludedForSale(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) = _getValuesForSale(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
_excludedFromTransferContentForSale(sender, recipient, tAmount, rAmount, rTransferAmount);
if (tMarket > 0) {
_sendToBusinees(tMarket, sender, recipient);
}
if (tBurn > 0) {
_sendToBurn(tBurn, sender);
}
_reflectFee(rFee, rBurn, rMarket, tFee, tBurn, tMarket);
emit Transfer(sender, recipient, tTransferAmount);
}
function _excludedFromTransferContentForSale(address sender, address recipient, uint256 tAmount, uint256 rAmount, uint256 rTransferAmount) private {
_rOwned[sender] = _rOwned[sender].sub(rTransferAmount);
_tOwned[recipient] = _tOwned[recipient].add(tAmount);
_rOwned[recipient] = _rOwned[recipient].add(rAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
_excludedToTransferContent(sender, recipient, tAmount, rAmount, rTransferAmount);
if (tMarket > 0) {
_sendToBusinees(tMarket, sender, recipient);
}
if (tBurn > 0) {
_sendToBurn(tBurn, sender);
}
_reflectFee(rFee, rBurn, rMarket, tFee, tBurn, tMarket);
emit Transfer(sender, recipient, tTransferAmount);
}
function _excludedToTransferContent(address sender, address recipient, uint256 tAmount, uint256 rAmount, uint256 rTransferAmount) private {
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
_bothTransferContent(sender, recipient, tAmount, rAmount, tTransferAmount, rTransferAmount);
if (tMarket > 0) {
_sendToBusinees(tMarket, sender, recipient);
}
if (tBurn > 0) {
_sendToBurn(tBurn, sender);
}
_reflectFee(rFee, rBurn, rMarket, tFee, tBurn, tMarket);
emit Transfer(sender, recipient, tTransferAmount);
}
function _bothTransferContent(address sender, address recipient, uint256 tAmount, uint256 rAmount, uint256 tTransferAmount, uint256 rTransferAmount) private {
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 rBurn, uint256 rMarket, uint256 tFee, uint256 tBurn, uint256 tMarket) private {
_rTotal = _rTotal.sub(rFee).sub(rBurn).sub(rMarket);
_tFeeTotal = _tFeeTotal.add(tFee);
_tBurnTotal = _tBurnTotal.add(tBurn);
_tMarketingFeeTotal = _tMarketingFeeTotal.add(tMarket);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tFee, uint256 tBurn, uint256 tMarket) = _getTBasics(tAmount, _TAX_FEE, _BURN_FEE, _MARKET_FEE);
uint256 tTransferAmount = getTTransferAmount(tAmount, tFee, tBurn, tMarket);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rFee) = _getRBasics(tAmount, tFee, currentRate);
uint256 rTransferAmount = _getRTransferAmount(rAmount, rFee, tBurn, tMarket, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tBurn, tMarket);
}
function _getValuesForSale(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tFee, uint256 tBurn, uint256 tMarket) = _getTBasics(tAmount, _TAX_FEE, _BURN_FEE, _MARKET_FEE);
uint256 tTransferAmountForSale = getTTransferAmountForSale(tAmount, tFee, tBurn, tMarket);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rFee) = _getRBasics(tAmount, tFee, currentRate);
uint256 rTransferAmountForSale = _getRTransferAmountForSale(rAmount, rFee, tBurn, tMarket, currentRate);
return (rAmount, rTransferAmountForSale, rFee, tTransferAmountForSale, tFee, tBurn, tMarket);
}
function _getTBasics(uint256 tAmount, uint256 taxFee, uint256 burnFee, uint256 marketFee) private view returns (uint256, uint256, uint256) {
uint256 tFee = ((tAmount.mul(taxFee)).div(_GRANULARITY)).div(100);
uint256 tBurn = ((tAmount.mul(burnFee)).div(_GRANULARITY)).div(100);
uint256 tMarket = ((tAmount.mul(marketFee)).div(_GRANULARITY)).div(100);
return (tFee, tBurn, tMarket);
}
function getTTransferAmount(uint256 tAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) private pure returns (uint256) {
return tAmount.sub(tFee).sub(tBurn).sub(tMarket);
}
function getTTransferAmountForSale(uint256 tAmount, uint256 tFee, uint256 tBurn, uint256 tMarket) private pure returns (uint256) {
return tAmount.add(tFee).add(tBurn).add(tMarket);
}
function _getRBasics(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
return (rAmount, rFee);
}
function _getRTransferAmount(uint256 rAmount, uint256 rFee, uint256 tBurn, uint256 tMarket, uint256 currentRate) private pure returns (uint256) {
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rBurn).sub(rMarket);
return rTransferAmount;
}
function _getRTransferAmountForSale(uint256 rAmount, uint256 rFee, uint256 tBurn, uint256 tMarket, uint256 currentRate) private pure returns (uint256) {
uint256 rBurn = tBurn.mul(currentRate);
uint256 rMarket = tMarket.mul(currentRate);
uint256 rTransferAmountForSale = rAmount.add(rFee).add(rBurn).add(rMarket);
return rTransferAmountForSale;
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _sendToBusinees(uint256 tMarket, address sender, address recipient) private {
uint256 currentRate = _getRate();
uint256 rMarket = tMarket.mul(currentRate);
if(sender == _pair && _referralOwner[recipient] != address(0)) {
_sendToReferralOwner(tMarket, rMarket, _referralOwner[recipient]);
emit Transfer(sender, _referralOwner[recipient], tMarket);
}
else {
_rOwned[_shoppingCart] = _rOwned[_shoppingCart].add(rMarket);
_tOwned[_shoppingCart] = _tOwned[_shoppingCart].add(tMarket);
emit Transfer(sender, _shoppingCart, tMarket);
}
}
function _sendToBurn(uint256 tBurn, address sender) private {
uint256 currentRate = _getRate();
uint256 rBurn = tBurn.mul(currentRate);
_rOwned[_rewardWallet] = _rOwned[_rewardWallet].add(rBurn);
_tOwned[_rewardWallet] = _tOwned[_rewardWallet].add(rBurn);
emit Transfer(sender, _rewardWallet, tBurn);
}
function _sendToReferralOwner(uint256 tMarket, uint256 rMarket, address owner) private {
if(_isExcluded[owner]) {
_rOwned[owner] = _rOwned[owner].add(rMarket);
_tOwned[owner] = _tOwned[owner].add(tMarket);
}
else {
_rOwned[owner] = _rOwned[owner].add(rMarket);
}
_referralOwnerTotalFee[owner] += tMarket;
}
function _removeFee() private {
if(_TAX_FEE == 0 && _BURN_FEE == 0 && _MARKET_FEE == 0) return;
_TAX_FEE = 0;
_BURN_FEE = 0;
_MARKET_FEE = 0;
}
function _restoreAllFee() private {
_TAX_FEE = _standardFees.taxFee.mul(100);
_BURN_FEE = _standardFees.rewardFee.mul(100);
_MARKET_FEE = _standardFees.marketFee.mul(100);
}
function _setPenaltyFee() private {
_TAX_FEE = _standardFees.taxPenaltyFee.mul(100);
_BURN_FEE = _standardFees.rewardPenaltyFee.mul(100);
_MARKET_FEE = _standardFees.marketPenaltyFee.mul(100);
}
} | 43,437 |
65 | // Calculate x / y rounding towards zero, where x and y are unsigned 256-bitinteger numbers.Revert on overflow or when y is zero.x unsigned 256-bit integer number y unsigned 256-bit integer numberreturn signed 64.64-bit fixed point number / | function divu(uint256 x, uint256 y) internal pure returns (int128) {
require(y != 0);
uint128 result = divuu(x, y);
require(result <= uint128(MAX_64x64));
return int128(result);
}
| function divu(uint256 x, uint256 y) internal pure returns (int128) {
require(y != 0);
uint128 result = divuu(x, y);
require(result <= uint128(MAX_64x64));
return int128(result);
}
| 50,883 |
45 | // don't allow the first 4 races to be removed | require(raceBaseStats.length > 4);
delete raceBaseStats[raceBaseStats.length - 1];
| require(raceBaseStats.length > 4);
delete raceBaseStats[raceBaseStats.length - 1];
| 25,495 |
100 | // Add new token gauge | function addGauge(address _token) external {
require(msg.sender == governance, "!gov");
require(gauges[_token] == address(0x0), "exists");
gauges[_token] = address(new Gauge(_token));
_tokens.push(_token);
}
| function addGauge(address _token) external {
require(msg.sender == governance, "!gov");
require(gauges[_token] == address(0x0), "exists");
gauges[_token] = address(new Gauge(_token));
_tokens.push(_token);
}
| 10,658 |
41 | // Get flight key/ | function getFlightKey(address airline, string memory flight, uint256 timestamp) pure internal returns(bytes32) {
return keccak256(abi.encodePacked(airline, flight, timestamp));
}
| function getFlightKey(address airline, string memory flight, uint256 timestamp) pure internal returns(bytes32) {
return keccak256(abi.encodePacked(airline, flight, timestamp));
}
| 26,480 |
1 | // Presale | address public _signerAddress = 0xF6bA99F2E6ce96B74d4df667C01c5ed2EF249be2;
bool public onSaleWhitelist = false;
mapping(address => uint256) public mintedWL;
uint256 public price = 0.03 ether;
uint256 public priceWL = 0.025 ether;
uint256 public maxTokensPurchase = 10;
| address public _signerAddress = 0xF6bA99F2E6ce96B74d4df667C01c5ed2EF249be2;
bool public onSaleWhitelist = false;
mapping(address => uint256) public mintedWL;
uint256 public price = 0.03 ether;
uint256 public priceWL = 0.025 ether;
uint256 public maxTokensPurchase = 10;
| 72,271 |
25 | // Emitted when a node set to in compliant or compliant. / | event IncompliantNode(
| event IncompliantNode(
| 78,943 |
18 | // admin events | event BlockLockSet(uint256 _value);
event NewAdmin(address _newAdmin);
event NewManager(address _newManager);
event NewInvestor(address _newInvestor);
event RemovedInvestor(address _investor);
event FundAssetsChanged(
string indexed tokenSymbol,
string assetInfo,
uint8 amount,
uint256 totalAssetAmount
| event BlockLockSet(uint256 _value);
event NewAdmin(address _newAdmin);
event NewManager(address _newManager);
event NewInvestor(address _newInvestor);
event RemovedInvestor(address _investor);
event FundAssetsChanged(
string indexed tokenSymbol,
string assetInfo,
uint8 amount,
uint256 totalAssetAmount
| 7,374 |
29 | // Deposit `_value` tokens for `_addr` and lock until `_unlock_time`/_addr Create lock for address/_value Amount to deposit/_unlock_time Epoch time when tokens unlock, rounded down to whole weeks | function create_lock_for(address _addr, uint _value, uint _unlock_time) external nonReentrant onlyOwner {
require(_value > 0); // dev: need non-zero value
LockedBalance memory _locked = locked[_addr];
require(_locked.amount == 0, "Withdraw old tokens first");
uint unlock_time = (_unlock_time / WEEK) * WEEK; // Locktime is rounded down to weeks
require(unlock_time > block.timestamp, "Can only lock until time in the future");
require(unlock_time <= block.timestamp + MAXTIME, "Voting lock can be 3 years max");
_deposit_for(_addr, _value, unlock_time, _locked, DepositType.CREATE_LOCK_TYPE);
}
| function create_lock_for(address _addr, uint _value, uint _unlock_time) external nonReentrant onlyOwner {
require(_value > 0); // dev: need non-zero value
LockedBalance memory _locked = locked[_addr];
require(_locked.amount == 0, "Withdraw old tokens first");
uint unlock_time = (_unlock_time / WEEK) * WEEK; // Locktime is rounded down to weeks
require(unlock_time > block.timestamp, "Can only lock until time in the future");
require(unlock_time <= block.timestamp + MAXTIME, "Voting lock can be 3 years max");
_deposit_for(_addr, _value, unlock_time, _locked, DepositType.CREATE_LOCK_TYPE);
}
| 35,969 |
768 | // Transfer the ownership of the Finder to the new Governor now that all the addresses have been updated. |
finder.transferOwnership(newGovernor);
|
finder.transferOwnership(newGovernor);
| 1,815 |
30 | // solium-disable-next-line | block.timestamp
);
return;
| block.timestamp
);
return;
| 2,456 |
22 | // Adds a friend request to the requests mapping/_to To friend address/_from From friend address | function _addRequest(address _to, FriendRequest memory _from) private {
requests[_to].push(_from);
uint index = requests[_to].length;
requestsTracker[_to][_from.sender] = index;
requestsTracker[_from.sender][_to] = index;
}
| function _addRequest(address _to, FriendRequest memory _from) private {
requests[_to].push(_from);
uint index = requests[_to].length;
requestsTracker[_to][_from.sender] = index;
requestsTracker[_from.sender][_to] = index;
}
| 42,982 |
70 | // Same as {get}, with a custom error message when `key` is not in the map. CAUTION: This function is deprecated because it requires allocating memory for the errormessage unnecessarily. For custom revert reasons use {tryGet}. / | function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
}
| function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
}
| 30,436 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.