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 |
|---|---|---|---|---|
1 | // Scale factor of the fixed curve. | uint256 public immutable fixedCurveA;
| uint256 public immutable fixedCurveA;
| 24,279 |
21 | // Sets state variable that tells contract if it can send data to EventProxy/eventSendSet Bool to set state variable to | function setEventSend(bool eventSendSet) external;
| function setEventSend(bool eventSendSet) external;
| 8,251 |
5 | // Deposits tokens in proportion to the Unipilot's current holdings & mints them/ `Unipilot`s LP token./amount0Desired Max amount of token0 to deposit/amount1Desired Max amount of token1 to deposit/recipient Recipient of shares/ return lpShares Number of shares minted/ return amount0 Amount of token0 deposited in vault/ return amount1 Amount of token1 deposited in vault | function deposit(
uint256 amount0Desired,
uint256 amount1Desired,
address recipient
)
external
payable
returns (
uint256 lpShares,
uint256 amount0,
| function deposit(
uint256 amount0Desired,
uint256 amount1Desired,
address recipient
)
external
payable
returns (
uint256 lpShares,
uint256 amount0,
| 27,263 |
68 | // Bad interface | require(upgradeAgent.isUpgradeAgent());
| require(upgradeAgent.isUpgradeAgent());
| 22,747 |
663 | // Check the exchange rate without any state changes/ @inheritdoc IOracle | function peek(bytes calldata data) public view override returns (bool, uint256) {
uint256 rate = abi.decode(data, (uint256));
return (rate != 0, rate);
}
| function peek(bytes calldata data) public view override returns (bool, uint256) {
uint256 rate = abi.decode(data, (uint256));
return (rate != 0, rate);
}
| 6,390 |
93 | // Rounds down to the nearest tick where tick % tickSpacing == 0/tick The tick to round/tickSpacing The tick spacing to round to/ return the floored tick/Ensure tick +/- tickSpacing does not overflow or underflow int24 | function floor(int24 tick, int24 tickSpacing) internal pure returns (int24) {
int24 mod = tick % tickSpacing;
unchecked {
if (mod >= 0) return tick - mod;
return tick - mod - tickSpacing;
}
}
| function floor(int24 tick, int24 tickSpacing) internal pure returns (int24) {
int24 mod = tick % tickSpacing;
unchecked {
if (mod >= 0) return tick - mod;
return tick - mod - tickSpacing;
}
}
| 17,273 |
1,102 | // https:etherscan.io/address/0xe2f532c389deb5E42DCe53e78A9762949A885455; | Synth existingSynth = Synth(0xe2f532c389deb5E42DCe53e78A9762949A885455);
| Synth existingSynth = Synth(0xe2f532c389deb5E42DCe53e78A9762949A885455);
| 49,053 |
707 | // Private hash Delegate struct for EIP-712_delegate VotingDelegate struct return bytes32 hash of _delegate/ | function _hash(VotingDelegate memory _delegate) internal pure returns (bytes32) {
return keccak256(
abi.encode(
DELEGATE_TYPEHASH,
_delegate.owner,
_delegate.delegate,
_delegate.nonce,
_delegate.expirationTime
)
);
}
| function _hash(VotingDelegate memory _delegate) internal pure returns (bytes32) {
return keccak256(
abi.encode(
DELEGATE_TYPEHASH,
_delegate.owner,
_delegate.delegate,
_delegate.nonce,
_delegate.expirationTime
)
);
}
| 32,847 |
77 | // Set current adjustment to inactive (e.g. if we are re-tuning early) | adjustments[id_].active = false;
| adjustments[id_].active = false;
| 5,554 |
20 | // The owner can withdraw ethers already during presale,/ only if the minimum funding level has been reached | function ownerWithdraw(uint256 value) external onlyOwner {
// The owner cannot withdraw if the presale did not reach the minimum funding amount
if (totalFunding < PRESALE_MINIMUM_FUNDING) throw;
// Withdraw the amount requested
if (!owner.send(value)) throw;
}
| function ownerWithdraw(uint256 value) external onlyOwner {
// The owner cannot withdraw if the presale did not reach the minimum funding amount
if (totalFunding < PRESALE_MINIMUM_FUNDING) throw;
// Withdraw the amount requested
if (!owner.send(value)) throw;
}
| 34,447 |
6 | // Get conversion rate from minimum receive token quantity. dstQty(1018)(10dstDecimals) / (10srcDecimals) / srcQty | kyberTradeInfo.conversionRate = _minDestinationQuantity
.mul(PreciseUnitMath.preciseUnit())
.mul(10 ** kyberTradeInfo.sourceTokenDecimals)
.div(10 ** kyberTradeInfo.destinationTokenDecimals)
.div(_sourceQuantity);
| kyberTradeInfo.conversionRate = _minDestinationQuantity
.mul(PreciseUnitMath.preciseUnit())
.mul(10 ** kyberTradeInfo.sourceTokenDecimals)
.div(10 ** kyberTradeInfo.destinationTokenDecimals)
.div(_sourceQuantity);
| 40,380 |
28 | // A contract for TopWolves/Rob Park/NFT Minting | contract TopWolves is ERC721, Ownable, ReentrancyGuard {
using SafeMath for uint256;
using SafeMath for uint16;
using SafeMath for uint8;
uint16 private _tokenId;
// Team wallet
address walletAddress = 0x9569c3ca25C5cb45Fa3eabe4A1f4b94f527a9Fd6;
// Minting Limitation
uint16 public secretFreeMintLimit = 500;
uint16 public totalLimit = 5555;
/**
* Mint Step flag
* 0: freeMint (for giveaway and promotion),
* 1: preSale - 24 hours
* 2: publicSale,
* 3: paused
* 4: not started
*/
uint8 public mintStep = 4;
// Merkle Tree Root
bytes32 private merkleRoot;
// Mint Price
uint public mintPriceDiscount = 0.1 ether;
uint public mintPrice = 0.12 ether;
// BaseURI (real)
string private realBaseURI = "https://gateway.pinata.cloud/ipfs/QmRiNsuRoYQmSAnvziBHSY4xHN43BHxgjvnoDxKyQQQ8Un/";
uint8 private LIMIT1 = 1; // presale first 8 hours : can mint only 1
uint8 private LIMIT3 = 3; // presale rest 16 hours : can mint only 3
/*
uint256 firstPresaleTime = 3600 * 8;
uint256 secondPresaleTime = 3600 * 16;
*/
uint256 firstPresaleTime = 60;
uint256 secondPresaleTime = 120;
uint256 public presaleStartTime = block.timestamp;
mapping (address => uint8) addressFreeMintCountMap;
mapping (address => uint8) addressFirstPresaleCountMap; // Up to 1
mapping (address => uint8) addressSecondPresaleCountMap; // Up to 3
mapping (address => uint8) addressPublicSaleCountMap; // Up to Unlimited
constructor() ERC721("TopWolves", "TWOL") {
}
event Mint (address indexed _from,
uint8 _mintStep,
uint _tokenId,
uint _mintPrice,
uint8 _mintCount,
uint8 _freeMintCount,
uint8 _preSaleCount,
uint8 _publicSaleCount);
event Setting ( uint8 _mintStep,
uint256 _mintPrice,
uint256 _mintPriceDiscount,
uint16 _totalLimit,
uint8 _limit3,
uint8 _limit1);
/**
* Override _baseURI
*
*/
function _baseURI() internal view override returns (string memory) {
return realBaseURI;
}
/**
* Override tokenURI
*/
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "Token does not exist");
return string(abi.encodePacked(_baseURI(), Strings.toString(tokenId), ".json"));
}
/**
* Address -> leaf for MerkleTree
*/
function _leaf(address account) private pure returns (bytes32) {
return keccak256(abi.encodePacked(account));
}
/**
* Verify WhiteList using MerkleTree
*/
function verifyWhitelist(bytes32 leaf, bytes32[] memory proof) private view returns (bool) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash < proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
// Check if the computed hash (root) is equal to the provided root
return computedHash == merkleRoot;
}
function setPresaleStart() external onlyOwner returns (uint256) {
presaleStartTime = block.timestamp;
mintStep = 1;
return presaleStartTime;
}
/**
* Secret Free Mint
* mintStep: 0
* mintCount: Up to 2
*/
function mintFreeSecret(uint8 _mintCount) external nonReentrant returns (uint256) {
require(mintStep == 0 && _mintCount > 0);
require(msg.sender != address(0));
for (uint8 i = 0; i < _mintCount; i++) {
_tokenId++;
_safeMint(msg.sender, _tokenId);
}
addressFreeMintCountMap[msg.sender] += _mintCount;
secretFreeMintLimit -= _mintCount;
totalLimit -= _mintCount;
emit Mint(msg.sender,
mintStep,
_tokenId,
0, // _mintPrice
_mintCount,
addressFreeMintCountMap[msg.sender],
addressFirstPresaleCountMap[msg.sender] + addressSecondPresaleCountMap[msg.sender],
addressPublicSaleCountMap[msg.sender]);
return _tokenId;
}
/**
* Presale with WhiteList
* mintStep: 1: 24hours
* mintCount: Up to 2
*/
/*function mintPresale(uint8 _mintCount, bytes32[] memory _proof) external payable nonReentrant returns (uint256) {
require(_mintCount > 0);
require(msg.sender != address(0));
require(mintStep == 1);
require(( // Presale 1
(_mintCount <= LIMIT1)
&& (block.timestamp <= presaleStartTime + firstPresaleTime)
&& (msg.value == (mintPriceDiscount * _mintCount))
&& (addressFirstPresaleCountMap[msg.sender] + _mintCount <= LIMIT1)
) || ( // Presale 2
(_mintCount <= LIMIT3)
&& (block.timestamp > presaleStartTime + firstPresaleTime)
&& (block.timestamp <= presaleStartTime + firstPresaleTime + secondPresaleTime)
&& (addressSecondPresaleCountMap[msg.sender] + _mintCount <= LIMIT3)
&& (msg.value == (mintPriceDiscount * _mintCount))
));
require(verifyWhitelist(_leaf(msg.sender), _proof) == true);
for (uint8 i = 0; i < _mintCount; i++) {
_tokenId++;
_safeMint(msg.sender, _tokenId);
}
if ((block.timestamp > presaleStartTime + firstPresaleTime) && (block.timestamp <= presaleStartTime + firstPresaleTime + secondPresaleTime))
addressSecondPresaleCountMap[msg.sender] += _mintCount;
else
addressFirstPresaleCountMap[msg.sender] += _mintCount;
totalLimit -= _mintCount;
emit Mint(msg.sender,
mintStep,
_tokenId,
mintPrice,
_mintCount,
addressFreeMintCountMap[msg.sender],
addressFirstPresaleCountMap[msg.sender] + addressSecondPresaleCountMap[msg.sender],
addressPublicSaleCountMap[msg.sender]);
return _tokenId;
}*/
function mintPresale(uint8 _mintCount) external payable nonReentrant returns (uint256) {
require(_mintCount > 0);
require(msg.sender != address(0));
require(mintStep == 1);
require(( // Presale 1
(_mintCount <= LIMIT1)
&& (block.timestamp <= presaleStartTime + firstPresaleTime)
&& (msg.value == (mintPriceDiscount * _mintCount))
&& (addressFirstPresaleCountMap[msg.sender] + _mintCount <= LIMIT1)
) || ( // Presale 2
(_mintCount <= LIMIT3)
&& (block.timestamp > presaleStartTime + firstPresaleTime)
&& (block.timestamp <= presaleStartTime + firstPresaleTime + secondPresaleTime)
&& (addressSecondPresaleCountMap[msg.sender] + _mintCount <= LIMIT3)
&& (msg.value == (mintPriceDiscount * _mintCount))
));
for (uint8 i = 0; i < _mintCount; i++) {
_tokenId++;
_safeMint(msg.sender, _tokenId);
}
if ((block.timestamp > presaleStartTime + firstPresaleTime) && (block.timestamp <= presaleStartTime + firstPresaleTime + secondPresaleTime))
addressSecondPresaleCountMap[msg.sender] += _mintCount;
else
addressFirstPresaleCountMap[msg.sender] += _mintCount;
totalLimit -= _mintCount;
emit Mint(msg.sender,
mintStep,
_tokenId,
mintPrice,
_mintCount,
addressFreeMintCountMap[msg.sender],
addressFirstPresaleCountMap[msg.sender] + addressSecondPresaleCountMap[msg.sender],
addressPublicSaleCountMap[msg.sender]);
return _tokenId;
}
/**
* Public Sale
* mintStep: 2
* mintCount: Up to Unlimited
*/
function mintPublic(uint8 _mintCount) external payable nonReentrant returns (uint256) {
require(mintStep == 2 && _mintCount > 0, "Not Public Mint Step");
require(msg.sender != address(0));
require(msg.value == (mintPrice * _mintCount),"Incorrect the send price");
require(_mintCount <= totalLimit);
for (uint8 i = 0; i < _mintCount; i++) {
_tokenId++;
_safeMint(msg.sender, _tokenId);
}
addressPublicSaleCountMap[msg.sender] += _mintCount;
totalLimit -= _mintCount;
emit Mint(msg.sender,
mintStep,
_tokenId,
mintPrice,
_mintCount,
addressFreeMintCountMap[msg.sender],
addressFirstPresaleCountMap[msg.sender] + addressSecondPresaleCountMap[msg.sender],
addressPublicSaleCountMap[msg.sender]);
return _tokenId;
}
/**
* Set status of mintStep
* 0: freeMint (for giveaway and promotion),
* 1: preSale - 8 hours,
* 2: publicSale,
* 3: paused
* 4: not started
*/
function setMintStep(uint8 _mintStep) external onlyOwner returns (uint8) {
require(_mintStep >= 0 && _mintStep <= 4);
mintStep = _mintStep;
emit Setting(mintStep, mintPrice, mintPriceDiscount, totalLimit, LIMIT3, LIMIT1);
return mintStep;
}
// Get Balance
function getBalance() external view onlyOwner returns (uint256) {
return address(this).balance;
}
// Withdraw
function withdraw() external onlyOwner {
require(address(this).balance != 0, "withdrawFunds: must have funds to withdraw");
uint256 balance = address(this).balance;
payable(walletAddress).transfer(balance);
}
/// Set Methods
function setRealBaseURI(string memory _realBaseURI) external onlyOwner returns (string memory) {
realBaseURI = _realBaseURI;
return realBaseURI;
}
function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner returns (bytes32) {
merkleRoot = _merkleRoot;
return merkleRoot;
}
/**
* Get TokenList by sender
*/
function getTokenList(address account) external view returns (uint256[] memory) {
require(msg.sender != address(0));
require(account != address(0));
address selectedAccount = msg.sender;
if (owner() == msg.sender)
selectedAccount = account;
uint256 count = balanceOf(selectedAccount);
uint256[] memory tokenIdList = new uint256[](count);
if (count == 0)
return tokenIdList;
uint256 cnt = 0;
for (uint256 i = 1; i < (_tokenId + 1); i++) {
if (_exists(i) && (ownerOf(i) == selectedAccount)) {
tokenIdList[cnt++] = i;
}
if (cnt == count)
break;
}
return tokenIdList;
}
/**
* Get Setting
* 0 : mintStep
* 1 : mintPrice
* 2 : mintPriceDiscount
* 3 : totalLimit
* 4 : LIMIT5
* 5 : LIMIT2
*/
function getSetting() external view returns (uint256[] memory) {
uint256[] memory setting = new uint256[](6);
setting[0] = mintStep;
setting[1] = mintPrice;
setting[2] = mintPriceDiscount;
setting[3] = totalLimit;
setting[4] = LIMIT3;
setting[5] = LIMIT1;
return setting;
}
/**
* Get Status by sender
* 0 : freeMintCount
* 1 : presaleCount
* 2 : publicSaleCount
*/
function getAccountStatus(address account) external view returns (uint8[] memory) {
require(msg.sender != address(0));
require(account != address(0));
address selectedAccount = msg.sender;
if (owner() == msg.sender)
selectedAccount = account;
uint8[] memory status = new uint8[](3);
if(balanceOf(selectedAccount) == 0)
return status;
status[0] = addressFreeMintCountMap[selectedAccount];
status[1] = addressFirstPresaleCountMap[msg.sender] + addressSecondPresaleCountMap[msg.sender];
status[2] = addressPublicSaleCountMap[selectedAccount];
return status;
}
} | contract TopWolves is ERC721, Ownable, ReentrancyGuard {
using SafeMath for uint256;
using SafeMath for uint16;
using SafeMath for uint8;
uint16 private _tokenId;
// Team wallet
address walletAddress = 0x9569c3ca25C5cb45Fa3eabe4A1f4b94f527a9Fd6;
// Minting Limitation
uint16 public secretFreeMintLimit = 500;
uint16 public totalLimit = 5555;
/**
* Mint Step flag
* 0: freeMint (for giveaway and promotion),
* 1: preSale - 24 hours
* 2: publicSale,
* 3: paused
* 4: not started
*/
uint8 public mintStep = 4;
// Merkle Tree Root
bytes32 private merkleRoot;
// Mint Price
uint public mintPriceDiscount = 0.1 ether;
uint public mintPrice = 0.12 ether;
// BaseURI (real)
string private realBaseURI = "https://gateway.pinata.cloud/ipfs/QmRiNsuRoYQmSAnvziBHSY4xHN43BHxgjvnoDxKyQQQ8Un/";
uint8 private LIMIT1 = 1; // presale first 8 hours : can mint only 1
uint8 private LIMIT3 = 3; // presale rest 16 hours : can mint only 3
/*
uint256 firstPresaleTime = 3600 * 8;
uint256 secondPresaleTime = 3600 * 16;
*/
uint256 firstPresaleTime = 60;
uint256 secondPresaleTime = 120;
uint256 public presaleStartTime = block.timestamp;
mapping (address => uint8) addressFreeMintCountMap;
mapping (address => uint8) addressFirstPresaleCountMap; // Up to 1
mapping (address => uint8) addressSecondPresaleCountMap; // Up to 3
mapping (address => uint8) addressPublicSaleCountMap; // Up to Unlimited
constructor() ERC721("TopWolves", "TWOL") {
}
event Mint (address indexed _from,
uint8 _mintStep,
uint _tokenId,
uint _mintPrice,
uint8 _mintCount,
uint8 _freeMintCount,
uint8 _preSaleCount,
uint8 _publicSaleCount);
event Setting ( uint8 _mintStep,
uint256 _mintPrice,
uint256 _mintPriceDiscount,
uint16 _totalLimit,
uint8 _limit3,
uint8 _limit1);
/**
* Override _baseURI
*
*/
function _baseURI() internal view override returns (string memory) {
return realBaseURI;
}
/**
* Override tokenURI
*/
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "Token does not exist");
return string(abi.encodePacked(_baseURI(), Strings.toString(tokenId), ".json"));
}
/**
* Address -> leaf for MerkleTree
*/
function _leaf(address account) private pure returns (bytes32) {
return keccak256(abi.encodePacked(account));
}
/**
* Verify WhiteList using MerkleTree
*/
function verifyWhitelist(bytes32 leaf, bytes32[] memory proof) private view returns (bool) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash < proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
// Check if the computed hash (root) is equal to the provided root
return computedHash == merkleRoot;
}
function setPresaleStart() external onlyOwner returns (uint256) {
presaleStartTime = block.timestamp;
mintStep = 1;
return presaleStartTime;
}
/**
* Secret Free Mint
* mintStep: 0
* mintCount: Up to 2
*/
function mintFreeSecret(uint8 _mintCount) external nonReentrant returns (uint256) {
require(mintStep == 0 && _mintCount > 0);
require(msg.sender != address(0));
for (uint8 i = 0; i < _mintCount; i++) {
_tokenId++;
_safeMint(msg.sender, _tokenId);
}
addressFreeMintCountMap[msg.sender] += _mintCount;
secretFreeMintLimit -= _mintCount;
totalLimit -= _mintCount;
emit Mint(msg.sender,
mintStep,
_tokenId,
0, // _mintPrice
_mintCount,
addressFreeMintCountMap[msg.sender],
addressFirstPresaleCountMap[msg.sender] + addressSecondPresaleCountMap[msg.sender],
addressPublicSaleCountMap[msg.sender]);
return _tokenId;
}
/**
* Presale with WhiteList
* mintStep: 1: 24hours
* mintCount: Up to 2
*/
/*function mintPresale(uint8 _mintCount, bytes32[] memory _proof) external payable nonReentrant returns (uint256) {
require(_mintCount > 0);
require(msg.sender != address(0));
require(mintStep == 1);
require(( // Presale 1
(_mintCount <= LIMIT1)
&& (block.timestamp <= presaleStartTime + firstPresaleTime)
&& (msg.value == (mintPriceDiscount * _mintCount))
&& (addressFirstPresaleCountMap[msg.sender] + _mintCount <= LIMIT1)
) || ( // Presale 2
(_mintCount <= LIMIT3)
&& (block.timestamp > presaleStartTime + firstPresaleTime)
&& (block.timestamp <= presaleStartTime + firstPresaleTime + secondPresaleTime)
&& (addressSecondPresaleCountMap[msg.sender] + _mintCount <= LIMIT3)
&& (msg.value == (mintPriceDiscount * _mintCount))
));
require(verifyWhitelist(_leaf(msg.sender), _proof) == true);
for (uint8 i = 0; i < _mintCount; i++) {
_tokenId++;
_safeMint(msg.sender, _tokenId);
}
if ((block.timestamp > presaleStartTime + firstPresaleTime) && (block.timestamp <= presaleStartTime + firstPresaleTime + secondPresaleTime))
addressSecondPresaleCountMap[msg.sender] += _mintCount;
else
addressFirstPresaleCountMap[msg.sender] += _mintCount;
totalLimit -= _mintCount;
emit Mint(msg.sender,
mintStep,
_tokenId,
mintPrice,
_mintCount,
addressFreeMintCountMap[msg.sender],
addressFirstPresaleCountMap[msg.sender] + addressSecondPresaleCountMap[msg.sender],
addressPublicSaleCountMap[msg.sender]);
return _tokenId;
}*/
function mintPresale(uint8 _mintCount) external payable nonReentrant returns (uint256) {
require(_mintCount > 0);
require(msg.sender != address(0));
require(mintStep == 1);
require(( // Presale 1
(_mintCount <= LIMIT1)
&& (block.timestamp <= presaleStartTime + firstPresaleTime)
&& (msg.value == (mintPriceDiscount * _mintCount))
&& (addressFirstPresaleCountMap[msg.sender] + _mintCount <= LIMIT1)
) || ( // Presale 2
(_mintCount <= LIMIT3)
&& (block.timestamp > presaleStartTime + firstPresaleTime)
&& (block.timestamp <= presaleStartTime + firstPresaleTime + secondPresaleTime)
&& (addressSecondPresaleCountMap[msg.sender] + _mintCount <= LIMIT3)
&& (msg.value == (mintPriceDiscount * _mintCount))
));
for (uint8 i = 0; i < _mintCount; i++) {
_tokenId++;
_safeMint(msg.sender, _tokenId);
}
if ((block.timestamp > presaleStartTime + firstPresaleTime) && (block.timestamp <= presaleStartTime + firstPresaleTime + secondPresaleTime))
addressSecondPresaleCountMap[msg.sender] += _mintCount;
else
addressFirstPresaleCountMap[msg.sender] += _mintCount;
totalLimit -= _mintCount;
emit Mint(msg.sender,
mintStep,
_tokenId,
mintPrice,
_mintCount,
addressFreeMintCountMap[msg.sender],
addressFirstPresaleCountMap[msg.sender] + addressSecondPresaleCountMap[msg.sender],
addressPublicSaleCountMap[msg.sender]);
return _tokenId;
}
/**
* Public Sale
* mintStep: 2
* mintCount: Up to Unlimited
*/
function mintPublic(uint8 _mintCount) external payable nonReentrant returns (uint256) {
require(mintStep == 2 && _mintCount > 0, "Not Public Mint Step");
require(msg.sender != address(0));
require(msg.value == (mintPrice * _mintCount),"Incorrect the send price");
require(_mintCount <= totalLimit);
for (uint8 i = 0; i < _mintCount; i++) {
_tokenId++;
_safeMint(msg.sender, _tokenId);
}
addressPublicSaleCountMap[msg.sender] += _mintCount;
totalLimit -= _mintCount;
emit Mint(msg.sender,
mintStep,
_tokenId,
mintPrice,
_mintCount,
addressFreeMintCountMap[msg.sender],
addressFirstPresaleCountMap[msg.sender] + addressSecondPresaleCountMap[msg.sender],
addressPublicSaleCountMap[msg.sender]);
return _tokenId;
}
/**
* Set status of mintStep
* 0: freeMint (for giveaway and promotion),
* 1: preSale - 8 hours,
* 2: publicSale,
* 3: paused
* 4: not started
*/
function setMintStep(uint8 _mintStep) external onlyOwner returns (uint8) {
require(_mintStep >= 0 && _mintStep <= 4);
mintStep = _mintStep;
emit Setting(mintStep, mintPrice, mintPriceDiscount, totalLimit, LIMIT3, LIMIT1);
return mintStep;
}
// Get Balance
function getBalance() external view onlyOwner returns (uint256) {
return address(this).balance;
}
// Withdraw
function withdraw() external onlyOwner {
require(address(this).balance != 0, "withdrawFunds: must have funds to withdraw");
uint256 balance = address(this).balance;
payable(walletAddress).transfer(balance);
}
/// Set Methods
function setRealBaseURI(string memory _realBaseURI) external onlyOwner returns (string memory) {
realBaseURI = _realBaseURI;
return realBaseURI;
}
function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner returns (bytes32) {
merkleRoot = _merkleRoot;
return merkleRoot;
}
/**
* Get TokenList by sender
*/
function getTokenList(address account) external view returns (uint256[] memory) {
require(msg.sender != address(0));
require(account != address(0));
address selectedAccount = msg.sender;
if (owner() == msg.sender)
selectedAccount = account;
uint256 count = balanceOf(selectedAccount);
uint256[] memory tokenIdList = new uint256[](count);
if (count == 0)
return tokenIdList;
uint256 cnt = 0;
for (uint256 i = 1; i < (_tokenId + 1); i++) {
if (_exists(i) && (ownerOf(i) == selectedAccount)) {
tokenIdList[cnt++] = i;
}
if (cnt == count)
break;
}
return tokenIdList;
}
/**
* Get Setting
* 0 : mintStep
* 1 : mintPrice
* 2 : mintPriceDiscount
* 3 : totalLimit
* 4 : LIMIT5
* 5 : LIMIT2
*/
function getSetting() external view returns (uint256[] memory) {
uint256[] memory setting = new uint256[](6);
setting[0] = mintStep;
setting[1] = mintPrice;
setting[2] = mintPriceDiscount;
setting[3] = totalLimit;
setting[4] = LIMIT3;
setting[5] = LIMIT1;
return setting;
}
/**
* Get Status by sender
* 0 : freeMintCount
* 1 : presaleCount
* 2 : publicSaleCount
*/
function getAccountStatus(address account) external view returns (uint8[] memory) {
require(msg.sender != address(0));
require(account != address(0));
address selectedAccount = msg.sender;
if (owner() == msg.sender)
selectedAccount = account;
uint8[] memory status = new uint8[](3);
if(balanceOf(selectedAccount) == 0)
return status;
status[0] = addressFreeMintCountMap[selectedAccount];
status[1] = addressFirstPresaleCountMap[msg.sender] + addressSecondPresaleCountMap[msg.sender];
status[2] = addressPublicSaleCountMap[selectedAccount];
return status;
}
} | 21,463 |
14 | // Convert a color from the HSL colorspace to RGB and return the Red, Green, and Blue components.Core function that was originally parsed in Javascript, translated to Solidity. / | function hueToRGB (uint256 hue, uint8 _lightness) public pure returns (uint8, uint8, uint8) {
uint256 c;
uint256 lightness = _lightness * HUNDREDTH;
if (lightness < (ONE / 2)) {
c = 2 * lightness;
} else {
c = 2 * (ONE - lightness);
}
uint256 x;
uint256 temp = (hue / 60) % (2 * ONE);
if (temp > ONE) {
x = c * (ONE - (temp - ONE)) / ONE;
} else {
x = c * (ONE - (ONE - temp)) / ONE;
}
uint256 m = lightness - c / 2;
uint256 r;
uint256 g;
uint256 b;
if (hue < (60 * ONE)) {
r = c;
g = x;
b = 0;
} else if (hue < (120 * ONE)) {
r = x;
g = c;
b = 0;
} else if (hue < (180 * ONE)) {
r = 0;
g = c;
b = x;
} else if (hue < (240 * ONE)) {
r = 0;
g = x;
b = c;
} else if (hue < (300 * ONE)) {
r = x;
g = 0;
b = c;
} else {
r = c;
g = 0;
b = x;
}
return (roundComponent(r, m), roundComponent(g, m), roundComponent(b, m));
}
| function hueToRGB (uint256 hue, uint8 _lightness) public pure returns (uint8, uint8, uint8) {
uint256 c;
uint256 lightness = _lightness * HUNDREDTH;
if (lightness < (ONE / 2)) {
c = 2 * lightness;
} else {
c = 2 * (ONE - lightness);
}
uint256 x;
uint256 temp = (hue / 60) % (2 * ONE);
if (temp > ONE) {
x = c * (ONE - (temp - ONE)) / ONE;
} else {
x = c * (ONE - (ONE - temp)) / ONE;
}
uint256 m = lightness - c / 2;
uint256 r;
uint256 g;
uint256 b;
if (hue < (60 * ONE)) {
r = c;
g = x;
b = 0;
} else if (hue < (120 * ONE)) {
r = x;
g = c;
b = 0;
} else if (hue < (180 * ONE)) {
r = 0;
g = c;
b = x;
} else if (hue < (240 * ONE)) {
r = 0;
g = x;
b = c;
} else if (hue < (300 * ONE)) {
r = x;
g = 0;
b = c;
} else {
r = c;
g = 0;
b = x;
}
return (roundComponent(r, m), roundComponent(g, m), roundComponent(b, m));
}
| 46,790 |
17 | // increment the skip count | pools[poolIndex].contributionSkipCount += 1;
| pools[poolIndex].contributionSkipCount += 1;
| 10,102 |
12 | // Emit an event when the PRIME price is set/tokenId is the token ID/price is the new PRIME price | event PriceSet(uint256 tokenId, uint256 price);
| event PriceSet(uint256 tokenId, uint256 price);
| 36,507 |
18 | // Withdraw the entire balance for an account / | function withdrawAll()
external
override
| function withdrawAll()
external
override
| 60,049 |
5 | // Define the inflationary model | inflationaryModelPerYear[1] = YearlyMintInfo(
MAX_MINT_AMOUNT_YEAR_1,
0,
MAX_MINT_AMOUNT_YEAR_1
);
inflationaryModelPerYear[2] = YearlyMintInfo(
MAX_MINT_AMOUNT_YEAR_2,
0,
MAX_MINT_AMOUNT_YEAR_2
);
| inflationaryModelPerYear[1] = YearlyMintInfo(
MAX_MINT_AMOUNT_YEAR_1,
0,
MAX_MINT_AMOUNT_YEAR_1
);
inflationaryModelPerYear[2] = YearlyMintInfo(
MAX_MINT_AMOUNT_YEAR_2,
0,
MAX_MINT_AMOUNT_YEAR_2
);
| 16,277 |
67 | // perform reclaim token by admin | function adminReclaimToken(address _address) public onlyOwner {
uint256 amount = reclaimTokenMap.get(_address);
require(amount > 0);
require(token.balanceOf(address(this)) >= amount);
token.transfer(_address, amount);
// remove from map
reclaimTokenMap.remove(_address);
}
| function adminReclaimToken(address _address) public onlyOwner {
uint256 amount = reclaimTokenMap.get(_address);
require(amount > 0);
require(token.balanceOf(address(this)) >= amount);
token.transfer(_address, amount);
// remove from map
reclaimTokenMap.remove(_address);
}
| 9,557 |
209 | // Reset to allow add/remove tokens, or manual weight updates | if (block.number >= gradualUpdate.endBlock) {
gradualUpdate.startBlock = 0;
}
| if (block.number >= gradualUpdate.endBlock) {
gradualUpdate.startBlock = 0;
}
| 23,368 |
120 | // Send transfers to dead address | if (burnAmt > 0) {
_transferStandard(sender, deadWallet, burnAmt);
}
| if (burnAmt > 0) {
_transferStandard(sender, deadWallet, burnAmt);
}
| 25,286 |
52 | // The number of memory words this memory view occupies, rounded up. memView The viewreturnuint256 - The number of memory words / | function words(bytes29 memView) internal pure returns (uint256) {
return uint256(len(memView)).add(32) / 32;
}
| function words(bytes29 memView) internal pure returns (uint256) {
return uint256(len(memView)).add(32) / 32;
}
| 46,641 |
9 | // returns sorted token addresses, used to handle return values from pairs sorted in this order | function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, "GemLibrary: IDENTICAL_ADDRESSES");
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), "GemLibrary: ZERO_ADDRESS");
}
| function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, "GemLibrary: IDENTICAL_ADDRESSES");
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), "GemLibrary: ZERO_ADDRESS");
}
| 1,459 |
22 | // Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings/owner Token owner/operator Operator to check/ return bool true if `_operator` is approved for all | function isApprovedForAll(address owner, address operator)
public override(ERC721Upgradeable, IERC721Upgradeable) view
returns (bool)
| function isApprovedForAll(address owner, address operator)
public override(ERC721Upgradeable, IERC721Upgradeable) view
returns (bool)
| 27,169 |
46 | // Past report is too old. | emit ReportTimestampOutOfRange(providerAddress);
| emit ReportTimestampOutOfRange(providerAddress);
| 29,369 |
24 | // We can unsafely cast to int256 because balances are actually stored as uint112 | _unsafeCastToInt256(amountsInOrOut, positive),
dueProtocolFeeAmounts
);
| _unsafeCastToInt256(amountsInOrOut, positive),
dueProtocolFeeAmounts
);
| 12,012 |
42 | // Event logged when a new address is authorized. | event AuthorizedAddressAdded(
address indexed target,
address indexed caller
);
| event AuthorizedAddressAdded(
address indexed target,
address indexed caller
);
| 33,355 |
16 | // Update token price. tokenPrice_ The new token price / | function setTokenPrice(uint256 tokenPrice_) external onlyOwner {
tokenPrice = tokenPrice_;
}
| function setTokenPrice(uint256 tokenPrice_) external onlyOwner {
tokenPrice = tokenPrice_;
}
| 74,606 |
104 | // revert(); msg.value is the amount of Ether sent by the transaction. |
if (msg.value > 0) {
fund(lastGateway);
} else {
|
if (msg.value > 0) {
fund(lastGateway);
} else {
| 46,389 |
52 | // Whether `a` is less than `b`. a a FixedPoint.Signed. b an int256.return True if `a < b`, or False. / | function isLessThan(Signed memory a, int256 b) internal pure returns (bool) {
return a.rawValue < fromUnscaledInt(b).rawValue;
}
| function isLessThan(Signed memory a, int256 b) internal pure returns (bool) {
return a.rawValue < fromUnscaledInt(b).rawValue;
}
| 1,151 |
39 | // returns the balance in staked UNIC with Multiplier | function balanceOf(address owner) external view returns (uint256 unicWithMultiplierSum) {
uint256 balanceOf = stakingNftContract.balanceOf(owner);
unicWithMultiplierSum = 0;
for (uint256 i = 0; i < balanceOf; i++) {
unicWithMultiplierSum += stakingPoolContract.getStakeWithMultiplier(stakingNftContract.tokenOfOwnerByIndex(owner, i));
}
}
| function balanceOf(address owner) external view returns (uint256 unicWithMultiplierSum) {
uint256 balanceOf = stakingNftContract.balanceOf(owner);
unicWithMultiplierSum = 0;
for (uint256 i = 0; i < balanceOf; i++) {
unicWithMultiplierSum += stakingPoolContract.getStakeWithMultiplier(stakingNftContract.tokenOfOwnerByIndex(owner, i));
}
}
| 42,759 |
23 | // Send to UniSwap | IWETH(WETH).deposit{value : totalETHContributed}();
| IWETH(WETH).deposit{value : totalETHContributed}();
| 7,001 |
78 | // withdraw token bonus earned from locking up liquidity-------------------------------------------------------------- _user--> address of the user making withdrawal releasedAmount --> released token to be withdrawn------------------------------------------------------------------returns whether successfully withdrawn or not. / | function _withdrawUserTokenBonus(address _user, uint releasedAmount) internal returns(bool) {
_users[_user].tokenWithdrawn = _users[_user].tokenWithdrawn.add(releasedAmount);
_pendingBonusesToken = _pendingBonusesToken.sub(releasedAmount);
(uint fee, uint feeInToken) = _calculateTokenFee(releasedAmount);
require(IERC20(uToken).transferFrom(_user, wallet, fee), "must approve fee");
token.transfer(_user, releasedAmount);
emit UserTokenBonusWithdrawn(_user, releasedAmount, feeInToken);
return true;
}
| function _withdrawUserTokenBonus(address _user, uint releasedAmount) internal returns(bool) {
_users[_user].tokenWithdrawn = _users[_user].tokenWithdrawn.add(releasedAmount);
_pendingBonusesToken = _pendingBonusesToken.sub(releasedAmount);
(uint fee, uint feeInToken) = _calculateTokenFee(releasedAmount);
require(IERC20(uToken).transferFrom(_user, wallet, fee), "must approve fee");
token.transfer(_user, releasedAmount);
emit UserTokenBonusWithdrawn(_user, releasedAmount, feeInToken);
return true;
}
| 30,022 |
1 | // need memory keynote for every single string datatype within the function |
function createCampaign(
address _owner,
string memory _title,
string memory _description,
uint256 _target,
uint256 _deadline,
string memory _image
|
function createCampaign(
address _owner,
string memory _title,
string memory _description,
uint256 _target,
uint256 _deadline,
string memory _image
| 14,678 |
61 | // FinalAmount = PAPY/SecondsPerYearn Compounded interest = FinalAmount - P; | userReward = (user.amount * fixedAPY * multiplier) / SECONDS_YEAR / _RATE_NOMINATOR;
| userReward = (user.amount * fixedAPY * multiplier) / SECONDS_YEAR / _RATE_NOMINATOR;
| 35,114 |
25 | // private claim all accumulated outstanding tokens back to the callers wallet | function _claim() private {
// Return with no action if the staking period has not commenced yet.
if (rewardStartTime == 0) {
return;
}
uint32 lastClaimTime = userStakes[msg.sender].lastClaimTime;
// If the user staked before the start time was set, update the stake time to be the now known start Time
if (lastClaimTime < rewardStartTime) {
lastClaimTime = rewardStartTime;
}
// Calculation includes Fixed 5% APR + Dynamic
// Adjust claim time to never exceed the reward end date
uint32 claimTime = (block.timestamp < rewardStartTime + rewardLifetime)
? uint32(block.timestamp)
: rewardStartTime + rewardLifetime;
uint128 fixedClaimAmount = (((userStakes[msg.sender].amount *
fixedAPR) / 10000) * (claimTime - lastClaimTime)) / rewardLifetime;
uint128 dynamicClaimAmount = userStakes[msg.sender].unclaimedDynReward;
dynamicTokensAllocated -= dynamicClaimAmount;
uint128 totalClaim = fixedClaimAmount + dynamicClaimAmount;
require(
fixedRewardsAvailable >= fixedClaimAmount,
"Insufficient Fixed Rewards available"
);
if (totalClaim > 0) {
token.safeTransfer(msg.sender, totalClaim);
}
if (fixedClaimAmount > 0) {
fixedRewardsAvailable -= uint128(fixedClaimAmount); // decrease the tokens remaining to reward
}
userStakes[msg.sender].lastClaimTime = uint32(claimTime);
if (dynamicClaimAmount > 0) {
userStakes[msg.sender].unclaimedDynReward = 0;
}
// _updateFixedObligation(msg.sender); - refactored into stake, claim, unstake
emit ClaimReward(msg.sender, fixedClaimAmount, dynamicClaimAmount);
}
| function _claim() private {
// Return with no action if the staking period has not commenced yet.
if (rewardStartTime == 0) {
return;
}
uint32 lastClaimTime = userStakes[msg.sender].lastClaimTime;
// If the user staked before the start time was set, update the stake time to be the now known start Time
if (lastClaimTime < rewardStartTime) {
lastClaimTime = rewardStartTime;
}
// Calculation includes Fixed 5% APR + Dynamic
// Adjust claim time to never exceed the reward end date
uint32 claimTime = (block.timestamp < rewardStartTime + rewardLifetime)
? uint32(block.timestamp)
: rewardStartTime + rewardLifetime;
uint128 fixedClaimAmount = (((userStakes[msg.sender].amount *
fixedAPR) / 10000) * (claimTime - lastClaimTime)) / rewardLifetime;
uint128 dynamicClaimAmount = userStakes[msg.sender].unclaimedDynReward;
dynamicTokensAllocated -= dynamicClaimAmount;
uint128 totalClaim = fixedClaimAmount + dynamicClaimAmount;
require(
fixedRewardsAvailable >= fixedClaimAmount,
"Insufficient Fixed Rewards available"
);
if (totalClaim > 0) {
token.safeTransfer(msg.sender, totalClaim);
}
if (fixedClaimAmount > 0) {
fixedRewardsAvailable -= uint128(fixedClaimAmount); // decrease the tokens remaining to reward
}
userStakes[msg.sender].lastClaimTime = uint32(claimTime);
if (dynamicClaimAmount > 0) {
userStakes[msg.sender].unclaimedDynReward = 0;
}
// _updateFixedObligation(msg.sender); - refactored into stake, claim, unstake
emit ClaimReward(msg.sender, fixedClaimAmount, dynamicClaimAmount);
}
| 6,353 |
24 | // Step 5: create gauges for the single-recipient gauge types The LM committee gauge will be remain as a SingleRecipientGauge permanently, however the gauges for veBAL, Polygon and Arbitrum types are temporary pending an automated solution. These three gauges will in time be retired (killed) and replaced with new gauge implementations which automate the distribution of BAL to BPT stakers on other networks and veBAL holders. | {
authorizer.grantRole(authorizerAdaptor.getActionId(IGaugeController.add_gauge.selector), address(this));
| {
authorizer.grantRole(authorizerAdaptor.getActionId(IGaugeController.add_gauge.selector), address(this));
| 22,801 |
47 | // save some gas by making only one contract call | function burnFrom(address _from, uint256 _value) returns (bool)
| function burnFrom(address _from, uint256 _value) returns (bool)
| 41,472 |
27 | // Current resource supply | uint public resourceSupply;
| uint public resourceSupply;
| 1,400 |
51 | // every reward era, the reward amount halves. |
return (50 * 10**uint(decimals) ).div( 2**rewardEra ) ;
|
return (50 * 10**uint(decimals) ).div( 2**rewardEra ) ;
| 48,186 |
70 | // deposit all liquidity from msg.senderreturn success/failure / | function depositAll() external returns (bool) {
return deposit(IERC20(reserve).balanceOf(msg.sender));
}
| function depositAll() external returns (bool) {
return deposit(IERC20(reserve).balanceOf(msg.sender));
}
| 44,744 |
38 | // Calculates sqrt(1.0001^tick)2^96/Throws if |tick| > max tick/tick The input tick for the above formula/ return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)/ at the given tick | function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
require(absTick <= uint256(MAX_TICK), 'T');
uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;
if (tick > 0) ratio = type(uint256).max / ratio;
// this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
// we then downcast because we know the result always fits within 160 bits due to our tick input constraint
// we round up in the division so getTickAtSqrtRatio of the output price is always consistent
sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
}
| function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
require(absTick <= uint256(MAX_TICK), 'T');
uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;
if (tick > 0) ratio = type(uint256).max / ratio;
// this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
// we then downcast because we know the result always fits within 160 bits due to our tick input constraint
// we round up in the division so getTickAtSqrtRatio of the output price is always consistent
sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
}
| 2,807 |
229 | // Makes Data Availability Service keyset valid keysetBytes bytes of the serialized keyset / | function setValidKeyset(bytes calldata keysetBytes) external;
| function setValidKeyset(bytes calldata keysetBytes) external;
| 36,705 |
119 | // thrown when caller is not the flywheel | error FlywheelError();
| error FlywheelError();
| 21,794 |
52 | // PRIVILEGED GOVERNANCE FUNCTION. Allows governance to remove a factory_factory Address of the factory contract to remove / | function removeFactory(address _factory) external onlyInitialized onlyOwner {
require(isFactory[_factory], "Factory does not exist");
factories = factories.remove(_factory);
isFactory[_factory] = false;
emit FactoryRemoved(_factory);
}
| function removeFactory(address _factory) external onlyInitialized onlyOwner {
require(isFactory[_factory], "Factory does not exist");
factories = factories.remove(_factory);
isFactory[_factory] = false;
emit FactoryRemoved(_factory);
}
| 34,334 |
229 | // 1. Take out collateral | doTakeCollateral(lp, amt.amtLPTake);
| doTakeCollateral(lp, amt.amtLPTake);
| 32,828 |
86 | // note this will always return 0 before update has been called successfully for the first time. | function consult(address token, uint amountIn) internal view returns (uint amountOut) {
if (token == token0) {
amountOut = price0Average.mul(amountIn).decode144();
} else {
require(token == token1, 'OracleSimple: INVALID_TOKEN');
amountOut = price1Average.mul(amountIn).decode144();
}
}
| function consult(address token, uint amountIn) internal view returns (uint amountOut) {
if (token == token0) {
amountOut = price0Average.mul(amountIn).decode144();
} else {
require(token == token1, 'OracleSimple: INVALID_TOKEN');
amountOut = price1Average.mul(amountIn).decode144();
}
}
| 5,896 |
61 | // Get the approved address for a single NFT. Throws if `_tokenId` is not a valid NFT. _tokenId ID of the NFT to query the approval of.return Address that _tokenId is approved for. / | function getApproved(
uint256 _tokenId
)
external
override
view
validNFToken(_tokenId)
returns (address)
| function getApproved(
uint256 _tokenId
)
external
override
view
validNFToken(_tokenId)
returns (address)
| 1,860 |
14 | // fetch local storage / | function getStorage() internal pure returns (Storage storage s) {
bytes32 namespace = NAMESPACE;
// solhint-disable-next-line no-inline-assembly
assembly {
s.slot := namespace
}
}
| function getStorage() internal pure returns (Storage storage s) {
bytes32 namespace = NAMESPACE;
// solhint-disable-next-line no-inline-assembly
assembly {
s.slot := namespace
}
}
| 30,212 |
177 | // Execution of INVEST proposal./proposal_ proposal. | function _executeInvest(Proposal storage proposal_) private {
// Check that DAO has sufficient balance for investment.
require(availableBalance() >= proposal_.amount);
// Transfer funds.
payable(proposal_.proposalAddress).call{value: proposal_.amount}("");
// If secondary address for invest token is specified then save it to holdings.
if(proposal_.investTokenAddress != address(0x0)) {
if (!_holdings.contains(proposal_.investTokenAddress)) {
_holdings.add(proposal_.investTokenAddress);
// Emit event that holdings addresses have changed.
emit HoldingsAddressesChanged();
}
}
}
| function _executeInvest(Proposal storage proposal_) private {
// Check that DAO has sufficient balance for investment.
require(availableBalance() >= proposal_.amount);
// Transfer funds.
payable(proposal_.proposalAddress).call{value: proposal_.amount}("");
// If secondary address for invest token is specified then save it to holdings.
if(proposal_.investTokenAddress != address(0x0)) {
if (!_holdings.contains(proposal_.investTokenAddress)) {
_holdings.add(proposal_.investTokenAddress);
// Emit event that holdings addresses have changed.
emit HoldingsAddressesChanged();
}
}
}
| 12,723 |
48 | // add the tokens to the user's balance | balances[msg.sender] = balances[msg.sender].add(_amount);
Deposit(msg.sender, _amount, balances[msg.sender]);
| balances[msg.sender] = balances[msg.sender].add(_amount);
Deposit(msg.sender, _amount, balances[msg.sender]);
| 45,134 |
5 | // allow deposit of funds | receive() external payable {}
// convenience function
function contractBalance() public view returns (uint256) {
return address(this).balance;
}
| receive() external payable {}
// convenience function
function contractBalance() public view returns (uint256) {
return address(this).balance;
}
| 44,893 |
133 | // 5. If it is below the minimum, don't allow this draw. | require(collateralRatio(loan) > minCratio, "Cannot draw this much");
| require(collateralRatio(loan) > minCratio, "Cannot draw this much");
| 7,596 |
609 | // reset re-entrancy guard | entered = 1;
| entered = 1;
| 21,694 |
27 | // require(msg.sender == address(eurekaTokenContract)); | require(_value == submissionFee, 'transferred amount needs to equal the submission fee');
uint submissionId = submissionCounter++;
ArticleSubmission storage submission = articleSubmissions[submissionId];
submission.submissionId = submissionId;
submission.submissionOwner = _from;
submitArticleVersion(submissionId, _articleHash, _articleURL, _authors, _authorContributionRatios, _linkedArticles, _linkedArticlesSplitRatios);
| require(_value == submissionFee, 'transferred amount needs to equal the submission fee');
uint submissionId = submissionCounter++;
ArticleSubmission storage submission = articleSubmissions[submissionId];
submission.submissionId = submissionId;
submission.submissionOwner = _from;
submitArticleVersion(submissionId, _articleHash, _articleURL, _authors, _authorContributionRatios, _linkedArticles, _linkedArticlesSplitRatios);
| 7,785 |
3 | // ownership | address public _master;
| address public _master;
| 3,320 |
45 | // Returns whether transfering is stopped. / | function isTransferringStopped() external view override returns (bool) {
return _stopped;
}
| function isTransferringStopped() external view override returns (bool) {
return _stopped;
}
| 47,262 |
123 | // Returns all currently active adIds. | function getAdIds() external view returns (uint256[]) {
return adIds;
}
| function getAdIds() external view returns (uint256[]) {
return adIds;
}
| 29,003 |
24 | // May emit a {RoleGranted} event. / | function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
| function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
| 22,313 |
30 | // Withdraws all the ETH of `msg.sender`./It can only be called when the contract state is not `PostDeposit`./ Emits a {Withdrawal} event./minimumETHAmount The minimum amount of ETH that must be received for the transaction not to revert. | function withdrawAll(uint256 minimumETHAmount) external returns (uint256);
| function withdrawAll(uint256 minimumETHAmount) external returns (uint256);
| 1,847 |
141 | // use by default 500,000 gas to process auto-claiming dividends | uint256 public gasForProcessing = 500000;
| uint256 public gasForProcessing = 500000;
| 9,232 |
23 | // the cliff period has not ended, therefore, no tokens to draw down | if (_getNow() <= schedule.cliff) {
return 0;
}
| if (_getNow() <= schedule.cliff) {
return 0;
}
| 14,996 |
39 | // update shares per token | _sharesPerPolkamoon = _totalShares.div(_totalSupply);
| _sharesPerPolkamoon = _totalShares.div(_totalSupply);
| 72,382 |
82 | // Contract initializer. factory Address of the initial factory. data Data to send as msg.data to the implementation to initialize the proxied contract.It should include the signature and the parameters of the function to be called, as described inThis parameter is optional, if no data is given the initialization call to proxied contract will be skipped. / | function initialize(address factory, bytes memory data) public payable {
require(_factory() == address(0));
assert(FACTORY_SLOT == bytes32(uint256(keccak256('eip1967.proxy.factory')) - 1));
_setFactory(factory);
if(data.length > 0) {
(bool success,) = _implementation().delegatecall(data);
require(success);
}
}
| function initialize(address factory, bytes memory data) public payable {
require(_factory() == address(0));
assert(FACTORY_SLOT == bytes32(uint256(keccak256('eip1967.proxy.factory')) - 1));
_setFactory(factory);
if(data.length > 0) {
(bool success,) = _implementation().delegatecall(data);
require(success);
}
}
| 20,215 |
5 | // Mapping from owner to number of owned token | mapping (address => uint256) internal ownedTokensCount;
| mapping (address => uint256) internal ownedTokensCount;
| 5,046 |
42 | // Called by a Suspender to suspend, triggers stopped state. / | function suspend() public onlySuspender whenNotSuspended {
_suspended = true;
emit Suspended(msg.sender);
}
| function suspend() public onlySuspender whenNotSuspended {
_suspended = true;
emit Suspended(msg.sender);
}
| 12,603 |
12 | // generate the arcadiumSwap pair path of token -> usdc. | address[] memory path = new address[](2);
path[0] = token;
path[1] = address(usdcRewardCurrency);
uint256 usdcPriorBalance = usdcRewardCurrency.balanceOf(address(this));
require(IERC20(token).approve(address(arcadiumSwapRouter), totalTokenBalance), 'approval failed');
| address[] memory path = new address[](2);
path[0] = token;
path[1] = address(usdcRewardCurrency);
uint256 usdcPriorBalance = usdcRewardCurrency.balanceOf(address(this));
require(IERC20(token).approve(address(arcadiumSwapRouter), totalTokenBalance), 'approval failed');
| 17,521 |
0 | // ░██████╗██╗░░██╗██╗██████╗░░█████╗░ ███╗░░██╗░█████╗░██████╗░██╗░░░██╗ ██╔════╝██║░░██║██║██╔══██╗██╔══██╗ ████╗░██║██╔══██╗██╔══██╗██║░░░██║ ╚█████╗░███████║██║██████╦╝███████║ ██╔██╗██║███████║██████╔╝██║░░░██║ ░╚═══██╗██╔══██║██║██╔══██╗██╔══██║ ██║╚████║██╔══██║██╔══██╗██║░░░██║ ██████╔╝██║░░██║██║██████╦╝██║░░██║ ██║░╚███║██║░░██║██║░░██║╚██████╔╝ ╚═════╝░╚═╝░░╚═╝╚═╝╚═════╝░╚═╝░░╚═╝ ╚═╝░░╚══╝╚═╝░░╚═╝╚═╝░░╚═╝░╚═════╝░/ | interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function burn(uint256 amount) external;
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function burnFrom(address account, uint256 amount) external;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function burn(uint256 amount) external;
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function burnFrom(address account, uint256 amount) external;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 52,138 |
131 | // iOVM_L1TokenGateway / | interface iOVM_L1TokenGateway {
/**********
* Events *
**********/
event DepositInitiated(
address indexed _from,
address _to,
uint256 _amount
);
event WithdrawalFinalized(
address indexed _to,
uint256 _amount
);
/********************
* Public Functions *
********************/
function deposit(
uint _amount
)
external;
function depositTo(
address _to,
uint _amount
)
external;
/*************************
* Cross-chain Functions *
*************************/
function finalizeWithdrawal(
address _to,
uint _amount
)
external;
}
| interface iOVM_L1TokenGateway {
/**********
* Events *
**********/
event DepositInitiated(
address indexed _from,
address _to,
uint256 _amount
);
event WithdrawalFinalized(
address indexed _to,
uint256 _amount
);
/********************
* Public Functions *
********************/
function deposit(
uint _amount
)
external;
function depositTo(
address _to,
uint _amount
)
external;
/*************************
* Cross-chain Functions *
*************************/
function finalizeWithdrawal(
address _to,
uint _amount
)
external;
}
| 59,860 |
66 | // A bid to an auction must be made in the auction's desired currency. | require(newOffer.currency == targetListing.currency, "must use approved currency to bid");
| require(newOffer.currency == targetListing.currency, "must use approved currency to bid");
| 1,835 |
1 | // SafeMath div funciotn function for safe devide / | function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
| function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
| 39,928 |
1 | // Deploys a new DegenData contract. | function deployDegenData(
uint256 _id,
string memory _name,
uint256 _renameCost,
address _worlds,
address _degens,
address _payments
| function deployDegenData(
uint256 _id,
string memory _name,
uint256 _renameCost,
address _worlds,
address _degens,
address _payments
| 5,620 |
188 | // Any calls to nonReentrant after this point will fail | _status = _ENTERED;
_;
| _status = _ENTERED;
_;
| 430 |
255 | // Transfer Liquidity Asset from burn to LiquidityLocker. | liquidityAsset.safeTransfer(liquidityLocker, liquidityAssetRecoveredFromBurn);
principalOut = principalOut.sub(defaultSuffered); // Subtract rest of the Loan's principal from `principalOut`.
emit DefaultSuffered(
loan, // The Loan that suffered the default.
defaultSuffered, // Total default suffered from the Loan by the Pool after liquidation.
bptsBurned, // Amount of BPTs burned from StakeLocker.
postBurnBptBal, // Remaining BPTs in StakeLocker post-burn.
liquidityAssetRecoveredFromBurn // Amount of Liquidity Asset recovered from burning BPTs.
| liquidityAsset.safeTransfer(liquidityLocker, liquidityAssetRecoveredFromBurn);
principalOut = principalOut.sub(defaultSuffered); // Subtract rest of the Loan's principal from `principalOut`.
emit DefaultSuffered(
loan, // The Loan that suffered the default.
defaultSuffered, // Total default suffered from the Loan by the Pool after liquidation.
bptsBurned, // Amount of BPTs burned from StakeLocker.
postBurnBptBal, // Remaining BPTs in StakeLocker post-burn.
liquidityAssetRecoveredFromBurn // Amount of Liquidity Asset recovered from burning BPTs.
| 60,228 |
272 | // If the account has never borrowed the token, return 0 | uint256 lastBorrowBlock = tokenInfo.getLastBorrowBlock();
if (lastBorrowBlock == 0)
return 0;
else {
| uint256 lastBorrowBlock = tokenInfo.getLastBorrowBlock();
if (lastBorrowBlock == 0)
return 0;
else {
| 42,308 |
37 | // function to calculate the quantity of TOKEN based on the TOKEN price of bnbAmount | function calculateTokenAmount(uint256 bnbAmount) public view returns (uint256) {
uint256 tokenAmount = tokenPrice.mul(bnbAmount).div(DEFAULT_DECIMALS);
return tokenAmount;
}
| function calculateTokenAmount(uint256 bnbAmount) public view returns (uint256) {
uint256 tokenAmount = tokenPrice.mul(bnbAmount).div(DEFAULT_DECIMALS);
return tokenAmount;
}
| 41,036 |
9 | // try to recover collateral from position | if (loanPosition.positionTokenAmountFilled > 0) {
uint256 collateralAmountNeeded = amountWithdrawn - loanPosition.collateralTokenAmountFilled;
if (loanPosition.positionTokenAddressFilled != loanPosition.collateralTokenAddressFilled) {
if (!BZxVault(vaultContract).withdrawToken(
loanPosition.positionTokenAddressFilled,
oracleAddresses[loanOrder.oracleAddress],
loanPosition.positionTokenAmountFilled
)) {
revert("withdrawCollateral: BZxVault.withdrawToken (position) failed");
}
| if (loanPosition.positionTokenAmountFilled > 0) {
uint256 collateralAmountNeeded = amountWithdrawn - loanPosition.collateralTokenAmountFilled;
if (loanPosition.positionTokenAddressFilled != loanPosition.collateralTokenAddressFilled) {
if (!BZxVault(vaultContract).withdrawToken(
loanPosition.positionTokenAddressFilled,
oracleAddresses[loanOrder.oracleAddress],
loanPosition.positionTokenAmountFilled
)) {
revert("withdrawCollateral: BZxVault.withdrawToken (position) failed");
}
| 12,303 |
0 | // ===================================== proof of stake (defaults at too many tokens), No masternodes | uint public stakingRequirement = 10000000e18;
| uint public stakingRequirement = 10000000e18;
| 70,713 |
7 | // check that the vendor's token balance is enough to do swap | uint256 amountOfEthToTransfer = tokenAmountToSell / tokensPerEth;
uint256 ownerEthBalance = address(this).balance;
require(ownerEthBalance >= amountOfEthToTransfer, "Vendor has not enough funds to accept the sell request");
| uint256 amountOfEthToTransfer = tokenAmountToSell / tokensPerEth;
uint256 ownerEthBalance = address(this).balance;
require(ownerEthBalance >= amountOfEthToTransfer, "Vendor has not enough funds to accept the sell request");
| 43,282 |
33 | // This is used to allow some account to utilise transferFrom and sends tokens on your behalf, this method is disabled if emergencyLock is activated_spender Who can send tokens on your behalf_value The amount of tokens that are allowed to be sentreturn if successful returns true/ | function approve(address _spender, uint256 _value) lockAffected public returns (bool success) {
allowances[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| function approve(address _spender, uint256 _value) lockAffected public returns (bool success) {
allowances[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| 49,941 |
115 | // Constructor, takes maximum amount of wei accepted in the crowdsale. _cap Max amount of wei to be contributed / | constructor(uint256 _cap) public {
require(_cap > 0);
cap = _cap;
}
| constructor(uint256 _cap) public {
require(_cap > 0);
cap = _cap;
}
| 6,851 |
42 | // Block number when bonus SUSHI period ends. | uint256 public bonusEndBlock;
| uint256 public bonusEndBlock;
| 22,936 |
1 | // ERRORS |
error InvalidConfig(bytes32 config);
error ConfigIsLocked(bytes32 config);
error Unauthorized();
error NonExistentToken(uint256 tokenId);
|
error InvalidConfig(bytes32 config);
error ConfigIsLocked(bytes32 config);
error Unauthorized();
error NonExistentToken(uint256 tokenId);
| 29,420 |
5 | // bytes 1 to 32 are 0 because message length is stored as little endian. mload always reads 32 bytes. so we can and have to start reading recipient at offset 20 instead of 32. if we were to read at 32 the address would contain part of value and be corrupted. when reading from offset 20 mload will read 12 zero bytes followed by the 20 recipient address bytes and correctly convert it into an address. this saves some storage/gas over the alternative solution which is padding address to 32 bytes and reading recipient at offset 32. for more details | function parseMessage(bytes message)
internal
pure
returns(address recipient, uint256 amount, bytes32 txHash)
| function parseMessage(bytes message)
internal
pure
returns(address recipient, uint256 amount, bytes32 txHash)
| 1,343 |
66 | // Function used to set wallets and enable the sale. _etherWallet Address of ether wallet. _teamWallet Address of team wallet. _advisorWallet Address of advisors wallet. _bountyWallet Address of bounty wallet. _fundWallet Address of fund wallet. / | function setWallets(address _etherWallet, address _teamWallet, address _advisorWallet, address _bountyWallet, address _fundWallet) public onlyOwner inState(State.BEFORE_START) {
require(_etherWallet != address(0));
require(_teamWallet != address(0));
require(_advisorWallet != address(0));
require(_bountyWallet != address(0));
require(_fundWallet != address(0));
etherWallet = _etherWallet;
teamWallet = _teamWallet;
advisorWallet = _advisorWallet;
bountyWallet = _bountyWallet;
fundWallet = _fundWallet;
uint256 releaseTime = saleEnd + lockTime;
// Mint locked tokens
teamTokens = new TokenTimelock(token, teamWallet, releaseTime);
token.mint(teamTokens, teamCap);
// Mint released tokens
token.mint(advisorWallet, advisorCap);
token.mint(bountyWallet, bountyCap);
token.mint(fundWallet, fundCap);
currentState = State.SALE;
}
| function setWallets(address _etherWallet, address _teamWallet, address _advisorWallet, address _bountyWallet, address _fundWallet) public onlyOwner inState(State.BEFORE_START) {
require(_etherWallet != address(0));
require(_teamWallet != address(0));
require(_advisorWallet != address(0));
require(_bountyWallet != address(0));
require(_fundWallet != address(0));
etherWallet = _etherWallet;
teamWallet = _teamWallet;
advisorWallet = _advisorWallet;
bountyWallet = _bountyWallet;
fundWallet = _fundWallet;
uint256 releaseTime = saleEnd + lockTime;
// Mint locked tokens
teamTokens = new TokenTimelock(token, teamWallet, releaseTime);
token.mint(teamTokens, teamCap);
// Mint released tokens
token.mint(advisorWallet, advisorCap);
token.mint(bountyWallet, bountyCap);
token.mint(fundWallet, fundCap);
currentState = State.SALE;
}
| 4,261 |
26 | // Setup Header Area / Load free memory pointer | fillOrderCalldata := mload(0x40)
| fillOrderCalldata := mload(0x40)
| 24,003 |
24 | // we can accept 0 as minimum, this will be called only by trusted roles | uint256 minimum = 0;
ICurveDeposit_4token(curveDeposit()).add_liquidity(depositArray, minimum);
| uint256 minimum = 0;
ICurveDeposit_4token(curveDeposit()).add_liquidity(depositArray, minimum);
| 46,040 |
74 | // Returns the Name for a given token ID.Throws if the token ID does not exist. May return an empty string. tokenId uint256 ID of the token to query / | function tokenName(uint256 tokenId) external view returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: Name query for nonexistent token");
uint niftyType = _getNiftyTypeId(tokenId);
return _niftyTypeName[niftyType];
}
| function tokenName(uint256 tokenId) external view returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: Name query for nonexistent token");
uint niftyType = _getNiftyTypeId(tokenId);
return _niftyTypeName[niftyType];
}
| 15,969 |
64 | // Finally, update the _from user's swap balance | self.swap_balances[from_swaps[i]][from_swap_user_index].amount = self.swap_balances[from_swaps[i]][from_swap_user_index].amount.sub(_amount);
| self.swap_balances[from_swaps[i]][from_swap_user_index].amount = self.swap_balances[from_swaps[i]][from_swap_user_index].amount.sub(_amount);
| 72,640 |
17 | // Get the Agreement requiredSignatures map as an array of bools parallelto its signatories array. / | function _getRequiredSignaturesArray(Agreement storage agreement)
| function _getRequiredSignaturesArray(Agreement storage agreement)
| 33,235 |
75 | // Should https:github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, this function needs to emit an event with the updated approval. | allowedBurn[_from][msg.sender] = allowedBurn[_from][msg.sender].sub(_value);
_burn(_from, _value);
| allowedBurn[_from][msg.sender] = allowedBurn[_from][msg.sender].sub(_value);
_burn(_from, _value);
| 39,175 |
1,013 | // Emits a {BountyWasPaid} event. / |
function _distributeBounty(uint amount, uint validatorId) private {
TimeHelpers timeHelpers = TimeHelpers(contractManager.getContract("TimeHelpers"));
ValidatorService validatorService = ValidatorService(contractManager.getContract("ValidatorService"));
|
function _distributeBounty(uint amount, uint validatorId) private {
TimeHelpers timeHelpers = TimeHelpers(contractManager.getContract("TimeHelpers"));
ValidatorService validatorService = ValidatorService(contractManager.getContract("ValidatorService"));
| 2,839 |
211 | // Refund leftovers |
IERC20(Constants.USDC).transfer(
_sender,
IERC20(Constants.USDC).balanceOf(address(this))
);
|
IERC20(Constants.USDC).transfer(
_sender,
IERC20(Constants.USDC).balanceOf(address(this))
);
| 494 |
8 | // 0x95d89b41 = bytes4(keccak256("symbol()")) | string memory symbol = callAndParseStringReturn(token, 0x95d89b41);
if (bytes(symbol).length == 0) {
| string memory symbol = callAndParseStringReturn(token, 0x95d89b41);
if (bytes(symbol).length == 0) {
| 36,958 |
16 | // multiplies two ray, rounding half up to the nearest raya rayb ray return the result of ab, in ray/ | function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {
return halfRAY.add(a.mul(b)).div(RAY);
}
| function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {
return halfRAY.add(a.mul(b)).div(RAY);
}
| 16,059 |
65 | // sign(requestId ||lastSystemRandomness || userSeed || selected sender in group) | emit LogRequestUserRandom(
requestId,
lastRandomness,
userSeed,
grp.groupId,
getGroupPubKey(idx)
);
return requestId;
| emit LogRequestUserRandom(
requestId,
lastRandomness,
userSeed,
grp.groupId,
getGroupPubKey(idx)
);
return requestId;
| 33,882 |
19 | // Returns an Ethereum Signed Message, created from a `hash`. Thisproduces hash corresponding to the one signed with theJSON-RPC method as part of EIP-191. | * See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32")
mstore(0x1c, hash)
message := keccak256(0x00, 0x3c)
}
}
| * See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32")
mstore(0x1c, hash)
message := keccak256(0x00, 0x3c)
}
}
| 24,797 |
24 | // returns balance of our UniV3 LP, assuming 1 FRAX = 1 want, factoring curve swap fee | function balanceOfNFToptimistic() public view returns (uint256) {
(uint256 fraxBalance, uint256 usdcBalance) = principal();
uint256 fraxRebase = fraxBalance.div(1e12).mul(9996).div(DENOMINATOR); // div by 1e12 to convert frax to usdc, assume 1:1 swap on curve with fees
return fraxRebase.add(usdcBalance);
}
| function balanceOfNFToptimistic() public view returns (uint256) {
(uint256 fraxBalance, uint256 usdcBalance) = principal();
uint256 fraxRebase = fraxBalance.div(1e12).mul(9996).div(DENOMINATOR); // div by 1e12 to convert frax to usdc, assume 1:1 swap on curve with fees
return fraxRebase.add(usdcBalance);
}
| 18,295 |
52 | // USDB ERC20 Token backed by fiat reserves / | contract USDB is Ownable, ERC20, Pausable, Blacklistable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
string public currency;
address public masterMinter;
bool internal initialized;
mapping(address => uint256) internal balances;
mapping(address => mapping(address => uint256)) internal allowed;
uint256 internal totalSupply_ = 0;
mapping(address => bool) internal minters;
mapping(address => uint256) internal minterAllowed;
event Mint(address indexed minter, address indexed to, uint256 amount);
event Burn(address indexed burner, uint256 amount);
event MinterConfigured(address indexed minter, uint256 minterAllowedAmount);
event MinterRemoved(address indexed oldMinter);
event MasterMinterChanged(address indexed newMasterMinter);
function initialize(
string _name,
string _symbol,
string _currency,
uint8 _decimals,
address _masterMinter,
address _pauser,
address _blacklister,
address _owner
) public {
require(!initialized);
require(_masterMinter != address(0));
require(_pauser != address(0));
require(_blacklister != address(0));
require(_owner != address(0));
name = _name;
symbol = _symbol;
currency = _currency;
decimals = _decimals;
masterMinter = _masterMinter;
pauser = _pauser;
blacklister = _blacklister;
setOwner(_owner);
initialized = true;
}
/**
* @dev Throws if called by any account other than a minter
*/
modifier onlyMinters() {
require(minters[msg.sender] == true);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint. Must be less than or equal to the minterAllowance of the caller.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) whenNotPaused onlyMinters notBlacklisted(msg.sender) notBlacklisted(_to) public returns (bool) {
require(_to != address(0));
require(_amount > 0);
uint256 mintingAllowedAmount = minterAllowed[msg.sender];
require(_amount <= mintingAllowedAmount);
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
minterAllowed[msg.sender] = mintingAllowedAmount.sub(_amount);
emit Mint(msg.sender, _to, _amount);
emit Transfer(0x0, _to, _amount);
return true;
}
/**
* @dev Throws if called by any account other than the masterMinter
*/
modifier onlyMasterMinter() {
require(msg.sender == masterMinter);
_;
}
/**
* @dev Get minter allowance for an account
* @param minter The address of the minter
*/
function minterAllowance(address minter) public view returns (uint256) {
return minterAllowed[minter];
}
/**
* @dev Checks if account is a minter
* @param account The address to check
*/
function isMinter(address account) public view returns (bool) {
return minters[account];
}
/**
* @dev Get allowed amount for an account
* @param owner address The account owner
* @param spender address The account spender
*/
function allowance(address owner, address spender) public view returns (uint256) {
return allowed[owner][spender];
}
/**
* @dev Get totalSupply of token
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Get token balance of an account
* @param account address The account
*/
function balanceOf(address account) public view returns (uint256) {
return balances[account];
}
/**
* @dev Adds blacklisted check to approve
* @return True if the operation was successful.
*/
function approve(address _spender, uint256 _value) whenNotPaused notBlacklisted(msg.sender) notBlacklisted(_spender) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another.
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
* @return bool success
*/
function transferFrom(address _from, address _to, uint256 _value) whenNotPaused notBlacklisted(_to) notBlacklisted(msg.sender) notBlacklisted(_from) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
* @return bool success
*/
function transfer(address _to, uint256 _value) whenNotPaused notBlacklisted(msg.sender) notBlacklisted(_to) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Function to add/update a new minter
* @param minter The address of the minter
* @param minterAllowedAmount The minting amount allowed for the minter
* @return True if the operation was successful.
*/
function configureMinter(address minter, uint256 minterAllowedAmount) whenNotPaused onlyMasterMinter public returns (bool) {
minters[minter] = true;
minterAllowed[minter] = minterAllowedAmount;
emit MinterConfigured(minter, minterAllowedAmount);
return true;
}
/**
* @dev Function to remove a minter
* @param minter The address of the minter to remove
* @return True if the operation was successful.
*/
function removeMinter(address minter) onlyMasterMinter public returns (bool) {
minters[minter] = false;
minterAllowed[minter] = 0;
emit MinterRemoved(minter);
return true;
}
/**
* @dev allows a minter to burn some of its own tokens
* Validates that caller is a minter and that sender is not blacklisted
* amount is less than or equal to the minter's account balance
* @param _amount uint256 the amount of tokens to be burned
*/
function burn(uint256 _amount) whenNotPaused onlyMinters notBlacklisted(msg.sender) public {
uint256 balance = balances[msg.sender];
require(_amount > 0);
require(balance >= _amount);
totalSupply_ = totalSupply_.sub(_amount);
balances[msg.sender] = balance.sub(_amount);
emit Burn(msg.sender, _amount);
emit Transfer(msg.sender, address(0), _amount);
}
function updateMasterMinter(address _newMasterMinter) onlyOwner public {
require(_newMasterMinter != address(0));
masterMinter = _newMasterMinter;
emit MasterMinterChanged(masterMinter);
}
} | contract USDB is Ownable, ERC20, Pausable, Blacklistable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
string public currency;
address public masterMinter;
bool internal initialized;
mapping(address => uint256) internal balances;
mapping(address => mapping(address => uint256)) internal allowed;
uint256 internal totalSupply_ = 0;
mapping(address => bool) internal minters;
mapping(address => uint256) internal minterAllowed;
event Mint(address indexed minter, address indexed to, uint256 amount);
event Burn(address indexed burner, uint256 amount);
event MinterConfigured(address indexed minter, uint256 minterAllowedAmount);
event MinterRemoved(address indexed oldMinter);
event MasterMinterChanged(address indexed newMasterMinter);
function initialize(
string _name,
string _symbol,
string _currency,
uint8 _decimals,
address _masterMinter,
address _pauser,
address _blacklister,
address _owner
) public {
require(!initialized);
require(_masterMinter != address(0));
require(_pauser != address(0));
require(_blacklister != address(0));
require(_owner != address(0));
name = _name;
symbol = _symbol;
currency = _currency;
decimals = _decimals;
masterMinter = _masterMinter;
pauser = _pauser;
blacklister = _blacklister;
setOwner(_owner);
initialized = true;
}
/**
* @dev Throws if called by any account other than a minter
*/
modifier onlyMinters() {
require(minters[msg.sender] == true);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint. Must be less than or equal to the minterAllowance of the caller.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) whenNotPaused onlyMinters notBlacklisted(msg.sender) notBlacklisted(_to) public returns (bool) {
require(_to != address(0));
require(_amount > 0);
uint256 mintingAllowedAmount = minterAllowed[msg.sender];
require(_amount <= mintingAllowedAmount);
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
minterAllowed[msg.sender] = mintingAllowedAmount.sub(_amount);
emit Mint(msg.sender, _to, _amount);
emit Transfer(0x0, _to, _amount);
return true;
}
/**
* @dev Throws if called by any account other than the masterMinter
*/
modifier onlyMasterMinter() {
require(msg.sender == masterMinter);
_;
}
/**
* @dev Get minter allowance for an account
* @param minter The address of the minter
*/
function minterAllowance(address minter) public view returns (uint256) {
return minterAllowed[minter];
}
/**
* @dev Checks if account is a minter
* @param account The address to check
*/
function isMinter(address account) public view returns (bool) {
return minters[account];
}
/**
* @dev Get allowed amount for an account
* @param owner address The account owner
* @param spender address The account spender
*/
function allowance(address owner, address spender) public view returns (uint256) {
return allowed[owner][spender];
}
/**
* @dev Get totalSupply of token
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Get token balance of an account
* @param account address The account
*/
function balanceOf(address account) public view returns (uint256) {
return balances[account];
}
/**
* @dev Adds blacklisted check to approve
* @return True if the operation was successful.
*/
function approve(address _spender, uint256 _value) whenNotPaused notBlacklisted(msg.sender) notBlacklisted(_spender) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another.
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
* @return bool success
*/
function transferFrom(address _from, address _to, uint256 _value) whenNotPaused notBlacklisted(_to) notBlacklisted(msg.sender) notBlacklisted(_from) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
* @return bool success
*/
function transfer(address _to, uint256 _value) whenNotPaused notBlacklisted(msg.sender) notBlacklisted(_to) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Function to add/update a new minter
* @param minter The address of the minter
* @param minterAllowedAmount The minting amount allowed for the minter
* @return True if the operation was successful.
*/
function configureMinter(address minter, uint256 minterAllowedAmount) whenNotPaused onlyMasterMinter public returns (bool) {
minters[minter] = true;
minterAllowed[minter] = minterAllowedAmount;
emit MinterConfigured(minter, minterAllowedAmount);
return true;
}
/**
* @dev Function to remove a minter
* @param minter The address of the minter to remove
* @return True if the operation was successful.
*/
function removeMinter(address minter) onlyMasterMinter public returns (bool) {
minters[minter] = false;
minterAllowed[minter] = 0;
emit MinterRemoved(minter);
return true;
}
/**
* @dev allows a minter to burn some of its own tokens
* Validates that caller is a minter and that sender is not blacklisted
* amount is less than or equal to the minter's account balance
* @param _amount uint256 the amount of tokens to be burned
*/
function burn(uint256 _amount) whenNotPaused onlyMinters notBlacklisted(msg.sender) public {
uint256 balance = balances[msg.sender];
require(_amount > 0);
require(balance >= _amount);
totalSupply_ = totalSupply_.sub(_amount);
balances[msg.sender] = balance.sub(_amount);
emit Burn(msg.sender, _amount);
emit Transfer(msg.sender, address(0), _amount);
}
function updateMasterMinter(address _newMasterMinter) onlyOwner public {
require(_newMasterMinter != address(0));
masterMinter = _newMasterMinter;
emit MasterMinterChanged(masterMinter);
}
} | 61,101 |
56 | // Returns the current balance of the given asset. / | function checkBalance(address _asset)
| function checkBalance(address _asset)
| 26,180 |
596 | // List of addresses with privileged access / | mapping(address => uint) public privilegedAddresses;
| mapping(address => uint) public privilegedAddresses;
| 32,754 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.