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
|
---|---|---|---|---|
3 | // The exchange rate between total shares and BTC+ total supply. Express in WAD. It's equal to the amount of plus token per share. Note: The index will never decrease! | uint256 public index;
address public override governance;
mapping(address => bool) public override strategists;
address public override treasury;
| uint256 public index;
address public override governance;
mapping(address => bool) public override strategists;
address public override treasury;
| 7,621 |
101 | // wealth redistribution | referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus);
| referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus);
| 5,984 |
10 | // Get a reference to the first owner. | address _storedFirstOwner = store.firstOwnerOf(address(this), _tokenId);
| address _storedFirstOwner = store.firstOwnerOf(address(this), _tokenId);
| 11,767 |
78 | // Transfer the DUSK to this contract. | _token.safeTransferFrom(msg.sender, address(this), amount);
| _token.safeTransferFrom(msg.sender, address(this), amount);
| 51,799 |
3 | // 'Candidate({...})' creates a temporary Candidate object and 'candidates.push(...)' appends it to the end of 'candidates'. | candidates.push(Candidate({
name: CandidateNames[i],
voteCount: 0,
votersList: new address[](0)
}));
| candidates.push(Candidate({
name: CandidateNames[i],
voteCount: 0,
votersList: new address[](0)
}));
| 53,313 |
207 | // this view from the aggregator is the most gas efficient but it can throw when there's no data, so let's call it low-level to suppress any reverts | bytes memory payload = abi.encodeWithSignature("latestRoundData()");
| bytes memory payload = abi.encodeWithSignature("latestRoundData()");
| 75,852 |
155 | // Event emitted when controller is changed / | event NewController(KineControllerInterface oldController, KineControllerInterface newController);
| event NewController(KineControllerInterface oldController, KineControllerInterface newController);
| 70,457 |
4 | // The Balancer pool data Note we change style to match Balancer's custom getter | IVault private immutable _vault;
bytes32 private immutable _poolId;
| IVault private immutable _vault;
bytes32 private immutable _poolId;
| 23,485 |
24 | // Implements a security model with owner and ops. | contract OpsManaged is Owned() {
address public opsAddress;
event OpsAddressUpdated(address indexed _newAddress);
constructor() public
{
}
modifier onlyOwnerOrOps() {
require(isOwnerOrOps(msg.sender));
_;
}
function isOps(address _address) public view returns (bool) {
return (opsAddress != address(0) && _address == opsAddress);
}
function isOwnerOrOps(address _address) public view returns (bool) {
return (isOwner(_address) || isOps(_address));
}
function setOpsAddress(address _newOpsAddress) public onlyOwner returns (bool) {
require(_newOpsAddress != owner);
require(_newOpsAddress != address(this));
opsAddress = _newOpsAddress;
emit OpsAddressUpdated(opsAddress);
return true;
}
}
| contract OpsManaged is Owned() {
address public opsAddress;
event OpsAddressUpdated(address indexed _newAddress);
constructor() public
{
}
modifier onlyOwnerOrOps() {
require(isOwnerOrOps(msg.sender));
_;
}
function isOps(address _address) public view returns (bool) {
return (opsAddress != address(0) && _address == opsAddress);
}
function isOwnerOrOps(address _address) public view returns (bool) {
return (isOwner(_address) || isOps(_address));
}
function setOpsAddress(address _newOpsAddress) public onlyOwner returns (bool) {
require(_newOpsAddress != owner);
require(_newOpsAddress != address(this));
opsAddress = _newOpsAddress;
emit OpsAddressUpdated(opsAddress);
return true;
}
}
| 37,271 |
8 | // logs a new price after each change/_price token price, wei/aqo | event Price(uint256 _price);
| event Price(uint256 _price);
| 29,539 |
89 | // Collect the protocol fee accrued to the pool/recipient The address to which collected protocol fees should be sent/amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1/amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0/ return amount0 The protocol fee collected in token0/ return amount1 The protocol fee collected in token1 | function collectProtocol(
address recipient,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
| function collectProtocol(
address recipient,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
| 27,073 |
12 | // Implements the basic logic to burn a scaled balance token. In some instances, a burn transaction will emit a mint eventif the amount to burn is less than the interest that the user accrued user The user which debt is burnt target The address that will receive the underlying, if any amount The amount getting burned index The variable debt index of the reserve / | ) internal virtual {
uint256 amountScaled = amount.rayDiv(index);
require(amountScaled != 0, Errors.INVALID_BURN_AMOUNT);
uint256 scaledBalance = super.balanceOf(user);
uint256 balanceIncrease = scaledBalance.rayMul(index) -
scaledBalance.rayMul(_userState[user].additionalData);
_userState[user].additionalData = index.toUint128();
_burn(user, amountScaled.toUint128());
if (balanceIncrease > amount) {
uint256 amountToMint = balanceIncrease - amount;
emit Transfer(address(0), user, amountToMint);
emit Mint(user, user, amountToMint, balanceIncrease, index);
} else {
uint256 amountToBurn = amount - balanceIncrease;
emit Transfer(user, address(0), amountToBurn);
emit Burn(user, target, amountToBurn, balanceIncrease, index);
}
}
| ) internal virtual {
uint256 amountScaled = amount.rayDiv(index);
require(amountScaled != 0, Errors.INVALID_BURN_AMOUNT);
uint256 scaledBalance = super.balanceOf(user);
uint256 balanceIncrease = scaledBalance.rayMul(index) -
scaledBalance.rayMul(_userState[user].additionalData);
_userState[user].additionalData = index.toUint128();
_burn(user, amountScaled.toUint128());
if (balanceIncrease > amount) {
uint256 amountToMint = balanceIncrease - amount;
emit Transfer(address(0), user, amountToMint);
emit Mint(user, user, amountToMint, balanceIncrease, index);
} else {
uint256 amountToBurn = amount - balanceIncrease;
emit Transfer(user, address(0), amountToBurn);
emit Burn(user, target, amountToBurn, balanceIncrease, index);
}
}
| 23,998 |
58 | // @inheritdoc ERC4626Upgradeable | function totalAssets() public view override returns (uint256) {
return super.lendingAssets() - _lockedProfit();
}
| function totalAssets() public view override returns (uint256) {
return super.lendingAssets() - _lockedProfit();
}
| 15,206 |
470 | // Add asset to be included in account liquidity calculation cToken The address of the cToken market to be enabledreturn Success indicator for whether each corresponding market was entered / | function enterMarket(address cToken, address borrower) external returns (uint) {
require(msg.sender == cToken, "sender must be cToken");
return uint(addToMarketInternal(CToken(cToken), borrower));
}
| function enterMarket(address cToken, address borrower) external returns (uint) {
require(msg.sender == cToken, "sender must be cToken");
return uint(addToMarketInternal(CToken(cToken), borrower));
}
| 31,035 |
14 | // Set the metadata for a subgraph represented by `_tokenId`. `_tokenId` must exist. _tokenId ID of the NFT _subgraphMetadata IPFS hash for the metadata / | function setSubgraphMetadata(uint256 _tokenId, bytes32 _subgraphMetadata)
external
override
onlyMinter
| function setSubgraphMetadata(uint256 _tokenId, bytes32 _subgraphMetadata)
external
override
onlyMinter
| 31,074 |
120 | // ============ Create Bid ============ |
function createBid(bytes32 auctionId, uint256 amount)
external
payable
nonReentrant
whenNotPaused
auctionExists(auctionId)
auctionNotExpired(auctionId)
|
function createBid(bytes32 auctionId, uint256 amount)
external
payable
nonReentrant
whenNotPaused
auctionExists(auctionId)
auctionNotExpired(auctionId)
| 27,761 |
8 | // Allows the company to tokenize shares and transfer them e.g to the draggable contract and wrap them.If these shares are newly created, setTotalShares must be called first in order to adjust the total number of shares. / | function mintAndCall(address shareholder, address callee, uint256 amount, bytes calldata data) external {
mint(callee, amount);
require(IERC677Receiver(callee).onTokenTransfer(shareholder, amount, data));
}
| function mintAndCall(address shareholder, address callee, uint256 amount, bytes calldata data) external {
mint(callee, amount);
require(IERC677Receiver(callee).onTokenTransfer(shareholder, amount, data));
}
| 18,489 |
193 | // Search for the next available not minted token id | while (legendaryPositions[newTokenId-1]){
if (newTokenId >= legendaryAmount) {
newTokenId = 1;
} else {
| while (legendaryPositions[newTokenId-1]){
if (newTokenId >= legendaryAmount) {
newTokenId = 1;
} else {
| 33,344 |
0 | // Used to verify pending requests by transactee sending deposit to this contract | function () payable {
uint32 value = uint32(msg.value);
if (!_requestExists(msg.sender, value)) {
throw;
}
| function () payable {
uint32 value = uint32(msg.value);
if (!_requestExists(msg.sender, value)) {
throw;
}
| 10,321 |
3 | // Configuration. | string private baseURI;
uint256 public mintPrice = 0.04 ether;
uint256 public saleTime = 0;
bool private reservedNoundles = false;
uint256 public reserveMinted = 0;
bool public saleEnabled = false;
| string private baseURI;
uint256 public mintPrice = 0.04 ether;
uint256 public saleTime = 0;
bool private reservedNoundles = false;
uint256 public reserveMinted = 0;
bool public saleEnabled = false;
| 22,945 |
24 | // Override for extensions that require an internal state to check for validity (current user contributions,etc.) beneficiary Address receiving the tokens usdtAmount Value in wei involved in the purchase / | function _updatePurchasingState(address beneficiary, uint256 usdtAmount)
internal
| function _updatePurchasingState(address beneficiary, uint256 usdtAmount)
internal
| 17,863 |
33 | // TOTAL ALLOWED LEVERAGED POSITION | uint256 size = position.size;
uint256 collateralMasterWDecimals = _convertToTokenDecimals(position.collateral, position.price, tokenDecimals);
if(totalBalanceOfCollateralUSD > position.collateral){
| uint256 size = position.size;
uint256 collateralMasterWDecimals = _convertToTokenDecimals(position.collateral, position.price, tokenDecimals);
if(totalBalanceOfCollateralUSD > position.collateral){
| 43,916 |
41 | // MUST be valid photo pool ID | require(isValidPhotoId(_photoPoolId));
| require(isValidPhotoId(_photoPoolId));
| 39,842 |
149 | // Transfer Ether to receiving stealth address | _receiver.transfer(amount);
| _receiver.transfer(amount);
| 16,451 |
40 | // 安全关闭位置 close a given position ledgerType: ledger type epoch: epoch of the ledger positionIndex: position index of the user positionInfo: storage of the position info roundInfo: storage of the round info / | function _safeClosePosition(
uint256 ledgerType,
uint256 epoch,
uint256 positionIndex,
PositionInfo storage positionInfo,
RoundInfo storage roundInfo,
UserGlobalInfo storage userGlobalInfo
| function _safeClosePosition(
uint256 ledgerType,
uint256 epoch,
uint256 positionIndex,
PositionInfo storage positionInfo,
RoundInfo storage roundInfo,
UserGlobalInfo storage userGlobalInfo
| 9,319 |
18 | // WARNING: if you transfer to a contract that cannot handle incoming tokens you may lose them | balances[msg.sender] = sub(balanceOf(msg.sender), _value);
balances[_to] = add(balances[_to], _value);
Transfer(msg.sender, _to, _value);
| balances[msg.sender] = sub(balanceOf(msg.sender), _value);
balances[_to] = add(balances[_to], _value);
Transfer(msg.sender, _to, _value);
| 49,326 |
16 | // See '_setTickers()' in {OracleHouse}. restricted to admin only. / | function setTickers(
string memory _tickerUsdFiat,
string memory _tickerReserveAsset
) external override onlyRole(DEFAULT_ADMIN_ROLE) {
_setTickers(_tickerUsdFiat, _tickerReserveAsset);
}
| function setTickers(
string memory _tickerUsdFiat,
string memory _tickerReserveAsset
) external override onlyRole(DEFAULT_ADMIN_ROLE) {
_setTickers(_tickerUsdFiat, _tickerReserveAsset);
}
| 52,194 |
51 | // Tokens to bounty owner can be sent only after ICO | bool public sentTokensToBountyOwner = false;
uint public etherRaised = 0;
| bool public sentTokensToBountyOwner = false;
uint public etherRaised = 0;
| 4,742 |
11 | // ============================================================================== __ _|__|_ __ _.(_|(/_ || (/_| _\. (for UI & viewing things on etherscan)=====_|======================================================================= | function checkIfNameValid(string _nameStr)
public
view
returns(bool)
| function checkIfNameValid(string _nameStr)
public
view
returns(bool)
| 25,221 |
28 | // only owner view | function _onlyOwner() private view {
require(msg.sender == _owner, "Only the contract owner may perform this action");
}
| function _onlyOwner() private view {
require(msg.sender == _owner, "Only the contract owner may perform this action");
}
| 1,305 |
15 | // This is a virtual function that should be overridden so it returns the address to which the fallback function | * and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
| * and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
| 29,333 |
55 | // treasuryAmount += treasuryAmt; |
emit RewardsCalculated(
epoch,
rewardBaseCalAmount,
rewardAmount,
treasuryAmt
);
|
emit RewardsCalculated(
epoch,
rewardBaseCalAmount,
rewardAmount,
treasuryAmt
);
| 19,478 |
6 | // Returns true if blockchain of passed id is registered to swapblockchain number of blockchain/ | function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
| function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
| 46,045 |
45 | // address where funds are collected | address public wallet;
| address public wallet;
| 11,441 |
1 | // check caller balance ~~ | (, bytes memory data) = meow.staticcall(abi.encodeWithSelector(0x70a08231, msg.sender));
uint256 amount = abi.decode(data, (uint256));
require(amount >= 1_000_000 ether, "meow too quiet");
| (, bytes memory data) = meow.staticcall(abi.encodeWithSelector(0x70a08231, msg.sender));
uint256 amount = abi.decode(data, (uint256));
require(amount >= 1_000_000 ether, "meow too quiet");
| 31,402 |
405 | // Iterate over the number of spins and calculate totals:- player win amount- bankroll win amount- jackpot wins | (winAmount, lossAmount, jackpotAmount, jackpotWins) = getSpinResults(playerBet.blockNumber, playerBet.numSpins, playerBet.tokenValue.mul(1e14), _playerAddress);
| (winAmount, lossAmount, jackpotAmount, jackpotWins) = getSpinResults(playerBet.blockNumber, playerBet.numSpins, playerBet.tokenValue.mul(1e14), _playerAddress);
| 24,509 |
485 | // Apply the multiplier | fee = (fee * mint_fee_multiplier) / 1e6;
| fee = (fee * mint_fee_multiplier) / 1e6;
| 73,578 |
1 | // Price offered at the minimum amount. / | uint public price;
| uint public price;
| 30,274 |
1 | // Keeps track of the number of items sold on the marketplace | Counters.Counter private _itemsSold;
| Counters.Counter private _itemsSold;
| 7,349 |
58 | // Mint MDT tokens. (internal use only)_to address Address to send minted MDT to._amount uint256 Amount of MDT tokens to mint./ | function mint(address _to, uint256 _amount)
private
validRecipient(_to)
returns (bool)
| function mint(address _to, uint256 _amount)
private
validRecipient(_to)
returns (bool)
| 8,647 |
26 | // Get the specified trader's settlement value, including pending fee, funding payment,/ owed realized PnL and unrealized PnL/Note the difference between `settlementTokenBalanceX10_S`, `getSettlementTokenValue()` and `getBalance()`:/They are all settlement token balances but with or without/pending fee, funding payment, owed realized PnL, unrealized PnL, respectively/In practical applications, we use `getSettlementTokenValue()` to get the trader's debt (if < 0)/trader The address of the trader/ return balance The balance amount (in settlement token's decimals) | function getSettlementTokenValue(address trader) external view returns (int256 balance);
| function getSettlementTokenValue(address trader) external view returns (int256 balance);
| 10,895 |
0 | // Use Horner's method to compute f(x). The idea is that a_0 + a_1x + a_2x^2 + ... + a_nx^n = (...(((a_nx) + a_{n-1})x + a_{n-2})x + ...) + a_0. Consequently we need to do deg(f) horner iterations that consist of: 1. Multiply the last result by x 2. Add the next coefficient (starting from the highest coefficient)We slightly diverge from the algorithm above by updating the result only onceevery 7 horner iterations.We do this because variable assignment in solidity's functional-style assembly results ina swap followed by a pop.7 is the highest batch we can do due to the 16 slots | result :=
add(0x549a83d43c90aaf1a28c445c81abc883cb61e4353a84ea0fcb15ccee6d6482f, mulmod(
add(0x6f753527f0dec9b713d52f08e4556a3963a2f7e5e282b2e97ffde3e12569b76, mulmod(
add(0x233eff8cfcc744de79d412f724898d13c0e53b1132046ee45db7a101242a73f, mulmod(
add(0x60105b3cb5aab151ce615173eaecbe94014ff5d72e884addcd4b9d973fed9fd, mulmod(
add(0x295046a010dd6757176414b0fd144c1d2517fc463df01a12c0ab58bbbac26ea, mulmod(
add(0x4cec4cd52fab6da76b4ab7a41ffd844aad8981917d2295273ff6ab2cce622d8, mulmod(
add(0x43869b387c2d0eab20661ebdfaca58b4b23feac014e1e1d9413164312e77da, mulmod(
result,
x, PRIME)),
| result :=
add(0x549a83d43c90aaf1a28c445c81abc883cb61e4353a84ea0fcb15ccee6d6482f, mulmod(
add(0x6f753527f0dec9b713d52f08e4556a3963a2f7e5e282b2e97ffde3e12569b76, mulmod(
add(0x233eff8cfcc744de79d412f724898d13c0e53b1132046ee45db7a101242a73f, mulmod(
add(0x60105b3cb5aab151ce615173eaecbe94014ff5d72e884addcd4b9d973fed9fd, mulmod(
add(0x295046a010dd6757176414b0fd144c1d2517fc463df01a12c0ab58bbbac26ea, mulmod(
add(0x4cec4cd52fab6da76b4ab7a41ffd844aad8981917d2295273ff6ab2cce622d8, mulmod(
add(0x43869b387c2d0eab20661ebdfaca58b4b23feac014e1e1d9413164312e77da, mulmod(
result,
x, PRIME)),
| 26,897 |
119 | // sending plaftrom fee to the super manager | require(betDeEx.collectPlatformFee(_platformFee), "platform fee should be collected");
betDeEx.emitEndEvent(endedBy, _choice, _platformFee);
| require(betDeEx.collectPlatformFee(_platformFee), "platform fee should be collected");
betDeEx.emitEndEvent(endedBy, _choice, _platformFee);
| 17,788 |
0 | // Interface for required functionality in the ERC721 standardfor non-fungible tokens. Author: Nadav Hollander (nadav at dharma.io) / | contract ERC721 {
// Function
function totalSupply() public view returns (uint256 _totalSupply);
function balanceOf(address _owner) public view returns (uint256 _balance);
function ownerOf(uint _tokenId) public view returns (address _owner);
function approve(address _to, uint _tokenId) public;
function transferFrom(address _from, address _to, uint _tokenId) public;
function transfer(address _to, uint _tokenId) public;
function implementsERC721() public view returns (bool _implementsERC721);
// Events
event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
}
| contract ERC721 {
// Function
function totalSupply() public view returns (uint256 _totalSupply);
function balanceOf(address _owner) public view returns (uint256 _balance);
function ownerOf(uint _tokenId) public view returns (address _owner);
function approve(address _to, uint _tokenId) public;
function transferFrom(address _from, address _to, uint _tokenId) public;
function transfer(address _to, uint _tokenId) public;
function implementsERC721() public view returns (bool _implementsERC721);
// Events
event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
}
| 12,941 |
65 | // 获取期权信息/tokenAddress 目标代币地址,0表示eth/strikePrice 用户设置的行权价格,结算时系统会根据标的物当前价与行权价比较,计算用户盈亏/orientation 看涨/看跌两个方向。true:看涨,false:看跌/exerciseBlock 到达该日期后用户手动进行行权,日期在系统中使用区块号进行记录/ return 期权信息 | function getOptionInfo(
address tokenAddress,
uint strikePrice,
bool orientation,
uint exerciseBlock
) external view returns (OptionView memory);
| function getOptionInfo(
address tokenAddress,
uint strikePrice,
bool orientation,
uint exerciseBlock
) external view returns (OptionView memory);
| 66,286 |
22 | // Calculate the DOMAIN_SEPARATOR | function _calculateDomainSeparator(uint256 chainId) private view returns (bytes32) {
return keccak256(
abi.encode(
DOMAIN_SEPARATOR_SIGNATURE_HASH,
chainId,
address(this)
)
);
}
| function _calculateDomainSeparator(uint256 chainId) private view returns (bytes32) {
return keccak256(
abi.encode(
DOMAIN_SEPARATOR_SIGNATURE_HASH,
chainId,
address(this)
)
);
}
| 39,095 |
126 | // Mint and burn star | mapping(address => bool) public minters;
| mapping(address => bool) public minters;
| 15,668 |
60 | // Generate flight key | bytes32 key = getFlightKey(airline, flightID, timestamp);
| bytes32 key = getFlightKey(airline, flightID, timestamp);
| 55,596 |
14 | // Boolean variable that contains whether all installments for the pool were made or not. | mapping (uint8 => bool) public installmentsEnded;
| mapping (uint8 => bool) public installmentsEnded;
| 36,797 |
187 | // Writes an oracle observation to the array/Writable at most once per block. Index represents the most recently written element. cardinality and index must be tracked externally./ If the index is at the end of the allowable array length (according to cardinality), and the next cardinality/ is greater than the current one, cardinality may be increased. This restriction is created to preserve ordering./self The stored oracle array/index The index of the observation that was most recently written to the observations array/blockTimestamp The timestamp of the new observation/tick The active tick at the time of the new observation/liquidity The total in-range liquidity | function write(
Observation[65535] storage self,
uint16 index,
uint32 blockTimestamp,
int24 tick,
uint128 liquidity,
uint16 cardinality,
uint16 cardinalityNext
| function write(
Observation[65535] storage self,
uint16 index,
uint32 blockTimestamp,
int24 tick,
uint128 liquidity,
uint16 cardinality,
uint16 cardinalityNext
| 76,274 |
364 | // Admin call to delegate the votes of the COMP-like underlying compLikeDelegatee The address to delegate votes to / | function _delegateCompLikeTo(address compLikeDelegatee) external {
require(msg.sender == admin, "only the admin may set the comp-like delegate");
CompLike(underlying).delegate(compLikeDelegatee);
}
| function _delegateCompLikeTo(address compLikeDelegatee) external {
require(msg.sender == admin, "only the admin may set the comp-like delegate");
CompLike(underlying).delegate(compLikeDelegatee);
}
| 37,504 |
1 | // public function to convert uint256 to string num uint256 integer to convertreturn string string convert from given uint256 / | function uint2str(uint256 num) public pure returns (string memory _uintAsString) {
if (num == 0) {
return "0";
}
uint256 j = num;
uint256 len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint256 k = len - 1;
while (num != 0) {
bstr[k--] = bytes1(uint8(48 + (num % 10)));
num /= 10;
}
return string(bstr);
}
| function uint2str(uint256 num) public pure returns (string memory _uintAsString) {
if (num == 0) {
return "0";
}
uint256 j = num;
uint256 len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint256 k = len - 1;
while (num != 0) {
bstr[k--] = bytes1(uint8(48 + (num % 10)));
num /= 10;
}
return string(bstr);
}
| 30,200 |
162 | // Set a token sunset timestamp. / | function setTokenSunsetTimestamp(uint256 _timestamp) external;
| function setTokenSunsetTimestamp(uint256 _timestamp) external;
| 46,628 |
21 | // Internal utility function that combines`_origin` and `_nonce`. Both origin and nonce should be less than 2^32 - 1 _origin Domain of chain where the transfer originated _nonce The unique identifier for the message from origin to destinationreturn Returns (`_origin` << 32) & `_nonce` / | function _originAndNonce(uint32 _origin, uint32 _nonce) internal pure returns (uint64) {
return (uint64(_origin) << 32) | _nonce;
}
| function _originAndNonce(uint32 _origin, uint32 _nonce) internal pure returns (uint64) {
return (uint64(_origin) << 32) | _nonce;
}
| 29,978 |
10 | // Move the last value to the index where the value to delete is | set._values[toDeleteIndex] = lastvalue;
| set._values[toDeleteIndex] = lastvalue;
| 14,730 |
41 | // Maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault,/ through a withdraw call./ - return the maximum amount of assets that could be transferred from owner through withdraw/ and not cause a revert, which MUST NOT be higher than the actual maximum/ that would be accepted (it should underestimate if necessary)./ - factor in both global and user-specific limits,/ like if withdrawals are entirely disabled (even temporarily) it MUST return 0. | function maxWithdraw(address owner) public view virtual returns (uint256) {
return convertToAssets(balanceOf(owner));
}
| function maxWithdraw(address owner) public view virtual returns (uint256) {
return convertToAssets(balanceOf(owner));
}
| 10,464 |
73 | // Whitelist Spotter to read the Osm data (only necessary if it is the first time the token is being added to an ilk) !!!!!!!! Only if PIP_UNIV2WBTCETH = Osm or PIP_UNIV2WBTCETH = Median and hasn't been already whitelisted due a previous deployed ilk | LPOsmAbstract(PIP_UNIV2WBTCETH).kiss(MCD_SPOT);
| LPOsmAbstract(PIP_UNIV2WBTCETH).kiss(MCD_SPOT);
| 20,510 |
31 | // Property Token | contract PropToken is ERC20, Owned {
using SafeMath for uint256;
uint256 internal _cap;
address private _mintContract;
address private _burnContract;
address internal _propertyRegistry;
bool private _canMint;
modifier onlySystemAdmin {
require(PropTokenHelpers(getDataAddress()).hasSystemAdminRights(msg.sender), "PropToken: You need to have system admin rights!");
_;
}
modifier onlyPropManager {
require(PropTokenHelpers(getDataAddress()).isCPAdminOfProperty(msg.sender, address(this)) || msg.sender == PropTokenHelpers(getDataAddress()).getCPOfProperty(address(this)),
"PropToken: you don't have permission!");
_;
}
constructor(string memory name, string memory symbol) internal ERC20(name, symbol) {
}
function changeLI(address newOwner) public onlySystemAdmin {
_owner = newOwner;
}
/**
* @dev Sends `amount` of token from caller address to `recipient`
* @param recipient Address where we are sending to
* @param amount Amount of tokens to send
* @return bool Returns true if transfer was successful
*/
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transferWithFee(msg.sender, recipient, amount);
return true;
}
/**
* @dev Sends `amount` of token from `sender` to `recipient`
* @param sender Address from which we send
* @param recipient Address where we are sending to
* @param amount Amount of tokens to send
* @return bool Returns true if transfer was successful
*/
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_approve(sender, msg.sender, allowance(sender, msg.sender).sub(amount, "ERC20: transfer amount exceeds allowance"));
_transferWithFee(sender, recipient, amount);
return true;
}
/// @notice mint tokens for given wallets
/// @param accounts Array of wallets
/// @param amounts Amount of tokens to mint to each wallet
function mint(address[] memory accounts, uint256[] memory amounts) public returns (bool) {
require(_canMint, "PropToken: Minting is not enabled!");
require(PropTokenHelpers(getDataAddress()).isCPAdminOfProperty(msg.sender, address(this)) || _mintContract == msg.sender, "PropToken: you don't have permission to mint");
require(accounts.length == amounts.length, "PropToken: Arrays must be of same length!");
for (uint256 i = 0; i < accounts.length; i++) {
require(totalSupply().add(amounts[i]) <= _cap, "PropToken: cap exceeded");
require(PropTokenHelpers(getDataAddress()).canTransferPropTokensTo(accounts[i], address(this)), "PropToken: Wallet is not whitelisted");
_mint(accounts[i], amounts[i]);
}
return true;
}
/// @notice burn and mint at he same time
/// @param from Address from which we burn
/// @param to Address to which we mint
/// @param amount Amount of tokens to burn and mint
function burnAndMint(address from, address to, uint256 amount) public onlySystemAdmin returns (bool) {
_burn(from, amount);
_mint(to, amount);
return true;
}
function contractBurn(address user, uint256 amount) public returns (bool) {
require(msg.sender == _burnContract, "PropToken: Only burn contract can burn tokens from users!");
_burn(user, amount);
return true;
}
/// @notice You need permission to call this function
function freezeToken() public onlyPropManager {
PropTokenHelpers(getDataAddress()).freezeProperty(address(this));
}
/// @notice You need permission to call this function
function unfreezeToken() public onlyPropManager {
PropTokenHelpers(getDataAddress()).unfreezeProperty(address(this));
}
/// @notice set contract that is allowed to mint
/// @param mintContract Address of contract that is allowed to mint
function setMintContract(address mintContract) public onlyPropManager {
require(PropTokenHelpers(getDataAddress()).isContractWhitelisted(mintContract), "PropToken: Contract is not whitelisted");
_mintContract = mintContract;
}
/// @notice set contract that is allowed to burn
/// @param burnContract Address of contract that is allowed to burn
function setBurnContract(address burnContract) public onlyPropManager {
require(PropTokenHelpers(getDataAddress()).isContractWhitelisted(burnContract), "PropToken: Contract is not whitelisted");
_burnContract = burnContract;
}
/// @notice set this contract into minting mode
function allowMint() public {
require(PropTokenHelpers(getDataAddress()).isCPAdminOfProperty(msg.sender, address(this)), "PropToken: Only CP admin!");
_canMint = true;
}
function _transferWithFee(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "PropToken: transfer from the zero address");
require(recipient != address(0), "PropToken: transfer to the zero address");
require(!PropTokenHelpers(getDataAddress()).isPropTokenFrozen(address(this)), "PropToken: Transactions are frozen");
address blocksquare = PropTokenHelpers(getDataAddress()).getBlocksquareAddress();
address cp = PropTokenHelpers(getDataAddress()).getCPOfProperty(address(this));
if (PropTokenHelpers(getDataAddress()).hasSystemAdminRights(sender) || recipient == getOceanPointContract() || recipient == _burnContract) {
_transfer(sender, recipient, amount);
}
else if (recipient == blocksquare || recipient == cp || recipient == owner()) {
_transfer(sender, recipient, amount);
}
else {
require(PropTokenHelpers(getDataAddress()).canTransferPropTokensTo(recipient, address(this)), "PropToken: Can't send tokens to!");
if (sender == blocksquare || sender == cp || sender == owner()) {
_transfer(sender, recipient, amount);
}
else {
_fee(sender, recipient, amount, blocksquare, cp);
}
}
}
function _fee(address sender, address recipient, uint256 amount, address blocksquare, address cp) private {
uint256 blocksquareFee = (amount.mul(PropTokenHelpers(getDataAddress()).getBlocksquareFee())).div(1000);
uint256 liFee = (amount.mul(PropTokenHelpers(getDataAddress()).getLicencedIssuerFee())).div(1000);
uint256 cpFee = (amount.mul(PropTokenHelpers(getDataAddress()).getCertifiedPartnerFee())).div(1000);
uint256 together = blocksquareFee.add(liFee).add(cpFee);
_transfer(sender, blocksquare, blocksquareFee);
_transfer(sender, cp, cpFee);
_transfer(sender, owner(), liFee);
_transfer(sender, recipient, amount.sub(together));
}
function getDataAddress() internal view returns (address) {
return PropTokenHelpers(_propertyRegistry).getDataProxy();
}
/// @notice gets maximum number of tokens that can be created
function cap() public view returns (uint256) {
return _cap;
}
/// @notice check if this property can be minted
function canBeMinted() public view returns (bool) {
return _canMint;
}
/// @notice retrieves address of contract that is allowed to mint
function getMintContract() public view returns (address) {
return _mintContract;
}
/// @notice retrieves address of contract that is allowed to burn
function getBurnContract() public view returns (address) {
return _burnContract;
}
/// @notice retrieves ocean point contract address
function getOceanPointContract() public view returns (address) {
return PropTokenHelpers(getDataAddress()).getOceanPointContract();
}
}
| contract PropToken is ERC20, Owned {
using SafeMath for uint256;
uint256 internal _cap;
address private _mintContract;
address private _burnContract;
address internal _propertyRegistry;
bool private _canMint;
modifier onlySystemAdmin {
require(PropTokenHelpers(getDataAddress()).hasSystemAdminRights(msg.sender), "PropToken: You need to have system admin rights!");
_;
}
modifier onlyPropManager {
require(PropTokenHelpers(getDataAddress()).isCPAdminOfProperty(msg.sender, address(this)) || msg.sender == PropTokenHelpers(getDataAddress()).getCPOfProperty(address(this)),
"PropToken: you don't have permission!");
_;
}
constructor(string memory name, string memory symbol) internal ERC20(name, symbol) {
}
function changeLI(address newOwner) public onlySystemAdmin {
_owner = newOwner;
}
/**
* @dev Sends `amount` of token from caller address to `recipient`
* @param recipient Address where we are sending to
* @param amount Amount of tokens to send
* @return bool Returns true if transfer was successful
*/
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transferWithFee(msg.sender, recipient, amount);
return true;
}
/**
* @dev Sends `amount` of token from `sender` to `recipient`
* @param sender Address from which we send
* @param recipient Address where we are sending to
* @param amount Amount of tokens to send
* @return bool Returns true if transfer was successful
*/
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_approve(sender, msg.sender, allowance(sender, msg.sender).sub(amount, "ERC20: transfer amount exceeds allowance"));
_transferWithFee(sender, recipient, amount);
return true;
}
/// @notice mint tokens for given wallets
/// @param accounts Array of wallets
/// @param amounts Amount of tokens to mint to each wallet
function mint(address[] memory accounts, uint256[] memory amounts) public returns (bool) {
require(_canMint, "PropToken: Minting is not enabled!");
require(PropTokenHelpers(getDataAddress()).isCPAdminOfProperty(msg.sender, address(this)) || _mintContract == msg.sender, "PropToken: you don't have permission to mint");
require(accounts.length == amounts.length, "PropToken: Arrays must be of same length!");
for (uint256 i = 0; i < accounts.length; i++) {
require(totalSupply().add(amounts[i]) <= _cap, "PropToken: cap exceeded");
require(PropTokenHelpers(getDataAddress()).canTransferPropTokensTo(accounts[i], address(this)), "PropToken: Wallet is not whitelisted");
_mint(accounts[i], amounts[i]);
}
return true;
}
/// @notice burn and mint at he same time
/// @param from Address from which we burn
/// @param to Address to which we mint
/// @param amount Amount of tokens to burn and mint
function burnAndMint(address from, address to, uint256 amount) public onlySystemAdmin returns (bool) {
_burn(from, amount);
_mint(to, amount);
return true;
}
function contractBurn(address user, uint256 amount) public returns (bool) {
require(msg.sender == _burnContract, "PropToken: Only burn contract can burn tokens from users!");
_burn(user, amount);
return true;
}
/// @notice You need permission to call this function
function freezeToken() public onlyPropManager {
PropTokenHelpers(getDataAddress()).freezeProperty(address(this));
}
/// @notice You need permission to call this function
function unfreezeToken() public onlyPropManager {
PropTokenHelpers(getDataAddress()).unfreezeProperty(address(this));
}
/// @notice set contract that is allowed to mint
/// @param mintContract Address of contract that is allowed to mint
function setMintContract(address mintContract) public onlyPropManager {
require(PropTokenHelpers(getDataAddress()).isContractWhitelisted(mintContract), "PropToken: Contract is not whitelisted");
_mintContract = mintContract;
}
/// @notice set contract that is allowed to burn
/// @param burnContract Address of contract that is allowed to burn
function setBurnContract(address burnContract) public onlyPropManager {
require(PropTokenHelpers(getDataAddress()).isContractWhitelisted(burnContract), "PropToken: Contract is not whitelisted");
_burnContract = burnContract;
}
/// @notice set this contract into minting mode
function allowMint() public {
require(PropTokenHelpers(getDataAddress()).isCPAdminOfProperty(msg.sender, address(this)), "PropToken: Only CP admin!");
_canMint = true;
}
function _transferWithFee(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "PropToken: transfer from the zero address");
require(recipient != address(0), "PropToken: transfer to the zero address");
require(!PropTokenHelpers(getDataAddress()).isPropTokenFrozen(address(this)), "PropToken: Transactions are frozen");
address blocksquare = PropTokenHelpers(getDataAddress()).getBlocksquareAddress();
address cp = PropTokenHelpers(getDataAddress()).getCPOfProperty(address(this));
if (PropTokenHelpers(getDataAddress()).hasSystemAdminRights(sender) || recipient == getOceanPointContract() || recipient == _burnContract) {
_transfer(sender, recipient, amount);
}
else if (recipient == blocksquare || recipient == cp || recipient == owner()) {
_transfer(sender, recipient, amount);
}
else {
require(PropTokenHelpers(getDataAddress()).canTransferPropTokensTo(recipient, address(this)), "PropToken: Can't send tokens to!");
if (sender == blocksquare || sender == cp || sender == owner()) {
_transfer(sender, recipient, amount);
}
else {
_fee(sender, recipient, amount, blocksquare, cp);
}
}
}
function _fee(address sender, address recipient, uint256 amount, address blocksquare, address cp) private {
uint256 blocksquareFee = (amount.mul(PropTokenHelpers(getDataAddress()).getBlocksquareFee())).div(1000);
uint256 liFee = (amount.mul(PropTokenHelpers(getDataAddress()).getLicencedIssuerFee())).div(1000);
uint256 cpFee = (amount.mul(PropTokenHelpers(getDataAddress()).getCertifiedPartnerFee())).div(1000);
uint256 together = blocksquareFee.add(liFee).add(cpFee);
_transfer(sender, blocksquare, blocksquareFee);
_transfer(sender, cp, cpFee);
_transfer(sender, owner(), liFee);
_transfer(sender, recipient, amount.sub(together));
}
function getDataAddress() internal view returns (address) {
return PropTokenHelpers(_propertyRegistry).getDataProxy();
}
/// @notice gets maximum number of tokens that can be created
function cap() public view returns (uint256) {
return _cap;
}
/// @notice check if this property can be minted
function canBeMinted() public view returns (bool) {
return _canMint;
}
/// @notice retrieves address of contract that is allowed to mint
function getMintContract() public view returns (address) {
return _mintContract;
}
/// @notice retrieves address of contract that is allowed to burn
function getBurnContract() public view returns (address) {
return _burnContract;
}
/// @notice retrieves ocean point contract address
function getOceanPointContract() public view returns (address) {
return PropTokenHelpers(getDataAddress()).getOceanPointContract();
}
}
| 32,492 |
17 | // tokenURI() base path./Without trailing slash | string internal _baseTokenURI;
| string internal _baseTokenURI;
| 12,991 |
29 | // check whether the contract be called directly or not Modifier that will execute internal code block only if called directly(Not via delegatecall) / | modifier onlyEthDepositLogic() {
require(isEthDepositLogic(), "delegatecall is not allowed");
_;
}
| modifier onlyEthDepositLogic() {
require(isEthDepositLogic(), "delegatecall is not allowed");
_;
}
| 194 |
267 | // Read the transfer | Transfer memory transfer;
readTx(data, offset, transfer);
TransferAuxiliaryData memory auxData = abi.decode(auxiliaryData, (TransferAuxiliaryData));
| Transfer memory transfer;
readTx(data, offset, transfer);
TransferAuxiliaryData memory auxData = abi.decode(auxiliaryData, (TransferAuxiliaryData));
| 51,117 |
60 | // Get batch of ERC20 balances.return Batch of ERC20 balances. / | function batchERC20Balances(address[] calldata tokens, address[] calldata tokenHolders) external view returns (uint256[] memory, uint256[] memory) {
uint256[] memory batchBalancesOf = batchBalanceOf(tokens, tokenHolders);
uint256[] memory batchEthBalances = batchEthBalance(tokenHolders);
return (batchEthBalances, batchBalancesOf);
}
| function batchERC20Balances(address[] calldata tokens, address[] calldata tokenHolders) external view returns (uint256[] memory, uint256[] memory) {
uint256[] memory batchBalancesOf = batchBalanceOf(tokens, tokenHolders);
uint256[] memory batchEthBalances = batchEthBalance(tokenHolders);
return (batchEthBalances, batchBalancesOf);
}
| 40,827 |
25 | // 10% of the total Ether sent is used to pay existing holders. | var fee = div(value_, 10);
| var fee = div(value_, 10);
| 13,849 |
164 | // Transfers a Kitty to another address. If transferring to a smart/contract be VERY CAREFUL to ensure that it is aware of ERC-721 (or/CryptoKitties specifically) or your Kitty may be lost forever. Seriously./_to The address of the recipient, can be a user or contract./_tokenId The ID of the Kitty to transfer./Required for ERC-721 compliance. | function transfer(
address _to,
uint256 _tokenId
)
public
whenNotPaused
| function transfer(
address _to,
uint256 _tokenId
)
public
whenNotPaused
| 33,254 |
7 | // Withdraw structure |
struct withdrawal
|
struct withdrawal
| 28,362 |
95 | // Crimecash Token with Governance.address: https:ropsten.etherscan.io/address/0x263361900b60d3b0fce9e3eb77abfb7c398f3c46code | contract CrimeCash is ERC20("CrimeCash", "CRIME"), Ownable {
constructor() public {
_setupDecimals(8);
}
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
}
function burn(address _from, uint256 _amount) public onlyOwner {
_burn(_from, _amount);
}
} | contract CrimeCash is ERC20("CrimeCash", "CRIME"), Ownable {
constructor() public {
_setupDecimals(8);
}
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
}
function burn(address _from, uint256 _amount) public onlyOwner {
_burn(_from, _amount);
}
} | 27,951 |
49 | // Change the vault series | vault_.seriesId = newSeriesId;
_tweak(vaultId, vault_);
| vault_.seriesId = newSeriesId;
_tweak(vaultId, vault_);
| 9,441 |
280 | // substract withdrawal reward from total deposit | totalPendingDeposit -= withdrawalReward;
| totalPendingDeposit -= withdrawalReward;
| 34,288 |
23 | // 团队质押收益时间 | mapping (address => uint256) private teamPledgeHarvestTime;
| mapping (address => uint256) private teamPledgeHarvestTime;
| 5,151 |
444 | // fire a burnt event | emit Burnt(msg.sender, _from, _value);
| emit Burnt(msg.sender, _from, _value);
| 7,142 |
204 | // Copied and modified from sushiswap code: https:github.com/sushiswap/sushiswap/blob/master/contracts/MasterChef.sol | interface IMigrator {
function replaceMigrate(IERC20 lpToken) external returns (IERC20, uint);
function migrate(IERC20 lpToken) external returns (IERC20, uint);
}
| interface IMigrator {
function replaceMigrate(IERC20 lpToken) external returns (IERC20, uint);
function migrate(IERC20 lpToken) external returns (IERC20, uint);
}
| 34,616 |
164 | // Returns the downcasted uint80 from uint256, reverting onoverflow (when the input is greater than largest uint80). Counterpart to Solidity's `uint80` operator. Requirements: - input must fit into 80 bits _Available since v4.7._ / | function toUint80(uint256 value) internal pure returns (uint80) {
require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
return uint80(value);
}
| function toUint80(uint256 value) internal pure returns (uint80) {
require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
return uint80(value);
}
| 14,444 |
24 | // set the token&39;s tokenExchangeRate, | function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
if (_tokenExchangeRate == 0) throw;
if (_tokenExchangeRate == tokenExchangeRate) throw;
tokenExchangeRate = _tokenExchangeRate;
}
| function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
if (_tokenExchangeRate == 0) throw;
if (_tokenExchangeRate == tokenExchangeRate) throw;
tokenExchangeRate = _tokenExchangeRate;
}
| 11,391 |
2 | // Whether the distribution's feeRecipient has claimed its fee. | bool wasFeeClaimed;
| bool wasFeeClaimed;
| 13,161 |
12 | // totalNFT staked | uint256 public totalNFT;
| uint256 public totalNFT;
| 81,345 |
20 | // Match functions : | function uint2str(uint256 _i)
internal
pure
returns (string memory _uintAsString)
| function uint2str(uint256 _i)
internal
pure
returns (string memory _uintAsString)
| 312 |
126 | // Updates balance of winner minus fee amount | balances[_winner] += (_pot - fee);
balances[beneficiary] += fee;
| balances[_winner] += (_pot - fee);
balances[beneficiary] += fee;
| 36,148 |
1 | // change your cost by changing the value of 1 , for example: 5 ether etc... | uint256 public cost = 1 ether;
| uint256 public cost = 1 ether;
| 19,355 |
35 | // Fallback function to buy the tokens/ | function () payable {
require(msg.value > 0);
buyTokens(msg.sender, msg.value);
}
| function () payable {
require(msg.value > 0);
buyTokens(msg.sender, msg.value);
}
| 15,374 |
51 | // Acceptance state | bool sellerAccepted;
bool buyerAccepted;
| bool sellerAccepted;
bool buyerAccepted;
| 36,059 |
326 | // tokenIn The address of the input token/tokenOut The address of the output token/recipient The address to receive the tokens/amountOut The exact amount of the output token to receive/ return tradeSuccess Indicates whether the trade succeeded | function swapExactOutput(
address tokenIn,
address tokenOut,
address recipient,
uint256 amountOut
) external returns (bool tradeSuccess);
| function swapExactOutput(
address tokenIn,
address tokenOut,
address recipient,
uint256 amountOut
) external returns (bool tradeSuccess);
| 63,497 |
170 | // public methods public method to harvest all the unharvested epochs until current epoch - 1 | function massHarvest() external returns (uint){
uint totalDistributedValue;
uint epochId = _getEpochId().sub(1); // fails in epoch 0
// force max number of epochs
if (epochId > NR_OF_EPOCHS) {
epochId = NR_OF_EPOCHS;
}
for (uint128 i = lastEpochIdHarvested[msg.sender] + 1; i <= epochId; i++) {
// i = epochId
// compute distributed Value and do one single transfer at the end
totalDistributedValue += _harvest(i);
}
emit MassHarvest(msg.sender, epochId.sub(lastEpochIdHarvested[msg.sender]), totalDistributedValue);
if (totalDistributedValue > 0) {
_bond.transferFrom(_communityVault, msg.sender, totalDistributedValue);
}
return totalDistributedValue;
}
| function massHarvest() external returns (uint){
uint totalDistributedValue;
uint epochId = _getEpochId().sub(1); // fails in epoch 0
// force max number of epochs
if (epochId > NR_OF_EPOCHS) {
epochId = NR_OF_EPOCHS;
}
for (uint128 i = lastEpochIdHarvested[msg.sender] + 1; i <= epochId; i++) {
// i = epochId
// compute distributed Value and do one single transfer at the end
totalDistributedValue += _harvest(i);
}
emit MassHarvest(msg.sender, epochId.sub(lastEpochIdHarvested[msg.sender]), totalDistributedValue);
if (totalDistributedValue > 0) {
_bond.transferFrom(_communityVault, msg.sender, totalDistributedValue);
}
return totalDistributedValue;
}
| 37,757 |
248 | // Prepare a users array to whitelist the Safe. | address[] memory users = new address[](1);
users[0] = address(safe);
| address[] memory users = new address[](1);
users[0] = address(safe);
| 36,149 |
136 | // Register whether or not the new owner is willing to accept ownership. | _willAcceptOwnership[controller][msg.sender] = willAcceptOwnership;
| _willAcceptOwnership[controller][msg.sender] = willAcceptOwnership;
| 4,883 |
50 | // Resume all paused functionalities of Boomflow.Only WhitelistAdmin (DEX) have the access permission. / | function Resume()
public
onlyWhitelistAdmin
| function Resume()
public
onlyWhitelistAdmin
| 39,351 |
24 | // Function to finish the sender's participation for the asset.The asset profit is redeemed as well as all the Dai deposited. / | function finish() nonReentrant external {
_finish(msg.sender);
}
| function finish() nonReentrant external {
_finish(msg.sender);
}
| 18,212 |
11 | // Validate the length of the data in state is a multiple of 32 | uint256 argLen = arg.length;
require(
argLen != 0 && argLen % 32 == 0,
"Dynamic state variables must be a multiple of 32 bytes"
);
| uint256 argLen = arg.length;
require(
argLen != 0 && argLen % 32 == 0,
"Dynamic state variables must be a multiple of 32 bytes"
);
| 24,619 |
1 | // inscribe an inscription.The inscribing function solely validates the format of the calldata and does not verify its content. The correct content data should be prepared.The inscribing function does not check for content duplication. Ethernals are inscribed by sending a transaction to the contract, the calldata must encoded as follows: - 3 bytes: header, must be "eth" - 1 byte: version, must be 1 - 1 byte: content type length - content type bytes with length of content type length - 4 byte: content length - content bytes with length of content lengthinput the calldata to be inscribedreturn bytes inscription ID | fallback(bytes calldata input) external returns (bytes memory) {
require(msg.sender == tx.origin, "only EOA");
require(keccak256(abi.encodePacked(string(input[0:3]))) == keccak256(abi.encodePacked(ETHERNAL_HEAER)), "invalid header");
require(uint8(input[3]) == ETHERNAL_VER, "invalid version");
uint8 ctlen = uint8(input[4]);
uint32 clen = uint32(bytes4(input[5+ctlen:9+ctlen]));
require(ctlen > 0 && clen > 0 && input.length == 9 + ctlen + clen, "invalid calldata length");
uint256 id = _inscriptionIdTracker.current();
_inscriptionIdTracker.increment();
_inscribe(msg.sender, id, new bytes(0));
return abi.encode(id);
}
| fallback(bytes calldata input) external returns (bytes memory) {
require(msg.sender == tx.origin, "only EOA");
require(keccak256(abi.encodePacked(string(input[0:3]))) == keccak256(abi.encodePacked(ETHERNAL_HEAER)), "invalid header");
require(uint8(input[3]) == ETHERNAL_VER, "invalid version");
uint8 ctlen = uint8(input[4]);
uint32 clen = uint32(bytes4(input[5+ctlen:9+ctlen]));
require(ctlen > 0 && clen > 0 && input.length == 9 + ctlen + clen, "invalid calldata length");
uint256 id = _inscriptionIdTracker.current();
_inscriptionIdTracker.increment();
_inscribe(msg.sender, id, new bytes(0));
return abi.encode(id);
}
| 22,830 |
290 | // AirSwap Swap contract https:github.com/airswap/airswap-protocols/blob/master/source/swap/contracts/interfaces/ISwap.sol | ISwap public immutable SWAP_CONTRACT;
| ISwap public immutable SWAP_CONTRACT;
| 29,555 |
26 | // The following functions are required by OpenSea Operator Filter (https:github.com/ProjectOpenSea/operator-filter-registry) | function setApprovalForAll(address operator, bool approved) public override(ERC721,IERC721) onlyAllowedOperatorApproval(operator) {
super.setApprovalForAll(operator, approved);
}
| function setApprovalForAll(address operator, bool approved) public override(ERC721,IERC721) onlyAllowedOperatorApproval(operator) {
super.setApprovalForAll(operator, approved);
}
| 37,039 |
424 | // Add to the global liquidation collateral count. | _addCollateral(rawLiquidationCollateral, lockedCollateral.add(finalFeeBond));
| _addCollateral(rawLiquidationCollateral, lockedCollateral.add(finalFeeBond));
| 2,714 |
20 | // user supply QBT APY == ((qubitRate365 daysprice Of Qubit) / (Total boosted balanceexchangeRateprice of asset) )my boosted balance/ my balance | uint accountSupply = IQToken(market).balanceOf(account);
apyAccountSupplyQBT = accountSupply > 0 ? apySupplyQBT.mul(accountDistributions[market][account].boostedSupply).div(accountSupply) : 0;
| uint accountSupply = IQToken(market).balanceOf(account);
apyAccountSupplyQBT = accountSupply > 0 ? apySupplyQBT.mul(accountDistributions[market][account].boostedSupply).div(accountSupply) : 0;
| 15,969 |
368 | // Emitted when iToken's collateral factor is changed by admin | event NewCollateralFactor(
address iToken,
uint256 oldCollateralFactorMantissa,
uint256 newCollateralFactorMantissa
);
function _setCollateralFactor(
address iToken,
uint256 newCollateralFactorMantissa
) external;
| event NewCollateralFactor(
address iToken,
uint256 oldCollateralFactorMantissa,
uint256 newCollateralFactorMantissa
);
function _setCollateralFactor(
address iToken,
uint256 newCollateralFactorMantissa
) external;
| 40,614 |
26 | // Calculates black scholes for the ITM option at mint given strikeprice and underlying given the parameters (if underling >= strike price this ispremium of call, and put otherwise) t is the days until expiry v is the annualized volatility sp is the underlying price st is the strike pricereturn premium is the premium of option / | function blackScholes(
uint256 t,
uint256 v,
uint256 sp,
uint256 st
| function blackScholes(
uint256 t,
uint256 v,
uint256 sp,
uint256 st
| 58,800 |
4 | // Returns the type of the validator return uint8/ | function getType()
external
view
returns(uint8)
| function getType()
external
view
returns(uint8)
| 50,921 |
15 | // The user must be among the approvers, and must have not approved the request before | require(approvers[msg.sender]);
require(!request.approvals[msg.sender]);
| require(approvers[msg.sender]);
require(!request.approvals[msg.sender]);
| 21,366 |
206 | // Pause the sale | function saleStop() public onlyOwner {
_saleIsActive = false;
}
| function saleStop() public onlyOwner {
_saleIsActive = false;
}
| 28,732 |
47 | // Set new HoQu token exchange rate. / | function setTokenRate(uint256 _tokenRate) onlyOwner {
require (_tokenRate > 0);
tokenRate = _tokenRate;
}
| function setTokenRate(uint256 _tokenRate) onlyOwner {
require (_tokenRate > 0);
tokenRate = _tokenRate;
}
| 44,962 |
195 | // the following needs to be done as to fetch up to date fees information from the NFT tokensOwed0 and 1 represent fees owed for that NFT | if(tokensOwed0 == 0 && tokensOwed1 == 0) {
(,,,,,,,,,, tokensOwed0, tokensOwed1) = INonfungiblePositionManager(nonfungiblePositionManager).positions(_setups[_positions[positionId].setupIndex].objectId);
}
| if(tokensOwed0 == 0 && tokensOwed1 == 0) {
(,,,,,,,,,, tokensOwed0, tokensOwed1) = INonfungiblePositionManager(nonfungiblePositionManager).positions(_setups[_positions[positionId].setupIndex].objectId);
}
| 27,853 |
3 | // Token symbol getter overriden to return the a symbol based on the carbon project data | function symbol() public view virtual override returns (string memory) {
string memory globalProjectId;
string memory vintageName;
(globalProjectId, vintageName) = getGlobalProjectVintageIdentifiers();
return
string(
abi.encodePacked('TCO2-', globalProjectId, '-', vintageName)
);
}
| function symbol() public view virtual override returns (string memory) {
string memory globalProjectId;
string memory vintageName;
(globalProjectId, vintageName) = getGlobalProjectVintageIdentifiers();
return
string(
abi.encodePacked('TCO2-', globalProjectId, '-', vintageName)
);
}
| 8,266 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.