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 |
|---|---|---|---|---|
45 | // we can possibly take some fee here from owner and tenant to make this economically viable - ha ha ha! | function acceptNegotiationTenant() payable isActive {
// only prospective tenant chosen by landlord/ owner can accept and finalize the contract
if (msg.sender != acceptedNegotiation.tenant.getAccountAddress()) throw;
// paise kaun dega be
if (msg.value < acceptedNegotiation.condition.rent + acceptedNegotiation.condition.security) throw;
// okay for now keeping 2% of rent with the contract
uint fee = (2 * acceptedNegotiation.condition.rent) / 100 ;
uint rent = acceptedNegotiation.condition.rent;
// contract will keep the security deposit and finally return it to tenant if all goes well
if (!owner.getAccountAddress().send(rent - fee)) throw;
state = State.Locked;
tenant = acceptedNegotiation.tenant;
condition = acceptedNegotiation.condition;
}
| function acceptNegotiationTenant() payable isActive {
// only prospective tenant chosen by landlord/ owner can accept and finalize the contract
if (msg.sender != acceptedNegotiation.tenant.getAccountAddress()) throw;
// paise kaun dega be
if (msg.value < acceptedNegotiation.condition.rent + acceptedNegotiation.condition.security) throw;
// okay for now keeping 2% of rent with the contract
uint fee = (2 * acceptedNegotiation.condition.rent) / 100 ;
uint rent = acceptedNegotiation.condition.rent;
// contract will keep the security deposit and finally return it to tenant if all goes well
if (!owner.getAccountAddress().send(rent - fee)) throw;
state = State.Locked;
tenant = acceptedNegotiation.tenant;
condition = acceptedNegotiation.condition;
}
| 1,429 |
216 | // Not letting people use this function to create new pools. | require(pool.stakingToken != address(0), "LPStaking: Pool doesn't exist");
address _stakingToken = stakingTokenProvider.stakingTokenForVaultToken(pool.rewardToken);
| require(pool.stakingToken != address(0), "LPStaking: Pool doesn't exist");
address _stakingToken = stakingTokenProvider.stakingTokenForVaultToken(pool.rewardToken);
| 27,384 |
7 | // Init USDC chainlink properties | chainlinkUSDC = chainlinkUSDC_;
decimalsUSDC = IChainlinkAggregatorV3Interface(chainlinkUSDC_)
.decimals();
| chainlinkUSDC = chainlinkUSDC_;
decimalsUSDC = IChainlinkAggregatorV3Interface(chainlinkUSDC_)
.decimals();
| 37,216 |
149 | // See {IERC2612Permit-permit}./ | function permit(
address owner,
address spender,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "Permit: expired deadline");
| function permit(
address owner,
address spender,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "Permit: expired deadline");
| 22,222 |
272 | // require(offers[videoId].seller == address(0)); | require(msg.value > 0);
Bid memory bidExisting = bids[videoId];
if(bidExisting.value > 0){
require(msg.value > bidExisting.value);
pendingWithdrawals[bidExisting.bidder] += bidExisting.value;
}
| require(msg.value > 0);
Bid memory bidExisting = bids[videoId];
if(bidExisting.value > 0){
require(msg.value > bidExisting.value);
pendingWithdrawals[bidExisting.bidder] += bidExisting.value;
}
| 1,619 |
36 | // pay the service fee for contract deployment | feeReceiver.transfer(msg.value);
| feeReceiver.transfer(msg.value);
| 4,062 |
17 | // See {ERC20Pausable} and {Pausable-_pause}. Requirements: - the caller must have the `PAUSER_ROLE`. / | function pause() public virtual {
require(
morpherAccessControl.hasRole(PAUSER_ROLE, _msgSender()),
"MorpherToken: must have pauser role to pause"
);
_pause();
}
| function pause() public virtual {
require(
morpherAccessControl.hasRole(PAUSER_ROLE, _msgSender()),
"MorpherToken: must have pauser role to pause"
);
_pause();
}
| 5,647 |
14 | // Exercises an option after `expiryTime` but before `expiryTime + windowSize`.Requires a transaction inclusion proof which is verified by our chain relay.Can only be called by the parent factory contract.seller Account to exercise againstheight Bitcoin block heightindex Bitcoin tx indextxid Bitcoin transaction idproof Bitcoin inclusion proofrawtx Bitcoin raw tx/ | ) external override canExercise {
address buyer = msg.sender;
(bytes20 btcHash,) = IObligation(obligation).getBtcAddress(seller);
// verify & validate tx, use default confirmations
uint output = IReferee(referee)
.verifyTx(
height,
index,
txid,
proof,
rawtx,
btcHash
);
// burn seller's obligations
IObligation(obligation).executeExercise(buyer, seller, output);
}
| ) external override canExercise {
address buyer = msg.sender;
(bytes20 btcHash,) = IObligation(obligation).getBtcAddress(seller);
// verify & validate tx, use default confirmations
uint output = IReferee(referee)
.verifyTx(
height,
index,
txid,
proof,
rawtx,
btcHash
);
// burn seller's obligations
IObligation(obligation).executeExercise(buyer, seller, output);
}
| 25,983 |
168 | // After the Boost/Repay check if the ratio doesn't trigger another call/_method Type of action to be called/_user The actual address that owns the Aave position/_ratioBefore Ratio before action/ return Boolean if the recent action preformed correctly and the ratio | function ratioGoodAfter(AaveSubscriptionsV2.AaveHolder memory _holder, Method _method, address _user, uint _ratioBefore) public view returns(bool, uint, string memory) {
uint currRatio = getSafetyRatio(AAVE_MARKET_ADDRESS, _user);
if (_method == Method.Repay) {
if (currRatio >= _holder.maxRatio)
return (false, currRatio, "Repay increased ratio over max");
if (currRatio <= _ratioBefore) return (false, currRatio, "Repay made ratio worse");
} else if (_method == Method.Boost) {
if (currRatio <= _holder.minRatio)
return (false, currRatio, "Boost lowered ratio over min");
if (currRatio >= _ratioBefore) return (false, currRatio, "Boost didn't lower ratio");
}
return (true, currRatio, "");
}
| function ratioGoodAfter(AaveSubscriptionsV2.AaveHolder memory _holder, Method _method, address _user, uint _ratioBefore) public view returns(bool, uint, string memory) {
uint currRatio = getSafetyRatio(AAVE_MARKET_ADDRESS, _user);
if (_method == Method.Repay) {
if (currRatio >= _holder.maxRatio)
return (false, currRatio, "Repay increased ratio over max");
if (currRatio <= _ratioBefore) return (false, currRatio, "Repay made ratio worse");
} else if (_method == Method.Boost) {
if (currRatio <= _holder.minRatio)
return (false, currRatio, "Boost lowered ratio over min");
if (currRatio >= _ratioBefore) return (false, currRatio, "Boost didn't lower ratio");
}
return (true, currRatio, "");
}
| 36,342 |
202 | // init price percentage | _priceKey = [500000, 800000, 1100000, 1400000, 1700000, 2000000, 2300000, 2600000, 2900000, 3200000, 3500000, 3800000, 4100000,
4400000, 4700000, 5000000, 5300000, 5600000, 5900000, 6200000, 6500000];
_percentageValue = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100];
for (uint256 i = 0; i < _priceKey.length; i++) {
_pricePercentageMapping[_priceKey[i]] = _percentageValue[i];
}
| _priceKey = [500000, 800000, 1100000, 1400000, 1700000, 2000000, 2300000, 2600000, 2900000, 3200000, 3500000, 3800000, 4100000,
4400000, 4700000, 5000000, 5300000, 5600000, 5900000, 6200000, 6500000];
_percentageValue = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100];
for (uint256 i = 0; i < _priceKey.length; i++) {
_pricePercentageMapping[_priceKey[i]] = _percentageValue[i];
}
| 37,245 |
16 | // Approve DYDXSolo to spend to repay flashloan | IERC20(info.asset).approve(_dydxSoloMargin, amountOwing);
| IERC20(info.asset).approve(_dydxSoloMargin, amountOwing);
| 19,750 |
220 | // Retunrs the tokenIds of 'owner' / | function walletOfOwner(address _owner) public view returns (uint256[] memory) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) return new uint256[](0);
uint256[] memory tokensId = new uint256[](tokenCount);
for (uint256 i; i < tokenCount; i++) {
tokensId[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokensId;
}
| function walletOfOwner(address _owner) public view returns (uint256[] memory) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) return new uint256[](0);
uint256[] memory tokensId = new uint256[](tokenCount);
for (uint256 i; i < tokenCount; i++) {
tokensId[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokensId;
}
| 49,376 |
295 | // copied from Forwarder (can't reference string constants even from another library) | string public constant GENERIC_PARAMS = "address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data,uint256 validUntil";
bytes public constant RELAYDATA_TYPE = "RelayData(uint256 gasPrice,uint256 pctRelayFee,uint256 baseRelayFee,address relayWorker,address paymaster,address forwarder,bytes paymasterData,uint256 clientId)";
string public constant RELAY_REQUEST_NAME = "RelayRequest";
string public constant RELAY_REQUEST_SUFFIX = string(abi.encodePacked("RelayData relayData)", RELAYDATA_TYPE));
bytes public constant RELAY_REQUEST_TYPE = abi.encodePacked(
RELAY_REQUEST_NAME,"(",GENERIC_PARAMS,",", RELAY_REQUEST_SUFFIX);
| string public constant GENERIC_PARAMS = "address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data,uint256 validUntil";
bytes public constant RELAYDATA_TYPE = "RelayData(uint256 gasPrice,uint256 pctRelayFee,uint256 baseRelayFee,address relayWorker,address paymaster,address forwarder,bytes paymasterData,uint256 clientId)";
string public constant RELAY_REQUEST_NAME = "RelayRequest";
string public constant RELAY_REQUEST_SUFFIX = string(abi.encodePacked("RelayData relayData)", RELAYDATA_TYPE));
bytes public constant RELAY_REQUEST_TYPE = abi.encodePacked(
RELAY_REQUEST_NAME,"(",GENERIC_PARAMS,",", RELAY_REQUEST_SUFFIX);
| 70,249 |
41 | // 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.
*/
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.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
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.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
function min(uint256 x, uint256 y) internal pure returns (uint256 z) {
z = x < y ? x : y;
}
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
function sqrt(uint256 y) internal pure returns (uint256 z) {
if (y > 3) {
z = y;
uint256 x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
| 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.
*/
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.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
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.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
function min(uint256 x, uint256 y) internal pure returns (uint256 z) {
z = x < y ? x : y;
}
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
function sqrt(uint256 y) internal pure returns (uint256 z) {
if (y > 3) {
z = y;
uint256 x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
| 37,019 |
61 | // pay out recipient | recipient.transfer(valueRemainingAfterSubtractingCost);
| recipient.transfer(valueRemainingAfterSubtractingCost);
| 38,191 |
122 | // Creates `_amount` token to `_to`. Must only be called by the owner (Technoking). | function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
| function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
| 26,373 |
692 | // Once the voting period + executionDelay for a proposal has ended, evaluate the outcome and execute the proposal if voting quorum met & vote passes. To pass, stake-weighted vote must be > 50% Yes. Requires that caller is an active staker at the time the proposal is created _proposalId - id of the proposalreturn Outcome of proposal evaluation / | function evaluateProposalOutcome(uint256 _proposalId)
external returns (Outcome)
| function evaluateProposalOutcome(uint256 _proposalId)
external returns (Outcome)
| 7,727 |
67 | // Use abi.encodePacked to concatenate the messahe prefix and the message to sign. | bytes32 prefixedHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", dataHash));
| bytes32 prefixedHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", dataHash));
| 33,645 |
25 | // Storage / | struct SortitionSumTrees {
mapping(bytes32 => SortitionSumTree) sortitionSumTrees;
}
| struct SortitionSumTrees {
mapping(bytes32 => SortitionSumTree) sortitionSumTrees;
}
| 24,750 |
14 | // transfer MIG 721 from bridge in case token gets stuck or someone is sending by mistake / | function transfer721(uint256 _tokenId, address _owner) external onlyOwner {
require(_owner != address(0), "Can not send to address 0");
migContract.safeTransferFrom(address(this), _owner, _tokenId);
}
| function transfer721(uint256 _tokenId, address _owner) external onlyOwner {
require(_owner != address(0), "Can not send to address 0");
migContract.safeTransferFrom(address(this), _owner, _tokenId);
}
| 7,656 |
25 | // final amount the user got | finalAmountOut = DesynSafeMath.bsub(_tokenAmountOut, redeemAndPerformanceFeeReceived);
_pushUnderlying(bPool, poolToken, msg.sender, finalAmountOut);
if (redeemFee != 0) {
_pushUnderlying(bPool, poolToken, address(this), redeemAndPerformanceFeeReceived);
IERC20(poolToken).safeApprove(self.vaultAddress(), 0);
IERC20(poolToken).safeApprove(self.vaultAddress(), redeemAndPerformanceFeeReceived);
}
| finalAmountOut = DesynSafeMath.bsub(_tokenAmountOut, redeemAndPerformanceFeeReceived);
_pushUnderlying(bPool, poolToken, msg.sender, finalAmountOut);
if (redeemFee != 0) {
_pushUnderlying(bPool, poolToken, address(this), redeemAndPerformanceFeeReceived);
IERC20(poolToken).safeApprove(self.vaultAddress(), 0);
IERC20(poolToken).safeApprove(self.vaultAddress(), redeemAndPerformanceFeeReceived);
}
| 24,533 |
49 | // 2. mint same amount of sponsorToken | sponsorToken.mint(msg.sender, sTokenBalance);
| sponsorToken.mint(msg.sender, sTokenBalance);
| 20,550 |
83 | // L2_MSG | expectedSeqKind = 3;
| expectedSeqKind = 3;
| 61,940 |
1 | // We use mappings instead of arrays because it allows us to pack values in storage more tightly without storing the length redundantly. We pack 8 operations' data in each bucket. Each uint32 value is set to 1 upon proposal creation if it has to be scheduled and executed through the manager. Upon queuing, the value is set to nonce + 2, where the nonce is received from the manager when scheduling the operation. | mapping(uint256 operationBucket => uint32[8]) managerData;
| mapping(uint256 operationBucket => uint32[8]) managerData;
| 1,647 |
30 | // Recent report is not too recent. | if (reportTimestampRecent < minValidTimestamp) {
| if (reportTimestampRecent < minValidTimestamp) {
| 48,525 |
80 | // nft creator bytes lengths | uint8 constant NFT_CREATOR_ID_BYTES = 4;
| uint8 constant NFT_CREATOR_ID_BYTES = 4;
| 46,226 |
60 | // Determine the current account liquidity wrt collateral requirementsreturn 2.account shortfall below collateral requirements) / | function getAccountLiquidity(address account) external view returns (uint, uint) {
(uint liquidity, uint shortfall) = getHypotheticalAccountLiquidityInternal(account, LendTokenInterface(address(0)), 0, 0);
return (liquidity, shortfall);
}
| function getAccountLiquidity(address account) external view returns (uint, uint) {
(uint liquidity, uint shortfall) = getHypotheticalAccountLiquidityInternal(account, LendTokenInterface(address(0)), 0, 0);
return (liquidity, shortfall);
}
| 39,901 |
132 | // Make sure we have a valid swap path. | require(swapPath.length > 1 && swapPath[swapPath.length - 1] == _collateralAddress, "Invalid swap path");
| require(swapPath.length > 1 && swapPath[swapPath.length - 1] == _collateralAddress, "Invalid swap path");
| 58,466 |
37 | // Append userAddress and relayer address at the end to extract it from calling context | (bool success, bytes memory returnData) = address(this).call(
abi.encodePacked(functionSignature, userAddress)
);
require(success, "Function call not successful");
return returnData;
| (bool success, bytes memory returnData) = address(this).call(
abi.encodePacked(functionSignature, userAddress)
);
require(success, "Function call not successful");
return returnData;
| 86,901 |
372 | // Update a delegator with token pools shares from its lastClaimRound through a given round _delegator Delegator address _endRound The last round for which to update a delegator's stake with earnings pool shares _lastClaimRound The round for which a delegator has last claimed earnings / | function updateDelegatorWithEarnings(address _delegator, uint256 _endRound, uint256 _lastClaimRound) internal {
Delegator storage del = delegators[_delegator];
uint256 startRound = _lastClaimRound.add(1);
uint256 currentBondedAmount = del.bondedAmount;
uint256 currentFees = del.fees;
uint256 lip36Round = roundsManager().lipUpgradeRound(36);
// Only will have earnings to claim if you have a delegate
// If not delegated, skip the earnings claim process
if (del.delegateAddress != address(0)) {
if (startRound <= lip36Round) {
// Cannot claim earnings for more than maxEarningsClaimsRounds before LIP-36
// This is a number to cause transactions to fail early if
// we know they will require too much gas to loop through all the necessary rounds to claim earnings
// The user should instead manually invoke `claimEarnings` to split up the claiming process
// across multiple transactions
uint256 endLoopRound = _endRound <= lip36Round ? _endRound : lip36Round;
require(endLoopRound.sub(_lastClaimRound) <= maxEarningsClaimsRounds, "too many rounds to claim through");
}
(
currentBondedAmount,
currentFees
) = pendingStakeAndFees(_delegator, _endRound);
// Only execute cumulative factor logic after LIP-36 upgrade round
// After LIP-36 upgrade round the following code block should only be executed if _endRound is the current round
// See claimEarnings() and autoClaimEarnings()
if (_endRound >= lip36Round) {
// Check whether the endEarningsPool is initialised
// If it is not initialised set it's cumulative factors so that they can be used when a delegator
// next claims earnings as the start cumulative factors (see delegatorCumulativeStakeAndFees())
Transcoder storage t = transcoders[del.delegateAddress];
EarningsPool.Data storage endEarningsPool = t.earningsPoolPerRound[_endRound];
if (endEarningsPool.cumulativeRewardFactor == 0) {
uint256 lastRewardRound = t.lastRewardRound;
if (lastRewardRound < _endRound) {
endEarningsPool.cumulativeRewardFactor = cumulativeFactorsPool(t, lastRewardRound).cumulativeRewardFactor;
}
}
if (endEarningsPool.cumulativeFeeFactor == 0) {
uint256 lastFeeRound = t.lastFeeRound;
if (lastFeeRound < _endRound) {
endEarningsPool.cumulativeFeeFactor = cumulativeFactorsPool(t, lastFeeRound).cumulativeFeeFactor;
}
}
if (del.delegateAddress == _delegator) {
t.cumulativeFees = 0;
t.cumulativeRewards = 0;
// activeCumulativeRewards is not cleared here because the next reward() call will set it to cumulativeRewards
}
}
}
emit EarningsClaimed(
del.delegateAddress,
_delegator,
currentBondedAmount.sub(del.bondedAmount),
currentFees.sub(del.fees),
startRound,
_endRound
);
del.lastClaimRound = _endRound;
// Rewards are bonded by default
del.bondedAmount = currentBondedAmount;
del.fees = currentFees;
}
| function updateDelegatorWithEarnings(address _delegator, uint256 _endRound, uint256 _lastClaimRound) internal {
Delegator storage del = delegators[_delegator];
uint256 startRound = _lastClaimRound.add(1);
uint256 currentBondedAmount = del.bondedAmount;
uint256 currentFees = del.fees;
uint256 lip36Round = roundsManager().lipUpgradeRound(36);
// Only will have earnings to claim if you have a delegate
// If not delegated, skip the earnings claim process
if (del.delegateAddress != address(0)) {
if (startRound <= lip36Round) {
// Cannot claim earnings for more than maxEarningsClaimsRounds before LIP-36
// This is a number to cause transactions to fail early if
// we know they will require too much gas to loop through all the necessary rounds to claim earnings
// The user should instead manually invoke `claimEarnings` to split up the claiming process
// across multiple transactions
uint256 endLoopRound = _endRound <= lip36Round ? _endRound : lip36Round;
require(endLoopRound.sub(_lastClaimRound) <= maxEarningsClaimsRounds, "too many rounds to claim through");
}
(
currentBondedAmount,
currentFees
) = pendingStakeAndFees(_delegator, _endRound);
// Only execute cumulative factor logic after LIP-36 upgrade round
// After LIP-36 upgrade round the following code block should only be executed if _endRound is the current round
// See claimEarnings() and autoClaimEarnings()
if (_endRound >= lip36Round) {
// Check whether the endEarningsPool is initialised
// If it is not initialised set it's cumulative factors so that they can be used when a delegator
// next claims earnings as the start cumulative factors (see delegatorCumulativeStakeAndFees())
Transcoder storage t = transcoders[del.delegateAddress];
EarningsPool.Data storage endEarningsPool = t.earningsPoolPerRound[_endRound];
if (endEarningsPool.cumulativeRewardFactor == 0) {
uint256 lastRewardRound = t.lastRewardRound;
if (lastRewardRound < _endRound) {
endEarningsPool.cumulativeRewardFactor = cumulativeFactorsPool(t, lastRewardRound).cumulativeRewardFactor;
}
}
if (endEarningsPool.cumulativeFeeFactor == 0) {
uint256 lastFeeRound = t.lastFeeRound;
if (lastFeeRound < _endRound) {
endEarningsPool.cumulativeFeeFactor = cumulativeFactorsPool(t, lastFeeRound).cumulativeFeeFactor;
}
}
if (del.delegateAddress == _delegator) {
t.cumulativeFees = 0;
t.cumulativeRewards = 0;
// activeCumulativeRewards is not cleared here because the next reward() call will set it to cumulativeRewards
}
}
}
emit EarningsClaimed(
del.delegateAddress,
_delegator,
currentBondedAmount.sub(del.bondedAmount),
currentFees.sub(del.fees),
startRound,
_endRound
);
del.lastClaimRound = _endRound;
// Rewards are bonded by default
del.bondedAmount = currentBondedAmount;
del.fees = currentFees;
}
| 42,747 |
73 | // FEI stablecoin interface/Fei Protocol | interface IVolt is IERC20 {
// ----------- Events -----------
event Minting(
address indexed _to,
address indexed _minter,
uint256 _amount
);
event Burning(
address indexed _to,
address indexed _burner,
uint256 _amount
);
event IncentiveContractUpdate(
address indexed _incentivized,
address indexed _incentiveContract
);
// ----------- State changing api -----------
function burn(uint256 amount) external;
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
// ----------- Minter only state changing api -----------
function mint(address account, uint256 amount) external;
}
| interface IVolt is IERC20 {
// ----------- Events -----------
event Minting(
address indexed _to,
address indexed _minter,
uint256 _amount
);
event Burning(
address indexed _to,
address indexed _burner,
uint256 _amount
);
event IncentiveContractUpdate(
address indexed _incentivized,
address indexed _incentiveContract
);
// ----------- State changing api -----------
function burn(uint256 amount) external;
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
// ----------- Minter only state changing api -----------
function mint(address account, uint256 amount) external;
}
| 13,956 |
751 | // Auto-generated via 'PrintLambertFactors.py' | uint256 private constant LAMBERT_CONV_RADIUS =
0x002f16ac6c59de6f8d5d6f63c1482a7c86;
uint256 private constant LAMBERT_POS2_SAMPLE =
0x0003060c183060c183060c183060c18306;
uint256 private constant LAMBERT_POS2_MAXVAL =
0x01af16ac6c59de6f8d5d6f63c1482a7c80;
uint256 private constant LAMBERT_POS3_MAXVAL =
0x6b22d43e72c326539cceeef8bb48f255ff;
| uint256 private constant LAMBERT_CONV_RADIUS =
0x002f16ac6c59de6f8d5d6f63c1482a7c86;
uint256 private constant LAMBERT_POS2_SAMPLE =
0x0003060c183060c183060c183060c18306;
uint256 private constant LAMBERT_POS2_MAXVAL =
0x01af16ac6c59de6f8d5d6f63c1482a7c80;
uint256 private constant LAMBERT_POS3_MAXVAL =
0x6b22d43e72c326539cceeef8bb48f255ff;
| 38,885 |
6 | // See {ERC20Pausable} and {Pausable-_unpause}. Requirements: - the caller must have the `PAUSER_ROLE`. / | function unpause() public virtual {
require(hasRole(PAUSER_ROLE, _msgSender()), "RetaERC20MinterPauser: must have pauser role to unpause");
_unpause();
}
| function unpause() public virtual {
require(hasRole(PAUSER_ROLE, _msgSender()), "RetaERC20MinterPauser: must have pauser role to unpause");
_unpause();
}
| 4,067 |
10 | // See {IBEP20-symbol} and {ERC20-symbol}. | function symbol()
public
view
virtual
override(IBEP20, ERC20)
returns (string memory)
{
return ERC20.symbol();
}
| function symbol()
public
view
virtual
override(IBEP20, ERC20)
returns (string memory)
{
return ERC20.symbol();
}
| 32,231 |
41 | // Verify a part of the zkp, that is responsible for the aggregation | function _verifyRecursivePartOfProof(uint256[] calldata _recurisiveAggregationInput) internal view returns (bool) {
require(_recurisiveAggregationInput.length == 4);
PairingsBn254.G1Point memory pairWithGen = PairingsBn254.new_g1_checked(
_recurisiveAggregationInput[0],
_recurisiveAggregationInput[1]
);
PairingsBn254.G1Point memory pairWithX = PairingsBn254.new_g1_checked(
_recurisiveAggregationInput[2],
_recurisiveAggregationInput[3]
);
PairingsBn254.G2Point memory g2Gen = PairingsBn254.new_g2(
[
0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2,
0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed
],
[
0x090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b,
0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa
]
);
PairingsBn254.G2Point memory g2X = PairingsBn254.new_g2(
[
0x260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c1,
0x0118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b0
],
[
0x04fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe4,
0x22febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55
]
);
return PairingsBn254.pairingProd2(pairWithGen, g2Gen, pairWithX, g2X);
}
| function _verifyRecursivePartOfProof(uint256[] calldata _recurisiveAggregationInput) internal view returns (bool) {
require(_recurisiveAggregationInput.length == 4);
PairingsBn254.G1Point memory pairWithGen = PairingsBn254.new_g1_checked(
_recurisiveAggregationInput[0],
_recurisiveAggregationInput[1]
);
PairingsBn254.G1Point memory pairWithX = PairingsBn254.new_g1_checked(
_recurisiveAggregationInput[2],
_recurisiveAggregationInput[3]
);
PairingsBn254.G2Point memory g2Gen = PairingsBn254.new_g2(
[
0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2,
0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed
],
[
0x090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b,
0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa
]
);
PairingsBn254.G2Point memory g2X = PairingsBn254.new_g2(
[
0x260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c1,
0x0118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b0
],
[
0x04fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe4,
0x22febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55
]
);
return PairingsBn254.pairingProd2(pairWithGen, g2Gen, pairWithX, g2X);
}
| 5,169 |
99 | // Calculate actual amount by matching feeToken with the given tokenand then adding/subtracting the feeAmount from the given amount / | function calculateActualAmount(
LoopringTypes.Order memory self,
uint fillAmount,
address token
)
internal
pure
returns (uint)
| function calculateActualAmount(
LoopringTypes.Order memory self,
uint fillAmount,
address token
)
internal
pure
returns (uint)
| 2,231 |
97 | // Simple governance setter/_newGovernanceToken New value | function _setGovernanceToken(address _newGovernanceToken) internal {
governanceToken = IERC20(_newGovernanceToken);
}
| function _setGovernanceToken(address _newGovernanceToken) internal {
governanceToken = IERC20(_newGovernanceToken);
}
| 54,184 |
5 | // Target price for a token, to be scaled according to sales pace./Represented as an 18 decimal fixed point number. | int256 public targetPrice;
| int256 public targetPrice;
| 9,162 |
102 | // / | function getCurDay() public view returns (uint256) {
return uint256(uint(now) / uint(DAY_IN_SECONDS));
}
| function getCurDay() public view returns (uint256) {
return uint256(uint(now) / uint(DAY_IN_SECONDS));
}
| 11,744 |
89 | // Update lp address to the pool._poolPid - number of pool _newPoints - new amount of allocation pointsDO NOT add the same LP token more than once. Rewards will be messed up if you do.Can only be called by the current owner. / | function setPoll(uint256 _poolPid, uint256 _newPoints) public onlyOwner {
totalPoints = totalPoints.sub(poolInfo[_poolPid].allocPointAmount).add(_newPoints);
poolInfo[_poolPid].allocPointAmount = _newPoints;
}
| function setPoll(uint256 _poolPid, uint256 _newPoints) public onlyOwner {
totalPoints = totalPoints.sub(poolInfo[_poolPid].allocPointAmount).add(_newPoints);
poolInfo[_poolPid].allocPointAmount = _newPoints;
}
| 3,074 |
60 | // Distributes ether to token holders as dividends./SHOULD distribute the paid ether to token holders as dividends./SHOULD NOT directly transfer ether to token holders in this function./MUST emit a `DividendsDistributed` event when the amount of distributed ether is greater than 0. | function distributeDividends() external payable;
| function distributeDividends() external payable;
| 11,196 |
60 | // Check whether the pre-ICO is active at the moment./ | function isPreIco() public constant returns (bool) {
bool withinPreIco = now >= startTimePreIco && now <= endTimePreIco;
return withinPreIco;
}
| function isPreIco() public constant returns (bool) {
bool withinPreIco = now >= startTimePreIco && now <= endTimePreIco;
return withinPreIco;
}
| 54,179 |
169 | // Mint UDT | if(_referrer != address(0))
{
IUniswapOracle udtOracle = uniswapOracles[udt];
if(address(udtOracle) != address(0))
{
| if(_referrer != address(0))
{
IUniswapOracle udtOracle = uniswapOracles[udt];
if(address(udtOracle) != address(0))
{
| 39,674 |
119 | // amount in real tokens/wei if ether | function withdrawDepositById(uint32 dep_id) public {
(uint32 dp_id, uint256 index) = getCustomerDeposit(msg.sender,0); // deposit already exists for this customer?
require(dp_id != BAD_DEPOSIT_PROFILE_ID, "10");
uint256 amount = customers_deposits[index].deposits[dep_id].deposit_amount;
(,,uint8 p_dep_type,address p_tok_addr,,uint256 p_min_lock_time) = depProfilesRegister.getDepositProfileById(customers_deposits[index].deposits[dep_id].deposit_profile_id);
require(customers_deposits[index].deposits[dep_id].deposit_date + p_min_lock_time >= now,"12");
if (p_dep_type == ERC20_TOKEN || p_dep_type == UNISWAP_PAIR){
ERC20Token token = ERC20Token(p_tok_addr);
uint256 contractTokenBalance = token.balanceOf(address(this));
require(contractTokenBalance >= amount, "13");
//ensure we revert in case of failure
try token.transfer(msg.sender, amount) {
//before we closed deposit - extract reward (if deposit is extractable, reward is also extractable)
withdrawDepositRewardById(dep_id);
//and after that close deposit
customers_deposits[index].deposits[dep_id].votes = 0;
customers_deposits[index].deposits[dep_id].deposit_amount = 0; //just close it
uint256[] memory empty;
emit CustomerWithdrawDeposit(msg.sender, customers_deposits[index].deposits[dep_id].deposit_profile_id, dep_id, amount, empty);
} catch {
require(false,"3");
}
} else if (p_dep_type == ERC721_TOKEN){
ERC721Token token = ERC721Token(p_tok_addr);
uint256 tokens_count = token.balanceOf(address(this));
require(tokens_count > 0,"14");
Deposit storage dep = customers_deposits[index].deposits[dep_id];
/*for(uint256 i=0; i < dep.tokens_number; i++){
try token.approve(msg.sender, dep.token_ids[i]) {
//do nothing
} catch {
require(false, "6");
}
}*/
for(uint256 i=0; i < dep.tokens_number; i++){
try token.safeTransferFrom(address(this), msg.sender, dep.token_ids[i]){
//do nothing
} catch {
require(false,"8");
}
}
//and if all went well - withdraw reward & close ERC721 deposit
withdrawDepositRewardById(dep_id);
//and after that close deposit
customers_deposits[index].deposits[dep_id].votes = 0;
customers_deposits[index].deposits[dep_id].deposit_amount = 0; //just close it
uint256 tn = customers_deposits[index].deposits[dep_id].tokens_number;
uint256[] memory tok_ids = new uint256[](tn);
for (uint256 i=0; i < tn; i++){
tok_ids[i] = customers_deposits[index].deposits[dep_id].token_ids[i];
}
emit CustomerWithdrawDeposit(msg.sender, customers_deposits[index].deposits[dep_id].deposit_profile_id, dep_id, amount, tok_ids);
} else if (p_dep_type == NATIVE_ETHEREUM){
require(address(this).balance >= amount, "13");
bool success = false;
(success, ) = msg.sender.call{value: amount}("");
require(success, "15");
withdrawDepositRewardById(dep_id);
//and after that close deposit
customers_deposits[index].deposits[dep_id].votes = 0;
customers_deposits[index].deposits[dep_id].deposit_amount = 0; //just close it
uint256[] memory empty;
emit CustomerWithdrawDeposit(msg.sender, customers_deposits[index].deposits[dep_id].deposit_profile_id, dep_id, amount, empty);
}
}
| function withdrawDepositById(uint32 dep_id) public {
(uint32 dp_id, uint256 index) = getCustomerDeposit(msg.sender,0); // deposit already exists for this customer?
require(dp_id != BAD_DEPOSIT_PROFILE_ID, "10");
uint256 amount = customers_deposits[index].deposits[dep_id].deposit_amount;
(,,uint8 p_dep_type,address p_tok_addr,,uint256 p_min_lock_time) = depProfilesRegister.getDepositProfileById(customers_deposits[index].deposits[dep_id].deposit_profile_id);
require(customers_deposits[index].deposits[dep_id].deposit_date + p_min_lock_time >= now,"12");
if (p_dep_type == ERC20_TOKEN || p_dep_type == UNISWAP_PAIR){
ERC20Token token = ERC20Token(p_tok_addr);
uint256 contractTokenBalance = token.balanceOf(address(this));
require(contractTokenBalance >= amount, "13");
//ensure we revert in case of failure
try token.transfer(msg.sender, amount) {
//before we closed deposit - extract reward (if deposit is extractable, reward is also extractable)
withdrawDepositRewardById(dep_id);
//and after that close deposit
customers_deposits[index].deposits[dep_id].votes = 0;
customers_deposits[index].deposits[dep_id].deposit_amount = 0; //just close it
uint256[] memory empty;
emit CustomerWithdrawDeposit(msg.sender, customers_deposits[index].deposits[dep_id].deposit_profile_id, dep_id, amount, empty);
} catch {
require(false,"3");
}
} else if (p_dep_type == ERC721_TOKEN){
ERC721Token token = ERC721Token(p_tok_addr);
uint256 tokens_count = token.balanceOf(address(this));
require(tokens_count > 0,"14");
Deposit storage dep = customers_deposits[index].deposits[dep_id];
/*for(uint256 i=0; i < dep.tokens_number; i++){
try token.approve(msg.sender, dep.token_ids[i]) {
//do nothing
} catch {
require(false, "6");
}
}*/
for(uint256 i=0; i < dep.tokens_number; i++){
try token.safeTransferFrom(address(this), msg.sender, dep.token_ids[i]){
//do nothing
} catch {
require(false,"8");
}
}
//and if all went well - withdraw reward & close ERC721 deposit
withdrawDepositRewardById(dep_id);
//and after that close deposit
customers_deposits[index].deposits[dep_id].votes = 0;
customers_deposits[index].deposits[dep_id].deposit_amount = 0; //just close it
uint256 tn = customers_deposits[index].deposits[dep_id].tokens_number;
uint256[] memory tok_ids = new uint256[](tn);
for (uint256 i=0; i < tn; i++){
tok_ids[i] = customers_deposits[index].deposits[dep_id].token_ids[i];
}
emit CustomerWithdrawDeposit(msg.sender, customers_deposits[index].deposits[dep_id].deposit_profile_id, dep_id, amount, tok_ids);
} else if (p_dep_type == NATIVE_ETHEREUM){
require(address(this).balance >= amount, "13");
bool success = false;
(success, ) = msg.sender.call{value: amount}("");
require(success, "15");
withdrawDepositRewardById(dep_id);
//and after that close deposit
customers_deposits[index].deposits[dep_id].votes = 0;
customers_deposits[index].deposits[dep_id].deposit_amount = 0; //just close it
uint256[] memory empty;
emit CustomerWithdrawDeposit(msg.sender, customers_deposits[index].deposits[dep_id].deposit_profile_id, dep_id, amount, empty);
}
}
| 2,910 |
28 | // Initialize fee settings on DelegatedManager and transfer `owner` and `methodologist` roles. _manager Instance of DelegatedManager_owner Address that will be given the `owner` DelegatedManager's role_methodologist Address that will be given the `methodologist` DelegatedManager's role_ownerFeeSplit Percent of fees in precise units (10^16 = 1%) sent to owner, rest to methodologist_ownerFeeRecipient Address which receives owner's share of fees when they're distributed / | function _setManagerState(
IDelegatedManager _manager,
address _owner,
address _methodologist,
uint256 _ownerFeeSplit,
address _ownerFeeRecipient
| function _setManagerState(
IDelegatedManager _manager,
address _owner,
address _methodologist,
uint256 _ownerFeeSplit,
address _ownerFeeRecipient
| 8,434 |
36 | // Shut SAI CDP and gets WETH back | tub.shut(cup); // CDP is closed using the SAI just exited and the MKR previously sent by the user (via the proxy call)
tub.exit(pethAmt); // Converts PETH to WETH
| tub.shut(cup); // CDP is closed using the SAI just exited and the MKR previously sent by the user (via the proxy call)
tub.exit(pethAmt); // Converts PETH to WETH
| 36,090 |
27 | // _transfer(msg.sender, _to, _value); |
if (msg.sender == owner) {
|
if (msg.sender == owner) {
| 19,260 |
327 | // Current oToken premium | uint256 public currentOtokenPremium;
| uint256 public currentOtokenPremium;
| 21,079 |
37 | // 真实账户余额 | uint256 Balances;
| uint256 Balances;
| 4,975 |
3 | // Only the Admiral can mint coins / | function mint(address receiver, uint amount) public onlyAdmiral {
_mint(receiver, amount * (10 ** uint256(decimals())));
}
| function mint(address receiver, uint amount) public onlyAdmiral {
_mint(receiver, amount * (10 ** uint256(decimals())));
}
| 39,665 |
26 | // PYLON token address | address public pylonAddress;
| address public pylonAddress;
| 22,856 |
141 | // Set DAOCommitteeProxy contract address/_committee New DAOCommitteeProxy contract address | function setCommittee(address _committee) external override onlyOwner {
require(_committee != address(0), "DAOAgendaManager: address is zero");
committee = IDAOCommittee(_committee);
}
| function setCommittee(address _committee) external override onlyOwner {
require(_committee != address(0), "DAOAgendaManager: address is zero");
committee = IDAOCommittee(_committee);
}
| 5,535 |
32 | // Make sure we are not done yet. | modifier canMint() {
require(!released);
_;
}
| modifier canMint() {
require(!released);
_;
}
| 47,451 |
5 | // Allows anyone to transfer all given tokens in a Loot Box to the associated ERC721 owner./A Loot Box contract will be counterfactually created, tokens transferred to the ERC721 owner, then destroyed./erc721 The address of the ERC721/tokenId The ERC721 token id/erc20s An array of ERC20 tokens whose entire balance should be transferred/erc721s An array of structs defining ERC721 tokens that should be transferred/erc1155s An array of struct defining ERC1155 tokens that should be transferred | function plunder(
address erc721,
uint256 tokenId,
IERC20Upgradeable[] calldata erc20s,
LootBox.WithdrawERC721[] calldata erc721s,
LootBox.WithdrawERC1155[] calldata erc1155s
| function plunder(
address erc721,
uint256 tokenId,
IERC20Upgradeable[] calldata erc20s,
LootBox.WithdrawERC721[] calldata erc721s,
LootBox.WithdrawERC1155[] calldata erc1155s
| 1,593 |
310 | // Nonces for each VRF key from which randomness has been requested. Must stay in sync with VRFCoordinator[_keyHash][this] | mapping(bytes32 /* keyHash */ => uint256 /* nonce */) private nonces;
| mapping(bytes32 /* keyHash */ => uint256 /* nonce */) private nonces;
| 11,414 |
652 | // Calculate releasable amount | uint256 amount = 0;
for (
uint256 i = claim.periodsClaimed;
i < claim.timePeriods.length;
i++
) {
if (claim.timePeriods[i] <= block.timestamp) {
amount = amount.add(claim.tokenAmounts[i]);
claim.periodsClaimed = claim.periodsClaimed.add(1);
} else {
| uint256 amount = 0;
for (
uint256 i = claim.periodsClaimed;
i < claim.timePeriods.length;
i++
) {
if (claim.timePeriods[i] <= block.timestamp) {
amount = amount.add(claim.tokenAmounts[i]);
claim.periodsClaimed = claim.periodsClaimed.add(1);
} else {
| 46,604 |
73 | // Address early participation whitelist status changed | event Whitelisted(address addr, bool status, uint minCap, uint maxCap);
event WhitelistItemChanged(address addr, bool status, uint minCap, uint maxCap);
| event Whitelisted(address addr, bool status, uint minCap, uint maxCap);
event WhitelistItemChanged(address addr, bool status, uint minCap, uint maxCap);
| 36,437 |
0 | // (_ _)/\ /\ / \'._ (\_/) _.'/ \/_.''._'--('.')--'_.''._\| \_ / `;=/ " \=;` \ _/ | \/ `\__|`\___/`|__/`\/ jgs`\(/|\)/ `" ` " | event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
event ETHValue(uint256 amount);
IWETH immutable weth;
| event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
event ETHValue(uint256 amount);
IWETH immutable weth;
| 60,624 |
15 | // ==========Controls========== // Sets the controller address and the token name & symbol. Note: This saves on storage costs for multi-step dynaset deployment.controller Controller of the dynaset name Name of the dynaset token symbol Symbol of the dynaset token / | function configure(
address controller,//admin
address dam,//digital asset manager
string calldata name,
string calldata symbol
| function configure(
address controller,//admin
address dam,//digital asset manager
string calldata name,
string calldata symbol
| 7,541 |
3 | // Updates the bond size.There is a waiting period of 2 days before the new value goes into effect.newBondSize the new bond size./ | function updateBondSize(Params storage self, uint128 newBondSize) internal {
validateBondSize(self, newBondSize);
if (self.updatedBondSize != 0 && now >= self.effectiveUpdateTime) {
self.previousBondSize = self.updatedBondSize;
}
self.updatedBondSize = newBondSize;
self.effectiveUpdateTime = uint64(now) + WAITING_PERIOD;
}
| function updateBondSize(Params storage self, uint128 newBondSize) internal {
validateBondSize(self, newBondSize);
if (self.updatedBondSize != 0 && now >= self.effectiveUpdateTime) {
self.previousBondSize = self.updatedBondSize;
}
self.updatedBondSize = newBondSize;
self.effectiveUpdateTime = uint64(now) + WAITING_PERIOD;
}
| 8,514 |
33 | // Create a sell lock. Called by seller. chainIdAdapterIdAssetId 4 bytes chainId, 4 bytes adapterId, 8 bytes assetId / | function lockSell(bytes16 chainIdAdapterIdAssetId, bytes32 hashedSecret, address buyer, uint256 timeout, uint256 value) external {
// Check there is enough.
require (chainIdAdapterIdAssetIdAccountValue[chainIdAdapterIdAssetId][msg.sender] >= value, "Sell order not big enough.");
// Calculate lockId.
bytes32 lockId = keccak256(abi.encodePacked(msg.sender, hashedSecret, buyer, timeout));
// Ensure lockId is not already in use.
require (lockIdValue[lockId] == 0, "Sell lock already exists.");
// Move value into sell lock.
removeDeposit(chainIdAdapterIdAssetId, value);
lockIdValue[lockId] = value;
// Log info.
// emit LockSell(orderId, hashedSecret, timeout, value);
}
| function lockSell(bytes16 chainIdAdapterIdAssetId, bytes32 hashedSecret, address buyer, uint256 timeout, uint256 value) external {
// Check there is enough.
require (chainIdAdapterIdAssetIdAccountValue[chainIdAdapterIdAssetId][msg.sender] >= value, "Sell order not big enough.");
// Calculate lockId.
bytes32 lockId = keccak256(abi.encodePacked(msg.sender, hashedSecret, buyer, timeout));
// Ensure lockId is not already in use.
require (lockIdValue[lockId] == 0, "Sell lock already exists.");
// Move value into sell lock.
removeDeposit(chainIdAdapterIdAssetId, value);
lockIdValue[lockId] = value;
// Log info.
// emit LockSell(orderId, hashedSecret, timeout, value);
}
| 21,299 |
87 | // See {IERC1155-balanceOf}. Requirements: - `account` cannot be the zero address. / | function balanceOf(address account, uint256 id) public view override returns (uint256) {
require(account != address(0), "ERC1155: balance query for the zero address");
return _balances[id][account];
}
| function balanceOf(address account, uint256 id) public view override returns (uint256) {
require(account != address(0), "ERC1155: balance query for the zero address");
return _balances[id][account];
}
| 912 |
41 | // Function to add a proposal that should be considered for execution/proposalId Id that should identify the proposal uniquely/txHashes EIP-712 hashes of the transactions that should be executed/nonce Nonce that should be used when asking the question on the oracle | function addProposalWithNonce(string memory proposalId, bytes32[] memory txHashes, uint256 nonce) public {
// We load some storage variables into memory to save gas
uint256 templateId = template;
uint32 timeout = questionTimeout;
address arbitrator = questionArbitrator;
// We generate the question string used for the oracle
string memory question = buildQuestion(proposalId, txHashes);
bytes32 questionHash = keccak256(bytes(question));
if (nonce > 0) {
// Previous nonce must have been invalidated by the oracle.
// However, if the proposal was internally invalidated, it should not be possible to ask it again.
bytes32 currentQuestionId = questionIds[questionHash];
require(currentQuestionId != INVALIDATED, "This proposal has been marked as invalid");
require(oracle.resultFor(currentQuestionId) == INVALIDATED, "Previous proposal was not invalidated");
} else {
require(questionIds[questionHash] == bytes32(0), "Proposal has already been submitted");
}
bytes32 expectedQuestionId = getQuestionId(
templateId, question, arbitrator, timeout, 0, nonce
);
// Set the question hash for this quesion id
questionIds[questionHash] = expectedQuestionId;
// Ask the question with a starting time of 0, so that it can be immediately answered
bytes32 questionId = oracle.askQuestion(templateId, question, arbitrator, timeout, 0, nonce);
require(expectedQuestionId == questionId, "Unexpected question id");
emit ProposalQuestionCreated(questionId, proposalId);
}
| function addProposalWithNonce(string memory proposalId, bytes32[] memory txHashes, uint256 nonce) public {
// We load some storage variables into memory to save gas
uint256 templateId = template;
uint32 timeout = questionTimeout;
address arbitrator = questionArbitrator;
// We generate the question string used for the oracle
string memory question = buildQuestion(proposalId, txHashes);
bytes32 questionHash = keccak256(bytes(question));
if (nonce > 0) {
// Previous nonce must have been invalidated by the oracle.
// However, if the proposal was internally invalidated, it should not be possible to ask it again.
bytes32 currentQuestionId = questionIds[questionHash];
require(currentQuestionId != INVALIDATED, "This proposal has been marked as invalid");
require(oracle.resultFor(currentQuestionId) == INVALIDATED, "Previous proposal was not invalidated");
} else {
require(questionIds[questionHash] == bytes32(0), "Proposal has already been submitted");
}
bytes32 expectedQuestionId = getQuestionId(
templateId, question, arbitrator, timeout, 0, nonce
);
// Set the question hash for this quesion id
questionIds[questionHash] = expectedQuestionId;
// Ask the question with a starting time of 0, so that it can be immediately answered
bytes32 questionId = oracle.askQuestion(templateId, question, arbitrator, timeout, 0, nonce);
require(expectedQuestionId == questionId, "Unexpected question id");
emit ProposalQuestionCreated(questionId, proposalId);
}
| 23,685 |
28 | // assemble the given address bytecode. If bytecode exists then the _addr is a contract. | function isContract(address _addr) private returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
| function isContract(address _addr) private returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
| 8,585 |
81 | // Calls {_grantRole} internally. Requirements: - the caller must have `role`'s admin role. / | function grantRole(bytes32 role, address account) external virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
| function grantRole(bytes32 role, address account) external virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
| 23,973 |
193 | // Burn all Pynths issued for the loan | pynthsETH().burn(msg.sender, pynthLoan.loanAmount);
| pynthsETH().burn(msg.sender, pynthLoan.loanAmount);
| 31,128 |
5 | // Add rewards token to the list / | function addReward(address _rewardsToken) external virtual;
| function addReward(address _rewardsToken) external virtual;
| 29,554 |
3 | // only change when stakers had actions. | if (totalNodeStaked != newTotalNodeStaked) {
totalNodeStaked = newTotalNodeStaked;
}
| if (totalNodeStaked != newTotalNodeStaked) {
totalNodeStaked = newTotalNodeStaked;
}
| 19,243 |
82 | // mint to user | _balances[userAddress] = _balances[userAddress].add(userToken);
emit Transfer(address(0), userAddress, userToken);
| _balances[userAddress] = _balances[userAddress].add(userToken);
emit Transfer(address(0), userAddress, userToken);
| 53,593 |
25 | // Modifier that checks if the function caller is also the smart contract owner / | modifier onlyOwner { require(msg.sender == owner); _; }
| modifier onlyOwner { require(msg.sender == owner); _; }
| 1,383 |
1 | // CONSTANTS |
uint256 public constant DOGE_PRICE_WHITELIST = 5 ether / 100;
uint256 public constant DOGE_PRICE_ETH = 8 ether / 100;
uint256 public constant WHITELIST_DOGES = 1000;
uint256 public constant DOGES_PER_AST_MINT_LEVEL = 5000;
uint256 public constant MAXIMUM_MINTS_PER_WHITELIST_ADDRESS = 10;
uint256 public constant NUM_GEN0_DOGES = 10_000;
|
uint256 public constant DOGE_PRICE_WHITELIST = 5 ether / 100;
uint256 public constant DOGE_PRICE_ETH = 8 ether / 100;
uint256 public constant WHITELIST_DOGES = 1000;
uint256 public constant DOGES_PER_AST_MINT_LEVEL = 5000;
uint256 public constant MAXIMUM_MINTS_PER_WHITELIST_ADDRESS = 10;
uint256 public constant NUM_GEN0_DOGES = 10_000;
| 22,617 |
220 | // Ensure they're not trying to exceed their staked DOWS amount | require(value <= transferableShadows(messageSender), "Cannot transfer staked or escrowed DOWS");
| require(value <= transferableShadows(messageSender), "Cannot transfer staked or escrowed DOWS");
| 38,826 |
82 | // get shares and eth required for each share | CalculationStruct[] memory calculations = new CalculationStruct[](tokens.length);
uint256 totalEthRequired = 0;
for (i = 0; i < tokens.length; i++) {
calculations[i].tokenShare = poolRatio.mul(pipt.getBalance(tokens[i])).div(1 ether);
(calculations[i].tokenReserve, calculations[i].ethReserve,) = uniswapPairFor(tokens[i]).getReserves();
calculations[i].ethRequired = getAmountIn(
calculations[i].tokenShare,
calculations[i].ethReserve,
calculations[i].tokenReserve
);
| CalculationStruct[] memory calculations = new CalculationStruct[](tokens.length);
uint256 totalEthRequired = 0;
for (i = 0; i < tokens.length; i++) {
calculations[i].tokenShare = poolRatio.mul(pipt.getBalance(tokens[i])).div(1 ether);
(calculations[i].tokenReserve, calculations[i].ethReserve,) = uniswapPairFor(tokens[i]).getReserves();
calculations[i].ethRequired = getAmountIn(
calculations[i].tokenShare,
calculations[i].ethReserve,
calculations[i].tokenReserve
);
| 56,431 |
56 | // Set the current transaction signer | currentContextAddress = signerAddress;
| currentContextAddress = signerAddress;
| 24,027 |
4 | // assert(b > 0);Solidity automatically throws when dividing by 0 uint256 c = a / b; assert(a == bc + a % b);There is no case in which this doesn't hold | return a / b;
| return a / b;
| 1,578 |
94 | // Get allowed B coupons from address to acceptor address. Parameters: _from: address of the B coupon sender. _acceptor: address of the B coupon acceptor./ | function allowanceBcoupons(address _from, address _acceptor) constant external returns (uint remaining) {
return allowed_B_coupons[_from][_acceptor];
}
| function allowanceBcoupons(address _from, address _acceptor) constant external returns (uint remaining) {
return allowed_B_coupons[_from][_acceptor];
}
| 9,452 |
29 | // calculate the number of tokens to be send. multipling with (108) since the token used has 8 decimals | uint256 numToken = getTokenAmount(weiAmount).mul(10 ** 8);
| uint256 numToken = getTokenAmount(weiAmount).mul(10 ** 8);
| 17,682 |
286 | // Calculates part of the matched fill results for a given situation using the maximal fill order matching/strategy./leftOrder The left order in the order matching situation./rightOrder The right order in the order matching situation./leftMakerAssetAmountRemaining The amount of the left order maker asset that can still be filled./leftTakerAssetAmountRemaining The amount of the left order taker asset that can still be filled./rightMakerAssetAmountRemaining The amount of the right order maker asset that can still be filled./rightTakerAssetAmountRemaining The amount of the right order taker asset that can still be filled./ return MatchFillResults struct that does not include fees paid. | function _calculateMatchedFillResultsWithMaximalFill(
LibOrder.Order memory leftOrder,
LibOrder.Order memory rightOrder,
uint256 leftMakerAssetAmountRemaining,
uint256 leftTakerAssetAmountRemaining,
uint256 rightMakerAssetAmountRemaining,
uint256 rightTakerAssetAmountRemaining
)
private
pure
| function _calculateMatchedFillResultsWithMaximalFill(
LibOrder.Order memory leftOrder,
LibOrder.Order memory rightOrder,
uint256 leftMakerAssetAmountRemaining,
uint256 leftTakerAssetAmountRemaining,
uint256 rightMakerAssetAmountRemaining,
uint256 rightTakerAssetAmountRemaining
)
private
pure
| 28,721 |
13 | // Claimable Ex Extension for the Claimable contract, where the ownership transfer can be canceled. / | contract ClaimableEx is Claimable {
/*
* @dev Cancels the ownership transfer.
*/
function cancelOwnershipTransfer() onlyOwner public {
pendingOwner = owner;
}
}
| contract ClaimableEx is Claimable {
/*
* @dev Cancels the ownership transfer.
*/
function cancelOwnershipTransfer() onlyOwner public {
pendingOwner = owner;
}
}
| 11,468 |
20 | // Ownable The modified Ownable contract has two owner addresses to provide authorization controlfunctions. / | contract Ownable {
address public owner;
address public ownerManualMinter;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
/**
* ownerManualMinter contains the eth address of the party allowed to manually mint outside the crowdsale contract
* this is setup at construction time
*/
ownerManualMinter = 0x673eaa69e19b4b8e541396d37889924b9dc74c7e ; // To be changed right after contract is deployed
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner || msg.sender == ownerManualMinter);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* This shall be invoked with the ICO crowd sale smart contract address once it´s ready
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
/**
* @dev After the manual minting process ends, this shall be invoked passing the ICO crowd sale contract address so that
* nobody else will be ever able to mint more tokens
* @param newOwner The address to transfer ownership to.
*/
function transferOwnershipManualMinter(address newOwner) onlyOwner public {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
ownerManualMinter = newOwner;
}
}
| contract Ownable {
address public owner;
address public ownerManualMinter;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
/**
* ownerManualMinter contains the eth address of the party allowed to manually mint outside the crowdsale contract
* this is setup at construction time
*/
ownerManualMinter = 0x673eaa69e19b4b8e541396d37889924b9dc74c7e ; // To be changed right after contract is deployed
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner || msg.sender == ownerManualMinter);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* This shall be invoked with the ICO crowd sale smart contract address once it´s ready
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
/**
* @dev After the manual minting process ends, this shall be invoked passing the ICO crowd sale contract address so that
* nobody else will be ever able to mint more tokens
* @param newOwner The address to transfer ownership to.
*/
function transferOwnershipManualMinter(address newOwner) onlyOwner public {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
ownerManualMinter = newOwner;
}
}
| 55,683 |
23 | // This is an alternative to {approve} that can be used as a mitigation forproblems described in {IERC20-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;
}
| 56 |
2 | // initializing objects | ExchangeOracle oracle;
IERC20 cblt_Token;
| ExchangeOracle oracle;
IERC20 cblt_Token;
| 14,784 |
57 | // Gov ONLY. Enables a list of tokens for trading/wrapping to_tokensThe list of tokens to add / | function addTokens(address[] memory _tokens) public onlyGov {
for (uint256 index = 0; index < _tokens.length; index++) {
allowedTokens[_tokens[index]] = true;
}
emit TokensAdded(_tokens);
}
| function addTokens(address[] memory _tokens) public onlyGov {
for (uint256 index = 0; index < _tokens.length; index++) {
allowedTokens[_tokens[index]] = true;
}
emit TokensAdded(_tokens);
}
| 18,990 |
57 | // Declares Starbase MVP has been launched launchedAt When the MVP launched (timestamp) / | function declareMvpLaunched(uint256 launchedAt) external onlyFundraiser() returns (bool) {
require(mvpLaunchedAt == 0); // overwriting the launch date is not permitted
require(launchedAt <= now);
require(starbaseCrowdsale.isEnded());
mvpLaunchedAt = launchedAt;
MvpLaunched(launchedAt);
return true;
}
| function declareMvpLaunched(uint256 launchedAt) external onlyFundraiser() returns (bool) {
require(mvpLaunchedAt == 0); // overwriting the launch date is not permitted
require(launchedAt <= now);
require(starbaseCrowdsale.isEnded());
mvpLaunchedAt = launchedAt;
MvpLaunched(launchedAt);
return true;
}
| 40,726 |
272 | // Set some Nfts aside / | // function reserveNftS(uint256 numberOfNfts, address[] memory _senderAddress) public onlyOwner {
// for (uint i = 0; i < numberOfNfts; i++) {
// uint supply = totalSupply();
// if (totalSupply() < MAX_NFT_SUPPLY)
// {
// _safeMint(_senderAddress[i], supply);
// }
// }
// }
| // function reserveNftS(uint256 numberOfNfts, address[] memory _senderAddress) public onlyOwner {
// for (uint i = 0; i < numberOfNfts; i++) {
// uint supply = totalSupply();
// if (totalSupply() < MAX_NFT_SUPPLY)
// {
// _safeMint(_senderAddress[i], supply);
// }
// }
// }
| 7,848 |
299 | // if the user redirected the interest, then only the redirectedbalance generates interest. In that case, the interest generatedby the redirected balance is added to the current principal balance. | return currentPrincipalBalance.add(
calculateCumulatedBalanceInternal(
_user,
redirectedBalance
)
.sub(redirectedBalance)
);
| return currentPrincipalBalance.add(
calculateCumulatedBalanceInternal(
_user,
redirectedBalance
)
.sub(redirectedBalance)
);
| 15,218 |
41 | // _miner is the miner being disputed. For every mined value 5 miners are saved in an array and the _minerIndexprovided by the party initiating the dispute | address _miner = _request.minersByValue[_timestamp][_minerIndex];
bytes32 _hash =
keccak256(abi.encodePacked(_miner, _requestId, _timestamp));
| address _miner = _request.minersByValue[_timestamp][_minerIndex];
bytes32 _hash =
keccak256(abi.encodePacked(_miner, _requestId, _timestamp));
| 36,004 |
486 | // Note, we allow the transactionRootProducer to be a witness, witnesses length must be 1, zero fill 65 for witness data.. Select Witnesses Signature | function verifyTransactionWitness(signature, transactionHashID, outputOwner, rootProducer) {
| function verifyTransactionWitness(signature, transactionHashID, outputOwner, rootProducer) {
| 21,728 |
11 | // Contract module which provides a basic access control mechanism, wherethere is an account (an owner) that can be granted exclusive access tospecific functions.By default, the owner account will be the one that deploys the contract. This | * can later be changed with {transferOwnership}.
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
| * can later be changed with {transferOwnership}.
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
| 34,536 |
20 | // babylonian method (https:en.wikipedia.org/wiki/Methods_of_computing_square_rootsBabylonian_method) | function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
| function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
| 2,383 |
50 | // PRIVILEGED GOVERNANCE FUNCTION. Allows governance to remove a Set_setToken Address of the SetToken contract to remove / | function removeSet(address _setToken) external onlyInitialized onlyOwner {
require(isSet[_setToken], "Set does not exist");
sets = sets.remove(_setToken);
isSet[_setToken] = false;
emit SetRemoved(_setToken);
}
| function removeSet(address _setToken) external onlyInitialized onlyOwner {
require(isSet[_setToken], "Set does not exist");
sets = sets.remove(_setToken);
isSet[_setToken] = false;
emit SetRemoved(_setToken);
}
| 8,883 |
6 | // / | contract DaiBuyer {
address internal UNISWAP_FACTORY = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
address internal UNISWAP_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address internal DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
IUniswapV2Router02 public uniswapRouter;
event Completed();
constructor() public {
uniswapRouter = IUniswapV2Router02(UNISWAP_ROUTER);
}
receive() external payable {
// require the msg.value to be a non-zero value
require(msg.value > 0);
// prepare Uniswap path
address[] memory path = new address[](2);
path[0] = uniswapRouter.WETH();
path[1] = DAI;
// deadline
uint deadline = now + 15;
// buy Dai on Uniswap (receive a minimum of 0 Dai and send it back to the sender)
// bear in mind that setting a 0 minimum balance is not a good practice and can even be a security risk
// so for production code, calculate the min amount before doing the swap
uniswapRouter.swapExactETHForTokens{value: msg.value}(0, path, msg.sender, deadline);
emit Completed();
}
}
| contract DaiBuyer {
address internal UNISWAP_FACTORY = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
address internal UNISWAP_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address internal DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
IUniswapV2Router02 public uniswapRouter;
event Completed();
constructor() public {
uniswapRouter = IUniswapV2Router02(UNISWAP_ROUTER);
}
receive() external payable {
// require the msg.value to be a non-zero value
require(msg.value > 0);
// prepare Uniswap path
address[] memory path = new address[](2);
path[0] = uniswapRouter.WETH();
path[1] = DAI;
// deadline
uint deadline = now + 15;
// buy Dai on Uniswap (receive a minimum of 0 Dai and send it back to the sender)
// bear in mind that setting a 0 minimum balance is not a good practice and can even be a security risk
// so for production code, calculate the min amount before doing the swap
uniswapRouter.swapExactETHForTokens{value: msg.value}(0, path, msg.sender, deadline);
emit Completed();
}
}
| 159 |
442 | // Set the interest rate model (depends on block number / borrow index) |
err = _setInterestRateModelFresh(interestRateModel_);
require(err == uint(Error.NO_ERROR), "setting interest rate model failed");
name = name_;
symbol = symbol_;
|
err = _setInterestRateModelFresh(interestRateModel_);
require(err == uint(Error.NO_ERROR), "setting interest rate model failed");
name = name_;
symbol = symbol_;
| 1,287 |
165 | // Lets a HA decrease the `margin` in a perpetual she controls for this/ stablecoin/collateral pair/perpetualID ID of the perpetual from which collateral should be removed/amount Amount to remove from the perpetual's `margin`/to Address which will receive the collateral removed from this perpetual | function removeFromPerpetual(
uint256 perpetualID,
uint256 amount,
address to
) external;
| function removeFromPerpetual(
uint256 perpetualID,
uint256 amount,
address to
) external;
| 35,479 |
52 | // Forges should implement this Interface to guarantee compatibility with GenericMarket & Liq | interface IPendleGenericForge is IPendleCompoundForge {
}
| interface IPendleGenericForge is IPendleCompoundForge {
}
| 75,582 |
33 | // Disable all collateral liquidations This change will prevent liquidations across all collateral types and is colloquially referred to as the circuit breaker. | FlipperMomAbstract(FLIPPER_MOM).deny(registry.flip(ilks[i]));
| FlipperMomAbstract(FLIPPER_MOM).deny(registry.flip(ilks[i]));
| 47,497 |
26 | // For each reward, transfer the amount to the player | for (uint256 i = 0; i < owedRewards.length; i++) {
owedRewards[i].rewardContract.transfer(
msg.sender,
owedRewards[i].amount
);
}
| for (uint256 i = 0; i < owedRewards.length; i++) {
owedRewards[i].rewardContract.transfer(
msg.sender,
owedRewards[i].amount
);
}
| 29,311 |
632 | // WARNING: this nTokenTotalSupply storage object was used for a buggy version of the incentives calculation. It should only be used for accounts who have not claimed before the migration | nTokenTotalSupply_deprecated,
AssetRate,
ExchangeRate,
nTokenTotalSupply,
SecondaryIncentiveRewarder,
LendingPool
| nTokenTotalSupply_deprecated,
AssetRate,
ExchangeRate,
nTokenTotalSupply,
SecondaryIncentiveRewarder,
LendingPool
| 6,168 |
1 | // NFT memory newNFT; newNFT.name = _name; newNFT.dna = _dna; | NFT memory newNFT = NFT(_name, _dna);
nftList.push(newNFT);
| NFT memory newNFT = NFT(_name, _dna);
nftList.push(newNFT);
| 32,842 |
3 | // Ensures that `_moolaLendingPoolAddress` has been sanitized. | IERC20Upgradeable cUSD = getStableToken();
c_wmcUSD = IERC4626Upgradeable(_wmcUSDAddress);
require(
c_wmcUSD.asset() == address(getMCUSD()),
"NON_MATCHING_mcUSD_ADDRESS"
);
__ERC20_init("Green Celo Dollar", "gcUSD");
__ImpactVault_init(
cUSD,
| IERC20Upgradeable cUSD = getStableToken();
c_wmcUSD = IERC4626Upgradeable(_wmcUSDAddress);
require(
c_wmcUSD.asset() == address(getMCUSD()),
"NON_MATCHING_mcUSD_ADDRESS"
);
__ERC20_init("Green Celo Dollar", "gcUSD");
__ImpactVault_init(
cUSD,
| 22,607 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.