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 |
|---|---|---|---|---|
14 | // Error for unsupported function (returned when calling empty renounceOwnership()) | error UnsupportedFunction();
| error UnsupportedFunction();
| 34,982 |
23 | // return the symbol of the token./ | function symbol() external view override returns(string memory){
return _symbol;
}
| function symbol() external view override returns(string memory){
return _symbol;
}
| 17,785 |
14 | // ------------------------------------------------------------------------ Lets a user list a software module for sale in this registry ------------------------------------------------------------------------ | function listModule(uint price, bytes32 sellerUsername, bytes32 moduleName, string usernameAndProjectName, bytes4 licenseId) public {
// make sure input params are valid
require(price != 0 && sellerUsername != "" && moduleName != "" && bytes(usernameAndProjectName).length != 0 && licenseId != 0);
// make sure the name isn't already taken
require(moduleIds[usernameAndProjectName] == 0);
numModules += 1;
moduleIds[usernameAndProjectName] = numModules;
ModuleForSale storage module = modules[numModules];
module.price = price;
module.sellerUsername = sellerUsername;
module.moduleName = moduleName;
module.sellerAddress = msg.sender;
module.licenseId = licenseId;
}
| function listModule(uint price, bytes32 sellerUsername, bytes32 moduleName, string usernameAndProjectName, bytes4 licenseId) public {
// make sure input params are valid
require(price != 0 && sellerUsername != "" && moduleName != "" && bytes(usernameAndProjectName).length != 0 && licenseId != 0);
// make sure the name isn't already taken
require(moduleIds[usernameAndProjectName] == 0);
numModules += 1;
moduleIds[usernameAndProjectName] = numModules;
ModuleForSale storage module = modules[numModules];
module.price = price;
module.sellerUsername = sellerUsername;
module.moduleName = moduleName;
module.sellerAddress = msg.sender;
module.licenseId = licenseId;
}
| 47,219 |
5 | // mapping asset historic | mapping(uint256 => History[]) private _history;
| mapping(uint256 => History[]) private _history;
| 6,253 |
10 | // `msg.sender` approves `_addr` to spend `_value` tokens /_spender The address of the account able to transfer the tokens /_value The amount of wei to be approved for transfer / return Whether the approval was successful or not | function approve(address _spender, uint256 _value) returns (bool success);
| function approve(address _spender, uint256 _value) returns (bool success);
| 43,108 |
43 | // to check the user etherbalance | function etherbalance(address _account)public view returns (uint) {
return _account.balance;
}
| function etherbalance(address _account)public view returns (uint) {
return _account.balance;
}
| 42,400 |
770 | // Price calculation when price is decreased linearly in proportion to time: tau: The number of seconds after the start of the auction where the price will hit 0 top: Initial price dur: current seconds since the start of the auction Returns y = top((tau - dur) / tau) Note the internal call to mul multiples by RAY, thereby ensuring that the rmul calculation which utilizes top and tau (RAY values) is also a RAY value. | function price(uint256 top, uint256 dur) override external view returns (uint256) {
if (dur >= tau) return 0;
return rmul(top, mul(tau - dur, RAY) / tau);
}
| function price(uint256 top, uint256 dur) override external view returns (uint256) {
if (dur >= tau) return 0;
return rmul(top, mul(tau - dur, RAY) / tau);
}
| 12,107 |
6 | // Check the deposit parameters | require(amount > 0, "Amount must be greater than 0.");
require(
unlockTimestamp > block.timestamp,
"Unlock timestamp must be in the future."
);
| require(amount > 0, "Amount must be greater than 0.");
require(
unlockTimestamp > block.timestamp,
"Unlock timestamp must be in the future."
);
| 16,044 |
214 | // leaving _flAmount to be the same as the older version | function repay(address _market, ExchangeData memory _data, uint _rateMode, uint256 _gasCost, uint _flAmount) public payable burnGas(10) {
address lendingPool = ILendingPoolAddressesProviderV2(_market).getLendingPool();
// send msg.value for exchange to the receiver
AAVE_RECEIVER.transfer(msg.value);
address[] memory assets = new address[](1);
assets[0] = _data.srcAddr;
uint256[] memory amounts = new uint256[](1);
amounts[0] = _data.srcAmount;
// for repay we are using regular flash loan with paying back the flash loan + premium
uint256[] memory modes = new uint256[](1);
modes[0] = 0;
// create data
bytes memory encodedData = packExchangeData(_data);
bytes memory data = abi.encode(encodedData, _market, _gasCost, _rateMode, true, address(this));
// give permission to receiver and execute tx
givePermission(AAVE_RECEIVER);
ILendingPoolV2(lendingPool).flashLoan(AAVE_RECEIVER, assets, amounts, modes, address(this), data, AAVE_REFERRAL_CODE);
removePermission(AAVE_RECEIVER);
}
| function repay(address _market, ExchangeData memory _data, uint _rateMode, uint256 _gasCost, uint _flAmount) public payable burnGas(10) {
address lendingPool = ILendingPoolAddressesProviderV2(_market).getLendingPool();
// send msg.value for exchange to the receiver
AAVE_RECEIVER.transfer(msg.value);
address[] memory assets = new address[](1);
assets[0] = _data.srcAddr;
uint256[] memory amounts = new uint256[](1);
amounts[0] = _data.srcAmount;
// for repay we are using regular flash loan with paying back the flash loan + premium
uint256[] memory modes = new uint256[](1);
modes[0] = 0;
// create data
bytes memory encodedData = packExchangeData(_data);
bytes memory data = abi.encode(encodedData, _market, _gasCost, _rateMode, true, address(this));
// give permission to receiver and execute tx
givePermission(AAVE_RECEIVER);
ILendingPoolV2(lendingPool).flashLoan(AAVE_RECEIVER, assets, amounts, modes, address(this), data, AAVE_REFERRAL_CODE);
removePermission(AAVE_RECEIVER);
}
| 83,238 |
93 | // Lets a SLP enter the protocol by sending collateral to the system in exchange of sanTokens/user Address of the SLP to send sanTokens to/amount Amount of collateral sent/poolManager Address of the `PoolManager` of the required collateral | function deposit(
uint256 amount,
address user,
address poolManager
) external;
| function deposit(
uint256 amount,
address user,
address poolManager
) external;
| 31,553 |
110 | // calculateFeeUses basis points to calculate fee / | function calculateFee(uint amount) internal returns (uint) {
require((amount / 1000) * 1000 == amount, 'amount is too small');
return amount * feeRate / 10000;
}
| function calculateFee(uint amount) internal returns (uint) {
require((amount / 1000) * 1000 == amount, 'amount is too small');
return amount * feeRate / 10000;
}
| 49,019 |
651 | // Address of the token held in the position as collateral | address public HELD_TOKEN;
| address public HELD_TOKEN;
| 72,446 |
60 | // "commit" for bet settlement can only be obtained by hashing a "reveal". | uint commit = uint(keccak256(abi.encodePacked(combinationParameter[uint8(SettleParam.Reveal)])));
| uint commit = uint(keccak256(abi.encodePacked(combinationParameter[uint8(SettleParam.Reveal)])));
| 16,209 |
5 | // Emitted on borrow() and flashLoan() when debt needs to be opened reserve The address of the underlying asset being borrowed user The address of the user initiating the borrow(), receiving the funds on borrow() or justinitiator of the transaction on flashLoan() onBehalfOf The address that will be getting the debt amount The amount borrowed out interestRateMode The rate mode: 1 for Stable, 2 for Variable borrowRate The numeric rate at which the user has borrowed, expressed in ray referralCode The referral code used / | event Borrow(
| event Borrow(
| 21,833 |
51 | // jhhong/계정(approver)이 계정(spender)에게 위임한 통화량을 반환한다./approver 위임할 계정/spender 위임받을 계정/ return 계정(approver)이 계정(spender)에게 위임한 통화량 | function allowance(address approver, address spender) public view returns (uint256) {
return _allowances[approver][spender];
}
| function allowance(address approver, address spender) public view returns (uint256) {
return _allowances[approver][spender];
}
| 46,247 |
84 | // Adjust reward accordingly | reward = adjustedReward;
| reward = adjustedReward;
| 61,433 |
176 | // require(msg.value >= FEE, "Value below price"); |
_safeMint(_to, tokenid);
|
_safeMint(_to, tokenid);
| 42,130 |
20 | // When does the period end? | uint public endBlock;
| uint public endBlock;
| 25,694 |
13 | // since we have to be able to return -1 (if the char isn't found or input error),this function must return an "int" type with a max length of (2^128 - 1) | return -1;
| return -1;
| 2,335 |
115 | // transferring WETH with unwrap flag | _withdrawWeth(_receiver, _amount);
| _withdrawWeth(_receiver, _amount);
| 19,325 |
23 | // Only manager is able to call this function Sets the devaluation period of collateral after liquidation asset The address of the main collateral token newValue The devaluation period in blocks / | function setDevaluationPeriod(address asset, uint newValue) public onlyManager {
require(newValue != 0, "Unit Protocol: INCORRECT_DEVALUATION_VALUE");
devaluationPeriod[asset] = newValue;
}
| function setDevaluationPeriod(address asset, uint newValue) public onlyManager {
require(newValue != 0, "Unit Protocol: INCORRECT_DEVALUATION_VALUE");
devaluationPeriod[asset] = newValue;
}
| 84,055 |
2 | // dUtlityBenchmark contract. Inherits from dUtility. Used for benchmarks. / | contract dUtilityBenchmark is dUtility {
/**
* @dev Sets up contract for conducting benchmarks.
* @param _verifier Address of verifier contract.
* @param _households List of household addresses to add for the benchmark.
* @param _energyDeltaHashes List of energy delta hashes corresponding to household addresses.
* @return success bool
*/
function setupBenchmark(
address _verifier,
address[] calldata _households,
bytes32[] calldata _energyDeltaHashes
) external onlyOwner returns (bool) {
require(
_households.length == _energyDeltaHashes.length,
"Households have to be the same length as energy delta hashes."
);
_setVerifier(_verifier);
for (uint i = 0; i < _households.length; ++i) {
_addHousehold(_households[i]);
_updateEnergy(_households[i], _energyDeltaHashes[i], true);
}
return true;
}
}
| contract dUtilityBenchmark is dUtility {
/**
* @dev Sets up contract for conducting benchmarks.
* @param _verifier Address of verifier contract.
* @param _households List of household addresses to add for the benchmark.
* @param _energyDeltaHashes List of energy delta hashes corresponding to household addresses.
* @return success bool
*/
function setupBenchmark(
address _verifier,
address[] calldata _households,
bytes32[] calldata _energyDeltaHashes
) external onlyOwner returns (bool) {
require(
_households.length == _energyDeltaHashes.length,
"Households have to be the same length as energy delta hashes."
);
_setVerifier(_verifier);
for (uint i = 0; i < _households.length; ++i) {
_addHousehold(_households[i]);
_updateEnergy(_households[i], _energyDeltaHashes[i], true);
}
return true;
}
}
| 30,851 |
15 | // We use a single lock for the whole contract. / | bool private reentrancyLock = false;
| bool private reentrancyLock = false;
| 9,037 |
50 | // функция, которая позволяет посмотреть список участников в хронологическом порядке, которые имеют депозит больше 0.05 eth | function getInvestors() public view returns(address payable [] memory) {
return investors;
}
| function getInvestors() public view returns(address payable [] memory) {
return investors;
}
| 16,364 |
187 | // CONFIGURATION //Attempts to tunnel a route over the main token and save it./This route is of the form [from, 0, main, 0, to] | function generateAutomaticRoute(IERC20 from, IERC20 to) private {
IERC20 main = mainToken;
require(from != main && to != main, "!no route found");
address[] memory route = new address[](5);
route[0] = address(from);
route[1] = address(0);
route[2] = address(main);
route[3] = address(0);
route[4] = address(to);
_setRoute(from, to, route);
}
| function generateAutomaticRoute(IERC20 from, IERC20 to) private {
IERC20 main = mainToken;
require(from != main && to != main, "!no route found");
address[] memory route = new address[](5);
route[0] = address(from);
route[1] = address(0);
route[2] = address(main);
route[3] = address(0);
route[4] = address(to);
_setRoute(from, to, route);
}
| 48,742 |
1 | // WETH to token price | mapping (address => FixedPoint.uq112x112) internal W2TPrice;
mapping (address => uint256) internal price0CumulativeLastUpdate;
mapping (address => uint256) internal price1CumulativeLastUpdate;
mapping (address => uint32) public blockTimestampLastUpdate;
mapping (address => IUniswapV2Pair) public uniswapPairs;
| mapping (address => FixedPoint.uq112x112) internal W2TPrice;
mapping (address => uint256) internal price0CumulativeLastUpdate;
mapping (address => uint256) internal price1CumulativeLastUpdate;
mapping (address => uint32) public blockTimestampLastUpdate;
mapping (address => IUniswapV2Pair) public uniswapPairs;
| 25,364 |
9 | // (bool success, ) = address(lock).call( abi.encodeWithSignature( "purchase(uint256[],address[],address[],address[],bytes[])", val, recipient, referrer, keyManager, data ) ); require(success, "calldata failed");require(totalSupply() + 1 <= maxSupply, "Max Supply reached"); | _safeMint(msg.sender, 1);
| _safeMint(msg.sender, 1);
| 16,253 |
71 | // ============ R = 1 cases ============ |
function _ROneSellBaseToken(PMMState memory state, uint256 payBaseAmount)
internal
pure
returns (
uint256 // receiveQuoteToken
)
|
function _ROneSellBaseToken(PMMState memory state, uint256 payBaseAmount)
internal
pure
returns (
uint256 // receiveQuoteToken
)
| 36,521 |
94 | // name of token | ERC721("Lucky Eggs", "LUCK") {
owner = msg.sender;
}
| ERC721("Lucky Eggs", "LUCK") {
owner = msg.sender;
}
| 30,742 |
16 | // "toETHaddr" is the address to which the ETH contributions are forwarded to, aka FWDaddrETH "addrESSgenesis" is the address of the Essentia ERC20 token contract, aka ESSgenesis NOTE: this contract will sell only its token balance on the ERC20 specified in addrESSgenesis the maxCap in ETH and the tokenPrice will indirectly set the ESS token amount on sale NOTE: this contract should have sufficient ESS token balance to be > maxCap / tokenPrice NOTE: this contract will stop REGARDLESS of the above (maxCap) when its token balance is all sold The Owner of this contract can set: Price, End, MaxCap, ESS |
constructor
(
address toETHaddr,
address addrESSgenesis
|
constructor
(
address toETHaddr,
address addrESSgenesis
| 19,027 |
36 | // Implementation of the `IERC734` "KeyHolder" interface. / | contract ERC734 is IERC734 {
uint256 public constant MANAGEMENT_KEY = 1;
uint256 public constant ACTION_KEY = 2;
uint256 public constant CLAIM_SIGNER_KEY = 3;
uint256 public constant ENCRYPTION_KEY = 4;
bool private identitySettled = false;
uint256 private executionNonce;
struct Execution {
address to;
uint256 value;
bytes data;
bool approved;
bool executed;
}
mapping (bytes32 => Key) private keys;
mapping (uint256 => bytes32[]) private keysByPurpose;
mapping (uint256 => Execution) private executions;
event ExecutionFailed(uint256 indexed executionId, address indexed to, uint256 indexed value, bytes data);
function set(address _owner) public {
bytes32 _key = keccak256(abi.encode(_owner));
require(!identitySettled, "Key already exists");
identitySettled = true;
keys[_key].key = _key;
keys[_key].purposes = [1];
keys[_key].keyType = 1;
keysByPurpose[1].push(_key);
emit KeyAdded(_key, 1, 1);
}
/**
* @notice Implementation of the getKey function from the ERC-734 standard
*
* @param _key The public key. for non-hex and long keys, its the Keccak256 hash of the key
*
* @return purposes Returns the full key data, if present in the identity.
* @return keyType Returns the full key data, if present in the identity.
* @return key Returns the full key data, if present in the identity.
*/
function getKey(bytes32 _key)
public
override
view
returns(uint256[] memory purposes, uint256 keyType, bytes32 key)
{
return (keys[_key].purposes, keys[_key].keyType, keys[_key].key);
}
/**
* @notice gets the purposes of a key
*
* @param _key The public key. for non-hex and long keys, its the Keccak256 hash of the key
*
* @return _purposes Returns the purposes of the specified key
*/
function getKeyPurposes(bytes32 _key)
public
override
view
returns(uint256[] memory _purposes)
{
return (keys[_key].purposes);
}
/**
* @notice gets all the keys with a specific purpose from an identity
*
* @param _purpose a uint256[] Array of the key types, like 1 = MANAGEMENT, 2 = ACTION, 3 = CLAIM, 4 = ENCRYPTION
*
* @return _keys Returns an array of public key bytes32 hold by this identity and having the specified purpose
*/
function getKeysByPurpose(uint256 _purpose)
public
override
view
returns(bytes32[] memory _keys)
{
return keysByPurpose[_purpose];
}
/**
* @notice implementation of the addKey function of the ERC-734 standard
* Adds a _key to the identity. The _purpose specifies the purpose of key. Initially we propose four purposes:
* 1: MANAGEMENT keys, which can manage the identity
* 2: ACTION keys, which perform actions in this identities name (signing, logins, transactions, etc.)
* 3: CLAIM signer keys, used to sign claims on other identities which need to be revokable.
* 4: ENCRYPTION keys, used to encrypt data e.g. hold in claims.
* MUST only be done by keys of purpose 1, or the identity itself.
* If its the identity itself, the approval process will determine its approval.
*
* @param _key keccak256 representation of an ethereum address
* @param _type type of key used, which would be a uint256 for different key types. e.g. 1 = ECDSA, 2 = RSA, etc.
* @param _purpose a uint256[] Array of the key types, like 1 = MANAGEMENT, 2 = ACTION, 3 = CLAIM, 4 = ENCRYPTION
*
* @return success Returns TRUE if the addition was successful and FALSE if not
*/
function addKey(bytes32 _key, uint256 _purpose, uint256 _type)
public
override
returns (bool success)
{
if (msg.sender != address(this)) {
require(keyHasPurpose(keccak256(abi.encode(msg.sender)), 1), "Permissions: Sender does not have management key");
}
if (keys[_key].key == _key) {
for (uint keyPurposeIndex = 0; keyPurposeIndex < keys[_key].purposes.length; keyPurposeIndex++) {
uint256 purpose = keys[_key].purposes[keyPurposeIndex];
if (purpose == _purpose) {
revert("Conflict: Key already has purpose");
}
}
keys[_key].purposes.push(_purpose);
} else {
keys[_key].key = _key;
keys[_key].purposes = [_purpose];
keys[_key].keyType = _type;
}
keysByPurpose[_purpose].push(_key);
emit KeyAdded(_key, _purpose, _type);
return true;
}
function approve(uint256 _id, bool _approve)
public
override
returns (bool success)
{
require(keyHasPurpose(keccak256(abi.encode(msg.sender)), 2), "Sender does not have action key");
emit Approved(_id, _approve);
if (_approve == true) {
executions[_id].approved = true;
(success,) = executions[_id].to.call.value(executions[_id].value)(abi.encode(executions[_id].data, 0));
if (success) {
executions[_id].executed = true;
emit Executed(
_id,
executions[_id].to,
executions[_id].value,
executions[_id].data
);
return true;
} else {
emit ExecutionFailed(
_id,
executions[_id].to,
executions[_id].value,
executions[_id].data
);
return false;
}
} else {
executions[_id].approved = false;
}
return true;
}
function execute(address _to, uint256 _value, bytes memory _data)
public
override
payable
returns (uint256 executionId)
{
require(!executions[executionNonce].executed, "Already executed");
executions[executionNonce].to = _to;
executions[executionNonce].value = _value;
executions[executionNonce].data = _data;
emit ExecutionRequested(executionNonce, _to, _value, _data);
if (keyHasPurpose(keccak256(abi.encode(msg.sender)), 2)) {
approve(executionNonce, true);
}
executionNonce++;
return executionNonce-1;
}
function removeKey(bytes32 _key, uint256 _purpose)
public
override
returns (bool success)
{
require(keys[_key].key == _key, "NonExisting: Key isn't registered");
if (msg.sender != address(this)) {
require(keyHasPurpose(keccak256(abi.encode(msg.sender)), 1), "Permissions: Sender does not have management key"); // Sender has MANAGEMENT_KEY
}
require(keys[_key].purposes.length > 0, "NonExisting: Key doesn't have such purpose");
uint purposeIndex = 0;
while (keys[_key].purposes[purposeIndex] != _purpose) {
purposeIndex++;
if (purposeIndex >= keys[_key].purposes.length) {
break;
}
}
require(purposeIndex < keys[_key].purposes.length, "NonExisting: Key doesn't have such purpose");
keys[_key].purposes[purposeIndex] = keys[_key].purposes[keys[_key].purposes.length - 1];
keys[_key].purposes.pop();
uint keyIndex = 0;
while (keysByPurpose[_purpose][keyIndex] != _key) {
keyIndex++;
}
keysByPurpose[_purpose][keyIndex] = keysByPurpose[_purpose][keysByPurpose[_purpose].length - 1];
keysByPurpose[_purpose].pop();
uint keyType = keys[_key].keyType;
if (keys[_key].purposes.length == 0) {
delete keys[_key];
}
emit KeyRemoved(_key, _purpose, keyType);
return true;
}
/**
* @notice Returns true if the key has MANAGEMENT purpose or the specified purpose.
*/
function keyHasPurpose(bytes32 _key, uint256 _purpose)
public
override
view
returns(bool result)
{
Key memory key = keys[_key];
if (key.key == 0) return false;
for (uint keyPurposeIndex = 0; keyPurposeIndex < key.purposes.length; keyPurposeIndex++) {
uint256 purpose = key.purposes[keyPurposeIndex];
if (purpose == MANAGEMENT_KEY || purpose == _purpose) return true;
}
return false;
}
}
| contract ERC734 is IERC734 {
uint256 public constant MANAGEMENT_KEY = 1;
uint256 public constant ACTION_KEY = 2;
uint256 public constant CLAIM_SIGNER_KEY = 3;
uint256 public constant ENCRYPTION_KEY = 4;
bool private identitySettled = false;
uint256 private executionNonce;
struct Execution {
address to;
uint256 value;
bytes data;
bool approved;
bool executed;
}
mapping (bytes32 => Key) private keys;
mapping (uint256 => bytes32[]) private keysByPurpose;
mapping (uint256 => Execution) private executions;
event ExecutionFailed(uint256 indexed executionId, address indexed to, uint256 indexed value, bytes data);
function set(address _owner) public {
bytes32 _key = keccak256(abi.encode(_owner));
require(!identitySettled, "Key already exists");
identitySettled = true;
keys[_key].key = _key;
keys[_key].purposes = [1];
keys[_key].keyType = 1;
keysByPurpose[1].push(_key);
emit KeyAdded(_key, 1, 1);
}
/**
* @notice Implementation of the getKey function from the ERC-734 standard
*
* @param _key The public key. for non-hex and long keys, its the Keccak256 hash of the key
*
* @return purposes Returns the full key data, if present in the identity.
* @return keyType Returns the full key data, if present in the identity.
* @return key Returns the full key data, if present in the identity.
*/
function getKey(bytes32 _key)
public
override
view
returns(uint256[] memory purposes, uint256 keyType, bytes32 key)
{
return (keys[_key].purposes, keys[_key].keyType, keys[_key].key);
}
/**
* @notice gets the purposes of a key
*
* @param _key The public key. for non-hex and long keys, its the Keccak256 hash of the key
*
* @return _purposes Returns the purposes of the specified key
*/
function getKeyPurposes(bytes32 _key)
public
override
view
returns(uint256[] memory _purposes)
{
return (keys[_key].purposes);
}
/**
* @notice gets all the keys with a specific purpose from an identity
*
* @param _purpose a uint256[] Array of the key types, like 1 = MANAGEMENT, 2 = ACTION, 3 = CLAIM, 4 = ENCRYPTION
*
* @return _keys Returns an array of public key bytes32 hold by this identity and having the specified purpose
*/
function getKeysByPurpose(uint256 _purpose)
public
override
view
returns(bytes32[] memory _keys)
{
return keysByPurpose[_purpose];
}
/**
* @notice implementation of the addKey function of the ERC-734 standard
* Adds a _key to the identity. The _purpose specifies the purpose of key. Initially we propose four purposes:
* 1: MANAGEMENT keys, which can manage the identity
* 2: ACTION keys, which perform actions in this identities name (signing, logins, transactions, etc.)
* 3: CLAIM signer keys, used to sign claims on other identities which need to be revokable.
* 4: ENCRYPTION keys, used to encrypt data e.g. hold in claims.
* MUST only be done by keys of purpose 1, or the identity itself.
* If its the identity itself, the approval process will determine its approval.
*
* @param _key keccak256 representation of an ethereum address
* @param _type type of key used, which would be a uint256 for different key types. e.g. 1 = ECDSA, 2 = RSA, etc.
* @param _purpose a uint256[] Array of the key types, like 1 = MANAGEMENT, 2 = ACTION, 3 = CLAIM, 4 = ENCRYPTION
*
* @return success Returns TRUE if the addition was successful and FALSE if not
*/
function addKey(bytes32 _key, uint256 _purpose, uint256 _type)
public
override
returns (bool success)
{
if (msg.sender != address(this)) {
require(keyHasPurpose(keccak256(abi.encode(msg.sender)), 1), "Permissions: Sender does not have management key");
}
if (keys[_key].key == _key) {
for (uint keyPurposeIndex = 0; keyPurposeIndex < keys[_key].purposes.length; keyPurposeIndex++) {
uint256 purpose = keys[_key].purposes[keyPurposeIndex];
if (purpose == _purpose) {
revert("Conflict: Key already has purpose");
}
}
keys[_key].purposes.push(_purpose);
} else {
keys[_key].key = _key;
keys[_key].purposes = [_purpose];
keys[_key].keyType = _type;
}
keysByPurpose[_purpose].push(_key);
emit KeyAdded(_key, _purpose, _type);
return true;
}
function approve(uint256 _id, bool _approve)
public
override
returns (bool success)
{
require(keyHasPurpose(keccak256(abi.encode(msg.sender)), 2), "Sender does not have action key");
emit Approved(_id, _approve);
if (_approve == true) {
executions[_id].approved = true;
(success,) = executions[_id].to.call.value(executions[_id].value)(abi.encode(executions[_id].data, 0));
if (success) {
executions[_id].executed = true;
emit Executed(
_id,
executions[_id].to,
executions[_id].value,
executions[_id].data
);
return true;
} else {
emit ExecutionFailed(
_id,
executions[_id].to,
executions[_id].value,
executions[_id].data
);
return false;
}
} else {
executions[_id].approved = false;
}
return true;
}
function execute(address _to, uint256 _value, bytes memory _data)
public
override
payable
returns (uint256 executionId)
{
require(!executions[executionNonce].executed, "Already executed");
executions[executionNonce].to = _to;
executions[executionNonce].value = _value;
executions[executionNonce].data = _data;
emit ExecutionRequested(executionNonce, _to, _value, _data);
if (keyHasPurpose(keccak256(abi.encode(msg.sender)), 2)) {
approve(executionNonce, true);
}
executionNonce++;
return executionNonce-1;
}
function removeKey(bytes32 _key, uint256 _purpose)
public
override
returns (bool success)
{
require(keys[_key].key == _key, "NonExisting: Key isn't registered");
if (msg.sender != address(this)) {
require(keyHasPurpose(keccak256(abi.encode(msg.sender)), 1), "Permissions: Sender does not have management key"); // Sender has MANAGEMENT_KEY
}
require(keys[_key].purposes.length > 0, "NonExisting: Key doesn't have such purpose");
uint purposeIndex = 0;
while (keys[_key].purposes[purposeIndex] != _purpose) {
purposeIndex++;
if (purposeIndex >= keys[_key].purposes.length) {
break;
}
}
require(purposeIndex < keys[_key].purposes.length, "NonExisting: Key doesn't have such purpose");
keys[_key].purposes[purposeIndex] = keys[_key].purposes[keys[_key].purposes.length - 1];
keys[_key].purposes.pop();
uint keyIndex = 0;
while (keysByPurpose[_purpose][keyIndex] != _key) {
keyIndex++;
}
keysByPurpose[_purpose][keyIndex] = keysByPurpose[_purpose][keysByPurpose[_purpose].length - 1];
keysByPurpose[_purpose].pop();
uint keyType = keys[_key].keyType;
if (keys[_key].purposes.length == 0) {
delete keys[_key];
}
emit KeyRemoved(_key, _purpose, keyType);
return true;
}
/**
* @notice Returns true if the key has MANAGEMENT purpose or the specified purpose.
*/
function keyHasPurpose(bytes32 _key, uint256 _purpose)
public
override
view
returns(bool result)
{
Key memory key = keys[_key];
if (key.key == 0) return false;
for (uint keyPurposeIndex = 0; keyPurposeIndex < key.purposes.length; keyPurposeIndex++) {
uint256 purpose = key.purposes[keyPurposeIndex];
if (purpose == MANAGEMENT_KEY || purpose == _purpose) return true;
}
return false;
}
}
| 45,335 |
11 | // Require the following conditions: - oracle is active- oracle type is assigned- oracle type is active / | function requireOracleActiveWithAssignedActiveOracleType(address _oracle, bytes32 _oracleType) external view {
Oracle storage o = oracleDetails[_oracle];
require(o.active == true, "Oracle is not active");
require(o.assignedOracleTypes.has(_oracleType), "Oracle type not assigned");
require(
pggConfig.getOracleStakes().isOracleStakeActive(_oracle, _oracleType) == true,
"Oracle type not active"
);
}
| function requireOracleActiveWithAssignedActiveOracleType(address _oracle, bytes32 _oracleType) external view {
Oracle storage o = oracleDetails[_oracle];
require(o.active == true, "Oracle is not active");
require(o.assignedOracleTypes.has(_oracleType), "Oracle type not assigned");
require(
pggConfig.getOracleStakes().isOracleStakeActive(_oracle, _oracleType) == true,
"Oracle type not active"
);
}
| 31,931 |
278 | // - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event./ | function safeTransferFrom(address from, address to, uint256 tokenId) external;
| function safeTransferFrom(address from, address to, uint256 tokenId) external;
| 39,624 |
20 | // Emitted when a Pool is registered by calling `registerPool`. / | event PoolRegistered(bytes32 indexed poolId, address indexed poolAddress, PoolSpecialization specialization);
| event PoolRegistered(bytes32 indexed poolId, address indexed poolAddress, PoolSpecialization specialization);
| 22,853 |
0 | // Neobank Interface Utilities for Neobank / | interface INeobank {
//@dev functions from Neobank that are going to be used
function depositIntoAccount(
address _owner,
uint256 _accountNumber,
uint256 _amount
) external payable;
function depositERC20IntoAccount(
address _owner,
uint256 _accountNumber,
uint256 _amount,
address currency
) external payable;
}
| interface INeobank {
//@dev functions from Neobank that are going to be used
function depositIntoAccount(
address _owner,
uint256 _accountNumber,
uint256 _amount
) external payable;
function depositERC20IntoAccount(
address _owner,
uint256 _accountNumber,
uint256 _amount,
address currency
) external payable;
}
| 6,056 |
28 | // Append only list of requested forced action hashes. | bytes32[] actionHashList;
| bytes32[] actionHashList;
| 39,792 |
272 | // column16_row0/ mload(0x31a0), pedersen/hash3/ec_subset_sum/bit_neg_0 = 1 - pedersen__hash3__ec_subset_sum__bit_0. |
let val := addmod(
1,
sub(PRIME, /*intermediate_value/pedersen/hash3/ec_subset_sum/bit_0*/ mload(0x4240)),
PRIME)
mstore(0x4260, val)
|
let val := addmod(
1,
sub(PRIME, /*intermediate_value/pedersen/hash3/ec_subset_sum/bit_0*/ mload(0x4240)),
PRIME)
mstore(0x4260, val)
| 4,360 |
52 | // Only allows to withdraw non-core strategy tokens ~ this is over and above normal yield | function yearn(address _strategy, address _token, uint parts) public {
require(msg.sender == strategist || msg.sender == governance, "!governance");
// This contract should never have value in it, but just incase since this is a public call
uint _before = IERC20(_token).balanceOf(address(this));
Strategy(_strategy).withdraw(_token);
uint _after = IERC20(_token).balanceOf(address(this));
if (_after > _before) {
uint _amount = _after.sub(_before);
address _want = Strategy(_strategy).want();
uint[] memory _distribution;
uint _expected;
_before = IERC20(_want).balanceOf(address(this));
IERC20(_token).safeApprove(onesplit, 0);
IERC20(_token).safeApprove(onesplit, _amount);
(_expected, _distribution) = OneSplitAudit(onesplit).getExpectedReturn(_token, _want, _amount, parts, 0);
OneSplitAudit(onesplit).swap(_token, _want, _amount, _expected, _distribution, 0);
_after = IERC20(_want).balanceOf(address(this));
if (_after > _before) {
_amount = _after.sub(_before);
uint _reward = _amount.mul(split).div(max);
earn(_want, _amount.sub(_reward));
IERC20(_want).safeTransfer(rewards, _reward);
}
}
}
| function yearn(address _strategy, address _token, uint parts) public {
require(msg.sender == strategist || msg.sender == governance, "!governance");
// This contract should never have value in it, but just incase since this is a public call
uint _before = IERC20(_token).balanceOf(address(this));
Strategy(_strategy).withdraw(_token);
uint _after = IERC20(_token).balanceOf(address(this));
if (_after > _before) {
uint _amount = _after.sub(_before);
address _want = Strategy(_strategy).want();
uint[] memory _distribution;
uint _expected;
_before = IERC20(_want).balanceOf(address(this));
IERC20(_token).safeApprove(onesplit, 0);
IERC20(_token).safeApprove(onesplit, _amount);
(_expected, _distribution) = OneSplitAudit(onesplit).getExpectedReturn(_token, _want, _amount, parts, 0);
OneSplitAudit(onesplit).swap(_token, _want, _amount, _expected, _distribution, 0);
_after = IERC20(_want).balanceOf(address(this));
if (_after > _before) {
_amount = _after.sub(_before);
uint _reward = _amount.mul(split).div(max);
earn(_want, _amount.sub(_reward));
IERC20(_want).safeTransfer(rewards, _reward);
}
}
}
| 11,244 |
2 | // updates the rage trade pool settings/poolId rage trade pool id/newSettings updated rage trade pool settings | function updatePoolSettings(uint32 poolId, PoolSettings calldata newSettings) external;
| function updatePoolSettings(uint32 poolId, PoolSettings calldata newSettings) external;
| 26,854 |
231 | // --------------------------------------------/Breed crabs for a fee /--------------------------------------------/ | function breed(uint256 oneCrab, uint256 anotherCrab) external payable {
// Checks for payment.
require(msg.value >= _price);
// Caller must own the Crabies.
require(_owns(msg.sender, oneCrab));
require(_owns(msg.sender, anotherCrab));
// Get the DNA of the two Crabies.
CrabyDNA storage oneCrabDNA_actual = _tokenDetails[oneCrab];
CrabyDNA storage anotherCrabDNA_actual = _tokenDetails[anotherCrab];
bytes32 oneCrabyDNA = oneCrabDNA_actual.crabyDNA;
bytes32 anotherCrabyDNA = anotherCrabDNA_actual.crabyDNA;
// Check that the Crabies are ready to breed and haven't bred before.
require(oneCrabyDNA[0] >= 0x02);
require(oneCrabyDNA[1] == 0x00);
require(anotherCrabyDNA[0] >= 0x02);
require(anotherCrabyDNA[1] == 0x00);
// this will be the new crabs DNA
bytes32 offspringDNA = 0x00;
// Get some random bytes to determine DNA mixing
bytes32 dnaMixer = randBytes32(oneCrab + anotherCrab);
bytes32 x = 0xff00000000000000000000000000000000000000000000000000000000000000;
//Randomly mix the two DNA streams, starting at byte 4 and ending at byte 22
for (uint8 i = 4; i < 12; i++){
if (dnaMixer[i] > 0x8F){
offspringDNA ^= (x & oneCrabyDNA[i]) >> (i*8);
}
| function breed(uint256 oneCrab, uint256 anotherCrab) external payable {
// Checks for payment.
require(msg.value >= _price);
// Caller must own the Crabies.
require(_owns(msg.sender, oneCrab));
require(_owns(msg.sender, anotherCrab));
// Get the DNA of the two Crabies.
CrabyDNA storage oneCrabDNA_actual = _tokenDetails[oneCrab];
CrabyDNA storage anotherCrabDNA_actual = _tokenDetails[anotherCrab];
bytes32 oneCrabyDNA = oneCrabDNA_actual.crabyDNA;
bytes32 anotherCrabyDNA = anotherCrabDNA_actual.crabyDNA;
// Check that the Crabies are ready to breed and haven't bred before.
require(oneCrabyDNA[0] >= 0x02);
require(oneCrabyDNA[1] == 0x00);
require(anotherCrabyDNA[0] >= 0x02);
require(anotherCrabyDNA[1] == 0x00);
// this will be the new crabs DNA
bytes32 offspringDNA = 0x00;
// Get some random bytes to determine DNA mixing
bytes32 dnaMixer = randBytes32(oneCrab + anotherCrab);
bytes32 x = 0xff00000000000000000000000000000000000000000000000000000000000000;
//Randomly mix the two DNA streams, starting at byte 4 and ending at byte 22
for (uint8 i = 4; i < 12; i++){
if (dnaMixer[i] > 0x8F){
offspringDNA ^= (x & oneCrabyDNA[i]) >> (i*8);
}
| 3,207 |
15 | // ERC721 with permit/Nonfungible tokens that support an approve via signature, i.e. permit | abstract contract ERC721Permit is DeadlineValidation, ERC721Enumerable, IERC721Permit {
/// @dev Value is equal to keccak256("Permit(address spender,uint256 tokenId,uint256 nonce,uint256 deadline)");
bytes32 public constant override PERMIT_TYPEHASH =
0x49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad;
/// @dev The hash of the name used in the permit signature verification
bytes32 private immutable nameHash;
/// @dev The hash of the version string used in the permit signature verification
bytes32 private immutable versionHash;
/// @return The domain seperator used in encoding of permit signature
bytes32 public immutable override DOMAIN_SEPARATOR;
/// @notice Computes the nameHash and versionHash
constructor(
string memory name_,
string memory symbol_,
string memory version_
) ERC721(name_, symbol_) {
bytes32 _nameHash = keccak256(bytes(name_));
bytes32 _versionHash = keccak256(bytes(version_));
nameHash = _nameHash;
versionHash = _versionHash;
DOMAIN_SEPARATOR = keccak256(
abi.encode(
// keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)')
0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,
_nameHash,
_versionHash,
_getChainId(),
address(this)
)
);
}
function permit(
address spender,
uint256 tokenId,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external override onlyNotExpired(deadline) {
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(
abi.encode(PERMIT_TYPEHASH, spender, tokenId, _getAndIncrementNonce(tokenId), deadline)
)
)
);
address owner = ownerOf(tokenId);
require(spender != owner, 'ERC721Permit: approval to current owner');
if (Address.isContract(owner)) {
require(
IERC1271(owner).isValidSignature(digest, abi.encodePacked(r, s, v)) == 0x1626ba7e,
'Unauthorized'
);
} else {
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0), 'Invalid signature');
require(recoveredAddress == owner, 'Unauthorized');
}
_approve(spender, tokenId);
}
/// @dev Gets the current nonce for a token ID and then increments it, returning the original value
function _getAndIncrementNonce(uint256 tokenId) internal virtual returns (uint256);
/// @dev Gets the current chain ID
/// @return chainId The current chain ID
function _getChainId() internal view returns (uint256 chainId) {
assembly {
chainId := chainid()
}
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721Enumerable, IERC721Permit)
returns (bool)
{
return
interfaceId == type(ERC721Enumerable).interfaceId ||
interfaceId == type(IERC721Permit).interfaceId ||
super.supportsInterface(interfaceId);
}
} | abstract contract ERC721Permit is DeadlineValidation, ERC721Enumerable, IERC721Permit {
/// @dev Value is equal to keccak256("Permit(address spender,uint256 tokenId,uint256 nonce,uint256 deadline)");
bytes32 public constant override PERMIT_TYPEHASH =
0x49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad;
/// @dev The hash of the name used in the permit signature verification
bytes32 private immutable nameHash;
/// @dev The hash of the version string used in the permit signature verification
bytes32 private immutable versionHash;
/// @return The domain seperator used in encoding of permit signature
bytes32 public immutable override DOMAIN_SEPARATOR;
/// @notice Computes the nameHash and versionHash
constructor(
string memory name_,
string memory symbol_,
string memory version_
) ERC721(name_, symbol_) {
bytes32 _nameHash = keccak256(bytes(name_));
bytes32 _versionHash = keccak256(bytes(version_));
nameHash = _nameHash;
versionHash = _versionHash;
DOMAIN_SEPARATOR = keccak256(
abi.encode(
// keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)')
0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,
_nameHash,
_versionHash,
_getChainId(),
address(this)
)
);
}
function permit(
address spender,
uint256 tokenId,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external override onlyNotExpired(deadline) {
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(
abi.encode(PERMIT_TYPEHASH, spender, tokenId, _getAndIncrementNonce(tokenId), deadline)
)
)
);
address owner = ownerOf(tokenId);
require(spender != owner, 'ERC721Permit: approval to current owner');
if (Address.isContract(owner)) {
require(
IERC1271(owner).isValidSignature(digest, abi.encodePacked(r, s, v)) == 0x1626ba7e,
'Unauthorized'
);
} else {
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0), 'Invalid signature');
require(recoveredAddress == owner, 'Unauthorized');
}
_approve(spender, tokenId);
}
/// @dev Gets the current nonce for a token ID and then increments it, returning the original value
function _getAndIncrementNonce(uint256 tokenId) internal virtual returns (uint256);
/// @dev Gets the current chain ID
/// @return chainId The current chain ID
function _getChainId() internal view returns (uint256 chainId) {
assembly {
chainId := chainid()
}
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721Enumerable, IERC721Permit)
returns (bool)
{
return
interfaceId == type(ERC721Enumerable).interfaceId ||
interfaceId == type(IERC721Permit).interfaceId ||
super.supportsInterface(interfaceId);
}
} | 14,324 |
1 | // The reference value to check against | mapping(address => uint256) public referenceValues;
| mapping(address => uint256) public referenceValues;
| 27,358 |
4 | // calculate staking rewards | uint256 stakingRewards = amount / 10;
| uint256 stakingRewards = amount / 10;
| 11,337 |
6 | // remove stable yield distributor- Caller is only EmissionManager who manage yield distribution _reserve The address of the internal asset _index The index of stable yield distributors array / | ) external payable onlyEmissionManager {
require(_reserve != address(0), Errors.YD_INVALID_CONFIGURATION);
uint256 length = _reserveToSDistributorCount[_reserve];
require(_index < length, Errors.YD_INVALID_CONFIGURATION);
length = length - 1;
address removing = _reserveToSDistributors[_reserve][_index];
if (_index != length)
_reserveToSDistributors[_reserve][_index] = _reserveToSDistributors[_reserve][length];
delete _reserveToSDistributors[_reserve][length];
_reserveToSDistributorCount[_reserve] = length;
emit RemoveStableYieldDistributor(_reserve, removing);
}
| ) external payable onlyEmissionManager {
require(_reserve != address(0), Errors.YD_INVALID_CONFIGURATION);
uint256 length = _reserveToSDistributorCount[_reserve];
require(_index < length, Errors.YD_INVALID_CONFIGURATION);
length = length - 1;
address removing = _reserveToSDistributors[_reserve][_index];
if (_index != length)
_reserveToSDistributors[_reserve][_index] = _reserveToSDistributors[_reserve][length];
delete _reserveToSDistributors[_reserve][length];
_reserveToSDistributorCount[_reserve] = length;
emit RemoveStableYieldDistributor(_reserve, removing);
}
| 23,213 |
59 | // spawningFor: per address, the points they can spawn with | mapping(address => uint32[]) public spawningFor;
| mapping(address => uint32[]) public spawningFor;
| 57,600 |
191 | // initialize the summonDelay if it's 0 | if (summonDelay[msg.sender] == 0) {
summonDelay[msg.sender] = startDelay;
}
| if (summonDelay[msg.sender] == 0) {
summonDelay[msg.sender] = startDelay;
}
| 15,139 |
30 | // log ether drop event / | emit NewDropOut(_queue[_winpos], _round - 1, _winpos + 1, _reward);
| emit NewDropOut(_queue[_winpos], _round - 1, _winpos + 1, _reward);
| 48,740 |
32 | // it should also be the same agreement class proxy address | return idx != 0 && _agreementClasses[idx - 1] == agreementClass;
| return idx != 0 && _agreementClasses[idx - 1] == agreementClass;
| 7,361 |
19 | // ============ Modifiers ============ //Throws if the sender is not the SetToken manager contract owner / | modifier onlyOwner(ISetToken _setToken) {
require(msg.sender == _manager(_setToken).owner(), "Must be owner");
_;
}
| modifier onlyOwner(ISetToken _setToken) {
require(msg.sender == _manager(_setToken).owner(), "Must be owner");
_;
}
| 66,694 |
7 | // Transfers the provided reward amount into RewardsPool and/ creates a new, one-week reward interval starting from now./ Reward tokens from the previous reward interval that unlocked/ over the time will be available for withdrawal immediately./ Reward tokens from the previous interval that has not been yet/ unlocked, are added to the new interval being created./This function can be called only by the owner given that it creates/a new interval with one week length, starting from now. | function topUpReward(uint256 reward) external onlyOwner {
rewardAccumulated = earned();
/* solhint-disable not-rely-on-time */
if (block.timestamp >= intervalFinish) {
// see https://github.com/crytic/slither/issues/844
// slither-disable-next-line divide-before-multiply
rewardRate = reward / DURATION;
} else {
uint256 remaining = intervalFinish - block.timestamp;
uint256 leftover = remaining * rewardRate;
rewardRate = (reward + leftover) / DURATION;
}
intervalFinish = block.timestamp + DURATION;
lastUpdateTime = block.timestamp;
/* solhint-enable avoid-low-level-calls */
emit RewardToppedUp(reward);
rewardToken.safeTransferFrom(msg.sender, address(this), reward);
}
| function topUpReward(uint256 reward) external onlyOwner {
rewardAccumulated = earned();
/* solhint-disable not-rely-on-time */
if (block.timestamp >= intervalFinish) {
// see https://github.com/crytic/slither/issues/844
// slither-disable-next-line divide-before-multiply
rewardRate = reward / DURATION;
} else {
uint256 remaining = intervalFinish - block.timestamp;
uint256 leftover = remaining * rewardRate;
rewardRate = (reward + leftover) / DURATION;
}
intervalFinish = block.timestamp + DURATION;
lastUpdateTime = block.timestamp;
/* solhint-enable avoid-low-level-calls */
emit RewardToppedUp(reward);
rewardToken.safeTransferFrom(msg.sender, address(this), reward);
}
| 48,905 |
126 | // break if the offer started after the payment date | if (nOfferDate > _nPaymentDate) {
break;
}
| if (nOfferDate > _nPaymentDate) {
break;
}
| 8,091 |
122 | // check that new times array is in order | if (i.add(1) < _timesToExpiry.length) {
require(_timesToExpiry[i] < _timesToExpiry[i.add(1)], "MarginCalculator: time should be in order");
}
| if (i.add(1) < _timesToExpiry.length) {
require(_timesToExpiry[i] < _timesToExpiry[i.add(1)], "MarginCalculator: time should be in order");
}
| 67,488 |
272 | // aggregated deposit | uint256 deposit0PricedInToken1 = deposit0.mul((price < twap) ? price : twap).div(PRECISION);
if (deposit0 > 0) {
IERC20(token0).safeTransferFrom(
msg.sender,
address(this),
deposit0
);
}
| uint256 deposit0PricedInToken1 = deposit0.mul((price < twap) ? price : twap).div(PRECISION);
if (deposit0 > 0) {
IERC20(token0).safeTransferFrom(
msg.sender,
address(this),
deposit0
);
}
| 38,322 |
210 | // See {ERC721-_approve}. / | function _approve(address to, uint16 tokenId) internal virtual override {
_tokenApprovals[getInternalMapping(tokenId)] = to;
emit Approval(ownerOf(tokenId), to, tokenId);
}
| function _approve(address to, uint16 tokenId) internal virtual override {
_tokenApprovals[getInternalMapping(tokenId)] = to;
emit Approval(ownerOf(tokenId), to, tokenId);
}
| 10,724 |
309 | // propose to remove a scheme for a controller_avatar the address of the controller from which we want to remove a scheme_scheme the address of the scheme we want to remove_descriptionHash proposal description hash NB: not only registers the proposal, but also votes for it/ | function proposeToRemoveScheme(Avatar _avatar, address _scheme, string memory _descriptionHash)
public
returns(bytes32)
| function proposeToRemoveScheme(Avatar _avatar, address _scheme, string memory _descriptionHash)
public
returns(bytes32)
| 11,195 |
279 | // this import function should be called if accounts that don't have debt this is safe only if the owner of the compound account is an EOA | function importCollateral(address[] calldata cTokenCollateral) external {
address account = tx.origin;
address avatar = registry.getAvatar(account);
// redeem all non ETH collateral from Compound and deposit it in B
_transferCollateral(
cTokenCollateral,
account,
avatar
);
}
| function importCollateral(address[] calldata cTokenCollateral) external {
address account = tx.origin;
address avatar = registry.getAvatar(account);
// redeem all non ETH collateral from Compound and deposit it in B
_transferCollateral(
cTokenCollateral,
account,
avatar
);
}
| 18,779 |
164 | // Transfer Bond Amount back to Block Producer | transfer(BOND_SIZE, EtherToken, EtherToken, blockProducer)
| transfer(BOND_SIZE, EtherToken, EtherToken, blockProducer)
| 21,499 |
156 | // Gets the segment corresponding to the last pool in the path/path The bytes encoded swap path/ return The segment containing all data necessary to target the last pool in the path | function getLastPool(bytes memory path) internal pure returns (bytes memory) {
if(path.length==POP_OFFSET){
return path;
}else{
return path.slice(path.length-POP_OFFSET, path.length);
}
}
| function getLastPool(bytes memory path) internal pure returns (bytes memory) {
if(path.length==POP_OFFSET){
return path;
}else{
return path.slice(path.length-POP_OFFSET, path.length);
}
}
| 81,260 |
108 | // Iterate over each owner and token ID | for (uint256 i = 0; i < _owners.length; i++) {
batchBalances[i] = _isOwner(_owners[i], _ids[i]) ? 1 : 0;
}
| for (uint256 i = 0; i < _owners.length; i++) {
batchBalances[i] = _isOwner(_owners[i], _ids[i]) ? 1 : 0;
}
| 20,446 |
73 | // Total allocation points. Must be the sum of all allocation points in all pools. | uint256 public totalAllocPoint;
uint256 public suwpPerSecond;
uint256 private constant ACC_SUWP_PRECISION = 1e12;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Harvest(address indexed user, uint256 indexed pid, uint256 amount);
event LogPoolAddition(uint256 indexed pid, uint256 allocPoint, IERC20 indexed lpToken, IRewarder indexed rewarder);
| uint256 public totalAllocPoint;
uint256 public suwpPerSecond;
uint256 private constant ACC_SUWP_PRECISION = 1e12;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Harvest(address indexed user, uint256 indexed pid, uint256 amount);
event LogPoolAddition(uint256 indexed pid, uint256 allocPoint, IERC20 indexed lpToken, IRewarder indexed rewarder);
| 5,801 |
28 | // withdraw foreign tokens / | function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) {
ERC20Basic token = ERC20Basic(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
| function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) {
ERC20Basic token = ERC20Basic(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
| 34,119 |
7 | // Performs a delegetecall on a targetContract in the context of self.Internally reverts execution to avoid side effects (making it static). Catches revert and returns encoded result as bytes. targetContract Address of the contract containing the code to execute. calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments). / | function simulateDelegatecall(
address targetContract,
bytes memory calldataPayload
| function simulateDelegatecall(
address targetContract,
bytes memory calldataPayload
| 16,985 |
11 | // This contract is for creating proxy to access ERC721Rarible token. The beacon should be initialized before call ERC721RaribleFactoryC2 constructor./ | contract ERC721RaribleFactoryC2 is Ownable {
address public beacon;
address transferProxy;
address lazyTransferProxy;
event Create721RaribleProxy(address proxy);
event Create721RaribleUserProxy(address proxy);
constructor(address _beacon, address _transferProxy, address _lazyTransferProxy) {
beacon = _beacon;
transferProxy = _transferProxy;
lazyTransferProxy = _lazyTransferProxy;
}
function createToken(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI, uint salt) external {
address beaconProxy = deployProxy(getData(_name, _symbol, baseURI, contractURI), salt);
ERC721RaribleMinimal token = ERC721RaribleMinimal(address(beaconProxy));
token.transferOwnership(_msgSender());
emit Create721RaribleProxy(beaconProxy);
}
function createToken(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI, address[] memory operators, uint salt) external {
address beaconProxy = deployProxy(getData(_name, _symbol, baseURI, contractURI, operators), salt);
ERC721RaribleMinimal token = ERC721RaribleMinimal(address(beaconProxy));
token.transferOwnership(_msgSender());
emit Create721RaribleUserProxy(beaconProxy);
}
//deploying BeaconProxy contract with create2
function deployProxy(bytes memory data, uint salt) internal returns(address proxy){
bytes memory bytecode = getCreationBytecode(data);
assembly {
proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)
if iszero(extcodesize(proxy)) {
revert(0, 0)
}
}
}
//adding constructor arguments to BeaconProxy bytecode
function getCreationBytecode(bytes memory _data) internal view returns (bytes memory) {
return abi.encodePacked(type(BeaconProxy).creationCode, abi.encode(beacon, _data));
}
//returns address that contract with such arguments will be deployed on
function getAddress(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI, uint _salt)
public
view
returns (address)
{
bytes memory bytecode = getCreationBytecode(getData(_name, _symbol, baseURI, contractURI));
bytes32 hash = keccak256(
abi.encodePacked(bytes1(0xff), address(this), _salt, keccak256(bytecode))
);
return address(uint160(uint(hash)));
}
function getData(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI) view internal returns(bytes memory){
return abi.encodeWithSelector(ERC721RaribleMinimal(0).__ERC721Rarible_init.selector, _name, _symbol, baseURI, contractURI, transferProxy, lazyTransferProxy);
}
//returns address that private contract with such arguments will be deployed on
function getAddress(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI, address[] memory operators, uint _salt)
public
view
returns (address)
{
bytes memory bytecode = getCreationBytecode(getData(_name, _symbol, baseURI, contractURI, operators));
bytes32 hash = keccak256(
abi.encodePacked(bytes1(0xff), address(this), _salt, keccak256(bytecode))
);
return address(uint160(uint(hash)));
}
function getData(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI, address[] memory operators) view internal returns(bytes memory){
return abi.encodeWithSelector(ERC721RaribleMinimal(0).__ERC721RaribleUser_init.selector, _name, _symbol, baseURI, contractURI, operators, transferProxy, lazyTransferProxy);
}
}
| contract ERC721RaribleFactoryC2 is Ownable {
address public beacon;
address transferProxy;
address lazyTransferProxy;
event Create721RaribleProxy(address proxy);
event Create721RaribleUserProxy(address proxy);
constructor(address _beacon, address _transferProxy, address _lazyTransferProxy) {
beacon = _beacon;
transferProxy = _transferProxy;
lazyTransferProxy = _lazyTransferProxy;
}
function createToken(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI, uint salt) external {
address beaconProxy = deployProxy(getData(_name, _symbol, baseURI, contractURI), salt);
ERC721RaribleMinimal token = ERC721RaribleMinimal(address(beaconProxy));
token.transferOwnership(_msgSender());
emit Create721RaribleProxy(beaconProxy);
}
function createToken(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI, address[] memory operators, uint salt) external {
address beaconProxy = deployProxy(getData(_name, _symbol, baseURI, contractURI, operators), salt);
ERC721RaribleMinimal token = ERC721RaribleMinimal(address(beaconProxy));
token.transferOwnership(_msgSender());
emit Create721RaribleUserProxy(beaconProxy);
}
//deploying BeaconProxy contract with create2
function deployProxy(bytes memory data, uint salt) internal returns(address proxy){
bytes memory bytecode = getCreationBytecode(data);
assembly {
proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)
if iszero(extcodesize(proxy)) {
revert(0, 0)
}
}
}
//adding constructor arguments to BeaconProxy bytecode
function getCreationBytecode(bytes memory _data) internal view returns (bytes memory) {
return abi.encodePacked(type(BeaconProxy).creationCode, abi.encode(beacon, _data));
}
//returns address that contract with such arguments will be deployed on
function getAddress(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI, uint _salt)
public
view
returns (address)
{
bytes memory bytecode = getCreationBytecode(getData(_name, _symbol, baseURI, contractURI));
bytes32 hash = keccak256(
abi.encodePacked(bytes1(0xff), address(this), _salt, keccak256(bytecode))
);
return address(uint160(uint(hash)));
}
function getData(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI) view internal returns(bytes memory){
return abi.encodeWithSelector(ERC721RaribleMinimal(0).__ERC721Rarible_init.selector, _name, _symbol, baseURI, contractURI, transferProxy, lazyTransferProxy);
}
//returns address that private contract with such arguments will be deployed on
function getAddress(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI, address[] memory operators, uint _salt)
public
view
returns (address)
{
bytes memory bytecode = getCreationBytecode(getData(_name, _symbol, baseURI, contractURI, operators));
bytes32 hash = keccak256(
abi.encodePacked(bytes1(0xff), address(this), _salt, keccak256(bytecode))
);
return address(uint160(uint(hash)));
}
function getData(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI, address[] memory operators) view internal returns(bytes memory){
return abi.encodeWithSelector(ERC721RaribleMinimal(0).__ERC721RaribleUser_init.selector, _name, _symbol, baseURI, contractURI, operators, transferProxy, lazyTransferProxy);
}
}
| 38,033 |
108 | // Return the amount of ETH to be drawn from a trove's collateral and sent as gas compensation. | function _getCollGasCompensation(uint _entireColl) internal pure returns (uint) {
return _entireColl / PERCENT_DIVISOR;
}
| function _getCollGasCompensation(uint _entireColl) internal pure returns (uint) {
return _entireColl / PERCENT_DIVISOR;
}
| 31,818 |
346 | // make sure enough eth has been sent | require (msg.value >= gen0PromoPrice * numberToMint);
| require (msg.value >= gen0PromoPrice * numberToMint);
| 3,637 |
11 | // Iterate over the offer items. prettier-ignore | for { let i := 0 } lt(i, offerLength) {
| for { let i := 0 } lt(i, offerLength) {
| 22,485 |
49 | // maker dst quantity is the requested quantity he wants to receive. user src quantity is what user gives. so user src quantity is matched with maker dst quantity | if (orderData.dstAmount <= userRemainingSrcQty) {
totalUserDstAmount += orderData.srcAmount;
userRemainingSrcQty -= orderData.dstAmount;
} else {
| if (orderData.dstAmount <= userRemainingSrcQty) {
totalUserDstAmount += orderData.srcAmount;
userRemainingSrcQty -= orderData.dstAmount;
} else {
| 16,753 |
178 | // The ICECREAM TOKEN! | IcecreamToken public icecream;
| IcecreamToken public icecream;
| 41,836 |
24 | // The basis point number of votes required in order for a voter to become a proposer. DIFFERS from GovernerBravo | uint256 public proposalThresholdBPS;
| uint256 public proposalThresholdBPS;
| 38,071 |
21 | // require user to set to zero before resetting to nonzero | require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
| require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
| 11,126 |
16 | // Users can withdraw their available balance/Avoids reentrancy | function withdraw() external {
uint amount = addressToPendingWithdrawal[msg.sender];
addressToPendingWithdrawal[msg.sender] = 0;
payable(msg.sender).transfer(amount);
}
| function withdraw() external {
uint amount = addressToPendingWithdrawal[msg.sender];
addressToPendingWithdrawal[msg.sender] = 0;
payable(msg.sender).transfer(amount);
}
| 54,316 |
101 | // return the expected MET for ETH/_depositAmount ETH./ return expected MET value for ETH | function getMetForEthResult(uint _depositAmount) public view returns (uint256) {
return convertingReturn(WhichToken.Eth, _depositAmount);
}
| function getMetForEthResult(uint _depositAmount) public view returns (uint256) {
return convertingReturn(WhichToken.Eth, _depositAmount);
}
| 36,877 |
18 | // Deposit ethers to EtherDelta./amount Amount of ethers to deposit in EtherDelta | function deposit(uint amount) internal {
EtherDelta(ETHERDELTA_ADDR).deposit.value(amount)();
}
| function deposit(uint amount) internal {
EtherDelta(ETHERDELTA_ADDR).deposit.value(amount)();
}
| 49,107 |
2 | // --------------------------------------------------------------------------EInterface | function allow_spend(address _coin) private returns(uint){
EInterface pixiu = EInterface(_coin);
uint allow = pixiu.allowance(msg.sender, this);
return allow;
}
| function allow_spend(address _coin) private returns(uint){
EInterface pixiu = EInterface(_coin);
uint allow = pixiu.allowance(msg.sender, this);
return allow;
}
| 25,308 |
52 | // modifier Checks minimal amount, what was sent to function call. _minimalAmount - minimal amount neccessary tocontinue function call / | modifier minimalPrice(uint256 _minimalAmount) {
require(msg.value >= _minimalAmount, "Not enough Ether provided.");
_;
}
| modifier minimalPrice(uint256 _minimalAmount) {
require(msg.value >= _minimalAmount, "Not enough Ether provided.");
_;
}
| 39,470 |
30 | // Approve the passed address to spend the specified amount of currency units on behalf of msg.sender.Beware that changing an allowance with this method brings the risk that someone may use both the oldand the new allowance by unfortunate transaction ordering. One possible solution to mitigate thisrace condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: spender The address which will spend the funds. value The amount of currency units to be spent. / | function approve(address spender, uint256 value) public returns (bool) {
assert(spender != address(0));
if(details[spender].banned_spender){
if(details[msg.sender].allowed[spender] > 0){
details[msg.sender].allowed[spender] = 0;
}
return false;
}
details[msg.sender].allowed[spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
| function approve(address spender, uint256 value) public returns (bool) {
assert(spender != address(0));
if(details[spender].banned_spender){
if(details[msg.sender].allowed[spender] > 0){
details[msg.sender].allowed[spender] = 0;
}
return false;
}
details[msg.sender].allowed[spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
| 10,387 |
174 | // v2 | ExtraRewardStashV2 stash = new ExtraRewardStashV2(_pid,operator,_staker,_gauge,rewardFactory);
return address(stash);
| ExtraRewardStashV2 stash = new ExtraRewardStashV2(_pid,operator,_staker,_gauge,rewardFactory);
return address(stash);
| 18,582 |
16 | // only pull the minimum between allowance left and the amount that should be pulled for the period | uint256 allowanceLeft = allowance.sub(rewardNotTransferred);
if (amountToPull > allowanceLeft) {
amountToPull = allowanceLeft;
}
| uint256 allowanceLeft = allowance.sub(rewardNotTransferred);
if (amountToPull > allowanceLeft) {
amountToPull = allowanceLeft;
}
| 37,575 |
21 | // round 19 | t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 1197934381747032348421303489683932612752526046745577259575778515005162320212)
t0 := sbox_partial(t0, q)
t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
| t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 1197934381747032348421303489683932612752526046745577259575778515005162320212)
t0 := sbox_partial(t0, q)
t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
| 24,335 |
69 | // Emit state changes | emit Stake(msg.sender, tokenAddress, tempBenefit, block.timestamp);
| emit Stake(msg.sender, tokenAddress, tempBenefit, block.timestamp);
| 825 |
125 | // call mintRewards | uint titheBTRFLY = payout.mul(terms.tithe).div(100000);
uint fee = payout.mul( terms.fee ).div( 100000 );
uint totalMint = titheBTRFLY.add(fee).add(payout);
ITreasury(treasury).mintRewards(address(this),totalMint);
| uint titheBTRFLY = payout.mul(terms.tithe).div(100000);
uint fee = payout.mul( terms.fee ).div( 100000 );
uint totalMint = titheBTRFLY.add(fee).add(payout);
ITreasury(treasury).mintRewards(address(this),totalMint);
| 27,553 |
28 | // Set new deployer | address oldDeployer = deployer;
deployer = newDeployer;
| address oldDeployer = deployer;
deployer = newDeployer;
| 24,798 |
30 | // this internal view function gets the contract type for the contract which does a SSTORE lookup to the mapping addressToType[x] on uninitialized mapping location, it throws an error.Possible Contract Types: 1 = ERC721, 2 = ERC1155, 3 = OpenSea Storefront / | function _getContractType(address contract_) internal view returns (uint256) {
// We compare calldata to contract data and return, this process is cheap, so
// it is the first condition to check and return.
if (contract_ == OS_STORE) return 3;
// Otherwise, we do a SLOAD. The loaded data must be {1} or {2} as they are
// the only supported types in a mapping SLOAD
uint256 _contractType = addressToType[contract_];
require(_contractType == 1 || _contractType == 2, "Unsupported Type!");
return _contractType;
}
| function _getContractType(address contract_) internal view returns (uint256) {
// We compare calldata to contract data and return, this process is cheap, so
// it is the first condition to check and return.
if (contract_ == OS_STORE) return 3;
// Otherwise, we do a SLOAD. The loaded data must be {1} or {2} as they are
// the only supported types in a mapping SLOAD
uint256 _contractType = addressToType[contract_];
require(_contractType == 1 || _contractType == 2, "Unsupported Type!");
return _contractType;
}
| 29,004 |
42 | // Action with list parameter | function newListProposal(address asset, uint256 claimRate, uint256 allocation) public returns(uint) {
string memory typeStr = "LIST";
proposalCount += 1;
mapPID_type[proposalCount] = typeStr;
ListDetails memory list;
list.asset = asset;
list.claimRate = claimRate;
list.allocation = allocation;
mapPID_list[proposalCount] = list;
emit NewProposal(msg.sender, proposalCount, typeStr);
return proposalCount;
}
| function newListProposal(address asset, uint256 claimRate, uint256 allocation) public returns(uint) {
string memory typeStr = "LIST";
proposalCount += 1;
mapPID_type[proposalCount] = typeStr;
ListDetails memory list;
list.asset = asset;
list.claimRate = claimRate;
list.allocation = allocation;
mapPID_list[proposalCount] = list;
emit NewProposal(msg.sender, proposalCount, typeStr);
return proposalCount;
}
| 25,075 |
85 | // First, try assuming that the derivative is an LP token | address pool = curveRegistryContract.get_pool_from_lp_token(_derivatives[i]);
| address pool = curveRegistryContract.get_pool_from_lp_token(_derivatives[i]);
| 42,629 |
1,050 | // At this point we know that the sender is a trusted forwarder, we copy the msg.data , except the last 20 bytes (and update the total length) | assembly {
let ptr := mload(0x40)
| assembly {
let ptr := mload(0x40)
| 73,002 |
53 | // SETTERS //set new asset price/_tokenIdasset UniqueId/_priceasset price | function setPrice(uint256 _tokenId, uint256 _price) public onlyGrantedContracts {
assetIndexToPrice[_tokenId] = _price;
}
| function setPrice(uint256 _tokenId, uint256 _price) public onlyGrantedContracts {
assetIndexToPrice[_tokenId] = _price;
}
| 29,967 |
62 | // Pausable TokenAllows you to pause/unpause transfers of your token. / | contract PausableToken is StandardToken, HasOwner {
/// Indicates whether the token contract is paused or not.
bool public paused = false;
/**
* @dev Event fired when the token contracts gets paused.
*/
event Pause();
/**
* @dev Event fired when the token contracts gets unpaused.
*/
event Unpause();
/**
* @dev Allows a function to be called only when the token contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Pauses the token contract.
*/
function pause() public onlyOwner whenNotPaused {
paused = true;
emit Pause();
}
/**
* @dev Unpauses the token contract.
*/
function unpause() public onlyOwner {
require(paused);
paused = false;
emit Unpause();
}
/// Overrides of the standard token's functions to add the paused/unpaused functionality.
function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) {
return super.transfer(_to, _value);
}
function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) {
return super.approve(_spender, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) {
return super.transferFrom(_from, _to, _value);
}
}
| contract PausableToken is StandardToken, HasOwner {
/// Indicates whether the token contract is paused or not.
bool public paused = false;
/**
* @dev Event fired when the token contracts gets paused.
*/
event Pause();
/**
* @dev Event fired when the token contracts gets unpaused.
*/
event Unpause();
/**
* @dev Allows a function to be called only when the token contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Pauses the token contract.
*/
function pause() public onlyOwner whenNotPaused {
paused = true;
emit Pause();
}
/**
* @dev Unpauses the token contract.
*/
function unpause() public onlyOwner {
require(paused);
paused = false;
emit Unpause();
}
/// Overrides of the standard token's functions to add the paused/unpaused functionality.
function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) {
return super.transfer(_to, _value);
}
function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) {
return super.approve(_spender, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) {
return super.transferFrom(_from, _to, _value);
}
}
| 15,807 |
11 | // ========== SETTERS ========== / | function setMinimumStakeTime(uint _seconds) external onlyOwner {
// Set the min stake time on locking synthetix
require(_seconds <= MAX_MINIMUM_STAKING_TIME, "stake time exceed maximum 1 week");
minimumStakeTime = _seconds;
emit MinimumStakeTimeUpdated(minimumStakeTime);
}
| function setMinimumStakeTime(uint _seconds) external onlyOwner {
// Set the min stake time on locking synthetix
require(_seconds <= MAX_MINIMUM_STAKING_TIME, "stake time exceed maximum 1 week");
minimumStakeTime = _seconds;
emit MinimumStakeTimeUpdated(minimumStakeTime);
}
| 10,523 |
46 | // Returns the address of a specific index value | function getRecordHolder(uint256 index) constant returns (address) {
return address(recordTokenHolders[index.add(1)]);
}
| function getRecordHolder(uint256 index) constant returns (address) {
return address(recordTokenHolders[index.add(1)]);
}
| 28,863 |
10 | // The bit position of `extraData` in packed ownership. | uint256 internal constant _BITPOS_EXTRA_DATA = 232;
| uint256 internal constant _BITPOS_EXTRA_DATA = 232;
| 10,826 |
0 | // IMPORTS |
using ECDSA for bytes32;
|
using ECDSA for bytes32;
| 25,381 |
0 | // 생성자_councilAddress 위원회 주소/ | constructor(address _councilAddress) public validAddress(_councilAddress) {
council = CouncilInterface(_councilAddress);
}
| constructor(address _councilAddress) public validAddress(_councilAddress) {
council = CouncilInterface(_councilAddress);
}
| 28,340 |
3 | // triggers on gamification event | event CustomPlant(uint256 nftID, uint256 value, uint256 actionID, string payload);
| event CustomPlant(uint256 nftID, uint256 value, uint256 actionID, string payload);
| 16,166 |
52 | // Sets asset spending allowance for a specified spender.Resolves asset implementation contract for the caller and forwards there arguments along withthe caller address._spender holder address to set allowance to. _value amount to allow. return success. / | function approve(address _spender, uint _value) public returns(bool) {
return _getAsset()._performApprove(_spender, _value, msg.sender);
}
| function approve(address _spender, uint _value) public returns(bool) {
return _getAsset()._performApprove(_spender, _value, msg.sender);
}
| 8,641 |
11 | // Convert signed 128.128 bit fixed point number into quadruple precisionnumber.x signed 128.128 bit fixed point numberreturn quadruple precision number / | function from128x128 (int256 x) internal pure returns (bytes16) {
if (x == 0) return bytes16 (0);
else {
// We rely on overflow behavior here
uint256 result = uint256 (x > 0 ? x : -x);
uint256 msb = msb (result);
if (msb < 112) result <<= 112 - msb;
else if (msb > 112) result >>= msb - 112;
result = result & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF | 16255 + msb << 112;
if (x < 0) result |= 0x80000000000000000000000000000000;
return bytes16 (uint128 (result));
}
}
| function from128x128 (int256 x) internal pure returns (bytes16) {
if (x == 0) return bytes16 (0);
else {
// We rely on overflow behavior here
uint256 result = uint256 (x > 0 ? x : -x);
uint256 msb = msb (result);
if (msb < 112) result <<= 112 - msb;
else if (msb > 112) result >>= msb - 112;
result = result & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF | 16255 + msb << 112;
if (x < 0) result |= 0x80000000000000000000000000000000;
return bytes16 (uint128 (result));
}
}
| 25,690 |
25 | // Sets rate if it was not set earlier_rate preICO wei to tokens rate/ | function setRate(uint _rate) public onlyOwner {
rate = _rate;
RateChanged(_rate);
}
| function setRate(uint _rate) public onlyOwner {
rate = _rate;
RateChanged(_rate);
}
| 20,227 |
14 | // upper 128 bits of 2256 / sqrt(1.0001) where the 128th bit is 1 | 0xfffcb933bd6fad37aa2d162d1a59400100000000000000000000000000000000
),
0x1ffffffffffffffffffffffffffffffff // mask lower 129 bits
)
| 0xfffcb933bd6fad37aa2d162d1a59400100000000000000000000000000000000
),
0x1ffffffffffffffffffffffffffffffff // mask lower 129 bits
)
| 23,666 |
22 | // Users need to schedule an unstake and wait for/ `unstakeWaitPeriod` before being able to unstake. This is to prevent/ the stakers from frontrunning insurance claims by unstaking to evade/ them, or repeatedly unstake/stake to work around the proposal spam/ protection./This parameter is governable by the DAO, and the DAO is expected/ to set this to a value that is large enough to allow insurance claims/ to be resolved. | uint256 public unstakeWaitPeriod = EPOCH_LENGTH;
| uint256 public unstakeWaitPeriod = EPOCH_LENGTH;
| 16,281 |
62 | // Do all transactions | delegate.batchTransferToken(
_lrcTokenAddress,
tx.origin,
feeRecipient,
walletSplitPercentage,
batch
);
| delegate.batchTransferToken(
_lrcTokenAddress,
tx.origin,
feeRecipient,
walletSplitPercentage,
batch
);
| 42,305 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.