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 |
|---|---|---|---|---|
94 | // Pure function to get the name of the token.return The name of the token. / | function name() external pure returns (string memory) {
return _NAME;
}
| function name() external pure returns (string memory) {
return _NAME;
}
| 30,779 |
13 | // Repay the debts / | function repay() external {
uint _balance = underlying.balanceOf(address(this));
underlying.safeApprove(address(cy), _balance);
require(cy.repayBorrow(_balance) == 0, "repay failed");
}
| function repay() external {
uint _balance = underlying.balanceOf(address(this));
underlying.safeApprove(address(cy), _balance);
require(cy.repayBorrow(_balance) == 0, "repay failed");
}
| 79,773 |
12 | // Adds liquidity to the trading pool./At least one of nftIds or tokenAmount must be greater than zero./The caller must approve the Trading Pool contract to transfer the NFTs and ERC20 tokens./receiver The recipient of the liquidity pool tokens./nftIds The IDs of the NFTs being deposited./tokenAmount The amount of the ... | function addLiquidity(
address receiver,
DataTypes.LPType lpType,
uint256[] calldata nftIds,
uint256 tokenAmount,
uint256 spotPrice,
address curve,
uint256 delta,
uint256 fee
| function addLiquidity(
address receiver,
DataTypes.LPType lpType,
uint256[] calldata nftIds,
uint256 tokenAmount,
uint256 spotPrice,
address curve,
uint256 delta,
uint256 fee
| 43,229 |
10 | // Locks tokens into the claimable pool _amount Amount of tokens to be locked / | function _lockTokens(uint256 _amount) internal {
maxLockedTokens += _amount.mul(SCALAR); // Applies scalar for precision
(bool transferSuccess, ) = tokenAddress.call(
abi.encodeWithSignature(
"transferFrom(address,address,uint256)",
msg.sender,
... | function _lockTokens(uint256 _amount) internal {
maxLockedTokens += _amount.mul(SCALAR); // Applies scalar for precision
(bool transferSuccess, ) = tokenAddress.call(
abi.encodeWithSignature(
"transferFrom(address,address,uint256)",
msg.sender,
... | 11,453 |
53 | // fired after a recommit for a purchase | event Recommit(uint indexed id, address indexed user, uint count);
| event Recommit(uint indexed id, address indexed user, uint count);
| 2,095 |
7 | // Function to mint new communal token to given address with token URIto The address that will own the minted tokentokenURI string The token URI of the minted tokencommunal - set token communal, true or false return uint256 is token id of new created token | function mint(address to, string calldata, bool communal) external returns (uint256);
| function mint(address to, string calldata, bool communal) external returns (uint256);
| 45,607 |
431 | // Set the address of the Reward Control contract to be triggered to accrue ALK rewards for participants _rewardControl The address of the underlying reward control contractreturn uint 0=success, otherwise a failure (see ErrorReporter.sol for details) / | function setRewardControlAddress(address _rewardControl)
external
returns (uint256)
| function setRewardControlAddress(address _rewardControl)
external
returns (uint256)
| 74,193 |
345 | // Transactional reward | _userReward = _compoundRewards.mul(rateReward).div(100);
| _userReward = _compoundRewards.mul(rateReward).div(100);
| 14,313 |
29 | // Returns the minimum bond amount required to make an assertion. This is calculated as the final fee of thecurrency divided by the burnedBondPercentage. If burn percentage is 50% then the min bond is 2x the final fee. currency currency to calculate the minimum bond for.return minimum bond amount. / | function getMinimumBond(address currency) public view returns (uint256) {
uint256 finalFee = cachedCurrencies[currency].finalFee;
return (finalFee * 1e18) / burnedBondPercentage;
}
| function getMinimumBond(address currency) public view returns (uint256) {
uint256 finalFee = cachedCurrencies[currency].finalFee;
return (finalFee * 1e18) / burnedBondPercentage;
}
| 22,437 |
16 | // The internal function used by the `stake` and `addPool` functions./ See the `stake` public function for more details./_toPoolStakingAddress The staking address of the pool where the coins should be staked./_amount The amount of coins to be staked. | function _stake(address _toPoolStakingAddress, uint256 _amount) internal {
address staker = msg.sender;
_amount = msg.value;
_stake(_toPoolStakingAddress, staker, _amount);
}
| function _stake(address _toPoolStakingAddress, uint256 _amount) internal {
address staker = msg.sender;
_amount = msg.value;
_stake(_toPoolStakingAddress, staker, _amount);
}
| 15,145 |
2 | // Missing the given role or admin access | error Access_MissingRoleOrAdmin(bytes32 role);
| error Access_MissingRoleOrAdmin(bytes32 role);
| 37,939 |
9 | // Start address = buffer address + offset + sizeof(buffer length) | dest := add(add(bufptr, 32), off)
| dest := add(add(bufptr, 32), off)
| 18,486 |
10 | // Hippo can not be cloned more than its maximum clone number | require(hippo.numOfClones < hippo.maxNum, "It exceeds the maximum number of clones");
| require(hippo.numOfClones < hippo.maxNum, "It exceeds the maximum number of clones");
| 30,349 |
17 | // Users functions | modifier checkPermission(uint256 perm) {
require((permissions[msg.sender] & perm) > 0);
_;
}
| modifier checkPermission(uint256 perm) {
require((permissions[msg.sender] & perm) > 0);
_;
}
| 4,106 |
25 | // bet a users token against another users token | function betAgainstUser(uint _betId1, uint _betId2) public defcon3 returns(bool){
require(betBanks[_betId1].bet != emptyBet && betBanks[_betId2].bet != emptyBet);//require that both tokens are active and hold funds
require(betBanks[_betId1].owner == msg.sender || betBanks[_betId2].owner == msg.sende... | function betAgainstUser(uint _betId1, uint _betId2) public defcon3 returns(bool){
require(betBanks[_betId1].bet != emptyBet && betBanks[_betId2].bet != emptyBet);//require that both tokens are active and hold funds
require(betBanks[_betId1].owner == msg.sender || betBanks[_betId2].owner == msg.sende... | 11,343 |
136 | // Emits an {Approval} event. Requirements: - `owner` cannot be the zero address. - `spender` cannot be the zero address./ | function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(o... | function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(o... | 36,389 |
101 | // Token Geyser A smart-contract based mechanism to distribute tokens over time, inspired loosely by Compound and Uniswap.Distribution tokens are added to a locked pool in the contract and become unlocked over time according to a once-configurable unlock schedule. Once unlocked, they are available to be claimed by user... | contract TokenGeyser is IStaking, Ownable {
using SafeMath for uint256;
event Staked(address indexed user, uint256 amount, uint256 total, bytes data);
event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data);
event TokensClaimed(address indexed user, uint256 amount);
event To... | contract TokenGeyser is IStaking, Ownable {
using SafeMath for uint256;
event Staked(address indexed user, uint256 amount, uint256 total, bytes data);
event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data);
event TokensClaimed(address indexed user, uint256 amount);
event To... | 9,845 |
64 | // Gyouji: Kuma Matsuri | uint256 taxGonValue = gonValue.div(100).mul(_taxFeeKumaGyouji);
_gonBalances[from] = _gonBalances[from].sub(gonValue);
_gonBalances[to] = _gonBalances[to].add(gonValue.sub(taxGonValue));
_gonBalances[address(this)] = _gonBalances[address(this)].add(
taxGon... | uint256 taxGonValue = gonValue.div(100).mul(_taxFeeKumaGyouji);
_gonBalances[from] = _gonBalances[from].sub(gonValue);
_gonBalances[to] = _gonBalances[to].add(gonValue.sub(taxGonValue));
_gonBalances[address(this)] = _gonBalances[address(this)].add(
taxGon... | 21,885 |
2 | // Reentrancy Guard | bool private _entered;
bool public _eventSend;
Destinations public destinations;
uint256 public nextCycleStartTime;
bool private isLogicContract;
modifier onlyAdmin() {
| bool private _entered;
bool public _eventSend;
Destinations public destinations;
uint256 public nextCycleStartTime;
bool private isLogicContract;
modifier onlyAdmin() {
| 31,812 |
27 | // Returns orders array length. / | function getOrdersLength() public view override returns (uint256) {
return orders.length;
}
| function getOrdersLength() public view override returns (uint256) {
return orders.length;
}
| 20,563 |
20 | // Call overridden function Modify in this contract | Modify(description, price);
| Modify(description, price);
| 10,998 |
427 | // 所有 | // function MaxAssetToTarget(address user) external view returns(uint256) {
// uint256 buildRatio = mConfig.getUint(mConfig.BUILD_RATIO());
// uint256 totalCollateral = collaterSys.GetUserTotalCollateralInUsd(user);
// }
| // function MaxAssetToTarget(address user) external view returns(uint256) {
// uint256 buildRatio = mConfig.getUint(mConfig.BUILD_RATIO());
// uint256 totalCollateral = collaterSys.GetUserTotalCollateralInUsd(user);
// }
| 42,877 |
69 | // List of token default partitions (for ERC20 compatibility). | bytes32 internal _defaultPartition;
| bytes32 internal _defaultPartition;
| 2,160 |
74 | // Withdrawing ETH | if (_currency == address(0)) {
payable(owner()).transfer(_amount);
} else {
| if (_currency == address(0)) {
payable(owner()).transfer(_amount);
} else {
| 73,895 |
11 | // Enter the NFT raffle | function enterRaffle(uint256 _numTickets) external payable nftHeld {
if (block.timestamp > endTime) {
revert RaffleNotOpen();
}
if (_numTickets <= 0) {
revert InvalidTicketAmount();
}
if (msg.value < ticketFee * _numTickets) {
revert Insu... | function enterRaffle(uint256 _numTickets) external payable nftHeld {
if (block.timestamp > endTime) {
revert RaffleNotOpen();
}
if (_numTickets <= 0) {
revert InvalidTicketAmount();
}
if (msg.value < ticketFee * _numTickets) {
revert Insu... | 24,762 |
307 | // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel) | emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);
return uint(Error.NO_ERROR);
| emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);
return uint(Error.NO_ERROR);
| 30,959 |
14 | // Meta-transactions override for OpenSea. / | function _msgSender() internal override view returns (address) {
return ContextMixin.msgSender();
}
| function _msgSender() internal override view returns (address) {
return ContextMixin.msgSender();
}
| 10,660 |
240 | // Calculates time elapsed rounded down to the nearest interestPeriod / | function calculateEffectiveTimeElapsedForNewLender(
Position storage position,
uint256 timestamp
)
private
view
returns (uint256)
| function calculateEffectiveTimeElapsedForNewLender(
Position storage position,
uint256 timestamp
)
private
view
returns (uint256)
| 24,510 |
15 | // Number of NFTs minted | uint256 public nftCount = 0;
| uint256 public nftCount = 0;
| 8,479 |
37 | // Bid in an active auction. _auctionId The ID of the auction to bid in._bidAmount The bid amount in the currency specified by the auction. / | function bidInAuction(uint256 _auctionId, uint256 _bidAmount) external payable;
| function bidInAuction(uint256 _auctionId, uint256 _bidAmount) external payable;
| 26,778 |
44 | // Import and refactor of Synthetix StakingRewarder/Calculates and pays out rewards/bitbeckers/MVP release/ @custom:source This is an experimental contract. @custom:source https:github.com/Synthetixio/synthetix/blob/develop/contracts/StakingRewards.sol | contract Rewarder is ReentrancyGuard, Pausable, IRewarder, AccessControl {
bytes32 public constant CONFIG_ROLE = keccak256("CONFIG_ROLE");
bytes32 public constant REWARD_MINTER_ROLE = keccak256("REWARD_MINTER_ROLE");
using Counters for Counters.Counter;
using SafeMath for uint256;
using SafeERC20 f... | contract Rewarder is ReentrancyGuard, Pausable, IRewarder, AccessControl {
bytes32 public constant CONFIG_ROLE = keccak256("CONFIG_ROLE");
bytes32 public constant REWARD_MINTER_ROLE = keccak256("REWARD_MINTER_ROLE");
using Counters for Counters.Counter;
using SafeMath for uint256;
using SafeERC20 f... | 22,525 |
424 | // Oracle which gives the price of any given asset / | PriceOracle public oracle;
| PriceOracle public oracle;
| 7,598 |
3,794 | // 1899 | entry "neurocomputationally" : ENG_ADVERB
| entry "neurocomputationally" : ENG_ADVERB
| 22,735 |
124 | // Update dev address by the previous dev. | function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
| function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
| 6,097 |
143 | // function when someone gambles a.k.a sends ether to the contract | function buy() whenNotPaused payable public{
// No arguments are necessary, all
// information is already part of
// the transaction. The keyword payable
// is required for the function to
// be able to receive Ether.
// If the bet is not equal to the ante + the ... | function buy() whenNotPaused payable public{
// No arguments are necessary, all
// information is already part of
// the transaction. The keyword payable
// is required for the function to
// be able to receive Ether.
// If the bet is not equal to the ante + the ... | 51,840 |
27 | // Event fired each time an oracle submits a response | event FlightStatusInfo(
address airline,
string flight,
uint256 timestamp,
uint8 status
);
event OracleReport(
address airline,
string flight,
| event FlightStatusInfo(
address airline,
string flight,
uint256 timestamp,
uint8 status
);
event OracleReport(
address airline,
string flight,
| 308 |
0 | // restrict functions to just owner address | modifier onlyOwner {
AppStorage storage app = VotingPowerStorage.appStorage();
require(msg.sender == app.owner, "only owner");
_;
}
| modifier onlyOwner {
AppStorage storage app = VotingPowerStorage.appStorage();
require(msg.sender == app.owner, "only owner");
_;
}
| 8,495 |
62 | // | * function increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool success) {
* return super.increaseAllowance(spender, addedValue);
* }
| * function increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool success) {
* return super.increaseAllowance(spender, addedValue);
* }
| 24,288 |
30 | // Send this function the petIds of 6 of your Wild Hard (3 star pets) to receive 1 four star pet. | 45,973 | ||
0 | // Your subscription ID. | uint64 s_subscriptionId;
| uint64 s_subscriptionId;
| 19,710 |
13 | // Returns number of confirmations of a transaction./transactionId Transaction ID./ return Number of confirmations. | function getConfirmationCount(uint transactionId)
public
constant
delegated
returns (uint)
| function getConfirmationCount(uint transactionId)
public
constant
delegated
returns (uint)
| 31,788 |
197 | // import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { AddressArrayUtils } from "contracts/lib/AddressArrayUtils.sol"; import { ExplicitERC20 } from "contracts/lib/ExplicitERC20.sol"; import { IController } from "contracts/interfaces/IController.sol"; import { IModule } from "contracts/int... | using AddressArrayUtils for address[];
using Invoke for ISetToken;
using Position for ISetToken;
using PreciseUnitMath for uint256;
using ResourceIdentifier for IController;
using SafeCast for int256;
using SafeCast for uint256;
using SafeMath for uint256;
using SignedSafeMath for in... | using AddressArrayUtils for address[];
using Invoke for ISetToken;
using Position for ISetToken;
using PreciseUnitMath for uint256;
using ResourceIdentifier for IController;
using SafeCast for int256;
using SafeCast for uint256;
using SafeMath for uint256;
using SignedSafeMath for in... | 6,386 |
15 | // / | constructor(
uint256 tradeFee_,
address factory_,
address sushiRouter_
| constructor(
uint256 tradeFee_,
address factory_,
address sushiRouter_
| 1,967 |
16 | // 10% fees are for dev/dao/projects | token.mint(msg.sender, _reward);
emit Mined(nftId, _reward, msg.sender);
| token.mint(msg.sender, _reward);
emit Mined(nftId, _reward, msg.sender);
| 60,454 |
169 | // Minting costs | function setMintRate(uint256 _mintRate) public onlyOwner {
mintRate = _mintRate;
}
| function setMintRate(uint256 _mintRate) public onlyOwner {
mintRate = _mintRate;
}
| 24,183 |
38 | // leftTakerAssetAmountRemaining == rightMakerAssetAmountRemaining Case 3: Both orders are fully filled. Technically, this could be captured by the above cases, but this calculation will be more precise since it does not include rounding. | matchedFillResults = _calculateCompleteFillBoth(
leftMakerAssetAmountRemaining,
leftTakerAssetAmountRemaining,
rightMakerAssetAmountRemaining,
rightTakerAssetAmountRemaining
);
| matchedFillResults = _calculateCompleteFillBoth(
leftMakerAssetAmountRemaining,
leftTakerAssetAmountRemaining,
rightMakerAssetAmountRemaining,
rightTakerAssetAmountRemaining
);
| 47,941 |
21 | // function onERC721Received( address operator,address from,uint256 tokenId, | // bytes calldata data) external view override returns (bytes4) {
// require(address(whitelistedNftContract) == _msgSender());
// return IERC721Receiver.onERC721Received.selector;
// }
| // bytes calldata data) external view override returns (bytes4) {
// require(address(whitelistedNftContract) == _msgSender());
// return IERC721Receiver.onERC721Received.selector;
// }
| 7,956 |
113 | // Withdraw all assets from strategy sending assets to Vault. / | function withdrawAll() external;
| function withdrawAll() external;
| 5,694 |
56 | // src/IStakingRewards.sol/ pragma solidity 0.8.9; / | interface IStakingRewards {
// Views
function balanceOf(address account) external view returns (uint);
function earned(address account) external view returns (uint);
function getRewardForDuration() external view returns (uint);
function lastTimeRewardApplicable() external view returns (uint);
... | interface IStakingRewards {
// Views
function balanceOf(address account) external view returns (uint);
function earned(address account) external view returns (uint);
function getRewardForDuration() external view returns (uint);
function lastTimeRewardApplicable() external view returns (uint);
... | 27,207 |
130 | // Function to stop minting new tokens. return True if the operation was successful./ | function finishMinting() public onlyOwner canMint returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
| function finishMinting() public onlyOwner canMint returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
| 3,296 |
1 | // Check if the caller is the proxy admin. / | modifier onlyProxyAdmin(IGraphProxy _proxy) {
require(msg.sender == _proxy.admin(), "Caller must be the proxy admin");
_;
}
| modifier onlyProxyAdmin(IGraphProxy _proxy) {
require(msg.sender == _proxy.admin(), "Caller must be the proxy admin");
_;
}
| 1,553 |
184 | // Set setEulersFused. Can only be called by the owner. | function setEulersFused(uint256 _newEulersFused) public onlyOwner {
eulersFused = _newEulersFused;
}
| function setEulersFused(uint256 _newEulersFused) public onlyOwner {
eulersFused = _newEulersFused;
}
| 38,743 |
160 | // Get the current valid order for the asset or fail | Order memory order = _getValidOrder(_nftAddress, _assetId);
| Order memory order = _getValidOrder(_nftAddress, _assetId);
| 17,205 |
6 | // TODO: Create all Auctions through here. Right now we do it manually. This will be smoother. It will give us control over id's too (see next lineTODO: make Token IDS to be unique. By sha3 hash. so they can be stored in the graph. right now we just hardcode 1234 as the ID in migrations | function newAuction(uint256 id, string name) public{
// address newContract =
new Auction(msg.sender, id, name, this);
// acc = newContract;
}
| function newAuction(uint256 id, string name) public{
// address newContract =
new Auction(msg.sender, id, name, this);
// acc = newContract;
}
| 514 |
71 | // Position Manager cannot be zero. | error PositionManagerCannotBeZero();
| error PositionManagerCannotBeZero();
| 9,502 |
47 | // Interface for auction contract | bytes4 private constant InterfaceSignature_MarsGenesisAuction =
bytes4(keccak256('landIdIsForSale(uint256 tokenId)')) ^
bytes4(keccak256('landNoLongerForSale(uint256)'));
Counters.Counter private _promoTokenIdTracker;
Counters.Counter private _tokenIdTracker;
| bytes4 private constant InterfaceSignature_MarsGenesisAuction =
bytes4(keccak256('landIdIsForSale(uint256 tokenId)')) ^
bytes4(keccak256('landNoLongerForSale(uint256)'));
Counters.Counter private _promoTokenIdTracker;
Counters.Counter private _tokenIdTracker;
| 53,395 |
12 | // A modifier that defines a protected initializer function that can be invoked at most once. In its scope,`onlyInitializing` functions can be used to initialize parent contracts. Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of aconstructor. | * Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) ||
(!Address.isContract(address(this)) && _initialized == 1),
'Initializable: contract is already initialized'
);
_initialized = 1;
... | * Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) ||
(!Address.isContract(address(this)) && _initialized == 1),
'Initializable: contract is already initialized'
);
_initialized = 1;
... | 25,489 |
67 | // /uint256 t = self.endWithdrawalTime - self.startTime;uint256 s = now - self.startTime;uint256 pa = self.pricePurchasedAt[msg.sender];uint256 pu = self.tokensPerEth;uint256 multiplierPercent =(100(t - s))/t;self.pricePurchasedAt = pa-((pa-pu)/3) | uint256 timeLeft;
timeLeft = self.endWithdrawalTime.sub(now);
uint256 multiplierPercent = (timeLeft.mul(100)) / (self.endWithdrawalTime.sub(self.startTime));
refundWei = (multiplierPercent.mul(self.hasContributed[msg.sender])) / 100;
self.valuationSums[self.personalCaps[msg.sender]] = se... | uint256 timeLeft;
timeLeft = self.endWithdrawalTime.sub(now);
uint256 multiplierPercent = (timeLeft.mul(100)) / (self.endWithdrawalTime.sub(self.startTime));
refundWei = (multiplierPercent.mul(self.hasContributed[msg.sender])) / 100;
self.valuationSums[self.personalCaps[msg.sender]] = se... | 65,261 |
51 | // Emitted when an offer is cancelled. | event CancelledOffer(address indexed offeror, uint256 indexed offerId);
| event CancelledOffer(address indexed offeror, uint256 indexed offerId);
| 27,265 |
0 | // Constructor / | constructor(address _admins)
Fees(_admins)
public
| constructor(address _admins)
Fees(_admins)
public
| 31,418 |
9 | // token is relisted on Fractional with an initial reserve price equal to 2x the price of the token | uint8 internal constant RESALE_MULTIPLIER = 2;
| uint8 internal constant RESALE_MULTIPLIER = 2;
| 38,243 |
10 | // Access modifier for CEO-only or CFO-only functionality | modifier onlyCeoOrCfo() {
require(
msg.sender != address(0) &&
(
msg.sender == ceoAddress ||
msg.sender == cfoAddress
),
"only CEO or CFO is allowed to perform this operation"
);
_;
}
| modifier onlyCeoOrCfo() {
require(
msg.sender != address(0) &&
(
msg.sender == ceoAddress ||
msg.sender == cfoAddress
),
"only CEO or CFO is allowed to perform this operation"
);
_;
}
| 20,927 |
31 | // The amount to deposit for registration or extension/ Note: the price moves quickly depending on what other addresses do./ The current price might change after you send a `deposit()` transaction/ before the transaction is executed. | function currentPrice() public view returns (uint256) {
require(now >= set_price_at, "An underflow in price computation");
uint256 seconds_passed = now - set_price_at;
return decayedPrice(set_price, seconds_passed);
}
| function currentPrice() public view returns (uint256) {
require(now >= set_price_at, "An underflow in price computation");
uint256 seconds_passed = now - set_price_at;
return decayedPrice(set_price, seconds_passed);
}
| 78,731 |
50 | // returns amount of users by address to ever stake via the contract | function getUserCount()
public
view
returns(uint)
| function getUserCount()
public
view
returns(uint)
| 32,425 |
165 | // Gets the initial ETH balance, so swap won't touch any staked ETH | uint256 initialETHBalance = address(this).balance;
_swapTokenForETH(swapToken);
uint256 newETH=(address(this).balance - initialETHBalance);
| uint256 initialETHBalance = address(this).balance;
_swapTokenForETH(swapToken);
uint256 newETH=(address(this).balance - initialETHBalance);
| 40,316 |
94 | // DEDUCT FROM SENDER, CREDIT BENEFICIARY | balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
| balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
| 47,440 |
197 | // Gets some minimal info of a previously submitted block that's kept onchain./A DEX can use this function to implement a payment receipt verification/contract with a challange-response scheme./blockIdx The block index. | function getBlockInfo(uint blockIdx)
external
virtual
view
returns (ExchangeData.BlockInfo memory);
| function getBlockInfo(uint blockIdx)
external
virtual
view
returns (ExchangeData.BlockInfo memory);
| 31,492 |
60 | // total remaining payout is decreased | totalRemainingPayout -= info.payout;
| totalRemainingPayout -= info.payout;
| 7,105 |
6 | // Updates data / | function update(address assetToken) external override {
/*
* Reads data from oracle
*/
(,int price,,uint256 latestUpdate,) = _priceFeeds[assetToken].latestRoundData();
/*
* Updates price
*/
price *= 1e10;
_prices[assetToken] = uint256(price)... | function update(address assetToken) external override {
/*
* Reads data from oracle
*/
(,int price,,uint256 latestUpdate,) = _priceFeeds[assetToken].latestRoundData();
/*
* Updates price
*/
price *= 1e10;
_prices[assetToken] = uint256(price)... | 2,840 |
13 | // Library for converting numbers into strings and other string operations./Solady (https:github.com/vectorized/solady/blob/main/src/utils/LibString.sol)/Modified from Solmate (https:github.com/transmissions11/solmate/blob/main/src/utils/LibString.sol) | library LibString {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The `length` of the output is too small to contain all the hex digits.
erro... | library LibString {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The `length` of the output is too small to contain all the hex digits.
erro... | 17,998 |
17 | // We use < for ownerIndexEnd and tokenBalanceOwner because tokenOfOwnerByIndex is 0-indexed while the token balance is 1-indexed | require(ownerIndexStart >= 0 && ownerIndexEnd < tokenBalanceOwner, "INDEX_OUT_OF_RANGE");
| require(ownerIndexStart >= 0 && ownerIndexEnd < tokenBalanceOwner, "INDEX_OUT_OF_RANGE");
| 67,617 |
234 | // Transfer the investment asset to the fund. Does not follow the checks-effects-interactions pattern, but it is preferred to have the final state of the VaultProxy prior to running __postBuySharesHook(). | ERC20(_denominationAsset).safeTransferFrom(msg.sender, _vaultProxy, _investmentAmount);
| ERC20(_denominationAsset).safeTransferFrom(msg.sender, _vaultProxy, _investmentAmount);
| 18,579 |
15 | // Set token IDs for lootbox classes | _setTokenIdsForClass(_option, 0, _commonItems);
_setTokenIdsForClass(_option, 1, _rareItems);
_setTokenIdsForClass(_option, 2, _epicItems);
| _setTokenIdsForClass(_option, 0, _commonItems);
_setTokenIdsForClass(_option, 1, _rareItems);
_setTokenIdsForClass(_option, 2, _epicItems);
| 39,823 |
45 | // Ensures networkWeight is set by the end of the Referendum stage, even if 0 votes are cast. | proposal.networkWeight = getLockedGold().getTotalLockedGold();
emit ProposalApproved(proposalId);
return true;
| proposal.networkWeight = getLockedGold().getTotalLockedGold();
emit ProposalApproved(proposalId);
return true;
| 24,142 |
210 | // Calculate tax and after-tax amount | uint256 taxRate = calculateTax();
uint256 taxedAmount = amount.mul(taxRate).div(100);
uint256 stakedAmount = amount.sub(taxedAmount);
| uint256 taxRate = calculateTax();
uint256 taxedAmount = amount.mul(taxRate).div(100);
uint256 stakedAmount = amount.sub(taxedAmount);
| 18,556 |
5 | // Sets {REDEEM_ADDRESS_USER} attribute for redeemAddress as `_account`. Sets {USER_REDEEM_ADDRESS} attribute for `_account` as redeemAddress. Emits a {RegisterNewUser} event. Requirements: - `_account` should not be a registered as user.- number of redeem address should not be greater than max availables. / | function registerNewUser(address _account, string calldata _id)
public
onlyOwner
{
require(!_isUser(_account), "user exist");
require(usersById[_id] == address(0), "id already taken");
redemptionAddressCount++;
require(
REDEMPTION_ADDRESS_COUNT > rede... | function registerNewUser(address _account, string calldata _id)
public
onlyOwner
{
require(!_isUser(_account), "user exist");
require(usersById[_id] == address(0), "id already taken");
redemptionAddressCount++;
require(
REDEMPTION_ADDRESS_COUNT > rede... | 35,885 |
39 | // Checks whether royalty info can be set in the given execution context. | function _canSetRoyaltyInfo() internal view override returns (bool) {
return hasRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
| function _canSetRoyaltyInfo() internal view override returns (bool) {
return hasRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
| 15,734 |
59 | // Adds two `Signed`s, reverting on overflow. a a FixedPoint.Signed. b a FixedPoint.Signed.return the sum of `a` and `b`. / | function add(Signed memory a, Signed memory b) internal pure returns (Signed memory) {
return Signed(a.rawValue.add(b.rawValue));
}
| function add(Signed memory a, Signed memory b) internal pure returns (Signed memory) {
return Signed(a.rawValue.add(b.rawValue));
}
| 1,158 |
480 | // `tokenId` が発行されていれば true を返します. / | function exists(uint256 tokenId) external view virtual returns (bool) {
return _exists(tokenId);
}
| function exists(uint256 tokenId) external view virtual returns (bool) {
return _exists(tokenId);
}
| 31,984 |
63 | // Token Issuance // Know if new tokens can be issued in the future.return bool 'true' if tokens can still be issued by the issuer, 'false' if they can't anymore. / | function isIssuable() external view override returns (bool) {
return _isIssuable;
}
| function isIssuable() external view override returns (bool) {
return _isIssuable;
}
| 37,105 |
5 | // ! lk.sol | (c) 2019 Develop by BelovITLab LLC (smartcontract.ru), author @stupidlovejoy | License: MIT / | library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if(a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
... | library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if(a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
... | 10,592 |
4 | // buy resource using `ETH` with exact resource amount,/ resource must be valuate by `WETH`./resource resource contract address./prePath pre path for exchange resource./ for exampleif prePath is [`tokenA`, `tokenB`, `tokenC`],/ make sure [`tokenA`, `tokenB`, `tokenC` `resource.token()`] is existing in `IUniswapV2Router... | function buyExactTokenValuatedResourceByETH(
IResource resource,
address[] memory prePath,
uint256 amountOut,
uint256 deadline,
bytes memory data
) external payable returns (uint256 value);
| function buyExactTokenValuatedResourceByETH(
IResource resource,
address[] memory prePath,
uint256 amountOut,
uint256 deadline,
bytes memory data
) external payable returns (uint256 value);
| 40,307 |
52 | // gets the SPT emission rate for a node - nodes are locked into the emission rate that was active at the time of registration | function nodeEmissionRate(uint256 regTime) public view override returns (uint256) {
uint256 band1 = EMISSION_START + (SECONDS_IN_A_YEAR * 1);
if(regTime <= band1) {
return EMISSION_PER_DAY_YEARS[0];
}
uint256 band2 = EMISSION_START + (SECONDS_IN_A_YEAR * 2);
if(re... | function nodeEmissionRate(uint256 regTime) public view override returns (uint256) {
uint256 band1 = EMISSION_START + (SECONDS_IN_A_YEAR * 1);
if(regTime <= band1) {
return EMISSION_PER_DAY_YEARS[0];
}
uint256 band2 = EMISSION_START + (SECONDS_IN_A_YEAR * 2);
if(re... | 39,442 |
16 | // Finally, we are writing the faucet contract.We can see that DaiFaucet inherits the mortal contract, which in turn inherits the owned contract.This way, we have modularised our contracts for their specific functions and added our totalcontrol over it. Inside the contract we have two events that will watch and log eve... | contract DaiFaucet is mortal {
event Withdrawal(address indexed to, uint amount);
event Deposit(address indexed from, uint amount);
// We have added the withdraw function that will take care to send Dai to anyone who calls this function.
// As you can see, we have added 2 conditions for the withdrawa... | contract DaiFaucet is mortal {
event Withdrawal(address indexed to, uint amount);
event Deposit(address indexed from, uint amount);
// We have added the withdraw function that will take care to send Dai to anyone who calls this function.
// As you can see, we have added 2 conditions for the withdrawa... | 50,626 |
135 | // Safe yfin transfer function, just in case if rounding error causes pool to not have enough YFINs. | function safeYfinTransfer(address _to, uint256 _amount) internal {
uint256 yfinBal = yfin.balanceOf(address(this));
if (_amount > yfinBal) {
yfin.transfer(_to, yfinBal);
} else {
yfin.transfer(_to, _amount);
}
}
| function safeYfinTransfer(address _to, uint256 _amount) internal {
uint256 yfinBal = yfin.balanceOf(address(this));
if (_amount > yfinBal) {
yfin.transfer(_to, yfinBal);
} else {
yfin.transfer(_to, _amount);
}
}
| 84,843 |
13 | // MINT |
uint256 x = random(50, 420, supply); //starting x/y position
uint256 y = random(500, 920, supply);
uint256 leafs = random(1, 25, supply);
uint256 background = random(0, backgroungColors.length - 1, supply);
infos[supply] = Character(
block.number,
msg.sen... |
uint256 x = random(50, 420, supply); //starting x/y position
uint256 y = random(500, 920, supply);
uint256 leafs = random(1, 25, supply);
uint256 background = random(0, backgroungColors.length - 1, supply);
infos[supply] = Character(
block.number,
msg.sen... | 22,081 |
142 | // Used to have strongly-typed access to internal mutative functions in dTrade | interface IdTradeInternal {
function emitExchangeTracking(
bytes32 trackingCode,
bytes32 toCurrencyKey,
uint256 toAmount
) external;
function emitSynthExchange(
address account,
bytes32 fromCurrencyKey,
uint256 fromAmount,
bytes32 toCurrencyKey,
... | interface IdTradeInternal {
function emitExchangeTracking(
bytes32 trackingCode,
bytes32 toCurrencyKey,
uint256 toAmount
) external;
function emitSynthExchange(
address account,
bytes32 fromCurrencyKey,
uint256 fromAmount,
bytes32 toCurrencyKey,
... | 13,446 |
58 | // Register new liquidity added to the future _amount the liquidity amount added must be called from the future contract / | function registerNewFutureLiquidity(uint256 _amount) external;
| function registerNewFutureLiquidity(uint256 _amount) external;
| 52,509 |
34 | // Claimable Protocol Smart contract allow recipients to claim ERC20 tokens according to an initial cliff and a vesting period Formual: - claimable at cliff: (cliff / vesting)amount - claimable at time t after cliff (t0 = start time) (t - t0) / vestingamount - multiple claims, last claim at t1, claim at t: (t - t1) / v... | contract Claimable is Context {
using SafeMath for uint256;
/// @notice unique claim ticket id, auto-increment
uint256 public currentId;
/// @notice claim ticket
/// @dev payable is not needed for ERC20, need more work to support Ether
struct Ticket {
address token; // ERC20 token addres... | contract Claimable is Context {
using SafeMath for uint256;
/// @notice unique claim ticket id, auto-increment
uint256 public currentId;
/// @notice claim ticket
/// @dev payable is not needed for ERC20, need more work to support Ether
struct Ticket {
address token; // ERC20 token addres... | 12,476 |
180 | // Void disputable action `_disputableActionId`This hook must be implemented by Disputable apps. We provide a base implementation to ensure that the `onlyAgreement` modifieris included. Subclasses should implement the internal implementation of the hook._disputableActionId Identifier of the action to be voided/ | function onDisputableActionVoided(uint256 _disputableActionId) external onlyAgreement {
_onDisputableActionVoided(_disputableActionId);
}
| function onDisputableActionVoided(uint256 _disputableActionId) external onlyAgreement {
_onDisputableActionVoided(_disputableActionId);
}
| 58,176 |
37 | // global pending rewards counter | pendingRewards = pendingRewards.add(amount);
| pendingRewards = pendingRewards.add(amount);
| 20,246 |
48 | // remove players from match | function removeFromMatch(uint256 matchId, address[] memory players)
public
virtual
override
onlyRole(DEFAULT_ADMIN_ROLE)
| function removeFromMatch(uint256 matchId, address[] memory players)
public
virtual
override
onlyRole(DEFAULT_ADMIN_ROLE)
| 3,450 |
9 | // Add to whitelist by updating the Merkle tree rootrootCaller must be contract owner / | function updateRoot(bytes32 _root) external onlyRole(DEFAULT_ADMIN_ROLE) {
root = _root;
}
| function updateRoot(bytes32 _root) external onlyRole(DEFAULT_ADMIN_ROLE) {
root = _root;
}
| 36,276 |
200 | // Get number of transaction roots | let transactionRootsLength := selectTransactionRootsLength(blockHeader)
| let transactionRootsLength := selectTransactionRootsLength(blockHeader)
| 21,527 |
20 | // at the end, we increment the stakes of the team selected with the player bet | if (player == 1) {
totalBetOne += msg.value;
} else {
| if (player == 1) {
totalBetOne += msg.value;
} else {
| 10,302 |
4 | // Set Methods / | function setAddress(bytes32 key, address value) public {
_addressStorage[msg.sender][key] = value;
}
| function setAddress(bytes32 key, address value) public {
_addressStorage[msg.sender][key] = value;
}
| 49,632 |
193 | // Snapshots are created by the internal {updateValueAtNow} function.To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with a block number.To get the balance of an account at the time of a snapshot, call the {balanceOfAt} function with a block number Inspired by Jordi Baylina's MiniMe... |
using SafeMath for uint256;
|
using SafeMath for uint256;
| 2,870 |
266 | // If they don't have any debt ownership, they don't have any fees | if (initialDebtOwnership == 0) return result;
| if (initialDebtOwnership == 0) return result;
| 6,043 |
215 | // View function to see pending HYPEs on frontend single token. | function pendingHYPE_single(uint256 _pid, address _user) external view returns (uint256) {
SinglePoolInfo storage pool = poolInfo_single[_pid];
UserInfo storage user = userInfo_single[_pid][_user];
uint256 accHYPEPerShare = pool.accHYPEPerShare;
uint256 sSupply = pool.sToken.balanceO... | function pendingHYPE_single(uint256 _pid, address _user) external view returns (uint256) {
SinglePoolInfo storage pool = poolInfo_single[_pid];
UserInfo storage user = userInfo_single[_pid][_user];
uint256 accHYPEPerShare = pool.accHYPEPerShare;
uint256 sSupply = pool.sToken.balanceO... | 9,143 |
5 | // See {Pausable} and {Pausable-_unpause}. Requirements: - the caller must have the `PAUSER_ROLE`. / | function unpause() public onlyRole(PAUSER_ROLE) {
_unpause();
}
| function unpause() public onlyRole(PAUSER_ROLE) {
_unpause();
}
| 34,702 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.