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 |
|---|---|---|---|---|
23 | // First try to get contract verifier | address verifier = ADDRESS_RESOLVER.contractVerifiers(to);
| address verifier = ADDRESS_RESOLVER.contractVerifiers(to);
| 10,012 |
26 | // constructor / | function BadPractices() {
creator = tx.origin;
owner = msg.sender;
}
| function BadPractices() {
creator = tx.origin;
owner = msg.sender;
}
| 41,655 |
15 | // Contract module defining the ERC721 NFT Token.There is a total supply of N tokens to be minted, each unit costs ETH.some are reserved for presale and promo purposes. / | contract AndreyWeb3MintGas is ERC721, Ownable {
using Strings for uint256;
using Counters for Counters.Counter;
Counters.Counter private supply;
string _baseTokenURI;
uint256 public _cardPrice = 5000000000000000; // .005 ETH
bool public _saleIsActive = true;
// Reserve units for team - Giveaways/Prizes/Presales etc
uint public _cardReserve = 5;
uint public _mainCardCnt = 100;
constructor(string memory baseURI) ERC721("AndreyWeb3 Mint Gas Test", "AW3MG") {
setBaseURI(baseURI);
}
function totalSupply() public override view returns (uint256) {
return supply.current();
}
function withdraw() public onlyOwner {
uint balance = address(this).balance;
msg.sender.transfer(balance);
}
/**
* Mint a number of cards straight in target wallet.
* @param _to: The target wallet address, make sure it's the correct wallet.
* @param _numberOfTokens: The number of tokens to mint.
* @dev This function can only be called by the contract owner as it is a free mint.
*/
function mintFreeCards(address _to, uint _numberOfTokens) public onlyOwner {
uint currSupply = supply.current();
require(_numberOfTokens <= _cardReserve, "Not enough cards left in reserve");
require(currSupply >= _mainCardCnt);
require(currSupply + _numberOfTokens <= _mainCardCnt + _cardReserve, "Purchase would exceed max supply of cards");
_mintLoop(_to, _numberOfTokens);
_cardReserve -= _numberOfTokens;
}
/**
* Mint a number of cards straight in the caller's wallet.
* @param _numberOfTokens: The number of tokens to mint.
*/
function mintCard(uint _numberOfTokens) public payable {
require(_saleIsActive, "Sale must be active to mint a Card");
require(_numberOfTokens < 6, "Can only mint 5 tokens at a time");
require(supply.current() + _numberOfTokens <= _mainCardCnt, "Purchase would exceed max supply of cards");
require(msg.value >= _cardPrice * _numberOfTokens, "Ether value sent is not correct");
_mintLoop(msg.sender, _numberOfTokens);
}
function _mintLoop(address _receiver, uint256 _numberOfTokens) internal {
for(uint256 i = 0; i < _numberOfTokens; i++) {
supply.increment();
_safeMint(_receiver, supply.current());
}
}
function flipSaleState() public onlyOwner {
_saleIsActive = !_saleIsActive;
}
function setBaseURI(string memory baseURI) public onlyOwner {
_baseTokenURI = baseURI;
}
// Might wanna adjust price later on.
function setPrice(uint256 _newPrice) public onlyOwner() {
_cardPrice = _newPrice;
}
function getBaseURI() public view returns(string memory) {
return _baseTokenURI;
}
function getPrice() public view returns(uint256){
return _cardPrice;
}
function tokenURI(uint256 tokenId) public override view returns(string memory) {
return string(abi.encodePacked(_baseTokenURI, tokenId.toString()));
}
function tokensOfOwner(address _owner) external view returns(uint256[] memory ) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
for (uint i = 0; i < tokenCount; i++) {
result[i] = tokenOfOwnerByIndex(_owner, i);
}
return result;
}
}
}
| contract AndreyWeb3MintGas is ERC721, Ownable {
using Strings for uint256;
using Counters for Counters.Counter;
Counters.Counter private supply;
string _baseTokenURI;
uint256 public _cardPrice = 5000000000000000; // .005 ETH
bool public _saleIsActive = true;
// Reserve units for team - Giveaways/Prizes/Presales etc
uint public _cardReserve = 5;
uint public _mainCardCnt = 100;
constructor(string memory baseURI) ERC721("AndreyWeb3 Mint Gas Test", "AW3MG") {
setBaseURI(baseURI);
}
function totalSupply() public override view returns (uint256) {
return supply.current();
}
function withdraw() public onlyOwner {
uint balance = address(this).balance;
msg.sender.transfer(balance);
}
/**
* Mint a number of cards straight in target wallet.
* @param _to: The target wallet address, make sure it's the correct wallet.
* @param _numberOfTokens: The number of tokens to mint.
* @dev This function can only be called by the contract owner as it is a free mint.
*/
function mintFreeCards(address _to, uint _numberOfTokens) public onlyOwner {
uint currSupply = supply.current();
require(_numberOfTokens <= _cardReserve, "Not enough cards left in reserve");
require(currSupply >= _mainCardCnt);
require(currSupply + _numberOfTokens <= _mainCardCnt + _cardReserve, "Purchase would exceed max supply of cards");
_mintLoop(_to, _numberOfTokens);
_cardReserve -= _numberOfTokens;
}
/**
* Mint a number of cards straight in the caller's wallet.
* @param _numberOfTokens: The number of tokens to mint.
*/
function mintCard(uint _numberOfTokens) public payable {
require(_saleIsActive, "Sale must be active to mint a Card");
require(_numberOfTokens < 6, "Can only mint 5 tokens at a time");
require(supply.current() + _numberOfTokens <= _mainCardCnt, "Purchase would exceed max supply of cards");
require(msg.value >= _cardPrice * _numberOfTokens, "Ether value sent is not correct");
_mintLoop(msg.sender, _numberOfTokens);
}
function _mintLoop(address _receiver, uint256 _numberOfTokens) internal {
for(uint256 i = 0; i < _numberOfTokens; i++) {
supply.increment();
_safeMint(_receiver, supply.current());
}
}
function flipSaleState() public onlyOwner {
_saleIsActive = !_saleIsActive;
}
function setBaseURI(string memory baseURI) public onlyOwner {
_baseTokenURI = baseURI;
}
// Might wanna adjust price later on.
function setPrice(uint256 _newPrice) public onlyOwner() {
_cardPrice = _newPrice;
}
function getBaseURI() public view returns(string memory) {
return _baseTokenURI;
}
function getPrice() public view returns(uint256){
return _cardPrice;
}
function tokenURI(uint256 tokenId) public override view returns(string memory) {
return string(abi.encodePacked(_baseTokenURI, tokenId.toString()));
}
function tokensOfOwner(address _owner) external view returns(uint256[] memory ) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
for (uint i = 0; i < tokenCount; i++) {
result[i] = tokenOfOwnerByIndex(_owner, i);
}
return result;
}
}
}
| 30,276 |
66 | // // FUNCTIONS ///OpenZeppelin's ECDSA library is used to call all ECDSA functions directly on the bytes32 variables themselves. | using ECDSA for bytes32;
| using ECDSA for bytes32;
| 10,182 |
6 | // Give permissions to new derivative contract and then hand over ownership. | tokenCurrency.addMinter(derivative);
tokenCurrency.addBurner(derivative);
tokenCurrency.resetOwner(derivative);
_registerContract(new address[](0), address(derivative));
emit CreatedExpiringMultiParty(address(derivative), msg.sender);
return address(derivative);
| tokenCurrency.addMinter(derivative);
tokenCurrency.addBurner(derivative);
tokenCurrency.resetOwner(derivative);
_registerContract(new address[](0), address(derivative));
emit CreatedExpiringMultiParty(address(derivative), msg.sender);
return address(derivative);
| 43,049 |
98 | // Freze account / | function _freeze(address target, bool freeze) internal {
_beforeAccountFreeze(target);
require(target != address(0), "FreezableToken: target the zero address");
_frozenAccounts[target] = freeze;
emit FrozenFunds(target, freeze);
}
| function _freeze(address target, bool freeze) internal {
_beforeAccountFreeze(target);
require(target != address(0), "FreezableToken: target the zero address");
_frozenAccounts[target] = freeze;
emit FrozenFunds(target, freeze);
}
| 76,233 |
0 | // Returns the addition of two unsigned integers, reverting on overflow. Counterpart to Solidity's `+` operator. Requirements: - Addition cannot overflow./ | function add(
uint256 a,
uint256 b
)
internal
pure
returns (
uint256
)
| function add(
uint256 a,
uint256 b
)
internal
pure
returns (
uint256
)
| 14,955 |
44 | // Allows address to be approved for transferFrom(). | function _approve(uint256 _tokenId, address _approved) internal {
gunIndexToApproved[_tokenId] = _approved;
}
| function _approve(uint256 _tokenId, address _approved) internal {
gunIndexToApproved[_tokenId] = _approved;
}
| 13,007 |
118 | // Sets the address of the application's Mailbox. _mailbox The address of the Mailbox contract. / | function setMailbox(address _mailbox) external virtual onlyOwner {
_setMailbox(_mailbox);
}
| function setMailbox(address _mailbox) external virtual onlyOwner {
_setMailbox(_mailbox);
}
| 19,109 |
114 | // ...or the crowdfunding period is over, but the minimum has been reached | (block.timestamp >= endTimestamp && totalCollected >= minimalGoal)
);
| (block.timestamp >= endTimestamp && totalCollected >= minimalGoal)
);
| 32,918 |
11 | // Burn redeemTokens to withdraw underlyingTokens and strikeTokens from expired options. optionToken The address of the option contract. unwindQuantity Quantity of option tokens used to calculate the amount of redeem tokens to burn. receiver The underlyingTokens are sent to the receiver address and the redeemTokens are burned. / | function safeUnwind(
IOption optionToken,
uint256 unwindQuantity,
address receiver
)
internal
returns (
uint256,
uint256,
uint256
| function safeUnwind(
IOption optionToken,
uint256 unwindQuantity,
address receiver
)
internal
returns (
uint256,
uint256,
uint256
| 13,250 |
103 | // LifestoryPlanets contract | IERC721 private immutable planetContract;
| IERC721 private immutable planetContract;
| 22,884 |
45 | // Allows a liquidity provider to give anend user fast liquidity by pre-filling anincoming transfer message.Transfers tokens from the liquidity provider to the end recipient, minus the LP fee;Records the liquidity provider, who receivesthe full token amount when the transfer message is handled. fast liquidity can only be provided for ONE token transferwith the same (recipient, amount) at a time.in the case that multiple token transfers with the same (recipient, amount) _message The incoming transfer message to pre-fill / | function preFill(bytes calldata _message) external {
// parse tokenId and action from message
bytes29 _msg = _message.ref(0).mustBeMessage();
bytes29 _tokenId = _msg.tokenId().mustBeTokenId();
bytes29 _action = _msg.action().mustBeTransfer();
// calculate prefill ID
bytes32 _id = _preFillId(_tokenId, _action);
// require that transfer has not already been pre-filled
require(liquidityProvider[_id] == address(0), "!unfilled");
// record liquidity provider
liquidityProvider[_id] = msg.sender;
// transfer tokens from liquidity provider to token recipient
IERC20 _token = _mustHaveToken(_tokenId);
_token.safeTransferFrom(
msg.sender,
_action.evmRecipient(),
_applyPreFillFee(_action.amnt())
);
}
| function preFill(bytes calldata _message) external {
// parse tokenId and action from message
bytes29 _msg = _message.ref(0).mustBeMessage();
bytes29 _tokenId = _msg.tokenId().mustBeTokenId();
bytes29 _action = _msg.action().mustBeTransfer();
// calculate prefill ID
bytes32 _id = _preFillId(_tokenId, _action);
// require that transfer has not already been pre-filled
require(liquidityProvider[_id] == address(0), "!unfilled");
// record liquidity provider
liquidityProvider[_id] = msg.sender;
// transfer tokens from liquidity provider to token recipient
IERC20 _token = _mustHaveToken(_tokenId);
_token.safeTransferFrom(
msg.sender,
_action.evmRecipient(),
_applyPreFillFee(_action.amnt())
);
}
| 13,863 |
101 | // check User ID uid user ID / | function checkUserID(uint uid)
internal
pure
| function checkUserID(uint uid)
internal
pure
| 6,431 |
1 | // returns the stored accumulator value as an int256 | function cumulative(Snapshot memory self) internal view returns (int256) {
return int256(self.accumulator);
}
| function cumulative(Snapshot memory self) internal view returns (int256) {
return int256(self.accumulator);
}
| 9,384 |
29 | // (toNodeOperator, toTnft, toBnft, toTreasury) | uint256[] memory payouts = new uint256[](4);
| uint256[] memory payouts = new uint256[](4);
| 10,935 |
20 | // Initializes the contract setting the deployer as the initial owner. / | constructor () {
address msgSender = _msgSender();
_owner = msgSender;
| constructor () {
address msgSender = _msgSender();
_owner = msgSender;
| 378 |
33 | // Gets the address of a registered FarmGenerator at specifiex index / | function farmGeneratorAtIndex(uint256 _index) external view returns (address) {
return farmGenerators.at(_index);
}
| function farmGeneratorAtIndex(uint256 _index) external view returns (address) {
return farmGenerators.at(_index);
}
| 58,733 |
154 | // --------------------------------- ETH --------------------------------- |
function deposit(
address payable to,
uint256 value,
uint256 fees,
bytes32 secretHash
)
payable external
|
function deposit(
address payable to,
uint256 value,
uint256 fees,
bytes32 secretHash
)
payable external
| 75,420 |
15 | // Modifiers. | modifier whenSale() {
require(checkSalePeriod(), "This is not sale period.");
_;
}
| modifier whenSale() {
require(checkSalePeriod(), "This is not sale period.");
_;
}
| 46,358 |
14 | // Pre-sale | require(_presaleOpen, "mint: Pre-sale are closed.");
require(presaleSupply < presaleMaxSupply, "mint: Pre-sale max mint supply reached.");
require(_amount.add(presaleSupply) <= presaleMaxSupply, "mint: Requested mint amount will overflow presale max mint supply.");
require(IERC721(presalePartnersAddress).balanceOf(_msgSender()) > 0, "mint: You are not eligible to pre-sale.");
presaleSupply = presaleSupply.add(_amount);
| require(_presaleOpen, "mint: Pre-sale are closed.");
require(presaleSupply < presaleMaxSupply, "mint: Pre-sale max mint supply reached.");
require(_amount.add(presaleSupply) <= presaleMaxSupply, "mint: Requested mint amount will overflow presale max mint supply.");
require(IERC721(presalePartnersAddress).balanceOf(_msgSender()) > 0, "mint: You are not eligible to pre-sale.");
presaleSupply = presaleSupply.add(_amount);
| 29,995 |
117 | // Calculate burn amount and dev amount | uint256 burnAmt = amount.mul(_burnFee).div(100);
uint256 devAmt = amount.mul(_devFee).div(100);
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, (amount.sub(burnAmt).sub(devAmt)));
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
| uint256 burnAmt = amount.mul(_burnFee).div(100);
uint256 devAmt = amount.mul(_devFee).div(100);
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, (amount.sub(burnAmt).sub(devAmt)));
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
| 15,994 |
9 | // Stake tokens in pool | _stake(amount0, amount1);
| _stake(amount0, amount1);
| 31,919 |
33 | // Set price of 1 token | price = 0.00379 ether;
| price = 0.00379 ether;
| 41,893 |
35 | // Creates a vesting contract that vests its balance of any ERC20 token to the_beneficiary, gradually in a linear fashion until _start + _duration. By then allof the balance will have vested. _beneficiary address of the beneficiary to whom vested tokens are transferred _cliff duration in seconds of the cliff in which tokens will begin to vest _start the time (as Unix time) at which point vesting starts _duration duration in seconds of the period in which the tokens will vest _revocable whether the vesting is revocable or not / | constructor(
| constructor(
| 5,387 |
13 | // TODO: block.timestamp sec | s_claimedRewardsSum[_staker] += _rewards;
emit MoniesRequested(_staker, _rewards, block.timestamp);
| s_claimedRewardsSum[_staker] += _rewards;
emit MoniesRequested(_staker, _rewards, block.timestamp);
| 13,133 |
167 | // Update the order structs. makerOrder The maker order data structure. takerOrder The taker order data structure. toTakerAmount The amount of tokens to be moved to the taker. toTakerAmount The amount of tokens to be moved to the maker.return Success if the update succeeds. / | function __updateOrders__(
Order makerOrder,
Order takerOrder,
uint256 toTakerAmount,
uint256 toMakerAmount
) private
view
| function __updateOrders__(
Order makerOrder,
Order takerOrder,
uint256 toTakerAmount,
uint256 toMakerAmount
) private
view
| 11,927 |
26 | // Get staking infos of a user user The user address for which to get staking infosreturn The staking infos of the user / | function getUserInfo(address user)
| function getUserInfo(address user)
| 21,019 |
168 | // subtract network fee | fromAmountSlice = fromAmountSlice.sub(value);
| fromAmountSlice = fromAmountSlice.sub(value);
| 39,855 |
40 | // deploy mgr | mgr = mgrFab.newTinlakeManager(dai, daiJoin, lenderDeployer.seniorToken(), lenderDeployer.seniorOperator(), lenderDeployer.seniorTranche(), end, vat, vow);
wireClerk(mgr, vat, spotter, jug, matBuffer);
| mgr = mgrFab.newTinlakeManager(dai, daiJoin, lenderDeployer.seniorToken(), lenderDeployer.seniorOperator(), lenderDeployer.seniorTranche(), end, vat, vow);
wireClerk(mgr, vat, spotter, jug, matBuffer);
| 4,904 |
37 | // added | function exists(uint256 _tokenId) external view returns (bool);
| function exists(uint256 _tokenId) external view returns (bool);
| 31,309 |
45 | // subtract how much we've spent | balance -= payoutToSend;
| balance -= payoutToSend;
| 61,779 |
10 | // Returns the number of pools in the path /path The encoded swap path / return The number of pools in the path | function numPools(bytes memory path) internal pure returns (uint256) {
// Ignore the first token address. From then on every fee and token offset indicates a pool.
return ((path.length - ADDR_SIZE) / NEXT_OFFSET);
}
| function numPools(bytes memory path) internal pure returns (uint256) {
// Ignore the first token address. From then on every fee and token offset indicates a pool.
return ((path.length - ADDR_SIZE) / NEXT_OFFSET);
}
| 9,062 |
11 | // Modifiers to allow any combination of roles | modifier hasAnyOfTwoRoles(bytes32 role1, bytes32 role2) {
require(
_core.hasRole(role1, msg.sender) ||
_core.hasRole(role2, msg.sender),
"UNAUTHORIZED"
);
_;
}
| modifier hasAnyOfTwoRoles(bytes32 role1, bytes32 role2) {
require(
_core.hasRole(role1, msg.sender) ||
_core.hasRole(role2, msg.sender),
"UNAUTHORIZED"
);
_;
}
| 13,101 |
183 | // withdraw ERC20 from the contract/token address of the ERC20 to send/to address destination of the ERC20/amount quantity of ERC20 to send | function withdrawERC20(
address token,
address to,
uint256 amount
| function withdrawERC20(
address token,
address to,
uint256 amount
| 40,692 |
1,003 | // leaving _flAmount to be the same as the older version | function repay(address _market, ExchangeData memory _data, uint _rateMode, uint256 _gasCost, uint _flAmount) public payable burnGas(10) {
address lendingPool = ILendingPoolAddressesProviderV2(_market).getLendingPool();
// send msg.value for exchange to the receiver
AAVE_RECEIVER.transfer(msg.value);
address[] memory assets = new address[](1);
assets[0] = _data.srcAddr;
uint256[] memory amounts = new uint256[](1);
amounts[0] = _data.srcAmount;
// for repay we are using regular flash loan with paying back the flash loan + premium
uint256[] memory modes = new uint256[](1);
modes[0] = 0;
// create data
bytes memory encodedData = packExchangeData(_data);
bytes memory data = abi.encode(encodedData, _market, _gasCost, _rateMode, true, address(this));
// give permission to receiver and execute tx
givePermission(AAVE_RECEIVER);
ILendingPoolV2(lendingPool).flashLoan(AAVE_RECEIVER, assets, amounts, modes, address(this), data, AAVE_REFERRAL_CODE);
removePermission(AAVE_RECEIVER);
}
| function repay(address _market, ExchangeData memory _data, uint _rateMode, uint256 _gasCost, uint _flAmount) public payable burnGas(10) {
address lendingPool = ILendingPoolAddressesProviderV2(_market).getLendingPool();
// send msg.value for exchange to the receiver
AAVE_RECEIVER.transfer(msg.value);
address[] memory assets = new address[](1);
assets[0] = _data.srcAddr;
uint256[] memory amounts = new uint256[](1);
amounts[0] = _data.srcAmount;
// for repay we are using regular flash loan with paying back the flash loan + premium
uint256[] memory modes = new uint256[](1);
modes[0] = 0;
// create data
bytes memory encodedData = packExchangeData(_data);
bytes memory data = abi.encode(encodedData, _market, _gasCost, _rateMode, true, address(this));
// give permission to receiver and execute tx
givePermission(AAVE_RECEIVER);
ILendingPoolV2(lendingPool).flashLoan(AAVE_RECEIVER, assets, amounts, modes, address(this), data, AAVE_REFERRAL_CODE);
removePermission(AAVE_RECEIVER);
}
| 57,989 |
1 | // PackedFixed18Lib A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20. Library for the packed signed fixed-decimal type. / | library PackedFixed18Lib {
PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);
PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);
/**
* @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal
* @param self packed signed fixed-decimal
* @return New unpacked signed fixed-decimal
*/
function unpack(PackedFixed18 self) internal pure returns (Fixed18) {
return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));
}
}
| library PackedFixed18Lib {
PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);
PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);
/**
* @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal
* @param self packed signed fixed-decimal
* @return New unpacked signed fixed-decimal
*/
function unpack(PackedFixed18 self) internal pure returns (Fixed18) {
return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));
}
}
| 21,547 |
0 | // 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't solhint-disable-next-line var-name-mixedcase | bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
| bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
| 5,825 |
184 | // Enters the Compound market so it can be deposited/borrowed/_cTokenAddr CToken address of the token | function enterMarket(address _cTokenAddr) public {
address[] memory markets = new address[](1);
markets[0] = _cTokenAddr;
ComptrollerInterface(COMPTROLLER_ADDR).enterMarkets(markets);
}
| function enterMarket(address _cTokenAddr) public {
address[] memory markets = new address[](1);
markets[0] = _cTokenAddr;
ComptrollerInterface(COMPTROLLER_ADDR).enterMarkets(markets);
}
| 33,234 |
1 | // Translates contract address to token id, which is then mapped to the features of the rental listing | mapping(address => mapping(uint256 => Listing)) private _listingMap;
| mapping(address => mapping(uint256 => Listing)) private _listingMap;
| 18,311 |
38 | // return the symbol of the token / | function symbol() public override view returns (string memory) {
return _symbol;
}
| function symbol() public override view returns (string memory) {
return _symbol;
}
| 41,808 |
7 | // Set the ts, g1 or g2 parameters | function setParameter(bytes32 parameter, int128 value)
external
auth
| function setParameter(bytes32 parameter, int128 value)
external
auth
| 32,156 |
37 | // Roach Racing Club NFT registry/Shadow Syndicate / Andrey Pelipenko (kindex@kindex.lv)/Stores NFT ownership and metadata like genome and parents./Uses ERC-721A implementation to optimize gas consumptions during batch mints. | contract RoachNFT is ERC721A, Operators/*, IRoachNFT*/ {
struct Roach {
// array of genes in secret format
bytes genome;
// NFT id of parents
uint40[2] parents;
// UNIX time when egg was minted
uint40 creationTime;
// UNIX time when egg was revealed to roach
uint40 revealTime;
// Gen0, Gen1, etc
uint40 generation;
// Resistance percentage (1234 = 12.34%)
uint16 resistance;
}
mapping(uint => Roach) public roach;
uint16 public GEN0_RESISTANCE = 10000; // 100%
IMetadata public metadataContract;
event Mint(address indexed account, uint indexed tokenId, uint traitBonus, string syndicate);
event Reveal(address indexed owner, uint indexed tokenId);
event GenomeChanged(uint indexed tokenId, bytes genome);
event MetadataContractChanged(IMetadata metadataContract);
constructor(IMetadata _metadataContract)
ERC721A('RCH', 'R')
{
_setMetadataContract(_metadataContract);
}
/// @dev Token numeration starts from 1 (genesis collection id 1..10k)
function _startTokenId() internal view override returns (uint256) {
return 1;
}
/// @notice Returns contract level metadata for roach
/// @return genome Array of genes in secret format
/// @return parents Array of 2 parent roach id
/// @return creationTime UNIX time when egg was minted
/// @return revealTime UNIX time when egg was revealed to roach
/// @return generation Gen0, Gen1, etc
/// @return resistance Resistance percentage (1234 = 12.34%)
/// @return name Roach name
function getRoach(uint roachId) external view
returns (
bytes memory genome,
uint40[2] memory parents,
uint40 creationTime,
uint40 revealTime,
uint40 generation,
uint16 resistance,
string memory name,
address owner)
{
require(_exists(roachId), "query for nonexistent token");
Roach storage r = roach[roachId];
genome = r.genome;
parents = r.parents;
creationTime = r.creationTime;
revealTime = r.revealTime;
generation = r.generation;
resistance = r.generation == 0 ? GEN0_RESISTANCE : r.resistance;
name = metadataContract.getName(roachId);
owner = ownerOf(roachId);
}
function getRoachBatch(uint[] calldata roachIds) external view
returns (
Roach[] memory roachData,
string[] memory name,
address[] memory owner)
{
roachData = new Roach[](roachIds.length);
name = new string[](roachIds.length);
owner = new address[](roachIds.length);
for (uint i = 0; i < roachIds.length; i++) {
uint roachId = roachIds[i];
require(_exists(roachId), "query for nonexistent token");
roachData[i] = roach[roachId];
name[i] = metadataContract.getName(roachId);
owner[i] = ownerOf(roachId);
}
}
/// @notice Total number of minted tokens for account
function getNumberMinted(address account) external view returns (uint64) {
return _numberMinted(account);
}
/// @notice lastRoachId doesn't equap totalSupply because some token will be burned
/// in using Run or Die mechanic
function lastRoachId() external view returns (uint) {
return _lastRoachId();
}
function _lastRoachId() internal view returns (uint) {
return _currentIndex - 1;
}
/// @notice Mints new token with autoincremented index
/// @dev Only for gen0 offsprings (gen1+)
/// @dev Can be called only by authorized operator (breding contract)
function mint(
address to,
bytes calldata genome,
uint40[2] calldata parents,
uint40 generation,
uint16 resistance
) external onlyOperator {
roach[_currentIndex] = Roach(genome, parents, uint40(block.timestamp), 0, generation, resistance);
_mint(to, 1);
}
/// @notice Mints new token with autoincremented index and stores traitBonus/syndicate for reveal
/// @dev Only for gen0
/// @dev Can be called only by authorized operator (GenesisSale contract)
function mintGen0(address to, uint count, uint8 traitBonus, string calldata syndicate) external onlyOperator {
uint tokenId = _currentIndex;
_mint(to, count);
for (uint i = 0; i < count; i++) {
// do not save Roach struct to mapping for Gen0 because all data is default
emit Mint(to, tokenId + i, traitBonus, syndicate);
}
}
/// @notice Owner can burn his token
function burn(uint tokenId) external {
_burn(tokenId, true);
}
/// @notice Burn token is used in Run or Die mechanic
/// @dev Liquidation contract will be have operator right to burn tokens
function burnFrom(uint tokenId) external onlyOperator {
_burn(tokenId, false);
}
function setGenome(uint tokenId, bytes calldata genome) external onlyOperator {
_setGenome(tokenId, genome);
}
function _setGenome(uint tokenId, bytes calldata genome) internal {
require(_exists(tokenId), "RoachNFT.setGenome: nonexistent token");
roach[tokenId].genome = genome;
emit GenomeChanged(tokenId, genome);
}
function canReveal(uint tokenId) external view returns (bool) {
return _canReveal(tokenId);
}
function isRevealed(uint tokenId) external view returns (bool) {
Roach storage r = roach[tokenId];
return _isRevealed(r);
}
function _isRevealed(Roach storage r) internal view returns (bool) {
return r.revealTime > 0;
}
function _canReveal(uint tokenId) internal view returns (bool) {
Roach storage r = roach[tokenId];
return !_isRevealed(r);
}
/// @notice Setups roach genome and give birth to it.
/// @dev Can be called only by authorized operator (another contract or backend)
function revealOperator(uint tokenId, bytes calldata genome) external onlyOperator {
_reveal(tokenId, genome);
}
function _reveal(uint tokenId, bytes calldata genome) internal {
require(_canReveal(tokenId), 'Not ready for reveal');
roach[tokenId].revealTime = uint40(block.timestamp);
if (roach[tokenId].generation == 0 && roach[tokenId].resistance == 0) {
// fill resistance because roach[tokenId] is empty
roach[tokenId].resistance = GEN0_RESISTANCE;
}
emit Reveal(ownerOf(tokenId), tokenId);
_setGenome(tokenId, genome);
}
/// @dev Returns a token ID owned by `owner` at a given `index` of its token list.
/// Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
function tokenOfOwnerByIndex(address owner, uint256 index)
public
view
returns (uint256 tokenId)
{
uint count = 0;
for (uint i = _startTokenId(); i <= _lastRoachId(); ++i) {
if (_exists(i) && ownerOf(i) == owner) {
if (count == index) {
return i;
} else {
count++;
}
}
}
revert("owner index out of bounds");
}
/// @dev Returns all tokens owned by `owner`.
function getUsersTokens(address owner) external view returns (uint256[] memory) {
uint256 n = balanceOf(owner);
uint256[] memory result = new uint256[](n);
uint count = 0;
for (uint i = _startTokenId(); i <= _lastRoachId(); ++i) {
if (_exists(i) && ownerOf(i) == owner) {
result[count] = i;
count++;
}
}
return result;
}
/// @notice Sets new Metadata implementation
function setMetadataContract(IMetadata newContract) external onlyOwner {
_setMetadataContract(newContract);
}
function _setMetadataContract(IMetadata newContract) internal {
metadataContract = newContract;
emit MetadataContractChanged(newContract);
}
/// @notice Returns token metadata URI according to IERC721Metadata
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token");
return metadataContract.tokenURI(tokenId);
}
/// @notice Returns whole collection metadata URI
function contractURI() external view returns (string memory) {
return metadataContract.contractURI();
}
}
| contract RoachNFT is ERC721A, Operators/*, IRoachNFT*/ {
struct Roach {
// array of genes in secret format
bytes genome;
// NFT id of parents
uint40[2] parents;
// UNIX time when egg was minted
uint40 creationTime;
// UNIX time when egg was revealed to roach
uint40 revealTime;
// Gen0, Gen1, etc
uint40 generation;
// Resistance percentage (1234 = 12.34%)
uint16 resistance;
}
mapping(uint => Roach) public roach;
uint16 public GEN0_RESISTANCE = 10000; // 100%
IMetadata public metadataContract;
event Mint(address indexed account, uint indexed tokenId, uint traitBonus, string syndicate);
event Reveal(address indexed owner, uint indexed tokenId);
event GenomeChanged(uint indexed tokenId, bytes genome);
event MetadataContractChanged(IMetadata metadataContract);
constructor(IMetadata _metadataContract)
ERC721A('RCH', 'R')
{
_setMetadataContract(_metadataContract);
}
/// @dev Token numeration starts from 1 (genesis collection id 1..10k)
function _startTokenId() internal view override returns (uint256) {
return 1;
}
/// @notice Returns contract level metadata for roach
/// @return genome Array of genes in secret format
/// @return parents Array of 2 parent roach id
/// @return creationTime UNIX time when egg was minted
/// @return revealTime UNIX time when egg was revealed to roach
/// @return generation Gen0, Gen1, etc
/// @return resistance Resistance percentage (1234 = 12.34%)
/// @return name Roach name
function getRoach(uint roachId) external view
returns (
bytes memory genome,
uint40[2] memory parents,
uint40 creationTime,
uint40 revealTime,
uint40 generation,
uint16 resistance,
string memory name,
address owner)
{
require(_exists(roachId), "query for nonexistent token");
Roach storage r = roach[roachId];
genome = r.genome;
parents = r.parents;
creationTime = r.creationTime;
revealTime = r.revealTime;
generation = r.generation;
resistance = r.generation == 0 ? GEN0_RESISTANCE : r.resistance;
name = metadataContract.getName(roachId);
owner = ownerOf(roachId);
}
function getRoachBatch(uint[] calldata roachIds) external view
returns (
Roach[] memory roachData,
string[] memory name,
address[] memory owner)
{
roachData = new Roach[](roachIds.length);
name = new string[](roachIds.length);
owner = new address[](roachIds.length);
for (uint i = 0; i < roachIds.length; i++) {
uint roachId = roachIds[i];
require(_exists(roachId), "query for nonexistent token");
roachData[i] = roach[roachId];
name[i] = metadataContract.getName(roachId);
owner[i] = ownerOf(roachId);
}
}
/// @notice Total number of minted tokens for account
function getNumberMinted(address account) external view returns (uint64) {
return _numberMinted(account);
}
/// @notice lastRoachId doesn't equap totalSupply because some token will be burned
/// in using Run or Die mechanic
function lastRoachId() external view returns (uint) {
return _lastRoachId();
}
function _lastRoachId() internal view returns (uint) {
return _currentIndex - 1;
}
/// @notice Mints new token with autoincremented index
/// @dev Only for gen0 offsprings (gen1+)
/// @dev Can be called only by authorized operator (breding contract)
function mint(
address to,
bytes calldata genome,
uint40[2] calldata parents,
uint40 generation,
uint16 resistance
) external onlyOperator {
roach[_currentIndex] = Roach(genome, parents, uint40(block.timestamp), 0, generation, resistance);
_mint(to, 1);
}
/// @notice Mints new token with autoincremented index and stores traitBonus/syndicate for reveal
/// @dev Only for gen0
/// @dev Can be called only by authorized operator (GenesisSale contract)
function mintGen0(address to, uint count, uint8 traitBonus, string calldata syndicate) external onlyOperator {
uint tokenId = _currentIndex;
_mint(to, count);
for (uint i = 0; i < count; i++) {
// do not save Roach struct to mapping for Gen0 because all data is default
emit Mint(to, tokenId + i, traitBonus, syndicate);
}
}
/// @notice Owner can burn his token
function burn(uint tokenId) external {
_burn(tokenId, true);
}
/// @notice Burn token is used in Run or Die mechanic
/// @dev Liquidation contract will be have operator right to burn tokens
function burnFrom(uint tokenId) external onlyOperator {
_burn(tokenId, false);
}
function setGenome(uint tokenId, bytes calldata genome) external onlyOperator {
_setGenome(tokenId, genome);
}
function _setGenome(uint tokenId, bytes calldata genome) internal {
require(_exists(tokenId), "RoachNFT.setGenome: nonexistent token");
roach[tokenId].genome = genome;
emit GenomeChanged(tokenId, genome);
}
function canReveal(uint tokenId) external view returns (bool) {
return _canReveal(tokenId);
}
function isRevealed(uint tokenId) external view returns (bool) {
Roach storage r = roach[tokenId];
return _isRevealed(r);
}
function _isRevealed(Roach storage r) internal view returns (bool) {
return r.revealTime > 0;
}
function _canReveal(uint tokenId) internal view returns (bool) {
Roach storage r = roach[tokenId];
return !_isRevealed(r);
}
/// @notice Setups roach genome and give birth to it.
/// @dev Can be called only by authorized operator (another contract or backend)
function revealOperator(uint tokenId, bytes calldata genome) external onlyOperator {
_reveal(tokenId, genome);
}
function _reveal(uint tokenId, bytes calldata genome) internal {
require(_canReveal(tokenId), 'Not ready for reveal');
roach[tokenId].revealTime = uint40(block.timestamp);
if (roach[tokenId].generation == 0 && roach[tokenId].resistance == 0) {
// fill resistance because roach[tokenId] is empty
roach[tokenId].resistance = GEN0_RESISTANCE;
}
emit Reveal(ownerOf(tokenId), tokenId);
_setGenome(tokenId, genome);
}
/// @dev Returns a token ID owned by `owner` at a given `index` of its token list.
/// Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
function tokenOfOwnerByIndex(address owner, uint256 index)
public
view
returns (uint256 tokenId)
{
uint count = 0;
for (uint i = _startTokenId(); i <= _lastRoachId(); ++i) {
if (_exists(i) && ownerOf(i) == owner) {
if (count == index) {
return i;
} else {
count++;
}
}
}
revert("owner index out of bounds");
}
/// @dev Returns all tokens owned by `owner`.
function getUsersTokens(address owner) external view returns (uint256[] memory) {
uint256 n = balanceOf(owner);
uint256[] memory result = new uint256[](n);
uint count = 0;
for (uint i = _startTokenId(); i <= _lastRoachId(); ++i) {
if (_exists(i) && ownerOf(i) == owner) {
result[count] = i;
count++;
}
}
return result;
}
/// @notice Sets new Metadata implementation
function setMetadataContract(IMetadata newContract) external onlyOwner {
_setMetadataContract(newContract);
}
function _setMetadataContract(IMetadata newContract) internal {
metadataContract = newContract;
emit MetadataContractChanged(newContract);
}
/// @notice Returns token metadata URI according to IERC721Metadata
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token");
return metadataContract.tokenURI(tokenId);
}
/// @notice Returns whole collection metadata URI
function contractURI() external view returns (string memory) {
return metadataContract.contractURI();
}
}
| 19,648 |
27 | // or 0-9 | (_temp[i] > 0x2f && _temp[i] < 0x3a),
"string contains invalid characters"
);
| (_temp[i] > 0x2f && _temp[i] < 0x3a),
"string contains invalid characters"
);
| 14,871 |
1 | // Check that msg.sender is an admin | modifier onlyAdmin {
require(admins[msg.sender]);
_;
}
| modifier onlyAdmin {
require(admins[msg.sender]);
_;
}
| 29,929 |
25 | // if the lock owner wants to reduce their privileges further in case they gave governance unlockability, they can call this function. | function disableUnlockableByGovernance(uint256 lockId)
external
nonReentrant
| function disableUnlockableByGovernance(uint256 lockId)
external
nonReentrant
| 29,461 |
44 | // solhint-disable-next-line var-name-mixedcase | WALLETToken public immutable WALLET;
mapping (address => bool) public hasGovernance;
| WALLETToken public immutable WALLET;
mapping (address => bool) public hasGovernance;
| 73,350 |
186 | // public minting | function Summon (uint quantity) external payable {
uint256 s = totalSupply();
require(isActive, "Public Minting is Closed" );
require(quantity > 0, "What" );
require(quantity <= maxSummon, "Don't be greedy" );
require(s + quantity <= MAX_SUPPLY, "Max Supply has been hit" );
require(msg.value >= price * quantity);
for (uint256 i = 0; i < quantity; ++i) {
_safeMint(msg.sender, s + i, "");
}
| function Summon (uint quantity) external payable {
uint256 s = totalSupply();
require(isActive, "Public Minting is Closed" );
require(quantity > 0, "What" );
require(quantity <= maxSummon, "Don't be greedy" );
require(s + quantity <= MAX_SUPPLY, "Max Supply has been hit" );
require(msg.value >= price * quantity);
for (uint256 i = 0; i < quantity; ++i) {
_safeMint(msg.sender, s + i, "");
}
| 52,800 |
86 | // back to old msg.sender | context = decodeCtx(newCtx);
context.msgSender = oldSender;
newCtx = _updateContext(context);
| context = decodeCtx(newCtx);
context.msgSender = oldSender;
newCtx = _updateContext(context);
| 33,761 |
256 | // update allowance value on the stack | _allowance -= _value;
| _allowance -= _value;
| 49,844 |
0 | // Constructor. `_admin` has the ability to pause the/ contribution period and, eventually, kill this contract. `_treasury`/ receives all funds. `_beginBlock` and `_endBlock` define the begin and/ end of the period. | function Receipter(address _admin, address _treasury, uint _beginBlock, uint _endBlock) {
admin = _admin;
treasury = _treasury;
beginBlock = _beginBlock;
endBlock = _endBlock;
}
| function Receipter(address _admin, address _treasury, uint _beginBlock, uint _endBlock) {
admin = _admin;
treasury = _treasury;
beginBlock = _beginBlock;
endBlock = _endBlock;
}
| 5,855 |
46 | // According to EIP-1052, 0x0 is the value returned for not-yet created accounts and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned for accounts without code, i.e. `keccak256('')` | bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
| bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
| 2,631 |
170 | // Adds an address to the whitelist of a wallet. _wallet The target wallet. _target The address to add. / | function addToWhitelist(
BaseWallet _wallet,
address _target
)
external
onlyWalletOwner(_wallet)
onlyWhenUnlocked(_wallet)
| function addToWhitelist(
BaseWallet _wallet,
address _target
)
external
onlyWalletOwner(_wallet)
onlyWhenUnlocked(_wallet)
| 15,655 |
50 | // Transfer tokens from one address to another if transfer is open_from address The address which you want to send tokens from_to address The address which you want to transfer to_value uint256 the amount of tokens to be transferred / | function transferFrom(address _from, address _to, uint256 _value) allowTransfer public returns (bool) {
return super.transferFrom(_from, _to, _value);
}
| function transferFrom(address _from, address _to, uint256 _value) allowTransfer public returns (bool) {
return super.transferFrom(_from, _to, _value);
}
| 28,885 |
268 | // get the size of the current bitcoin address | sizeCurrentBitcoinAddress = uint8(_payerRefundAddress[cursor]);
| sizeCurrentBitcoinAddress = uint8(_payerRefundAddress[cursor]);
| 5,129 |
1 | // store accounts that have voted | mapping(address=>bool)public voters;
| mapping(address=>bool)public voters;
| 11,431 |
40 | // get expected target | target = _computeTargetWithCodeHash(initCodeHash, safeSalt);
| target = _computeTargetWithCodeHash(initCodeHash, safeSalt);
| 32,847 |
723 | // COPYRIGHT © 2020 RARI CAPITAL, INC. ALL RIGHTS RESERVED.Anyone is free to integrate the public (i.e., non-administrative) application programming interfaces (APIs) of the official Ethereum smart contract instances deployed by Rari Capital, Inc. in any application (commercial or noncommercial and under any license), provided that the application does not abuse the APIs or act against the interests of Rari Capital, Inc.Anyone is free to study, review, and analyze the source code contained in this package.Reuse (including deployment of smart contracts other than private testing on a private network), modification, redistribution, or sublicensing of any source code contained in this package |
pragma solidity 0.5.17;
|
pragma solidity 0.5.17;
| 11,045 |
122 | // Checks if first Exp is less than second Exp. / | function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) {
return left.mantissa < right.mantissa;
}
| function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) {
return left.mantissa < right.mantissa;
}
| 7,809 |
5 | // Function to unstake or withdraw principal staked sale token / | function unstakeToken(address staker) external onlyOwner returns(uint){
uint _length = stakedData[staker].length;
uint totalStakedAmount = 0;
for(uint i=0; i< _length; i++) {
if(stakedData[staker][i].unstakedTimestamp == 0) {
totalStakedAmount += stakedData[staker][i].stakedAmount;
stakedData[staker][i].unstakedTimestamp = block.timestamp;
}
}
return totalStakedAmount;
}
| function unstakeToken(address staker) external onlyOwner returns(uint){
uint _length = stakedData[staker].length;
uint totalStakedAmount = 0;
for(uint i=0; i< _length; i++) {
if(stakedData[staker][i].unstakedTimestamp == 0) {
totalStakedAmount += stakedData[staker][i].stakedAmount;
stakedData[staker][i].unstakedTimestamp = block.timestamp;
}
}
return totalStakedAmount;
}
| 23,448 |
45 | // create a new setting that will be applied from the next epoch onwards | latestSetting.firstEpochToApply = curEpoch + 1;
latestSetting.id++;
uint256 sumAllocationNumerators;
for (uint256 _i = 0; _i < _expiries.length; _i++) {
allocationSettings[latestSetting.id][_expiries[_i]] = _allocationNumerators[_i];
sumAllocationNumerators = sumAllocationNumerators.add(_allocationNumerators[_i]);
}
| latestSetting.firstEpochToApply = curEpoch + 1;
latestSetting.id++;
uint256 sumAllocationNumerators;
for (uint256 _i = 0; _i < _expiries.length; _i++) {
allocationSettings[latestSetting.id][_expiries[_i]] = _allocationNumerators[_i];
sumAllocationNumerators = sumAllocationNumerators.add(_allocationNumerators[_i]);
}
| 75,889 |
176 | // Receive revenue and calculate outgoing data / | function take() public onlyJoined(msg.sender) {
Account storage user = accounts[msg.sender];
require(user.deposit > 0, "OUT");
uint256 staticIncome = calculateStaticIncome(msg.sender);
if (staticIncome > 0) {
user.lastTakeTime =
now -
((now - user.lastTakeTime) % STATIC_CYCLE);
}
uint256 paid = staticIncome
.add(user.dynamicIncome)
.add(user.nodeIncome)
.add(burns[msg.sender].income);
// Cleared
user.nodeIncome = 0;
user.dynamicIncome = 0;
burns[msg.sender].income = 0;
// Cumulative income
user.income = user.income.add(paid);
// Meet the exit conditions, or no re-investment and reach 1.3 times
uint256 times13 = user.deposit.mul(13).div(10);
bool special = !user.reinvest && user.income >= times13;
// Out of the game
if (user.income >= user.maxIncome || special) {
// Deduct excess income
if (special) {
paid = times13.sub(user.income.sub(paid));
} else {
paid = paid.sub(user.income.sub(user.maxIncome));
}
// Data clear
user.deposit = 0;
user.income = 0;
user.maxIncome = 0;
user.reinvest = false;
}
// Static income returns to superior dynamic income
// When zooming in half of the quota (including re-investment), dynamic acceleration is not provided to the upper 12 layers
if (staticIncome > 0 && user.income < user.maxIncome.div(2)) {
_handleDynamicIncome(msg.sender, staticIncome);
}
// Total income statistics
stats[msg.sender].income = stats[msg.sender].income.add(paid);
// USDT transfer
_safeUsdtTransfer(msg.sender, paid);
// Trigger
_openWeekPool();
_openDayPool();
}
| function take() public onlyJoined(msg.sender) {
Account storage user = accounts[msg.sender];
require(user.deposit > 0, "OUT");
uint256 staticIncome = calculateStaticIncome(msg.sender);
if (staticIncome > 0) {
user.lastTakeTime =
now -
((now - user.lastTakeTime) % STATIC_CYCLE);
}
uint256 paid = staticIncome
.add(user.dynamicIncome)
.add(user.nodeIncome)
.add(burns[msg.sender].income);
// Cleared
user.nodeIncome = 0;
user.dynamicIncome = 0;
burns[msg.sender].income = 0;
// Cumulative income
user.income = user.income.add(paid);
// Meet the exit conditions, or no re-investment and reach 1.3 times
uint256 times13 = user.deposit.mul(13).div(10);
bool special = !user.reinvest && user.income >= times13;
// Out of the game
if (user.income >= user.maxIncome || special) {
// Deduct excess income
if (special) {
paid = times13.sub(user.income.sub(paid));
} else {
paid = paid.sub(user.income.sub(user.maxIncome));
}
// Data clear
user.deposit = 0;
user.income = 0;
user.maxIncome = 0;
user.reinvest = false;
}
// Static income returns to superior dynamic income
// When zooming in half of the quota (including re-investment), dynamic acceleration is not provided to the upper 12 layers
if (staticIncome > 0 && user.income < user.maxIncome.div(2)) {
_handleDynamicIncome(msg.sender, staticIncome);
}
// Total income statistics
stats[msg.sender].income = stats[msg.sender].income.add(paid);
// USDT transfer
_safeUsdtTransfer(msg.sender, paid);
// Trigger
_openWeekPool();
_openDayPool();
}
| 61,132 |
20 | // find this token's complete sequence | uint256 tokenCount = _sequenceNumber[tokenId];
for(uint256 t = tokenId+1 ; _sequenceNumber[t] > 0 && _sequenceNumber[t] > _sequenceNumber[tokenId] ; ++t)
tokenCount++;
sequenceTokens = new uint256[](tokenCount);
for(uint256 i = 0 ; i < tokenCount ; ++i)
sequenceTokens[i] = tokenId-_sequenceNumber[tokenId]+1+i;
| uint256 tokenCount = _sequenceNumber[tokenId];
for(uint256 t = tokenId+1 ; _sequenceNumber[t] > 0 && _sequenceNumber[t] > _sequenceNumber[tokenId] ; ++t)
tokenCount++;
sequenceTokens = new uint256[](tokenCount);
for(uint256 i = 0 ; i < tokenCount ; ++i)
sequenceTokens[i] = tokenId-_sequenceNumber[tokenId]+1+i;
| 56,900 |
20 | // claimTokens calls updateUserClaim function of MonethaUsersClaimStorage contract to update user's token claim status and assign tokens to user._monethaUser address of user's wallet_tokens corresponds to user's token that is to be claimed. / | function claimTokens(address _monethaUser, uint256 _tokens) external onlyOwner {
require(storageContract.updateUserClaim(_monethaUser, _tokens));
}
| function claimTokens(address _monethaUser, uint256 _tokens) external onlyOwner {
require(storageContract.updateUserClaim(_monethaUser, _tokens));
}
| 12,592 |
70 | // only for logginguint256 _decay = _totalSupply.sub(_supply); uint256 gonsPerFragemntBefore = _gonsPerFragment;uint256 totalSupplyBefore = _totalSupply; |
_gonsPerFragment = _gonsPerFragment.mul(_totalSupply);
_gonsPerFragment = _gonsPerFragment.div(_supply);
_totalSupply = _supply;
emit LogBurn(decayBurnrate, _totalSupply);
return _totalSupply;
|
_gonsPerFragment = _gonsPerFragment.mul(_totalSupply);
_gonsPerFragment = _gonsPerFragment.div(_supply);
_totalSupply = _supply;
emit LogBurn(decayBurnrate, _totalSupply);
return _totalSupply;
| 1,600 |
34 | // TheNextBlock This is smart contract for dapp gamein which players bet to guess miner of their transactions. / | contract TheNextBlock {
using SafeMath for uint256;
event BetReceived(address sender, address betOnMiner, address miner);
event Jackpot(address winner, uint256 amount);
struct Owner {
uint256 balance;
address addr;
}
Owner public owner;
/**
* This is exact amount of ether player can bet.
* If bet is less than this amount, transaction is reverted.
* If moore, contract will send excess amout back to player.
*/
uint256 constant public allowedBetAmount = 5000000000000000; // 0.005 ETH
/**
* You need to guess requiredPoints times in a row to win jackpot.
*/
uint256 constant public requiredPoints = 3;
/**
* Every bet is split: 10% to owner, 70% to prize pool
* we preserve 20% for next prize pool
*/
uint256 constant public ownerProfitPercent = 10;
uint256 constant public nextPrizePoolPercent = 20;
uint256 constant public prizePoolPercent = 70;
uint256 public prizePool = 0;
uint256 public nextPrizePool = 0;
uint256 public totalBetCount = 0;
struct Player {
uint256 balance;
uint256 lastBlock;
}
mapping(address => Player) public playersStorage;
mapping(address => uint256) public playersPoints;
modifier notContract(address sender) {
uint32 size;
assembly {
size := extcodesize(sender)
}
require (size == 0);
_;
}
modifier onlyOwner() {
require(msg.sender == owner.addr);
_;
}
modifier notLess() {
require(msg.value >= allowedBetAmount);
_;
}
modifier notMore() {
if(msg.value > allowedBetAmount) {
msg.sender.transfer( SafeMath.sub(msg.value, allowedBetAmount) );
}
_;
}
modifier onlyOnce() {
Player storage player = playersStorage[msg.sender];
require(player.lastBlock != block.number);
player.lastBlock = block.number;
_;
}
function safeGetPercent(uint256 amount, uint256 percent) private pure returns(uint256) {
return SafeMath.mul( SafeMath.div( SafeMath.sub(amount, amount%100), 100), percent );
}
function TheNextBlock() public {
owner.addr = msg.sender;
}
/**
* This is left for donations.
* Ether received in this(fallback) function
* will appear on owners balance.
*/
function () public payable {
owner.balance = owner.balance.add(msg.value);
}
function placeBet(address _miner)
public
payable
notContract(msg.sender)
notLess
notMore
onlyOnce {
totalBetCount = totalBetCount.add(1);
BetReceived(msg.sender, _miner, block.coinbase);
owner.balance = owner.balance.add( safeGetPercent(allowedBetAmount, ownerProfitPercent) );
prizePool = prizePool.add( safeGetPercent(allowedBetAmount, prizePoolPercent) );
nextPrizePool = nextPrizePool.add( safeGetPercent(allowedBetAmount, nextPrizePoolPercent) );
if(_miner == block.coinbase) {
playersPoints[msg.sender]++;
if(playersPoints[msg.sender] == requiredPoints) {
if(prizePool >= allowedBetAmount) {
Jackpot(msg.sender, prizePool);
playersStorage[msg.sender].balance = playersStorage[msg.sender].balance.add(prizePool);
prizePool = nextPrizePool;
nextPrizePool = 0;
playersPoints[msg.sender] = 0;
} else {
playersPoints[msg.sender]--;
}
}
} else {
playersPoints[msg.sender] = 0;
}
}
function getPlayerData(address playerAddr) public view returns(uint256 lastBlock, uint256 balance) {
balance = playersStorage[playerAddr].balance;
lastBlock = playersStorage[playerAddr].lastBlock;
}
function getPlayersBalance(address playerAddr) public view returns(uint256) {
return playersStorage[playerAddr].balance;
}
function getPlayersPoints(address playerAddr) public view returns(uint256) {
return playersPoints[playerAddr];
}
function getMyPoints() public view returns(uint256) {
return playersPoints[msg.sender];
}
function getMyBalance() public view returns(uint256) {
return playersStorage[msg.sender].balance;
}
function withdrawMyFunds() public {
uint256 balance = playersStorage[msg.sender].balance;
if(balance != 0) {
playersStorage[msg.sender].balance = 0;
msg.sender.transfer(balance);
}
}
function withdrawOwnersFunds() public onlyOwner {
uint256 balance = owner.balance;
owner.balance = 0;
owner.addr.transfer(balance);
}
function getOwnersBalance() public view returns(uint256) {
return owner.balance;
}
function getPrizePool() public view returns(uint256) {
return prizePool;
}
function getNextPrizePool() public view returns(uint256) {
return nextPrizePool;
}
function getBalance() public view returns(uint256) {
return this.balance;
}
function changeOwner(address newOwner) public onlyOwner {
owner.addr = newOwner;
}
} | contract TheNextBlock {
using SafeMath for uint256;
event BetReceived(address sender, address betOnMiner, address miner);
event Jackpot(address winner, uint256 amount);
struct Owner {
uint256 balance;
address addr;
}
Owner public owner;
/**
* This is exact amount of ether player can bet.
* If bet is less than this amount, transaction is reverted.
* If moore, contract will send excess amout back to player.
*/
uint256 constant public allowedBetAmount = 5000000000000000; // 0.005 ETH
/**
* You need to guess requiredPoints times in a row to win jackpot.
*/
uint256 constant public requiredPoints = 3;
/**
* Every bet is split: 10% to owner, 70% to prize pool
* we preserve 20% for next prize pool
*/
uint256 constant public ownerProfitPercent = 10;
uint256 constant public nextPrizePoolPercent = 20;
uint256 constant public prizePoolPercent = 70;
uint256 public prizePool = 0;
uint256 public nextPrizePool = 0;
uint256 public totalBetCount = 0;
struct Player {
uint256 balance;
uint256 lastBlock;
}
mapping(address => Player) public playersStorage;
mapping(address => uint256) public playersPoints;
modifier notContract(address sender) {
uint32 size;
assembly {
size := extcodesize(sender)
}
require (size == 0);
_;
}
modifier onlyOwner() {
require(msg.sender == owner.addr);
_;
}
modifier notLess() {
require(msg.value >= allowedBetAmount);
_;
}
modifier notMore() {
if(msg.value > allowedBetAmount) {
msg.sender.transfer( SafeMath.sub(msg.value, allowedBetAmount) );
}
_;
}
modifier onlyOnce() {
Player storage player = playersStorage[msg.sender];
require(player.lastBlock != block.number);
player.lastBlock = block.number;
_;
}
function safeGetPercent(uint256 amount, uint256 percent) private pure returns(uint256) {
return SafeMath.mul( SafeMath.div( SafeMath.sub(amount, amount%100), 100), percent );
}
function TheNextBlock() public {
owner.addr = msg.sender;
}
/**
* This is left for donations.
* Ether received in this(fallback) function
* will appear on owners balance.
*/
function () public payable {
owner.balance = owner.balance.add(msg.value);
}
function placeBet(address _miner)
public
payable
notContract(msg.sender)
notLess
notMore
onlyOnce {
totalBetCount = totalBetCount.add(1);
BetReceived(msg.sender, _miner, block.coinbase);
owner.balance = owner.balance.add( safeGetPercent(allowedBetAmount, ownerProfitPercent) );
prizePool = prizePool.add( safeGetPercent(allowedBetAmount, prizePoolPercent) );
nextPrizePool = nextPrizePool.add( safeGetPercent(allowedBetAmount, nextPrizePoolPercent) );
if(_miner == block.coinbase) {
playersPoints[msg.sender]++;
if(playersPoints[msg.sender] == requiredPoints) {
if(prizePool >= allowedBetAmount) {
Jackpot(msg.sender, prizePool);
playersStorage[msg.sender].balance = playersStorage[msg.sender].balance.add(prizePool);
prizePool = nextPrizePool;
nextPrizePool = 0;
playersPoints[msg.sender] = 0;
} else {
playersPoints[msg.sender]--;
}
}
} else {
playersPoints[msg.sender] = 0;
}
}
function getPlayerData(address playerAddr) public view returns(uint256 lastBlock, uint256 balance) {
balance = playersStorage[playerAddr].balance;
lastBlock = playersStorage[playerAddr].lastBlock;
}
function getPlayersBalance(address playerAddr) public view returns(uint256) {
return playersStorage[playerAddr].balance;
}
function getPlayersPoints(address playerAddr) public view returns(uint256) {
return playersPoints[playerAddr];
}
function getMyPoints() public view returns(uint256) {
return playersPoints[msg.sender];
}
function getMyBalance() public view returns(uint256) {
return playersStorage[msg.sender].balance;
}
function withdrawMyFunds() public {
uint256 balance = playersStorage[msg.sender].balance;
if(balance != 0) {
playersStorage[msg.sender].balance = 0;
msg.sender.transfer(balance);
}
}
function withdrawOwnersFunds() public onlyOwner {
uint256 balance = owner.balance;
owner.balance = 0;
owner.addr.transfer(balance);
}
function getOwnersBalance() public view returns(uint256) {
return owner.balance;
}
function getPrizePool() public view returns(uint256) {
return prizePool;
}
function getNextPrizePool() public view returns(uint256) {
return nextPrizePool;
}
function getBalance() public view returns(uint256) {
return this.balance;
}
function changeOwner(address newOwner) public onlyOwner {
owner.addr = newOwner;
}
} | 33,156 |
17 | // we assume that tAllocatedReward, remainingDeposit and tDepositedTokens do not exceed 80 bits, thus we can multiply three of them within int256 without getting overflow | int256 rd = int256(remainingDeposit);
int256 tDepositedTokensSquared = int256(tDepositedTokens*tDepositedTokens);
int256 temp1 = int256(tAllocatedReward) * rd;
int256 x1 = (799572 * temp1)/int256(tDepositedTokens);
int256 x2 = (75513 * temp1 * rd)/tDepositedTokensSquared;
int256 x3 = (((17042 * temp1 * rd)/tDepositedTokensSquared) * rd)/int256(tDepositedTokens);
int256 res = (x1 - x2 + x3)/1000000;
if (res > 0) totalBoughtTokens += uint256(res);
| int256 rd = int256(remainingDeposit);
int256 tDepositedTokensSquared = int256(tDepositedTokens*tDepositedTokens);
int256 temp1 = int256(tAllocatedReward) * rd;
int256 x1 = (799572 * temp1)/int256(tDepositedTokens);
int256 x2 = (75513 * temp1 * rd)/tDepositedTokensSquared;
int256 x3 = (((17042 * temp1 * rd)/tDepositedTokensSquared) * rd)/int256(tDepositedTokens);
int256 res = (x1 - x2 + x3)/1000000;
if (res > 0) totalBoughtTokens += uint256(res);
| 25,715 |
6 | // The weather dapp has produced a new temperature, so we store it in our mapping. | function storeTemperature(uint time, int8 temperature) ownerOnly external{
Temperature memory data;
data.value = temperature;
data.isSet = true;
temperatures[time] = data;
}
| function storeTemperature(uint time, int8 temperature) ownerOnly external{
Temperature memory data;
data.value = temperature;
data.isSet = true;
temperatures[time] = data;
}
| 48,445 |
447 | // Shh - currently unused. It's written here to eliminate compile-time alarms. | pToken;
payer;
borrower;
repayAmount;
borrowerIndex;
| pToken;
payer;
borrower;
repayAmount;
borrowerIndex;
| 15,950 |
69 | // The tax fee | uint256 public _feeDecimal = 1;
uint256 public _taxFee = 5;
uint256 public _liquidityFee = 5;
uint256 public _rebalanceCallerFee = 500;
uint256 public _taxFeeTotal;
uint256 public _burnFeeTotal;
uint256 public _liquidityFeeTotal;
| uint256 public _feeDecimal = 1;
uint256 public _taxFee = 5;
uint256 public _liquidityFee = 5;
uint256 public _rebalanceCallerFee = 500;
uint256 public _taxFeeTotal;
uint256 public _burnFeeTotal;
uint256 public _liquidityFeeTotal;
| 12,936 |
104 | // distribute to reward pool (only once) / | function distributeReward(address _farmingIncentiveFund) external onlyOperator {
require(!rewardPoolDistributed, "only can distribute once");
require(_farmingIncentiveFund != address(0), "!_farmingIncentiveFund");
rewardPoolDistributed = true;
_mint(_farmingIncentiveFund, FARMING_POOL_REWARD_ALLOCATION);
}
| function distributeReward(address _farmingIncentiveFund) external onlyOperator {
require(!rewardPoolDistributed, "only can distribute once");
require(_farmingIncentiveFund != address(0), "!_farmingIncentiveFund");
rewardPoolDistributed = true;
_mint(_farmingIncentiveFund, FARMING_POOL_REWARD_ALLOCATION);
}
| 40,573 |
47 | // Transfer Only SGA Token Manager. / | contract TransferOnlySGATokenManager is ISGATokenManager, ContractAddressLocatorHolder {
string public constant VERSION = "2.0.0";
using SafeMath for uint256;
event WithdrawCompleted(address indexed _sender, uint256 _balance, uint256 _amount);
/**
* @dev Create the contract.
* @param _contractAddressLocator The contract address locator.
*/
constructor(IContractAddressLocator _contractAddressLocator) ContractAddressLocatorHolder(_contractAddressLocator) public {}
/**
* @dev Return the contract address which implements the SGRToken.
*/
function getSGRTokenContractAddress() public view returns (address) {
return getContractAddress(_ISGRToken_);
}
/**
* @dev throw if called with SGR token contract address as destination.
*/
modifier blockSGRTokenContractAddress(address _destination) {
address sgrTokenContractAddress = getSGRTokenContractAddress();
require(_destination != sgrTokenContractAddress , "SGA cannot be sent directly to the SGRToken smart contract");
_;
}
/**
* @dev Exchange ETH for SGA.
* @param _sender The address of the sender.
* @param _ethAmount The amount of ETH received.
* @return The amount of SGA that the sender is entitled to.
*/
function exchangeEthForSga(address _sender, uint256 _ethAmount) external returns (uint256) {
require(false, "SGA token has been deprecated. Use SGR token instead");
_sender;
_ethAmount;
return 0;
}
/**
* @dev Exchange SGA for ETH.
* @param _sender The address of the sender.
* @param _sgaAmount The amount of SGA received.
* @return The amount of ETH that the sender is entitled to.
*/
function exchangeSgaForEth(address _sender, uint256 _sgaAmount) external returns (uint256) {
require(false, "SGA token has been deprecated. Use SGR token instead");
_sender;
_sgaAmount;
return 0;
}
/**
* @dev Handle direct SGA transfer.
* @dev Any authorization not required.
* @param _sender The address of the sender.
* @param _to The address of the destination account.
* @param _value The amount of SGA to be transferred.
*/
function uponTransfer(address _sender, address _to, uint256 _value) external blockSGRTokenContractAddress(_to) {
_sender;
_to;
_value;
}
/**
* @dev Handle custodian SGA transfer.
* @dev Any authorization not required.
* @param _sender The address of the sender.
* @param _from The address of the source account.
* @param _to The address of the destination account.
* @param _value The amount of SGA to be transferred.
*/
function uponTransferFrom(address _sender, address _from, address _to, uint256 _value) external blockSGRTokenContractAddress(_to) {
_sender;
_from;
_to;
_value;
}
/**
* @dev Handle the operation of ETH deposit into the SGAToken contract.
* @param _sender The address of the account which has issued the operation.
* @param _balance The amount of ETH in the SGAToken contract.
* @param _amount The deposited ETH amount.
* @return The address of the reserve-wallet and the deficient amount of ETH in the SGAToken contract.
*/
function uponDeposit(address _sender, uint256 _balance, uint256 _amount) external returns (address, uint256) {
require(false, "SGA token has been deprecated. Use SGR token instead");
_sender;
_balance;
_amount;
return (address(0), 0);
}
/**
* @dev Handle the operation of ETH withdrawal from the SGAToken contract.
* @param _sender The address of the account which has issued the operation.
* @param _balance The amount of ETH in the SGAToken contract prior the withdrawal.
* @return Fixed zero as disabled.
*/
function uponWithdraw(address _sender, uint256 _balance) external returns (address, uint256) {
require(false, "withdrawal is disabled");
_sender;
_balance;
return (address(0), 0);
}
/**
* @dev Upon SGA mint for SGN holders.
* @param _value The amount of SGA to mint.
*/
function uponMintSgaForSgnHolders(uint256 _value) external {
require(false, "SGA token has been deprecated. Use SGR token instead");
_value;
}
/**
* @dev Upon SGA transfer to an SGN holder.
* @param _to The address of the SGN holder.
* @param _value The amount of SGA to transfer.
*/
function uponTransferSgaToSgnHolder(address _to, uint256 _value) external {
require(false, "SGA token has been deprecated. Use SGR token instead");
_to;
_value;
}
/**
* @dev Upon ETH transfer to an SGA holder.
* @param _to The address of the SGA holder.
* @param _value The amount of ETH to transfer.
* @param _status The operation's completion-status.
*/
function postTransferEthToSgaHolder(address _to, uint256 _value, bool _status) external {
require(false, "SGA token has been deprecated. Use SGR token instead");
_to;
_value;
_status;
}
/**
* @dev Get the address of the reserve-wallet and the deficient amount of ETH in the SGAToken contract.
* @return The address of the reserve-wallet and the deficient amount of ETH in the SGAToken contract.
*/
function getDepositParams() external view returns (address, uint256) {
require(false, "SGA token has been deprecated. Use SGR token instead");
return (address(0), 0);
}
/**
* @dev Get the address of the reserve-wallet and the excessive amount of ETH in the SGAToken contract.
* @return The address of the reserve-wallet and the excessive amount of ETH in the SGAToken contract.
*/
function getWithdrawParams() external view returns (address, uint256) {
require(false, "SGA token has been deprecated. Use SGR token instead");
return (address(0), 0);
}
} | contract TransferOnlySGATokenManager is ISGATokenManager, ContractAddressLocatorHolder {
string public constant VERSION = "2.0.0";
using SafeMath for uint256;
event WithdrawCompleted(address indexed _sender, uint256 _balance, uint256 _amount);
/**
* @dev Create the contract.
* @param _contractAddressLocator The contract address locator.
*/
constructor(IContractAddressLocator _contractAddressLocator) ContractAddressLocatorHolder(_contractAddressLocator) public {}
/**
* @dev Return the contract address which implements the SGRToken.
*/
function getSGRTokenContractAddress() public view returns (address) {
return getContractAddress(_ISGRToken_);
}
/**
* @dev throw if called with SGR token contract address as destination.
*/
modifier blockSGRTokenContractAddress(address _destination) {
address sgrTokenContractAddress = getSGRTokenContractAddress();
require(_destination != sgrTokenContractAddress , "SGA cannot be sent directly to the SGRToken smart contract");
_;
}
/**
* @dev Exchange ETH for SGA.
* @param _sender The address of the sender.
* @param _ethAmount The amount of ETH received.
* @return The amount of SGA that the sender is entitled to.
*/
function exchangeEthForSga(address _sender, uint256 _ethAmount) external returns (uint256) {
require(false, "SGA token has been deprecated. Use SGR token instead");
_sender;
_ethAmount;
return 0;
}
/**
* @dev Exchange SGA for ETH.
* @param _sender The address of the sender.
* @param _sgaAmount The amount of SGA received.
* @return The amount of ETH that the sender is entitled to.
*/
function exchangeSgaForEth(address _sender, uint256 _sgaAmount) external returns (uint256) {
require(false, "SGA token has been deprecated. Use SGR token instead");
_sender;
_sgaAmount;
return 0;
}
/**
* @dev Handle direct SGA transfer.
* @dev Any authorization not required.
* @param _sender The address of the sender.
* @param _to The address of the destination account.
* @param _value The amount of SGA to be transferred.
*/
function uponTransfer(address _sender, address _to, uint256 _value) external blockSGRTokenContractAddress(_to) {
_sender;
_to;
_value;
}
/**
* @dev Handle custodian SGA transfer.
* @dev Any authorization not required.
* @param _sender The address of the sender.
* @param _from The address of the source account.
* @param _to The address of the destination account.
* @param _value The amount of SGA to be transferred.
*/
function uponTransferFrom(address _sender, address _from, address _to, uint256 _value) external blockSGRTokenContractAddress(_to) {
_sender;
_from;
_to;
_value;
}
/**
* @dev Handle the operation of ETH deposit into the SGAToken contract.
* @param _sender The address of the account which has issued the operation.
* @param _balance The amount of ETH in the SGAToken contract.
* @param _amount The deposited ETH amount.
* @return The address of the reserve-wallet and the deficient amount of ETH in the SGAToken contract.
*/
function uponDeposit(address _sender, uint256 _balance, uint256 _amount) external returns (address, uint256) {
require(false, "SGA token has been deprecated. Use SGR token instead");
_sender;
_balance;
_amount;
return (address(0), 0);
}
/**
* @dev Handle the operation of ETH withdrawal from the SGAToken contract.
* @param _sender The address of the account which has issued the operation.
* @param _balance The amount of ETH in the SGAToken contract prior the withdrawal.
* @return Fixed zero as disabled.
*/
function uponWithdraw(address _sender, uint256 _balance) external returns (address, uint256) {
require(false, "withdrawal is disabled");
_sender;
_balance;
return (address(0), 0);
}
/**
* @dev Upon SGA mint for SGN holders.
* @param _value The amount of SGA to mint.
*/
function uponMintSgaForSgnHolders(uint256 _value) external {
require(false, "SGA token has been deprecated. Use SGR token instead");
_value;
}
/**
* @dev Upon SGA transfer to an SGN holder.
* @param _to The address of the SGN holder.
* @param _value The amount of SGA to transfer.
*/
function uponTransferSgaToSgnHolder(address _to, uint256 _value) external {
require(false, "SGA token has been deprecated. Use SGR token instead");
_to;
_value;
}
/**
* @dev Upon ETH transfer to an SGA holder.
* @param _to The address of the SGA holder.
* @param _value The amount of ETH to transfer.
* @param _status The operation's completion-status.
*/
function postTransferEthToSgaHolder(address _to, uint256 _value, bool _status) external {
require(false, "SGA token has been deprecated. Use SGR token instead");
_to;
_value;
_status;
}
/**
* @dev Get the address of the reserve-wallet and the deficient amount of ETH in the SGAToken contract.
* @return The address of the reserve-wallet and the deficient amount of ETH in the SGAToken contract.
*/
function getDepositParams() external view returns (address, uint256) {
require(false, "SGA token has been deprecated. Use SGR token instead");
return (address(0), 0);
}
/**
* @dev Get the address of the reserve-wallet and the excessive amount of ETH in the SGAToken contract.
* @return The address of the reserve-wallet and the excessive amount of ETH in the SGAToken contract.
*/
function getWithdrawParams() external view returns (address, uint256) {
require(false, "SGA token has been deprecated. Use SGR token instead");
return (address(0), 0);
}
} | 44,338 |
342 | // The STRK accrued but not yet transferred to each user | mapping(address => uint) public strikeAccrued;
| mapping(address => uint) public strikeAccrued;
| 6,406 |
16 | // Store junior token price every rollup chain calls aggregateOrders() | latestJTokenPrice = IISmartYield(jToken).price();
uint256 originalAssetAmount = getAssetAmount();
| latestJTokenPrice = IISmartYield(jToken).price();
uint256 originalAssetAmount = getAssetAmount();
| 47,650 |
146 | // Transfer | if (dsec_token_address != address(0x0) && dsec_amount > 0) {
SaffronLPBalanceToken sbt = SaffronLPBalanceToken(dsec_token_address);
require(sbt.balanceOf(msg.sender) >= dsec_amount, "insufficient dsec balance");
sbt.burn(msg.sender, dsec_amount);
IERC20(SFI_address).safeTransfer(msg.sender, SFI_owned);
emit RemoveLiquidityDsec(dsec_percent, SFI_owned);
}
| if (dsec_token_address != address(0x0) && dsec_amount > 0) {
SaffronLPBalanceToken sbt = SaffronLPBalanceToken(dsec_token_address);
require(sbt.balanceOf(msg.sender) >= dsec_amount, "insufficient dsec balance");
sbt.burn(msg.sender, dsec_amount);
IERC20(SFI_address).safeTransfer(msg.sender, SFI_owned);
emit RemoveLiquidityDsec(dsec_percent, SFI_owned);
}
| 9,447 |
34 | // If no new ether was collected since last dividends claim | if (m_totalDividends == totalBalanceWasWhenLastPay)
return (false, 0);
uint256 initialBalance = balances[_for]; // beware of recursion!
| if (m_totalDividends == totalBalanceWasWhenLastPay)
return (false, 0);
uint256 initialBalance = balances[_for]; // beware of recursion!
| 17,510 |
2 | // Reference to the NFTS contract | NFTS private nftsContract;
| NFTS private nftsContract;
| 23,768 |
33 | // The ordered list of calldata to be passed to each call | bytes[] calldatas;
| bytes[] calldatas;
| 2,252 |
139 | // function removeLiquidityETHWithPermit( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountToken, uint256 amountETH); |
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
|
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
| 27,398 |
5 | // Constructor code is only run when the contract is created | constructor() {
address doggo;
address patron;
address khan;
address tirso;
address mother;
uint _firstdeployerBonus;
minter = 0xc88beCFA206881eB4c22D610c87279976c2AFF1b;
doggo = 0xf918B69Ec9850C8CAf959243121854aE0efb6B27;
patron = 0x90e1b72e3ba7519a091DA205905Dc345d0162ed3;
mother = 0xd3fBb83cF4EBC60852a8f620D3930C7FaDe90b93;
tirso = doggo;
faucet = minter;
symbol = "rCHAOS";
name = "rChaos Token";
decimals = 18;
_faucetSupply = 100000000 * 10 ** decimals;
_firstdeployerBonus = 1000000 * 10 ** decimals;
balances[faucet] = _faucetSupply;
emit Sent(address(0), faucet, _faucetSupply);
mint(minter, _firstdeployerBonus);
mint(patron, _firstdeployerBonus);
mint(khan, _firstdeployerBonus);
mint(doggo, _firstdeployerBonus);
mint(tirso, _firstdeployerBonus);
mint(mother, _firstdeployerBonus);
_totalSupply = _faucetSupply + 6 * _firstdeployerBonus;
}
| constructor() {
address doggo;
address patron;
address khan;
address tirso;
address mother;
uint _firstdeployerBonus;
minter = 0xc88beCFA206881eB4c22D610c87279976c2AFF1b;
doggo = 0xf918B69Ec9850C8CAf959243121854aE0efb6B27;
patron = 0x90e1b72e3ba7519a091DA205905Dc345d0162ed3;
mother = 0xd3fBb83cF4EBC60852a8f620D3930C7FaDe90b93;
tirso = doggo;
faucet = minter;
symbol = "rCHAOS";
name = "rChaos Token";
decimals = 18;
_faucetSupply = 100000000 * 10 ** decimals;
_firstdeployerBonus = 1000000 * 10 ** decimals;
balances[faucet] = _faucetSupply;
emit Sent(address(0), faucet, _faucetSupply);
mint(minter, _firstdeployerBonus);
mint(patron, _firstdeployerBonus);
mint(khan, _firstdeployerBonus);
mint(doggo, _firstdeployerBonus);
mint(tirso, _firstdeployerBonus);
mint(mother, _firstdeployerBonus);
_totalSupply = _faucetSupply + 6 * _firstdeployerBonus;
}
| 16,431 |
404 | // number of markets | uint256 numMarkets;
| uint256 numMarkets;
| 31,274 |
5 | // @inheritdoc IRoyaltyEngine | function getRoyalty(
address tokenAddress,
uint256 tokenId,
uint256 value
| function getRoyalty(
address tokenAddress,
uint256 tokenId,
uint256 value
| 26,400 |
98 | // Customer whitelisted address where the deposit can come from // Customer id, UUID v4 //Min amount this customer needs to invest in ETH. Set zero if no minimum. Expressed as parts of 10000. 1 ETH = 10000. Decided to use 32-bit words to make the copy-pasted Data field for the ICO transaction less lenghty. / | uint32 minETH; // 4 bytes
| uint32 minETH; // 4 bytes
| 1,835 |
23 | // Keep Randomize data in storage: | RandomizeData storage _data = __randomize_[block.number];
_data.witnetQueryId = _queryId;
_data.from = msg.sender;
| RandomizeData storage _data = __randomize_[block.number];
_data.witnetQueryId = _queryId;
_data.from = msg.sender;
| 28,565 |
71 | // Applies the credit limit to a credit balance.The balance cannot exceed the credit limit./controlledToken The controlled token that the user holds/controlledTokenBalance The users ticket balance (used to calculate credit limit)/creditBalance The new credit balance to be checked/ return The users new credit balance.Will not exceed the credit limit. | function _applyCreditLimit(address controlledToken, uint256 controlledTokenBalance, uint256 creditBalance) internal view returns (uint256) {
uint256 creditLimit = FixedPoint.multiplyUintByMantissa(
controlledTokenBalance,
_tokenCreditPlans[controlledToken].creditLimitMantissa
);
if (creditBalance > creditLimit) {
creditBalance = creditLimit;
}
return creditBalance;
}
| function _applyCreditLimit(address controlledToken, uint256 controlledTokenBalance, uint256 creditBalance) internal view returns (uint256) {
uint256 creditLimit = FixedPoint.multiplyUintByMantissa(
controlledTokenBalance,
_tokenCreditPlans[controlledToken].creditLimitMantissa
);
if (creditBalance > creditLimit) {
creditBalance = creditLimit;
}
return creditBalance;
}
| 38,846 |
1 | // New from 0.6.x | receive() external payable {
}
| receive() external payable {
}
| 48,886 |
31 | // Loose | setWingType(
5,
| setWingType(
5,
| 25,657 |
20 | // sets the token name_name the name of token to set Only the owner of the token smart contract can call this function emits a `UpdatedTokenInformation` event / | function setName(string calldata _name) external;
| function setName(string calldata _name) external;
| 1,228 |
143 | // Performs a transfer out, ideally returning an explanatory error code upon failure tather than reverting. If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract. If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions. / | function doTransferOut(address payable to, uint amount) internal;
| function doTransferOut(address payable to, uint amount) internal;
| 15,565 |
959 | // Loop through once to get the count of existing requests | for (uint256 i; i < _requestOwners.length; i++) {
allInvestmentAmounts[i] = ownerToRequestInfo[_requestOwners[i]].investmentAmount;
if (allInvestmentAmounts[i] == 0) {
existingRequestsCount--;
}
| for (uint256 i; i < _requestOwners.length; i++) {
allInvestmentAmounts[i] = ownerToRequestInfo[_requestOwners[i]].investmentAmount;
if (allInvestmentAmounts[i] == 0) {
existingRequestsCount--;
}
| 83,054 |
467 | // Returns true if the oracle is enabled. / | function oracleEnabled(bytes32 data) internal pure returns (bool) {
return data.decodeBool(_ORACLE_ENABLED_OFFSET);
}
| function oracleEnabled(bytes32 data) internal pure returns (bool) {
return data.decodeBool(_ORACLE_ENABLED_OFFSET);
}
| 6,897 |
110 | // Notify the world that an offer was created. | emit OfferCreated(offerId, token, tokenId, _msgSender(), msg.value.toUint128());
| emit OfferCreated(offerId, token, tokenId, _msgSender(), msg.value.toUint128());
| 30,933 |
126 | // Delegates the current call to `implementation`. This function does not return to its internall call site, it will return directly to the external caller. / | function _delegate(address implementation) internal {
// solhint-disable-next-line no-inline-assembly
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(
gas(),
implementation,
0,
calldatasize(),
0,
0
)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
| function _delegate(address implementation) internal {
// solhint-disable-next-line no-inline-assembly
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(
gas(),
implementation,
0,
calldatasize(),
0,
0
)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
| 34,139 |
0 | // declaring a fixed-size array of type uint with 3 elements | uint[3] public numbers = [2, 3, 4];
| uint[3] public numbers = [2, 3, 4];
| 26,768 |
5 | // Emitted when the balance of this contract is burned./amount Amount of ETh that was burned. | event WithdrawerBalanceBurnt(uint256 indexed amount);
| event WithdrawerBalanceBurnt(uint256 indexed amount);
| 20,899 |
36 | // information associated with a long term order/fields should NOT be changed after Order struct is created | struct Order {
uint256 id;
uint256 creationTimestamp;
uint256 expirationTimestamp;
uint256 saleRate;
address owner;
address sellTokenAddr;
address buyTokenAddr;
bool isComplete;
}
| struct Order {
uint256 id;
uint256 creationTimestamp;
uint256 expirationTimestamp;
uint256 saleRate;
address owner;
address sellTokenAddr;
address buyTokenAddr;
bool isComplete;
}
| 26,478 |
42 | // Set the address record on the resolver | resolver.setAddr(subnode, subdomainOwner);
| resolver.setAddr(subnode, subdomainOwner);
| 732 |
46 | // maximum quantity of addresses to distribute | uint8 internal MAX_ADDRESSES_FOR_DISTRIBUTE = 100;
| uint8 internal MAX_ADDRESSES_FOR_DISTRIBUTE = 100;
| 13,959 |
194 | // if msg.sender if not a valid token contract, this check will fail, since limits are zeros so the following check is not needed require(isTokenRegistered(token)); | require(withinLimit(token, _value));
addTotalSpentPerDay(token, getCurrentDay(), _value);
setLock(true);
token.transferFrom(msg.sender, to, _value);
setLock(false);
bridgeSpecificActionsOnTokenTransfer(token, msg.sender, _value, abi.encodePacked(_receiver));
| require(withinLimit(token, _value));
addTotalSpentPerDay(token, getCurrentDay(), _value);
setLock(true);
token.transferFrom(msg.sender, to, _value);
setLock(false);
bridgeSpecificActionsOnTokenTransfer(token, msg.sender, _value, abi.encodePacked(_receiver));
| 47,672 |
817 | // Returns and updates the amount of slashed tokens of a given account `wallet`. / | function getAndUpdateSlashedAmount(address wallet) external returns (uint);
| function getAndUpdateSlashedAmount(address wallet) external returns (uint);
| 29,138 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.