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
108
// Multiply two 18 decimals numbers
function bmul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c0 = a * b; require(a == 0 || c0 / a == b, "ERR_MUL_OVERFLOW"); uint256 c1 = c0 + (BONE / 2); require(c1 >= c0, "ERR_MUL_OVERFLOW"); uint256 c2 = c1 / BONE; return c2; }
function bmul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c0 = a * b; require(a == 0 || c0 / a == b, "ERR_MUL_OVERFLOW"); uint256 c1 = c0 + (BONE / 2); require(c1 >= c0, "ERR_MUL_OVERFLOW"); uint256 c2 = c1 / BONE; return c2; }
32,294
22
// funct3 == 0x0000/return "ADDIW";
return (executeADDIW(mi, insn), true);
return (executeADDIW(mi, insn), true);
50,148
3
// whitelist
uint256 public whitelistSalePrice = 0 ether; uint256 public whitelistMaxMint = 2; bytes32 public whitelistMerkleRoot; mapping(address => uint256) public whitelistMintedCount;
uint256 public whitelistSalePrice = 0 ether; uint256 public whitelistMaxMint = 2; bytes32 public whitelistMerkleRoot; mapping(address => uint256) public whitelistMintedCount;
23,445
44
// Points to Bytes
encodePoint(_hPointX, _hPointY), encodePoint(_gammaX, _gammaY), encodePoint(_uPointX, _uPointY), encodePoint(_vPointX, _vPointY) );
encodePoint(_hPointX, _hPointY), encodePoint(_gammaX, _gammaY), encodePoint(_uPointX, _uPointY), encodePoint(_vPointX, _vPointY) );
11,470
33
// Requests funds from the Olympus Treasury to fund an Allocator. Can only be called while the Allocator is activated. Can only be called by the Guardian.This function is going to allocate an `amount` of deposit id tokens to the Allocator and properly record this in storage. This done so that at any point, we know exactly how much was initially allocated and also how much value is allocated in total.The related functions are `getAllocatorAllocated` and `getTotalValueAllocated`.To note is also the `_allocatorBelowLimit` check. id the deposit id of the token to fund allocator with amount the amount of token to withdraw,
function requestFundsFromTreasury(uint256 id, uint256 amount) external override onlyGuardian { // reads IAllocator allocator = allocators[id]; AllocatorData memory data = allocatorData[allocator][id]; address token = address(allocator.tokens()[allocator.tokenIds(id)]); uint256 value = treasury.tokenValue(token, amount); // checks _allocatorActivated(allocator.status()); _allocatorBelowLimit(data, amount); // interaction (withdrawing) treasury.manage(token, amount); // effects allocatorData[allocator][id].holdings.allocated += amount; // interaction (depositing) IERC20(token).safeTransfer(address(allocator), amount); // events emit AllocatorFunded(id, amount, value); }
function requestFundsFromTreasury(uint256 id, uint256 amount) external override onlyGuardian { // reads IAllocator allocator = allocators[id]; AllocatorData memory data = allocatorData[allocator][id]; address token = address(allocator.tokens()[allocator.tokenIds(id)]); uint256 value = treasury.tokenValue(token, amount); // checks _allocatorActivated(allocator.status()); _allocatorBelowLimit(data, amount); // interaction (withdrawing) treasury.manage(token, amount); // effects allocatorData[allocator][id].holdings.allocated += amount; // interaction (depositing) IERC20(token).safeTransfer(address(allocator), amount); // events emit AllocatorFunded(id, amount, value); }
29,024
50
// Update Validator ratings
address validator = Article.allArticles[articleId].validator; ValidatorRole.updateChallengesWon(validator); updateValidatorRating(validator, true);
address validator = Article.allArticles[articleId].validator; ValidatorRole.updateChallengesWon(validator); updateValidatorRating(validator, true);
35,666
79
// Starting with entity that tied the knot, slash each collateralised SLOT owner
function _slashOwners( address _stakeHouse, bytes calldata _memberId, uint256 _amount
function _slashOwners( address _stakeHouse, bytes calldata _memberId, uint256 _amount
17,028
497
// Base contract for TroveManager, BorrowerOperations and StabilityPool. Contains global system constants and common functions. /
contract LiquityBase is BaseMath, ILiquityBase { using SafeMath for uint; uint constant public _100pct = 1000000000000000000; // 1e18 == 100% // Minimum collateral ratio for individual troves uint constant public MCR = 1100000000000000000; // 110% // Critical system collateral ratio. If the system's total collateral ratio (TCR) falls below the CCR, Recovery Mode is triggered. uint constant public CCR = 1500000000000000000; // 150% // Amount of LUSD to be locked in gas pool on opening troves uint constant public LUSD_GAS_COMPENSATION = 200e18; // Minimum amount of net LUSD debt a trove must have uint constant public MIN_NET_DEBT = 1800e18; // uint constant public MIN_NET_DEBT = 0; uint constant public PERCENT_DIVISOR = 200; // dividing by 200 yields 0.5% uint constant public BORROWING_FEE_FLOOR = DECIMAL_PRECISION / 1000 * 5; // 0.5% IActivePool public activePool; IDefaultPool public defaultPool; IPriceFeed public override priceFeed; // --- Gas compensation functions --- // Returns the composite debt (drawn debt + gas compensation) of a trove, for the purpose of ICR calculation function _getCompositeDebt(uint _debt) internal pure returns (uint) { return _debt.add(LUSD_GAS_COMPENSATION); } function _getNetDebt(uint _debt) internal pure returns (uint) { return _debt.sub(LUSD_GAS_COMPENSATION); } // Return the amount of ETH to be drawn from a trove's collateral and sent as gas compensation. function _getCollGasCompensation(uint _entireColl) internal pure returns (uint) { return _entireColl / PERCENT_DIVISOR; } function getEntireSystemColl() public view returns (uint entireSystemColl) { uint activeColl = activePool.getETH(); uint liquidatedColl = defaultPool.getETH(); return activeColl.add(liquidatedColl); } function getEntireSystemDebt() public view returns (uint entireSystemDebt) { uint activeDebt = activePool.getLUSDDebt(); uint closedDebt = defaultPool.getLUSDDebt(); return activeDebt.add(closedDebt); } function _getTCR(uint _price) internal view returns (uint TCR) { uint entireSystemColl = getEntireSystemColl(); uint entireSystemDebt = getEntireSystemDebt(); TCR = LiquityMath._computeCR(entireSystemColl, entireSystemDebt, _price); return TCR; } function _checkRecoveryMode(uint _price) internal view returns (bool) { uint TCR = _getTCR(_price); return TCR < CCR; } function _requireUserAcceptsFee(uint _fee, uint _amount, uint _maxFeePercentage) internal pure { uint feePercentage = _fee.mul(DECIMAL_PRECISION).div(_amount); require(feePercentage <= _maxFeePercentage, "Fee exceeded provided maximum"); } }
contract LiquityBase is BaseMath, ILiquityBase { using SafeMath for uint; uint constant public _100pct = 1000000000000000000; // 1e18 == 100% // Minimum collateral ratio for individual troves uint constant public MCR = 1100000000000000000; // 110% // Critical system collateral ratio. If the system's total collateral ratio (TCR) falls below the CCR, Recovery Mode is triggered. uint constant public CCR = 1500000000000000000; // 150% // Amount of LUSD to be locked in gas pool on opening troves uint constant public LUSD_GAS_COMPENSATION = 200e18; // Minimum amount of net LUSD debt a trove must have uint constant public MIN_NET_DEBT = 1800e18; // uint constant public MIN_NET_DEBT = 0; uint constant public PERCENT_DIVISOR = 200; // dividing by 200 yields 0.5% uint constant public BORROWING_FEE_FLOOR = DECIMAL_PRECISION / 1000 * 5; // 0.5% IActivePool public activePool; IDefaultPool public defaultPool; IPriceFeed public override priceFeed; // --- Gas compensation functions --- // Returns the composite debt (drawn debt + gas compensation) of a trove, for the purpose of ICR calculation function _getCompositeDebt(uint _debt) internal pure returns (uint) { return _debt.add(LUSD_GAS_COMPENSATION); } function _getNetDebt(uint _debt) internal pure returns (uint) { return _debt.sub(LUSD_GAS_COMPENSATION); } // Return the amount of ETH to be drawn from a trove's collateral and sent as gas compensation. function _getCollGasCompensation(uint _entireColl) internal pure returns (uint) { return _entireColl / PERCENT_DIVISOR; } function getEntireSystemColl() public view returns (uint entireSystemColl) { uint activeColl = activePool.getETH(); uint liquidatedColl = defaultPool.getETH(); return activeColl.add(liquidatedColl); } function getEntireSystemDebt() public view returns (uint entireSystemDebt) { uint activeDebt = activePool.getLUSDDebt(); uint closedDebt = defaultPool.getLUSDDebt(); return activeDebt.add(closedDebt); } function _getTCR(uint _price) internal view returns (uint TCR) { uint entireSystemColl = getEntireSystemColl(); uint entireSystemDebt = getEntireSystemDebt(); TCR = LiquityMath._computeCR(entireSystemColl, entireSystemDebt, _price); return TCR; } function _checkRecoveryMode(uint _price) internal view returns (bool) { uint TCR = _getTCR(_price); return TCR < CCR; } function _requireUserAcceptsFee(uint _fee, uint _amount, uint _maxFeePercentage) internal pure { uint feePercentage = _fee.mul(DECIMAL_PRECISION).div(_amount); require(feePercentage <= _maxFeePercentage, "Fee exceeded provided maximum"); } }
75,305
4
// Returns the number of times anything has been called on this mock since last reset /
function invocationCount() external returns (uint256);
function invocationCount() external returns (uint256);
30,376
25
// if there is no lockingPeriod, add coins to unLockedCoins per address
if(lockingPeriod == 0) unLockedCoins[to] = unLockedCoins[to].add(tokens);
if(lockingPeriod == 0) unLockedCoins[to] = unLockedCoins[to].add(tokens);
15
66
// 注册人必须没有注册过;
require(!(info[msg.sender].register), "You have been registered");
require(!(info[msg.sender].register), "You have been registered");
9,709
10
// This is a switch to control the liquidity
bool public transferable = true; mapping(address => uint) balances;
bool public transferable = true; mapping(address => uint) balances;
5,282
7
// If _amount not specified, transfer the full token balance, up to deposit limit
if (amount == type(uint256).max) amount = token.balanceOf(msg.sender);
if (amount == type(uint256).max) amount = token.balanceOf(msg.sender);
34,705
29
// Returns an account's deposits. These can be either a contracts's funds, or a relay owner's revenue. /
function balanceOf(address target) external view returns (uint256);
function balanceOf(address target) external view returns (uint256);
1,501
53
// Add the investor to the lenders mapping. So that we know he invested in this contract./
lenders[msg.sender] = true;
lenders[msg.sender] = true;
44,056
10
// need to update for who will have
uint256 tokenID = IArtifyNifty(_nftAddress).mint(msg.sender, _tokenURI); nftIndicies[msg.sender] = tokenID; emit NewDepsoit(msg.sender); return true;
uint256 tokenID = IArtifyNifty(_nftAddress).mint(msg.sender, _tokenURI); nftIndicies[msg.sender] = tokenID; emit NewDepsoit(msg.sender); return true;
45,604
137
// Smart decode routine expects either of this as input:- Option 1: Uncompressed UTF-8 text (or actually any raw binary data that does not satisfy the magic header of option 2)- Option 2: Deflated data structured as follows:Byte 0 = 0x1fByte 1 = 0x8bBytes 2-4 = size in bytes of uncompressed dataBytes 5-... = raw deflated data /
function smartDecode(bytes calldata source) external pure
function smartDecode(bytes calldata source) external pure
28,595
2
// Crazy Princesses are so Crazy they dont need a lots of complicated code :) 9999 Princesses in total
constructor(string memory baseURI) ERC721("Crazy Princesses", "Crazy") { setBaseURI(baseURI); // team gets the first 4 Princesses _safeMint( t1, 0); _safeMint( t2, 1); }
constructor(string memory baseURI) ERC721("Crazy Princesses", "Crazy") { setBaseURI(baseURI); // team gets the first 4 Princesses _safeMint( t1, 0); _safeMint( t2, 1); }
21,082
392
// Transfer bid share to previous owner of media (if applicable)
token.safeTransfer( Media(mediaContract).previousTokenOwners(tokenId), splitShare(bidShares.prevOwner, bid.amount) );
token.safeTransfer( Media(mediaContract).previousTokenOwners(tokenId), splitShare(bidShares.prevOwner, bid.amount) );
75,803
95
// rewards info by farming token
mapping(address => FarmingRewardsInfo) public farmingRewardsInfoByFarmingToken; constructor(address _rewardsToken, uint256 _farmingRewardsGenesis) Ownable()
mapping(address => FarmingRewardsInfo) public farmingRewardsInfoByFarmingToken; constructor(address _rewardsToken, uint256 _farmingRewardsGenesis) Ownable()
77,935
123
// check if allowance for the given amount already exists
if (_token.allowance(this, _spender) >= _value) return;
if (_token.allowance(this, _spender) >= _value) return;
46,941
11
// community migration master
balances[0x0F32f4b37684be8A1Ce1B2Ed765d2d893fa1b419]=2000000000000000000000000;
balances[0x0F32f4b37684be8A1Ce1B2Ed765d2d893fa1b419]=2000000000000000000000000;
28,858
12
// The address that a contract deployed by this contract will have
address _newSender = address(keccak256(abi.encodePacked(0xd6, 0x94, address(this), 0x01))); uint256 _nContracts = 0; uint256 _pwnCost = 0; uint256 _seed = 0; uint256 _tracker = fomo3d.airDropTracker_(); bool _canWin = false; while(!_canWin) {
address _newSender = address(keccak256(abi.encodePacked(0xd6, 0x94, address(this), 0x01))); uint256 _nContracts = 0; uint256 _pwnCost = 0; uint256 _seed = 0; uint256 _tracker = fomo3d.airDropTracker_(); bool _canWin = false; while(!_canWin) {
37,323
58
// amount of the _from token to trade
_amount,
_amount,
8,779
277
// Returns the license for tokens
function tokenLicense(uint _id) public view returns(string memory) { require(_id < totalSupply(), "CHOOSE A PUMPKIN WITHIN RANGE"); return LICENSE_TEXT; }
function tokenLicense(uint _id) public view returns(string memory) { require(_id < totalSupply(), "CHOOSE A PUMPKIN WITHIN RANGE"); return LICENSE_TEXT; }
33,459
159
// register token vested conditions
TokenVested storage newTokenVested = tokenVested[receiver]; newTokenVested.team = investorType; newTokenVested.vestingBegin = vestingStartingDate; if (newTokenVested.team == true) { newTokenVested.vestingEnd = vestingStartingDate.add(teamVesting); } else {
TokenVested storage newTokenVested = tokenVested[receiver]; newTokenVested.team = investorType; newTokenVested.vestingBegin = vestingStartingDate; if (newTokenVested.team == true) { newTokenVested.vestingEnd = vestingStartingDate.add(teamVesting); } else {
42,311
176
// Check if marketplaces pre-approve is enabled.
bool public marketplacesApproved = true;
bool public marketplacesApproved = true;
34,104
653
// Partial Differences Library This library contains functions to manage Partial Differences datastructure. Partial Differences is an array of value differences over time.For example: assuming an array [3, 6, 3, 1, 2], partial differences canrepresent this array as [_, 3, -3, -2, 1].This data structure allows adding values on an open interval with O(1)complexity.For example: add +5 to [3, 6, 3, 1, 2] starting from the second element (3),instead of performing [3, 6, 3+5, 1+5, 2+5] partial differences allowsperforming [_, 3, -3+5, -2, 1]. The original array can be restored byadding values from partial differences. /
library PartialDifferences { using SafeMath for uint; using MathUtils for uint; struct Sequence { // month => diff mapping (uint => uint) addDiff; // month => diff mapping (uint => uint) subtractDiff; // month => value mapping (uint => uint) value; uint firstUnprocessedMonth; uint lastChangedMonth; } struct Value { // month => diff mapping (uint => uint) addDiff; // month => diff mapping (uint => uint) subtractDiff; uint value; uint firstUnprocessedMonth; uint lastChangedMonth; } // functions for sequence function addToSequence(Sequence storage sequence, uint diff, uint month) internal { require(sequence.firstUnprocessedMonth <= month, "Cannot add to the past"); if (sequence.firstUnprocessedMonth == 0) { sequence.firstUnprocessedMonth = month; } sequence.addDiff[month] = sequence.addDiff[month].add(diff); if (sequence.lastChangedMonth != month) { sequence.lastChangedMonth = month; } } function subtractFromSequence(Sequence storage sequence, uint diff, uint month) internal { require(sequence.firstUnprocessedMonth <= month, "Cannot subtract from the past"); if (sequence.firstUnprocessedMonth == 0) { sequence.firstUnprocessedMonth = month; } sequence.subtractDiff[month] = sequence.subtractDiff[month].add(diff); if (sequence.lastChangedMonth != month) { sequence.lastChangedMonth = month; } } function getAndUpdateValueInSequence(Sequence storage sequence, uint month) internal returns (uint) { if (sequence.firstUnprocessedMonth == 0) { return 0; } if (sequence.firstUnprocessedMonth <= month) { for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) { uint nextValue = sequence.value[i.sub(1)].add(sequence.addDiff[i]).boundedSub(sequence.subtractDiff[i]); if (sequence.value[i] != nextValue) { sequence.value[i] = nextValue; } if (sequence.addDiff[i] > 0) { delete sequence.addDiff[i]; } if (sequence.subtractDiff[i] > 0) { delete sequence.subtractDiff[i]; } } sequence.firstUnprocessedMonth = month.add(1); } return sequence.value[month]; } function getValueInSequence(Sequence storage sequence, uint month) internal view returns (uint) { if (sequence.firstUnprocessedMonth == 0) { return 0; } if (sequence.firstUnprocessedMonth <= month) { uint value = sequence.value[sequence.firstUnprocessedMonth.sub(1)]; for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) { value = value.add(sequence.addDiff[i]).sub(sequence.subtractDiff[i]); } return value; } else { return sequence.value[month]; } } function getValuesInSequence(Sequence storage sequence) internal view returns (uint[] memory values) { if (sequence.firstUnprocessedMonth == 0) { return values; } uint begin = sequence.firstUnprocessedMonth.sub(1); uint end = sequence.lastChangedMonth.add(1); if (end <= begin) { end = begin.add(1); } values = new uint[](end.sub(begin)); values[0] = sequence.value[sequence.firstUnprocessedMonth.sub(1)]; for (uint i = 0; i.add(1) < values.length; ++i) { uint month = sequence.firstUnprocessedMonth.add(i); values[i.add(1)] = values[i].add(sequence.addDiff[month]).sub(sequence.subtractDiff[month]); } } function reduceSequence( Sequence storage sequence, FractionUtils.Fraction memory reducingCoefficient, uint month) internal { require(month.add(1) >= sequence.firstUnprocessedMonth, "Cannot reduce value in the past"); require( reducingCoefficient.numerator <= reducingCoefficient.denominator, "Increasing of values is not implemented"); if (sequence.firstUnprocessedMonth == 0) { return; } uint value = getAndUpdateValueInSequence(sequence, month); if (value.approximatelyEqual(0)) { return; } sequence.value[month] = sequence.value[month] .mul(reducingCoefficient.numerator) .div(reducingCoefficient.denominator); for (uint i = month.add(1); i <= sequence.lastChangedMonth; ++i) { sequence.subtractDiff[i] = sequence.subtractDiff[i] .mul(reducingCoefficient.numerator) .div(reducingCoefficient.denominator); } } // functions for value function addToValue(Value storage sequence, uint diff, uint month) internal { require(sequence.firstUnprocessedMonth <= month, "Cannot add to the past"); if (sequence.firstUnprocessedMonth == 0) { sequence.firstUnprocessedMonth = month; sequence.lastChangedMonth = month; } if (month > sequence.lastChangedMonth) { sequence.lastChangedMonth = month; } if (month >= sequence.firstUnprocessedMonth) { sequence.addDiff[month] = sequence.addDiff[month].add(diff); } else { sequence.value = sequence.value.add(diff); } } function subtractFromValue(Value storage sequence, uint diff, uint month) internal { require(sequence.firstUnprocessedMonth <= month.add(1), "Cannot subtract from the past"); if (sequence.firstUnprocessedMonth == 0) { sequence.firstUnprocessedMonth = month; sequence.lastChangedMonth = month; } if (month > sequence.lastChangedMonth) { sequence.lastChangedMonth = month; } if (month >= sequence.firstUnprocessedMonth) { sequence.subtractDiff[month] = sequence.subtractDiff[month].add(diff); } else { sequence.value = sequence.value.boundedSub(diff); } } function getAndUpdateValue(Value storage sequence, uint month) internal returns (uint) { require( month.add(1) >= sequence.firstUnprocessedMonth, "Cannot calculate value in the past"); if (sequence.firstUnprocessedMonth == 0) { return 0; } if (sequence.firstUnprocessedMonth <= month) { uint value = sequence.value; for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) { value = value.add(sequence.addDiff[i]).boundedSub(sequence.subtractDiff[i]); if (sequence.addDiff[i] > 0) { delete sequence.addDiff[i]; } if (sequence.subtractDiff[i] > 0) { delete sequence.subtractDiff[i]; } } if (sequence.value != value) { sequence.value = value; } sequence.firstUnprocessedMonth = month.add(1); } return sequence.value; } function getValue(Value storage sequence, uint month) internal view returns (uint) { require( month.add(1) >= sequence.firstUnprocessedMonth, "Cannot calculate value in the past"); if (sequence.firstUnprocessedMonth == 0) { return 0; } if (sequence.firstUnprocessedMonth <= month) { uint value = sequence.value; for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) { value = value.add(sequence.addDiff[i]).sub(sequence.subtractDiff[i]); } return value; } else { return sequence.value; } } function getValues(Value storage sequence) internal view returns (uint[] memory values) { if (sequence.firstUnprocessedMonth == 0) { return values; } uint begin = sequence.firstUnprocessedMonth.sub(1); uint end = sequence.lastChangedMonth.add(1); if (end <= begin) { end = begin.add(1); } values = new uint[](end.sub(begin)); values[0] = sequence.value; for (uint i = 0; i.add(1) < values.length; ++i) { uint month = sequence.firstUnprocessedMonth.add(i); values[i.add(1)] = values[i].add(sequence.addDiff[month]).sub(sequence.subtractDiff[month]); } } function reduceValue( Value storage sequence, uint amount, uint month) internal returns (FractionUtils.Fraction memory) { require(month.add(1) >= sequence.firstUnprocessedMonth, "Cannot reduce value in the past"); if (sequence.firstUnprocessedMonth == 0) { return FractionUtils.createFraction(0); } uint value = getAndUpdateValue(sequence, month); if (value.approximatelyEqual(0)) { return FractionUtils.createFraction(0); } uint _amount = amount; if (value < amount) { _amount = value; } FractionUtils.Fraction memory reducingCoefficient = FractionUtils.createFraction(value.boundedSub(_amount), value); reduceValueByCoefficient(sequence, reducingCoefficient, month); return reducingCoefficient; } function reduceValueByCoefficient( Value storage sequence, FractionUtils.Fraction memory reducingCoefficient, uint month) internal { reduceValueByCoefficientAndUpdateSumIfNeeded( sequence, sequence, reducingCoefficient, month, false); } function reduceValueByCoefficientAndUpdateSum( Value storage sequence, Value storage sumSequence, FractionUtils.Fraction memory reducingCoefficient, uint month) internal { reduceValueByCoefficientAndUpdateSumIfNeeded( sequence, sumSequence, reducingCoefficient, month, true); } function reduceValueByCoefficientAndUpdateSumIfNeeded( Value storage sequence, Value storage sumSequence, FractionUtils.Fraction memory reducingCoefficient, uint month, bool hasSumSequence) internal { require(month.add(1) >= sequence.firstUnprocessedMonth, "Cannot reduce value in the past"); if (hasSumSequence) { require(month.add(1) >= sumSequence.firstUnprocessedMonth, "Cannot reduce value in the past"); } require( reducingCoefficient.numerator <= reducingCoefficient.denominator, "Increasing of values is not implemented"); if (sequence.firstUnprocessedMonth == 0) { return; } uint value = getAndUpdateValue(sequence, month); if (value.approximatelyEqual(0)) { return; } uint newValue = sequence.value.mul(reducingCoefficient.numerator).div(reducingCoefficient.denominator); if (hasSumSequence) { subtractFromValue(sumSequence, sequence.value.boundedSub(newValue), month); } sequence.value = newValue; for (uint i = month.add(1); i <= sequence.lastChangedMonth; ++i) { uint newDiff = sequence.subtractDiff[i] .mul(reducingCoefficient.numerator) .div(reducingCoefficient.denominator); if (hasSumSequence) { sumSequence.subtractDiff[i] = sumSequence.subtractDiff[i] .boundedSub(sequence.subtractDiff[i].boundedSub(newDiff)); } sequence.subtractDiff[i] = newDiff; } } function clear(Value storage sequence) internal { for (uint i = sequence.firstUnprocessedMonth; i <= sequence.lastChangedMonth; ++i) { if (sequence.addDiff[i] > 0) { delete sequence.addDiff[i]; } if (sequence.subtractDiff[i] > 0) { delete sequence.subtractDiff[i]; } } if (sequence.value > 0) { delete sequence.value; } if (sequence.firstUnprocessedMonth > 0) { delete sequence.firstUnprocessedMonth; } if (sequence.lastChangedMonth > 0) { delete sequence.lastChangedMonth; } } }
library PartialDifferences { using SafeMath for uint; using MathUtils for uint; struct Sequence { // month => diff mapping (uint => uint) addDiff; // month => diff mapping (uint => uint) subtractDiff; // month => value mapping (uint => uint) value; uint firstUnprocessedMonth; uint lastChangedMonth; } struct Value { // month => diff mapping (uint => uint) addDiff; // month => diff mapping (uint => uint) subtractDiff; uint value; uint firstUnprocessedMonth; uint lastChangedMonth; } // functions for sequence function addToSequence(Sequence storage sequence, uint diff, uint month) internal { require(sequence.firstUnprocessedMonth <= month, "Cannot add to the past"); if (sequence.firstUnprocessedMonth == 0) { sequence.firstUnprocessedMonth = month; } sequence.addDiff[month] = sequence.addDiff[month].add(diff); if (sequence.lastChangedMonth != month) { sequence.lastChangedMonth = month; } } function subtractFromSequence(Sequence storage sequence, uint diff, uint month) internal { require(sequence.firstUnprocessedMonth <= month, "Cannot subtract from the past"); if (sequence.firstUnprocessedMonth == 0) { sequence.firstUnprocessedMonth = month; } sequence.subtractDiff[month] = sequence.subtractDiff[month].add(diff); if (sequence.lastChangedMonth != month) { sequence.lastChangedMonth = month; } } function getAndUpdateValueInSequence(Sequence storage sequence, uint month) internal returns (uint) { if (sequence.firstUnprocessedMonth == 0) { return 0; } if (sequence.firstUnprocessedMonth <= month) { for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) { uint nextValue = sequence.value[i.sub(1)].add(sequence.addDiff[i]).boundedSub(sequence.subtractDiff[i]); if (sequence.value[i] != nextValue) { sequence.value[i] = nextValue; } if (sequence.addDiff[i] > 0) { delete sequence.addDiff[i]; } if (sequence.subtractDiff[i] > 0) { delete sequence.subtractDiff[i]; } } sequence.firstUnprocessedMonth = month.add(1); } return sequence.value[month]; } function getValueInSequence(Sequence storage sequence, uint month) internal view returns (uint) { if (sequence.firstUnprocessedMonth == 0) { return 0; } if (sequence.firstUnprocessedMonth <= month) { uint value = sequence.value[sequence.firstUnprocessedMonth.sub(1)]; for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) { value = value.add(sequence.addDiff[i]).sub(sequence.subtractDiff[i]); } return value; } else { return sequence.value[month]; } } function getValuesInSequence(Sequence storage sequence) internal view returns (uint[] memory values) { if (sequence.firstUnprocessedMonth == 0) { return values; } uint begin = sequence.firstUnprocessedMonth.sub(1); uint end = sequence.lastChangedMonth.add(1); if (end <= begin) { end = begin.add(1); } values = new uint[](end.sub(begin)); values[0] = sequence.value[sequence.firstUnprocessedMonth.sub(1)]; for (uint i = 0; i.add(1) < values.length; ++i) { uint month = sequence.firstUnprocessedMonth.add(i); values[i.add(1)] = values[i].add(sequence.addDiff[month]).sub(sequence.subtractDiff[month]); } } function reduceSequence( Sequence storage sequence, FractionUtils.Fraction memory reducingCoefficient, uint month) internal { require(month.add(1) >= sequence.firstUnprocessedMonth, "Cannot reduce value in the past"); require( reducingCoefficient.numerator <= reducingCoefficient.denominator, "Increasing of values is not implemented"); if (sequence.firstUnprocessedMonth == 0) { return; } uint value = getAndUpdateValueInSequence(sequence, month); if (value.approximatelyEqual(0)) { return; } sequence.value[month] = sequence.value[month] .mul(reducingCoefficient.numerator) .div(reducingCoefficient.denominator); for (uint i = month.add(1); i <= sequence.lastChangedMonth; ++i) { sequence.subtractDiff[i] = sequence.subtractDiff[i] .mul(reducingCoefficient.numerator) .div(reducingCoefficient.denominator); } } // functions for value function addToValue(Value storage sequence, uint diff, uint month) internal { require(sequence.firstUnprocessedMonth <= month, "Cannot add to the past"); if (sequence.firstUnprocessedMonth == 0) { sequence.firstUnprocessedMonth = month; sequence.lastChangedMonth = month; } if (month > sequence.lastChangedMonth) { sequence.lastChangedMonth = month; } if (month >= sequence.firstUnprocessedMonth) { sequence.addDiff[month] = sequence.addDiff[month].add(diff); } else { sequence.value = sequence.value.add(diff); } } function subtractFromValue(Value storage sequence, uint diff, uint month) internal { require(sequence.firstUnprocessedMonth <= month.add(1), "Cannot subtract from the past"); if (sequence.firstUnprocessedMonth == 0) { sequence.firstUnprocessedMonth = month; sequence.lastChangedMonth = month; } if (month > sequence.lastChangedMonth) { sequence.lastChangedMonth = month; } if (month >= sequence.firstUnprocessedMonth) { sequence.subtractDiff[month] = sequence.subtractDiff[month].add(diff); } else { sequence.value = sequence.value.boundedSub(diff); } } function getAndUpdateValue(Value storage sequence, uint month) internal returns (uint) { require( month.add(1) >= sequence.firstUnprocessedMonth, "Cannot calculate value in the past"); if (sequence.firstUnprocessedMonth == 0) { return 0; } if (sequence.firstUnprocessedMonth <= month) { uint value = sequence.value; for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) { value = value.add(sequence.addDiff[i]).boundedSub(sequence.subtractDiff[i]); if (sequence.addDiff[i] > 0) { delete sequence.addDiff[i]; } if (sequence.subtractDiff[i] > 0) { delete sequence.subtractDiff[i]; } } if (sequence.value != value) { sequence.value = value; } sequence.firstUnprocessedMonth = month.add(1); } return sequence.value; } function getValue(Value storage sequence, uint month) internal view returns (uint) { require( month.add(1) >= sequence.firstUnprocessedMonth, "Cannot calculate value in the past"); if (sequence.firstUnprocessedMonth == 0) { return 0; } if (sequence.firstUnprocessedMonth <= month) { uint value = sequence.value; for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) { value = value.add(sequence.addDiff[i]).sub(sequence.subtractDiff[i]); } return value; } else { return sequence.value; } } function getValues(Value storage sequence) internal view returns (uint[] memory values) { if (sequence.firstUnprocessedMonth == 0) { return values; } uint begin = sequence.firstUnprocessedMonth.sub(1); uint end = sequence.lastChangedMonth.add(1); if (end <= begin) { end = begin.add(1); } values = new uint[](end.sub(begin)); values[0] = sequence.value; for (uint i = 0; i.add(1) < values.length; ++i) { uint month = sequence.firstUnprocessedMonth.add(i); values[i.add(1)] = values[i].add(sequence.addDiff[month]).sub(sequence.subtractDiff[month]); } } function reduceValue( Value storage sequence, uint amount, uint month) internal returns (FractionUtils.Fraction memory) { require(month.add(1) >= sequence.firstUnprocessedMonth, "Cannot reduce value in the past"); if (sequence.firstUnprocessedMonth == 0) { return FractionUtils.createFraction(0); } uint value = getAndUpdateValue(sequence, month); if (value.approximatelyEqual(0)) { return FractionUtils.createFraction(0); } uint _amount = amount; if (value < amount) { _amount = value; } FractionUtils.Fraction memory reducingCoefficient = FractionUtils.createFraction(value.boundedSub(_amount), value); reduceValueByCoefficient(sequence, reducingCoefficient, month); return reducingCoefficient; } function reduceValueByCoefficient( Value storage sequence, FractionUtils.Fraction memory reducingCoefficient, uint month) internal { reduceValueByCoefficientAndUpdateSumIfNeeded( sequence, sequence, reducingCoefficient, month, false); } function reduceValueByCoefficientAndUpdateSum( Value storage sequence, Value storage sumSequence, FractionUtils.Fraction memory reducingCoefficient, uint month) internal { reduceValueByCoefficientAndUpdateSumIfNeeded( sequence, sumSequence, reducingCoefficient, month, true); } function reduceValueByCoefficientAndUpdateSumIfNeeded( Value storage sequence, Value storage sumSequence, FractionUtils.Fraction memory reducingCoefficient, uint month, bool hasSumSequence) internal { require(month.add(1) >= sequence.firstUnprocessedMonth, "Cannot reduce value in the past"); if (hasSumSequence) { require(month.add(1) >= sumSequence.firstUnprocessedMonth, "Cannot reduce value in the past"); } require( reducingCoefficient.numerator <= reducingCoefficient.denominator, "Increasing of values is not implemented"); if (sequence.firstUnprocessedMonth == 0) { return; } uint value = getAndUpdateValue(sequence, month); if (value.approximatelyEqual(0)) { return; } uint newValue = sequence.value.mul(reducingCoefficient.numerator).div(reducingCoefficient.denominator); if (hasSumSequence) { subtractFromValue(sumSequence, sequence.value.boundedSub(newValue), month); } sequence.value = newValue; for (uint i = month.add(1); i <= sequence.lastChangedMonth; ++i) { uint newDiff = sequence.subtractDiff[i] .mul(reducingCoefficient.numerator) .div(reducingCoefficient.denominator); if (hasSumSequence) { sumSequence.subtractDiff[i] = sumSequence.subtractDiff[i] .boundedSub(sequence.subtractDiff[i].boundedSub(newDiff)); } sequence.subtractDiff[i] = newDiff; } } function clear(Value storage sequence) internal { for (uint i = sequence.firstUnprocessedMonth; i <= sequence.lastChangedMonth; ++i) { if (sequence.addDiff[i] > 0) { delete sequence.addDiff[i]; } if (sequence.subtractDiff[i] > 0) { delete sequence.subtractDiff[i]; } } if (sequence.value > 0) { delete sequence.value; } if (sequence.firstUnprocessedMonth > 0) { delete sequence.firstUnprocessedMonth; } if (sequence.lastChangedMonth > 0) { delete sequence.lastChangedMonth; } } }
52,906
2
// store a proof of existence in the contract state
function storeProof(bytes32 proof) internal { proofs[proof] = true; }
function storeProof(bytes32 proof) internal { proofs[proof] = true; }
22,883
321
// Returns the value associated with `key`.O(1). Requirements: - `key` must be in the map. /
function _get(Map storage map, bytes32 key) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based }
function _get(Map storage map, bytes32 key) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based }
1,920
67
// If we entered here, that means the change output with a proper non-zero value was found.
resultInfo.changeIndex = uint32(i); resultInfo.changeValue = outputValue;
resultInfo.changeIndex = uint32(i); resultInfo.changeValue = outputValue;
10,959
23
// T1 - T4: OK
contract BoringOwnableData { // V1 - V5: OK address public owner; // V1 - V5: OK address public pendingOwner; }
contract BoringOwnableData { // V1 - V5: OK address public owner; // V1 - V5: OK address public pendingOwner; }
4,721
25
// ERC165
bytes4 public constant INTERFACE_SIGNATURE_ERC165 = bytes4(keccak256('supportsInterface(bytes4)')); bytes4 public constant INTERFACE_SIGNATURE_Ticket721Controller = bytes4(keccak256('getMintPrice()')) ^ bytes4(keccak256('getTicketPrice(uint256)')) ^ bytes4(keccak256('getLinkedSale()')) ^ bytes4(keccak256('name()')) ^ bytes4(keccak256('getData()')) ^ bytes4(keccak256('getSaleEnd()')) ^
bytes4 public constant INTERFACE_SIGNATURE_ERC165 = bytes4(keccak256('supportsInterface(bytes4)')); bytes4 public constant INTERFACE_SIGNATURE_Ticket721Controller = bytes4(keccak256('getMintPrice()')) ^ bytes4(keccak256('getTicketPrice(uint256)')) ^ bytes4(keccak256('getLinkedSale()')) ^ bytes4(keccak256('name()')) ^ bytes4(keccak256('getData()')) ^ bytes4(keccak256('getSaleEnd()')) ^
6,989
14
// Contract owner address
address public owner;
address public owner;
325
17
// Returns the URI for a given token's metadata/id the token ID of interest/ return the URI for this token
function tokenURI(uint256 id) public view override returns (string memory) { if(ownerOf(id) == address(0)) revert TokenDoesNotExist(); if(idToBatch(id) > _revealedBatch) return preRevealURI; uint256 offsetId = getShuffledId(id); return string(abi.encodePacked(baseURI,offsetId.toString(),".json")); }
function tokenURI(uint256 id) public view override returns (string memory) { if(ownerOf(id) == address(0)) revert TokenDoesNotExist(); if(idToBatch(id) > _revealedBatch) return preRevealURI; uint256 offsetId = getShuffledId(id); return string(abi.encodePacked(baseURI,offsetId.toString(),".json")); }
18,311
78
// 设置管理员
* @param {Object} address */ function admAccount(address target, bool freeze) onlyOwner public { admins[target] = freeze; }
* @param {Object} address */ function admAccount(address target, bool freeze) onlyOwner public { admins[target] = freeze; }
17,706
509
// Approves token for 3rd party contract. Restricted for current credit manager only/token ERC20 token for allowance/swapContract Swap contract address
function approveToken(address token, address swapContract) external override creditManagerOnly // T:[CA-2]
function approveToken(address token, address swapContract) external override creditManagerOnly // T:[CA-2]
34,544
2
// STRUCTURE OF SOLAR SYSTEMThe information details and properties that each specific solar system should have
struct SolarSystem { uint panelSize; uint totalValue; address consumer; uint percentageHeld; uint lastPaymentTimestamp; uint unpaidUsage; // measured in kWh // ADD // This will at least also need the size of the battery bank, inverter size, and geo location. // Note: Consider onboarding here the energy meter. The main and most accurate energy meter for the solar system will come from datalogger and IoT monitor of the actual inverter/regulator. The brand and comms protocol these have may defer eg. Schneider vs SMA. }
struct SolarSystem { uint panelSize; uint totalValue; address consumer; uint percentageHeld; uint lastPaymentTimestamp; uint unpaidUsage; // measured in kWh // ADD // This will at least also need the size of the battery bank, inverter size, and geo location. // Note: Consider onboarding here the energy meter. The main and most accurate energy meter for the solar system will come from datalogger and IoT monitor of the actual inverter/regulator. The brand and comms protocol these have may defer eg. Schneider vs SMA. }
44,081
92
// Pancakeswap
IUniswapV2Router public pancakeRouter = IUniswapV2Router(0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F); mapping(address => mapping(address => address[])) public uniswapPaths;
IUniswapV2Router public pancakeRouter = IUniswapV2Router(0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F); mapping(address => mapping(address => address[])) public uniswapPaths;
10,767
95
// withdrow for manual distribution
function withdrawFund() onlyOwner payable{ require(isFinalized); require(minFundingGoalReached()); uint256 tokenAmount = token.balanceOf(address(this)); token.transfer(wallet, tokenAmount); }
function withdrawFund() onlyOwner payable{ require(isFinalized); require(minFundingGoalReached()); uint256 tokenAmount = token.balanceOf(address(this)); token.transfer(wallet, tokenAmount); }
29,501
137
// Returns a slice containing the entire bytes32, interpreted as a null-terminated utf-8 string. self The bytes32 value to convert to a slice.return A new slice containing the value of the input argument up to thefirst null. /
function toSliceB32(bytes32 self) internal pure returns (slice memory ret) { // Allocate space for `self` in memory, copy it there, and point ret at it assembly { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x20)) mstore(ptr, self) mstore(add(ret, 0x20), ptr) } ret._len = len(self); }
function toSliceB32(bytes32 self) internal pure returns (slice memory ret) { // Allocate space for `self` in memory, copy it there, and point ret at it assembly { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x20)) mstore(ptr, self) mstore(add(ret, 0x20), ptr) } ret._len = len(self); }
47,102
6
// 0x1626ba7e is the interfaceId for signature contracts (see IERC1271)
return IERC1271(signer).isValidSignature(digest, abi.encodePacked(r, s, v)) == 0x1626ba7e;
return IERC1271(signer).isValidSignature(digest, abi.encodePacked(r, s, v)) == 0x1626ba7e;
38,030
50
// exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true;
30,952
84
// Amount of wNXM (in token Wei) to reserve each period. Overwrites reservePercent in update.
uint256 public reserveAmount;
uint256 public reserveAmount;
19,860
532
// Deserialize the cash group storage bytes into a user friendly object
function deserializeCashGroupStorage(uint256 currencyId) internal view returns (CashGroupSettings memory)
function deserializeCashGroupStorage(uint256 currencyId) internal view returns (CashGroupSettings memory)
6,104
27
// Public Functions: Pre-Execution//Allows a user to prove the initial state of a contract. _ovmContractAddress Address of the contract on the OVM. _ethContractAddress Address of the corresponding contract on L1. _stateTrieWitness Proof of the account state. /
function proveContractState( address _ovmContractAddress, address _ethContractAddress, bytes memory _stateTrieWitness ) override external onlyDuringPhase(TransitionPhase.PRE_EXECUTION) contributesToFraudProof(preStateRoot, transactionHash)
function proveContractState( address _ovmContractAddress, address _ethContractAddress, bytes memory _stateTrieWitness ) override external onlyDuringPhase(TransitionPhase.PRE_EXECUTION) contributesToFraudProof(preStateRoot, transactionHash)
35,084
58
// Abstract method//Gets the number of valid signatures that must be provided to execute a specific relayed transaction._wallet The target wallet._data The data of the relayed transaction. return The number of required signatures./
function getRequiredSignatures(BaseWallet _wallet, bytes _data) internal view returns (uint256);
function getRequiredSignatures(BaseWallet _wallet, bytes _data) internal view returns (uint256);
2,391
48
// Duration of stake
uint256 constant stakeDuration = 30 days;
uint256 constant stakeDuration = 30 days;
78,446
20
// Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. /
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); }
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); }
167
28
// should find the best rate strategy for all Reserves, even if the user doesnt have an investments in it. This should be based off the stable APR and variable APR as well as the offered Monthly payment, prinicpal balance, and expected loan duration Basically find the method that gives them the most profit for their profile type.
/*function setBestRateStrategy(address _reserve, address _user) public{ AdvisorUserReserveData storage user = advisorUserReserveData[_user][_reserve]; //get User Reserve Data (uint256 currentATokenBalance, uint256 currentUnderlyingBalance, uint256 currentBorrowBalance, uint256 principalBorrowBalance, uint256 borrowRateMode, uint256 borrowRate, uint256 liquidityRate, uint256 originationFee, uint256 variableBorrowIndex, uint256 lastUpdateTimestamp, bool usageAsCollateralEnabled) = lendingPool.getUserReserveData(_reserve, _user); }*/
/*function setBestRateStrategy(address _reserve, address _user) public{ AdvisorUserReserveData storage user = advisorUserReserveData[_user][_reserve]; //get User Reserve Data (uint256 currentATokenBalance, uint256 currentUnderlyingBalance, uint256 currentBorrowBalance, uint256 principalBorrowBalance, uint256 borrowRateMode, uint256 borrowRate, uint256 liquidityRate, uint256 originationFee, uint256 variableBorrowIndex, uint256 lastUpdateTimestamp, bool usageAsCollateralEnabled) = lendingPool.getUserReserveData(_reserve, _user); }*/
13,628
42
// list allows a DDA to remove asset_asset address /
function unlistDda(address _asset) public onlyOwner() { require(blacklist[msg.sender] == false); uint256 indexToDelete; uint256 lastAcctIndex; address lastAdd; ListAsset storage listing = listOfAssets[_asset]; listing.price = 0; listing.amount= 0; listing.isLong= false; indexToDelete = openDdaListIndex[_asset]; lastAcctIndex = openDdaListAssets.length.sub(1); lastAdd = openDdaListAssets[lastAcctIndex]; openDdaListAssets[indexToDelete]=lastAdd; openDdaListIndex[lastAdd]= indexToDelete; openDdaListAssets.length--; openDdaListIndex[_asset] = 0; }
function unlistDda(address _asset) public onlyOwner() { require(blacklist[msg.sender] == false); uint256 indexToDelete; uint256 lastAcctIndex; address lastAdd; ListAsset storage listing = listOfAssets[_asset]; listing.price = 0; listing.amount= 0; listing.isLong= false; indexToDelete = openDdaListIndex[_asset]; lastAcctIndex = openDdaListAssets.length.sub(1); lastAdd = openDdaListAssets[lastAcctIndex]; openDdaListAssets[indexToDelete]=lastAdd; openDdaListIndex[lastAdd]= indexToDelete; openDdaListAssets.length--; openDdaListIndex[_asset] = 0; }
23,843
8
// require(false, "HELLO: HOW ARE YOU TODAY!");
liquidity = IUniswapV2Pair(pair).mint(to); // << PROBLEM IS HERE
liquidity = IUniswapV2Pair(pair).mint(to); // << PROBLEM IS HERE
12,908
9
// Implements ISnapshotable
function createSnapshot() public returns (uint256)
function createSnapshot() public returns (uint256)
7,717
19
// uint256 roundValue = value.ceil(basePercent);
uint256 percent = value.mul(basePercent).div(10000); return percent;
uint256 percent = value.mul(basePercent).div(10000); return percent;
13,362
55
// Create pair address for uniswap
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[Wallet_Dev] = true; emit Transfer(address(0), owner(), _tTotal);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[Wallet_Dev] = true; emit Transfer(address(0), owner(), _tTotal);
2,557
9
// Check oracle authorization
if(block.number - order.blockNumber >= blockRange) revert BlockOutOfRange(); if ( !_validateOracleAuthorization( orderHash, order.signatureVersion, order.extraSignature, order.blockNumber ) ) { return false;
if(block.number - order.blockNumber >= blockRange) revert BlockOutOfRange(); if ( !_validateOracleAuthorization( orderHash, order.signatureVersion, order.extraSignature, order.blockNumber ) ) { return false;
41,336
55
// give them shares for the NFTs
uint256 sp = adjustNftShares(_nftId) * _amount; userNftLocks[msg.sender][_nftId].sharePoints = userNftLocks[msg.sender][_nftId].sharePoints + sp; vaultContracts.minerContract.giveShares(msg.sender, sp, true);
uint256 sp = adjustNftShares(_nftId) * _amount; userNftLocks[msg.sender][_nftId].sharePoints = userNftLocks[msg.sender][_nftId].sharePoints + sp; vaultContracts.minerContract.giveShares(msg.sender, sp, true);
5,224
634
// res += valcoefficients[154].
res := addmod(res, mulmod(val, /*coefficients[154]*/ mload(0x1740), PRIME), PRIME)
res := addmod(res, mulmod(val, /*coefficients[154]*/ mload(0x1740), PRIME), PRIME)
59,071
13
// Returns proof for NFT. _tokenId Id of the NFT. /
function tokenProof( uint256 _tokenId ) validNFToken(_tokenId) external view returns(string)
function tokenProof( uint256 _tokenId ) validNFToken(_tokenId) external view returns(string)
4,364
0
// ITreasurer extension to allow express claim
interface ITreasurerExpress is ITreasurer { // Allows user to claim reward in an express way function claimRewardExpress(uint256[] calldata _weeksToClaim) external; }
interface ITreasurerExpress is ITreasurer { // Allows user to claim reward in an express way function claimRewardExpress(uint256[] calldata _weeksToClaim) external; }
5,704
52
// returns a unique id based on the nft registry and tokenId the nftID is used to set the risk group and value for nfts
function nftID(address registry, uint tokenId) public pure returns (bytes32) { return keccak256(abi.encodePacked(registry, tokenId)); }
function nftID(address registry, uint tokenId) public pure returns (bytes32) { return keccak256(abi.encodePacked(registry, tokenId)); }
40,375
363
// AddressWhitelist provides payee-whitelist functionality./This contract will allow the user to maintain a whitelist of addresses/These addresses will live outside of the various spend limits
contract AddressWhitelist is ControllableOwnable { using SafeMath for uint256; event AddedToWhitelist(address _sender, address[] _addresses); event SubmittedWhitelistAddition(address[] _addresses, bytes32 _hash); event CancelledWhitelistAddition(address _sender, bytes32 _hash); event RemovedFromWhitelist(address _sender, address[] _addresses); event SubmittedWhitelistRemoval(address[] _addresses, bytes32 _hash); event CancelledWhitelistRemoval(address _sender, bytes32 _hash); mapping(address => bool) public whitelistMap; address[] public whitelistArray; address[] private _pendingWhitelistAddition; address[] private _pendingWhitelistRemoval; bool public submittedWhitelistAddition; bool public submittedWhitelistRemoval; bool public isSetWhitelist; /// @dev Check if the provided addresses contain the owner or the zero-address address. modifier hasNoOwnerOrZeroAddress(address[] memory _addresses) { for (uint i = 0; i < _addresses.length; i++) { require(!_isOwner(_addresses[i]), "provided whitelist contains the owner address"); require(_addresses[i] != address(0), "provided whitelist contains the zero address"); } _; } /// @dev Check that neither addition nor removal operations have already been submitted. modifier noActiveSubmission() { require(!submittedWhitelistAddition && !submittedWhitelistRemoval, "whitelist operation has already been submitted"); _; } /// @dev Getter for pending addition array. function pendingWhitelistAddition() external view returns (address[] memory) { return _pendingWhitelistAddition; } /// @dev Getter for pending removal array. function pendingWhitelistRemoval() external view returns (address[] memory) { return _pendingWhitelistRemoval; } /// @dev Add initial addresses to the whitelist. /// @param _addresses are the Ethereum addresses to be whitelisted. function setWhitelist(address[] calldata _addresses) external onlyOwner hasNoOwnerOrZeroAddress(_addresses) { // Require that the whitelist has not been initialized. require(!isSetWhitelist, "whitelist has already been initialized"); // Add each of the provided addresses to the whitelist. for (uint i = 0; i < _addresses.length; i++) { // adds to the whitelist mapping whitelistMap[_addresses[i]] = true; // adds to the whitelist array whitelistArray.push(_addresses[i]); } isSetWhitelist = true; // Emit the addition event. emit AddedToWhitelist(msg.sender, _addresses); } /// @dev Add addresses to the whitelist. /// @param _addresses are the Ethereum addresses to be whitelisted. function submitWhitelistAddition(address[] calldata _addresses) external onlyOwner noActiveSubmission hasNoOwnerOrZeroAddress(_addresses) { // Require that the whitelist has been initialized. require(isSetWhitelist, "whitelist has not been initialized"); // Require this array of addresses not empty require(_addresses.length > 0, "pending whitelist addition is empty"); // Set the provided addresses to the pending addition addresses. _pendingWhitelistAddition = _addresses; // Flag the operation as submitted. submittedWhitelistAddition = true; // Emit the submission event. emit SubmittedWhitelistAddition(_addresses, calculateHash(_addresses)); } /// @dev Confirm pending whitelist addition. /// @dev This will only ever be applied post 2FA, by one of the Controllers /// @param _hash is the hash of the pending whitelist array, a form of lamport lock function confirmWhitelistAddition(bytes32 _hash) external onlyController { // Require that the whitelist addition has been submitted. require(submittedWhitelistAddition, "whitelist addition has not been submitted"); // Require that confirmation hash and the hash of the pending whitelist addition match require(_hash == calculateHash(_pendingWhitelistAddition), "hash of the pending whitelist addition do not match"); // Whitelist pending addresses. for (uint i = 0; i < _pendingWhitelistAddition.length; i++) { // check if it doesn't exist already. if (!whitelistMap[_pendingWhitelistAddition[i]]) { // add to the Map and the Array whitelistMap[_pendingWhitelistAddition[i]] = true; whitelistArray.push(_pendingWhitelistAddition[i]); } } // Emit the addition event. emit AddedToWhitelist(msg.sender, _pendingWhitelistAddition); // Reset pending addresses. delete _pendingWhitelistAddition; // Reset the submission flag. submittedWhitelistAddition = false; } /// @dev Cancel pending whitelist addition. function cancelWhitelistAddition(bytes32 _hash) external onlyOwnerOrController { // Check if operation has been submitted. require(submittedWhitelistAddition, "whitelist addition has not been submitted"); // Require that confirmation hash and the hash of the pending whitelist addition match require(_hash == calculateHash(_pendingWhitelistAddition), "hash of the pending whitelist addition does not match"); // Reset pending addresses. delete _pendingWhitelistAddition; // Reset the submitted operation flag. submittedWhitelistAddition = false; // Emit the cancellation event. emit CancelledWhitelistAddition(msg.sender, _hash); } /// @dev Remove addresses from the whitelist. /// @param _addresses are the Ethereum addresses to be removed. function submitWhitelistRemoval(address[] calldata _addresses) external onlyOwner noActiveSubmission { // Require that the whitelist has been initialized. require(isSetWhitelist, "whitelist has not been initialized"); // Require that the array of addresses is not empty require(_addresses.length > 0, "pending whitelist removal is empty"); // Add the provided addresses to the pending addition list. _pendingWhitelistRemoval = _addresses; // Flag the operation as submitted. submittedWhitelistRemoval = true; // Emit the submission event. emit SubmittedWhitelistRemoval(_addresses, calculateHash(_addresses)); } /// @dev Confirm pending removal of whitelisted addresses. function confirmWhitelistRemoval(bytes32 _hash) external onlyController { // Require that the pending whitelist is not empty and the operation has been submitted. require(submittedWhitelistRemoval, "whitelist removal has not been submitted"); // Require that confirmation hash and the hash of the pending whitelist removal match require(_hash == calculateHash(_pendingWhitelistRemoval), "hash of the pending whitelist removal does not match the confirmed hash"); // Remove pending addresses. for (uint i = 0; i < _pendingWhitelistRemoval.length; i++) { // check if it exists if (whitelistMap[_pendingWhitelistRemoval[i]]) { whitelistMap[_pendingWhitelistRemoval[i]] = false; for (uint j = 0; j < whitelistArray.length.sub(1); j++) { if (whitelistArray[j] == _pendingWhitelistRemoval[i]) { whitelistArray[j] = whitelistArray[whitelistArray.length - 1]; break; } } whitelistArray.length--; } } // Emit the removal event. emit RemovedFromWhitelist(msg.sender, _pendingWhitelistRemoval); // Reset pending addresses. delete _pendingWhitelistRemoval; // Reset the submission flag. submittedWhitelistRemoval = false; } /// @dev Cancel pending removal of whitelisted addresses. function cancelWhitelistRemoval(bytes32 _hash) external onlyOwnerOrController { // Check if operation has been submitted. require(submittedWhitelistRemoval, "whitelist removal has not been submitted"); // Require that confirmation hash and the hash of the pending whitelist removal match require(_hash == calculateHash(_pendingWhitelistRemoval), "hash of the pending whitelist removal do not match"); // Reset pending addresses. delete _pendingWhitelistRemoval; // Reset pending addresses. submittedWhitelistRemoval = false; // Emit the cancellation event. emit CancelledWhitelistRemoval(msg.sender, _hash); } /// @dev Method used to hash our whitelist address arrays. function calculateHash(address[] memory _addresses) public pure returns (bytes32) { return keccak256(abi.encodePacked(_addresses)); } }
contract AddressWhitelist is ControllableOwnable { using SafeMath for uint256; event AddedToWhitelist(address _sender, address[] _addresses); event SubmittedWhitelistAddition(address[] _addresses, bytes32 _hash); event CancelledWhitelistAddition(address _sender, bytes32 _hash); event RemovedFromWhitelist(address _sender, address[] _addresses); event SubmittedWhitelistRemoval(address[] _addresses, bytes32 _hash); event CancelledWhitelistRemoval(address _sender, bytes32 _hash); mapping(address => bool) public whitelistMap; address[] public whitelistArray; address[] private _pendingWhitelistAddition; address[] private _pendingWhitelistRemoval; bool public submittedWhitelistAddition; bool public submittedWhitelistRemoval; bool public isSetWhitelist; /// @dev Check if the provided addresses contain the owner or the zero-address address. modifier hasNoOwnerOrZeroAddress(address[] memory _addresses) { for (uint i = 0; i < _addresses.length; i++) { require(!_isOwner(_addresses[i]), "provided whitelist contains the owner address"); require(_addresses[i] != address(0), "provided whitelist contains the zero address"); } _; } /// @dev Check that neither addition nor removal operations have already been submitted. modifier noActiveSubmission() { require(!submittedWhitelistAddition && !submittedWhitelistRemoval, "whitelist operation has already been submitted"); _; } /// @dev Getter for pending addition array. function pendingWhitelistAddition() external view returns (address[] memory) { return _pendingWhitelistAddition; } /// @dev Getter for pending removal array. function pendingWhitelistRemoval() external view returns (address[] memory) { return _pendingWhitelistRemoval; } /// @dev Add initial addresses to the whitelist. /// @param _addresses are the Ethereum addresses to be whitelisted. function setWhitelist(address[] calldata _addresses) external onlyOwner hasNoOwnerOrZeroAddress(_addresses) { // Require that the whitelist has not been initialized. require(!isSetWhitelist, "whitelist has already been initialized"); // Add each of the provided addresses to the whitelist. for (uint i = 0; i < _addresses.length; i++) { // adds to the whitelist mapping whitelistMap[_addresses[i]] = true; // adds to the whitelist array whitelistArray.push(_addresses[i]); } isSetWhitelist = true; // Emit the addition event. emit AddedToWhitelist(msg.sender, _addresses); } /// @dev Add addresses to the whitelist. /// @param _addresses are the Ethereum addresses to be whitelisted. function submitWhitelistAddition(address[] calldata _addresses) external onlyOwner noActiveSubmission hasNoOwnerOrZeroAddress(_addresses) { // Require that the whitelist has been initialized. require(isSetWhitelist, "whitelist has not been initialized"); // Require this array of addresses not empty require(_addresses.length > 0, "pending whitelist addition is empty"); // Set the provided addresses to the pending addition addresses. _pendingWhitelistAddition = _addresses; // Flag the operation as submitted. submittedWhitelistAddition = true; // Emit the submission event. emit SubmittedWhitelistAddition(_addresses, calculateHash(_addresses)); } /// @dev Confirm pending whitelist addition. /// @dev This will only ever be applied post 2FA, by one of the Controllers /// @param _hash is the hash of the pending whitelist array, a form of lamport lock function confirmWhitelistAddition(bytes32 _hash) external onlyController { // Require that the whitelist addition has been submitted. require(submittedWhitelistAddition, "whitelist addition has not been submitted"); // Require that confirmation hash and the hash of the pending whitelist addition match require(_hash == calculateHash(_pendingWhitelistAddition), "hash of the pending whitelist addition do not match"); // Whitelist pending addresses. for (uint i = 0; i < _pendingWhitelistAddition.length; i++) { // check if it doesn't exist already. if (!whitelistMap[_pendingWhitelistAddition[i]]) { // add to the Map and the Array whitelistMap[_pendingWhitelistAddition[i]] = true; whitelistArray.push(_pendingWhitelistAddition[i]); } } // Emit the addition event. emit AddedToWhitelist(msg.sender, _pendingWhitelistAddition); // Reset pending addresses. delete _pendingWhitelistAddition; // Reset the submission flag. submittedWhitelistAddition = false; } /// @dev Cancel pending whitelist addition. function cancelWhitelistAddition(bytes32 _hash) external onlyOwnerOrController { // Check if operation has been submitted. require(submittedWhitelistAddition, "whitelist addition has not been submitted"); // Require that confirmation hash and the hash of the pending whitelist addition match require(_hash == calculateHash(_pendingWhitelistAddition), "hash of the pending whitelist addition does not match"); // Reset pending addresses. delete _pendingWhitelistAddition; // Reset the submitted operation flag. submittedWhitelistAddition = false; // Emit the cancellation event. emit CancelledWhitelistAddition(msg.sender, _hash); } /// @dev Remove addresses from the whitelist. /// @param _addresses are the Ethereum addresses to be removed. function submitWhitelistRemoval(address[] calldata _addresses) external onlyOwner noActiveSubmission { // Require that the whitelist has been initialized. require(isSetWhitelist, "whitelist has not been initialized"); // Require that the array of addresses is not empty require(_addresses.length > 0, "pending whitelist removal is empty"); // Add the provided addresses to the pending addition list. _pendingWhitelistRemoval = _addresses; // Flag the operation as submitted. submittedWhitelistRemoval = true; // Emit the submission event. emit SubmittedWhitelistRemoval(_addresses, calculateHash(_addresses)); } /// @dev Confirm pending removal of whitelisted addresses. function confirmWhitelistRemoval(bytes32 _hash) external onlyController { // Require that the pending whitelist is not empty and the operation has been submitted. require(submittedWhitelistRemoval, "whitelist removal has not been submitted"); // Require that confirmation hash and the hash of the pending whitelist removal match require(_hash == calculateHash(_pendingWhitelistRemoval), "hash of the pending whitelist removal does not match the confirmed hash"); // Remove pending addresses. for (uint i = 0; i < _pendingWhitelistRemoval.length; i++) { // check if it exists if (whitelistMap[_pendingWhitelistRemoval[i]]) { whitelistMap[_pendingWhitelistRemoval[i]] = false; for (uint j = 0; j < whitelistArray.length.sub(1); j++) { if (whitelistArray[j] == _pendingWhitelistRemoval[i]) { whitelistArray[j] = whitelistArray[whitelistArray.length - 1]; break; } } whitelistArray.length--; } } // Emit the removal event. emit RemovedFromWhitelist(msg.sender, _pendingWhitelistRemoval); // Reset pending addresses. delete _pendingWhitelistRemoval; // Reset the submission flag. submittedWhitelistRemoval = false; } /// @dev Cancel pending removal of whitelisted addresses. function cancelWhitelistRemoval(bytes32 _hash) external onlyOwnerOrController { // Check if operation has been submitted. require(submittedWhitelistRemoval, "whitelist removal has not been submitted"); // Require that confirmation hash and the hash of the pending whitelist removal match require(_hash == calculateHash(_pendingWhitelistRemoval), "hash of the pending whitelist removal do not match"); // Reset pending addresses. delete _pendingWhitelistRemoval; // Reset pending addresses. submittedWhitelistRemoval = false; // Emit the cancellation event. emit CancelledWhitelistRemoval(msg.sender, _hash); } /// @dev Method used to hash our whitelist address arrays. function calculateHash(address[] memory _addresses) public pure returns (bytes32) { return keccak256(abi.encodePacked(_addresses)); } }
42,757
12
// function getAbilities(uint _index) public view returns(string[] memory)
// { // return existingTokens[ownedTokens[msg.sender][_index] - 1].abilities; // }
// { // return existingTokens[ownedTokens[msg.sender][_index] - 1].abilities; // }
32,724
2
// We expect a first bytes32 number of addresses following by the bytes20 addresses packed.
require( (data.length % 20 == 0), "wrong data sent, length doesn't match" ); uint256 numAddresses = data.length / 20;
require( (data.length % 20 == 0), "wrong data sent, length doesn't match" ); uint256 numAddresses = data.length / 20;
1,690
5
// If there's a price, collect price.
address artistRecipient = primarySaleRecipient[_tokenId]; _collectPriceOnClaim(artistRecipient, _quantity, _currency, _pricePerToken);
address artistRecipient = primarySaleRecipient[_tokenId]; _collectPriceOnClaim(artistRecipient, _quantity, _currency, _pricePerToken);
13,508
31
// if (receiver == 0) receiver = msg.sender;
require(whitelisted[receiver]); require(tokensinvestor[receiver] > 0); uint256 tokensclaim = tokensinvestor[receiver]; balances[address(this)] = (balances[address(this)]).sub(tokensclaim); balances[receiver] = (balances[receiver]).add(tokensclaim); tokensinvestor[receiver] = 0; emit Transfer(address(this), receiver, balances[receiver]);
require(whitelisted[receiver]); require(tokensinvestor[receiver] > 0); uint256 tokensclaim = tokensinvestor[receiver]; balances[address(this)] = (balances[address(this)]).sub(tokensclaim); balances[receiver] = (balances[receiver]).add(tokensclaim); tokensinvestor[receiver] = 0; emit Transfer(address(this), receiver, balances[receiver]);
35,926
235
// Remit the fee if required
if (fee > 0) {
if (fee > 0) {
24,438
130
// 3. It swaps the {vbswap} token for {lpToken0} & {lpToken1}4. Adds more liquidity to the pool.5. It deposits the new LP tokens. /
function harvest() external whenNotPaused { require(!Address.isContract(msg.sender), "!contract"); IRewardPool(rewardPool).withdraw(poolId, 0); chargeFees(); addLiquidity(); deposit(); emit StratHarvest(msg.sender); }
function harvest() external whenNotPaused { require(!Address.isContract(msg.sender), "!contract"); IRewardPool(rewardPool).withdraw(poolId, 0); chargeFees(); addLiquidity(); deposit(); emit StratHarvest(msg.sender); }
13,073
68
// values obtained are out of 0-31 inclusive
uint256 result = energy.add(metabolism).mul(1e18); // range of 0-64 1E18 if (og1.contains(tamagId)){ result = result.mul(OG1_BONUS).div(100); }else if (og2.contains(tamagId)){
uint256 result = energy.add(metabolism).mul(1e18); // range of 0-64 1E18 if (og1.contains(tamagId)){ result = result.mul(OG1_BONUS).div(100); }else if (og2.contains(tamagId)){
43,428
26
// _result = false;
var st = userSellingTokenOf[msg.sender][_tokenAddress]; st.cancel = true; Erc20Token token = Erc20Token(_tokenAddress); var sellingAmount = token.allowance(msg.sender,this); //防范外部调用, 2017-09-27 st.thisAmount = sellingAmount; OnSetSellingToken(_tokenAddress, msg.sender, sellingAmount, st.price, st.lineTime, st.cancel);
var st = userSellingTokenOf[msg.sender][_tokenAddress]; st.cancel = true; Erc20Token token = Erc20Token(_tokenAddress); var sellingAmount = token.allowance(msg.sender,this); //防范外部调用, 2017-09-27 st.thisAmount = sellingAmount; OnSetSellingToken(_tokenAddress, msg.sender, sellingAmount, st.price, st.lineTime, st.cancel);
21,409
36
// Gets total balance of this contract in terms of the underlying This excludes the value of the current message, if anyreturn The quantity of underlying tokens owned by this contract /
function getCashOnChain() internal view returns (uint) { EIP20Interface token = EIP20Interface(underlying); return token.balanceOf(address(this)); }
function getCashOnChain() internal view returns (uint) { EIP20Interface token = EIP20Interface(underlying); return token.balanceOf(address(this)); }
40,088
407
// require(currentContract != 0, "If app code has not been set yet, do not call"); Todo: filter out some calls or handle in the end fallback
delegatedFwd(loadImplementation(), msg.data);
delegatedFwd(loadImplementation(), msg.data);
12,626
69
// The interface of DefiPortal
DefiPortalInterface public defiPortal;
DefiPortalInterface public defiPortal;
9,037
590
// Get the pending rewards for a userreturn rewards Returns rewards[0] as the rewards available now, as well as rewards /
function redeemRewards(uint256 expiry, address user) external returns (uint256 rewards);
function redeemRewards(uint256 expiry, address user) external returns (uint256 rewards);
69,771
204
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; IERC20(pool.stakeToken).safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; }
function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; IERC20(pool.stakeToken).safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; }
1,520
61
// MiniMeTokenFactory / 이 계약은 계약에서 복제 계약을 생성하는 데 사용됩니다.
contract MiniMeTokenFactory { // 새로운 기능으로 새로운 토큰을 만들어 DApp를 업데이트하십시오. // msg.sender 는 이 복제 토큰의 컨트롤러가됩니다. // _parentToken 복제 될 토큰의 주소 // _snapshotBlock 상위 토큰 블록 // 복제 토큰의 초기 배포 결정 // _tokenName 새 토큰의 이름 // @param _decimalUnits 새 토큰의 소수 자릿수 // @param _tokenSymbol 새 토큰에 대한 토큰 기호 // @param _transfersEnabled true 이면 토큰을 전송할 수 있습니다. // @return 새 토큰 계약의 주소 function createCloneToken( address _parentToken, uint _snapshotBlock, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, bool _transfersEnabled ) public returns (MiniMeToken) { MiniMeToken newToken = new MiniMeToken( this, _parentToken, _snapshotBlock, _tokenName, _decimalUnits, _tokenSymbol, _transfersEnabled ); newToken.changeController(msg.sender); return newToken; } }
contract MiniMeTokenFactory { // 새로운 기능으로 새로운 토큰을 만들어 DApp를 업데이트하십시오. // msg.sender 는 이 복제 토큰의 컨트롤러가됩니다. // _parentToken 복제 될 토큰의 주소 // _snapshotBlock 상위 토큰 블록 // 복제 토큰의 초기 배포 결정 // _tokenName 새 토큰의 이름 // @param _decimalUnits 새 토큰의 소수 자릿수 // @param _tokenSymbol 새 토큰에 대한 토큰 기호 // @param _transfersEnabled true 이면 토큰을 전송할 수 있습니다. // @return 새 토큰 계약의 주소 function createCloneToken( address _parentToken, uint _snapshotBlock, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, bool _transfersEnabled ) public returns (MiniMeToken) { MiniMeToken newToken = new MiniMeToken( this, _parentToken, _snapshotBlock, _tokenName, _decimalUnits, _tokenSymbol, _transfersEnabled ); newToken.changeController(msg.sender); return newToken; } }
52,417
2
// Adds two exponentials, returning a new exponential. /
function addExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError error, uint result) = addUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); }
function addExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError error, uint result) = addUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); }
23,133
1
// Function to initialize the contract.It should be called through the `data` argument when creating the proxy.It must be called only once. The `assert` is to guarantee that behavior. _tokenAddress The ERC20 token address on the chain or '0x0' for Ethereum. It is the asset for the respective contract._minimumTimeBetweenExecutions The minimum time in seconds between executions to run the Compound redeem. /
function init(address _tokenAddress, uint256 _minimumTimeBetweenExecutions) external { assert( minimumTimeBetweenExecutions == 0 && executionId == 0 && totalBalance == 0 && tokenAddress == address(0) ); tokenAddress = _tokenAddress; minimumTimeBetweenExecutions = _minimumTimeBetweenExecutions; address _compound = DPiggyInterface(admin).compound(); isCompound = (_tokenAddress == _compound); totalBalance = 0; feeExemptionAmountForAucEscrowed = 0; executionId = 0; executions[executionId] = Execution({ time: now, rate: DPiggyInterface(admin).percentagePrecision(), totalDai: 0, totalRedeemed: 0, totalBought: 0, totalBalance: 0, totalFeeDeduction: 0, feeAmount: 0 }); /* Initialize the stored data that controls the reentrancy guard. * Due to the proxy, it must be set on a separate initialize method instead of the constructor. */ _notEntered = true; }
function init(address _tokenAddress, uint256 _minimumTimeBetweenExecutions) external { assert( minimumTimeBetweenExecutions == 0 && executionId == 0 && totalBalance == 0 && tokenAddress == address(0) ); tokenAddress = _tokenAddress; minimumTimeBetweenExecutions = _minimumTimeBetweenExecutions; address _compound = DPiggyInterface(admin).compound(); isCompound = (_tokenAddress == _compound); totalBalance = 0; feeExemptionAmountForAucEscrowed = 0; executionId = 0; executions[executionId] = Execution({ time: now, rate: DPiggyInterface(admin).percentagePrecision(), totalDai: 0, totalRedeemed: 0, totalBought: 0, totalBalance: 0, totalFeeDeduction: 0, feeAmount: 0 }); /* Initialize the stored data that controls the reentrancy guard. * Due to the proxy, it must be set on a separate initialize method instead of the constructor. */ _notEntered = true; }
41,261
143
// Pending - Tells if an update has been requested but not yet completed
bool pendingBitcoinPrice; bool pendingLastHash;
bool pendingBitcoinPrice; bool pendingLastHash;
6,764
6
// The GUINIV3DAIUSDC1-A Oracle is very expensive to poke, and the price should notchange frequently, so it is getting poked only once a day.
(ok,) = guniv3daiusdc1.call(abi.encodeWithSelector(0x18178358)); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("BAT-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("ZRX-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("LRC-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("BAL-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("UNIV2LINKETH-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("GUNIV3DAIUSDC1-A"))); last = block.timestamp;
(ok,) = guniv3daiusdc1.call(abi.encodeWithSelector(0x18178358)); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("BAT-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("ZRX-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("LRC-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("BAL-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("UNIV2LINKETH-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("GUNIV3DAIUSDC1-A"))); last = block.timestamp;
11,456
115
// collaboration of update / consult
function expectedPrice(address token, uint256 amountIn) external view returns (uint224 amountOut)
function expectedPrice(address token, uint256 amountIn) external view returns (uint224 amountOut)
24,963
1
// Type of distribution/token.
TokenType tokenType;
TokenType tokenType;
41,216
42
// The struct consists of ERC20-style token metadata.
struct ERC20Metadata { string name; string symbol; uint8 decimals; }
struct ERC20Metadata { string name; string symbol; uint8 decimals; }
63,240
623
// Self Permit/Functionality to call permit on any EIP-2612-compliant token for use in the route/These functions are expected to be embedded in multicalls to allow EOAs to approve a contract and call a function/ that requires an approval in a single transaction.
abstract contract SelfPermit is ISelfPermit { /// @inheritdoc ISelfPermit function selfPermit( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public payable override { ERC20(token).permit(msg.sender, address(this), value, deadline, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitIfNecessary( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable override { if (ERC20(token).allowance(msg.sender, address(this)) < value) selfPermit(token, value, deadline, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitAllowed( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public payable override { IERC20PermitAllowed(token).permit(msg.sender, address(this), nonce, expiry, true, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitAllowedIfNecessary( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external payable override { if (ERC20(token).allowance(msg.sender, address(this)) < type(uint256).max) selfPermitAllowed(token, nonce, expiry, v, r, s); } }// forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/base/Multicall.sol
abstract contract SelfPermit is ISelfPermit { /// @inheritdoc ISelfPermit function selfPermit( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public payable override { ERC20(token).permit(msg.sender, address(this), value, deadline, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitIfNecessary( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable override { if (ERC20(token).allowance(msg.sender, address(this)) < value) selfPermit(token, value, deadline, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitAllowed( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public payable override { IERC20PermitAllowed(token).permit(msg.sender, address(this), nonce, expiry, true, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitAllowedIfNecessary( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external payable override { if (ERC20(token).allowance(msg.sender, address(this)) < type(uint256).max) selfPermitAllowed(token, nonce, expiry, v, r, s); } }// forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/base/Multicall.sol
61,765
38
// Creator of the proposal
address proposer;
address proposer;
68,727
7
// send tokens via the owner
token.transferFrom(msg.sender, admin, amount); bytes32 signature = keccak256(abi.encodePacked(msg.sender, to, chainId, destChainId, amount, nonce)); emit Transfer( msg.sender, to, destChainId, amount, block.timestamp,
token.transferFrom(msg.sender, admin, amount); bytes32 signature = keccak256(abi.encodePacked(msg.sender, to, chainId, destChainId, amount, nonce)); emit Transfer( msg.sender, to, destChainId, amount, block.timestamp,
62,055
97
// Helper method to check if an address is the owner of a target wallet. _wallet The target wallet. _addr The address. /
function isOwner(BaseWallet _wallet, address _addr) internal view returns (bool) { return _wallet.owner() == _addr; }
function isOwner(BaseWallet _wallet, address _addr) internal view returns (bool) { return _wallet.owner() == _addr; }
29,170
37
// Returns true if a borrower has repaid his loan in the market, falseotherwise /
function repaid(address _borrower) public view returns (bool) { uint actualRequest = actualBorrowerRequest(_borrower); uint expectedRepayment = actualRequest.add(getInterest(_borrower, actualRequest)); if (borrowerRepaid[msg.sender] == expectedRepayment) { return true; } else { return false; } }
function repaid(address _borrower) public view returns (bool) { uint actualRequest = actualBorrowerRequest(_borrower); uint expectedRepayment = actualRequest.add(getInterest(_borrower, actualRequest)); if (borrowerRepaid[msg.sender] == expectedRepayment) { return true; } else { return false; } }
17,992
93
// add percents for sub guesses
for (uint subEvents = minRewardEvents; subEvents < events; subEvents++) { uint subWinnersCount = calcSublinesGuesses(events, subEvents); uint subRevenue = guessedRawRevenues[subEvents] * subWinnersCount; amount += subRevenue; revenue.details[subEvents] = subRevenue; }
for (uint subEvents = minRewardEvents; subEvents < events; subEvents++) { uint subWinnersCount = calcSublinesGuesses(events, subEvents); uint subRevenue = guessedRawRevenues[subEvents] * subWinnersCount; amount += subRevenue; revenue.details[subEvents] = subRevenue; }
6,068
5
// 价格数据合约
address public nestPriceFacade = 0xB5D2890c061c321A5B6A4a4254bb1522425BAF0A;
address public nestPriceFacade = 0xB5D2890c061c321A5B6A4a4254bb1522425BAF0A;
29,624
51
// ERC721Receiver callback checking and calling helper.
function _checkOnERC721Received( address from_, address to_, uint256 tokenId_, bytes memory data_
function _checkOnERC721Received( address from_, address to_, uint256 tokenId_, bytes memory data_
29,628
20
// オーナー限定のアクセス修飾子を作成
modifier onlyOwner() { require(msg.sender == mOwner.mAddress); _; }
modifier onlyOwner() { require(msg.sender == mOwner.mAddress); _; }
31,658
113
// Provides an interface to the ratio unitreturn Ratio scale unit (1e8 or 1108) /
function getRatioScale() internal pure returns (uint256) { return RATIO_SCALE; }
function getRatioScale() internal pure returns (uint256) { return RATIO_SCALE; }
38,473
32
// function remove(bytes32 slot,address self)internal
//{ //ContractStorage storage SCID = storageContract(slot); // ////SCID._this.requireNotNull(); ////SCID.thisHash.require...(); ////SCID.thisHex.requireNotEmpty(); // //SCID._this = AddressLogic.NULL; // //chainId.requireNotEmpty(); // //SCID.thisHex = stringLogic.empty; ////SCID.thisBytesPacked = abi.encodePacked(self); ////SCID.thisHashPacked = bytes32Logic.NULL; //SCID.thisHash = bytes32Logic.NULL; // //SCID.domainNameSeperator = bytes32Logic.NULL; //}
//{ //ContractStorage storage SCID = storageContract(slot); // ////SCID._this.requireNotNull(); ////SCID.thisHash.require...(); ////SCID.thisHex.requireNotEmpty(); // //SCID._this = AddressLogic.NULL; // //chainId.requireNotEmpty(); // //SCID.thisHex = stringLogic.empty; ////SCID.thisBytesPacked = abi.encodePacked(self); ////SCID.thisHashPacked = bytes32Logic.NULL; //SCID.thisHash = bytes32Logic.NULL; // //SCID.domainNameSeperator = bytes32Logic.NULL; //}
47,602
3
// Wave speed
traitValues[2] = ['0.00', '0.005', '0.007', '0.008' , '0.009', '0.01', '0.011', '0.012', '0.014'];
traitValues[2] = ['0.00', '0.005', '0.007', '0.008' , '0.009', '0.01', '0.011', '0.012', '0.014'];
23,864
133
// Bridge Library to map GSN RelayRequest into a call of a Forwarder /
library GsnEip712Library { // maximum length of return value/revert reason for 'execute' method. Will truncate result if exceeded. uint256 private constant MAX_RETURN_SIZE = 1024; //copied from Forwarder (can't reference string constants even from another library) string public constant GENERIC_PARAMS = "address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data,uint256 validUntil"; bytes public constant RELAYDATA_TYPE = "RelayData(uint256 gasPrice,uint256 pctRelayFee,uint256 baseRelayFee,address relayWorker,address paymaster,address forwarder,bytes paymasterData,uint256 clientId)"; string public constant RELAY_REQUEST_NAME = "RelayRequest"; string public constant RELAY_REQUEST_SUFFIX = string(abi.encodePacked("RelayData relayData)", RELAYDATA_TYPE)); bytes public constant RELAY_REQUEST_TYPE = abi.encodePacked( RELAY_REQUEST_NAME,"(",GENERIC_PARAMS,",", RELAY_REQUEST_SUFFIX); bytes32 public constant RELAYDATA_TYPEHASH = keccak256(RELAYDATA_TYPE); bytes32 public constant RELAY_REQUEST_TYPEHASH = keccak256(RELAY_REQUEST_TYPE); struct EIP712Domain { string name; string version; uint256 chainId; address verifyingContract; } bytes32 public constant EIP712DOMAIN_TYPEHASH = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); function splitRequest( GsnTypes.RelayRequest calldata req ) internal pure returns ( bytes memory suffixData ) { suffixData = abi.encode( hashRelayData(req.relayData)); } //verify that the recipient trusts the given forwarder // MUST be called by paymaster function verifyForwarderTrusted(GsnTypes.RelayRequest calldata relayRequest) internal view { (bool success, bytes memory ret) = relayRequest.request.to.staticcall( abi.encodeWithSelector( IRelayRecipient.isTrustedForwarder.selector, relayRequest.relayData.forwarder ) ); require(success, "isTrustedForwarder: reverted"); require(ret.length == 32, "isTrustedForwarder: bad response"); require(abi.decode(ret, (bool)), "invalid forwarder for recipient"); } function verifySignature(GsnTypes.RelayRequest calldata relayRequest, bytes calldata signature) internal view { (bytes memory suffixData) = splitRequest(relayRequest); bytes32 _domainSeparator = domainSeparator(relayRequest.relayData.forwarder); IForwarder forwarder = IForwarder(payable(relayRequest.relayData.forwarder)); forwarder.verify(relayRequest.request, _domainSeparator, RELAY_REQUEST_TYPEHASH, suffixData, signature); } function verify(GsnTypes.RelayRequest calldata relayRequest, bytes calldata signature) internal view { verifyForwarderTrusted(relayRequest); verifySignature(relayRequest, signature); } function execute(GsnTypes.RelayRequest calldata relayRequest, bytes calldata signature) internal returns (bool forwarderSuccess, bool callSuccess, bytes memory ret) { (bytes memory suffixData) = splitRequest(relayRequest); bytes32 _domainSeparator = domainSeparator(relayRequest.relayData.forwarder); /* solhint-disable-next-line avoid-low-level-calls */ (forwarderSuccess, ret) = relayRequest.relayData.forwarder.call( abi.encodeWithSelector(IForwarder.execute.selector, relayRequest.request, _domainSeparator, RELAY_REQUEST_TYPEHASH, suffixData, signature )); if ( forwarderSuccess ) { //decode return value of execute: (callSuccess, ret) = abi.decode(ret, (bool, bytes)); } truncateInPlace(ret); } //truncate the given parameter (in-place) if its length is above the given maximum length // do nothing otherwise. //NOTE: solidity warns unless the method is marked "pure", but it DOES modify its parameter. function truncateInPlace(bytes memory data) internal pure { MinLibBytes.truncateInPlace(data, MAX_RETURN_SIZE); } function domainSeparator(address forwarder) internal pure returns (bytes32) { return hashDomain(EIP712Domain({ name : "GSN Relayed Transaction", version : "2", chainId : getChainID(), verifyingContract : forwarder })); } function getChainID() internal pure returns (uint256 id) { /* solhint-disable no-inline-assembly */ assembly { id := chainid() } } function hashDomain(EIP712Domain memory req) internal pure returns (bytes32) { return keccak256(abi.encode( EIP712DOMAIN_TYPEHASH, keccak256(bytes(req.name)), keccak256(bytes(req.version)), req.chainId, req.verifyingContract)); } function hashRelayData(GsnTypes.RelayData calldata req) internal pure returns (bytes32) { return keccak256(abi.encode( RELAYDATA_TYPEHASH, req.gasPrice, req.pctRelayFee, req.baseRelayFee, req.relayWorker, req.paymaster, req.forwarder, keccak256(req.paymasterData), req.clientId )); } }
library GsnEip712Library { // maximum length of return value/revert reason for 'execute' method. Will truncate result if exceeded. uint256 private constant MAX_RETURN_SIZE = 1024; //copied from Forwarder (can't reference string constants even from another library) string public constant GENERIC_PARAMS = "address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data,uint256 validUntil"; bytes public constant RELAYDATA_TYPE = "RelayData(uint256 gasPrice,uint256 pctRelayFee,uint256 baseRelayFee,address relayWorker,address paymaster,address forwarder,bytes paymasterData,uint256 clientId)"; string public constant RELAY_REQUEST_NAME = "RelayRequest"; string public constant RELAY_REQUEST_SUFFIX = string(abi.encodePacked("RelayData relayData)", RELAYDATA_TYPE)); bytes public constant RELAY_REQUEST_TYPE = abi.encodePacked( RELAY_REQUEST_NAME,"(",GENERIC_PARAMS,",", RELAY_REQUEST_SUFFIX); bytes32 public constant RELAYDATA_TYPEHASH = keccak256(RELAYDATA_TYPE); bytes32 public constant RELAY_REQUEST_TYPEHASH = keccak256(RELAY_REQUEST_TYPE); struct EIP712Domain { string name; string version; uint256 chainId; address verifyingContract; } bytes32 public constant EIP712DOMAIN_TYPEHASH = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); function splitRequest( GsnTypes.RelayRequest calldata req ) internal pure returns ( bytes memory suffixData ) { suffixData = abi.encode( hashRelayData(req.relayData)); } //verify that the recipient trusts the given forwarder // MUST be called by paymaster function verifyForwarderTrusted(GsnTypes.RelayRequest calldata relayRequest) internal view { (bool success, bytes memory ret) = relayRequest.request.to.staticcall( abi.encodeWithSelector( IRelayRecipient.isTrustedForwarder.selector, relayRequest.relayData.forwarder ) ); require(success, "isTrustedForwarder: reverted"); require(ret.length == 32, "isTrustedForwarder: bad response"); require(abi.decode(ret, (bool)), "invalid forwarder for recipient"); } function verifySignature(GsnTypes.RelayRequest calldata relayRequest, bytes calldata signature) internal view { (bytes memory suffixData) = splitRequest(relayRequest); bytes32 _domainSeparator = domainSeparator(relayRequest.relayData.forwarder); IForwarder forwarder = IForwarder(payable(relayRequest.relayData.forwarder)); forwarder.verify(relayRequest.request, _domainSeparator, RELAY_REQUEST_TYPEHASH, suffixData, signature); } function verify(GsnTypes.RelayRequest calldata relayRequest, bytes calldata signature) internal view { verifyForwarderTrusted(relayRequest); verifySignature(relayRequest, signature); } function execute(GsnTypes.RelayRequest calldata relayRequest, bytes calldata signature) internal returns (bool forwarderSuccess, bool callSuccess, bytes memory ret) { (bytes memory suffixData) = splitRequest(relayRequest); bytes32 _domainSeparator = domainSeparator(relayRequest.relayData.forwarder); /* solhint-disable-next-line avoid-low-level-calls */ (forwarderSuccess, ret) = relayRequest.relayData.forwarder.call( abi.encodeWithSelector(IForwarder.execute.selector, relayRequest.request, _domainSeparator, RELAY_REQUEST_TYPEHASH, suffixData, signature )); if ( forwarderSuccess ) { //decode return value of execute: (callSuccess, ret) = abi.decode(ret, (bool, bytes)); } truncateInPlace(ret); } //truncate the given parameter (in-place) if its length is above the given maximum length // do nothing otherwise. //NOTE: solidity warns unless the method is marked "pure", but it DOES modify its parameter. function truncateInPlace(bytes memory data) internal pure { MinLibBytes.truncateInPlace(data, MAX_RETURN_SIZE); } function domainSeparator(address forwarder) internal pure returns (bytes32) { return hashDomain(EIP712Domain({ name : "GSN Relayed Transaction", version : "2", chainId : getChainID(), verifyingContract : forwarder })); } function getChainID() internal pure returns (uint256 id) { /* solhint-disable no-inline-assembly */ assembly { id := chainid() } } function hashDomain(EIP712Domain memory req) internal pure returns (bytes32) { return keccak256(abi.encode( EIP712DOMAIN_TYPEHASH, keccak256(bytes(req.name)), keccak256(bytes(req.version)), req.chainId, req.verifyingContract)); } function hashRelayData(GsnTypes.RelayData calldata req) internal pure returns (bytes32) { return keccak256(abi.encode( RELAYDATA_TYPEHASH, req.gasPrice, req.pctRelayFee, req.baseRelayFee, req.relayWorker, req.paymaster, req.forwarder, keccak256(req.paymasterData), req.clientId )); } }
32,353
8
// createSwapPair /
function createSwapPair(bytes32 ethTxHash, address erc20Addr, string calldata name, string calldata symbol, uint8 decimals) onlyOwner external returns (address) { require(swapMappingETH2BSC[erc20Addr] == address(0x0), "duplicated swap pair"); BEP20UpgradeableProxy proxyToken = new BEP20UpgradeableProxy(bep20Implementation, bep20ProxyAdmin, ""); IProxyInitialize token = IProxyInitialize(address(proxyToken)); token.initialize(name, symbol, decimals, 0, true, address(this)); swapMappingETH2BSC[erc20Addr] = address(token); swapMappingBSC2ETH[address(token)] = erc20Addr; emit SwapPairCreated(ethTxHash, address(token), erc20Addr, symbol, name, decimals); return address(token); }
function createSwapPair(bytes32 ethTxHash, address erc20Addr, string calldata name, string calldata symbol, uint8 decimals) onlyOwner external returns (address) { require(swapMappingETH2BSC[erc20Addr] == address(0x0), "duplicated swap pair"); BEP20UpgradeableProxy proxyToken = new BEP20UpgradeableProxy(bep20Implementation, bep20ProxyAdmin, ""); IProxyInitialize token = IProxyInitialize(address(proxyToken)); token.initialize(name, symbol, decimals, 0, true, address(this)); swapMappingETH2BSC[erc20Addr] = address(token); swapMappingBSC2ETH[address(token)] = erc20Addr; emit SwapPairCreated(ethTxHash, address(token), erc20Addr, symbol, name, decimals); return address(token); }
39,979
154
// given genes of kitten 1 & 2, return a genetic combination - may have a random factor/genes1 genes of mom/genes2 genes of sire/ return the genes that are supposed to be passed down the child
function mixGenes(uint256 genes1, uint256 genes2, uint256 targetBlock) public pure returns (uint256);
function mixGenes(uint256 genes1, uint256 genes2, uint256 targetBlock) public pure returns (uint256);
28,650
0
// Multiplies two numbers, throws on overflow./
function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; }
function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; }
1,028
238
// Pull in rewards from the rewards distributor, if applicable
for (uint256 i = 0; i < rewardDistributors.length; i++){ address reward_distributor_address = rewardDistributors[i]; if (reward_distributor_address != address(0)) { IFraxGaugeFXSRewardsDistributor(reward_distributor_address).distributeReward(address(this)); }
for (uint256 i = 0; i < rewardDistributors.length; i++){ address reward_distributor_address = rewardDistributors[i]; if (reward_distributor_address != address(0)) { IFraxGaugeFXSRewardsDistributor(reward_distributor_address).distributeReward(address(this)); }
18,562