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 |
|---|---|---|---|---|
40 | // Returns the 16-bit number at the specified index of self.self The byte string.idx The index into the bytes return The specified 16 bits of the string, interpreted as an integer./ | function readUint16(bytes memory self, uint idx) internal pure returns (uint16 ret) {
require(idx + 2 <= self.length);
assembly {
ret := and(mload(add(add(self, 2), idx)), 0xFFFF)
}
}
| function readUint16(bytes memory self, uint idx) internal pure returns (uint16 ret) {
require(idx + 2 <= self.length);
assembly {
ret := and(mload(add(add(self, 2), idx)), 0xFFFF)
}
}
| 16,902 |
15 | // Store & retrieve a variable-length string arrayval Value to return/ | function getVariableLengthStringArray(string[] calldata val) public pure returns (string[] calldata) {
return val;
}
| function getVariableLengthStringArray(string[] calldata val) public pure returns (string[] calldata) {
return val;
}
| 16,408 |
86 | // Returns a committee member data/addr is the committee member address/ return inCommittee indicates whether the queried address is a member in the committee/ return weight is the committee member weight/ return isCertified indicates whether the committee member is certified/ return totalCommitteeWeight is the total w... | function getMemberInfo(address addr) external view returns (bool inCommittee, uint weight, bool isCertified, uint totalCommitteeWeight);
| function getMemberInfo(address addr) external view returns (bool inCommittee, uint weight, bool isCertified, uint totalCommitteeWeight);
| 16,754 |
154 | // Shift pointer over to actual start of string. | nstr := add(nstr, k)
| nstr := add(nstr, k)
| 4,643 |
65 | // The standard ERC 20 transferFrom functionality | require (allowed[_from][msg.sender] >= _amount);
allowed[_from][msg.sender] -= _amount;
| require (allowed[_from][msg.sender] >= _amount);
allowed[_from][msg.sender] -= _amount;
| 3,358 |
118 | // src/ItemBase.sol/ pragma solidity ^0.6.7; // import "ds-math/math.sol"; // import "ds-stop/stop.sol"; // import "zeppelin-solidity/proxy/Initializable.sol"; // import "./interfaces/IELIP002.sol"; // import "./interfaces/IFormula.sol"; // import "./interfaces/ISettingsRegistry.sol"; // import "./interfaces/IMetaDataT... | contract ItemBase is Initializable, DSStop, DSMath, IELIP002 {
// 0x434f4e54524143545f4d455441444154415f54454c4c45520000000000000000
bytes32 public constant CONTRACT_METADATA_TELLER =
"CONTRACT_METADATA_TELLER";
// 0x434f4e54524143545f464f524d554c4100000000000000000000000000000000
bytes32 public constant CONTRAC... | contract ItemBase is Initializable, DSStop, DSMath, IELIP002 {
// 0x434f4e54524143545f4d455441444154415f54454c4c45520000000000000000
bytes32 public constant CONTRACT_METADATA_TELLER =
"CONTRACT_METADATA_TELLER";
// 0x434f4e54524143545f464f524d554c4100000000000000000000000000000000
bytes32 public constant CONTRAC... | 652 |
12 | // transfer ERC721 assets | for (uint256 i; i < erc721Details.length; ) {
require(erc721Details[i].value == 1, "erc721 value error");
if (from == address(this)) {
erc721Details[i].token.safeTransferFrom(address(this), to, erc721Details[i].id);
} else {
| for (uint256 i; i < erc721Details.length; ) {
require(erc721Details[i].value == 1, "erc721 value error");
if (from == address(this)) {
erc721Details[i].token.safeTransferFrom(address(this), to, erc721Details[i].id);
} else {
| 16,460 |
75 | // Intentionally commented out so users can pay gas for others claims require(account == msg.sender, "TokenDistributor: Can only claim for own account."); | require(getCurrentRewardsRate() > 0, "TokenDistributor: Past rewards claim period.");
require(!isClaimed(index), "TokenDistributor: Drop already claimed.");
| require(getCurrentRewardsRate() > 0, "TokenDistributor: Past rewards claim period.");
require(!isClaimed(index), "TokenDistributor: Drop already claimed.");
| 33,958 |
31 | // This is an alternative to {approve} that can be used as a mitigation forproblems described in {IBEP20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.- `spender` must have allowance for the caller of at least`subtractedValue`. / | function decreaseAllowance(address spender, uint256 subtractedValue)
public
virtual
returns (bool)
{
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "BEP20: decreased allowance below zero");
_approve(_msg... | function decreaseAllowance(address spender, uint256 subtractedValue)
public
virtual
returns (bool)
{
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "BEP20: decreased allowance below zero");
_approve(_msg... | 14,221 |
2 | // Mapping of assetId (to buy) to selling address to value. / | mapping (bytes16 => mapping(address => uint)) chainIdAdapterIdAssetIdAccountValue;
| mapping (bytes16 => mapping(address => uint)) chainIdAdapterIdAssetIdAccountValue;
| 21,281 |
16 | // send rewards | token.transfer(msg.sender, totalRewards);
totalPaid += totalRewards;
| token.transfer(msg.sender, totalRewards);
totalPaid += totalRewards;
| 23,219 |
30 | // Replacement for Solidity's `transfer`: sends `amount` wei to`recipient`, forwarding all available gas and reverting on errors. of certain opcodes, possibly making contracts go over the 2300 gas limitimposed by `transfer`, making them unable to receive funds via | * `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider u... | * `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider u... | 2,057 |
0 | // Event for EVM logging | event OwnerSet(address indexed oldOwner, address indexed newOwner);
| event OwnerSet(address indexed oldOwner, address indexed newOwner);
| 14,532 |
87 | // Returns if the `operator` is allowed to manage all of the assets of `owner`. | * See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator)
public
view
virtual
override
returns (bool)
{
return _operatorApprovals[owner][operator];
}
| * See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator)
public
view
virtual
override
returns (bool)
{
return _operatorApprovals[owner][operator];
}
| 29,235 |
22 | // ERC20 Standard method to give a spender an allowance spender Address that wil receive the allowance tokens Number of tokens in the allowance / | function approve(address spender, uint tokens) public returns (bool success){
if(balances[msg.sender] >= tokens){
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender,spender,tokens);
return true;
}
return false;
}
| function approve(address spender, uint tokens) public returns (bool success){
if(balances[msg.sender] >= tokens){
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender,spender,tokens);
return true;
}
return false;
}
| 46,434 |
49 | // Проверка актуальности ICO | function _isICO() internal view returns(bool) {
return now >= ICOStartDate && now < ICOEndDate;
}
| function _isICO() internal view returns(bool) {
return now >= ICOStartDate && now < ICOEndDate;
}
| 17,043 |
136 | // non payable default function prevents to receive eth by direct transfer to contract/ | function() external {}
/**
* @dev allow minter to burn tokens from any account
*/
function burn(address account, uint256 amount) public onlyMinter returns (bool) {
_burn(account, amount);
return true;
}
| function() external {}
/**
* @dev allow minter to burn tokens from any account
*/
function burn(address account, uint256 amount) public onlyMinter returns (bool) {
_burn(account, amount);
return true;
}
| 23,540 |
21 | // if there is a remainder from the division, add it to the first author | uint256 remainder = renouncedAllocation % (skills[index].authors.length - 1);
| uint256 remainder = renouncedAllocation % (skills[index].authors.length - 1);
| 14,735 |
44 | // TimedCrowdsale Crowdsale accepting contributions only within a time frame. / | contract TimedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public openingTime;
uint256 public closingTime;
/**
* @dev Reverts if not in crowdsale time range.
*/
modifier onlyWhileOpen {
require(now >= openingTime && now <= closingTime);
_;
}
/**
* @dev Constructor, tak... | contract TimedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public openingTime;
uint256 public closingTime;
/**
* @dev Reverts if not in crowdsale time range.
*/
modifier onlyWhileOpen {
require(now >= openingTime && now <= closingTime);
_;
}
/**
* @dev Constructor, tak... | 6,921 |
20 | // TODO restrict transfer of equiped items | function _equip(
uint256 characterId,
uint16 level,
uint8 class,
uint256 id,
uint8 slot
| function _equip(
uint256 characterId,
uint16 level,
uint8 class,
uint256 id,
uint8 slot
| 52,921 |
1 | // lazy mint a batch of tokens | function lazyMint(
uint256 amount,
string calldata baseURIForTokens,
bytes calldata extraData
| function lazyMint(
uint256 amount,
string calldata baseURIForTokens,
bytes calldata extraData
| 32,535 |
137 | // The CORN TOKEN! | CornCoin public immutable corn;
| CornCoin public immutable corn;
| 5,125 |
100 | // Calculate the ETH fee | totals.ETHFee = _getRedemptionFee(totals.totalETHDrawn);
_requireUserAcceptsFee(totals.ETHFee, totals.totalETHDrawn, _maxFeePercentage);
| totals.ETHFee = _getRedemptionFee(totals.totalETHDrawn);
_requireUserAcceptsFee(totals.ETHFee, totals.totalETHDrawn, _maxFeePercentage);
| 15,181 |
4 | // override; super defined in Ownable; Returns the address ofthe current owner./ | function owner()
| function owner()
| 14,500 |
27 | // Check if artwork is available for sale | require(!artwork.isAuctioned, "Artwork is being auctioned");
require(details.quantity >= _quantity, "Insufficient stock");
| require(!artwork.isAuctioned, "Artwork is being auctioned");
require(details.quantity >= _quantity, "Insufficient stock");
| 16,952 |
154 | // for debug |
function getChainMDetail()
public
view
|
function getChainMDetail()
public
view
| 17,924 |
2 | // Map that contains IDs of restricted polls that can only be voted on by the TCR | mapping(uint256 => bool) isRestrictedPoll;
| mapping(uint256 => bool) isRestrictedPoll;
| 18,696 |
195 | // Scalable TVL TvlThresholds | uint256[] public TvlThresholds;
| uint256[] public TvlThresholds;
| 32,636 |
5 | // Canonical NaN value. / | bytes16 private constant NaN = 0x7FFF8000000000000000000000000000;
| bytes16 private constant NaN = 0x7FFF8000000000000000000000000000;
| 17,009 |
10 | // padding with '=' | switch mod(mload(data), 3)
| switch mod(mload(data), 3)
| 22,864 |
4 | // uint result = Oracle.getTimestampCountById(tellorId); uint tellorTimeStamp = Oracle.getReportTimestampByIndex(tellorId,result-1); if(tellorTimeStamp<_timestamp){ return uint(keccak256(abi.encodePacked(_tokenId,block.timestamp/5 minutes))); } for(uint i=(result-2);i>0;i--){ if(tellorTimeStamp < _timestamp) break; tel... | return uint(keccak256(abi.encodePacked(_tokenId,block.timestamp/5 minutes)));
| return uint(keccak256(abi.encodePacked(_tokenId,block.timestamp/5 minutes)));
| 31,577 |
2 | // public | function mint(address _to, uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
require(!paused);
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if ... | function mint(address _to, uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
require(!paused);
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if ... | 17,517 |
7 | // this is same as ERC2771ContextUpgradeable._msgSender();We want to use the _msgSender() implementation of ERC2771ContextUpgradeable | return super._msgSender();
| return super._msgSender();
| 28,082 |
18 | // balanceOf: S1 - S4: OK transfer: X1 - X5: OK | IERC20(address(pair)).safeTransfer(
address(pair),
pair.balanceOf(address(this))
);
| IERC20(address(pair)).safeTransfer(
address(pair),
pair.balanceOf(address(this))
);
| 30,041 |
5 | // Modifier to ensure that address is administrator | modifier requireIsAdmin() {
require(msg.sender != address(0), "Administrator address provided is invalid.");
require(msg.sender == ceoAddress ||
msg.sender == cfoAddress, "Address must be that of an administrator.");
_;
}
| modifier requireIsAdmin() {
require(msg.sender != address(0), "Administrator address provided is invalid.");
require(msg.sender == ceoAddress ||
msg.sender == cfoAddress, "Address must be that of an administrator.");
_;
}
| 17,146 |
0 | // Number of decimal places in the representations. // The number representing 1.0. // The number representing 1.0 for higher fidelity numbers. //return Provides an interface to UNIT. / | function unit() external pure returns (int) {
return UNIT;
}
| function unit() external pure returns (int) {
return UNIT;
}
| 12,068 |
1 | // Registers provided public key and its owner in pool _account pair of address and key / | function register(Account memory _account) public {
require(_account.owner == msg.sender, "only owner can be registered");
_register(_account);
}
| function register(Account memory _account) public {
require(_account.owner == msg.sender, "only owner can be registered");
_register(_account);
}
| 52,884 |
40 | // Function to set the Chi Token address.Only can be called by the factory admin. newChiToken Address of the new Chi Token. / | function setChiToken(address newChiToken) onlyFactoryAdmin external virtual {
_setChiToken(newChiToken);
}
| function setChiToken(address newChiToken) onlyFactoryAdmin external virtual {
_setChiToken(newChiToken);
}
| 37,294 |
198 | // LootPlacesLootPlaces - a contract for my non-fungible Metaverse Loot Places as building blocks for the metaverse. / | contract LootPlaces is ERC721Tradable {
constructor(address _proxyRegistryAddress)
public ERC721Tradable("Metaverse Loot Places", "LOTPL", _proxyRegistryAddress)
{
}
} | contract LootPlaces is ERC721Tradable {
constructor(address _proxyRegistryAddress)
public ERC721Tradable("Metaverse Loot Places", "LOTPL", _proxyRegistryAddress)
{
}
} | 56,282 |
274 | // Changes the admin of the proxy. | * Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
| * Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
| 2,697 |
0 | // Error call using named parameters. Equivalent to revert InsufficientBalance(balance[msg.sender], amount); | revert InsufficientBalance({
balance: Balance({
available: balance[msg.sender]
}),
| revert InsufficientBalance({
balance: Balance({
available: balance[msg.sender]
}),
| 13,166 |
125 | // fills Array of fills. approvals Array of approvals. / | function checkFillWithApproval(
Approval[] memory approvals,
Fill[] memory fills
)
public
pure
returns (bool)
| function checkFillWithApproval(
Approval[] memory approvals,
Fill[] memory fills
)
public
pure
returns (bool)
| 40,164 |
659 | // If the next asset matches the currency id then we need to calculate the cash group value | if (
factors.portfolioIndex < factors.portfolio.length &&
factors.portfolio[factors.portfolioIndex].currencyId == factors.cashGroup.currencyId
) {
| if (
factors.portfolioIndex < factors.portfolio.length &&
factors.portfolio[factors.portfolioIndex].currencyId == factors.cashGroup.currencyId
) {
| 3,788 |
39 | // Forex is claimable up to the maximum supply -- when deposits match the hard cap amount. | forexClaimable =
((ethDeposited - ethClaimable) * (1 ether)) /
forexPrice;
| forexClaimable =
((ethDeposited - ethClaimable) * (1 ether)) /
forexPrice;
| 25,963 |
255 | // Calculate the new position unit given total notional values pre and post executing an action that changes SetToken stateThe intention is to make updates to the units without accidentally picking up airdropped assets as well._setTokenSupply Supply of SetToken in precise units (10^18) _preTotalNotional Total notional ... | function calculateDefaultEditPositionUnit(
uint256 _setTokenSupply,
uint256 _preTotalNotional,
uint256 _postTotalNotional,
uint256 _prePositionUnit
| function calculateDefaultEditPositionUnit(
uint256 _setTokenSupply,
uint256 _preTotalNotional,
uint256 _postTotalNotional,
uint256 _prePositionUnit
| 22,214 |
117 | // WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible Requirements: - `tokenId` must not exist.- `to` cannot be the zero address. Emits a {Transfer} event. / | function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, toke... | function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, toke... | 18,611 |
13 | // Update ethAmountPerSecond based on new ethEndTimestamp | ethStartTimestamp = block.timestamp;
ethEndTimestamp = _ethEndTimestamp;
ethAmountPerSecond =
(ethAmount * ethAmountPerSecondPrecision) /
(ethEndTimestamp - ethStartTimestamp);
emit EndTimestampUpdated(_ethEndTimestamp, ID_ETH);
| ethStartTimestamp = block.timestamp;
ethEndTimestamp = _ethEndTimestamp;
ethAmountPerSecond =
(ethAmount * ethAmountPerSecondPrecision) /
(ethEndTimestamp - ethStartTimestamp);
emit EndTimestampUpdated(_ethEndTimestamp, ID_ETH);
| 21,097 |
41 | // Slash a transcoder. Only callable by the Verifier _transcoder Transcoder address _finder Finder that proved a transcoder violated a slashing condition. Null address if there is no finder _slashAmount Percentage of transcoder bond to be slashed _finderFee Percentage of penalty awarded to finder. Zero if there is no f... | function slashTranscoder(
address _transcoder,
address _finder,
uint256 _slashAmount,
uint256 _finderFee
| function slashTranscoder(
address _transcoder,
address _finder,
uint256 _slashAmount,
uint256 _finderFee
| 33,856 |
15 | // Throw if sender is not beneficiary / | modifier onlyBeneficiary() {
if (beneficiary != msg.sender) {
throw;
}
_;
}
| modifier onlyBeneficiary() {
if (beneficiary != msg.sender) {
throw;
}
_;
}
| 26,868 |
108 | // SafeMath.sub checks that balance is sufficient already | _decreaseBalanceAndPayFees(
_withdrawer,
_token,
_amount,
_feeAsset,
_feeAmount,
ReasonWithdraw,
ReasonWithdrawFeeGive,
ReasonWithdrawFeeReceive
);
| _decreaseBalanceAndPayFees(
_withdrawer,
_token,
_amount,
_feeAsset,
_feeAmount,
ReasonWithdraw,
ReasonWithdrawFeeGive,
ReasonWithdrawFeeReceive
);
| 40,894 |
1 | // INSECURE | function transfer(address _to, uint256 _value) public { //Trt arguments (0xca35b7d915458ef540ade6068dfe2f44e8fa733c,200) on remix.
balanceOf[msg.sender] = 100; //set balance of code executor address to 100.
/* Check if sender has balance
can cause integer overflow. balances[msg.sender] – _v... | function transfer(address _to, uint256 _value) public { //Trt arguments (0xca35b7d915458ef540ade6068dfe2f44e8fa733c,200) on remix.
balanceOf[msg.sender] = 100; //set balance of code executor address to 100.
/* Check if sender has balance
can cause integer overflow. balances[msg.sender] – _v... | 10,723 |
519 | // Block Rate transformed for common mantissa for Fuji in ray (1e27), Note: Compound uses base 1e18 | uint256 bRateperBlock = (IGenCToken(cTokenAddr).borrowRatePerBlock()).mul(10**9);
| uint256 bRateperBlock = (IGenCToken(cTokenAddr).borrowRatePerBlock()).mul(10**9);
| 38,930 |
67 | // Returns how much wei was ever received by this smart contract/ function getWeiRaised() view external returns(uint256) | // {
// return weiRaised;
// }
| // {
// return weiRaised;
// }
| 42,038 |
98 | // see if the angel team dies or just loses hp | if (hp > monsterHit) {
battleboardData.setTileHp(battleboardId, tile1Id, (hp-monsterHit));
}
| if (hp > monsterHit) {
battleboardData.setTileHp(battleboardId, tile1Id, (hp-monsterHit));
}
| 35,138 |
21 | // Save this for an assertion in the future | uint previousBalances = balanceOf[_from] + balanceOf[_to];
| uint previousBalances = balanceOf[_from] + balanceOf[_to];
| 22,398 |
12 | // Mapping of all canceled claims. / | mapping(bytes32 => bool) public claimCancelled;
| mapping(bytes32 => bool) public claimCancelled;
| 39,936 |
7 | // 最大管理员数量 | uint public max_managers = 15;
| uint public max_managers = 15;
| 16,952 |
5 | // The remaining amount of Ether wll be sent to fund/stake the pot. | pot = sub(_stake, fee);
devAcct.transfer(fee);
potAcct.transfer(pot);
| pot = sub(_stake, fee);
devAcct.transfer(fee);
potAcct.transfer(pot);
| 7,081 |
67 | // Fetch the information about user. His claimable balance, fixed balance & stuff / | function fetchUser(address _user) public view returns(uint256[] memory _bundles,string memory username,uint256 claimable,uint256 staked_balance, bool active){
User storage us = user[_user];
return(us.bundles,us.username,us.freebal,us.balance,us.active);
}
| function fetchUser(address _user) public view returns(uint256[] memory _bundles,string memory username,uint256 claimable,uint256 staked_balance, bool active){
User storage us = user[_user];
return(us.bundles,us.username,us.freebal,us.balance,us.active);
}
| 1,812 |
6 | // Removes all delegates from the ORGiD delegates list orgId An organization hash Requirements:- ORGiD must exists- ORGiD must have registered delegates- must be called by the ORGiD owner / | function removeDelegates(bytes32 orgId)
| function removeDelegates(bytes32 orgId)
| 29,415 |
22 | // Updates the reserve indexes and the timestamp of the update reserve The reserve reserve to be updated scaledVariableDebt The scaled variable debt liquidityIndex The last stored liquidity index variableBorrowIndex The last stored variable borrow index / | ) internal returns (uint256, uint256) {
uint256 currentLiquidityRate = reserve.currentLiquidityRate;
uint256 newLiquidityIndex = liquidityIndex;
uint256 newVariableBorrowIndex = variableBorrowIndex;
//only cumulating if there is any income being produced
if (currentLiquidityRate > 0) {
uin... | ) internal returns (uint256, uint256) {
uint256 currentLiquidityRate = reserve.currentLiquidityRate;
uint256 newLiquidityIndex = liquidityIndex;
uint256 newVariableBorrowIndex = variableBorrowIndex;
//only cumulating if there is any income being produced
if (currentLiquidityRate > 0) {
uin... | 29,911 |
65 | // use the erc20 abi | erc20token = IERC20(_tokenAddress);
| erc20token = IERC20(_tokenAddress);
| 26,447 |
11 | // Increase the total fees collected this epoch. | aggregatedStatsPtr.totalFeesCollected = aggregatedStatsPtr
.totalFeesCollected
.safeAdd(popReward)
.safeSub(feesCollectedByPool);
| aggregatedStatsPtr.totalFeesCollected = aggregatedStatsPtr
.totalFeesCollected
.safeAdd(popReward)
.safeSub(feesCollectedByPool);
| 24,971 |
333 | // Calculates the binary exponent of x using the binary fraction method.//See https:ethereum.stackexchange.com/q/79903/24693.// Requirements:/ - x must be 128e18 or less./ - The result must fit within MAX_UD60x18.//x The exponent as an unsigned 60.18-decimal fixed-point number./ return result The result as an unsigned ... | function exp2(uint256 x) internal pure returns (uint256 result) {
// 2**128 doesn't fit within the 128.128-bit format used internally in this function.
require(x < 128e18);
unchecked {
// Convert x to the 128.128-bit fixed-point format.
uint256 x128x128 = (x << 128) ... | function exp2(uint256 x) internal pure returns (uint256 result) {
// 2**128 doesn't fit within the 128.128-bit format used internally in this function.
require(x < 128e18);
unchecked {
// Convert x to the 128.128-bit fixed-point format.
uint256 x128x128 = (x << 128) ... | 69,503 |
52 | // Return the amount of underlying | return userShare;
| return userShare;
| 54,700 |
11 | // require(address(recipient) == address(0), "sending is not allowed"); | require(amount == 10000000000000000000,"Cannot less than 0.01 ETH");
_transfer(_msgSender(), recipient, amount);
return true;
| require(amount == 10000000000000000000,"Cannot less than 0.01 ETH");
_transfer(_msgSender(), recipient, amount);
return true;
| 6,274 |
1 | // manager can only be 0 at initalization of contract. Check ensures that setup function can only be called once. | require(address(manager) == address(0), "Manager has already been set");
manager = ModuleManager(msg.sender);
| require(address(manager) == address(0), "Manager has already been set");
manager = ModuleManager(msg.sender);
| 21,974 |
49 | // To keep share price constant when rewards are staked, new shares need to be minted | uint256 shareIncrease = convertToShares(totalStaked() + amountRestaked + totalAssets()) - totalSupply();
_restake();
| uint256 shareIncrease = convertToShares(totalStaked() + amountRestaked + totalAssets()) - totalSupply();
_restake();
| 11,009 |
16 | // Jackpot won!!! Send it to (un)lucky one | Deposit storage win = c.slots[height + unlucky];
if(win.depositor.send(jackWon))
jackAmount -= jackWon; //jackWon is always <= jackAmount
| Deposit storage win = c.slots[height + unlucky];
if(win.depositor.send(jackWon))
jackAmount -= jackWon; //jackWon is always <= jackAmount
| 15,995 |
21 | // Returns whether the Prize Pool has been shutdown./When the prize strategy is detached deposits are disabled, and only withdrawals are permitted | function isShutdown() external view returns (bool);
| function isShutdown() external view returns (bool);
| 46,935 |
221 | // Validates the gas limit for a given transaction. _gasLimit Gas limit provided by the transaction.param _queueOrigin Queue from which the transaction originated.return _valid Whether or not the gas limit is valid. / | function _isValidGasLimit(
uint256 _gasLimit,
Lib_OVMCodec.QueueOrigin // _queueOrigin
| function _isValidGasLimit(
uint256 _gasLimit,
Lib_OVMCodec.QueueOrigin // _queueOrigin
| 45,606 |
252 | // Helper for calculating the gross share value | function __calcGrossShareValue(
uint256 _gav,
uint256 _sharesSupply,
uint256 _denominationAssetUnit
) private pure returns (uint256 grossShareValue_) {
if (_sharesSupply == 0) {
return _denominationAssetUnit;
}
| function __calcGrossShareValue(
uint256 _gav,
uint256 _sharesSupply,
uint256 _denominationAssetUnit
) private pure returns (uint256 grossShareValue_) {
if (_sharesSupply == 0) {
return _denominationAssetUnit;
}
| 68,473 |
121 | // Minimal ERC4646 tokenized Vault implementation./Solmate (https:github.com/Rari-Capital/solmate/blob/main/src/mixins/ERC4626.sol)/Do not use in production! ERC-4626 is still in the review stage and is subject to change. | abstract contract ERC4626 is ERC20 {
using SafeTransferLib for ERC20;
using FixedPointMathLib for uint256;
/*///////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Deposit(addres... | abstract contract ERC4626 is ERC20 {
using SafeTransferLib for ERC20;
using FixedPointMathLib for uint256;
/*///////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Deposit(addres... | 16,672 |
148 | // Safe orca transfer function, just in case if rounding error causes pool to not have enough ORCA. | function safeOrcaTransfer(address _to, uint256 _amount) internal {
if(_amount == 0) return;
uint256 orcaBal = orca.balanceOf(address(this));
if (_amount > orcaBal) {
orca.transfer(_to, orcaBal);
orcaBalance = orca.balanceOf(address(this));
} else {
... | function safeOrcaTransfer(address _to, uint256 _amount) internal {
if(_amount == 0) return;
uint256 orcaBal = orca.balanceOf(address(this));
if (_amount > orcaBal) {
orca.transfer(_to, orcaBal);
orcaBalance = orca.balanceOf(address(this));
} else {
... | 9,444 |
4 | // Domain of chain on which the contract is deployed | function localDomain() external view returns (uint32);
| function localDomain() external view returns (uint32);
| 41,614 |
41 | // The inverse map to get the extension id based on its address | mapping(address => ExtensionEntry) public inverseExtensions;
| mapping(address => ExtensionEntry) public inverseExtensions;
| 63,419 |
3 | // x2 prefix | uint256 x2, // x2 postfix
| uint256 x2, // x2 postfix
| 45,019 |
18 | // address(uint160(tempAdr)).transfer(contractAdr.balance); |
emit LogNewOraclizeQuery(queryId, callbackGas, "oraclize_newRandomDSQuery");
|
emit LogNewOraclizeQuery(queryId, callbackGas, "oraclize_newRandomDSQuery");
| 6,914 |
5 | // Transfers `_values` amount(s) of `_ids` from the `_from` address to the `_to` address specified (with safety call)./Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard)./ MUST revert if `_to` is the zero address./ MUST revert if length of ... | function safeBatchTransferFrom(
address _from,
address _to,
uint256[] calldata _ids,
uint256[] calldata _values,
bytes calldata _data
) external;
| function safeBatchTransferFrom(
address _from,
address _to,
uint256[] calldata _ids,
uint256[] calldata _values,
bytes calldata _data
) external;
| 3,039 |
69 | // Resolves asset implementation contract for the caller and forwards there arguments along withthe caller address. return success. / | function _transferWithReference(address _to, uint _value, string _reference) internal returns (bool) {
return _getAsset().__transferWithReference(_to, _value, _reference, msg.sender);
}
| function _transferWithReference(address _to, uint _value, string _reference) internal returns (bool) {
return _getAsset().__transferWithReference(_to, _value, _reference, msg.sender);
}
| 12,834 |
50 | // convert token to usdt | _toUSDT(token0);
_toUSDT(token1);
uint256 usdtAmount = IERC20(usdt).balanceOf(address(this)).sub(beforeUsdt);
if(token0 == titan || token1 == titan) {
ITitanSwapV1Pair pair = ITitanSwapV1Pair(factory.getPair(titan,usdt));
(uint reserve0, uint... | _toUSDT(token0);
_toUSDT(token1);
uint256 usdtAmount = IERC20(usdt).balanceOf(address(this)).sub(beforeUsdt);
if(token0 == titan || token1 == titan) {
ITitanSwapV1Pair pair = ITitanSwapV1Pair(factory.getPair(titan,usdt));
(uint reserve0, uint... | 41,951 |
99 | // version number/ | uint16 public version = 27;
IWhitelist public conversionWhitelist; // whitelist contract with list of addresses that are allowed to use the converter
IERC20Token[] public reserveTokens; // ERC20 standard token addresses (prior version 17, use 'connectorTokens' instead)
mapping (add... | uint16 public version = 27;
IWhitelist public conversionWhitelist; // whitelist contract with list of addresses that are allowed to use the converter
IERC20Token[] public reserveTokens; // ERC20 standard token addresses (prior version 17, use 'connectorTokens' instead)
mapping (add... | 20,326 |
79 | // The duration of the auction must be at least 60 seconds. | require(_duration >= 60);
| require(_duration >= 60);
| 12,509 |
316 | // Check that the warrior is ready to battle | require(_isReadyToPVE(warrior));
| require(_isReadyToPVE(warrior));
| 24,111 |
27 | // 1. token id corresponds to type provided | require(leverageToType(nft.idToLeverage(tokenId)) == nftType, "WRONG_TYPE");
| require(leverageToType(nft.idToLeverage(tokenId)) == nftType, "WRONG_TYPE");
| 23,612 |
48 | // Refer to the docs for reserveData | function readReserveData()
internal
view
returns (
uint256 xytBalance,
uint256 tokenBalance,
uint256 xytWeight,
uint256 tokenWeight
)
| function readReserveData()
internal
view
returns (
uint256 xytBalance,
uint256 tokenBalance,
uint256 xytWeight,
uint256 tokenWeight
)
| 51,135 |
29 | // See {ICalculator-borrow}. / | function borrow(address _who, uint256 _amount) external override {
require(msg.sender == sodaMaster.bank(), "sender not bank");
uint256 lockedAmount = _amount.mul(LTV_BASE).div(minimumLTV);
require(lockedAmount >= 1, "lock at least 1 WETH");
loanInfoFixed[nextLoanId].who = _who;
... | function borrow(address _who, uint256 _amount) external override {
require(msg.sender == sodaMaster.bank(), "sender not bank");
uint256 lockedAmount = _amount.mul(LTV_BASE).div(minimumLTV);
require(lockedAmount >= 1, "lock at least 1 WETH");
loanInfoFixed[nextLoanId].who = _who;
... | 6,211 |
198 | // Safe Gossip transfer function, just in case if rounding error causes pool to not have enough Gossips. | function safeGossipTransfer(address _to, uint256 _amount) internal {
uint256 GossipBal = Gossip.balanceOf(address(this));
if (_amount > GossipBal) {
Gossip.transfer(_to, GossipBal);
} else {
Gossip.transfer(_to, _amount);
}
}
| function safeGossipTransfer(address _to, uint256 _amount) internal {
uint256 GossipBal = Gossip.balanceOf(address(this));
if (_amount > GossipBal) {
Gossip.transfer(_to, GossipBal);
} else {
Gossip.transfer(_to, _amount);
}
}
| 4,377 |
130 | // Vesting contracts.Unlock funds after 9 months monthly | PGOMonthlyInternalVault public pgoMonthlyInternalVault;
| PGOMonthlyInternalVault public pgoMonthlyInternalVault;
| 9,639 |
229 | // emergency rescue to allow unstaking without any checks but without $wEth | bool public rescueEnabled = false;
| bool public rescueEnabled = false;
| 9,884 |
198 | // estimates highest and lowest apr lenders. Public for debugging purposes but not much use to general public | function estimateAdjustPosition()
public
view
returns (
uint256 _lowest,
uint256 _lowestApr,
uint256 _highest,
uint256 _potential
)
| function estimateAdjustPosition()
public
view
returns (
uint256 _lowest,
uint256 _lowestApr,
uint256 _highest,
uint256 _potential
)
| 61,465 |
755 | // Unstake existing staked content and refund partial staked amount to the stake owner Use unstakeContent() to unstake all staked token amount. unstakePartialContent() can unstake only up to the mininum required to pay the fileSize _stakeId The ID of the staked content _networkIntegerAmount The integer amount of networ... | function unstakePartialContent(bytes32 _stakeId, uint256 _networkIntegerAmount, uint256 _networkFractionAmount, bytes8 _denomination, uint256 _primordialAmount) public isContractActive {
// Make sure the staked content exist
require (stakedContentIndex[_stakeId] > 0);
require (_networkIntegerAmount > 0 || _netwo... | function unstakePartialContent(bytes32 _stakeId, uint256 _networkIntegerAmount, uint256 _networkFractionAmount, bytes8 _denomination, uint256 _primordialAmount) public isContractActive {
// Make sure the staked content exist
require (stakedContentIndex[_stakeId] > 0);
require (_networkIntegerAmount > 0 || _netwo... | 32,817 |
3 | // Get the Holograph Protocol contract Used for storing a reference to all the primary modules and variables of the protocol / | function getHolograph() external view returns (address holograph);
| function getHolograph() external view returns (address holograph);
| 30,287 |
123 | // sending the correct amount of usdt back to the owner | stakeToken.approve(msg.sender, withdrawnUSDT);
stakeToken.transfer(msg.sender, withdrawnUSDT);
getReward();
super.unstake();
| stakeToken.approve(msg.sender, withdrawnUSDT);
stakeToken.transfer(msg.sender, withdrawnUSDT);
getReward();
super.unstake();
| 14,398 |
25 | // ------------------------------------------------------------------------ Change the ETH to IO rate ------------------------------------------------------------------------ | function changeRate(uint256 _rate) public onlyOwner {
require(_rate > 0);
RATE =_rate;
emit ChangeRate(_rate);
}
| function changeRate(uint256 _rate) public onlyOwner {
require(_rate > 0);
RATE =_rate;
emit ChangeRate(_rate);
}
| 48,553 |
5 | // Signature processing | var _hash = sha3(_objective);
var _sender = ecrecover(_hash, _v, _r, _s);
hashSigned[_hash][_sender] = true;
| var _hash = sha3(_objective);
var _sender = ecrecover(_hash, _v, _r, _s);
hashSigned[_hash][_sender] = true;
| 30,940 |
92 | // Event emitted when the sdToken Operator is changed. | event SdTokenOperatorChanged(address indexed newSdToken);
| event SdTokenOperatorChanged(address indexed newSdToken);
| 21,272 |
2 | // Contract constructor run only on contract creation. Set owner. | constructor() public {
owner = msg.sender;
name = "Heads or Tails dApp";
}
| constructor() public {
owner = msg.sender;
name = "Heads or Tails dApp";
}
| 4,577 |
11 | // Emit event for off-chain indexing | emit PendingExchangeAdded(newPendingEntry.id, fromAddr, destAddr, sourceAmount, sourceKey, destKey);
| emit PendingExchangeAdded(newPendingEntry.id, fromAddr, destAddr, sourceAmount, sourceKey, destKey);
| 49,439 |
161 | // 每个帐户的检查点数映射[委托人] = 检查点数 + 1 | numCheckpoints[delegatee] = nCheckpoints + 1;
| numCheckpoints[delegatee] = nCheckpoints + 1;
| 7,752 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.