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 |
|---|---|---|---|---|
24 | // anit-sniper | uint256 public tradingActiveBlock = 0; // 0 means trading is not active
mapping(address => bool) public boughtEarly; // mapping to track addresses that buy within the first 2 blocks pay a 3x tax for 24 hours to sell
uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty
| uint256 public tradingActiveBlock = 0; // 0 means trading is not active
mapping(address => bool) public boughtEarly; // mapping to track addresses that buy within the first 2 blocks pay a 3x tax for 24 hours to sell
uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty
| 15,104 |
98 | // Make sure the holder doesn't transfer more than what he already has. | uint256 transferable = vested.sub(grant.transferred);
if (transferable == 0) {
return;
}
| uint256 transferable = vested.sub(grant.transferred);
if (transferable == 0) {
return;
}
| 46,640 |
81 | // import { InitializableAdminUpgradeabilityProxy } from "../shared/@openzeppelin-2.5/upgrades/InitializableAdminUpgradeabilityProxy.sol"; | constructor(
address _logic,
address admin_,
bytes memory _data
| constructor(
address _logic,
address admin_,
bytes memory _data
| 43,746 |
18 | // workaround for stack too deep | uint16 srcChainId = _srcChainId;
bytes memory srcAddress = _srcAddress;
uint64 nonce = _nonce;
bytes memory payload = _payload;
bytes32 from_ = from;
address to_ = to;
uint amount_ = amount;
bytes memory payloadForCall_ = payloadForCall;
| uint16 srcChainId = _srcChainId;
bytes memory srcAddress = _srcAddress;
uint64 nonce = _nonce;
bytes memory payload = _payload;
bytes32 from_ = from;
address to_ = to;
uint amount_ = amount;
bytes memory payloadForCall_ = payloadForCall;
| 17,085 |
11 | // Reward distributor contract for the masterchef | contract RewardDistributor is Ownable, ReentrancyGuard {
// The $RIVAL TOKEN!
IBEP20 public rivalToken;
// The operator can only withdraw wrong tokens in the contract
address private _operator;
// Event
event OperatorTransferred(
address indexed previousOperator,
address indexed newOperator
);
event OperatorTokenRecovery(address tokenRecovered, uint256 amount);
modifier onlyOperator() {
require(
_operator == _msgSender(),
"operator: caller is not the operator"
);
_;
}
constructor(IBEP20 _rivalToken) public {
rivalToken = _rivalToken;
_operator = _msgSender();
emit OperatorTransferred(address(0), _operator);
}
// Safe $RIVAL transfer function, just in case if rounding error causes pool to not have enough $RIVALs.
function safeRivalTokenTransfer(address _to, uint256 _amount)
external
onlyOperator
nonReentrant
returns (uint256)
{
uint256 rivalBal = rivalToken.balanceOf(address(this));
if (_amount > rivalBal) {
_amount = rivalBal;
}
if (_amount > 0) {
rivalToken.transfer(_to, _amount);
return _amount;
}
return 0;
}
/**
* @dev operator of the contract
*/
function operator() external view returns (address) {
return _operator;
}
/**
* @dev Transfers operator of the contract to a new account (`newOperator`).
* Can only be called by the current operator.
*/
function transferOperator(address newOperator) external onlyOwner {
require(
newOperator != address(0),
"RewardDistributor::transferOperator: new operator is the zero address"
);
emit OperatorTransferred(_operator, newOperator);
_operator = newOperator;
}
/**
* @notice It allows the operator to recover wrong tokens sent to the contract
* @param _tokenAddress: the address of the token to withdraw
* @param _tokenAmount: the number of tokens to withdraw
* @dev This function is only callable by operator.
*/
function recoverWrongTokens(address _tokenAddress, uint256 _tokenAmount)
external
onlyOwner
{
IBEP20(_tokenAddress).transfer(_msgSender(), _tokenAmount);
emit OperatorTokenRecovery(_tokenAddress, _tokenAmount);
}
}
| contract RewardDistributor is Ownable, ReentrancyGuard {
// The $RIVAL TOKEN!
IBEP20 public rivalToken;
// The operator can only withdraw wrong tokens in the contract
address private _operator;
// Event
event OperatorTransferred(
address indexed previousOperator,
address indexed newOperator
);
event OperatorTokenRecovery(address tokenRecovered, uint256 amount);
modifier onlyOperator() {
require(
_operator == _msgSender(),
"operator: caller is not the operator"
);
_;
}
constructor(IBEP20 _rivalToken) public {
rivalToken = _rivalToken;
_operator = _msgSender();
emit OperatorTransferred(address(0), _operator);
}
// Safe $RIVAL transfer function, just in case if rounding error causes pool to not have enough $RIVALs.
function safeRivalTokenTransfer(address _to, uint256 _amount)
external
onlyOperator
nonReentrant
returns (uint256)
{
uint256 rivalBal = rivalToken.balanceOf(address(this));
if (_amount > rivalBal) {
_amount = rivalBal;
}
if (_amount > 0) {
rivalToken.transfer(_to, _amount);
return _amount;
}
return 0;
}
/**
* @dev operator of the contract
*/
function operator() external view returns (address) {
return _operator;
}
/**
* @dev Transfers operator of the contract to a new account (`newOperator`).
* Can only be called by the current operator.
*/
function transferOperator(address newOperator) external onlyOwner {
require(
newOperator != address(0),
"RewardDistributor::transferOperator: new operator is the zero address"
);
emit OperatorTransferred(_operator, newOperator);
_operator = newOperator;
}
/**
* @notice It allows the operator to recover wrong tokens sent to the contract
* @param _tokenAddress: the address of the token to withdraw
* @param _tokenAmount: the number of tokens to withdraw
* @dev This function is only callable by operator.
*/
function recoverWrongTokens(address _tokenAddress, uint256 _tokenAmount)
external
onlyOwner
{
IBEP20(_tokenAddress).transfer(_msgSender(), _tokenAmount);
emit OperatorTokenRecovery(_tokenAddress, _tokenAmount);
}
}
| 16,633 |
2 | // given the address, returns the length of defaults array | function getDefaultsLength(address _address) public view returns (uint);
| function getDefaultsLength(address _address) public view returns (uint);
| 20,920 |
6 | // To keep things simple, the default function handles all logic for both lenders and borrowers | function() payable {
if (msg.value > 0) {
if (currentState == State.raising) {
lend();
} else if (currentState == State.repaying) {
repay();
}
}
}
| function() payable {
if (msg.value > 0) {
if (currentState == State.raising) {
lend();
} else if (currentState == State.repaying) {
repay();
}
}
}
| 44,691 |
6 | // ---------------------------UserApplication config--------------------------- | function getConfig(uint16 _version, uint16 _chainId, address, uint _configType) external view returns (bytes memory) {
return lzEndpoint.getConfig(_version, _chainId, address(this), _configType);
}
| function getConfig(uint16 _version, uint16 _chainId, address, uint _configType) external view returns (bytes memory) {
return lzEndpoint.getConfig(_version, _chainId, address(this), _configType);
}
| 4,342 |
2 | // Whether the party can spend ETH from the party's balance with arbitrary call proposals. | bool allowArbCallsToSpendPartyEth;
| bool allowArbCallsToSpendPartyEth;
| 12,764 |
12 | // The current sale round index. | uint256 public currentSaleIndex;
| uint256 public currentSaleIndex;
| 4,508 |
9 | // Withdraw all unlocked tokens from the grant. | function withdraw() public onlyGrantee {
require(
requestedNewGrantee == address(0),
"Can not withdraw with pending reassignment"
);
tokenGrant.withdraw(grantId);
uint256 amount = token.balanceOf(address(this));
token.safeTransfer(grantee, amount);
emit TokensWithdrawn(grantee, amount);
}
| function withdraw() public onlyGrantee {
require(
requestedNewGrantee == address(0),
"Can not withdraw with pending reassignment"
);
tokenGrant.withdraw(grantId);
uint256 amount = token.balanceOf(address(this));
token.safeTransfer(grantee, amount);
emit TokensWithdrawn(grantee, amount);
}
| 7,832 |
269 | // Internal createPermission for access inside the kernel (on instantiation)/ | function _createPermission(address _entity, address _app, bytes32 _role, address _manager) internal {
_setPermission(_entity, _app, _role, EMPTY_PARAM_HASH);
_setPermissionManager(_manager, _app, _role);
}
| function _createPermission(address _entity, address _app, bytes32 _role, address _manager) internal {
_setPermission(_entity, _app, _role, EMPTY_PARAM_HASH);
_setPermissionManager(_manager, _app, _role);
}
| 26,649 |
31 | // NOTE: Optionally, compute additional fee here | return 200_000_000_000_000_000; // 0.2 LINK
| return 200_000_000_000_000_000; // 0.2 LINK
| 22,690 |
41 | // Extend veCRV lock time to maximum amount of 4 years./Must be called by governance or locker. | function maxLock() external {
require(msg.sender == governance || lockers[msg.sender], "!locker");
uint max = now + (365 days * 4);
uint lock_end = veCRV.locked__end(address(proxy));
if(lock_end < (max / WEEK) * WEEK){
proxy.safeExecute(
address(veCRV),
0,
abi.encodeWithSignature("increase_unlock_time(uint256)", max)
);
}
}
| function maxLock() external {
require(msg.sender == governance || lockers[msg.sender], "!locker");
uint max = now + (365 days * 4);
uint lock_end = veCRV.locked__end(address(proxy));
if(lock_end < (max / WEEK) * WEEK){
proxy.safeExecute(
address(veCRV),
0,
abi.encodeWithSignature("increase_unlock_time(uint256)", max)
);
}
}
| 9,265 |
3 | // --------------------Set Functions------------------------ |
function setAddress(bytes32 _key, address _value)
external;
function setUint(bytes32 _key, uint _value)
external;
function setString(bytes32 _key, string _value)
external;
|
function setAddress(bytes32 _key, address _value)
external;
function setUint(bytes32 _key, uint _value)
external;
function setString(bytes32 _key, string _value)
external;
| 25,686 |
3 | // Decreases the number of remaining Beans that can be minted for Immunefi bug bounties. This should only decrease after a BIR unless the DAO votes to decrease the remaining Beans. | function decreaseRemainingBeans(uint256 numBeans) external isOwner {
remainingBeans -= numBeans;
}
| function decreaseRemainingBeans(uint256 numBeans) external isOwner {
remainingBeans -= numBeans;
}
| 27,581 |
245 | // matched number | remainBalance = getTotalRewards(issueIndex).mul(nomatch[issueIndex]).mul(100).div(10000);
drawingPhase = false;
emit Drawing(issueIndex, winningNumbers);
| remainBalance = getTotalRewards(issueIndex).mul(nomatch[issueIndex]).mul(100).div(10000);
drawingPhase = false;
emit Drawing(issueIndex, winningNumbers);
| 22,883 |
123 | // Perform an ERC20 token transfer. Designed to be called by transfer functions possessingthe onlyProxy or optionalProxy modifiers. / | function _transfer_byProxy(address from, address to, uint value, bytes data)
internal
returns (bool)
| function _transfer_byProxy(address from, address to, uint value, bytes data)
internal
returns (bool)
| 5,961 |
100 | // Mapping from token ID to approved address | mapping(uint256 => address) private _tokenApprovals;
| mapping(uint256 => address) private _tokenApprovals;
| 188 |
60 | // Returns the total supply of WETH10 token as the ETH held in this contract. | function totalSupply() external view override returns(uint256) {
return address(this).balance + flashMinted;
}
| function totalSupply() external view override returns(uint256) {
return address(this).balance + flashMinted;
}
| 24,013 |
91 | // Adds a bid to fee history. Doesn't perform any checks if the bid is valid! returnReturns how the trade ethers were split. Same value as splitTrade function./ | function _registerTrade(uint32 _canvasId, uint _amount)
internal
stateOwned(_canvasId)
forceOwned(_canvasId)
returns (
uint commission,
uint paintersRewards,
uint sellerProfit
| function _registerTrade(uint32 _canvasId, uint _amount)
internal
stateOwned(_canvasId)
forceOwned(_canvasId)
returns (
uint commission,
uint paintersRewards,
uint sellerProfit
| 19,784 |
11 | // Function is called by Auction contract when auction is started / | function processAuctionStart() external onlyAuction {
_accrueInterest();
_transferReserves();
factory.burnStake();
}
| function processAuctionStart() external onlyAuction {
_accrueInterest();
_transferReserves();
factory.burnStake();
}
| 8,336 |
47 | // Number of total mints from the given address | uint256 totalMints;
| uint256 totalMints;
| 19,060 |
52 | // convert _amount gOHM into sBalance_ sOHM _to address _amount uintreturn sBalance_ uint / | function unwrap(address _to, uint256 _amount) external returns (uint256 sBalance_) {
gOHM.burn(msg.sender, _amount);
sBalance_ = gOHM.balanceFrom(_amount);
sOHM.safeTransfer(_to, sBalance_);
}
| function unwrap(address _to, uint256 _amount) external returns (uint256 sBalance_) {
gOHM.burn(msg.sender, _amount);
sBalance_ = gOHM.balanceFrom(_amount);
sOHM.safeTransfer(_to, sBalance_);
}
| 27,285 |
17 | // emit Transfer(msg.sender,_from,_to,_value); | emit Transfer(_from,_to,_value);
return true;
| emit Transfer(_from,_to,_value);
return true;
| 37,814 |
157 | // MarketPlace core/Contains models, variables, and internal methods for the marketplace./We omit a fallback function to prevent accidental sends to this contract. | contract MarketPlaceBase is Ownable {
// Represents an sale on an NFT
struct Sale {
// Current owner of NFT
address seller;
// Price (in wei)
uint128 price;
// Time when sale started
// NOTE: 0 if this sale has been concluded
uint64 startedAt;
}
struct Affiliates {
address affiliate_address;
uint64 commission;
uint64 pricecut;
}
//Affiliates[] affiliates;
// Reference to contract tracking NFT ownership
ERC721 public nonFungibleContract;
// Cut owner takes on each sale, measured in basis points (1/100 of a percent).
// Values 0-10,000 map to 0%-100%
uint256 public ownerCut;
//map the Affiliate Code to the Affiliate
mapping (uint256 => Affiliates) codeToAffiliate;
// Map from token ID to their corresponding sale.
mapping (uint256 => Sale) tokenIdToSale;
event SaleCreated(uint256 tokenId, uint256 price);
event SaleSuccessful(uint256 tokenId, uint256 price, address buyer);
event SaleCancelled(uint256 tokenId);
/// @dev Returns true if the claimant owns the token.
/// @param _claimant - Address claiming to own the token.
/// @param _tokenId - ID of token whose ownership to verify.
function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
return (nonFungibleContract.ownerOf(_tokenId) == _claimant);
}
/// @dev Escrows the NFT, assigning ownership to this contract.
/// Throws if the escrow fails.
/// @param _owner - Current owner address of token to escrow.
/// @param _tokenId - ID of token whose approval to verify.
function _escrow(address _owner, uint256 _tokenId) internal {
// it will throw if transfer fails
nonFungibleContract.transferFrom(_owner, this, _tokenId);
}
/// @dev Transfers an NFT owned by this contract to another address.
/// Returns true if the transfer succeeds.
/// @param _receiver - Address to transfer NFT to.
/// @param _tokenId - ID of token to transfer.
function _transfer(address _receiver, uint256 _tokenId) internal {
// it will throw if transfer fails
nonFungibleContract.transfer(_receiver, _tokenId);
}
/// @dev Adds an sale to the list of open sales. Also fires the
/// SaleCreated event.
/// @param _tokenId The ID of the token to be put on sale.
/// @param _sale Sale to add.
function _addSale(uint256 _tokenId, Sale _sale) internal {
tokenIdToSale[_tokenId] = _sale;
SaleCreated(
uint256(_tokenId),
uint256(_sale.price)
);
}
/// @dev Cancels a sale unconditionally.
function _cancelSale(uint256 _tokenId, address _seller) internal {
_removeSale(_tokenId);
_transfer(_seller, _tokenId);
SaleCancelled(_tokenId);
}
/// @dev Computes the price and transfers winnings.
/// Does NOT transfer ownership of token.
function _bid(uint256 _tokenId, uint256 _bidAmount)
internal
returns (uint256)
{
// Get a reference to the sale struct
Sale storage sale = tokenIdToSale[_tokenId];
// Explicitly check that this sale is currently live.
// (Because of how Ethereum mappings work, we can't just count
// on the lookup above failing. An invalid _tokenId will just
// return a sale object that is all zeros.)
require(_isOnSale(sale));
// Check that the bid is greater than or equal to the current price
uint256 price = sale.price;
require(_bidAmount >= price);
// Grab a reference to the seller before the sale struct
// gets deleted.
address seller = sale.seller;
// The bid is good! Remove the sale before sending the fees
// to the sender so we can't have a reentrancy attack.
_removeSale(_tokenId);
// Transfer proceeds to seller (if there are any!)
if (price > 0) {
// Calculate the Marketplace's cut.
// (NOTE: _computeCut() is guaranteed to return a
// value <= price, so this subtraction can't go negative.)
uint256 marketplaceCut = _computeCut(price);
uint256 sellerProceeds = price - marketplaceCut;
// NOTE: Doing a transfer() in the middle of a complex
// method like this is generally discouraged because of
// reentrancy attacks and DoS attacks if the seller is
// a contract with an invalid fallback function. We explicitly
// guard against reentrancy attacks by removing the auction
// before calling transfer(), and the only thing the seller
// can DoS is the sale of their own asset! (And if it's an
// accident, they can call cancelAuction(). )
seller.transfer(sellerProceeds);
}
// Calculate any excess funds included with the bid. If the excess
// is anything worth worrying about, transfer it back to bidder.
// NOTE: We checked above that the bid amount is greater than or
// equal to the price so this cannot underflow.
uint256 bidExcess = _bidAmount - price;
// Return the funds. Similar to the previous transfer, this is
// not susceptible to a re-entry attack because the auction is
// removed before any transfers occur.
msg.sender.transfer(bidExcess);
// Tell the world!
SaleSuccessful(_tokenId, price, msg.sender);
return price;
}
/// @dev Removes a sale from the list of open sales.
/// @param _tokenId - ID of NFT on sale.
function _removeSale(uint256 _tokenId) internal {
delete tokenIdToSale[_tokenId];
}
/// @dev Returns true if the NFT is on sale.
/// @param _sale - Sale to check.
function _isOnSale(Sale storage _sale) internal view returns (bool) {
return (_sale.startedAt > 0);
}
/// @dev Computes owner's cut of a sale.
/// @param _price - Sale price of NFT.
function _computeCut(uint256 _price) internal view returns (uint256) {
// NOTE: We don't use SafeMath (or similar) in this function because
// all of our entry functions carefully cap the maximum values for
// currency (at 128-bits), and ownerCut <= 10000 (see the require()
// statement in the Marketplace constructor). The result of this
// function is always guaranteed to be <= _price.
return _price * ownerCut / 10000;
}
function _computeAffiliateCut(uint256 _price,Affiliates affiliate) internal view returns (uint256) {
// NOTE: We don't use SafeMath (or similar) in this function because
// all of our entry functions carefully cap the maximum values for
// currency (at 128-bits), and ownerCut <= 10000 (see the require()
// statement in the Marketplace constructor). The result of this
// function is always guaranteed to be <= _price.
return _price * affiliate.commission / 10000;
}
/// @dev Adds an affiliate to the list.
/// @param _code The referall code of the affiliate.
/// @param _affiliate Affiliate to add.
function _addAffiliate(uint256 _code, Affiliates _affiliate) internal {
codeToAffiliate[_code] = _affiliate;
}
/// @dev Removes a affiliate from the list.
/// @param _code - The referall code of the affiliate.
function _removeAffiliate(uint256 _code) internal {
delete codeToAffiliate[_code];
}
//_bidReferral(_tokenId, msg.value);
/// @dev Computes the price and transfers winnings.
/// Does NOT transfer ownership of token.
function _bidReferral(uint256 _tokenId, uint256 _bidAmount,Affiliates _affiliate)
internal
returns (uint256)
{
// Get a reference to the sale struct
Sale storage sale = tokenIdToSale[_tokenId];
//Only Owner of Contract can sell referrals
require(sale.seller==owner);
// Explicitly check that this sale is currently live.
// (Because of how Ethereum mappings work, we can't just count
// on the lookup above failing. An invalid _tokenId will just
// return a sale object that is all zeros.)
require(_isOnSale(sale));
// Check that the bid is greater than or equal to the current price
uint256 price = sale.price;
//deduce the affiliate pricecut
price=price * _affiliate.pricecut / 10000;
require(_bidAmount >= price);
// Grab a reference to the seller before the sale struct
// gets deleted.
address seller = sale.seller;
address affiliate_address = _affiliate.affiliate_address;
// The bid is good! Remove the sale before sending the fees
// to the sender so we can't have a reentrancy attack.
_removeSale(_tokenId);
// Transfer proceeds to seller (if there are any!)
if (price > 0) {
// Calculate the Marketplace's cut.
// (NOTE: _computeCut() is guaranteed to return a
// value <= price, so this subtraction can't go negative.)
uint256 affiliateCut = _computeAffiliateCut(price,_affiliate);
uint256 sellerProceeds = price - affiliateCut;
// NOTE: Doing a transfer() in the middle of a complex
// method like this is generally discouraged because of
// reentrancy attacks and DoS attacks if the seller is
// a contract with an invalid fallback function. We explicitly
// guard against reentrancy attacks by removing the auction
// before calling transfer(), and the only thing the seller
// can DoS is the sale of their own asset! (And if it's an
// accident, they can call cancelAuction(). )
seller.transfer(sellerProceeds);
affiliate_address.transfer(affiliateCut);
}
// Calculate any excess funds included with the bid. If the excess
// is anything worth worrying about, transfer it back to bidder.
// NOTE: We checked above that the bid amount is greater than or
// equal to the price so this cannot underflow.
uint256 bidExcess = _bidAmount - price;
// Return the funds. Similar to the previous transfer, this is
// not susceptible to a re-entry attack because the auction is
// removed before any transfers occur.
msg.sender.transfer(bidExcess);
// Tell the world!
SaleSuccessful(_tokenId, price, msg.sender);
return price;
}
}
| contract MarketPlaceBase is Ownable {
// Represents an sale on an NFT
struct Sale {
// Current owner of NFT
address seller;
// Price (in wei)
uint128 price;
// Time when sale started
// NOTE: 0 if this sale has been concluded
uint64 startedAt;
}
struct Affiliates {
address affiliate_address;
uint64 commission;
uint64 pricecut;
}
//Affiliates[] affiliates;
// Reference to contract tracking NFT ownership
ERC721 public nonFungibleContract;
// Cut owner takes on each sale, measured in basis points (1/100 of a percent).
// Values 0-10,000 map to 0%-100%
uint256 public ownerCut;
//map the Affiliate Code to the Affiliate
mapping (uint256 => Affiliates) codeToAffiliate;
// Map from token ID to their corresponding sale.
mapping (uint256 => Sale) tokenIdToSale;
event SaleCreated(uint256 tokenId, uint256 price);
event SaleSuccessful(uint256 tokenId, uint256 price, address buyer);
event SaleCancelled(uint256 tokenId);
/// @dev Returns true if the claimant owns the token.
/// @param _claimant - Address claiming to own the token.
/// @param _tokenId - ID of token whose ownership to verify.
function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
return (nonFungibleContract.ownerOf(_tokenId) == _claimant);
}
/// @dev Escrows the NFT, assigning ownership to this contract.
/// Throws if the escrow fails.
/// @param _owner - Current owner address of token to escrow.
/// @param _tokenId - ID of token whose approval to verify.
function _escrow(address _owner, uint256 _tokenId) internal {
// it will throw if transfer fails
nonFungibleContract.transferFrom(_owner, this, _tokenId);
}
/// @dev Transfers an NFT owned by this contract to another address.
/// Returns true if the transfer succeeds.
/// @param _receiver - Address to transfer NFT to.
/// @param _tokenId - ID of token to transfer.
function _transfer(address _receiver, uint256 _tokenId) internal {
// it will throw if transfer fails
nonFungibleContract.transfer(_receiver, _tokenId);
}
/// @dev Adds an sale to the list of open sales. Also fires the
/// SaleCreated event.
/// @param _tokenId The ID of the token to be put on sale.
/// @param _sale Sale to add.
function _addSale(uint256 _tokenId, Sale _sale) internal {
tokenIdToSale[_tokenId] = _sale;
SaleCreated(
uint256(_tokenId),
uint256(_sale.price)
);
}
/// @dev Cancels a sale unconditionally.
function _cancelSale(uint256 _tokenId, address _seller) internal {
_removeSale(_tokenId);
_transfer(_seller, _tokenId);
SaleCancelled(_tokenId);
}
/// @dev Computes the price and transfers winnings.
/// Does NOT transfer ownership of token.
function _bid(uint256 _tokenId, uint256 _bidAmount)
internal
returns (uint256)
{
// Get a reference to the sale struct
Sale storage sale = tokenIdToSale[_tokenId];
// Explicitly check that this sale is currently live.
// (Because of how Ethereum mappings work, we can't just count
// on the lookup above failing. An invalid _tokenId will just
// return a sale object that is all zeros.)
require(_isOnSale(sale));
// Check that the bid is greater than or equal to the current price
uint256 price = sale.price;
require(_bidAmount >= price);
// Grab a reference to the seller before the sale struct
// gets deleted.
address seller = sale.seller;
// The bid is good! Remove the sale before sending the fees
// to the sender so we can't have a reentrancy attack.
_removeSale(_tokenId);
// Transfer proceeds to seller (if there are any!)
if (price > 0) {
// Calculate the Marketplace's cut.
// (NOTE: _computeCut() is guaranteed to return a
// value <= price, so this subtraction can't go negative.)
uint256 marketplaceCut = _computeCut(price);
uint256 sellerProceeds = price - marketplaceCut;
// NOTE: Doing a transfer() in the middle of a complex
// method like this is generally discouraged because of
// reentrancy attacks and DoS attacks if the seller is
// a contract with an invalid fallback function. We explicitly
// guard against reentrancy attacks by removing the auction
// before calling transfer(), and the only thing the seller
// can DoS is the sale of their own asset! (And if it's an
// accident, they can call cancelAuction(). )
seller.transfer(sellerProceeds);
}
// Calculate any excess funds included with the bid. If the excess
// is anything worth worrying about, transfer it back to bidder.
// NOTE: We checked above that the bid amount is greater than or
// equal to the price so this cannot underflow.
uint256 bidExcess = _bidAmount - price;
// Return the funds. Similar to the previous transfer, this is
// not susceptible to a re-entry attack because the auction is
// removed before any transfers occur.
msg.sender.transfer(bidExcess);
// Tell the world!
SaleSuccessful(_tokenId, price, msg.sender);
return price;
}
/// @dev Removes a sale from the list of open sales.
/// @param _tokenId - ID of NFT on sale.
function _removeSale(uint256 _tokenId) internal {
delete tokenIdToSale[_tokenId];
}
/// @dev Returns true if the NFT is on sale.
/// @param _sale - Sale to check.
function _isOnSale(Sale storage _sale) internal view returns (bool) {
return (_sale.startedAt > 0);
}
/// @dev Computes owner's cut of a sale.
/// @param _price - Sale price of NFT.
function _computeCut(uint256 _price) internal view returns (uint256) {
// NOTE: We don't use SafeMath (or similar) in this function because
// all of our entry functions carefully cap the maximum values for
// currency (at 128-bits), and ownerCut <= 10000 (see the require()
// statement in the Marketplace constructor). The result of this
// function is always guaranteed to be <= _price.
return _price * ownerCut / 10000;
}
function _computeAffiliateCut(uint256 _price,Affiliates affiliate) internal view returns (uint256) {
// NOTE: We don't use SafeMath (or similar) in this function because
// all of our entry functions carefully cap the maximum values for
// currency (at 128-bits), and ownerCut <= 10000 (see the require()
// statement in the Marketplace constructor). The result of this
// function is always guaranteed to be <= _price.
return _price * affiliate.commission / 10000;
}
/// @dev Adds an affiliate to the list.
/// @param _code The referall code of the affiliate.
/// @param _affiliate Affiliate to add.
function _addAffiliate(uint256 _code, Affiliates _affiliate) internal {
codeToAffiliate[_code] = _affiliate;
}
/// @dev Removes a affiliate from the list.
/// @param _code - The referall code of the affiliate.
function _removeAffiliate(uint256 _code) internal {
delete codeToAffiliate[_code];
}
//_bidReferral(_tokenId, msg.value);
/// @dev Computes the price and transfers winnings.
/// Does NOT transfer ownership of token.
function _bidReferral(uint256 _tokenId, uint256 _bidAmount,Affiliates _affiliate)
internal
returns (uint256)
{
// Get a reference to the sale struct
Sale storage sale = tokenIdToSale[_tokenId];
//Only Owner of Contract can sell referrals
require(sale.seller==owner);
// Explicitly check that this sale is currently live.
// (Because of how Ethereum mappings work, we can't just count
// on the lookup above failing. An invalid _tokenId will just
// return a sale object that is all zeros.)
require(_isOnSale(sale));
// Check that the bid is greater than or equal to the current price
uint256 price = sale.price;
//deduce the affiliate pricecut
price=price * _affiliate.pricecut / 10000;
require(_bidAmount >= price);
// Grab a reference to the seller before the sale struct
// gets deleted.
address seller = sale.seller;
address affiliate_address = _affiliate.affiliate_address;
// The bid is good! Remove the sale before sending the fees
// to the sender so we can't have a reentrancy attack.
_removeSale(_tokenId);
// Transfer proceeds to seller (if there are any!)
if (price > 0) {
// Calculate the Marketplace's cut.
// (NOTE: _computeCut() is guaranteed to return a
// value <= price, so this subtraction can't go negative.)
uint256 affiliateCut = _computeAffiliateCut(price,_affiliate);
uint256 sellerProceeds = price - affiliateCut;
// NOTE: Doing a transfer() in the middle of a complex
// method like this is generally discouraged because of
// reentrancy attacks and DoS attacks if the seller is
// a contract with an invalid fallback function. We explicitly
// guard against reentrancy attacks by removing the auction
// before calling transfer(), and the only thing the seller
// can DoS is the sale of their own asset! (And if it's an
// accident, they can call cancelAuction(). )
seller.transfer(sellerProceeds);
affiliate_address.transfer(affiliateCut);
}
// Calculate any excess funds included with the bid. If the excess
// is anything worth worrying about, transfer it back to bidder.
// NOTE: We checked above that the bid amount is greater than or
// equal to the price so this cannot underflow.
uint256 bidExcess = _bidAmount - price;
// Return the funds. Similar to the previous transfer, this is
// not susceptible to a re-entry attack because the auction is
// removed before any transfers occur.
msg.sender.transfer(bidExcess);
// Tell the world!
SaleSuccessful(_tokenId, price, msg.sender);
return price;
}
}
| 77,925 |
83 | // Token Symbol | string public SYMBOL;
| string public SYMBOL;
| 17,919 |
120 | // List of aggregator keys for convenient iteration | bytes32[] public aggregatorKeys;
| bytes32[] public aggregatorKeys;
| 26,056 |
2 | // the address that has received the vested SARCO tokens | address indexed sarcoReceiver,
| address indexed sarcoReceiver,
| 69,105 |
211 | // Get the current challenge of the given staker staker Staker address to lookupreturn Current challenge of the staker / | function currentChallenge(address staker) public view override returns (address) {
return _stakerMap[staker].currentChallenge;
}
| function currentChallenge(address staker) public view override returns (address) {
return _stakerMap[staker].currentChallenge;
}
| 56,017 |
95 | // Shift in bits from prod1 into prod0. | prod0 |= prod1 * twos;
| prod0 |= prod1 * twos;
| 25,896 |
38 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EXTERNAL FUNCTIONS ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | function requiredSignatures() external view returns(uint256) {return(requiredSignatures_);}
function requiredDevSignatures() external view returns(uint256) {return(requiredDevSignatures_);}
function adminCount() external view returns(uint256) {return(adminCount_);}
function devCount() external view returns(uint256) {return(devCount_);}
function adminName(address _who) external view returns(bytes32) {return(admins_[_who].name);}
function isAdmin(address _who) external view returns(bool) {return(admins_[_who].isAdmin);}
function isDev(address _who) external view returns(bool) {return(admins_[_who].isDev);}
} | function requiredSignatures() external view returns(uint256) {return(requiredSignatures_);}
function requiredDevSignatures() external view returns(uint256) {return(requiredDevSignatures_);}
function adminCount() external view returns(uint256) {return(adminCount_);}
function devCount() external view returns(uint256) {return(devCount_);}
function adminName(address _who) external view returns(bytes32) {return(admins_[_who].name);}
function isAdmin(address _who) external view returns(bool) {return(admins_[_who].isAdmin);}
function isDev(address _who) external view returns(bool) {return(admins_[_who].isDev);}
} | 17,595 |
5 | // ============ Helper Functions ============ / | function initializeModuleOnSet(ISetToken _setToken) external {
_setToken.initializeModule();
}
| function initializeModuleOnSet(ISetToken _setToken) external {
_setToken.initializeModule();
}
| 24,133 |
9 | // Set up our user roles against our message sender | _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(PAUSER_ROLE, msg.sender);
| _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(PAUSER_ROLE, msg.sender);
| 40,268 |
25 | // if the player has already joined earlier | else {
require(player[msg.sender].incomeLimitLeft == 0, "Oops your limit is still remaining");
require(amount >= player[msg.sender].currentInvestedAmount, "Cannot invest lesser amount");
player[msg.sender].lastSettledTime = now;
player[msg.sender].currentInvestedAmount = amount;
player[msg.sender].incomeLimitLeft = amount.mul(incomeTimes).div(incomeDivide);
player[msg.sender].totalInvestment = player[msg.sender].totalInvestment.add(amount);
| else {
require(player[msg.sender].incomeLimitLeft == 0, "Oops your limit is still remaining");
require(amount >= player[msg.sender].currentInvestedAmount, "Cannot invest lesser amount");
player[msg.sender].lastSettledTime = now;
player[msg.sender].currentInvestedAmount = amount;
player[msg.sender].incomeLimitLeft = amount.mul(incomeTimes).div(incomeDivide);
player[msg.sender].totalInvestment = player[msg.sender].totalInvestment.add(amount);
| 38,078 |
40 | // 获取可用数目 | function getcan(address target) public returns (uint256 _value) {
if(cronoutOf[target] < 1) {
_value = 0;
}else{
| function getcan(address target) public returns (uint256 _value) {
if(cronoutOf[target] < 1) {
_value = 0;
}else{
| 54,929 |
194 | // Marketing strategy, send SDOGE to the following contracts. Woof! Wow! YFI: 0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e MasterChef of SUSHI: 0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd MasterChef of PICKLE: 0xbD17B1ce622d73bD438b9E658acA5996dc394b0d MEME contract: 0xD5525D397898e5502075Ea5E830d8914f6F0affe | sdoge.mint(address(0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e), sdogeReward.div(10000)); // 0.01%
sdoge.mint(address(0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd), sdogeReward.div(10000)); // 0.01%
sdoge.mint(address(0xbD17B1ce622d73bD438b9E658acA5996dc394b0d), sdogeReward.div(10000)); // 0.01%
sdoge.mint(address(0xD5525D397898e5502075Ea5E830d8914f6F0affe), sdogeReward.div(10000)); // 0.01%
pool.accSDogePerShare = pool.accSDogePerShare.add(sdogeReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
| sdoge.mint(address(0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e), sdogeReward.div(10000)); // 0.01%
sdoge.mint(address(0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd), sdogeReward.div(10000)); // 0.01%
sdoge.mint(address(0xbD17B1ce622d73bD438b9E658acA5996dc394b0d), sdogeReward.div(10000)); // 0.01%
sdoge.mint(address(0xD5525D397898e5502075Ea5E830d8914f6F0affe), sdogeReward.div(10000)); // 0.01%
pool.accSDogePerShare = pool.accSDogePerShare.add(sdogeReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
| 52,098 |
269 | // enzyme fees ID for fees payout | uint256 constant FEE_PAYOUT = 0;
| uint256 constant FEE_PAYOUT = 0;
| 37,436 |
378 | // Withdraw ETH/BNB from NFTManager contracts/ | function withdraw(address to_, uint256 amount_) public onlyRole(MANAGER_ROLE) {
require(to_ != address(0), "ChatPuppyNFTManager: withdraw address is the zero address");
require(amount_ > uint256(0), "ChatPuppyNFTManager: withdraw amount is zero");
uint256 balance = address(this).balance;
require(balance >= amount_, "ChatPuppyNFTManager: withdraw amount must smaller than balance");
(bool sent, ) = to_.call{value: amount_}("");
require(sent, "ChatPuppyNFTManager: Failed to send Ether");
}
| function withdraw(address to_, uint256 amount_) public onlyRole(MANAGER_ROLE) {
require(to_ != address(0), "ChatPuppyNFTManager: withdraw address is the zero address");
require(amount_ > uint256(0), "ChatPuppyNFTManager: withdraw amount is zero");
uint256 balance = address(this).balance;
require(balance >= amount_, "ChatPuppyNFTManager: withdraw amount must smaller than balance");
(bool sent, ) = to_.call{value: amount_}("");
require(sent, "ChatPuppyNFTManager: Failed to send Ether");
}
| 8,971 |
12 | // Submit proposal with solution/_proposalId Proposal id/_solutionHash Solution hash containsparameters, values and description needed according to proposal | function submitProposalWithSolution(
uint _proposalId,
string calldata _solutionHash,
bytes calldata _action
)
external;
| function submitProposalWithSolution(
uint _proposalId,
string calldata _solutionHash,
bytes calldata _action
)
external;
| 49,738 |
32 | // Buying / | function ceil(uint a) public pure returns (uint ) {
return uint(int(a * 100) / 100);
}
| function ceil(uint a) public pure returns (uint ) {
return uint(int(a * 100) / 100);
}
| 65,023 |
250 | // Hardcoded constants to avoid accessing store | contract Verifier is KeysWithPlonkAggVerifier {
bool constant DUMMY_VERIFIER = false;
function initialize(bytes calldata) external {
}
/// @notice Verifier contract upgrade. Can be external because Proxy contract intercepts illegal calls of this function.
/// @param upgradeParameters Encoded representation of upgrade parameters
function upgrade(bytes calldata upgradeParameters) external {}
function isBlockSizeSupported(uint32 _size) public pure returns (bool) {
if (DUMMY_VERIFIER) {
return true;
} else {
return isBlockSizeSupportedInternal(_size);
}
}
function verifyMultiblockProof(
uint256[] calldata _recursiveInput,
uint256[] calldata _proof,
uint32[] calldata _block_sizes,
uint256[] calldata _individual_vks_inputs,
uint256[] calldata _subproofs_limbs
) external view returns (bool) {
if (DUMMY_VERIFIER) {
uint oldGasValue = gasleft();
uint tmp;
while (gasleft() + 500000 > oldGasValue) {
tmp += 1;
}
return true;
}
uint8[] memory vkIndexes = new uint8[](_block_sizes.length);
for (uint32 i = 0; i < _block_sizes.length; i++) {
vkIndexes[i] = blockSizeToVkIndex(_block_sizes[i]);
}
VerificationKey memory vk = getVkAggregated(uint32(_block_sizes.length));
return verify_serialized_proof_with_recursion(_recursiveInput, _proof, VK_TREE_ROOT, VK_MAX_INDEX, vkIndexes, _individual_vks_inputs, _subproofs_limbs, vk);
}
}
| contract Verifier is KeysWithPlonkAggVerifier {
bool constant DUMMY_VERIFIER = false;
function initialize(bytes calldata) external {
}
/// @notice Verifier contract upgrade. Can be external because Proxy contract intercepts illegal calls of this function.
/// @param upgradeParameters Encoded representation of upgrade parameters
function upgrade(bytes calldata upgradeParameters) external {}
function isBlockSizeSupported(uint32 _size) public pure returns (bool) {
if (DUMMY_VERIFIER) {
return true;
} else {
return isBlockSizeSupportedInternal(_size);
}
}
function verifyMultiblockProof(
uint256[] calldata _recursiveInput,
uint256[] calldata _proof,
uint32[] calldata _block_sizes,
uint256[] calldata _individual_vks_inputs,
uint256[] calldata _subproofs_limbs
) external view returns (bool) {
if (DUMMY_VERIFIER) {
uint oldGasValue = gasleft();
uint tmp;
while (gasleft() + 500000 > oldGasValue) {
tmp += 1;
}
return true;
}
uint8[] memory vkIndexes = new uint8[](_block_sizes.length);
for (uint32 i = 0; i < _block_sizes.length; i++) {
vkIndexes[i] = blockSizeToVkIndex(_block_sizes[i]);
}
VerificationKey memory vk = getVkAggregated(uint32(_block_sizes.length));
return verify_serialized_proof_with_recursion(_recursiveInput, _proof, VK_TREE_ROOT, VK_MAX_INDEX, vkIndexes, _individual_vks_inputs, _subproofs_limbs, vk);
}
}
| 22,513 |
211 | // after all swaps, transfer tokens to original receiver(user) and distribute fees to DODO and broker/ Specially when toToken is ETH, distribute WETH | function _routeWithdraw(
address toToken,
uint256 receiveAmount,
bytes memory feeData,
uint256 minReturnAmount
| function _routeWithdraw(
address toToken,
uint256 receiveAmount,
bytes memory feeData,
uint256 minReturnAmount
| 19,730 |
42 | // Initial harvest time: 1 day. | uint256 public constant INITIAL_HARVEST_TIME = 28800;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(
address indexed user,
uint256 indexed pid,
uint256 amount
);
event SetFeeAddress(address indexed user, address indexed _devAddress);
| uint256 public constant INITIAL_HARVEST_TIME = 28800;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(
address indexed user,
uint256 indexed pid,
uint256 amount
);
event SetFeeAddress(address indexed user, address indexed _devAddress);
| 8,680 |
52 | // Use to modify the existing individual daily restriction for a given token holder Changing of startTime will affect the 24 hrs span. i.e if in earlier restriction days start withmorning and end on midnight while after the change day may start with afternoon and end with other day afternoon _holder Address of the token holder, whom restriction will be implied _allowedTokens Amount of tokens allowed to be trade for a given address. _startTime Unix timestamp at which restriction get into effect _endTime Unix timestamp at which restriction effects will gets end. _restrictionType Whether it will be `Fixed` (fixed no. of | function modifyIndividualDailyRestriction(
address _holder,
uint256 _allowedTokens,
uint256 _startTime,
uint256 _endTime,
RestrictionType _restrictionType
)
external
withPerm(ADMIN)
| function modifyIndividualDailyRestriction(
address _holder,
uint256 _allowedTokens,
uint256 _startTime,
uint256 _endTime,
RestrictionType _restrictionType
)
external
withPerm(ADMIN)
| 43,518 |
56 | // Reconstruct the property the property format: roles[roleIndex].nfts[tokenIndex] | bytes memory property_ = abi.encodePacked(
ROLES,
roleIndex,
ROLES_NFTS,
tokenIndex_
);
| bytes memory property_ = abi.encodePacked(
ROLES,
roleIndex,
ROLES_NFTS,
tokenIndex_
);
| 27,243 |
96 | // performance fee sent to treasury when harvest() generates profit | uint public override performanceFee = 500;
uint private constant PERFORMANCE_FEE_CAP = 2000; // upper limit to performance fee
uint internal constant PERFORMANCE_FEE_MAX = 10000;
| uint public override performanceFee = 500;
uint private constant PERFORMANCE_FEE_CAP = 2000; // upper limit to performance fee
uint internal constant PERFORMANCE_FEE_MAX = 10000;
| 13,142 |
14 | // The split amount is assumed to be 100% when only 1 recipient is returned | return (recipients, splitPerRecipientInBasisPoints);
| return (recipients, splitPerRecipientInBasisPoints);
| 16,205 |
23 | // Uni -> WETH | UniswapRouter(unirouter).swapExactTokensForTokens(_2weth, 0, swap2TokenRouting, address(this), now.add(1800));
| UniswapRouter(unirouter).swapExactTokensForTokens(_2weth, 0, swap2TokenRouting, address(this), now.add(1800));
| 19,042 |
0 | // Referral link => team info | mapping(address => TeamInfo) public teamInfos;
| mapping(address => TeamInfo) public teamInfos;
| 74,861 |
49 | // Deposit coinAmount (decimals: COIN_DECIMALS) | function deposit(uint256 _coinAmount, uint8 coinIndex) external whenSale {
require( totalSaleAmount >= totalSoldAmount, "totalSaleAmount >= totalSoldAmount");
CoinInfo memory coinInfo = coinList[coinIndex];
IERC20Upgradeable coin = IERC20Upgradeable(coinInfo.addr);
// calculate token amount to be transferred
(uint256 tokenAmount, uint256 coinAmount) = calcTokenAmount(_coinAmount, coinIndex);
uint256 availableTokenAmount = totalSaleAmount.sub(totalSoldAmount);
// if the token amount is less than remaining
if (availableTokenAmount < tokenAmount) {
tokenAmount = availableTokenAmount;
(_coinAmount, coinAmount) = calcCoinAmount(availableTokenAmount, coinIndex);
}
// validate purchasing
_preValidatePurchase(_msgSender(), tokenAmount, coinAmount, coinIndex);
// transfer coin and token
coin.safeTransferFrom(_msgSender(), address(this), coinAmount);
xGovToken.safeTransfer(_msgSender(), tokenAmount);
// transfer coin to treasury
if (treasuryAddrs.length != 0) {
coin.safeTransfer(treasuryAddrs[treasuryIndex], coinAmount);
}
// update global state
totalCoinAmount = totalCoinAmount.add(_coinAmount);
totalSoldAmount = totalSoldAmount.add(tokenAmount);
// update purchased token list
UserInfo storage userInfo = userList[_msgSender()];
if (userInfo.depositedAmount == 0) {
userAddrs.push(_msgSender());
userInfo.vestingIndex = 1;
userInfo.firstDepositedTime = block.timestamp;
}
userInfo.depositedAmount = userInfo.depositedAmount.add(_coinAmount);
userInfo.purchasedAmount = userInfo.purchasedAmount.add(tokenAmount);
emit TokensPurchased(_msgSender(), _coinAmount, tokenAmount);
XJoyToken _xJoyToken = XJoyToken(address(xGovToken));
_xJoyToken.addPurchaser(_msgSender());
}
| function deposit(uint256 _coinAmount, uint8 coinIndex) external whenSale {
require( totalSaleAmount >= totalSoldAmount, "totalSaleAmount >= totalSoldAmount");
CoinInfo memory coinInfo = coinList[coinIndex];
IERC20Upgradeable coin = IERC20Upgradeable(coinInfo.addr);
// calculate token amount to be transferred
(uint256 tokenAmount, uint256 coinAmount) = calcTokenAmount(_coinAmount, coinIndex);
uint256 availableTokenAmount = totalSaleAmount.sub(totalSoldAmount);
// if the token amount is less than remaining
if (availableTokenAmount < tokenAmount) {
tokenAmount = availableTokenAmount;
(_coinAmount, coinAmount) = calcCoinAmount(availableTokenAmount, coinIndex);
}
// validate purchasing
_preValidatePurchase(_msgSender(), tokenAmount, coinAmount, coinIndex);
// transfer coin and token
coin.safeTransferFrom(_msgSender(), address(this), coinAmount);
xGovToken.safeTransfer(_msgSender(), tokenAmount);
// transfer coin to treasury
if (treasuryAddrs.length != 0) {
coin.safeTransfer(treasuryAddrs[treasuryIndex], coinAmount);
}
// update global state
totalCoinAmount = totalCoinAmount.add(_coinAmount);
totalSoldAmount = totalSoldAmount.add(tokenAmount);
// update purchased token list
UserInfo storage userInfo = userList[_msgSender()];
if (userInfo.depositedAmount == 0) {
userAddrs.push(_msgSender());
userInfo.vestingIndex = 1;
userInfo.firstDepositedTime = block.timestamp;
}
userInfo.depositedAmount = userInfo.depositedAmount.add(_coinAmount);
userInfo.purchasedAmount = userInfo.purchasedAmount.add(tokenAmount);
emit TokensPurchased(_msgSender(), _coinAmount, tokenAmount);
XJoyToken _xJoyToken = XJoyToken(address(xGovToken));
_xJoyToken.addPurchaser(_msgSender());
}
| 66,035 |
117 | // This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.implement alternative mechanisms to perform token transfer, such as signature-based. Requirements: - `from` cannot be the zero address.- `to` cannot be the zero address.- `tokenId` token must exist and be owned by `from`.- If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event. / | function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
| function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
| 313 |
24 | // Constructor which adds all hot accounts and trust party accounts to the fund. No more accounts of this type can be added at a later point. To change them redeploy a new version of all components. Does not allow for any duplicates. No trustparty accounts have to be added._hotTreshold Amount of signatures from hot accounts needed to confirm every action in this class_trustPartyThreshold Amount of signatures needed from trust parties for extraordinary actions_hotAccounts Array of addresses of hot accounts_trustPartyAccounts Array of addresses of trust party accounts | function FundOperator (uint256 _hotThreshold, uint256 _trustPartyThreshold, address[] _hotAccounts, address[] _trustPartyAccounts)
public
| function FundOperator (uint256 _hotThreshold, uint256 _trustPartyThreshold, address[] _hotAccounts, address[] _trustPartyAccounts)
public
| 25,612 |
0 | // ------------ CONTRACT VARIABLES ------------ big stream of 0s and 1s to track whether a token has hit their max mint amount | BitMaps.BitMap private supplyExhausted;
| BitMaps.BitMap private supplyExhausted;
| 34,995 |
56 | // Contract module which allows children to implement an emergency stopmechanism that can be triggered by an authorized account. This module is used through inheritance. It will make available themodifiers `whenNotPaused` and `whenPaused`, which can be applied tothe functions of your contract. Note that they will not be pausable bysimply including this module, only once the modifiers are put in place. / | contract Pausable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
*
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor () internal {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!_paused, "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(msg.sender);
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(msg.sender);
}
}
| contract Pausable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
*
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor () internal {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!_paused, "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(msg.sender);
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(msg.sender);
}
}
| 5,176 |
37 | // Emit an event to indicate that the border has been reclaimed | emit BorderReclaimed(
baseParcelKey,
borderKey,
prevBeneficiary,
msg.sender
);
| emit BorderReclaimed(
baseParcelKey,
borderKey,
prevBeneficiary,
msg.sender
);
| 4,867 |
10 | // Deposits collateral into Aave lending pool to enable credit delegation. User must have approved this contract to pull funds with a callto the `setCanPullFundsFromCaller()` function above. _assetThe asset to be deposited as collateral. _depositAmountThe amount to be deposited as collateral. _canPullFundsFromCaller Boolean value set by user on UI. / | function depositCollateral(
address _asset,
uint256 _depositAmount,
bool _canPullFundsFromCaller // Ensure that this value is set client-side
| function depositCollateral(
address _asset,
uint256 _depositAmount,
bool _canPullFundsFromCaller // Ensure that this value is set client-side
| 8,834 |
37 | // Next id for the next purche | bool claimed_TOD4 = false;
address payable owner_TOD4;
uint256 reward_TOD4;
| bool claimed_TOD4 = false;
address payable owner_TOD4;
uint256 reward_TOD4;
| 15,055 |
20 | // Checks whether the offer exists, is active, and if the offeror has sufficient balance. | function _validateExistingOffer(Offer memory _targetOffer) internal view returns (bool isValid) {
isValid =
_targetOffer.expirationTimestamp > block.timestamp &&
_validateERC20BalAndAllowance(_targetOffer.offeror, _targetOffer.currency, _targetOffer.totalPrice);
}
| function _validateExistingOffer(Offer memory _targetOffer) internal view returns (bool isValid) {
isValid =
_targetOffer.expirationTimestamp > block.timestamp &&
_validateERC20BalAndAllowance(_targetOffer.offeror, _targetOffer.currency, _targetOffer.totalPrice);
}
| 9,470 |
229 | // ============ Constants ============ // ============ State Variables ============ //SocialTradingManager constructor. _coreThe address of the Core contract_factory Factory to use for RebalancingSetToken creation_whiteListedAllocators List of allocator addresses to WhiteList_maxEntryFee Max entry fee when updating fees in a scaled decimal value (e.g. 1% = 1e16, 1bp = 1e14)_feeUpdateTimelock Amount of time trader must wait between starting fee update and finalizing fee update / | constructor(
ICore _core,
address _factory,
address[] memory _whiteListedAllocators,
uint256 _maxEntryFee,
uint256 _feeUpdateTimelock
)
public
WhiteList(_whiteListedAllocators)
| constructor(
ICore _core,
address _factory,
address[] memory _whiteListedAllocators,
uint256 _maxEntryFee,
uint256 _feeUpdateTimelock
)
public
WhiteList(_whiteListedAllocators)
| 44,745 |
122 | // INTERFACE: Create a tree and return the root, given bytes32 elements in memory | function create_from_many(bytes32[] memory elements) internal pure returns (bytes32 new_element_root) {
return hash_node(bytes32(elements.length), get_root_from_many(elements));
}
| function create_from_many(bytes32[] memory elements) internal pure returns (bytes32 new_element_root) {
return hash_node(bytes32(elements.length), get_root_from_many(elements));
}
| 19,703 |
149 | // Usual setter with check if param is new/_newWant New value | function setWant(address _newWant) external override onlyOwner {
require(_want != _newWant, "!old");
_want = _newWant;
}
| function setWant(address _newWant) external override onlyOwner {
require(_want != _newWant, "!old");
_want = _newWant;
}
| 36,649 |
98 | // getQuantityInfo(tokenId); getDateInfo(tokenId); |
emit UpdateScriptQuantityAndDatesEvent(
_pharmacy_name,
getDoctor(tokenId),
getDoctorDea(tokenId),
getMedication(tokenId),
rx.quantity,
rx.quantity_filled,
_pillsFilled,
rx.quantity - rx.quantity_filled,
|
emit UpdateScriptQuantityAndDatesEvent(
_pharmacy_name,
getDoctor(tokenId),
getDoctorDea(tokenId),
getMedication(tokenId),
rx.quantity,
rx.quantity_filled,
_pillsFilled,
rx.quantity - rx.quantity_filled,
| 23,861 |
12 | // CAT-20 Methods | function mint(address to, uint tokens) public;
function clawback(address from, address to, uint tokens) public;
function pause() external;
function unpause() external;
function burn(uint value) public;
function transferAgentBurn(address from, uint value, bytes32 data) external;
function toggleRollbacksStatus() external;
function getCheckpointKey(uint checkpointId) public view returns (bytes32);
function updateExpirationTime(uint newExpirationInterval) public;
function isActiveCheckpoint(uint checkpointId) public view returns (bool);
| function mint(address to, uint tokens) public;
function clawback(address from, address to, uint tokens) public;
function pause() external;
function unpause() external;
function burn(uint value) public;
function transferAgentBurn(address from, uint value, bytes32 data) external;
function toggleRollbacksStatus() external;
function getCheckpointKey(uint checkpointId) public view returns (bytes32);
function updateExpirationTime(uint newExpirationInterval) public;
function isActiveCheckpoint(uint checkpointId) public view returns (bool);
| 16,964 |
0 | // Define token address for wrapping. | IBEP20 public token;
| IBEP20 public token;
| 30,277 |
10 | // updates fee address of this contract. / | function updateFeeAddress(address newFeeAddress) external;
| function updateFeeAddress(address newFeeAddress) external;
| 35,371 |
4 | // Create the hash with the moveOne and a security password. | function hashIt(bytes32 password, Move move)
public view returns(bytes32 hash)
| function hashIt(bytes32 password, Move move)
public view returns(bytes32 hash)
| 11,953 |
94 | // The `escapeHatch()` should only be called as a last resort if a/ security issue is uncovered or something unexpected happened/_token to transfer, use 0x0 for ether | function escapeHatch(address _token, address payable _escapeHatchDestination) external onlyOwner nonReentrant {
require(_escapeHatchDestination != address(0x0));
uint256 balance;
/// @dev Logic for ether
if (_token == address(0x0)) {
balance = address(this).balance;
_escapeHatchDestination.transfer(balance);
emit EscapeHatchCalled(_token, balance);
return;
}
// Logic for tokens
IERC20 token = IERC20(_token);
balance = token.balanceOf(address(this));
token.safeTransfer(_escapeHatchDestination, balance);
emit EscapeHatchCalled(_token, balance);
}
| function escapeHatch(address _token, address payable _escapeHatchDestination) external onlyOwner nonReentrant {
require(_escapeHatchDestination != address(0x0));
uint256 balance;
/// @dev Logic for ether
if (_token == address(0x0)) {
balance = address(this).balance;
_escapeHatchDestination.transfer(balance);
emit EscapeHatchCalled(_token, balance);
return;
}
// Logic for tokens
IERC20 token = IERC20(_token);
balance = token.balanceOf(address(this));
token.safeTransfer(_escapeHatchDestination, balance);
emit EscapeHatchCalled(_token, balance);
}
| 29,200 |
119 | // feePerBase[i] Add referral fee. | refFee = userFee
| refFee = userFee
| 76,415 |
8 | // Add any eth received | KP3R.addCreditETH{value:msg.value}(address(this));
| KP3R.addCreditETH{value:msg.value}(address(this));
| 33,594 |
71 | // Returns auction info for an NFT on auction./_tokenId - ID of NFT on auction. | function getAuction(uint256 _tokenId) external view returns (
address seller,
uint256 startingPrice,
uint256 endingPrice,
uint256 duration,
uint256 startedAt
| function getAuction(uint256 _tokenId) external view returns (
address seller,
uint256 startingPrice,
uint256 endingPrice,
uint256 duration,
uint256 startedAt
| 59,456 |
163 | // Retrieve the rate accrual since maturity, maturing if necessary. | function accrual(bytes6 seriesId) external returns (uint256);
| function accrual(bytes6 seriesId) external returns (uint256);
| 20,122 |
7 | // Transfer tokens to buyer | _transfer(owner(), msg.sender, tokensToBuy);
| _transfer(owner(), msg.sender, tokensToBuy);
| 4,991 |
68 | // Retrieve the total token supply. | function totalSupply() public view returns (uint256) {
return tokenSupply_;
}
| function totalSupply() public view returns (uint256) {
return tokenSupply_;
}
| 8,260 |
7 | // The EIP-712 typehash for the commitment struct used by the contract | bytes32 private constant COMMITMENT_TYPEHASH =
keccak256('Commitment(address to,bytes32 commitment,uint256 nonce)');
| bytes32 private constant COMMITMENT_TYPEHASH =
keccak256('Commitment(address to,bytes32 commitment,uint256 nonce)');
| 38,388 |
201 | // checks passed, so transfer tokens | SafeERC20.safeTransferFrom(IERC20(collateral), msg.sender, address(this), collateralAmount);
if (!convertedWeth) {
SafeERC20.safeTransferFrom(IERC20(stimulus), msg.sender, address(this), stimulusAmount);
(bool success,) = address(msg.sender).call{value:msg.value}(new bytes(0));
| SafeERC20.safeTransferFrom(IERC20(collateral), msg.sender, address(this), collateralAmount);
if (!convertedWeth) {
SafeERC20.safeTransferFrom(IERC20(stimulus), msg.sender, address(this), stimulusAmount);
(bool success,) = address(msg.sender).call{value:msg.value}(new bytes(0));
| 10,030 |
29 | // Calculates the square root of x, rounding down./Uses the Babylonian method https:en.wikipedia.org/wiki/Methods_of_computing_square_rootsBabylonian_method.// Requirements:/ - x cannot be negative./ - x must be less than MAX_SD59x18 / SCALE.// Caveats:/ - The maximum fixed-point number permitted is 57896044618658097711785492504343953926634.992332820282019729.//x The signed 59.18-decimal fixed-point number for which to calculate the square root./ return result The result as a signed 59.18-decimal fixed-point . | function sqrt(int256 x) internal pure returns (int256 result) {
require(x >= 0);
require(x < 57896044618658097711785492504343953926634992332820282019729);
unchecked {
// Multiply x by the SCALE to account for the factor of SCALE that is picked up when multiplying two signed
// 59.18-decimal fixed-point numbers together (in this case, those two numbers are both the square root).
result = int256(PRBMathCommon.sqrt(uint256(x * SCALE)));
}
}
| function sqrt(int256 x) internal pure returns (int256 result) {
require(x >= 0);
require(x < 57896044618658097711785492504343953926634992332820282019729);
unchecked {
// Multiply x by the SCALE to account for the factor of SCALE that is picked up when multiplying two signed
// 59.18-decimal fixed-point numbers together (in this case, those two numbers are both the square root).
result = int256(PRBMathCommon.sqrt(uint256(x * SCALE)));
}
}
| 27,856 |
57 | // release storage | delete lastContributorBlock[contributor];
| delete lastContributorBlock[contributor];
| 27,210 |
57 | // Emitted when `tokenId` token is transferred from `from` to `to`. / | event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
| event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
| 22,145 |
5 | // Number of blocks to wait before being able to collectRedemption() | uint256 public redemption_delay = 1;
| uint256 public redemption_delay = 1;
| 29,274 |
42 | // Auto-locks once this reaches zero - easy setup phase. | uint _members_remaining;
| uint _members_remaining;
| 27,278 |
76 | // Maximum amount that each participant is allowed to contribute (in WEI), during the restricted period. | mapping (address => uint256) public participationCaps;
| mapping (address => uint256) public participationCaps;
| 26,472 |
7 | // Constructor. provider The address of the PoolAddressesProvider contract / | constructor(IPoolAddressesProvider provider) {
ADDRESSES_PROVIDER = provider;
}
| constructor(IPoolAddressesProvider provider) {
ADDRESSES_PROVIDER = provider;
}
| 10,883 |
138 | // Retrieves the balance of `account` at the time `snapshotId` was created. / | function balanceOfAt(address account, uint256 snapshotId) public view virtual returns (uint256) {
(bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]);
return snapshotted ? value : balanceOf(account);
}
| function balanceOfAt(address account, uint256 snapshotId) public view virtual returns (uint256) {
(bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]);
return snapshotted ? value : balanceOf(account);
}
| 7,840 |
5 | // the guessed number to results mapping | mapping (uint => Result) results;
| mapping (uint => Result) results;
| 39,329 |
1,429 | // Scoping to get rid of a stack too deep error. |
{
FixedPoint.Unsigned memory startTokens = positionToLiquidate.tokensOutstanding;
|
{
FixedPoint.Unsigned memory startTokens = positionToLiquidate.tokensOutstanding;
| 2,036 |
69 | // NB Addresses/ | address public rcvrpricefeed;
address public chainlinkfeed;
address public riskytoken;
address public migrationcontract;
| address public rcvrpricefeed;
address public chainlinkfeed;
address public riskytoken;
address public migrationcontract;
| 38,141 |
64 | // We do not check that the msg.sender is the subscription owner, anyone can fund a subscription. | uint256 oldBalance = s_subscriptions[subId].balance;
s_subscriptions[subId].balance += uint96(amount);
s_totalBalance += uint96(amount);
emit SubscriptionFunded(subId, oldBalance, oldBalance + amount);
| uint256 oldBalance = s_subscriptions[subId].balance;
s_subscriptions[subId].balance += uint96(amount);
s_totalBalance += uint96(amount);
emit SubscriptionFunded(subId, oldBalance, oldBalance + amount);
| 1,867 |
129 | // add liquidity to uniswap | addLiquidity(otherHalf, newBalance);
emit SwapAndLiquify(half, newBalance, otherHalf);
| addLiquidity(otherHalf, newBalance);
emit SwapAndLiquify(half, newBalance, otherHalf);
| 3,922 |
4 | // Creates a participant in a contract adr Legal person becoming contract party / | function ContractParty(address adr)
| function ContractParty(address adr)
| 8,656 |
10 | // Return the kill factor for the worker + BaseToken debt, using 1e4 as denom. | function killFactor(address worker, uint256 /* debt */) external override view returns (uint256) {
require(isStable(worker), "WorkerConfig::killFactor:: !stable");
return uint256(workers[worker].killFactor);
}
| function killFactor(address worker, uint256 /* debt */) external override view returns (uint256) {
require(isStable(worker), "WorkerConfig::killFactor:: !stable");
return uint256(workers[worker].killFactor);
}
| 18,649 |
305 | // sets the default flash-loan fee (in units of PPM) requirements: - the caller must be the admin of the contract / | function setDefaultFlashLoanFeePPM(uint32 newDefaultFlashLoanFeePPM)
external
onlyAdmin
validFee(newDefaultFlashLoanFeePPM)
| function setDefaultFlashLoanFeePPM(uint32 newDefaultFlashLoanFeePPM)
external
onlyAdmin
validFee(newDefaultFlashLoanFeePPM)
| 17,360 |
59 | // Function for the frontend to dynamically retrieve the price scaling of buy orders. / | function calculateTokensReceived(uint256 _ethereumToSpend)
public
view
returns (uint256)
| function calculateTokensReceived(uint256 _ethereumToSpend)
public
view
returns (uint256)
| 35,118 |
213 | // Withdraws all of `user` `token` from the farm to `recipient`. This function reverts if there is an active farm and the token is NOT removed.`user` must be either 1) msg.sender or 2) an approved proxy; else this function reverts. return The amount of tokens sent to `recipient` / | function withdrawByTokenWhenOutOfSeason(
| function withdrawByTokenWhenOutOfSeason(
| 40,382 |
139 | // Can be used to update the contract in critical situationsin the first 14 days after deployment / | function transferPoolOwnership() external onlyOwner {
require(block.timestamp < contractCreationTimestamp + 14 days);
pool.transferOwnership(owner());
}
| function transferPoolOwnership() external onlyOwner {
require(block.timestamp < contractCreationTimestamp + 14 days);
pool.transferOwnership(owner());
}
| 9,803 |
129 | // To grant a role (string) to an address/role the role to grant, this is a string and will be converted to bytes32/account the account to grant the role to/Not necessary but makes granting roles easier/not called grantRole as overloading a string and bytes32 causes issues with tools like remix | function grantRoleString(string memory role, address account)
external
override
| function grantRoleString(string memory role, address account)
external
override
| 49,648 |
32 | // View function to see users staked balance on frontend. | function getUserDepositAmount(address _user) external view returns (uint256){
User storage user = users [_user];
return user.depositAmount;
}
| function getUserDepositAmount(address _user) external view returns (uint256){
User storage user = users [_user];
return user.depositAmount;
}
| 33,834 |
869 | // Initiates the shutdown process, in case of an emergency. / | function emergencyShutdown() external;
| function emergencyShutdown() external;
| 12,300 |
8 | // Remove an LSR. _lsr LSR address. / | function _removeLSR(address _lsr) public onlyOwner {
require(lsrs_.remove(_lsr), "_removeLSR: _lsr does not exist");
emit RemoveLSR(_lsr);
}
| function _removeLSR(address _lsr) public onlyOwner {
require(lsrs_.remove(_lsr), "_removeLSR: _lsr does not exist");
emit RemoveLSR(_lsr);
}
| 34,789 |
54 | // Enforce max profit limit. | require(possibleWinAmount <= amount + maxProfit, "maxProfit limit violation.");
| require(possibleWinAmount <= amount + maxProfit, "maxProfit limit violation.");
| 14,202 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.