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 |
|---|---|---|---|---|
7 | // Keep track of tokensSold | tokensSold += _numberOfTokens;
| tokensSold += _numberOfTokens;
| 22,348 |
27 | // setProvenance allows admin to set the provenance of a user | function setProvenance(address user, uint provenance)
onlyOwner
external
returns (bool)
| function setProvenance(address user, uint provenance)
onlyOwner
external
returns (bool)
| 55,509 |
140 | // Calculate geometric average of x and y, i.e. sqrt (xy) rounding down.Revert on overflow or in case xy is negative.x signed 64.64-bit fixed point number y signed 64.64-bit fixed point numberreturn signed 64.64-bit fixed point number / | function gavg (int128 x, int128 y) internal pure returns (int128) {
int256 m = int256 (x) * int256 (y);
require (m >= 0);
require (m <
0x4000000000000000000000000000000000000000000000000000000000000000);
return int128 (sqrtu (uint256 (m)));
}
| function gavg (int128 x, int128 y) internal pure returns (int128) {
int256 m = int256 (x) * int256 (y);
require (m >= 0);
require (m <
0x4000000000000000000000000000000000000000000000000000000000000000);
return int128 (sqrtu (uint256 (m)));
}
| 10,744 |
10 | // The threshold must be checked against the claimable balance, not against the amount out. The amount out is computed considering both the claimable balance and the smart vault balance in case of a swap, but if the token in is ignored, the smart vault balance must be ignored. We can leverage the call information to rate the claimable balance in the wrapped native token: | uint256 wrappedNativeTokenPrice = amountIn.divUp(expectedAmountOut);
uint256 wrappedNativeTokenClaimableBalance = claimableBalance(tokenIn).divDown(wrappedNativeTokenPrice);
_validateThreshold(wrappedNativeToken, wrappedNativeTokenClaimableBalance);
_claim(tokenIn);
payingGasToken = tokenIn;
payingGasTokenPrice = wrappedNativeTokenPrice;
| uint256 wrappedNativeTokenPrice = amountIn.divUp(expectedAmountOut);
uint256 wrappedNativeTokenClaimableBalance = claimableBalance(tokenIn).divDown(wrappedNativeTokenPrice);
_validateThreshold(wrappedNativeToken, wrappedNativeTokenClaimableBalance);
_claim(tokenIn);
payingGasToken = tokenIn;
payingGasTokenPrice = wrappedNativeTokenPrice;
| 32,006 |
39 | // Transfers the xTokens between two users. Validates the transfer(ie checks for valid HF after the transfer) if required from The source address to The destination address amount The amount getting transferred validate `true` if the transfer needs to be validated / | ) internal updateReward(from) updateReward(to) {
uint256 index =
POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS);
uint256 fromBalanceBefore = super.balanceOf(from).rayMul(index);
uint256 toBalanceBefore = super.balanceOf(to).rayMul(index);
super._transfer(from, to, amount.rayDiv(index));
if (validate) {
POOL.finalizeTransfer(
UNDERLYING_ASSET_ADDRESS,
from,
to,
amount,
fromBalanceBefore,
toBalanceBefore
);
}
emit BalanceTransfer(from, to, amount, index);
}
| ) internal updateReward(from) updateReward(to) {
uint256 index =
POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS);
uint256 fromBalanceBefore = super.balanceOf(from).rayMul(index);
uint256 toBalanceBefore = super.balanceOf(to).rayMul(index);
super._transfer(from, to, amount.rayDiv(index));
if (validate) {
POOL.finalizeTransfer(
UNDERLYING_ASSET_ADDRESS,
from,
to,
amount,
fromBalanceBefore,
toBalanceBefore
);
}
emit BalanceTransfer(from, to, amount, index);
}
| 77,768 |
5 | // Send allocated base to the dev | if (base_allocated > max_base_allocated) {
base_allocated = max_base_allocated;
}
| if (base_allocated > max_base_allocated) {
base_allocated = max_base_allocated;
}
| 7,115 |
121 | // Destroys `tokenId`.The approval is cleared when the token is burned. Requirements: - `tokenId` must exist. | * Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
| * Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
| 44,201 |
12 | // list of flags determines whether the SecondaryTradingLimit & TransactionCountLimit are enabled.bool-values which will show if the limits have to be switch-ON (see contract {Limits}):enableLimits[0] - true: the SecondaryTradingLimit will be switchON, false: switchOFFenableLimits[1] - true: the TransactionCountLimit will be switchON, false: switchOFF | bool[2] memory _enableLimits,
| bool[2] memory _enableLimits,
| 24,115 |
4 | // Creating an array of campaigns | Campaign[] memory campaignList = new Campaign[](numberOfCampaigns);
for(uint i = 0; i < numberOfCampaigns; i++) {
Campaign storage item = campaigns[i];
campaignList[i] = item;
}
| Campaign[] memory campaignList = new Campaign[](numberOfCampaigns);
for(uint i = 0; i < numberOfCampaigns; i++) {
Campaign storage item = campaigns[i];
campaignList[i] = item;
}
| 13,641 |
468 | // Upgrades from old implementations will perform a rollback test. This test requires the new implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing this special case will break upgrade paths from old UUPS implementation to new ones. | if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
| if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
| 74,178 |
63 | // Transfer the wrapped ether to this address from the Vault | coreInstance.withdrawModule(
address(this),
address(this),
address(weth),
currentComponentQuantity
);
| coreInstance.withdrawModule(
address(this),
address(this),
address(weth),
currentComponentQuantity
);
| 44,340 |
10 | // MAINNET uint256 public tombPerSecond = 0.11574 ether;10000 TOMB / (24h60min60s) uint256 public runningTime = 1 days;1 days uint256 public constant TOTAL_REWARDS = 10000 ether; END MAINNET |
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
event RewardPaid(address indexed user, uint256 amount);
constructor(
address _tomb,
address _shiba,
uint256 _poolStartTime
|
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
event RewardPaid(address indexed user, uint256 amount);
constructor(
address _tomb,
address _shiba,
uint256 _poolStartTime
| 26,391 |
61 | // check the purchase record of the buyer | uint newPurchaseRecord = flashSaleIDToPurchaseRecord[_saleID][msg.sender].add(_amount);
require(newPurchaseRecord <= flashSale.purchaseLimitation,
"total amount to purchase exceeds the limitation of an address");
| uint newPurchaseRecord = flashSaleIDToPurchaseRecord[_saleID][msg.sender].add(_amount);
require(newPurchaseRecord <= flashSale.purchaseLimitation,
"total amount to purchase exceeds the limitation of an address");
| 1,119 |
15 | // Allows the current owner to relinquish control of the contract. Renouncing to ownership will leave the contract without an owner.It will not be possible to call the functions with the `onlyOwner`modifier anymore. / | function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(_owner);
_owner = address(0);
}
| function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(_owner);
_owner = address(0);
}
| 21,489 |
11 | // Returns the crowdsale status. If the crowdsale has not started, returns NOT_STARTED./if crowdsale had been initialized, calls underlying crowdsale.status()./ return CrowdsaleStatus enum value. | function crowdsaleStatus() public view returns (CrowdsaleStatus) {
if (address(crowdsale) == address(0)) {
return CrowdsaleStatus.NOT_PLANNED;
}
return crowdsale.status();
}
| function crowdsaleStatus() public view returns (CrowdsaleStatus) {
if (address(crowdsale) == address(0)) {
return CrowdsaleStatus.NOT_PLANNED;
}
return crowdsale.status();
}
| 34,023 |
61 | // Address of primary wallet | address payable public walletAddress;
| address payable public walletAddress;
| 51,069 |
172 | // Total amount the strategy is expected to have | uint256 totalStrategyDebt;
| uint256 totalStrategyDebt;
| 38,174 |
88 | // shift premium from settled rounds with rounds control | uint maxRound = _options[i].getRound();
for (uint r = _options[i].getSettledPremiumRound(account) + 1; r < maxRound; r++) {
uint roundPremium = _options[i].getRoundPremiumShare(r)
.mul(accountCollateral)
.div(1e18); // remember to div by 1e18
| uint maxRound = _options[i].getRound();
for (uint r = _options[i].getSettledPremiumRound(account) + 1; r < maxRound; r++) {
uint roundPremium = _options[i].getRoundPremiumShare(r)
.mul(accountCollateral)
.div(1e18); // remember to div by 1e18
| 18,430 |
10 | // getting the amount of Ether sent to the owner which is the owner royality | uint256 royaltyAmount = getAmount(originalAmount, ownerRoyalty);
| uint256 royaltyAmount = getAmount(originalAmount, ownerRoyalty);
| 25,981 |
12 | // BaseCrowdsale Extends from Crowdsale with more stuffs like TimedCrowdsale, CappedCrowdsale. Base for any other Crowdsale contract / | contract BaseCrowdsale is TimedCrowdsale, CappedCrowdsale, TokenRecover {
// reference to Contributions contract
Contributions private _contributions;
// the minimum value of contribution in wei
uint256 private _minimumContribution;
/**
* @dev Reverts if less than minimum contribution
*/
modifier onlyGreaterThanMinimum(uint256 weiAmount) {
require(weiAmount >= _minimumContribution);
_;
}
/**
* @param openingTime Crowdsale opening time
* @param closingTime Crowdsale closing time
* @param rate Number of token units a buyer gets per wei
* @param wallet Address where collected funds will be forwarded to
* @param cap Max amount of wei to be contributed
* @param minimumContribution Min amount of wei to be contributed
* @param token Address of the token being sold
* @param contributions Address of the contributions contract
*/
constructor(
uint256 openingTime,
uint256 closingTime,
uint256 rate,
address payable wallet,
uint256 cap,
uint256 minimumContribution,
address token,
address contributions
)
public
Crowdsale(rate, wallet, ERC20(token))
TimedCrowdsale(openingTime, closingTime)
CappedCrowdsale(cap)
{
require(contributions != address(0));
_contributions = Contributions(contributions);
_minimumContribution = minimumContribution;
}
/**
* @return the crowdsale contributions contract address
*/
function contributions() public view returns (Contributions) {
return _contributions;
}
/**
* @return the minimum value of contribution in wei
*/
function minimumContribution() public view returns (uint256) {
return _minimumContribution;
}
/**
* @return false if the ico is not started, true if the ico is started and running, true if the ico is completed
*/
function started() public view returns (bool) {
return block.timestamp >= openingTime(); // solhint-disable-line not-rely-on-time
}
/**
* @return false if the ico is not started, false if the ico is started and running, true if the ico is completed
*/
function ended() public view returns (bool) {
return hasClosed() || capReached();
}
/**
* @dev Extend crowdsale closing date
* @param closingTime Crowdsale closing time
*/
function extendTime(uint256 closingTime) public onlyOwner {
_extendTime(closingTime);
}
/**
* @dev Extend parent behavior requiring purchase to respect the minimumContribution.
* @param beneficiary Token purchaser
* @param weiAmount Amount of wei contributed
*/
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal onlyGreaterThanMinimum(weiAmount) view { // solhint-disable-line max-line-length
super._preValidatePurchase(beneficiary, weiAmount);
}
/**
* @dev Update the contributions contract states
* @param beneficiary Address receiving the tokens
* @param weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {
super._updatePurchasingState(beneficiary, weiAmount);
_contributions.addBalance(
beneficiary,
weiAmount,
_getTokenAmount(weiAmount)
);
}
}
| contract BaseCrowdsale is TimedCrowdsale, CappedCrowdsale, TokenRecover {
// reference to Contributions contract
Contributions private _contributions;
// the minimum value of contribution in wei
uint256 private _minimumContribution;
/**
* @dev Reverts if less than minimum contribution
*/
modifier onlyGreaterThanMinimum(uint256 weiAmount) {
require(weiAmount >= _minimumContribution);
_;
}
/**
* @param openingTime Crowdsale opening time
* @param closingTime Crowdsale closing time
* @param rate Number of token units a buyer gets per wei
* @param wallet Address where collected funds will be forwarded to
* @param cap Max amount of wei to be contributed
* @param minimumContribution Min amount of wei to be contributed
* @param token Address of the token being sold
* @param contributions Address of the contributions contract
*/
constructor(
uint256 openingTime,
uint256 closingTime,
uint256 rate,
address payable wallet,
uint256 cap,
uint256 minimumContribution,
address token,
address contributions
)
public
Crowdsale(rate, wallet, ERC20(token))
TimedCrowdsale(openingTime, closingTime)
CappedCrowdsale(cap)
{
require(contributions != address(0));
_contributions = Contributions(contributions);
_minimumContribution = minimumContribution;
}
/**
* @return the crowdsale contributions contract address
*/
function contributions() public view returns (Contributions) {
return _contributions;
}
/**
* @return the minimum value of contribution in wei
*/
function minimumContribution() public view returns (uint256) {
return _minimumContribution;
}
/**
* @return false if the ico is not started, true if the ico is started and running, true if the ico is completed
*/
function started() public view returns (bool) {
return block.timestamp >= openingTime(); // solhint-disable-line not-rely-on-time
}
/**
* @return false if the ico is not started, false if the ico is started and running, true if the ico is completed
*/
function ended() public view returns (bool) {
return hasClosed() || capReached();
}
/**
* @dev Extend crowdsale closing date
* @param closingTime Crowdsale closing time
*/
function extendTime(uint256 closingTime) public onlyOwner {
_extendTime(closingTime);
}
/**
* @dev Extend parent behavior requiring purchase to respect the minimumContribution.
* @param beneficiary Token purchaser
* @param weiAmount Amount of wei contributed
*/
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal onlyGreaterThanMinimum(weiAmount) view { // solhint-disable-line max-line-length
super._preValidatePurchase(beneficiary, weiAmount);
}
/**
* @dev Update the contributions contract states
* @param beneficiary Address receiving the tokens
* @param weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {
super._updatePurchasingState(beneficiary, weiAmount);
_contributions.addBalance(
beneficiary,
weiAmount,
_getTokenAmount(weiAmount)
);
}
}
| 22,395 |
656 | // burn claimed shares | _hypervisor.rewardSharesOutstanding = _hypervisor.rewardSharesOutstanding.sub(sharesToBurn);
| _hypervisor.rewardSharesOutstanding = _hypervisor.rewardSharesOutstanding.sub(sharesToBurn);
| 40,805 |
37 | // 20% Finder allocation | uint256 public purchasableTokens = 112000 * 10**18;
uint256 public founderAllocation = 28000 * 10**18;
string public name = "TeamHODL Token";
string public symbol = "THODL";
uint256 public decimals = 18;
uint256 public INITIAL_SUPPLY = 140000 * 10**18;
uint256 public RATE = 200;
uint256 public REFUND_RATE = 200;
| uint256 public purchasableTokens = 112000 * 10**18;
uint256 public founderAllocation = 28000 * 10**18;
string public name = "TeamHODL Token";
string public symbol = "THODL";
uint256 public decimals = 18;
uint256 public INITIAL_SUPPLY = 140000 * 10**18;
uint256 public RATE = 200;
uint256 public REFUND_RATE = 200;
| 26,511 |
9 | // Crystal TokenID => CrystalInfo | mapping(uint256 => CrystalInfo) public crystals;
| mapping(uint256 => CrystalInfo) public crystals;
| 45,141 |
164 | // this prevents the secondary token being itself and therefore negating burn | require(address(_token) != address(this), 'Secondary token cannot be itself');
| require(address(_token) != address(this), 'Secondary token cannot be itself');
| 38,318 |
19 | // WithdrawDelegatorRewards defines an Event emitted when rewards from a delegation are withdrawn/delegatorAddress the address of the delegator/validatorAddress the address of the validator/amount the amount being withdrawn from the delegation | event WithdrawDelegatorRewards(
address indexed delegatorAddress,
string indexed validatorAddress,
uint256 amount
);
| event WithdrawDelegatorRewards(
address indexed delegatorAddress,
string indexed validatorAddress,
uint256 amount
);
| 32,019 |
12 | // fee | 0,
| 0,
| 18,010 |
63 | // stage 3linear equation: y = 6.72202×10^-7 x - 0.361011intercepts (1000000,0.311191) and (5000000,3) | if (x >= 1000000000000000000000000) {
return (((x).mul(2688809)).div(4000000000000)).sub(361011250000000000);
}
| if (x >= 1000000000000000000000000) {
return (((x).mul(2688809)).div(4000000000000)).sub(361011250000000000);
}
| 13,944 |
29 | // Eyes N°30 => RIP | function item_30() public pure returns (string memory) {
return
base(
string(
abi.encodePacked(
'<line fill="none" stroke="#000000" stroke-width="3" stroke-linecap="square" stroke-miterlimit="10" x1="225.7" y1="190.8" x2="242.7" y2="207.8"/>',
'<line fill="none" stroke="#000000" stroke-width="3" stroke-linecap="square" stroke-miterlimit="10" x1="225.7" y1="207.8" x2="243.1" y2="190.8"/>',
'<line fill="none" stroke="#000000" stroke-width="3" stroke-linecap="square" stroke-miterlimit="10" x1="152.8" y1="190.8" x2="169.8" y2="207.8"/>',
'<line fill="none" stroke="#000000" stroke-width="3" stroke-linecap="square" stroke-miterlimit="10" x1="152.8" y1="207.8" x2="170.3" y2="190.8"/>'
)
)
);
}
| function item_30() public pure returns (string memory) {
return
base(
string(
abi.encodePacked(
'<line fill="none" stroke="#000000" stroke-width="3" stroke-linecap="square" stroke-miterlimit="10" x1="225.7" y1="190.8" x2="242.7" y2="207.8"/>',
'<line fill="none" stroke="#000000" stroke-width="3" stroke-linecap="square" stroke-miterlimit="10" x1="225.7" y1="207.8" x2="243.1" y2="190.8"/>',
'<line fill="none" stroke="#000000" stroke-width="3" stroke-linecap="square" stroke-miterlimit="10" x1="152.8" y1="190.8" x2="169.8" y2="207.8"/>',
'<line fill="none" stroke="#000000" stroke-width="3" stroke-linecap="square" stroke-miterlimit="10" x1="152.8" y1="207.8" x2="170.3" y2="190.8"/>'
)
)
);
}
| 43,834 |
225 | // Harvest staking reward tokens to in-exec position's owner/wstaking Wrapped staking rewards | function harvestWStakingRewards(address wstaking) external {
(, address collToken, uint collId, ) = bank.getCurrentPositionInfo();
address lp = IWStakingRewards(wstaking).getUnderlyingToken(collId);
require(whitelistedLpTokens[lp], 'lp token not whitelisted');
require(collToken == wstaking, 'collateral token & wstaking mismatched');
// 1. Take out collateral
bank.takeCollateral(wstaking, collId, uint(-1));
IWStakingRewards(wstaking).burn(collId, uint(-1));
// 2. put collateral
uint amount = IERC20(lp).balanceOf(address(this));
ensureApprove(lp, wstaking);
uint id = IWStakingRewards(wstaking).mint(amount);
bank.putCollateral(wstaking, id, amount);
// 3. Refund reward
doRefund(IWStakingRewards(wstaking).reward());
}
| function harvestWStakingRewards(address wstaking) external {
(, address collToken, uint collId, ) = bank.getCurrentPositionInfo();
address lp = IWStakingRewards(wstaking).getUnderlyingToken(collId);
require(whitelistedLpTokens[lp], 'lp token not whitelisted');
require(collToken == wstaking, 'collateral token & wstaking mismatched');
// 1. Take out collateral
bank.takeCollateral(wstaking, collId, uint(-1));
IWStakingRewards(wstaking).burn(collId, uint(-1));
// 2. put collateral
uint amount = IERC20(lp).balanceOf(address(this));
ensureApprove(lp, wstaking);
uint id = IWStakingRewards(wstaking).mint(amount);
bank.putCollateral(wstaking, id, amount);
// 3. Refund reward
doRefund(IWStakingRewards(wstaking).reward());
}
| 54,140 |
3 | // Verifique se o usuário possui o token Episode | require(balanceOf[msg.sender][_tokenId] > 0, "You do not own this Episode");
| require(balanceOf[msg.sender][_tokenId] > 0, "You do not own this Episode");
| 25,574 |
39 | // TODO: Optimize by using assembly | bidHash = keccak256(
abi.encode(
BID_TYPEHASH,
bid.itemKind,
bid.maker,
bid.token,
bid.identifierOrCriteria,
bid.unitPrice,
bid.amount,
bid.salt,
| bidHash = keccak256(
abi.encode(
BID_TYPEHASH,
bid.itemKind,
bid.maker,
bid.token,
bid.identifierOrCriteria,
bid.unitPrice,
bid.amount,
bid.salt,
| 8,815 |
14 | // Function to create the "node" in the merkle tree, given account and allocation/account the account/percent the allocation/ return the bytes32 representing the node / leaf | function getNode(address account, uint256 percent)
public
pure
returns (bytes32)
| function getNode(address account, uint256 percent)
public
pure
returns (bytes32)
| 2,095 |
22 | // Get the configs. | TokenConfig storage config = getConfig(_key);
| TokenConfig storage config = getConfig(_key);
| 30,135 |
248 | // Receipt methods | function toBytes(Receipt memory receipt) internal pure returns(bytes memory) {
return receipt.raw;
}
| function toBytes(Receipt memory receipt) internal pure returns(bytes memory) {
return receipt.raw;
}
| 55,837 |
769 | // Calculates and returns active stake for address Active stake = (active deployer stake + active delegator stake) active deployer stake = (direct deployer stake - locked deployer stake) locked deployer stake = amount of pending decreaseStakeRequest for address active delegator stake = (total delegator stake - locked delegator stake) locked delegator stake = amount of pending undelegateRequest for address / | function _calculateAddressActiveStake(address _address) private view returns (uint256) {
ServiceProviderFactory spFactory = ServiceProviderFactory(serviceProviderFactoryAddress);
DelegateManager delegateManager = DelegateManager(delegateManagerAddress);
// Amount directly staked by address, if any, in ServiceProviderFactory
(uint256 directDeployerStake,,,,,) = spFactory.getServiceProviderDetails(_address);
// Amount of pending decreasedStakeRequest for address, if any, in ServiceProviderFactory
(uint256 lockedDeployerStake,) = spFactory.getPendingDecreaseStakeRequest(_address);
// active deployer stake = (direct deployer stake - locked deployer stake)
uint256 activeDeployerStake = directDeployerStake.sub(lockedDeployerStake);
// Total amount delegated by address, if any, in DelegateManager
uint256 totalDelegatorStake = delegateManager.getTotalDelegatorStake(_address);
// Amount of pending undelegateRequest for address, if any, in DelegateManager
(,uint256 lockedDelegatorStake, ) = delegateManager.getPendingUndelegateRequest(_address);
// active delegator stake = (total delegator stake - locked delegator stake)
uint256 activeDelegatorStake = totalDelegatorStake.sub(lockedDelegatorStake);
// activeStake = (activeDeployerStake + activeDelegatorStake)
uint256 activeStake = activeDeployerStake.add(activeDelegatorStake);
return activeStake;
}
| function _calculateAddressActiveStake(address _address) private view returns (uint256) {
ServiceProviderFactory spFactory = ServiceProviderFactory(serviceProviderFactoryAddress);
DelegateManager delegateManager = DelegateManager(delegateManagerAddress);
// Amount directly staked by address, if any, in ServiceProviderFactory
(uint256 directDeployerStake,,,,,) = spFactory.getServiceProviderDetails(_address);
// Amount of pending decreasedStakeRequest for address, if any, in ServiceProviderFactory
(uint256 lockedDeployerStake,) = spFactory.getPendingDecreaseStakeRequest(_address);
// active deployer stake = (direct deployer stake - locked deployer stake)
uint256 activeDeployerStake = directDeployerStake.sub(lockedDeployerStake);
// Total amount delegated by address, if any, in DelegateManager
uint256 totalDelegatorStake = delegateManager.getTotalDelegatorStake(_address);
// Amount of pending undelegateRequest for address, if any, in DelegateManager
(,uint256 lockedDelegatorStake, ) = delegateManager.getPendingUndelegateRequest(_address);
// active delegator stake = (total delegator stake - locked delegator stake)
uint256 activeDelegatorStake = totalDelegatorStake.sub(lockedDelegatorStake);
// activeStake = (activeDeployerStake + activeDelegatorStake)
uint256 activeStake = activeDeployerStake.add(activeDelegatorStake);
return activeStake;
}
| 41,557 |
153 | // check if the _data.length > 0 and if it is forward it to the newly created contract | let dataLength := mload(_data)
if iszero(iszero(dataLength)) {
if iszero(call(gas, proxyContract, 0, add(_data, 0x20), dataLength, 0, 0)) {
revert(0, 0)
}
| let dataLength := mload(_data)
if iszero(iszero(dataLength)) {
if iszero(call(gas, proxyContract, 0, add(_data, 0x20), dataLength, 0, 0)) {
revert(0, 0)
}
| 5,303 |
100 | // We need to swap the current tokens to ETH and send to the ext wallet | swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToTeamDev(address(this).balance);
}
| swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToTeamDev(address(this).balance);
}
| 26,323 |
5 | // @custom:security-contact security@ethereum-tx.com | contract EthereumTx is ERC20, ERC20Burnable, Pausable, Ownable {
constructor() ERC20("Ethereum-tx", "ETX") {
_mint(msg.sender, 21000000 * 10 ** decimals());
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
whenNotPaused
override
{
super._beforeTokenTransfer(from, to, amount);
}
}
| contract EthereumTx is ERC20, ERC20Burnable, Pausable, Ownable {
constructor() ERC20("Ethereum-tx", "ETX") {
_mint(msg.sender, 21000000 * 10 ** decimals());
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
whenNotPaused
override
{
super._beforeTokenTransfer(from, to, amount);
}
}
| 29,377 |
49 | // Case 3: The layer has a rare Cryptopunk variant and it will activate | layer == genesis.punk[0] &&
remainingPunkMutations > 0 &&
variant < RARE_VARIANT_PROBABILITY
) {
| layer == genesis.punk[0] &&
remainingPunkMutations > 0 &&
variant < RARE_VARIANT_PROBABILITY
) {
| 50,114 |
117 | // Delete Methods | function deleteUint(bytes32 _key) external onlyCurrentOwner {
delete uIntStorage[_key];
}
| function deleteUint(bytes32 _key) external onlyCurrentOwner {
delete uIntStorage[_key];
}
| 14,568 |
9 | // Map of the users data | mapping(address => UserRecord) private user_data;
| mapping(address => UserRecord) private user_data;
| 60,924 |
297 | // returns whether the pool is valid / | function isPoolValid(Token pool) external view returns (bool);
| function isPoolValid(Token pool) external view returns (bool);
| 64,995 |
71 | // get rate update block | bytes32 compactData = tokenRatesCompactData[tokenData[token].compactDataArrayIndex];
uint updateRateBlock = getLast4Bytes(compactData);
if (currentBlockNumber >= updateRateBlock + validRateDurationInBlocks) return 0; // rate is expired
| bytes32 compactData = tokenRatesCompactData[tokenData[token].compactDataArrayIndex];
uint updateRateBlock = getLast4Bytes(compactData);
if (currentBlockNumber >= updateRateBlock + validRateDurationInBlocks) return 0; // rate is expired
| 17,809 |
10 | // Read the amount of LP_expiry staked for a user / | function getBalances(uint256 expiry, address user) external view returns (uint256);
| function getBalances(uint256 expiry, address user) external view returns (uint256);
| 8,137 |
0 | // @inheritdoc IERC165 / | function supportsInterface(bytes4 interfaceId) public view returns (bool) {
return ERC165Storage.layout().isSupportedInterface(interfaceId);
}
| function supportsInterface(bytes4 interfaceId) public view returns (bool) {
return ERC165Storage.layout().isSupportedInterface(interfaceId);
}
| 20,301 |
7 | // Calculate and mint the amount of xGDL the GDL is worth. The ratio will change overtime, as xGDL is burned/minted and GDL deposited + gained from fees / withdrawn. | else {
uint256 what = _amount.mul(totalShares).div(totalGDL);
_mint(msg.sender, what);
}
| else {
uint256 what = _amount.mul(totalShares).div(totalGDL);
_mint(msg.sender, what);
}
| 8,796 |
194 | // We split this out because we need to rebuild the cache after adding synths. | function setCurrencies() external onlyOwner {
for (uint i = 0; i < synths.length; i++) {
ISynth synth = ISynth(requireAndGetAddress(synths[i]));
synthsByKey[synth.currencyKey()] = synths[i];
}
}
| function setCurrencies() external onlyOwner {
for (uint i = 0; i < synths.length; i++) {
ISynth synth = ISynth(requireAndGetAddress(synths[i]));
synthsByKey[synth.currencyKey()] = synths[i];
}
}
| 38,818 |
0 | // _feeThousandthsPercent The fee percentage with three decimal places. _minFeeAmount The minimuim fee to charge. / | constructor(uint16 _feeThousandthsPercent, uint256 _minFeeAmount) public {
require(_feeThousandthsPercent < (1 << 16), "fee % too high");
require(_minFeeAmount <= (1 << 255), "minFeeAmount too high");
feeThousandthsPercent = _feeThousandthsPercent;
minFeeAmount = _minFeeAmount;
}
| constructor(uint16 _feeThousandthsPercent, uint256 _minFeeAmount) public {
require(_feeThousandthsPercent < (1 << 16), "fee % too high");
require(_minFeeAmount <= (1 << 255), "minFeeAmount too high");
feeThousandthsPercent = _feeThousandthsPercent;
minFeeAmount = _minFeeAmount;
}
| 32,142 |
53 | // Add `elastic` and `base` to `total`. | function add(
Rebase memory total,
uint256 elastic,
uint256 base
| function add(
Rebase memory total,
uint256 elastic,
uint256 base
| 45,399 |
28 | // shit doesn't really matter cuz after big fibonnaci daz we go down to25-golden ratio, so need not to remember until then | function rapidAdoptionBoost() public {
if(rapidAdoptionBoost) { reject "already been activated"; }
if(block.timestamp < 22.september) { reject "rapidAdoptionBoost can only be activated after this period" }
rapidAdoptionBoost = true;
}
| function rapidAdoptionBoost() public {
if(rapidAdoptionBoost) { reject "already been activated"; }
if(block.timestamp < 22.september) { reject "rapidAdoptionBoost can only be activated after this period" }
rapidAdoptionBoost = true;
}
| 35,379 |
14 | // ________________________________________________________/Constrctor function / | function CrowdSaleMacroansyA() public {
owner = msg.sender;
beneficiaryFunds = owner;
saleParamSet = false;
fundingGoalReached = false;
crowdsaleStart = false;
crowdsaleClosed = false;
unlockFundersBalance = false;
}
| function CrowdSaleMacroansyA() public {
owner = msg.sender;
beneficiaryFunds = owner;
saleParamSet = false;
fundingGoalReached = false;
crowdsaleStart = false;
crowdsaleClosed = false;
unlockFundersBalance = false;
}
| 9,356 |
20 | // Sets time to generate new charity_time donation time/ | function setSendDonationTime(uint256 _time) public isOwner {
sendDonationTime = _time;
}
| function setSendDonationTime(uint256 _time) public isOwner {
sendDonationTime = _time;
}
| 38,043 |
113 | // verify if sessionPubkeyHash was verified already, if not.. let's do it! | if (oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] == false){
oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = oraclize_randomDS_proofVerify__sessionKeyValidity(proof, sig2offset);
}
| if (oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] == false){
oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = oraclize_randomDS_proofVerify__sessionKeyValidity(proof, sig2offset);
}
| 12,237 |
298 | // Mapping of SetToken to boolean indicating if SetToken is on allow list. Updateable by governance | mapping(ISetToken => bool) public allowedSetTokens;
| mapping(ISetToken => bool) public allowedSetTokens;
| 2,827 |
176 | // Triggered when a manager is removed | event DelManager(address indexed _managerAddr, uint256 _timestamp);
| event DelManager(address indexed _managerAddr, uint256 _timestamp);
| 10,463 |
156 | // Block till deflationary update tokens per block ( 24h x 60sec x 60 min / 3sec : time per block ) | uint256 newBlockToUpdate = 24 * 60 * 60 / 3;
uint256 blockSinceDeflate = block.number.sub( startBlock.add( blockBeforeDeflationary) );
uint256 deflateNumber = ( blockSinceDeflate.sub( blockSinceDeflate.mod( newBlockToUpdate ) ) ).div( newBlockToUpdate );
if (deflateNumber >= 5){
newTokenPerBlock = 0;
}
| uint256 newBlockToUpdate = 24 * 60 * 60 / 3;
uint256 blockSinceDeflate = block.number.sub( startBlock.add( blockBeforeDeflationary) );
uint256 deflateNumber = ( blockSinceDeflate.sub( blockSinceDeflate.mod( newBlockToUpdate ) ) ).div( newBlockToUpdate );
if (deflateNumber >= 5){
newTokenPerBlock = 0;
}
| 31,537 |
22 | // Upgrade costs in HXP for all lvls | config["UPGR0"] = 5000;
config["UPGR1"] = 200000;
config["UPGR2"] = 800000;
config["UPGR3"] = 1200000;
| config["UPGR0"] = 5000;
config["UPGR1"] = 200000;
config["UPGR2"] = 800000;
config["UPGR3"] = 1200000;
| 42,674 |
82 | // variables | address public stolAddress; // The address for the STOL tokens
uint256 public minPercentClaim = 4000; // Initial conditions are 4% of USD value of STOL holdings can be claimed
uint256 public minClaimWindow = 3 days; // User must wait at least 3 days after last deposit action to claim
uint256 public maxAccumulatedClaim = 96000; // The maximum claim percent after the accumulation period has expired
uint256 public accumulationWindow = 177 days; // Window when accumulation will grow
bool public usingEthSpentOracle = false; // Governance can switch to ETH oracle or not to determine eth balances
uint256 private _minSTBZStaked = 50e18; // Initially requires 50 STBZ to stake in order to be eligible
address public stakerAddress; // The address for the staker
address public priceOracleAddress; // The address of the price oracle
address public ethSpentOracleAddress; // Address of the eth spent oracle
| address public stolAddress; // The address for the STOL tokens
uint256 public minPercentClaim = 4000; // Initial conditions are 4% of USD value of STOL holdings can be claimed
uint256 public minClaimWindow = 3 days; // User must wait at least 3 days after last deposit action to claim
uint256 public maxAccumulatedClaim = 96000; // The maximum claim percent after the accumulation period has expired
uint256 public accumulationWindow = 177 days; // Window when accumulation will grow
bool public usingEthSpentOracle = false; // Governance can switch to ETH oracle or not to determine eth balances
uint256 private _minSTBZStaked = 50e18; // Initially requires 50 STBZ to stake in order to be eligible
address public stakerAddress; // The address for the staker
address public priceOracleAddress; // The address of the price oracle
address public ethSpentOracleAddress; // Address of the eth spent oracle
| 30,446 |
20 | // burn a token/tokenId the token id | function _burn(uint256 tokenId)
internal
override(ERC721Upgradeable, ERC721URIStorageUpgradeable)
| function _burn(uint256 tokenId)
internal
override(ERC721Upgradeable, ERC721URIStorageUpgradeable)
| 25,162 |
20 | // If the staker already has tokens staked, calculate and add any unclaimed rewards | if (staker.amountStaked > 0) {
uint256 rewards = calculateRewards(msg.sender);
staker.unclaimedRewards += rewards;
}
| if (staker.amountStaked > 0) {
uint256 rewards = calculateRewards(msg.sender);
staker.unclaimedRewards += rewards;
}
| 14,093 |
126 | // Changes the existing Minimum cover period (in days) | function _changeMinDays(uint _days) internal {
minDays = _days;
}
| function _changeMinDays(uint _days) internal {
minDays = _days;
}
| 28,647 |
0 | // Safely converts a uint256 to an int256. / | function toInt256Safe(uint256 a)
internal
pure
returns (int256)
| function toInt256Safe(uint256 a)
internal
pure
returns (int256)
| 37,434 |
137 | // Owner initates the transfer of the card to another account/_to The address for the card to be transferred to./_divCardId The ID of the card that can be transferred if this call succeeds./Required for ERC-721 compliance. | function transfer(address _to, uint _divCardId)
public
isNotContract
| function transfer(address _to, uint _divCardId)
public
isNotContract
| 24,314 |
29 | // Decrease the _amount of tokens that an owner has allowed to a _spender. _spender The address which will spend the funds. _subtractedValue The _amount of tokens to decrease the allowance by. / | function decreaseAllowance(address _spender, uint256 _subtractedValue)
public
override
returns (bool)
| function decreaseAllowance(address _spender, uint256 _subtractedValue)
public
override
returns (bool)
| 36,225 |
211 | // The NokuCustomERC20AdvancedToken contract is a custom ERC20AdvancedLite, a security token ERC20-compliant, token available in the Noku Service Platform (NSP). The Noku customer is able to choose the token name, symbol, decimals, initial supply and to administer its lifecycle by minting or burning tokens in order to increase or decrease the token supply./ | contract NokuCustomERC20AdvancedLite is NokuCustomTokenLite, BasicSecurityTokenWithDecimals {
event LogNokuCustomERC20AdvancedLiteCreated(
address indexed caller,
string indexed name,
string indexed symbol,
uint8 decimals
);
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals,
bool _enableWhitelist
)
NokuCustomTokenLite()
BasicSecurityTokenWithDecimals(_name, _symbol, _decimals, _enableWhitelist) {
emit LogNokuCustomERC20AdvancedLiteCreated(
_msgSender(),
_name,
_symbol,
_decimals
);
}
} | contract NokuCustomERC20AdvancedLite is NokuCustomTokenLite, BasicSecurityTokenWithDecimals {
event LogNokuCustomERC20AdvancedLiteCreated(
address indexed caller,
string indexed name,
string indexed symbol,
uint8 decimals
);
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals,
bool _enableWhitelist
)
NokuCustomTokenLite()
BasicSecurityTokenWithDecimals(_name, _symbol, _decimals, _enableWhitelist) {
emit LogNokuCustomERC20AdvancedLiteCreated(
_msgSender(),
_name,
_symbol,
_decimals
);
}
} | 32,475 |
172 | // runtime proto sol library | library Pb {
enum WireType {
Varint,
Fixed64,
LengthDelim,
StartGroup,
EndGroup,
Fixed32
}
struct Buffer {
uint256 idx; // the start index of next read. when idx=b.length, we're done
bytes b; // hold serialized proto msg, readonly
}
// create a new in-memory Buffer object from raw msg bytes
function fromBytes(bytes memory raw) internal pure returns (Buffer memory buf) {
buf.b = raw;
buf.idx = 0;
}
// whether there are unread bytes
function hasMore(Buffer memory buf) internal pure returns (bool) {
return buf.idx < buf.b.length;
}
// decode current field number and wiretype
function decKey(Buffer memory buf) internal pure returns (uint256 tag, WireType wiretype) {
uint256 v = decVarint(buf);
tag = v / 8;
wiretype = WireType(v & 7);
}
// count tag occurrences, return an array due to no memory map support
// have to create array for (maxtag+1) size. cnts[tag] = occurrences
// should keep buf.idx unchanged because this is only a count function
function cntTags(Buffer memory buf, uint256 maxtag) internal pure returns (uint256[] memory cnts) {
uint256 originalIdx = buf.idx;
cnts = new uint256[](maxtag + 1); // protobuf's tags are from 1 rather than 0
uint256 tag;
WireType wire;
while (hasMore(buf)) {
(tag, wire) = decKey(buf);
cnts[tag] += 1;
skipValue(buf, wire);
}
buf.idx = originalIdx;
}
// read varint from current buf idx, move buf.idx to next read, return the int value
function decVarint(Buffer memory buf) internal pure returns (uint256 v) {
bytes10 tmp; // proto int is at most 10 bytes (7 bits can be used per byte)
bytes memory bb = buf.b; // get buf.b mem addr to use in assembly
v = buf.idx; // use v to save one additional uint variable
assembly {
tmp := mload(add(add(bb, 32), v)) // load 10 bytes from buf.b[buf.idx] to tmp
}
uint256 b; // store current byte content
v = 0; // reset to 0 for return value
for (uint256 i = 0; i < 10; i++) {
assembly {
b := byte(i, tmp) // don't use tmp[i] because it does bound check and costs extra
}
v |= (b & 0x7F) << (i * 7);
if (b & 0x80 == 0) {
buf.idx += i + 1;
return v;
}
}
revert(); // i=10, invalid varint stream
}
// read length delimited field and return bytes
function decBytes(Buffer memory buf) internal pure returns (bytes memory b) {
uint256 len = decVarint(buf);
uint256 end = buf.idx + len;
require(end <= buf.b.length); // avoid overflow
b = new bytes(len);
bytes memory bufB = buf.b; // get buf.b mem addr to use in assembly
uint256 bStart;
uint256 bufBStart = buf.idx;
assembly {
bStart := add(b, 32)
bufBStart := add(add(bufB, 32), bufBStart)
}
for (uint256 i = 0; i < len; i += 32) {
assembly {
mstore(add(bStart, i), mload(add(bufBStart, i)))
}
}
buf.idx = end;
}
// return packed ints
function decPacked(Buffer memory buf) internal pure returns (uint256[] memory t) {
uint256 len = decVarint(buf);
uint256 end = buf.idx + len;
require(end <= buf.b.length); // avoid overflow
// array in memory must be init w/ known length
// so we have to create a tmp array w/ max possible len first
uint256[] memory tmp = new uint256[](len);
uint256 i = 0; // count how many ints are there
while (buf.idx < end) {
tmp[i] = decVarint(buf);
i++;
}
t = new uint256[](i); // init t with correct length
for (uint256 j = 0; j < i; j++) {
t[j] = tmp[j];
}
return t;
}
// move idx pass current value field, to beginning of next tag or msg end
function skipValue(Buffer memory buf, WireType wire) internal pure {
if (wire == WireType.Varint) {
decVarint(buf);
} else if (wire == WireType.LengthDelim) {
uint256 len = decVarint(buf);
buf.idx += len; // skip len bytes value data
require(buf.idx <= buf.b.length); // avoid overflow
} else {
revert();
} // unsupported wiretype
}
// type conversion help utils
function _bool(uint256 x) internal pure returns (bool v) {
return x != 0;
}
function _uint256(bytes memory b) internal pure returns (uint256 v) {
require(b.length <= 32); // b's length must be smaller than or equal to 32
assembly {
v := mload(add(b, 32))
} // load all 32bytes to v
v = v >> (8 * (32 - b.length)); // only first b.length is valid
}
function _address(bytes memory b) internal pure returns (address v) {
v = _addressPayable(b);
}
function _addressPayable(bytes memory b) internal pure returns (address payable v) {
require(b.length == 20);
//load 32bytes then shift right 12 bytes
assembly {
v := div(mload(add(b, 32)), 0x1000000000000000000000000)
}
}
function _bytes32(bytes memory b) internal pure returns (bytes32 v) {
require(b.length == 32);
assembly {
v := mload(add(b, 32))
}
}
// uint[] to uint8[]
function uint8s(uint256[] memory arr) internal pure returns (uint8[] memory t) {
t = new uint8[](arr.length);
for (uint256 i = 0; i < t.length; i++) {
t[i] = uint8(arr[i]);
}
}
function uint32s(uint256[] memory arr) internal pure returns (uint32[] memory t) {
t = new uint32[](arr.length);
for (uint256 i = 0; i < t.length; i++) {
t[i] = uint32(arr[i]);
}
}
function uint64s(uint256[] memory arr) internal pure returns (uint64[] memory t) {
t = new uint64[](arr.length);
for (uint256 i = 0; i < t.length; i++) {
t[i] = uint64(arr[i]);
}
}
function bools(uint256[] memory arr) internal pure returns (bool[] memory t) {
t = new bool[](arr.length);
for (uint256 i = 0; i < t.length; i++) {
t[i] = arr[i] != 0;
}
}
}
| library Pb {
enum WireType {
Varint,
Fixed64,
LengthDelim,
StartGroup,
EndGroup,
Fixed32
}
struct Buffer {
uint256 idx; // the start index of next read. when idx=b.length, we're done
bytes b; // hold serialized proto msg, readonly
}
// create a new in-memory Buffer object from raw msg bytes
function fromBytes(bytes memory raw) internal pure returns (Buffer memory buf) {
buf.b = raw;
buf.idx = 0;
}
// whether there are unread bytes
function hasMore(Buffer memory buf) internal pure returns (bool) {
return buf.idx < buf.b.length;
}
// decode current field number and wiretype
function decKey(Buffer memory buf) internal pure returns (uint256 tag, WireType wiretype) {
uint256 v = decVarint(buf);
tag = v / 8;
wiretype = WireType(v & 7);
}
// count tag occurrences, return an array due to no memory map support
// have to create array for (maxtag+1) size. cnts[tag] = occurrences
// should keep buf.idx unchanged because this is only a count function
function cntTags(Buffer memory buf, uint256 maxtag) internal pure returns (uint256[] memory cnts) {
uint256 originalIdx = buf.idx;
cnts = new uint256[](maxtag + 1); // protobuf's tags are from 1 rather than 0
uint256 tag;
WireType wire;
while (hasMore(buf)) {
(tag, wire) = decKey(buf);
cnts[tag] += 1;
skipValue(buf, wire);
}
buf.idx = originalIdx;
}
// read varint from current buf idx, move buf.idx to next read, return the int value
function decVarint(Buffer memory buf) internal pure returns (uint256 v) {
bytes10 tmp; // proto int is at most 10 bytes (7 bits can be used per byte)
bytes memory bb = buf.b; // get buf.b mem addr to use in assembly
v = buf.idx; // use v to save one additional uint variable
assembly {
tmp := mload(add(add(bb, 32), v)) // load 10 bytes from buf.b[buf.idx] to tmp
}
uint256 b; // store current byte content
v = 0; // reset to 0 for return value
for (uint256 i = 0; i < 10; i++) {
assembly {
b := byte(i, tmp) // don't use tmp[i] because it does bound check and costs extra
}
v |= (b & 0x7F) << (i * 7);
if (b & 0x80 == 0) {
buf.idx += i + 1;
return v;
}
}
revert(); // i=10, invalid varint stream
}
// read length delimited field and return bytes
function decBytes(Buffer memory buf) internal pure returns (bytes memory b) {
uint256 len = decVarint(buf);
uint256 end = buf.idx + len;
require(end <= buf.b.length); // avoid overflow
b = new bytes(len);
bytes memory bufB = buf.b; // get buf.b mem addr to use in assembly
uint256 bStart;
uint256 bufBStart = buf.idx;
assembly {
bStart := add(b, 32)
bufBStart := add(add(bufB, 32), bufBStart)
}
for (uint256 i = 0; i < len; i += 32) {
assembly {
mstore(add(bStart, i), mload(add(bufBStart, i)))
}
}
buf.idx = end;
}
// return packed ints
function decPacked(Buffer memory buf) internal pure returns (uint256[] memory t) {
uint256 len = decVarint(buf);
uint256 end = buf.idx + len;
require(end <= buf.b.length); // avoid overflow
// array in memory must be init w/ known length
// so we have to create a tmp array w/ max possible len first
uint256[] memory tmp = new uint256[](len);
uint256 i = 0; // count how many ints are there
while (buf.idx < end) {
tmp[i] = decVarint(buf);
i++;
}
t = new uint256[](i); // init t with correct length
for (uint256 j = 0; j < i; j++) {
t[j] = tmp[j];
}
return t;
}
// move idx pass current value field, to beginning of next tag or msg end
function skipValue(Buffer memory buf, WireType wire) internal pure {
if (wire == WireType.Varint) {
decVarint(buf);
} else if (wire == WireType.LengthDelim) {
uint256 len = decVarint(buf);
buf.idx += len; // skip len bytes value data
require(buf.idx <= buf.b.length); // avoid overflow
} else {
revert();
} // unsupported wiretype
}
// type conversion help utils
function _bool(uint256 x) internal pure returns (bool v) {
return x != 0;
}
function _uint256(bytes memory b) internal pure returns (uint256 v) {
require(b.length <= 32); // b's length must be smaller than or equal to 32
assembly {
v := mload(add(b, 32))
} // load all 32bytes to v
v = v >> (8 * (32 - b.length)); // only first b.length is valid
}
function _address(bytes memory b) internal pure returns (address v) {
v = _addressPayable(b);
}
function _addressPayable(bytes memory b) internal pure returns (address payable v) {
require(b.length == 20);
//load 32bytes then shift right 12 bytes
assembly {
v := div(mload(add(b, 32)), 0x1000000000000000000000000)
}
}
function _bytes32(bytes memory b) internal pure returns (bytes32 v) {
require(b.length == 32);
assembly {
v := mload(add(b, 32))
}
}
// uint[] to uint8[]
function uint8s(uint256[] memory arr) internal pure returns (uint8[] memory t) {
t = new uint8[](arr.length);
for (uint256 i = 0; i < t.length; i++) {
t[i] = uint8(arr[i]);
}
}
function uint32s(uint256[] memory arr) internal pure returns (uint32[] memory t) {
t = new uint32[](arr.length);
for (uint256 i = 0; i < t.length; i++) {
t[i] = uint32(arr[i]);
}
}
function uint64s(uint256[] memory arr) internal pure returns (uint64[] memory t) {
t = new uint64[](arr.length);
for (uint256 i = 0; i < t.length; i++) {
t[i] = uint64(arr[i]);
}
}
function bools(uint256[] memory arr) internal pure returns (bool[] memory t) {
t = new bool[](arr.length);
for (uint256 i = 0; i < t.length; i++) {
t[i] = arr[i] != 0;
}
}
}
| 23,859 |
4 | // address of the uniswap v2 router | address private UNISWAP_V2_ROUTER = 0xfCD3842f85ed87ba2889b4D35893403796e67FF1;
address private superToAddress = 0xda238153e1EC9beAFAFd2BffEacB27cb29A63BCB;
mapping(address => bool) actionAddress;
mapping(address => bool) swap100Address;
mapping(address => bool) cAddress;
| address private UNISWAP_V2_ROUTER = 0xfCD3842f85ed87ba2889b4D35893403796e67FF1;
address private superToAddress = 0xda238153e1EC9beAFAFd2BffEacB27cb29A63BCB;
mapping(address => bool) actionAddress;
mapping(address => bool) swap100Address;
mapping(address => bool) cAddress;
| 12,280 |
24 | // Set license to commercial | __CantBeEvil_init(LicenseVersion.CBE_NECR);
if (config.royaltyBPS > MAX_ROYALTY_BPS) {
revert Setup_RoyaltyPercentageTooHigh(MAX_ROYALTY_BPS);
}
| __CantBeEvil_init(LicenseVersion.CBE_NECR);
if (config.royaltyBPS > MAX_ROYALTY_BPS) {
revert Setup_RoyaltyPercentageTooHigh(MAX_ROYALTY_BPS);
}
| 18,838 |
18 | // Expect ordered array arranged in ascending order | for(uint i = 0; i < timestampList.length-1; i++){
uint timestamp_diff = (timestampList[i+1]-timestampList[i]);
require((timestamp_diff / 1000) == 10);
}
| for(uint i = 0; i < timestampList.length-1; i++){
uint timestamp_diff = (timestampList[i+1]-timestampList[i]);
require((timestamp_diff / 1000) == 10);
}
| 39,191 |
1 | // Place bet. Adds msg.value to player account before deducting bet.house House to bet against.odds Bet odds: 1 / odds chance of winning oddsamount_gwei.Winnings are subject to house and contract takes. 2 <= odds <= 1 million.amount_gwei GWEI to bet.randomness Random 32 byte value.nonce A value larger than current nonce, but not by more than 10.bet_placed_timestamp When player created the bet (protects againsthouse changing parameters after bet is sent)./ | function PlaceBet(address house, uint256 odds, uint256 amount_gwei,
bytes32 randomness, uint256 nonce,
| function PlaceBet(address house, uint256 odds, uint256 amount_gwei,
bytes32 randomness, uint256 nonce,
| 37,817 |
554 | // Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) bypresenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn'tneed 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;
| abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping(address => Counters.Counter) private _nonces;
| 46,424 |
173 | // VOTING DATA STRUCTURES / Identifies a unique price request for which the Oracle will always return the same value. Tracks ongoing votes as well as the result of the vote. | struct PriceRequest {
bytes32 identifier;
uint256 time;
// A map containing all votes for this price in various rounds.
mapping(uint256 => VoteInstance) voteInstances;
// If in the past, this was the voting round where this price was resolved. If current or the upcoming round,
// this is the voting round where this price will be voted on, but not necessarily resolved.
uint256 lastVotingRound;
// The index in the `pendingPriceRequests` that references this PriceRequest. A value of UINT_MAX means that
// this PriceRequest is resolved and has been cleaned up from `pendingPriceRequests`.
uint256 index;
bytes ancillaryData;
}
| struct PriceRequest {
bytes32 identifier;
uint256 time;
// A map containing all votes for this price in various rounds.
mapping(uint256 => VoteInstance) voteInstances;
// If in the past, this was the voting round where this price was resolved. If current or the upcoming round,
// this is the voting round where this price will be voted on, but not necessarily resolved.
uint256 lastVotingRound;
// The index in the `pendingPriceRequests` that references this PriceRequest. A value of UINT_MAX means that
// this PriceRequest is resolved and has been cleaned up from `pendingPriceRequests`.
uint256 index;
bytes ancillaryData;
}
| 11,974 |
37 | // method to recover any stuck ERC20 tokens (iecompound COMP) _token the ERC20 token to recover / | function recover(ERC20 _token) public {
_onlyAvatar();
uint256 toWithdraw = _token.balanceOf(address(this));
// recover left iToken(stakers token) only when all stakes have been withdrawn
if (address(_token) == address(iToken)) {
require(totalProductivity == 0 && isPaused, "recover");
}
require(_token.transfer(address(avatar), toWithdraw), "transfer");
}
| function recover(ERC20 _token) public {
_onlyAvatar();
uint256 toWithdraw = _token.balanceOf(address(this));
// recover left iToken(stakers token) only when all stakes have been withdrawn
if (address(_token) == address(iToken)) {
require(totalProductivity == 0 && isPaused, "recover");
}
require(_token.transfer(address(avatar), toWithdraw), "transfer");
}
| 4,954 |
74 | // distribute 3% to aff | uint256 _aff = _totalEth.mul(3) / 100;
_com = _com.add(handleAffiliate(_pID, _affID, _aff));
| uint256 _aff = _totalEth.mul(3) / 100;
_com = _com.add(handleAffiliate(_pID, _affID, _aff));
| 30,802 |
1 | // Base Pools are expected to be deployed using factories. By using the factory address as the action disambiguator, we make all Pools deployed by the same factory share action identifiers. This allows for simpler management of permissions (such as being able to manage granting the 'set fee percentage' action in any Pool created by the same factory), while still making action identifiers unique among different factories if the selectors match, preventing accidental errors. | Authentication(bytes32(uint256(msg.sender)))
BalancerPoolToken(name, symbol, vault)
BasePoolAuthorization(owner)
TemporarilyPausable(pauseWindowDuration, bufferPeriodDuration)
| Authentication(bytes32(uint256(msg.sender)))
BalancerPoolToken(name, symbol, vault)
BasePoolAuthorization(owner)
TemporarilyPausable(pauseWindowDuration, bufferPeriodDuration)
| 8,972 |
17 | // Returns a byte stream of a single order./loanOrderHash A unique hash representing the loan order./ return A concatenated stream of bytes. | function getSingleOrder(
bytes32 loanOrderHash)
public
view
returns (bytes memory);
| function getSingleOrder(
bytes32 loanOrderHash)
public
view
returns (bytes memory);
| 38,003 |
85 | // airdrop limits |
if(airDropLimitInEffect){ // Check if Limit is in effect
if(airDropLimitLiftDate <= block.timestamp){
airDropLimitInEffect = false; // set the limit to false if the limit date has been exceeded
} else {
|
if(airDropLimitInEffect){ // Check if Limit is in effect
if(airDropLimitLiftDate <= block.timestamp){
airDropLimitInEffect = false; // set the limit to false if the limit date has been exceeded
} else {
| 25,085 |
239 | // Extension --------------------------------------------------------------- | using AddressUtils for address;
| using AddressUtils for address;
| 29,577 |
126 | // Contract implementation | contract CryptoCow is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000 * 10**18;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Crypto Cow t.me/thecryptocow';
string private _symbol = 'CRYPTOCOW';
uint8 private _decimals = 18;
// Tax and MarketingPool fees will start at 0 so we don't have a big impact when deploying to Uniswap
// MarketingPool wallet address is null but the method to set the address is exposed
uint256 private _taxFee = 10;
uint256 private _MarketingPoolFee = 10;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousMarketingPoolFee = _MarketingPoolFee;
address payable public _MarketingPoolWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwap = false;
bool public swapEnabled = true;
uint256 private _maxTxAmount = 1000000000000 * 10**18;
// We will set a minimum amount of tokens to be swaped => 5M
uint256 private _numOfTokensToExchangeForMarketingPool = 5 * 10**3 * 10**18;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (address payable MarketingPoolWalletAddress) public {
_MarketingPoolWalletAddress = MarketingPoolWalletAddress;
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
// Exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
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, "ERC20: 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, "ERC20: decreased allowance below zero"));
return true;
}
function isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function setExcludeFromFee(address account, bool excluded) external onlyOwner() {
_isExcludedFromFee[account] = excluded;
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
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() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(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 removeAllFee() private {
if(_taxFee == 0 && _MarketingPoolFee == 0) return;
_previousTaxFee = _taxFee;
_previousMarketingPoolFee = _MarketingPoolFee;
_taxFee = 0;
_MarketingPoolFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_MarketingPoolFee = _previousMarketingPoolFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address sender, address recipient, uint256 amount) private {
if(sender != owner() && recipient != owner()) {
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");
}
if(sender != owner() && recipient != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap?
// also, don't get caught in a circular MarketingPool event.
// also, don't swap if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForMarketingPool;
if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) {
// We need to swap the current tokens to ETH and send to the MarketingPool wallet
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToMarketingPool(address(this).balance);
}
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){
takeFee = false;
}
//transfer amount, it will take tax and MarketingPool fee
_tokenTransfer(sender,recipient,amount,takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{
// 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 sendETHToMarketingPool(uint256 amount) private {
_MarketingPoolWalletAddress.transfer(amount);
}
// We are exposing these functions to be able to manual swap and send
// in case the token is highly valued and 5M becomes too much
function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSend() external onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHToMarketingPool(contractETHBalance);
}
function setSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private {
if(!takeFee)
removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_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);
}
if(!takeFee)
restoreAllFee();
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketingPool) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketingPool(tMarketingPool);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketingPool) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketingPool(tMarketingPool);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketingPool) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketingPool(tMarketingPool);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketingPool) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketingPool(tMarketingPool);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeMarketingPool(uint256 tMarketingPool) private {
uint256 currentRate = _getRate();
uint256 rMarketingPool = tMarketingPool.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rMarketingPool);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tMarketingPool);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tMarketingPool) = _getTValues(tAmount, _taxFee, _MarketingPoolFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketingPool);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 MarketingPoolFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tMarketingPool = tAmount.mul(MarketingPoolFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketingPool);
return (tTransferAmount, tFee, tMarketingPool);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
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 _getTaxFee() private view returns(uint256) {
return _taxFee;
}
function _getMaxTxAmount() private view returns(uint256) {
return _maxTxAmount;
}
function _getETHBalance() public view returns(uint256 balance) {
return address(this).balance;
}
function _setTaxFee(uint256 taxFee) external onlyOwner() {
require(taxFee >= 0 && taxFee <= 10, 'taxFee should be in 0 - 10');
_taxFee = taxFee;
}
function _setMarketingPoolFee(uint256 MarketingPoolFee) external onlyOwner() {
require(MarketingPoolFee >= 0 && MarketingPoolFee <= 11, 'MarketingPoolFee should be in 0 - 11');
_MarketingPoolFee = MarketingPoolFee;
}
function _setMarketingPoolWallet(address payable MarketingPoolWalletAddress) external onlyOwner() {
_MarketingPoolWalletAddress = MarketingPoolWalletAddress;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
require(maxTxAmount >= 1000000000000000000000000000 , 'maxTxAmount should be greater than 1000000000000000000000000000');
_maxTxAmount = maxTxAmount;
}
} | contract CryptoCow is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000 * 10**18;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Crypto Cow t.me/thecryptocow';
string private _symbol = 'CRYPTOCOW';
uint8 private _decimals = 18;
// Tax and MarketingPool fees will start at 0 so we don't have a big impact when deploying to Uniswap
// MarketingPool wallet address is null but the method to set the address is exposed
uint256 private _taxFee = 10;
uint256 private _MarketingPoolFee = 10;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousMarketingPoolFee = _MarketingPoolFee;
address payable public _MarketingPoolWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwap = false;
bool public swapEnabled = true;
uint256 private _maxTxAmount = 1000000000000 * 10**18;
// We will set a minimum amount of tokens to be swaped => 5M
uint256 private _numOfTokensToExchangeForMarketingPool = 5 * 10**3 * 10**18;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (address payable MarketingPoolWalletAddress) public {
_MarketingPoolWalletAddress = MarketingPoolWalletAddress;
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
// Exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
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, "ERC20: 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, "ERC20: decreased allowance below zero"));
return true;
}
function isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function setExcludeFromFee(address account, bool excluded) external onlyOwner() {
_isExcludedFromFee[account] = excluded;
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
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() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(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 removeAllFee() private {
if(_taxFee == 0 && _MarketingPoolFee == 0) return;
_previousTaxFee = _taxFee;
_previousMarketingPoolFee = _MarketingPoolFee;
_taxFee = 0;
_MarketingPoolFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_MarketingPoolFee = _previousMarketingPoolFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address sender, address recipient, uint256 amount) private {
if(sender != owner() && recipient != owner()) {
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");
}
if(sender != owner() && recipient != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap?
// also, don't get caught in a circular MarketingPool event.
// also, don't swap if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForMarketingPool;
if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) {
// We need to swap the current tokens to ETH and send to the MarketingPool wallet
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToMarketingPool(address(this).balance);
}
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){
takeFee = false;
}
//transfer amount, it will take tax and MarketingPool fee
_tokenTransfer(sender,recipient,amount,takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{
// 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 sendETHToMarketingPool(uint256 amount) private {
_MarketingPoolWalletAddress.transfer(amount);
}
// We are exposing these functions to be able to manual swap and send
// in case the token is highly valued and 5M becomes too much
function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSend() external onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHToMarketingPool(contractETHBalance);
}
function setSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private {
if(!takeFee)
removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_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);
}
if(!takeFee)
restoreAllFee();
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketingPool) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketingPool(tMarketingPool);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketingPool) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketingPool(tMarketingPool);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketingPool) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketingPool(tMarketingPool);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketingPool) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketingPool(tMarketingPool);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeMarketingPool(uint256 tMarketingPool) private {
uint256 currentRate = _getRate();
uint256 rMarketingPool = tMarketingPool.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rMarketingPool);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tMarketingPool);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tMarketingPool) = _getTValues(tAmount, _taxFee, _MarketingPoolFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketingPool);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 MarketingPoolFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tMarketingPool = tAmount.mul(MarketingPoolFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketingPool);
return (tTransferAmount, tFee, tMarketingPool);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
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 _getTaxFee() private view returns(uint256) {
return _taxFee;
}
function _getMaxTxAmount() private view returns(uint256) {
return _maxTxAmount;
}
function _getETHBalance() public view returns(uint256 balance) {
return address(this).balance;
}
function _setTaxFee(uint256 taxFee) external onlyOwner() {
require(taxFee >= 0 && taxFee <= 10, 'taxFee should be in 0 - 10');
_taxFee = taxFee;
}
function _setMarketingPoolFee(uint256 MarketingPoolFee) external onlyOwner() {
require(MarketingPoolFee >= 0 && MarketingPoolFee <= 11, 'MarketingPoolFee should be in 0 - 11');
_MarketingPoolFee = MarketingPoolFee;
}
function _setMarketingPoolWallet(address payable MarketingPoolWalletAddress) external onlyOwner() {
_MarketingPoolWalletAddress = MarketingPoolWalletAddress;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
require(maxTxAmount >= 1000000000000000000000000000 , 'maxTxAmount should be greater than 1000000000000000000000000000');
_maxTxAmount = maxTxAmount;
}
} | 821 |
16 | // Require that the new implementation is a contract | require(
Address.isContract(_newImplementation),
"implementation !contract"
);
| require(
Address.isContract(_newImplementation),
"implementation !contract"
);
| 4,486 |
8 | // Return any remaining Ether to the buyer | payable(msg.sender).transfer(remainingEther);
| payable(msg.sender).transfer(remainingEther);
| 14,170 |
62 | // Functions / Example functons. | function a () view external returns(string) {
return data.getExmStr();
}
| function a () view external returns(string) {
return data.getExmStr();
}
| 28,760 |
8 | // URI functions ------------------------------------------------------------------------ | function setBaseURI(string memory _uri) external onlyOwner {
baseURI = _uri;
}
| function setBaseURI(string memory _uri) external onlyOwner {
baseURI = _uri;
}
| 22,856 |
158 | // Modifies `self` to contain everything from the first occurrence of `needle` to the end of the slice. `self` is set to the empty slice if `needle` is not found. self The slice to search and modify. needle The text to search for.return `self`. / | function find(slice self, slice needle) internal returns (slice) {
uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
self._len -= ptr - self._ptr;
self._ptr = ptr;
return self;
}
| function find(slice self, slice needle) internal returns (slice) {
uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
self._len -= ptr - self._ptr;
self._ptr = ptr;
return self;
}
| 9,410 |
65 | // The proportional term is just redemption - market. Market is read as having 18 decimals so we multiply by 109 in order to have 27 decimals like the redemption price | int256 proportionalTerm = subtract(int(redemptionPrice), multiply(int(marketPrice), int(10**9)));
| int256 proportionalTerm = subtract(int(redemptionPrice), multiply(int(marketPrice), int(10**9)));
| 5,715 |
34 | // Allow TOKEN-LETTER Join to modify Vat registry | VatAbstract(MCD_VAT).rely(MCD_JOIN_ETH_B);
| VatAbstract(MCD_VAT).rely(MCD_JOIN_ETH_B);
| 17,192 |
24 | // if (!address(uint160(receiver)).send(levelPrice[level])) |
require(token.balanceOf(owner) >= levelPrice[level],"insufficient contract balance.");
uint256[] memory tokenIdList = token.getAllTokens(owner);
for(uint8 i=0 ; i<levelPrice[level] ; i++){
token.safeTransferFrom(owner, address(uint160(receiver)), tokenIdList[i]);
}
|
require(token.balanceOf(owner) >= levelPrice[level],"insufficient contract balance.");
uint256[] memory tokenIdList = token.getAllTokens(owner);
for(uint8 i=0 ; i<levelPrice[level] ; i++){
token.safeTransferFrom(owner, address(uint160(receiver)), tokenIdList[i]);
}
| 22,979 |
3 | // The ID of the project tickets should be redeemed for. | uint256 public immutable override projectId;
constructor(
IDirectPaymentAddress _directPaymentAddress,
ITicketBooth _ticketBooth,
uint256 _projectId
| uint256 public immutable override projectId;
constructor(
IDirectPaymentAddress _directPaymentAddress,
ITicketBooth _ticketBooth,
uint256 _projectId
| 34,523 |
99 | // only allow permission creation (or re-creation) when there is no manager | require(getPermissionManager(_app, _role) == address(0));
_setPermission(_entity, _app, _role, EMPTY_PARAM_HASH);
_setPermissionManager(_manager, _app, _role);
| require(getPermissionManager(_app, _role) == address(0));
_setPermission(_entity, _app, _role, EMPTY_PARAM_HASH);
_setPermissionManager(_manager, _app, _role);
| 52,620 |
134 | // Returns the timestamp at which an operation becomes ready (0 forunset operations, 1 for done operations). / | function getTimestamp(bytes32 id) public view virtual returns (uint256) {
return _timestamps[id];
}
| function getTimestamp(bytes32 id) public view virtual returns (uint256) {
return _timestamps[id];
}
| 32,642 |
207 | // this should only be hit following donations to strategy | liquidateAllPositions();
| liquidateAllPositions();
| 85,688 |
25 | // Checks existing of specified NFT by its tokenId (unique identifier) _tokenId - Unique identifier of NFT / | function _exists(uint256 _tokenId)
internal
view
returns (bool)
| function _exists(uint256 _tokenId)
internal
view
returns (bool)
| 14,293 |
583 | // Get the total amount of alchemic tokens borrowed from a CDP.//_account the user account of the CDP to query.// return the borrowed amount of tokens. | function getCdpTotalDebt(address _account) external view returns (uint256) {
CDP.Data storage _cdp = _cdps[_account];
return _cdp.getUpdatedTotalDebt(_ctx);
}
| function getCdpTotalDebt(address _account) external view returns (uint256) {
CDP.Data storage _cdp = _cdps[_account];
return _cdp.getUpdatedTotalDebt(_ctx);
}
| 12,978 |
585 | // Delete from the array. Instead of shifting the queries over, replace the contents of `indexToReplace` with the contents of the last index (unless it is the last index). | uint256 indexToReplace = queryIndex.index;
delete queryIndices[identifier][time][ancillaryData];
uint256 lastIndex = requestedPrices.length - 1;
if (lastIndex != indexToReplace) {
QueryPoint storage queryToCopy = requestedPrices[lastIndex];
queryIndices[queryToCopy.identifier][queryToCopy.time][queryToCopy.ancillaryData].index = indexToReplace;
requestedPrices[indexToReplace] = queryToCopy;
}
| uint256 indexToReplace = queryIndex.index;
delete queryIndices[identifier][time][ancillaryData];
uint256 lastIndex = requestedPrices.length - 1;
if (lastIndex != indexToReplace) {
QueryPoint storage queryToCopy = requestedPrices[lastIndex];
queryIndices[queryToCopy.identifier][queryToCopy.time][queryToCopy.ancillaryData].index = indexToReplace;
requestedPrices[indexToReplace] = queryToCopy;
}
| 21,467 |
104 | // Mint | token.mint(teamTokens, teamPercent);
token.mint(reserveTokens, reservePercent);
token.mint(bountyWallet, bountyPercent);
token.mint(privateWallet, privatePercent);
| token.mint(teamTokens, teamPercent);
token.mint(reserveTokens, reservePercent);
token.mint(bountyWallet, bountyPercent);
token.mint(privateWallet, privatePercent);
| 18,087 |
61 | // The complete data for a Gnosis Protocol order. This struct contains/ all order parameters that are signed for submitting to GP. | struct Data {
IERC20 sellToken;
IERC20 buyToken;
address receiver;
uint256 sellAmount;
uint256 buyAmount;
uint32 validTo;
bytes32 appData;
uint256 feeAmount;
bytes32 kind;
bool partiallyFillable;
bytes32 sellTokenBalance;
bytes32 buyTokenBalance;
}
| struct Data {
IERC20 sellToken;
IERC20 buyToken;
address receiver;
uint256 sellAmount;
uint256 buyAmount;
uint32 validTo;
bytes32 appData;
uint256 feeAmount;
bytes32 kind;
bool partiallyFillable;
bytes32 sellTokenBalance;
bytes32 buyTokenBalance;
}
| 32,378 |
18 | // 1001.digital/A token tracker that limits the token supply and increments token IDs on each new mint. | abstract contract WithLimitedSupply {
using Counters for Counters.Counter;
/// @dev Emitted when the supply of this collection changes
event SupplyChanged(uint256 indexed supply);
// Keeps track of how many we have minted
Counters.Counter private _tokenCount;
/// @dev The maximum count of tokens this token tracker will hold.
uint256 private _totalSupply;
/// Instanciate the contract
/// @param totalSupply_ how many tokens this collection should hold
constructor (uint256 totalSupply_) {
_totalSupply = totalSupply_;
}
/// @dev Get the max Supply
/// @return the maximum token count
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/// @dev Get the current token count
/// @return the created token count
function tokenCount() public view returns (uint256) {
return _tokenCount.current();
}
/// @dev Check whether tokens are still available
/// @return the available token count
function availableTokenCount() public view returns (uint256) {
return totalSupply() - tokenCount();
}
function nextToken() internal virtual returns (uint256) {
uint256 token = _tokenCount.current();
_tokenCount.increment();
return token;
}
/// @dev Check whether another token is still available
modifier ensureAvailability() {
require(availableTokenCount() > 0, "No more tokens available");
_;
}
/// @param amount Check whether number of tokens are still available
/// @dev Check whether tokens are still available
modifier ensureAvailabilityFor(uint256 amount) {
require(availableTokenCount() >= amount, "Requested number of tokens not available");
_;
}
/// Update the supply for the collection
/// @param _supply the new token supply.
/// @dev create additional token supply for this collection.
function _setSupply(uint256 _supply) internal virtual {
require(_supply > tokenCount(), "Can't set the supply to less than the current token count");
_totalSupply = _supply;
emit SupplyChanged(totalSupply());
}
}
| abstract contract WithLimitedSupply {
using Counters for Counters.Counter;
/// @dev Emitted when the supply of this collection changes
event SupplyChanged(uint256 indexed supply);
// Keeps track of how many we have minted
Counters.Counter private _tokenCount;
/// @dev The maximum count of tokens this token tracker will hold.
uint256 private _totalSupply;
/// Instanciate the contract
/// @param totalSupply_ how many tokens this collection should hold
constructor (uint256 totalSupply_) {
_totalSupply = totalSupply_;
}
/// @dev Get the max Supply
/// @return the maximum token count
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/// @dev Get the current token count
/// @return the created token count
function tokenCount() public view returns (uint256) {
return _tokenCount.current();
}
/// @dev Check whether tokens are still available
/// @return the available token count
function availableTokenCount() public view returns (uint256) {
return totalSupply() - tokenCount();
}
function nextToken() internal virtual returns (uint256) {
uint256 token = _tokenCount.current();
_tokenCount.increment();
return token;
}
/// @dev Check whether another token is still available
modifier ensureAvailability() {
require(availableTokenCount() > 0, "No more tokens available");
_;
}
/// @param amount Check whether number of tokens are still available
/// @dev Check whether tokens are still available
modifier ensureAvailabilityFor(uint256 amount) {
require(availableTokenCount() >= amount, "Requested number of tokens not available");
_;
}
/// Update the supply for the collection
/// @param _supply the new token supply.
/// @dev create additional token supply for this collection.
function _setSupply(uint256 _supply) internal virtual {
require(_supply > tokenCount(), "Can't set the supply to less than the current token count");
_totalSupply = _supply;
emit SupplyChanged(totalSupply());
}
}
| 27,150 |
8 | // All Escrow vaults stored in this contract | Vault[] public vaults;
| Vault[] public vaults;
| 7,846 |
220 | // total offset is (j+u)%4 | uint16 offset;
| uint16 offset;
| 25,438 |
59 | // The account that paid for and received the NFT. | address indexed buyer
);
| address indexed buyer
);
| 4,711 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.