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 |
|---|---|---|---|---|
127 | // Looks at all active defined games and:- tells each game to send fees to collector (us)- if ended: tries to pay winner, moves to endedGames | function refreshGames()
public
returns (uint _numGamesEnded, uint _feesCollected)
| function refreshGames()
public
returns (uint _numGamesEnded, uint _feesCollected)
| 63,880 |
86 | // if sold out, return Complete state NOTE: this would not work with a ReserveAuction where this minter holds the token!!!! | if (_nftTotalSupply() == maxSupply) {
return State.Complete;
}
| if (_nftTotalSupply() == maxSupply) {
return State.Complete;
}
| 2,531 |
4 | // Only when the UA needs to resume the message flow in blocking mode and clear the stored payload_srcChainId - the chainId of the source chain_srcAddress - the contract address of the source contract at the source chain | function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress)
external;
| function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress)
external;
| 20,015 |
70 | // update data for new owner | tokenOwner[_tokenId] = newOwner;
| tokenOwner[_tokenId] = newOwner;
| 49,093 |
30 | // emit softCap reached | softCapReached = true;
| softCapReached = true;
| 21,794 |
11 | // LiquidityPoolData liquidityPoolData;amm liquidity pool data. | uint256 liquidityPoolTokenAmount;
uint256 reward; // position reward.
uint256 lockedRewardPerBlock; // position locked reward per block.
uint256 creationBlock; // block when this position was created.
| uint256 liquidityPoolTokenAmount;
uint256 reward; // position reward.
uint256 lockedRewardPerBlock; // position locked reward per block.
uint256 creationBlock; // block when this position was created.
| 7,104 |
20 | // Event emitted when deposit fee is updated | event DepositFeeUpdated(uint256 indexed pid, uint16 oldFee, uint16 newFee);
| event DepositFeeUpdated(uint256 indexed pid, uint16 oldFee, uint16 newFee);
| 34,227 |
56 | // Verifies that an order signature is valid./signer address of signer./hash Signed Keccak-256 hash./v ECDSA signature parameter v./r ECDSA signature parameters r./s ECDSA signature parameters s./ return Validity of order signature. | function isValidSignature(
address signer,
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s)
public
pure
returns (bool)
| function isValidSignature(
address signer,
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s)
public
pure
returns (bool)
| 16,636 |
161 | // in case of burn on behalf | if(_from != msg.sender) {
| if(_from != msg.sender) {
| 50,088 |
11 | // Maximum value that can be safely used as a divisor. Hardcoded to 24 digits. / | function maxFixedDivisor() internal pure returns(int256) {
return 1000000000000000000000000000000000000000000000000;
}
| function maxFixedDivisor() internal pure returns(int256) {
return 1000000000000000000000000000000000000000000000000;
}
| 47,732 |
130 | // calls `buyTokens()` | buyTokens();
| buyTokens();
| 54,916 |
12 | // passing scriptAddress to allow called script access its own public fx-s if needed | if(scriptAddress.delegatecall(bytes4(keccak256("execute(address)")), scriptAddress)) {
script.state = ScriptState.Done;
result = true;
} else {
| if(scriptAddress.delegatecall(bytes4(keccak256("execute(address)")), scriptAddress)) {
script.state = ScriptState.Done;
result = true;
} else {
| 21,040 |
12 | // expectedLiquidity - availableLiquidity U = ------------------------------------- expectedLiquidity |
uint256 U_WAD = (WAD * (expectedLiquidity - availableLiquidity)) /
expectedLiquidity;
|
uint256 U_WAD = (WAD * (expectedLiquidity - availableLiquidity)) /
expectedLiquidity;
| 7,023 |
303 | // during the beta, ensure that the new staked balance isn't greater than the max limit | if (maxStakedBalanceEnabled) {
require(maxStakedBalances[_reserveToken] == 0 || initialStakedBalance.add(_amount) <= maxStakedBalances[_reserveToken], "ERR_MAX_STAKED_BALANCE_REACHED");
}
| if (maxStakedBalanceEnabled) {
require(maxStakedBalances[_reserveToken] == 0 || initialStakedBalance.add(_amount) <= maxStakedBalances[_reserveToken], "ERR_MAX_STAKED_BALANCE_REACHED");
}
| 10,130 |
72 | // Calculates the amount of tokens that has already vested. Default implementation is a linear vesting curve. / | function vestedAmount(address token, uint64 timestamp) public view virtual returns (uint256) {
return _vestingSchedule(IERC20(token).balanceOf(address(this)) + released(token), timestamp);
}
| function vestedAmount(address token, uint64 timestamp) public view virtual returns (uint256) {
return _vestingSchedule(IERC20(token).balanceOf(address(this)) + released(token), timestamp);
}
| 19,718 |
140 | // pay the rest of the 500 winners | pay500Winners(_pot);
| pay500Winners(_pot);
| 42,265 |
22 | // LARGE threshold is a super majority of 75% ||| FOR / (FOR + AGAINST)) > 3/4 ->4FOR > 3(FOR + AGAINST) ->FOR > 3TOTAL | result = (proposalVote.forVotes > 3 * proposalVote.againstVotes);
| result = (proposalVote.forVotes > 3 * proposalVote.againstVotes);
| 18,626 |
1 | // special variable holding info/address of about owner of smart contract consturctor:special function that can be called whenever a contrat is created. we can pass parameters to it or leave it as such | uint public balance;//this is to keep track of ether inside contract . we increase it time to time
| uint public balance;//this is to keep track of ether inside contract . we increase it time to time
| 20,948 |
146 | // deposit ids will be (_blockDepositId, _blockDepositId + 1, .... _blockDepositId + numDeposits - 1) | _blockDepositId = _blockDepositId.add(numDeposits);
require(
| _blockDepositId = _blockDepositId.add(numDeposits);
require(
| 36,910 |
264 | // Every time a monster gets pregnant, counter is incremented. | pregnantMonsters++;
| pregnantMonsters++;
| 41,035 |
4 | // Reference to the NFT contract | address nftContract;
| address nftContract;
| 8,943 |
5 | // Allows adapter to access to proxy's DAI balance in the vat | if (VatLike(vat).can(address(this), address(daiJoin)) == 0) {
VatLike(vat).hope(daiJoin);
}
| if (VatLike(vat).can(address(this), address(daiJoin)) == 0) {
VatLike(vat).hope(daiJoin);
}
| 49,700 |
20 | // firstly we are getting tokens from the original caller of the transaction since the pool can get less/more tokens then expected, _amountToSell_ can be changed | {
| {
| 24,268 |
7 | // Get the current ruling of a dispute. This is useful for parties to know if they should appeal._disputeID The ID of the dispute. return _ruling The current ruling which will be given if there is no appeal or which has been given. / | function currentRuling(uint256 _disputeID) public view onlyIfDisputeExists(_disputeID) returns(uint256 _ruling) {
return disputes[_disputeID].arbitrator.currentRuling(disputes[_disputeID].disputeID);
}
| function currentRuling(uint256 _disputeID) public view onlyIfDisputeExists(_disputeID) returns(uint256 _ruling) {
return disputes[_disputeID].arbitrator.currentRuling(disputes[_disputeID].disputeID);
}
| 24,472 |
2 | // max supply for 1st level NFTs | uint maxSupplyNft = 10000;
| uint maxSupplyNft = 10000;
| 26,940 |
8 | // Triggered when authorization status changed _address Address who will gain or lose authorization to _contractName _authorized Boolean whether or not the address is authorized _contractName Name of the contract / | event AuthorizationChanged(address indexed _address, bool _authorized, string _contractName);
| event AuthorizationChanged(address indexed _address, bool _authorized, string _contractName);
| 67,794 |
3 | // Balances MMT for each account | mapping(address => uint256) private balances;
| mapping(address => uint256) private balances;
| 22,078 |
102 | // withdraws ether can only be called by the owner if the converter is inactive or by upgrader contract can only be called after the upgrader contract has accepted the ownership of this contract can only be called if the converter has an ETH reserve_toaddress to send the ETH to/ | function withdrawETH(address payable _to)
public
override
protected
ownerOnly
validReserve(ETH_RESERVE_ADDRESS)
| function withdrawETH(address payable _to)
public
override
protected
ownerOnly
validReserve(ETH_RESERVE_ADDRESS)
| 25,307 |
86 | // Change in total pooled DAI is the total pooled DAI before fees minus the total pooled DAI after fees | (bool isOk, uint256 deltaTotalPooledDai) = postRebaseTotalPooledDai.trySub(_totalPooledDai); // Interest earned since last rebase
| (bool isOk, uint256 deltaTotalPooledDai) = postRebaseTotalPooledDai.trySub(_totalPooledDai); // Interest earned since last rebase
| 2,770 |
64 | // both sides safe | require(srcTotalDebtIssued <= multiply(srcSAFE.lockedCollateral, collateralType_.safetyPrice), "SAFEEngine/not-safe-src");
require(dstTotalDebtIssued <= multiply(dstSAFE.lockedCollateral, collateralType_.safetyPrice), "SAFEEngine/not-safe-dst");
| require(srcTotalDebtIssued <= multiply(srcSAFE.lockedCollateral, collateralType_.safetyPrice), "SAFEEngine/not-safe-src");
require(dstTotalDebtIssued <= multiply(dstSAFE.lockedCollateral, collateralType_.safetyPrice), "SAFEEngine/not-safe-dst");
| 9,582 |
323 | // Check whether it supports history of stakesreturn Always true / | function supportsHistory() external view returns (bool) {
_requireIsInitialized();
return true;
}
| function supportsHistory() external view returns (bool) {
_requireIsInitialized();
return true;
}
| 25,962 |
296 | // Modifier for functions that can only be called by the BNV manager | modifier onlyManager() {
require((msg.sender == _manager), "Bnv manager only");
_;
}
| modifier onlyManager() {
require((msg.sender == _manager), "Bnv manager only");
_;
}
| 44,177 |
137 | // accumulate tax | castles[castleId].taxPool += tax;
| castles[castleId].taxPool += tax;
| 38,623 |
29 | // Declare Life event structure | event LifeEvent(string name, string description, string mesg);
contractEvent[] public contractEvents;
| event LifeEvent(string name, string description, string mesg);
contractEvent[] public contractEvents;
| 50,425 |
367 | // See {IERC777-granularity}. This implementation always returns `1`. / |
function granularity() public view override returns (uint256) {
return 1;
}
|
function granularity() public view override returns (uint256) {
return 1;
}
| 69 |
132 | // validate token ownership, which also validates token existence under the hood | require(_from == ownerOf(_tokenId), "access denied");
| require(_from == ownerOf(_tokenId), "access denied");
| 42,767 |
33 | // Returns the downcasted int248 from int256, reverting onoverflow (when the input is less than smallest int248 orgreater than largest int248). Counterpart to Solidity's `int248` operator. Requirements: - input must fit into 248 bits _Available since v4.7._ / | function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
}
| function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
}
| 6,136 |
18 | // Enable or disable approval for a third party ("operator") to manage all of caller's tokens MUST emit the ApprovalForAll event on success _operatorAddress to add to the set of authorized operators _approvedTrue if the operator is approved, false to revoke approval / | function setApprovalForAll(address _operator, bool _approved) external;
| function setApprovalForAll(address _operator, bool _approved) external;
| 13,123 |
0 | // Convenience method for depositing eth into non-payable contractswhich the forked provider tests would like to impersonateas a message sender. destination destination of eth payment / | function fund(address destination) public payable {
selfdestruct(payable(address(destination)));
}
| function fund(address destination) public payable {
selfdestruct(payable(address(destination)));
}
| 9,085 |
18 | // Sets the collection name. _collectionId The id of the collection. _name The name to be set. / | function setCollectionName(
uint256 _collectionId,
string memory _name
| function setCollectionName(
uint256 _collectionId,
string memory _name
| 23,556 |
15 | // Event for new start & end blocks | event NewStartAndEndBlocks(uint256 startBlock, uint256 endBlock);
| event NewStartAndEndBlocks(uint256 startBlock, uint256 endBlock);
| 24,463 |
102 | // ---------------------------------------------------------------------------- Secondary Accounts Data Structure ---------------------------------------------------------------------------- | library Accounts {
struct Account {
uint timestamp;
uint index;
address account;
}
struct Data {
bool initialised;
mapping(address => Account) entries;
address[] index;
}
event AccountAdded(address owner, address account, uint totalAfter);
event AccountRemoved(address owner, address account, uint totalAfter);
function init(Data storage self) internal {
require(!self.initialised);
self.initialised = true;
}
function hasKey(Data storage self, address account) internal view returns (bool) {
return self.entries[account].timestamp > 0;
}
function add(Data storage self, address owner, address account) internal {
require(self.entries[account].timestamp == 0);
self.index.push(account);
self.entries[account] = Account(block.timestamp, self.index.length - 1, account);
emit AccountAdded(owner, account, self.index.length);
}
function remove(Data storage self, address owner, address account) internal {
require(self.entries[account].timestamp > 0);
uint removeIndex = self.entries[account].index;
emit AccountRemoved(owner, account, self.index.length - 1);
uint lastIndex = self.index.length - 1;
address lastIndexKey = self.index[lastIndex];
self.index[removeIndex] = lastIndexKey;
self.entries[lastIndexKey].index = removeIndex;
delete self.entries[account];
if (self.index.length > 0) {
self.index.pop();
}
}
function removeAll(Data storage self, address owner) internal {
if (self.initialised) {
while (self.index.length > 0) {
uint lastIndex = self.index.length - 1;
address lastIndexKey = self.index[lastIndex];
emit AccountRemoved(owner, lastIndexKey, lastIndex);
delete self.entries[lastIndexKey];
self.index.pop();
}
}
}
function length(Data storage self) internal view returns (uint) {
return self.index.length;
}
}
| library Accounts {
struct Account {
uint timestamp;
uint index;
address account;
}
struct Data {
bool initialised;
mapping(address => Account) entries;
address[] index;
}
event AccountAdded(address owner, address account, uint totalAfter);
event AccountRemoved(address owner, address account, uint totalAfter);
function init(Data storage self) internal {
require(!self.initialised);
self.initialised = true;
}
function hasKey(Data storage self, address account) internal view returns (bool) {
return self.entries[account].timestamp > 0;
}
function add(Data storage self, address owner, address account) internal {
require(self.entries[account].timestamp == 0);
self.index.push(account);
self.entries[account] = Account(block.timestamp, self.index.length - 1, account);
emit AccountAdded(owner, account, self.index.length);
}
function remove(Data storage self, address owner, address account) internal {
require(self.entries[account].timestamp > 0);
uint removeIndex = self.entries[account].index;
emit AccountRemoved(owner, account, self.index.length - 1);
uint lastIndex = self.index.length - 1;
address lastIndexKey = self.index[lastIndex];
self.index[removeIndex] = lastIndexKey;
self.entries[lastIndexKey].index = removeIndex;
delete self.entries[account];
if (self.index.length > 0) {
self.index.pop();
}
}
function removeAll(Data storage self, address owner) internal {
if (self.initialised) {
while (self.index.length > 0) {
uint lastIndex = self.index.length - 1;
address lastIndexKey = self.index[lastIndex];
emit AccountRemoved(owner, lastIndexKey, lastIndex);
delete self.entries[lastIndexKey];
self.index.pop();
}
}
}
function length(Data storage self) internal view returns (uint) {
return self.index.length;
}
}
| 49,775 |
251 | // Push tokens to recipient | if (amount0 > 0) token0.safeTransfer(to, amount0);
if (amount1 > 0) token1.safeTransfer(to, amount1);
emit Withdraw(msg.sender, to, shares, amount0, amount1);
| if (amount0 > 0) token0.safeTransfer(to, amount0);
if (amount1 > 0) token1.safeTransfer(to, amount1);
emit Withdraw(msg.sender, to, shares, amount0, amount1);
| 12,162 |
54 | // Extend parent behavior requiring purchase to respect the user's funding cap. _beneficiary Token purchaser _weiAmount Amount of wei contributed / | function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
super._preValidatePurchase(_beneficiary, _weiAmount);
require(contributions[_beneficiary].add(_weiAmount) <= caps[_beneficiary]);
}
| function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
super._preValidatePurchase(_beneficiary, _weiAmount);
require(contributions[_beneficiary].add(_weiAmount) <= caps[_beneficiary]);
}
| 52,319 |
5 | // Creates a notification when a commit is executed commitID ID of the commit that's executed / | event ExecuteCommit(uint128 commitID);
| event ExecuteCommit(uint128 commitID);
| 44,391 |
158 | // Delta | vKeySmall.delta2.x[0] = _vKey.delta2.x[0];
vKeySmall.delta2.x[1] = _vKey.delta2.x[1];
vKeySmall.delta2.y[0] = _vKey.delta2.y[0];
vKeySmall.delta2.y[1] = _vKey.delta2.y[1];
| vKeySmall.delta2.x[0] = _vKey.delta2.x[0];
vKeySmall.delta2.x[1] = _vKey.delta2.x[1];
vKeySmall.delta2.y[0] = _vKey.delta2.y[0];
vKeySmall.delta2.y[1] = _vKey.delta2.y[1];
| 62,922 |
1,182 | // adjustments[19]/mload(0x5060), Constraint expression for ecdsa/signature0/q_on_curve/on_curve: column19_row15column19_row15 - (column19_row7column20_row8176 + ecdsa/sig_config.alphacolumn19_row7 + ecdsa/sig_config.beta). |
let val := addmod(
mulmod(/*column19_row15*/ mload(0x3920), /*column19_row15*/ mload(0x3920), PRIME),
sub(
PRIME,
addmod(
|
let val := addmod(
mulmod(/*column19_row15*/ mload(0x3920), /*column19_row15*/ mload(0x3920), PRIME),
sub(
PRIME,
addmod(
| 4,398 |
192 | // write 3 bytes | let output := add(
add(
shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)),
shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))),
add(
shl( 6, and(mload(add(tablePtr, and(shr( 8, input), 0xFF))), 0xFF)),
and(mload(add(tablePtr, and( input , 0xFF))), 0xFF)
)
)
mstore(resultPtr, shl(232, output))
| let output := add(
add(
shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)),
shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))),
add(
shl( 6, and(mload(add(tablePtr, and(shr( 8, input), 0xFF))), 0xFF)),
and(mload(add(tablePtr, and( input , 0xFF))), 0xFF)
)
)
mstore(resultPtr, shl(232, output))
| 16,372 |
7 | // Controls the current state of the tontine | enum State {
// Money is currently with investment target
INVESTING,
// Contract has begun paying out
PAYING_OUT
}
| enum State {
// Money is currently with investment target
INVESTING,
// Contract has begun paying out
PAYING_OUT
}
| 780 |
37 | // add the period's energy to participant's overall total | participant.total += amount;
| participant.total += amount;
| 35,617 |
6 | // override this function | function _nonblockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual;
| function _nonblockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual;
| 25,137 |
45 | // Check if we've received extra tokens or didn't receive enough | uint256 actualBalance = IPARTY(party).balanceOf(address(this));
require(
actualBalance >= unallocatedParty,
"LPM::vestAllocation: Insufficient PARTY transferred"
);
unallocatedParty = actualBalance;
| uint256 actualBalance = IPARTY(party).balanceOf(address(this));
require(
actualBalance >= unallocatedParty,
"LPM::vestAllocation: Insufficient PARTY transferred"
);
unallocatedParty = actualBalance;
| 10,506 |
6 | // Tells if contract is on maintenancereturn _maintenance if contract is on maintenance / | function maintenance() public view returns (bool _maintenance) {
bytes32 position = maintenancePosition;
assembly {
_maintenance := sload(position)
}
}
| function maintenance() public view returns (bool _maintenance) {
bytes32 position = maintenancePosition;
assembly {
_maintenance := sload(position)
}
}
| 33,586 |
14 | // Returns TRUE if a key is present and has the given purpose. If the key is not present it returns FALSE. / | function keyHasPurpose(bytes32 _key, uint256 _purpose) external view returns (bool exists);
| function keyHasPurpose(bytes32 _key, uint256 _purpose) external view returns (bool exists);
| 514 |
3 | // fee constants | uint128 constant feeNominator = 997;
uint128 constant feeDenominator = 1000;
| uint128 constant feeNominator = 997;
uint128 constant feeDenominator = 1000;
| 51,502 |
25 | // Ownable is used because solidity complain trying to deploy a contract whose code is too large when everything is added into Lord of Coin contract./ The only owner function is `init` which is to setup for the first time after deployment./ After init finished, owner will be renounced automatically. owner() function will return 0x0 address. | contract DevTreasury is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
/// @dev Developer wallet
address payable public devWallet;
/// @dev SDVD contract address
address public sdvd;
/// @dev Uniswap router
IUniswapV2Router02 uniswapRouter;
/// @dev Uniswap factory
IUniswapV2Factory uniswapFactory;
/// @dev WETH address
address weth;
/// @dev Uniswap LP address
address public pairAddress;
/// @notice Release balance every 1 hour to dev wallet
uint256 public releaseThreshold = 1 hours;
/// @dev Last release timestamp
uint256 public releaseTime;
constructor (address _uniswapRouter, address _sdvd) public {
// Set dev wallet
devWallet = msg.sender;
// Set uniswap router
uniswapRouter = IUniswapV2Router02(_uniswapRouter);
// Set uniswap factory
uniswapFactory = IUniswapV2Factory(uniswapRouter.factory());
// Get weth address
weth = uniswapRouter.WETH();
// Set SDVD address
sdvd = _sdvd;
// Approve uniswap router to spend sdvd
IERC20(sdvd).approve(_uniswapRouter, uint256(- 1));
// Set initial release time
releaseTime = block.timestamp;
}
/* ========== Owner Only ========== */
function init() external onlyOwner {
// Get pair address after init because we wait until pair created in lord of coin
pairAddress = uniswapFactory.getPair(sdvd, weth);
// Renounce ownership immediately after init
renounceOwnership();
}
/* ========== Mutative ========== */
/// @notice Release SDVD to market regardless the price so dev doesn't own any SDVD from 0.5% fee.
/// This is to protect SDVD holders.
function release() external {
_release();
}
/* ========== Internal ========== */
function _release() internal {
if (releaseTime.add(releaseThreshold) <= block.timestamp) {
// Update release time
releaseTime = block.timestamp;
// Get SDVD balance
uint256 sdvdBalance = IERC20(sdvd).balanceOf(address(this));
// If there is SDVD in this contract
// and there is enough liquidity to swap
if (sdvdBalance > 0 && IERC20(sdvd).balanceOf(pairAddress) >= sdvdBalance) {
address[] memory path = new address[](2);
path[0] = sdvd;
path[1] = weth;
// Swap SDVD to ETH on uniswap
// uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline
uniswapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
sdvdBalance,
0,
path,
devWallet,
block.timestamp.add(30 minutes)
);
}
}
}
}
| contract DevTreasury is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
/// @dev Developer wallet
address payable public devWallet;
/// @dev SDVD contract address
address public sdvd;
/// @dev Uniswap router
IUniswapV2Router02 uniswapRouter;
/// @dev Uniswap factory
IUniswapV2Factory uniswapFactory;
/// @dev WETH address
address weth;
/// @dev Uniswap LP address
address public pairAddress;
/// @notice Release balance every 1 hour to dev wallet
uint256 public releaseThreshold = 1 hours;
/// @dev Last release timestamp
uint256 public releaseTime;
constructor (address _uniswapRouter, address _sdvd) public {
// Set dev wallet
devWallet = msg.sender;
// Set uniswap router
uniswapRouter = IUniswapV2Router02(_uniswapRouter);
// Set uniswap factory
uniswapFactory = IUniswapV2Factory(uniswapRouter.factory());
// Get weth address
weth = uniswapRouter.WETH();
// Set SDVD address
sdvd = _sdvd;
// Approve uniswap router to spend sdvd
IERC20(sdvd).approve(_uniswapRouter, uint256(- 1));
// Set initial release time
releaseTime = block.timestamp;
}
/* ========== Owner Only ========== */
function init() external onlyOwner {
// Get pair address after init because we wait until pair created in lord of coin
pairAddress = uniswapFactory.getPair(sdvd, weth);
// Renounce ownership immediately after init
renounceOwnership();
}
/* ========== Mutative ========== */
/// @notice Release SDVD to market regardless the price so dev doesn't own any SDVD from 0.5% fee.
/// This is to protect SDVD holders.
function release() external {
_release();
}
/* ========== Internal ========== */
function _release() internal {
if (releaseTime.add(releaseThreshold) <= block.timestamp) {
// Update release time
releaseTime = block.timestamp;
// Get SDVD balance
uint256 sdvdBalance = IERC20(sdvd).balanceOf(address(this));
// If there is SDVD in this contract
// and there is enough liquidity to swap
if (sdvdBalance > 0 && IERC20(sdvd).balanceOf(pairAddress) >= sdvdBalance) {
address[] memory path = new address[](2);
path[0] = sdvd;
path[1] = weth;
// Swap SDVD to ETH on uniswap
// uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline
uniswapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
sdvdBalance,
0,
path,
devWallet,
block.timestamp.add(30 minutes)
);
}
}
}
}
| 73,871 |
1 | // @inheritdoc IGenericLender | string public override lenderName;
| string public override lenderName;
| 32,529 |
203 | // This only usese the first gauge of the pool. Should be enough for most cases, however, if this is not the case, then this method should be overriden |
return gauges[0];
|
return gauges[0];
| 70,517 |
124 | // Gets the amount of staked LRC for an exchange./exchangeAddr The address of the exchange/ return stakedLRC The amount of LRC | function getExchangeStake(
address exchangeAddr
)
public
virtual
view
returns (uint stakedLRC);
| function getExchangeStake(
address exchangeAddr
)
public
virtual
view
returns (uint stakedLRC);
| 31,440 |
54 | // Update stake record | bytes32 recordId = keccak256(data);
StakeRecord storage record = info.stakeRecords[recordId];
record.amount = amount.add(record.amount);
record.unlockedAt = record.unlockedAt == 0 ? getUnlockedAtSignal(data) : record.unlockedAt;
| bytes32 recordId = keccak256(data);
StakeRecord storage record = info.stakeRecords[recordId];
record.amount = amount.add(record.amount);
record.unlockedAt = record.unlockedAt == 0 ? getUnlockedAtSignal(data) : record.unlockedAt;
| 18,867 |
2 | // Do not allow construction without upgrade master set. / | constructor(address _upgradeMaster) public {
upgradeMaster = _upgradeMaster;
}
| constructor(address _upgradeMaster) public {
upgradeMaster = _upgradeMaster;
}
| 11,856 |
536 | // Internal function to gets amount of locked NXM tokens,staked against smartcontract by index _stakerAddress address of user _stakedContractAddress staked contract address _stakedContractIndex index of staking / | function deprecated_getStakerLockedTokensOnSmartContract(
address _stakerAddress,
address _stakedContractAddress,
uint _stakedContractIndex
)
public
view
returns
(uint amount)
| function deprecated_getStakerLockedTokensOnSmartContract(
address _stakerAddress,
address _stakedContractAddress,
uint _stakedContractIndex
)
public
view
returns
(uint amount)
| 28,726 |
58 | // Give all initial supply to the contract. | balances[this] = INITIAL_SUPPLY;
Transfer(0x0, this, INITIAL_SUPPLY);
| balances[this] = INITIAL_SUPPLY;
Transfer(0x0, this, INITIAL_SUPPLY);
| 17,062 |
260 | // Fee + Transfer amount | value = value.add(uint256(LibBytes.readBytes32(_encodedFunction, 36)));
| value = value.add(uint256(LibBytes.readBytes32(_encodedFunction, 36)));
| 32,762 |
2 | // Lookup / | function query() internal view returns (IQueryController) {
return IQueryController(registry.getContract("Query"));
}
| function query() internal view returns (IQueryController) {
return IQueryController(registry.getContract("Query"));
}
| 22,284 |
3 | // results | mapping(uint => uint) weightOfResults;
mapping(uint => string) resolvedStrings;
mapping(uint => int) resolvedInts;
mapping(uint => bytes) resolvedBytes;
mapping(uint => address) resolvedAddresses;
| mapping(uint => uint) weightOfResults;
mapping(uint => string) resolvedStrings;
mapping(uint => int) resolvedInts;
mapping(uint => bytes) resolvedBytes;
mapping(uint => address) resolvedAddresses;
| 8,117 |
12 | // Detach the current staking contract./ Note that this is callable only by an authorized address. | function detachStakingContract()
external
override
onlyAuthorized
| function detachStakingContract()
external
override
onlyAuthorized
| 21,320 |
193 | // The event emitted when the owner sets new deposit and withdrawal timeouts | event SetTimeouts(uint256 depositTimeout, uint256 withdrawalTimeout);
| event SetTimeouts(uint256 depositTimeout, uint256 withdrawalTimeout);
| 16,333 |
725 | // Close Krug stream | pool.closeStream(86);
| pool.closeStream(86);
| 26,954 |
70 | // Maximum integer for token transfer approval | uint256 constant internal MAX_INT = 2**256 - 1;
| uint256 constant internal MAX_INT = 2**256 - 1;
| 26,208 |
8 | // ---------------- LendingPoolDataProvider --------------------- | function calculateUserGlobalData(address _user)
public
view
virtual
returns (
uint256 totalLiquidityBalanceETH,
uint256 totalCollateralBalanceETH,
uint256 totalBorrowBalanceETH,
uint256 totalFeesETH,
uint256 currentLtv,
| function calculateUserGlobalData(address _user)
public
view
virtual
returns (
uint256 totalLiquidityBalanceETH,
uint256 totalCollateralBalanceETH,
uint256 totalBorrowBalanceETH,
uint256 totalFeesETH,
uint256 currentLtv,
| 29,860 |
25 | // assert(a == bc + a % b);There is no case in which this doesn't hold |
return c;
|
return c;
| 30 |
62 | // If there is some division reminder, we just collect it too. | uint256 tokensAmount = (msg.value * TOKEN_CENTS) / tokenPrice;
require(tokensAmount > 0);
tokensPurchased += tokensAmount;
require(WellToken(TOKEN_ADDRESS).transferFrom(ASSET_MANAGER_WALLET, _participant, tokensAmount));
saleContributions += msg.value;
ESCROW_WALLET.transfer(msg.value);
emit Contributed(_participant, msg.value, tokensAmount);
return true;
| uint256 tokensAmount = (msg.value * TOKEN_CENTS) / tokenPrice;
require(tokensAmount > 0);
tokensPurchased += tokensAmount;
require(WellToken(TOKEN_ADDRESS).transferFrom(ASSET_MANAGER_WALLET, _participant, tokensAmount));
saleContributions += msg.value;
ESCROW_WALLET.transfer(msg.value);
emit Contributed(_participant, msg.value, tokensAmount);
return true;
| 61,206 |
69 | // Vesting stages, each stage has timestamp and percent of unlocked balance | Stage[] stages;
| Stage[] stages;
| 77,282 |
85 | // Check if recipient is already wearing hat; also checks storage to maintain balance == 1 invariant | if (_staticBalanceOf(_to, _hatId) > 0)
revert AlreadyWearingHat(_to, _hatId);
| if (_staticBalanceOf(_to, _hatId) > 0)
revert AlreadyWearingHat(_to, _hatId);
| 10,403 |
6 | // allows gas less trading on OpenSea | return
super.isApprovedForAll(owner, operator) ||
isOwnersOpenSeaProxy(owner, operator);
| return
super.isApprovedForAll(owner, operator) ||
isOwnersOpenSeaProxy(owner, operator);
| 16,214 |
33 | // Verifies the nonce of a voter on a proposal/_proposalId The id of the proposal/_voter The address of the voter/_relayerNonce The nonce submitted by the relayer | function verifyNonce(uint256 _proposalId, address _voter, uint256 _relayerNonce) public view {
Proposal storage _proposal = proposals[_proposalId];
require(_proposal.voters[_voter].nonce.add(1) == _relayerNonce, "INVALID_NONCE");
}
| function verifyNonce(uint256 _proposalId, address _voter, uint256 _relayerNonce) public view {
Proposal storage _proposal = proposals[_proposalId];
require(_proposal.voters[_voter].nonce.add(1) == _relayerNonce, "INVALID_NONCE");
}
| 19,681 |
1 | // the finalization needs to be executed on itself to update the storage of this proxy it also needs to be invoked by the governance, not by address(this), so delegatecall is needed | (bool success, bytes memory result) = address(this).delegatecall(
abi.encodeWithSignature("finalizeUpgrade()")
);
require(success, "Issue when finalizing the upgrade");
| (bool success, bytes memory result) = address(this).delegatecall(
abi.encodeWithSignature("finalizeUpgrade()")
);
require(success, "Issue when finalizing the upgrade");
| 47,596 |
26 | // {IERC20-approve}, and its usage is discouraged. / | function safeApprove(ERC20 token, address spender, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
| function safeApprove(ERC20 token, address spender, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
| 996 |
20 | // hunterPrice = Min(0.1ether, 0.01ethercurrentHunterNumber) |
uint public totalUserNumber = 0;
uint public totalLotteryNumber = 0;
uint public totalBuyCardNumber = 0;
uint public totalSellCardNumber = 0;
uint public totalDragonLotteryNumber = 0;
mapping (uint => uint) public mapMartialUserCount; // martial total user count
mapping (uint => uint) public mapMartialLotteryCount; // martial total lottery count
mapping (address => uint) public mapUserLotteryNumber;
|
uint public totalUserNumber = 0;
uint public totalLotteryNumber = 0;
uint public totalBuyCardNumber = 0;
uint public totalSellCardNumber = 0;
uint public totalDragonLotteryNumber = 0;
mapping (uint => uint) public mapMartialUserCount; // martial total user count
mapping (uint => uint) public mapMartialLotteryCount; // martial total lottery count
mapping (address => uint) public mapUserLotteryNumber;
| 34,135 |
57 | // it is still active, but in foreclosure state it is NOW or was in the past | uint256 collection = patronageOwed();
return timeLastCollected.add(((now.sub(timeLastCollected)).mul(deposit).div(collection)));
| uint256 collection = patronageOwed();
return timeLastCollected.add(((now.sub(timeLastCollected)).mul(deposit).div(collection)));
| 9,223 |
99 | // rebalance ETH fees proportionally to half the liquidity | uint256 totalRedirectEthFee = _devFee.add(_liquidityFee.div(2));
uint256 liquidityEthBalance = newBalance.mul(_liquidityFee.div(2)).div(totalRedirectEthFee);
uint256 devEthBalance = newBalance.mul(_devFee).div(totalRedirectEthFee);
| uint256 totalRedirectEthFee = _devFee.add(_liquidityFee.div(2));
uint256 liquidityEthBalance = newBalance.mul(_liquidityFee.div(2)).div(totalRedirectEthFee);
uint256 devEthBalance = newBalance.mul(_devFee).div(totalRedirectEthFee);
| 26,789 |
32 | // 100 size1 symmetry1000 SPIRALBITS per size per symnum of crystals involved | uint96 winnings = 100 * 1 * 1000 ether * uint96(teams[nextTeam].numCrystals);
teams[i].winningSpiralBits = winnings;
teams[nextTeam].symmetriesLost = 1;
| uint96 winnings = 100 * 1 * 1000 ether * uint96(teams[nextTeam].numCrystals);
teams[i].winningSpiralBits = winnings;
teams[nextTeam].symmetriesLost = 1;
| 51,974 |
15 | // setter | function setTestResultA(address _patient, uint _testResultA) public allDortors {
patient[_patient].testResultA = _testResultA;
}
| function setTestResultA(address _patient, uint _testResultA) public allDortors {
patient[_patient].testResultA = _testResultA;
}
| 2,737 |
128 | // The maximum value of a uint256 contains 78 digits (1 byte per digit),but we allocate 128 bytes to keep the free memory pointer 32-byte word aliged. We will need 1 32-byte word to store the length,and 3 32-byte words to store a maximum of 78 digits. Total: 32 + 332 = 128. | ptr := add(mload(0x40), 128)
| ptr := add(mload(0x40), 128)
| 3,009 |
152 | // if round is not active and end round needs to be ran | } else if (_now > round_[_rID].end && round_[_rID].ended == false) {
| } else if (_now > round_[_rID].end && round_[_rID].ended == false) {
| 3,484 |
45 | // here we are calculating the average rating of the product based on the number of the rating and the averge number of reviews it got..the logic will allow one peson to write multiple reviews | if(products[productId].numReviews > 0){
uint256 avgRating = products[productId].totalRating / products[productId].
numReviews;
if(avgRating < highestRating){
highestRating = avgRating;
highestRatedProductId = productId;
}
| if(products[productId].numReviews > 0){
uint256 avgRating = products[productId].totalRating / products[productId].
numReviews;
if(avgRating < highestRating){
highestRating = avgRating;
highestRatedProductId = productId;
}
| 14,883 |
184 | // Equivalent to `_safeMint(to, quantity, '')`. / | function _safeMint(address to, uint256 quantity) internal virtual {
_safeMint(to, quantity, '');
}
| function _safeMint(address to, uint256 quantity) internal virtual {
_safeMint(to, quantity, '');
}
| 1,597 |
4 | // the current tick | int24 tick;
| int24 tick;
| 13,944 |
9 | // 3. bonuse : 10 levels can get bonuse 1 USDC.e , Direct get 10 USDC.e | if (investers[upline].join_time > 0) {
investers[upline].bonuse = 10;
for (int256 i = 0; i < 10; i++) {
upline = investers[upline].upline;
if (upline == address(0)) break;
investers[upline].bonuse = 1;
investers[upline].balance += 1;
}
| if (investers[upline].join_time > 0) {
investers[upline].bonuse = 10;
for (int256 i = 0; i < 10; i++) {
upline = investers[upline].upline;
if (upline == address(0)) break;
investers[upline].bonuse = 1;
investers[upline].balance += 1;
}
| 32,756 |
311 | // Emitted when iToken's Distribution borrow speed is updated/IRewardDistributorV2 calculates supply and borrow speed respectively | event DistributionBorrowSpeedUpdated(address iToken, uint256 borrowSpeed);
function updateDistributionSpeed() external;
| event DistributionBorrowSpeedUpdated(address iToken, uint256 borrowSpeed);
function updateDistributionSpeed() external;
| 50,590 |
213 | // The SWEET TOKEN! | Sweets public SWEET;
| Sweets public SWEET;
| 18,188 |
285 | // if the user is redirecting his interest towards someone else,we update the redirected balance of the redirection address by adding the accrued interestand the amount deposited | updateRedirectedBalanceOfRedirectionAddressInternal(_account, balanceIncrease.add(_amount), 0);
| updateRedirectedBalanceOfRedirectionAddressInternal(_account, balanceIncrease.add(_amount), 0);
| 81,023 |
6 | // FIX logic here : set Minter, mint amount limit | require(_amount < mintLimit, "Mint up to 10000 Churu");
_mint(_to, _amount);
| require(_amount < mintLimit, "Mint up to 10000 Churu");
_mint(_to, _amount);
| 2,997 |
4 | // Add liquidity mannualy instead of using the router. This allows us to add liquidity in proportion we want, regardless of current pool reserves. Adding liquidity must: 1. Transfer both tokens to the pair 2. Mint LP tokens to some address. | SafeERC20.safeTransfer(address(token), address(uniswapV2Pair), half);
SafeERC20.safeTransfer(address(usdc), address(uniswapV2Pair), usdcReceived);
uniswapV2Pair.mint(timelock);
emit SwapAndLiquify(otherHalf, usdcReceived, half);
| SafeERC20.safeTransfer(address(token), address(uniswapV2Pair), half);
SafeERC20.safeTransfer(address(usdc), address(uniswapV2Pair), usdcReceived);
uniswapV2Pair.mint(timelock);
emit SwapAndLiquify(otherHalf, usdcReceived, half);
| 49,661 |
5 | // Open or close minting | function setOpen(bool _value) external onlyOwner {
open = _value;
}
| function setOpen(bool _value) external onlyOwner {
open = _value;
}
| 33,489 |
50 | // Checks if left Exp <= right Exp. / | function lessThanOrEqualExp(Exp memory left, Exp memory right) pure internal returns (bool) {
return left.mantissa <= right.mantissa;
}
| function lessThanOrEqualExp(Exp memory left, Exp memory right) pure internal returns (bool) {
return left.mantissa <= right.mantissa;
}
| 103 |
9 | // To shutdown the contract. | function destroy() public {
//only owner can shutdown this contract
require(owner == msg.sender, "Access Denied!");
daiContract.transfer(owner, daiContract.balanceOf(address(this)));
// cast address to payable
address payable addr = payable(address(owner));
selfdestruct(addr);
}
| function destroy() public {
//only owner can shutdown this contract
require(owner == msg.sender, "Access Denied!");
daiContract.transfer(owner, daiContract.balanceOf(address(this)));
// cast address to payable
address payable addr = payable(address(owner));
selfdestruct(addr);
}
| 35,744 |
20 | // ------------------------------------------------------------------------ Round One Sale Period ------------------------------------------------------------------------ | function isRoundOneSalePeriod(uint date) public constant returns (bool) {
return date >= roundOneFrom && date <= roundOneUntil && roundOneAmount > 0;
}
| function isRoundOneSalePeriod(uint date) public constant returns (bool) {
return date >= roundOneFrom && date <= roundOneUntil && roundOneAmount > 0;
}
| 41,487 |
47 | // Transfer tokens from `from` to `to` by decreasing the balance of `from` by `-amount` and increasing the balanceof `to` by `+amount`. | * Both the sender and recipient will be notified of the token transfer through the LSP1 {universalReceiver}
* function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive
* all the parameters in the calldata packed encoded.
*
* Any logic in the {_beforeTokenTransfer} function will run before updating the balances.
*
* @param from the address to decrease the balance.
* @param to the address to increase the balance.
* @param amount the amount of tokens to transfer from `from` to `to`.
* @param allowNonLSP1Recipient a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not.
* @param data Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address.
*
* @custom:requirements
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have at least `amount` of tokens.
*
* @custom:events {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 amount,
bool allowNonLSP1Recipient,
bytes memory data
) internal virtual {
if (from == address(0) || to == address(0)) {
revert LSP7CannotSendWithAddressZero();
}
uint256 balance = _tokenOwnerBalances[from];
if (amount > balance) {
revert LSP7AmountExceedsBalance(balance, from, amount);
}
address operator = msg.sender;
_beforeTokenTransfer(from, to, amount);
_tokenOwnerBalances[from] -= amount;
_tokenOwnerBalances[to] += amount;
emit Transfer(operator, from, to, amount, allowNonLSP1Recipient, data);
bytes memory lsp1Data = abi.encode(from, to, amount, data);
_notifyTokenSender(from, lsp1Data);
_notifyTokenReceiver(to, allowNonLSP1Recipient, lsp1Data);
}
| * Both the sender and recipient will be notified of the token transfer through the LSP1 {universalReceiver}
* function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive
* all the parameters in the calldata packed encoded.
*
* Any logic in the {_beforeTokenTransfer} function will run before updating the balances.
*
* @param from the address to decrease the balance.
* @param to the address to increase the balance.
* @param amount the amount of tokens to transfer from `from` to `to`.
* @param allowNonLSP1Recipient a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not.
* @param data Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address.
*
* @custom:requirements
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have at least `amount` of tokens.
*
* @custom:events {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 amount,
bool allowNonLSP1Recipient,
bytes memory data
) internal virtual {
if (from == address(0) || to == address(0)) {
revert LSP7CannotSendWithAddressZero();
}
uint256 balance = _tokenOwnerBalances[from];
if (amount > balance) {
revert LSP7AmountExceedsBalance(balance, from, amount);
}
address operator = msg.sender;
_beforeTokenTransfer(from, to, amount);
_tokenOwnerBalances[from] -= amount;
_tokenOwnerBalances[to] += amount;
emit Transfer(operator, from, to, amount, allowNonLSP1Recipient, data);
bytes memory lsp1Data = abi.encode(from, to, amount, data);
_notifyTokenSender(from, lsp1Data);
_notifyTokenReceiver(to, allowNonLSP1Recipient, lsp1Data);
}
| 24,912 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.