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
89
// set the tokenURI of a token with no extension.Can only be called by owner/admin. /
function setTokenURI(uint256 tokenId, string calldata uri) external;
function setTokenURI(uint256 tokenId, string calldata uri) external;
9,832
111
// auction ending price
FPI.FixedPointInt memory endingPrice = _vaultCollateral.div(_vaultDebt);
FPI.FixedPointInt memory endingPrice = _vaultCollateral.div(_vaultDebt);
24,396
238
// the price to mint a token
uint256 public constant MINT_PRICE = 60000000000000000; // 0.06 Ether
uint256 public constant MINT_PRICE = 60000000000000000; // 0.06 Ether
55,450
72
// Trim positions
bytes memory positionsEncoded = abi.encode(positions); assembly { mstore(add(positionsEncoded, 0x40), currentPositionIdx) }
bytes memory positionsEncoded = abi.encode(positions); assembly { mstore(add(positionsEncoded, 0x40), currentPositionIdx) }
8,397
1
// ERC223 functions and events
function balanceOf(address who) public constant returns (uint); function totalSupply() constant public returns (uint256 _supply); function transfer(address to, uint value) public returns (bool ok); function transfer(address to, uint value, bytes data) public returns (bool ok); function transfer(address to, uint value, bytes data, string customFallback) public returns (bool ok); event Transfer(address indexed from, address indexed to, uint value, bytes indexed data);
function balanceOf(address who) public constant returns (uint); function totalSupply() constant public returns (uint256 _supply); function transfer(address to, uint value) public returns (bool ok); function transfer(address to, uint value, bytes data) public returns (bool ok); function transfer(address to, uint value, bytes data, string customFallback) public returns (bool ok); event Transfer(address indexed from, address indexed to, uint value, bytes indexed data);
78,283
185
// Mints over this amount automatically rebase. 18 decimals.
uint256 public rebaseThreshold; OUSD oUSD;
uint256 public rebaseThreshold; OUSD oUSD;
75,093
40
// calculate token amount
uint256 bonusMultiplier = getBonusMultiplier(weiAmountSent); uint256 newTokens = weiAmountSent.mul(tokenBaseRate).mul(bonusMultiplier).div(100);
uint256 bonusMultiplier = getBonusMultiplier(weiAmountSent); uint256 newTokens = weiAmountSent.mul(tokenBaseRate).mul(bonusMultiplier).div(100);
36,328
50
// winnerFee to scientists
developerAddr.transfer(toScien);
developerAddr.transfer(toScien);
21,626
49
// Foundation bytes4(keccak256('getFees(uint256)')) == 0xd5a06d4c
interfaceId == 0xd5a06d4c ||
interfaceId == 0xd5a06d4c ||
17,592
32
// Send claimable license fees to address and record the claimaddress The address to claim for
function _claim(address user) private nonReentrant { uint256 claimableUsdc = _claimable(user); require(claimableUsdc > 0, 'NO FEES TO CLAIM'); // @dev Transfer USDC to user TransferHelper.safeTransfer(USDC, user, claimableUsdc); // @dev Update USDC balance usdcBalance = IERC20(USDC).balanceOf(address(this)); // @dev Update last claim block lastClaimBlock[user] = block.number - 1; }
function _claim(address user) private nonReentrant { uint256 claimableUsdc = _claimable(user); require(claimableUsdc > 0, 'NO FEES TO CLAIM'); // @dev Transfer USDC to user TransferHelper.safeTransfer(USDC, user, claimableUsdc); // @dev Update USDC balance usdcBalance = IERC20(USDC).balanceOf(address(this)); // @dev Update last claim block lastClaimBlock[user] = block.number - 1; }
12,791
1
// overhead of forwarder verify+signature, plus hub overhead.
uint256 constant public FORWARDER_HUB_OVERHEAD = 50000;
uint256 constant public FORWARDER_HUB_OVERHEAD = 50000;
10,174
0
// The amount that was loaned, in pence GBP. /
uint public amount;
uint public amount;
43,427
78
// bot/sniper penalty.
if(earlyBuyPenaltyInEffect() && automatedMarketMakerPairs[from] && !automatedMarketMakerPairs[to] && buyTotalFees > 0){ if(!boughtEarly[to]){ boughtEarly[to] = true; botsCaught += 1; emit CaughtEarlyBuyer(to); }
if(earlyBuyPenaltyInEffect() && automatedMarketMakerPairs[from] && !automatedMarketMakerPairs[to] && buyTotalFees > 0){ if(!boughtEarly[to]){ boughtEarly[to] = true; botsCaught += 1; emit CaughtEarlyBuyer(to); }
20,401
182
// Split off from `nonReentrant` to keep contract below the 24 KB size limit.Saves space because function modifier code is "inlined" into every function with the modifier).In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit. /
function _beforeNonReentrant(bool localOnly) private { require(_notEntered, "re-entered"); if (!localOnly) comptroller._beforeNonReentrant(); _notEntered = false; }
function _beforeNonReentrant(bool localOnly) private { require(_notEntered, "re-entered"); if (!localOnly) comptroller._beforeNonReentrant(); _notEntered = false; }
39,399
0
// Punter who made the most recent bet
address public punterAddress;
address public punterAddress;
44,083
351
// Smart contract owner only function.ERC2981 royalty standard implementation function.It is upto the marketplace to honour this standard.Function sets royalties for the entire collection for secondary sales.To set royalties for the entire collection,enter the royalty receiver's address in the receiver field andenter the basis points in the basisPoints field.Basis points limit is 10000, 500 basis points will mean 5% royalties on each sale.To receive royalties to a payment splitter smart contract,enter the payment splitter smart contract's contract address in the receiver field. /
function setCollectionLevelRoyalties(address receiver, uint96 basisPoints) public onlyOwner { _setDefaultRoyalty(receiver, basisPoints); }
function setCollectionLevelRoyalties(address receiver, uint96 basisPoints) public onlyOwner { _setDefaultRoyalty(receiver, basisPoints); }
27,430
13
// special case for 0 sell amount
if (_sellAmount == 0) return 0;
if (_sellAmount == 0) return 0;
37,472
36
// Calculates the geometric mean of x and y, i.e. $$sqrt(xy)$$, rounding down.//Requirements:/ - xy must fit within `MAX_UD60x18`, lest it overflows.//x The first operand as an UD60x18 number./y The second operand as an UD60x18 number./ return result The result as an UD60x18 number.
function gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { uint256 xUint = unwrap(x); uint256 yUint = unwrap(y); if (xUint == 0 || yUint == 0) { return ZERO; } unchecked { // Checking for overflow this way is faster than letting Solidity do it. uint256 xyUint = xUint * yUint; if (xyUint / xUint != yUint) { revert PRBMathUD60x18__GmOverflow(x, y); } // We don't need to multiply the result by `UNIT` here because the x*y product had picked up a factor of `UNIT` // during multiplication. See the comments in the `prbSqrt` function. result = wrap(prbSqrt(xyUint)); } }
function gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { uint256 xUint = unwrap(x); uint256 yUint = unwrap(y); if (xUint == 0 || yUint == 0) { return ZERO; } unchecked { // Checking for overflow this way is faster than letting Solidity do it. uint256 xyUint = xUint * yUint; if (xyUint / xUint != yUint) { revert PRBMathUD60x18__GmOverflow(x, y); } // We don't need to multiply the result by `UNIT` here because the x*y product had picked up a factor of `UNIT` // during multiplication. See the comments in the `prbSqrt` function. result = wrap(prbSqrt(xyUint)); } }
5,495
5
// Compute optimal deposit amount helper/amtA amount of token A desired to deposit/amtB amonut of token B desired to deposit/resA amount of token A in reserve/resB amount of token B in reserve
function _optimalDepositA( uint256 amtA, uint256 amtB, uint256 resA, uint256 resB
function _optimalDepositA( uint256 amtA, uint256 amtB, uint256 resA, uint256 resB
2,564
2
// Proxy Gives the possibility to delegate any call to a foreign implementation. /
contract Proxy { address public implementation; function upgradeTo(address _address) public { implementation = _address; } /** * @dev Fallback function allowing to perform a delegatecall to the given implementation. * This function will return whatever the implementation call returns */ function () external payable { address _impl = implementation; require(_impl != address(0)); assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize) let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0) let size := returndatasize returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } } }
contract Proxy { address public implementation; function upgradeTo(address _address) public { implementation = _address; } /** * @dev Fallback function allowing to perform a delegatecall to the given implementation. * This function will return whatever the implementation call returns */ function () external payable { address _impl = implementation; require(_impl != address(0)); assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize) let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0) let size := returndatasize returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } } }
2,295
48
// Set token offering to approve allowance for offering contract to distribute tokensofferingAddr Address of token offering contract amountForSale Amount of tokens for sale, set 0 to max out /
function setTokenOffering(address offeringAddr, uint256 amountForSale) external onlyOwner onlyTokenOfferingAddrNotSet { require(!transferEnabled); uint256 amount = (amountForSale == 0) ? TOKEN_OFFERING_ALLOWANCE : amountForSale; require(amount <= TOKEN_OFFERING_ALLOWANCE); approve(offeringAddr, amount); tokenOfferingAddr = offeringAddr; }
function setTokenOffering(address offeringAddr, uint256 amountForSale) external onlyOwner onlyTokenOfferingAddrNotSet { require(!transferEnabled); uint256 amount = (amountForSale == 0) ? TOKEN_OFFERING_ALLOWANCE : amountForSale; require(amount <= TOKEN_OFFERING_ALLOWANCE); approve(offeringAddr, amount); tokenOfferingAddr = offeringAddr; }
42,457
29
// reserve token
address public reserveToken;
address public reserveToken;
26,939
275
// get underlying token index
(isUnderlying, underlyingIndex) = curveReg.isUnderlyingToken( swapAddress, toTokenAddress ); if (isUnderlying) { crvTokensBought = _enterCurve( swapAddress, tokensBought, underlyingIndex
(isUnderlying, underlyingIndex) = curveReg.isUnderlyingToken( swapAddress, toTokenAddress ); if (isUnderlying) { crvTokensBought = _enterCurve( swapAddress, tokensBought, underlyingIndex
16,286
269
// Reserve 125 Pandimensionals for team - Giveaways/Prizes etc
uint public pandimensionalReserve = 125; event pandimensionalNameChange(address _by, uint _tokenId, string _name); event licenseisLocked(string _licenseText);
uint public pandimensionalReserve = 125; event pandimensionalNameChange(address _by, uint _tokenId, string _name); event licenseisLocked(string _licenseText);
10,308
38
// Claims any rewards for the developers, if set
function claimTips() public { require(msg.sender == devaddr, "dev: wut?"); require(tips > 0, "dev: broke"); uint256 claimable = tips; // devPaid = devPaid.add(claimable); tips = 0; safeRewardsTransfer(devaddr, claimable); }
function claimTips() public { require(msg.sender == devaddr, "dev: wut?"); require(tips > 0, "dev: broke"); uint256 claimable = tips; // devPaid = devPaid.add(claimable); tips = 0; safeRewardsTransfer(devaddr, claimable); }
25,613
54
// Current number of addresses on the premint list
uint16 premintListCount;
uint16 premintListCount;
34,388
22
// push the strategy to the array of strategies
tokenStrategies[_token].strategies.push(_strategy);
tokenStrategies[_token].strategies.push(_strategy);
19,985
80
// A method to add a stakeholder._stakeholder The stakeholder to add./
function addStakeholder(address _stakeholder) private
function addStakeholder(address _stakeholder) private
34,308
34
// Math errors/ 0x40: Math operator caused an underflow.
Underflow,
Underflow,
18,518
5
// @getTotalTasks returns total Number of Tasks that are registered (approved + not-approved + complete).
function getTotalTasks() external view returns (uint);
function getTotalTasks() external view returns (uint);
21,995
11
// Destroys `tokenId`.The approval is cleared when the token is burned. Requirements: - `tokenId` must exist.
* Emits a {Transfer} event. */ function burn(uint256 _tokenId) public onlyRole(BURNER_ROLE) { // Delegate to internal OpenZeppelin burn function _burn(_tokenId); }
* Emits a {Transfer} event. */ function burn(uint256 _tokenId) public onlyRole(BURNER_ROLE) { // Delegate to internal OpenZeppelin burn function _burn(_tokenId); }
3,895
1
// Threshold can only be 0 at initialization. Check ensures that setup function can only be called once.
require(threshold == 0, "GS200");
require(threshold == 0, "GS200");
24,305
2
// Total number of seats in the game
uint256 public constant TOTAL_SEATS = 4;
uint256 public constant TOTAL_SEATS = 4;
23,535
25
// get the balance of a user./token The token type/ return The balance
function getBalance(ERC20 token, address user) public view returns(uint) { if (token == ETH_TOKEN_ADDRESS) return user.balance; else return token.balanceOf(user); }
function getBalance(ERC20 token, address user) public view returns(uint) { if (token == ETH_TOKEN_ADDRESS) return user.balance; else return token.balanceOf(user); }
16,744
52
// instantiate SafeMath library
using SafeMath for uint; IERC20 internal weth; //represents weth. IERC20 internal token; //represents the project's token which should have a weth pair on uniswap IERC20 internal lpToken; //lpToken for liquidity provisioning address internal uToken1; //utility token address internal uToken2; //utility token for migration address internal platformWallet; //fee receiver uint internal scalar = 10**36; //unit for scaling
using SafeMath for uint; IERC20 internal weth; //represents weth. IERC20 internal token; //represents the project's token which should have a weth pair on uniswap IERC20 internal lpToken; //lpToken for liquidity provisioning address internal uToken1; //utility token address internal uToken2; //utility token for migration address internal platformWallet; //fee receiver uint internal scalar = 10**36; //unit for scaling
46,733
0
// Non player charactor
address private npc;
address private npc;
7,058
28
// We have enough tokens, execute the transfer
balances[msg.sender] = balances[msg.sender].sub(totalTokensToTransfer); for (i = 0; i < destinations.length; i++){
balances[msg.sender] = balances[msg.sender].sub(totalTokensToTransfer); for (i = 0; i < destinations.length; i++){
18,351
1
// Should return whether the signature provided is valid for the provided data data Arbitrary length data signed on the behalf of address(this) signature Signature byte array associated with _datareturn magicValueMUST return the bytes4 magic value 0x20c13b0b when function passes.MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)MUST allow external calls /
function isValidSignature(bytes calldata data, bytes calldata signature) external view returns (bytes4 magicValue);
function isValidSignature(bytes calldata data, bytes calldata signature) external view returns (bytes4 magicValue);
13,482
2
// require(msg.sender == ownerA || msg.sender == ownerB, "owners can only swap");
require( DAI.balanceOf(_fromAddress) >= 20, "Insufficient balance" ); Swap storage swap_ = swapOrder[swapIndex]; swap_.amountIn = _amount; swap_.currencyDecimal = decimals; swap_.owner = _fromAddress; swapIndex++; (bool status) = DAI.transferFrom(_fromAddress, address(this), _amount);
require( DAI.balanceOf(_fromAddress) >= 20, "Insufficient balance" ); Swap storage swap_ = swapOrder[swapIndex]; swap_.amountIn = _amount; swap_.currencyDecimal = decimals; swap_.owner = _fromAddress; swapIndex++; (bool status) = DAI.transferFrom(_fromAddress, address(this), _amount);
17,337
187
// key for funding fee amount per sizemarket the market to checkcollateralToken the collateralToken to get the key forisLong whether to get the key for the long or short side return key for funding fee amount per size
function fundingFeeAmountPerSizeKey(address market, address collateralToken, bool isLong) internal pure returns (bytes32) { return keccak256(abi.encode( FUNDING_FEE_AMOUNT_PER_SIZE, market, collateralToken, isLong )); }
function fundingFeeAmountPerSizeKey(address market, address collateralToken, bool isLong) internal pure returns (bytes32) { return keccak256(abi.encode( FUNDING_FEE_AMOUNT_PER_SIZE, market, collateralToken, isLong )); }
30,890
69
// Should return filled values leftOrder left order rightOrder right order leftOrderFill current fill of the left order (0 if order is unfilled) rightOrderFill current fill of the right order (0 if order is unfilled) /
function fillOrder(LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder, uint leftOrderFill, uint rightOrderFill) internal pure returns (FillResult memory) { (uint leftMakeValue, uint leftTakeValue) = LibOrder.calculateRemaining(leftOrder, leftOrderFill); (uint rightMakeValue, uint rightTakeValue) = LibOrder.calculateRemaining(rightOrder, rightOrderFill); //We have 3 cases here: if (rightTakeValue > leftMakeValue) { //1nd: left order should be fully filled return fillLeft(leftMakeValue, leftTakeValue, rightOrder.makeAsset.value, rightOrder.takeAsset.value); }//2st: right order should be fully filled or 3d: both should be fully filled if required values are the same return fillRight(leftOrder.makeAsset.value, leftOrder.takeAsset.value, rightMakeValue, rightTakeValue); }
function fillOrder(LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder, uint leftOrderFill, uint rightOrderFill) internal pure returns (FillResult memory) { (uint leftMakeValue, uint leftTakeValue) = LibOrder.calculateRemaining(leftOrder, leftOrderFill); (uint rightMakeValue, uint rightTakeValue) = LibOrder.calculateRemaining(rightOrder, rightOrderFill); //We have 3 cases here: if (rightTakeValue > leftMakeValue) { //1nd: left order should be fully filled return fillLeft(leftMakeValue, leftTakeValue, rightOrder.makeAsset.value, rightOrder.takeAsset.value); }//2st: right order should be fully filled or 3d: both should be fully filled if required values are the same return fillRight(leftOrder.makeAsset.value, leftOrder.takeAsset.value, rightMakeValue, rightTakeValue); }
66,593
3
// bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) /
bytes32 internal constant IMPLEMENTATION_KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
bytes32 internal constant IMPLEMENTATION_KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
5,535
33
// SBTC Token
i = 2;
i = 2;
39,368
6
// LiquidationManager key
bytes32 private constant LIQUIDATION_MANAGER = keccak256("LIQUIDATION_MANAGER");
bytes32 private constant LIQUIDATION_MANAGER = keccak256("LIQUIDATION_MANAGER");
37,822
16
// All card tokenArray (not exceeding 2^32-1)
Card[] public cardArray;
Card[] public cardArray;
50,758
23
// if yes: mint to address if no: create and mint
address wrapped_asset = wrappedAssets[asset_id]; if (wrapped_asset == address(0)) { uint8 asset_decimals = data.toUint8(103); wrapped_asset = deployWrappedAsset(asset_id, token_chain, token_address, asset_decimals); }
address wrapped_asset = wrappedAssets[asset_id]; if (wrapped_asset == address(0)) { uint8 asset_decimals = data.toUint8(103); wrapped_asset = deployWrappedAsset(asset_id, token_chain, token_address, asset_decimals); }
34,436
13
// returns start of current Epoch
function currentEpoch() public view returns (uint256) { return block.timestamp/eDuration*eDuration; }
function currentEpoch() public view returns (uint256) { return block.timestamp/eDuration*eDuration; }
2,596
43
// Zero buy tax
uint256 public constant buyLiquidityFee = 0; uint256 public constant buyMarketingFee = 0; uint256 public constant buyDevFee = 0; uint256 public constant buyTotalFees = 0;
uint256 public constant buyLiquidityFee = 0; uint256 public constant buyMarketingFee = 0; uint256 public constant buyDevFee = 0; uint256 public constant buyTotalFees = 0;
18,606
155
// prevent withdraws
allowAAWithdraw = false; allowBBWithdraw = false;
allowAAWithdraw = false; allowBBWithdraw = false;
33,413
5
// Branchless `packed = (block.timestamp <= expires ? 1 : 0)`. If the `block.timestamp == expires`, the `lt` clause will be true if there is a non-zero user address in the lower 160 bits of `packed`.
packed := mul( packed,
packed := mul( packed,
13,900
12
// Mapping from (assetAddress, paymentAddress) to amount of escrowed ERC20.
mapping(address => mapping (address => uint256)) internal _escrowedErc20;
mapping(address => mapping (address => uint256)) internal _escrowedErc20;
46,748
53
// Transfer ERC20 tokens out of vault/ access control: only owner/ state machine: when balance >= amount/ state scope: none/ token transfer: transfer any token/to Address of the recipient/amount Amount of ETH to transfer
function transferETH(address to, uint256 amount) external payable override onlyOwner { // perform transfer TransferHelper.safeTransferETH(to, amount); }
function transferETH(address to, uint256 amount) external payable override onlyOwner { // perform transfer TransferHelper.safeTransferETH(to, amount); }
46,010
77
// COL token collaterals
mapping(address => mapping(address => uint)) public colToken;
mapping(address => mapping(address => uint)) public colToken;
22,970
143
// address of wallet that has access to reserved mint
address public projectWallet = 0x46954016be77333a7DA7B7D424599852B1415aa3;
address public projectWallet = 0x46954016be77333a7DA7B7D424599852B1415aa3;
15,619
10
// : resets tax settings to initial state/
function taxReset() external onlyOwner { _taxActive = false; _taxTotal = 0; for(uint8 i = 0; i < _taxRecipients.length; i++) { _taxRecipientAmounts[_taxRecipients[i]] = 0; _isTaxRecipient[_taxRecipients[i]] = false; } delete _taxRecipients; }
function taxReset() external onlyOwner { _taxActive = false; _taxTotal = 0; for(uint8 i = 0; i < _taxRecipients.length; i++) { _taxRecipientAmounts[_taxRecipients[i]] = 0; _isTaxRecipient[_taxRecipients[i]] = false; } delete _taxRecipients; }
21,535
18
// return the address of the owner. /
function owner() public view returns(address) { return _owner; }
function owner() public view returns(address) { return _owner; }
51,137
55
// 每次交易后价格上涨
uint RISE_RATE = 110; uint RISE_RATE_FAST = 150;
uint RISE_RATE = 110; uint RISE_RATE_FAST = 150;
47,799
14
// if there is already such record in escrow storage, update it, but don't change the state
escrowStorage.editEscrow( msg.sender, escrowStorage.isEscrowActive(msg.sender), feePermille );
escrowStorage.editEscrow( msg.sender, escrowStorage.isEscrowActive(msg.sender), feePermille );
43,721
451
// Lists of (timestamp, quantity) pairs per account, sorted in ascending time order.These are the times at which each given quantity of XTK vests. // An account's total escrowed XTK balance to save recomputing this for fee extraction purposes. // An account's total vested reward XTK. // The total remaining escrowed balance, for verifying the actual XTK balance of this contract against. // Limit vesting entries to disallow unbounded iteration over vesting schedules. Community vesting won't last longer than 5 years // ========== Initializer ========== /
{ xtk = IERC20(_xtk); name = _name; symbol = _symbol; Ownable.initialize(msg.sender); }
{ xtk = IERC20(_xtk); name = _name; symbol = _symbol; Ownable.initialize(msg.sender); }
35,880
57
// Recover signer address from a message by using their signature hash bytes32 message, the hash is the signed message. What is recovered is the signer address. signature bytes signature, the signature is generated using web3.eth.sign() /
function recover(bytes32 hash, bytes memory signature) internal pure returns (address)
function recover(bytes32 hash, bytes memory signature) internal pure returns (address)
9,184
49
// Returns last accounted reward block, either the current block number or the endBlock of the pool /
function _lastAccountedRewardBlock(uint256 _pid) internal view returns (uint32 _value) { _value = poolInfo[_pid].endBlock; if (_value > block.number) _value = block.number.toUint32(); }
function _lastAccountedRewardBlock(uint256 _pid) internal view returns (uint32 _value) { _value = poolInfo[_pid].endBlock; if (_value > block.number) _value = block.number.toUint32(); }
22,015
76
// International Securities Identification Number (ISIN)/
string constant public ISIN = "CH0465030796";
string constant public ISIN = "CH0465030796";
3,001
1
// kovanIERC20 public constant iETH = IERC20(0x0afBFCe9DB35FFd1dFdF144A788fa196FD08EFe9);IERC20 public constant vBZRX = IERC20(0x6F8304039f34fd6A6acDd511988DCf5f62128a32);
uint256 public iETHSwapRate = 0.0002 ether; bool public isActive; uint256 public iETHSold; uint256 public vBZRXBought; mapping (address => uint256) public whitelist; function convert(
uint256 public iETHSwapRate = 0.0002 ether; bool public isActive; uint256 public iETHSold; uint256 public vBZRXBought; mapping (address => uint256) public whitelist; function convert(
26,751
7
// @inheritdoc IERC20Detailed
function name() public view override returns (string memory) { return _name; }
function name() public view override returns (string memory) { return _name; }
4,639
37
// Calculate and mint the amount of xSushi the Sushi is worth. The ratio will change overtime, as xSushi is burned/minted and Sushi deposited + gained from fees / withdrawn.
else { uint256 what = _amount.mul(totalShares).div(totalSushi); _mint(msg.sender, what); }
else { uint256 what = _amount.mul(totalShares).div(totalSushi); _mint(msg.sender, what); }
66,144
172
// Set the new extension of the uri_newExtensionURI The new base uri/
function setExtensionURI(string memory _newExtensionURI) external onlyOwner { __extensionURI = _newExtensionURI; }
function setExtensionURI(string memory _newExtensionURI) external onlyOwner { __extensionURI = _newExtensionURI; }
65,759
88
// disables an address from minting / burningaddr the address to disbale/
function removeAdmin(address addr) external onlyOwner { admins[addr] = false; }
function removeAdmin(address addr) external onlyOwner { admins[addr] = false; }
31,726
95
// Extend parent behavior requiring to be within contributing period. beneficiary Token purchaser weiAmount Amount of wei contributed /
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal onlyWhileOpen view { super._preValidatePurchase(beneficiary, weiAmount); }
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal onlyWhileOpen view { super._preValidatePurchase(beneficiary, weiAmount); }
44,826
419
// Sets the fee beneficiary for subsequent Draws.Can only be called by admins. _feeBeneficiary The beneficiary for the fee fraction.Cannot be the 0 address. /
function setNextFeeBeneficiary(address _feeBeneficiary) public onlyAdmin { _setNextFeeBeneficiary(_feeBeneficiary); }
function setNextFeeBeneficiary(address _feeBeneficiary) public onlyAdmin { _setNextFeeBeneficiary(_feeBeneficiary); }
55,321
2
// Function to mint tokens.
* NOTE: restricting access to owner only. See {BEP20Mintable-mint}. * * @param account The address that will receive the minted tokens * @param amount The amount of tokens to mint */ function _mint(address account, uint256 amount) internal override(BEP20, BEP20Capped) onlyOwner { super._mint(account, amount); }
* NOTE: restricting access to owner only. See {BEP20Mintable-mint}. * * @param account The address that will receive the minted tokens * @param amount The amount of tokens to mint */ function _mint(address account, uint256 amount) internal override(BEP20, BEP20Capped) onlyOwner { super._mint(account, amount); }
29,404
16
// Function modifier to require caller to be authorized /
modifier authorized() { require(isAuthorized(msg.sender), "!AUTHORIZED"); _; }
modifier authorized() { require(isAuthorized(msg.sender), "!AUTHORIZED"); _; }
24,218
3
// Get the referrer address that referred the user
function getReferrer(address _user) public override view returns (address) { return referrers[_user]; }
function getReferrer(address _user) public override view returns (address) { return referrers[_user]; }
41,440
399
// Migrates the accounting variables from the current creditline to a brand new one _borrower The borrower address _maxLimit The new max limit _interestApr The new interest APR _paymentPeriodInDays The new payment period in days _termInDays The new term in days _lateFeeApr The new late fee APR /
function migrateCreditLine( address _borrower, uint256 _maxLimit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr, uint256 _principalGracePeriodInDays
function migrateCreditLine( address _borrower, uint256 _maxLimit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr, uint256 _principalGracePeriodInDays
83,965
18
// check if merkle root is empty
if (merkleHash == 0x00) { return (STATUS_FAIL, MSG_MERKLE_CANNOT_EMPTY); }
if (merkleHash == 0x00) { return (STATUS_FAIL, MSG_MERKLE_CANNOT_EMPTY); }
44,715
21
// supplyDelta = supplyDelta.div(1e18);
return (supplyDelta);
return (supplyDelta);
44,112
75
// Refund Ether invested in ICO to the sender if ICO failed./
function refundIco() public { require(hasIcoFailed); require(icoPurchases[msg.sender].burnableTiqs > 0 && icoPurchases[msg.sender].refundableWei > 0); uint256 amountWei = icoPurchases[msg.sender].refundableWei; msg.sender.transfer(amountWei); icoPurchases[msg.sender].refundableWei = 0; icoPurchases[msg.sender].burnableTiqs = 0; token.burnFromAddress(msg.sender); }
function refundIco() public { require(hasIcoFailed); require(icoPurchases[msg.sender].burnableTiqs > 0 && icoPurchases[msg.sender].refundableWei > 0); uint256 amountWei = icoPurchases[msg.sender].refundableWei; msg.sender.transfer(amountWei); icoPurchases[msg.sender].refundableWei = 0; icoPurchases[msg.sender].burnableTiqs = 0; token.burnFromAddress(msg.sender); }
49,551
26
// SPDX-License-Identifier: No License
library Address { function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
library Address { function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
15,173
31
// called by the admin to unpause, returns to normal stateReset genesis state. Once paused, the rounds would need to be kickstarted by genesis /
function unpause() external whenPaused onlyAdmin { genesisStartOnce = false; _unpause(); emit Unpause(currentEpoch); }
function unpause() external whenPaused onlyAdmin { genesisStartOnce = false; _unpause(); emit Unpause(currentEpoch); }
28,235
1
// RLP encodes a list of RLP encoded byte byte strings. _in The list of RLP encoded byte strings.return The RLP encoded list of items in bytes. /
function writeList(bytes[] memory _in) internal pure returns (bytes memory) { bytes memory list = _flatten(_in); return abi.encodePacked(_writeLength(list.length, 192), list); }
function writeList(bytes[] memory _in) internal pure returns (bytes memory) { bytes memory list = _flatten(_in); return abi.encodePacked(_writeLength(list.length, 192), list); }
28,702
186
// A map from an address to a token to a deposit
mapping (address => mapping (uint16 => Deposit)) pendingDeposits;
mapping (address => mapping (uint16 => Deposit)) pendingDeposits;
19,644
131
// Indicates which sessions have already been settled by storing keccak256(receiver, sender, expiration_block) => expiration_block.
mapping (bytes32 => uint256) public settled_sessions;
mapping (bytes32 => uint256) public settled_sessions;
62,008
4
// Multiplication cannot overflow, reverts if so. Counterpart to Solidity'soperator. Returns the multiplication of two unsigned integers.Multiplication /
function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) {return 0;} uint256 c = a * b; assert(c / a == b); return c; }
function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) {return 0;} uint256 c = a * b; assert(c / a == b); return c; }
42,992
10
// Lock token into bridge
deposits[_localToken][_remoteToken][_tokenId] = true; IERC721(_localToken).transferFrom(_from, address(this), _tokenId);
deposits[_localToken][_remoteToken][_tokenId] = true; IERC721(_localToken).transferFrom(_from, address(this), _tokenId);
23,872
67
// returns list of pool token's info /
function getPoolInfoList() external view returns (PoolInfo[] memory) { return poolInfoList; }
function getPoolInfoList() external view returns (PoolInfo[] memory) { return poolInfoList; }
12,350
61
// commit the upgrade.No going back from here. requires the PERM_UPGRADE permission /
function commitUpgrade() public ifPermitted(msg.sender, PERM_UPGRADE) ifInState(State.Upgraded) { // Remove ourself from the list of superusers of the token store store.setPermission(address(this), PERM_SUPERUSER, false); super.commitUpgrade(); }
function commitUpgrade() public ifPermitted(msg.sender, PERM_UPGRADE) ifInState(State.Upgraded) { // Remove ourself from the list of superusers of the token store store.setPermission(address(this), PERM_SUPERUSER, false); super.commitUpgrade(); }
18,328
2
// Main identifiers
bytes32 private constant POOL = 'POOL'; bytes32 private constant POOL_CONFIGURATOR = 'POOL_CONFIGURATOR'; bytes32 private constant PRICE_ORACLE = 'PRICE_ORACLE'; bytes32 private constant ACL_MANAGER = 'ACL_MANAGER'; bytes32 private constant ACL_ADMIN = 'ACL_ADMIN'; bytes32 private constant PRICE_ORACLE_SENTINEL = 'PRICE_ORACLE_SENTINEL'; bytes32 private constant DATA_PROVIDER = 'DATA_PROVIDER';
bytes32 private constant POOL = 'POOL'; bytes32 private constant POOL_CONFIGURATOR = 'POOL_CONFIGURATOR'; bytes32 private constant PRICE_ORACLE = 'PRICE_ORACLE'; bytes32 private constant ACL_MANAGER = 'ACL_MANAGER'; bytes32 private constant ACL_ADMIN = 'ACL_ADMIN'; bytes32 private constant PRICE_ORACLE_SENTINEL = 'PRICE_ORACLE_SENTINEL'; bytes32 private constant DATA_PROVIDER = 'DATA_PROVIDER';
36,030
3
// Changes state of ether spender address/
function setEtherSpender(address spender, bool state) public ownerOnly { allowedEtherSpenders[spender] = state; emit AllowedSpenderSet(spender, state); }
function setEtherSpender(address spender, bool state) public ownerOnly { allowedEtherSpenders[spender] = state; emit AllowedSpenderSet(spender, state); }
46,376
88
// solhint-disable-next-line func-visibility
constructor (string memory name, string memory symbol) ERC20(name, symbol) {}// solhint-disable-line no-empty-blocks function mint(address account, uint256 amount) external onlyOwner { _mint(account, amount); }
constructor (string memory name, string memory symbol) ERC20(name, symbol) {}// solhint-disable-line no-empty-blocks function mint(address account, uint256 amount) external onlyOwner { _mint(account, amount); }
5,717
214
// calculate the total underlying balance
function investedBalance() public view override returns (uint256) { return calcWithdraw(pool(), stakedBalance(), int128(index())); }
function investedBalance() public view override returns (uint256) { return calcWithdraw(pool(), stakedBalance(), int128(index())); }
35,175
0
// Reports the Witnet-provided result to a previously posted request. /Will assume `block.timestamp` as the timestamp at which the request was solved./Fails if:/- the `_queryId` is not in 'Posted' status./- provided `_drTxHash` is zero;/- length of provided `_result` is zero./_queryId The unique identifier of the data request./_drTxHash The hash of the corresponding data request transaction in Witnet./_result The result itself as bytes.
function reportResult( uint256 _queryId, bytes32 _drTxHash, bytes calldata _result ) external;
function reportResult( uint256 _queryId, bytes32 _drTxHash, bytes calldata _result ) external;
14,016
222
// Opens credit account in ETH/creditManager Address of credit Manager. Should used WETH as underlying asset/onBehalfOf The address that we open credit account. Same as msg.sender if the user wants to open it forhis own wallet,/ or a different address if the beneficiary is a different wallet/leverageFactor Multiplier to borrowers own funds/referralCode Code used to register the integrator originating the operation, for potential rewards./ 0 if the action is executed directly by the user, without any middle-man
function openCreditAccountETH( address creditManager, address payable onBehalfOf, uint256 leverageFactor, uint256 referralCode ) external payable;
function openCreditAccountETH( address creditManager, address payable onBehalfOf, uint256 leverageFactor, uint256 referralCode ) external payable;
28,691
93
// /
function ZapIn( address fromToken, uint256 amountIn,
function ZapIn( address fromToken, uint256 amountIn,
3,494
171
// Sets `amount` as the allowance of `spender` over the `owner` s tokens. This internal function is equivalent to `approve`, and can be used toe.g. set automatic allowances for certain subsystems, etc.
* Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
* Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
8,646
27
// Use Checks-Effects-Interactions pattern
if(redeemFXSBalances[msg.sender] > 0){ FXSAmount = redeemFXSBalances[msg.sender]; redeemFXSBalances[msg.sender] = 0; unclaimedPoolFXS = unclaimedPoolFXS.sub(FXSAmount); sendFXS = true; }
if(redeemFXSBalances[msg.sender] > 0){ FXSAmount = redeemFXSBalances[msg.sender]; redeemFXSBalances[msg.sender] = 0; unclaimedPoolFXS = unclaimedPoolFXS.sub(FXSAmount); sendFXS = true; }
18,663
282
// create the tokens
_mint(initialHolder, initialSupply);
_mint(initialHolder, initialSupply);
2,924
34
// Event gets emitted every time this demo contract gets resetted. /
event DemoResetted();
event DemoResetted();
20,985
2
// add state where you can't put money when someone else pays to contract
// enum State { Created, Locked, Release } // State public state; uint256 public totalAmout; uint256 public initialAmount; uint256 public timeGiven; uint256 public monthlyPayment; uint256 public amount; uint256 public months; address payable public seller; address payable public buyer; uint256 public amountLeft; //timegiven is is months. 2592000 seconds is in 1 month. constructor(uint256 _totalAmout, uint256 _timeGiven) public { timeGiven = block.timestamp + (_timeGiven * 2592000); totalAmout = _totalAmout; seller = msg.sender; amountLeft = totalAmout; monthlyPayment = _totalAmout / _timeGiven; months = _timeGiven; }
// enum State { Created, Locked, Release } // State public state; uint256 public totalAmout; uint256 public initialAmount; uint256 public timeGiven; uint256 public monthlyPayment; uint256 public amount; uint256 public months; address payable public seller; address payable public buyer; uint256 public amountLeft; //timegiven is is months. 2592000 seconds is in 1 month. constructor(uint256 _totalAmout, uint256 _timeGiven) public { timeGiven = block.timestamp + (_timeGiven * 2592000); totalAmout = _totalAmout; seller = msg.sender; amountLeft = totalAmout; monthlyPayment = _totalAmout / _timeGiven; months = _timeGiven; }
23,176
296
// require character is a space
_temp[i] == 0x20 ||
_temp[i] == 0x20 ||
3,592
0
// Order nonces
mapping(address => uint64) public nonces; constructor(address _admin, IPortalsMulticall _multicall) Owned(_admin) EIP712("PortalsRouter", "1") { PORTALS_MULTICALL = _multicall; }
mapping(address => uint64) public nonces; constructor(address _admin, IPortalsMulticall _multicall) Owned(_admin) EIP712("PortalsRouter", "1") { PORTALS_MULTICALL = _multicall; }
4,629
349
// If it's zero, they haven't issued, and they have no debt.
if (debtShareBalance == 0) return 0; (debtBalance, , ) = _debtBalanceOfAndTotalDebt(debtShareBalance, currencyKey);
if (debtShareBalance == 0) return 0; (debtBalance, , ) = _debtBalanceOfAndTotalDebt(debtShareBalance, currencyKey);
63,534