Unnamed: 0 int64 0 7.36k | comments stringlengths 3 35.2k | code_string stringlengths 1 527k | code stringlengths 1 527k | __index_level_0__ int64 0 88.6k |
|---|---|---|---|---|
11 | // Transfers 'value' amount of tokens from address 'from' to address 'to'. | * Emits {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external override returns (bool) {
require(to != from);
require(to != address(0));
require(value <= balanceOf[from]);
require(value <= allowed[from][msg.sender]);
balanceOf[from] -= value;
balanceOf[to] += value;
allowed[from][msg.sender] -= value;
addHolder(to);
emit Transfer(from, to, value);
return true;
}
| * Emits {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external override returns (bool) {
require(to != from);
require(to != address(0));
require(value <= balanceOf[from]);
require(value <= allowed[from][msg.sender]);
balanceOf[from] -= value;
balanceOf[to] += value;
allowed[from][msg.sender] -= value;
addHolder(to);
emit Transfer(from, to, value);
return true;
}
| 1,271 |
6 | // for curve t2t | ICurvePool curvePool;
| ICurvePool curvePool;
| 34,369 |
28 | // Storing address of target | constructor(address _target) public{
target = _target;
}
| constructor(address _target) public{
target = _target;
}
| 29,878 |
27 | // ERC721 functions | function balanceOf(address _owner) public view override returns (uint256 _balance){
//à compléter
}
| function balanceOf(address _owner) public view override returns (uint256 _balance){
//à compléter
}
| 8,165 |
170 | // name of your Token (eg. "BoredApeYachtClub") | string memory _name,
| string memory _name,
| 13,953 |
23 | // Sets the pool payment default duration. _poolId The Id of the pool. _duration The duration to be set. / | function setPaymentDefaultDuration(
uint256 _poolId,
uint32 _duration
| function setPaymentDefaultDuration(
uint256 _poolId,
uint32 _duration
| 11,237 |
116 | // generate our synth currency key to check if enough time has elapsed | address _synth;
bytes32 _synthCurrencyKey;
if (_vaultToken == 0x1b905331F7dE2748F4D6a0678e1521E20347643F) {
| address _synth;
bytes32 _synthCurrencyKey;
if (_vaultToken == 0x1b905331F7dE2748F4D6a0678e1521E20347643F) {
| 60,124 |
7 | // allow owner to set flush address | function setFlushAddress(address to) external onlyOwner{
flushAddress = to;
}
| function setFlushAddress(address to) external onlyOwner{
flushAddress = to;
}
| 19,931 |
59 | // Require that the random result is not 0 | require(randomResult != 0, "Waffle: Please wait for Chainlink VRF to update the winner first.");
| require(randomResult != 0, "Waffle: Please wait for Chainlink VRF to update the winner first.");
| 8,570 |
163 | // deletes proposal signature data after successfully executing a multiSig function | function deleteProposal(Data storage self, bytes32 _whatFunction)
internal
| function deleteProposal(Data storage self, bytes32 _whatFunction)
internal
| 2,977 |
30 | // Gets the balance of the specified address._owner The address to query the the balance of. return An uint256 representing the amount owned by the passed address./ | function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
| function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
| 1,844 |
144 | // Get new id | newNftId = _reissueStakeNftId(nftId, lookupIndex);
| newNftId = _reissueStakeNftId(nftId, lookupIndex);
| 13,583 |
112 | // Transfers the StakeAmount from the reporded miner to the reporting party | TellorTransfer.doTransfer(self, disp.reportedMiner,disp.reportingParty, self.uintVars[keccak256("stakeAmount")]);
| TellorTransfer.doTransfer(self, disp.reportedMiner,disp.reportingParty, self.uintVars[keccak256("stakeAmount")]);
| 8,760 |
99 | // check name string查询某个名字是否可以注册 / | function checkIfNameValid(string memory nameStr)
public
view
returns(bool)
| function checkIfNameValid(string memory nameStr)
public
view
returns(bool)
| 36,981 |
26 | // set Question to Closed | allQuestions[allAnswers[_id].questionId].state = State.Closed;
| allQuestions[allAnswers[_id].questionId].state = State.Closed;
| 30,029 |
2 | // He tweeted and we created. / | abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this;
return msg.data;
}
}
| abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this;
return msg.data;
}
}
| 30 |
74 | // 撤销买单,当 卖队列无法满足 买队列时 正确 | function cancelBuyOrder() public override {
require(msg.sender!=address(0), "#1");
ITlbShop(_contractShop)._cancelBuyOrder(msg.sender);
}
| function cancelBuyOrder() public override {
require(msg.sender!=address(0), "#1");
ITlbShop(_contractShop)._cancelBuyOrder(msg.sender);
}
| 50,676 |
4 | // : Mints NFT to desired wallet: walletAddress - The walletAddress to mint to: quantity - The quantity to mint / | function mint(address walletAddress, uint256 quantity) external onlyRole(MINTER_ROLE) {
require(!PAUSED, "Minting is paused");
_safeMint(walletAddress, quantity);
}
| function mint(address walletAddress, uint256 quantity) external onlyRole(MINTER_ROLE) {
require(!PAUSED, "Minting is paused");
_safeMint(walletAddress, quantity);
}
| 15,019 |
475 | // returns an `Sint256` positive representation of an unsigned integer / | function toPos256(uint256 n) internal pure returns (Sint256 memory) {
return Sint256({ value: n, isNeg: false });
}
| function toPos256(uint256 n) internal pure returns (Sint256 memory) {
return Sint256({ value: n, isNeg: false });
}
| 31,422 |
86 | // previous rounds | function getRoundTotalSupply(uint r) external view returns(uint256);
function getRoundExpiryDate(uint r) external view returns(uint);
function getRoundStrikePrice(uint r) external view returns(uint);
function getRoundSettlePrice(uint r) external view returns(uint);
function getRoundTotalPremiums(uint r) external view returns(uint);
function getRoundBalanceOf(uint r, address account) external view returns (uint256);
function getRoundPremiumShare(uint r) external view returns(uint);
function setRoundPremiumShare(uint r, uint premiumShare) external;
function getUnclaimedProfitsRounds(address account) external view returns (uint[] memory);
function popUnclaimedProfitsRound(address account) external returns (uint);
| function getRoundTotalSupply(uint r) external view returns(uint256);
function getRoundExpiryDate(uint r) external view returns(uint);
function getRoundStrikePrice(uint r) external view returns(uint);
function getRoundSettlePrice(uint r) external view returns(uint);
function getRoundTotalPremiums(uint r) external view returns(uint);
function getRoundBalanceOf(uint r, address account) external view returns (uint256);
function getRoundPremiumShare(uint r) external view returns(uint);
function setRoundPremiumShare(uint r, uint premiumShare) external;
function getUnclaimedProfitsRounds(address account) external view returns (uint[] memory);
function popUnclaimedProfitsRound(address account) external returns (uint);
| 13,370 |
222 | // Disables the corresponding DMMA from minting new tokens. This allows the market to close over time, since users are only able to redeem tokens.dmmTokenIdThe DMMA that should be disabled. / | function disableMarket(uint dmmTokenId) external;
| function disableMarket(uint dmmTokenId) external;
| 2,470 |
117 | // weiAmount(fee %)(EDO/Wei) / (decimals in edo/wei) / (decimals in percentage) | if (!__isSell__(makerOrder)) {
| if (!__isSell__(makerOrder)) {
| 11,892 |
132 | // PUBLIC FACING: Enter the auction lobby for the current round referrerAddr TRX address of referring user (optional; 0x0 for no referrer) / | function xfLobbyEnter(address referrerAddr)
external
payable
| function xfLobbyEnter(address referrerAddr)
external
payable
| 76,734 |
128 | // This method can be used by the owner to extract mistakenly/sent tokens to this contract./_token The address of the token contract that you want to recover | function rescueTokens(address _token, address _dst) public governance {
uint balance = IERC20(_token).balanceOf(address(this));
IERC20(_token).safeTransfer(_dst, balance);
}
| function rescueTokens(address _token, address _dst) public governance {
uint balance = IERC20(_token).balanceOf(address(this));
IERC20(_token).safeTransfer(_dst, balance);
}
| 3,237 |
16 | // Whether or not a particular contract is available for projects to migrate their funds and Tickets to. | mapping(ITerminal => bool) public override migrationIsAllowed;
| mapping(ITerminal => bool) public override migrationIsAllowed;
| 28,490 |
146 | // Update price oracle with the pre-exit balances | _updateOracle(lastChangeBlock, balances[0], balances[1]);
| _updateOracle(lastChangeBlock, balances[0], balances[1]);
| 52,204 |
55 | // send back ETH above fee | safeTransferETH(msg.sender, msg.value.sub(fee));
emit TokensBurned(msg.sender, vault.Id, _amount);
| safeTransferETH(msg.sender, msg.value.sub(fee));
emit TokensBurned(msg.sender, vault.Id, _amount);
| 11,174 |
5 | // Removes the ClaimIssuer contract of a trusted claim issuer trustedIssueris the address of the trusted issuer's ClaimIssuer contract / | function removeTrustedIssuer(
IClaimIssuer trustedIssuer
| function removeTrustedIssuer(
IClaimIssuer trustedIssuer
| 12,830 |
183 | // Disable an old outbox from interacting with the bridge _outbox Outbox contract to remove / | function removeOldOutbox(address _outbox) external;
| function removeOldOutbox(address _outbox) external;
| 55,993 |
364 | // 验证交易滑点是否满足条件/path 兑换路径/uniV3Factory uniswap v3 factory/maxSqrtSlippage 最大滑点,最大值: 1e4/ return 当前价 | function verifySlippage(
bytes memory path,
address uniV3Factory,
uint32 maxSqrtSlippage
| function verifySlippage(
bytes memory path,
address uniV3Factory,
uint32 maxSqrtSlippage
| 35,509 |
12 | // PAUSE GUARDIAN FUNCTIONS / Admin function to change the Pause Guardian newPauseGuardian The address of the new Pause Guardianreturn uint 0=success, otherwise a failure. (See enum Error for details) / | function _setPauseGuardian(address newPauseGuardian) external onlyGovernor returns (uint) {
return comptroller._setPauseGuardian(newPauseGuardian);
}
| function _setPauseGuardian(address newPauseGuardian) external onlyGovernor returns (uint) {
return comptroller._setPauseGuardian(newPauseGuardian);
}
| 41,969 |
130 | // WorkLock interface/ | interface WorkLockInterface {
function token() external view returns (NuCypherToken);
}
| interface WorkLockInterface {
function token() external view returns (NuCypherToken);
}
| 49,991 |
49 | // adds a pool to the whitelist can only be called by the contract owner_poolAnchor pool anchor/ | function addPoolToWhitelist(IConverterAnchor _poolAnchor)
| function addPoolToWhitelist(IConverterAnchor _poolAnchor)
| 23,135 |
6 | // Returns the amount of tokens owned by `account`./ | function balanceOf(address account) external view returns (uint256);
| function balanceOf(address account) external view returns (uint256);
| 2,918 |
107 | // change the minimum amount of tokens to sell from fees | function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){
require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply.");
require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply.");
swapTokensAtAmount = newAmount;
return true;
}
| function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){
require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply.");
require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply.");
swapTokensAtAmount = newAmount;
return true;
}
| 665 |
73 | // loop over past epochs from the latest `dead` epoch to the current | uint256 earliest_non_dead_auction_epoch = 1;
uint256 earlist_epoch = getEarliestActiveAuctionEpoch();
uint256 epochCurrent = epoch();
uint256 temp_epoch = (epochCurrent.sub(earlist_epoch) > Constants.getCouponAuctionMaxEpochsBestBidderSelection()) ? earlist_epoch.add(Constants.getCouponAuctionMaxEpochsBestBidderSelection()) : epochCurrent;
for (uint256 d_idx = earlist_epoch; d_idx < temp_epoch; d_idx++) {
uint256 temp_coupon_auction_epoch = d_idx;
Epoch.AuctionState storage auction = getCouponAuctionAtEpoch(temp_coupon_auction_epoch);
earliest_non_dead_auction_epoch = d_idx;
if (auction.finished) {
| uint256 earliest_non_dead_auction_epoch = 1;
uint256 earlist_epoch = getEarliestActiveAuctionEpoch();
uint256 epochCurrent = epoch();
uint256 temp_epoch = (epochCurrent.sub(earlist_epoch) > Constants.getCouponAuctionMaxEpochsBestBidderSelection()) ? earlist_epoch.add(Constants.getCouponAuctionMaxEpochsBestBidderSelection()) : epochCurrent;
for (uint256 d_idx = earlist_epoch; d_idx < temp_epoch; d_idx++) {
uint256 temp_coupon_auction_epoch = d_idx;
Epoch.AuctionState storage auction = getCouponAuctionAtEpoch(temp_coupon_auction_epoch);
earliest_non_dead_auction_epoch = d_idx;
if (auction.finished) {
| 41,094 |
10 | // Ownership check above ensures no underflow. | unchecked {
balanceOf[owner]--;
}
| unchecked {
balanceOf[owner]--;
}
| 13,055 |
95 | // No trading is performed on deposit | if(nonContract == true){ }
| if(nonContract == true){ }
| 3,977 |
275 | // Set maximum count to mint per once. / | function setMaxToMint(uint256 _maxValue) external onlyOwner {
maxToMint = _maxValue;
}
| function setMaxToMint(uint256 _maxValue) external onlyOwner {
maxToMint = _maxValue;
}
| 34,031 |
141 | // We need this libary for Rarible | library LibPart {
bytes32 public constant TYPE_HASH = keccak256("Part(address account,uint96 value)");
struct Part {
address payable account;
uint96 value;
}
function hash(Part memory part) internal pure returns (bytes32) {
return keccak256(abi.encode(TYPE_HASH, part.account, part.value));
}
}
| library LibPart {
bytes32 public constant TYPE_HASH = keccak256("Part(address account,uint96 value)");
struct Part {
address payable account;
uint96 value;
}
function hash(Part memory part) internal pure returns (bytes32) {
return keccak256(abi.encode(TYPE_HASH, part.account, part.value));
}
}
| 44,913 |
115 | // Create tokens / | function create(uint256 tokensToCreate) external;
| function create(uint256 tokensToCreate) external;
| 70,647 |
176 | // SPECTRE tokens created per block. | uint256 public spectrePerBlock;
| uint256 public spectrePerBlock;
| 45,090 |
491 | // Update remove delegator evaluation window duration _duration - new window duration / | function updateRemoveDelegatorEvalDuration(uint256 _duration) external {
_requireIsInitialized();
require(msg.sender == governanceAddress, ERROR_ONLY_GOVERNANCE);
removeDelegatorEvalDuration = _duration;
emit RemoveDelegatorEvalDurationUpdated(_duration);
}
| function updateRemoveDelegatorEvalDuration(uint256 _duration) external {
_requireIsInitialized();
require(msg.sender == governanceAddress, ERROR_ONLY_GOVERNANCE);
removeDelegatorEvalDuration = _duration;
emit RemoveDelegatorEvalDurationUpdated(_duration);
}
| 3,330 |
22 | // We take the portion of the offer that we need | _take(offerId, uint128(baux), offerType);
payAmt = 0; //All amount is sold
| _take(offerId, uint128(baux), offerType);
payAmt = 0; //All amount is sold
| 12,989 |
287 | // A descriptive name for a collection of NFTs in this contract | function name() external view returns (string memory _name);
| function name() external view returns (string memory _name);
| 3,734 |
24 | // "_selectorCount >> 3" is a gas efficient division by 8 "_selectorCount / 8" | uint256 selectorSlotCount = _selectorCount >> 3;
| uint256 selectorSlotCount = _selectorCount >> 3;
| 9,854 |
135 | // Internal functions // / | function _getSetting(bytes32 name) internal view returns (SettingsLib.Setting memory) {
return settings[name];
}
| function _getSetting(bytes32 name) internal view returns (SettingsLib.Setting memory) {
return settings[name];
}
| 56,016 |
448 | // expmods_and_points.points[102] = -(g^16372z). | mstore(add(expmodsAndPoints, 0x1000), point)
| mstore(add(expmodsAndPoints, 0x1000), point)
| 29,090 |
1 | // USDC token contract address on BSC Testnet | address private constant WALLET_A =
0x4862ADFAdFF8f20633Fb52C1eD5040602cB5626E; // address for Wallet A
address private constant WALLET_B =
0xAE28a1cCeb77258DfbE07cB308ecf65DE49398c9; // address for Wallet B
address private constant WALLET_C =
0x1cc1468758C02bcB1988CcBce827d58F7889CE03; // address for Wallet C
uint256 private totalDeposited;
mapping(address => uint256) public depositedAmounts;
| address private constant WALLET_A =
0x4862ADFAdFF8f20633Fb52C1eD5040602cB5626E; // address for Wallet A
address private constant WALLET_B =
0xAE28a1cCeb77258DfbE07cB308ecf65DE49398c9; // address for Wallet B
address private constant WALLET_C =
0x1cc1468758C02bcB1988CcBce827d58F7889CE03; // address for Wallet C
uint256 private totalDeposited;
mapping(address => uint256) public depositedAmounts;
| 4,351 |
18 | // Modifier that checks that the contract has finished successfully/ | modifier hasFinished() {
require((gameFinishedTime != 0) && now >= (gameFinishedTime + (15 days)));
_;
}
| modifier hasFinished() {
require((gameFinishedTime != 0) && now >= (gameFinishedTime + (15 days)));
_;
}
| 23,932 |
23 | // replace | require(oldFacetAddress != _newFacetAddress, "LibDiamondCut: Can't replace function with same function");
removeSelector(oldFacetAddress, selector);
addSelector(_newFacetAddress, selector);
| require(oldFacetAddress != _newFacetAddress, "LibDiamondCut: Can't replace function with same function");
removeSelector(oldFacetAddress, selector);
addSelector(_newFacetAddress, selector);
| 42,726 |
46 | // We write previously calculated values into storage // We emit a Mint event, and a Transfer event // We call the defense hook / unused function comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens); |
return (uint256(Error.NO_ERROR), vars.actualMintAmount);
|
return (uint256(Error.NO_ERROR), vars.actualMintAmount);
| 2,026 |
9 | // function to add tokens to the user that calls the contract the money held in contract is sent using a payable modifier function money can be released using selfdestruct(address) | function addTokens() payable {
uint present = 0;
uint tokensToAdd = msg.value/(10**18);
for(uint i = 0; i < userAddresses.length; i++) {
if(userAddresses[i] == msg.sender) {
present = 1;
break;
}
}
// adding tokens if the user present in the userAddresses array
if (present == 1) {
users[msg.sender].tokensBought += tokensToAdd;
}
}
| function addTokens() payable {
uint present = 0;
uint tokensToAdd = msg.value/(10**18);
for(uint i = 0; i < userAddresses.length; i++) {
if(userAddresses[i] == msg.sender) {
present = 1;
break;
}
}
// adding tokens if the user present in the userAddresses array
if (present == 1) {
users[msg.sender].tokensBought += tokensToAdd;
}
}
| 46,591 |
22 | // Converts all of caller's dividends to tokens. / | function reinvest()
onlyStronghands()
public
| function reinvest()
onlyStronghands()
public
| 2,126 |
95 | // gets start index and end index in a stream schedule/streamId stream index/start start time (in seconds)/end end time (in seconds) | function startEndScheduleIndex(
uint256 streamId,
uint256 start,
uint256 end
| function startEndScheduleIndex(
uint256 streamId,
uint256 start,
uint256 end
| 14,770 |
47 | // reset topCandidate | topCandidate = address(0);
topCandidateVotes = 0;
if (managerLimit > managers.length) {
nextVotingPeriod = block.number.add(13000);
} else {
| topCandidate = address(0);
topCandidateVotes = 0;
if (managerLimit > managers.length) {
nextVotingPeriod = block.number.add(13000);
} else {
| 23,614 |
3 | // Address of mintable token instance / | Mintable public token;
| Mintable public token;
| 50,872 |
7 | // self administration | _setupRole(TIMELOCK_ADMIN_ROLE, address(this));
| _setupRole(TIMELOCK_ADMIN_ROLE, address(this));
| 6,205 |
6 | // 定义一个调用AddressList的合约 | contract MockAlarmList {
using AlarmList for AlarmList.alarmMap;
AlarmList.alarmMap tasks;
function insert(
address _addr,
address _creator,
uint256 _type,
uint256 _begin,
uint256 _peroid
) public returns (bool) {
return tasks.insert(_addr, _creator, _type, _begin, _peroid);
}
function remove(address _addr) public returns (bool) {
return tasks.remove(_addr);
}
function get(uint256 _idx) public view returns (AlarmList.element) {
return tasks.get(_idx);
}
function getByAddr(address _addr) public view returns (AlarmList.element) {
return tasks.getByAddr(_addr);
}
function getList(uint256 from, uint256 _count)
public
view
returns (AlarmList.element[] memory)
{
return tasks.getList(from, _count);
}
function count() public view returns (uint256) {
return tasks.count();
}
}
| contract MockAlarmList {
using AlarmList for AlarmList.alarmMap;
AlarmList.alarmMap tasks;
function insert(
address _addr,
address _creator,
uint256 _type,
uint256 _begin,
uint256 _peroid
) public returns (bool) {
return tasks.insert(_addr, _creator, _type, _begin, _peroid);
}
function remove(address _addr) public returns (bool) {
return tasks.remove(_addr);
}
function get(uint256 _idx) public view returns (AlarmList.element) {
return tasks.get(_idx);
}
function getByAddr(address _addr) public view returns (AlarmList.element) {
return tasks.getByAddr(_addr);
}
function getList(uint256 from, uint256 _count)
public
view
returns (AlarmList.element[] memory)
{
return tasks.getList(from, _count);
}
function count() public view returns (uint256) {
return tasks.count();
}
}
| 4,889 |
90 | // chainlink already give data as 108 so covnert to 18 decimal | function checkInflation() external view returns(uint256){
return _inflation();
}
| function checkInflation() external view returns(uint256){
return _inflation();
}
| 41,004 |
261 | // Mapping from Pool ID to quantity of AO available to buy at `price` | mapping (uint256 => uint256) public poolTotalQuantity;
| mapping (uint256 => uint256) public poolTotalQuantity;
| 53,066 |
151 | // Ensure that the supplied default expiration does not exceed 1 month. | require(
newTimelockExpiration <= 30 days,
"New timelock expiration cannot exceed one month."
);
| require(
newTimelockExpiration <= 30 days,
"New timelock expiration cannot exceed one month."
);
| 35,453 |
74 | // Moves `amount` tokens from the caller's account to `recipient`. Returns a boolean value indicating whether the operation succeeded. | * Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| * Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 156 |
2 | // info about rewards for a particular staking token | struct StakingRewardsInfo {
address stakingRewards;
uint rewardAmount;
}
| struct StakingRewardsInfo {
address stakingRewards;
uint rewardAmount;
}
| 11,297 |
50 | // Returns an `BooleanSlot` with member `value` located at `slot`. / | function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
| function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
| 18,634 |
0 | // activates / deactivates the terms of use. | function setTermsActivation(TermsDataTypes.Terms storage termsData, bool _active) external {
if (_active) {
_activateTerms(termsData);
} else {
_deactivateTerms(termsData);
}
}
| function setTermsActivation(TermsDataTypes.Terms storage termsData, bool _active) external {
if (_active) {
_activateTerms(termsData);
} else {
_deactivateTerms(termsData);
}
}
| 24,779 |
99 | // A crowdsaled token that you can also burn./ | contract BurnableCrowdsaleToken is BurnableToken, CrowdsaleToken {
function BurnableCrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable) public
CrowdsaleToken(_name, _symbol, _initialSupply, _decimals, _mintable) {
}
}
| contract BurnableCrowdsaleToken is BurnableToken, CrowdsaleToken {
function BurnableCrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable) public
CrowdsaleToken(_name, _symbol, _initialSupply, _decimals, _mintable) {
}
}
| 48,807 |
225 | // We will use these to be able to calculate remaining correctly. | uint256 public totalGiftSupply;
uint256 public totalPublicSupply;
mapping(address => bool) private _allowList;
mapping(address => uint256) private _allowListClaimed;
address public authAdmin;
string private _contractURI = '';
string private _tokenBaseURI = '';
string private _tokenRevealedBaseURI = '';
string public contractName;
| uint256 public totalGiftSupply;
uint256 public totalPublicSupply;
mapping(address => bool) private _allowList;
mapping(address => uint256) private _allowListClaimed;
address public authAdmin;
string private _contractURI = '';
string private _tokenBaseURI = '';
string private _tokenRevealedBaseURI = '';
string public contractName;
| 23,315 |
25 | // Update collection size | function setCollectionSize (uint256 newCollectionSize)
public
onlyOwner
virtual
returns (uint256)
| function setCollectionSize (uint256 newCollectionSize)
public
onlyOwner
virtual
returns (uint256)
| 46,934 |
239 | // returns the amount of each reserve token entitled for a given amount of pool tokens_amountamount of pool tokens_reserveTokens address of each reserve token return the amount of each reserve token entitled for the given amount of pool tokens/ | function removeLiquidityReturn(uint256 _amount, IERC20Token[] memory _reserveTokens)
public
view
returns (uint256[] memory)
| function removeLiquidityReturn(uint256 _amount, IERC20Token[] memory _reserveTokens)
public
view
returns (uint256[] memory)
| 25,368 |
13 | // Query balance | (bool success, bytes memory returnData) = tokenAddress.staticcall(balanceOfData);
uint256 totalBalance = success && returnData.length == 32 ? returnData.readUint256(0) : 0;
| (bool success, bytes memory returnData) = tokenAddress.staticcall(balanceOfData);
uint256 totalBalance = success && returnData.length == 32 ? returnData.readUint256(0) : 0;
| 515 |
98 | // event UpdateTaxes(); |
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event BuyBackTriggered(uint256 amount);
event OwnerForcedSwapBack(uint256 timestamp);
|
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event BuyBackTriggered(uint256 amount);
event OwnerForcedSwapBack(uint256 timestamp);
| 26,986 |
28 | // Withdraws contributions of multiple appeal rounds at once. This function is O(n) where n is the number of rounds.This could exceed the gas limit, therefore this function should be used only as a utility and not be relied upon by other contracts._localDisputeID The dispute ID as defined in the arbitrable contract._beneficiary The address that made the contributions._cursor The round from where to start withdrawing._count The number of rounds to iterate. If set to 0 or a value larger than the number of rounds, iterates until the last round._ruling The ruling to which the contributions were made. / | function batchWithdrawFeesAndRewards(
ArbitrableStorage storage self,
uint256 _localDisputeID,
address payable _beneficiary,
uint256 _cursor,
uint256 _count,
uint256 _ruling
| function batchWithdrawFeesAndRewards(
ArbitrableStorage storage self,
uint256 _localDisputeID,
address payable _beneficiary,
uint256 _cursor,
uint256 _count,
uint256 _ruling
| 31,820 |
18 | // update counters | for (uint256 i = 0; i < numberOfTokens; ++i) {
_tokenIds.increment();
}
| for (uint256 i = 0; i < numberOfTokens; ++i) {
_tokenIds.increment();
}
| 19,428 |
148 | // accrues interest and updates the interest rate model using _setInterestRateModelFresh Admin function to accrue interest and update the interest rate model newInterestRateModel the new interest rate model to usereturn uint 0=success, otherwise a failure (see ErrorReporter.sol for details) / | function _setInterestRateModel(address newInterestRateModel) public override returns (uint256) {
uint256 error = accrueInterest();
if (error != uint256(Error.NO_ERROR)) {
// accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed
return Error(error).fail(FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED);
}
// _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to.
return _setInterestRateModelFresh(newInterestRateModel);
}
| function _setInterestRateModel(address newInterestRateModel) public override returns (uint256) {
uint256 error = accrueInterest();
if (error != uint256(Error.NO_ERROR)) {
// accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed
return Error(error).fail(FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED);
}
// _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to.
return _setInterestRateModelFresh(newInterestRateModel);
}
| 27,511 |
41 | // update reserves and, on the first call per block, price accumulators | function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
| function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
| 1,529 |
3 | // if will still block the message pathway from (srcChainId, srcAddress). should not receive message from untrusted remote. | require(_srcAddress.length == trustedRemote.length && trustedRemote.length > 0 && keccak256(_srcAddress) == keccak256(trustedRemote), "LzApp: invalid source sending contract");
_blockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload);
| require(_srcAddress.length == trustedRemote.length && trustedRemote.length > 0 && keccak256(_srcAddress) == keccak256(trustedRemote), "LzApp: invalid source sending contract");
_blockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload);
| 21,184 |
66 | // TODO comment actual hash value. | bytes32 constant private ERC20TOKEN_ERC1820_INTERFACE_ID = keccak256( "ERC20Token" );
| bytes32 constant private ERC20TOKEN_ERC1820_INTERFACE_ID = keccak256( "ERC20Token" );
| 9,915 |
178 | // Calculates amount of base tokens that needs to be paid out to all users / | function calcPayoff(
uint256[] memory strikePrices,
uint256 expiryPrice,
bool isPut,
uint256[] memory longSupplies,
uint256[] memory shortSupplies
| function calcPayoff(
uint256[] memory strikePrices,
uint256 expiryPrice,
bool isPut,
uint256[] memory longSupplies,
uint256[] memory shortSupplies
| 2,087 |
53 | // Set fee wallet | function SetFeeWallet(address _team_wallet) public onlyOwner {
team_wallet = _team_wallet;
}
| function SetFeeWallet(address _team_wallet) public onlyOwner {
team_wallet = _team_wallet;
}
| 34,013 |
122 | // Destroys `amount` tokens of token type `id` from `from` Requirements: - `from` cannot be the zero address.- `from` must have at least `amount` tokens of token type `id`. / | function _burn(
address from,
uint256 id,
uint256 amount
| function _burn(
address from,
uint256 id,
uint256 amount
| 21,441 |
7 | // if it's dai_join_addr don't check gem() it will fail | if (_joinAddr == DAI_JOIN_ADDR) return false;
| if (_joinAddr == DAI_JOIN_ADDR) return false;
| 45,724 |
234 | // The facet of the Ethernauts Explore contract that send a ship to explore the deep space./An owned ship can be send on an expedition. Exploration takes timeand will always result in “success”. This means the ship can never be destroyedand always returns with a collection of loot. The degree of success is dependenton different factors as sector stats, gamma ray burst number and ship stats.While the ship is exploring it cannot be acted on in any way until the expedition completes.After the ship returns from an expedition the user is then rewarded with a number of objects (assets)./Ethernatus - Fernando | contract EthernautsExplore is EthernautsLogic {
/// @dev Delegate constructor to Nonfungible contract.
function EthernautsExplore() public
EthernautsLogic() {}
/*** EVENTS ***/
/// emit signal to anyone listening in the universe
event Explore(uint256 shipId, uint256 sectorID, uint256 crewId, uint256 time);
event Result(uint256 shipId, uint256 sectorID);
/*** CONSTANTS ***/
uint8 constant STATS_CAPOUT = 2**8 - 1; // all stats have a range from 0 to 255
// @dev Sanity check that allows us to ensure that we are pointing to the
// right explore contract in our EthernautsCrewMember(address _CExploreAddress) call.
bool public isEthernautsExplore = true;
// An approximation of currently how many seconds are in between blocks.
uint256 public secondsPerBlock = 15;
uint256 public TICK_TIME = 15; // time is always in minutes
// exploration fee
uint256 public percentageCut = 90;
int256 public SPEED_STAT_MAX = 30;
int256 public RANGE_STAT_MAX = 20;
int256 public MIN_TIME_EXPLORE = 60;
int256 public MAX_TIME_EXPLORE = 2160;
int256 public RANGE_SCALE = 2;
/// @dev Sector stats
enum SectorStats {Size, Threat, Difficulty, Slots}
/// @dev hold all ships in exploration
uint256[] explorers;
/// @dev A mapping from Ship token to the exploration index.
mapping (uint256 => uint256) public tokenIndexToExplore;
/// @dev A mapping from Asset UniqueIDs to the sector token id.
mapping (uint256 => uint256) public tokenIndexToSector;
/// @dev A mapping from exploration index to the crew token id.
mapping (uint256 => uint256) public exploreIndexToCrew;
/// @dev A mission counter for crew.
mapping (uint256 => uint16) public missions;
/// @dev A mapping from Owner Cut (wei) to the sector token id.
mapping (uint256 => uint256) public sectorToOwnerCut;
mapping (uint256 => uint256) public sectorToOracleFee;
/// @dev Get a list of ship exploring our universe
function getExplorerList() public view returns(
uint256[3][]
) {
uint256[3][] memory tokens = new uint256[3][](50);
uint256 index = 0;
for(uint256 i = 0; i < explorers.length && index < 50; i++) {
if (explorers[i] > 0) {
tokens[index][0] = explorers[i];
tokens[index][1] = tokenIndexToSector[explorers[i]];
tokens[index][2] = exploreIndexToCrew[i];
index++;
}
}
if (index == 0) {
// Return an empty array
return new uint256[3][](0);
} else {
return tokens;
}
}
/// @dev Get a list of ship exploring our universe
/// @param _shipTokenId The Token ID that represents a ship
function getIndexByShip(uint256 _shipTokenId) public view returns( uint256 ) {
for(uint256 i = 0; i < explorers.length; i++) {
if (explorers[i] == _shipTokenId) {
return i;
}
}
return 0;
}
function setOwnerCut(uint256 _sectorId, uint256 _ownerCut) external onlyCLevel {
sectorToOwnerCut[_sectorId] = _ownerCut;
}
function setOracleFee(uint256 _sectorId, uint256 _oracleFee) external onlyCLevel {
sectorToOracleFee[_sectorId] = _oracleFee;
}
function setTickTime(uint256 _tickTime) external onlyCLevel {
TICK_TIME = _tickTime;
}
function setPercentageCut(uint256 _percentageCut) external onlyCLevel {
percentageCut = _percentageCut;
}
function setMissions(uint256 _tokenId, uint16 _total) public onlyCLevel {
missions[_tokenId] = _total;
}
/// @notice Explore a sector with a defined ship. Sectors contain a list of Objects that can be given to the players
/// when exploring. Each entry has a Drop Rate and are sorted by Sector ID and Drop rate.
/// The drop rate is a whole number between 0 and 1,000,000. 0 is 0% and 1,000,000 is 100%.
/// Every time a Sector is explored a random number between 0 and 1,000,000 is calculated for each available Object.
/// If the final result is lower than the Drop Rate of the Object, that Object will be rewarded to the player once
/// Exploration is complete. Only 1 to 5 Objects maximum can be dropped during one exploration.
/// (FUTURE VERSIONS) The final number will be affected by the user’s Ship Stats.
/// @param _shipTokenId The Token ID that represents a ship
/// @param _sectorTokenId The Token ID that represents a sector
/// @param _crewTokenId The Token ID that represents a crew
function explore(uint256 _shipTokenId, uint256 _sectorTokenId, uint256 _crewTokenId) payable external whenNotPaused {
// charge a fee for each exploration when the results are ready
require(msg.value >= sectorToOwnerCut[_sectorTokenId]);
// check if Asset is a ship or not
require(ethernautsStorage.isCategory(_shipTokenId, uint8(AssetCategory.Ship)));
// check if _sectorTokenId is a sector or not
require(ethernautsStorage.isCategory(_sectorTokenId, uint8(AssetCategory.Sector)));
// Ensure the Ship is in available state, otherwise it cannot explore
require(ethernautsStorage.isState(_shipTokenId, uint8(AssetState.Available)));
// ship could not be in exploration
require(tokenIndexToExplore[_shipTokenId] == 0);
require(!isExploring(_shipTokenId));
// check if explorer is ship owner
require(msg.sender == ethernautsStorage.ownerOf(_shipTokenId));
// check if owner sector is not empty
address sectorOwner = ethernautsStorage.ownerOf(_sectorTokenId);
// check if there is a crew and validating crew member
if (_crewTokenId > 0) {
// crew member should not be in exploration
require(!isExploring(_crewTokenId));
// check if Asset is a crew or not
require(ethernautsStorage.isCategory(_crewTokenId, uint8(AssetCategory.CrewMember)));
// check if crew member is same owner
require(msg.sender == ethernautsStorage.ownerOf(_crewTokenId));
}
/// store exploration data
tokenIndexToExplore[_shipTokenId] = explorers.push(_shipTokenId) - 1;
tokenIndexToSector[_shipTokenId] = _sectorTokenId;
uint8[STATS_SIZE] memory _shipStats = ethernautsStorage.getStats(_shipTokenId);
uint8[STATS_SIZE] memory _sectorStats = ethernautsStorage.getStats(_sectorTokenId);
// check if there is a crew and store data and change ship stats
if (_crewTokenId > 0) {
/// store crew exploration data
exploreIndexToCrew[tokenIndexToExplore[_shipTokenId]] = _crewTokenId;
missions[_crewTokenId]++;
//// 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;
}
if (_shipStats[uint256(ShipStats.Speed)] > STATS_CAPOUT) {
_shipStats[uint256(ShipStats.Speed)] = STATS_CAPOUT;
}
}
/// set exploration time
uint256 time = uint256(_explorationTime(
_shipStats[uint256(ShipStats.Range)],
_shipStats[uint256(ShipStats.Speed)],
_sectorStats[uint256(SectorStats.Size)]
));
// exploration time in minutes converted to seconds
time *= 60;
uint64 _cooldownEndBlock = uint64((time/secondsPerBlock) + block.number);
ethernautsStorage.setAssetCooldown(_shipTokenId, now + time, _cooldownEndBlock);
// check if there is a crew store data and set crew exploration time
if (_crewTokenId > 0) {
/// store crew exploration time
ethernautsStorage.setAssetCooldown(_crewTokenId, now + time, _cooldownEndBlock);
}
// to avoid mistakes and charge unnecessary extra fees
uint256 feeExcess = SafeMath.sub(msg.value, sectorToOwnerCut[_sectorTokenId]);
uint256 payment = uint256(SafeMath.div(SafeMath.mul(msg.value, percentageCut), 100)) - sectorToOracleFee[_sectorTokenId];
/// emit signal to anyone listening in the universe
Explore(_shipTokenId, _sectorTokenId, _crewTokenId, now + time);
// keeping oracle accounts with balance
oracleAddress.transfer(sectorToOracleFee[_sectorTokenId]);
// paying sector owner
sectorOwner.transfer(payment);
// send excess back to explorer
msg.sender.transfer(feeExcess);
}
/// @notice Exploration is complete and at most 10 Objects will return during one exploration.
/// @param _shipTokenId The Token ID that represents a ship and can explore
/// @param _sectorTokenId The Token ID that represents a sector and can be explored
/// @param _IDs that represents a object returned from exploration
/// @param _attributes that represents attributes for each object returned from exploration
/// @param _stats that represents all stats for each object returned from exploration
function explorationResults(
uint256 _shipTokenId,
uint256 _sectorTokenId,
uint16[10] _IDs,
uint8[10] _attributes,
uint8[STATS_SIZE][10] _stats
)
external onlyOracle
{
uint256 cooldown;
uint64 cooldownEndBlock;
uint256 builtBy;
(,,,,,cooldownEndBlock, cooldown, builtBy) = ethernautsStorage.assets(_shipTokenId);
address owner = ethernautsStorage.ownerOf(_shipTokenId);
require(owner != address(0));
/// create objects returned from exploration
uint256 i = 0;
for (i = 0; i < 10 && _IDs[i] > 0; i++) {
_buildAsset(
_sectorTokenId,
owner,
0,
_IDs[i],
uint8(AssetCategory.Object),
uint8(_attributes[i]),
_stats[i],
cooldown,
cooldownEndBlock
);
}
// to guarantee at least 1 result per exploration
require(i > 0);
/// remove from explore list
explorers[tokenIndexToExplore[_shipTokenId]] = 0;
delete tokenIndexToExplore[_shipTokenId];
delete tokenIndexToSector[_shipTokenId];
/// emit signal to anyone listening in the universe
Result(_shipTokenId, _sectorTokenId);
}
/// @notice Cancel ship exploration in case it get stuck
/// @param _shipTokenId The Token ID that represents a ship and can explore
function cancelExplorationByShip(
uint256 _shipTokenId
)
external onlyCLevel
{
uint256 index = tokenIndexToExplore[_shipTokenId];
if (index > 0) {
/// remove from explore list
explorers[index] = 0;
if (exploreIndexToCrew[index] > 0) {
delete exploreIndexToCrew[index];
}
}
delete tokenIndexToExplore[_shipTokenId];
delete tokenIndexToSector[_shipTokenId];
}
/// @notice Cancel exploration in case it get stuck
/// @param _index The exploration position that represents a exploring ship
function cancelExplorationByIndex(
uint256 _index
)
external onlyCLevel
{
uint256 shipId = explorers[_index];
/// remove from exploration list
explorers[_index] = 0;
if (shipId > 0) {
delete tokenIndexToExplore[shipId];
delete tokenIndexToSector[shipId];
}
if (exploreIndexToCrew[_index] > 0) {
delete exploreIndexToCrew[_index];
}
}
/// @notice Add exploration in case contract needs to be add trxs from previous contract
/// @param _shipTokenId The Token ID that represents a ship
/// @param _sectorTokenId The Token ID that represents a sector
/// @param _crewTokenId The Token ID that represents a crew
function addExplorationByShip(
uint256 _shipTokenId, uint256 _sectorTokenId, uint256 _crewTokenId
)
external onlyCLevel whenPaused
{
uint256 index = explorers.push(_shipTokenId) - 1;
/// store exploration data
tokenIndexToExplore[_shipTokenId] = index;
tokenIndexToSector[_shipTokenId] = _sectorTokenId;
// check if there is a crew and store data and change ship stats
if (_crewTokenId > 0) {
/// store crew exploration data
exploreIndexToCrew[index] = _crewTokenId;
missions[_crewTokenId]++;
}
ethernautsStorage.setAssetCooldown(_shipTokenId, now, uint64(block.number));
}
/// @dev Creates a new Asset with the given fields. ONly available for C Levels
/// @param _creatorTokenID The asset who is father of this asset
/// @param _price asset price
/// @param _assetID asset ID
/// @param _category see Asset Struct description
/// @param _attributes see Asset Struct description
/// @param _stats see Asset Struct description
/// @param _cooldown see Asset Struct description
/// @param _cooldownEndBlock see Asset Struct description
function _buildAsset(
uint256 _creatorTokenID,
address _owner,
uint256 _price,
uint16 _assetID,
uint8 _category,
uint8 _attributes,
uint8[STATS_SIZE] _stats,
uint256 _cooldown,
uint64 _cooldownEndBlock
)
private returns (uint256)
{
uint256 tokenID = ethernautsStorage.createAsset(
_creatorTokenID,
_owner,
_price,
_assetID,
_category,
uint8(AssetState.Available),
_attributes,
_stats,
_cooldown,
_cooldownEndBlock
);
// emit the build event
Build(
_owner,
tokenID,
_assetID,
_price
);
return tokenID;
}
/// @notice Exploration Time: The time it takes to explore a Sector is dependent on the Sector Size
/// along with the Ship’s Range and Speed.
/// @param _shipRange ship range
/// @param _shipSpeed ship speed
/// @param _sectorSize sector size
function _explorationTime(
uint8 _shipRange,
uint8 _shipSpeed,
uint8 _sectorSize
) private view returns (int256) {
int256 minToExplore = 0;
minToExplore = SafeMath.min(_shipSpeed, SPEED_STAT_MAX) - 1;
minToExplore = -72 * minToExplore;
minToExplore += MAX_TIME_EXPLORE;
uint256 minRange = uint256(SafeMath.min(_shipRange, RANGE_STAT_MAX));
uint256 scaledRange = uint256(RANGE_STAT_MAX * RANGE_SCALE);
int256 minExplore = (minToExplore - MIN_TIME_EXPLORE);
minToExplore -= fraction(minExplore, int256(minRange), int256(scaledRange));
minToExplore += fraction(minToExplore, int256(_sectorSize) - int256(10), 10);
minToExplore = SafeMath.max(minToExplore, MIN_TIME_EXPLORE);
return minToExplore;
}
/// @notice calcs a perc without float or double :(
function fraction(int256 _subject, int256 _numerator, int256 _denominator)
private pure returns (int256) {
int256 division = _subject * _numerator - _subject * _denominator;
int256 total = _subject * _denominator + division;
return total / _denominator;
}
/// @notice Any C-level can fix how many seconds per blocks are currently observed.
/// @param _secs The seconds per block
function setSecondsPerBlock(uint256 _secs) external onlyCLevel {
require(_secs > 0);
secondsPerBlock = _secs;
}
}
| contract EthernautsExplore is EthernautsLogic {
/// @dev Delegate constructor to Nonfungible contract.
function EthernautsExplore() public
EthernautsLogic() {}
/*** EVENTS ***/
/// emit signal to anyone listening in the universe
event Explore(uint256 shipId, uint256 sectorID, uint256 crewId, uint256 time);
event Result(uint256 shipId, uint256 sectorID);
/*** CONSTANTS ***/
uint8 constant STATS_CAPOUT = 2**8 - 1; // all stats have a range from 0 to 255
// @dev Sanity check that allows us to ensure that we are pointing to the
// right explore contract in our EthernautsCrewMember(address _CExploreAddress) call.
bool public isEthernautsExplore = true;
// An approximation of currently how many seconds are in between blocks.
uint256 public secondsPerBlock = 15;
uint256 public TICK_TIME = 15; // time is always in minutes
// exploration fee
uint256 public percentageCut = 90;
int256 public SPEED_STAT_MAX = 30;
int256 public RANGE_STAT_MAX = 20;
int256 public MIN_TIME_EXPLORE = 60;
int256 public MAX_TIME_EXPLORE = 2160;
int256 public RANGE_SCALE = 2;
/// @dev Sector stats
enum SectorStats {Size, Threat, Difficulty, Slots}
/// @dev hold all ships in exploration
uint256[] explorers;
/// @dev A mapping from Ship token to the exploration index.
mapping (uint256 => uint256) public tokenIndexToExplore;
/// @dev A mapping from Asset UniqueIDs to the sector token id.
mapping (uint256 => uint256) public tokenIndexToSector;
/// @dev A mapping from exploration index to the crew token id.
mapping (uint256 => uint256) public exploreIndexToCrew;
/// @dev A mission counter for crew.
mapping (uint256 => uint16) public missions;
/// @dev A mapping from Owner Cut (wei) to the sector token id.
mapping (uint256 => uint256) public sectorToOwnerCut;
mapping (uint256 => uint256) public sectorToOracleFee;
/// @dev Get a list of ship exploring our universe
function getExplorerList() public view returns(
uint256[3][]
) {
uint256[3][] memory tokens = new uint256[3][](50);
uint256 index = 0;
for(uint256 i = 0; i < explorers.length && index < 50; i++) {
if (explorers[i] > 0) {
tokens[index][0] = explorers[i];
tokens[index][1] = tokenIndexToSector[explorers[i]];
tokens[index][2] = exploreIndexToCrew[i];
index++;
}
}
if (index == 0) {
// Return an empty array
return new uint256[3][](0);
} else {
return tokens;
}
}
/// @dev Get a list of ship exploring our universe
/// @param _shipTokenId The Token ID that represents a ship
function getIndexByShip(uint256 _shipTokenId) public view returns( uint256 ) {
for(uint256 i = 0; i < explorers.length; i++) {
if (explorers[i] == _shipTokenId) {
return i;
}
}
return 0;
}
function setOwnerCut(uint256 _sectorId, uint256 _ownerCut) external onlyCLevel {
sectorToOwnerCut[_sectorId] = _ownerCut;
}
function setOracleFee(uint256 _sectorId, uint256 _oracleFee) external onlyCLevel {
sectorToOracleFee[_sectorId] = _oracleFee;
}
function setTickTime(uint256 _tickTime) external onlyCLevel {
TICK_TIME = _tickTime;
}
function setPercentageCut(uint256 _percentageCut) external onlyCLevel {
percentageCut = _percentageCut;
}
function setMissions(uint256 _tokenId, uint16 _total) public onlyCLevel {
missions[_tokenId] = _total;
}
/// @notice Explore a sector with a defined ship. Sectors contain a list of Objects that can be given to the players
/// when exploring. Each entry has a Drop Rate and are sorted by Sector ID and Drop rate.
/// The drop rate is a whole number between 0 and 1,000,000. 0 is 0% and 1,000,000 is 100%.
/// Every time a Sector is explored a random number between 0 and 1,000,000 is calculated for each available Object.
/// If the final result is lower than the Drop Rate of the Object, that Object will be rewarded to the player once
/// Exploration is complete. Only 1 to 5 Objects maximum can be dropped during one exploration.
/// (FUTURE VERSIONS) The final number will be affected by the user’s Ship Stats.
/// @param _shipTokenId The Token ID that represents a ship
/// @param _sectorTokenId The Token ID that represents a sector
/// @param _crewTokenId The Token ID that represents a crew
function explore(uint256 _shipTokenId, uint256 _sectorTokenId, uint256 _crewTokenId) payable external whenNotPaused {
// charge a fee for each exploration when the results are ready
require(msg.value >= sectorToOwnerCut[_sectorTokenId]);
// check if Asset is a ship or not
require(ethernautsStorage.isCategory(_shipTokenId, uint8(AssetCategory.Ship)));
// check if _sectorTokenId is a sector or not
require(ethernautsStorage.isCategory(_sectorTokenId, uint8(AssetCategory.Sector)));
// Ensure the Ship is in available state, otherwise it cannot explore
require(ethernautsStorage.isState(_shipTokenId, uint8(AssetState.Available)));
// ship could not be in exploration
require(tokenIndexToExplore[_shipTokenId] == 0);
require(!isExploring(_shipTokenId));
// check if explorer is ship owner
require(msg.sender == ethernautsStorage.ownerOf(_shipTokenId));
// check if owner sector is not empty
address sectorOwner = ethernautsStorage.ownerOf(_sectorTokenId);
// check if there is a crew and validating crew member
if (_crewTokenId > 0) {
// crew member should not be in exploration
require(!isExploring(_crewTokenId));
// check if Asset is a crew or not
require(ethernautsStorage.isCategory(_crewTokenId, uint8(AssetCategory.CrewMember)));
// check if crew member is same owner
require(msg.sender == ethernautsStorage.ownerOf(_crewTokenId));
}
/// store exploration data
tokenIndexToExplore[_shipTokenId] = explorers.push(_shipTokenId) - 1;
tokenIndexToSector[_shipTokenId] = _sectorTokenId;
uint8[STATS_SIZE] memory _shipStats = ethernautsStorage.getStats(_shipTokenId);
uint8[STATS_SIZE] memory _sectorStats = ethernautsStorage.getStats(_sectorTokenId);
// check if there is a crew and store data and change ship stats
if (_crewTokenId > 0) {
/// store crew exploration data
exploreIndexToCrew[tokenIndexToExplore[_shipTokenId]] = _crewTokenId;
missions[_crewTokenId]++;
//// 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;
}
if (_shipStats[uint256(ShipStats.Speed)] > STATS_CAPOUT) {
_shipStats[uint256(ShipStats.Speed)] = STATS_CAPOUT;
}
}
/// set exploration time
uint256 time = uint256(_explorationTime(
_shipStats[uint256(ShipStats.Range)],
_shipStats[uint256(ShipStats.Speed)],
_sectorStats[uint256(SectorStats.Size)]
));
// exploration time in minutes converted to seconds
time *= 60;
uint64 _cooldownEndBlock = uint64((time/secondsPerBlock) + block.number);
ethernautsStorage.setAssetCooldown(_shipTokenId, now + time, _cooldownEndBlock);
// check if there is a crew store data and set crew exploration time
if (_crewTokenId > 0) {
/// store crew exploration time
ethernautsStorage.setAssetCooldown(_crewTokenId, now + time, _cooldownEndBlock);
}
// to avoid mistakes and charge unnecessary extra fees
uint256 feeExcess = SafeMath.sub(msg.value, sectorToOwnerCut[_sectorTokenId]);
uint256 payment = uint256(SafeMath.div(SafeMath.mul(msg.value, percentageCut), 100)) - sectorToOracleFee[_sectorTokenId];
/// emit signal to anyone listening in the universe
Explore(_shipTokenId, _sectorTokenId, _crewTokenId, now + time);
// keeping oracle accounts with balance
oracleAddress.transfer(sectorToOracleFee[_sectorTokenId]);
// paying sector owner
sectorOwner.transfer(payment);
// send excess back to explorer
msg.sender.transfer(feeExcess);
}
/// @notice Exploration is complete and at most 10 Objects will return during one exploration.
/// @param _shipTokenId The Token ID that represents a ship and can explore
/// @param _sectorTokenId The Token ID that represents a sector and can be explored
/// @param _IDs that represents a object returned from exploration
/// @param _attributes that represents attributes for each object returned from exploration
/// @param _stats that represents all stats for each object returned from exploration
function explorationResults(
uint256 _shipTokenId,
uint256 _sectorTokenId,
uint16[10] _IDs,
uint8[10] _attributes,
uint8[STATS_SIZE][10] _stats
)
external onlyOracle
{
uint256 cooldown;
uint64 cooldownEndBlock;
uint256 builtBy;
(,,,,,cooldownEndBlock, cooldown, builtBy) = ethernautsStorage.assets(_shipTokenId);
address owner = ethernautsStorage.ownerOf(_shipTokenId);
require(owner != address(0));
/// create objects returned from exploration
uint256 i = 0;
for (i = 0; i < 10 && _IDs[i] > 0; i++) {
_buildAsset(
_sectorTokenId,
owner,
0,
_IDs[i],
uint8(AssetCategory.Object),
uint8(_attributes[i]),
_stats[i],
cooldown,
cooldownEndBlock
);
}
// to guarantee at least 1 result per exploration
require(i > 0);
/// remove from explore list
explorers[tokenIndexToExplore[_shipTokenId]] = 0;
delete tokenIndexToExplore[_shipTokenId];
delete tokenIndexToSector[_shipTokenId];
/// emit signal to anyone listening in the universe
Result(_shipTokenId, _sectorTokenId);
}
/// @notice Cancel ship exploration in case it get stuck
/// @param _shipTokenId The Token ID that represents a ship and can explore
function cancelExplorationByShip(
uint256 _shipTokenId
)
external onlyCLevel
{
uint256 index = tokenIndexToExplore[_shipTokenId];
if (index > 0) {
/// remove from explore list
explorers[index] = 0;
if (exploreIndexToCrew[index] > 0) {
delete exploreIndexToCrew[index];
}
}
delete tokenIndexToExplore[_shipTokenId];
delete tokenIndexToSector[_shipTokenId];
}
/// @notice Cancel exploration in case it get stuck
/// @param _index The exploration position that represents a exploring ship
function cancelExplorationByIndex(
uint256 _index
)
external onlyCLevel
{
uint256 shipId = explorers[_index];
/// remove from exploration list
explorers[_index] = 0;
if (shipId > 0) {
delete tokenIndexToExplore[shipId];
delete tokenIndexToSector[shipId];
}
if (exploreIndexToCrew[_index] > 0) {
delete exploreIndexToCrew[_index];
}
}
/// @notice Add exploration in case contract needs to be add trxs from previous contract
/// @param _shipTokenId The Token ID that represents a ship
/// @param _sectorTokenId The Token ID that represents a sector
/// @param _crewTokenId The Token ID that represents a crew
function addExplorationByShip(
uint256 _shipTokenId, uint256 _sectorTokenId, uint256 _crewTokenId
)
external onlyCLevel whenPaused
{
uint256 index = explorers.push(_shipTokenId) - 1;
/// store exploration data
tokenIndexToExplore[_shipTokenId] = index;
tokenIndexToSector[_shipTokenId] = _sectorTokenId;
// check if there is a crew and store data and change ship stats
if (_crewTokenId > 0) {
/// store crew exploration data
exploreIndexToCrew[index] = _crewTokenId;
missions[_crewTokenId]++;
}
ethernautsStorage.setAssetCooldown(_shipTokenId, now, uint64(block.number));
}
/// @dev Creates a new Asset with the given fields. ONly available for C Levels
/// @param _creatorTokenID The asset who is father of this asset
/// @param _price asset price
/// @param _assetID asset ID
/// @param _category see Asset Struct description
/// @param _attributes see Asset Struct description
/// @param _stats see Asset Struct description
/// @param _cooldown see Asset Struct description
/// @param _cooldownEndBlock see Asset Struct description
function _buildAsset(
uint256 _creatorTokenID,
address _owner,
uint256 _price,
uint16 _assetID,
uint8 _category,
uint8 _attributes,
uint8[STATS_SIZE] _stats,
uint256 _cooldown,
uint64 _cooldownEndBlock
)
private returns (uint256)
{
uint256 tokenID = ethernautsStorage.createAsset(
_creatorTokenID,
_owner,
_price,
_assetID,
_category,
uint8(AssetState.Available),
_attributes,
_stats,
_cooldown,
_cooldownEndBlock
);
// emit the build event
Build(
_owner,
tokenID,
_assetID,
_price
);
return tokenID;
}
/// @notice Exploration Time: The time it takes to explore a Sector is dependent on the Sector Size
/// along with the Ship’s Range and Speed.
/// @param _shipRange ship range
/// @param _shipSpeed ship speed
/// @param _sectorSize sector size
function _explorationTime(
uint8 _shipRange,
uint8 _shipSpeed,
uint8 _sectorSize
) private view returns (int256) {
int256 minToExplore = 0;
minToExplore = SafeMath.min(_shipSpeed, SPEED_STAT_MAX) - 1;
minToExplore = -72 * minToExplore;
minToExplore += MAX_TIME_EXPLORE;
uint256 minRange = uint256(SafeMath.min(_shipRange, RANGE_STAT_MAX));
uint256 scaledRange = uint256(RANGE_STAT_MAX * RANGE_SCALE);
int256 minExplore = (minToExplore - MIN_TIME_EXPLORE);
minToExplore -= fraction(minExplore, int256(minRange), int256(scaledRange));
minToExplore += fraction(minToExplore, int256(_sectorSize) - int256(10), 10);
minToExplore = SafeMath.max(minToExplore, MIN_TIME_EXPLORE);
return minToExplore;
}
/// @notice calcs a perc without float or double :(
function fraction(int256 _subject, int256 _numerator, int256 _denominator)
private pure returns (int256) {
int256 division = _subject * _numerator - _subject * _denominator;
int256 total = _subject * _denominator + division;
return total / _denominator;
}
/// @notice Any C-level can fix how many seconds per blocks are currently observed.
/// @param _secs The seconds per block
function setSecondsPerBlock(uint256 _secs) external onlyCLevel {
require(_secs > 0);
secondsPerBlock = _secs;
}
}
| 33,730 |
98 | // slither-disable-next-line timestamp | if (maxEnd <= start) {
continue;
}
| if (maxEnd <= start) {
continue;
}
| 21,643 |
13 | // Ability to add liquidity to the pool (mints LP tokens) Add liquidity of GNXToken and GNXNative to this trading pool. Users are rewarded in LP which can be exchanged for liquidity and trading accrued fees.Liquidity of both tokens added must be equal. Technically only one param required but having two params for both tokens makes it clear that both are required to add liquidity.ERC20 LP tokens are minted equal to the GNXNative deposit made. Required deposit amount must be calculated in front-end. Equal deposit is enforced by contract to prevent price manipulation.tokenDeposit Quantity of GNXToken deposited.nativeDeposit Quantity of GNXNative deposited. | function addLiquidity(uint256 tokenDeposit, uint256 nativeDeposit) public override(IGNXPool) returns (uint256) {
// Iniital liquidity add
if (tokenReserve() == 0) {
// Pulling GNXToken
token.transferFrom(msg.sender, address(this), tokenDeposit);
// Pulling GNXNative
native.transferFrom(msg.sender, address(this), nativeDeposit);
// Sends LPs in exchange for initial deposit
uint256 _nativeReserve = nativeReserve();
_mint(msg.sender, _nativeReserve);
emit liquidityChange(msg.sender, address(this), _nativeReserve);
return _nativeReserve;
// Normal liquidity add
} else {
uint256 _nativeReserve = nativeReserve() - nativeDeposit;
uint256 _tokenReserve = tokenReserve();
uint256 tokenOutput = (nativeDeposit * _tokenReserve) / _nativeReserve;
require(nativeDeposit >= tokenOutput, "GNX: insufficient token amount"); // Maintains pool price
// Pulls GNXToken
token.transferFrom(msg.sender, address(this), tokenDeposit);
// Pulls GNXNative
native.transferFrom(msg.sender, address(this), nativeDeposit);
// Mints LP tokens
uint256 liquidityTokens = (totalSupply() * nativeDeposit) / _nativeReserve;
_mint(msg.sender, liquidityTokens);
emit liquidityChange(msg.sender, address(this), nativeDeposit);
return liquidityTokens;
}
}
| function addLiquidity(uint256 tokenDeposit, uint256 nativeDeposit) public override(IGNXPool) returns (uint256) {
// Iniital liquidity add
if (tokenReserve() == 0) {
// Pulling GNXToken
token.transferFrom(msg.sender, address(this), tokenDeposit);
// Pulling GNXNative
native.transferFrom(msg.sender, address(this), nativeDeposit);
// Sends LPs in exchange for initial deposit
uint256 _nativeReserve = nativeReserve();
_mint(msg.sender, _nativeReserve);
emit liquidityChange(msg.sender, address(this), _nativeReserve);
return _nativeReserve;
// Normal liquidity add
} else {
uint256 _nativeReserve = nativeReserve() - nativeDeposit;
uint256 _tokenReserve = tokenReserve();
uint256 tokenOutput = (nativeDeposit * _tokenReserve) / _nativeReserve;
require(nativeDeposit >= tokenOutput, "GNX: insufficient token amount"); // Maintains pool price
// Pulls GNXToken
token.transferFrom(msg.sender, address(this), tokenDeposit);
// Pulls GNXNative
native.transferFrom(msg.sender, address(this), nativeDeposit);
// Mints LP tokens
uint256 liquidityTokens = (totalSupply() * nativeDeposit) / _nativeReserve;
_mint(msg.sender, liquidityTokens);
emit liquidityChange(msg.sender, address(this), nativeDeposit);
return liquidityTokens;
}
}
| 7,468 |
2 | // Gas optimization: this is cheaper than asserting 'a' not being zero, but the benefit is lost if 'b' is also tested. |
if (a == 0) {
return 0;
}
|
if (a == 0) {
return 0;
}
| 17,788 |
378 | // NOTE: We don't use SafeMath (or similar) in this function becauseall of our public functions carefully cap the maximum values fortime (at 64-bits) and currency (at 128-bits). _duration isalso known to be non-zero (see the require() statement in_addAuction()) | if (_secondsPassed >= _duration) {
| if (_secondsPassed >= _duration) {
| 25,218 |
2 | // mapping of a staker to its current properties | mapping (address => Staker) public stakers;
| mapping (address => Staker) public stakers;
| 33,203 |
115 | // Allows the admin to set the price for tokens sold during phases 1 and 2 of the sale. | function setTokensPerKEther(uint256 _tokensPerKEther) external onlyAdmin onlyBeforeSale returns (bool) {
require(_tokensPerKEther > 0);
tokensPerKEther = _tokensPerKEther;
TokensPerKEtherUpdated(_tokensPerKEther);
return true;
}
| function setTokensPerKEther(uint256 _tokensPerKEther) external onlyAdmin onlyBeforeSale returns (bool) {
require(_tokensPerKEther > 0);
tokensPerKEther = _tokensPerKEther;
TokensPerKEtherUpdated(_tokensPerKEther);
return true;
}
| 26,529 |
71 | // A getter that searches the delegationChain for the level of/authority a specific delegate has within a Pledge/p The Pledge that will be searched/idDelegate The specified delegate that's searched for/ return If the delegate chain contains the delegate with the/`admins` array index `idDelegate` this returns that delegates/corresponding index in the delegationChain. Otherwise it returns/the NOTFOUND constant | function getDelegateIdx(Pledge p, uint64 idDelegate) internal returns(uint64) {
for (uint i=0; i < p.delegationChain.length; i++) {
if (p.delegationChain[i] == idDelegate) return uint64(i);
}
return NOTFOUND;
}
| function getDelegateIdx(Pledge p, uint64 idDelegate) internal returns(uint64) {
for (uint i=0; i < p.delegationChain.length; i++) {
if (p.delegationChain[i] == idDelegate) return uint64(i);
}
return NOTFOUND;
}
| 47,828 |
37 | // This is an alternative to {approve} that can be used as a mitigation forproblems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - 'spender' cannot be the zero address. / | function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
| function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
| 15,297 |
77 | // Grants tokens to an address, including a portion that will vest over timeaccording to a set vesting schedule. The overall duration and cliff duration of the grant mustbe an even multiple of the vesting interval.beneficiary = Address to which tokens will be granted. vestingAmount = The number of tokens subject to vesting. startDay = Start day of the grant's vesting schedule, in days since the UNIX epoch(start of day). The startDay may be given as a date in the future or in the past, going as farback as year 2000. duration = Duration of the vesting schedule, with respect to | function addGrant(
address beneficiary,
uint256 vestingAmount,
uint32 startDay,
uint32 duration,
uint32 cliffDuration,
uint32 interval,
bool isRevocable
| function addGrant(
address beneficiary,
uint256 vestingAmount,
uint32 startDay,
uint32 duration,
uint32 cliffDuration,
uint32 interval,
bool isRevocable
| 50,423 |
8 | // Finalizes a withdrawal via Outbox message; callable only by L2Gateway.outboundTransfer _token L1 address of token being withdrawn from _from initiator of withdrawal _to address the L2 withdrawal call set as the destination. _amount Token amount being withdrawn _data encoded exitNum (Sequentially increasing exit counter determined by the L2Gateway) and additinal hook data / | function finalizeInboundTransfer(
address _token,
address _from,
address _to,
uint256 _amount,
bytes calldata _data
| function finalizeInboundTransfer(
address _token,
address _from,
address _to,
uint256 _amount,
bytes calldata _data
| 35,874 |
492 | // Ensure the ExchangeRates contract has the feed for sETHBTC; | exchangerates_i.addAggregator("sETHBTC", 0xAc559F25B1619171CbC396a50854A3240b6A4e99);
| exchangerates_i.addAggregator("sETHBTC", 0xAc559F25B1619171CbC396a50854A3240b6A4e99);
| 6,217 |
85 | // deploy a token vesting contract for the founder tokens | uint256 cliff = 6 * 4 weeks; // 4 months
founderTokenVesting = new TokenVesting(
_pathFounderAddress,
now, // start vesting now
cliff, // cliff time
cliff, // 100% unlocked at cliff
false // irrevocable
);
| uint256 cliff = 6 * 4 weeks; // 4 months
founderTokenVesting = new TokenVesting(
_pathFounderAddress,
now, // start vesting now
cliff, // cliff time
cliff, // 100% unlocked at cliff
false // irrevocable
);
| 56,304 |
22 | // Mapping from holder address to their (enumerable) set of owned tokens | mapping (address => EnumerableSet.UintSet) private _holderTokens;
| mapping (address => EnumerableSet.UintSet) private _holderTokens;
| 48,653 |
19 | // Function modifier to require caller to be contract owner / | modifier onlyOwner() {
require(isOwner(msg.sender), "!OWNER");
_;
}
| modifier onlyOwner() {
require(isOwner(msg.sender), "!OWNER");
_;
}
| 41,608 |
10 | // timestamp for when presale would end | uint256 public timeToEndPresale = 1647586800;
modifier onlyWhenNotPaused() {
require(!_paused, "Contract currently paused");
_;
}
| uint256 public timeToEndPresale = 1647586800;
modifier onlyWhenNotPaused() {
require(!_paused, "Contract currently paused");
_;
}
| 66,559 |
77 | // Returns the last node in the list (node with the smallest key)return address for the tail of the list / | function getLast(Data storage self) public view returns (address) {
return self.tail;
}
| function getLast(Data storage self) public view returns (address) {
return self.tail;
}
| 35,149 |
18 | // Update the continuously compounding (risk premium) interest rate for a given debtor, from this block onwards / | function setRiskPremiumInterestRate(address _debtor, uint96 _rate) external override onlyElevatedAccess {
// First checkpoint the base interest & debtor risk premium interest
Debtor storage debtor = debtors[_debtor];
_getDebtorCache(_getBaseCache(), debtor, true);
debtor.rate = _rate;
emit RiskPremiumInterestRateSet(_debtor, _rate);
}
| function setRiskPremiumInterestRate(address _debtor, uint96 _rate) external override onlyElevatedAccess {
// First checkpoint the base interest & debtor risk premium interest
Debtor storage debtor = debtors[_debtor];
_getDebtorCache(_getBaseCache(), debtor, true);
debtor.rate = _rate;
emit RiskPremiumInterestRateSet(_debtor, _rate);
}
| 18,942 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.