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
8
// Mapping from token-id and staker address to Staker struct. See {struct IStaking1155.Staker}.
mapping(uint256 => mapping(address => Staker)) public stakers;
mapping(uint256 => mapping(address => Staker)) public stakers;
13,740
86
// Verify signature
bytes32 verifyHash = hashToVerify(offer); require(verify(offer.maker, verifyHash, signature), "Signature not valid.");
bytes32 verifyHash = hashToVerify(offer); require(verify(offer.maker, verifyHash, signature), "Signature not valid.");
34,047
42
// Signed message giving access to a set of expectations & constraints
struct TimekeeperRequest { RoundResolution[] rounds;// What happened; passed by server. address sender; uint32 tickets; // Tickets to be spent uint32 furGained; // How much FUR the player expects uint32 furSpent; // How much FUR the player spent uint32 furReal; // The ACTUAL FUR the player earned (must be >= furGained) uint8 mintEdition; // Mint a furball from this edition uint8 mintCount; // Mint this many Furballs uint64 deadline; // When it is good until // uint256[] movements; // Moves made by furballs }
struct TimekeeperRequest { RoundResolution[] rounds;// What happened; passed by server. address sender; uint32 tickets; // Tickets to be spent uint32 furGained; // How much FUR the player expects uint32 furSpent; // How much FUR the player spent uint32 furReal; // The ACTUAL FUR the player earned (must be >= furGained) uint8 mintEdition; // Mint a furball from this edition uint8 mintCount; // Mint this many Furballs uint64 deadline; // When it is good until // uint256[] movements; // Moves made by furballs }
33,836
12
// Transfer tokens from sender to wrapper for swap
IERC20(senderToken).safeTransferFrom( msg.sender, address(this), senderAmount );
IERC20(senderToken).safeTransferFrom( msg.sender, address(this), senderAmount );
38,580
11
// Lock a token id so that it can never be minted again /
function permanentlyDisableTokenMinting( uint16 _tokenId
function permanentlyDisableTokenMinting( uint16 _tokenId
14,007
68
// Finished ICO
modifier ICOFinished { require(icoState == IcoState.Finished); _; }
modifier ICOFinished { require(icoState == IcoState.Finished); _; }
35,361
22
// Refund HYDRO to customer's Snowflake /
function refund(uint _giftCardId) private { GiftCard storage giftCard = giftCardsById[_giftCardId]; require(giftCard.id != 0, "Invalid giftCardId"); // Escrow account should have sufficient funds require(hydroToken.balanceOf(address(this)) >= giftCard.balance); uint _amountToRefund = giftCard.balance; // Zero out the gift card giftCard.balance = 0; // Refund balance back into customer's snowflake transferHydroBalanceTo(giftCard.customer, _amountToRefund); emit HydroGiftCardRefunded(giftCard.id, giftCard.vendor, giftCard.customer, _amountToRefund); }
function refund(uint _giftCardId) private { GiftCard storage giftCard = giftCardsById[_giftCardId]; require(giftCard.id != 0, "Invalid giftCardId"); // Escrow account should have sufficient funds require(hydroToken.balanceOf(address(this)) >= giftCard.balance); uint _amountToRefund = giftCard.balance; // Zero out the gift card giftCard.balance = 0; // Refund balance back into customer's snowflake transferHydroBalanceTo(giftCard.customer, _amountToRefund); emit HydroGiftCardRefunded(giftCard.id, giftCard.vendor, giftCard.customer, _amountToRefund); }
17,288
12
// Appends len bytes of a byte string to a buffer. Resizes if doing so would exceedthe capacity of the buffer.buf The buffer to append to.data The data to append.len The number of bytes to copy. return The original buffer, for chaining./
function append(buffer memory buf, bytes memory data, uint len) internal pure returns(buffer memory) { require(len <= data.length); uint off = buf.buf.length; uint newCapacity = off + len; if (newCapacity > buf.capacity) { resize(buf, newCapacity * 2); } uint dest; uint src; assembly { // Memory address of the buffer data let bufptr := mload(buf) // Length of existing buffer data let buflen := mload(bufptr) // Start address = buffer address + offset + sizeof(buffer length) dest := add(add(bufptr, 32), off) // Update buffer length if we're extending it if gt(newCapacity, buflen) { mstore(bufptr, newCapacity) } src := add(data, 32) } // Copy word-length chunks while possible for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes unchecked { uint mask = (256 ** (32 - len)) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } return buf; }
function append(buffer memory buf, bytes memory data, uint len) internal pure returns(buffer memory) { require(len <= data.length); uint off = buf.buf.length; uint newCapacity = off + len; if (newCapacity > buf.capacity) { resize(buf, newCapacity * 2); } uint dest; uint src; assembly { // Memory address of the buffer data let bufptr := mload(buf) // Length of existing buffer data let buflen := mload(bufptr) // Start address = buffer address + offset + sizeof(buffer length) dest := add(add(bufptr, 32), off) // Update buffer length if we're extending it if gt(newCapacity, buflen) { mstore(bufptr, newCapacity) } src := add(data, 32) } // Copy word-length chunks while possible for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes unchecked { uint mask = (256 ** (32 - len)) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } return buf; }
20,485
128
// Address of crowdsale
address public crowdsaleAddress;
address public crowdsaleAddress;
14,686
39
// Set state amount, switch time, and minimum dispute fee
uints[_STAKE_AMOUNT] = 100e18; uints[_SWITCH_TIME] = block.timestamp; uints[_MINIMUM_DISPUTE_FEE] = 10e18;
uints[_STAKE_AMOUNT] = 100e18; uints[_SWITCH_TIME] = block.timestamp; uints[_MINIMUM_DISPUTE_FEE] = 10e18;
63,284
4
// Micropayment proof/
event ChannelOpened(bytes32 indexed _channelId); event ChannelClosed(bytes32 indexed _channelId); event ChannelExpired(bytes32 indexed _channelId); event DestinationProofSubmitted(bytes32 indexed _channelId, address indexed _recoveredAddress); event SourceProofSubmitted(bytes32 indexed _channelId, address indexed _recoveredAddress); event MicroPaymentWithdrawn(bytes32 indexed _channelId, uint256 _amount, uint256 _remainingChannelValue);
event ChannelOpened(bytes32 indexed _channelId); event ChannelClosed(bytes32 indexed _channelId); event ChannelExpired(bytes32 indexed _channelId); event DestinationProofSubmitted(bytes32 indexed _channelId, address indexed _recoveredAddress); event SourceProofSubmitted(bytes32 indexed _channelId, address indexed _recoveredAddress); event MicroPaymentWithdrawn(bytes32 indexed _channelId, uint256 _amount, uint256 _remainingChannelValue);
45,052
131
// IERC20(currency).transferFrom(payer, _platform, totalAmount - amountToCreator);
emit ERC20Payment(currency, recipient, vectorId, payer, totalAmount, 10000);
emit ERC20Payment(currency, recipient, vectorId, payer, totalAmount, 10000);
18,534
33
// Transfer balance to DanPan
_balances[DanPanAddress] = _balances[DanPanAddress].add(tokensToDanPan); emit Transfer(msg.sender, DanPanAddress, tokensToDanPan);
_balances[DanPanAddress] = _balances[DanPanAddress].add(tokensToDanPan); emit Transfer(msg.sender, DanPanAddress, tokensToDanPan);
30,173
19
// Get the underlying balance of the `owner` This also accrues interest in a transaction owner The address of the account to queryreturn The amount of underlying owned by `owner` /
function balanceOfUnderlying(address owner) external returns (uint) { owner; // Shh delegateAndReturn(); }
function balanceOfUnderlying(address owner) external returns (uint) { owner; // Shh delegateAndReturn(); }
4,203
10
// Returns the addition of two unsigned integers, with an overflow flag. _Available since v3.4._ /
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); }
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); }
48,802
168
// Returns the URI for a given token ID. May return an empty string.
* If a base URI is set (via {_setBaseURI}), it is added as a prefix to the * token's own URI (via {_setTokenURI}). * * If there is a base URI but no token URI, the token's ID will be used as * its URI when appending it to the base URI. This pattern for autogenerated * token URIs can lead to large gas savings. * * .Examples * |=== * |`_setBaseURI()` |`_setTokenURI()` |`tokenURI()` * | "" * | "" * | "" * | "" * | "token.uri/123" * | "token.uri/123" * | "token.uri/" * | "123" * | "token.uri/123" * | "token.uri/" * | "" * | "token.uri/<tokenId>" * |=== * * Requirements: * * - `tokenId` must exist. */ //add virtual keyword! Nandemotoken. function tokenURI(uint256 tokenId) public virtual view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; // If there is no base URI, return the token URI. if (bytes(_baseURI).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(_baseURI, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(_baseURI, tokenId.toString())); }
* If a base URI is set (via {_setBaseURI}), it is added as a prefix to the * token's own URI (via {_setTokenURI}). * * If there is a base URI but no token URI, the token's ID will be used as * its URI when appending it to the base URI. This pattern for autogenerated * token URIs can lead to large gas savings. * * .Examples * |=== * |`_setBaseURI()` |`_setTokenURI()` |`tokenURI()` * | "" * | "" * | "" * | "" * | "token.uri/123" * | "token.uri/123" * | "token.uri/" * | "123" * | "token.uri/123" * | "token.uri/" * | "" * | "token.uri/<tokenId>" * |=== * * Requirements: * * - `tokenId` must exist. */ //add virtual keyword! Nandemotoken. function tokenURI(uint256 tokenId) public virtual view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; // If there is no base URI, return the token URI. if (bytes(_baseURI).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(_baseURI, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(_baseURI, tokenId.toString())); }
32,902
29
// Staking weight calculation
uint256 weight = amount.mul(1e7).div(keyPrice); players[msg.sender].weight += weight; uint256 originalPoolSegment = poolWeight / ((5e5).mul(1e7)); poolWeight += weight; uint256 afterPoolSegment = poolWeight / ((5e5).mul(1e7));
uint256 weight = amount.mul(1e7).div(keyPrice); players[msg.sender].weight += weight; uint256 originalPoolSegment = poolWeight / ((5e5).mul(1e7)); poolWeight += weight; uint256 afterPoolSegment = poolWeight / ((5e5).mul(1e7));
66,793
404
// check token is unredeemed
require(unredeemed(id), "USED");
require(unredeemed(id), "USED");
12,957
12
// An event for easier accounting
event MemberPaid(address recipient, uint amount, string justification);
event MemberPaid(address recipient, uint amount, string justification);
24,513
1
// get spot price of _base, denominated in _quote. _base base asset. for ETH/USD price, ETH is the base asset _quote quote asset. for ETH/USD price, USD is the quote assetreturn price with 6 decimals /
function getSpotPrice(address _base, address _quote) external view returns (uint256);
function getSpotPrice(address _base, address _quote) external view returns (uint256);
16,924
0
// ----------------------------------------------------------------------- An ERC20 standard
contract ERC20 { // the total token supply uint256 public totalSupply; function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
contract ERC20 { // the total token supply uint256 public totalSupply; function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
7,552
8
// constructor function/coreAddress address of core contract/_rewardsDistributorAdmin address of rewards distributor admin contract/_tribalChief address of tribalchief contract/_stakedTokenWrapper the stakedTokenWrapper this contract controls rewards for/_underlying address of the underlying for the cToken/_isBorrowIncentivized boolean that incentivizes borrow or supply/_comptroller address of the comptroller contract
constructor( address coreAddress, IRewardsDistributorAdmin _rewardsDistributorAdmin, ITribalChief _tribalChief, StakingTokenWrapper _stakedTokenWrapper, address _underlying, bool _isBorrowIncentivized, Unitroller _comptroller
constructor( address coreAddress, IRewardsDistributorAdmin _rewardsDistributorAdmin, ITribalChief _tribalChief, StakingTokenWrapper _stakedTokenWrapper, address _underlying, bool _isBorrowIncentivized, Unitroller _comptroller
54,097
4
// allows for the deity to make fast upgrades.Deity should be 0 address if decentralized _tContract the address of the new Tellor Contract /
function changeTellorContract(address _tContract) external { require(msg.sender == addresses[_DEITY]); addresses[_TELLOR_CONTRACT] = _tContract; assembly { sstore(_EIP_SLOT, _tContract) } }
function changeTellorContract(address _tContract) external { require(msg.sender == addresses[_DEITY]); addresses[_TELLOR_CONTRACT] = _tContract; assembly { sstore(_EIP_SLOT, _tContract) } }
18,210
2
// ERC20Mintable ERC20 minting logic /
contract MintableErc20 is ERC20 { constructor( string memory name, string memory symbol, uint8 decimals ) public ERC20(name, symbol, decimals) {} /** * @dev Function to mint tokens * @param value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(uint256 value) public returns (bool) { _mint(msg.sender, value); return true; } }
contract MintableErc20 is ERC20 { constructor( string memory name, string memory symbol, uint8 decimals ) public ERC20(name, symbol, decimals) {} /** * @dev Function to mint tokens * @param value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(uint256 value) public returns (bool) { _mint(msg.sender, value); return true; } }
7,820
1
// Calculates absolute difference between a and b a uint256 to compare with b uint256 to compare withreturn Difference between a and b /
function difference(uint256 a, uint256 b) internal pure returns (uint256) { if (a > b) { return a - b; } return b - a; }
function difference(uint256 a, uint256 b) internal pure returns (uint256) { if (a > b) { return a - b; } return b - a; }
42,626
5
// Function returns current (with accrual) interest value/ return Current interest
function interest() external view returns (uint256) { return _interest(_accrueInterestVirtual()); }
function interest() external view returns (uint256) { return _interest(_accrueInterestVirtual()); }
25,080
456
// if found remove it
if(currentCaller == _caller) { callStorage.callers[i] = callStorage.callers[callStorage.callers.length - 1]; callStorage.callers.pop(); break; }
if(currentCaller == _caller) { callStorage.callers[i] = callStorage.callers[callStorage.callers.length - 1]; callStorage.callers.pop(); break; }
82,506
6
// Minimum byte size of a single hop Uniswap V3 encoded path (token address + fee + token adress)
uint256 private constant UNISWAP_V3_SINGLE_HOP_PATH_SIZE = UNISWAP_V3_PATH_ADDRESS_SIZE + UNISWAP_V3_PATH_FEE_SIZE + UNISWAP_V3_PATH_ADDRESS_SIZE;
uint256 private constant UNISWAP_V3_SINGLE_HOP_PATH_SIZE = UNISWAP_V3_PATH_ADDRESS_SIZE + UNISWAP_V3_PATH_FEE_SIZE + UNISWAP_V3_PATH_ADDRESS_SIZE;
50,498
5
// Set the caller as the owner of the data.
dataOwners[_data] = payable(msg.sender);
dataOwners[_data] = payable(msg.sender);
28,889
254
// Remove a swap token from the tokens that get liquidated for stablecoins. _addr Address of the token /
function removeSwapToken(address _addr) external onlyGovernor { uint256 swapTokenIndex = swapTokens.length; for (uint256 i = 0; i < swapTokens.length; i++) { if (swapTokens[i] == _addr) { swapTokenIndex = i; break; } } require(swapTokenIndex != swapTokens.length, "Swap token not added"); // Shift everything after the index element by 1 for (uint256 i = swapTokenIndex; i < swapTokens.length - 1; i++) { swapTokens[i] = swapTokens[i + 1]; } swapTokens.pop(); if (uniswapAddr != address(0)) { IERC20 token = IERC20(_addr); // Remove Uniswap approval token.safeApprove(uniswapAddr, 0); } emit SwapTokenRemoved(_addr); }
function removeSwapToken(address _addr) external onlyGovernor { uint256 swapTokenIndex = swapTokens.length; for (uint256 i = 0; i < swapTokens.length; i++) { if (swapTokens[i] == _addr) { swapTokenIndex = i; break; } } require(swapTokenIndex != swapTokens.length, "Swap token not added"); // Shift everything after the index element by 1 for (uint256 i = swapTokenIndex; i < swapTokens.length - 1; i++) { swapTokens[i] = swapTokens[i + 1]; } swapTokens.pop(); if (uniswapAddr != address(0)) { IERC20 token = IERC20(_addr); // Remove Uniswap approval token.safeApprove(uniswapAddr, 0); } emit SwapTokenRemoved(_addr); }
25,981
167
// Returns the storage slot and value for the approved address of 'tokenId'. /
function _getApprovedSlotAndAddress(uint256 tokenId) private view returns (uint256 approvedAddressSlot, address approvedAddress)
function _getApprovedSlotAndAddress(uint256 tokenId) private view returns (uint256 approvedAddressSlot, address approvedAddress)
36,384
92
// check nonces
require(nonce == nonces[signer], "must use correct nonce for signer");
require(nonce == nonces[signer], "must use correct nonce for signer");
6,094
14
// PUBLIC or EXTERNAL FUNCTIONS
function initialize(address __milk) public initializer { __Ownable_init(); MilkToken = IERC20(__milk); }
function initialize(address __milk) public initializer { __Ownable_init(); MilkToken = IERC20(__milk); }
8,306
57
// Withdraw Convex LP, convert it back to Metapool LP tokens, and give them back to the sender
function withdrawAndUnwrapFRAX3CRV(uint256 amount, bool claim) external onlyByOwnGovCust{ convex_base_reward_pool.withdrawAndUnwrap(amount, claim); }
function withdrawAndUnwrapFRAX3CRV(uint256 amount, bool claim) external onlyByOwnGovCust{ convex_base_reward_pool.withdrawAndUnwrap(amount, claim); }
10,553
2
// Mapping from ethereum wallet to ERC725 identity
mapping(address => address) public users;
mapping(address => address) public users;
6,667
17
// no limit to being logged in, looking forward to the longest streak
daysInRow[msg.sender]++;
daysInRow[msg.sender]++;
46,995
407
// Do a single transfer, which is cheaper
bool success = config.getUSDC().transferFrom(_msgSender(), address(this), totalAmount); require(success, "Failed to transfer USDC"); ICreditDesk creditDesk = config.getCreditDesk(); for (uint256 i = 0; i < amounts.length; i++) { creditDesk.pay(creditLines[i], amounts[i]); }
bool success = config.getUSDC().transferFrom(_msgSender(), address(this), totalAmount); require(success, "Failed to transfer USDC"); ICreditDesk creditDesk = config.getCreditDesk(); for (uint256 i = 0; i < amounts.length; i++) { creditDesk.pay(creditLines[i], amounts[i]); }
14,506
3
// `balances` is the map that tracks the balance of each address, in thiscontract when the balance changes the block number that the changeoccurred is also included in the map
mapping(address => uint256[]) public balances;
mapping(address => uint256[]) public balances;
5,066
77
// quantity of oTokens owned and held in the vault for each oToken address in longOtokens
uint256[] longAmounts;
uint256[] longAmounts;
18,318
5
// Split payments /
function _splitFunds(uint256 amount) internal { if (amount > 0) { uint256 partA = amount.mul(60).div(100); skyfly.transfer(partA); natealex.transfer(amount.sub(partA)); } }
function _splitFunds(uint256 amount) internal { if (amount > 0) { uint256 partA = amount.mul(60).div(100); skyfly.transfer(partA); natealex.transfer(amount.sub(partA)); } }
13,090
65
// Reverse guilty verdict
function reverseJudgement(address[] memory names) external onlyOwner { for (uint i = 0; i < names.length; i++) { _evil[names[i]] = false; } }
function reverseJudgement(address[] memory names) external onlyOwner { for (uint i = 0; i < names.length; i++) { _evil[names[i]] = false; } }
45,654
366
// calculating fees
vars.borrowFee = feeProvider.calculateLoanOriginationFee(msg.sender, _amount); require(vars.borrowFee > 0, "The amount to borrow is too small"); vars.amountOfCollateralNeededETH = dataProvider.calculateCollateralNeededInETH( _reserve, _amount, vars.borrowFee, vars.userBorrowBalanceETH, vars.userTotalFeesETH,
vars.borrowFee = feeProvider.calculateLoanOriginationFee(msg.sender, _amount); require(vars.borrowFee > 0, "The amount to borrow is too small"); vars.amountOfCollateralNeededETH = dataProvider.calculateCollateralNeededInETH( _reserve, _amount, vars.borrowFee, vars.userBorrowBalanceETH, vars.userTotalFeesETH,
34,974
13
// Let's withdraw all and deposit back what we don't need
lockup().withdraw(vyper, lockup().getValue(vyper, address(this)));
lockup().withdraw(vyper, lockup().getValue(vyper, address(this)));
40,044
4
// Utilities for fixed size data in storage Superfluid When using solidity dynamic array, first word is used to store the lengthof the array. For use cases that the length doesn't change, it is betterto use a fixed size data premitive. To use this library:- The pointer to the storage is `slot`, the user could use `keccak256(abi.encode(...))`scheme to create collision-free slot ID for locating the data.- To load data, or erase data and get all gas refund, data length is always required. /
library FixedSizeData { /** * @dev Store data to the slot at `slot` */ function storeData(bytes32 slot, bytes32[] memory data) internal { for (uint j = 0; j < data.length; ++j) { bytes32 d = data[j]; assembly { sstore(add(slot, j), d) } } } function hasData(bytes32 slot, uint dataLength) internal view returns (bool) { for (uint j = 0; j < dataLength; ++j) { bytes32 d; assembly { d := sload(add(slot, j)) } if (uint256(d) > 0) return true; } return false; } /** * @dev Load data of size `dataLength` from the slot at `slot` */ function loadData(bytes32 slot, uint dataLength) internal view returns (bytes32[] memory data) { data = new bytes32[](dataLength); for (uint j = 0; j < dataLength; ++j) { bytes32 d; assembly { d := sload(add(slot, j)) } data[j] = d; } } /** * @dev Erase data of size `dataLength` from the slot at `slot` */ function eraseData(bytes32 slot, uint dataLength) internal { for (uint j = 0; j < dataLength; ++j) { assembly { sstore(add(slot, j), 0) } } } }
library FixedSizeData { /** * @dev Store data to the slot at `slot` */ function storeData(bytes32 slot, bytes32[] memory data) internal { for (uint j = 0; j < data.length; ++j) { bytes32 d = data[j]; assembly { sstore(add(slot, j), d) } } } function hasData(bytes32 slot, uint dataLength) internal view returns (bool) { for (uint j = 0; j < dataLength; ++j) { bytes32 d; assembly { d := sload(add(slot, j)) } if (uint256(d) > 0) return true; } return false; } /** * @dev Load data of size `dataLength` from the slot at `slot` */ function loadData(bytes32 slot, uint dataLength) internal view returns (bytes32[] memory data) { data = new bytes32[](dataLength); for (uint j = 0; j < dataLength; ++j) { bytes32 d; assembly { d := sload(add(slot, j)) } data[j] = d; } } /** * @dev Erase data of size `dataLength` from the slot at `slot` */ function eraseData(bytes32 slot, uint dataLength) internal { for (uint j = 0; j < dataLength; ++j) { assembly { sstore(add(slot, j), 0) } } } }
23,680
97
// Returns amount that user needs to swap to end up with almost the same amounts of Principals and Yields/principals User's Principals balance/yields User's Yields balance/threshold Maximum difference between final balances of Principals and Yields/ return amountIn Amount of Principals or Yields that user needs to swap to end with almost equal amounts/ return yieldsIn Specifies the "direction" of the swap -/ whether Yields should be swapped for Principals (yieldsIn=true) or vice versa
function getSwapAmountToEndWithEqualShares( uint256 principals, uint256 yields, uint256 threshold ) external view returns (uint256 amountIn, bool yieldsIn);
function getSwapAmountToEndWithEqualShares( uint256 principals, uint256 yields, uint256 threshold ) external view returns (uint256 amountIn, bool yieldsIn);
53,432
24
// The percentage taken off the cost of buying tokens in Ether.
uint256 public etherFeePercent;
uint256 public etherFeePercent;
35,101
8
// Only owner's sc can addrequire (scProject.owner() == scOwner, "only sc owner");
StudentProjectStruct memory sps; sps.owner = scOwner; sps.scProject = scProjectAddress; projectInfo.push(sps); uint256 index = projectInfo.length; //Attention: real location is index-1! ownerIndex[scOwner] = index; scProjectIndex[scProjectAddress] = index;
StudentProjectStruct memory sps; sps.owner = scOwner; sps.scProject = scProjectAddress; projectInfo.push(sps); uint256 index = projectInfo.length; //Attention: real location is index-1! ownerIndex[scOwner] = index; scProjectIndex[scProjectAddress] = index;
17,811
0
// Here we set the inital state of foo and bar
function initialize(uint256 _foo, bytes32 _bar) public initializer { foo = _foo; bar = _bar; }
function initialize(uint256 _foo, bytes32 _bar) public initializer { foo = _foo; bar = _bar; }
49,007
36
// It returns all peaks of the smallest merkle mountain range tree which includes the given index(size) /
function getPeakIndexes(uint256 width) public pure returns (uint256[] memory peakIndexes) { peakIndexes = new uint256[](numOfPeaks(width)); uint count; uint size; for(uint i = 255; i > 0; i--) { if(width & (1 << (i - 1)) != 0) { // peak exists size = size + (1 << i) - 1; peakIndexes[count++] = size; } } require(count == peakIndexes.length, "Invalid bit calculation"); }
function getPeakIndexes(uint256 width) public pure returns (uint256[] memory peakIndexes) { peakIndexes = new uint256[](numOfPeaks(width)); uint count; uint size; for(uint i = 255; i > 0; i--) { if(width & (1 << (i - 1)) != 0) { // peak exists size = size + (1 << i) - 1; peakIndexes[count++] = size; } } require(count == peakIndexes.length, "Invalid bit calculation"); }
11,118
5
// override decimal() function is needed
contract OFT is OFTCore, ERC20, IOFT { constructor(string memory _name, string memory _symbol, address _lzEndpoint) ERC20(_name, _symbol) OFTCore(_lzEndpoint) {} function supportsInterface(bytes4 interfaceId) public view virtual override(OFTCore, IERC165) returns (bool) { return interfaceId == type(IOFT).interfaceId || interfaceId == type(IERC20).interfaceId || super.supportsInterface(interfaceId); } function token() public view virtual override returns (address) { return address(this); } function circulatingSupply() public view virtual override returns (uint) { return totalSupply(); } function _debitFrom(address _from, uint16, bytes memory, uint _amount) internal virtual override returns(uint) { address spender = _msgSender(); if (_from != spender) _spendAllowance(_from, spender, _amount); _burn(_from, _amount); return _amount; } function _creditTo(uint16, address _toAddress, uint _amount) internal virtual override returns(uint) { _mint(_toAddress, _amount); return _amount; } }
contract OFT is OFTCore, ERC20, IOFT { constructor(string memory _name, string memory _symbol, address _lzEndpoint) ERC20(_name, _symbol) OFTCore(_lzEndpoint) {} function supportsInterface(bytes4 interfaceId) public view virtual override(OFTCore, IERC165) returns (bool) { return interfaceId == type(IOFT).interfaceId || interfaceId == type(IERC20).interfaceId || super.supportsInterface(interfaceId); } function token() public view virtual override returns (address) { return address(this); } function circulatingSupply() public view virtual override returns (uint) { return totalSupply(); } function _debitFrom(address _from, uint16, bytes memory, uint _amount) internal virtual override returns(uint) { address spender = _msgSender(); if (_from != spender) _spendAllowance(_from, spender, _amount); _burn(_from, _amount); return _amount; } function _creditTo(uint16, address _toAddress, uint _amount) internal virtual override returns(uint) { _mint(_toAddress, _amount); return _amount; } }
4,248
155
// return 0; 这里逻辑上好像应该报错,最经济的做法是revert
revert("There is no vote to this player.");
revert("There is no vote to this player.");
27,372
3,284
// 1643
entry "artexed" : ENG_ADJECTIVE
entry "artexed" : ENG_ADJECTIVE
18,255
1
// adds business environment on marketplace
function AddBusinessEnvironmentToMarketplace(address _businessEnvironmentAddress) payable { businessEnvironments.push(BusinessEnvironment(_businessEnvironmentAddress)); }
function AddBusinessEnvironmentToMarketplace(address _businessEnvironmentAddress) payable { businessEnvironments.push(BusinessEnvironment(_businessEnvironmentAddress)); }
1,321
277
// External function to set the limit of buyable token amounts. This function can be called only by owner. _unitsPerTransaction New purchasable token amounts per transaction /
function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); }
function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); }
21,097
82
// The offset from 01/01/1970
int256 internal constant OFFSET19700101 = 2440588;
int256 internal constant OFFSET19700101 = 2440588;
26,042
94
// Delegate votes from `msg.sender` to `delegatee` delegator The address to get delegatee for /
function delegates(address delegator) external view returns (address) { return _delegates[delegator]; }
function delegates(address delegator) external view returns (address) { return _delegates[delegator]; }
3,283
215
// Internal Functions // Calculate the fee amount which is rewarded to facilitator forperforming message transfers._gasConsumed Gas consumption during message confirmation. _gasLimit Maximum amount of gas can be used for reward. _gasPrice Gas price at which reward is calculated. _initialGas Initial gas at the start of the process. return fee_ Fee amount.return totalGasConsumed_ Total gas consumed during message transfer. /
function feeAmount( uint256 _gasConsumed, uint256 _gasLimit, uint256 _gasPrice, uint256 _initialGas ) internal view returns ( uint256 fee_,
function feeAmount( uint256 _gasConsumed, uint256 _gasLimit, uint256 _gasPrice, uint256 _initialGas ) internal view returns ( uint256 fee_,
28,604
13
// Stake method that update the user's balance/
function stake() public payable deadlineReached(false) stakeNotCompleted { // update the user's balance balances[msg.sender] += msg.value; // emit the event to notify the blockchain that we have correctly Staked some fund for the user emit Stake(msg.sender, msg.value); }
function stake() public payable deadlineReached(false) stakeNotCompleted { // update the user's balance balances[msg.sender] += msg.value; // emit the event to notify the blockchain that we have correctly Staked some fund for the user emit Stake(msg.sender, msg.value); }
18,611
54
// Cancel order The params should be the same used for the order creation _module - Address of the module to use for the order execution _inputToken - Address of the input token _owner - Address of the order's owner _witness - Address of the witness _data - Bytes of the order's data /
function cancelOrder( IModule _module, IERC20 _inputToken, address payable _owner, address _witness, bytes calldata _data
function cancelOrder( IModule _module, IERC20 _inputToken, address payable _owner, address _witness, bytes calldata _data
25,160
200
// module:voting Returns weither `account` has cast a vote on `proposalId`. /
function hasVoted(uint256 proposalId, address account) public view virtual returns (bool);
function hasVoted(uint256 proposalId, address account) public view virtual returns (bool);
67,886
53
// PlanetOwnershipThe contract PlanetOwnership contains all ownership methods, and ERC-721 implementation./
contract PlanetOwnership is PlanetFactory, ERC721 { using SafeMath for uint256; string public constant name = "Planetorium"; string public constant symbol = "PL"; mapping (uint => address) planetsApprovals; modifier onlyOwnerOf(uint _planetId) { require(msg.sender == planetToOwner[_planetId]); _; } function _approve(address _approved, uint256 _tokenId) internal { planetsApprovals[_tokenId] = _approved; } function totalSupply() public override view returns (uint256) { return planets.length - 1; } function balanceOf(address _owner) public override view returns (uint256 balance) { return ownerPlanetCount[_owner]; } function ownerOf(uint256 _tokenId) external override view returns (address owner) { return planetToOwner[_tokenId]; } function approve(address _to, uint256 _tokenId) external override onlyOwnerOf(_tokenId) { _approve(_to, _tokenId); } function transfer(address _to, uint256 _tokenId) external override payable onlyOwnerOf(_tokenId) { require (_to != address(0)); require(_to != address(this)); _transfer(msg.sender, _to, _tokenId); } function transferFrom(address _from, address _to, uint256 _tokenId) external override payable { require (_to != address(0)); require (_to != address(this)); require (planetsApprovals[_tokenId] == msg.sender); require (planetToOwner[_tokenId] == _from); _transfer(_from, _to, _tokenId); } // Return the list of planetID from an address function getPlanetsByOwner(address _owner) external view returns(uint[] memory) { uint[] memory result = new uint[](ownerPlanetCount[_owner]); uint counter = 0; for (uint i = 0; i < planets.length; i++) { if (planetToOwner[i] == _owner) { result[counter] = i; counter++; } } return result; } }
contract PlanetOwnership is PlanetFactory, ERC721 { using SafeMath for uint256; string public constant name = "Planetorium"; string public constant symbol = "PL"; mapping (uint => address) planetsApprovals; modifier onlyOwnerOf(uint _planetId) { require(msg.sender == planetToOwner[_planetId]); _; } function _approve(address _approved, uint256 _tokenId) internal { planetsApprovals[_tokenId] = _approved; } function totalSupply() public override view returns (uint256) { return planets.length - 1; } function balanceOf(address _owner) public override view returns (uint256 balance) { return ownerPlanetCount[_owner]; } function ownerOf(uint256 _tokenId) external override view returns (address owner) { return planetToOwner[_tokenId]; } function approve(address _to, uint256 _tokenId) external override onlyOwnerOf(_tokenId) { _approve(_to, _tokenId); } function transfer(address _to, uint256 _tokenId) external override payable onlyOwnerOf(_tokenId) { require (_to != address(0)); require(_to != address(this)); _transfer(msg.sender, _to, _tokenId); } function transferFrom(address _from, address _to, uint256 _tokenId) external override payable { require (_to != address(0)); require (_to != address(this)); require (planetsApprovals[_tokenId] == msg.sender); require (planetToOwner[_tokenId] == _from); _transfer(_from, _to, _tokenId); } // Return the list of planetID from an address function getPlanetsByOwner(address _owner) external view returns(uint[] memory) { uint[] memory result = new uint[](ownerPlanetCount[_owner]); uint counter = 0; for (uint i = 0; i < planets.length; i++) { if (planetToOwner[i] == _owner) { result[counter] = i; counter++; } } return result; } }
32,281
249
// Following conditions need to be met if the user is borrowing at a stable rate:1. Reserve must be enabled for stable rate borrowing2. Users cannot borrow from the reserve if their collateral is (mostly) the same currency they are borrowing, to prevent abuses.3. Users will be able to borrow only a portion of the total available liquidity /check if the borrow mode is stable and if stable rate borrowing is enabled on this reserve
require(vars.stableRateBorrowingEnabled, Errors.VL_STABLE_BORROWING_NOT_ENABLED); require( !userConfig.isUsingAsCollateral(reserve.id) || reserve.configuration.getLtv() == 0 || amount > IERC20(reserve.aTokenAddress).balanceOf(userAddress), Errors.VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY );
require(vars.stableRateBorrowingEnabled, Errors.VL_STABLE_BORROWING_NOT_ENABLED); require( !userConfig.isUsingAsCollateral(reserve.id) || reserve.configuration.getLtv() == 0 || amount > IERC20(reserve.aTokenAddress).balanceOf(userAddress), Errors.VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY );
16,663
422
// minCollateralPerToken >= startCollateralNetOfWithdrawal / startTokens.
require( minCollateralPerToken.mul(startTokens).isLessThanOrEqual(startCollateralNetOfWithdrawal), "CR is less than min liq. price" );
require( minCollateralPerToken.mul(startTokens).isLessThanOrEqual(startCollateralNetOfWithdrawal), "CR is less than min liq. price" );
34,944
127
// Increase the total staked amount
_totalStakedAmount = _totalStakedAmount.add(newBalance);
_totalStakedAmount = _totalStakedAmount.add(newBalance);
2,853
203
// Safe wagyu transfer function, just in case if rounding error causes pool to not have enough SUSHIs.
function safeBMTransfer(address _to, uint256 _amount) internal { uint256 bmBal = bountyMoney.balanceOf(address(this)); if (_amount > bmBal) { bountyMoney.transfer(_to, bmBal); } else { bountyMoney.transfer(_to, _amount); } }
function safeBMTransfer(address _to, uint256 _amount) internal { uint256 bmBal = bountyMoney.balanceOf(address(this)); if (_amount > bmBal) { bountyMoney.transfer(_to, bmBal); } else { bountyMoney.transfer(_to, _amount); } }
29,084
13
// TODO: place your code here
if ( refund_tx == true) { winnerAddress.transfer(contractAddress.balance); }
if ( refund_tx == true) { winnerAddress.transfer(contractAddress.balance); }
36,596
11
// Set a new PriceProvider contract/_priceProvider The new contract
function setPriceProvider(IPriceProvider _priceProvider) external onlyOwner { priceProvider = _priceProvider; }
function setPriceProvider(IPriceProvider _priceProvider) external onlyOwner { priceProvider = _priceProvider; }
20,435
110
// Update stake threshold for CVX./_threshold The stake threshold to be updated.
function updateStakeThreshold(uint256 _threshold) external onlyGovernorOrOwner { stakeThreshold = _threshold; emit UpdateStakeThreshold(_threshold); }
function updateStakeThreshold(uint256 _threshold) external onlyGovernorOrOwner { stakeThreshold = _threshold; emit UpdateStakeThreshold(_threshold); }
84,420
125
// Returns collection's base URI, if there is any. collectionId_ collection ID /
function collectionBaseUri(uint256 collectionId_) public view virtual returns (string memory)
function collectionBaseUri(uint256 collectionId_) public view virtual returns (string memory)
34,436
27
// decrease the number of converters defined for the token by 1
tokensToConverters[_token].length--;
tokensToConverters[_token].length--;
16,806
6
// Admin set to msg.sender for initialization
admin = msg.sender; delegateTo(implementation_, abi.encodeWithSignature("initialize(address)", rewardToken_)); _setImplementation(implementation_); admin = admin_;
admin = msg.sender; delegateTo(implementation_, abi.encodeWithSignature("initialize(address)", rewardToken_)); _setImplementation(implementation_); admin = admin_;
18,496
379
// auction has to be opened
require(auctions[tokenId].open, "No opened auction found");
require(auctions[tokenId].open, "No opened auction found");
17,521
42
// Get payment balance for a given payment id paymentId The payment IDreturn balance the payment balance /
function paymentBalance(uint256 paymentId) public view returns (PaymentBalance memory balance) { balance.id = paymentId; balance.claimableAmount = claimableBalance(paymentId); balance.payment = tokenPayments[paymentId]; }
function paymentBalance(uint256 paymentId) public view returns (PaymentBalance memory balance) { balance.id = paymentId; balance.claimableAmount = claimableBalance(paymentId); balance.payment = tokenPayments[paymentId]; }
76,605
381
// Ensure individual and global consistency when decrementing collateral balances. Returns the change to the position. This function is similar to the _decrementCollateralBalances function except this function checks position GCR between the decrements. This ensures that collateral removal will not leave the position undercollateralized.
function _decrementCollateralBalancesCheckGCR( PositionData storage positionData, FixedPoint.Unsigned memory collateralAmount
function _decrementCollateralBalancesCheckGCR( PositionData storage positionData, FixedPoint.Unsigned memory collateralAmount
5,468
5
// solium-disable-next-line security/no-low-level-calls
(bool success, ) = _tokenAddress.call(abi.encodeWithSignature( "transferFrom(address,address,uint256)", msg.sender, _to, _amount )); assembly { switch returndatasize() case 0 { // not a standard erc20
(bool success, ) = _tokenAddress.call(abi.encodeWithSignature( "transferFrom(address,address,uint256)", msg.sender, _to, _amount )); assembly { switch returndatasize() case 0 { // not a standard erc20
29,784
72
// Prepare and confirm batch
uint256 tokenId = _mintEmptyBatch(address(this), recipient); _updateBatchWithData(tokenId, serialNumber, quantity, uri); _linkWithVintage(tokenId, projectVintageTokenId); _confirmBatch(tokenId);
uint256 tokenId = _mintEmptyBatch(address(this), recipient); _updateBatchWithData(tokenId, serialNumber, quantity, uri); _linkWithVintage(tokenId, projectVintageTokenId); _confirmBatch(tokenId);
16,089
6
// INIT /
) internal onlyInitializing { __ERC721StakingExtension_init_unchained( _minStakingDuration, _maxStakingTotalDurations ); }
) internal onlyInitializing { __ERC721StakingExtension_init_unchained( _minStakingDuration, _maxStakingTotalDurations ); }
18,968
91
// get latest bancor contracts
BancorNetworkInterface bancorNetwork = BancorNetworkInterface( bancorRegistry.getBancorContractAddresByName("BancorNetwork") ); PathFinderInterface pathFinder = PathFinderInterface( bancorRegistry.getBancorContractAddresByName("BancorNetworkPathFinder") );
BancorNetworkInterface bancorNetwork = BancorNetworkInterface( bancorRegistry.getBancorContractAddresByName("BancorNetwork") ); PathFinderInterface pathFinder = PathFinderInterface( bancorRegistry.getBancorContractAddresByName("BancorNetworkPathFinder") );
15,003
207
// principal fully covered by excess interest
interestAppliedToPrincipal = loanCloseAmountLessInterest;
interestAppliedToPrincipal = loanCloseAmountLessInterest;
40,433
5
// Calculates the next TWAB checkpoint for an account with a decreasing balance.With Account struct and amount decreasing calculates the next TWAB observable checkpoint. _accountAccount whose balance will be decreased _amount Amount to decrease the balance by _revertMessageRevert message for insufficient balancereturn accountDetails Updated Account.details structreturn twab TWAB observation (with decreasing average)return isNewWhether TWAB is new or calling twice in the same block /
function decreaseBalance( Account storage _account, uint208 _amount, string memory _revertMessage, uint32 _currentTime ) internal returns ( AccountDetails memory accountDetails, ObservationLib.Observation memory twab,
function decreaseBalance( Account storage _account, uint208 _amount, string memory _revertMessage, uint32 _currentTime ) internal returns ( AccountDetails memory accountDetails, ObservationLib.Observation memory twab,
6,570
41
// Return borrow balance of ETH/ERC20_Token.This function is the accurate way to get Compound borrow balance.It costs ~84K gas and is not a view function. _asset token address to query the balance. _who address of the account. /
function getBorrowBalanceOf(address _asset, address _who) external override returns (uint256) { address cTokenAddr = _getCTokenAddr(_asset); return IGenCToken(cTokenAddr).borrowBalanceCurrent(_who); }
function getBorrowBalanceOf(address _asset, address _who) external override returns (uint256) { address cTokenAddr = _getCTokenAddr(_asset); return IGenCToken(cTokenAddr).borrowBalanceCurrent(_who); }
37,031
0
// ==================== EVENTS ==================== // ==================== MODIFIERS ==================== /
modifier onlyOGStaking() { require(ogStakingContract != address(0), "OG staking address is not set yet"); require(_msgSender() == ogStakingContract, "Not allowed caller"); _; }
modifier onlyOGStaking() { require(ogStakingContract != address(0), "OG staking address is not set yet"); require(_msgSender() == ogStakingContract, "Not allowed caller"); _; }
44,169
8
// {TransparentUpgradeableProxy-upgradeToAndCall}. Requirements: - This contract must be the admin of `proxy`. /
function upgradeAndCall( TransparentUpgradeableProxy proxy, address implementation, bytes memory data ) public payable virtual onlyOwner { proxy.upgradeToAndCall{value: msg.value}(implementation, data);
function upgradeAndCall( TransparentUpgradeableProxy proxy, address implementation, bytes memory data ) public payable virtual onlyOwner { proxy.upgradeToAndCall{value: msg.value}(implementation, data);
12,867
10
// GovToken public flag
bool public GOVTOKEN_PUBLIC_FLAG;
bool public GOVTOKEN_PUBLIC_FLAG;
65,687
67
// Sets or unsets the approval of a given operatorAn operator is allowed to transfer all tokens of the sender on their behalf. to operator address to set the approval approved representing the status of the approval to be set /
function setApprovalForAll(address to, bool approved) public { require(to != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][to] = approved; emit ApprovalForAll(_msgSender(), to, approved); }
function setApprovalForAll(address to, bool approved) public { require(to != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][to] = approved; emit ApprovalForAll(_msgSender(), to, approved); }
15,070
219
// Internal function to perform borrow from the bank and return the amount received./token The token to perform borrow action./amountCall The amount use in the transferFrom call./ NOTE: Caller must ensure that cToken interest was already accrued up to this block.
function doBorrow(address token, uint amountCall) internal returns (uint) { Bank storage bank = banks[token]; // assume the input is already sanity checked. uint balanceBefore = IERC20(token).balanceOf(address(this)); require(ICErc20(bank.cToken).borrow(amountCall) == 0, 'bad borrow'); uint balanceAfter = IERC20(token).balanceOf(address(this)); bank.totalDebt = bank.totalDebt.add(amountCall); return balanceAfter.sub(balanceBefore); }
function doBorrow(address token, uint amountCall) internal returns (uint) { Bank storage bank = banks[token]; // assume the input is already sanity checked. uint balanceBefore = IERC20(token).balanceOf(address(this)); require(ICErc20(bank.cToken).borrow(amountCall) == 0, 'bad borrow'); uint balanceAfter = IERC20(token).balanceOf(address(this)); bank.totalDebt = bank.totalDebt.add(amountCall); return balanceAfter.sub(balanceBefore); }
15,203
234
// Decode a CBOR value into a Witnet.Result instance./_cborValue An instance of `Witnet.Value`./ return A `Witnet.Result` instance.
function resultFromCborValue(Witnet.CBOR memory _cborValue) public pure returns (Witnet.Result memory)
function resultFromCborValue(Witnet.CBOR memory _cborValue) public pure returns (Witnet.Result memory)
28,875
20
// Emitted when the allowance of a `spender` for an `owner` is set by a call to {approve}. `value` is the new allowance./
event Approval(address indexed owner, address indexed spender, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
8,352
70
// Reads an immutable arg with type uint80.
function _getArgUint80(uint256 argOffset) internal pure returns (uint80 arg) { uint256 offset = _getImmutableArgsOffset(); /// @solidity memory-safe-assembly assembly { arg := shr(176, calldataload(add(offset, argOffset))) } }
function _getArgUint80(uint256 argOffset) internal pure returns (uint80 arg) { uint256 offset = _getImmutableArgsOffset(); /// @solidity memory-safe-assembly assembly { arg := shr(176, calldataload(add(offset, argOffset))) } }
20,533
56
// update balances in staker info
stakerSender.balance = stakerSender.balance - amount; stakerReceiver.balance = receiverFinalBalance;
stakerSender.balance = stakerSender.balance - amount; stakerReceiver.balance = receiverFinalBalance;
32,997
15
// Return if there is no balance.
if (IERC20(tokenAddr).balanceOf(address(vault)) == 0) { return; }
if (IERC20(tokenAddr).balanceOf(address(vault)) == 0) { return; }
29,016
170
// 用户未提取的BDK分红
users[msg.sender].bSurplus = users[msg.sender].bSurplus.sub(bNum); if(transferEnable[msg.sender]){ transferFrom(address(this), msg.sender, bNum); }else {
users[msg.sender].bSurplus = users[msg.sender].bSurplus.sub(bNum); if(transferEnable[msg.sender]){ transferFrom(address(this), msg.sender, bNum); }else {
15,106
1
// Bundle struct to save bundle info /
struct BundleStruct { string unitType; uint date; string metadataUrl; address projectAddress; }
struct BundleStruct { string unitType; uint date; string metadataUrl; address projectAddress; }
20,793
14
// this function is called when Royale Govenance withdrawl from yield generation pool.It add all the withdrawl amount in the reserve amount.All the users who requested for the withdrawl are added to the reserveRecipients.
function updateWithdrawQueue() internal{ for(uint8 i=0;i<3;i++){ reserveAmount[i]=reserveAmount[i].add(totalWithdraw[i]); totalWithdraw[i]=0; } for(uint i=0; i<withdrawRecipients.length; i++) { reserveRecipients[withdrawRecipients[i]]=true; isInQ[withdrawRecipients[i]]=false; } uint count=withdrawRecipients.length; for(uint i=0;i<count;i++){ withdrawRecipients.pop(); } }
function updateWithdrawQueue() internal{ for(uint8 i=0;i<3;i++){ reserveAmount[i]=reserveAmount[i].add(totalWithdraw[i]); totalWithdraw[i]=0; } for(uint i=0; i<withdrawRecipients.length; i++) { reserveRecipients[withdrawRecipients[i]]=true; isInQ[withdrawRecipients[i]]=false; } uint count=withdrawRecipients.length; for(uint i=0;i<count;i++){ withdrawRecipients.pop(); } }
7,674
60
// marking month 1 as paid on time
sips[msg.sender][_sipId].depositStatus[1] = 2; sips[msg.sender][_sipId].monthlyBenefitAmount[1] = _singleMonthBenefit;
sips[msg.sender][_sipId].depositStatus[1] = 2; sips[msg.sender][_sipId].monthlyBenefitAmount[1] = _singleMonthBenefit;
24,120
20
// Should return the Allocator name /
function name() external view virtual returns (string memory);
function name() external view virtual returns (string memory);
39,145
230
// 0 EndTimestamp is reserved to check if a tokenId is on auction or not
require(endTime != 0, "End time cannot be 0"); require(_msgSender() == ownerOf(tokenId), "Only token owner can alter end time"); Auction memory auction = _tokenIdToAuction[tokenId]; require(auction.endTimestamp > block.timestamp + auction.minLastBidDuration, "Auction has already ended"); auction.endTimestamp = endTime; _tokenIdToAuction[tokenId] = auction; emit AuctionEndTimeAltered(tokenId, endTime, ownerOf(tokenId));
require(endTime != 0, "End time cannot be 0"); require(_msgSender() == ownerOf(tokenId), "Only token owner can alter end time"); Auction memory auction = _tokenIdToAuction[tokenId]; require(auction.endTimestamp > block.timestamp + auction.minLastBidDuration, "Auction has already ended"); auction.endTimestamp = endTime; _tokenIdToAuction[tokenId] = auction; emit AuctionEndTimeAltered(tokenId, endTime, ownerOf(tokenId));
33,590
21
// Emitted when the allowance of a `spender` for an `owner` is set bya call to {approve}. `value` is the new allowance. /
event Approval(address indexed owner, address indexed spender, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
25,141
11
// -------------- Deletion Functions ------------------
function deleteAddress(bytes32 _key) external; function deleteUint(bytes32 _key) external; function deleteString(bytes32 _key) external;
function deleteAddress(bytes32 _key) external; function deleteUint(bytes32 _key) external; function deleteString(bytes32 _key) external;
22,697
168
// Returns `amount` in reflection. /
function _getRAmount(uint256 amount) private view returns (uint256) { uint256 currentRate = _getRate(); return amount * currentRate; }
function _getRAmount(uint256 amount) private view returns (uint256) { uint256 currentRate = _getRate(); return amount * currentRate; }
7,064