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 |
|---|---|---|---|---|
11 | // starts from the passed epoch to find the first activated epoch/_latestEpoch an active user will have all bits flipped to one for the whole bitmask/this parameter indicates where to start looking back from/if the user has never been activated, this will return epoch zero/do not start from an epoch in the future - activated users will be 'lastActivated' until epoch 255/we do not require the bitfield to be persistent in storage to check it here | function lastActive(Bitfield calldata self, uint8 _latestEpoch) public pure returns (uint8) {
// check if the starting epoch is active
while (_latestEpoch > 0) {
if (isActive(self, _latestEpoch)) {
return _latestEpoch;
// if not, decrement and continue our loop
} else {
_latestEpoch -= 1;
}
}
return 0;
}
| function lastActive(Bitfield calldata self, uint8 _latestEpoch) public pure returns (uint8) {
// check if the starting epoch is active
while (_latestEpoch > 0) {
if (isActive(self, _latestEpoch)) {
return _latestEpoch;
// if not, decrement and continue our loop
} else {
_latestEpoch -= 1;
}
}
return 0;
}
| 28,036 |
219 | // Creates a new mToken using the already-existing tokens.dmmTokens The tokens that should be added to this controller. underlyingTokensThe tokens that should be wrapped to create a new DMMA. / | function addMarketFromExistingDmmTokens(
| function addMarketFromExistingDmmTokens(
| 2,467 |
128 | // This event is fired whenever a user clicks on a button, thereby creating a clickand resetting our block timer / | event ButtonClick(address indexed owner, uint256 tokenId);
| event ButtonClick(address indexed owner, uint256 tokenId);
| 15,701 |
93 | // Write the last 32 bytes | mstore(dEnd, last)
| mstore(dEnd, last)
| 15,036 |
2 | // mapping of user info indexed by the user ID | mapping (uint => UserInfo) userInfo;
| mapping (uint => UserInfo) userInfo;
| 49,150 |
255 | // Ensure invoke bController.isBController() returns true | require(newBController.isBController(), "marker method returned false");
| require(newBController.isBController(), "marker method returned false");
| 18,892 |
16 | // additive tax, that in intervat 0-35% | return (((amount - vMin) * 35 * amount) / (vMax - vMin)) / 100;
| return (((amount - vMin) * 35 * amount) / (vMax - vMin)) / 100;
| 7,552 |
166 | // ------------------------------------------------------------------------ Get the MTF balance of the token holderuser the address of the token holder ------------------------------------------------------------------------ | function yourMTFBalance(address user) external view returns(uint256 mtfBalance){
return IERC20(mtFinance).balanceOf(user);
}
| function yourMTFBalance(address user) external view returns(uint256 mtfBalance){
return IERC20(mtFinance).balanceOf(user);
}
| 12,752 |
653 | // Reads the uint128 at `rdPtr` in returndata. | function readUint128(
ReturndataPointer rdPtr
| function readUint128(
ReturndataPointer rdPtr
| 23,663 |
26 | // If route > 3, offeredItemType is ERC20 (1). Route is 2 or 3, offeredItemType = route. Route is 0 or 1, it is route + 2. | offeredItemType := byte(route, BasicOrder_offeredItemByteMap)
| offeredItemType := byte(route, BasicOrder_offeredItemByteMap)
| 21,129 |
17 | // Caches a pool key | function cachePoolKey(address pool, PoolAddress.PoolKey memory poolKey) private returns (uint80 poolId) {
poolId = _poolIds[pool];
if (poolId == 0) {
_poolIds[pool] = (poolId = _nextPoolId++);
_poolIdToPoolKey[poolId] = poolKey;
}
}
| function cachePoolKey(address pool, PoolAddress.PoolKey memory poolKey) private returns (uint80 poolId) {
poolId = _poolIds[pool];
if (poolId == 0) {
_poolIds[pool] = (poolId = _nextPoolId++);
_poolIdToPoolKey[poolId] = poolKey;
}
}
| 34,329 |
7 | // returns the address of the LendingPoolDataProvider proxy return the lending pool data provider proxy address / | function getLendingPoolDataProvider() public view returns (address) {
return getAddress(DATA_PROVIDER);
}
| function getLendingPoolDataProvider() public view returns (address) {
return getAddress(DATA_PROVIDER);
}
| 3,209 |
430 | // RootChainable / | contract RootChainable is Ownable {
address public rootChain;
// Rootchain changed
event RootChainChanged(
address indexed previousRootChain,
address indexed newRootChain
);
// only root chain
modifier onlyRootChain() {
require(msg.sender == rootChain);
_;
}
/**
* @dev Allows the current owner to change root chain address.
* @param newRootChain The address to new rootchain.
*/
function changeRootChain(address newRootChain) public onlyOwner {
require(newRootChain != address(0));
emit RootChainChanged(rootChain, newRootChain);
rootChain = newRootChain;
}
}
| contract RootChainable is Ownable {
address public rootChain;
// Rootchain changed
event RootChainChanged(
address indexed previousRootChain,
address indexed newRootChain
);
// only root chain
modifier onlyRootChain() {
require(msg.sender == rootChain);
_;
}
/**
* @dev Allows the current owner to change root chain address.
* @param newRootChain The address to new rootchain.
*/
function changeRootChain(address newRootChain) public onlyOwner {
require(newRootChain != address(0));
emit RootChainChanged(rootChain, newRootChain);
rootChain = newRootChain;
}
}
| 46,748 |
193 | // The position has been closed by either repayment, liquidation, or redemption./position The address of the user whose position is closed. | event PositionClosed(address indexed position);
| event PositionClosed(address indexed position);
| 20,049 |
39 | // Return how much tokens will be minted as per algorithm. Each year 10% tokens will be reduced | function tokensToMint()private returns(uint256 _tokensToMint){
uint8 tiersToBeMinted = currentTier() - getTierForLastMiniting();
require(tiersToBeMinted>0);
for(uint8 i = 0;i<tiersToBeMinted;i++){
_tokensToMint = _tokensToMint.add(lastMintedTokens.sub(lastMintedTokens.mul(10).div(100)));
lastMintedTokens = lastMintedTokens.sub(lastMintedTokens.mul(10).div(100));
}
return _tokensToMint;
}
| function tokensToMint()private returns(uint256 _tokensToMint){
uint8 tiersToBeMinted = currentTier() - getTierForLastMiniting();
require(tiersToBeMinted>0);
for(uint8 i = 0;i<tiersToBeMinted;i++){
_tokensToMint = _tokensToMint.add(lastMintedTokens.sub(lastMintedTokens.mul(10).div(100)));
lastMintedTokens = lastMintedTokens.sub(lastMintedTokens.mul(10).div(100));
}
return _tokensToMint;
}
| 30,972 |
38 | // ========== INTERNAL VIEW ========== / | ) public view returns (uint256) {
bytes32 key = keccak256(
abi.encodePacked(uint256(rewardType), uint256(feeType))
);
return rewardsPercentage[key];
}
| ) public view returns (uint256) {
bytes32 key = keccak256(
abi.encodePacked(uint256(rewardType), uint256(feeType))
);
return rewardsPercentage[key];
}
| 5,580 |
6 | // exclude from paying fees or having max transaction amount | excludeFromFees(owner(), true);
excludeFromFees(_marketingWallet, true);
excludeFromFees(_devWallet, true);
excludeFromFees(address(this), true);
| excludeFromFees(owner(), true);
excludeFromFees(_marketingWallet, true);
excludeFromFees(_devWallet, true);
excludeFromFees(address(this), true);
| 5,053 |
203 | // AOUintSetting This contract stores all AO uint256 setting variables / | contract AOUintSetting is TheAO {
// Mapping from settingId to it's actual uint256 value
mapping (uint256 => uint256) public settingValue;
// Mapping from settingId to it's potential uint256 value that is at pending state
mapping (uint256 => uint256) public pendingValue;
/**
* @dev Constructor function
*/
constructor() public {}
/**
* @dev Checks if the calling contract address is The AO
* OR
* If The AO is set to a Name/TAO, then check if calling address is the Advocate
*/
modifier onlyTheAO {
require (AOLibrary.isTheAO(msg.sender, theAO, nameTAOPositionAddress));
_;
}
/***** The AO ONLY METHODS *****/
/**
* @dev The AO set the NameTAOPosition Address
* @param _nameTAOPositionAddress The address of NameTAOPosition
*/
function setNameTAOPositionAddress(address _nameTAOPositionAddress) public onlyTheAO {
require (_nameTAOPositionAddress != address(0));
nameTAOPositionAddress = _nameTAOPositionAddress;
}
/**
* @dev Transfer ownership of The AO to new address
* @param _theAO The new address to be transferred
*/
function transferOwnership(address _theAO) public onlyTheAO {
require (_theAO != address(0));
theAO = _theAO;
}
/**
* @dev Whitelist `_account` address to transact on behalf of others
* @param _account The address to whitelist
* @param _whitelist Either to whitelist or not
*/
function setWhitelist(address _account, bool _whitelist) public onlyTheAO {
require (_account != address(0));
whitelist[_account] = _whitelist;
}
/***** PUBLIC METHODS *****/
/**
* @dev Set pending value
* @param _settingId The ID of the setting
* @param _value The uint256 value to be set
*/
function setPendingValue(uint256 _settingId, uint256 _value) public inWhitelist {
pendingValue[_settingId] = _value;
}
/**
* @dev Move value from pending to setting
* @param _settingId The ID of the setting
*/
function movePendingToSetting(uint256 _settingId) public inWhitelist {
uint256 _tempValue = pendingValue[_settingId];
delete pendingValue[_settingId];
settingValue[_settingId] = _tempValue;
}
}
| contract AOUintSetting is TheAO {
// Mapping from settingId to it's actual uint256 value
mapping (uint256 => uint256) public settingValue;
// Mapping from settingId to it's potential uint256 value that is at pending state
mapping (uint256 => uint256) public pendingValue;
/**
* @dev Constructor function
*/
constructor() public {}
/**
* @dev Checks if the calling contract address is The AO
* OR
* If The AO is set to a Name/TAO, then check if calling address is the Advocate
*/
modifier onlyTheAO {
require (AOLibrary.isTheAO(msg.sender, theAO, nameTAOPositionAddress));
_;
}
/***** The AO ONLY METHODS *****/
/**
* @dev The AO set the NameTAOPosition Address
* @param _nameTAOPositionAddress The address of NameTAOPosition
*/
function setNameTAOPositionAddress(address _nameTAOPositionAddress) public onlyTheAO {
require (_nameTAOPositionAddress != address(0));
nameTAOPositionAddress = _nameTAOPositionAddress;
}
/**
* @dev Transfer ownership of The AO to new address
* @param _theAO The new address to be transferred
*/
function transferOwnership(address _theAO) public onlyTheAO {
require (_theAO != address(0));
theAO = _theAO;
}
/**
* @dev Whitelist `_account` address to transact on behalf of others
* @param _account The address to whitelist
* @param _whitelist Either to whitelist or not
*/
function setWhitelist(address _account, bool _whitelist) public onlyTheAO {
require (_account != address(0));
whitelist[_account] = _whitelist;
}
/***** PUBLIC METHODS *****/
/**
* @dev Set pending value
* @param _settingId The ID of the setting
* @param _value The uint256 value to be set
*/
function setPendingValue(uint256 _settingId, uint256 _value) public inWhitelist {
pendingValue[_settingId] = _value;
}
/**
* @dev Move value from pending to setting
* @param _settingId The ID of the setting
*/
function movePendingToSetting(uint256 _settingId) public inWhitelist {
uint256 _tempValue = pendingValue[_settingId];
delete pendingValue[_settingId];
settingValue[_settingId] = _tempValue;
}
}
| 32,439 |
5 | // Factor for converting eth <-> tokens with required precision of calculations | uint constant private precision_factor = 1e18;
| uint constant private precision_factor = 1e18;
| 40,005 |
43 | // Approves other address to transfer awnership of Artwork | function approve(address _to, uin256 _NFTmaniacId) public override {
require(
msg.sender == NFTmaniacToOwner[_NFTmaniacId],
"Must be the Artwork owner."
);
NFTmaniacApprovals[_NFTmaniacId] = _to;
emit Approval(msg.sender, _to, _NFTmaniacId);
}
| function approve(address _to, uin256 _NFTmaniacId) public override {
require(
msg.sender == NFTmaniacToOwner[_NFTmaniacId],
"Must be the Artwork owner."
);
NFTmaniacApprovals[_NFTmaniacId] = _to;
emit Approval(msg.sender, _to, _NFTmaniacId);
}
| 2,597 |
138 | // return current block number | return block.number;
| return block.number;
| 50,757 |
27 | // super._beforeTokenTransfer(from, to, tokenId); |
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
|
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
| 7,633 |
96 | // settle preimum dividends | uint poolerTotalSupply = poolerTokenContract.totalSupply();
uint totalPremiums = option.totalPremiums();
uint round = option.getRound();
| uint poolerTotalSupply = poolerTokenContract.totalSupply();
uint totalPremiums = option.totalPremiums();
uint round = option.getRound();
| 41,803 |
36 | // Emergency withdraw enabled by GLQ team in an emergency case/ | function emergencyWithdraw() public {
require(
_emergencyWithdraw == true,
"The emergency withdraw feature is not enabled"
);
uint256 index = _indexStaker[msg.sender];
require (index > 0, "Invalid staking index");
GlqStaker storage staker = _stakers[index - 1];
IERC20 glqToken = IERC20(_glqTokenAddress);
require(
staker.amount > 0,
"Not funds deposited in the staking contract");
require(
glqToken.transfer(msg.sender, staker.amount) == true,
"Error transfer on the contract"
);
staker.amount = 0;
}
| function emergencyWithdraw() public {
require(
_emergencyWithdraw == true,
"The emergency withdraw feature is not enabled"
);
uint256 index = _indexStaker[msg.sender];
require (index > 0, "Invalid staking index");
GlqStaker storage staker = _stakers[index - 1];
IERC20 glqToken = IERC20(_glqTokenAddress);
require(
staker.amount > 0,
"Not funds deposited in the staking contract");
require(
glqToken.transfer(msg.sender, staker.amount) == true,
"Error transfer on the contract"
);
staker.amount = 0;
}
| 11,128 |
21 | // Subtract current LP value | uint previousValue = userInfo.lockedSsLpValue;
totalSupply -= userInfo.lockedSsLpValue;
_votes[userInfo.delegate] -= userInfo.lockedSsLpValue;
| uint previousValue = userInfo.lockedSsLpValue;
totalSupply -= userInfo.lockedSsLpValue;
_votes[userInfo.delegate] -= userInfo.lockedSsLpValue;
| 36,335 |
17 | // Add the token to the stakedTokens array | stakers[msg.sender].stakedTokens.push(stakedToken);
| stakers[msg.sender].stakedTokens.push(stakedToken);
| 15,254 |
2 | // ============ Initializer ============ |
function __MD1Configuration_init(
address rewardsOracle,
string calldata ipnsName,
uint256 ipfsUpdatePeriod,
uint256 marketMakerRewardsAmount,
uint256 traderRewardsAmount,
uint256 traderScoreAlpha
)
internal
|
function __MD1Configuration_init(
address rewardsOracle,
string calldata ipnsName,
uint256 ipfsUpdatePeriod,
uint256 marketMakerRewardsAmount,
uint256 traderRewardsAmount,
uint256 traderScoreAlpha
)
internal
| 44,590 |
14 | // ROUND DATA | mapping (uint256 => F3Ddatasets.Round) public round_; // (rID => data) round data
mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id
uint256[3] private affPerLv_ = [20,10,5]; //affiliate's scale per level, parent 20%, pa's pa 10%, papapa 5%
| mapping (uint256 => F3Ddatasets.Round) public round_; // (rID => data) round data
mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id
uint256[3] private affPerLv_ = [20,10,5]; //affiliate's scale per level, parent 20%, pa's pa 10%, papapa 5%
| 7,614 |
543 | // can't escape to a sponsor that hasn't been linked | if ( !azimuth.hasBeenLinked(_sponsor) ) return false;
| if ( !azimuth.hasBeenLinked(_sponsor) ) return false;
| 2,266 |
15 | // calcOutGivenIn aO = tokenAmountOutbO = tokenBalanceOut bI = tokenBalanceIn//bI \(wI / wO) \ aI = tokenAmountInaO = bO|1 - | --------------------------| ^|wI = tokenWeightIn \\ ( bI + ( aI( 1 - sF )) // wO = tokenWeightOutsF = swapFee/ | {
uint weightRatio = bdiv(tokenWeightIn, tokenWeightOut);
uint adjustedIn = bsub(BONE, swapFee);
adjustedIn = bmul(tokenAmountIn, adjustedIn);
uint y = bdiv(tokenBalanceIn, badd(tokenBalanceIn, adjustedIn));
if (y == 0) {
return 0;
}
uint foo = bpow(y, weightRatio);
uint bar = bsub(BONE, foo);
tokenAmountOut = bmul(tokenBalanceOut, bar);
return tokenAmountOut;
}
| {
uint weightRatio = bdiv(tokenWeightIn, tokenWeightOut);
uint adjustedIn = bsub(BONE, swapFee);
adjustedIn = bmul(tokenAmountIn, adjustedIn);
uint y = bdiv(tokenBalanceIn, badd(tokenBalanceIn, adjustedIn));
if (y == 0) {
return 0;
}
uint foo = bpow(y, weightRatio);
uint bar = bsub(BONE, foo);
tokenAmountOut = bmul(tokenBalanceOut, bar);
return tokenAmountOut;
}
| 38,620 |
187 | // call end tx function to fire end tx event. | endTx(_pID, _team, _eth, _keys, _eventData_);
| endTx(_pID, _team, _eth, _keys, _eventData_);
| 21,141 |
58 | // Function to mint tokens _to The address that will receive the minted tokens. _amount The amount of tokens to mint.return A boolean that indicates if the operation was successful. / | function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
| function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
| 350 |
27 | // Business UGVCToken | contract UGVCToken is Token, Owner {
uint256 public constant INITIAL_SUPPLY = 15 * 10000 * 10000 * 1 ether; // 1e9 * 1e18
string public constant NAME = "UGV Chain"; //名称
string public constant SYMBOL = "UGVC"; // 简称
// string public constant STANDARD = "UGV Chain 1.0";
uint8 public constant DECIMALS = 18;
uint256 public constant BUY = 0; // 用于自动买卖
uint256 constant RATE = 1 szabo;
bool private couldTrade = false;
// string public standard = STANDARD;
// string public name;
// string public symbol;
// uint public decimals;
uint256 public sellPrice;
uint256 public buyPrice;
uint minBalanceForAccounts;
mapping (address => bool) frozenAccount;
event FrozenFunds(address indexed _target, bool _frozen);
function UGVCToken() Token(INITIAL_SUPPLY, NAME, DECIMALS, SYMBOL) {
balanceOf[msg.sender] = totalSupply;
buyPrice = 100000000;
sellPrice = 100000000;
}
function transfer(address _to, uint256 _value) returns (bool success) {
if (balanceOf[msg.sender] < _value) {
revert(); // Check if the sender has enough
}
if (balanceOf[_to] + _value < balanceOf[_to]) {
revert(); // Check for overflows
}
if (frozenAccount[msg.sender]) {
revert(); // Check if frozen
}
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (frozenAccount[_from]) {
revert(); // Check if frozen
}
if (balanceOf[_from] < _value) {
revert(); // Check if the sender has enough
}
if (balanceOf[_to] + _value < balanceOf[_to]) {
revert(); // Check for overflows
}
if (_value > allowance[_from][msg.sender]) {
revert(); // Check allowance
}
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
}
function freezeAccount(address _target, bool freeze) onlyOwner {
frozenAccount[_target] = freeze;
FrozenFunds(_target, freeze);
}
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
function buy() payable returns (uint amount) {
require(couldTrade);
amount = msg.value * RATE / buyPrice;
require(balanceOf[this] >= amount);
require(balanceOf[msg.sender] + amount >= amount);
balanceOf[this] -= amount;
balanceOf[msg.sender] += amount;
Transfer(this, msg.sender, amount);
return amount;
}
function sell(uint256 amountInWeiDecimalIs18) returns (uint256 revenue) {
require(couldTrade);
uint256 amount = amountInWeiDecimalIs18;
require(balanceOf[msg.sender] >= amount);
require(!frozenAccount[msg.sender]);
revenue = amount * sellPrice / RATE;
balanceOf[this] += amount;
balanceOf[msg.sender] -= amount;
require(msg.sender.send(revenue));
Transfer(msg.sender, this, amount);
return revenue;
}
function withdraw(uint256 amount) onlyOwner returns (bool success) {
require(msg.sender.send(amount));
return true;
}
function setCouldTrade(uint256 amountInWeiDecimalIs18) onlyOwner returns (bool success) {
couldTrade = true;
require(balanceOf[msg.sender] >= amountInWeiDecimalIs18);
require(balanceOf[this] + amountInWeiDecimalIs18 >= amountInWeiDecimalIs18);
balanceOf[msg.sender] -= amountInWeiDecimalIs18;
balanceOf[this] += amountInWeiDecimalIs18;
Transfer(msg.sender, this, amountInWeiDecimalIs18);
return true;
}
function stopTrade() onlyOwner returns (bool success) {
couldTrade = false;
uint256 _remain = balanceOf[this];
require(balanceOf[msg.sender] + _remain >= _remain);
balanceOf[msg.sender] += _remain;
balanceOf[this] -= _remain;
Transfer(this, msg.sender, _remain);
return true;
}
function () {
revert();
}
} | contract UGVCToken is Token, Owner {
uint256 public constant INITIAL_SUPPLY = 15 * 10000 * 10000 * 1 ether; // 1e9 * 1e18
string public constant NAME = "UGV Chain"; //名称
string public constant SYMBOL = "UGVC"; // 简称
// string public constant STANDARD = "UGV Chain 1.0";
uint8 public constant DECIMALS = 18;
uint256 public constant BUY = 0; // 用于自动买卖
uint256 constant RATE = 1 szabo;
bool private couldTrade = false;
// string public standard = STANDARD;
// string public name;
// string public symbol;
// uint public decimals;
uint256 public sellPrice;
uint256 public buyPrice;
uint minBalanceForAccounts;
mapping (address => bool) frozenAccount;
event FrozenFunds(address indexed _target, bool _frozen);
function UGVCToken() Token(INITIAL_SUPPLY, NAME, DECIMALS, SYMBOL) {
balanceOf[msg.sender] = totalSupply;
buyPrice = 100000000;
sellPrice = 100000000;
}
function transfer(address _to, uint256 _value) returns (bool success) {
if (balanceOf[msg.sender] < _value) {
revert(); // Check if the sender has enough
}
if (balanceOf[_to] + _value < balanceOf[_to]) {
revert(); // Check for overflows
}
if (frozenAccount[msg.sender]) {
revert(); // Check if frozen
}
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (frozenAccount[_from]) {
revert(); // Check if frozen
}
if (balanceOf[_from] < _value) {
revert(); // Check if the sender has enough
}
if (balanceOf[_to] + _value < balanceOf[_to]) {
revert(); // Check for overflows
}
if (_value > allowance[_from][msg.sender]) {
revert(); // Check allowance
}
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
}
function freezeAccount(address _target, bool freeze) onlyOwner {
frozenAccount[_target] = freeze;
FrozenFunds(_target, freeze);
}
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
function buy() payable returns (uint amount) {
require(couldTrade);
amount = msg.value * RATE / buyPrice;
require(balanceOf[this] >= amount);
require(balanceOf[msg.sender] + amount >= amount);
balanceOf[this] -= amount;
balanceOf[msg.sender] += amount;
Transfer(this, msg.sender, amount);
return amount;
}
function sell(uint256 amountInWeiDecimalIs18) returns (uint256 revenue) {
require(couldTrade);
uint256 amount = amountInWeiDecimalIs18;
require(balanceOf[msg.sender] >= amount);
require(!frozenAccount[msg.sender]);
revenue = amount * sellPrice / RATE;
balanceOf[this] += amount;
balanceOf[msg.sender] -= amount;
require(msg.sender.send(revenue));
Transfer(msg.sender, this, amount);
return revenue;
}
function withdraw(uint256 amount) onlyOwner returns (bool success) {
require(msg.sender.send(amount));
return true;
}
function setCouldTrade(uint256 amountInWeiDecimalIs18) onlyOwner returns (bool success) {
couldTrade = true;
require(balanceOf[msg.sender] >= amountInWeiDecimalIs18);
require(balanceOf[this] + amountInWeiDecimalIs18 >= amountInWeiDecimalIs18);
balanceOf[msg.sender] -= amountInWeiDecimalIs18;
balanceOf[this] += amountInWeiDecimalIs18;
Transfer(msg.sender, this, amountInWeiDecimalIs18);
return true;
}
function stopTrade() onlyOwner returns (bool success) {
couldTrade = false;
uint256 _remain = balanceOf[this];
require(balanceOf[msg.sender] + _remain >= _remain);
balanceOf[msg.sender] += _remain;
balanceOf[this] -= _remain;
Transfer(this, msg.sender, _remain);
return true;
}
function () {
revert();
}
} | 18,924 |
39 | // Mints tokens for the sender propotional to the amount of ETH sent in the transaction. Emits the Contribution event. / | function contribute(
address payable backer,
uint256 editionId,
uint256 amount
| function contribute(
address payable backer,
uint256 editionId,
uint256 amount
| 47,335 |
21 | // indicates if soft-liquidation was activated | function safe() external view returns(bool);
| function safe() external view returns(bool);
| 30,486 |
2 | // A module that allows contracts to self-destruct. / | contract Killable {
address payable public _owner;
/**
* Initialized with the deployer as the owner.
*/
constructor() internal {
_owner = msg.sender;
}
/**
* Self-destruct the contract.
* This function can only be executed by the owner.
*/
function kill() public {
require(msg.sender == _owner, "only owner method");
selfdestruct(_owner);
}
}
| contract Killable {
address payable public _owner;
/**
* Initialized with the deployer as the owner.
*/
constructor() internal {
_owner = msg.sender;
}
/**
* Self-destruct the contract.
* This function can only be executed by the owner.
*/
function kill() public {
require(msg.sender == _owner, "only owner method");
selfdestruct(_owner);
}
}
| 35,928 |
31 | // Final Number is based on server roll and lastSaleTimestamp. | uint16 winningTicket = uint16(
addmod(serverRoll, lotteries[lottId].lastSaleTimestamp, lotteries[lottId].numTickets)
);
address winner = lotteries[lottId].tickets[winningTicket];
lotteries[lottId].winner = winner;
lotteries[lottId].winningTicket = winningTicket;
| uint16 winningTicket = uint16(
addmod(serverRoll, lotteries[lottId].lastSaleTimestamp, lotteries[lottId].numTickets)
);
address winner = lotteries[lottId].tickets[winningTicket];
lotteries[lottId].winner = winner;
lotteries[lottId].winningTicket = winningTicket;
| 47,414 |
139 | // chainlink keep job start-------- harvest() actions for chainlink keeper | function harvestForChainlink(address _strategy) public {
require(msg.sender == address(this), "!this");
require(harvestable(_strategy), "generic-chainlink-keeper-v2::harvest:not-workable");
IStrategy(_strategy).harvest();
strategyLastHarvest[_strategy] = block.timestamp;
emit HarvestedByKeeper(_strategy);
}
| function harvestForChainlink(address _strategy) public {
require(msg.sender == address(this), "!this");
require(harvestable(_strategy), "generic-chainlink-keeper-v2::harvest:not-workable");
IStrategy(_strategy).harvest();
strategyLastHarvest[_strategy] = block.timestamp;
emit HarvestedByKeeper(_strategy);
}
| 18,019 |
15 | // Claim vested token _beneficiary address that should get the available token this will be eligible after vesting start + cliff or schedule times / | function claim(address _beneficiary) public {
address beneficiary = _beneficiary;
Grant storage grantInfo = grants[beneficiary];
require(grantInfo.value > 0, "Grant does not exist");
uint256 vested = calculateTransferableTokens(grantInfo, now);
require(vested > 0, "There is no vested tokens");
uint256 transferable = vested.sub(grantInfo.transferred);
require(transferable > 0, "There is no remaining balance for this address");
require(token.balanceOf(address(this)) >= transferable, "Contract Balance is insufficient");
grantInfo.transferred = grantInfo.transferred.add(transferable);
token.transfer(beneficiary, transferable);
emit NewRelease(beneficiary, transferable);
}
| function claim(address _beneficiary) public {
address beneficiary = _beneficiary;
Grant storage grantInfo = grants[beneficiary];
require(grantInfo.value > 0, "Grant does not exist");
uint256 vested = calculateTransferableTokens(grantInfo, now);
require(vested > 0, "There is no vested tokens");
uint256 transferable = vested.sub(grantInfo.transferred);
require(transferable > 0, "There is no remaining balance for this address");
require(token.balanceOf(address(this)) >= transferable, "Contract Balance is insufficient");
grantInfo.transferred = grantInfo.transferred.add(transferable);
token.transfer(beneficiary, transferable);
emit NewRelease(beneficiary, transferable);
}
| 11,356 |
65 | // Counts the number of values that have been submited for the requestif called for the currentRequest being mined it can tell you how many miners have submitted a value for thatrequest so far _requestId the requestId to look upreturn uint count of the number of values received for the requestId / | function getNewValueCountbyRequestId(uint256 _requestId)
| function getNewValueCountbyRequestId(uint256 _requestId)
| 24,534 |
1 | // Returns the latest price BNB vs BUSD / | function getLatestPrice() public view returns (int) {
(
uint80 roundID,
int price,
uint startedAt,
uint timeStamp,
uint80 answeredInRound
) = BNB_USD_Feed.latestRoundData();
int busd = (price * getLatestBUSD_USDPrice()) / 10**12; // per 1 BNB (6 decimals)
return busd;
}
| function getLatestPrice() public view returns (int) {
(
uint80 roundID,
int price,
uint startedAt,
uint timeStamp,
uint80 answeredInRound
) = BNB_USD_Feed.latestRoundData();
int busd = (price * getLatestBUSD_USDPrice()) / 10**12; // per 1 BNB (6 decimals)
return busd;
}
| 5,765 |
20 | // Unlocks the contract for owner when _lockTime is exceeds | function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock.");
require(block.timestamp > _lockTime , "Contract is locked.");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
| function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock.");
require(block.timestamp > _lockTime , "Contract is locked.");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
| 27,775 |
16 | // Internal function to calculate the output from one ETH swap./ | function calcOutputEth(address _token, uint256 _value)
internal
view
returns (uint256, address[] memory)
| function calcOutputEth(address _token, uint256 _value)
internal
view
returns (uint256, address[] memory)
| 72,988 |
141 | // TokenRecover Allow to recover any ERC20 sent into the contract for error / | contract TokenRecover is Ownable {
/**
* @dev Remember that only owner can call so be careful when use on contracts generated from other contracts.
* @param tokenAddress The token contract address
* @param tokenAmount Number of tokens to be sent
*/
function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner {
IERC20(tokenAddress).transfer(owner(), tokenAmount);
}
}
| contract TokenRecover is Ownable {
/**
* @dev Remember that only owner can call so be careful when use on contracts generated from other contracts.
* @param tokenAddress The token contract address
* @param tokenAmount Number of tokens to be sent
*/
function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner {
IERC20(tokenAddress).transfer(owner(), tokenAmount);
}
}
| 3,424 |
64 | // return adm The admin slot. / | function _admin() internal view returns (address adm) {
bytes32 slot = ADMIN_SLOT;
//solium-disable-next-line
assembly {
adm := sload(slot)
}
}
| function _admin() internal view returns (address adm) {
bytes32 slot = ADMIN_SLOT;
//solium-disable-next-line
assembly {
adm := sload(slot)
}
}
| 40,571 |
138 | // Function for getting the withdrawal credentials used to initiate pool validators withdrawal from the beacon chain./ | function withdrawalCredentials() external view returns (bytes32);
| function withdrawalCredentials() external view returns (bytes32);
| 51,069 |
89 | // Split the reward between the caller and the moonbase contract | uint256 callerReward = basedReward.div(100);
uint256 moonbaseReward = basedReward.sub(callerReward);
| uint256 callerReward = basedReward.div(100);
uint256 moonbaseReward = basedReward.sub(callerReward);
| 41,853 |
3 | // Safety function for recovering missent ERC20 tokenstoken address of the ERC20 contract/ | function recoverToken(IERC20 token) external onlyRecoverer {
token.transfer(msg.sender, token.balanceOf(address(this)));
}
| function recoverToken(IERC20 token) external onlyRecoverer {
token.transfer(msg.sender, token.balanceOf(address(this)));
}
| 37,827 |
6 | // ╔═════════════════════════════╗ | constructor(string memory baseURI) ERC1155("") {
_setBaseURI(baseURI);
}
| constructor(string memory baseURI) ERC1155("") {
_setBaseURI(baseURI);
}
| 12,431 |
13 | // 0 | bool initialized;
| bool initialized;
| 30,200 |
44 | // Loop through the locked stakes, first by getting the liquiditylock_multiplier portion | new_combined_weight = 0;
for (uint256 i = 0; i < lockedNFTs[account].length; i++) {
LockedNFT memory thisNFT = lockedNFTs[account][i];
uint256 lock_multiplier = thisNFT.lock_multiplier;
| new_combined_weight = 0;
for (uint256 i = 0; i < lockedNFTs[account].length; i++) {
LockedNFT memory thisNFT = lockedNFTs[account][i];
uint256 lock_multiplier = thisNFT.lock_multiplier;
| 4,280 |
114 | // utility for uint8 array _array target array _index array index to remove / | function _removeElementAt8(uint8[] storage _array, uint256 _index) internal
returns (bool)
| function _removeElementAt8(uint8[] storage _array, uint256 _index) internal
returns (bool)
| 4,783 |
4 | // Encodes a cross domain message based on the V0 (legacy) encoding._target Address of the target of the message. _sender Address of the sender of the message. _data Data to send with the message. _nonceMessage nonce. return Encoded cross domain message. / | function encodeCrossDomainMessageV0(
address _target,
address _sender,
bytes memory _data,
uint256 _nonce
| function encodeCrossDomainMessageV0(
address _target,
address _sender,
bytes memory _data,
uint256 _nonce
| 15,863 |
41 | // This function deactivates the emergency mode/_token Token on which the emergency mode will be deactivated | function deactivateEmergency(ILERC20 _token) override external onlyLosslessEnv {
tokenConfig[_token].emergencyMode = 0;
emit EmergencyDeactivation(_token);
}
| function deactivateEmergency(ILERC20 _token) override external onlyLosslessEnv {
tokenConfig[_token].emergencyMode = 0;
emit EmergencyDeactivation(_token);
}
| 41,847 |
145 | // Returns the symbol of the token, usually a shorter version of thename. / |
function symbol() external view returns (string memory);
|
function symbol() external view returns (string memory);
| 27 |
601 | // Check if there is excess eth | uint256 excessETH = msg.value.sub(amountETH);
| uint256 excessETH = msg.value.sub(amountETH);
| 80,923 |
231 | // Returns a list of Positions, through traversing the components. Each component with a non-zero virtual unitis considered a Default Position, and each externalPositionModule will generate a unique position.Virtual units are converted to real units. This function is typically used off-chain for data presentation purposes. / | function getPositions() external view returns (ISetToken.Position[] memory) {
ISetToken.Position[] memory positions = new ISetToken.Position[](_getPositionCount());
uint256 positionCount = 0;
for (uint256 i = 0; i < components.length; i++) {
address component = components[i];
// A default position exists if the default virtual unit is > 0
if (_defaultPositionVirtualUnit(component) > 0) {
positions[positionCount] = ISetToken.Position({
component: component,
module: address(0),
unit: getDefaultPositionRealUnit(component),
positionState: DEFAULT,
data: ""
});
positionCount++;
}
address[] memory externalModules = _externalPositionModules(component);
for (uint256 j = 0; j < externalModules.length; j++) {
address currentModule = externalModules[j];
positions[positionCount] = ISetToken.Position({
component: component,
module: currentModule,
unit: getExternalPositionRealUnit(component, currentModule),
positionState: EXTERNAL,
data: _externalPositionData(component, currentModule)
});
positionCount++;
}
}
return positions;
}
| function getPositions() external view returns (ISetToken.Position[] memory) {
ISetToken.Position[] memory positions = new ISetToken.Position[](_getPositionCount());
uint256 positionCount = 0;
for (uint256 i = 0; i < components.length; i++) {
address component = components[i];
// A default position exists if the default virtual unit is > 0
if (_defaultPositionVirtualUnit(component) > 0) {
positions[positionCount] = ISetToken.Position({
component: component,
module: address(0),
unit: getDefaultPositionRealUnit(component),
positionState: DEFAULT,
data: ""
});
positionCount++;
}
address[] memory externalModules = _externalPositionModules(component);
for (uint256 j = 0; j < externalModules.length; j++) {
address currentModule = externalModules[j];
positions[positionCount] = ISetToken.Position({
component: component,
module: currentModule,
unit: getExternalPositionRealUnit(component, currentModule),
positionState: EXTERNAL,
data: _externalPositionData(component, currentModule)
});
positionCount++;
}
}
return positions;
}
| 21,453 |
39 | // Uint256 variable to check which pool should we add liquidity to e.g(ACG/WBNB - ACG/USDT) | uint256 public liquidityPoolToUse = 0; // 0 = WBNB/ACG - 1 = USDT/ACG - 2 = Special/ACG
| uint256 public liquidityPoolToUse = 0; // 0 = WBNB/ACG - 1 = USDT/ACG - 2 = Special/ACG
| 31,653 |
224 | // check if the base fee gas price is higher than we allow | if (readBaseFee() > maxGasPrice) {
return false;
}
| if (readBaseFee() > maxGasPrice) {
return false;
}
| 27,376 |
147 | // Returns whether the SetToken component default position real unit is greater than or equal to units passed in. / | function hasSufficientDefaultUnits(ISetToken _setToken, address _component, uint256 _unit) internal view returns(bool) {
return _setToken.getDefaultPositionRealUnit(_component) >= _unit.toInt256();
}
| function hasSufficientDefaultUnits(ISetToken _setToken, address _component, uint256 _unit) internal view returns(bool) {
return _setToken.getDefaultPositionRealUnit(_component) >= _unit.toInt256();
}
| 39,171 |
4 | // The crowd proposal author | address payable public immutable author;
| address payable public immutable author;
| 62,127 |
23 | // ------------------------------------------------------------ ------------------------- Properties ----------------------- ------------------------------------------------------------ | mapping(address => Tenant) private tenants;
mapping(bytes32 => mapping(bytes32 => bool)) private tenantPublicKeys; // Mapping to check whether a public key has been used in a tenant's profile
address[] private mediators; // List of mediators
Apartment[] private apartments; // List of apartments
mapping(bytes32 => uint[]) private cityApartments; // Country+City SHA256 hash => apartment ids; to allow fetching apartments of a city
mapping(address => uint[]) private ownerApartments; // Mapping to get the apartments of an owner and to check if the address has been used
mapping(bytes32 => mapping(bytes32 => bool)) private ownerPublicKeys; // Mapping to check whether a public key has been used in an apartment
| mapping(address => Tenant) private tenants;
mapping(bytes32 => mapping(bytes32 => bool)) private tenantPublicKeys; // Mapping to check whether a public key has been used in a tenant's profile
address[] private mediators; // List of mediators
Apartment[] private apartments; // List of apartments
mapping(bytes32 => uint[]) private cityApartments; // Country+City SHA256 hash => apartment ids; to allow fetching apartments of a city
mapping(address => uint[]) private ownerApartments; // Mapping to get the apartments of an owner and to check if the address has been used
mapping(bytes32 => mapping(bytes32 => bool)) private ownerPublicKeys; // Mapping to check whether a public key has been used in an apartment
| 43,369 |
51 | // PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH Anytime there is division, there is a risk of numerical instability from rounding errors. In order to minimize this risk, we adhere to the following guidelines: 1) The conversion rate adopted is the number of shares that equals 1 UNBASE.The inverse rate must not be used--totalShares is always the numerator and _totalSupply isalways the denominator. (i.e. If you want to convert shares to UNBASE instead ofmultiplying by the inverse rate, you should divide by the normal rate) 2) Share balances converted into UnbaseToken are always rounded down (truncated). We make the following | using SafeMath for uint256;
event LogRebase(uint256 indexed _epoch, uint256 totalSupply);
event LogUserBanStatusUpdated(address user, bool banned);
| using SafeMath for uint256;
event LogRebase(uint256 indexed _epoch, uint256 totalSupply);
event LogUserBanStatusUpdated(address user, bool banned);
| 9,678 |
394 | // Store the token address. | address token = _tokens[i];
| address token = _tokens[i];
| 43,799 |
185 | // getVotingProxy(): returns _point's current voting proxy | function getVotingProxy(uint32 _point)
view
external
returns (address voter)
| function getVotingProxy(uint32 _point)
view
external
returns (address voter)
| 14,343 |
198 | // PRICE REQUEST AND ACCESS FUNCTIONS // Enqueues a request (if a request isn't already present) for the given `identifier`, `time` pair. Time must be in the past and the identifier must be supported. The length of the ancillary datais limited such that this method abides by the EVM transaction gas limit. identifier uniquely identifies the price requested. eg BTC/USD (encoded as bytes32) could be requested. time unix timestamp for the price request. ancillaryData arbitrary data appended to a price request to give the voters more info from the caller. / | function requestPrice(
bytes32 identifier,
uint256 time,
bytes memory ancillaryData
| function requestPrice(
bytes32 identifier,
uint256 time,
bytes memory ancillaryData
| 21,300 |
8 | // lock the tokens deposited for this account so they can be used to pay for gas.after calling unlockTokenDeposit(), the account can't use this paymaster until the deposit is locked. / | function lockTokenDeposit() public {
unlockBlock[msg.sender] = 0;
}
| function lockTokenDeposit() public {
unlockBlock[msg.sender] = 0;
}
| 22,156 |
8 | // Fetches Aave prices for tokens/_market Address of LendingPoolAddressesProvider for specific market/_tokens Arr. of tokens for which to get the prices/ return prices Array of prices | function getPrices(address _market, address[] memory _tokens)
public
view
returns (uint256[] memory prices)
| function getPrices(address _market, address[] memory _tokens)
public
view
returns (uint256[] memory prices)
| 44,638 |
338 | // Implementation of the ERC3156 Flash loans extension, as defined in | * Adds the {flashLoan} method, which provides flash loan support at the token
* level. By default there is no fee, but this can be changed by overriding {flashFee}.
*
* _Available since v4.1._
*/
abstract contract ERC20FlashMint is ERC20, IERC3156FlashLender {
bytes32 private constant _RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan");
/**
* @dev Returns the maximum amount of tokens available for loan.
* @param token The address of the token that is requested.
* @return The amount of token that can be loaned.
*/
function maxFlashLoan(address token) public view virtual override returns (uint256) {
return token == address(this) ? type(uint256).max - ERC20.totalSupply() : 0;
}
/**
* @dev Returns the fee applied when doing flash loans. This function calls
* the {_flashFee} function which returns the fee applied when doing flash
* loans.
* @param token The token to be flash loaned.
* @param amount The amount of tokens to be loaned.
* @return The fees applied to the corresponding flash loan.
*/
function flashFee(address token, uint256 amount) public view virtual override returns (uint256) {
require(token == address(this), "ERC20FlashMint: wrong token");
return _flashFee(token, amount);
}
/**
* @dev Returns the fee applied when doing flash loans. By default this
* implementation has 0 fees. This function can be overloaded to make
* the flash loan mechanism deflationary.
* @param token The token to be flash loaned.
* @param amount The amount of tokens to be loaned.
* @return The fees applied to the corresponding flash loan.
*/
function _flashFee(address token, uint256 amount) internal view virtual returns (uint256) {
// silence warning about unused variable without the addition of bytecode.
token;
amount;
return 0;
}
/**
* @dev Returns the receiver address of the flash fee. By default this
* implementation returns the address(0) which means the fee amount will be burnt.
* This function can be overloaded to change the fee receiver.
* @return The address for which the flash fee will be sent to.
*/
function _flashFeeReceiver() internal view virtual returns (address) {
return address(0);
}
/**
* @dev Performs a flash loan. New tokens are minted and sent to the
* `receiver`, who is required to implement the {IERC3156FlashBorrower}
* interface. By the end of the flash loan, the receiver is expected to own
* amount + fee tokens and have them approved back to the token contract itself so
* they can be burned.
* @param receiver The receiver of the flash loan. Should implement the
* {IERC3156FlashBorrower-onFlashLoan} interface.
* @param token The token to be flash loaned. Only `address(this)` is
* supported.
* @param amount The amount of tokens to be loaned.
* @param data An arbitrary datafield that is passed to the receiver.
* @return `true` if the flash loan was successful.
*/
// This function can reenter, but it doesn't pose a risk because it always preserves the property that the amount
// minted at the beginning is always recovered and burned at the end, or else the entire function will revert.
// slither-disable-next-line reentrancy-no-eth
function flashLoan(
IERC3156FlashBorrower receiver,
address token,
uint256 amount,
bytes calldata data
) public virtual override returns (bool) {
require(amount <= maxFlashLoan(token), "ERC20FlashMint: amount exceeds maxFlashLoan");
uint256 fee = flashFee(token, amount);
_mint(address(receiver), amount);
require(
receiver.onFlashLoan(msg.sender, token, amount, fee, data) == _RETURN_VALUE,
"ERC20FlashMint: invalid return value"
);
address flashFeeReceiver = _flashFeeReceiver();
_spendAllowance(address(receiver), address(this), amount + fee);
if (fee == 0 || flashFeeReceiver == address(0)) {
_burn(address(receiver), amount + fee);
} else {
_burn(address(receiver), amount);
_transfer(address(receiver), flashFeeReceiver, fee);
}
return true;
}
}
| * Adds the {flashLoan} method, which provides flash loan support at the token
* level. By default there is no fee, but this can be changed by overriding {flashFee}.
*
* _Available since v4.1._
*/
abstract contract ERC20FlashMint is ERC20, IERC3156FlashLender {
bytes32 private constant _RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan");
/**
* @dev Returns the maximum amount of tokens available for loan.
* @param token The address of the token that is requested.
* @return The amount of token that can be loaned.
*/
function maxFlashLoan(address token) public view virtual override returns (uint256) {
return token == address(this) ? type(uint256).max - ERC20.totalSupply() : 0;
}
/**
* @dev Returns the fee applied when doing flash loans. This function calls
* the {_flashFee} function which returns the fee applied when doing flash
* loans.
* @param token The token to be flash loaned.
* @param amount The amount of tokens to be loaned.
* @return The fees applied to the corresponding flash loan.
*/
function flashFee(address token, uint256 amount) public view virtual override returns (uint256) {
require(token == address(this), "ERC20FlashMint: wrong token");
return _flashFee(token, amount);
}
/**
* @dev Returns the fee applied when doing flash loans. By default this
* implementation has 0 fees. This function can be overloaded to make
* the flash loan mechanism deflationary.
* @param token The token to be flash loaned.
* @param amount The amount of tokens to be loaned.
* @return The fees applied to the corresponding flash loan.
*/
function _flashFee(address token, uint256 amount) internal view virtual returns (uint256) {
// silence warning about unused variable without the addition of bytecode.
token;
amount;
return 0;
}
/**
* @dev Returns the receiver address of the flash fee. By default this
* implementation returns the address(0) which means the fee amount will be burnt.
* This function can be overloaded to change the fee receiver.
* @return The address for which the flash fee will be sent to.
*/
function _flashFeeReceiver() internal view virtual returns (address) {
return address(0);
}
/**
* @dev Performs a flash loan. New tokens are minted and sent to the
* `receiver`, who is required to implement the {IERC3156FlashBorrower}
* interface. By the end of the flash loan, the receiver is expected to own
* amount + fee tokens and have them approved back to the token contract itself so
* they can be burned.
* @param receiver The receiver of the flash loan. Should implement the
* {IERC3156FlashBorrower-onFlashLoan} interface.
* @param token The token to be flash loaned. Only `address(this)` is
* supported.
* @param amount The amount of tokens to be loaned.
* @param data An arbitrary datafield that is passed to the receiver.
* @return `true` if the flash loan was successful.
*/
// This function can reenter, but it doesn't pose a risk because it always preserves the property that the amount
// minted at the beginning is always recovered and burned at the end, or else the entire function will revert.
// slither-disable-next-line reentrancy-no-eth
function flashLoan(
IERC3156FlashBorrower receiver,
address token,
uint256 amount,
bytes calldata data
) public virtual override returns (bool) {
require(amount <= maxFlashLoan(token), "ERC20FlashMint: amount exceeds maxFlashLoan");
uint256 fee = flashFee(token, amount);
_mint(address(receiver), amount);
require(
receiver.onFlashLoan(msg.sender, token, amount, fee, data) == _RETURN_VALUE,
"ERC20FlashMint: invalid return value"
);
address flashFeeReceiver = _flashFeeReceiver();
_spendAllowance(address(receiver), address(this), amount + fee);
if (fee == 0 || flashFeeReceiver == address(0)) {
_burn(address(receiver), amount + fee);
} else {
_burn(address(receiver), amount);
_transfer(address(receiver), flashFeeReceiver, fee);
}
return true;
}
}
| 6,685 |
0 | // The Ownable constructor sets the original `owner` of the contract to the sender account./ | constructor() public {
owner_ = msg.sender;
}
| constructor() public {
owner_ = msg.sender;
}
| 1,947 |
131 | // Returns balance of BPT Token of given user address _address address of the user / | function getBalanceBpOf(address _address)
external
view
returns (uint256)
| function getBalanceBpOf(address _address)
external
view
returns (uint256)
| 37,169 |
21 | // require the swap amount is exact | require(
(zeroForOne && amount1 == uint256(-swapAmount1)) ||
(!zeroForOne && amount0 == uint256(-swapAmount0)),
"stm"
);
require(
zeroForOne ? (amount0 <= leftTokenIn) : (amount1 <= leftTokenIn),
"over"
);
| require(
(zeroForOne && amount1 == uint256(-swapAmount1)) ||
(!zeroForOne && amount0 == uint256(-swapAmount0)),
"stm"
);
require(
zeroForOne ? (amount0 <= leftTokenIn) : (amount1 <= leftTokenIn),
"over"
);
| 21,549 |
296 | // add PACK id to map |
for(uint256 j = 0; j < mintedImg.length; j++) {
require(!ImgStatus[mintedImg[j]], "This number is existed");
ImgStatus[mintedImg[j]] = true;
}
|
for(uint256 j = 0; j < mintedImg.length; j++) {
require(!ImgStatus[mintedImg[j]], "This number is existed");
ImgStatus[mintedImg[j]] = true;
}
| 15,761 |
32 | // The total funds that are timelocked. | uint256 public timelockTotalSupply;
| uint256 public timelockTotalSupply;
| 16,355 |
6 | // Questions: if the app is set up to have the transfers pre-assigned in the same way the swap app is atm, will the adjudicator know that if no correct preimage is included in the commitment, it should 0 transfers? | // enum ActionType {
// CLAIM_MONEY
// // // NOTE: These following action will soon
// // // be built in as a framework-level
// // // constant but for now must be app-level.
// // END_CHANNEL
// }
| // enum ActionType {
// CLAIM_MONEY
// // // NOTE: These following action will soon
// // // be built in as a framework-level
// // // constant but for now must be app-level.
// // END_CHANNEL
// }
| 28,552 |
302 | // Hop Facet (Optimized)/LI.FI (https:li.fi)/Provides functionality for bridging through Hop/ @custom:version 2.0.0 | contract HopFacetOptimized is ILiFi, SwapperV2 {
/// Types ///
struct HopData {
uint256 bonderFee;
uint256 amountOutMin;
uint256 deadline;
uint256 destinationAmountOutMin;
uint256 destinationDeadline;
IHopBridge hopBridge;
address relayer;
uint256 relayerFee;
uint256 nativeFee;
}
/// External Methods ///
/// @notice Sets approval for the Hop Bridge to spend the specified token
/// @param bridges The Hop Bridges to approve
/// @param tokensToApprove The tokens to approve to approve to the Hop Bridges
function setApprovalForBridges(
address[] calldata bridges,
address[] calldata tokensToApprove
) external {
LibDiamond.enforceIsContractOwner();
for (uint256 i; i < bridges.length; i++) {
// Give Hop approval to bridge tokens
LibAsset.maxApproveERC20(
IERC20(tokensToApprove[i]),
address(bridges[i]),
type(uint256).max
);
}
}
/// @notice Bridges ERC20 tokens via Hop Protocol from L1
/// @param _bridgeData the core information needed for bridging
/// @param _hopData data specific to Hop Protocol
function startBridgeTokensViaHopL1ERC20(
ILiFi.BridgeData calldata _bridgeData,
HopData calldata _hopData
) external payable {
// Deposit assets
LibAsset.transferFromERC20(
_bridgeData.sendingAssetId,
msg.sender,
address(this),
_bridgeData.minAmount
);
// Bridge assets
_hopData.hopBridge.sendToL2{ value: _hopData.nativeFee }(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline,
_hopData.relayer,
_hopData.relayerFee
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Bridges Native tokens via Hop Protocol from L1
/// @param _bridgeData the core information needed for bridging
/// @param _hopData data specific to Hop Protocol
function startBridgeTokensViaHopL1Native(
ILiFi.BridgeData calldata _bridgeData,
HopData calldata _hopData
) external payable {
// Bridge assets
_hopData.hopBridge.sendToL2{
value: _bridgeData.minAmount + _hopData.nativeFee
}(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline,
_hopData.relayer,
_hopData.relayerFee
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Performs a swap before bridging ERC20 tokens via Hop Protocol from L1
/// @param _bridgeData the core information needed for bridging
/// @param _swapData an array of swap related data for performing swaps before bridging
/// @param _hopData data specific to Hop Protocol
function swapAndStartBridgeTokensViaHopL1ERC20(
ILiFi.BridgeData memory _bridgeData,
LibSwap.SwapData[] calldata _swapData,
HopData calldata _hopData
) external payable {
// Deposit and swap assets
_bridgeData.minAmount = _depositAndSwap(
_bridgeData.transactionId,
_bridgeData.minAmount,
_swapData,
payable(msg.sender),
_hopData.nativeFee
);
// Bridge assets
_hopData.hopBridge.sendToL2{ value: _hopData.nativeFee }(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline,
_hopData.relayer,
_hopData.relayerFee
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Performs a swap before bridging Native tokens via Hop Protocol from L1
/// @param _bridgeData the core information needed for bridging
/// @param _swapData an array of swap related data for performing swaps before bridging
/// @param _hopData data specific to Hop Protocol
function swapAndStartBridgeTokensViaHopL1Native(
ILiFi.BridgeData memory _bridgeData,
LibSwap.SwapData[] calldata _swapData,
HopData calldata _hopData
) external payable {
// Deposit and swap assets
_bridgeData.minAmount = _depositAndSwap(
_bridgeData.transactionId,
_bridgeData.minAmount,
_swapData,
payable(msg.sender),
_hopData.nativeFee
);
// Bridge assets
_hopData.hopBridge.sendToL2{
value: _bridgeData.minAmount + _hopData.nativeFee
}(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline,
_hopData.relayer,
_hopData.relayerFee
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Bridges ERC20 tokens via Hop Protocol from L2
/// @param _bridgeData the core information needed for bridging
/// @param _hopData data specific to Hop Protocol
function startBridgeTokensViaHopL2ERC20(
ILiFi.BridgeData calldata _bridgeData,
HopData calldata _hopData
) external {
// Deposit assets
LibAsset.transferFromERC20(
_bridgeData.sendingAssetId,
msg.sender,
address(this),
_bridgeData.minAmount
);
// Bridge assets
_hopData.hopBridge.swapAndSend(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.bonderFee,
_hopData.amountOutMin,
_hopData.deadline,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Bridges Native tokens via Hop Protocol from L2
/// @param _bridgeData the core information needed for bridging
/// @param _hopData data specific to Hop Protocol
function startBridgeTokensViaHopL2Native(
ILiFi.BridgeData calldata _bridgeData,
HopData calldata _hopData
) external payable {
// Bridge assets
_hopData.hopBridge.swapAndSend{ value: _bridgeData.minAmount }(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.bonderFee,
_hopData.amountOutMin,
_hopData.deadline,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Performs a swap before bridging ERC20 tokens via Hop Protocol from L2
/// @param _bridgeData the core information needed for bridging
/// @param _swapData an array of swap related data for performing swaps before bridging
/// @param _hopData data specific to Hop Protocol
function swapAndStartBridgeTokensViaHopL2ERC20(
ILiFi.BridgeData memory _bridgeData,
LibSwap.SwapData[] calldata _swapData,
HopData calldata _hopData
) external payable {
// Deposit and swap assets
_bridgeData.minAmount = _depositAndSwap(
_bridgeData.transactionId,
_bridgeData.minAmount,
_swapData,
payable(msg.sender)
);
// Bridge assets
_hopData.hopBridge.swapAndSend(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.bonderFee,
_hopData.amountOutMin,
_hopData.deadline,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Performs a swap before bridging Native tokens via Hop Protocol from L2
/// @param _bridgeData the core information needed for bridging
/// @param _swapData an array of swap related data for performing swaps before bridging
/// @param _hopData data specific to Hop Protocol
function swapAndStartBridgeTokensViaHopL2Native(
ILiFi.BridgeData memory _bridgeData,
LibSwap.SwapData[] calldata _swapData,
HopData calldata _hopData
) external payable {
// Deposit and swap assets
_bridgeData.minAmount = _depositAndSwap(
_bridgeData.transactionId,
_bridgeData.minAmount,
_swapData,
payable(msg.sender)
);
// Bridge assets
_hopData.hopBridge.swapAndSend{ value: _bridgeData.minAmount }(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.bonderFee,
_hopData.amountOutMin,
_hopData.deadline,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline
);
emit LiFiTransferStarted(_bridgeData);
}
}
| contract HopFacetOptimized is ILiFi, SwapperV2 {
/// Types ///
struct HopData {
uint256 bonderFee;
uint256 amountOutMin;
uint256 deadline;
uint256 destinationAmountOutMin;
uint256 destinationDeadline;
IHopBridge hopBridge;
address relayer;
uint256 relayerFee;
uint256 nativeFee;
}
/// External Methods ///
/// @notice Sets approval for the Hop Bridge to spend the specified token
/// @param bridges The Hop Bridges to approve
/// @param tokensToApprove The tokens to approve to approve to the Hop Bridges
function setApprovalForBridges(
address[] calldata bridges,
address[] calldata tokensToApprove
) external {
LibDiamond.enforceIsContractOwner();
for (uint256 i; i < bridges.length; i++) {
// Give Hop approval to bridge tokens
LibAsset.maxApproveERC20(
IERC20(tokensToApprove[i]),
address(bridges[i]),
type(uint256).max
);
}
}
/// @notice Bridges ERC20 tokens via Hop Protocol from L1
/// @param _bridgeData the core information needed for bridging
/// @param _hopData data specific to Hop Protocol
function startBridgeTokensViaHopL1ERC20(
ILiFi.BridgeData calldata _bridgeData,
HopData calldata _hopData
) external payable {
// Deposit assets
LibAsset.transferFromERC20(
_bridgeData.sendingAssetId,
msg.sender,
address(this),
_bridgeData.minAmount
);
// Bridge assets
_hopData.hopBridge.sendToL2{ value: _hopData.nativeFee }(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline,
_hopData.relayer,
_hopData.relayerFee
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Bridges Native tokens via Hop Protocol from L1
/// @param _bridgeData the core information needed for bridging
/// @param _hopData data specific to Hop Protocol
function startBridgeTokensViaHopL1Native(
ILiFi.BridgeData calldata _bridgeData,
HopData calldata _hopData
) external payable {
// Bridge assets
_hopData.hopBridge.sendToL2{
value: _bridgeData.minAmount + _hopData.nativeFee
}(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline,
_hopData.relayer,
_hopData.relayerFee
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Performs a swap before bridging ERC20 tokens via Hop Protocol from L1
/// @param _bridgeData the core information needed for bridging
/// @param _swapData an array of swap related data for performing swaps before bridging
/// @param _hopData data specific to Hop Protocol
function swapAndStartBridgeTokensViaHopL1ERC20(
ILiFi.BridgeData memory _bridgeData,
LibSwap.SwapData[] calldata _swapData,
HopData calldata _hopData
) external payable {
// Deposit and swap assets
_bridgeData.minAmount = _depositAndSwap(
_bridgeData.transactionId,
_bridgeData.minAmount,
_swapData,
payable(msg.sender),
_hopData.nativeFee
);
// Bridge assets
_hopData.hopBridge.sendToL2{ value: _hopData.nativeFee }(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline,
_hopData.relayer,
_hopData.relayerFee
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Performs a swap before bridging Native tokens via Hop Protocol from L1
/// @param _bridgeData the core information needed for bridging
/// @param _swapData an array of swap related data for performing swaps before bridging
/// @param _hopData data specific to Hop Protocol
function swapAndStartBridgeTokensViaHopL1Native(
ILiFi.BridgeData memory _bridgeData,
LibSwap.SwapData[] calldata _swapData,
HopData calldata _hopData
) external payable {
// Deposit and swap assets
_bridgeData.minAmount = _depositAndSwap(
_bridgeData.transactionId,
_bridgeData.minAmount,
_swapData,
payable(msg.sender),
_hopData.nativeFee
);
// Bridge assets
_hopData.hopBridge.sendToL2{
value: _bridgeData.minAmount + _hopData.nativeFee
}(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline,
_hopData.relayer,
_hopData.relayerFee
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Bridges ERC20 tokens via Hop Protocol from L2
/// @param _bridgeData the core information needed for bridging
/// @param _hopData data specific to Hop Protocol
function startBridgeTokensViaHopL2ERC20(
ILiFi.BridgeData calldata _bridgeData,
HopData calldata _hopData
) external {
// Deposit assets
LibAsset.transferFromERC20(
_bridgeData.sendingAssetId,
msg.sender,
address(this),
_bridgeData.minAmount
);
// Bridge assets
_hopData.hopBridge.swapAndSend(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.bonderFee,
_hopData.amountOutMin,
_hopData.deadline,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Bridges Native tokens via Hop Protocol from L2
/// @param _bridgeData the core information needed for bridging
/// @param _hopData data specific to Hop Protocol
function startBridgeTokensViaHopL2Native(
ILiFi.BridgeData calldata _bridgeData,
HopData calldata _hopData
) external payable {
// Bridge assets
_hopData.hopBridge.swapAndSend{ value: _bridgeData.minAmount }(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.bonderFee,
_hopData.amountOutMin,
_hopData.deadline,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Performs a swap before bridging ERC20 tokens via Hop Protocol from L2
/// @param _bridgeData the core information needed for bridging
/// @param _swapData an array of swap related data for performing swaps before bridging
/// @param _hopData data specific to Hop Protocol
function swapAndStartBridgeTokensViaHopL2ERC20(
ILiFi.BridgeData memory _bridgeData,
LibSwap.SwapData[] calldata _swapData,
HopData calldata _hopData
) external payable {
// Deposit and swap assets
_bridgeData.minAmount = _depositAndSwap(
_bridgeData.transactionId,
_bridgeData.minAmount,
_swapData,
payable(msg.sender)
);
// Bridge assets
_hopData.hopBridge.swapAndSend(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.bonderFee,
_hopData.amountOutMin,
_hopData.deadline,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline
);
emit LiFiTransferStarted(_bridgeData);
}
/// @notice Performs a swap before bridging Native tokens via Hop Protocol from L2
/// @param _bridgeData the core information needed for bridging
/// @param _swapData an array of swap related data for performing swaps before bridging
/// @param _hopData data specific to Hop Protocol
function swapAndStartBridgeTokensViaHopL2Native(
ILiFi.BridgeData memory _bridgeData,
LibSwap.SwapData[] calldata _swapData,
HopData calldata _hopData
) external payable {
// Deposit and swap assets
_bridgeData.minAmount = _depositAndSwap(
_bridgeData.transactionId,
_bridgeData.minAmount,
_swapData,
payable(msg.sender)
);
// Bridge assets
_hopData.hopBridge.swapAndSend{ value: _bridgeData.minAmount }(
_bridgeData.destinationChainId,
_bridgeData.receiver,
_bridgeData.minAmount,
_hopData.bonderFee,
_hopData.amountOutMin,
_hopData.deadline,
_hopData.destinationAmountOutMin,
_hopData.destinationDeadline
);
emit LiFiTransferStarted(_bridgeData);
}
}
| 8,947 |
63 | // Returns the vote signer for the specified account. account The address of the account.return The address with which the account can sign votes. / | function getVoteSigner(address account) public view returns (address) {
return getLegacySigner(account, VoteSigner);
}
| function getVoteSigner(address account) public view returns (address) {
return getLegacySigner(account, VoteSigner);
}
| 15,216 |
5 | // 3D Vector | function _3DVector_new(uint depth, uint row, uint col) internal pure returns (_3DVector memory) {
uint area = row * col;
uint[] memory data = new uint[](depth * area);
return _3DVector(data, row, col, area, depth);
}
| function _3DVector_new(uint depth, uint row, uint col) internal pure returns (_3DVector memory) {
uint area = row * col;
uint[] memory data = new uint[](depth * area);
return _3DVector(data, row, col, area, depth);
}
| 15,106 |
6 | // Withdraw |
function withdrawBeans(
uint32[] calldata crates,
uint256[] calldata amounts
)
external
|
function withdrawBeans(
uint32[] calldata crates,
uint256[] calldata amounts
)
external
| 43,873 |
6 | // Emitted when a previously stored claim is successfuly revoked by the attester | event ClaimRevoked(
bytes sig
);
| event ClaimRevoked(
bytes sig
);
| 37,990 |
1 | // Check that the deadline is in the future | require(_deadline > block.timestamp, "The deadline should be a date in the future.");
| require(_deadline > block.timestamp, "The deadline should be a date in the future.");
| 5,456 |
69 | // Ensure the auction has ended | require(block.timestamp >= (firstBidTime + auction.duration), "AUCTION_NOT_OVER");
| require(block.timestamp >= (firstBidTime + auction.duration), "AUCTION_NOT_OVER");
| 41,669 |
72 | // queried by others ({ERC165Checker}).For an implementation, see {ERC165}./ Returns true if this contract implements the interface defined by`interfaceId`. See the correspondingto learn more about how these ids are created. This function call must use less than 30 000 gas. / | function supportsInterface(bytes4 interfaceId) external view returns (bool);
| function supportsInterface(bytes4 interfaceId) external view returns (bool);
| 44,756 |
13 | // sets the fusion contract | function setOmniFusionContract(address _address) external onlyOwner {
_omniFusionContract = IERC1155(_address);
}
| function setOmniFusionContract(address _address) external onlyOwner {
_omniFusionContract = IERC1155(_address);
}
| 13,261 |
20 | // EIP-712 typehash for this contract's domain. | function DOMAIN_SEPARATOR() public view returns (bytes32) {
return block.chainid == DOMAIN_SEPARATOR_CHAIN_ID ? _DOMAIN_SEPARATOR : calculateDomainSeparator();
}
| function DOMAIN_SEPARATOR() public view returns (bytes32) {
return block.chainid == DOMAIN_SEPARATOR_CHAIN_ID ? _DOMAIN_SEPARATOR : calculateDomainSeparator();
}
| 51,175 |
15 | // 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");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| 13,335 |
4 | // Check if the contract is active./ | modifier isActive() {
require(active);
_;
}
| modifier isActive() {
require(active);
_;
}
| 743 |
351 | // Accumulate DSR interest | PotLike(potAddress).drip();
| PotLike(potAddress).drip();
| 31,081 |
140 | // Returns true if the contract is paused, and false otherwise./ | function paused() external view returns (bool);
| function paused() external view returns (bool);
| 15,195 |
7 | // Throws if called by any address that does not have all the roles. | modifier onlyOperatorsWithAllRoles(
uint256 roleMask
)
| modifier onlyOperatorsWithAllRoles(
uint256 roleMask
)
| 23,728 |
6 | // Public functions //Initialize function sets initial storage values./_redemptionAdminMultiSig Address of the redemption admin multisig contract./_assets Address of the assets contract. | function initialize(
IMultiSigWallet _redemptionAdminMultiSig,
IMultiSigWallet _basicProtectorMultiSig,
address _superProtectorMultiSig,
Assets _assets,
MPVToken _mpvToken,
MasterPropertyValue _masterPropertyValue
| function initialize(
IMultiSigWallet _redemptionAdminMultiSig,
IMultiSigWallet _basicProtectorMultiSig,
address _superProtectorMultiSig,
Assets _assets,
MPVToken _mpvToken,
MasterPropertyValue _masterPropertyValue
| 9,434 |
9 | // Make sure mint doesn't go over total supply | require(_totalMinted() + amount <= PublicSupply + reservedMinted, "Mint would go over max supply");
| require(_totalMinted() + amount <= PublicSupply + reservedMinted, "Mint would go over max supply");
| 54,241 |
234 | // Gets the redeem fine of the NFT self The NFT configurationreturn The redeem fine / | function getRedeemFine(DataTypes.NftConfigurationMap storage self) internal view returns (uint256) {
return (self.data & ~REDEEM_FINE_MASK) >> REDEEM_FINE_START_BIT_POSITION;
}
| function getRedeemFine(DataTypes.NftConfigurationMap storage self) internal view returns (uint256) {
return (self.data & ~REDEEM_FINE_MASK) >> REDEEM_FINE_START_BIT_POSITION;
}
| 64,422 |
135 | // Delegate the votes for a Compound COMP-like token held by the prize pool/compLike The COMP-like token held by the prize pool that should be delegated/to The address to delegate to | function compLikeDelegate(ICompLike compLike, address to) external onlyOwner {
if (compLike.balanceOf(address(this)) > 0) {
compLike.delegate(to);
}
}
| function compLikeDelegate(ICompLike compLike, address to) external onlyOwner {
if (compLike.balanceOf(address(this)) > 0) {
compLike.delegate(to);
}
}
| 14,406 |
58 | // Note: the ERC-165 identifier for the ERC1363 token transfer0x4bbee2df ===bytes4(keccak256('transferAndCall(address,uint256)')) ^bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) / | bytes4 private constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
| bytes4 private constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
| 10,774 |
549 | // withdrawETHGainToTrove: - Triggers a LQTY issuance, based on time passed since the last issuance. The LQTY issuance is shared between all depositors and front ends - Sends all depositor's LQTY gain todepositor - Sends all tagged front end's LQTY gain to the tagged front end - Transfers the depositor's entire ETH gain from the Stability Pool to the caller's trove - Leaves their compounded deposit in the Stability Pool - Updates snapshots for deposit and tagged front end stake / | function withdrawETHGainToTrove(address _upperHint, address _lowerHint) external override {
uint initialDeposit = deposits[msg.sender].initialValue;
_requireUserHasDeposit(initialDeposit);
_requireUserHasTrove(msg.sender);
_requireUserHasETHGain(msg.sender);
ICommunityIssuance communityIssuanceCached = communityIssuance;
_triggerLQTYIssuance(communityIssuanceCached);
uint depositorETHGain = getDepositorETHGain(msg.sender);
uint compoundedLUSDDeposit = getCompoundedLUSDDeposit(msg.sender);
uint LUSDLoss = initialDeposit.sub(compoundedLUSDDeposit); // Needed only for event log
// First pay out any LQTY gains
address frontEnd = deposits[msg.sender].frontEndTag;
_payOutLQTYGains(communityIssuanceCached, msg.sender, frontEnd);
// Update front end stake
uint compoundedFrontEndStake = getCompoundedFrontEndStake(frontEnd);
uint newFrontEndStake = compoundedFrontEndStake;
_updateFrontEndStakeAndSnapshots(frontEnd, newFrontEndStake);
emit FrontEndStakeChanged(frontEnd, newFrontEndStake, msg.sender);
_updateDepositAndSnapshots(msg.sender, compoundedLUSDDeposit);
/* Emit events before transferring ETH gain to Trove.
This lets the event log make more sense (i.e. so it appears that first the ETH gain is withdrawn
and then it is deposited into the Trove, not the other way around). */
emit ETHGainWithdrawn(msg.sender, depositorETHGain, LUSDLoss);
emit UserDepositChanged(msg.sender, compoundedLUSDDeposit);
ETH = ETH.sub(depositorETHGain);
emit StabilityPoolETHBalanceUpdated(ETH);
emit EtherSent(msg.sender, depositorETHGain);
borrowerOperations.moveETHGainToTrove{ value: depositorETHGain }(msg.sender, _upperHint, _lowerHint);
}
| function withdrawETHGainToTrove(address _upperHint, address _lowerHint) external override {
uint initialDeposit = deposits[msg.sender].initialValue;
_requireUserHasDeposit(initialDeposit);
_requireUserHasTrove(msg.sender);
_requireUserHasETHGain(msg.sender);
ICommunityIssuance communityIssuanceCached = communityIssuance;
_triggerLQTYIssuance(communityIssuanceCached);
uint depositorETHGain = getDepositorETHGain(msg.sender);
uint compoundedLUSDDeposit = getCompoundedLUSDDeposit(msg.sender);
uint LUSDLoss = initialDeposit.sub(compoundedLUSDDeposit); // Needed only for event log
// First pay out any LQTY gains
address frontEnd = deposits[msg.sender].frontEndTag;
_payOutLQTYGains(communityIssuanceCached, msg.sender, frontEnd);
// Update front end stake
uint compoundedFrontEndStake = getCompoundedFrontEndStake(frontEnd);
uint newFrontEndStake = compoundedFrontEndStake;
_updateFrontEndStakeAndSnapshots(frontEnd, newFrontEndStake);
emit FrontEndStakeChanged(frontEnd, newFrontEndStake, msg.sender);
_updateDepositAndSnapshots(msg.sender, compoundedLUSDDeposit);
/* Emit events before transferring ETH gain to Trove.
This lets the event log make more sense (i.e. so it appears that first the ETH gain is withdrawn
and then it is deposited into the Trove, not the other way around). */
emit ETHGainWithdrawn(msg.sender, depositorETHGain, LUSDLoss);
emit UserDepositChanged(msg.sender, compoundedLUSDDeposit);
ETH = ETH.sub(depositorETHGain);
emit StabilityPoolETHBalanceUpdated(ETH);
emit EtherSent(msg.sender, depositorETHGain);
borrowerOperations.moveETHGainToTrove{ value: depositorETHGain }(msg.sender, _upperHint, _lowerHint);
}
| 10,535 |
1 | // Immutable, but accounts may revoke them (tracked in __revokedDefaultOperators). | mapping(address => bool) private _defaultOperators;
| mapping(address => bool) private _defaultOperators;
| 19,957 |
4 | // roundNum==1? round one is live. roundNum == 2? round two is live :) | uint public roundNum;
bool public burnMintActive;
bool public revealed;
| uint public roundNum;
bool public burnMintActive;
bool public revealed;
| 41,067 |
254 | // - get current protocol used | TokenProtocol[] memory tokenProtocols = _getCurrentProtocols();
| TokenProtocol[] memory tokenProtocols = _getCurrentProtocols();
| 35,907 |
58 | // / | contract Draw is Ownable, Pausable, Destructible {
using Address for address payable;
// Events
event Draw(address indexed drawer, uint32 pixel);
event Received(address indexed drawer, uint256 amount);
event Sent(address indexed receiver, uint256 amount);
// Storage
mapping(address => uint256) public pixelStats;
uint256 public startPrice;
// price 10000000000000 wei => 0.00001 eth
constructor(uint256 _startPrice) {
startPrice = _startPrice;
}
function draw(uint32[] memory _pixelsData) public payable {
for (uint j = 0; j < _pixelsData.length; j++) {
pixelStats[msg.sender] += 1;
emit Draw(msg.sender, _pixelsData[j]);
}
emit Received(msg.sender, msg.value);
}
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
function withdraw(address payable _receiver, uint256 _amount) external onlyOwner {
require(_receiver != address(0));
require(_amount > 0);
_receiver.sendValue(_amount);
emit Sent(_receiver, _amount);
}
}
| contract Draw is Ownable, Pausable, Destructible {
using Address for address payable;
// Events
event Draw(address indexed drawer, uint32 pixel);
event Received(address indexed drawer, uint256 amount);
event Sent(address indexed receiver, uint256 amount);
// Storage
mapping(address => uint256) public pixelStats;
uint256 public startPrice;
// price 10000000000000 wei => 0.00001 eth
constructor(uint256 _startPrice) {
startPrice = _startPrice;
}
function draw(uint32[] memory _pixelsData) public payable {
for (uint j = 0; j < _pixelsData.length; j++) {
pixelStats[msg.sender] += 1;
emit Draw(msg.sender, _pixelsData[j]);
}
emit Received(msg.sender, msg.value);
}
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
function withdraw(address payable _receiver, uint256 _amount) external onlyOwner {
require(_receiver != address(0));
require(_amount > 0);
_receiver.sendValue(_amount);
emit Sent(_receiver, _amount);
}
}
| 12,216 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.