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
|
---|---|---|---|---|
5 | // Expensive and ONLY CALLABLE EXTERNALLY because it returns a dynamic array. | function tokensOfOwner(address _owner) external view returns(uint256[] memory ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 total = totalSupply(); // is this custom? do i need a counter?
uint256 resultIndex = 0;
// Tickets are generated sequentially, starting at 0
uint256 ticketId;
for (ticketId = 0; ticketId < total; ticketId++) {
if (ownerOf(ticketId) == _owner) {
result[resultIndex] = ticketId;
resultIndex++;
}
}
return result;
}
}
| function tokensOfOwner(address _owner) external view returns(uint256[] memory ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 total = totalSupply(); // is this custom? do i need a counter?
uint256 resultIndex = 0;
// Tickets are generated sequentially, starting at 0
uint256 ticketId;
for (ticketId = 0; ticketId < total; ticketId++) {
if (ownerOf(ticketId) == _owner) {
result[resultIndex] = ticketId;
resultIndex++;
}
}
return result;
}
}
| 37,725 |
312 | // Prepare update of target allocation (with time delay enforced). newTargetAllocation New target allocation.return `true` if successful. / | function prepareTargetAllocation(uint256 newTargetAllocation)
external
onlyGovernance
returns (bool)
| function prepareTargetAllocation(uint256 newTargetAllocation)
external
onlyGovernance
returns (bool)
| 23,390 |
172 | // Mint tokens for dev address | MyToken.mint(devAddress, devReward)
| MyToken.mint(devAddress, devReward)
| 22,277 |
24 | // escrow[msg.sender] += bids[nftAddress][tokenID[i]].price; |
emit AcceptBid({
nft: nftAddress,
tokenID: tokenID[i],
price: bids[nftAddress][tokenID[i]].price
});
|
emit AcceptBid({
nft: nftAddress,
tokenID: tokenID[i],
price: bids[nftAddress][tokenID[i]].price
});
| 34,033 |
85 | // Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.The call is not executed if the target address is not a contract.from address representing the previous owner of the given token ID to target address that will receive the tokens tokenId uint256 ID of the token to be transferred _data bytes optional data to send along with the callreturn bool whether the call correctly returned the expected magic value / | function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
| function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
| 31,744 |
6 | // Description: Used to initialize all variables when contract is launched. Only ever run at launch. / | function initialize() public {
require(!_initialized);
_owner = _msgSender();
_tax = 0xefe5bb8529b6bF478EF8c18cd115746F162C9C2d;
_banner = _msgSender();
_treasury = _msgSender();
_tradeIsOpen = false;
_buyIsOpen = true;
_sellIsOpen = false;
_blockRestriction = 2;
_timeRestriction = 60;
_taxAmount = 320;
_sellTaxFactor = 18000;
_transactRestriction = 250000000;
_transactRestrictionTime = 60;
_transactRestrictionTimeStart = block.timestamp;
_DECIMALS = 9;
_DECIMALFACTOR = 10 ** _DECIMALS;
_SUPPLY = 100000000000;
_TotalSupply = _SUPPLY * _DECIMALFACTOR;
_TENTHOUSANDUNITS = 10000;
_NAME = "DumpBuster";
_SYMBOL = "GTFO";
_balances[_msgSender()] = _TotalSupply;
_initialized = true;
emit OwnerSet(address(0), _owner);
}
| function initialize() public {
require(!_initialized);
_owner = _msgSender();
_tax = 0xefe5bb8529b6bF478EF8c18cd115746F162C9C2d;
_banner = _msgSender();
_treasury = _msgSender();
_tradeIsOpen = false;
_buyIsOpen = true;
_sellIsOpen = false;
_blockRestriction = 2;
_timeRestriction = 60;
_taxAmount = 320;
_sellTaxFactor = 18000;
_transactRestriction = 250000000;
_transactRestrictionTime = 60;
_transactRestrictionTimeStart = block.timestamp;
_DECIMALS = 9;
_DECIMALFACTOR = 10 ** _DECIMALS;
_SUPPLY = 100000000000;
_TotalSupply = _SUPPLY * _DECIMALFACTOR;
_TENTHOUSANDUNITS = 10000;
_NAME = "DumpBuster";
_SYMBOL = "GTFO";
_balances[_msgSender()] = _TotalSupply;
_initialized = true;
emit OwnerSet(address(0), _owner);
}
| 50,582 |
98 | // Sets Operator | function setOperator(address _operator) external onlyOperator {
operator = _operator;
}
| function setOperator(address _operator) external onlyOperator {
operator = _operator;
}
| 26,872 |
2,078 | // 1041 | entry "intreatingly" : ENG_ADVERB
| entry "intreatingly" : ENG_ADVERB
| 21,877 |
10 | // Internal function to preview how many base tokens will be received when unwrapping a given amount of shares./shares The amount of shares to preview a redemption./ return base_ The amount of base tokens that would be returned from redeeming. | function _unwrapPreview(
uint256 shares
| function _unwrapPreview(
uint256 shares
| 41,631 |
9 | // Sends a move with a given name, optionally attaching a WCHI paymentto the given receiver.For no payment, amount and receiver should beset to zero. If a nonce other than uint256.max is passed, then the move is validonly if it matches exactly the account's next nonce.The nonce usedis returned. / | function move (string memory ns, string memory name, string memory mv,
| function move (string memory ns, string memory name, string memory mv,
| 6,466 |
289 | // transfer tokens to the data contract | require(auditData.token().transferFrom(msg.sender, address(auditData), price));
| require(auditData.token().transferFrom(msg.sender, address(auditData), price));
| 36,234 |
69 | // StakeManager call this function to deposit for user. - Must update pool info - Must give pending reward to user. - Emit `BalanceAdded` event. _user User address. _protocol Protocol address. _amount Stake amount. _nftId NftId./ | ) external override onlyModule("STAKE") {
PoolInfo storage pool = poolInfo[_protocol];
UserInfo storage user = userInfo[_protocol][_user];
if (pool.protocol == address(0)) {
initPool(_protocol);
} else {
updatePool(_protocol);
if (user.amount > 0) {
uint256 pending = user
.amount
.mul(pool.accEthPerShare)
.div(1e12)
.sub(user.rewardDebt);
safeRewardTransfer(_user, _protocol, pending);
}
}
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accEthPerShare).div(1e12);
pool.totalStaked = pool.totalStaked.add(_amount);
emit BalanceAdded(
_user,
_protocol,
_nftId,
_amount,
pool.totalStaked,
block.timestamp
);
}
| ) external override onlyModule("STAKE") {
PoolInfo storage pool = poolInfo[_protocol];
UserInfo storage user = userInfo[_protocol][_user];
if (pool.protocol == address(0)) {
initPool(_protocol);
} else {
updatePool(_protocol);
if (user.amount > 0) {
uint256 pending = user
.amount
.mul(pool.accEthPerShare)
.div(1e12)
.sub(user.rewardDebt);
safeRewardTransfer(_user, _protocol, pending);
}
}
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accEthPerShare).div(1e12);
pool.totalStaked = pool.totalStaked.add(_amount);
emit BalanceAdded(
_user,
_protocol,
_nftId,
_amount,
pool.totalStaked,
block.timestamp
);
}
| 47,042 |
101 | // use EIP 191 0x1900 + this logic address + data + nonce of signing key | bytes32 msgHash ; //inject UNINIT LOCAL/STATE VAR
bytes32 prefixedHash ; //inject UNINIT LOCAL/STATE VAR
return prefixedHash;
| bytes32 msgHash ; //inject UNINIT LOCAL/STATE VAR
bytes32 prefixedHash ; //inject UNINIT LOCAL/STATE VAR
return prefixedHash;
| 23,702 |
18 | // Call smart contract from vault/Only manager can do this/Only smart contracts and functions whitelisted in the filters can be called/_contract smart contract address/_value ETH to send with the call/_args function signature and parameters | function managerCall(address _contract, uint256 _value, bytes memory _args) external nonReentrant onlyManager {
if (address(config.filterMapper) == address(0)) revert FilterMapperNotAssigned();
_internalManagerCall(_contract, _value, _args);
}
| function managerCall(address _contract, uint256 _value, bytes memory _args) external nonReentrant onlyManager {
if (address(config.filterMapper) == address(0)) revert FilterMapperNotAssigned();
_internalManagerCall(_contract, _value, _args);
}
| 32,106 |
23 | // considering fee as a separate input | require(ticketData[utxoPos].reservedAmount == outputData.amount, "Wrong amount sent to quasar owner");
require(ticketData[utxoPos].token == outputData.token, "Wrong token sent to quasar owner");
| require(ticketData[utxoPos].reservedAmount == outputData.amount, "Wrong amount sent to quasar owner");
require(ticketData[utxoPos].token == outputData.token, "Wrong token sent to quasar owner");
| 27,001 |
51 | // Query if a contract implements an interface _interfaceId The interface identifier, as specified in ERC-165 Interface identification is specified in ERC-165. This functionuses less than 30,000 gas. / | function supportsInterface(bytes4 _interfaceId)
external
view
returns (bool);
| function supportsInterface(bytes4 _interfaceId)
external
view
returns (bool);
| 40,433 |
272 | // flip the fraction | price = (1e24 / price) / 1e12;
| price = (1e24 / price) / 1e12;
| 39,876 |
53 | // Max wallet holding (% at launch) | uint256 public _maxWalletToken = _tTotal.mul(1).div(100);
uint256 private _previousMaxWalletToken = _maxWalletToken;
| uint256 public _maxWalletToken = _tTotal.mul(1).div(100);
uint256 private _previousMaxWalletToken = _maxWalletToken;
| 75,471 |
78 | // console.log("about to transfer tokens async"); | _asyncTransfer(sale.recipient, nativeFee);
| _asyncTransfer(sale.recipient, nativeFee);
| 27,947 |
173 | // At main sale bonuses will be available only during the first 48 hours. | uint public mainSaleBonusEndTime;
| uint public mainSaleBonusEndTime;
| 44,635 |
150 | // Send to the treasury | retirementYeldTreasury.transfer(retirementYeld);
| retirementYeldTreasury.transfer(retirementYeld);
| 14,550 |
194 | // need to add up since the range could be in the middle somewheretraverse inversely to make more current queries more gas efficient | for (uint i = locks.length - 1; i + 1 != 0; i--) {
uint256 lockEpoch = uint256(locks[i].unlockTime).sub(lockDuration);
| for (uint i = locks.length - 1; i + 1 != 0; i--) {
uint256 lockEpoch = uint256(locks[i].unlockTime).sub(lockDuration);
| 31,491 |
76 | // NOTE leave game in playable state when possible TODO deal with leaving after start TODO deal with game-ending exits TODO reveal all player cards TODO consider stake sacrifice as penalty | function leaveGame() external {
uint256 gameId = player_to_game[msg.sender];
if (gameId != 0) {
require(games[gameId].turn == 0, 'Leaving after start not yet supported');
player_to_game[msg.sender] = 0;
// remove from list of game's players
uint256 numPlayers = getNumPlayers(gameId);
for (uint256 i = 0; i < numPlayers; i++) {
if (game_to_players[gameId][i].id == msg.sender) {
delete game_to_players[gameId][i];
game_to_players[gameId][i] = game_to_players[gameId][numPlayers - 1];
break;
}
}
} else {
// TODO add address in readable format
string memory message = string(abi.encodePacked(msg.sender, ' is not playing'));
console.log(message);
}
}
| function leaveGame() external {
uint256 gameId = player_to_game[msg.sender];
if (gameId != 0) {
require(games[gameId].turn == 0, 'Leaving after start not yet supported');
player_to_game[msg.sender] = 0;
// remove from list of game's players
uint256 numPlayers = getNumPlayers(gameId);
for (uint256 i = 0; i < numPlayers; i++) {
if (game_to_players[gameId][i].id == msg.sender) {
delete game_to_players[gameId][i];
game_to_players[gameId][i] = game_to_players[gameId][numPlayers - 1];
break;
}
}
} else {
// TODO add address in readable format
string memory message = string(abi.encodePacked(msg.sender, ' is not playing'));
console.log(message);
}
}
| 41,300 |
105 | // @nonce Sends premiums to the liquidity pool / | receive() external payable {}
/**
* @notice Used for changing the lockup period
* @param value New period value
*/
function setLockupPeriod(uint256 value) external override onlyOwner {
require(value <= 60 days, "Lockup period is too large");
lockupPeriod = value;
}
| receive() external payable {}
/**
* @notice Used for changing the lockup period
* @param value New period value
*/
function setLockupPeriod(uint256 value) external override onlyOwner {
require(value <= 60 days, "Lockup period is too large");
lockupPeriod = value;
}
| 9,859 |
19 | // transfer token for a specified address_to The address to transfer to._value The amount to be transferred./ | function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
| function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
| 19,967 |
293 | // Indicates whether the given address can mint more tokens./ | function addressMintAvailable(address to) public view virtual returns (bool) {
return _mintCounts[to] < MAX_MINTS_PER_ADDRESS;
}
| function addressMintAvailable(address to) public view virtual returns (bool) {
return _mintCounts[to] < MAX_MINTS_PER_ADDRESS;
}
| 20,500 |
43 | // +---------------------------------------------------------------------------------------+ Private Functions+---------------------------------------------------------------------------------------+ |
function transferReferralTokens(address referrer, uint256 bonusPercent, uint purchaseAmountBig) private {
uint256 referralAmountBig = purchaseAmountBig.mul(bonusPercent).div(10**2);
_token.transfer(referrer, (referralAmountBig));
}
|
function transferReferralTokens(address referrer, uint256 bonusPercent, uint purchaseAmountBig) private {
uint256 referralAmountBig = purchaseAmountBig.mul(bonusPercent).div(10**2);
_token.transfer(referrer, (referralAmountBig));
}
| 45,280 |
43 | // Create a list of orders/_orders Orders to create/_amounts Amounts of options to buy / sell for each order/ return The hashes of the orders | function createOrders(Order[] memory _orders, uint256[] memory _amounts) external returns(bytes32[] memory) {
require(_orders.length == _amounts.length, "Arrays must have same length");
bytes32[] memory result = new bytes32[](_orders.length);
for (uint256 i=0; i < _orders.length; i++) {
result[i] = createOrder(_orders[i], _amounts[i]);
}
return result;
}
| function createOrders(Order[] memory _orders, uint256[] memory _amounts) external returns(bytes32[] memory) {
require(_orders.length == _amounts.length, "Arrays must have same length");
bytes32[] memory result = new bytes32[](_orders.length);
for (uint256 i=0; i < _orders.length; i++) {
result[i] = createOrder(_orders[i], _amounts[i]);
}
return result;
}
| 50,521 |
117 | // get the new reserve weights | (uint32 primaryReserveWeight, uint32 secondaryReserveWeight) = effectiveReserveWeights(referenceRate);
| (uint32 primaryReserveWeight, uint32 secondaryReserveWeight) = effectiveReserveWeights(referenceRate);
| 50,032 |
100 | // Checks if the msg.sender is the admin address / | modifier onlyAdmin() {
require(msg.sender == admin, "admin: wut?");
_;
}
| modifier onlyAdmin() {
require(msg.sender == admin, "admin: wut?");
_;
}
| 41,103 |
5 | // Emitted on successful vested token claim when the number of tokens claimed/ is 1 or more. Does not fire for 0 claims./to recipient of claim/amt of tokens claimed | event VestClaim(address indexed to, uint256 amt);
| event VestClaim(address indexed to, uint256 amt);
| 6,381 |
163 | // The VaultChef is a vault management contract that manages vaults, their strategies and the share positions of investors in these vaults. Positions are not hardcoded into the contract like traditional staking contracts, instead they are managed as ERC-1155 receipt tokens. This receipt-token mechanism is supposed to simplify zapping and other derivative protocols. The VaultChef contract has the following design principles. 1. Simplicity of Strategies: Strategies should be as simple as possible. 2. Control of Governance: Governance should never be able to steal underlying funds. 3. Auditability: It should be easy for third-party reviewers to assess the safety of the VaultChef. | interface IVaultChefCore is IERC1155 {
/// @notice A vault is a strategy users can stake underlying tokens in to receive a share of the vault value.
struct Vault {
/// @notice The token this strategy will compound.
IERC20 underlyingToken;
/// @notice The timestamp of the last harvest, set to zero while no harvests have happened.
uint96 lastHarvestTimestamp;
/// @notice The strategy contract.
IStrategy strategy;
/// @notice The performance fee portion of the harvests that is sent to the feeAddress, denominated by 10,000.
uint16 performanceFeeBP;
/// @notice Whether deposits are currently paused.
bool paused;
/// @notice Whether the vault has panicked which means the funds are pulled from the strategy and it is paused forever.
bool panicked;
}
/**
* @notice Deposit `underlyingAmount` amount of underlying tokens into the vault and receive `sharesReceived` proportional to the actually staked amount.
* @notice Deposits mint `sharesReceived` receipt tokens as ERC-1155 tokens to msg.sender with the tokenId equal to the vaultId.
* @notice The tokens are transferred from `msg.sender` which requires approval if pulled is set to false, otherwise `msg.sender` needs to implement IPullDepositor.
* @param vaultId The id of the vault.
* @param underlyingAmount The intended amount of tokens to deposit (this might not equal the actual deposited amount due to tx/stake fees or the pull mechanism).
* @param pulled Uses a pull-based deposit hook if set to true, otherwise traditional safeTransferFrom. The pull-based mechanism allows the depositor to send tokens using a hook.
* @param minSharesReceived The minimum amount of shares that must be received, or the transaction reverts.
* @dev This pull-based methodology is extremely valuable for zapping transfer-tax tokens more economically.
* @dev `msg.sender` must be a smart contract implementing the `IPullDepositor` interface.
* @return sharesReceived The number of shares minted to the msg.sender.
*/
function depositUnderlying(
uint256 vaultId,
uint256 underlyingAmount,
bool pulled,
uint256 minSharesReceived
) external returns (uint256 sharesReceived);
/**
* @notice Withdraws `shares` from the vault into underlying tokens to the `msg.sender`.
* @notice Burns `shares` receipt tokens from the `msg.sender`.
* @param vaultId The id of the vault.
* @param shares The amount of shares to burn, underlying tokens will be sent to msg.sender proportionally.
* @param minUnderlyingReceived The minimum amount of underlying tokens that must be received, or the transaction reverts.
*/
function withdrawShares(
uint256 vaultId,
uint256 shares,
uint256 minUnderlyingReceived
) external returns (uint256 underlyingReceived);
/**
* @notice Withdraws `shares` from the vault into underlying tokens to the `to` address.
* @notice To prevent phishing, we require msg.sender to be a contract as this is intended for more economical zapping of transfer-tax token withdrawals.
* @notice Burns `shares` receipt tokens from the `msg.sender`.
* @param vaultId The id of the vault.
* @param shares The amount of shares to burn, underlying tokens will be sent to msg.sender proportionally.
* @param minUnderlyingReceived The minimum amount of underlying tokens that must be received, or the transaction reverts.
*/
function withdrawSharesTo(
uint256 vaultId,
uint256 shares,
uint256 minUnderlyingReceived,
address to
) external returns (uint256 underlyingReceived);
/**
* @notice Total amount of shares in circulation for a given vaultId.
* @param vaultId The id of the vault.
* @return The total number of shares currently in circulation.
*/
function totalSupply(uint256 vaultId) external view returns (uint256);
/**
* @notice Calls harvest on the underlying strategy to compound pending rewards to underlying tokens.
* @notice The performance fee is minted to the owner as shares, it can never be greater than 5% of the underlyingIncrease.
* @return underlyingIncrease The amount of underlying tokens generated.
* @dev Can only be called by owner.
*/
function harvest(uint256 vaultId)
external
returns (uint256 underlyingIncrease);
/**
* @notice Adds a new vault to the vaultchef.
* @param strategy The strategy contract that manages the allocation of the funds for this vault, also defines the underlying token
* @param performanceFeeBP The percentage of the harvest rewards that are given to the governance, denominated by 10,000 and maximum 5%.
* @dev Can only be called by owner.
*/
function addVault(IStrategy strategy, uint16 performanceFeeBP) external;
/**
* @notice Updates the performanceFee of the vault.
* @param vaultId The id of the vault.
* @param performanceFeeBP The percentage of the harvest rewards that are given to the governance, denominated by 10,000 and maximum 5%.
* @dev Can only be called by owner.
*/
function setVault(uint256 vaultId, uint16 performanceFeeBP) external;
/**
* @notice Allows the `pullDepositor` to create pull-based deposits (useful for zapping contract).
* @notice Having a whitelist is not necessary for this functionality as it is safe but upon defensive code recommendations one was added in.
* @dev Can only be called by owner.
*/
function setPullDepositor(address pullDepositor, bool isAllowed) external;
/**
* @notice Withdraws funds from the underlying staking contract to the strategy and irreversibly pauses the vault.
* @param vaultId The id of the vault.
* @dev Can only be called by owner.
*/
function panicVault(uint256 vaultId) external;
/**
* @notice Returns true if there is a vault associated with the `vaultId`.
* @param vaultId The id of the vault.
*/
function isValidVault(uint256 vaultId) external returns (bool);
/**
* @notice Returns the Vault information of the vault at `vaultId`, returns if non-existent.
* @param vaultId The id of the vault.
*/
function vaultInfo(uint256 vaultId) external returns (Vault memory);
/**
* @notice Pauses the vault which means deposits and harvests are no longer permitted, reverts if already set to the desired value.
* @param vaultId The id of the vault.
* @param paused True to pause, false to unpause.
* @dev Can only be called by owner.
*/
function pauseVault(uint256 vaultId, bool paused) external;
/**
* @notice Transfers tokens from the VaultChef to the `to` address.
* @notice Cannot be abused by governance since the protocol never ever transfers tokens to the VaultChef. Any tokens stored there are accidentally sent there.
* @param token The token to withdraw from the VaultChef.
* @param to The address to send the token to.
* @dev Can only be called by owner.
*/
function inCaseTokensGetStuck(IERC20 token, address to) external;
/**
* @notice Transfers tokens from the underlying strategy to the `to` address.
* @notice Cannot be abused by governance since VaultChef prevents token to be equal to the underlying token.
* @param token The token to withdraw from the strategy.
* @param to The address to send the token to.
* @param amount The amount of tokens to withdraw.
* @dev Can only be called by owner.
*/
function inCaseVaultTokensGetStuck(
uint256 vaultId,
IERC20 token,
address to,
uint256 amount
) external;
}
| interface IVaultChefCore is IERC1155 {
/// @notice A vault is a strategy users can stake underlying tokens in to receive a share of the vault value.
struct Vault {
/// @notice The token this strategy will compound.
IERC20 underlyingToken;
/// @notice The timestamp of the last harvest, set to zero while no harvests have happened.
uint96 lastHarvestTimestamp;
/// @notice The strategy contract.
IStrategy strategy;
/// @notice The performance fee portion of the harvests that is sent to the feeAddress, denominated by 10,000.
uint16 performanceFeeBP;
/// @notice Whether deposits are currently paused.
bool paused;
/// @notice Whether the vault has panicked which means the funds are pulled from the strategy and it is paused forever.
bool panicked;
}
/**
* @notice Deposit `underlyingAmount` amount of underlying tokens into the vault and receive `sharesReceived` proportional to the actually staked amount.
* @notice Deposits mint `sharesReceived` receipt tokens as ERC-1155 tokens to msg.sender with the tokenId equal to the vaultId.
* @notice The tokens are transferred from `msg.sender` which requires approval if pulled is set to false, otherwise `msg.sender` needs to implement IPullDepositor.
* @param vaultId The id of the vault.
* @param underlyingAmount The intended amount of tokens to deposit (this might not equal the actual deposited amount due to tx/stake fees or the pull mechanism).
* @param pulled Uses a pull-based deposit hook if set to true, otherwise traditional safeTransferFrom. The pull-based mechanism allows the depositor to send tokens using a hook.
* @param minSharesReceived The minimum amount of shares that must be received, or the transaction reverts.
* @dev This pull-based methodology is extremely valuable for zapping transfer-tax tokens more economically.
* @dev `msg.sender` must be a smart contract implementing the `IPullDepositor` interface.
* @return sharesReceived The number of shares minted to the msg.sender.
*/
function depositUnderlying(
uint256 vaultId,
uint256 underlyingAmount,
bool pulled,
uint256 minSharesReceived
) external returns (uint256 sharesReceived);
/**
* @notice Withdraws `shares` from the vault into underlying tokens to the `msg.sender`.
* @notice Burns `shares` receipt tokens from the `msg.sender`.
* @param vaultId The id of the vault.
* @param shares The amount of shares to burn, underlying tokens will be sent to msg.sender proportionally.
* @param minUnderlyingReceived The minimum amount of underlying tokens that must be received, or the transaction reverts.
*/
function withdrawShares(
uint256 vaultId,
uint256 shares,
uint256 minUnderlyingReceived
) external returns (uint256 underlyingReceived);
/**
* @notice Withdraws `shares` from the vault into underlying tokens to the `to` address.
* @notice To prevent phishing, we require msg.sender to be a contract as this is intended for more economical zapping of transfer-tax token withdrawals.
* @notice Burns `shares` receipt tokens from the `msg.sender`.
* @param vaultId The id of the vault.
* @param shares The amount of shares to burn, underlying tokens will be sent to msg.sender proportionally.
* @param minUnderlyingReceived The minimum amount of underlying tokens that must be received, or the transaction reverts.
*/
function withdrawSharesTo(
uint256 vaultId,
uint256 shares,
uint256 minUnderlyingReceived,
address to
) external returns (uint256 underlyingReceived);
/**
* @notice Total amount of shares in circulation for a given vaultId.
* @param vaultId The id of the vault.
* @return The total number of shares currently in circulation.
*/
function totalSupply(uint256 vaultId) external view returns (uint256);
/**
* @notice Calls harvest on the underlying strategy to compound pending rewards to underlying tokens.
* @notice The performance fee is minted to the owner as shares, it can never be greater than 5% of the underlyingIncrease.
* @return underlyingIncrease The amount of underlying tokens generated.
* @dev Can only be called by owner.
*/
function harvest(uint256 vaultId)
external
returns (uint256 underlyingIncrease);
/**
* @notice Adds a new vault to the vaultchef.
* @param strategy The strategy contract that manages the allocation of the funds for this vault, also defines the underlying token
* @param performanceFeeBP The percentage of the harvest rewards that are given to the governance, denominated by 10,000 and maximum 5%.
* @dev Can only be called by owner.
*/
function addVault(IStrategy strategy, uint16 performanceFeeBP) external;
/**
* @notice Updates the performanceFee of the vault.
* @param vaultId The id of the vault.
* @param performanceFeeBP The percentage of the harvest rewards that are given to the governance, denominated by 10,000 and maximum 5%.
* @dev Can only be called by owner.
*/
function setVault(uint256 vaultId, uint16 performanceFeeBP) external;
/**
* @notice Allows the `pullDepositor` to create pull-based deposits (useful for zapping contract).
* @notice Having a whitelist is not necessary for this functionality as it is safe but upon defensive code recommendations one was added in.
* @dev Can only be called by owner.
*/
function setPullDepositor(address pullDepositor, bool isAllowed) external;
/**
* @notice Withdraws funds from the underlying staking contract to the strategy and irreversibly pauses the vault.
* @param vaultId The id of the vault.
* @dev Can only be called by owner.
*/
function panicVault(uint256 vaultId) external;
/**
* @notice Returns true if there is a vault associated with the `vaultId`.
* @param vaultId The id of the vault.
*/
function isValidVault(uint256 vaultId) external returns (bool);
/**
* @notice Returns the Vault information of the vault at `vaultId`, returns if non-existent.
* @param vaultId The id of the vault.
*/
function vaultInfo(uint256 vaultId) external returns (Vault memory);
/**
* @notice Pauses the vault which means deposits and harvests are no longer permitted, reverts if already set to the desired value.
* @param vaultId The id of the vault.
* @param paused True to pause, false to unpause.
* @dev Can only be called by owner.
*/
function pauseVault(uint256 vaultId, bool paused) external;
/**
* @notice Transfers tokens from the VaultChef to the `to` address.
* @notice Cannot be abused by governance since the protocol never ever transfers tokens to the VaultChef. Any tokens stored there are accidentally sent there.
* @param token The token to withdraw from the VaultChef.
* @param to The address to send the token to.
* @dev Can only be called by owner.
*/
function inCaseTokensGetStuck(IERC20 token, address to) external;
/**
* @notice Transfers tokens from the underlying strategy to the `to` address.
* @notice Cannot be abused by governance since VaultChef prevents token to be equal to the underlying token.
* @param token The token to withdraw from the strategy.
* @param to The address to send the token to.
* @param amount The amount of tokens to withdraw.
* @dev Can only be called by owner.
*/
function inCaseVaultTokensGetStuck(
uint256 vaultId,
IERC20 token,
address to,
uint256 amount
) external;
}
| 40,660 |
101 | // copy curLine into result | assembly {
for { let j := 0 } lt(j, numloops) { j := add(1, j) } { mstore(add(resPosition, mul(32, j)), mload(add(strToCopy, mul(32, add(1, j))))) }
| assembly {
for { let j := 0 } lt(j, numloops) { j := add(1, j) } { mstore(add(resPosition, mul(32, j)), mload(add(strToCopy, mul(32, add(1, j))))) }
| 35,958 |
142 | // Setup the post-process. _to The handler of post-process. / | function _setPostProcess(address _to) internal {
// If the stack length equals 0, just skip
// If the top is a custom post-process, replace it with the handler
// address.
if (stack.length == 0) {
return;
} else if (
stack.peek() == bytes32(bytes12(uint96(HandlerType.Custom)))
) {
stack.pop();
// Check if the handler is already set.
if (bytes4(stack.peek()) != 0x00000000) stack.setAddress(_to);
stack.setHandlerType(HandlerType.Custom);
}
}
| function _setPostProcess(address _to) internal {
// If the stack length equals 0, just skip
// If the top is a custom post-process, replace it with the handler
// address.
if (stack.length == 0) {
return;
} else if (
stack.peek() == bytes32(bytes12(uint96(HandlerType.Custom)))
) {
stack.pop();
// Check if the handler is already set.
if (bytes4(stack.peek()) != 0x00000000) stack.setAddress(_to);
stack.setHandlerType(HandlerType.Custom);
}
}
| 8,325 |
219 | // AggregatorV3Interface / Chainlink compatibility | function latestRoundData() external view returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
| function latestRoundData() external view returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
| 22,683 |
41 | // User must approve this contract to transfer the given amount | cargoGems.transferFrom(msg.sender, address(this), amountToStake);
| cargoGems.transferFrom(msg.sender, address(this), amountToStake);
| 25,883 |
5 | // Returns `true` if `account` has been granted `permission`. / | function hasPermission(bytes32 permission, address account) external view returns (bool);
| function hasPermission(bytes32 permission, address account) external view returns (bool);
| 62,381 |
405 | // Percent of oraclePrice paid to disputer in the Disputed state (i.e. following a successful dispute) Represented as a multiplier, see above. | FixedPoint.Unsigned public disputerDisputeRewardPct;
| FixedPoint.Unsigned public disputerDisputeRewardPct;
| 34,708 |
41 | // A mapping from hero ID to its current health. | mapping(uint => uint) public heroIdToHealth;
| mapping(uint => uint) public heroIdToHealth;
| 32,217 |
53 | // Minimal amount of Parsecs to cover all rewards | uint256 public constant MINIMAL_AMOUNT_OF_PARSECS = 290563097000000; // 290,563,097.000000 PRSC
| uint256 public constant MINIMAL_AMOUNT_OF_PARSECS = 290563097000000; // 290,563,097.000000 PRSC
| 36,757 |
97 | // ========== INTERNAL CHECKS ========== / | function _onlyGovernor() internal view {
if (msg.sender != authority.governor()) revert UNAUTHORIZED();
}
| function _onlyGovernor() internal view {
if (msg.sender != authority.governor()) revert UNAUTHORIZED();
}
| 46,901 |
23 | // allows to transfer ERC20 token to specific TravelPlan by anyoneID TravelPlan existing UUID amount ERC20 token value defined by its decimals | * Emits a {ContributeToTravelPlan, Transfer} event.
*/
function contributeToTravelPlan(uint256 ID, uint256 amount) external {
TravelPlan storage plan = travelPlans[ID];
require(plan.ID == ID, "doesn't exist");
plan.contributedAmount += amount;
token.safeTransferFrom(msg.sender, address(this), amount);
emit ContributeToTravelPlan(ID, msg.sender, amount);
emit Transfer(msg.sender, address(this), amount);
}
| * Emits a {ContributeToTravelPlan, Transfer} event.
*/
function contributeToTravelPlan(uint256 ID, uint256 amount) external {
TravelPlan storage plan = travelPlans[ID];
require(plan.ID == ID, "doesn't exist");
plan.contributedAmount += amount;
token.safeTransferFrom(msg.sender, address(this), amount);
emit ContributeToTravelPlan(ID, msg.sender, amount);
emit Transfer(msg.sender, address(this), amount);
}
| 25,939 |
73 | // Extend activation series | extendActivation(msg.sender);
if (users[msg.sender].info.line == 2) {
toReferrer(users[msg.sender].info.referrer, msg.value / 100 * 40, 1);
toFund(msg.value / 100 * 30 + msg.value / 100 * 20 + msg.value / 100 * 10);
}
| extendActivation(msg.sender);
if (users[msg.sender].info.line == 2) {
toReferrer(users[msg.sender].info.referrer, msg.value / 100 * 40, 1);
toFund(msg.value / 100 * 30 + msg.value / 100 * 20 + msg.value / 100 * 10);
}
| 38,170 |
302 | // Free daily summon. | function payWithDailyFreePoint()
whenNotPaused
public
| function payWithDailyFreePoint()
whenNotPaused
public
| 51,958 |
95 | // Withdraw functions | function _withdraw(bytes memory _proof, uint256 amount, bytes32 _root,
bytes32 _nullifierHash, address payable _recipient,
address payable _relayer, uint256 _fee, uint256 _refund,
| function _withdraw(bytes memory _proof, uint256 amount, bytes32 _root,
bytes32 _nullifierHash, address payable _recipient,
address payable _relayer, uint256 _fee, uint256 _refund,
| 79,475 |
35 | // Recovers ERC2O tokens sent by mistake to the contractRecovers ERC2O tokens sent by mistake to the contracttoken Address tof the EC2O token return bool: success/ | function recoverERC20(address token) external onlyOwner nonReentrant returns(bool) {
if(rewardTokens[token]) revert Errors.CannotRecoverToken();
uint256 amount = IERC20(token).balanceOf(address(this));
if(amount == 0) revert Errors.NullAmount();
IERC20(token).safeTransfer(owner(), amount);
return true;
}
| function recoverERC20(address token) external onlyOwner nonReentrant returns(bool) {
if(rewardTokens[token]) revert Errors.CannotRecoverToken();
uint256 amount = IERC20(token).balanceOf(address(this));
if(amount == 0) revert Errors.NullAmount();
IERC20(token).safeTransfer(owner(), amount);
return true;
}
| 24,074 |
3 | // sends the unlocked amount of TRIBE to the stakingRewards contract/ return amount of TRIBE sent | function drip() public override postGenesis whenNotPaused nonContract returns(uint256) {
require(isDripAvailable(), "FeiRewardsDistributor: Not passed drip frequency");
// solhint-disable-next-line not-rely-on-time
lastDistributionTime = block.timestamp;
uint amount = releasedReward();
require(amount != 0, "FeiRewardsDistributor: no rewards");
distributedRewards = distributedRewards.add(amount);
tribe().transfer(address(stakingContract), amount);
stakingContract.notifyRewardAmount(amount);
_incentivize();
emit Drip(msg.sender, amount);
return amount;
}
| function drip() public override postGenesis whenNotPaused nonContract returns(uint256) {
require(isDripAvailable(), "FeiRewardsDistributor: Not passed drip frequency");
// solhint-disable-next-line not-rely-on-time
lastDistributionTime = block.timestamp;
uint amount = releasedReward();
require(amount != 0, "FeiRewardsDistributor: no rewards");
distributedRewards = distributedRewards.add(amount);
tribe().transfer(address(stakingContract), amount);
stakingContract.notifyRewardAmount(amount);
_incentivize();
emit Drip(msg.sender, amount);
return amount;
}
| 3,558 |
48 | // after tokenLockEndTime owner Token | function withdrawTokenToInvestorOwner(address _investorAddr) public onlyOwner returns(bool){
require(_investorAddr != address(0), "");
require(now > tokenLockEndTime, "");
Investor memory investor = investorMap[_investorAddr];
if(investor.isLocked && now > investor.endTime && !freezeAccountMap[investor.addr]){
require(tokenContract.transfer(investor.addr, investor.lockAmount), "");
emit WithdrawalToken(investor.addr, investor.lockAmount);
investor.endTime = 0;
investor.isLocked = false;
investor.lockAmount = 0;
investorMap[investor.addr] = investor;
emit UnLock(investor.addr, investor.lockAmount);
}
return true;
}
| function withdrawTokenToInvestorOwner(address _investorAddr) public onlyOwner returns(bool){
require(_investorAddr != address(0), "");
require(now > tokenLockEndTime, "");
Investor memory investor = investorMap[_investorAddr];
if(investor.isLocked && now > investor.endTime && !freezeAccountMap[investor.addr]){
require(tokenContract.transfer(investor.addr, investor.lockAmount), "");
emit WithdrawalToken(investor.addr, investor.lockAmount);
investor.endTime = 0;
investor.isLocked = false;
investor.lockAmount = 0;
investorMap[investor.addr] = investor;
emit UnLock(investor.addr, investor.lockAmount);
}
return true;
}
| 43,527 |
3 | // Permissions mapping system | struct Perms {
bool Grantee;
bool Burner;
}
| struct Perms {
bool Grantee;
bool Burner;
}
| 60,201 |
19 | // This method relies in extcodesize, which returns 0 for contracts in construction, since the code is only stored at the end of the constructor execution. |
uint256 size;
|
uint256 size;
| 3,947 |
12 | // ,address _serviceFeeAddress, uint256 _serviceCost | ) /*payable*/ {
nftCollection = _nftCollection;
rewardsToken = _rewardsToken;
rewardsPerHour = _StakingReward;
// payable(_serviceFeeAddress).transfer(_serviceCost);
}
| ) /*payable*/ {
nftCollection = _nftCollection;
rewardsToken = _rewardsToken;
rewardsPerHour = _StakingReward;
// payable(_serviceFeeAddress).transfer(_serviceCost);
}
| 33,656 |
192 | // Get the current challenge of the given staker staker Staker address to lookupreturn Current challenge of the staker / | function currentChallenge(address staker) public view override returns (address) {
return _stakerMap[staker].currentChallenge;
}
| function currentChallenge(address staker) public view override returns (address) {
return _stakerMap[staker].currentChallenge;
}
| 47,645 |
90 | // } else { return; } } } | 13,653 |
||
8 | // generate random from block number | uint randomIndex = (block.number / currentItem.itemTokens.length)% currentItem.itemTokens.length;
| uint randomIndex = (block.number / currentItem.itemTokens.length)% currentItem.itemTokens.length;
| 40,640 |
12 | // Check if number of Lemon Tokens to issue is higher than coins remaining for airdrop (last transaction of airdrop) | if (tokensIssued > lemonsRemainingToDrop)
tokensIssued = lemonsRemainingToDrop;
| if (tokensIssued > lemonsRemainingToDrop)
tokensIssued = lemonsRemainingToDrop;
| 70,682 |
193 | // Order must be targeted at this protocol version (this Exchange contract). / | if (order.exchange != address(this)) {
return false;
}
| if (order.exchange != address(this)) {
return false;
}
| 4,789 |
2 | // Claim an erc20 claim token for a single ticket token | function claim(uint256 ticketTokenId, address claimToken) external;
| function claim(uint256 ticketTokenId, address claimToken) external;
| 22,252 |
142 | // All we care about is the ratio of each coin | function balances(int128 arg0) external returns (uint256 out);
| function balances(int128 arg0) external returns (uint256 out);
| 48,296 |
102 | // array of PoolStake contracts | address[] private _poolStakes;
| address[] private _poolStakes;
| 61,460 |
61 | // Check submission count & set minipool withdrawable | RocketDAONodeTrustedInterface rocketDAONodeTrusted = RocketDAONodeTrustedInterface(getContractAddress("rocketDAONodeTrusted"));
if (calcBase.mul(submissionCount).div(rocketDAONodeTrusted.getMemberCount()) >= rocketDAOProtocolSettingsNetwork.getNodeConsensusThreshold()) {
setMinipoolWithdrawable(_minipoolAddress);
}
| RocketDAONodeTrustedInterface rocketDAONodeTrusted = RocketDAONodeTrustedInterface(getContractAddress("rocketDAONodeTrusted"));
if (calcBase.mul(submissionCount).div(rocketDAONodeTrusted.getMemberCount()) >= rocketDAOProtocolSettingsNetwork.getNodeConsensusThreshold()) {
setMinipoolWithdrawable(_minipoolAddress);
}
| 69,001 |
11 | // message unnecessarily. For custom revert reasons use {trySub}. Counterpart to Solidity's `-` operator. Requirements: - Subtraction cannot overflow. / | function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
| function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
| 23,773 |
11 | // 4.Butta | balanceOf[0x3CB617913C6Ab9b4bc0CF17C2fAEBe3149E58dC6] = TOKEN_FOR_INDIVIDUAL * 10 ** uint256(decimals) * 2 / 100;
balanceOf[0x39535CfC26F74F73C2508922140c5859B733ec67] = TOKEN_FOR_INDIVIDUAL * 10 ** uint256(decimals) * 2 / 100;
balanceOf[0x7906A41853dA81E0e1bC122687C47fc4fb02e1e8] = TOKEN_FOR_INDIVIDUAL * 10 ** uint256(decimals) * 2 / 100;
balanceOf[0x1C30f6dCe6a955f68a644cd08058A71C0b5211BC] = TOKEN_FOR_INDIVIDUAL * 10 ** uint256(decimals) * 2 / 100;
| balanceOf[0x3CB617913C6Ab9b4bc0CF17C2fAEBe3149E58dC6] = TOKEN_FOR_INDIVIDUAL * 10 ** uint256(decimals) * 2 / 100;
balanceOf[0x39535CfC26F74F73C2508922140c5859B733ec67] = TOKEN_FOR_INDIVIDUAL * 10 ** uint256(decimals) * 2 / 100;
balanceOf[0x7906A41853dA81E0e1bC122687C47fc4fb02e1e8] = TOKEN_FOR_INDIVIDUAL * 10 ** uint256(decimals) * 2 / 100;
balanceOf[0x1C30f6dCe6a955f68a644cd08058A71C0b5211BC] = TOKEN_FOR_INDIVIDUAL * 10 ** uint256(decimals) * 2 / 100;
| 16,926 |
23 | // Modifier to check if the caller is the owner of the nftAddress | modifier onlyNFTOwner(address nftAddress) {
ICaptrizERC1155 nftContract = ICaptrizERC1155(nftAddress);
require(
nftContract.owner() == msg.sender,
"Not the owner of this NFT address"
);
_;
}
| modifier onlyNFTOwner(address nftAddress) {
ICaptrizERC1155 nftContract = ICaptrizERC1155(nftAddress);
require(
nftContract.owner() == msg.sender,
"Not the owner of this NFT address"
);
_;
}
| 20,170 |
156 | // GET - The address of the Smart Contract whose code will serve as a model for all the Native EthItems.Every EthItem will have its own address, but the code will be cloned from this one. / | function nativeModel() external view returns (address nativeModelAddress, uint256 nativeModelVersion);
| function nativeModel() external view returns (address nativeModelAddress, uint256 nativeModelVersion);
| 18,613 |
0 | // Interface declaration from: https:github.com/ethereum/eips/issues/20 | contract ERC20Interface {
//from: https://github.com/OpenZeppelin/zeppelin-solidity/blob/b395b06b65ce35cac155c13d01ab3fc9d42c5cfb/contracts/token/ERC20Basic.sol
uint256 public totalSupply; //tokens that can vote, transfer, receive dividend
function balanceOf(address who) public constant returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
//from: https://github.com/OpenZeppelin/zeppelin-solidity/blob/b395b06b65ce35cac155c13d01ab3fc9d42c5cfb/contracts/token/ERC20.sol
function allowance(address owner, address spender) public constant returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| contract ERC20Interface {
//from: https://github.com/OpenZeppelin/zeppelin-solidity/blob/b395b06b65ce35cac155c13d01ab3fc9d42c5cfb/contracts/token/ERC20Basic.sol
uint256 public totalSupply; //tokens that can vote, transfer, receive dividend
function balanceOf(address who) public constant returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
//from: https://github.com/OpenZeppelin/zeppelin-solidity/blob/b395b06b65ce35cac155c13d01ab3fc9d42c5cfb/contracts/token/ERC20.sol
function allowance(address owner, address spender) public constant returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 8,369 |
4 | // Numerical approximation of the tangent function,using the fact that sin(x)/cos(x) = tan(x). theta: angle in radians digits: digits of precision of the anglereturn tan(x) Example input:tan(11,1) => tan(1.1) tan(3,0) => tan(3) / | function tan(int256 theta, uint8 digits) public pure returns(int256) {
return (FixidityLib.divide(sin(theta, digits), cos(theta, digits)));
/** Taylor series approximation of tan(x), but is poor near asymptotes.
*
int256 x = FixidityLib.newFixed(theta, digits);
int256 _2pi = FixidityLib.multiply(FixidityLib.newFixed(2),pi());
int256 _3_2pi = FixidityLib.multiply(pi(), FixidityLib.newFixedFraction(3, 2));
x = normAngle(x);
int256 temp = FixidityLib.abs(FixidityLib.subtract(x, pi()));
int8 c = 1;
if (FixidityLib.subtract(x, pi()) < 0 && FixidityLib.subtract(x, FixidityLib.divide(pi(), FixidityLib.newFixed(2))) > 0) { // > 90 deg and < 180 deg
x = temp;
c = -1;
} else if (FixidityLib.subtract(x, pi()) > 0 && FixidityLib.subtract(x, _3_2pi) < 0) { // > 180 deg and < 270 deg
x = FixidityLib.subtract(temp, FixidityLib.multiply(temp, FixidityLib.newFixed(2)));
} else if(FixidityLib.subtract(x, _3_2pi) > 0) { // > 270 deg and < 360 deg
x = FixidityLib.subtract(x, _2pi);
c = -1;
}
int256 x_3 = FixidityLib.multiply(FixidityLib.multiply(x, x), x);
int256 x_5 = FixidityLib.multiply(FixidityLib.multiply(x_3, x), x);
int256 a = FixidityLib.add(x, FixidityLib.divide(x_3, FixidityLib.newFixed(3)));
int256 b = FixidityLib.add(a, FixidityLib.multiply(x_5, FixidityLib.newFixedFraction(2, 15)));
return b*c;
*/
}
| function tan(int256 theta, uint8 digits) public pure returns(int256) {
return (FixidityLib.divide(sin(theta, digits), cos(theta, digits)));
/** Taylor series approximation of tan(x), but is poor near asymptotes.
*
int256 x = FixidityLib.newFixed(theta, digits);
int256 _2pi = FixidityLib.multiply(FixidityLib.newFixed(2),pi());
int256 _3_2pi = FixidityLib.multiply(pi(), FixidityLib.newFixedFraction(3, 2));
x = normAngle(x);
int256 temp = FixidityLib.abs(FixidityLib.subtract(x, pi()));
int8 c = 1;
if (FixidityLib.subtract(x, pi()) < 0 && FixidityLib.subtract(x, FixidityLib.divide(pi(), FixidityLib.newFixed(2))) > 0) { // > 90 deg and < 180 deg
x = temp;
c = -1;
} else if (FixidityLib.subtract(x, pi()) > 0 && FixidityLib.subtract(x, _3_2pi) < 0) { // > 180 deg and < 270 deg
x = FixidityLib.subtract(temp, FixidityLib.multiply(temp, FixidityLib.newFixed(2)));
} else if(FixidityLib.subtract(x, _3_2pi) > 0) { // > 270 deg and < 360 deg
x = FixidityLib.subtract(x, _2pi);
c = -1;
}
int256 x_3 = FixidityLib.multiply(FixidityLib.multiply(x, x), x);
int256 x_5 = FixidityLib.multiply(FixidityLib.multiply(x_3, x), x);
int256 a = FixidityLib.add(x, FixidityLib.divide(x_3, FixidityLib.newFixed(3)));
int256 b = FixidityLib.add(a, FixidityLib.multiply(x_5, FixidityLib.newFixedFraction(2, 15)));
return b*c;
*/
}
| 32,787 |
68 | // Check initialize parameters | if (
initializePackedParameters.pendingStateTimeout >
_HALT_AGGREGATION_TIMEOUT
) {
revert PendingStateTimeoutExceedHaltAggregationTimeout();
}
| if (
initializePackedParameters.pendingStateTimeout >
_HALT_AGGREGATION_TIMEOUT
) {
revert PendingStateTimeoutExceedHaltAggregationTimeout();
}
| 6,221 |
337 | // config event mint parameters. | function setMintEventConfig( uint256 _eventID, address _mintFeeToken, uint256 _mintFeeAmount, uint256 _mintMaxCount, uint256 _mintTimeStart,uint256 _mintTimeEnd, uint256 _oneTimeMaxCount,
| function setMintEventConfig( uint256 _eventID, address _mintFeeToken, uint256 _mintFeeAmount, uint256 _mintMaxCount, uint256 _mintTimeStart,uint256 _mintTimeEnd, uint256 _oneTimeMaxCount,
| 18,199 |
314 | // return l2Block return L2 block when the L2 tx was initiated or 0 if no L2 to L1 transaction is active | function l2ToL1Block() external view returns (uint256);
| function l2ToL1Block() external view returns (uint256);
| 11,419 |
9 | // Ensures the caller is authorized to upgrade the contract/This function is called in `upgradeTo` & `upgradeToAndCall`/_newImpl The new implementation address | function _authorizeUpgrade(address _newImpl) internal override onlyOwner {}
}
| function _authorizeUpgrade(address _newImpl) internal override onlyOwner {}
}
| 4,624 |
98 | // address(this),adds no entropy | blockhash(blockn),
entropy)
));
| blockhash(blockn),
entropy)
));
| 29,010 |
2 | // emitted every time a user is added to the leaderboard | event LogAddToLeaderboard(address _user, address _market, uint256 _card);
| event LogAddToLeaderboard(address _user, address _market, uint256 _card);
| 28,318 |
33 | // AllowanceTarget contract / | contract AllowanceTarget is IAllowanceTarget {
using Address for address;
uint256 constant private TIME_LOCK_DURATION = 1 days;
address public spender;
address public newSpender;
uint256 public timelockExpirationTime;
modifier onlySpender() {
require(spender == msg.sender, "AllowanceTarget: not the spender");
_;
}
constructor(address _spender) public {
require(_spender != address(0), "AllowanceTarget: _spender should not be 0");
// Set spender
spender = _spender;
}
function setSpenderWithTimelock(address _newSpender) override external onlySpender {
require(_newSpender.isContract(), "AllowanceTarget: new spender not a contract");
require(newSpender == address(0) && timelockExpirationTime == 0, "AllowanceTarget: SetSpender in progress");
timelockExpirationTime = now + TIME_LOCK_DURATION;
newSpender = _newSpender;
}
function completeSetSpender() override external {
require(timelockExpirationTime != 0, "AllowanceTarget: no pending SetSpender");
require(now >= timelockExpirationTime, "AllowanceTarget: time lock not expired yet");
// Set new spender
spender = newSpender;
// Reset
timelockExpirationTime = 0;
newSpender = address(0);
}
function teardown() override external onlySpender {
selfdestruct(payable(spender));
}
/// @dev Execute an arbitrary call. Only an authority can call this.
/// @param target The call target.
/// @param callData The call data.
/// @return resultData The data returned by the call.
function executeCall(
address payable target,
bytes calldata callData
)
override
external
onlySpender
returns (bytes memory resultData)
{
bool success;
(success, resultData) = target.call(callData);
if (!success) {
// Get the error message returned
assembly {
let ptr := mload(0x40)
let size := returndatasize()
returndatacopy(ptr, 0, size)
revert(ptr, size)
}
}
}
} | contract AllowanceTarget is IAllowanceTarget {
using Address for address;
uint256 constant private TIME_LOCK_DURATION = 1 days;
address public spender;
address public newSpender;
uint256 public timelockExpirationTime;
modifier onlySpender() {
require(spender == msg.sender, "AllowanceTarget: not the spender");
_;
}
constructor(address _spender) public {
require(_spender != address(0), "AllowanceTarget: _spender should not be 0");
// Set spender
spender = _spender;
}
function setSpenderWithTimelock(address _newSpender) override external onlySpender {
require(_newSpender.isContract(), "AllowanceTarget: new spender not a contract");
require(newSpender == address(0) && timelockExpirationTime == 0, "AllowanceTarget: SetSpender in progress");
timelockExpirationTime = now + TIME_LOCK_DURATION;
newSpender = _newSpender;
}
function completeSetSpender() override external {
require(timelockExpirationTime != 0, "AllowanceTarget: no pending SetSpender");
require(now >= timelockExpirationTime, "AllowanceTarget: time lock not expired yet");
// Set new spender
spender = newSpender;
// Reset
timelockExpirationTime = 0;
newSpender = address(0);
}
function teardown() override external onlySpender {
selfdestruct(payable(spender));
}
/// @dev Execute an arbitrary call. Only an authority can call this.
/// @param target The call target.
/// @param callData The call data.
/// @return resultData The data returned by the call.
function executeCall(
address payable target,
bytes calldata callData
)
override
external
onlySpender
returns (bytes memory resultData)
{
bool success;
(success, resultData) = target.call(callData);
if (!success) {
// Get the error message returned
assembly {
let ptr := mload(0x40)
let size := returndatasize()
returndatacopy(ptr, 0, size)
revert(ptr, size)
}
}
}
} | 26,388 |
2 | // working day shift feature, to make YMD shifted of block.timestamp cases:Paris local time from block.timestamp (GMT) + 1 hourlocalShift = truepositiveShift = 16060 NewYork local time from block.timestamp (GMT) - 5 hourlocalShift = falsepositiveShift = 56060 Tokyo local time from block.timestamp (GMT) + 9 hourlocalShift = truepositiveShift = 96060 / | bool public positiveShift;
uint256 public localShift;
| bool public positiveShift;
uint256 public localShift;
| 17,728 |
71 | // Get pool total supply | uint256 poolTotalSupply = pool.totalSupply();
| uint256 poolTotalSupply = pool.totalSupply();
| 24,801 |
26 | // existing token address | address public tokenAddress;
| address public tokenAddress;
| 81,001 |
291 | // https:docs.pynthetix.io/contracts/source/contracts/pynthetix | contract Perifi is BasePynthetix {
// ========== CONSTRUCTOR ==========
constructor(
address payable _proxy,
TokenState _tokenState,
address _owner,
uint _totalSupply,
address _resolver
) public BasePynthetix(_proxy, _tokenState, _owner, _totalSupply, _resolver) {}
// ========== OVERRIDDEN FUNCTIONS ==========
function exchange(
bytes32 sourceCurrencyKey,
uint sourceAmount,
bytes32 destinationCurrencyKey
) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived) {
return exchanger().exchange(messageSender, sourceCurrencyKey, sourceAmount, destinationCurrencyKey, messageSender);
}
function exchangeOnBehalf(
address exchangeForAddress,
bytes32 sourceCurrencyKey,
uint sourceAmount,
bytes32 destinationCurrencyKey
) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived) {
return
exchanger().exchangeOnBehalf(
exchangeForAddress,
messageSender,
sourceCurrencyKey,
sourceAmount,
destinationCurrencyKey
);
}
function exchangeWithTracking(
bytes32 sourceCurrencyKey,
uint sourceAmount,
bytes32 destinationCurrencyKey,
address originator,
bytes32 trackingCode
) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived) {
return
exchanger().exchangeWithTracking(
messageSender,
sourceCurrencyKey,
sourceAmount,
destinationCurrencyKey,
messageSender,
originator,
trackingCode
);
}
function exchangeOnBehalfWithTracking(
address exchangeForAddress,
bytes32 sourceCurrencyKey,
uint sourceAmount,
bytes32 destinationCurrencyKey,
address originator,
bytes32 trackingCode
) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived) {
return
exchanger().exchangeOnBehalfWithTracking(
exchangeForAddress,
messageSender,
sourceCurrencyKey,
sourceAmount,
destinationCurrencyKey,
originator,
trackingCode
);
}
function exchangeWithVirtual(
bytes32 sourceCurrencyKey,
uint sourceAmount,
bytes32 destinationCurrencyKey,
bytes32 trackingCode
)
external
exchangeActive(sourceCurrencyKey, destinationCurrencyKey)
optionalProxy
returns (uint amountReceived, IVirtualPynth vPynth)
{
return
exchanger().exchangeWithVirtual(
messageSender,
sourceCurrencyKey,
sourceAmount,
destinationCurrencyKey,
messageSender,
trackingCode
);
}
function settle(bytes32 currencyKey)
external
optionalProxy
returns (
uint reclaimed,
uint refunded,
uint numEntriesSettled
)
{
return exchanger().settle(messageSender, currencyKey);
}
function mint() external issuanceActive returns (bool) {
require(address(rewardsDistribution()) != address(0), "RewardsDistribution not set");
SupplySchedule _supplySchedule = supplySchedule();
IRewardsDistribution _rewardsDistribution = rewardsDistribution();
uint supplyToMint = _supplySchedule.mintableSupply();
require(supplyToMint > 0, "No supply is mintable");
// record minting event before mutation to token supply
_supplySchedule.recordMintEvent(supplyToMint);
// Set minted PERI balance to RewardEscrow's balance
// Minus the minterReward and set balance of minter to add reward
uint minterReward = _supplySchedule.minterReward();
// Get the remainder
uint amountToDistribute = supplyToMint.sub(minterReward);
// Set the token balance to the RewardsDistribution contract
tokenState.setBalanceOf(
address(_rewardsDistribution),
tokenState.balanceOf(address(_rewardsDistribution)).add(amountToDistribute)
);
emitTransfer(address(this), address(_rewardsDistribution), amountToDistribute);
// Kick off the distribution of rewards
_rewardsDistribution.distributeRewards(amountToDistribute);
// Assign the minters reward.
tokenState.setBalanceOf(msg.sender, tokenState.balanceOf(msg.sender).add(minterReward));
emitTransfer(address(this), msg.sender, minterReward);
totalSupply = totalSupply.add(supplyToMint);
return true;
}
function liquidateDelinquentAccount(address account, uint susdAmount)
external
systemActive
optionalProxy
returns (bool)
{
(uint totalRedeemed, uint amountLiquidated) = issuer().liquidateDelinquentAccount(
account,
susdAmount,
messageSender
);
emitAccountLiquidated(account, totalRedeemed, amountLiquidated, messageSender);
// Transfer PERI redeemed to messageSender
// Reverts if amount to redeem is more than balanceOf account, ie due to escrowed balance
return _transferByProxy(account, messageSender, totalRedeemed);
}
// ========== EVENTS ==========
event PynthExchange(
address indexed account,
bytes32 fromCurrencyKey,
uint256 fromAmount,
bytes32 toCurrencyKey,
uint256 toAmount,
address toAddress
);
bytes32 internal constant SYNTHEXCHANGE_SIG = keccak256(
"PynthExchange(address,bytes32,uint256,bytes32,uint256,address)"
);
function emitPynthExchange(
address account,
bytes32 fromCurrencyKey,
uint256 fromAmount,
bytes32 toCurrencyKey,
uint256 toAmount,
address toAddress
) external onlyExchanger {
proxy._emit(
abi.encode(fromCurrencyKey, fromAmount, toCurrencyKey, toAmount, toAddress),
2,
SYNTHEXCHANGE_SIG,
addressToBytes32(account),
0,
0
);
}
event ExchangeTracking(bytes32 indexed trackingCode, bytes32 toCurrencyKey, uint256 toAmount);
bytes32 internal constant EXCHANGE_TRACKING_SIG = keccak256("ExchangeTracking(bytes32,bytes32,uint256)");
function emitExchangeTracking(
bytes32 trackingCode,
bytes32 toCurrencyKey,
uint256 toAmount
) external onlyExchanger {
proxy._emit(abi.encode(toCurrencyKey, toAmount), 2, EXCHANGE_TRACKING_SIG, trackingCode, 0, 0);
}
event ExchangeReclaim(address indexed account, bytes32 currencyKey, uint amount);
bytes32 internal constant EXCHANGERECLAIM_SIG = keccak256("ExchangeReclaim(address,bytes32,uint256)");
function emitExchangeReclaim(
address account,
bytes32 currencyKey,
uint256 amount
) external onlyExchanger {
proxy._emit(abi.encode(currencyKey, amount), 2, EXCHANGERECLAIM_SIG, addressToBytes32(account), 0, 0);
}
event ExchangeRebate(address indexed account, bytes32 currencyKey, uint amount);
bytes32 internal constant EXCHANGEREBATE_SIG = keccak256("ExchangeRebate(address,bytes32,uint256)");
function emitExchangeRebate(
address account,
bytes32 currencyKey,
uint256 amount
) external onlyExchanger {
proxy._emit(abi.encode(currencyKey, amount), 2, EXCHANGEREBATE_SIG, addressToBytes32(account), 0, 0);
}
event AccountLiquidated(address indexed account, uint periRedeemed, uint amountLiquidated, address liquidator);
bytes32 internal constant ACCOUNTLIQUIDATED_SIG = keccak256("AccountLiquidated(address,uint256,uint256,address)");
function emitAccountLiquidated(
address account,
uint256 periRedeemed,
uint256 amountLiquidated,
address liquidator
) internal {
proxy._emit(
abi.encode(periRedeemed, amountLiquidated, liquidator),
2,
ACCOUNTLIQUIDATED_SIG,
addressToBytes32(account),
0,
0
);
}
}
| contract Perifi is BasePynthetix {
// ========== CONSTRUCTOR ==========
constructor(
address payable _proxy,
TokenState _tokenState,
address _owner,
uint _totalSupply,
address _resolver
) public BasePynthetix(_proxy, _tokenState, _owner, _totalSupply, _resolver) {}
// ========== OVERRIDDEN FUNCTIONS ==========
function exchange(
bytes32 sourceCurrencyKey,
uint sourceAmount,
bytes32 destinationCurrencyKey
) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived) {
return exchanger().exchange(messageSender, sourceCurrencyKey, sourceAmount, destinationCurrencyKey, messageSender);
}
function exchangeOnBehalf(
address exchangeForAddress,
bytes32 sourceCurrencyKey,
uint sourceAmount,
bytes32 destinationCurrencyKey
) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived) {
return
exchanger().exchangeOnBehalf(
exchangeForAddress,
messageSender,
sourceCurrencyKey,
sourceAmount,
destinationCurrencyKey
);
}
function exchangeWithTracking(
bytes32 sourceCurrencyKey,
uint sourceAmount,
bytes32 destinationCurrencyKey,
address originator,
bytes32 trackingCode
) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived) {
return
exchanger().exchangeWithTracking(
messageSender,
sourceCurrencyKey,
sourceAmount,
destinationCurrencyKey,
messageSender,
originator,
trackingCode
);
}
function exchangeOnBehalfWithTracking(
address exchangeForAddress,
bytes32 sourceCurrencyKey,
uint sourceAmount,
bytes32 destinationCurrencyKey,
address originator,
bytes32 trackingCode
) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived) {
return
exchanger().exchangeOnBehalfWithTracking(
exchangeForAddress,
messageSender,
sourceCurrencyKey,
sourceAmount,
destinationCurrencyKey,
originator,
trackingCode
);
}
function exchangeWithVirtual(
bytes32 sourceCurrencyKey,
uint sourceAmount,
bytes32 destinationCurrencyKey,
bytes32 trackingCode
)
external
exchangeActive(sourceCurrencyKey, destinationCurrencyKey)
optionalProxy
returns (uint amountReceived, IVirtualPynth vPynth)
{
return
exchanger().exchangeWithVirtual(
messageSender,
sourceCurrencyKey,
sourceAmount,
destinationCurrencyKey,
messageSender,
trackingCode
);
}
function settle(bytes32 currencyKey)
external
optionalProxy
returns (
uint reclaimed,
uint refunded,
uint numEntriesSettled
)
{
return exchanger().settle(messageSender, currencyKey);
}
function mint() external issuanceActive returns (bool) {
require(address(rewardsDistribution()) != address(0), "RewardsDistribution not set");
SupplySchedule _supplySchedule = supplySchedule();
IRewardsDistribution _rewardsDistribution = rewardsDistribution();
uint supplyToMint = _supplySchedule.mintableSupply();
require(supplyToMint > 0, "No supply is mintable");
// record minting event before mutation to token supply
_supplySchedule.recordMintEvent(supplyToMint);
// Set minted PERI balance to RewardEscrow's balance
// Minus the minterReward and set balance of minter to add reward
uint minterReward = _supplySchedule.minterReward();
// Get the remainder
uint amountToDistribute = supplyToMint.sub(minterReward);
// Set the token balance to the RewardsDistribution contract
tokenState.setBalanceOf(
address(_rewardsDistribution),
tokenState.balanceOf(address(_rewardsDistribution)).add(amountToDistribute)
);
emitTransfer(address(this), address(_rewardsDistribution), amountToDistribute);
// Kick off the distribution of rewards
_rewardsDistribution.distributeRewards(amountToDistribute);
// Assign the minters reward.
tokenState.setBalanceOf(msg.sender, tokenState.balanceOf(msg.sender).add(minterReward));
emitTransfer(address(this), msg.sender, minterReward);
totalSupply = totalSupply.add(supplyToMint);
return true;
}
function liquidateDelinquentAccount(address account, uint susdAmount)
external
systemActive
optionalProxy
returns (bool)
{
(uint totalRedeemed, uint amountLiquidated) = issuer().liquidateDelinquentAccount(
account,
susdAmount,
messageSender
);
emitAccountLiquidated(account, totalRedeemed, amountLiquidated, messageSender);
// Transfer PERI redeemed to messageSender
// Reverts if amount to redeem is more than balanceOf account, ie due to escrowed balance
return _transferByProxy(account, messageSender, totalRedeemed);
}
// ========== EVENTS ==========
event PynthExchange(
address indexed account,
bytes32 fromCurrencyKey,
uint256 fromAmount,
bytes32 toCurrencyKey,
uint256 toAmount,
address toAddress
);
bytes32 internal constant SYNTHEXCHANGE_SIG = keccak256(
"PynthExchange(address,bytes32,uint256,bytes32,uint256,address)"
);
function emitPynthExchange(
address account,
bytes32 fromCurrencyKey,
uint256 fromAmount,
bytes32 toCurrencyKey,
uint256 toAmount,
address toAddress
) external onlyExchanger {
proxy._emit(
abi.encode(fromCurrencyKey, fromAmount, toCurrencyKey, toAmount, toAddress),
2,
SYNTHEXCHANGE_SIG,
addressToBytes32(account),
0,
0
);
}
event ExchangeTracking(bytes32 indexed trackingCode, bytes32 toCurrencyKey, uint256 toAmount);
bytes32 internal constant EXCHANGE_TRACKING_SIG = keccak256("ExchangeTracking(bytes32,bytes32,uint256)");
function emitExchangeTracking(
bytes32 trackingCode,
bytes32 toCurrencyKey,
uint256 toAmount
) external onlyExchanger {
proxy._emit(abi.encode(toCurrencyKey, toAmount), 2, EXCHANGE_TRACKING_SIG, trackingCode, 0, 0);
}
event ExchangeReclaim(address indexed account, bytes32 currencyKey, uint amount);
bytes32 internal constant EXCHANGERECLAIM_SIG = keccak256("ExchangeReclaim(address,bytes32,uint256)");
function emitExchangeReclaim(
address account,
bytes32 currencyKey,
uint256 amount
) external onlyExchanger {
proxy._emit(abi.encode(currencyKey, amount), 2, EXCHANGERECLAIM_SIG, addressToBytes32(account), 0, 0);
}
event ExchangeRebate(address indexed account, bytes32 currencyKey, uint amount);
bytes32 internal constant EXCHANGEREBATE_SIG = keccak256("ExchangeRebate(address,bytes32,uint256)");
function emitExchangeRebate(
address account,
bytes32 currencyKey,
uint256 amount
) external onlyExchanger {
proxy._emit(abi.encode(currencyKey, amount), 2, EXCHANGEREBATE_SIG, addressToBytes32(account), 0, 0);
}
event AccountLiquidated(address indexed account, uint periRedeemed, uint amountLiquidated, address liquidator);
bytes32 internal constant ACCOUNTLIQUIDATED_SIG = keccak256("AccountLiquidated(address,uint256,uint256,address)");
function emitAccountLiquidated(
address account,
uint256 periRedeemed,
uint256 amountLiquidated,
address liquidator
) internal {
proxy._emit(
abi.encode(periRedeemed, amountLiquidated, liquidator),
2,
ACCOUNTLIQUIDATED_SIG,
addressToBytes32(account),
0,
0
);
}
}
| 1,752 |
14 | // OnlyOnTime only if the call of the function is within the auction time, the transaction will be executed | modifier OnlyOnTime(string memory name) {
require(now < NameToOwner[name].TimeLimit, "The auction has finished.");
_;
}
| modifier OnlyOnTime(string memory name) {
require(now < NameToOwner[name].TimeLimit, "The auction has finished.");
_;
}
| 16,304 |
6 | // returns the number of settleable invocations for project `_projectId`. | function getNumSettleableInvocations(
uint256 _projectId
) external view returns (uint256 numSettleableInvocations);
| function getNumSettleableInvocations(
uint256 _projectId
) external view returns (uint256 numSettleableInvocations);
| 37,874 |
0 | // constants | uint256 public constant FULL_VESTING = 1e18;
| uint256 public constant FULL_VESTING = 1e18;
| 19,217 |
63 | // Returns the substraction of two unsigned integers, with an overflow flag. _Available since v3.4._/ | function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
| function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
| 24,494 |
11 | // Computes the token0 and token1 value for a given amount of liquidity, the current/ pool prices and the prices at the tick boundaries/sqrtRatioX96 A sqrt price representing the current pool prices/sqrtRatioAX96 A sqrt price representing the first tick boundary/sqrtRatioBX96 A sqrt price representing the second tick boundary/liquidity The liquidity being valued/ return amount0 The amount of token0/ return amount1 The amount of token1 | function getAmountsForLiquidity(
uint160 sqrtRatioX96,
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint128 liquidity
| function getAmountsForLiquidity(
uint160 sqrtRatioX96,
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint128 liquidity
| 14,957 |
1 | // Event for tracking updated maintainer fee.maintainerFee - new maintainer fee./ | event MaintainerFeeUpdated(uint256 maintainerFee);
| event MaintainerFeeUpdated(uint256 maintainerFee);
| 16,091 |
87 | // ---------- INTERNAL FUNCTIONS ---------- / | {
require(
_msgSender() != address(0),
"caller is the zero address"
);
require(_weiAmount != 0, "weiAmount is 0");
require(
block.timestamp >= startDate && block.timestamp <= endDate,
"sale period is ended"
);
if (_buyType == BuyType.USDT) {
usdt.transferFrom(_msgSender(), address(this), _weiAmount);
}
// calculate token amount to be created
uint256 tokens = _getTokenAmount(_weiAmount, _buyType);
// update state
weiRaised = weiRaised + _weiAmount;
// deliverTokens
token.safeTransfer(_msgSender(), tokens);
emit TokensPurchased(_msgSender(), _weiAmount, tokens);
_forwardFunds(_weiAmount, _buyType);
}
| {
require(
_msgSender() != address(0),
"caller is the zero address"
);
require(_weiAmount != 0, "weiAmount is 0");
require(
block.timestamp >= startDate && block.timestamp <= endDate,
"sale period is ended"
);
if (_buyType == BuyType.USDT) {
usdt.transferFrom(_msgSender(), address(this), _weiAmount);
}
// calculate token amount to be created
uint256 tokens = _getTokenAmount(_weiAmount, _buyType);
// update state
weiRaised = weiRaised + _weiAmount;
// deliverTokens
token.safeTransfer(_msgSender(), tokens);
emit TokensPurchased(_msgSender(), _weiAmount, tokens);
_forwardFunds(_weiAmount, _buyType);
}
| 10,139 |
2 | // Must be a positive supply of the Set | require(
totalSupply() > 0,
"Invalid supply"
);
| require(
totalSupply() > 0,
"Invalid supply"
);
| 51,218 |
2 | // uint256[] memory items; |
for (uint256 i = 0; i < players.length; i++) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(players[i], newItemId);
_setTokenURI(newItemId, tokenURI);
|
for (uint256 i = 0; i < players.length; i++) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(players[i], newItemId);
_setTokenURI(newItemId, tokenURI);
| 2,263 |
16 | // Custom Transaction Context/ See more: https:remix-ide.readthedocs.io/en/latest/unittesting.htmlcustomization/ sender: account-0/ value: 1375748393000 | function checkBasicTransactionSafemoonStyle() public {
uint256 transferAmount = 1375748393000;
uint256 originalBalance0 = balanceOf(TestsAccounts.getAccount(0));
uint256 originalBalance1 = balanceOf(TestsAccounts.getAccount(1));
transferTaxFree(TestsAccounts.getAccount(1),transferAmount);
uint256 afterBalance0 = balanceOf(TestsAccounts.getAccount(0));
uint256 afterBalance1 = balanceOf(TestsAccounts.getAccount(1));
// Account-0 has the right balance?
Assert.equal(afterBalance0 , originalBalance0 - transferAmount, "these should be equal for first account");
// Account-1 has the right balance?
Assert.equal(afterBalance1 , originalBalance1 + transferAmount, "these should be equal for second account");
//Assert.equal(balanceOf(DAO_address), uint256(45000000000000000), "total should equal 45000000000000000 passed to constructor");
}
| function checkBasicTransactionSafemoonStyle() public {
uint256 transferAmount = 1375748393000;
uint256 originalBalance0 = balanceOf(TestsAccounts.getAccount(0));
uint256 originalBalance1 = balanceOf(TestsAccounts.getAccount(1));
transferTaxFree(TestsAccounts.getAccount(1),transferAmount);
uint256 afterBalance0 = balanceOf(TestsAccounts.getAccount(0));
uint256 afterBalance1 = balanceOf(TestsAccounts.getAccount(1));
// Account-0 has the right balance?
Assert.equal(afterBalance0 , originalBalance0 - transferAmount, "these should be equal for first account");
// Account-1 has the right balance?
Assert.equal(afterBalance1 , originalBalance1 + transferAmount, "these should be equal for second account");
//Assert.equal(balanceOf(DAO_address), uint256(45000000000000000), "total should equal 45000000000000000 passed to constructor");
}
| 50,888 |
36 | // Set Recommend Lock position Reward and unlock rate RecomReward Recommend Lock position Reward rate RecomReward Recommend Lock position unlock rate / | function setRecommendReward(uint RecomReward,uint RecomUnlock)public
onlyOwner
RateLimit(RecomReward)
RateLimit(RecomUnlock)
| function setRecommendReward(uint RecomReward,uint RecomUnlock)public
onlyOwner
RateLimit(RecomReward)
RateLimit(RecomUnlock)
| 46,651 |
2 | // Returns the SECP256k1 public key associated with an ENS node.Defined in EIP 619. node The ENS node to queryreturn x The X coordinate of the curve point for the public key.return y The Y coordinate of the curve point for the public key. / | function pubkey(bytes32 node) virtual override external view returns (bytes32 x, bytes32 y) {
return (pubkeys[node].x, pubkeys[node].y);
}
| function pubkey(bytes32 node) virtual override external view returns (bytes32 x, bytes32 y) {
return (pubkeys[node].x, pubkeys[node].y);
}
| 6,728 |
74 | // If the delegator orders their entire stake, remove the delegator from delegator list of the pool | _removePoolDelegator(_poolStakingAddress, staker);
| _removePoolDelegator(_poolStakingAddress, staker);
| 25,615 |
3 | // Emitted when the implementation returned by the beacon is changed.implementation address / | event Upgraded(address indexed implementation);
uint256 public nonce;
| event Upgraded(address indexed implementation);
uint256 public nonce;
| 42,360 |
8 | // Getter for the amount of Ether already released to a payee. / | function released(address account) public view returns (uint256) {
return _released[account];
}
| function released(address account) public view returns (uint256) {
return _released[account];
}
| 23,185 |
819 | // Reads the uint40 at `mPtr` in memory. | function readUint40(MemoryPointer mPtr) internal pure returns (uint40 value) {
assembly {
value := mload(mPtr)
}
}
| function readUint40(MemoryPointer mPtr) internal pure returns (uint40 value) {
assembly {
value := mload(mPtr)
}
}
| 23,752 |
5 | // Make a forked token to dispute a claim. This avoid creating a token all the time, since most milestones should not be disputed._milestoneID The ID of the milestone. / | function makeVoteToken(uint _milestoneID) public {
Milestone storage milestone=milestones[_milestoneID];
if( ousterID != _milestoneID ) { require(milestone.claimTime!=0); } // The milestone is currently claimed by the team, unless this is the ouster.
require(address(milestone.voteToken)==0x0); // Token has not already been made.
milestone.voteToken=MiniMeToken(token.createCloneToken(
"",
token.decimals(),
"",
block.number,
true
));
}
| function makeVoteToken(uint _milestoneID) public {
Milestone storage milestone=milestones[_milestoneID];
if( ousterID != _milestoneID ) { require(milestone.claimTime!=0); } // The milestone is currently claimed by the team, unless this is the ouster.
require(address(milestone.voteToken)==0x0); // Token has not already been made.
milestone.voteToken=MiniMeToken(token.createCloneToken(
"",
token.decimals(),
"",
block.number,
true
));
}
| 39,883 |
244 | // reverts if the caller does not have access / | modifier checkAccess() {
require(hasAccess(msg.sender, msg.data), "No access");
_;
}
| modifier checkAccess() {
require(hasAccess(msg.sender, msg.data), "No access");
_;
}
| 44,748 |
30 | // check that the value sent with the function is at least the token price | require(msg.value >= tokenPrices[tokenId] + fee, string(abi.encodePacked("Payment is not enough. Don't forget the fee which is of 10% of the sale price")));
| require(msg.value >= tokenPrices[tokenId] + fee, string(abi.encodePacked("Payment is not enough. Don't forget the fee which is of 10% of the sale price")));
| 20,509 |
1 | // Minting constants | uint256 public maxMintPerTransaction;
uint256 public MINT_SUPPLY_PER_FACTION;
uint256 public TEAM_SUPPLY_PER_FACTION;
| uint256 public maxMintPerTransaction;
uint256 public MINT_SUPPLY_PER_FACTION;
uint256 public TEAM_SUPPLY_PER_FACTION;
| 27,153 |
47 | // модификатор onlyOwnerOf гарантирует, что owner = msg.senderaddress owner = ownerOf(_unicornId); | require(_to != msg.sender);
if (approvedFor(_unicornId) != address(0) || _to != address(0)) {
unicornApprovals[_unicornId] = _to;
emit Approval(msg.sender, _to, _unicornId);
}
| require(_to != msg.sender);
if (approvedFor(_unicornId) != address(0) || _to != address(0)) {
unicornApprovals[_unicornId] = _to;
emit Approval(msg.sender, _to, _unicornId);
}
| 28,116 |
9 | // Add battle request | BattleRequest memory newRequest;
newRequest.pepeId = _pepeId;
newRequest.amount = _amount;
newRequest.player = msg.sender;
battleRequests.push(newRequest);
emit StakedForBattle(_pepeId, _amount, msg.sender);
| BattleRequest memory newRequest;
newRequest.pepeId = _pepeId;
newRequest.amount = _amount;
newRequest.player = msg.sender;
battleRequests.push(newRequest);
emit StakedForBattle(_pepeId, _amount, msg.sender);
| 19,766 |
43 | // Holders can redeem their tokens to claim the project's overflowed tokens, or to trigger rules determined by the project's current funding cycle's data source./Only a token holder or a designated operator can redeem its tokens./_holder The account to redeem tokens for./_projectId The ID of the project to which the tokens being redeemed belong./_tokenCount The number of project tokens to redeem, as a fixed point number with 18 decimals./_token The token being reclaimed. This terminal ignores this property since it only manages one token./_minReturnedTokens The minimum amount of terminal tokens expected in return, as a fixed point number with the same | function redeemTokensOf(
address _holder,
uint256 _projectId,
uint256 _tokenCount,
address _token,
uint256 _minReturnedTokens,
address payable _beneficiary,
string memory _memo,
bytes memory _metadata
)
| function redeemTokensOf(
address _holder,
uint256 _projectId,
uint256 _tokenCount,
address _token,
uint256 _minReturnedTokens,
address payable _beneficiary,
string memory _memo,
bytes memory _metadata
)
| 30,169 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.