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 |
|---|---|---|---|---|
138 | // pragma solidity >=0.8.10; / | /* import {IUniswapV2Router02} from "./IUniswapV2Router02.sol"; */
/* import {IUniswapV2Factory} from "./IUniswapV2Factory.sol"; */
/* import {IUniswapV2Pair} from "./IUniswapV2Pair.sol"; */
/* import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */
/* import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; */
/* import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol"; */
/* import {SafeMath} from "lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol"; */
contract NureOnna is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0xdead);
bool private swapping;
address public marketingWallet;
address public devWallet;
uint256 public maxTransactionAmount;
uint256 public swapTokensAtAmount;
uint256 public maxWallet;
uint256 public percentForLPBurn = 25; // 25 = .25%
bool public lpBurnEnabled = false;
uint256 public lpBurnFrequency = 3600 seconds;
uint256 public lastLpBurnTime;
uint256 public manualBurnFrequency = 30 minutes;
uint256 public lastManualLpBurnTime;
bool public limitsInEffect = true;
bool public tradingActive = false;
bool public swapEnabled = false;
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
bool public transferDelayEnabled = true;
uint256 public buyTotalFees;
uint256 public buyMarketingFee;
uint256 public buyLiquidityFee;
uint256 public buyDevFee;
uint256 public sellTotalFees;
uint256 public sellMarketingFee;
uint256 public sellLiquidityFee;
uint256 public sellDevFee;
uint256 public tokensForMarketing;
uint256 public tokensForLiquidity;
uint256 public tokensForDev;
/******************/
// exlcude from fees and max transaction amount
mapping(address => bool) private _isExcludedFromFees;
mapping(address => bool) public _isExcludedMaxTransactionAmount;
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping(address => bool) public automatedMarketMakerPairs;
event UpdateUniswapV2Router(
address indexed newAddress,
address indexed oldAddress
);
event ExcludeFromFees(address indexed account, bool isExcluded);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event marketingWalletUpdated(
address indexed newWallet,
address indexed oldWallet
);
event devWalletUpdated(
address indexed newWallet,
address indexed oldWallet
);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event AutoNukeLP();
event ManualNukeLP();
constructor() ERC20("NureOnna", "NURE") {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
);
excludeFromMaxTransaction(address(_uniswapV2Router), true);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
excludeFromMaxTransaction(address(uniswapV2Pair), true);
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
uint256 _buyMarketingFee =4;
uint256 _buyLiquidityFee = 0;
uint256 _buyDevFee = 0;
uint256 _sellMarketingFee = 4;
uint256 _sellLiquidityFee = 0;
uint256 _sellDevFee = 0;
uint256 totalSupply = 1_000_000_000 * 1e18;
maxTransactionAmount = 10_000_000 * 1e18; // 1% from total supply maxTransactionAmountTxn
maxWallet = 20_000_000 * 1e18; // 2% from total supply maxWallet
swapTokensAtAmount = (totalSupply * 5) / 10000; // 0.05% swap wallet
buyMarketingFee = _buyMarketingFee;
buyLiquidityFee = _buyLiquidityFee;
buyDevFee = _buyDevFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
sellMarketingFee = _sellMarketingFee;
sellLiquidityFee = _sellLiquidityFee;
sellDevFee = _sellDevFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
marketingWallet = address(0x09225B01cBf21ce7199E3BCf00cD25ebbdbbDA49); // set as marketing wallet
devWallet = address(0x09225B01cBf21ce7199E3BCf00cD25ebbdbbDA49); // set as dev wallet
// exclude from paying fees or having max transaction amount
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(address(0xdead), true);
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
/*
_mint is an internal function in ERC20.sol that is only called here,
and CANNOT be called ever again
*/
_mint(msg.sender, totalSupply);
}
receive() external payable {}
// once enabled, can never be turned off
function enableTrading() external onlyOwner {
tradingActive = true;
swapEnabled = true;
lastLpBurnTime = block.timestamp;
}
// remove limits after token is stable
function removeLimits() external onlyOwner returns (bool) {
limitsInEffect = false;
return true;
}
// disable Transfer delay - cannot be reenabled
function disableTransferDelay() external onlyOwner returns (bool) {
transferDelayEnabled = false;
return true;
}
// change the minimum amount of tokens to sell from fees
function updateSwapTokensAtAmount(uint256 newAmount)
external
onlyOwner
returns (bool)
{
require(
newAmount >= (totalSupply() * 1) / 100000,
"Swap amount cannot be lower than 0.001% total supply."
);
require(
newAmount <= (totalSupply() * 5) / 1000,
"Swap amount cannot be higher than 0.5% total supply."
);
swapTokensAtAmount = newAmount;
return true;
}
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
require(
newNum >= ((totalSupply() * 1) / 1000) / 1e18,
"Cannot set maxTransactionAmount lower than 0.1%"
);
maxTransactionAmount = newNum * (10**18);
}
function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
require(
newNum >= ((totalSupply() * 5) / 1000) / 1e18,
"Cannot set maxWallet lower than 0.5%"
);
maxWallet = newNum * (10**18);
}
function excludeFromMaxTransaction(address updAds, bool isEx)
public
onlyOwner
{
_isExcludedMaxTransactionAmount[updAds] = isEx;
}
// only use to disable contract sales if absolutely necessary (emergency use only)
function updateSwapEnabled(bool enabled) external onlyOwner {
swapEnabled = enabled;
}
function updateBuyFees(
uint256 _marketingFee,
uint256 _liquidityFee,
uint256 _devFee
) external onlyOwner {
buyMarketingFee = _marketingFee;
buyLiquidityFee = _liquidityFee;
buyDevFee = _devFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
require(buyTotalFees <= 9, "Must keep fees at 9% or less");
}
function updateSellFees(
uint256 _marketingFee,
uint256 _liquidityFee,
uint256 _devFee
) external onlyOwner {
sellMarketingFee = _marketingFee;
sellLiquidityFee = _liquidityFee;
sellDevFee = _devFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
require(sellTotalFees <= 9, "Must keep fees at 9% or less");
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function setAutomatedMarketMakerPair(address pair, bool value)
public
onlyOwner
{
require(
pair != uniswapV2Pair,
"The pair cannot be removed from automatedMarketMakerPairs"
);
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
function updateMarketingWallet(address newMarketingWallet)
external
onlyOwner
{
emit marketingWalletUpdated(newMarketingWallet, marketingWallet);
marketingWallet = newMarketingWallet;
}
function updateDevWallet(address newWallet) external onlyOwner {
emit devWalletUpdated(newWallet, devWallet);
devWallet = newWallet;
}
function isExcludedFromFees(address account) public view returns (bool) {
return _isExcludedFromFees[account];
}
event BoughtEarly(address indexed sniper);
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
if (amount == 0) {
super._transfer(from, to, 0);
return;
}
if (limitsInEffect) {
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
!swapping
) {
if (!tradingActive) {
require(
_isExcludedFromFees[from] || _isExcludedFromFees[to],
"Trading is not active."
);
}
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
if (transferDelayEnabled) {
if (
to != owner() &&
to != address(uniswapV2Router) &&
to != address(uniswapV2Pair)
) {
require(
_holderLastTransferTimestamp[tx.origin] <
block.number,
"_transfer:: Transfer Delay enabled. Only one purchase per block allowed."
);
_holderLastTransferTimestamp[tx.origin] = block.number;
}
}
//when buy
if (
automatedMarketMakerPairs[from] &&
!_isExcludedMaxTransactionAmount[to]
) {
require(
amount <= maxTransactionAmount,
"Buy transfer amount exceeds the maxTransactionAmount."
);
require(
amount + balanceOf(to) <= maxWallet,
"Max wallet exceeded"
);
}
//when sell
else if (
automatedMarketMakerPairs[to] &&
!_isExcludedMaxTransactionAmount[from]
) {
require(
amount <= maxTransactionAmount,
"Sell transfer amount exceeds the maxTransactionAmount."
);
} else if (!_isExcludedMaxTransactionAmount[to]) {
require(
amount + balanceOf(to) <= maxWallet,
"Max wallet exceeded"
);
}
}
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if (
canSwap &&
swapEnabled &&
!swapping &&
!automatedMarketMakerPairs[from] &&
!_isExcludedFromFees[from] &&
!_isExcludedFromFees[to]
) {
swapping = true;
swapBack();
swapping = false;
}
if (
!swapping &&
automatedMarketMakerPairs[to] &&
lpBurnEnabled &&
block.timestamp >= lastLpBurnTime + lpBurnFrequency &&
!_isExcludedFromFees[from]
) {
autoBurnLiquidityPairTokens();
}
bool takeFee = !swapping;
// if any account belongs to _isExcludedFromFee account then remove the fee
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
uint256 fees = 0;
// only take fees on buys/sells, do not take on wallet transfers
if (takeFee) {
// on sell
if (automatedMarketMakerPairs[to] && sellTotalFees > 0) {
fees = amount.mul(sellTotalFees).div(100);
tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees;
tokensForDev += (fees * sellDevFee) / sellTotalFees;
tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees;
}
// on buy
else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) {
fees = amount.mul(buyTotalFees).div(100);
tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees;
tokensForDev += (fees * buyDevFee) / buyTotalFees;
tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees;
}
if (fees > 0) {
super._transfer(from, address(this), fees);
}
amount -= fees;
}
super._transfer(from, to, amount);
}
function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
deadAddress,
block.timestamp
);
}
function swapBack() private {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForLiquidity +
tokensForMarketing +
tokensForDev;
bool success;
if (contractBalance == 0 || totalTokensToSwap == 0) {
return;
}
if (contractBalance > swapTokensAtAmount * 20) {
contractBalance = swapTokensAtAmount * 20;
}
// Halve the amount of liquidity tokens
uint256 liquidityTokens = (contractBalance * tokensForLiquidity) /
totalTokensToSwap /
2;
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForEth(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(
totalTokensToSwap
);
uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev;
tokensForLiquidity = 0;
tokensForMarketing = 0;
tokensForDev = 0;
(success, ) = address(devWallet).call{value: ethForDev}("");
if (liquidityTokens > 0 && ethForLiquidity > 0) {
addLiquidity(liquidityTokens, ethForLiquidity);
emit SwapAndLiquify(
amountToSwapForETH,
ethForLiquidity,
tokensForLiquidity
);
}
(success, ) = address(marketingWallet).call{
value: address(this).balance
}("");
}
function setAutoLPBurnSettings(
uint256 _frequencyInSeconds,
uint256 _percent,
bool _Enabled
) external onlyOwner {
require(
_frequencyInSeconds >= 600,
"cannot set buyback more often than every 10 minutes"
);
require(
_percent <= 1000 && _percent >= 0,
"Must set auto LP burn percent between 0% and 10%"
);
lpBurnFrequency = _frequencyInSeconds;
percentForLPBurn = _percent;
lpBurnEnabled = _Enabled;
}
function autoBurnLiquidityPairTokens() internal returns (bool) {
lastLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(
10000
);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0) {
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit AutoNukeLP();
return true;
}
function manualBurnLiquidityPairTokens(uint256 percent)
external
onlyOwner
returns (bool)
{
require(
block.timestamp > lastManualLpBurnTime + manualBurnFrequency,
"Must wait for cooldown to finish"
);
require(percent <= 1000, "May not nuke more than 10% of tokens in LP");
lastManualLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0) {
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit ManualNukeLP();
return true;
}
} | /* import {IUniswapV2Router02} from "./IUniswapV2Router02.sol"; */
/* import {IUniswapV2Factory} from "./IUniswapV2Factory.sol"; */
/* import {IUniswapV2Pair} from "./IUniswapV2Pair.sol"; */
/* import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */
/* import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; */
/* import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol"; */
/* import {SafeMath} from "lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol"; */
contract NureOnna is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0xdead);
bool private swapping;
address public marketingWallet;
address public devWallet;
uint256 public maxTransactionAmount;
uint256 public swapTokensAtAmount;
uint256 public maxWallet;
uint256 public percentForLPBurn = 25; // 25 = .25%
bool public lpBurnEnabled = false;
uint256 public lpBurnFrequency = 3600 seconds;
uint256 public lastLpBurnTime;
uint256 public manualBurnFrequency = 30 minutes;
uint256 public lastManualLpBurnTime;
bool public limitsInEffect = true;
bool public tradingActive = false;
bool public swapEnabled = false;
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
bool public transferDelayEnabled = true;
uint256 public buyTotalFees;
uint256 public buyMarketingFee;
uint256 public buyLiquidityFee;
uint256 public buyDevFee;
uint256 public sellTotalFees;
uint256 public sellMarketingFee;
uint256 public sellLiquidityFee;
uint256 public sellDevFee;
uint256 public tokensForMarketing;
uint256 public tokensForLiquidity;
uint256 public tokensForDev;
/******************/
// exlcude from fees and max transaction amount
mapping(address => bool) private _isExcludedFromFees;
mapping(address => bool) public _isExcludedMaxTransactionAmount;
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping(address => bool) public automatedMarketMakerPairs;
event UpdateUniswapV2Router(
address indexed newAddress,
address indexed oldAddress
);
event ExcludeFromFees(address indexed account, bool isExcluded);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event marketingWalletUpdated(
address indexed newWallet,
address indexed oldWallet
);
event devWalletUpdated(
address indexed newWallet,
address indexed oldWallet
);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event AutoNukeLP();
event ManualNukeLP();
constructor() ERC20("NureOnna", "NURE") {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
);
excludeFromMaxTransaction(address(_uniswapV2Router), true);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
excludeFromMaxTransaction(address(uniswapV2Pair), true);
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
uint256 _buyMarketingFee =4;
uint256 _buyLiquidityFee = 0;
uint256 _buyDevFee = 0;
uint256 _sellMarketingFee = 4;
uint256 _sellLiquidityFee = 0;
uint256 _sellDevFee = 0;
uint256 totalSupply = 1_000_000_000 * 1e18;
maxTransactionAmount = 10_000_000 * 1e18; // 1% from total supply maxTransactionAmountTxn
maxWallet = 20_000_000 * 1e18; // 2% from total supply maxWallet
swapTokensAtAmount = (totalSupply * 5) / 10000; // 0.05% swap wallet
buyMarketingFee = _buyMarketingFee;
buyLiquidityFee = _buyLiquidityFee;
buyDevFee = _buyDevFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
sellMarketingFee = _sellMarketingFee;
sellLiquidityFee = _sellLiquidityFee;
sellDevFee = _sellDevFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
marketingWallet = address(0x09225B01cBf21ce7199E3BCf00cD25ebbdbbDA49); // set as marketing wallet
devWallet = address(0x09225B01cBf21ce7199E3BCf00cD25ebbdbbDA49); // set as dev wallet
// exclude from paying fees or having max transaction amount
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(address(0xdead), true);
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
/*
_mint is an internal function in ERC20.sol that is only called here,
and CANNOT be called ever again
*/
_mint(msg.sender, totalSupply);
}
receive() external payable {}
// once enabled, can never be turned off
function enableTrading() external onlyOwner {
tradingActive = true;
swapEnabled = true;
lastLpBurnTime = block.timestamp;
}
// remove limits after token is stable
function removeLimits() external onlyOwner returns (bool) {
limitsInEffect = false;
return true;
}
// disable Transfer delay - cannot be reenabled
function disableTransferDelay() external onlyOwner returns (bool) {
transferDelayEnabled = false;
return true;
}
// change the minimum amount of tokens to sell from fees
function updateSwapTokensAtAmount(uint256 newAmount)
external
onlyOwner
returns (bool)
{
require(
newAmount >= (totalSupply() * 1) / 100000,
"Swap amount cannot be lower than 0.001% total supply."
);
require(
newAmount <= (totalSupply() * 5) / 1000,
"Swap amount cannot be higher than 0.5% total supply."
);
swapTokensAtAmount = newAmount;
return true;
}
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
require(
newNum >= ((totalSupply() * 1) / 1000) / 1e18,
"Cannot set maxTransactionAmount lower than 0.1%"
);
maxTransactionAmount = newNum * (10**18);
}
function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
require(
newNum >= ((totalSupply() * 5) / 1000) / 1e18,
"Cannot set maxWallet lower than 0.5%"
);
maxWallet = newNum * (10**18);
}
function excludeFromMaxTransaction(address updAds, bool isEx)
public
onlyOwner
{
_isExcludedMaxTransactionAmount[updAds] = isEx;
}
// only use to disable contract sales if absolutely necessary (emergency use only)
function updateSwapEnabled(bool enabled) external onlyOwner {
swapEnabled = enabled;
}
function updateBuyFees(
uint256 _marketingFee,
uint256 _liquidityFee,
uint256 _devFee
) external onlyOwner {
buyMarketingFee = _marketingFee;
buyLiquidityFee = _liquidityFee;
buyDevFee = _devFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
require(buyTotalFees <= 9, "Must keep fees at 9% or less");
}
function updateSellFees(
uint256 _marketingFee,
uint256 _liquidityFee,
uint256 _devFee
) external onlyOwner {
sellMarketingFee = _marketingFee;
sellLiquidityFee = _liquidityFee;
sellDevFee = _devFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
require(sellTotalFees <= 9, "Must keep fees at 9% or less");
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function setAutomatedMarketMakerPair(address pair, bool value)
public
onlyOwner
{
require(
pair != uniswapV2Pair,
"The pair cannot be removed from automatedMarketMakerPairs"
);
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
function updateMarketingWallet(address newMarketingWallet)
external
onlyOwner
{
emit marketingWalletUpdated(newMarketingWallet, marketingWallet);
marketingWallet = newMarketingWallet;
}
function updateDevWallet(address newWallet) external onlyOwner {
emit devWalletUpdated(newWallet, devWallet);
devWallet = newWallet;
}
function isExcludedFromFees(address account) public view returns (bool) {
return _isExcludedFromFees[account];
}
event BoughtEarly(address indexed sniper);
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
if (amount == 0) {
super._transfer(from, to, 0);
return;
}
if (limitsInEffect) {
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
!swapping
) {
if (!tradingActive) {
require(
_isExcludedFromFees[from] || _isExcludedFromFees[to],
"Trading is not active."
);
}
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
if (transferDelayEnabled) {
if (
to != owner() &&
to != address(uniswapV2Router) &&
to != address(uniswapV2Pair)
) {
require(
_holderLastTransferTimestamp[tx.origin] <
block.number,
"_transfer:: Transfer Delay enabled. Only one purchase per block allowed."
);
_holderLastTransferTimestamp[tx.origin] = block.number;
}
}
//when buy
if (
automatedMarketMakerPairs[from] &&
!_isExcludedMaxTransactionAmount[to]
) {
require(
amount <= maxTransactionAmount,
"Buy transfer amount exceeds the maxTransactionAmount."
);
require(
amount + balanceOf(to) <= maxWallet,
"Max wallet exceeded"
);
}
//when sell
else if (
automatedMarketMakerPairs[to] &&
!_isExcludedMaxTransactionAmount[from]
) {
require(
amount <= maxTransactionAmount,
"Sell transfer amount exceeds the maxTransactionAmount."
);
} else if (!_isExcludedMaxTransactionAmount[to]) {
require(
amount + balanceOf(to) <= maxWallet,
"Max wallet exceeded"
);
}
}
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if (
canSwap &&
swapEnabled &&
!swapping &&
!automatedMarketMakerPairs[from] &&
!_isExcludedFromFees[from] &&
!_isExcludedFromFees[to]
) {
swapping = true;
swapBack();
swapping = false;
}
if (
!swapping &&
automatedMarketMakerPairs[to] &&
lpBurnEnabled &&
block.timestamp >= lastLpBurnTime + lpBurnFrequency &&
!_isExcludedFromFees[from]
) {
autoBurnLiquidityPairTokens();
}
bool takeFee = !swapping;
// if any account belongs to _isExcludedFromFee account then remove the fee
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
uint256 fees = 0;
// only take fees on buys/sells, do not take on wallet transfers
if (takeFee) {
// on sell
if (automatedMarketMakerPairs[to] && sellTotalFees > 0) {
fees = amount.mul(sellTotalFees).div(100);
tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees;
tokensForDev += (fees * sellDevFee) / sellTotalFees;
tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees;
}
// on buy
else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) {
fees = amount.mul(buyTotalFees).div(100);
tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees;
tokensForDev += (fees * buyDevFee) / buyTotalFees;
tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees;
}
if (fees > 0) {
super._transfer(from, address(this), fees);
}
amount -= fees;
}
super._transfer(from, to, amount);
}
function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
deadAddress,
block.timestamp
);
}
function swapBack() private {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForLiquidity +
tokensForMarketing +
tokensForDev;
bool success;
if (contractBalance == 0 || totalTokensToSwap == 0) {
return;
}
if (contractBalance > swapTokensAtAmount * 20) {
contractBalance = swapTokensAtAmount * 20;
}
// Halve the amount of liquidity tokens
uint256 liquidityTokens = (contractBalance * tokensForLiquidity) /
totalTokensToSwap /
2;
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForEth(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(
totalTokensToSwap
);
uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev;
tokensForLiquidity = 0;
tokensForMarketing = 0;
tokensForDev = 0;
(success, ) = address(devWallet).call{value: ethForDev}("");
if (liquidityTokens > 0 && ethForLiquidity > 0) {
addLiquidity(liquidityTokens, ethForLiquidity);
emit SwapAndLiquify(
amountToSwapForETH,
ethForLiquidity,
tokensForLiquidity
);
}
(success, ) = address(marketingWallet).call{
value: address(this).balance
}("");
}
function setAutoLPBurnSettings(
uint256 _frequencyInSeconds,
uint256 _percent,
bool _Enabled
) external onlyOwner {
require(
_frequencyInSeconds >= 600,
"cannot set buyback more often than every 10 minutes"
);
require(
_percent <= 1000 && _percent >= 0,
"Must set auto LP burn percent between 0% and 10%"
);
lpBurnFrequency = _frequencyInSeconds;
percentForLPBurn = _percent;
lpBurnEnabled = _Enabled;
}
function autoBurnLiquidityPairTokens() internal returns (bool) {
lastLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(
10000
);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0) {
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit AutoNukeLP();
return true;
}
function manualBurnLiquidityPairTokens(uint256 percent)
external
onlyOwner
returns (bool)
{
require(
block.timestamp > lastManualLpBurnTime + manualBurnFrequency,
"Must wait for cooldown to finish"
);
require(percent <= 1000, "May not nuke more than 10% of tokens in LP");
lastManualLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0) {
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit ManualNukeLP();
return true;
}
} | 2,102 |
27 | // Called only by future Bridge contract to withdraw the Realms _tokenIds Ids of Realms / | function bridgeWithdraw(address _player, uint256[] memory _tokenIds)
public
onlyBridge
| function bridgeWithdraw(address _player, uint256[] memory _tokenIds)
public
onlyBridge
| 29,552 |
143 | // there are two types of retractions. | if (status == StatusChoices.NO_PLEDGE_INFO) {
pledgeSum = classifySquareUp(_maker);
} else {
| if (status == StatusChoices.NO_PLEDGE_INFO) {
pledgeSum = classifySquareUp(_maker);
} else {
| 19,917 |
53 | // create pair | lpPair = IDexFactory(dexRouter.factory()).createPair(
address(this),
dexRouter.WETH()
);
_excludeFromMaxTransaction(address(lpPair), true);
_setAutomatedMarketMakerPair(address(lpPair), true);
uint256 totalSupply = 100 * 1e6 * 1e18; // 100000000
maxBuyAmount = (totalSupply * 2) / 100; // 2%
| lpPair = IDexFactory(dexRouter.factory()).createPair(
address(this),
dexRouter.WETH()
);
_excludeFromMaxTransaction(address(lpPair), true);
_setAutomatedMarketMakerPair(address(lpPair), true);
uint256 totalSupply = 100 * 1e6 * 1e18; // 100000000
maxBuyAmount = (totalSupply * 2) / 100; // 2%
| 11,770 |
36 | // ------------------------------------------------------------------------ This will give how much of the pending reward is claimable by user according to the current date ------------------------------------------------------------------------ | function claimableReward(address user, uint256 _pendingReward) public view returns(uint256) {
uint256 totalDays = (block.timestamp.sub(stakers[user].stakeDate)).div(1 days);
if(totalDays < 5){
return onePercent(_pendingReward).mul(40); //40% of the pending reward
} else if(totalDays < 7){
return onePercent(_pendingReward).mul(80); // 80% of the pending reward
}
return _pendingReward;
}
| function claimableReward(address user, uint256 _pendingReward) public view returns(uint256) {
uint256 totalDays = (block.timestamp.sub(stakers[user].stakeDate)).div(1 days);
if(totalDays < 5){
return onePercent(_pendingReward).mul(40); //40% of the pending reward
} else if(totalDays < 7){
return onePercent(_pendingReward).mul(80); // 80% of the pending reward
}
return _pendingReward;
}
| 16,063 |
333 | // see if we have a character other than a number | if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39))
_hasNonNumber = true;
| if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39))
_hasNonNumber = true;
| 38,283 |
38 | // Count all NFTs assigned to an owner/NFTs assigned to the zero address are considered invalid, and this/function throws for queries about the zero address./_owner An address for whom to query the balance/ return The number of NFTs owned by `_owner`, possibly zero | function balanceOf(address _owner)
external
view
returns (uint256);
| function balanceOf(address _owner)
external
view
returns (uint256);
| 23,955 |
180 | // _proxyRegistryAddress - 0xa5409ec958c83c3f309868babaca7c86dcb077c1 | constructor(address _proxyRegistryAddress) public ERC1155Tradable("Lympo NFT", "LYMPO", _proxyRegistryAddress) {
_setBaseMetadataURI("https://api.lympo.io/pools/assets/");
}
| constructor(address _proxyRegistryAddress) public ERC1155Tradable("Lympo NFT", "LYMPO", _proxyRegistryAddress) {
_setBaseMetadataURI("https://api.lympo.io/pools/assets/");
}
| 58,837 |
2 | // If, at a certain point, we decide to disable or redirect donations. Otherwise, owner no other purpose. "isOwner isAMistake!" | function changeOwner(address newOwner) public returns (address oldOwner) {
require(msg.sender == owner, "msg.sender must be owner");
oldOwner = owner;
owner = newOwner;
emit OwnerChanged(oldOwner, newOwner);
return oldOwner;
}
| function changeOwner(address newOwner) public returns (address oldOwner) {
require(msg.sender == owner, "msg.sender must be owner");
oldOwner = owner;
owner = newOwner;
emit OwnerChanged(oldOwner, newOwner);
return oldOwner;
}
| 28,581 |
1 | // The identifier of the role which allows accounts to mint tokens. | bytes32 public constant MINTER_ROLE = keccak256("MINTER");
event Paused(address minter, bool state);
constructor(string memory name, string memory symbol) ERC20(name, symbol) {
_setupRole(ADMIN_ROLE, msg.sender);
_setupRole(MINTER_ROLE, msg.sender);
_setRoleAdmin(MINTER_ROLE, ADMIN_ROLE);
_setRoleAdmin(ADMIN_ROLE, ADMIN_ROLE);
| bytes32 public constant MINTER_ROLE = keccak256("MINTER");
event Paused(address minter, bool state);
constructor(string memory name, string memory symbol) ERC20(name, symbol) {
_setupRole(ADMIN_ROLE, msg.sender);
_setupRole(MINTER_ROLE, msg.sender);
_setRoleAdmin(MINTER_ROLE, ADMIN_ROLE);
_setRoleAdmin(ADMIN_ROLE, ADMIN_ROLE);
| 42,287 |
12 | // in "decimals==18,6,6,8,18" | function getFreeFundsOriginal(Position memory _position, bool _getAll) public view returns(uint256[5] memory){
if( _getAll == true ){
// return all FreeFunds in cashbox
return[
IERC20(_position.token0).balanceOf(address(this)),
IERC20(_position.token1).balanceOf(address(this)),
IERC20(_position.token2).balanceOf(address(this)),
IERC20(_position.token3).balanceOf(address(this)),
IERC20(_position.token4).balanceOf(address(this))
];
}
else {
// return enter_amounts needed to add liquidity
return[
(IERC20(_position.token0).balanceOf(address(this))).mul(_position.enterPercentage).div(100),
(IERC20(_position.token1).balanceOf(address(this))).mul(_position.enterPercentage).div(100),
(IERC20(_position.token2).balanceOf(address(this))).mul(_position.enterPercentage).div(100),
(IERC20(_position.token3).balanceOf(address(this))).mul(_position.enterPercentage).div(100),
(IERC20(_position.token4).balanceOf(address(this))).mul(_position.enterPercentage).div(100)
];
}
}
| function getFreeFundsOriginal(Position memory _position, bool _getAll) public view returns(uint256[5] memory){
if( _getAll == true ){
// return all FreeFunds in cashbox
return[
IERC20(_position.token0).balanceOf(address(this)),
IERC20(_position.token1).balanceOf(address(this)),
IERC20(_position.token2).balanceOf(address(this)),
IERC20(_position.token3).balanceOf(address(this)),
IERC20(_position.token4).balanceOf(address(this))
];
}
else {
// return enter_amounts needed to add liquidity
return[
(IERC20(_position.token0).balanceOf(address(this))).mul(_position.enterPercentage).div(100),
(IERC20(_position.token1).balanceOf(address(this))).mul(_position.enterPercentage).div(100),
(IERC20(_position.token2).balanceOf(address(this))).mul(_position.enterPercentage).div(100),
(IERC20(_position.token3).balanceOf(address(this))).mul(_position.enterPercentage).div(100),
(IERC20(_position.token4).balanceOf(address(this))).mul(_position.enterPercentage).div(100)
];
}
}
| 2,813 |
33 | // Number of Tokens opposed to the proposal | uint nay;
| uint nay;
| 22,118 |
0 | // ERC20 token to mock ITEP, send all balance to the deployer / | constructor() public {
_balances[msg.sender] = supply;
_totalSupply = supply;
}
| constructor() public {
_balances[msg.sender] = supply;
_totalSupply = supply;
}
| 3,072 |
59 | // Emit Event | emit EmergencyWithdraw(lpWithdrawn);
| emit EmergencyWithdraw(lpWithdrawn);
| 4,195 |
41 | // simple transfer, lock recipient collateral Note: the market must have 'unlocked' funds | ITreasury(treasury).lock(recipient, amount);
ITreasury(treasury).release(sender, sender, amount);
| ITreasury(treasury).lock(recipient, amount);
ITreasury(treasury).release(sender, sender, amount);
| 52,007 |
19 | // Transfer supplying token(e.g. DAI, USDT) to Controller | uint256 supplyTokenBalance = IERC20(supplyToken).balanceOf(address(this));
IERC20(supplyToken).safeTransfer(msg.sender, supplyTokenBalance);
emit UnCommitted(_uncommitAmount);
| uint256 supplyTokenBalance = IERC20(supplyToken).balanceOf(address(this));
IERC20(supplyToken).safeTransfer(msg.sender, supplyTokenBalance);
emit UnCommitted(_uncommitAmount);
| 51,115 |
84 | // Returns the annual staking reward rate/ return annualStakingRewardsRatePercentMille is the annual rate in percent-mille | function getAnnualStakingRewardsRatePercentMille() external view returns (uint32);
| function getAnnualStakingRewardsRatePercentMille() external view returns (uint32);
| 13,403 |
2 | // L1StandardERC20 L1StandardERC20 is the Oasys Standard ERC20 contract. / | contract L1StandardERC20 is ERC20PresetMinterPauser {
/***************
* Constructor *
***************/
/**
* @param _name Name of the ERC20.
* @param _symbol Symbol of the ERC20.
*/
constructor(string memory _name, string memory _symbol)
ERC20PresetMinterPauser(_name, _symbol)
{}
}
| contract L1StandardERC20 is ERC20PresetMinterPauser {
/***************
* Constructor *
***************/
/**
* @param _name Name of the ERC20.
* @param _symbol Symbol of the ERC20.
*/
constructor(string memory _name, string memory _symbol)
ERC20PresetMinterPauser(_name, _symbol)
{}
}
| 36,463 |
17 | // owner > spender > allowance mapping. | mapping(address => mapping(address => uint256)) public override allowance;
| mapping(address => mapping(address => uint256)) public override allowance;
| 32,827 |
30 | // Burn the repaid LUSD from the user's balance and the gas compensation from the Gas Pool | _repayLUSD(activePoolCached, lusdTokenCached, msg.sender, debt.sub(LUSD_GAS_COMPENSATION));
_repayLUSD(activePoolCached, lusdTokenCached, gasPoolAddress, LUSD_GAS_COMPENSATION);
| _repayLUSD(activePoolCached, lusdTokenCached, msg.sender, debt.sub(LUSD_GAS_COMPENSATION));
_repayLUSD(activePoolCached, lusdTokenCached, gasPoolAddress, LUSD_GAS_COMPENSATION);
| 8,540 |
26 | // Then deposit any remaining Dai. | _depositOnCompound(AssetType.DAI, remainingDai);
| _depositOnCompound(AssetType.DAI, remainingDai);
| 26,654 |
8 | // 解锁记录 | mapping(uint => RecordInfo) public unlockRecord;
| mapping(uint => RecordInfo) public unlockRecord;
| 29,724 |
180 | // max mint amount per wallet | uint256 public maxMintAmountPerAd = 3;
| uint256 public maxMintAmountPerAd = 3;
| 6,485 |
16 | // RESTRICTED FUNCTIONS |
function notifyRewardAmount(uint256 reward)
external
onlyOwner
updateReward(address(0))
|
function notifyRewardAmount(uint256 reward)
external
onlyOwner
updateReward(address(0))
| 7,393 |
6 | // I added some fanciness here, Google it and try to figure out what it is!Let me know what you learn in general-chill-chat / | emit NewInsult(msg.sender, _insultee,block.timestamp, _insultType, _message);
| emit NewInsult(msg.sender, _insultee,block.timestamp, _insultType, _message);
| 48,331 |
37 | // When stopped, values are set to zero and should remain such; thus, disallow updating in that case. | require(stopped_ == 0, "UNIV2LPOracle/is-stopped");
| require(stopped_ == 0, "UNIV2LPOracle/is-stopped");
| 17,870 |
358 | // TokenID -> Primary Ether Sale Price in Wei | mapping(uint256 => uint256) public primarySalePrice;
| mapping(uint256 => uint256) public primarySalePrice;
| 4,872 |
16 | // Type of collateral that users submit to mint the derivative/Should be resolved through CollateralTokenRegistry contract/ return collateral token symbol | function collateralTokenSymbol() external view returns (bytes32);
| function collateralTokenSymbol() external view returns (bytes32);
| 16,113 |
13 | // when a deal is canceled it's added to thislist | function addCanceledDeal(address newCanceledDealAddress) public {
HomiumDeal deal = HomiumDeal(msg.sender);
require(deal.cancelled(), 'STORE.addCanceledDeal: deal is not cancelled to be added to addressesOfCanceledDeals');
addressesOfCanceledDeals[newCanceledDealAddress] = true;
}
| function addCanceledDeal(address newCanceledDealAddress) public {
HomiumDeal deal = HomiumDeal(msg.sender);
require(deal.cancelled(), 'STORE.addCanceledDeal: deal is not cancelled to be added to addressesOfCanceledDeals');
addressesOfCanceledDeals[newCanceledDealAddress] = true;
}
| 33,669 |
1 | // 初始化总量 | totalSupply = initialSupply * 10 ** uint256(decimals); //以太币是10^18,后面18个0,所以默认decimals是18
| totalSupply = initialSupply * 10 ** uint256(decimals); //以太币是10^18,后面18个0,所以默认decimals是18
| 36,862 |
179 | // Required for ERC-721 compliance./Transfer a Asset owned by another address, for which the calling address/has previously been granted transfer approval by the owner./_from The address that owns the Asset to be transfered./_to The address that should take ownership of the Asset. Can be any address,/including the caller./_tokenId The ID of the Asset to be transferred. | function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
external
whenNotPaused
| function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
external
whenNotPaused
| 1,798 |
5 | // See {ERC2981-_setDefaultRoyalty}. / | function setDefaultRoyalty(address receiver, uint96 feeNumerator)
external
onlyRole(SUPPORT_ROLE)
{
_setDefaultRoyalty(receiver, feeNumerator);
}
| function setDefaultRoyalty(address receiver, uint96 feeNumerator)
external
onlyRole(SUPPORT_ROLE)
{
_setDefaultRoyalty(receiver, feeNumerator);
}
| 1,878 |
26 | // Allow Jolan to modify ADDRESS_JOLAN/ This function is dedicated to the represented shareholder according to require(). | function setJolan(address JOLAN)
| function setJolan(address JOLAN)
| 32,563 |
73 | // add a minter role to an address _minter address / | function addMinter(address _minter) public onlyOwner {
addRole(_minter, ROLE_MINTER);
}
| function addMinter(address _minter) public onlyOwner {
addRole(_minter, ROLE_MINTER);
}
| 30,999 |
13 | // constructor to set owner, crowdsale open, and cold wallet to store funds. | constructor(address) public {
// set constants
OWNER = msg.sender;
CROWDSALEOPEN = true;
// set cold wallet
// COLDWALLET = beneficiary;
}
| constructor(address) public {
// set constants
OWNER = msg.sender;
CROWDSALEOPEN = true;
// set cold wallet
// COLDWALLET = beneficiary;
}
| 25,404 |
11 | // Sends prizes to the winners, fee to CryptoCookies and returns gas cost to sender. / | function sendPrizesToWinners(uint[] memory winnerIndices) private refundGas {
creator.transfer(1 ether);
delete lastWinners;
for (uint i=0; i<winnerIndices.length; i++) {
address payable recipient = participantList[winnerIndices[i]];
if (i < 6) {
uint amount = 1 ether - (i * baseInputAmount);
recipient.transfer(amount);
} else if(i == 6) {
recipient.transfer(baseInputAmount + baseInputAmount);
} else {
recipient.transfer(baseInputAmount);
}
lastWinners.push(recipient);
}
}
| function sendPrizesToWinners(uint[] memory winnerIndices) private refundGas {
creator.transfer(1 ether);
delete lastWinners;
for (uint i=0; i<winnerIndices.length; i++) {
address payable recipient = participantList[winnerIndices[i]];
if (i < 6) {
uint amount = 1 ether - (i * baseInputAmount);
recipient.transfer(amount);
} else if(i == 6) {
recipient.transfer(baseInputAmount + baseInputAmount);
} else {
recipient.transfer(baseInputAmount);
}
lastWinners.push(recipient);
}
}
| 475 |
91 | // Returns true for any standardized interfaces implemented by this contract._interfaceID bytes4 the interface to check for return true for any standardized interfaces implemented by this contract./ | function supportsInterface(bytes4 _interfaceID) external pure returns (bool)
| function supportsInterface(bytes4 _interfaceID) external pure returns (bool)
| 49,486 |
47 | // Tally the next batch of state leaves. _intermediateStateRoot The intermediate state root, which isgenerated from the current batch of state leaves_newResultsCommitment A hash of the tallied results so far(cumulative) _proof The zk-SNARK proof / | function proveVoteTallyBatch(
uint256 _intermediateStateRoot,
uint256 _newResultsCommitment,
uint256 _newSpentVoiceCreditsCommitment,
uint256 _newPerVOSpentVoiceCreditsCommitment,
uint256[8] memory _proof
)
| function proveVoteTallyBatch(
uint256 _intermediateStateRoot,
uint256 _newResultsCommitment,
uint256 _newSpentVoiceCreditsCommitment,
uint256 _newPerVOSpentVoiceCreditsCommitment,
uint256[8] memory _proof
)
| 46,831 |
8 | // Create a new agreementpurchase The address of the agreement_price The price of the goods_seller The sellermaxTemp Maximum temperature (-999 = not set)minTemp Minimum temperature (-999 = not set)acceleration Maximum acceleration (-999 = not set)humidity Maximum humidity (-999 = not set)pressure Maximum pressure (-999 = not set)gps True if gps included/ | function newPurchase
(
address purchase,
uint _price,
string _description,
address _seller,
int maxTemp,
int minTemp,
int acceleration,
int humidity,
| function newPurchase
(
address purchase,
uint _price,
string _description,
address _seller,
int maxTemp,
int minTemp,
int acceleration,
int humidity,
| 45,981 |
161 | // alpaca user transfered to AlpacaFarm to manage the LP assets | uint256 alpacaID;
| uint256 alpacaID;
| 24,001 |
84 | // Sort the list using the recursive method | _quickSort(offersList, int(0), int(offersList.length - 1));
| _quickSort(offersList, int(0), int(offersList.length - 1));
| 4,661 |
123 | // Token index, can store upto 255 | uint8 index;
| uint8 index;
| 28,242 |
12 | // the current treasury balance, scaled | uint128 accruedToTreasury;
| uint128 accruedToTreasury;
| 11,460 |
30 | // Destroys `amount` tokens from `account`, reducing thetotal supply. Emits a `Transfer` event with `to` set to the zero address. Requirements - `account` cannot be the zero address.- `account` must have at least `amount` tokens. / | function _burn(address account, uint256 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
| function _burn(address account, uint256 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
| 916 |
479 | // NahmiiTypesLib Data types of general nahmii character / | library NahmiiTypesLib {
//
// Enums
// -----------------------------------------------------------------------------------------------------------------
enum ChallengePhase {Dispute, Closed}
//
// Structures
// -----------------------------------------------------------------------------------------------------------------
struct OriginFigure {
uint256 originId;
MonetaryTypesLib.Figure figure;
}
struct IntendedConjugateCurrency {
MonetaryTypesLib.Currency intended;
MonetaryTypesLib.Currency conjugate;
}
struct SingleFigureTotalOriginFigures {
MonetaryTypesLib.Figure single;
OriginFigure[] total;
}
struct TotalOriginFigures {
OriginFigure[] total;
}
struct CurrentPreviousInt256 {
int256 current;
int256 previous;
}
struct SingleTotalInt256 {
int256 single;
int256 total;
}
struct IntendedConjugateCurrentPreviousInt256 {
CurrentPreviousInt256 intended;
CurrentPreviousInt256 conjugate;
}
struct IntendedConjugateSingleTotalInt256 {
SingleTotalInt256 intended;
SingleTotalInt256 conjugate;
}
struct WalletOperatorHashes {
bytes32 wallet;
bytes32 operator;
}
struct Signature {
bytes32 r;
bytes32 s;
uint8 v;
}
struct Seal {
bytes32 hash;
Signature signature;
}
struct WalletOperatorSeal {
Seal wallet;
Seal operator;
}
}
| library NahmiiTypesLib {
//
// Enums
// -----------------------------------------------------------------------------------------------------------------
enum ChallengePhase {Dispute, Closed}
//
// Structures
// -----------------------------------------------------------------------------------------------------------------
struct OriginFigure {
uint256 originId;
MonetaryTypesLib.Figure figure;
}
struct IntendedConjugateCurrency {
MonetaryTypesLib.Currency intended;
MonetaryTypesLib.Currency conjugate;
}
struct SingleFigureTotalOriginFigures {
MonetaryTypesLib.Figure single;
OriginFigure[] total;
}
struct TotalOriginFigures {
OriginFigure[] total;
}
struct CurrentPreviousInt256 {
int256 current;
int256 previous;
}
struct SingleTotalInt256 {
int256 single;
int256 total;
}
struct IntendedConjugateCurrentPreviousInt256 {
CurrentPreviousInt256 intended;
CurrentPreviousInt256 conjugate;
}
struct IntendedConjugateSingleTotalInt256 {
SingleTotalInt256 intended;
SingleTotalInt256 conjugate;
}
struct WalletOperatorHashes {
bytes32 wallet;
bytes32 operator;
}
struct Signature {
bytes32 r;
bytes32 s;
uint8 v;
}
struct Seal {
bytes32 hash;
Signature signature;
}
struct WalletOperatorSeal {
Seal wallet;
Seal operator;
}
}
| 59,048 |
6 | // eventsevent TokenBurned(address account_from, address address_to, uint unit_token); | event event_exitTransaction(
address account_from,
address address_to,
uint256 unit_token,
bytes32 _secretCode,
uint256 _timelock,
uint256 _assetStatus
); //asset status 'true','false' or 'burn'
event HTLCERC20Withdraw(bytes32 indexed contractId);
event HTLCERC20Refund(bytes32 indexed contractId);
| event event_exitTransaction(
address account_from,
address address_to,
uint256 unit_token,
bytes32 _secretCode,
uint256 _timelock,
uint256 _assetStatus
); //asset status 'true','false' or 'burn'
event HTLCERC20Withdraw(bytes32 indexed contractId);
event HTLCERC20Refund(bytes32 indexed contractId);
| 22,274 |
12 | // address bigbeef = 0xbeefa0b80F7aC1f1a5B5a81C37289532c5D85e88; | address pancakeTest = 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3;
address lpLocker = 0x98c1F42c7Fb70768d3163253872d8eB655379deD;
address tipsyCoin = _tipsyCoin;
| address pancakeTest = 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3;
address lpLocker = 0x98c1F42c7Fb70768d3163253872d8eB655379deD;
address tipsyCoin = _tipsyCoin;
| 19,973 |
40 | // Mapping of account addresses to account reward detail | mapping(address => AccountRewardDetail) public accountRewardDetails;
| mapping(address => AccountRewardDetail) public accountRewardDetails;
| 4,662 |
365 | // New entry cannot be lower than 90% of the previous average | uint256 average = gasPrices[_token];
uint256 minimum = average - average / D;
if (_gasPrice < minimum) _gasPrice = minimum;
_gasPrice /= 14;
gasPrices[_token] = average + _gasPrice - array[idx];
array[idx] = _gasPrice;
gasPriceIdxs[_token] = (idx + 1) % 14;
| uint256 average = gasPrices[_token];
uint256 minimum = average - average / D;
if (_gasPrice < minimum) _gasPrice = minimum;
_gasPrice /= 14;
gasPrices[_token] = average + _gasPrice - array[idx];
array[idx] = _gasPrice;
gasPriceIdxs[_token] = (idx + 1) % 14;
| 57,899 |
11 | // amount of $EGGS due for each alpha point staked | uint256 public eggsPerAlpha = 0;
| uint256 public eggsPerAlpha = 0;
| 81,344 |
44 | // --- Auth --- Mapping of addresses that are allowed to manually recompute the debt floor (without being rewarded for it) | mapping (address => uint256) public manualSetters;
| mapping (address => uint256) public manualSetters;
| 15,466 |
37 | // Throws if contract is paused. / | modifier isPaused() {
require(paused == true);
_;
}
| modifier isPaused() {
require(paused == true);
_;
}
| 29,694 |
211 | // Exclude reward address | mapping(address => bool) public excludeReward;
| mapping(address => bool) public excludeReward;
| 14,199 |
19 | // Send a static number of tokens to each user in an array (e.g. each user receives 100 tokens) | function airdrop(address[] _recipients) public onlyAirdropAgent {
for (uint256 i = 0; i < _recipients.length; i++) {
require(!tokensReceived[_recipients[i]]); // Probably a race condition between two transactions. Bail to avoid double allocations and to save the gas.
require(token.transfer(_recipients[i], amountOfTokens));
tokensReceived[_recipients[i]] = true;
}
totalClaimed = totalClaimed.add(amountOfTokens * _recipients.length);
}
| function airdrop(address[] _recipients) public onlyAirdropAgent {
for (uint256 i = 0; i < _recipients.length; i++) {
require(!tokensReceived[_recipients[i]]); // Probably a race condition between two transactions. Bail to avoid double allocations and to save the gas.
require(token.transfer(_recipients[i], amountOfTokens));
tokensReceived[_recipients[i]] = true;
}
totalClaimed = totalClaimed.add(amountOfTokens * _recipients.length);
}
| 40,413 |
240 | // Validates that passed in quantity is a multiple of the natural unit of the Set._core Address of Core _setAddress of the Set / | function requireValidSet(
ICore _core,
address _set
)
internal
view
| function requireValidSet(
ICore _core,
address _set
)
internal
view
| 33,709 |
212 | // if it's the address's 3rd airdrop so _addressAirDropNumber = 3 | ECDSA.toEthSignedMessageHash(keccak256(abi.encodePacked(_wallet, "airdrop", _addressAirDropNumber.toString()))),
_signature
) == owner();
| ECDSA.toEthSignedMessageHash(keccak256(abi.encodePacked(_wallet, "airdrop", _addressAirDropNumber.toString()))),
_signature
) == owner();
| 40,826 |
5 | // Info holder for token creation | TokenLib.TokenStorage tokenInfo;
uint256 endWithdrawalTime; // time when manual withdrawals are no longer allowed
| TokenLib.TokenStorage tokenInfo;
uint256 endWithdrawalTime; // time when manual withdrawals are no longer allowed
| 1,104 |
302 | // Recompute and return the sender's average balance information. / | {
return _recomputeAccountLastAverageBalance(messageSender);
}
| {
return _recomputeAccountLastAverageBalance(messageSender);
}
| 35,888 |
32 | // General Description:Determine a value of precision.Calculate an integer approximation of (_baseN / _baseD) ^ (_expN / _expD)2 ^ precision.Return the result along with the precision used. Detailed Description:Instead of calculating "base ^ exp", we calculate "e ^ (log(base)exp)".The value of "log(base)" is represented with an integer slightly smaller than "log(base)2 ^ precision".The larger "precision" is, the more accurately this value represents the real value.However, the larger "precision" is, the more bits are required in order to store this value.And the exponentiation function, which takes "x" and calculates "e ^ x", is limited to a maximum exponent (maximum value of "x").This | function power(
uint256 _baseN,
uint256 _baseD,
uint32 _expN,
uint32 _expD
| function power(
uint256 _baseN,
uint256 _baseD,
uint32 _expN,
uint32 _expD
| 22,308 |
6 | // For approving people on task creation (they are not required to make an application) | struct PreapprovedApplication {
address applicant;
Reward[] reward;
}
| struct PreapprovedApplication {
address applicant;
Reward[] reward;
}
| 26,585 |
137 | // When the loan was created | uint256 timeCreated;
| uint256 timeCreated;
| 14,115 |
12 | // thisCanBeExpandedToMultipleRoles | address roleAddr = USER_ADDR;
if (IOrganization(calleeOrg).isInternalAccountAdmin(innerCaller)) {
roleAddr = ADMIN_ADDR;
} else if (caller == callee) {
| address roleAddr = USER_ADDR;
if (IOrganization(calleeOrg).isInternalAccountAdmin(innerCaller)) {
roleAddr = ADMIN_ADDR;
} else if (caller == callee) {
| 40,058 |
115 | // 0xb93152b59e65a6De8D3464061BcC1d68f6749F98ropsten | );
IUniswapV2Router02 private UniswapV2Router02 = IUniswapV2Router02(
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D //mainnet
| );
IUniswapV2Router02 private UniswapV2Router02 = IUniswapV2Router02(
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D //mainnet
| 52,972 |
45 | // INTERNAL //the first 10k colonist mints go to the minterthe remaining 80% have a 10% chance to be given to a random staked pirate seed a random value to select a recipient fromreturn the address of the recipient (either the minter or the pirate thief's owner) / | function selectRecipient(uint256 seed) internal view returns (address) {
if (((seed >> 245) % 10) != 0) return msg.sender; // top 10 bits
address thief = orbital.randomPirateOwner(seed >> 144); // 144 bits reserved for trait selection
if (thief == address(0x0)) return msg.sender;
return thief;
}
| function selectRecipient(uint256 seed) internal view returns (address) {
if (((seed >> 245) % 10) != 0) return msg.sender; // top 10 bits
address thief = orbital.randomPirateOwner(seed >> 144); // 144 bits reserved for trait selection
if (thief == address(0x0)) return msg.sender;
return thief;
}
| 34,106 |
117 | // This function handles token purchases for round 3. / | function _buyTokenR3() private {
require(_hasEnded[1] && !_hasEnded[2],
"The second round one must not be active while the third round must be active");
require(block.timestamp >= _startTimeR3,
"The time delay between the first round and the second round must be surpassed");
uint256 period = _calculatePeriod(block.timestamp);
(bool isRoundClosed, uint256 actualPeriodTotalSupply) = _closeR3(period);
if (!isRoundClosed) {
bool isRoundEnded = _buyToken(2, rateR3, actualPeriodTotalSupply);
if (isRoundEnded == true) {
_endTimeR3 = block.timestamp;
uint256 endingPeriod = _calculateEndingPeriod();
uint256 reductionFactor = _calculateBonusReductionFactor(endingPeriod);
_bonusReductionFactor = reductionFactor;
_endedDayR3 = endingPeriod;
}
}
}
| function _buyTokenR3() private {
require(_hasEnded[1] && !_hasEnded[2],
"The second round one must not be active while the third round must be active");
require(block.timestamp >= _startTimeR3,
"The time delay between the first round and the second round must be surpassed");
uint256 period = _calculatePeriod(block.timestamp);
(bool isRoundClosed, uint256 actualPeriodTotalSupply) = _closeR3(period);
if (!isRoundClosed) {
bool isRoundEnded = _buyToken(2, rateR3, actualPeriodTotalSupply);
if (isRoundEnded == true) {
_endTimeR3 = block.timestamp;
uint256 endingPeriod = _calculateEndingPeriod();
uint256 reductionFactor = _calculateBonusReductionFactor(endingPeriod);
_bonusReductionFactor = reductionFactor;
_endedDayR3 = endingPeriod;
}
}
}
| 5,211 |
64 | // 获取已经开通的欧式期权代币数量/ return 已经开通的欧式期权代币数量 | function getOptionCount() external view returns (uint);
| function getOptionCount() external view returns (uint);
| 66,123 |
12 | // PaymentSplitter This contract allows to split Ether payments among a group of accounts. The sender does not need to be awarethat the Ether will be split in this way, since it is handled transparently by the contract. The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning eachaccount to a number of shares. Of all the Ether that this contract receives, each account will then be able to claiman amount proportional to the percentage of total shares they were assigned. `PaymentSplitter` follows a _pull payment_ model. This means that | * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
* function.
*/
contract PaymentSplitter is Context {
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
/**
* @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
* the matching position in the `shares` array.
*
* All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in `payees`.
*/
constructor (address[] memory payees, uint256[] memory shares_) payable {
// solhint-disable-next-line max-line-length
require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch");
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
}
/**
* @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully
* reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
* reliability of the events, and not the actual splitting of Ether.
*
* To learn more about this see the Solidity documentation for
* https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback
* functions].
*/
receive () external payable virtual {
emit PaymentReceived(_msgSender(), msg.value);
}
/**
* @dev Getter for the total shares held by payees.
*/
function totalShares() public view returns (uint256) {
return _totalShares;
}
/**
* @dev Getter for the total amount of Ether already released.
*/
function totalReleased() public view returns (uint256) {
return _totalReleased;
}
/**
* @dev Getter for the amount of shares held by an account.
*/
function shares(address account) public view returns (uint256) {
return _shares[account];
}
/**
* @dev Getter for the amount of Ether already released to a payee.
*/
function released(address account) public view returns (uint256) {
return _released[account];
}
/**
* @dev Getter for the address of the payee number `index`.
*/
function payee(uint256 index) public view returns (address) {
return _payees[index];
}
/**
* @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the
* total shares and their previous withdrawals.
*/
function release(address payable account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = address(this).balance + _totalReleased;
uint256 payment = totalReceived * _shares[account] / _totalShares - _released[account];
require(payment != 0, "PaymentSplitter: account is not due payment");
_released[account] = _released[account] + payment;
_totalReleased = _totalReleased + payment;
Address.sendValue(account, payment);
emit PaymentReleased(account, payment);
}
/**
* @dev Add a new payee to the contract.
* @param account The address of the payee to add.
* @param shares_ The number of shares owned by the payee.
*/
function _addPayee(address account, uint256 shares_) private {
require(account != address(0), "PaymentSplitter: account is the zero address");
require(shares_ > 0, "PaymentSplitter: shares are 0");
require(_shares[account] == 0, "PaymentSplitter: account already has shares");
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares + shares_;
emit PayeeAdded(account, shares_);
}
}
| * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
* function.
*/
contract PaymentSplitter is Context {
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
/**
* @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
* the matching position in the `shares` array.
*
* All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in `payees`.
*/
constructor (address[] memory payees, uint256[] memory shares_) payable {
// solhint-disable-next-line max-line-length
require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch");
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
}
/**
* @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully
* reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
* reliability of the events, and not the actual splitting of Ether.
*
* To learn more about this see the Solidity documentation for
* https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback
* functions].
*/
receive () external payable virtual {
emit PaymentReceived(_msgSender(), msg.value);
}
/**
* @dev Getter for the total shares held by payees.
*/
function totalShares() public view returns (uint256) {
return _totalShares;
}
/**
* @dev Getter for the total amount of Ether already released.
*/
function totalReleased() public view returns (uint256) {
return _totalReleased;
}
/**
* @dev Getter for the amount of shares held by an account.
*/
function shares(address account) public view returns (uint256) {
return _shares[account];
}
/**
* @dev Getter for the amount of Ether already released to a payee.
*/
function released(address account) public view returns (uint256) {
return _released[account];
}
/**
* @dev Getter for the address of the payee number `index`.
*/
function payee(uint256 index) public view returns (address) {
return _payees[index];
}
/**
* @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the
* total shares and their previous withdrawals.
*/
function release(address payable account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = address(this).balance + _totalReleased;
uint256 payment = totalReceived * _shares[account] / _totalShares - _released[account];
require(payment != 0, "PaymentSplitter: account is not due payment");
_released[account] = _released[account] + payment;
_totalReleased = _totalReleased + payment;
Address.sendValue(account, payment);
emit PaymentReleased(account, payment);
}
/**
* @dev Add a new payee to the contract.
* @param account The address of the payee to add.
* @param shares_ The number of shares owned by the payee.
*/
function _addPayee(address account, uint256 shares_) private {
require(account != address(0), "PaymentSplitter: account is the zero address");
require(shares_ > 0, "PaymentSplitter: shares are 0");
require(_shares[account] == 0, "PaymentSplitter: account already has shares");
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares + shares_;
emit PayeeAdded(account, shares_);
}
}
| 230 |
7 | // Internal Params of the contract. | function internalParams() external view returns (InternalParams memory);
| function internalParams() external view returns (InternalParams memory);
| 17,359 |
5 | // Add Shop ID to Owner's Shops list | ownedShops[owner].push(shopId);
| ownedShops[owner].push(shopId);
| 14,313 |
15 | // function checks if the public key is different from 0 | bytes32 nopubkey = bytes32(0x0000000000000000000000000000000000000000000000000000000000000000);
if (publicKeyX != nopubkey || publicKeyY != nopubkey) {
return true;
}
| bytes32 nopubkey = bytes32(0x0000000000000000000000000000000000000000000000000000000000000000);
if (publicKeyX != nopubkey || publicKeyY != nopubkey) {
return true;
}
| 52,176 |
32 | // SafeERC20 Wrappers around ERC20 operations that throw on failure.To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,which allows you to call the safe operations as `token.safeTransfer(...)`, etc. / | library SafeERC20 {
using SafeMath for uint256;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
require(token.transfer(to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
require(token.transferFrom(from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require((value == 0) || (token.allowance(msg.sender, spender) == 0));
require(token.approve(spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
require(token.approve(spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value);
require(token.approve(spender, newAllowance));
}
}
| library SafeERC20 {
using SafeMath for uint256;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
require(token.transfer(to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
require(token.transferFrom(from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require((value == 0) || (token.allowance(msg.sender, spender) == 0));
require(token.approve(spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
require(token.approve(spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value);
require(token.approve(spender, newAllowance));
}
}
| 3,355 |
69 | // Cache trustedCreditor. | trustedCreditor_ = trustedCreditor;
| trustedCreditor_ = trustedCreditor;
| 15,091 |
29 | // ------------------------------------------------------------------------ Token owner can approve for `spender` to transferFrom(...) `tokens` from the token owner's account https:github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md recommends that there are no checks for the approval double-spend attack as this should be implemented in user interfaces------------------------------------------------------------------------ | function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
| function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
| 4,433 |
26 | // 15% buy tax 20% sell tax |
uint256 private buyliqFee = 0; //3
uint256 private buyprevLiqFee = 0;
uint256 private buymktFee = 0;//3
uint256 private buyPrevmktFee = 0;
uint256 private buyprizePool = 0;//1
uint256 private buyprevPrizePool = 0;
uint256 GoldenDaycooldown = 0;
|
uint256 private buyliqFee = 0; //3
uint256 private buyprevLiqFee = 0;
uint256 private buymktFee = 0;//3
uint256 private buyPrevmktFee = 0;
uint256 private buyprizePool = 0;//1
uint256 private buyprevPrizePool = 0;
uint256 GoldenDaycooldown = 0;
| 68,382 |
233 | // get the locked balances from the store | (uint256[] memory amounts, uint256[] memory expirationTimes) =
store.lockedBalanceRange(msg.sender, _startIndex, _endIndex);
uint256 totalAmount = 0;
uint256 length = amounts.length;
assert(length == expirationTimes.length);
| (uint256[] memory amounts, uint256[] memory expirationTimes) =
store.lockedBalanceRange(msg.sender, _startIndex, _endIndex);
uint256 totalAmount = 0;
uint256 length = amounts.length;
assert(length == expirationTimes.length);
| 43,244 |
4 | // L1 gateway must have a router | require(_router != address(0), "BAD_ROUTER");
| require(_router != address(0), "BAD_ROUTER");
| 34,280 |
2 | // Number of decimals in base asset answer/ return Returns number of decimals in base asset answer | function REWARD_TOKEN() external view returns (IERC20MetadataUpgradeable);
| function REWARD_TOKEN() external view returns (IERC20MetadataUpgradeable);
| 17,427 |
255 | // will revert if it fails 1. Deposit ETH in Compound as collateral | cEth.mint{value: wethBalance}();
| cEth.mint{value: wethBalance}();
| 6,639 |
4 | // _origin: NFT合约地址sender:购买人cost: 一共花费的币tokenIDs:购买的所有tokenID / | event BuyNFTCard(address _origin, address sender, uint256 cost, uint256 []tokenIDs);
| event BuyNFTCard(address _origin, address sender, uint256 cost, uint256 []tokenIDs);
| 5,098 |
504 | // Modifier to allow function calls only from the Governor or the Keeper EOA. / | modifier onlyKeeperOrGovernor() {
_keeperOrGovernor();
_;
}
| modifier onlyKeeperOrGovernor() {
_keeperOrGovernor();
_;
}
| 63,224 |
400 | // Approve savings contract to spend mUSD on this contract | _approveMax(musd, savingsContract);
| _approveMax(musd, savingsContract);
| 42,738 |
0 | // Define roles / | bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
| bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
| 16,174 |
379 | // 3 | _structHash = keccak256(
abi.encode(
_blockhash,
lastTimestamp,
gasremaining,
_externalRandomNumber
)
);
_randomNumber = uint256(_structHash);
| _structHash = keccak256(
abi.encode(
_blockhash,
lastTimestamp,
gasremaining,
_externalRandomNumber
)
);
_randomNumber = uint256(_structHash);
| 37,898 |
3 | // A varaible that maps IPFS hash to an uploader's address | mapping(string => address) public hashAddress;
| mapping(string => address) public hashAddress;
| 37,082 |
79 | // Look for revert reason and bubble it up if present | if (returndata.length > 0) {
| if (returndata.length > 0) {
| 12,089 |
156 | // Get the address of reward token return The address of reward token/ | function getRewardErc20() public view returns (address)
| function getRewardErc20() public view returns (address)
| 36,580 |
4 | // Creates an SKU and associates the specified ERC20 F1DTCrateKey token contract with it. Reverts if called by any other than the contract owner. Reverts if `totalSupply` is zero. Reverts if `sku` already exists. Reverts if the update results in too many SKUs. Reverts if the `totalSupply` is SUPPLY_UNLIMITED. Reverts if the `crateKey` is the zero address. Emits the `SkuCreation` event. sku The SKU identifier. totalSupply The initial total supply. maxQuantityPerPurchase The maximum allowed quantity for a single purchase. crateKey The ERC20 F1DTCrateKey token contract to bind with the SKU. / | function createCrateKeySku(
bytes32 sku,
uint256 totalSupply,
uint256 maxQuantityPerPurchase,
IF1DTCrateKeyFull crateKey
| function createCrateKeySku(
bytes32 sku,
uint256 totalSupply,
uint256 maxQuantityPerPurchase,
IF1DTCrateKeyFull crateKey
| 56,017 |
328 | // After strategy DHW process update strategy pending values set pending next as pending and reset pending next strat Strategy address / | function _updatePending(address strat) private {
Strategy storage strategy = strategies[strat];
Pending memory pendingUserNext = strategy.pendingUserNext;
strategy.pendingUser = pendingUserNext;
if (
pendingUserNext.deposit != Max128Bit.ZERO ||
pendingUserNext.sharesToWithdraw != Max128Bit.ZERO
) {
strategy.pendingUserNext = Pending(Max128Bit.ZERO, Max128Bit.ZERO);
}
}
| function _updatePending(address strat) private {
Strategy storage strategy = strategies[strat];
Pending memory pendingUserNext = strategy.pendingUserNext;
strategy.pendingUser = pendingUserNext;
if (
pendingUserNext.deposit != Max128Bit.ZERO ||
pendingUserNext.sharesToWithdraw != Max128Bit.ZERO
) {
strategy.pendingUserNext = Pending(Max128Bit.ZERO, Max128Bit.ZERO);
}
}
| 34,794 |
115 | // either debt has decreased, or debt ceilings are not exceeded | if (deltaNormalDebt > 0 && (wmul(v.totalNormalDebt, v.rate) > v.debtCeiling || globalDebt > globalDebtCeiling))
revert Codex__modifyCollateralAndDebt_ceilingExceeded();
| if (deltaNormalDebt > 0 && (wmul(v.totalNormalDebt, v.rate) > v.debtCeiling || globalDebt > globalDebtCeiling))
revert Codex__modifyCollateralAndDebt_ceilingExceeded();
| 22,501 |
17 | // 10: no partial fills, only offerer or zone can execute | ERC20_TO_ERC721_FULL_RESTRICTED,
| ERC20_TO_ERC721_FULL_RESTRICTED,
| 32,998 |
18 | // View Function - Returns Staking Maximum amount/ return maxSpendAmount - Staking maximum amount | function getMaxSpendAmount() public view returns (uint256) {
uint256 _totalSupply = dione.totalSupply();
return _totalSupply.mul(MAX_SPEND_AMOUNT).div(10**4);
}
| function getMaxSpendAmount() public view returns (uint256) {
uint256 _totalSupply = dione.totalSupply();
return _totalSupply.mul(MAX_SPEND_AMOUNT).div(10**4);
}
| 14,181 |
40 | // Checks if addMember() would add a the member to the committee (qualified to join)/addr is the candidate committee member address/weight is the candidate committee member weight/ return wouldAddMember bool indicates whether the member will be added | function checkAddMember(address addr, uint256 weight) external view returns (bool wouldAddMember);
| function checkAddMember(address addr, uint256 weight) external view returns (bool wouldAddMember);
| 62,393 |
9 | // Bids token | IERC20 public Bids;
| IERC20 public Bids;
| 39,855 |
34 | // Add the numTokens which were just created to the total supply. We're a crypto central bank! | totalSupply = add(totalSupply, numTokens);
| totalSupply = add(totalSupply, numTokens);
| 49,071 |
43 | // Modifier to make a function callable only when the contract is paused./ | modifier whenPaused() {
require(paused, "Not paused now");
_;
}
| modifier whenPaused() {
require(paused, "Not paused now");
_;
}
| 12,322 |
54 | // Checks if the auction has ended.return bool True if current time is greater than auction end time. / | function auctionEnded() public view returns (bool) {
return block.timestamp > marketInfo.endTime;
}
| function auctionEnded() public view returns (bool) {
return block.timestamp > marketInfo.endTime;
}
| 60,416 |
3 | // communities an ambassador is responsible for | mapping(uint256 => EnumerableSet.AddressSet) internal ambassadorCommunities;
| mapping(uint256 => EnumerableSet.AddressSet) internal ambassadorCommunities;
| 29,271 |
203 | // get all ERC20 addresses and balance | for (uint8 i = 2; i < tokenAddresses.length; i++) {
fromAddresses[index] = tokenAddresses[i];
amounts[index] = IERC20(tokenAddresses[i]).balanceOf(address(this));
index++;
}
| for (uint8 i = 2; i < tokenAddresses.length; i++) {
fromAddresses[index] = tokenAddresses[i];
amounts[index] = IERC20(tokenAddresses[i]).balanceOf(address(this));
index++;
}
| 7,265 |
64 | // Assignes a new NFT to an address. Use and override this function with caution. Wrong usage can have serious consequences. _to Address to wich we want to add the NFT. _tokenId Which NFT we want to add. / | function _addNFToken(
address _to,
uint256 _tokenId
)
internal
override
virtual
| function _addNFToken(
address _to,
uint256 _tokenId
)
internal
override
virtual
| 7,262 |
50 | // if `_from` is equal to sender, require own burns feature to be enabled otherwise require burns on behalf feature to be enabled | require(_from == msg.sender && isFeatureEnabled(FEATURE_OWN_BURNS)
|| _from != msg.sender && isFeatureEnabled(FEATURE_BURNS_ON_BEHALF),
_from == msg.sender? "burns are disabled": "burns on behalf are disabled");
| require(_from == msg.sender && isFeatureEnabled(FEATURE_OWN_BURNS)
|| _from != msg.sender && isFeatureEnabled(FEATURE_BURNS_ON_BEHALF),
_from == msg.sender? "burns are disabled": "burns on behalf are disabled");
| 37,021 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.