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
117
// Fail if seize not allowed // Fail if borrower = liquidator //We calculate the new borrower and liquidator token balances, failing on underflow/overflow: borrowerTokensNew = accountTokens[borrower] - seizeTokens liquidatorTokensNew = accountTokens[liquidator] + seizeTokens /
(mathErr, borrowerTokensNew) = subUInt( accountTokens[borrower].tokens, seizeTokens ); if (mathErr != MathError.NO_ERROR) {
(mathErr, borrowerTokensNew) = subUInt( accountTokens[borrower].tokens, seizeTokens ); if (mathErr != MathError.NO_ERROR) {
5,038
4
// lets the owner change the current conjure routerconjureRouter_ the address of the new router/
function newConjureRouter(address payable conjureRouter_) external { require(msg.sender == factoryOwner, "Only factory owner"); require(conjureRouter_ != address(0), "No zero address for conjureRouter_"); conjureRouter = conjureRouter_; emit NewConjureRouter(conjureRouter); }
function newConjureRouter(address payable conjureRouter_) external { require(msg.sender == factoryOwner, "Only factory owner"); require(conjureRouter_ != address(0), "No zero address for conjureRouter_"); conjureRouter = conjureRouter_; emit NewConjureRouter(conjureRouter); }
54,345
137
// Selector of `log(uint256,string,address)`.
mstore(0x00, 0x7afac959) mstore(0x20, p0) mstore(0x40, 0x60) mstore(0x60, p2) writeString(0x80, p1)
mstore(0x00, 0x7afac959) mstore(0x20, p0) mstore(0x40, 0x60) mstore(0x60, p2) writeString(0x80, p1)
30,501
21
// Primary Sale /
function _canSetPrimarySaleRecipient() internal virtual override returns (bool)
function _canSetPrimarySaleRecipient() internal virtual override returns (bool)
14,533
51
// Checks if the recipient(brokerbot) has setting enabled to keep ether /
function hasSettingKeepEther(IBrokerbot recipient) public view returns (bool) { return recipient.settings() & KEEP_ETHER == KEEP_ETHER; }
function hasSettingKeepEther(IBrokerbot recipient) public view returns (bool) { return recipient.settings() & KEEP_ETHER == KEEP_ETHER; }
69,767
122
// Copy revert reason from call
assembly { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) }
assembly { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) }
42,759
365
// Calculate binary logarithm of x.Return NaN on negative x excluding -0.x quadruple precision numberreturn quadruple precision number /
function log_2 (bytes16 x) internal pure returns (bytes16) { unchecked { if (uint128 (x) > 0x80000000000000000000000000000000) return NaN; else if (x == 0x3FFF0000000000000000000000000000) return POSITIVE_ZERO; else { uint256 xExponent = uint128 (x) >> 112 & 0x7FFF; if (xExponent == 0x7FFF) return x; else { uint256 xSignifier = uint128 (x) & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF; if (xExponent == 0) xExponent = 1; else xSignifier |= 0x10000000000000000000000000000; if (xSignifier == 0) return NEGATIVE_INFINITY; bool resultNegative; uint256 resultExponent = 16495; uint256 resultSignifier; if (xExponent >= 0x3FFF) { resultNegative = false; resultSignifier = xExponent - 0x3FFF; xSignifier <<= 15; } else { resultNegative = true; if (xSignifier >= 0x10000000000000000000000000000) { resultSignifier = 0x3FFE - xExponent; xSignifier <<= 15; } else { uint256 msb = mostSignificantBit (xSignifier); resultSignifier = 16493 - msb; xSignifier <<= 127 - msb; } } if (xSignifier == 0x80000000000000000000000000000000) { if (resultNegative) resultSignifier += 1; uint256 shift = 112 - mostSignificantBit (resultSignifier); resultSignifier <<= shift; resultExponent -= shift; } else { uint256 bb = resultNegative ? 1 : 0; while (resultSignifier < 0x10000000000000000000000000000) { resultSignifier <<= 1; resultExponent -= 1; xSignifier *= xSignifier; uint256 b = xSignifier >> 255; resultSignifier += b ^ bb; xSignifier >>= 127 + b; } } return bytes16 (uint128 ((resultNegative ? 0x80000000000000000000000000000000 : 0) | resultExponent << 112 | resultSignifier & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF)); } } } }
function log_2 (bytes16 x) internal pure returns (bytes16) { unchecked { if (uint128 (x) > 0x80000000000000000000000000000000) return NaN; else if (x == 0x3FFF0000000000000000000000000000) return POSITIVE_ZERO; else { uint256 xExponent = uint128 (x) >> 112 & 0x7FFF; if (xExponent == 0x7FFF) return x; else { uint256 xSignifier = uint128 (x) & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF; if (xExponent == 0) xExponent = 1; else xSignifier |= 0x10000000000000000000000000000; if (xSignifier == 0) return NEGATIVE_INFINITY; bool resultNegative; uint256 resultExponent = 16495; uint256 resultSignifier; if (xExponent >= 0x3FFF) { resultNegative = false; resultSignifier = xExponent - 0x3FFF; xSignifier <<= 15; } else { resultNegative = true; if (xSignifier >= 0x10000000000000000000000000000) { resultSignifier = 0x3FFE - xExponent; xSignifier <<= 15; } else { uint256 msb = mostSignificantBit (xSignifier); resultSignifier = 16493 - msb; xSignifier <<= 127 - msb; } } if (xSignifier == 0x80000000000000000000000000000000) { if (resultNegative) resultSignifier += 1; uint256 shift = 112 - mostSignificantBit (resultSignifier); resultSignifier <<= shift; resultExponent -= shift; } else { uint256 bb = resultNegative ? 1 : 0; while (resultSignifier < 0x10000000000000000000000000000) { resultSignifier <<= 1; resultExponent -= 1; xSignifier *= xSignifier; uint256 b = xSignifier >> 255; resultSignifier += b ^ bb; xSignifier >>= 127 + b; } } return bytes16 (uint128 ((resultNegative ? 0x80000000000000000000000000000000 : 0) | resultExponent << 112 | resultSignifier & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF)); } } } }
36,768
115
// ========= 權限控管 =========
modifier isPlatinumContract() { require(platinum != 0x0); require(msg.sender == platinum); _; }
modifier isPlatinumContract() { require(platinum != 0x0); require(msg.sender == platinum); _; }
20,308
32
// pool 1
mapping(address => uint) pool1;
mapping(address => uint) pool1;
21,193
260
// Mints 3000 Vanguards/
function mintVanguards(uint256 numberOfTokens) external payable { require(IS_VANGUARDS_MINT_ACTIVE, "Vanguards Mint is Not Active"); require(numberOfTokens <= 5, "Max 5 Vanguards Per Transaction are allowed"); require((totalSupply()+numberOfTokens) <= 3000, "Vanguards Mint Finished"); require(msg.value == (numberOfTokens * VANGUARDS_PRICE), "Wrong Eth value sent"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); _safeMint(msg.sender, mintIndex); } }
function mintVanguards(uint256 numberOfTokens) external payable { require(IS_VANGUARDS_MINT_ACTIVE, "Vanguards Mint is Not Active"); require(numberOfTokens <= 5, "Max 5 Vanguards Per Transaction are allowed"); require((totalSupply()+numberOfTokens) <= 3000, "Vanguards Mint Finished"); require(msg.value == (numberOfTokens * VANGUARDS_PRICE), "Wrong Eth value sent"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); _safeMint(msg.sender, mintIndex); } }
36,117
74
// PO header
require(po.poNumber > 0, "PO does not exist");
require(po.poNumber > 0, "PO does not exist");
8,219
222
// 레벨 풀 일 경우 사용자는 레퍼럴에 등록되어 있어야 함
if(pool.level > 0) require(referralContract.getGrade(msg.sender) > 0, "deposit : user referral");
if(pool.level > 0) require(referralContract.getGrade(msg.sender) > 0, "deposit : user referral");
59,742
17
// Contract constructor. _implementation Address of the initial implementation. _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. /
constructor(address _implementation, bytes _data) public payable { assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation")); _setImplementation(_implementation); if(_data.length > 0) { require(_implementation.delegatecall(_data)); } }
constructor(address _implementation, bytes _data) public payable { assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation")); _setImplementation(_implementation); if(_data.length > 0) { require(_implementation.delegatecall(_data)); } }
43,704
270
// Overload {revokeRole} to track enumerable memberships /
function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.revokeRole(role, account); _roleMembers[role].remove(account); }
function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.revokeRole(role, account); _roleMembers[role].remove(account); }
6,458
13
// Register available stickers/Each element on the array represents a token ID property,/so the countryIds[1] has the type typeIds[1], shirtNumber[1] and amounts[1]/countryIds Array of country IDs/typeIds Array of type IDs/shirtNumbers Array of shirt numbers/amounts Array of amounts
function registerStickers( uint256[] memory countryIds, uint256[] memory typeIds, uint256[] memory shirtNumbers, uint256[] memory amounts
function registerStickers( uint256[] memory countryIds, uint256[] memory typeIds, uint256[] memory shirtNumbers, uint256[] memory amounts
7,766
28
// Reset allowance after paying to the smart contract
if(path[path.length-1] != NATIVE && IERC20(path[path.length-1]).allowance(address(this), addresses[1]) > 0) { Helper.safeApprove( path[path.length-1], addresses[1], 0 ); }
if(path[path.length-1] != NATIVE && IERC20(path[path.length-1]).allowance(address(this), addresses[1]) > 0) { Helper.safeApprove( path[path.length-1], addresses[1], 0 ); }
63,254
31
// Fee can only be decreased!
function changeFee(uint _fee) onlyOwner { require(_fee <= fee); fee = _fee; }
function changeFee(uint _fee) onlyOwner { require(_fee <= fee); fee = _fee; }
11,157
68
// Update alloc point when totalUsedCover updates. - Only Plan Manager can call this function. - Init pool if not initialized. _protocol Protocol address. _allocPoint New allocPoint./
{ PoolInfo storage pool = poolInfo[_protocol]; if (poolInfo[_protocol].protocol == address(0)) { initPool(_protocol); } else { updatePool(_protocol); totalAllocPoint = totalAllocPoint.sub(pool.allocPoint).add( _allocPoint ); pool.allocPoint = _allocPoint; pool.rewardDebt = pool.allocPoint.mul(accEthPerAlloc).div(1e12); } }
{ PoolInfo storage pool = poolInfo[_protocol]; if (poolInfo[_protocol].protocol == address(0)) { initPool(_protocol); } else { updatePool(_protocol); totalAllocPoint = totalAllocPoint.sub(pool.allocPoint).add( _allocPoint ); pool.allocPoint = _allocPoint; pool.rewardDebt = pool.allocPoint.mul(accEthPerAlloc).div(1e12); } }
7,267
7
// set owner to users[0] because unknown user will return 0 from userIndex this also allows owners to withdraw their own earnings using same functions as regular users
users.push(owner);
users.push(owner);
19,700
4
// mstore(add(buff, 0x20), byte(0x1f, v))
mstore(0x40, add(buff, 0x21))
mstore(0x40, add(buff, 0x21))
12,004
14
// apply actions
for (uint i = 0; i < actions.length; i++) { handleAction(actions[i]); }
for (uint i = 0; i < actions.length; i++) { handleAction(actions[i]); }
25,026
5
// Event emmited when a pool is created/pool address of the new pool/fee address of thhe commission contract
event NewGasTaxCommissionStakingPool(address indexed pool, address fee);
event NewGasTaxCommissionStakingPool(address indexed pool, address fee);
18,848
45
// utility functions/ Return an empty structreturn r The empty struct /
function nil() internal pure returns (Data memory r) { assembly { r := 0 } }
function nil() internal pure returns (Data memory r) { assembly { r := 0 } }
53,549
23
// Determine the blockReward based on inputs specifying an end date. Used on the front end to show the exact settings the Farm contract will be deployed with /
function determineBlockReward (uint256 _amount, uint256 _startBlock, uint256 _bonusEndBlock, uint256 _bonus, uint256 _endBlock) public pure returns (uint256, uint256) { uint256 bonusBlocks = _bonusEndBlock.sub(_startBlock); uint256 nonBonusBlocks = _endBlock.sub(_bonusEndBlock); uint256 effectiveBlocks = bonusBlocks.mul(_bonus).add(nonBonusBlocks); uint256 blockReward = _amount.div(effectiveBlocks); uint256 requiredAmount = blockReward.mul(effectiveBlocks); return (blockReward, requiredAmount); }
function determineBlockReward (uint256 _amount, uint256 _startBlock, uint256 _bonusEndBlock, uint256 _bonus, uint256 _endBlock) public pure returns (uint256, uint256) { uint256 bonusBlocks = _bonusEndBlock.sub(_startBlock); uint256 nonBonusBlocks = _endBlock.sub(_bonusEndBlock); uint256 effectiveBlocks = bonusBlocks.mul(_bonus).add(nonBonusBlocks); uint256 blockReward = _amount.div(effectiveBlocks); uint256 requiredAmount = blockReward.mul(effectiveBlocks); return (blockReward, requiredAmount); }
9,491
29
// clear last index
map._entries.pop(); delete map._indexes[key]; return true;
map._entries.pop(); delete map._indexes[key]; return true;
18,308
104
// Burn token /
function burn(uint256 amount) public override { _burn(msg.sender, amount); }
function burn(uint256 amount) public override { _burn(msg.sender, amount); }
37,820
83
// Set minimum fee for contract interface Transaction fees can be set by the TokenIOFeeContract Fees vary by contract interface specified `feeContract` | This method has an `internal` view self Internal storage proxying TokenIOStorage contract feeMin Minimum fee for interface contract transactions
* @return {"success" : "Returns true when successfully called from another contract"} */ function setFeeMin(Data storage self, uint feeMin) internal returns (bool success) { bytes32 id = keccak256(abi.encodePacked('fee.min', address(this))); require( self.Storage.setUint(id, feeMin), "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract." ); return true; }
* @return {"success" : "Returns true when successfully called from another contract"} */ function setFeeMin(Data storage self, uint feeMin) internal returns (bool success) { bytes32 id = keccak256(abi.encodePacked('fee.min', address(this))); require( self.Storage.setUint(id, feeMin), "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract." ); return true; }
26,740
206
// deposit underlyingAmount_ with the liquidity provider, callable by smartYield or controller
function _depositProvider(uint256 underlyingAmount_, uint256 takeFees_) external override onlySmartYieldOrController
function _depositProvider(uint256 underlyingAmount_, uint256 takeFees_) external override onlySmartYieldOrController
13,866
16
// Convert BPT to ETH value
value = bptBalance.mulTruncate( IRateProvider(platformAddress).getRate() );
value = bptBalance.mulTruncate( IRateProvider(platformAddress).getRate() );
1,377
3
// user account with big Ether balance
address public constant _CONTRACT_SHARK_ACCOUNT_2 = 0xAaAaaAAAaAaaAaAaAaaAAaAaAAAAAaAAAaaAaAa2;
address public constant _CONTRACT_SHARK_ACCOUNT_2 = 0xAaAaaAAAaAaaAaAaAaaAAaAaAAAAAaAAAaaAaAa2;
31,975
131
// Contracts are not allowed to deposit, claim or withdraw
modifier noContractsAllowed() { require(!(address(msg.sender).isContract()) && tx.origin == msg.sender, "No Contracts Allowed!"); _; }
modifier noContractsAllowed() { require(!(address(msg.sender).isContract()) && tx.origin == msg.sender, "No Contracts Allowed!"); _; }
18,826
9
// Checks if a user is staking in a SVreturn true if user is staking in the SV. Otherwise, false TODO: that might be turned into not public. It's used _userAddress instead of msg.sender because it might be called from Factory SC. /
function getUserIsStaking(address _userAddress) public view returns (bool) {
function getUserIsStaking(address _userAddress) public view returns (bool) {
29,959
4
// Gets the first block for which the refund is not active for a given `tokenId`/ tokenId The `tokenId` to query/ return _block The block beyond which the token cannot be refunded
function refundDeadlineOf(uint256 tokenId) external view returns (uint256 _block);
function refundDeadlineOf(uint256 tokenId) external view returns (uint256 _block);
25,405
6
// https:docs.soliditylang.org/en/v0.7.4/types.htmlallocating-memory-arraysSo first we need calc size of array to be returned
uint256 n = balanceOf(_owner); uint256[] memory result = new uint256[](n); for (uint16 i=0; i < n; i++) { result[i]=tokenOfOwnerByIndex(_owner, i); }
uint256 n = balanceOf(_owner); uint256[] memory result = new uint256[](n); for (uint16 i=0; i < n; i++) { result[i]=tokenOfOwnerByIndex(_owner, i); }
33,276
13
// Return largest tokenId minted. /
function maxTokenId() public view returns (uint256) { return _owners.length > 0 ? _owners.length - 1 : 0; }
function maxTokenId() public view returns (uint256) { return _owners.length > 0 ? _owners.length - 1 : 0; }
16,724
54
// Mapping from owner address to count of their tokens. /
mapping (address => uint256) private ownerToNFTokenCount;
mapping (address => uint256) private ownerToNFTokenCount;
2,352
34
// Indicates whether contribution identified by bytes32 id is already registered /
mapping (bytes32 => bool) public isContributionRegistered;
mapping (bytes32 => bool) public isContributionRegistered;
37,727
63
// Manager fee
function getPoolManagerFee(address pool) external view returns (uint256, uint256); function setPoolManagerFeeNumerator(address pool, uint256 numerator) external; function getMaximumManagerFeeNumeratorChange() external view returns (uint256); function getManagerFeeNumeratorChangeDelay() external view returns (uint256);
function getPoolManagerFee(address pool) external view returns (uint256, uint256); function setPoolManagerFeeNumerator(address pool, uint256 numerator) external; function getMaximumManagerFeeNumeratorChange() external view returns (uint256); function getManagerFeeNumeratorChangeDelay() external view returns (uint256);
45,473
235
// Gives Extensions a chance to run logic after shares are issued
__postBuySharesHook(_buyer, _investmentAmount, sharesIssued, _preBuySharesGav);
__postBuySharesHook(_buyer, _investmentAmount, sharesIssued, _preBuySharesGav);
18,580
226
// DOGE Background
dogeAssets['B']['A'].ratio = 90; dogeAssets['B']['A'].assets.push('Color 1'); dogeAssets['B']['A'].assets.push('Color 2'); dogeAssets['B']['A'].assets.push('Color 3'); dogeAssets['B']['A'].assets.push('Color 4'); dogeAssets['B']['A'].assets.push('Color 5'); dogeAssets['B']['A'].assets.push('Color 6'); dogeAssets['B']['A'].assets.push('Color 7'); dogeAssets['B']['A'].assets.push('Color 8'); dogeAssets['B']['A'].assets.push('Color 9');
dogeAssets['B']['A'].ratio = 90; dogeAssets['B']['A'].assets.push('Color 1'); dogeAssets['B']['A'].assets.push('Color 2'); dogeAssets['B']['A'].assets.push('Color 3'); dogeAssets['B']['A'].assets.push('Color 4'); dogeAssets['B']['A'].assets.push('Color 5'); dogeAssets['B']['A'].assets.push('Color 6'); dogeAssets['B']['A'].assets.push('Color 7'); dogeAssets['B']['A'].assets.push('Color 8'); dogeAssets['B']['A'].assets.push('Color 9');
28,546
51
// ======== MODIFIERS ======== // Throws if _dungeonId is not created yet. /
modifier tokenExists(uint _tokenId) { require(_tokenId < totalSupply()); _; }
modifier tokenExists(uint _tokenId) { require(_tokenId < totalSupply()); _; }
24,016
26
// Updates the time delay/newDelay The new time delay
function updateDelay(uint256 newDelay) external;
function updateDelay(uint256 newDelay) external;
16,436
9
// Returns the list of the underlying assets of all the initialized reserves It does not include dropped reservesreturn The addresses of the underlying assets of the initialized reserves // Returns the address of the underlying asset of a reserve by the reserve id as stored in the DataTypes.ReserveData struct id The id of the reserve as stored in the DataTypes.ReserveData structreturn The address of the reserve associated with id // Returns the auction related data of specific asset collection and token id. ntokenAsset The address of ntoken tokenId The token id which is currently auctioned for liquidationreturn The auction related
function getAuctionData(
function getAuctionData(
32,776
126
// calculate net amounts and fee
(uint256 toAmount, uint256 toFee) = calculateAmountAndFee(sender, amount);
(uint256 toAmount, uint256 toFee) = calculateAmountAndFee(sender, amount);
21,928
35
// ``` _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ /
library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
9,195
10
// See {BEP20-transfer}. Requirements: - `recipient` cannot be the zero address.- the caller must have a balance of at least `amount`. /
function transfer(address recipient, uint256 amount) public override virtual returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
function transfer(address recipient, uint256 amount) public override virtual returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
18,308
131
// The address of Treasury.
address public treasury;
address public treasury;
16,399
36
// see ILineOfCredit.addCredit
function addCredit( uint128 drate, uint128 frate, uint256 amount, address token, address lender
function addCredit( uint128 drate, uint128 frate, uint256 amount, address token, address lender
39,080
9
// [20]
perpetual.closeSlippageFactor.minValue, perpetual.closeSlippageFactor.maxValue, perpetual.fundingRateLimit.value, perpetual.fundingRateLimit.minValue, perpetual.fundingRateLimit.maxValue, perpetual.ammMaxLeverage.value, perpetual.ammMaxLeverage.minValue, perpetual.ammMaxLeverage.maxValue, perpetual.maxClosePriceDiscount.value, perpetual.maxClosePriceDiscount.minValue,
perpetual.closeSlippageFactor.minValue, perpetual.closeSlippageFactor.maxValue, perpetual.fundingRateLimit.value, perpetual.fundingRateLimit.minValue, perpetual.fundingRateLimit.maxValue, perpetual.ammMaxLeverage.value, perpetual.ammMaxLeverage.minValue, perpetual.ammMaxLeverage.maxValue, perpetual.maxClosePriceDiscount.value, perpetual.maxClosePriceDiscount.minValue,
44,282
267
// owner functions:/
* @dev Function to set the base URI for all token IDs. It is automatically added as a prefix to the token id in {tokenURI} to retrieve the token URI. */ function setBaseURI(string calldata baseURI_) external onlyOwner { _baseURI = baseURI_; }
* @dev Function to set the base URI for all token IDs. It is automatically added as a prefix to the token id in {tokenURI} to retrieve the token URI. */ function setBaseURI(string calldata baseURI_) external onlyOwner { _baseURI = baseURI_; }
16,154
0
// Simple constant to denote no active claim.
address constant NO_CLAIM = 0;
address constant NO_CLAIM = 0;
45,921
20
// Creates a randomness request for Chainlink VRF userProvidedSeed random number seed for the VRFreturn requestId id of the created randomness request /
function getRandomNumber(uint256 userProvidedSeed) private returns (bytes32 requestId) { require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet"); bytes32 _requestId = requestRandomness(keyHash, fee, userProvidedSeed); emit RequestedRandomness(_requestId); return _requestId; }
function getRandomNumber(uint256 userProvidedSeed) private returns (bytes32 requestId) { require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet"); bytes32 _requestId = requestRandomness(keyHash, fee, userProvidedSeed); emit RequestedRandomness(_requestId); return _requestId; }
2,887
84
// Recipient of revenues
function setBeneficiary(address payable _beneficiary) public onlyOwner { require(_beneficiary != address(0), "Not the zero address"); beneficiary = _beneficiary; }
function setBeneficiary(address payable _beneficiary) public onlyOwner { require(_beneficiary != address(0), "Not the zero address"); beneficiary = _beneficiary; }
11,337
5
// How many trailing decimals can be represented.
uint256 internal constant SCALE = 1e18;
uint256 internal constant SCALE = 1e18;
32,446
89
// Is the to address a contract? We can check the code size on that address and know.
uint length;
uint length;
30,683
5
// The minimum percentage difference between the last bid amount and the current bid.
uint8 public minBidIncrementPercentage;
uint8 public minBidIncrementPercentage;
25,773
23
// Seekers
string private constant _name = "Seekers"; string private constant _symbol = "SEEKK"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 100000000000 * 10 ** 9;
string private constant _name = "Seekers"; string private constant _symbol = "SEEKK"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 100000000000 * 10 ** 9;
4,607
37
// setName(newName);setSymbol(newSymbol);setTotalSupply(0);
setDecimals(newDecimals);
setDecimals(newDecimals);
40,978
173
// Current price
ethAmount.mul(1e18).div(tokenAmount) :
ethAmount.mul(1e18).div(tokenAmount) :
8,178
197
// Finalizes (or cancels) the strategy update by resetting the data/
function finalizeStrategyUpdate() public onlyControllerOrGovernance { _setStrategyUpdateTime(0); _setFutureStrategy(address(0)); }
function finalizeStrategyUpdate() public onlyControllerOrGovernance { _setStrategyUpdateTime(0); _setFutureStrategy(address(0)); }
18,046
131
// Refund refundable locked up amount _from address The address which you want to refund tokens fromreturn uint256 Returns amount of refunded tokens/
function refundLockedUp( address _from ) public onlyAuthorized returns (uint256)
function refundLockedUp( address _from ) public onlyAuthorized returns (uint256)
36,455
11
// deploy a new purchase contract
function deploy(string memory name, string memory symbol) public returns(address newContract){ owner = msg.sender; KingTokenNFTKing c = new KingTokenNFTKing(name,symbol,owner); address cAddr = address(c); contracts.push(cAddr); lastContractAddress = cAddr; return cAddr; }
function deploy(string memory name, string memory symbol) public returns(address newContract){ owner = msg.sender; KingTokenNFTKing c = new KingTokenNFTKing(name,symbol,owner); address cAddr = address(c); contracts.push(cAddr); lastContractAddress = cAddr; return cAddr; }
7,914
0
// this address can sign receipt to unlock account
address lockAddr;
address lockAddr;
355
20
// Mint for owner Only for ID > MAX_MMUSICIANS/
function mint_MAX_SUPPLY(address addr, uint256 id) public onlyOwner
function mint_MAX_SUPPLY(address addr, uint256 id) public onlyOwner
13,387
61
// Adds an auction to the list of open auctions._tokenId ID of the token to be put on auction. _auction Auction information of this token to open. /
function _addAuction(uint256 _tokenId, Auction _auction) internal { tokenIdToAuction[_tokenId] = _auction; emit AuctionCreated( uint256(_tokenId), uint256(_auction.price) ); }
function _addAuction(uint256 _tokenId, Auction _auction) internal { tokenIdToAuction[_tokenId] = _auction; emit AuctionCreated( uint256(_tokenId), uint256(_auction.price) ); }
2,759
5
// Save current exchange rate (immutables can't be read at construction, so we don't use `market` directly)
lastExchangeRate = ICToken(_market).exchangeRateStored();
lastExchangeRate = ICToken(_market).exchangeRateStored();
62,737
24
// to initialize staking manager with new addredd _stakingManagerAddress address of the staking smartcontract /
function setStakingManager(address _stakingManagerAddress) external onlyOwner { stakingManagerInterface = StakingManager(_stakingManagerAddress); stakingContract = _stakingManagerAddress; }
function setStakingManager(address _stakingManagerAddress) external onlyOwner { stakingManagerInterface = StakingManager(_stakingManagerAddress); stakingContract = _stakingManagerAddress; }
3,454
102
// read 4 characters
dataPtr := add(dataPtr, 4) let input := mload(dataPtr)
dataPtr := add(dataPtr, 4) let input := mload(dataPtr)
38,534
15
// Send the unknown back to the player
unknownNftCollection.safeTransferFrom(address(this), msg.sender, playerUnknown[msg.sender].value, 1, "Mengembalikan token lama Anda");
unknownNftCollection.safeTransferFrom(address(this), msg.sender, playerUnknown[msg.sender].value, 1, "Mengembalikan token lama Anda");
14,825
112
// for remove order we give makerSrc == userDst
require(removeOrder(list, maker, userDst, orderId));
require(removeOrder(list, maker, userDst, orderId));
5,915
1,477
// borrow amount
ILendingPool(lendingPool).borrow(_data.srcAddr, _data.srcAmount, borrowRateMode == 0 ? VARIABLE_RATE : borrowRateMode, AAVE_REFERRAL_CODE); uint256 destAmount; if (_data.destAddr != _data.srcAddr) { _data.dfsFeeDivider = isAutomation() ? AUTOMATIC_SERVICE_FEE : MANUAL_SERVICE_FEE; _data.user = user;
ILendingPool(lendingPool).borrow(_data.srcAddr, _data.srcAmount, borrowRateMode == 0 ? VARIABLE_RATE : borrowRateMode, AAVE_REFERRAL_CODE); uint256 destAmount; if (_data.destAddr != _data.srcAddr) { _data.dfsFeeDivider = isAutomation() ? AUTOMATIC_SERVICE_FEE : MANUAL_SERVICE_FEE; _data.user = user;
55,299
13
// Compute amount of Eth retrievable from Swap & check if above minimal Eth value provided Doing it soon prevents extra gas usage in case of failure due to useless approvale and swap
uint256[] memory uniswapAmounts = uniswapV2Router02.getAmountsOut(curveDyInDai, uniswapExchangePath); require(uniswapAmounts[1] > minETH, 'TBD/min-eth-not-reached');
uint256[] memory uniswapAmounts = uniswapV2Router02.getAmountsOut(curveDyInDai, uniswapExchangePath); require(uniswapAmounts[1] > minETH, 'TBD/min-eth-not-reached');
17,713
18
// GraphToken contract This is the implementation of the ERC20 Graph Token.The implementation exposes a Permit() function to allow for a spender to send a signed messageand approve funds to a spender following EIP2612 to make integration with other contracts easier. The token is initially owned by the deployer address that can mint tokens to create the initialdistribution. For convenience, an initial supply can be passed in the constructor that will beassigned to the deployer. The governor can add the RewardsManager contract to mint indexing rewards./
contract GraphToken is Governed, ERC20, ERC20Burnable { using SafeMath for uint256; // -- EIP712 -- // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#definition-of-domainseparator bytes32 private constant DOMAIN_TYPE_HASH = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)" ); bytes32 private constant DOMAIN_NAME_HASH = keccak256("Graph Token"); bytes32 private constant DOMAIN_VERSION_HASH = keccak256("0"); bytes32 private constant DOMAIN_SALT = 0x51f3d585afe6dfeb2af01bba0889a36c1db03beec88c6a4d0c53817069026afa; // Randomly generated salt bytes32 private constant PERMIT_TYPEHASH = keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ); // -- State -- bytes32 private DOMAIN_SEPARATOR; mapping(address => bool) private _minters; mapping(address => uint256) public nonces; // -- Events -- event MinterAdded(address indexed account); event MinterRemoved(address indexed account); modifier onlyMinter() { require(isMinter(msg.sender), "Only minter can call"); _; } /** * @dev Graph Token Contract Constructor. * @param _initialSupply Initial supply of GRT */ constructor(uint256 _initialSupply) ERC20("Graph Token", "GRT") { Governed._initialize(msg.sender); // The Governor has the initial supply of tokens _mint(msg.sender, _initialSupply); // The Governor is the default minter _addMinter(msg.sender); // EIP-712 domain separator DOMAIN_SEPARATOR = keccak256( abi.encode( DOMAIN_TYPE_HASH, DOMAIN_NAME_HASH, DOMAIN_VERSION_HASH, _getChainID(), address(this), DOMAIN_SALT ) ); } /** * @dev Approve token allowance by validating a message signed by the holder. * @param _owner Address of the token holder * @param _spender Address of the approved spender * @param _value Amount of tokens to approve the spender * @param _deadline Expiration time of the signed permit * @param _v Signature version * @param _r Signature r value * @param _s Signature s value */ function permit( address _owner, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s ) external { bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256( abi.encode( PERMIT_TYPEHASH, _owner, _spender, _value, nonces[_owner], _deadline ) ) ) ); nonces[_owner] = nonces[_owner].add(1); address recoveredAddress = ECDSA.recover(digest, abi.encodePacked(_r, _s, _v)); require(_owner == recoveredAddress, "GRT: invalid permit"); require(_deadline == 0 || block.timestamp <= _deadline, "GRT: expired permit"); _approve(_owner, _spender, _value); } /** * @dev Add a new minter. * @param _account Address of the minter */ function addMinter(address _account) external onlyGovernor { _addMinter(_account); } /** * @dev Remove a minter. * @param _account Address of the minter */ function removeMinter(address _account) external onlyGovernor { _removeMinter(_account); } /** * @dev Renounce to be a minter. */ function renounceMinter() external { _removeMinter(msg.sender); } /** * @dev Mint new tokens. * @param _to Address to send the newly minted tokens * @param _amount Amount of tokens to mint */ function mint(address _to, uint256 _amount) external onlyMinter { _mint(_to, _amount); } /** * @dev Return if the `_account` is a minter or not. * @param _account Address to check * @return True if the `_account` is minter */ function isMinter(address _account) public view returns (bool) { return _minters[_account]; } /** * @dev Add a new minter. * @param _account Address of the minter */ function _addMinter(address _account) private { _minters[_account] = true; emit MinterAdded(_account); } /** * @dev Remove a minter. * @param _account Address of the minter */ function _removeMinter(address _account) private { _minters[_account] = false; emit MinterRemoved(_account); } /** * @dev Get the running network chain ID. * @return The chain ID */ function _getChainID() private pure returns (uint256) { uint256 id; assembly { id := chainid() } return id; } }
contract GraphToken is Governed, ERC20, ERC20Burnable { using SafeMath for uint256; // -- EIP712 -- // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#definition-of-domainseparator bytes32 private constant DOMAIN_TYPE_HASH = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)" ); bytes32 private constant DOMAIN_NAME_HASH = keccak256("Graph Token"); bytes32 private constant DOMAIN_VERSION_HASH = keccak256("0"); bytes32 private constant DOMAIN_SALT = 0x51f3d585afe6dfeb2af01bba0889a36c1db03beec88c6a4d0c53817069026afa; // Randomly generated salt bytes32 private constant PERMIT_TYPEHASH = keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ); // -- State -- bytes32 private DOMAIN_SEPARATOR; mapping(address => bool) private _minters; mapping(address => uint256) public nonces; // -- Events -- event MinterAdded(address indexed account); event MinterRemoved(address indexed account); modifier onlyMinter() { require(isMinter(msg.sender), "Only minter can call"); _; } /** * @dev Graph Token Contract Constructor. * @param _initialSupply Initial supply of GRT */ constructor(uint256 _initialSupply) ERC20("Graph Token", "GRT") { Governed._initialize(msg.sender); // The Governor has the initial supply of tokens _mint(msg.sender, _initialSupply); // The Governor is the default minter _addMinter(msg.sender); // EIP-712 domain separator DOMAIN_SEPARATOR = keccak256( abi.encode( DOMAIN_TYPE_HASH, DOMAIN_NAME_HASH, DOMAIN_VERSION_HASH, _getChainID(), address(this), DOMAIN_SALT ) ); } /** * @dev Approve token allowance by validating a message signed by the holder. * @param _owner Address of the token holder * @param _spender Address of the approved spender * @param _value Amount of tokens to approve the spender * @param _deadline Expiration time of the signed permit * @param _v Signature version * @param _r Signature r value * @param _s Signature s value */ function permit( address _owner, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s ) external { bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256( abi.encode( PERMIT_TYPEHASH, _owner, _spender, _value, nonces[_owner], _deadline ) ) ) ); nonces[_owner] = nonces[_owner].add(1); address recoveredAddress = ECDSA.recover(digest, abi.encodePacked(_r, _s, _v)); require(_owner == recoveredAddress, "GRT: invalid permit"); require(_deadline == 0 || block.timestamp <= _deadline, "GRT: expired permit"); _approve(_owner, _spender, _value); } /** * @dev Add a new minter. * @param _account Address of the minter */ function addMinter(address _account) external onlyGovernor { _addMinter(_account); } /** * @dev Remove a minter. * @param _account Address of the minter */ function removeMinter(address _account) external onlyGovernor { _removeMinter(_account); } /** * @dev Renounce to be a minter. */ function renounceMinter() external { _removeMinter(msg.sender); } /** * @dev Mint new tokens. * @param _to Address to send the newly minted tokens * @param _amount Amount of tokens to mint */ function mint(address _to, uint256 _amount) external onlyMinter { _mint(_to, _amount); } /** * @dev Return if the `_account` is a minter or not. * @param _account Address to check * @return True if the `_account` is minter */ function isMinter(address _account) public view returns (bool) { return _minters[_account]; } /** * @dev Add a new minter. * @param _account Address of the minter */ function _addMinter(address _account) private { _minters[_account] = true; emit MinterAdded(_account); } /** * @dev Remove a minter. * @param _account Address of the minter */ function _removeMinter(address _account) private { _minters[_account] = false; emit MinterRemoved(_account); } /** * @dev Get the running network chain ID. * @return The chain ID */ function _getChainID() private pure returns (uint256) { uint256 id; assembly { id := chainid() } return id; } }
21,857
21
// parse string like "integer integer..." into array of integers[number]
function _parseResponse(string memory _a, uint number) internal pure returns (uint[] memory) { bytes memory bresult = bytes(_a); uint[] memory resInt = new uint[](number); uint idx = 0; uint mint = 0; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 32) { // ' ' delimiter resInt[idx++] = mint; mint = 0; if (idx == number) return resInt; } } resInt[idx++] = mint; return resInt; }
function _parseResponse(string memory _a, uint number) internal pure returns (uint[] memory) { bytes memory bresult = bytes(_a); uint[] memory resInt = new uint[](number); uint idx = 0; uint mint = 0; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 32) { // ' ' delimiter resInt[idx++] = mint; mint = 0; if (idx == number) return resInt; } } resInt[idx++] = mint; return resInt; }
41,198
65
// Get the account balance of another account with address _owner
function balanceOf(address _owner) constant external returns (uint256 balance);
function balanceOf(address _owner) constant external returns (uint256 balance);
3,808
4
// ab - resMod
prodDiv2_256 := sub(prodDiv2_256, gt(resMod, prodMod2_256)) prodMod2_256 := sub(prodMod2_256, resMod)
prodDiv2_256 := sub(prodDiv2_256, gt(resMod, prodMod2_256)) prodMod2_256 := sub(prodMod2_256, resMod)
30,590
2
// Modifier to protect an initializer function from being invoked twice. /
modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true;
modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true;
201
143
// Burns remaining tokens which are not sold during crowdsale /
function burnRemainingTokens() public onlyOwner
function burnRemainingTokens() public onlyOwner
23,615
4
// A Whitelist contract that can be locked and unlocked. Provides a modifierto check for locked state plus functions and events. The contract is never locked forwhitelisted addresses. The contracts starts off unlocked and can be locked andthen unlocked a single time. Once unlocked, the contract can never be locked back. Base contract which allows children to implement an emergency stop mechanism. /
contract LockableWhitelisted is Whitelist { event Locked(); event Unlocked(); bool public locked = false; bool private unlockedOnce = false; /** * @dev Modifier to make a function callable only when the contract is not locked * or the caller is whitelisted. */ modifier whenNotLocked(address _address) { require(!locked || whitelist[_address]); _; } /** * @dev Returns true if the specified address is whitelisted. * @param _address The address to check for whitelisting status. */ function isWhitelisted(address _address) public view returns (bool) { return whitelist[_address]; } /** * @dev Called by the owner to lock. */ function lock() onlyOwner public { require(!unlockedOnce); if (!locked) { locked = true; emit Locked(); } } /** * @dev Called by the owner to unlock. */ function unlock() onlyOwner public { if (locked) { locked = false; unlockedOnce = true; emit Unlocked(); } } }
contract LockableWhitelisted is Whitelist { event Locked(); event Unlocked(); bool public locked = false; bool private unlockedOnce = false; /** * @dev Modifier to make a function callable only when the contract is not locked * or the caller is whitelisted. */ modifier whenNotLocked(address _address) { require(!locked || whitelist[_address]); _; } /** * @dev Returns true if the specified address is whitelisted. * @param _address The address to check for whitelisting status. */ function isWhitelisted(address _address) public view returns (bool) { return whitelist[_address]; } /** * @dev Called by the owner to lock. */ function lock() onlyOwner public { require(!unlockedOnce); if (!locked) { locked = true; emit Locked(); } } /** * @dev Called by the owner to unlock. */ function unlock() onlyOwner public { if (locked) { locked = false; unlockedOnce = true; emit Unlocked(); } } }
49,261
198
// // Sets new fees depositFee_ deposit fee in ppm borrowFee_ borrow fee in ppm adminFee_ admin fee in ppm /
function setFees ( uint256 depositFee_, uint256 borrowFee_, uint256 adminFee_ ) public
function setFees ( uint256 depositFee_, uint256 borrowFee_, uint256 adminFee_ ) public
31,362
108
// calculate the address of a child contract given its salt
function computeAddress2(uint256 salt) external view returns (address child) { assembly { let data := mload(0x40) mstore(data, add( 0xff00000000000000000000000000000000000000000000000000000000000000, shl(0x58, address()) ) ) mstore(add(data, 21), salt) mstore(add(data, 53), add( add( 0x746d000000000000000000000000000000000000000000000000000000000000, shl(0x80, address()) ), 0x3318585733ff6000526015600bf30000 ) ) mstore(add(data, 53), keccak256(add(data, 53), 30)) child := and(keccak256(data, 85), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) }
function computeAddress2(uint256 salt) external view returns (address child) { assembly { let data := mload(0x40) mstore(data, add( 0xff00000000000000000000000000000000000000000000000000000000000000, shl(0x58, address()) ) ) mstore(add(data, 21), salt) mstore(add(data, 53), add( add( 0x746d000000000000000000000000000000000000000000000000000000000000, shl(0x80, address()) ), 0x3318585733ff6000526015600bf30000 ) ) mstore(add(data, 53), keccak256(add(data, 53), 30)) child := and(keccak256(data, 85), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) }
15,354
44
// Function to check which interfaces are suported by this contract. _interfaceID Id of the interface. /
function supportsInterface( bytes4 _interfaceID ) external view returns (bool)
function supportsInterface( bytes4 _interfaceID ) external view returns (bool)
25,071
1,284
// Price requests always go in the next round, so add 1 to the computed current round.
uint256 nextRoundId = currentRoundId.add(1); priceRequests[priceRequestId] = PriceRequest({ identifier: identifier, time: time,
uint256 nextRoundId = currentRoundId.add(1); priceRequests[priceRequestId] = PriceRequest({ identifier: identifier, time: time,
1,976
55
// Retrieve the bid from the bidder If ETH, this reverts if the bidder did not attach enough If ERC-20, this reverts if the bidder did not approve the ERC20TransferHelper or does not own the specified amount
_handleIncomingTransfer(_amount, currency);
_handleIncomingTransfer(_amount, currency);
41,657
89
// Recover the source address
address source = source(message, signature);
address source = source(message, signature);
56,244
4
// Emitted when the state of a reserve is updated. NOTE: This event is actually declaredin the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal,the event will actually be fired by the LendPool contract. The event is therefore replicated here so itgets added to the LendPool ABI asset The address of the underlying asset of the reserve liquidityRates The new liquidity rate variableBorrowRate The new variable borrow rate liquidityIndices The new liquidity index variableBorrowIndex The new variable borrow index // Deposits an `amount` of underlying asset into the reserve, receiving in return overlying mTokens.- E.g. User
function finalizeTransfer( address asset, address from, address to,
function finalizeTransfer( address asset, address from, address to,
13,541
44
// import '../libraries/UniswapV2Library.sol';
library UniswapV2Library { using SafeMath for uint; // 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, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } // calculates the CREATE2 address for a pair without making any external calls function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } // fetches and sorts the reserves for a pair function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) { (address token0,) = sortTokens(tokenA, tokenB); (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) { require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); amountB = amountA.mul(reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) { require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) { require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } } // performs chained getAmountIn calculations on any number of pairs function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[amounts.length - 1] = amountOut; for (uint i = path.length - 1; i > 0; i--) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } }
library UniswapV2Library { using SafeMath for uint; // 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, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } // calculates the CREATE2 address for a pair without making any external calls function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } // fetches and sorts the reserves for a pair function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) { (address token0,) = sortTokens(tokenA, tokenB); (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) { require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); amountB = amountA.mul(reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) { require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) { require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } } // performs chained getAmountIn calculations on any number of pairs function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[amounts.length - 1] = amountOut; for (uint i = path.length - 1; i > 0; i--) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } }
5,801
25
// Get current queue size
function getQueueLength() public view returns (uint) { return queue.length - currentReceiverIndex; }
function getQueueLength() public view returns (uint) { return queue.length - currentReceiverIndex; }
19,243
46
// Update actualWithdrawAmount
actualWithdrawAmount = treasuryBalance;
actualWithdrawAmount = treasuryBalance;
54,232
54
// the collateral is transferred to the stabilityPool and is not used as collateral anymore
factory.updateTotalCollateral(address(token_cache), recordedCollateral, false); factory.updateTotalDebt(_debt, false); stabilityPool.liquidate();
factory.updateTotalCollateral(address(token_cache), recordedCollateral, false); factory.updateTotalDebt(_debt, false); stabilityPool.liquidate();
17,221
452
// round 43
ark(i, q, 4267692623754666261749551533667592242661271409704769363166965280715887854739); sbox_partial(i, q); mix(i, q);
ark(i, q, 4267692623754666261749551533667592242661271409704769363166965280715887854739); sbox_partial(i, q); mix(i, q);
9,349
1
// require(num == 100, "num is error");
name = _name; owner = _owner;
name = _name; owner = _owner;
9,248
51
// 获取实际需要的清算数量
function getLiquidateAmount(uint id, uint y1) external view returns (uint256, uint256) { uint256 y2 = y1;//y2为实际清算额度 uint256 y = Y(id);//y为剩余清算额度 require(y1 <= y, "exceed max liquidate amount"); //剩余额度小于一次清算量,将剩余额度全部清算 IBondData b = bondData(id); uint decUnit = 10 ** uint(IERC20Detailed(b.crowdToken()).decimals()); if (y <= b.partialLiquidateAmount()) { y2 = y; } else { require(y1 >= decUnit, "below min liquidate amount");//设置最小清算额度为1单位 } uint256 x = calcLiquidatePawnAmount(id, y2); return (y2, x); }
function getLiquidateAmount(uint id, uint y1) external view returns (uint256, uint256) { uint256 y2 = y1;//y2为实际清算额度 uint256 y = Y(id);//y为剩余清算额度 require(y1 <= y, "exceed max liquidate amount"); //剩余额度小于一次清算量,将剩余额度全部清算 IBondData b = bondData(id); uint decUnit = 10 ** uint(IERC20Detailed(b.crowdToken()).decimals()); if (y <= b.partialLiquidateAmount()) { y2 = y; } else { require(y1 >= decUnit, "below min liquidate amount");//设置最小清算额度为1单位 } uint256 x = calcLiquidatePawnAmount(id, y2); return (y2, x); }
42,064
85
// When tokens become transferable.
uint256 cliff = block.timestamp + (10 * month);
uint256 cliff = block.timestamp + (10 * month);
42,246
20
// approve should be called when allowed[_spender] == 0. To incrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.sol /
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
20,251
92
// 31 IN DATA / SET DATA / GET DATA / STRING / PUBLIC / ONLY OWNER / CONSTANT
string inData_31 = " une première phrase " ;
string inData_31 = " une première phrase " ;
5,807
201
// Write record NonMutableStorage data /
function modifyNonMutableStorage( bytes32 _idxHash, bytes32 _nonMutableStorage1,
function modifyNonMutableStorage( bytes32 _idxHash, bytes32 _nonMutableStorage1,
32,828
226
// Reset for the next call
maggotAmountToBeMigrated = 0;
maggotAmountToBeMigrated = 0;
16,879
64
// ACTIONS
state_peggyId = _peggyId; state_powerThreshold = _powerThreshold; state_lastValsetCheckpoint = newCheckpoint;
state_peggyId = _peggyId; state_powerThreshold = _powerThreshold; state_lastValsetCheckpoint = newCheckpoint;
69,320
1
// Event published when a token is staked.
event Locked(uint256 tokenId);
event Locked(uint256 tokenId);
40,133