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
|
|---|---|---|---|---|
40
|
// Date and Time utilities for ethereum contracts /
|
contract DateTime {
struct _DateTime {
uint16 year;
uint8 month;
uint8 day;
uint8 hour;
uint8 minute;
uint8 second;
uint8 weekday;
}
uint constant DAY_IN_SECONDS = 86400;
uint constant YEAR_IN_SECONDS = 31536000;
uint constant LEAP_YEAR_IN_SECONDS = 31622400;
uint constant HOUR_IN_SECONDS = 3600;
uint constant MINUTE_IN_SECONDS = 60;
uint16 constant ORIGIN_YEAR = 1970;
function isLeapYear(uint16 year) internal pure returns (bool) {
if (year % 4 != 0) {
return false;
}
if (year % 100 != 0) {
return true;
}
if (year % 400 != 0) {
return false;
}
return true;
}
function leapYearsBefore(uint year) internal pure returns (uint) {
year -= 1;
return year / 4 - year / 100 + year / 400;
}
function getDaysInMonth(uint8 month, uint16 year) internal pure returns (uint8) {
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
return 31;
}
else if (month == 4 || month == 6 || month == 9 || month == 11) {
return 30;
}
else if (isLeapYear(year)) {
return 29;
}
else {
return 28;
}
}
function parseTimestamp(uint timestamp) internal pure returns (_DateTime dt) {
uint secondsAccountedFor = 0;
uint buf;
uint8 i;
// Year
dt.year = getYear(timestamp);
buf = leapYearsBefore(dt.year) - leapYearsBefore(ORIGIN_YEAR);
secondsAccountedFor += LEAP_YEAR_IN_SECONDS * buf;
secondsAccountedFor += YEAR_IN_SECONDS * (dt.year - ORIGIN_YEAR - buf);
// Month
uint secondsInMonth;
for (i = 1; i <= 12; i++) {
secondsInMonth = DAY_IN_SECONDS * getDaysInMonth(i, dt.year);
if (secondsInMonth + secondsAccountedFor > timestamp) {
dt.month = i;
break;
}
secondsAccountedFor += secondsInMonth;
}
// Day
for (i = 1; i <= getDaysInMonth(dt.month, dt.year); i++) {
if (DAY_IN_SECONDS + secondsAccountedFor > timestamp) {
dt.day = i;
break;
}
secondsAccountedFor += DAY_IN_SECONDS;
}
// Hour
dt.hour = getHour(timestamp);
// Minute
dt.minute = getMinute(timestamp);
// Second
dt.second = getSecond(timestamp);
// Day of week.
dt.weekday = getWeekday(timestamp);
}
function getYear(uint timestamp) internal pure returns (uint16) {
uint secondsAccountedFor = 0;
uint16 year;
uint numLeapYears;
// Year
year = uint16(ORIGIN_YEAR + timestamp / YEAR_IN_SECONDS);
numLeapYears = leapYearsBefore(year) - leapYearsBefore(ORIGIN_YEAR);
secondsAccountedFor += LEAP_YEAR_IN_SECONDS * numLeapYears;
secondsAccountedFor += YEAR_IN_SECONDS * (year - ORIGIN_YEAR - numLeapYears);
while (secondsAccountedFor > timestamp) {
if (isLeapYear(uint16(year - 1))) {
secondsAccountedFor -= LEAP_YEAR_IN_SECONDS;
}
else {
secondsAccountedFor -= YEAR_IN_SECONDS;
}
year -= 1;
}
return year;
}
function getMonth(uint timestamp) internal pure returns (uint8) {
return parseTimestamp(timestamp).month;
}
function getDay(uint timestamp) internal pure returns (uint8) {
return parseTimestamp(timestamp).day;
}
function getHour(uint timestamp) internal pure returns (uint8) {
return uint8((timestamp / 60 / 60) % 24);
}
function getMinute(uint timestamp) internal pure returns (uint8) {
return uint8((timestamp / 60) % 60);
}
function getSecond(uint timestamp) internal pure returns (uint8) {
return uint8(timestamp % 60);
}
function getWeekday(uint timestamp) internal pure returns (uint8) {
return uint8((timestamp / DAY_IN_SECONDS + 4) % 7);
}
function toTimestamp(uint16 year, uint8 month, uint8 day) internal pure returns (uint timestamp) {
return toTimestamp(year, month, day, 0, 0, 0);
}
function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour) internal pure returns (uint timestamp) {
return toTimestamp(year, month, day, hour, 0, 0);
}
function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute) internal pure returns (uint timestamp) {
return toTimestamp(year, month, day, hour, minute, 0);
}
function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute, uint8 second) internal pure returns (uint timestamp) {
uint16 i;
// Year
for (i = ORIGIN_YEAR; i < year; i++) {
if (isLeapYear(i)) {
timestamp += LEAP_YEAR_IN_SECONDS;
}
else {
timestamp += YEAR_IN_SECONDS;
}
}
// Month
uint8[12] memory monthDayCounts;
monthDayCounts[0] = 31;
if (isLeapYear(year)) {
monthDayCounts[1] = 29;
}
else {
monthDayCounts[1] = 28;
}
monthDayCounts[2] = 31;
monthDayCounts[3] = 30;
monthDayCounts[4] = 31;
monthDayCounts[5] = 30;
monthDayCounts[6] = 31;
monthDayCounts[7] = 31;
monthDayCounts[8] = 30;
monthDayCounts[9] = 31;
monthDayCounts[10] = 30;
monthDayCounts[11] = 31;
for (i = 1; i < month; i++) {
timestamp += DAY_IN_SECONDS * monthDayCounts[i - 1];
}
// Day
timestamp += DAY_IN_SECONDS * (day - 1);
// Hour
timestamp += HOUR_IN_SECONDS * (hour);
// Minute
timestamp += MINUTE_IN_SECONDS * (minute);
// Second
timestamp += second;
return timestamp;
}
}
|
contract DateTime {
struct _DateTime {
uint16 year;
uint8 month;
uint8 day;
uint8 hour;
uint8 minute;
uint8 second;
uint8 weekday;
}
uint constant DAY_IN_SECONDS = 86400;
uint constant YEAR_IN_SECONDS = 31536000;
uint constant LEAP_YEAR_IN_SECONDS = 31622400;
uint constant HOUR_IN_SECONDS = 3600;
uint constant MINUTE_IN_SECONDS = 60;
uint16 constant ORIGIN_YEAR = 1970;
function isLeapYear(uint16 year) internal pure returns (bool) {
if (year % 4 != 0) {
return false;
}
if (year % 100 != 0) {
return true;
}
if (year % 400 != 0) {
return false;
}
return true;
}
function leapYearsBefore(uint year) internal pure returns (uint) {
year -= 1;
return year / 4 - year / 100 + year / 400;
}
function getDaysInMonth(uint8 month, uint16 year) internal pure returns (uint8) {
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
return 31;
}
else if (month == 4 || month == 6 || month == 9 || month == 11) {
return 30;
}
else if (isLeapYear(year)) {
return 29;
}
else {
return 28;
}
}
function parseTimestamp(uint timestamp) internal pure returns (_DateTime dt) {
uint secondsAccountedFor = 0;
uint buf;
uint8 i;
// Year
dt.year = getYear(timestamp);
buf = leapYearsBefore(dt.year) - leapYearsBefore(ORIGIN_YEAR);
secondsAccountedFor += LEAP_YEAR_IN_SECONDS * buf;
secondsAccountedFor += YEAR_IN_SECONDS * (dt.year - ORIGIN_YEAR - buf);
// Month
uint secondsInMonth;
for (i = 1; i <= 12; i++) {
secondsInMonth = DAY_IN_SECONDS * getDaysInMonth(i, dt.year);
if (secondsInMonth + secondsAccountedFor > timestamp) {
dt.month = i;
break;
}
secondsAccountedFor += secondsInMonth;
}
// Day
for (i = 1; i <= getDaysInMonth(dt.month, dt.year); i++) {
if (DAY_IN_SECONDS + secondsAccountedFor > timestamp) {
dt.day = i;
break;
}
secondsAccountedFor += DAY_IN_SECONDS;
}
// Hour
dt.hour = getHour(timestamp);
// Minute
dt.minute = getMinute(timestamp);
// Second
dt.second = getSecond(timestamp);
// Day of week.
dt.weekday = getWeekday(timestamp);
}
function getYear(uint timestamp) internal pure returns (uint16) {
uint secondsAccountedFor = 0;
uint16 year;
uint numLeapYears;
// Year
year = uint16(ORIGIN_YEAR + timestamp / YEAR_IN_SECONDS);
numLeapYears = leapYearsBefore(year) - leapYearsBefore(ORIGIN_YEAR);
secondsAccountedFor += LEAP_YEAR_IN_SECONDS * numLeapYears;
secondsAccountedFor += YEAR_IN_SECONDS * (year - ORIGIN_YEAR - numLeapYears);
while (secondsAccountedFor > timestamp) {
if (isLeapYear(uint16(year - 1))) {
secondsAccountedFor -= LEAP_YEAR_IN_SECONDS;
}
else {
secondsAccountedFor -= YEAR_IN_SECONDS;
}
year -= 1;
}
return year;
}
function getMonth(uint timestamp) internal pure returns (uint8) {
return parseTimestamp(timestamp).month;
}
function getDay(uint timestamp) internal pure returns (uint8) {
return parseTimestamp(timestamp).day;
}
function getHour(uint timestamp) internal pure returns (uint8) {
return uint8((timestamp / 60 / 60) % 24);
}
function getMinute(uint timestamp) internal pure returns (uint8) {
return uint8((timestamp / 60) % 60);
}
function getSecond(uint timestamp) internal pure returns (uint8) {
return uint8(timestamp % 60);
}
function getWeekday(uint timestamp) internal pure returns (uint8) {
return uint8((timestamp / DAY_IN_SECONDS + 4) % 7);
}
function toTimestamp(uint16 year, uint8 month, uint8 day) internal pure returns (uint timestamp) {
return toTimestamp(year, month, day, 0, 0, 0);
}
function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour) internal pure returns (uint timestamp) {
return toTimestamp(year, month, day, hour, 0, 0);
}
function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute) internal pure returns (uint timestamp) {
return toTimestamp(year, month, day, hour, minute, 0);
}
function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute, uint8 second) internal pure returns (uint timestamp) {
uint16 i;
// Year
for (i = ORIGIN_YEAR; i < year; i++) {
if (isLeapYear(i)) {
timestamp += LEAP_YEAR_IN_SECONDS;
}
else {
timestamp += YEAR_IN_SECONDS;
}
}
// Month
uint8[12] memory monthDayCounts;
monthDayCounts[0] = 31;
if (isLeapYear(year)) {
monthDayCounts[1] = 29;
}
else {
monthDayCounts[1] = 28;
}
monthDayCounts[2] = 31;
monthDayCounts[3] = 30;
monthDayCounts[4] = 31;
monthDayCounts[5] = 30;
monthDayCounts[6] = 31;
monthDayCounts[7] = 31;
monthDayCounts[8] = 30;
monthDayCounts[9] = 31;
monthDayCounts[10] = 30;
monthDayCounts[11] = 31;
for (i = 1; i < month; i++) {
timestamp += DAY_IN_SECONDS * monthDayCounts[i - 1];
}
// Day
timestamp += DAY_IN_SECONDS * (day - 1);
// Hour
timestamp += HOUR_IN_SECONDS * (hour);
// Minute
timestamp += MINUTE_IN_SECONDS * (minute);
// Second
timestamp += second;
return timestamp;
}
}
| 45,583
|
33
|
// Transfers asset balance from the caller to specified ICAP adding specified comment.Resolves asset implementation contract for the caller and forwards there arguments along withthe caller address._icap recipient ICAP to give to. _value amount to transfer. _reference transfer comment to be included in a EToken2's Transfer event. return success. /
|
function transferToICAPWithReference(bytes32 _icap, uint _value, string _reference) public returns(bool) {
return _getAsset()._performTransferToICAPWithReference(_icap, _value, _reference, msg.sender);
}
|
function transferToICAPWithReference(bytes32 _icap, uint _value, string _reference) public returns(bool) {
return _getAsset()._performTransferToICAPWithReference(_icap, _value, _reference, msg.sender);
}
| 70,815
|
325
|
// Hero cooldown time. (Default value: 60 mins.)
|
uint256 public coolHero = 3600;
|
uint256 public coolHero = 3600;
| 41,887
|
103
|
// Address `addr` will no longer incur the `_burnRatePerTransferThousandth`/1000 burn on Transfers from it./addr Address to whitelist / dewhitelist /whitelisted True to add to whitelist, false to remove.
|
function setBurnWhitelistFromAddress (address addr, bool whitelisted) external onlyOwner {
if(whitelisted) {
_burnWhitelistFrom[addr] = whitelisted;
emit AddedToWhitelistFrom(addr);
} else {
delete _burnWhitelistFrom[addr];
emit RemovedFromWhitelistFrom(addr);
}
}
|
function setBurnWhitelistFromAddress (address addr, bool whitelisted) external onlyOwner {
if(whitelisted) {
_burnWhitelistFrom[addr] = whitelisted;
emit AddedToWhitelistFrom(addr);
} else {
delete _burnWhitelistFrom[addr];
emit RemovedFromWhitelistFrom(addr);
}
}
| 15,138
|
4
|
// a loan. It also includes the internal function {_takeOutLoanProcessNFTs} that See {MainnetCreateLoanWithNFTFacet._takeOutLoanProcessNFTs} TELLER NFT V2
|
TellerNFT_V2 private immutable TELLER_NFT_V2;
constructor(address tellerNFTV2Address) {
TELLER_NFT_V2 = TellerNFT_V2(tellerNFTV2Address);
}
|
TellerNFT_V2 private immutable TELLER_NFT_V2;
constructor(address tellerNFTV2Address) {
TELLER_NFT_V2 = TellerNFT_V2(tellerNFTV2Address);
}
| 51,441
|
71
|
// 5. RoundC
|
else if (RoundBHardCap <= RoundBSold && RoundCSold < RoundCHardCap) {
return 5;
}
|
else if (RoundBHardCap <= RoundBSold && RoundCSold < RoundCHardCap) {
return 5;
}
| 63,267
|
42
|
// view how much of the origin currency the target currency will take/_origin the address of the origin/_target the address of the target/_targetAmount the target amount/ return originAmount_ the amount of target that has been swapped for the origin
|
function viewTargetSwap(
address _origin,
address _target,
uint256 _targetAmount
|
function viewTargetSwap(
address _origin,
address _target,
uint256 _targetAmount
| 29,917
|
4
|
// Operator Data Flags // Flag used in operator data parameters to indicate the transfer is a withdrawal /
|
bytes32
|
bytes32
| 41,798
|
18
|
// Returns the amount of tokens owned by `account`. /
|
function balanceOf(address account) external view returns (uint256);
|
function balanceOf(address account) external view returns (uint256);
| 16
|
5
|
// This event will be emitted every time the implementation gets upgraded implementation representing the address of the upgraded implementation /
|
event Upgraded(address indexed implementation, uint256 version);
|
event Upgraded(address indexed implementation, uint256 version);
| 12,293
|
18
|
// ------------------------------------------------------------------------ Get the token balance for account tokenOwner ------------------------------------------------------------------------
|
function balanceOf(address tokenOwner) public override view returns (uint balance) {
return balances[tokenOwner];
}
|
function balanceOf(address tokenOwner) public override view returns (uint balance) {
return balances[tokenOwner];
}
| 1,799
|
83
|
// Burns a specific amount of tokens and emit transfer event for native chain to The address to transfer to in the native chain. value The amount of token to be burned. /
|
function transferToNative(bytes32 to, uint256 value) public {
_burn(msg.sender, value);
emit TransferToNative(msg.sender, to, value);
}
|
function transferToNative(bytes32 to, uint256 value) public {
_burn(msg.sender, value);
emit TransferToNative(msg.sender, to, value);
}
| 15,154
|
455
|
// We store the `bptAmount` in the previous slot to the `tokenAmounts` array. We can make sure there will be at least one available slot due to how the memory scratch space works. We can safely overwrite whatever is stored in this slot as we will revert immediately after that.
|
let start := sub(tokenAmounts, 0x20)
mstore(start, bptAmount)
|
let start := sub(tokenAmounts, 0x20)
mstore(start, bptAmount)
| 1,761
|
1
|
// contract properties
|
uint _ticketPrice = 0.05 ether; // wei
uint _commission = 30; // percents
uint[12] _rewards = [0, 0, 0, 0, 0, 0, 0, 14, 16, 20, 24, 26]; // as map [guessedEvents => rewardPercents]
uint _commissionFunds;
uint _accumulatedFunds;
|
uint _ticketPrice = 0.05 ether; // wei
uint _commission = 30; // percents
uint[12] _rewards = [0, 0, 0, 0, 0, 0, 0, 14, 16, 20, 24, 26]; // as map [guessedEvents => rewardPercents]
uint _commissionFunds;
uint _accumulatedFunds;
| 6,018
|
148
|
// Blacklist participant so they cannot make further purchases
|
blacklist[participant] = true;
AddedToBlacklist(participant, now);
stages.refundParticipant(_stage1, _stage2, _stage3, _stage4);
TokensReclaimed(participant, tokens, now);
|
blacklist[participant] = true;
AddedToBlacklist(participant, now);
stages.refundParticipant(_stage1, _stage2, _stage3, _stage4);
TokensReclaimed(participant, tokens, now);
| 48,193
|
131
|
// Verifies that the game exists/_gameId ID of the game/ return game Storage value of game info
|
function _verify(uint40 _gameId) internal view returns (Game storage game) {
game = games[_gameId];
// Reverts if game does not exist due to invalid ID or canceled game
if (_gameId == 0 || _gameId > currentId || game.p1.player == address(0))
revert InvalidGame();
}
|
function _verify(uint40 _gameId) internal view returns (Game storage game) {
game = games[_gameId];
// Reverts if game does not exist due to invalid ID or canceled game
if (_gameId == 0 || _gameId > currentId || game.p1.player == address(0))
revert InvalidGame();
}
| 36,152
|
124
|
// The market's last updated rewardBorrowIndex or rewardSupplyIndex
|
uint224 index;
|
uint224 index;
| 19,740
|
121
|
// Check if token transfer is free of any charge or not. return true if transfer is free of any charge./
|
function freeTransfer() public view returns (bool isTransferFree) {
return transferFeePaymentFinished || transferFeePercentage == 0;
}
|
function freeTransfer() public view returns (bool isTransferFree) {
return transferFeePaymentFinished || transferFeePercentage == 0;
}
| 31,999
|
3
|
// Invalid caller /
|
error InvalidCaller();
|
error InvalidCaller();
| 13,515
|
463
|
// Note: computing the current round is required to disallow people from revealing an old commit after the round is over.
|
uint256 roundId = voteTiming.computeCurrentRoundId(getCurrentTime());
PriceRequest storage priceRequest = _getPriceRequest(identifier, time, ancillaryData);
VoteInstance storage voteInstance = priceRequest.voteInstances[roundId];
VoteSubmission storage voteSubmission = voteInstance.voteSubmissions[msg.sender];
|
uint256 roundId = voteTiming.computeCurrentRoundId(getCurrentTime());
PriceRequest storage priceRequest = _getPriceRequest(identifier, time, ancillaryData);
VoteInstance storage voteInstance = priceRequest.voteInstances[roundId];
VoteSubmission storage voteSubmission = voteInstance.voteSubmissions[msg.sender];
| 9,203
|
197
|
// grab crew stats and merge with ship
|
uint8[STATS_SIZE] memory _crewStats = ethernautsStorage.getStats(_crewTokenId);
_shipStats[uint256(ShipStats.Range)] += _crewStats[uint256(ShipStats.Range)];
_shipStats[uint256(ShipStats.Speed)] += _crewStats[uint256(ShipStats.Speed)];
if (_shipStats[uint256(ShipStats.Range)] > STATS_CAPOUT) {
_shipStats[uint256(ShipStats.Range)] = STATS_CAPOUT;
}
|
uint8[STATS_SIZE] memory _crewStats = ethernautsStorage.getStats(_crewTokenId);
_shipStats[uint256(ShipStats.Range)] += _crewStats[uint256(ShipStats.Range)];
_shipStats[uint256(ShipStats.Speed)] += _crewStats[uint256(ShipStats.Speed)];
if (_shipStats[uint256(ShipStats.Range)] > STATS_CAPOUT) {
_shipStats[uint256(ShipStats.Range)] = STATS_CAPOUT;
}
| 63,207
|
39
|
// Withdraw token (assets of our contract) for a specified address token The address of token for transfer _to The address to transfer to amount The amount to be transferred /
|
function withdrawToken(address token, address _to, uint256 amount) onlyOwner public returns (bool) {
require(token != address(0));
require(Erc20Basic(token).balanceOf(address(this)) >= amount);
bool transferOk = Erc20Basic(token).transfer(_to, amount);
require(transferOk);
return true;
}
|
function withdrawToken(address token, address _to, uint256 amount) onlyOwner public returns (bool) {
require(token != address(0));
require(Erc20Basic(token).balanceOf(address(this)) >= amount);
bool transferOk = Erc20Basic(token).transfer(_to, amount);
require(transferOk);
return true;
}
| 23,662
|
20
|
// Get a storefront information by index._owner the address of store owner._index a index of storefront. return name The name of storefront. return isOpen The status of storefront./
|
function getFrontAtIndex(address _owner, uint _index) public view returns(string memory name, bool isOpen) {
require(isStore[_owner], "the owner's store doesn't exist");
Store storage s = stores[_owner];
require(_index < s.frontKeys.length, "out of index.");
Front memory f = s.fronts[s.frontKeys[_index]];
name = f.name;
isOpen = f.isOpen;
}
|
function getFrontAtIndex(address _owner, uint _index) public view returns(string memory name, bool isOpen) {
require(isStore[_owner], "the owner's store doesn't exist");
Store storage s = stores[_owner];
require(_index < s.frontKeys.length, "out of index.");
Front memory f = s.fronts[s.frontKeys[_index]];
name = f.name;
isOpen = f.isOpen;
}
| 36,588
|
150
|
// Set number of tokens to sell to nativeTokenAmount
|
contractTokenBalance = nativeTokenAmount;
swapTokens(contractTokenBalance);
swapping = false;
|
contractTokenBalance = nativeTokenAmount;
swapTokens(contractTokenBalance);
swapping = false;
| 15,609
|
216
|
// __ERC721_init("swng", "swng");
|
__ERC721_init("Vending Machines Tycoon", "VMT");
royaltyPercentage = _royaltyPercentage;
_owner = _contractOwner;
_mintRoyaltiesAddr = _mintRoyaltyReceiver;
_buyRoyaltiesAddr = _buyRoyaltyReceiver;
mintFeeAmount = _mintFeeAmount;
excludedList[_buyRoyaltyReceiver] = true;
baseURL = _baseURL;
openForPublic = _openForPublic;
|
__ERC721_init("Vending Machines Tycoon", "VMT");
royaltyPercentage = _royaltyPercentage;
_owner = _contractOwner;
_mintRoyaltiesAddr = _mintRoyaltyReceiver;
_buyRoyaltiesAddr = _buyRoyaltyReceiver;
mintFeeAmount = _mintFeeAmount;
excludedList[_buyRoyaltyReceiver] = true;
baseURL = _baseURL;
openForPublic = _openForPublic;
| 23,207
|
25
|
// set ETH/USD Price Feed
|
priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);
|
priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);
| 26,573
|
21
|
// Acceptable duration is between 1 - 30 days
|
revert TokenVault_InvalidDuration();
|
revert TokenVault_InvalidDuration();
| 10,721
|
137
|
// Reverts if not running in test mode. /
|
modifier onlyIfTest {
require(timerAddress != address(0x0));
_;
}
|
modifier onlyIfTest {
require(timerAddress != address(0x0));
_;
}
| 17,134
|
44
|
// Amalgamate lending metadata with strategy metadata
|
function augmentStratMetadata(IStrategy.StrategyMetadata[] memory stratMeta)
public
view
returns (ILStrategyMetadata[] memory)
|
function augmentStratMetadata(IStrategy.StrategyMetadata[] memory stratMeta)
public
view
returns (ILStrategyMetadata[] memory)
| 5,457
|
23
|
// Chainlink: rETH/ETH
|
return 0x536218f9E9Eb48863970252233c8F271f554C2d0;
|
return 0x536218f9E9Eb48863970252233c8F271f554C2d0;
| 10,940
|
79
|
// The block number when Reward mining ends.
|
uint256 public endBlock;
event feeAddressUpdated(address);
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(
address indexed user,
uint256 indexed pid,
uint256 amount
|
uint256 public endBlock;
event feeAddressUpdated(address);
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(
address indexed user,
uint256 indexed pid,
uint256 amount
| 7,459
|
166
|
// Provide a reasonable value for `tokenPriceInWei` when it would otherwise revert, using the starting price before auction starts.
|
tokenPriceInWei = _projectConfig.startPrice;
|
tokenPriceInWei = _projectConfig.startPrice;
| 37,845
|
36
|
// The block at which voting ends: votes must be cast prior to this block
|
uint256 endBlock;
|
uint256 endBlock;
| 5,871
|
3
|
// Goerli has a max gas limit of 2.5 million, we'll cap out at 200000, enough for about 10 words
|
uint32 callbackGasLimit = 200000;
|
uint32 callbackGasLimit = 200000;
| 13,354
|
73
|
// Instantiate quadron
|
qToken = IQuadron(_quadron);
|
qToken = IQuadron(_quadron);
| 5,307
|
8
|
// A base contract to be inherited by any contract that want to receive forwarded transactions.The contract designed to be stateless, it supports a scenario when a inherited contract isTrustedForwarder and Recipient at the same time. The contract supports token based nonce, that is why standard calldata extended by tokenId.
|
* Forwarded calldata layout: {bytes:data}{address:from}{uint256:tokenId}
*/
abstract contract ERC2771RegistryContext is Initializable, ContextUpgradeable {
// solhint-disable-next-line func-name-mixedcase
function __ERC2771RegistryContext_init() internal onlyInitializing {
__Context_init_unchained();
__ERC2771RegistryContext_init_unchained();
}
// solhint-disable-next-line func-name-mixedcase
function __ERC2771RegistryContext_init_unchained() internal onlyInitializing {}
/**
* @dev Return bool whether provided address is the trusted forwarder.
*/
function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
return forwarder == address(this);
}
/**
* @dev Return the tokenId of this call.
* If the call came through our trusted forwarder, return the original tokenId.
* otherwise, return zero tokenId.
*/
function _msgToken() internal view virtual returns (uint256 tokenId) {
if (isTrustedForwarder(msg.sender)) {
assembly {
tokenId := calldataload(sub(calldatasize(), 32))
}
}
}
/**
* @dev Return the sender of this call.
* If the call came through our trusted forwarder, return the original sender.
* otherwise, return `msg.sender`.
* Should be used in the contract anywhere instead of msg.sender
*/
function _msgSender() internal view virtual override returns (address sender) {
if (isTrustedForwarder(msg.sender)) {
// The assembly code is more direct than the Solidity version using `abi.decode`.
assembly {
sender := shr(96, calldataload(sub(calldatasize(), 52)))
}
} else {
return super._msgSender();
}
}
/**
* @dev Return the data of this call.
* If the call came through our trusted forwarder, return the original data.
* otherwise, return `msg.data`.
* Should be used in the contract anywhere instead of msg.data
*/
function _msgData() internal view virtual override returns (bytes calldata) {
if (isTrustedForwarder(msg.sender)) {
return msg.data[:msg.data.length - 52];
} else {
return super._msgData();
}
}
uint256[50] private __gap;
}
|
* Forwarded calldata layout: {bytes:data}{address:from}{uint256:tokenId}
*/
abstract contract ERC2771RegistryContext is Initializable, ContextUpgradeable {
// solhint-disable-next-line func-name-mixedcase
function __ERC2771RegistryContext_init() internal onlyInitializing {
__Context_init_unchained();
__ERC2771RegistryContext_init_unchained();
}
// solhint-disable-next-line func-name-mixedcase
function __ERC2771RegistryContext_init_unchained() internal onlyInitializing {}
/**
* @dev Return bool whether provided address is the trusted forwarder.
*/
function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
return forwarder == address(this);
}
/**
* @dev Return the tokenId of this call.
* If the call came through our trusted forwarder, return the original tokenId.
* otherwise, return zero tokenId.
*/
function _msgToken() internal view virtual returns (uint256 tokenId) {
if (isTrustedForwarder(msg.sender)) {
assembly {
tokenId := calldataload(sub(calldatasize(), 32))
}
}
}
/**
* @dev Return the sender of this call.
* If the call came through our trusted forwarder, return the original sender.
* otherwise, return `msg.sender`.
* Should be used in the contract anywhere instead of msg.sender
*/
function _msgSender() internal view virtual override returns (address sender) {
if (isTrustedForwarder(msg.sender)) {
// The assembly code is more direct than the Solidity version using `abi.decode`.
assembly {
sender := shr(96, calldataload(sub(calldatasize(), 52)))
}
} else {
return super._msgSender();
}
}
/**
* @dev Return the data of this call.
* If the call came through our trusted forwarder, return the original data.
* otherwise, return `msg.data`.
* Should be used in the contract anywhere instead of msg.data
*/
function _msgData() internal view virtual override returns (bytes calldata) {
if (isTrustedForwarder(msg.sender)) {
return msg.data[:msg.data.length - 52];
} else {
return super._msgData();
}
}
uint256[50] private __gap;
}
| 43,936
|
11
|
// We add half the scale before dividing so that we get rounding instead of truncation.See "Listing 6" and text above it at https:accu.org/index.php/journals/1717 Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.
|
(CarefulMath.MathError err1, uint doubleScaledProductWithHalfScale) = CarefulMath.addUInt(ExponentialNoError.halfExpScale, doubleScaledProduct);
if (err1 != CarefulMath.MathError.NO_ERROR) {
return (err1, ExponentialNoError.Exp({mantissa: 0}));
|
(CarefulMath.MathError err1, uint doubleScaledProductWithHalfScale) = CarefulMath.addUInt(ExponentialNoError.halfExpScale, doubleScaledProduct);
if (err1 != CarefulMath.MathError.NO_ERROR) {
return (err1, ExponentialNoError.Exp({mantissa: 0}));
| 7,002
|
15
|
// Unfortunately we can't create this array outright because Lib_RLPWriter.writeList will reject fixed-size arrays. Assigning index-by-index circumvents this issue.
|
raw[0] = Lib_RLPWriter.writeBytes(
Lib_Bytes32Utils.removeLeadingZeros(
bytes32(_account.nonce)
)
);
raw[1] = Lib_RLPWriter.writeBytes(
Lib_Bytes32Utils.removeLeadingZeros(
bytes32(_account.balance)
)
);
|
raw[0] = Lib_RLPWriter.writeBytes(
Lib_Bytes32Utils.removeLeadingZeros(
bytes32(_account.nonce)
)
);
raw[1] = Lib_RLPWriter.writeBytes(
Lib_Bytes32Utils.removeLeadingZeros(
bytes32(_account.balance)
)
);
| 42,183
|
102
|
// An event thats emitted when an account changes its delegate
|
event DelegateChanged(
address indexed delegator,
address indexed fromDelegate,
address indexed toDelegate
);
|
event DelegateChanged(
address indexed delegator,
address indexed fromDelegate,
address indexed toDelegate
);
| 622
|
14
|
// Sanity check interval
|
require(beginEpoch < endEpoch, "CR_INTERVAL_INVALID");
|
require(beginEpoch < endEpoch, "CR_INTERVAL_INVALID");
| 13,164
|
11
|
// Emit once collateral is reclaimed by a writer after `expiryTime + windowSize`.
|
event Refund(address indexed seller, uint256 amount);
|
event Refund(address indexed seller, uint256 amount);
| 15,364
|
21
|
// Returns the number of LP tokens the strategy has in circulation return uint Number of LP tokens in circulation/
|
function getCirculatingSupply() public view override returns (uint) {
return circulatingSupply;
}
|
function getCirculatingSupply() public view override returns (uint) {
return circulatingSupply;
}
| 1,001
|
6
|
// reference to $EGG for burning on mint
|
IEgg public egg;
|
IEgg public egg;
| 76,352
|
272
|
// Repay debt ONLY to skip reinvest in case of strategy migration period
|
_repaidDebt = _swapRewardsToDebt(_wethAmount);
|
_repaidDebt = _swapRewardsToDebt(_wethAmount);
| 67,692
|
68
|
// https:etherscan.io/address/0x24701A6368Ff6D2874d6b8cDadd461552B8A5283
|
address internal constant LINK_INTEREST_RATE_STRATEGY =
0x24701A6368Ff6D2874d6b8cDadd461552B8A5283;
|
address internal constant LINK_INTEREST_RATE_STRATEGY =
0x24701A6368Ff6D2874d6b8cDadd461552B8A5283;
| 15,765
|
23
|
// First pay out any LQTY gains
|
address frontEnd = deposits[msg.sender].frontEndTag;
_payOutLQTYGains(communityIssuanceCached, msg.sender, frontEnd);
|
address frontEnd = deposits[msg.sender].frontEndTag;
_payOutLQTYGains(communityIssuanceCached, msg.sender, frontEnd);
| 15,541
|
6
|
// define function here
|
function feedOnKitty(uint _zombieId, uint _kittyId, "kitty") public {
uint kittyDna; //we only care about one of the values returned from KittyInterface which is kittyDna
(,,,,,,,,,kittyDna) = kittyContract.getKitty(_kittyId);
feedAndMultiply(_zombieId, kittyDna);
}
|
function feedOnKitty(uint _zombieId, uint _kittyId, "kitty") public {
uint kittyDna; //we only care about one of the values returned from KittyInterface which is kittyDna
(,,,,,,,,,kittyDna) = kittyContract.getKitty(_kittyId);
feedAndMultiply(_zombieId, kittyDna);
}
| 27,031
|
286
|
// Pays out pending amount in a stream streamId The id of the stream to payout.return The amount paid out in underlying /
|
function payout(uint256 streamId)
public
returns (uint256 paidOut)
|
function payout(uint256 streamId)
public
returns (uint256 paidOut)
| 79,498
|
4
|
// Allows minter to create new tokens./Mint method is reserved for minter module./recipient Address receiving the new tokens./amount Number of minted tokens.
|
function mintToken(address recipient, uint256 amount) external;
|
function mintToken(address recipient, uint256 amount) external;
| 34,728
|
23
|
// if the applicant address is already taken by a member's delegateKey, reset it to their member address
|
if (members[memberAddressByDelegateKey[proposal.applicant]].exists) {
address memberToOverride = memberAddressByDelegateKey[proposal.applicant];
memberAddressByDelegateKey[memberToOverride] = memberToOverride;
members[memberToOverride].delegateKey = memberToOverride;
}
|
if (members[memberAddressByDelegateKey[proposal.applicant]].exists) {
address memberToOverride = memberAddressByDelegateKey[proposal.applicant];
memberAddressByDelegateKey[memberToOverride] = memberToOverride;
members[memberToOverride].delegateKey = memberToOverride;
}
| 43,168
|
18
|
// calculate the amount of tokens we need to reimburse uniswap for the flashloan
|
uint amountRequired = UniswapV2Library.getAmountsIn(factory, amountTokenBorrowed, path)[0];
|
uint amountRequired = UniswapV2Library.getAmountsIn(factory, amountTokenBorrowed, path)[0];
| 29,597
|
252
|
// Team Mint /
|
function teamMint(uint256 _quantity) external onlyOwner {
require(totalSupply() + _quantity <= maxSupply, "Sold out");
_safeMint(msg.sender, _quantity);
}
|
function teamMint(uint256 _quantity) external onlyOwner {
require(totalSupply() + _quantity <= maxSupply, "Sold out");
_safeMint(msg.sender, _quantity);
}
| 3,791
|
7
|
// Account Merging
|
function startMergingWindow() external;
function mergeAccount(address accountToMerge, uint256[] calldata entryIDs) external;
function nominateAccountToMerge(address account) external;
function accountMergingIsOpen() external view returns (bool);
|
function startMergingWindow() external;
function mergeAccount(address accountToMerge, uint256[] calldata entryIDs) external;
function nominateAccountToMerge(address account) external;
function accountMergingIsOpen() external view returns (bool);
| 974
|
20
|
// Passes on the accumulated debt changes from the markets, into the pool, so that vaults can later access this debt.
|
self.vaultsDebtDistribution.distributeValue(cumulativeDebtChangeD18);
|
self.vaultsDebtDistribution.distributeValue(cumulativeDebtChangeD18);
| 25,865
|
26
|
// If above ripcord threshold, then check if incentivized cooldown period has elapsed
|
if (currentLeverageRatio >= incentive.incentivizedLeverageRatio) {
if (lastTradeTimestamp.add(incentive.incentivizedTwapCooldownPeriod) < block.timestamp) {
return ShouldRebalance.RIPCORD;
}
|
if (currentLeverageRatio >= incentive.incentivizedLeverageRatio) {
if (lastTradeTimestamp.add(incentive.incentivizedTwapCooldownPeriod) < block.timestamp) {
return ShouldRebalance.RIPCORD;
}
| 11,781
|
4
|
// each user can get only 3 timesbe careful, SafeMath is not used. /
|
function mintForUsers() public virtual {
require(totalSupply() < maxAmount);
require(balanceOf(msg.sender) < baseAmount * 4);
_mint(msg.sender, baseAmount);
}
|
function mintForUsers() public virtual {
require(totalSupply() < maxAmount);
require(balanceOf(msg.sender) < baseAmount * 4);
_mint(msg.sender, baseAmount);
}
| 19,973
|
35
|
// Verify that the number of claims is a multiple of 3
|
if (numberOfShillings % 3 != 0 || numberOfShillings == 0)
revert InvalidNumberOfTokens();
|
if (numberOfShillings % 3 != 0 || numberOfShillings == 0)
revert InvalidNumberOfTokens();
| 32,928
|
0
|
// The OpenSea interface system that allows for approval fee skipping. /
|
contract OwnableDelegateProxy {}
contract ProxyRegistry {
mapping(address => OwnableDelegateProxy) public proxies;
}
|
contract OwnableDelegateProxy {}
contract ProxyRegistry {
mapping(address => OwnableDelegateProxy) public proxies;
}
| 49,496
|
114
|
// string memory _name = INFTXInventoryStaking(msg.sender).nftxVaultFactory().vault();
|
__ERC20_init(name, symbol);
baseToken = IERC20Upgradeable(_baseToken);
|
__ERC20_init(name, symbol);
baseToken = IERC20Upgradeable(_baseToken);
| 33,181
|
37
|
// Get Round number and control, we need these first otherwise behavior of other fetches may be undefined or unceccesary spending of LINK
|
function getInitialApiData() private
|
function getInitialApiData() private
| 42,805
|
3
|
// Emitted when the ACO fee destination address has been changed. previousAcoFeeDestination Address of the previous ACO fee destination. newAcoFeeDestination Address of the new ACO fee destination. /
|
event SetAcoFeeDestination(address previousAcoFeeDestination, address newAcoFeeDestination);
|
event SetAcoFeeDestination(address previousAcoFeeDestination, address newAcoFeeDestination);
| 992
|
356
|
// Mapping from token id to sha256 hash of metadata
|
mapping(uint256 => bytes32) public tokenMetadataHashes;
|
mapping(uint256 => bytes32) public tokenMetadataHashes;
| 30,616
|
22
|
// Map that contains the number of entries each user has bought, to prevent abuse, and the claiming info
|
struct ClaimStruct {
uint256 numEntriesPerUser;
uint256 amountSpentInWeis;
bool claimed;
}
|
struct ClaimStruct {
uint256 numEntriesPerUser;
uint256 amountSpentInWeis;
bool claimed;
}
| 31,838
|
11
|
// Verify that the priceDepth parameters is within the max No. of historical blocks a contract can track
|
modifier checkMaxBlockDepth(uint _value) {
require(_value > 0 && _value <= 255, "Price Depth parameter must be within then range [1-255]");
_;
}
|
modifier checkMaxBlockDepth(uint _value) {
require(_value > 0 && _value <= 255, "Price Depth parameter must be within then range [1-255]");
_;
}
| 50,730
|
8
|
// sell half and add liquidity
|
uint256 half = liquidityAddAmount.div(2);
drace.approve(address(routerV2), liquidityAddAmount);
address[] memory path = new address[](2);
path[0] = address(drace);
path[1] = otherTokenAddress;
IERC20 otherToken = IERC20(otherTokenAddress);
uint256 minToReceive = routerV2.getAmountsOut(half, path)[1];
|
uint256 half = liquidityAddAmount.div(2);
drace.approve(address(routerV2), liquidityAddAmount);
address[] memory path = new address[](2);
path[0] = address(drace);
path[1] = otherTokenAddress;
IERC20 otherToken = IERC20(otherTokenAddress);
uint256 minToReceive = routerV2.getAmountsOut(half, path)[1];
| 22,442
|
101
|
// It calls parent BasicToken.transfer() function. It will transfer an amount of tokens to an specific address/ return True if the token is transfered with success
|
function transfer(address _to, uint256 _value) isAllowed(msg.sender, _to) public returns (bool) {
return super.transfer(_to, _value);
}
|
function transfer(address _to, uint256 _value) isAllowed(msg.sender, _to) public returns (bool) {
return super.transfer(_to, _value);
}
| 33,234
|
5
|
// 終止帳號
|
function closeAccount() public onlyContractOwner {
selfdestruct(contractOwner);
}
|
function closeAccount() public onlyContractOwner {
selfdestruct(contractOwner);
}
| 19,512
|
196
|
// HELPERS /
|
function assertUint104(uint256 num) internal pure {
require(num <= type(uint104).max, "Overflow uint104");
}
|
function assertUint104(uint256 num) internal pure {
require(num <= type(uint104).max, "Overflow uint104");
}
| 17,322
|
47
|
// Returns array of three non-duplicating integers from 0-9
|
function generateIndexes
(
address account
)
internal
returns (uint8[3])
|
function generateIndexes
(
address account
)
internal
returns (uint8[3])
| 43,654
|
151
|
// Redeem mining reward The validation of this redeeming operation should be done by the caller, a registered sidechain contract Here we use cumulative mining reward to simplify the logic in sidechain code _receiver the receiver of the redeemed mining reward _cumulativeReward the latest cumulative mining reward /
|
function redeemMiningReward(address _receiver, uint256 _cumulativeReward)
|
function redeemMiningReward(address _receiver, uint256 _cumulativeReward)
| 50,045
|
238
|
// View function to see pending CROW on frontend.
|
function pendingCrow(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCrowPerShare = pool.accCrowPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0 && pool.lastRewardBlock < maxRewardBlockNumber) {
uint256 totalReward = getTotalRewardInfo(pool.lastRewardBlock, block.number);
uint256 crowReward = totalReward.mul(pool.allocPoint).div(totalAllocPoint);
accCrowPerShare = accCrowPerShare.add(crowReward.mul(accCrowPerShareMultiple).div(lpSupply));
}
return user.amount.mul(accCrowPerShare).div(accCrowPerShareMultiple).sub(user.rewardDebt);
}
|
function pendingCrow(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCrowPerShare = pool.accCrowPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0 && pool.lastRewardBlock < maxRewardBlockNumber) {
uint256 totalReward = getTotalRewardInfo(pool.lastRewardBlock, block.number);
uint256 crowReward = totalReward.mul(pool.allocPoint).div(totalAllocPoint);
accCrowPerShare = accCrowPerShare.add(crowReward.mul(accCrowPerShareMultiple).div(lpSupply));
}
return user.amount.mul(accCrowPerShare).div(accCrowPerShareMultiple).sub(user.rewardDebt);
}
| 25,785
|
253
|
// Base interface for a contract that will be called via the GSN from {IRelayHub}.TIP: You don't need to write an implementation yourself! Inherit from {GSNRecipient} instead./ Returns the address of the {IRelayHub} instance this recipient interacts with. /
|
function getHubAddr() external view returns (address);
|
function getHubAddr() external view returns (address);
| 7,809
|
400
|
// Check to see if a given address is a CRP addr - address to checkreturn boolean indicating whether it is a CRP /
|
function isCrp(address addr) external view returns (bool) {
return _isCrp[addr];
}
|
function isCrp(address addr) external view returns (bool) {
return _isCrp[addr];
}
| 23,477
|
113
|
// Withdraws the interest only of user, and updates the stake date, balance and etc../
|
function claim() external whenNotPaused nonReentrant {
uint256 balance = balances[msg.sender];
require(balance > 0, "balance should more than 0");
// calculate total balance with interest
(uint256 totalWithInterest, uint256 principalOfRepresentUmi, uint256 timePassed) = calculateRewardsAndTimePassed(msg.sender, 0);
require(
totalWithInterest > 0 && timePassed >= 0,
"calculate rewards and TimePassed error"
);
// interest to be paid
uint256 interest = totalWithInterest.sub(principalOfRepresentUmi);
require(interest > 0, "claim interest must more than 0");
require(totalFunding >= interest, "total funding not enough to pay interest");
// enough to pay interest
// reduce total funding
totalFunding = totalFunding.sub(interest);
uint256 claimTimestamp = _now();
// update stake date
stakeDates[msg.sender] = claimTimestamp;
// transfer interest to user
require(
umiToken.transfer(msg.sender, interest),
"claim: transfer failed"
);
// send claim event
emit Claimed(msg.sender, balance, interest, claimTimestamp);
}
|
function claim() external whenNotPaused nonReentrant {
uint256 balance = balances[msg.sender];
require(balance > 0, "balance should more than 0");
// calculate total balance with interest
(uint256 totalWithInterest, uint256 principalOfRepresentUmi, uint256 timePassed) = calculateRewardsAndTimePassed(msg.sender, 0);
require(
totalWithInterest > 0 && timePassed >= 0,
"calculate rewards and TimePassed error"
);
// interest to be paid
uint256 interest = totalWithInterest.sub(principalOfRepresentUmi);
require(interest > 0, "claim interest must more than 0");
require(totalFunding >= interest, "total funding not enough to pay interest");
// enough to pay interest
// reduce total funding
totalFunding = totalFunding.sub(interest);
uint256 claimTimestamp = _now();
// update stake date
stakeDates[msg.sender] = claimTimestamp;
// transfer interest to user
require(
umiToken.transfer(msg.sender, interest),
"claim: transfer failed"
);
// send claim event
emit Claimed(msg.sender, balance, interest, claimTimestamp);
}
| 38,281
|
44
|
// ========================================ERC20========================================= ERC20 Transfer function
|
function TRANSFER970(address to, uint value) public override returns (bool success) { //inject NONSTANDARD NAMING
_TRANSFER893(msg.sender, to, value);
return true;
}
|
function TRANSFER970(address to, uint value) public override returns (bool success) { //inject NONSTANDARD NAMING
_TRANSFER893(msg.sender, to, value);
return true;
}
| 22,795
|
17
|
// Contains 512-bit math functions/Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision/Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
|
library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = uint256(-int256(denominator)) & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use Newton-Raphson iteration to improve the precision.
// Thanks to Hensel's lifting lemma, this also works in modular
// arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // inverse mod 2**256
// Because the division is now exact we can divide by multiplying
// with the modular inverse of denominator. This will give us the
// correct result modulo 2**256. Since the precoditions guarantee
// that the outcome is less than 2**256, this is the final result.
// We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inv;
return result;
}
}
/// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < type(uint256).max);
result++;
}
}
}
}
|
library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = uint256(-int256(denominator)) & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use Newton-Raphson iteration to improve the precision.
// Thanks to Hensel's lifting lemma, this also works in modular
// arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // inverse mod 2**256
// Because the division is now exact we can divide by multiplying
// with the modular inverse of denominator. This will give us the
// correct result modulo 2**256. Since the precoditions guarantee
// that the outcome is less than 2**256, this is the final result.
// We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inv;
return result;
}
}
/// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < type(uint256).max);
result++;
}
}
}
}
| 34,960
|
13
|
// Returns the downcasted int16 from int256, reverting onoverflow (when the input is less than smallest int16 orgreater than largest int16). Counterpart to Solidity's `int16` operator. Requirements: - input must fit into 16 bits _Available since v3.1._ /
|
function toInt16(int256 value) internal pure returns (int16) {
require(
value >= type(int16).min && value <= type(int16).max,
"SafeCast: value doesn't fit in 16 bits"
);
return int16(value);
}
|
function toInt16(int256 value) internal pure returns (int16) {
require(
value >= type(int16).min && value <= type(int16).max,
"SafeCast: value doesn't fit in 16 bits"
);
return int16(value);
}
| 39,075
|
19
|
// Add the token to the staker's list of staked tokens
|
staker.stakedTokens.push(StakedToken(msg.sender, _tokenId));
|
staker.stakedTokens.push(StakedToken(msg.sender, _tokenId));
| 22,962
|
31
|
// The sender should already be certified
|
require(certifier.certified(msg.sender));
|
require(certifier.certified(msg.sender));
| 7,284
|
27
|
// Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. _spender The address which will spend the funds. _value The amount of tokens to be spent. /
|
function approve(address _spender, uint256 _value)
public
onlyPayloadSize(2 * 32)
returns (bool)
|
function approve(address _spender, uint256 _value)
public
onlyPayloadSize(2 * 32)
returns (bool)
| 15,257
|
96
|
// Lazily checks if every reserve tranche has reached maturity. If so redeems the tranche balance for the underlying collateral and removes the tranche from the reserve list. NOTE: We traverse the reserve list in the reverse order as deletions involve swapping the deleted element to the end of the list and removing the last element. We also skip the `reserveAt(0)`, i.e) the mature tranche, which is never removed.
|
uint256 reserveCount = _reserveCount();
for (uint256 i = reserveCount - 1; i > 0; i--) {
ITranche tranche = ITranche(address(_reserveAt(i)));
IBondController bond = IBondController(tranche.bond());
|
uint256 reserveCount = _reserveCount();
for (uint256 i = reserveCount - 1; i > 0; i--) {
ITranche tranche = ITranche(address(_reserveAt(i)));
IBondController bond = IBondController(tranche.bond());
| 13,707
|
27
|
// Claimable Extension for the Ownable contract, where the ownership needs to be claimed.This allows the new owner to accept the transfer. /
|
contract Claimable is Ownable {
address public pendingOwner;
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
pendingOwner = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
}
}
|
contract Claimable is Ownable {
address public pendingOwner;
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
pendingOwner = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
}
}
| 383
|
77
|
// We store the `bptAmount` in the previous slot to the `tokenAmounts` array. We can make sure there will be at least one available slot due to how the memory scratch space works. We can safely overwrite whatever is stored in this slot as we will revert immediately after that.
|
let start := sub(tokenAmounts, 0x20)
mstore(start, bptAmount)
|
let start := sub(tokenAmounts, 0x20)
mstore(start, bptAmount)
| 26,503
|
21
|
// function _msgSender() internal view virtual returns (address payable) {
|
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
|
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
| 8,432
|
14
|
// If this is the first mint the tokens are exactly the supplied underlying
|
mintAmount = _amount;
|
mintAmount = _amount;
| 42,468
|
4
|
// The interface for the contract that manages pools and the options parameters,accumulates the funds from the liquidity providers and makes the withdrawals for them,sells the options contracts to the options buyers and collateralizes them,exercises the ITM (in-the-money) options with the unrealized P&L and settles them,unlocks the expired options and distributes the premiums among the liquidity providers. /
|
interface IHegicPool is IERC721, IPriceCalculator {
enum OptionState {Invalid, Active, Exercised, Expired}
enum TrancheState {Invalid, Open, Closed}
/**
* @param state The state of the option: Invalid, Active, Exercised, Expired
* @param strike The option strike
* @param amount The option size
* @param lockedAmount The option collateral size locked
* @param expired The option expiration timestamp
* @param hedgePremium The share of the premium paid for hedging from the losses
* @param unhedgePremium The share of the premium paid to the hedged liquidity provider
**/
struct Option {
OptionState state;
uint256 strike;
uint256 amount;
uint256 lockedAmount;
uint256 expired;
uint256 hedgePremium;
uint256 unhedgePremium;
}
/**
* @param state The state of the liquidity tranche: Invalid, Open, Closed
* @param share The liquidity provider's share in the pool
* @param amount The size of liquidity provided
* @param creationTimestamp The liquidity deposit timestamp
* @param hedged The liquidity tranche type: hedged or unhedged (classic)
**/
struct Tranche {
TrancheState state;
uint256 share;
uint256 amount;
uint256 creationTimestamp;
bool hedged;
}
/**
* @param id The ERC721 token ID linked to the option
* @param settlementFee The part of the premium that
* is distributed among the HEGIC staking participants
* @param premium The part of the premium that
* is distributed among the liquidity providers
**/
event Acquired(uint256 indexed id, uint256 settlementFee, uint256 premium);
/**
* @param id The ERC721 token ID linked to the option
* @param profit The profits of the option if exercised
**/
event Exercised(uint256 indexed id, uint256 profit);
/**
* @param id The ERC721 token ID linked to the option
**/
event Expired(uint256 indexed id);
/**
* @param account The liquidity provider's address
* @param trancheID The liquidity tranche ID
**/
event Withdrawn(
address indexed account,
uint256 indexed trancheID,
uint256 amount
);
/**
* @param id The ERC721 token ID linked to the option
**/
function unlock(uint256 id) external;
/**
* @param id The ERC721 token ID linked to the option
**/
function exercise(uint256 id) external;
function setLockupPeriod(uint256, uint256) external;
/**
* @param value The hedging pool address
**/
function setHedgePool(address value) external;
/**
* @param trancheID The liquidity tranche ID
* @return amount The liquidity to be received with
* the positive or negative P&L earned or lost during
* the period of holding the liquidity tranche considered
**/
function withdraw(uint256 trancheID) external returns (uint256 amount);
function pricer() external view returns (IPriceCalculator);
/**
* @return amount The unhedged liquidity size
* (unprotected from the losses on selling the options)
**/
function unhedgedBalance() external view returns (uint256 amount);
/**
* @return amount The hedged liquidity size
* (protected from the losses on selling the options)
**/
function hedgedBalance() external view returns (uint256 amount);
/**
* @param account The liquidity provider's address
* @param amount The size of the liquidity tranche
* @param hedged The type of the liquidity tranche
* @param minShare The minimum share in the pool of the user
**/
function provideFrom(
address account,
uint256 amount,
bool hedged,
uint256 minShare
) external returns (uint256 share);
/**
* @param holder The option buyer address
* @param period The option period
* @param amount The option size
* @param strike The option strike
**/
function sellOption(
address holder,
uint256 period,
uint256 amount,
uint256 strike
) external returns (uint256 id);
/**
* @param trancheID The liquidity tranche ID
* @return amount The amount to be received after the withdrawal
**/
function withdrawWithoutHedge(uint256 trancheID)
external
returns (uint256 amount);
/**
* @return amount The total liquidity provided into the pool
**/
function totalBalance() external view returns (uint256 amount);
/**
* @return amount The total liquidity locked in the pool
**/
function lockedAmount() external view returns (uint256 amount);
function token() external view returns (IERC20);
/**
* @return state The state of the option: Invalid, Active, Exercised, Expired
* @return strike The option strike
* @return amount The option size
* @return lockedAmount The option collateral size locked
* @return expired The option expiration timestamp
* @return hedgePremium The share of the premium paid for hedging from the losses
* @return unhedgePremium The share of the premium paid to the hedged liquidity provider
**/
function options(uint256 id)
external
view
returns (
OptionState state,
uint256 strike,
uint256 amount,
uint256 lockedAmount,
uint256 expired,
uint256 hedgePremium,
uint256 unhedgePremium
);
/**
* @return state The state of the liquidity tranche: Invalid, Open, Closed
* @return share The liquidity provider's share in the pool
* @return amount The size of liquidity provided
* @return creationTimestamp The liquidity deposit timestamp
* @return hedged The liquidity tranche type: hedged or unhedged (classic)
**/
function tranches(uint256 id)
external
view
returns (
TrancheState state,
uint256 share,
uint256 amount,
uint256 creationTimestamp,
bool hedged
);
}
|
interface IHegicPool is IERC721, IPriceCalculator {
enum OptionState {Invalid, Active, Exercised, Expired}
enum TrancheState {Invalid, Open, Closed}
/**
* @param state The state of the option: Invalid, Active, Exercised, Expired
* @param strike The option strike
* @param amount The option size
* @param lockedAmount The option collateral size locked
* @param expired The option expiration timestamp
* @param hedgePremium The share of the premium paid for hedging from the losses
* @param unhedgePremium The share of the premium paid to the hedged liquidity provider
**/
struct Option {
OptionState state;
uint256 strike;
uint256 amount;
uint256 lockedAmount;
uint256 expired;
uint256 hedgePremium;
uint256 unhedgePremium;
}
/**
* @param state The state of the liquidity tranche: Invalid, Open, Closed
* @param share The liquidity provider's share in the pool
* @param amount The size of liquidity provided
* @param creationTimestamp The liquidity deposit timestamp
* @param hedged The liquidity tranche type: hedged or unhedged (classic)
**/
struct Tranche {
TrancheState state;
uint256 share;
uint256 amount;
uint256 creationTimestamp;
bool hedged;
}
/**
* @param id The ERC721 token ID linked to the option
* @param settlementFee The part of the premium that
* is distributed among the HEGIC staking participants
* @param premium The part of the premium that
* is distributed among the liquidity providers
**/
event Acquired(uint256 indexed id, uint256 settlementFee, uint256 premium);
/**
* @param id The ERC721 token ID linked to the option
* @param profit The profits of the option if exercised
**/
event Exercised(uint256 indexed id, uint256 profit);
/**
* @param id The ERC721 token ID linked to the option
**/
event Expired(uint256 indexed id);
/**
* @param account The liquidity provider's address
* @param trancheID The liquidity tranche ID
**/
event Withdrawn(
address indexed account,
uint256 indexed trancheID,
uint256 amount
);
/**
* @param id The ERC721 token ID linked to the option
**/
function unlock(uint256 id) external;
/**
* @param id The ERC721 token ID linked to the option
**/
function exercise(uint256 id) external;
function setLockupPeriod(uint256, uint256) external;
/**
* @param value The hedging pool address
**/
function setHedgePool(address value) external;
/**
* @param trancheID The liquidity tranche ID
* @return amount The liquidity to be received with
* the positive or negative P&L earned or lost during
* the period of holding the liquidity tranche considered
**/
function withdraw(uint256 trancheID) external returns (uint256 amount);
function pricer() external view returns (IPriceCalculator);
/**
* @return amount The unhedged liquidity size
* (unprotected from the losses on selling the options)
**/
function unhedgedBalance() external view returns (uint256 amount);
/**
* @return amount The hedged liquidity size
* (protected from the losses on selling the options)
**/
function hedgedBalance() external view returns (uint256 amount);
/**
* @param account The liquidity provider's address
* @param amount The size of the liquidity tranche
* @param hedged The type of the liquidity tranche
* @param minShare The minimum share in the pool of the user
**/
function provideFrom(
address account,
uint256 amount,
bool hedged,
uint256 minShare
) external returns (uint256 share);
/**
* @param holder The option buyer address
* @param period The option period
* @param amount The option size
* @param strike The option strike
**/
function sellOption(
address holder,
uint256 period,
uint256 amount,
uint256 strike
) external returns (uint256 id);
/**
* @param trancheID The liquidity tranche ID
* @return amount The amount to be received after the withdrawal
**/
function withdrawWithoutHedge(uint256 trancheID)
external
returns (uint256 amount);
/**
* @return amount The total liquidity provided into the pool
**/
function totalBalance() external view returns (uint256 amount);
/**
* @return amount The total liquidity locked in the pool
**/
function lockedAmount() external view returns (uint256 amount);
function token() external view returns (IERC20);
/**
* @return state The state of the option: Invalid, Active, Exercised, Expired
* @return strike The option strike
* @return amount The option size
* @return lockedAmount The option collateral size locked
* @return expired The option expiration timestamp
* @return hedgePremium The share of the premium paid for hedging from the losses
* @return unhedgePremium The share of the premium paid to the hedged liquidity provider
**/
function options(uint256 id)
external
view
returns (
OptionState state,
uint256 strike,
uint256 amount,
uint256 lockedAmount,
uint256 expired,
uint256 hedgePremium,
uint256 unhedgePremium
);
/**
* @return state The state of the liquidity tranche: Invalid, Open, Closed
* @return share The liquidity provider's share in the pool
* @return amount The size of liquidity provided
* @return creationTimestamp The liquidity deposit timestamp
* @return hedged The liquidity tranche type: hedged or unhedged (classic)
**/
function tranches(uint256 id)
external
view
returns (
TrancheState state,
uint256 share,
uint256 amount,
uint256 creationTimestamp,
bool hedged
);
}
| 5,499
|
73
|
// Adjust the balance
|
uint256 oldBalance = balances[_buyer];
balances[_buyer] = SafeMath.add(oldBalance, _amount);
totalSupply = checkedSupply;
trackHolder(_buyer);
|
uint256 oldBalance = balances[_buyer];
balances[_buyer] = SafeMath.add(oldBalance, _amount);
totalSupply = checkedSupply;
trackHolder(_buyer);
| 34,269
|
19
|
// Request to leave the set of collator candidates/ @custom:selector b1a3c1b7/candidateCount The number of candidates in the CandidatePool
|
function scheduleLeaveCandidates(uint256 candidateCount) external;
|
function scheduleLeaveCandidates(uint256 candidateCount) external;
| 32,308
|
7
|
// Si los depósitos 'msgSender = 0' , significa que es el primer depósito. Por esto, se agrega 1 al recuento total de jugadores y al contador de sus referidos.
|
if (activatedPlayer_[msg.sender] == false) {
activatedPlayer_[msg.sender] = true;
players += 1;
referralsOf_[_referredBy] += 1;
}
|
if (activatedPlayer_[msg.sender] == false) {
activatedPlayer_[msg.sender] = true;
players += 1;
referralsOf_[_referredBy] += 1;
}
| 9,689
|
24
|
// all returns all list elements _self is a pointer to list in the storagereturn all list elements /
|
function all(
List storage _self
)
public
view
returns(bytes32[] memory)
|
function all(
List storage _self
)
public
view
returns(bytes32[] memory)
| 13,711
|
2
|
// INSUR token address
|
address public INSUR;
|
address public INSUR;
| 32,574
|
26
|
// Adds `gauge` to the GaugeController with type `gaugeType` and an initial weight of zero /
|
function _addGauge(address gauge, string memory gaugeType) private {
require(_isGaugeFromValidFactory(gauge, gaugeType), "Invalid gauge");
// `_gaugeController` enforces that duplicate gauges may not be added so we do not need to check here.
_authorizerAdaptorEntrypoint.performAction(
address(_gaugeController),
abi.encodeWithSelector(IGaugeController.add_gauge.selector, gauge, _ETHEREUM_GAUGE_CONTROLLER_TYPE)
);
}
|
function _addGauge(address gauge, string memory gaugeType) private {
require(_isGaugeFromValidFactory(gauge, gaugeType), "Invalid gauge");
// `_gaugeController` enforces that duplicate gauges may not be added so we do not need to check here.
_authorizerAdaptorEntrypoint.performAction(
address(_gaugeController),
abi.encodeWithSelector(IGaugeController.add_gauge.selector, gauge, _ETHEREUM_GAUGE_CONTROLLER_TYPE)
);
}
| 34,504
|
2
|
// IOptimismMintableERC721/Interface for contracts that are compatible with the OptimismMintableERC721 standard./ Tokens that follow this standard can be easily transferred across the ERC721 bridge.
|
interface IOptimismMintableERC721 is IERC721Enumerable {
/// @notice Emitted when a token is minted.
/// @param account Address of the account the token was minted to.
/// @param tokenId Token ID of the minted token.
event Mint(address indexed account, uint256 tokenId);
/// @notice Emitted when a token is burned.
/// @param account Address of the account the token was burned from.
/// @param tokenId Token ID of the burned token.
event Burn(address indexed account, uint256 tokenId);
/// @notice Mints some token ID for a user, checking first that contract recipients
/// are aware of the ERC721 protocol to prevent tokens from being forever locked.
/// @param _to Address of the user to mint the token for.
/// @param _tokenId Token ID to mint.
function safeMint(address _to, uint256 _tokenId) external;
/// @notice Burns a token ID from a user.
/// @param _from Address of the user to burn the token from.
/// @param _tokenId Token ID to burn.
function burn(address _from, uint256 _tokenId) external;
/// @notice Chain ID of the chain where the remote token is deployed.
function REMOTE_CHAIN_ID() external view returns (uint256);
/// @notice Address of the token on the remote domain.
function REMOTE_TOKEN() external view returns (address);
/// @notice Address of the ERC721 bridge on this network.
function BRIDGE() external view returns (address);
/// @notice Chain ID of the chain where the remote token is deployed.
function remoteChainId() external view returns (uint256);
/// @notice Address of the token on the remote domain.
function remoteToken() external view returns (address);
/// @notice Address of the ERC721 bridge on this network.
function bridge() external view returns (address);
}
|
interface IOptimismMintableERC721 is IERC721Enumerable {
/// @notice Emitted when a token is minted.
/// @param account Address of the account the token was minted to.
/// @param tokenId Token ID of the minted token.
event Mint(address indexed account, uint256 tokenId);
/// @notice Emitted when a token is burned.
/// @param account Address of the account the token was burned from.
/// @param tokenId Token ID of the burned token.
event Burn(address indexed account, uint256 tokenId);
/// @notice Mints some token ID for a user, checking first that contract recipients
/// are aware of the ERC721 protocol to prevent tokens from being forever locked.
/// @param _to Address of the user to mint the token for.
/// @param _tokenId Token ID to mint.
function safeMint(address _to, uint256 _tokenId) external;
/// @notice Burns a token ID from a user.
/// @param _from Address of the user to burn the token from.
/// @param _tokenId Token ID to burn.
function burn(address _from, uint256 _tokenId) external;
/// @notice Chain ID of the chain where the remote token is deployed.
function REMOTE_CHAIN_ID() external view returns (uint256);
/// @notice Address of the token on the remote domain.
function REMOTE_TOKEN() external view returns (address);
/// @notice Address of the ERC721 bridge on this network.
function BRIDGE() external view returns (address);
/// @notice Chain ID of the chain where the remote token is deployed.
function remoteChainId() external view returns (uint256);
/// @notice Address of the token on the remote domain.
function remoteToken() external view returns (address);
/// @notice Address of the ERC721 bridge on this network.
function bridge() external view returns (address);
}
| 29,848
|
99
|
// Returns true if strategy can be upgraded./If there are no aTokens in strategy then it is upgradable
|
function isUpgradable() external view override returns (bool) {
return aToken.balanceOf(address(this)) == 0;
}
|
function isUpgradable() external view override returns (bool) {
return aToken.balanceOf(address(this)) == 0;
}
| 48,905
|
23
|
// Assigns all C-Level addresses/_ceo CEO address/_cfo CFO address/_coo COO address/_commish Commissioner address
|
function setCLevelAddresses(address _ceo, address _cfo, address _coo, address _commish) public onlyCEO {
require(_ceo != address(0));
require(_cfo != address(0));
require(_coo != address(0));
require(_commish != address(0));
ceoAddress = _ceo;
cfoAddress = _cfo;
cooAddress = _coo;
commissionerAddress = _commish;
}
|
function setCLevelAddresses(address _ceo, address _cfo, address _coo, address _commish) public onlyCEO {
require(_ceo != address(0));
require(_cfo != address(0));
require(_coo != address(0));
require(_commish != address(0));
ceoAddress = _ceo;
cfoAddress = _cfo;
cooAddress = _coo;
commissionerAddress = _commish;
}
| 41,479
|
18
|
// deposit made by bidder to initiate buyout /buyoutValuationDeposit = currentValuation - ((reserveTokens in primary curve) + (reserveTokens in secondary curve))
|
uint256 public buyoutValuationDeposit;
|
uint256 public buyoutValuationDeposit;
| 8,681
|
2
|
// return The symbol of the token /
|
function symbol() public view override returns (string memory) {
return _symbol;
}
|
function symbol() public view override returns (string memory) {
return _symbol;
}
| 7,792
|
56
|
// get getDepositDetails/
|
function getDepositDetails(uint256 _id) view public returns (address _withdrawalAddress, uint256 _tokenAmount, uint256 _unlockTime, bool _withdrawn) {
return(lockedToken[_id].withdrawalAddress,lockedToken[_id].tokenAmount, lockedToken[_id].unlockTime,lockedToken[_id].withdrawn);
}
|
function getDepositDetails(uint256 _id) view public returns (address _withdrawalAddress, uint256 _tokenAmount, uint256 _unlockTime, bool _withdrawn) {
return(lockedToken[_id].withdrawalAddress,lockedToken[_id].tokenAmount, lockedToken[_id].unlockTime,lockedToken[_id].withdrawn);
}
| 40,792
|
276
|
// Boolean indicating if return values of `getPoolBalance` are to be cached. /
|
bool _cachePoolBalances;
|
bool _cachePoolBalances;
| 35,789
|
166
|
// Check nft registry
|
IERC721 nftRegistry = _requireERC721(_nftAddress);
|
IERC721 nftRegistry = _requireERC721(_nftAddress);
| 47,931
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.