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 |
|---|---|---|---|---|
155 | // allOperations.length-1 | allOperations.push(allOperations[allOperations.length-1]);
delete votesMaskByOperation[operation];
delete votesCountByOperation[operation];
delete allOperationsIndicies[operation];
| allOperations.push(allOperations[allOperations.length-1]);
delete votesMaskByOperation[operation];
delete votesCountByOperation[operation];
delete allOperationsIndicies[operation];
| 57,343 |
83 | // Allows authorized acces to burn tokens. receiver the receiver to receive tokens. value number of tokens to be created. / | function authorizedBurnTokens(address receiver, uint value) public onlyAuthorized {
token.burn(receiver, value);
AuthorizedBurn(receiver, value);
}
| function authorizedBurnTokens(address receiver, uint value) public onlyAuthorized {
token.burn(receiver, value);
AuthorizedBurn(receiver, value);
}
| 41,781 |
88 | // check signature | bytes32 hash = _h.toEthSignedMessageHash();
address addr;
for (uint i = 0; i < 2; i++) {
addr = hash.recover(_sigs[i]);
| bytes32 hash = _h.toEthSignedMessageHash();
address addr;
for (uint i = 0; i < 2; i++) {
addr = hash.recover(_sigs[i]);
| 43,371 |
4 | // We use the config for the mgmt APIs | struct SubscriptionConfig {
address owner; // Owner can fund/withdraw/cancel the sub.
address requestedOwner; // For safely transferring sub ownership.
// Maintains the list of keys in s_consumers.
// We do this for 2 reasons:
// 1. To be able to clean up all keys from s_consumers when canceling a... | struct SubscriptionConfig {
address owner; // Owner can fund/withdraw/cancel the sub.
address requestedOwner; // For safely transferring sub ownership.
// Maintains the list of keys in s_consumers.
// We do this for 2 reasons:
// 1. To be able to clean up all keys from s_consumers when canceling a... | 1,825 |
53 | // See {BEP20-balanceOf}. / | function balanceOf(address account) override external view returns (uint256) {
return _balances[account];
}
| function balanceOf(address account) override external view returns (uint256) {
return _balances[account];
}
| 67,915 |
5 | // total number of pool shares | uint256 public totalShareAmount;
| uint256 public totalShareAmount;
| 39,058 |
10 | // allows gas less trading on OpenSea | return super.isApprovedForAll(owner, operator) || isOwnersOpenSeaProxy(owner, operator);
| return super.isApprovedForAll(owner, operator) || isOwnersOpenSeaProxy(owner, operator);
| 44,750 |
6 | // ---------------------------------------------------------------------------- ERC Token Standard 20 Interface https:github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md ---------------------------------------------------------------------------- | contract ERC20Interface {
function totalSupply() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spender) public view returns (uint remaining);
function transfer(address to, uint tokens) public returns ... | contract ERC20Interface {
function totalSupply() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spender) public view returns (uint remaining);
function transfer(address to, uint tokens) public returns ... | 4 |
17 | // Enumerable / | function totalSupply() public view returns (uint256) {
return amountMintedHeroes;
}
| function totalSupply() public view returns (uint256) {
return amountMintedHeroes;
}
| 31,194 |
17 | // normalize expires to handle 0 cases | expires = _normalizeExpires(expires);
uint256 basePrice = rentPrices[len - 1].mul(duration);
console.log("_price(%s): basePrice=%s", basePrice);
basePrice = basePrice.add(_premium(name, expires, duration));
console.log("_price(%s): after basePrice=%s", basePrice);
| expires = _normalizeExpires(expires);
uint256 basePrice = rentPrices[len - 1].mul(duration);
console.log("_price(%s): basePrice=%s", basePrice);
basePrice = basePrice.add(_premium(name, expires, duration));
console.log("_price(%s): after basePrice=%s", basePrice);
| 18,763 |
46 | // helper function for front end round prize pot | function getCurrentRoundPrizePot() public view returns(uint256 _rndPrize){
return roundPrizePot[roundCount];
}
| function getCurrentRoundPrizePot() public view returns(uint256 _rndPrize){
return roundPrizePot[roundCount];
}
| 14,882 |
27 | // Add liquidity to Uniswap and transfer remaining tokens to developer and marketing wallets | function addLiquidityAndTransfer(uint256 tokenAmount, address payable _devWallet, address payable marketing) public payable onlyOwner {
require(tokenAmount > 0, "Invalid amount");
require(_devWallet != address(0), "Invalid dev wallet address");
require(marketing != address(0), "Invalid marke... | function addLiquidityAndTransfer(uint256 tokenAmount, address payable _devWallet, address payable marketing) public payable onlyOwner {
require(tokenAmount > 0, "Invalid amount");
require(_devWallet != address(0), "Invalid dev wallet address");
require(marketing != address(0), "Invalid marke... | 37,026 |
0 | // TOTAL MAX SUPPLY = 80,000 rSHAREs | uint256 public constant FARMING_POOL_REWARD_ALLOCATION = 59500 ether;
uint256 public constant COMMUNITY_FUND_POOL_ALLOCATION = 5500 ether;
uint256 public constant DEV_FUND_POOL_ALLOCATION = 5000 ether;
uint256 public constant HOUSING_FUND_POOL_ALLOCATION = 5000 ether;
uint256 constant TEAM_FUND_POOL... | uint256 public constant FARMING_POOL_REWARD_ALLOCATION = 59500 ether;
uint256 public constant COMMUNITY_FUND_POOL_ALLOCATION = 5500 ether;
uint256 public constant DEV_FUND_POOL_ALLOCATION = 5000 ether;
uint256 public constant HOUSING_FUND_POOL_ALLOCATION = 5000 ether;
uint256 constant TEAM_FUND_POOL... | 37,878 |
0 | // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 232 - 1] | function currentBlockTimestamp() internal view returns (uint32) {
return uint32(block.timestamp % 2 ** 32);
}
| function currentBlockTimestamp() internal view returns (uint32) {
return uint32(block.timestamp % 2 ** 32);
}
| 11,529 |
122 | // Refunds account call Deploys an account if not deployed yet account account address token token address value value / | function refundAccountCall(
address account,
address token,
uint256 value
)
external
| function refundAccountCall(
address account,
address token,
uint256 value
)
external
| 11,303 |
69 | // send all token balance of an arbitary erc20 token/ | function reclaimToken(ERC20 token, address _to) external onlyOwner {
uint256 balance = token.balanceOf(this);
token.transfer(_to, balance);
}
| function reclaimToken(ERC20 token, address _to) external onlyOwner {
uint256 balance = token.balanceOf(this);
token.transfer(_to, balance);
}
| 40,562 |
4 | // bytes4(keccak256("OrderStatusError(bytes32,uint8)")) | bytes4 internal constant ORDER_STATUS_ERROR_SELECTOR =
0xfdb6ca8d;
| bytes4 internal constant ORDER_STATUS_ERROR_SELECTOR =
0xfdb6ca8d;
| 34,917 |
1 | // HARD-CODED LIMITS These numbers are quite arbitrary; they are small enough to avoid overflows when doing calculations with periods or shares, yet big enough to not limit reasonable use cases. | uint256 constant MAX_VOTING_PERIOD_LENGTH = 10**18; // maximum length of voting period
uint256 constant MAX_GRACE_PERIOD_LENGTH = 10**18; // maximum length of grace period
uint256 constant MAX_DILUTION_BOUND = 10**18; // maximum dilution bound
uint256 constant MAX_NUMBER_OF_SHARES = 10**18; // maximum n... | uint256 constant MAX_VOTING_PERIOD_LENGTH = 10**18; // maximum length of voting period
uint256 constant MAX_GRACE_PERIOD_LENGTH = 10**18; // maximum length of grace period
uint256 constant MAX_DILUTION_BOUND = 10**18; // maximum dilution bound
uint256 constant MAX_NUMBER_OF_SHARES = 10**18; // maximum n... | 49,449 |
43 | // Get security token offering smart contract details by the proposal index _securityTokenAddress The security token address _offeringFactoryProposalIndex The array index of the STO contract being checkedreturn Contract struct / | function getOfferingFactoryByProposal(address _securityTokenAddress, uint8 _offeringFactoryProposalIndex) view public returns (
address _offeringFactoryAddress
| function getOfferingFactoryByProposal(address _securityTokenAddress, uint8 _offeringFactoryProposalIndex) view public returns (
address _offeringFactoryAddress
| 40,249 |
550 | // if _collateral isn't enabled as collateral by _user, it cannot be liquidated | if (!vars.isCollateralEnabled) {
return (
uint256(LiquidationErrors.COLLATERAL_CANNOT_BE_LIQUIDATED),
"The collateral chosen cannot be liquidated"
);
}
| if (!vars.isCollateralEnabled) {
return (
uint256(LiquidationErrors.COLLATERAL_CANNOT_BE_LIQUIDATED),
"The collateral chosen cannot be liquidated"
);
}
| 24,536 |
4 | // Within the timeframe | require(block.timestamp < start+buyPeriod);
| require(block.timestamp < start+buyPeriod);
| 17,799 |
21 | // Calculates the maxTradeSize for an asset based on the asset's maxTradeVolume and price | /// @return {tok} The max trade size for the asset in whole tokens
function maxTradeSize(IAsset asset, uint192 price) private view returns (uint192) {
uint192 size = price == 0 ? FIX_MAX : asset.maxTradeVolume().div(price, ROUND);
return size > 0 ? size : 1;
}
| /// @return {tok} The max trade size for the asset in whole tokens
function maxTradeSize(IAsset asset, uint192 price) private view returns (uint192) {
uint192 size = price == 0 ? FIX_MAX : asset.maxTradeVolume().div(price, ROUND);
return size > 0 ? size : 1;
}
| 26,970 |
345 | // check if the base is valid | require(base == 2 || base == 8 || base == 10 || base == 16);
| require(base == 2 || base == 8 || base == 10 || base == 16);
| 50,537 |
55 | // update all provider's pending rewards, in order to apply retroactive reward multipliers | (PoolRewards memory poolRewardsData, ProviderRewards memory providerRewards) = _updateRewards(
provider,
poolToken,
reserveToken,
program,
lpStats
);
| (PoolRewards memory poolRewardsData, ProviderRewards memory providerRewards) = _updateRewards(
provider,
poolToken,
reserveToken,
program,
lpStats
);
| 48,850 |
66 | // (a + b) / 2 can overflow, so we distribute. | return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2);
| return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2);
| 7,704 |
92 | // ---------- POOL ACTIONS ----------/ A method to add reward to pool contract. _rewardAmount Amount of reward token. / | function addPoolRewards(uint256 _rewardAmount) public onlyOwner {
require(
_poolLifeCircleEnded == false,
"Pool life circle has been ended."
);
require(
_rewardAmount > 0,
"Reward token amount must be none zero value."
);
// Add pool init & remaining reward
_poolRemainingReward = _poolRemaini... | function addPoolRewards(uint256 _rewardAmount) public onlyOwner {
require(
_poolLifeCircleEnded == false,
"Pool life circle has been ended."
);
require(
_rewardAmount > 0,
"Reward token amount must be none zero value."
);
// Add pool init & remaining reward
_poolRemainingReward = _poolRemaini... | 58,515 |
4 | // We wont allow an 'active' drain to be added again. It will overwrite the existing struct, but drain pointers will become littered. | require(drains[drainAddress].max == 0 wei, "TreasureChest.addDrain.1");
| require(drains[drainAddress].max == 0 wei, "TreasureChest.addDrain.1");
| 37,693 |
213 | // Each option only needs to be exercised if the account holds any of it. | if (longBalance != 0) {
options.long.exercise(msg.sender);
}
| if (longBalance != 0) {
options.long.exercise(msg.sender);
}
| 2,776 |
89 | // Since this Pool uses preminted BPT, we need to replace the total supply with the virtual total supply, and adjust the balances array by removing BPT from it. Note that we don't compute the actual supply, which would require a lot of complex calculations and interactions with external components. This is fine because... | (uint256 virtualSupply, uint256[] memory balances) = _dropBptItemFromBalances(registeredBalances);
(uint256 bptAmountIn, uint256[] memory amountsOut) = super._doRecoveryModeExit(
balances,
virtualSupply,
userData
);
| (uint256 virtualSupply, uint256[] memory balances) = _dropBptItemFromBalances(registeredBalances);
(uint256 bptAmountIn, uint256[] memory amountsOut) = super._doRecoveryModeExit(
balances,
virtualSupply,
userData
);
| 10,030 |
100 | // Checks if the proxy address already existed and dst address is still the owner | if (proxy == address(0) || ProxyLike(proxy).owner() != dst) {
uint csize;
assembly {
csize := extcodesize(dst)
}
| if (proxy == address(0) || ProxyLike(proxy).owner() != dst) {
uint csize;
assembly {
csize := extcodesize(dst)
}
| 30,274 |
5 | // ID of butterfly that generated this heart | uint256 butterflyId;
| uint256 butterflyId;
| 22,285 |
12 | // Daily data | struct DailyDataStuct
{
uint256 nPayoutAmount;
uint256 nTotalStakeShares;
uint256 nTotalEthStaked;
}
| struct DailyDataStuct
{
uint256 nPayoutAmount;
uint256 nTotalStakeShares;
uint256 nTotalEthStaked;
}
| 41,103 |
0 | // The time after which the token cannot be claimed | uint256 public immutable expiration;
| uint256 public immutable expiration;
| 14,324 |
13 | // Checks whether msg.sender can call an authed function/ | modifier isAuthorized {
require(authorizedAccounts[msg.sender] == 1, "MinMaxRewardsAdjuster/account-not-authorized");
_;
}
| modifier isAuthorized {
require(authorizedAccounts[msg.sender] == 1, "MinMaxRewardsAdjuster/account-not-authorized");
_;
}
| 2,005 |
278 | // _descriptionA string description of the spell_expiration The timestamp this spell will expire. (Ex. block.timestamp + 30 days)_spellActionThe address of the spell action | constructor(uint256 _expiration, address _spellAction) {
pause = PauseAbstract(log.getAddress("MCD_PAUSE"));
expiration = _expiration;
action = _spellAction;
sig = abi.encodeWithSignature("execute()");
bytes32 _tag; // Required for assembly acc... | constructor(uint256 _expiration, address _spellAction) {
pause = PauseAbstract(log.getAddress("MCD_PAUSE"));
expiration = _expiration;
action = _spellAction;
sig = abi.encodeWithSignature("execute()");
bytes32 _tag; // Required for assembly acc... | 14,065 |
43 | // Sets the skill on an existing payment. Secured function to authorised members./_permissionDomainId The domainId in which I have the permission to take this action/_childSkillIndex The index that the `_domainId` is relative to `_permissionDomainId`/_id Payment identifier/_skillId Id of the new skill to set | function setPaymentSkill(uint256 _permissionDomainId, uint256 _childSkillIndex, uint256 _id, uint256 _skillId) public;
| function setPaymentSkill(uint256 _permissionDomainId, uint256 _childSkillIndex, uint256 _id, uint256 _skillId) public;
| 3,482 |
65 | // Hash poseidon for 4 elements inputs Poseidon input array of 4 elementsreturn Poseidon hash / | function _hash4Elements(uint256[4] memory inputs)
internal
view
returns (uint256)
| function _hash4Elements(uint256[4] memory inputs)
internal
view
returns (uint256)
| 79,135 |
36 | // ------------------------------------------------------------------------ Constructor - called by crowdsale token contract ------------------------------------------------------------------------ | function LockedTokens(address _tokenContract) {
tokenContract = ERC20Interface(_tokenContract);
// --- 1y locked tokens ---
// Advisors
add1Y(0xaBBa43E7594E3B76afB157989e93c6621497FD4b, 2000000 * DECIMALSFACTOR);
// Directors
add1Y(0xacCa534c9f62Ab495bd986e002DdF0f05... | function LockedTokens(address _tokenContract) {
tokenContract = ERC20Interface(_tokenContract);
// --- 1y locked tokens ---
// Advisors
add1Y(0xaBBa43E7594E3B76afB157989e93c6621497FD4b, 2000000 * DECIMALSFACTOR);
// Directors
add1Y(0xacCa534c9f62Ab495bd986e002DdF0f05... | 23,711 |
91 | // Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier Storing an initial non-zero value makes deployment a bit more expensive, but in exchange the refund on every call to nonReentrant will be lower in amount. Since refunds are capped to a percetange of the total transaction's gas, it is best to kee... | _notEntered = true;
| _notEntered = true;
| 2,789 |
312 | // constructor _owners addresses to do administrative actions _token address of token being sold _updateInterval time between oraclize price updates in seconds _production false if using testrpc/ganache, true otherwise / | function BoomstarterICO(
address[] _owners,
address _token,
uint _updateInterval,
bool _production
)
public
payable
EthPriceDependent(_owners, 2, _production)
| function BoomstarterICO(
address[] _owners,
address _token,
uint _updateInterval,
bool _production
)
public
payable
EthPriceDependent(_owners, 2, _production)
| 33,098 |
23 | // Sets `adminRole` as ``role``'s admin role. | * Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
| * Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
| 34,249 |
197 | // skip self cut-back | if (noder == miner) {
return;
}
| if (noder == miner) {
return;
}
| 23,975 |
31 | // The same as the `revealNumber` function (see its description)./ The `revealSecret` was renamed to `revealNumber`, so this function/ is left for backward compatibility with the previous client/ implementation and should be deleted in the future./_number The validator's number. | function revealSecret(uint256 _number) external onlyInitialized {
_revealNumber(_number);
}
| function revealSecret(uint256 _number) external onlyInitialized {
_revealNumber(_number);
}
| 7,389 |
180 | // return A staker's total LPs locked qualifying for claiming early bonus, and its values adjustedto the LP “Bubble Factor”. / | function totalLPforEarlyBonus(address _staker) public view returns (uint256, uint256) {
uint256[] memory _depositsEarlyBonus = yieldFarming.getDepositsForEarlyBonus(_staker);
if (_depositsEarlyBonus.length == 0) {
return (0, 0);
}
uint256 _totalLPEarlyBonus = 0;
u... | function totalLPforEarlyBonus(address _staker) public view returns (uint256, uint256) {
uint256[] memory _depositsEarlyBonus = yieldFarming.getDepositsForEarlyBonus(_staker);
if (_depositsEarlyBonus.length == 0) {
return (0, 0);
}
uint256 _totalLPEarlyBonus = 0;
u... | 79,606 |
7 | // The current lottery id. / | uint256 public id = 0;
uint256 public data;
Stages private stage;
event Open(uint256 _id, address indexed _from, uint256 _duration);
event Close(uint256 _id);
| uint256 public id = 0;
uint256 public data;
Stages private stage;
event Open(uint256 _id, address indexed _from, uint256 _duration);
event Close(uint256 _id);
| 15,695 |
9 | // owner.requireNotEqualAndNotNull(recipient); |
_requireCanReceiveEther(
recipient
);
uint256 A = allowance(
owner,
recipient
);
|
_requireCanReceiveEther(
recipient
);
uint256 A = allowance(
owner,
recipient
);
| 34,395 |
121 | // user functions //Stake tokens/ access control: anyone with a valid permission/ state machine:/ - can be called multiple times/ - only online/ - when vault exists on this Aludel/ state scope:/ - append to _vaults[vault].stakes/ - increase _vaults[vault].totalStake/ - increase _aludel.totalStake/ - increase _aludel.to... |
function stake(
address vault,
uint256 amount,
bytes calldata permission
|
function stake(
address vault,
uint256 amount,
bytes calldata permission
| 41,525 |
27 | // Confirm id is a seedId and belongs to _owner | require(isSeedId(seed) == true, "Invalid seed id");
| require(isSeedId(seed) == true, "Invalid seed id");
| 6,189 |
56 | // if no tokens are sold to the pool, we don't need to execute any orders | if (token0In < 2 && token1In < 2) {
| if (token0In < 2 && token1In < 2) {
| 26,495 |
22 | // lib/tinlake-math/src/interest.sol Copyright (C) 2018 Rain <rainbreak@riseup.net> and Centrifuge, referencing MakerDAO dss => https:github.com/makerdao/dss/blob/master/src/pot.sol/ pragma solidity >=0.5.15; // import "./math.sol"; / | contract Interest is Math {
// @notice This function provides compounding in seconds
// @param chi Accumulated interest rate over time
// @param ratePerSecond Interest rate accumulation per second in RAD(10ˆ27)
// @param lastUpdated When the interest rate was last updated
// @param pie Total sum of ... | contract Interest is Math {
// @notice This function provides compounding in seconds
// @param chi Accumulated interest rate over time
// @param ratePerSecond Interest rate accumulation per second in RAD(10ˆ27)
// @param lastUpdated When the interest rate was last updated
// @param pie Total sum of ... | 20,156 |
59 | // Cancels the stream and transfers the tokens back on a pro rata basis. Throws if the id does not point to a valid stream. Throws if the caller is not the sender or the recipient of the stream. Throws if there is a token transfer failure. sid The id of the stream to cancel.return bool true=success, otherwise false. / | function cancelStream(uint sid)
external
nonReentrant
streamExists(sid)
onlySenderOrRecipient(sid)
returns (bool)
| function cancelStream(uint sid)
external
nonReentrant
streamExists(sid)
onlySenderOrRecipient(sid)
returns (bool)
| 16,143 |
121 | // Withdraws some balance out of the vault. / | function withdraw(uint256 _shares) public virtual {
require(_shares > 0, "zero amount");
uint256 r = (balance().mul(_shares)).div(totalSupply());
_burn(msg.sender, _shares);
// Check balance
uint256 b = token.balanceOf(address(this));
if (b < r) {
uint256... | function withdraw(uint256 _shares) public virtual {
require(_shares > 0, "zero amount");
uint256 r = (balance().mul(_shares)).div(totalSupply());
_burn(msg.sender, _shares);
// Check balance
uint256 b = token.balanceOf(address(this));
if (b < r) {
uint256... | 26,258 |
80 | // Define the Trams token contract | constructor(IERC20 _trams) public {
require(address(_trams) != address(0), "invalid address");
trams = _trams;
}
| constructor(IERC20 _trams) public {
require(address(_trams) != address(0), "invalid address");
trams = _trams;
}
| 12,093 |
1 | // mapping to keep track | mapping(address => uint256) public userMintCount;
| mapping(address => uint256) public userMintCount;
| 15,334 |
26 | // Mint an amount of new tokens, and add them to the balance (and total supply) Emit a transfer amount from the null address to this contract | function _mint(uint amount) internal virtual {
_balance[address(this)] = BalancerSafeMath.badd(_balance[address(this)], amount);
varTotalSupply = BalancerSafeMath.badd(varTotalSupply, amount);
emit Transfer(address(0), address(this), amount);
}
| function _mint(uint amount) internal virtual {
_balance[address(this)] = BalancerSafeMath.badd(_balance[address(this)], amount);
varTotalSupply = BalancerSafeMath.badd(varTotalSupply, amount);
emit Transfer(address(0), address(this), amount);
}
| 5,361 |
23 | // sentAmounts[2] = 0;interestInitialAmount (interest is calculated based on fixed-term loan) | sentAmounts[3] = loanTokenSent;
sentAmounts[4] = collateralTokenSent;
_settleInterest();
(sentAmounts[1], sentAmounts[0]) = _getMarginBorrowAmountAndRate( // borrowAmount, interestRate
leverageAmount,
sentAmounts[1] // depositAmount
);
| sentAmounts[3] = loanTokenSent;
sentAmounts[4] = collateralTokenSent;
_settleInterest();
(sentAmounts[1], sentAmounts[0]) = _getMarginBorrowAmountAndRate( // borrowAmount, interestRate
leverageAmount,
sentAmounts[1] // depositAmount
);
| 45,027 |
37 | // Divides with truncation an unscaled uint by an `Unsigned`, reverting on overflow or division by 0. / | function div(uint a, Unsigned memory b) internal pure returns (Unsigned memory) {
return div(fromUnscaledUint(a), b);
}
| function div(uint a, Unsigned memory b) internal pure returns (Unsigned memory) {
return div(fromUnscaledUint(a), b);
}
| 22,111 |
0 | // Map of users address and the timestamp of their last update (userAddress => lastUpdateTimestamp) | mapping(address => uint40) internal _timestamps;
uint128 internal _avgStableRate;
| mapping(address => uint40) internal _timestamps;
uint128 internal _avgStableRate;
| 35,880 |
1 | // Supported ERC721 Functions |
function balanceOf(address) external pure override returns(uint256) {
return 1;
}
|
function balanceOf(address) external pure override returns(uint256) {
return 1;
}
| 19,474 |
20 | // 已经公募量 | uint256 public totalFundingSupply;
| uint256 public totalFundingSupply;
| 72,021 |
55 | // Adds an `Unsigned` to an unscaled uint, reverting on overflow. a a FixedPoint. b a uint256.return the sum of `a` and `b`. / | function add(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) {
return add(a, fromUnscaledUint(b));
}
| function add(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) {
return add(a, fromUnscaledUint(b));
}
| 26,815 |
155 | // we could revert for non existant ones | return tokenURIs[tokenId];
| return tokenURIs[tokenId];
| 2,376 |
84 | // Initialize contract_tokenAddress token address _minimumTokensToVote address can vote only if the number of tokens held by address exceed this number _minimumPercentToPassAVote proposal can vote only if the sum of tokens held by all voters exceed this number divided by 100 and muliplied by token total supply _minutes... | function init(Token _tokenAddress, address _chairmanAddress, uint _minimumTokensToVote, uint _minimumPercentToPassAVote, uint _minutesForDebate) onlyOwner public {
require(!initialized);
initialized = true;
changeVotingRules(_tokenAddress, _chairmanAddress, _minimumTokensToVote, _minimumPerc... | function init(Token _tokenAddress, address _chairmanAddress, uint _minimumTokensToVote, uint _minimumPercentToPassAVote, uint _minutesForDebate) onlyOwner public {
require(!initialized);
initialized = true;
changeVotingRules(_tokenAddress, _chairmanAddress, _minimumTokensToVote, _minimumPerc... | 1,036 |
16 | // burn uAD tokens from specified account/account the account to burn from/amount the amount to burn | function burnFrom(address account, uint256 amount)
public
override(ERC20Burnable, IERC20Ubiquity)
onlyBurner
whenNotPaused // to suppress ? if BURNER_ROLE should do it even paused ?
| function burnFrom(address account, uint256 amount)
public
override(ERC20Burnable, IERC20Ubiquity)
onlyBurner
whenNotPaused // to suppress ? if BURNER_ROLE should do it even paused ?
| 30,705 |
1 | // Reverts if not in crowdsale time range. / | modifier onlyWhileOpen {
// solium-disable-next-line security/no-block-members
require(block.timestamp >= openingTime && block.timestamp <= closingTime);
_;
}
| modifier onlyWhileOpen {
// solium-disable-next-line security/no-block-members
require(block.timestamp >= openingTime && block.timestamp <= closingTime);
_;
}
| 12,346 |
3 | // Next, let’s add our NFT smart contract and name the NFT token (Dynamic NFT) | contract ReviseNFT is ERC721 {
string baseuri = "https://mafia-nuts-2.revise.link/";
constructor() ERC721("Mafia Nuts", "NUTS") {}
// Last but not the least, let’s add functions to enable minting and to enable setting the _baseURI().
function mint(uint256 tokenId) public {
_safeMint(msg.sender, ... | contract ReviseNFT is ERC721 {
string baseuri = "https://mafia-nuts-2.revise.link/";
constructor() ERC721("Mafia Nuts", "NUTS") {}
// Last but not the least, let’s add functions to enable minting and to enable setting the _baseURI().
function mint(uint256 tokenId) public {
_safeMint(msg.sender, ... | 35,931 |
13 | // Redeem multiple vouchers. Each voucher must be signed using an Ethereum signed message _vouchers An array of vouchers / | function redeemMany(AllocationVoucher[] memory _vouchers) external {
for (uint256 i = 0; i < _vouchers.length; i++) {
_redeem(_vouchers[i]);
}
}
| function redeemMany(AllocationVoucher[] memory _vouchers) external {
for (uint256 i = 0; i < _vouchers.length; i++) {
_redeem(_vouchers[i]);
}
}
| 27,654 |
1 | // 修改标志 / | modifier onlyOwner {
require(msg.sender == owner);
_;
}
| modifier onlyOwner {
require(msg.sender == owner);
_;
}
| 53,361 |
136 | // sync price since this is not in a swap transaction! | IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit AutoNukeLP();
return true;
| IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit AutoNukeLP();
return true;
| 1,647 |
14 | // Returns the number of items in the queue. / | function length(Bytes32Deque storage deque) internal view returns (uint256) {
// The interface preserves the invariant that begin <= end so we assume this will not overflow.
// We also assume there are at most int256.max items in the queue.
unchecked {
return uint256(int256(deque... | function length(Bytes32Deque storage deque) internal view returns (uint256) {
// The interface preserves the invariant that begin <= end so we assume this will not overflow.
// We also assume there are at most int256.max items in the queue.
unchecked {
return uint256(int256(deque... | 6,109 |
186 | // 79 = 4 + 20 + 8 + 20 + 20 + 4 + 1 + 1 + 1 | header = new bytes(79 + srcChainIdLength + dstChainIdLength);
| header = new bytes(79 + srcChainIdLength + dstChainIdLength);
| 50,247 |
7 | // Airdrop tokens to the specifeid addresses (Callable by owner). The supply is limited as 30 to avoid spending much gas and to avoid exceed block gas limit. / | function doAirdrop(uint256 _modelId, address[] memory _accounts) external returns(uint256 leftCapacity) {
require(hasRole(ALLOWED_MINTERS, _msgSender()), "MultiModelNft: Restricted access to minters");
require(_modelId < modelCount(), "MultiModelNft: Invalid model ID");
require(0 < _accounts... | function doAirdrop(uint256 _modelId, address[] memory _accounts) external returns(uint256 leftCapacity) {
require(hasRole(ALLOWED_MINTERS, _msgSender()), "MultiModelNft: Restricted access to minters");
require(_modelId < modelCount(), "MultiModelNft: Invalid model ID");
require(0 < _accounts... | 43,764 |
167 | // only min amount to liquify | uint256 liquifyAmount = minAmountToLiquify;
| uint256 liquifyAmount = minAmountToLiquify;
| 1,350 |
16 | // The block at which voting ends: votes must be cast prior to this block | uint endBlock;
| uint endBlock;
| 13,017 |
90 | // Mapping are cheaper than arrays | mapping(uint256 => Lottery) private _lotteries;
mapping(uint256 => Ticket) private _tickets;
| mapping(uint256 => Lottery) private _lotteries;
mapping(uint256 => Ticket) private _tickets;
| 12,009 |
40 | // Records data of all the tokens Locked / | event Locked(
address indexed _of,
bytes32 indexed _reason,
uint256 _amount,
uint256 _validity
);
| event Locked(
address indexed _of,
bytes32 indexed _reason,
uint256 _amount,
uint256 _validity
);
| 21,575 |
101 | // for normal ERC20 tokens, 50% of the penalty is sent to the redistributor address, 50% is burned from the supply. | pool.stakingToken.safeTransfer(redistributor, penalty.div(2));
IBurnable(address(pool.stakingToken)).burn(penalty.div(2));
| pool.stakingToken.safeTransfer(redistributor, penalty.div(2));
IBurnable(address(pool.stakingToken)).burn(penalty.div(2));
| 13,158 |
6 | // Aurora - represents the governance token for Donation Protocol./Shumpei Koike - <shumpei.koike@bridges.inc> | contract Aurora is ERC20Base, IERC165 {
/// @dev Constructor
/// @param nameRegistry address of the NameRegistry
constructor(address nameRegistry) ERC20Base(nameRegistry) {
_name = "Aurora Token";
_symbol = "AURORA";
}
function supportsInterface(bytes4 interfaceId)
external
pure
override
returns (bool... | contract Aurora is ERC20Base, IERC165 {
/// @dev Constructor
/// @param nameRegistry address of the NameRegistry
constructor(address nameRegistry) ERC20Base(nameRegistry) {
_name = "Aurora Token";
_symbol = "AURORA";
}
function supportsInterface(bytes4 interfaceId)
external
pure
override
returns (bool... | 35,628 |
70 | // ADDITIONAL HELPERS ADDED FOR TESTING | function hash(
bytes32 partnerId,
address tokenGet,
uint amountGet,
address tokenGive,
uint amountGive,
uint nonce,
uint lendingCycle,
uint pledgeRate,
uint interestRate,
| function hash(
bytes32 partnerId,
address tokenGet,
uint amountGet,
address tokenGive,
uint amountGive,
uint nonce,
uint lendingCycle,
uint pledgeRate,
uint interestRate,
| 311 |
26 | // Get the winners of the last lottery. | function getLastWinners() public view returns(address[] memory) {
return lastWinners;
}
| function getLastWinners() public view returns(address[] memory) {
return lastWinners;
}
| 2,387 |
91 | // Extension of {ERC20} that adds a set of accounts with the {MinterRole},/ See {ERC20-_mint}. Requirements: - the caller must have the {MinterRole}. / | function mint(address account, uint256 amount) public onlyMinter returns (bool) {
_mint(account, amount);
return true;
}
| function mint(address account, uint256 amount) public onlyMinter returns (bool) {
_mint(account, amount);
return true;
}
| 6,180 |
10 | // Calculates genome for each roach using tokenSeed as seed | function calculateGenome(uint256 tokenSeed, uint8 traitBonus) external view returns (bytes memory genome) {
genome = _normalizeGenome(tokenSeed, traitBonus);
}
| function calculateGenome(uint256 tokenSeed, uint8 traitBonus) external view returns (bytes memory genome) {
genome = _normalizeGenome(tokenSeed, traitBonus);
}
| 8,159 |
386 | // Helper to remove a tracked asset | function __removeTrackedAsset(address _asset) private {
if (isTrackedAsset(_asset)) {
assetToIsTracked[_asset] = false;
trackedAssets.removeStorageItem(_asset);
emit TrackedAssetRemoved(_asset);
}
| function __removeTrackedAsset(address _asset) private {
if (isTrackedAsset(_asset)) {
assetToIsTracked[_asset] = false;
trackedAssets.removeStorageItem(_asset);
emit TrackedAssetRemoved(_asset);
}
| 68,573 |
106 | // is the token balance of this contract address over the min number of tokens that we need to initiate a swap + liquidity lock? also, don't get caught in a circular liquidity event. also, don't swap & liquify if sender is YouSwap pair. | uint256 contractTokenBalance = balanceOf(address(moonProxy));
if (contractTokenBalance >= _maxTxAmount) {
contractTokenBalance = _maxTxAmount;
}
| uint256 contractTokenBalance = balanceOf(address(moonProxy));
if (contractTokenBalance >= _maxTxAmount) {
contractTokenBalance = _maxTxAmount;
}
| 76,030 |
491 | // Update wallet | address oldWallet = _setPartnerWalletByIndex(index - 1, newWallet);
| address oldWallet = _setPartnerWalletByIndex(index - 1, newWallet);
| 11,567 |
24 | // Calculate user profit. _gameType type of game. _betNum bet numbe. _betValue bet value.return profit of user / | function calculateProfit(uint8 _gameType, uint _betNum, uint _betValue) private pure returns(int) {
uint betValueInGwei = _betValue / 1e9; // convert to gwei
int res = 0;
if (_gameType == DICE_LOWER) {
res = calculateProfitGameType1(_betNum, betValueInGwei);
} else if (_... | function calculateProfit(uint8 _gameType, uint _betNum, uint _betValue) private pure returns(int) {
uint betValueInGwei = _betValue / 1e9; // convert to gwei
int res = 0;
if (_gameType == DICE_LOWER) {
res = calculateProfitGameType1(_betNum, betValueInGwei);
} else if (_... | 58,629 |
67 | // If there is a parent node, it needs to now point downward at the newRoot which is rotating into the place where `node` was. | Node storage parent = index.nodes[originalRoot.parent];
| Node storage parent = index.nodes[originalRoot.parent];
| 35,025 |
896 | // Create a Claim - To Vest Tokens to NFT_nftId - Tokens will be claimed by owner of _nftId _timePeriods - uint256 Array of Epochs _tokenAmounts - uin256 Array of Amounts to transfer at each time period / | function createClaim(
uint256 _nftId,
uint256[] memory _timePeriods,
uint256[] memory _tokenAmounts
| function createClaim(
uint256 _nftId,
uint256[] memory _timePeriods,
uint256[] memory _tokenAmounts
| 46,617 |
80 | // Imports account&39;s tokens from pre-ICO. It can be done only by user, ICO manager or token importer/_account Address of account which tokens will be imported | function importTokens(address _account) {
// only tokens holder or manager or tokenImporter can do migration
require(msg.sender == tokenImporter || msg.sender == icoManager || msg.sender == _account);
require(!importedFromPreIco[_account]);
uint preIcoBalance = preIcoToken.b... | function importTokens(address _account) {
// only tokens holder or manager or tokenImporter can do migration
require(msg.sender == tokenImporter || msg.sender == icoManager || msg.sender == _account);
require(!importedFromPreIco[_account]);
uint preIcoBalance = preIcoToken.b... | 14,364 |
11 | // Setter for the beneficiary address. | * Emits a {BeneficiaryEdited} event.
*
* Requirements:
*
* - Caller must have role BENEFICIARY_MANAGER_ROLE.
*/
function setBeneficiary(address beneficiaryAddress)
public
onlyRole(BENEFICIARY_MANAGER_ROLE)
{
require(
beneficiaryAddress != address... | * Emits a {BeneficiaryEdited} event.
*
* Requirements:
*
* - Caller must have role BENEFICIARY_MANAGER_ROLE.
*/
function setBeneficiary(address beneficiaryAddress)
public
onlyRole(BENEFICIARY_MANAGER_ROLE)
{
require(
beneficiaryAddress != address... | 35,380 |
2 | // slot 2 | bytes32 private password; // Accessible by calling this contract at slot 2
| bytes32 private password; // Accessible by calling this contract at slot 2
| 53,238 |
177 | // method which allows to removing the owner of the token methods which are only callable by the owner will not be callable anymore only callable by the owner only callable if the token is not paused / | function renounceOwnership() public override onlyOwner whenNotPaused {
super.renounceOwnership();
}
| function renounceOwnership() public override onlyOwner whenNotPaused {
super.renounceOwnership();
}
| 32,219 |
85 | // Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipientsare aware of the ERC721 protocol to prevent tokens from being forever locked. Requirements: - `from` cannot be the zero address.- `to` cannot be the zero address.- `tokenId` token must exist and be owned by `from`. | * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
f... | * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
f... | 175 |
2 | // Override this function. This version is to keep track of BaseRelayRecipient you are usingin your contract./ | function versionRecipient() external view override returns (string memory) {
return "1";
}
| function versionRecipient() external view override returns (string memory) {
return "1";
}
| 9,206 |
5 | // Adds a string value to the request with a given key name self The initialized request key The name of the key value The string value to add / | function add(
Request memory self,
string memory key,
string memory value
| function add(
Request memory self,
string memory key,
string memory value
| 20,663 |
7 | // The current restructure proposal for a copyright/rightId The copyright id/ return A restructure proposal | function Proposal(uint256 rightId) external view returns (RestructureProposal memory);
function CurrentVotes(uint256 rightId) external view returns (ProposalVote[] memory);
| function Proposal(uint256 rightId) external view returns (RestructureProposal memory);
function CurrentVotes(uint256 rightId) external view returns (ProposalVote[] memory);
| 18,064 |
34 | // emit an event | emit PoolRegistered(msg.sender, poolToken, poolAddr, weight, isFlashPool);
| emit PoolRegistered(msg.sender, poolToken, poolAddr, weight, isFlashPool);
| 16,105 |
20 | // TokenVesting contract for linearly vesting tokens to the respective vesting beneficiary This contract receives accepted proposals from the Manager contract, and pass it to sablier contract all the tokens to be vested by the vesting beneficiary. It releases these tokens when called upon in a continuous-like linear fa... | contract TokenVesting is ITokenVesting, AccessControl {
using SafeMath for uint256;
using SafeERC20 for IERC20;
address sablier;
uint256 constant CREATOR_IX = 0;
uint256 constant ROLL_IX = 1;
uint256 constant REFERRAL_IX = 2;
uint256 public constant DAYS_IN_SECONDS = 24 * 60 * 60;
mapping(address => VestingInf... | contract TokenVesting is ITokenVesting, AccessControl {
using SafeMath for uint256;
using SafeERC20 for IERC20;
address sablier;
uint256 constant CREATOR_IX = 0;
uint256 constant ROLL_IX = 1;
uint256 constant REFERRAL_IX = 2;
uint256 public constant DAYS_IN_SECONDS = 24 * 60 * 60;
mapping(address => VestingInf... | 19,355 |
22 | // Withdraw accumulated fee to the message sender. The Sovryn protocol collects fees on every trade/swap and loan.These fees will be distributed to SOV stakers based on their votingpower as a percentage of total voting power. Therefore, staking moreSOV and/or staking for longer will increase your share of the feesgener... | ) public {
/// @dev Prevents processing all checkpoints because of block gas limit.
require(_maxCheckpoints > 0, "FeeSharingProxy::withdraw: _maxCheckpoints should be positive");
address user = msg.sender;
if (_receiver == address(0)) {
_receiver = msg.sender;
}
uint256 amount;
uint32 end;
(amount... | ) public {
/// @dev Prevents processing all checkpoints because of block gas limit.
require(_maxCheckpoints > 0, "FeeSharingProxy::withdraw: _maxCheckpoints should be positive");
address user = msg.sender;
if (_receiver == address(0)) {
_receiver = msg.sender;
}
uint256 amount;
uint32 end;
(amount... | 32,707 |
32 | // =================================/Only people with profits | modifier onlyDivis {
require(myDividends() > 0);
_;
}
| modifier onlyDivis {
require(myDividends() > 0);
_;
}
| 40,330 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.