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 |
|---|---|---|---|---|
218 | // Get the first order as the taker order | bytes memory takerOrder = _getOrder(orders, 0);
uint256 totalAmountBase = _getOrderAmountBase(takerOrder);
uint256 takerAmountBase = totalAmountBase.sub(orderFills[_getOrderHash(takerOrder)]);
uint256 fillAmountQuote = 0;
uint256 restAmountBase = takerAmountBase;
bool fBuy = _isOrderBuy(takerOrder);
| bytes memory takerOrder = _getOrder(orders, 0);
uint256 totalAmountBase = _getOrderAmountBase(takerOrder);
uint256 takerAmountBase = totalAmountBase.sub(orderFills[_getOrderHash(takerOrder)]);
uint256 fillAmountQuote = 0;
uint256 restAmountBase = takerAmountBase;
bool fBuy = _isOrderBuy(takerOrder);
| 32,134 |
149 | // ============ DPP Functions (create & reset) ============ |
function createDODOPrivatePool(
address baseToken,
address quoteToken,
uint256 baseInAmount,
uint256 quoteInAmount,
uint256 lpFeeRate,
uint256 i,
uint256 k,
bool isOpenTwap,
|
function createDODOPrivatePool(
address baseToken,
address quoteToken,
uint256 baseInAmount,
uint256 quoteInAmount,
uint256 lpFeeRate,
uint256 i,
uint256 k,
bool isOpenTwap,
| 15,786 |
22 | // Transfer tokens from one address to another _from address The address which you want to send tokens from _to address The address which you want to transfer to _value uint the amout of tokens to be transfered / | function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) public {
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// if (_value > _allowance) throw;
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
}
| function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) public {
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// if (_value > _allowance) throw;
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
}
| 12,063 |
21 | // Calculate the starting and ending time of the appointment (7 days from the current time) | uint256 startTime = block.timestamp;
uint256 endTime = startTime + 7 days;
| uint256 startTime = block.timestamp;
uint256 endTime = startTime + 7 days;
| 23,351 |
18 | // contest over, refund anything paid | msg.sender.transfer(msg.value);
lastPot=this.balance;
_stalemateTransfer();
lastBidTime=0;
_resetTiles();
_setNewStartTime();
return true;
| msg.sender.transfer(msg.value);
lastPot=this.balance;
_stalemateTransfer();
lastBidTime=0;
_resetTiles();
_setNewStartTime();
return true;
| 11,834 |
340 | // Calculate tan(x). May overflow for large results. May throw if tan(x)would be infinite, or return an approximation, or overflow. / | function tan(int256 realArg) internal pure returns (int256) {
return div(sin(realArg), cos(realArg));
}
| function tan(int256 realArg) internal pure returns (int256) {
return div(sin(realArg), cos(realArg));
}
| 35,464 |
29 | // 获取用户未取回的GDX staking收益 | function pendingGDXUser(address _user) public view returns (uint256) {
// pool 0
// staking bonus
UserInfo storage user = userInfo[_user];
PoolInfo storage pool = poolInfo[0];
uint256 stakingBonus;
uint256 accGDXRate = pool.accGDXPerShare;
uint256 totalShares = pool.totalShares;
if (totalShares == 0) {
stakingBonus = 0;
} else if (block.number > pool.lastRewardBlock) {
require(block.number >= pool.lastRewardBlock, "pendingGDXUser failed!");
uint256 multiplier = block.number.sub(pool.lastRewardBlock);
uint256 gdxReward = multiplier.mul(gdxPerBlock).div(90); // 区块产出的90%
accGDXRate = accGDXRate.add(gdxReward.mul(1e12).div(totalShares));
uint256 reward = user.shares.mul(accGDXRate).div(1e12);
require(reward >= user.rewardDebt, 'reward < user.rewardDebt');
stakingBonus = reward.sub(user.rewardDebt);
}
// pool 1
// mine pool bonus
uint256 pid;
bool isPoolOwner;
(pid, isPoolOwner) = getUserMinePoolID(_user);
if (pid == 0 || !isPoolOwner) { // 不是矿主
return stakingBonus;
}
pool = poolInfo[1];
UserMinePool storage mingPoolUser = userMinePoolInfo[_user];
uint256 miningPoolBonus = 0;
accGDXRate = pool.accGDXPerShare;
totalShares = pool.totalShares;
if (totalShares == 0) {
miningPoolBonus = 0;
} else if (block.number > pool.lastRewardBlock) {
uint256 multiplier = block.number.sub(pool.lastRewardBlock);
uint256 gdxReward = multiplier.mul(gdxPerBlock).div(10); // 区块产出的10%
accGDXRate = accGDXRate.add(gdxReward.mul(1e12).div(totalShares));
uint256 reward = mingPoolUser.shares.mul(accGDXRate).div(1e12);
require(reward >= mingPoolUser.rewardDebt, 'reward < user.rewardDebt');
miningPoolBonus = reward.sub(mingPoolUser.rewardDebt);
}
return stakingBonus.add(miningPoolBonus);
}
| function pendingGDXUser(address _user) public view returns (uint256) {
// pool 0
// staking bonus
UserInfo storage user = userInfo[_user];
PoolInfo storage pool = poolInfo[0];
uint256 stakingBonus;
uint256 accGDXRate = pool.accGDXPerShare;
uint256 totalShares = pool.totalShares;
if (totalShares == 0) {
stakingBonus = 0;
} else if (block.number > pool.lastRewardBlock) {
require(block.number >= pool.lastRewardBlock, "pendingGDXUser failed!");
uint256 multiplier = block.number.sub(pool.lastRewardBlock);
uint256 gdxReward = multiplier.mul(gdxPerBlock).div(90); // 区块产出的90%
accGDXRate = accGDXRate.add(gdxReward.mul(1e12).div(totalShares));
uint256 reward = user.shares.mul(accGDXRate).div(1e12);
require(reward >= user.rewardDebt, 'reward < user.rewardDebt');
stakingBonus = reward.sub(user.rewardDebt);
}
// pool 1
// mine pool bonus
uint256 pid;
bool isPoolOwner;
(pid, isPoolOwner) = getUserMinePoolID(_user);
if (pid == 0 || !isPoolOwner) { // 不是矿主
return stakingBonus;
}
pool = poolInfo[1];
UserMinePool storage mingPoolUser = userMinePoolInfo[_user];
uint256 miningPoolBonus = 0;
accGDXRate = pool.accGDXPerShare;
totalShares = pool.totalShares;
if (totalShares == 0) {
miningPoolBonus = 0;
} else if (block.number > pool.lastRewardBlock) {
uint256 multiplier = block.number.sub(pool.lastRewardBlock);
uint256 gdxReward = multiplier.mul(gdxPerBlock).div(10); // 区块产出的10%
accGDXRate = accGDXRate.add(gdxReward.mul(1e12).div(totalShares));
uint256 reward = mingPoolUser.shares.mul(accGDXRate).div(1e12);
require(reward >= mingPoolUser.rewardDebt, 'reward < user.rewardDebt');
miningPoolBonus = reward.sub(mingPoolUser.rewardDebt);
}
return stakingBonus.add(miningPoolBonus);
}
| 23,615 |
221 | // maxNumber | uint8 public maxNumber;
| uint8 public maxNumber;
| 42,841 |
78 | // Internal function to transfer ownership of a given token ID to another address.As opposed to transferFrom, this imposes no restrictions on msg.sender. from current owner of the token to address to receive the ownership of the given token ID tokenId uint256 ID of the token to be transferred / | function _transferFrom(address from, address to, uint256 tokenId) internal {
require(ownerOf(tokenId) == from);
require(to != address(0));
_clearApproval(tokenId);
_ownedTokensCount[from].decrement();
_ownedTokensCount[to].increment();
_tokenOwner[tokenId] = to;
emit Transfer(from, to, tokenId);
}
| function _transferFrom(address from, address to, uint256 tokenId) internal {
require(ownerOf(tokenId) == from);
require(to != address(0));
_clearApproval(tokenId);
_ownedTokensCount[from].decrement();
_ownedTokensCount[to].increment();
_tokenOwner[tokenId] = to;
emit Transfer(from, to, tokenId);
}
| 13,390 |
8 | // check if other stashes are also active, and if so, send to arbitratordo this here because processStash will have tokens from the arbitrator | uint256 activeCount = IRewardFactory(rewardFactory).activeRewardCount(token);
if(activeCount > 1){
| uint256 activeCount = IRewardFactory(rewardFactory).activeRewardCount(token);
if(activeCount > 1){
| 47,301 |
4 | // Define Tokens | wildToken=0x08A75dbC7167714CeaC1a8e43a8d643A4EDd625a;
dai=0x6B175474E89094C44Da98b954EedeAC495271d0F;
axs=0xBB0E17EF65F82Ab018d8EDd776e8DD940327B28b;
uni=0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984;
link=0x514910771AF9Ca656af840dff83E8264EcF986CA;
wbtc=0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;
aave=0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9;
matic=0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0;
comp=0xc00e94Cb662C3520282E6f5717214004A7f26888;
mkr=0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2;
| wildToken=0x08A75dbC7167714CeaC1a8e43a8d643A4EDd625a;
dai=0x6B175474E89094C44Da98b954EedeAC495271d0F;
axs=0xBB0E17EF65F82Ab018d8EDd776e8DD940327B28b;
uni=0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984;
link=0x514910771AF9Ca656af840dff83E8264EcF986CA;
wbtc=0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;
aave=0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9;
matic=0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0;
comp=0xc00e94Cb662C3520282E6f5717214004A7f26888;
mkr=0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2;
| 1,065 |
106 | // Check user is claiming the correct bracket | require(rewardForTicketId != 0, "No prize for this bracket");
if (_brackets[i] != 5) {
require(
_calculateRewardsForTicketId(_lotteryId, thisTicketId, _brackets[i] + 1) == 0,
"Bracket must be higher"
);
}
| require(rewardForTicketId != 0, "No prize for this bracket");
if (_brackets[i] != 5) {
require(
_calculateRewardsForTicketId(_lotteryId, thisTicketId, _brackets[i] + 1) == 0,
"Bracket must be higher"
);
}
| 9,133 |
801 | // https:etherscan.io/address/0x05a9CBe762B36632b3594DA4F082340E0e5343e8 | TokenState public constant tokenstatesusd_i = TokenState(0x05a9CBe762B36632b3594DA4F082340E0e5343e8);
| TokenState public constant tokenstatesusd_i = TokenState(0x05a9CBe762B36632b3594DA4F082340E0e5343e8);
| 29,626 |
0 | // This helper function just returns the pointed publication if the passed publication is a mirror,otherwise it returns the passed publication.profileId The token ID of the profile that published the given publication. pubId The publication ID of the given publication. _pubByIdByProfile A pointer to the storage mapping of publications by pubId by profile ID. return tuple First, the pointed publication's publishing profile ID, second, the pointed publication's ID, and third, thepointed publication's collect module. If the passed publication is not a mirror, this returns the given publication. / | function getPointedIfMirror(
uint256 profileId,
uint256 pubId,
mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))
storage _pubByIdByProfile
)
internal
view
returns (
uint256,
| function getPointedIfMirror(
uint256 profileId,
uint256 pubId,
mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))
storage _pubByIdByProfile
)
internal
view
returns (
uint256,
| 10,868 |
182 | // Admin function - lock rewards for given rhoToken until a specific block rhoToken address of the rhoToken contract lockEndBlock lock rewards until specific block no. / | function setTimeLockEndBlock(address rhoToken, uint256 lockEndBlock) external;
| function setTimeLockEndBlock(address rhoToken, uint256 lockEndBlock) external;
| 79,837 |
8 | // update winnerCandidate | function getWinner() public returns(uint) {
uint max = 0;
for(uint i = 0; i < candidates.length; i++)
if(candidates[i].voteCount > max)
{
max = candidates[i].voteCount;
winnerCandidate = i;
}
return winnerCandidate;
}
| function getWinner() public returns(uint) {
uint max = 0;
for(uint i = 0; i < candidates.length; i++)
if(candidates[i].voteCount > max)
{
max = candidates[i].voteCount;
winnerCandidate = i;
}
return winnerCandidate;
}
| 29,952 |
176 | // The USDB TOKEN! | UsdbToken public usdb;
| UsdbToken public usdb;
| 33,046 |
38 | // address(this) tries to challenge, but should fail | _groupRouter.challenge(address(_group), defaultMarketIdentifier, 0, 32 * 10 ** 18); // address(this)
| _groupRouter.challenge(address(_group), defaultMarketIdentifier, 0, 32 * 10 ** 18); // address(this)
| 1,658 |
4,018 | // 2010 | entry "astrakhaned" : ENG_ADJECTIVE
| entry "astrakhaned" : ENG_ADJECTIVE
| 18,622 |
2 | // 当前期奖金 | function current() external view returns (uint256);
| function current() external view returns (uint256);
| 55,093 |
646 | // Frees the position and recovers the collateral in the vat registry | EndLike(end).free(ilk);
| EndLike(end).free(ilk);
| 12,070 |
392 | // returns specific pool's data / | function poolData(Token pool) external view returns (Pool memory);
| function poolData(Token pool) external view returns (Pool memory);
| 31,372 |
127 | // real | address public ACE = 0x06147110022B768BA8F99A8f385df11a151A9cc8;
| address public ACE = 0x06147110022B768BA8F99A8f385df11a151A9cc8;
| 38,251 |
607 | // this is 721 version. in 20 or 1155 will use the same format but different interpretation wallet = 0 mean any tokenID = 0 mean next amount will overide tokenID denominatedAsset = 0 mean chain token (e.g. eth) chainID is to prevent replay attack |
function hash(
address wallet,
uint256 amount,
uint256 tokenID,
uint256 nonce,
uint256 pricePerUnit,
address denominatedAsset,
address refPorject,
uint256 chainID
|
function hash(
address wallet,
uint256 amount,
uint256 tokenID,
uint256 nonce,
uint256 pricePerUnit,
address denominatedAsset,
address refPorject,
uint256 chainID
| 11,418 |
12 | // Event emitted when set broker allowance | event BrokerApprove(uint16 indexed tokenId, address indexed owner, address indexed spender, uint128 amount);
| event BrokerApprove(uint16 indexed tokenId, address indexed owner, address indexed spender, uint128 amount);
| 28,753 |
18 | // Returns true if the current user has an oustanding withdrawal. / | function hasOutstandingWithdrawal(address _address)
public
view
returns (bool)
| function hasOutstandingWithdrawal(address _address)
public
view
returns (bool)
| 23,558 |
21 | // set the product timestamp record to recognize the action and emit the appropriate product event | if (isNew) {
| if (isNew) {
| 41,425 |
24 | // Destroy tokens from other account Remove `_value` tokens from the system irreversibly on behalf of `_from`._from the address of the sender _value the amount of money to burn / | function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
| function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
| 8,824 |
27 | // Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise. dataHash Hash of the data (could be either a message hash or transaction hash) data That should be signed (this is passed to an external validator contract) signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash. / | function checkSignatures(
bytes32 dataHash,
bytes memory data,
bytes memory signatures
| function checkSignatures(
bytes32 dataHash,
bytes memory data,
bytes memory signatures
| 27,067 |
141 | // Can only claim once | if (stakeDetails.achievementClaimed == _TRUE8) {
revert AchievementAlreadyClaimed();
}
| if (stakeDetails.achievementClaimed == _TRUE8) {
revert AchievementAlreadyClaimed();
}
| 26,706 |
49 | // Safe xtt transfer function, just in case if rounding error causes pool to not have enough XTTs. | function safeXttTransfer(address _to, uint256 _amount) internal {
xtt.safeTransfer(_to, _amount);
}
| function safeXttTransfer(address _to, uint256 _amount) internal {
xtt.safeTransfer(_to, _amount);
}
| 2,715 |
67 | // Returns the number of decimals used to get its user representation.For example, if `decimals` equals `2`, a balance of `505` tokens shouldbe displayed to a user as `5,05` (`505 / 102`). Tokens usually opt for a value of 18, imitating the relationship between | * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
| * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
| 39,491 |
0 | // Initializes Curve BTC Zap. / | function initialize() public initializer {
governance = msg.sender;
IERC20Upgradeable(BADGER_RENCRV).approve(BADGER_RENCRV_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_SBTCCRV).approve(BADGER_SBTCCRV_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_TBTCCRV).approve(BADGER_TBTCCRV_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_HRENCRV).approve(BADGER_HRENCRV_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_RENCRV_PLUS).approve(CURVE_BTC_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_SBTCCRV_PLUS).approve(CURVE_BTC_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_TBTCCRV_PLUS).approve(CURVE_BTC_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_HRENCRV_PLUS).approve(CURVE_BTC_PLUS, uint256(int256(-1)));
}
| function initialize() public initializer {
governance = msg.sender;
IERC20Upgradeable(BADGER_RENCRV).approve(BADGER_RENCRV_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_SBTCCRV).approve(BADGER_SBTCCRV_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_TBTCCRV).approve(BADGER_TBTCCRV_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_HRENCRV).approve(BADGER_HRENCRV_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_RENCRV_PLUS).approve(CURVE_BTC_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_SBTCCRV_PLUS).approve(CURVE_BTC_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_TBTCCRV_PLUS).approve(CURVE_BTC_PLUS, uint256(int256(-1)));
IERC20Upgradeable(BADGER_HRENCRV_PLUS).approve(CURVE_BTC_PLUS, uint256(int256(-1)));
}
| 37,175 |
23 | // Deduct the contribution now to protect against recursive calls | contributions[_contributerAddress] = 0;
| contributions[_contributerAddress] = 0;
| 41,082 |
34 | // Disable Chainlink address for the input of the current available pool value | function disableChainlink() public onlyOwner whenPaused {
chainlinkEnabled = false;
}
| function disableChainlink() public onlyOwner whenPaused {
chainlinkEnabled = false;
}
| 28,533 |
1 | // Strings String operations. / | library Strings {
/**
* @dev Converts a `uint256` to a `string`.
* via OraclizeAPI - MIT licence
* https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
*/
function fromUint256(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
uint256 index = digits - 1;
temp = value;
while (temp != 0) {
buffer[index--] = byte(uint8(48 + temp % 10));
temp /= 10;
}
return string(buffer);
}
} | library Strings {
/**
* @dev Converts a `uint256` to a `string`.
* via OraclizeAPI - MIT licence
* https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
*/
function fromUint256(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
uint256 index = digits - 1;
temp = value;
while (temp != 0) {
buffer[index--] = byte(uint8(48 + temp % 10));
temp /= 10;
}
return string(buffer);
}
} | 16,446 |
115 | // Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a Snapshot struct, but that would impede usage of functions that work on an array. | struct Snapshots {
uint256[] ids;
uint256[] values;
}
| struct Snapshots {
uint256[] ids;
uint256[] values;
}
| 9,623 |
50 | // 0xE2: The request is rejected on the grounds that it may cause the submitter to spend or stake an/ amount of value that is unjustifiably high when compared with the reward they will be getting | BridgeOversizedResult,
| BridgeOversizedResult,
| 24,495 |
49 | // Keep a reference to the number of beneficiaries there are to mint for. | uint256 _numberOfBeneficiaries = _mintForTiersData.length;
for (uint256 _i; _i < _numberOfBeneficiaries; ) {
| uint256 _numberOfBeneficiaries = _mintForTiersData.length;
for (uint256 _i; _i < _numberOfBeneficiaries; ) {
| 25,310 |
14 | // Meta data for edition | mapping(uint256 => string) metadataJson;
| mapping(uint256 => string) metadataJson;
| 75,433 |
215 | // If there are no fees to pay then exit early. | if (totalPaid.isEqual(0)) {
return totalPaid;
}
| if (totalPaid.isEqual(0)) {
return totalPaid;
}
| 29,256 |
226 | // lock function _amount the amount to lock _period the locking period _locker the locker _numerator price numerator _denominator price denominatorreturn lockingId / | function _lock(
uint256 _amount,
uint256 _period,
address _locker,
uint256 _numerator,
uint256 _denominator,
bytes32 _agreementHash)
internal
onlyAgree(_agreementHash)
returns(bytes32 lockingId)
| function _lock(
uint256 _amount,
uint256 _period,
address _locker,
uint256 _numerator,
uint256 _denominator,
bytes32 _agreementHash)
internal
onlyAgree(_agreementHash)
returns(bytes32 lockingId)
| 34,050 |
142 | // set Staked amount | Staked[sender] = _amount;
| Staked[sender] = _amount;
| 42,735 |
8 | // TODO add a clear function in EnumMap and EnumSet and use it | (bytes32 token, ) = tokenPrices.at(0);
tokenPrices.remove(token);
| (bytes32 token, ) = tokenPrices.at(0);
tokenPrices.remove(token);
| 30,255 |
49 | // This is to accomodate for the wTc contract being considered as a holder. Due to the nature of the wrapper, the numholders is+1. /Having an extra holder adds a buffer of funds in the contract | if(adjustforcontract==true)
{
numholders = numholders - 1;
}
| if(adjustforcontract==true)
{
numholders = numholders - 1;
}
| 56,952 |
52 | // KizunaLPBurn This contract burns $KIZUNA UNI-V3-POS LP NFT on receipt.KIZUNA tokens collected from LP fees are burnt to 0xdEaD.WETH collected is transferred to teh $KIZUNA deployer. / | contract KizunaLPBurn is IERC721Receiver {
address public caller;
INonfungiblePositionManager public v3PositionManagerContract;
IUniswapV3Pool public kizuPool;
address internal zeroXdEaD = 0x000000000000000000000000000000000000dEaD;
IERC20 public KIZUNA;
IERC20 public WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
event Collection(uint256 token0Amount, uint256 token1Amount);
struct Deposit {
address owner;
uint128 liquidity;
address token0;
address token1;
}
modifier onlyCaller() {
require(msg.sender == caller, "Only teh caller");
_;
}
constructor(address _token0, address _v3PositionManagerContract, address _pool) {
KIZUNA = IERC20(_token0);
v3PositionManagerContract = INonfungiblePositionManager(_v3PositionManagerContract);
kizuPool = IUniswapV3Pool(_pool);
caller = msg.sender;
}
/// @dev deposits[tokenId] => Deposit
mapping(uint256 => Deposit) public deposits;
// Implementing `onERC721Received` so this contract can receive custody of erc721 tokens
function onERC721Received(
address operator,
address,
uint256 tokenId,
bytes calldata
) external override returns (bytes4) {
// get position information
_createDeposit(operator, tokenId);
return this.onERC721Received.selector;
}
function _createDeposit(address owner, uint256 tokenId) internal {
(, , address _token0, address _token1, , , , uint128 liquidity, , , , ) =
v3PositionManagerContract.positions(tokenId);
deposits[tokenId] = Deposit({owner: owner, liquidity: liquidity, token0: _token0, token1: _token1});
}
function retrieve(uint256 _tokenId) external onlyCaller {
INonfungiblePositionManager.CollectParams memory params =
INonfungiblePositionManager.CollectParams({
tokenId: _tokenId,
recipient: address(this),
amount0Max: type(uint128).max,
amount1Max: type(uint128).max
});
(uint256 amount0, uint256 amount1) = v3PositionManagerContract.collect(params);
emit Collection(amount0, amount1);
_distribute();
}
function _distribute() internal {
uint256 kizuToBurn = IERC20(KIZUNA).balanceOf(address(this));
uint256 wethToTransfer = IERC20(WETH).balanceOf(address(this));
KIZUNA.transfer(zeroXdEaD, kizuToBurn);
// Unwrap
IWETH(address(WETH)).withdraw(wethToTransfer);
uint256 ethBal = address(this).balance;
payable(caller).transfer(ethBal);
}
function estimateUncollectedFees(uint256 _tokenId) external view returns (uint256, uint256) {
( , , , , , , , uint128 liquidity, uint256 inside0, uint256 inside1, , ) = v3PositionManagerContract.positions(_tokenId);
uint256 global0 = kizuPool.feeGrowthGlobal0X128();
uint256 global1 = kizuPool.feeGrowthGlobal1X128();
uint256 deltaFeeGrowth0 = global0 - inside0;
uint256 deltaFeeGrowth1 = global1 - inside1;
uint256 uncollectedFees0 = (deltaFeeGrowth0 * liquidity) >> 128;
uint256 uncollectedFees1 = (deltaFeeGrowth1 * liquidity) >> 128;
return (uncollectedFees0, uncollectedFees1);
}
function changeCaller(address newCaller) external onlyCaller {
require(newCaller != address(0), "zero address");
caller = newCaller;
}
// unstuck weth
function rescueWeth() external onlyCaller {
uint256 wethBalance = WETH.balanceOf(address(this));
WETH.transfer(caller, wethBalance);
}
// unstuck eth
function rescueEther() external onlyCaller {
uint256 balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
receive () external payable {}
} | contract KizunaLPBurn is IERC721Receiver {
address public caller;
INonfungiblePositionManager public v3PositionManagerContract;
IUniswapV3Pool public kizuPool;
address internal zeroXdEaD = 0x000000000000000000000000000000000000dEaD;
IERC20 public KIZUNA;
IERC20 public WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
event Collection(uint256 token0Amount, uint256 token1Amount);
struct Deposit {
address owner;
uint128 liquidity;
address token0;
address token1;
}
modifier onlyCaller() {
require(msg.sender == caller, "Only teh caller");
_;
}
constructor(address _token0, address _v3PositionManagerContract, address _pool) {
KIZUNA = IERC20(_token0);
v3PositionManagerContract = INonfungiblePositionManager(_v3PositionManagerContract);
kizuPool = IUniswapV3Pool(_pool);
caller = msg.sender;
}
/// @dev deposits[tokenId] => Deposit
mapping(uint256 => Deposit) public deposits;
// Implementing `onERC721Received` so this contract can receive custody of erc721 tokens
function onERC721Received(
address operator,
address,
uint256 tokenId,
bytes calldata
) external override returns (bytes4) {
// get position information
_createDeposit(operator, tokenId);
return this.onERC721Received.selector;
}
function _createDeposit(address owner, uint256 tokenId) internal {
(, , address _token0, address _token1, , , , uint128 liquidity, , , , ) =
v3PositionManagerContract.positions(tokenId);
deposits[tokenId] = Deposit({owner: owner, liquidity: liquidity, token0: _token0, token1: _token1});
}
function retrieve(uint256 _tokenId) external onlyCaller {
INonfungiblePositionManager.CollectParams memory params =
INonfungiblePositionManager.CollectParams({
tokenId: _tokenId,
recipient: address(this),
amount0Max: type(uint128).max,
amount1Max: type(uint128).max
});
(uint256 amount0, uint256 amount1) = v3PositionManagerContract.collect(params);
emit Collection(amount0, amount1);
_distribute();
}
function _distribute() internal {
uint256 kizuToBurn = IERC20(KIZUNA).balanceOf(address(this));
uint256 wethToTransfer = IERC20(WETH).balanceOf(address(this));
KIZUNA.transfer(zeroXdEaD, kizuToBurn);
// Unwrap
IWETH(address(WETH)).withdraw(wethToTransfer);
uint256 ethBal = address(this).balance;
payable(caller).transfer(ethBal);
}
function estimateUncollectedFees(uint256 _tokenId) external view returns (uint256, uint256) {
( , , , , , , , uint128 liquidity, uint256 inside0, uint256 inside1, , ) = v3PositionManagerContract.positions(_tokenId);
uint256 global0 = kizuPool.feeGrowthGlobal0X128();
uint256 global1 = kizuPool.feeGrowthGlobal1X128();
uint256 deltaFeeGrowth0 = global0 - inside0;
uint256 deltaFeeGrowth1 = global1 - inside1;
uint256 uncollectedFees0 = (deltaFeeGrowth0 * liquidity) >> 128;
uint256 uncollectedFees1 = (deltaFeeGrowth1 * liquidity) >> 128;
return (uncollectedFees0, uncollectedFees1);
}
function changeCaller(address newCaller) external onlyCaller {
require(newCaller != address(0), "zero address");
caller = newCaller;
}
// unstuck weth
function rescueWeth() external onlyCaller {
uint256 wethBalance = WETH.balanceOf(address(this));
WETH.transfer(caller, wethBalance);
}
// unstuck eth
function rescueEther() external onlyCaller {
uint256 balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
receive () external payable {}
} | 25,588 |
45 | // Forever invalidate the given proof._proof the AZTEC proof object/ | function invalidateProof(uint24 _proof) external;
| function invalidateProof(uint24 _proof) external;
| 31,712 |
10 | // Calculate the shares to mint, new price per share, and currentShareSupply is the total supply of shares currentBalance is the total balance of the vault vaultParams is the struct with vault general data vaultState is the struct with vault accounting statereturn newLockedAmount is the amount of funds to allocate for the new roundreturn queuedWithdrawAmount is the amount of funds set aside for withdrawalreturn newPricePerShare is the price per share of the new roundreturn mintShares is the amount of shares to mint from deposits / | function rollover(
uint256 currentShareSupply,
uint256 currentBalance,
Vault.VaultParams calldata vaultParams,
Vault.VaultState calldata vaultState
)
external
pure
returns (
uint256 newLockedAmount,
| function rollover(
uint256 currentShareSupply,
uint256 currentBalance,
Vault.VaultParams calldata vaultParams,
Vault.VaultState calldata vaultState
)
external
pure
returns (
uint256 newLockedAmount,
| 30,857 |
112 | // sell | if (
!_inSwapAndLiquify &&
_tradingOpen &&
(to == uniswapV2Pair || _isUniswapPair[to])
) {
uint256 _contractTokenBalance = balanceOf(address(this));
if (_contractTokenBalance > 0) {
if (
_contractTokenBalance > balanceOf(uniswapV2Pair).mul(feeRate).div(100)
) {
| if (
!_inSwapAndLiquify &&
_tradingOpen &&
(to == uniswapV2Pair || _isUniswapPair[to])
) {
uint256 _contractTokenBalance = balanceOf(address(this));
if (_contractTokenBalance > 0) {
if (
_contractTokenBalance > balanceOf(uniswapV2Pair).mul(feeRate).div(100)
) {
| 55,628 |
9 | // Event emitted whenever the cid is updated. | event MetadataUpdate();
| event MetadataUpdate();
| 2,595 |
131 | // Splits the slice, setting `self` to everything after the first occurrence of `needle`, and `token` to everything before it. If `needle` does not occur in `self`, `self` is set to the empty slice, and `token` is set to the entirety of `self`. self The slice to split. needle The text to search for in `self`. token An output parameter to which the first token is written.return `token`. / | function split(
slice memory self,
slice memory needle,
slice memory token
| function split(
slice memory self,
slice memory needle,
slice memory token
| 33,187 |
94 | // } | _balances[id][to] += amount;
| _balances[id][to] += amount;
| 13,011 |
76 | // get the previous average rate and its update-time | uint256 prevAverageRateT = decodeAverageRateT(averageRateInfoData);
uint256 prevAverageRateN = decodeAverageRateN(averageRateInfoData);
uint256 prevAverageRateD = decodeAverageRateD(averageRateInfoData);
| uint256 prevAverageRateT = decodeAverageRateT(averageRateInfoData);
uint256 prevAverageRateN = decodeAverageRateN(averageRateInfoData);
uint256 prevAverageRateD = decodeAverageRateD(averageRateInfoData);
| 8,049 |
1 | // Mapping from collection and socicalType to groupId | mapping(string => mapping(uint256 => uint256)) public _groupIdForCollection;
| mapping(string => mapping(uint256 => uint256)) public _groupIdForCollection;
| 22,484 |
316 | // prefix mean: false - negative, true - positive |
if(positionType == 1) {
if(initialPrice<=currentPrice) {
return (SafeMath.mul(SafeMath.sub(SafeMath.div(10**decimal,initialPrice), SafeMath.div(10**decimal,currentPrice)),amount), true);
} else {
|
if(positionType == 1) {
if(initialPrice<=currentPrice) {
return (SafeMath.mul(SafeMath.sub(SafeMath.div(10**decimal,initialPrice), SafeMath.div(10**decimal,currentPrice)),amount), true);
} else {
| 43,515 |
6 | // We found a loop in the delegation, not allowed. | require(to != msg.sender, "Found loop in delegation.");
| require(to != msg.sender, "Found loop in delegation.");
| 4,222 |
148 | // BLINKLESS ADDITION: TRACK OWNERSHIP | uint i = 0;
while(i < quantity){
uint tokenId = i + _currentIndex;
_addressData[to].tokenIds.push(uint16(tokenId));
i++;
}
| uint i = 0;
while(i < quantity){
uint tokenId = i + _currentIndex;
_addressData[to].tokenIds.push(uint16(tokenId));
i++;
}
| 48,714 |
24 | // allows execution only when reporting is enabled | modifier reportingAllowed {
_reportingAllowed();
_;
}
| modifier reportingAllowed {
_reportingAllowed();
_;
}
| 10,624 |
144 | // numerators[0] = point - trace_generator^(trace_length - 1). |
mstore(0x1040,
addmod(point, sub(PRIME, /*trace_generator^(trace_length - 1)*/ mload(0xf60)), PRIME))
|
mstore(0x1040,
addmod(point, sub(PRIME, /*trace_generator^(trace_length - 1)*/ mload(0xf60)), PRIME))
| 927 |
11 | // return Math.min(block.timestamp, periodFinish); | return block.timestamp < periodFinish ? block.timestamp : periodFinish;
| return block.timestamp < periodFinish ? block.timestamp : periodFinish;
| 72,632 |
137 | // Worker | address payable worker;
| address payable worker;
| 16,154 |
263 | // calculate gen share | uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
| uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
| 31,712 |
46 | // Returns the granularity/Granularity concept is similar to the one described by EIP777/ return granularity_ Granularity of the ETF token | function granularity() external view returns(uint256) { return granularity_; }
/// @notice Creates ETF tokens in exchange for underlying tokens. Before
/// calling, underlying tokens must be approved to be moved by the ETF Token
/// contract. The amount of approved tokens required depends on
/// baseUnitsToCreate.
/// @dev If any underlying tokens' `transferFrom` fails (eg. the token is
/// frozen), create will no longer work. At this point a token upgrade will
/// be necessary.
/// @param baseUnitsToCreate Number of base units to create
function create(uint256 baseUnitsToCreate)
external
whenNotPaused()
requireNonZero(baseUnitsToCreate)
requireMultiple(baseUnitsToCreate)
{
// Check overflow
require((totalSupply_ + baseUnitsToCreate) > totalSupply_);
for (uint8 i = 0; i < tokens.length; i++) {
TokenInfo memory tokenInfo = tokens[i];
ERC20 erc20 = ERC20(tokenInfo.addr);
transferUnderlyingTokensWhenCreate(erc20, tokenInfo.tokenUnits, baseUnitsToCreate);
}
mint(msg.sender, baseUnitsToCreate);
}
| function granularity() external view returns(uint256) { return granularity_; }
/// @notice Creates ETF tokens in exchange for underlying tokens. Before
/// calling, underlying tokens must be approved to be moved by the ETF Token
/// contract. The amount of approved tokens required depends on
/// baseUnitsToCreate.
/// @dev If any underlying tokens' `transferFrom` fails (eg. the token is
/// frozen), create will no longer work. At this point a token upgrade will
/// be necessary.
/// @param baseUnitsToCreate Number of base units to create
function create(uint256 baseUnitsToCreate)
external
whenNotPaused()
requireNonZero(baseUnitsToCreate)
requireMultiple(baseUnitsToCreate)
{
// Check overflow
require((totalSupply_ + baseUnitsToCreate) > totalSupply_);
for (uint8 i = 0; i < tokens.length; i++) {
TokenInfo memory tokenInfo = tokens[i];
ERC20 erc20 = ERC20(tokenInfo.addr);
transferUnderlyingTokensWhenCreate(erc20, tokenInfo.tokenUnits, baseUnitsToCreate);
}
mint(msg.sender, baseUnitsToCreate);
}
| 45,445 |
2 | // Inquire about using an index instead of hashed ID to prevent any chance of collision | struct IntakeStruct {
bytes8 id;
Base base;
}
| struct IntakeStruct {
bytes8 id;
Base base;
}
| 17,720 |
4 | // Burn the option tokens equivalent to the underlying requested | _burn(msg.sender, amountOfOptions);
| _burn(msg.sender, amountOfOptions);
| 71,414 |
14 | // Setup token contract address on attached proxy contract.Only allowed if token contract is already owned by this interactor._token Ownable token address. / | function setTokenOnProxy(Ownable _token) public onlyOwner {
require(Ownable(_token).owner() == address(this), "Interactor not owner of token");
ProxyInterface(proxy).setToken(_token);
}
| function setTokenOnProxy(Ownable _token) public onlyOwner {
require(Ownable(_token).owner() == address(this), "Interactor not owner of token");
ProxyInterface(proxy).setToken(_token);
}
| 24,371 |
29 | // Event which allows for logging of frozen token transfer activities. | event FrozenTokensTransferred(
address owner,
address recipient,
uint256 frozenAmount,
uint256 defrostingRate);
| event FrozenTokensTransferred(
address owner,
address recipient,
uint256 frozenAmount,
uint256 defrostingRate);
| 58,675 |
33 | // Check tx is sending funds to an operator. | bytes20 outputPublicKeyHash = parseP2PKHOutputScript(txBytes, operatorScriptStart, operatorScriptLength);
require(outputPublicKeyHash == expectedOperatorPKH, "The first tx output does not have a P2PKH output script for an operator.");
| bytes20 outputPublicKeyHash = parseP2PKHOutputScript(txBytes, operatorScriptStart, operatorScriptLength);
require(outputPublicKeyHash == expectedOperatorPKH, "The first tx output does not have a P2PKH output script for an operator.");
| 38,068 |
427 | // If no money left to apply, or don't need any changes, return the original amounts | if (amountRemaining == 0 || desiredAmount == 0) {
return (amountRemaining, currentSharePrice);
}
| if (amountRemaining == 0 || desiredAmount == 0) {
return (amountRemaining, currentSharePrice);
}
| 15,302 |
65 | // chutiapa below function bookALab( uint256 _labID,string memory _testType,string memory _testName,string memory phoneNumber,string memory time,string memory date,string memory _cost, string memory _promoCode | // ) public payable {
// address user = msg.sender;
// }
| // ) public payable {
// address user = msg.sender;
// }
| 30,126 |
136 | // Split the contract balance into halves | uint256 denominator = (buyFee.liquidity +
sellFee.liquidity +
buyFee.marketing +
sellFee.marketing +
buyFee.dev +
sellFee.dev) * 2;
uint256 tokensToAddLiquidityWith = (tokens *
(buyFee.liquidity + sellFee.liquidity)) / denominator;
uint256 toSwap = tokens - tokensToAddLiquidityWith;
| uint256 denominator = (buyFee.liquidity +
sellFee.liquidity +
buyFee.marketing +
sellFee.marketing +
buyFee.dev +
sellFee.dev) * 2;
uint256 tokensToAddLiquidityWith = (tokens *
(buyFee.liquidity + sellFee.liquidity)) / denominator;
uint256 toSwap = tokens - tokensToAddLiquidityWith;
| 2,790 |
75 | // key for the max decrease position impact factor | bytes32 public constant MAX_POSITION_IMPACT_FACTOR = keccak256(abi.encode("MAX_POSITION_IMPACT_FACTOR"));
| bytes32 public constant MAX_POSITION_IMPACT_FACTOR = keccak256(abi.encode("MAX_POSITION_IMPACT_FACTOR"));
| 30,782 |
51 | // if ETH amount supplied exceeds the price | if(msg.value > totalPrice) {
| if(msg.value > totalPrice) {
| 34,650 |
66 | // decrease allowance | _approve(sender, _msgSender(), _allowedFragments[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
| _approve(sender, _msgSender(), _allowedFragments[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
| 23,437 |
29 | // Delegate all of `account`'s voting units to `delegatee`. | * Emits events {DelegateChanged} and {DelegateVotesChanged}.
*/
function _delegate(address account, address delegatee) internal virtual {
address oldDelegate = delegates(account);
_delegation[account] = delegatee;
emit DelegateChanged(account, oldDelegate, delegatee);
_moveDelegateVotes(oldDelegate, delegatee, _getVotingUnits(account));
}
| * Emits events {DelegateChanged} and {DelegateVotesChanged}.
*/
function _delegate(address account, address delegatee) internal virtual {
address oldDelegate = delegates(account);
_delegation[account] = delegatee;
emit DelegateChanged(account, oldDelegate, delegatee);
_moveDelegateVotes(oldDelegate, delegatee, _getVotingUnits(account));
}
| 81,391 |
6 | // Sender borrows ETH from the protocol to a receiver address in spite of having insufficient collateral, but repays borrow or adds collateral to correct balance in the same blockAny ETH the sender sends with this payable function are considered a down payment and arealso transferred to the receiver address borrowAmount The amount of the underlying asset (Wei) to borrow receiver The address receiving the borrowed funds. This address must be able to receivethe corresponding underlying of mToken and it must implement FlashLoanReceiverInterface. flashParams Any other data necessary for flash loan repaymentreturn uint 0=success, otherwise a failure (see ErrorReporter.sol for details) | function flashBorrow(uint borrowAmount, address payable receiver, bytes calldata flashParams) external payable returns (uint) {
uint err = mtroller.enterMarketOnBehalf(thisFungibleMToken, msg.sender);
requireNoError(err, "enter market failed");
return flashBorrowInternal(thisFungibleMToken, msg.value, borrowAmount, receiver, flashParams);
}
| function flashBorrow(uint borrowAmount, address payable receiver, bytes calldata flashParams) external payable returns (uint) {
uint err = mtroller.enterMarketOnBehalf(thisFungibleMToken, msg.sender);
requireNoError(err, "enter market failed");
return flashBorrowInternal(thisFungibleMToken, msg.value, borrowAmount, receiver, flashParams);
}
| 12,972 |
56 | // Return balance of a certain address. _owner The address whose balance we want to check./ | {
return balances[_owner];
}
| {
return balances[_owner];
}
| 1,262 |
41 | // Putting this all together. The storage slot offset from '_proof' is... (_proof & 0xffff0000) + (_proof & 0xff00) + (_proof & 0xff) i.e. the storage slot offset IS the value of _proof | validatorAddress := sload(add(_proof, validators_slot))
isValidatorDisabled :=
shr(
shl(0x03, and(_proof, 0x1f)),
sload(add(shr(5, _proof), disabledValidators_slot))
)
queryInvalid := or(iszero(validatorAddress), isValidatorDisabled)
| validatorAddress := sload(add(_proof, validators_slot))
isValidatorDisabled :=
shr(
shl(0x03, and(_proof, 0x1f)),
sload(add(shr(5, _proof), disabledValidators_slot))
)
queryInvalid := or(iszero(validatorAddress), isValidatorDisabled)
| 30,239 |
5 | // 店舗情報を設定 / | function setStoreData(string name, string streetNo, string tel) returns (bool) {
// 登録者を設定する
storeData.push(StoreData(name, streetNo, tel, msg.sender));
for (uint i = 0; i < storeData.length; i++) {
//イベントを実行する
eventStoreData(storeData[i].name, storeData[i].streetNo
, storeData[i].tel, storeData[i].owner);
}
// 実行が完了するとtrueを返す
return true;
}
| function setStoreData(string name, string streetNo, string tel) returns (bool) {
// 登録者を設定する
storeData.push(StoreData(name, streetNo, tel, msg.sender));
for (uint i = 0; i < storeData.length; i++) {
//イベントを実行する
eventStoreData(storeData[i].name, storeData[i].streetNo
, storeData[i].tel, storeData[i].owner);
}
// 実行が完了するとtrueを返す
return true;
}
| 42,275 |
194 | // Implements safeTransfer, safeTransferFrom and/ safeApprove for CompatibleERC20.// See https:github.com/ethereum/solidity/issues/4116// This library allows interacting with ERC20 tokens that implement any of/ these interfaces:// (1) transfer returns true on success, false on failure/ (2) transfer returns true on success, reverts on failure/ (3) transfer returns nothing on success, reverts on failure// Additionally, safeTransferFromWithFees will return the final token/ value received after accounting for token fees. | library CompatibleERC20Functions {
using SafeMath for uint256;
/// @notice Calls transfer on the token and reverts if the call fails.
function safeTransfer(address token, address to, uint256 amount) internal {
CompatibleERC20(token).transfer(to, amount);
require(previousReturnValue(), "transfer failed");
}
/// @notice Calls transferFrom on the token and reverts if the call fails.
function safeTransferFrom(address token, address from, address to, uint256 amount) internal {
CompatibleERC20(token).transferFrom(from, to, amount);
require(previousReturnValue(), "transferFrom failed");
}
/// @notice Calls approve on the token and reverts if the call fails.
function safeApprove(address token, address spender, uint256 amount) internal {
CompatibleERC20(token).approve(spender, amount);
require(previousReturnValue(), "approve failed");
}
/// @notice Calls transferFrom on the token, reverts if the call fails and
/// returns the value transferred after fees.
function safeTransferFromWithFees(address token, address from, address to, uint256 amount) internal returns (uint256) {
uint256 balancesBefore = CompatibleERC20(token).balanceOf(to);
CompatibleERC20(token).transferFrom(from, to, amount);
require(previousReturnValue(), "transferFrom failed");
uint256 balancesAfter = CompatibleERC20(token).balanceOf(to);
return Math.min256(amount, balancesAfter.sub(balancesBefore));
}
/// @notice Checks the return value of the previous function. Returns true
/// if the previous function returned 32 non-zero bytes or returned zero
/// bytes.
function previousReturnValue() private pure returns (bool)
{
uint256 returnData = 0;
assembly { /* solium-disable-line security/no-inline-assembly */
// Switch on the number of bytes returned by the previous call
switch returndatasize
// 0 bytes: ERC20 of type (3), did not throw
case 0 {
returnData := 1
}
// 32 bytes: ERC20 of types (1) or (2)
case 32 {
// Copy the return data into scratch space
returndatacopy(0x0, 0x0, 32)
// Load the return data into returnData
returnData := mload(0x0)
}
// Other return size: return false
default { }
}
return returnData != 0;
}
}
| library CompatibleERC20Functions {
using SafeMath for uint256;
/// @notice Calls transfer on the token and reverts if the call fails.
function safeTransfer(address token, address to, uint256 amount) internal {
CompatibleERC20(token).transfer(to, amount);
require(previousReturnValue(), "transfer failed");
}
/// @notice Calls transferFrom on the token and reverts if the call fails.
function safeTransferFrom(address token, address from, address to, uint256 amount) internal {
CompatibleERC20(token).transferFrom(from, to, amount);
require(previousReturnValue(), "transferFrom failed");
}
/// @notice Calls approve on the token and reverts if the call fails.
function safeApprove(address token, address spender, uint256 amount) internal {
CompatibleERC20(token).approve(spender, amount);
require(previousReturnValue(), "approve failed");
}
/// @notice Calls transferFrom on the token, reverts if the call fails and
/// returns the value transferred after fees.
function safeTransferFromWithFees(address token, address from, address to, uint256 amount) internal returns (uint256) {
uint256 balancesBefore = CompatibleERC20(token).balanceOf(to);
CompatibleERC20(token).transferFrom(from, to, amount);
require(previousReturnValue(), "transferFrom failed");
uint256 balancesAfter = CompatibleERC20(token).balanceOf(to);
return Math.min256(amount, balancesAfter.sub(balancesBefore));
}
/// @notice Checks the return value of the previous function. Returns true
/// if the previous function returned 32 non-zero bytes or returned zero
/// bytes.
function previousReturnValue() private pure returns (bool)
{
uint256 returnData = 0;
assembly { /* solium-disable-line security/no-inline-assembly */
// Switch on the number of bytes returned by the previous call
switch returndatasize
// 0 bytes: ERC20 of type (3), did not throw
case 0 {
returnData := 1
}
// 32 bytes: ERC20 of types (1) or (2)
case 32 {
// Copy the return data into scratch space
returndatacopy(0x0, 0x0, 32)
// Load the return data into returnData
returnData := mload(0x0)
}
// Other return size: return false
default { }
}
return returnData != 0;
}
}
| 4,620 |
137 | // Revokes `role` from the calling account. | * Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
| * Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
| 34,837 |
38 | // Approve new owner request, can be call only by ownerwhich don&39;t call this new owner request before. / | function approveAddOwnerRequest () public onlyOwners {
require (!addOwner.isExecute && !addOwner.isCanceled);
require (addOwner.creationTimestamp + lifeTime >= uint32(now));
/**
*@dev new owner shoudn't be in owners mapping
*/
require (!owners[addOwner.newOwner]);
for (uint i = 0; i < addOwner.confirmators.length; i++){
require(addOwner.confirmators[i] != msg.sender);
}
addOwner.confirms++;
addOwner.confirmators.push(msg.sender);
if(addOwner.confirms >= needApprovesToConfirm){
addOwner.isExecute = true;
owners[addOwner.newOwner] = true;
ownersCount++;
}
emit AddOwnerRequestUpdate(msg.sender, addOwner.confirms, addOwner.isExecute);
}
| function approveAddOwnerRequest () public onlyOwners {
require (!addOwner.isExecute && !addOwner.isCanceled);
require (addOwner.creationTimestamp + lifeTime >= uint32(now));
/**
*@dev new owner shoudn't be in owners mapping
*/
require (!owners[addOwner.newOwner]);
for (uint i = 0; i < addOwner.confirmators.length; i++){
require(addOwner.confirmators[i] != msg.sender);
}
addOwner.confirms++;
addOwner.confirmators.push(msg.sender);
if(addOwner.confirms >= needApprovesToConfirm){
addOwner.isExecute = true;
owners[addOwner.newOwner] = true;
ownersCount++;
}
emit AddOwnerRequestUpdate(msg.sender, addOwner.confirms, addOwner.isExecute);
}
| 20,376 |
51 | // additional validations | require(tokens > 0);
| require(tokens > 0);
| 11,081 |
2 | // ERC721 | interface IERC721 {
function ownerOf(uint256 tokenId) external view returns (address);
function transferFrom(address from, address to, uint256 tokenId) external view;
}
| interface IERC721 {
function ownerOf(uint256 tokenId) external view returns (address);
function transferFrom(address from, address to, uint256 tokenId) external view;
}
| 24,337 |
302 | // MANAGER ONLY: Remove borrow asset. Borrow asset is exited in Compound marketsIf there is a borrow balance, borrow asset cannot be removed_setToken Instance of the SetToken _borrowAssets Addresses of borrow underlying assets to remove / | function removeBorrowAssets(ISetToken _setToken, address[] memory _borrowAssets) external onlyManagerAndValidSet(_setToken) {
// Sync Compound and SetToken positions prior to any removal action
sync(_setToken);
for(uint256 i = 0; i < _borrowAssets.length; i++) {
address cToken = underlyingToCToken[_borrowAssets[i]];
require(isBorrowCTokenEnabled[_setToken][cToken], "Borrow not enabled");
// Note: Will only exit market if cToken is not enabled as a collateral asset as well
// If there is an existing borrow balance, will revert and market cannot be exited on Compound
if (!isCollateralCTokenEnabled[_setToken][cToken]) {
_exitMarket(_setToken, cToken);
}
delete isBorrowCTokenEnabled[_setToken][cToken];
enabledAssets[_setToken].borrowCTokens = enabledAssets[_setToken].borrowCTokens.remove(cToken);
enabledAssets[_setToken].borrowAssets = enabledAssets[_setToken].borrowAssets.remove(_borrowAssets[i]);
}
emit BorrowAssetsRemoved(_setToken, _borrowAssets);
}
| function removeBorrowAssets(ISetToken _setToken, address[] memory _borrowAssets) external onlyManagerAndValidSet(_setToken) {
// Sync Compound and SetToken positions prior to any removal action
sync(_setToken);
for(uint256 i = 0; i < _borrowAssets.length; i++) {
address cToken = underlyingToCToken[_borrowAssets[i]];
require(isBorrowCTokenEnabled[_setToken][cToken], "Borrow not enabled");
// Note: Will only exit market if cToken is not enabled as a collateral asset as well
// If there is an existing borrow balance, will revert and market cannot be exited on Compound
if (!isCollateralCTokenEnabled[_setToken][cToken]) {
_exitMarket(_setToken, cToken);
}
delete isBorrowCTokenEnabled[_setToken][cToken];
enabledAssets[_setToken].borrowCTokens = enabledAssets[_setToken].borrowCTokens.remove(cToken);
enabledAssets[_setToken].borrowAssets = enabledAssets[_setToken].borrowAssets.remove(_borrowAssets[i]);
}
emit BorrowAssetsRemoved(_setToken, _borrowAssets);
}
| 35,917 |
11 | // Reads the current answer from aggregator delegated to.[deprecated] Use latestRoundData instead. This does not error if noanswer has been reached, it will simply return 0. Either wait to point toan already answered Aggregator or use the recommended latestRoundDatainstead which includes better verification information. / | function latestAnswer()
external
view
virtual
override
returns (int256)
| function latestAnswer()
external
view
virtual
override
returns (int256)
| 18,446 |
49 | // There must be an array of units | require(_units.length > 0, "Units must be greater than 0");
| require(_units.length > 0, "Units must be greater than 0");
| 17,237 |
68 | // getter function to determine current auction id.return current batchId / | function getCurrentBatchId() public view returns (uint32) {
// solhint-disable-next-line not-rely-on-time
return uint32(now / BATCH_TIME);
}
| function getCurrentBatchId() public view returns (uint32) {
// solhint-disable-next-line not-rely-on-time
return uint32(now / BATCH_TIME);
}
| 10,835 |
66 | // team tokens are equal to 5% of tokens | uint256 lockedTokens = 16250000000000000000000000; // 16 250 000 * 10**18
| uint256 lockedTokens = 16250000000000000000000000; // 16 250 000 * 10**18
| 54,106 |
164 | // Handle the receipt of ERC1363 tokens Any ERC1363 smart contract calls this function on the recipientafter a `transfer` or a `transferFrom`. This function MAY throw to revert and reject thetransfer. Return of other than the magic value MUST result in thetransaction being reverted.Note: the token contract address is always the message sender. operator address The address which called `transferAndCall` or `transferFromAndCall` function from address The address which are token transferred from value uint256 The amount of tokens transferred data bytes Additional data with no specified formatreturn `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` unless throwing / | function onTransferReceived(address operator, address from, uint256 value, bytes calldata data) external returns (bytes4);
| function onTransferReceived(address operator, address from, uint256 value, bytes calldata data) external returns (bytes4);
| 82,653 |
96 | // The constructor._token The address of the Fabric Token (fundraiser) contract. / |
function FabricTokenSafe(address _token) public
|
function FabricTokenSafe(address _token) public
| 48,340 |
3 | // ^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ _Available since v4.1._ / | modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
| modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
| 10,433 |
258 | // Pool Delegate Setter Functions /// | function setLiquidityCap(uint256 newLiquidityCap) external {
_whenProtocolNotPaused();
_isValidDelegateOrPoolAdmin();
liquidityCap = newLiquidityCap;
emit LiquidityCapSet(newLiquidityCap);
}
| function setLiquidityCap(uint256 newLiquidityCap) external {
_whenProtocolNotPaused();
_isValidDelegateOrPoolAdmin();
liquidityCap = newLiquidityCap;
emit LiquidityCapSet(newLiquidityCap);
}
| 20,868 |
10 | // token[_addr] = keccak256(abi.encodePacked(montos_bloqueados[_addr], montos_a_devolver[_addr], balance[_addr])); | if (++token[_addr]>254)
token[_addr]=0;
| if (++token[_addr]>254)
token[_addr]=0;
| 33,959 |
18 | // struct that helps define parameters for a swap | struct SwapHelper {
address token; // reward token we are swapping
uint256 deadline;
uint256 amountOutMinimum;
}
| struct SwapHelper {
address token; // reward token we are swapping
uint256 deadline;
uint256 amountOutMinimum;
}
| 48,247 |
36 | // `treasuryFunds` can't be zero. Otherwise, migrated communities will have zero. | _treasuryFunds = _treasuryFunds > 0 ? _treasuryFunds : 1e18;
uint256 _trancheAmount = (_validBeneficiaries *
_claimAmount *
(_treasuryFunds + _privateFunds)) / _treasuryFunds;
if (_trancheAmount < _minTranche) {
_trancheAmount = _minTranche;
} else if (_trancheAmount > _maxTranche) {
| _treasuryFunds = _treasuryFunds > 0 ? _treasuryFunds : 1e18;
uint256 _trancheAmount = (_validBeneficiaries *
_claimAmount *
(_treasuryFunds + _privateFunds)) / _treasuryFunds;
if (_trancheAmount < _minTranche) {
_trancheAmount = _minTranche;
} else if (_trancheAmount > _maxTranche) {
| 29,016 |
14 | // VOTING DATA | mapping(uint256 => mapping(uint256 => bool)) VotePidRid_; // plyId => Rid => voted
mapping(uint256 => F3Ddatasets.votingData) roundVotingData;
| mapping(uint256 => mapping(uint256 => bool)) VotePidRid_; // plyId => Rid => voted
mapping(uint256 => F3Ddatasets.votingData) roundVotingData;
| 59,623 |
358 | // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) |
pragma solidity ^0.8.0;
|
pragma solidity ^0.8.0;
| 9,135 |
91 | // IERC20 Set Protocol Interface for using ERC20 Tokens. This interface is needed to interact with tokens that are notfully ERC20 compliant and return something other than true on successful transfers. / | interface IERC20 {
function balanceOf(
address _owner
)
external
view
returns (uint256);
function allowance(
address _owner,
address _spender
)
external
view
returns (uint256);
function transfer(
address _to,
uint256 _quantity
)
external;
function transferFrom(
address _from,
address _to,
uint256 _quantity
)
external;
function approve(
address _spender,
uint256 _quantity
)
external
returns (bool);
}
| interface IERC20 {
function balanceOf(
address _owner
)
external
view
returns (uint256);
function allowance(
address _owner,
address _spender
)
external
view
returns (uint256);
function transfer(
address _to,
uint256 _quantity
)
external;
function transferFrom(
address _from,
address _to,
uint256 _quantity
)
external;
function approve(
address _spender,
uint256 _quantity
)
external
returns (bool);
}
| 52,580 |
116 | // IMPLEMENTATION: removeContractFromUpgradeable | function _removeContractFromUpgradeable(address addr) internal {
if (addr == address(0)) {
revert ZeroAddressException(); // F: [CC-36]
}
| function _removeContractFromUpgradeable(address addr) internal {
if (addr == address(0)) {
revert ZeroAddressException(); // F: [CC-36]
}
| 28,832 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.