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
192
// Updates the amount of rewards owed for each user before any tokens are moved TODO: revert for an non existing user?
function updateReward( address _user ) public
function updateReward( address _user ) public
46,271
22
// Rescue ERC721 assets sent directly to this contract. /
function withdrawForeignERC721(address tokenContract, uint256 tokenId) public onlyOwner { IERC721(tokenContract).safeTransferFrom(address(this), owner, tokenId); }
function withdrawForeignERC721(address tokenContract, uint256 tokenId) public onlyOwner { IERC721(tokenContract).safeTransferFrom(address(this), owner, tokenId); }
45,163
78
// Repay debt by selling base in a pool and using the resulting fyToken/ The base tokens need to be already in the pool, unaccounted for./ Only before maturity. After maturity use close.
function repay(bytes12 vaultId_, address to, int128 ink, uint128 min) external payable returns (uint128 art)
function repay(bytes12 vaultId_, address to, int128 ink, uint128 min) external payable returns (uint128 art)
64,109
57
// Additional non fungible properties of a Hedera Token.
struct NonFungibleTokenInfo { /// The shared hedera token info TokenInfo tokenInfo; /// The serial number of the nft int64 serialNumber; /// The account id specifying the owner of the non fungible token address ownerId; /// The epoch second at which the token was created. int64 creationTime; /// The unique metadata of the NFT bytes metadata; /// The account id specifying an account that has been granted spending permissions on this nft address spenderId; }
struct NonFungibleTokenInfo { /// The shared hedera token info TokenInfo tokenInfo; /// The serial number of the nft int64 serialNumber; /// The account id specifying the owner of the non fungible token address ownerId; /// The epoch second at which the token was created. int64 creationTime; /// The unique metadata of the NFT bytes metadata; /// The account id specifying an account that has been granted spending permissions on this nft address spenderId; }
15,763
17
// ...
24,581
3
// @inheritdoc IFractionalToken
uint256 public override nav;
uint256 public override nav;
19,110
308
// Calculates new ranges for orders and calls `vault.rebalance()`so that vault can update its positions. Can only be called by keeper. /
function rebalance(address _vault) external override { require(shouldRebalance(_vault), "cannot rebalance"); vaultData storage _data = vaultStrategyData[_vault]; int24 tick = getTick(_data.pool); int24 tickFloor = _floor(tick, _data.tickSpacing); int24 tickCeil = tickFloor + _data.tickSpacing; vaultStrategyData[_vault].vault.rebalance( 0, 0, tickFloor - _data.baseThreshold, tickCeil + _data.baseThreshold, tickFloor - _data.limitThreshold, tickFloor, tickCeil, tickCeil + _data.limitThreshold ); _data.lastTimestamp = block.timestamp; _data.lastTick = tick; }
function rebalance(address _vault) external override { require(shouldRebalance(_vault), "cannot rebalance"); vaultData storage _data = vaultStrategyData[_vault]; int24 tick = getTick(_data.pool); int24 tickFloor = _floor(tick, _data.tickSpacing); int24 tickCeil = tickFloor + _data.tickSpacing; vaultStrategyData[_vault].vault.rebalance( 0, 0, tickFloor - _data.baseThreshold, tickCeil + _data.baseThreshold, tickFloor - _data.limitThreshold, tickFloor, tickCeil, tickCeil + _data.limitThreshold ); _data.lastTimestamp = block.timestamp; _data.lastTick = tick; }
10,237
253
// Put an evil address into blacklist
function blacklistAddress(address userAddress) public { require(hasRole(MANAGER_ROLE, msg.sender), "only manager"); _beneficiaryAllocations[userAddress].blackListed = true; }
function blacklistAddress(address userAddress) public { require(hasRole(MANAGER_ROLE, msg.sender), "only manager"); _beneficiaryAllocations[userAddress].blackListed = true; }
11,046
101
// Important for security - any address without masterContract has address(0) as masterContract So approving address(0) would approve every address, leading to full loss of funds Also, ecrecover returns address(0) on failure. So we check this:
require(user != address(0), "MasterCMgr: User cannot be 0");
require(user != address(0), "MasterCMgr: User cannot be 0");
4,734
32
// Initiate the subscription struct
setSubscription( providerAddress, msg.sender, endpoint, blocks, uint96(block.number), uint96(block.number) + uint96(blocks) ); emit DataPurchase(
setSubscription( providerAddress, msg.sender, endpoint, blocks, uint96(block.number), uint96(block.number) + uint96(blocks) ); emit DataPurchase(
23,422
5
// The mapping between release and build numbers.
mapping(uint8 => uint16) internal buildsPerRelease;
mapping(uint8 => uint16) internal buildsPerRelease;
8,174
66
// Make a request to refresh a submissionDuration. Paying the full deposit right away is not required as it can be crowdfunded later. Note that the user can reapply even when current submissionDuration has not expired, but only after the start of renewal period._evidence A link to evidence using its URI. /
function reapplySubmission(string calldata _evidence, string calldata _name, string calldata _bio) external payable { Submission storage submission = submissions[msg.sender]; require(submission.registered && submission.status == Status.None, "Wrong status"); uint renewalAvailableAt = submission.submissionTime.addCap64(submissionDuration.subCap64(renewalPeriodDuration)); require(now >= renewalAvailableAt, "Can't reapply yet"); submission.status = Status.Vouching; emit ReapplySubmission(msg.sender, submission.requests.length); requestRegistration(msg.sender, _evidence); }
function reapplySubmission(string calldata _evidence, string calldata _name, string calldata _bio) external payable { Submission storage submission = submissions[msg.sender]; require(submission.registered && submission.status == Status.None, "Wrong status"); uint renewalAvailableAt = submission.submissionTime.addCap64(submissionDuration.subCap64(renewalPeriodDuration)); require(now >= renewalAvailableAt, "Can't reapply yet"); submission.status = Status.Vouching; emit ReapplySubmission(msg.sender, submission.requests.length); requestRegistration(msg.sender, _evidence); }
29,786
102
// Alley Hour taxes
uint256 private _alleyHourStartTimestamp = 0; CustomTaxPeriod private _alley1 = CustomTaxPeriod('alley1',0,3600,1,3,0,5,0,5,0,2,0,4,1,6); CustomTaxPeriod private _alley2 = CustomTaxPeriod('alley2',0,3600,1,1,0,3,0,3,0,1,1,3,2,4); uint256 private _blockedTimeLimit = 86400; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcludedFromMaxTransactionLimit; mapping (address => bool) private _isExcludedFromMaxWalletLimit; mapping (address => bool) private _isBlocked; mapping (address => bool) public automatedMarketMakerPairs;
uint256 private _alleyHourStartTimestamp = 0; CustomTaxPeriod private _alley1 = CustomTaxPeriod('alley1',0,3600,1,3,0,5,0,5,0,2,0,4,1,6); CustomTaxPeriod private _alley2 = CustomTaxPeriod('alley2',0,3600,1,1,0,3,0,3,0,1,1,3,2,4); uint256 private _blockedTimeLimit = 86400; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcludedFromMaxTransactionLimit; mapping (address => bool) private _isExcludedFromMaxWalletLimit; mapping (address => bool) private _isBlocked; mapping (address => bool) public automatedMarketMakerPairs;
11,193
1
// Super token that may be streamed to this contract
ISuperToken internal immutable _acceptedToken;
ISuperToken internal immutable _acceptedToken;
27,987
1
// Emit an event when the contract configuration is updated. /
event ContractConfigUpdated( uint256 maxSupply, address royalties, address beneficiary, string baseURI, string contractURI );
event ContractConfigUpdated( uint256 maxSupply, address royalties, address beneficiary, string baseURI, string contractURI );
11,911
72
// Put the royalty info on the stack for more efficient access.
RoyaltyInfo storage info = _royaltyInfo;
RoyaltyInfo storage info = _royaltyInfo;
26,988
9
// refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties.
struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; }
struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; }
4,263
115
// And the specified start time has not yet come If initialization return an error, check the start date!
require(now <= startTime); initialization(); emit Initialized(); renewal = 0; isInitialized = true;
require(now <= startTime); initialization(); emit Initialized(); renewal = 0; isInitialized = true;
78,493
37
// add to pairs for taxes.
pairs[pair] = true; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply);
pairs[pair] = true; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply);
8,348
2
// Empty baseURI is allowed
baseURI = _baseURI;
baseURI = _baseURI;
37,267
0
// Events emitted by a pool/Contains all events emitted by the pool
interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
1,925
11
// convert expiry to a readable string
(uint256 year, uint256 month, uint256 day) = BokkyPooBahsDateTimeLibrary.timestampToDate(expiryTimestamp);
(uint256 year, uint256 month, uint256 day) = BokkyPooBahsDateTimeLibrary.timestampToDate(expiryTimestamp);
43,273
55
// change crowdsale ETH rate newRate Figure that corresponds to the new ETH rate per token /
function setRate(uint256 newRate) external onlyOwner { require(isWeiAccepted, "Sale must allow Wei for purchases to set a rate for Wei!"); require(newRate != 0, "ETH rate must be more than 0!"); emit TokenRateChanged(rate, newRate); rate = newRate; }
function setRate(uint256 newRate) external onlyOwner { require(isWeiAccepted, "Sale must allow Wei for purchases to set a rate for Wei!"); require(newRate != 0, "ETH rate must be more than 0!"); emit TokenRateChanged(rate, newRate); rate = newRate; }
16,039
9
// this will be an array of ids but for now just doing one for simplicity
uint256[5] ids; address owner;
uint256[5] ids; address owner;
26,524
177
// event EquityWithdrawn(address asset, uint equityAvailableBefore, uint amount, address owner)
emit EquityWithdrawn(asset, equity, amount, admin); return uint(Error.NO_ERROR); // success
emit EquityWithdrawn(asset, equity, amount, admin); return uint(Error.NO_ERROR); // success
37,665
116
// Internal invoke call, /operationHash The hash of the operation/data The data to send to the `call()` operation/The data is prefixed with a global 1 byte revert flag/If revert is 1, then any revert from a `call()` operation is rethrown./Otherwise, the error is recorded in the `result` field of the `InvocationSuccess` event./Immediately following the revert byte (no padding), the data format is then is a series/of 1 or more tightly packed tuples:/`<target(20),amount(32),datalength(32),data>`/If `datalength == 0`, the data field must be omitted
function internalInvoke(bytes32 operationHash, bytes data) internal { // keep track of the number of operations processed uint256 numOps; // keep track of the result of each operation as a bit uint256 result; // We need to store a reference to this string as a variable so we can use it as an argument to // the revert call from assembly. string memory invalidLengthMessage = "Data field too short"; string memory callFailed = "Call failed"; // At an absolute minimum, the data field must be at least 85 bytes // <revert(1), to_address(20), value(32), data_length(32)> require(data.length >= 85, invalidLengthMessage); // Forward the call onto its actual target. Note that the target address can be `self` here, which is // actually the required flow for modifying the configuration of the authorized keys and recovery address. // // The assembly code below loads data directly from memory, so the enclosing function must be marked `internal` assembly { // A cursor pointing to the revert flag, starts after the length field of the data object let memPtr := add(data, 32) // The revert flag is the leftmost byte from memPtr let revertFlag := byte(0, mload(memPtr)) // A pointer to the end of the data object let endPtr := add(memPtr, mload(data)) // Now, memPtr is a cursor pointing to the begining of the current sub-operation memPtr := add(memPtr, 1) // Loop through data, parsing out the various sub-operations for { } lt(memPtr, endPtr) { } { // Load the length of the call data of the current operation // 52 = to(20) + value(32) let len := mload(add(memPtr, 52)) // Compute a pointer to the end of the current operation // 84 = to(20) + value(32) + size(32) let opEnd := add(len, add(memPtr, 84)) // Bail if the current operation&#39;s data overruns the end of the enclosing data buffer // NOTE: Comment out this bit of code and uncomment the next section if you want // the solidity-coverage tool to work. // See https://github.com/sc-forks/solidity-coverage/issues/287 if gt(opEnd, endPtr) { // The computed end of this operation goes past the end of the data buffer. Not good! revert(add(invalidLengthMessage, 32), mload(invalidLengthMessage)) } // NOTE: Code that is compatible with solidity-coverage // switch gt(opEnd, endPtr) // case 1 { // revert(add(invalidLengthMessage, 32), mload(invalidLengthMessage)) // } // This line of code packs in a lot of functionality! // - load the target address from memPtr, the address is only 20-bytes but mload always grabs 32-bytes, // so we have to divide the result by 2^96 to effectively right-shift by 12 bytes. // - load the value field, stored at memPtr+20 // - pass a pointer to the call data, stored at memPtr+84 // - use the previously loaded len field as the size of the call data // - make the call (passing all remaining gas to the child call) // - check the result (0 == reverted) if eq(0, call(gas, div(mload(memPtr), exp(2, 96)), mload(add(memPtr, 20)), add(memPtr, 84), len, 0, 0)) { switch revertFlag case 1 { revert(add(callFailed, 32), mload(callFailed)) } default { // mark this operation as failed // create the appropriate bit, &#39;or&#39; with previous result := or(result, exp(2, numOps)) } } // increment our counter numOps := add(numOps, 1) // Update mem pointer to point to the next sub-operation memPtr := opEnd } }
function internalInvoke(bytes32 operationHash, bytes data) internal { // keep track of the number of operations processed uint256 numOps; // keep track of the result of each operation as a bit uint256 result; // We need to store a reference to this string as a variable so we can use it as an argument to // the revert call from assembly. string memory invalidLengthMessage = "Data field too short"; string memory callFailed = "Call failed"; // At an absolute minimum, the data field must be at least 85 bytes // <revert(1), to_address(20), value(32), data_length(32)> require(data.length >= 85, invalidLengthMessage); // Forward the call onto its actual target. Note that the target address can be `self` here, which is // actually the required flow for modifying the configuration of the authorized keys and recovery address. // // The assembly code below loads data directly from memory, so the enclosing function must be marked `internal` assembly { // A cursor pointing to the revert flag, starts after the length field of the data object let memPtr := add(data, 32) // The revert flag is the leftmost byte from memPtr let revertFlag := byte(0, mload(memPtr)) // A pointer to the end of the data object let endPtr := add(memPtr, mload(data)) // Now, memPtr is a cursor pointing to the begining of the current sub-operation memPtr := add(memPtr, 1) // Loop through data, parsing out the various sub-operations for { } lt(memPtr, endPtr) { } { // Load the length of the call data of the current operation // 52 = to(20) + value(32) let len := mload(add(memPtr, 52)) // Compute a pointer to the end of the current operation // 84 = to(20) + value(32) + size(32) let opEnd := add(len, add(memPtr, 84)) // Bail if the current operation&#39;s data overruns the end of the enclosing data buffer // NOTE: Comment out this bit of code and uncomment the next section if you want // the solidity-coverage tool to work. // See https://github.com/sc-forks/solidity-coverage/issues/287 if gt(opEnd, endPtr) { // The computed end of this operation goes past the end of the data buffer. Not good! revert(add(invalidLengthMessage, 32), mload(invalidLengthMessage)) } // NOTE: Code that is compatible with solidity-coverage // switch gt(opEnd, endPtr) // case 1 { // revert(add(invalidLengthMessage, 32), mload(invalidLengthMessage)) // } // This line of code packs in a lot of functionality! // - load the target address from memPtr, the address is only 20-bytes but mload always grabs 32-bytes, // so we have to divide the result by 2^96 to effectively right-shift by 12 bytes. // - load the value field, stored at memPtr+20 // - pass a pointer to the call data, stored at memPtr+84 // - use the previously loaded len field as the size of the call data // - make the call (passing all remaining gas to the child call) // - check the result (0 == reverted) if eq(0, call(gas, div(mload(memPtr), exp(2, 96)), mload(add(memPtr, 20)), add(memPtr, 84), len, 0, 0)) { switch revertFlag case 1 { revert(add(callFailed, 32), mload(callFailed)) } default { // mark this operation as failed // create the appropriate bit, &#39;or&#39; with previous result := or(result, exp(2, numOps)) } } // increment our counter numOps := add(numOps, 1) // Update mem pointer to point to the next sub-operation memPtr := opEnd } }
6,113
113
// Given amountB, which amountA is required such that amountB / amountA is equal to the ratioamountA := amountBInTokenAratio /
function tokenAForTokenB( uint256 amountB, uint256 ratio, uint256 rate, uint256 sFactorA, uint256 sFactorB
function tokenAForTokenB( uint256 amountB, uint256 ratio, uint256 rate, uint256 sFactorA, uint256 sFactorB
24,813
27
// Set original owner
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
1,662
10
// Next, set the caller as the argument.
mstore(ChannelClosed_channel_ptr, caller())
mstore(ChannelClosed_channel_ptr, caller())
11,542
131
// id of this contract for metadata server
uint public contractId;
uint public contractId;
39,129
75
// Function that returns NFT's pending rewards
function pendingRewards(uint _NFT) public view returns(uint) { NFT storage nft = NFTDetails[_NFT]; uint256 _accNfyPerShare = accNfyPerShare; if (block.number > lastRewardBlock && totalStaked != 0) { uint256 blocksToReward = block.number.sub(lastRewardBlock); uint256 nfyReward = blocksToReward.mul(getRewardPerBlock()); _accNfyPerShare = _accNfyPerShare.add(nfyReward.mul(1e18).div(totalStaked)); } return nft._LPDeposited.mul(_accNfyPerShare).div(1e18).sub(nft._rewardDebt); }
function pendingRewards(uint _NFT) public view returns(uint) { NFT storage nft = NFTDetails[_NFT]; uint256 _accNfyPerShare = accNfyPerShare; if (block.number > lastRewardBlock && totalStaked != 0) { uint256 blocksToReward = block.number.sub(lastRewardBlock); uint256 nfyReward = blocksToReward.mul(getRewardPerBlock()); _accNfyPerShare = _accNfyPerShare.add(nfyReward.mul(1e18).div(totalStaked)); } return nft._LPDeposited.mul(_accNfyPerShare).div(1e18).sub(nft._rewardDebt); }
35,376
187
// Increase required energy
energyRequired = (totalSupply()**energyIncreaseExponent) * energyIncreaseConstant;
energyRequired = (totalSupply()**energyIncreaseExponent) * energyIncreaseConstant;
43,332
3
// get BillDetails at index _index Index of BillDetails to look up /
function getBillDetails(uint256 _index) external view override returns (BillDetails memory) { require(_index < totalBills(), "index out of bounds"); return billDetails[_index]; }
function getBillDetails(uint256 _index) external view override returns (BillDetails memory) { require(_index < totalBills(), "index out of bounds"); return billDetails[_index]; }
27,691
41
// Transfers `amount` tokens from `sender` to `recipient`. sender The account to transfer tokens from. recipient The account to transfer tokens to. amount The amount of tokens to transfer. /
function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(amount > 0, 'ERC20: transfer amount zero'); require(sender != address(0), 'ERC20: transfer from the zero address'); require(recipient != address(0), 'ERC20: transfer to the zero address'); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, 'ERC20: transfer amount exceeds balance'); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); }
function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(amount > 0, 'ERC20: transfer amount zero'); require(sender != address(0), 'ERC20: transfer from the zero address'); require(recipient != address(0), 'ERC20: transfer to the zero address'); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, 'ERC20: transfer amount exceeds balance'); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); }
31,845
3
// view reads blockchain!
function retrieve() public view returns(uint256) { return favouriteNumber; }
function retrieve() public view returns(uint256) { return favouriteNumber; }
30,534
236
// Checks that current Hf < 1
isLiquidatable = twvUSD < borrowAmountPlusInterestRateUSD;
isLiquidatable = twvUSD < borrowAmountPlusInterestRateUSD;
20,741
22
// emergency withdraw to allow removing unrefined without no care for the refined amount
bool public emergencyActivated;
bool public emergencyActivated;
78,834
151
// update share
uint lusdValue = LUSD.balanceOf(address(this)); (bool succ, uint colValue) = getCollateralValue(); require(succ, "deposit: chainlink is down"); uint totalValue = lusdValue.add(colValue);
uint lusdValue = LUSD.balanceOf(address(this)); (bool succ, uint colValue) = getCollateralValue(); require(succ, "deposit: chainlink is down"); uint totalValue = lusdValue.add(colValue);
28,504
14
// Emitted when an inflation mint call is executed successfully./grgAmount Amount of GRG tokens minted to the staking proxy.
event GrgMintEvent(uint256 grgAmount);
event GrgMintEvent(uint256 grgAmount);
25,067
139
// Airdrop tokens to all holders that are included from reward.Requirements:- the caller must have a balance of at least `amount`. /
function airdrop(uint256 amount) public { address sender = _msgSender(); //require(!_isExcludedFromReward[sender], "Excluded addresses cannot call this function"); require(balanceOf(sender) >= amount, "The caller must have balance >= amount."); ValuesFromAmount memory values = _getValues(amount, false, false); if (_isExcludedFromReward[sender]) { _tokenBalances[sender] -= values.amount; } _reflectionBalances[sender] -= values.rAmount; _reflectionTotal = _reflectionTotal - values.rAmount; _totalRewarded += amount; emit Airdrop(amount); }
function airdrop(uint256 amount) public { address sender = _msgSender(); //require(!_isExcludedFromReward[sender], "Excluded addresses cannot call this function"); require(balanceOf(sender) >= amount, "The caller must have balance >= amount."); ValuesFromAmount memory values = _getValues(amount, false, false); if (_isExcludedFromReward[sender]) { _tokenBalances[sender] -= values.amount; } _reflectionBalances[sender] -= values.rAmount; _reflectionTotal = _reflectionTotal - values.rAmount; _totalRewarded += amount; emit Airdrop(amount); }
12,994
17
// set a new ipfs hash for token /
function setIPFSHash(uint256 id, string calldata ipfsHash) external { require(ERC721.ownerOf(id) == _msgSender(), "only owner can set ipfs"); areas[id].ipfs = ipfsHash; }
function setIPFSHash(uint256 id, string calldata ipfsHash) external { require(ERC721.ownerOf(id) == _msgSender(), "only owner can set ipfs"); areas[id].ipfs = ipfsHash; }
64,291
2
// address _treasury_token, erc20 token used to mint/burn
uint _numOfTeams, uint _exchangeRate ) ERC1155Base( _defaultAdmin, _name, _symbol, _royaltyRecipient, _royaltyBps )
uint _numOfTeams, uint _exchangeRate ) ERC1155Base( _defaultAdmin, _name, _symbol, _royaltyRecipient, _royaltyBps )
2,939
53
// EU21 token contract address
address public constant tokenAddress = 0x87ea1F06d7293161B9ff080662c1b0DF775122D3;
address public constant tokenAddress = 0x87ea1F06d7293161B9ff080662c1b0DF775122D3;
57,429
1
// ๅ„ฒๅญ˜็›ฎๅ‰ๆ‰€ๆœ‰ๆญฃๅœจไบŒ็ดšๅธ‚ๅ ดไบคๆ˜“็š„ๆดปๅ‹•็ฅจๅˆธ่ณ‡่จŠ๏ผŒTrade struct ๅŒ…ๅซๆ“ๆœ‰่€…๏ผˆ่ณผ่ฒท่€…๏ผ‰ใ€็ฅจๅˆธ Id๏ผŒ่ฒฉๅ”ฎๅƒนๆ ผ่ณ‡่จŠใ€‚
mapping(uint256 => Trade) public tradingList;
mapping(uint256 => Trade) public tradingList;
30,223
281
// We read and store the key's index to prevent multiple reads from the same storage slot
uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value }));
uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value }));
1,827
56
// unstaking fee 0.50 percent
uint public constant unstakingFeeRate = 50;
uint public constant unstakingFeeRate = 50;
2,838
122
// Parse the return data to the local stack. localStack The local stack to place the return values. ret The return data. index The current tail. /
function _parse( bytes32[256] memory localStack, bytes memory ret, uint256 index
function _parse( bytes32[256] memory localStack, bytes memory ret, uint256 index
48,332
6
// Generate the expected integrity code from the hash
bytes6 expectedIntegrityCode = bytes6(updateHash);
bytes6 expectedIntegrityCode = bytes6(updateHash);
24,791
85
// Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with`errorMessage` as a fallback revert reason when `target` reverts. _Available since v3.1._ /
function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); }
function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); }
1,867
49
// Gets the owner wallet of the domain /
function getDomainOwner(string memory domain) public view returns (address owner)
function getDomainOwner(string memory domain) public view returns (address owner)
50,010
54
// Stops the contract - this is irreversible. Should only be usedin an emergency, for example an irreversible accounting bugor an exploit. Enables all depositors to withdraw their stakeinstantly. Also stops new rewards accounting.makeRewardsClaimableWhether any previously accumulated rewards should be claimable. /
function emergencyStop(bool makeRewardsClaimable) external override onlyOwner { if (ended) revert STATE_AlreadyStopped(); // Update state and put in irreversible emergency mode ended = true; claimable = makeRewardsClaimable; if (!claimable) { // Send distribution token back to owner distributionToken.transfer(msg.sender, distributionToken.balanceOf(address(this))); } emit EmergencyStop(msg.sender, makeRewardsClaimable); }
function emergencyStop(bool makeRewardsClaimable) external override onlyOwner { if (ended) revert STATE_AlreadyStopped(); // Update state and put in irreversible emergency mode ended = true; claimable = makeRewardsClaimable; if (!claimable) { // Send distribution token back to owner distributionToken.transfer(msg.sender, distributionToken.balanceOf(address(this))); } emit EmergencyStop(msg.sender, makeRewardsClaimable); }
72,103
0
// Scroing Config interface /
interface IScoringConfig { function getUserScore(address user, address token) external view returns (uint256); function getGlobalScore(address token) external view returns (uint256); }
interface IScoringConfig { function getUserScore(address user, address token) external view returns (uint256); function getGlobalScore(address token) external view returns (uint256); }
15,343
117
// This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.implement alternative mechanisms to perform token transfer, such as signature-based. Requirements: - `from` cannot be the zero address.- `to` cannot be the zero address.- `tokenId` token must exist and be owned by `from`.- If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event. /
function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); }
function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); }
21,718
233
// Combines account details with their twab history/details The account details/twabs The history of twabs for this account
struct Account { AccountDetails details; ObservationLib.Observation[MAX_CARDINALITY] twabs; }
struct Account { AccountDetails details; ObservationLib.Observation[MAX_CARDINALITY] twabs; }
49,781
5
// set address of promoter, developer and manager
address payable public promoter; address payable public developer; address payable public manager;
address payable public promoter; address payable public developer; address payable public manager;
28,174
92
// Fill the arrays with the active effectIds and their durations
for (uint256 i = 0; i < activeEffectsCount; i++) { uint256 effectId = proxy.activeEffectIds[i]; effectIds[i] = effectId; durations[i] = proxy.activeEffectDurations[effectId]; }
for (uint256 i = 0; i < activeEffectsCount; i++) { uint256 effectId = proxy.activeEffectIds[i]; effectIds[i] = effectId; durations[i] = proxy.activeEffectDurations[effectId]; }
13,904
242
// INTERFACE: Try to update a bytes32 element and append a bytes32 element, given a root, an index, a bytes32 element, and a Single Proof
function try_update_one_and_append_one( bytes32 root, uint256 index, bytes32 element, bytes32 update_element, bytes32 append_element, bytes32[] calldata proof
function try_update_one_and_append_one( bytes32 root, uint256 index, bytes32 element, bytes32 update_element, bytes32 append_element, bytes32[] calldata proof
14,277
194
// Sale must NOT be enabled
require(!sale, "Sale already in progress"); require(presale,"Presale must be active"); require(quantity != 0, "Requested quantity cannot be zero"); require(quantity * pricePer <= msg.value, "Not enough ether sent"); require(super.totalSupply() + quantity <= maxPreMint, "Purchase would exceed max tokens for presale"); require(minted[msg.sender] + quantity <= maxWallet, "Purchase would exceed max tokens per wallet"); require(!Address.isContract(msg.sender), "Contracts are not allowed to mint"); for (uint256 i = 0; i < quantity; i++) { _safeMint(to, _tokenIdCounter.current()); _tokenIdCounter.increment();
require(!sale, "Sale already in progress"); require(presale,"Presale must be active"); require(quantity != 0, "Requested quantity cannot be zero"); require(quantity * pricePer <= msg.value, "Not enough ether sent"); require(super.totalSupply() + quantity <= maxPreMint, "Purchase would exceed max tokens for presale"); require(minted[msg.sender] + quantity <= maxWallet, "Purchase would exceed max tokens per wallet"); require(!Address.isContract(msg.sender), "Contracts are not allowed to mint"); for (uint256 i = 0; i < quantity; i++) { _safeMint(to, _tokenIdCounter.current()); _tokenIdCounter.increment();
14,480
35
// For each asset there a different maximum amount a user can leverageWe make sure the leverage amount is below the maximum
require( initialDeposit > 0 && ((longAmount + initialDeposit) * 100) / longAmount >= getMinimumCollateralPercentage(), "NOT_ENOUGH_COLLATERAL" ); uint256 userDebtBefore = IERC20StableCoin(maiVault).vaultDebt(vaultId); IERC20(collateral).safeTransferFrom(
require( initialDeposit > 0 && ((longAmount + initialDeposit) * 100) / longAmount >= getMinimumCollateralPercentage(), "NOT_ENOUGH_COLLATERAL" ); uint256 userDebtBefore = IERC20StableCoin(maiVault).vaultDebt(vaultId); IERC20(collateral).safeTransferFrom(
8,822
85
// ============================= CONTRACT VARIABLES ==============================
1,551
2
// this function is called to create an ERC721 contract. /
function createContract( string memory _name, string memory _symbol, string memory _uri, address factory ) external returns (address);
function createContract( string memory _name, string memory _symbol, string memory _uri, address factory ) external returns (address);
7,208
206
// The total Fei currently boosting Vaults.
uint256 public totalBoosted;
uint256 public totalBoosted;
10,991
3
// To redeem tokens and track redemptions _value The number of tokens to redeem /
function redeemTokens(uint256 _value) public { ISecurityToken(securityToken).burnFromWithData(msg.sender, _value, ""); redeemedTokens[msg.sender] = redeemedTokens[msg.sender].add(_value); /*solium-disable-next-line security/no-block-members*/ emit Redeemed(msg.sender, _value, now); }
function redeemTokens(uint256 _value) public { ISecurityToken(securityToken).burnFromWithData(msg.sender, _value, ""); redeemedTokens[msg.sender] = redeemedTokens[msg.sender].add(_value); /*solium-disable-next-line security/no-block-members*/ emit Redeemed(msg.sender, _value, now); }
27,301
14
// The delegated account for each voting account
mapping(address => address) public delegate;
mapping(address => address) public delegate;
26,005
325
// Authorize UniV3 contract to move fund asset/Only allow governance and strategist identities to execute authorized functions to reduce miner fee consumption/token Authorized target token
function safeApproveAll(address token) public virtual onlyStrategistOrGovernance { ERC20Extends.safeApprove(token, address(UniV3PeripheryExtends.PM()), type(uint256).max); ERC20Extends.safeApprove(token, address(UniV3PeripheryExtends.SRT()), type(uint256).max); }
function safeApproveAll(address token) public virtual onlyStrategistOrGovernance { ERC20Extends.safeApprove(token, address(UniV3PeripheryExtends.PM()), type(uint256).max); ERC20Extends.safeApprove(token, address(UniV3PeripheryExtends.SRT()), type(uint256).max); }
1,943
89
// constuctor(<other arguments>, address _vrfCoordinator, address _link)
* @dev VRFConsumerBase(_vrfCoordinator, _link) public { * @dev <initialization with other arguments goes here> * @dev }
* @dev VRFConsumerBase(_vrfCoordinator, _link) public { * @dev <initialization with other arguments goes here> * @dev }
106
23
// - Lets a Lender and a Borrower increase the credit limit on a position- line status must be ACTIVE- callable by borrower id - position id that we are updating amount - amount to deposit by the Lenderreturn - if function executed successfully /
function increaseCredit(bytes32 id, uint256 amount) external payable returns (bool);
function increaseCredit(bytes32 id, uint256 amount) external payable returns (bool);
27,969
6
// Returns total count of active jobs
function activeJobsCount() view public returns (uint256);
function activeJobsCount() view public returns (uint256);
14,875
51
// Return an amount of allready collected tokens (for rewards)
uint256 _collectedTokens;
uint256 _collectedTokens;
20,948
18
// Function to report on totalsupply following ERC20 Standard
function totalSupply() public override view returns (uint256) { return totalSupply_; }
function totalSupply() public override view returns (uint256) { return totalSupply_; }
66,000
30
// Do not allow renouncing ownership /
function renounceOwnership() public override(Ownable) onlyOwner {} }
function renounceOwnership() public override(Ownable) onlyOwner {} }
75,633
0
// VaultInfo struct/this struct is used to store the vault metadata/ this should reduce the cost of minting by ~15,000/ by limiting us to max 296-1 vaults
struct VaultInfo { uint96 id; address minter; }
struct VaultInfo { uint96 id; address minter; }
11,410
49
// Computing height of a building with respect to city progression.
function _computeHeight( uint256 _x, uint256 _z, uint256 _height
function _computeHeight( uint256 _x, uint256 _z, uint256 _height
58,199
60
// Mapping from owner to a list of owned auctions
mapping (address => uint256[]) public ownedAuctions; event BidSuccess(address _from, uint256 _auctionId, uint256 _price, uint256 _bidIndex);
mapping (address => uint256[]) public ownedAuctions; event BidSuccess(address _from, uint256 _auctionId, uint256 _price, uint256 _bidIndex);
19,069
84
// Common logic for clearing the data of an Identity.
function resetIdentityData(Identity storage identity, address newRecoveryAddress, bool resetResolvers) private { for (uint i; i < identity.associatedAddresses.members.length; i++) { delete associatedAddressDirectory[identity.associatedAddresses.members[i]]; } delete identity.associatedAddresses; delete identity.providers; if (resetResolvers) delete identity.resolvers; identity.recoveryAddress = newRecoveryAddress; }
function resetIdentityData(Identity storage identity, address newRecoveryAddress, bool resetResolvers) private { for (uint i; i < identity.associatedAddresses.members.length; i++) { delete associatedAddressDirectory[identity.associatedAddresses.members[i]]; } delete identity.associatedAddresses; delete identity.providers; if (resetResolvers) delete identity.resolvers; identity.recoveryAddress = newRecoveryAddress; }
19,736
68
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) /Interface of the ERC165 standard, as defined in the https:eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be
// * queried by others ({ERC165Checker}). // * // * For an implementation, see {ERC165}. // */ // interface IERC165 { // /** // * @dev Returns true if this contract implements the interface defined by // * `interfaceId`. See the corresponding // * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] // * to learn more about how these ids are created. // * // * This function call must use less than 30 000 gas. // */ // function supportsInterface(bytes4 interfaceId) external view returns (bool); // }
// * queried by others ({ERC165Checker}). // * // * For an implementation, see {ERC165}. // */ // interface IERC165 { // /** // * @dev Returns true if this contract implements the interface defined by // * `interfaceId`. See the corresponding // * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] // * to learn more about how these ids are created. // * // * This function call must use less than 30 000 gas. // */ // function supportsInterface(bytes4 interfaceId) external view returns (bool); // }
9,869
56
// If there was already enough COIN in the safeEngine balance, just exits it without adding more debt
if (coin < multiply(wad, RAY)) {
if (coin < multiply(wad, RAY)) {
4,615
383
// To avoid rounding issues, we re-order and group the operations so we do 1 division and only at the end [supplyCurrent(Oracle price for the collateral)] / [ (1 + liquidationDiscount)(Oracle price for the borrow) ]
Error err; Exp memory onePlusLiquidationDiscount; // (1 + liquidationDiscount) Exp memory supplyCurrentTimesOracleCollateral; // supplyCurrent * Oracle price for the collateral Exp memory onePlusLiquidationDiscountTimesOracleBorrow; // (1 + liquidationDiscount) * Oracle price for the borrow Exp memory rawResult; (err, onePlusLiquidationDiscount) = addExp(
Error err; Exp memory onePlusLiquidationDiscount; // (1 + liquidationDiscount) Exp memory supplyCurrentTimesOracleCollateral; // supplyCurrent * Oracle price for the collateral Exp memory onePlusLiquidationDiscountTimesOracleBorrow; // (1 + liquidationDiscount) * Oracle price for the borrow Exp memory rawResult; (err, onePlusLiquidationDiscount) = addExp(
17,569
8
// This is a virtual function that should be overridden so it returns the address to which the fallback function
* and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); }
* and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); }
2,242
18
// Sum up total amounts owed to recipient
amount0 = unusedAmount0.add(baseAmount0).add(limitAmount0); amount1 = unusedAmount1.add(baseAmount1).add(limitAmount1); require(amount0 >= amount0Min, "amount0Min"); require(amount1 >= amount1Min, "amount1Min");
amount0 = unusedAmount0.add(baseAmount0).add(limitAmount0); amount1 = unusedAmount1.add(baseAmount1).add(limitAmount1); require(amount0 >= amount0Min, "amount0Min"); require(amount1 >= amount1Min, "amount1Min");
23,309
2
// Initiates sending of an AMB message to the opposite network_contract executor address on the other side_data calldata passed to the executor on the other side_gas gas limit used on the other network for executing a message_dataType AMB message dataType to be included as a part of the header/
function _sendMessage(address _contract, bytes _data, uint256 _gas, uint256 _dataType) internal returns (bytes32) { // it is not allowed to pass messages while other messages are processed // if other is not explicitly configured require(messageId() == bytes32(0) || allowReentrantRequests()); require(_gas >= getMinimumGasUsage(_data) && _gas <= maxGasPerTx()); (bytes32 _messageId, bytes memory header) = _packHeader(_contract, _gas, _dataType); bytes memory eventData = abi.encodePacked(header, _data); emitEventOnMessageRequest(_messageId, eventData); return _messageId; }
function _sendMessage(address _contract, bytes _data, uint256 _gas, uint256 _dataType) internal returns (bytes32) { // it is not allowed to pass messages while other messages are processed // if other is not explicitly configured require(messageId() == bytes32(0) || allowReentrantRequests()); require(_gas >= getMinimumGasUsage(_data) && _gas <= maxGasPerTx()); (bytes32 _messageId, bytes memory header) = _packHeader(_contract, _gas, _dataType); bytes memory eventData = abi.encodePacked(header, _data); emitEventOnMessageRequest(_messageId, eventData); return _messageId; }
21,821
8
// `voter` ์—๊ฒŒ ์ด ํˆฌํ‘œ๊ถŒ์— ๋Œ€ํ•œ ๊ถŒํ•œ์„ ๋ถ€์—ฌํ•˜์‹ญ์‹œ์˜ค. ์˜ค์ง `chairperson` ์œผ๋กœ๋ถ€ํ„ฐ ํ˜ธ์ถœ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
function giveRightToVote(address voter) public { // `require`์˜ ์ธ์ˆ˜๊ฐ€ `false`๋กœ ํ‰๊ฐ€๋˜๋ฉด, // ๊ทธ๊ฒƒ์€ ์ข…๋ฃŒ๋˜๊ณ  ๋ชจ๋“  ๋ณ€๊ฒฝ๋‚ด์šฉ์„ state์™€ // Ether Balance๋กœ ๋˜๋Œ๋ฆฝ๋‹ˆ๋‹ค. // ํ•จ์ˆ˜๊ฐ€ ์ž˜๋ชป ํ˜ธ์ถœ๋˜๋ฉด ์ด๊ฒƒ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. // ๊ทธ๋Ÿฌ๋‚˜ ์กฐ์‹ฌํ•˜์‹ญ์‹œ์˜ค, // ์ด๊ฒƒ์€ ํ˜„์žฌ ์ œ๊ณต๋œ ๋ชจ๋“  ๊ฐ€์Šค๋ฅผ ์†Œ๋น„ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค. // (์ด๊ฒƒ์€ ์•ž์œผ๋กœ ๋ฐ”๋€Œ๊ฒŒ ๋  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค) require( (msg.sender == chairperson) && !voters[voter].voted && (voters[voter].weight == 0) ); voters[voter].weight = 1; }
function giveRightToVote(address voter) public { // `require`์˜ ์ธ์ˆ˜๊ฐ€ `false`๋กœ ํ‰๊ฐ€๋˜๋ฉด, // ๊ทธ๊ฒƒ์€ ์ข…๋ฃŒ๋˜๊ณ  ๋ชจ๋“  ๋ณ€๊ฒฝ๋‚ด์šฉ์„ state์™€ // Ether Balance๋กœ ๋˜๋Œ๋ฆฝ๋‹ˆ๋‹ค. // ํ•จ์ˆ˜๊ฐ€ ์ž˜๋ชป ํ˜ธ์ถœ๋˜๋ฉด ์ด๊ฒƒ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. // ๊ทธ๋Ÿฌ๋‚˜ ์กฐ์‹ฌํ•˜์‹ญ์‹œ์˜ค, // ์ด๊ฒƒ์€ ํ˜„์žฌ ์ œ๊ณต๋œ ๋ชจ๋“  ๊ฐ€์Šค๋ฅผ ์†Œ๋น„ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค. // (์ด๊ฒƒ์€ ์•ž์œผ๋กœ ๋ฐ”๋€Œ๊ฒŒ ๋  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค) require( (msg.sender == chairperson) && !voters[voter].voted && (voters[voter].weight == 0) ); voters[voter].weight = 1; }
26,613
34
// user who will receive all funds
address internal beneficiary;
address internal beneficiary;
32,764
62
// current purchasable units per transaction
uint256 public unitsPerTransaction;
uint256 public unitsPerTransaction;
50,032
41
// Sells Shares if tokens transfered to this address
function _transferShares(address _sender, address _receipent, uint256 _amount) internal balanceCheck(_sender, _amount) notOkamaShares(_sender) checkContract(_receipent) notRestricted(_receipent){ if (_receipent == address(this)) { _sellViaCircValue(_sender, _amount); } else { shares[_sender] -= _amount; shares[_receipent] += _amount; emit Transfer(_sender, _receipent, _amount); } }
function _transferShares(address _sender, address _receipent, uint256 _amount) internal balanceCheck(_sender, _amount) notOkamaShares(_sender) checkContract(_receipent) notRestricted(_receipent){ if (_receipent == address(this)) { _sellViaCircValue(_sender, _amount); } else { shares[_sender] -= _amount; shares[_receipent] += _amount; emit Transfer(_sender, _receipent, _amount); } }
36,361
72
// max open sale tokens
uint public constant MAX_OPEN_SOLD = TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE; uint public constant STAKE_MULTIPLIER = TOTAL_SUPPLY / DIVISOR_STAKE;
uint public constant MAX_OPEN_SOLD = TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE; uint public constant STAKE_MULTIPLIER = TOTAL_SUPPLY / DIVISOR_STAKE;
7,325
46
// Transfer in sufficient dDai and use it to mint Dai.
totalDDaiRedeemed = _transferAndRedeemDDai(daiEquivalentAmount);
totalDDaiRedeemed = _transferAndRedeemDDai(daiEquivalentAmount);
19,358
334
// Returns the number of shares for a given `assetAmount`.Used by the frontend to calculate withdraw amounts. assetAmount is the asset amount to be withdrawnreturn share amount /
function assetAmountToShares(uint256 assetAmount) external view returns (uint256)
function assetAmountToShares(uint256 assetAmount) external view returns (uint256)
9,414
4
// ็ฎก็†่ฅไธšๆ‰ง็…ง็š„ๅˆ็บฆๅœฐๅ€ /
address bizLicContract;
address bizLicContract;
27,483
31
// Returns the number of decimals used to get its user representation.For example, if `decimals` equals `2`, a balance of `505` tokens shouldbe displayed to a user as `5,05` (`505 / 102`). Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; }
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; }
640
18
// The offset of an encoded pool key
uint256 private constant POP_OFFSET = NEXT_OFFSET + ADDR_SIZE;
uint256 private constant POP_OFFSET = NEXT_OFFSET + ADDR_SIZE;
5,484
84
// Gets the total amount of tokens sold/
function getTotalSold() public view virtual returns (uint256 totalSold) { return nTotalSold; }
function getTotalSold() public view virtual returns (uint256 totalSold) { return nTotalSold; }
17,153
306
// Precision factor used to improve rounding when computing weights for the final round
uint256 internal constant FINAL_ROUND_WEIGHT_PRECISION = 1000;
uint256 internal constant FINAL_ROUND_WEIGHT_PRECISION = 1000;
27,692
46
// ------------------------------------------------------------------------ Owners can send the funds to be distributed to stakers using this functiontokens number of tokens to distribute ------------------------------------------------------------------------
function ADDFUNDS(uint256 tokens) external onlyWhitelistAdmin{ //can only be called by regrewardContract uint256 transferTxFee = (onePercent(tokens).mul(txFee1)).div(10); uint256 tokens_ = (tokens.sub(transferTxFee)); _addPayout(tokens_); }
function ADDFUNDS(uint256 tokens) external onlyWhitelistAdmin{ //can only be called by regrewardContract uint256 transferTxFee = (onePercent(tokens).mul(txFee1)).div(10); uint256 tokens_ = (tokens.sub(transferTxFee)); _addPayout(tokens_); }
27,114
19
// ----------------------------- FEES----------------------------- Owner can send ETH to the Index, to perform some task, this eth belongs to him solhint-disable-next-line
function addOwnerBalance() external payable { accumulatedFee = accumulatedFee.add(msg.value); }
function addOwnerBalance() external payable { accumulatedFee = accumulatedFee.add(msg.value); }
1,041
40
// Modifier used to verify that a function for a given contract exists by using
* its {functionSelector} identifier and the key parent {contractAddress} identifier. * * @param contractAddress The contract where the functionSelector is supposed to live. * @param functionSelector The function identifier that will be checked */ modifier functionExists(address contractAddress, bytes4 functionSelector){ require(_functionTracking[contractAddress][functionSelector]._isTracked, "Seraph: Function is not tracked"); _; }
* its {functionSelector} identifier and the key parent {contractAddress} identifier. * * @param contractAddress The contract where the functionSelector is supposed to live. * @param functionSelector The function identifier that will be checked */ modifier functionExists(address contractAddress, bytes4 functionSelector){ require(_functionTracking[contractAddress][functionSelector]._isTracked, "Seraph: Function is not tracked"); _; }
34,945
117
// makes sure seller or buyer is not blacklisted
require(!_isBlacklisted[from] && !_isBlacklisted[to], "This account is blacklisted: If you feel this is incorrect please contac us and we will remove you"); require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if(amount == 0) { super._transfer(from, to, 0); return; }
require(!_isBlacklisted[from] && !_isBlacklisted[to], "This account is blacklisted: If you feel this is incorrect please contac us and we will remove you"); require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if(amount == 0) { super._transfer(from, to, 0); return; }
40,433
27
// InbestToken Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.Note they can later distribute these tokens as they wish using `transfer` and other`StandardToken` functions. /
contract InbestToken is StandardToken { string public constant name = "Inbest Token"; string public constant symbol = "IBST"; uint8 public constant decimals = 18; // TBD uint256 public constant INITIAL_SUPPLY = 17656263110 * (10 ** uint256(decimals)); /** * @dev Constructor that gives msg.sender all of existing tokens. */ function InbestToken() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; Transfer(0x0, msg.sender, INITIAL_SUPPLY); } }
contract InbestToken is StandardToken { string public constant name = "Inbest Token"; string public constant symbol = "IBST"; uint8 public constant decimals = 18; // TBD uint256 public constant INITIAL_SUPPLY = 17656263110 * (10 ** uint256(decimals)); /** * @dev Constructor that gives msg.sender all of existing tokens. */ function InbestToken() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; Transfer(0x0, msg.sender, INITIAL_SUPPLY); } }
26,968
8
// Amount of votes that holder has./sender_ address of the holder./ return number of votes.
function votesOf(address sender_) external view returns (uint256);
function votesOf(address sender_) external view returns (uint256);
1,770
31
// mapping of addresses to mapping of allowances for an address
mapping (address => mapping (address => uint)) allowances;
mapping (address => mapping (address => uint)) allowances;
17,316