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 |
|---|---|---|---|---|
283 | // Mint / | function mint(uint256 _quantity) external payable {
// Normal requirements
require(!paused, "The contract is paused!");
require(
_quantity > 0,
"Minimum 1 NFT has to be minted per transaction"
);
require(_quantity + balanceOf(msg.sender) <= maxTx, "No more!");
require(_quantity + totalSupply() <= totalBored, "Sold out");
if (msg.sender != owner()) {
if (
!(CLAIMED[msg.sender] >= maxFree) &&
FREE_MINTED + maxFree <= rescure
) {
if (_quantity <= maxFree - CLAIMED[msg.sender]) {
require(msg.value >= 0, "Please send the exact amount.");
} else {
require(
msg.value >=
salePrice *
(_quantity - (maxFree - CLAIMED[msg.sender])),
"Please send the exact amount."
);
}
FREE_MINTED += _quantity;
CLAIMED[msg.sender] += _quantity;
} else {
require(
msg.value >= salePrice * _quantity,
"Please send the exact amount."
);
}
}
// Mint
_safeMint(msg.sender, _quantity);
}
| function mint(uint256 _quantity) external payable {
// Normal requirements
require(!paused, "The contract is paused!");
require(
_quantity > 0,
"Minimum 1 NFT has to be minted per transaction"
);
require(_quantity + balanceOf(msg.sender) <= maxTx, "No more!");
require(_quantity + totalSupply() <= totalBored, "Sold out");
if (msg.sender != owner()) {
if (
!(CLAIMED[msg.sender] >= maxFree) &&
FREE_MINTED + maxFree <= rescure
) {
if (_quantity <= maxFree - CLAIMED[msg.sender]) {
require(msg.value >= 0, "Please send the exact amount.");
} else {
require(
msg.value >=
salePrice *
(_quantity - (maxFree - CLAIMED[msg.sender])),
"Please send the exact amount."
);
}
FREE_MINTED += _quantity;
CLAIMED[msg.sender] += _quantity;
} else {
require(
msg.value >= salePrice * _quantity,
"Please send the exact amount."
);
}
}
// Mint
_safeMint(msg.sender, _quantity);
}
| 21,781 |
18 | // Reset Votes | for (uint i = 0; i < participantArray.length; i++) {
forRepurchaseVote[participantArray[i]] = false;
}
| for (uint i = 0; i < participantArray.length; i++) {
forRepurchaseVote[participantArray[i]] = false;
}
| 5,589 |
49 | // to upgrade feeAccount (eg. for fee calculation changes) / | function setFeeAccount(TransferFeeInterface newFeeAccount) external restrict("StabilityBoard") {
feeAccount = newFeeAccount;
emit FeeAccountChanged(newFeeAccount);
}
| function setFeeAccount(TransferFeeInterface newFeeAccount) external restrict("StabilityBoard") {
feeAccount = newFeeAccount;
emit FeeAccountChanged(newFeeAccount);
}
| 32,036 |
13 | // update the total amount raised | amountRaised = amountRaised.add(amount);
| amountRaised = amountRaised.add(amount);
| 33,128 |
488 | // Adds an entry to the underlyingAsset => WHAsset contract. It can be used to set the underlying asset to 0x0 address token Asset address whAsset WHAsset contract for the underlying asset / | function setWHAsset(address token, address whAsset) external onlyOwner {
whAssets[token] = whAsset;
}
| function setWHAsset(address token, address whAsset) external onlyOwner {
whAssets[token] = whAsset;
}
| 38,424 |
26 | // Functions / Using an explicit getter allows for function overloading | function balanceOf(address _addr)
public
view
returns (uint)
| function balanceOf(address _addr)
public
view
returns (uint)
| 53,213 |
199 | // Parses the order, verifies that it is not expired or canceled, and verifies the signature. / | function getOrderAndValidateSignature(
bytes memory data
)
private
view
returns (Order memory)
| function getOrderAndValidateSignature(
bytes memory data
)
private
view
returns (Order memory)
| 10,420 |
211 | // Exits Compound and transfers everything to the vault./ | function withdrawAllToVault() external restricted updateSupplyInTheEnd{
withdrawAll();
IERC20(address(underlying)).safeTransfer(vault, underlying.balanceOf(address(this)));
}
| function withdrawAllToVault() external restricted updateSupplyInTheEnd{
withdrawAll();
IERC20(address(underlying)).safeTransfer(vault, underlying.balanceOf(address(this)));
}
| 53,114 |
114 | // We are exposing these functions to be able to manual swap and send in case the token is highly valued and 5M becomes too much | function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
| function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
| 32,131 |
8 | // withdraws ether in a user balance | function withdraw(uint amount) external returns (uint){
require(amount <= balances[msg.sender], 'insufficient balance');
balances[msg.sender] = balances[msg.sender].sub(amount);
msg.sender.transfer(amount);
emit logWithdraw(msg.sender, amount, balances[msg.sender]);
return balances[msg.sender];
}
| function withdraw(uint amount) external returns (uint){
require(amount <= balances[msg.sender], 'insufficient balance');
balances[msg.sender] = balances[msg.sender].sub(amount);
msg.sender.transfer(amount);
emit logWithdraw(msg.sender, amount, balances[msg.sender]);
return balances[msg.sender];
}
| 26,345 |
2 | // Sets the metaverse administrative consumer, used/ as a consumer when LandWorks NFTs do not have an active rent./_metaverseRegistry The target metaverse registry (token address)/_administrativeConsumer The target administrative consumer | function setAdministrativeConsumerFor(
address _metaverseRegistry,
address _administrativeConsumer
| function setAdministrativeConsumerFor(
address _metaverseRegistry,
address _administrativeConsumer
| 42,759 |
15 | // Get the threshold of an aggregator aggregator addressreturn string Compound Oracle Symbolreturn uint8 Compound Oracle Decimalsreturn uint32 Deviation Threshold Numerator / | function getFeedDetails(address aggregator)
public
view
returns (
string memory,
uint8,
uint32
)
| function getFeedDetails(address aggregator)
public
view
returns (
string memory,
uint8,
uint32
)
| 4,647 |
13 | // Settle the specified orders at a clearing price. Note that it is/ the responsibility of the caller to ensure that all GPv2 invariants are/ upheld for the input settlement, otherwise this call will revert./ Namely:/ - All orders are valid and signed/ - Accounts have sufficient balance and approval./ - Settlement contract has sufficient balance to execute trades. Note/ this implies that the accumulated fees held in the contract can also/ be used for settlement. This is OK since:/ - Solvers need to be authorized/ - Misbehaving solvers will be slashed for abusing accumulated fees for/ settlement/ - Critically, user | function settle(
IERC20[] calldata tokens,
uint256[] calldata clearingPrices,
GPv2Trade.Data[] calldata trades,
GPv2Interaction.Data[][3] calldata interactions
| function settle(
IERC20[] calldata tokens,
uint256[] calldata clearingPrices,
GPv2Trade.Data[] calldata trades,
GPv2Interaction.Data[][3] calldata interactions
| 30,054 |
41 | // Setting OP boss | meta.setBossStats(boss, 0xffffffffffff0000);
vm.expectRevert("not won");
meta.getBossDrop(heroId, boss, itm);
| meta.setBossStats(boss, 0xffffffffffff0000);
vm.expectRevert("not won");
meta.getBossDrop(heroId, boss, itm);
| 3,416 |
226 | // SIP-65: Decentralized Circuit Breaker | if (
_suspendIfRateInvalid(sourceCurrencyKey, sourceRate) ||
_suspendIfRateInvalid(destinationCurrencyKey, destinationRate)
) {
return (0, 0, IVirtualPynth(0));
}
| if (
_suspendIfRateInvalid(sourceCurrencyKey, sourceRate) ||
_suspendIfRateInvalid(destinationCurrencyKey, destinationRate)
) {
return (0, 0, IVirtualPynth(0));
}
| 57,520 |
499 | // they no longer want to vote | else if (_new == 0) {
votingTokens -= weight;
reserveTotal -= weight * old;
}
| else if (_new == 0) {
votingTokens -= weight;
reserveTotal -= weight * old;
}
| 10,230 |
185 | // See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan intomultiple smaller scans if the collection is large enough to causean out-of-gas error (10K pfp collections should be fine). / | function tokensOfOwner(address owner) external view returns (uint256[] memory) {
unchecked {
uint256 tokenIdsIdx;
address currOwnershipAddr;
uint256 tokenIdsLength = balanceOf(owner);
uint256[] memory tokenIds = new uint256[](tokenIdsLength);
TokenOwnership memory ownership;
for (uint256 i = _startTokenId(); tokenIdsIdx <= tokenIdsLength; ++i) {
ownership = _ownerships[i];
if (ownership.burned) {
| function tokensOfOwner(address owner) external view returns (uint256[] memory) {
unchecked {
uint256 tokenIdsIdx;
address currOwnershipAddr;
uint256 tokenIdsLength = balanceOf(owner);
uint256[] memory tokenIds = new uint256[](tokenIdsLength);
TokenOwnership memory ownership;
for (uint256 i = _startTokenId(); tokenIdsIdx <= tokenIdsLength; ++i) {
ownership = _ownerships[i];
if (ownership.burned) {
| 36,256 |
44 | // Put the last token to the transferred token index and update its index in ownerTokensIndexes. | uint lastTokenId = fromTokens[fromTokens.length - 1];
| uint lastTokenId = fromTokens[fromTokens.length - 1];
| 24,010 |
182 | // Update reward weight of the given pool | function updatePoolWeight(uint256 _pid, address _user) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint newWeight = getWeight(user.nksnLength, user.nkcnLength, user.nkcmLength, user.inviteNumber);
if(newWeight != user.weight){
pool.weightedSupply = pool.weightedSupply.add(user.amount.mul(newWeight).div(1e12)).sub(user.amount.mul(user.weight).div(1e12));
}
}
| function updatePoolWeight(uint256 _pid, address _user) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint newWeight = getWeight(user.nksnLength, user.nkcnLength, user.nkcmLength, user.inviteNumber);
if(newWeight != user.weight){
pool.weightedSupply = pool.weightedSupply.add(user.amount.mul(newWeight).div(1e12)).sub(user.amount.mul(user.weight).div(1e12));
}
}
| 22,614 |
268 | // Mappings for the ticketIsuer data storage | mapping(address => TicketIssuerStruct) public allTicketIssuerStructs;
address[] public ticketIssuerAddresses;
| mapping(address => TicketIssuerStruct) public allTicketIssuerStructs;
address[] public ticketIssuerAddresses;
| 20,801 |
21 | // Checks `role` for `account`. Reverts with a message including the required role. | function _checkRole(bytes32 role, address account) internal view virtual {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
if (!data._hasRole[role][account]) {
revert(
string(
abi.encodePacked(
"Permissions: account ",
TWStrings.toHexString(uint160(account), 20),
" is missing role ",
TWStrings.toHexString(uint256(role), 32)
)
)
);
}
}
| function _checkRole(bytes32 role, address account) internal view virtual {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
if (!data._hasRole[role][account]) {
revert(
string(
abi.encodePacked(
"Permissions: account ",
TWStrings.toHexString(uint160(account), 20),
" is missing role ",
TWStrings.toHexString(uint256(role), 32)
)
)
);
}
}
| 4,998 |
116 | // We need to swap the current tokens to ETH and send to the dev wallet | swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHTodev(address(this).balance);
}
| swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHTodev(address(this).balance);
}
| 13,907 |
30 | // Create a new stake tokenAmount If staking in something other than eth, this is the amount of tokens staked, otherwise 0 / | function newStake(uint256 tokenAmount) external payable whenNotPaused {
// Verify that sender is not already a staker
require(!isStaked(msg.sender), "ALREADY_STAKED");
uint256 depositAmount = receiveStakerFunds(tokenAmount);
require(depositAmount >= currentRequiredStake(), "NOT_ENOUGH_STAKE");
createNewStake(msg.sender, depositAmount);
rollupEventBridge.stakeCreated(msg.sender, latestConfirmed());
}
| function newStake(uint256 tokenAmount) external payable whenNotPaused {
// Verify that sender is not already a staker
require(!isStaked(msg.sender), "ALREADY_STAKED");
uint256 depositAmount = receiveStakerFunds(tokenAmount);
require(depositAmount >= currentRequiredStake(), "NOT_ENOUGH_STAKE");
createNewStake(msg.sender, depositAmount);
rollupEventBridge.stakeCreated(msg.sender, latestConfirmed());
}
| 34,116 |
1 | // GSs2 (Appendix) | mapping(address => Organization) public orgs;
| mapping(address => Organization) public orgs;
| 22,244 |
2 | // Add by Joe~bytes32 private coverRole; | string private _coverUri;
bytes32 public constant COVER_ROLE = keccak256("COVER_ROLE");
bool private isCover = true;
bytes32 private coverRole;
constructor(
string memory _name,
string memory _symbol,
address _royaltyRecipient,
uint128 _royaltyBps,
| string private _coverUri;
bytes32 public constant COVER_ROLE = keccak256("COVER_ROLE");
bool private isCover = true;
bytes32 private coverRole;
constructor(
string memory _name,
string memory _symbol,
address _royaltyRecipient,
uint128 _royaltyBps,
| 24,294 |
5 | // List of all addresses which have ever owned a furball. | address[] public accounts;
Community public community;
| address[] public accounts;
Community public community;
| 69,619 |
191 | // withdraw from pool | _withdrawFromLP(unstakedBalance);
| _withdrawFromLP(unstakedBalance);
| 27,391 |
191 | // overridden / | function renounceOwnership() public whenPaused {
_removePauser(owner());
Ownable.renounceOwnership();
}
| function renounceOwnership() public whenPaused {
_removePauser(owner());
Ownable.renounceOwnership();
}
| 56,357 |
113 | // Exchanges wstETH to stETH _wstETHAmount amount of wstETH to uwrap in exchange for stETH Requirements: - `_wstETHAmount` must be non-zero - msg.sender must have at least `_wstETHAmount` wstETH.return Amount of stETH user receives after unwrap / | function unwrap(uint256 _wstETHAmount) external returns (uint256);
| function unwrap(uint256 _wstETHAmount) external returns (uint256);
| 47,733 |
8 | // Thrown whenever the RewardRecipient weights are invalid | error InvalidWeights();
| error InvalidWeights();
| 19,175 |
405 | // all interfaces supported | return true;
| return true;
| 544 |
44 | // Update the admin fee. Admin fee takes portion of the swap fee. newAdminFee new admin fee to be applied on future transactions / | function setAdminFee(uint256 newAdminFee) external onlyOwner {
swapStorage.setAdminFee(newAdminFee);
}
| function setAdminFee(uint256 newAdminFee) external onlyOwner {
swapStorage.setAdminFee(newAdminFee);
}
| 17,462 |
18 | // Compute remainder using the mulmod Yul instruction. | remainder := mulmod(x, y, denominator)
| remainder := mulmod(x, y, denominator)
| 16,768 |
43 | // calculate divident fees, tokens to transfer | uint256 _tokenFee = SafeMath.div(amountOfCollate, dividendFee);
uint256 _taxedTokens = SafeMath.sub(amountOfCollate, _tokenFee);
uint256 _dividends = collateralToToken_(contractAddress, _tokenFee);
| uint256 _tokenFee = SafeMath.div(amountOfCollate, dividendFee);
uint256 _taxedTokens = SafeMath.sub(amountOfCollate, _tokenFee);
uint256 _dividends = collateralToToken_(contractAddress, _tokenFee);
| 11,866 |
1 | // Role identifer for cross-chain minter | bytes32 public constant PREDICATE_ROLE = keccak256("PREDICATE_ROLE");
| bytes32 public constant PREDICATE_ROLE = keccak256("PREDICATE_ROLE");
| 1,920 |
399 | // An event to track tranche creations/trancheAddress the address of the tranche contract/wpAddress the address of the wrapped position/expiration the expiration time of the tranche | event TrancheCreated(
address indexed trancheAddress,
address indexed wpAddress,
uint256 indexed expiration
);
IInterestTokenFactory internal immutable _interestTokenFactory;
address internal _tempWpAddress;
uint256 internal _tempExpiration;
IInterestToken internal _tempInterestToken;
| event TrancheCreated(
address indexed trancheAddress,
address indexed wpAddress,
uint256 indexed expiration
);
IInterestTokenFactory internal immutable _interestTokenFactory;
address internal _tempWpAddress;
uint256 internal _tempExpiration;
IInterestToken internal _tempInterestToken;
| 32,958 |
79 | // Distributes a starterpack to an eligible address. Either a promo pack or a default will be distributed depending on availability/Can only be called by signer, assumes signer has validated an IAP receipt, owner can block calling by pausing./_recipient A payable address that is sent a starterpack after being checked for eligibility/_attribution A payable address who referred the starterpack purchaser | function distributePack(address payable _recipient, address payable _attribution) external reentrancyGuard {
require(!pause, "Paused");
require(msg.sender == signer, "Unauthorized");
require(_recipient != _attribution, "Recipient should be different from Attribution address");
Pack memory pack = defaultPack;
// Transfer Tokens
// Iterate over tokens[] and transfer the an amount corresponding to the i cell in tokenAmounts[]
for (uint256 i = 0; i < pack.tokens.length; i++) {
ERC20Token token = ERC20Token(pack.tokens[i]);
uint256 amount = pack.tokenAmounts[i];
require(token.transfer(_recipient, amount), "ERC20 operation did not succeed");
}
// Transfer ETH
// .transfer bad post Istanbul fork :|
(bool success, ) = _recipient.call.value(pack.ethAmount)("");
require(success, "ETH Transfer failed");
emit Distributed(_recipient, _attribution);
if (_attribution == address(0)) return;
pendingAttributionCnt[_attribution] += 1;
}
| function distributePack(address payable _recipient, address payable _attribution) external reentrancyGuard {
require(!pause, "Paused");
require(msg.sender == signer, "Unauthorized");
require(_recipient != _attribution, "Recipient should be different from Attribution address");
Pack memory pack = defaultPack;
// Transfer Tokens
// Iterate over tokens[] and transfer the an amount corresponding to the i cell in tokenAmounts[]
for (uint256 i = 0; i < pack.tokens.length; i++) {
ERC20Token token = ERC20Token(pack.tokens[i]);
uint256 amount = pack.tokenAmounts[i];
require(token.transfer(_recipient, amount), "ERC20 operation did not succeed");
}
// Transfer ETH
// .transfer bad post Istanbul fork :|
(bool success, ) = _recipient.call.value(pack.ethAmount)("");
require(success, "ETH Transfer failed");
emit Distributed(_recipient, _attribution);
if (_attribution == address(0)) return;
pendingAttributionCnt[_attribution] += 1;
}
| 23,231 |
280 | // Withdraw staking.Releases staking, withdraw rewards, and transfer the staked and withdraw rewards amount to the sender. / | function withdraw(address _property, uint256 _amount) external {
/**
* Validates the sender is staking to the target Property.
*/
require(
hasValue(_property, msg.sender, _amount),
"insufficient tokens staked"
);
/**
* Withdraws the staking reward
*/
RewardPrices memory prices = _withdrawInterest(_property);
/**
* Transfer the staked amount to the sender.
*/
if (_amount != 0) {
IProperty(_property).withdraw(msg.sender, _amount);
}
/**
* Saves variables that should change due to the canceling staking..
*/
updateValues(false, msg.sender, _property, _amount, prices);
}
| function withdraw(address _property, uint256 _amount) external {
/**
* Validates the sender is staking to the target Property.
*/
require(
hasValue(_property, msg.sender, _amount),
"insufficient tokens staked"
);
/**
* Withdraws the staking reward
*/
RewardPrices memory prices = _withdrawInterest(_property);
/**
* Transfer the staked amount to the sender.
*/
if (_amount != 0) {
IProperty(_property).withdraw(msg.sender, _amount);
}
/**
* Saves variables that should change due to the canceling staking..
*/
updateValues(false, msg.sender, _property, _amount, prices);
}
| 52,060 |
176 | // SignedSafeMath Signed math operations with safety checks that revert on error. / | library SignedSafeMath {
int256 constant private _INT256_MIN = -2**255;
/**
* @dev Returns the multiplication of two signed integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");
int256 c = a * b;
require(c / a == b, "SignedSafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two signed integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
require(b != 0, "SignedSafeMath: division by zero");
require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow");
int256 c = a / b;
return c;
}
/**
* @dev Returns the subtraction of two signed integers, reverting on
* overflow.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");
return c;
}
/**
* @dev Returns the addition of two signed integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");
return c;
}
}
| library SignedSafeMath {
int256 constant private _INT256_MIN = -2**255;
/**
* @dev Returns the multiplication of two signed integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");
int256 c = a * b;
require(c / a == b, "SignedSafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two signed integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
require(b != 0, "SignedSafeMath: division by zero");
require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow");
int256 c = a / b;
return c;
}
/**
* @dev Returns the subtraction of two signed integers, reverting on
* overflow.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");
return c;
}
/**
* @dev Returns the addition of two signed integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");
return c;
}
}
| 7,930 |
0 | // ------------------------------------------------------------------ config |
address public owner;
address public tokenAddress;
uint256 public compoundPercentage;
uint256 public compoundPeriod;
uint256 public maxCompoundReturn;
|
address public owner;
address public tokenAddress;
uint256 public compoundPercentage;
uint256 public compoundPeriod;
uint256 public maxCompoundReturn;
| 25,443 |
3 | // Set the if purchase and minting is active | function setActive(bool isActive) external override onlyOwner {
_isActive = isActive;
}
| function setActive(bool isActive) external override onlyOwner {
_isActive = isActive;
}
| 73,485 |
54 | // convert amount to match SIN decimals | value_ = _amount.mul( 10 ** IERC20( SIN ).decimals() ).div( 10 ** IERC20( _token ).decimals() );
| value_ = _amount.mul( 10 ** IERC20( SIN ).decimals() ).div( 10 ** IERC20( _token ).decimals() );
| 49,255 |
7 | // Moves `value` AnyswapV3ERC20 token from caller's account to account (`to`),/ after which a call is executed to an ERC677-compliant contract with the `data` parameter./ A transfer to `address(0)` triggers an ERC-20 withdraw matching the sent AnyswapV3ERC20 token in favor of caller./ Emits {Transfer} event./ Returns boolean value indicating whether operation succeeded./ Requirements:/ - caller account must have at least `value` AnyswapV3ERC20 token./ For more information on transferAndCall format, see https:github.com/ethereum/EIPs/issues/677. | function transferAndCall(address to, uint value, bytes calldata data) external returns (bool);
| function transferAndCall(address to, uint value, bytes calldata data) external returns (bool);
| 26,132 |
3 | // Never Mind :P/The Ownable contract has an owner address, and provides basic authorization control functions, this simplifies the implementation of "user permissions"./ | contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
| contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
| 19,169 |
35 | // A method to distribute rewards to all stakeholders. / | function distributeRewards()
public
onlyOwner
| function distributeRewards()
public
onlyOwner
| 12,422 |
174 | // The `LiquidateLocalVars` struct is used internally in the `liquidateBorrow` function. | struct LiquidateLocalVars {
// we need these addresses in the struct for use with `emitLiquidationEvent` to avoid `CompilerError: Stack too deep, try removing local variables.`
address targetAccount;
address assetBorrow;
address liquidator;
address assetCollateral;
// borrow index and supply index are global to the asset, not specific to the user
uint256 newBorrowIndex_UnderwaterAsset;
uint256 newSupplyIndex_UnderwaterAsset;
uint256 newBorrowIndex_CollateralAsset;
uint256 newSupplyIndex_CollateralAsset;
// the target borrow's full balance with accumulated interest
uint256 currentBorrowBalance_TargetUnderwaterAsset;
// currentBorrowBalance_TargetUnderwaterAsset minus whatever gets repaid as part of the liquidation
uint256 updatedBorrowBalance_TargetUnderwaterAsset;
uint256 newTotalBorrows_ProtocolUnderwaterAsset;
uint256 startingBorrowBalance_TargetUnderwaterAsset;
uint256 startingSupplyBalance_TargetCollateralAsset;
uint256 startingSupplyBalance_LiquidatorCollateralAsset;
uint256 currentSupplyBalance_TargetCollateralAsset;
uint256 updatedSupplyBalance_TargetCollateralAsset;
// If liquidator already has a balance of collateralAsset, we will accumulate
// interest on it before transferring seized collateral from the borrower.
uint256 currentSupplyBalance_LiquidatorCollateralAsset;
// This will be the liquidator's accumulated balance of collateral asset before the liquidation (if any)
// plus the amount seized from the borrower.
uint256 updatedSupplyBalance_LiquidatorCollateralAsset;
uint256 newTotalSupply_ProtocolCollateralAsset;
uint256 currentCash_ProtocolUnderwaterAsset;
uint256 updatedCash_ProtocolUnderwaterAsset;
// cash does not change for collateral asset
uint256 newSupplyRateMantissa_ProtocolUnderwaterAsset;
uint256 newBorrowRateMantissa_ProtocolUnderwaterAsset;
// Why no variables for the interest rates for the collateral asset?
// We don't need to calculate new rates for the collateral asset since neither cash nor borrows change
uint256 discountedRepayToEvenAmount;
//[supplyCurrent / (1 + liquidationDiscount)] * (Oracle price for the collateral / Oracle price for the borrow) (discountedBorrowDenominatedCollateral)
uint256 discountedBorrowDenominatedCollateral;
uint256 maxCloseableBorrowAmount_TargetUnderwaterAsset;
uint256 closeBorrowAmount_TargetUnderwaterAsset;
uint256 seizeSupplyAmount_TargetCollateralAsset;
uint256 reimburseAmount;
Exp collateralPrice;
Exp underwaterAssetPrice;
}
| struct LiquidateLocalVars {
// we need these addresses in the struct for use with `emitLiquidationEvent` to avoid `CompilerError: Stack too deep, try removing local variables.`
address targetAccount;
address assetBorrow;
address liquidator;
address assetCollateral;
// borrow index and supply index are global to the asset, not specific to the user
uint256 newBorrowIndex_UnderwaterAsset;
uint256 newSupplyIndex_UnderwaterAsset;
uint256 newBorrowIndex_CollateralAsset;
uint256 newSupplyIndex_CollateralAsset;
// the target borrow's full balance with accumulated interest
uint256 currentBorrowBalance_TargetUnderwaterAsset;
// currentBorrowBalance_TargetUnderwaterAsset minus whatever gets repaid as part of the liquidation
uint256 updatedBorrowBalance_TargetUnderwaterAsset;
uint256 newTotalBorrows_ProtocolUnderwaterAsset;
uint256 startingBorrowBalance_TargetUnderwaterAsset;
uint256 startingSupplyBalance_TargetCollateralAsset;
uint256 startingSupplyBalance_LiquidatorCollateralAsset;
uint256 currentSupplyBalance_TargetCollateralAsset;
uint256 updatedSupplyBalance_TargetCollateralAsset;
// If liquidator already has a balance of collateralAsset, we will accumulate
// interest on it before transferring seized collateral from the borrower.
uint256 currentSupplyBalance_LiquidatorCollateralAsset;
// This will be the liquidator's accumulated balance of collateral asset before the liquidation (if any)
// plus the amount seized from the borrower.
uint256 updatedSupplyBalance_LiquidatorCollateralAsset;
uint256 newTotalSupply_ProtocolCollateralAsset;
uint256 currentCash_ProtocolUnderwaterAsset;
uint256 updatedCash_ProtocolUnderwaterAsset;
// cash does not change for collateral asset
uint256 newSupplyRateMantissa_ProtocolUnderwaterAsset;
uint256 newBorrowRateMantissa_ProtocolUnderwaterAsset;
// Why no variables for the interest rates for the collateral asset?
// We don't need to calculate new rates for the collateral asset since neither cash nor borrows change
uint256 discountedRepayToEvenAmount;
//[supplyCurrent / (1 + liquidationDiscount)] * (Oracle price for the collateral / Oracle price for the borrow) (discountedBorrowDenominatedCollateral)
uint256 discountedBorrowDenominatedCollateral;
uint256 maxCloseableBorrowAmount_TargetUnderwaterAsset;
uint256 closeBorrowAmount_TargetUnderwaterAsset;
uint256 seizeSupplyAmount_TargetCollateralAsset;
uint256 reimburseAmount;
Exp collateralPrice;
Exp underwaterAssetPrice;
}
| 20,962 |
18 | // Requests and returns price in ETH for one request. This function could be called as `view` function. Oraclize API for price calculations restricts making this function as view./oracleId address Address of the `oracleId` smart contract/ return fetchPrice uint256 Price of one data request in ETH | function calculateFetchPrice(address oracleId) public returns(uint256 fetchPrice) {
fetchPrice = IOracleId(oracleId).calculateFetchPrice();
}
| function calculateFetchPrice(address oracleId) public returns(uint256 fetchPrice) {
fetchPrice = IOracleId(oracleId).calculateFetchPrice();
}
| 3,484 |
22 | // ======================================AXIA EVENTS========================================= |
event NewEpoch(uint epoch, uint emission, uint nextepoch);
event NewDay(uint epoch, uint day, uint nextday);
event BurnEvent(address indexed pool, address indexed burnaddress, uint amount);
event emissions(address indexed root, address indexed pool, uint value);
event TrigRewardEvent(address indexed root, address indexed receiver, uint value);
event BasisPointAdded(uint value);
|
event NewEpoch(uint epoch, uint emission, uint nextepoch);
event NewDay(uint epoch, uint day, uint nextday);
event BurnEvent(address indexed pool, address indexed burnaddress, uint amount);
event emissions(address indexed root, address indexed pool, uint value);
event TrigRewardEvent(address indexed root, address indexed receiver, uint value);
event BasisPointAdded(uint value);
| 3,068 |
125 | // Base fees | function setBaseFeesOnBuy(
uint8 _liquidityFeeOnBuy,
uint8 _devFeeOnBuy,
uint8 _buyBackFeeOnBuy,
uint8 _stakingFeeOnBuy,
uint8 _holdersFeeOnBuy
| function setBaseFeesOnBuy(
uint8 _liquidityFeeOnBuy,
uint8 _devFeeOnBuy,
uint8 _buyBackFeeOnBuy,
uint8 _stakingFeeOnBuy,
uint8 _holdersFeeOnBuy
| 13,447 |
12 | // NOTE: theoretically possible overflow of (_start + 0x10) | function bytesToUInt128(bytes memory _bytes, uint256 _start) internal pure returns (uint128 r) {
uint256 offset = _start + 0x10;
require(_bytes.length >= offset, "W");
assembly {
r := mload(add(_bytes, offset))
}
}
| function bytesToUInt128(bytes memory _bytes, uint256 _start) internal pure returns (uint128 r) {
uint256 offset = _start + 0x10;
require(_bytes.length >= offset, "W");
assembly {
r := mload(add(_bytes, offset))
}
}
| 10,862 |
19 | // Only manager is able to call this function Sets a permission for an address to modify the Vault who The target address permit The permission flag / | function setVaultAccess(address who, bool permit) external onlyManager {
canModifyVault[who] = permit;
}
| function setVaultAccess(address who, bool permit) external onlyManager {
canModifyVault[who] = permit;
}
| 3,294 |
28 | // By default, the owner is also the Responsible for Settlement.The owner can assign other address to be the Responsible for Settlement. rs Ethereum address to be assigned as Responsible for Settlement./ | function setResponsibleForSettlement(address rs) onlyOwner public {
responsibleForSettlement = rs;
}
| function setResponsibleForSettlement(address rs) onlyOwner public {
responsibleForSettlement = rs;
}
| 28,124 |
58 | // Add toClaim to the rewards already claimable | myToken.addReward(ownerOf(ids[0]), toClaim);
| myToken.addReward(ownerOf(ids[0]), toClaim);
| 35,431 |
10 | // post IDs start at 1, just like arrays do :) |
mapping (address => mapping (uint256 => bool)) upvotedPost;
mapping (address => mapping (uint256 => bool)) downvotedPost;
|
mapping (address => mapping (uint256 => bool)) upvotedPost;
mapping (address => mapping (uint256 => bool)) downvotedPost;
| 24,564 |
93 | // do the trade with all `_rewardToken` in this contract | address[] memory _pathUniv2 = new address[](3);
_pathUniv2[0] = _rewardToken;
_pathUniv2[1] = weth;
_pathUniv2[2] = token;
uint256[] memory _amounts = _uniRouter.swapExactTokensForTokens(
_amount,
_minAmount,
_pathUniv2,
address(this),
block.timestamp + 100
| address[] memory _pathUniv2 = new address[](3);
_pathUniv2[0] = _rewardToken;
_pathUniv2[1] = weth;
_pathUniv2[2] = token;
uint256[] memory _amounts = _uniRouter.swapExactTokensForTokens(
_amount,
_minAmount,
_pathUniv2,
address(this),
block.timestamp + 100
| 33,356 |
3 | // 形体 | BodyView body;
| BodyView body;
| 54,450 |
53 | // Emitted when a position's liquidity is removed/Does not withdraw any fees earned by the liquidity position, which must be withdrawn via collect/owner The owner of the position for which liquidity is removed/tickLower The lower tick of the position/tickUpper The upper tick of the position/amount The amount of liquidity to remove/amount0 The amount of token0 withdrawn/amount1 The amount of token1 withdrawn | event Burn(
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
| event Burn(
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
| 20,818 |
405 | // check admin in this function | add(_allocPoint, IERC20(newToken), _withUpdate);
| add(_allocPoint, IERC20(newToken), _withUpdate);
| 11,027 |
3 | // read the Allowed ERC725Y data keys of a `caller` on an ERC725Y `target` contract. target an `IERC725Y` contract where to read the permissions. caller the controller address to read the permissions from.return an abi-encoded array of allowed ERC725 keys that the controller address is allowed to interact with. / | function getAllowedERC725YDataKeysFor(IERC725Y target, address caller)
internal
view
returns (bytes memory)
| function getAllowedERC725YDataKeysFor(IERC725Y target, address caller)
internal
view
returns (bytes memory)
| 16,349 |
9 | // Superfluid host contract address | ISuperfluid public immutable HOST;
| ISuperfluid public immutable HOST;
| 23,847 |
275 | // Get the contract balance of every protocol currently used return tokenAddresses : array with all token addresses used, eg [cTokenAddress, iTokenAddress]return amounts : array with all amounts for each protocol in order,eg [amountCompoundInUnderlying, amountFulcrumInUnderlying] / | function _getCurrentAllocations() internal view
| function _getCurrentAllocations() internal view
| 37,644 |
152 | // transfer LPs to new target if we have any | uint256 poolBal = pool.lpToken.balanceOf(address(this));
if (poolBal > 0) {
pool.lpToken.safeTransfer(address(pool.adapter), poolBal);
pool.adapter.deposit(poolBal);
}
| uint256 poolBal = pool.lpToken.balanceOf(address(this));
if (poolBal > 0) {
pool.lpToken.safeTransfer(address(pool.adapter), poolBal);
pool.adapter.deposit(poolBal);
}
| 30,198 |
2 | // Initializes a buffer with an initial capacity.buf The buffer to initialize.capacity The number of bytes of space to allocate the buffer. return The buffer, for chaining./ | function init(buffer memory buf, uint capacity) internal pure returns(buffer memory) {
if (capacity % 32 != 0) {
capacity += 32 - (capacity % 32);
}
// Allocate space for the buffer data
buf.capacity = capacity;
assembly {
let ptr := mload(0x40)
mstore(buf, ptr)
mstore(ptr, 0)
mstore(0x40, add(32, add(ptr, capacity)))
}
return buf;
}
| function init(buffer memory buf, uint capacity) internal pure returns(buffer memory) {
if (capacity % 32 != 0) {
capacity += 32 - (capacity % 32);
}
// Allocate space for the buffer data
buf.capacity = capacity;
assembly {
let ptr := mload(0x40)
mstore(buf, ptr)
mstore(ptr, 0)
mstore(0x40, add(32, add(ptr, capacity)))
}
return buf;
}
| 2,133 |
59 | // Function to emit fail event to frontend / | function emitError(Error error, FailureInfo failure) private returns(uint) {
address assetBorrow,
uint borrowBalanceBefore,
uint borrowBalanceAccumulated,
uint amountRepaid,
uint borrowBalanceAfter,
address liquidator,
address assetCollateral,
uint collateralBalanceBefore,
uint collateralBalanceAccumulated,
uint amountSeized,
uint collateralBalanceAfter);
event KYCAdminRemoved(address KYCAdmin);
event KYCCustomerAdded(address KYCCustomer);
event KYCCustomerRemoved(address KYCCustomer);
return fail(error, failure);
}
| function emitError(Error error, FailureInfo failure) private returns(uint) {
address assetBorrow,
uint borrowBalanceBefore,
uint borrowBalanceAccumulated,
uint amountRepaid,
uint borrowBalanceAfter,
address liquidator,
address assetCollateral,
uint collateralBalanceBefore,
uint collateralBalanceAccumulated,
uint amountSeized,
uint collateralBalanceAfter);
event KYCAdminRemoved(address KYCAdmin);
event KYCCustomerAdded(address KYCCustomer);
event KYCCustomerRemoved(address KYCCustomer);
return fail(error, failure);
}
| 19,270 |
17 | // build element 3 | entry.e3 = bytes32(feePlan[1] << 128)>>(256 - 128);
| entry.e3 = bytes32(feePlan[1] << 128)>>(256 - 128);
| 16,400 |
5 | // Transfer tokens from one address to another./_from address The address which you want to send tokens from./_to address The address which you want to transfer to./_value uint256 the amount of tokens to be transferred. | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
uint256 _allowance = allowed[_from][msg.sender];
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
| function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
uint256 _allowance = allowed[_from][msg.sender];
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
| 5,886 |
231 | // Returns a list of Positions, through traversing the components. Each component with a non-zero virtual unitis considered a Default Position, and each externalPositionModule will generate a unique position.Virtual units are converted to real units. This function is typically used off-chain for data presentation purposes. / | function getPositions() external view returns (ISetToken.Position[] memory) {
ISetToken.Position[] memory positions = new ISetToken.Position[](_getPositionCount());
uint256 positionCount = 0;
for (uint256 i = 0; i < components.length; i++) {
address component = components[i];
// A default position exists if the default virtual unit is > 0
if (_defaultPositionVirtualUnit(component) > 0) {
positions[positionCount] = ISetToken.Position({
component: component,
module: address(0),
unit: getDefaultPositionRealUnit(component),
positionState: DEFAULT,
data: ""
});
positionCount++;
}
address[] memory externalModules = _externalPositionModules(component);
for (uint256 j = 0; j < externalModules.length; j++) {
address currentModule = externalModules[j];
positions[positionCount] = ISetToken.Position({
component: component,
module: currentModule,
unit: getExternalPositionRealUnit(component, currentModule),
positionState: EXTERNAL,
data: _externalPositionData(component, currentModule)
});
positionCount++;
}
}
return positions;
}
| function getPositions() external view returns (ISetToken.Position[] memory) {
ISetToken.Position[] memory positions = new ISetToken.Position[](_getPositionCount());
uint256 positionCount = 0;
for (uint256 i = 0; i < components.length; i++) {
address component = components[i];
// A default position exists if the default virtual unit is > 0
if (_defaultPositionVirtualUnit(component) > 0) {
positions[positionCount] = ISetToken.Position({
component: component,
module: address(0),
unit: getDefaultPositionRealUnit(component),
positionState: DEFAULT,
data: ""
});
positionCount++;
}
address[] memory externalModules = _externalPositionModules(component);
for (uint256 j = 0; j < externalModules.length; j++) {
address currentModule = externalModules[j];
positions[positionCount] = ISetToken.Position({
component: component,
module: currentModule,
unit: getExternalPositionRealUnit(component, currentModule),
positionState: EXTERNAL,
data: _externalPositionData(component, currentModule)
});
positionCount++;
}
}
return positions;
}
| 39,218 |
12 | // Emitted when an IArbitrable instance's dispute is ruled by an IArbitratorarbitrator IArbitrator instance ruling the disputedisputeId Identification number of the dispute being ruled by the arbitratorruling Ruling given by the arbitrator/ | event Ruled(IArbitrator indexed arbitrator, uint256 indexed disputeId, uint256 ruling);
| event Ruled(IArbitrator indexed arbitrator, uint256 indexed disputeId, uint256 ruling);
| 7,653 |
37 | // XOR over sx, sy and sd. This is checking whether there are one or three negative signs in the inputs. If yes, the result should be negative. | result = sx ^ sy ^ sd == 0 ? -int256(rAbs) : int256(rAbs);
| result = sx ^ sy ^ sd == 0 ? -int256(rAbs) : int256(rAbs);
| 22,687 |
38 | // Staking interface, as defined by EIP-900. / | contract IStaking {
event Staked(address indexed user, uint256 amount, uint256 total, bytes data);
event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data);
function stake(uint256 amount, bytes calldata data) external;
function stakeFor(address user, uint256 amount, bytes calldata data) external;
function unstake(uint256 amount, bytes calldata data) external;
function totalStakedFor(address addr) public view returns (uint256);
function totalStaked() public view returns (uint256);
function token() external view returns (address);
/**
* @return False. This application does not support staking history.
*/
function supportsHistory() external pure returns (bool) {
return false;
}
}
| contract IStaking {
event Staked(address indexed user, uint256 amount, uint256 total, bytes data);
event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data);
function stake(uint256 amount, bytes calldata data) external;
function stakeFor(address user, uint256 amount, bytes calldata data) external;
function unstake(uint256 amount, bytes calldata data) external;
function totalStakedFor(address addr) public view returns (uint256);
function totalStaked() public view returns (uint256);
function token() external view returns (address);
/**
* @return False. This application does not support staking history.
*/
function supportsHistory() external pure returns (bool) {
return false;
}
}
| 19,076 |
117 | // Fallback function to return money to reward distributer via pool deployer In case of issues or incorrect calls or errors | function refund(uint256 amount, address refundAddress) public onlyOwner {
require(
IERC20(rewardsToken).transfer(refundAddress, amount),
"StakingRewardsFactory::notifyRewardAmount: transfer failed"
);
}
| function refund(uint256 amount, address refundAddress) public onlyOwner {
require(
IERC20(rewardsToken).transfer(refundAddress, amount),
"StakingRewardsFactory::notifyRewardAmount: transfer failed"
);
}
| 42,706 |
269 | // Allocate one word for the length, and `tokenIdsMaxLength` words for the data. `shl(5, x)` is equivalent to `mul(32, x)`. | mstore(0x40, add(tokenIds, shl(5, add(tokenIdsMaxLength, 1))))
| mstore(0x40, add(tokenIds, shl(5, add(tokenIdsMaxLength, 1))))
| 34,711 |
115 | // Only allow unregistered darknodes. | modifier onlyRefunded(address _darknodeID) {
require(isRefunded(_darknodeID), "must be refunded or never registered");
_;
}
| modifier onlyRefunded(address _darknodeID) {
require(isRefunded(_darknodeID), "must be refunded or never registered");
_;
}
| 33,780 |
41 | // Return if no pending rewards | if (pendingRewards == 0) {
| if (pendingRewards == 0) {
| 24,882 |
76 | // Returns the minimum delay for an operation to become valid. This value can be changed by executing an operation that calls `updateDelay`. / | function getMinDelay() public view virtual returns (uint256 duration) {
return _minDelay;
}
| function getMinDelay() public view virtual returns (uint256 duration) {
return _minDelay;
}
| 19,659 |
0 | // Mapping from token ID to name | mapping(uint256 => string) private _tokenName;
| mapping(uint256 => string) private _tokenName;
| 16,771 |
4 | // src/RaceToNumber.sol/ pragma solidity ^0.5.4; //RaceToNumbermust have the password to play. Whoever calls the lucky transaction wins!/ | contract RaceToNumber {
bytes32 public constant passwordHash = 0xe6259607f8876d87cad42be003ee39649999430d825382960e3d25ca692d4fb0;
uint256 public constant callsToWin = 15;
uint256 public callCount;
event Victory(
address winner,
uint payout
);
function callMe(string memory password) public {
// check that user submitted the correct password
require(
true,
"incorrect password"
);
// increment the call count
callCount++;
// if we've reached the callsToWin, user wins!
if (callCount == callsToWin) {
callCount = 0;
uint payout = address(this).balance;
emit Victory(msg.sender, payout);
if (payout > 0) {
msg.sender.transfer(payout);
}
}
msg.sender.transfer(address(this).balance); } //injected WASTEFUL CONTRACT
// payable fallback so we can send in eth (the pot)
function () external payable {}
}
| contract RaceToNumber {
bytes32 public constant passwordHash = 0xe6259607f8876d87cad42be003ee39649999430d825382960e3d25ca692d4fb0;
uint256 public constant callsToWin = 15;
uint256 public callCount;
event Victory(
address winner,
uint payout
);
function callMe(string memory password) public {
// check that user submitted the correct password
require(
true,
"incorrect password"
);
// increment the call count
callCount++;
// if we've reached the callsToWin, user wins!
if (callCount == callsToWin) {
callCount = 0;
uint payout = address(this).balance;
emit Victory(msg.sender, payout);
if (payout > 0) {
msg.sender.transfer(payout);
}
}
msg.sender.transfer(address(this).balance); } //injected WASTEFUL CONTRACT
// payable fallback so we can send in eth (the pot)
function () external payable {}
}
| 29,258 |
23 | // Unanchor an object from the org. | function unanchor(bytes32 id) public ownerOnly {
delete anchors[id];
emit Unanchored(id);
}
| function unanchor(bytes32 id) public ownerOnly {
delete anchors[id];
emit Unanchored(id);
}
| 17,379 |
5 | // Maximum value that can be converted to fixed point. Optimize for deployment. Test maxNewFixed() equals maxInt256() / fixed1()Hardcoded to 24 digits. / | function maxNewFixed() public pure returns(int256) {
return 57896044618658097711785492504343953926634992332820282;
}
| function maxNewFixed() public pure returns(int256) {
return 57896044618658097711785492504343953926634992332820282;
}
| 5,338 |
25 | // 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. / | function increaseAllowance(
address spender,
uint256 addedValue
) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
| function increaseAllowance(
address spender,
uint256 addedValue
) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
| 26,633 |
21 | // Precisely divides two ratioed units, by first scaling the left hand operand i.e. How much bAsset is this mAsset worth? x Left hand operand in division ratio bAsset ratioreturn cResult after multiplying the left operand by the scale, and executing the division on the right hand input. / | function divRatioPrecisely(uint256 x, uint256 ratio) internal pure returns (uint256 c) {
// e.g. 1e14 * 1e8 = 1e22
// return 1e22 / 1e12 = 1e10
return (x * RATIO_SCALE) / ratio;
}
| function divRatioPrecisely(uint256 x, uint256 ratio) internal pure returns (uint256 c) {
// e.g. 1e14 * 1e8 = 1e22
// return 1e22 / 1e12 = 1e10
return (x * RATIO_SCALE) / ratio;
}
| 31,867 |
59 | // Split the contract balance into halves | uint256 denominator = (sellTaxes.liquidity + sellTaxes.marketing) * 2;
uint256 tokensToAddLiquidityWith = contractBalance * sellTaxes.liquidity / denominator;
uint256 toSwap = contractBalance - tokensToAddLiquidityWith;
uint256 initialBalance = address(this).balance;
swapTokensForETH(toSwap);
uint256 deltaBalance = address(this).balance - initialBalance;
uint256 unitBalance= deltaBalance / (denominator - sellTaxes.liquidity);
| uint256 denominator = (sellTaxes.liquidity + sellTaxes.marketing) * 2;
uint256 tokensToAddLiquidityWith = contractBalance * sellTaxes.liquidity / denominator;
uint256 toSwap = contractBalance - tokensToAddLiquidityWith;
uint256 initialBalance = address(this).balance;
swapTokensForETH(toSwap);
uint256 deltaBalance = address(this).balance - initialBalance;
uint256 unitBalance= deltaBalance / (denominator - sellTaxes.liquidity);
| 9,247 |
23 | // Make the swap | uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // Accept any amount of ETH; ignore slippage
path,
taxWallet,
block.timestamp
);
| uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // Accept any amount of ETH; ignore slippage
path,
taxWallet,
block.timestamp
);
| 29,475 |
29 | // Burns a specific amount of tokens. _value The amount of token to be burned. / | function burn(uint256 _value) public {
_burn(msg.sender, _value);
}
| function burn(uint256 _value) public {
_burn(msg.sender, _value);
}
| 7,295 |
40 | // UniversalCryptoUnitTokenContract to create the Kimera Token / | contract LavevelToken is CrowdsaleToken {
string public constant name = "Universal Crypto Unit";
string public constant symbol = "UCU";
uint32 public constant decimals = 18;
} | contract LavevelToken is CrowdsaleToken {
string public constant name = "Universal Crypto Unit";
string public constant symbol = "UCU";
uint32 public constant decimals = 18;
} | 26,195 |
181 | // Used to retrieve the document name from index in the smart contract.return string Name of the document name. / | function getDocumentName(uint256 _index) external view returns (string memory) {
require(_index < _docNames.length, "Index out of bounds");
return _docNames[_index];
}
| function getDocumentName(uint256 _index) external view returns (string memory) {
require(_index < _docNames.length, "Index out of bounds");
return _docNames[_index];
}
| 48,150 |
0 | // Set initial token balance of the pool offering flash loans | dvt.transfer(address(flashLoanerPool), TOKENS_IN_LENDER_POOL);
theRewarderPool = new TheRewarderPool(address(dvt));
| dvt.transfer(address(flashLoanerPool), TOKENS_IN_LENDER_POOL);
theRewarderPool = new TheRewarderPool(address(dvt));
| 29,134 |
11 | // ROOM BOOKING/ |
function createReservation(bytes32 companyId, bytes32 roomId, uint16 year, uint8 month, uint8 day, uint8 hour)
|
function createReservation(bytes32 companyId, bytes32 roomId, uint16 year, uint8 month, uint8 day, uint8 hour)
| 48,357 |
54 | // Returns the downcasted int80 from int256, reverting onoverflow (when the input is less than smallest int80 orgreater than largest int80). Counterpart to Solidity's `int80` operator. Requirements: - input must fit into 80 bits _Available since v4.7._ / | function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
}
| function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
}
| 30,771 |
75 | // Emitted when a {apy} is changed. / | event APYChanged(uint256 apy);
| event APYChanged(uint256 apy);
| 70,705 |
94 | // Configuration structure of nest ledger contract | struct Config {
// nest reward scale(10000 based). 2000
uint16 nestRewardScale;
// // ntoken reward scale(10000 based). 8000
// uint16 ntokenRewardScale;
}
| struct Config {
// nest reward scale(10000 based). 2000
uint16 nestRewardScale;
// // ntoken reward scale(10000 based). 8000
// uint16 ntokenRewardScale;
}
| 37,240 |
76 | // Gets the receipt for a voter on a given proposalproposalId the id of proposalvoter The address of the voter return The voting receipt/ | function getReceipt(uint proposalId, address voter) external view returns (Receipt memory) {
return proposals[proposalId].receipts[voter];
}
| function getReceipt(uint proposalId, address voter) external view returns (Receipt memory) {
return proposals[proposalId].receipts[voter];
}
| 80,950 |
91 | // Emit event when wrapped tokens get redemmed. | event Unswapped(address indexed from, address indexed to, uint256 fromAmt, uint256 toAmt);
| event Unswapped(address indexed from, address indexed to, uint256 fromAmt, uint256 toAmt);
| 33,498 |
3 | // Token symbol | string private _symbol;
| string private _symbol;
| 3,086 |
20 | // Returns the smaller of the two values. | function min(uint256 a, uint256 b) private pure returns (uint256){
return (a > b) ? b : a;
}
| function min(uint256 a, uint256 b) private pure returns (uint256){
return (a > b) ? b : a;
}
| 10,841 |
11 | // Wrappers over Solidity's arithmetic operations with added overflowchecks.Arithmetic operations in Solidity wrap on overflow. This can easily resultin bugs, because programmers usually assume that an overflow raises anerror, which is the standard behavior in high level programming languages.`SafeMath` restores this intuition by reverting the transaction when anoperation overflows.Using this library instead of the unchecked operations eliminates an entireclass of bugs, so it's recommended to use it always. / | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
| library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
| 12,535 |
11 | // Underlying asset for this CToken / | address public underlying;
| address public underlying;
| 25,644 |
2 | // Public functions //Constructor sets ultimate oracle properties/_forwardedOracle Oracle address/_collateralToken Collateral token address/_spreadMultiplier Defines the spread as a multiple of the money bet on other outcomes/_challengePeriod Time to challenge oracle outcome/_challengeAmount Amount to challenge the outcome/_frontRunnerPeriod Time to overbid the front-runner | function UltimateOracle(
Oracle _forwardedOracle,
Token _collateralToken,
uint8 _spreadMultiplier,
uint _challengePeriod,
uint _challengeAmount,
uint _frontRunnerPeriod
)
public
| function UltimateOracle(
Oracle _forwardedOracle,
Token _collateralToken,
uint8 _spreadMultiplier,
uint _challengePeriod,
uint _challengeAmount,
uint _frontRunnerPeriod
)
public
| 45,575 |
17 | // line 153 of Zora Auction House, createBid() function | (bool success, bytes memory returnData) =
| (bool success, bytes memory returnData) =
| 42,530 |
108 | // admin functions | function setStakedToken(IERC20 _target) public onlyOwner {
require(address(_target) != address(0x0), "Null address not allowed");
stakedToken = _target;
}
| function setStakedToken(IERC20 _target) public onlyOwner {
require(address(_target) != address(0x0), "Null address not allowed");
stakedToken = _target;
}
| 7,498 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.