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
52
// Returns the 32 byte value at the specified index of self. self The byte string. idx The index into the bytesreturn The specified 32 bytes of the string. /
function readBytes32( bytes memory self, uint256 idx
function readBytes32( bytes memory self, uint256 idx
17,351
65
// FailedMessagesProcessor Functionality for fixing failed bridging operations. /
abstract contract FailedMessagesProcessor is BasicAMBMediator, BridgeOperationsStorage { event FailedMessageFixed(bytes32 indexed messageId, address token, address recipient, uint256 value); /** * @dev Method to be called when a bridged message execution failed. It will generate a new message requesting to * fix/roll back the transferred assets on the other network. * @param _messageId id of the message which execution failed. */ function requestFailedMessageFix(bytes32 _messageId) external { IAMB bridge = bridgeContract(); require(!bridge.messageCallStatus(_messageId)); require(bridge.failedMessageReceiver(_messageId) == address(this)); require(bridge.failedMessageSender(_messageId) == mediatorContractOnOtherSide()); bytes memory data = abi.encodeWithSelector(this.fixFailedMessage.selector, _messageId); _passMessage(data, false); } /** * @dev Handles the request to fix transferred assets which bridged message execution failed on the other network. * It uses the information stored by passMessage method when the assets were initially transferred * @param _messageId id of the message which execution failed on the other network. */ function fixFailedMessage(bytes32 _messageId) public onlyMediator { require(!messageFixed(_messageId)); address token = messageToken(_messageId); address recipient = messageRecipient(_messageId); uint256 value = messageValue(_messageId); setMessageFixed(_messageId); executeActionOnFixedTokens(token, recipient, value); emit FailedMessageFixed(_messageId, token, recipient, value); } /** * @dev Tells if a message sent to the AMB bridge has been fixed. * @return bool indicating the status of the message. */ function messageFixed(bytes32 _messageId) public view returns (bool) { return boolStorage[keccak256(abi.encodePacked("messageFixed", _messageId))]; } /** * @dev Sets that the message sent to the AMB bridge has been fixed. * @param _messageId of the message sent to the bridge. */ function setMessageFixed(bytes32 _messageId) internal { boolStorage[keccak256(abi.encodePacked("messageFixed", _messageId))] = true; } function executeActionOnFixedTokens( address _token, address _recipient, uint256 _value ) internal virtual; }
abstract contract FailedMessagesProcessor is BasicAMBMediator, BridgeOperationsStorage { event FailedMessageFixed(bytes32 indexed messageId, address token, address recipient, uint256 value); /** * @dev Method to be called when a bridged message execution failed. It will generate a new message requesting to * fix/roll back the transferred assets on the other network. * @param _messageId id of the message which execution failed. */ function requestFailedMessageFix(bytes32 _messageId) external { IAMB bridge = bridgeContract(); require(!bridge.messageCallStatus(_messageId)); require(bridge.failedMessageReceiver(_messageId) == address(this)); require(bridge.failedMessageSender(_messageId) == mediatorContractOnOtherSide()); bytes memory data = abi.encodeWithSelector(this.fixFailedMessage.selector, _messageId); _passMessage(data, false); } /** * @dev Handles the request to fix transferred assets which bridged message execution failed on the other network. * It uses the information stored by passMessage method when the assets were initially transferred * @param _messageId id of the message which execution failed on the other network. */ function fixFailedMessage(bytes32 _messageId) public onlyMediator { require(!messageFixed(_messageId)); address token = messageToken(_messageId); address recipient = messageRecipient(_messageId); uint256 value = messageValue(_messageId); setMessageFixed(_messageId); executeActionOnFixedTokens(token, recipient, value); emit FailedMessageFixed(_messageId, token, recipient, value); } /** * @dev Tells if a message sent to the AMB bridge has been fixed. * @return bool indicating the status of the message. */ function messageFixed(bytes32 _messageId) public view returns (bool) { return boolStorage[keccak256(abi.encodePacked("messageFixed", _messageId))]; } /** * @dev Sets that the message sent to the AMB bridge has been fixed. * @param _messageId of the message sent to the bridge. */ function setMessageFixed(bytes32 _messageId) internal { boolStorage[keccak256(abi.encodePacked("messageFixed", _messageId))] = true; } function executeActionOnFixedTokens( address _token, address _recipient, uint256 _value ) internal virtual; }
24,039
40
// Unsettled principal from previous call request periods which will settle.
principalPaidSum += cl._waterfall.totalPrincipalReservedUpToTranche( Math.min(trancheIndexAtGivenTimestamp, cl.uncalledCapitalTrancheIndex()) );
principalPaidSum += cl._waterfall.totalPrincipalReservedUpToTranche( Math.min(trancheIndexAtGivenTimestamp, cl.uncalledCapitalTrancheIndex()) );
39,892
179
// retrieve farming position
FarmingPosition storage farmingPosition = _positions[positionId]; FarmingSetup storage chosenSetup = _setups[farmingPosition.setupIndex]; uint128 liquidityAmount = _addLiquidity(farmingPosition.setupIndex, request);
FarmingPosition storage farmingPosition = _positions[positionId]; FarmingSetup storage chosenSetup = _setups[farmingPosition.setupIndex]; uint128 liquidityAmount = _addLiquidity(farmingPosition.setupIndex, request);
27,844
92
// ======== INTERNAL HELPER FUNCTIONS ======== //makes incremental adjustment to control variable /
function adjust() internal { uint blockCanAdjust = adjustment.lastBlock.add( adjustment.buffer ); if( adjustment.rate != 0 && block.number >= blockCanAdjust ) { uint initial = terms.controlVariable; if ( adjustment.add ) { terms.controlVariable = terms.controlVariable.add( adjustment.rate ); if ( terms.controlVariable >= adjustment.target ) { adjustment.rate = 0; } } else { terms.controlVariable = terms.controlVariable.sub( adjustment.rate ); if ( terms.controlVariable <= adjustment.target ) { adjustment.rate = 0; } } adjustment.lastBlock = block.number; emit ControlVariableAdjustment( initial, terms.controlVariable, adjustment.rate, adjustment.add ); } }
function adjust() internal { uint blockCanAdjust = adjustment.lastBlock.add( adjustment.buffer ); if( adjustment.rate != 0 && block.number >= blockCanAdjust ) { uint initial = terms.controlVariable; if ( adjustment.add ) { terms.controlVariable = terms.controlVariable.add( adjustment.rate ); if ( terms.controlVariable >= adjustment.target ) { adjustment.rate = 0; } } else { terms.controlVariable = terms.controlVariable.sub( adjustment.rate ); if ( terms.controlVariable <= adjustment.target ) { adjustment.rate = 0; } } adjustment.lastBlock = block.number; emit ControlVariableAdjustment( initial, terms.controlVariable, adjustment.rate, adjustment.add ); } }
10,698
15
// Add a new technician address/_officeId The professional office id/_address The new technician address
function addTechnician(uint32 _officeId, address _address) external onlyAuthorizedForUpdate(_officeId) { require(_address != address(0), "Invalid address"); require(officeIdByActivTechnicianAddress[_address] == 0, "Address already activ"); offices[_officeId].technicians[_address] = true; officeIdByActivTechnicianAddress[_address] = _officeId; }
function addTechnician(uint32 _officeId, address _address) external onlyAuthorizedForUpdate(_officeId) { require(_address != address(0), "Invalid address"); require(officeIdByActivTechnicianAddress[_address] == 0, "Address already activ"); offices[_officeId].technicians[_address] = true; officeIdByActivTechnicianAddress[_address] = _officeId; }
8,962
132
// Calcualtes vestable amount for beneficiary for current time _index index of vestingSchedules array /
function getVestedAmount(uint256 _index) public view returns (uint256)
function getVestedAmount(uint256 _index) public view returns (uint256)
23,991
178
// lets the owner convert SCD SAI into MCD DAI._wallet The target wallet._amount The amount of SAI to convert/
function swapSaiToDai( BaseWallet _wallet, uint256 _amount ) public onlyWalletOwner(_wallet) onlyWhenUnlocked(_wallet)
function swapSaiToDai( BaseWallet _wallet, uint256 _amount ) public onlyWalletOwner(_wallet) onlyWhenUnlocked(_wallet)
690
59
// This is an alternative to {approve} that can be used as a mitigation forproblems described in {BEP20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.- `spender` must have allowance for the caller of at least`subtractedValue`. /
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; }
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; }
23,071
109
// Percent of funds referrers receive. 20 = 2%.
uint128 public refPercent;
uint128 public refPercent;
31,351
63
// StandardERC20 Implementation of the StandardERC20 /
contract StandardERC20 is ERC20Decimals, ServicePayer { constructor ( string memory name_, string memory symbol_, uint8 decimals_, uint256 initialBalance_, address payable feeReceiver_ ) ERC20(name_, symbol_) ERC20Decimals(decimals_) ServicePayer(feeReceiver_, "StandardERC20") payable { require(initialBalance_ > 0, "StandardERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } function decimals() public view virtual override returns (uint8) { return super.decimals(); } }
contract StandardERC20 is ERC20Decimals, ServicePayer { constructor ( string memory name_, string memory symbol_, uint8 decimals_, uint256 initialBalance_, address payable feeReceiver_ ) ERC20(name_, symbol_) ERC20Decimals(decimals_) ServicePayer(feeReceiver_, "StandardERC20") payable { require(initialBalance_ > 0, "StandardERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } function decimals() public view virtual override returns (uint8) { return super.decimals(); } }
8,710
6
// If owner takes too long (does not respond in time and someone calls the player_declare_taking_too_long function), owner_took_too_long will be set to true and all players will be paid out. This represents the total sum that will be paid out in that case.
uint total_payout;
uint total_payout;
30,590
0
// permissions keyed by hash(user, worker, dapp)
mapping(bytes32 => bool) private permissions;
mapping(bytes32 => bool) private permissions;
15,298
264
// Mint
_safeMint(_target, _realIndex);
_safeMint(_target, _realIndex);
14,773
269
// First settle anything pending into sUSD as burning or issuing impacts the size of the debt pool
(, uint refunded, uint numEntriesSettled) = exchanger().settle(from, sUSD); if (numEntriesSettled > 0) { amount = exchanger().calculateAmountAfterSettlement(from, sUSD, amount, refunded); }
(, uint refunded, uint numEntriesSettled) = exchanger().settle(from, sUSD); if (numEntriesSettled > 0) { amount = exchanger().calculateAmountAfterSettlement(from, sUSD, amount, refunded); }
7,290
31
// Sets a new owner address/
function _setOwner(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(owner(), newOwner); addressStorage[OWNER] = newOwner; }
function _setOwner(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(owner(), newOwner); addressStorage[OWNER] = newOwner; }
42,461
174
// CohortDeployment event
event CohortDeployment( address indexed deployer, address indexed cohort, address poolAddress, uint256 when );
event CohortDeployment( address indexed deployer, address indexed cohort, address poolAddress, uint256 when );
76,101
28
// Check various conditions to determine whether a purchase is currently valid/amount The amount of tokens to be purchased
function validPurchase(uint256 amount) public view returns (bool) { bool nonZeroPurchase = amount != 0; bool isMinPurchase = (amount >= minimumPurchase); return saleActive && nonZeroPurchase && isMinPurchase; }
function validPurchase(uint256 amount) public view returns (bool) { bool nonZeroPurchase = amount != 0; bool isMinPurchase = (amount >= minimumPurchase); return saleActive && nonZeroPurchase && isMinPurchase; }
24,238
230
// Get total supply leftover amount ------------------------------------------------------------------------
function getUnsoldRemaining() external view returns (uint256) { return maxSupply - totalSupply(); }
function getUnsoldRemaining() external view returns (uint256) { return maxSupply - totalSupply(); }
81,403
1
// Get internal version number identifying an ArbOS buildreturn version number as int /
function arbOSVersion() external pure returns (uint256); function arbChainID() external view returns (uint256);
function arbOSVersion() external pure returns (uint256); function arbChainID() external view returns (uint256);
39,316
18
// Pay protocol fee
if (order.protocolFeeDiscounted != 0) { uint256 protocolFeeAmount = (order.protocolFeeDiscounted * order.price) / 10000; finalSellerAmount -= protocolFeeAmount; }
if (order.protocolFeeDiscounted != 0) { uint256 protocolFeeAmount = (order.protocolFeeDiscounted * order.price) / 10000; finalSellerAmount -= protocolFeeAmount; }
29,085
103
// Set AMO to Ether rate for round_round: Round to set _rate: AMO to Ether _rate /
function setRateForRound( SaleRounds _round, uint256 _rate ) public onlyOwner atStage(Stages.SetUp)
function setRateForRound( SaleRounds _round, uint256 _rate ) public onlyOwner atStage(Stages.SetUp)
29,259
340
// gives square. multiplies x by x /
function sq(uint256 x) internal pure returns (uint256)
function sq(uint256 x) internal pure returns (uint256)
2,506
20
// withdraw funds
function withdraw(address receiver) public onlyRole(DEFAULT_ADMIN_ROLE) { uint256 balance = address(this).balance; payable(receiver).transfer(balance); }
function withdraw(address receiver) public onlyRole(DEFAULT_ADMIN_ROLE) { uint256 balance = address(this).balance; payable(receiver).transfer(balance); }
23,458
83
// can't transfer parts to any of the battle contracts directly
for (uint j = 0; j < approvedBattles.length; j++) { require(_to != approvedBattles[j]); }
for (uint j = 0; j < approvedBattles.length; j++) { require(_to != approvedBattles[j]); }
46,182
116
// Rule CFA-2 https:github.com/superfluid-finance/protocol-monorepo/wiki/About-App-Credit Allow apps to take an additional amount of app credit (minimum deposit)
uint256 minimumDeposit = gov.getConfigAsUint256( ISuperfluid(msg.sender), token, SUPERTOKEN_MINIMUM_DEPOSIT_KEY);
uint256 minimumDeposit = gov.getConfigAsUint256( ISuperfluid(msg.sender), token, SUPERTOKEN_MINIMUM_DEPOSIT_KEY);
16,811
19
// Store the `msg.sender`.
mstore(0x3a, caller())
mstore(0x3a, caller())
22,735
75
// Check total supply cap reached, sell the all remaining tokens
if (tokensGenerated > leftForSale) { tokensGenerated = leftForSale; toFund = leftForSale.div(exchangeRate); }
if (tokensGenerated > leftForSale) { tokensGenerated = leftForSale; toFund = leftForSale.div(exchangeRate); }
27,597
80
// verify that the first token in the path is BNT
require(_path[0] == addressOf(BNT_TOKEN));
require(_path[0] == addressOf(BNT_TOKEN));
40,915
27
// Claim and send rewards
function claimSelfApeCoin() external { claimApeCoin(msg.sender); }
function claimSelfApeCoin() external { claimApeCoin(msg.sender); }
11,168
23
// transfer someone else's tokens, subject to approval
function transferFrom(address from, address to, uint value) public returns (bool success)
function transferFrom(address from, address to, uint value) public returns (bool success)
17,125
0
// Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,/ Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, andoptionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. /
constructor( address _logic, address admin_, bytes memory _data ) payable ERC1967Proxy(_logic, _data) { _changeAdmin(admin_); }
constructor( address _logic, address admin_, bytes memory _data ) payable ERC1967Proxy(_logic, _data) { _changeAdmin(admin_); }
6,630
3
// index of the stack
mul(stackIndex_, 0x20) ) ) switch opcode_
mul(stackIndex_, 0x20) ) ) switch opcode_
21,082
112
// check for valid signatures
require(signer != address(0), "Invalid signature for signer."); require(cosigner != address(0), "Invalid signature for cosigner.");
require(signer != address(0), "Invalid signature for signer."); require(cosigner != address(0), "Invalid signature for cosigner.");
36,618
14
// change the lockTime
function changeChangeLockTimeSeconds(uint256 _newLockTime) public onlyOwner { lockTime = _newLockTime; }
function changeChangeLockTimeSeconds(uint256 _newLockTime) public onlyOwner { lockTime = _newLockTime; }
37,844
32
// Whether or not the voter supports the proposal
bool support;
bool support;
18,031
123
// Lets a contract admin update the default royalty recipient and bps.
function _setupDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) internal { if (_royaltyBps > 10_000) { revert("Exceeds max bps"); } royaltyRecipient = _royaltyRecipient; royaltyBps = uint16(_royaltyBps); emit DefaultRoyalty(_royaltyRecipient, _royaltyBps); }
function _setupDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) internal { if (_royaltyBps > 10_000) { revert("Exceeds max bps"); } royaltyRecipient = _royaltyRecipient; royaltyBps = uint16(_royaltyBps); emit DefaultRoyalty(_royaltyRecipient, _royaltyBps); }
3,541
42
// Number of authorities signatures required to withdraw the money.// Must be lesser than number of authorities.
uint256 public requiredSignatures;
uint256 public requiredSignatures;
38,174
137
// perk not valid if any ancestor not unlocked
for (uint8 i = _parent(_index); i > PRESTIGE_INDEX; i = _parent(i)) { if (_perks[i] == 0) { return false; }
for (uint8 i = _parent(_index); i > PRESTIGE_INDEX; i = _parent(i)) { if (_perks[i] == 0) { return false; }
46,214
121
// Called by the Chainlink node to fulfill requests with multi-word support Given params must hash back to the commitment stored from `oracleRequest`.Will call the callback address' callback function without bubbling up errorchecking in a `require` so that the node can get paid. requestId The fulfillment request ID that must match the requester's payment The payment amount that will be released for the oracle (specified in wei) callbackAddress The callback address to call for fulfillment callbackFunctionId The callback function ID to use for fulfillment expiration The expiration that the node should respond by before the requester can cancel data The data
function fulfillOracleRequest2( bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes calldata data ) external override
function fulfillOracleRequest2( bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes calldata data ) external override
52,881
110
// Returns the address where a contract will be stored if deployed via {deploy} from a contract located at`deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}. /
function computeAddress( bytes32 salt, bytes32 bytecodeHash, address deployer ) internal pure returns (address) { bytes32 _data = keccak256( abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash) ); return address(uint160(uint256(_data))); }
function computeAddress( bytes32 salt, bytes32 bytecodeHash, address deployer ) internal pure returns (address) { bytes32 _data = keccak256( abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash) ); return address(uint160(uint256(_data))); }
13,765
5
// struct to store the game details which include:gameId, currencyAddress, feeAmount, playersWalletAddresses[], winnerFund, adminFund
struct Game { string colyseusGameRoomId; string gameId; uint256 feeAmount; address[] playersWalletAddresses; uint256 winnerFund; uint256 adminFund; }
struct Game { string colyseusGameRoomId; string gameId; uint256 feeAmount; address[] playersWalletAddresses; uint256 winnerFund; uint256 adminFund; }
736
320
// flash loan to position
if(DyDxActive && position > 0){ doDyDxFlashLoan(deficit, position); }
if(DyDxActive && position > 0){ doDyDxFlashLoan(deficit, position); }
51,962
31
// Returns true if the caller is the current owner. /
function isOwner(address account) public view returns (bool) { return account == _owner; }
function isOwner(address account) public view returns (bool) { return account == _owner; }
23,669
2
// assert(b > 0);Solidity automatically throws when dividing by 0 uint256 c = a / b; assert(a == bc + a % b);There is no case in which this doesn't hold
return a / b;
return a / b;
1,650
2
// Emitted when pendingComptrollerImplementation is changed/
event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);
event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);
10,558
23
// constructor the contract, get called in the first time deploy _acceptedToken the token that the pools will use as staking and reward token /
constructor(IERC20 _acceptedToken) Ownable() { linearAcceptedToken = _acceptedToken; }
constructor(IERC20 _acceptedToken) Ownable() { linearAcceptedToken = _acceptedToken; }
18,293
400
// Used by owner or other contracts
require(_msgSender() == owner || _msgSender() == address(this) || _msgSender() == _carAddress || _msgSender() == _auctionAddress, "Not allowed");
require(_msgSender() == owner || _msgSender() == address(this) || _msgSender() == _carAddress || _msgSender() == _auctionAddress, "Not allowed");
4,096
8
// Get the marketplace's trading commissions basis points.return bp - TradingCommissionsBasisPoints struct containing the individual basis points set for each marketplace commission receiver. /
function getTradingCommissionsBasisPoints() external view returns (TradingCommissionsBasisPoints memory bp);
function getTradingCommissionsBasisPoints() external view returns (TradingCommissionsBasisPoints memory bp);
20,289
164
// 挖矿结束时间
uint256 public periodFinish = 0; uint256 public periodStart = 0;
uint256 public periodFinish = 0; uint256 public periodStart = 0;
21,777
82
// Executes airdrop. airdropContract The address of the airdrop contract airdropParams Third party airdrop abi data. You need to get this from the third party airdrop. /
) external onlyPoolAdmin { MintableERC721Logic.executeAirdrop(airdropContract, airdropParams); }
) external onlyPoolAdmin { MintableERC721Logic.executeAirdrop(airdropContract, airdropParams); }
32,856
377
// bytes4(keccak256("Uint256DowncastError(uint8,uint256)"))
bytes4 internal constant UINT256_DOWNCAST_ERROR_SELECTOR = 0xc996af7b;
bytes4 internal constant UINT256_DOWNCAST_ERROR_SELECTOR = 0xc996af7b;
1,668
2
// COPIED AND MODIFIED FROM: Uniswap/v3-periphery/contracts/libraries/OracleLibrary.sol
function consult( address pool, uint32[] memory secondsAgos, uint32[] memory windows, uint256[] memory nowIdxs ) external view returns (int24[] memory arithmeticMeanTicks_, uint128[] memory harmonicMeanLiquidities_);
function consult( address pool, uint32[] memory secondsAgos, uint32[] memory windows, uint256[] memory nowIdxs ) external view returns (int24[] memory arithmeticMeanTicks_, uint128[] memory harmonicMeanLiquidities_);
42,833
59
// validate it is a valid flight
bytes32 flightId = _getFlightKey(airline, flight, timestamp); require(flights[flightId].isOpen, 'the flight does not exists');
bytes32 flightId = _getFlightKey(airline, flight, timestamp); require(flights[flightId].isOpen, 'the flight does not exists');
48,192
2
// public functions
function totalSupply() public view returns (uint256); function balanceOf(address addr) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool);
function totalSupply() public view returns (uint256); function balanceOf(address addr) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool);
45,748
141
// Transfer tokens to a specified address and then execute a callback on recipient. to The address to transfer to value The amount to be transferred data Additional data with no specified formatreturn A boolean that indicates if the operation was successful. /
function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool) { transfer(to, value); require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts"); return true; }
function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool) { transfer(to, value); require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts"); return true; }
410
98
// Setup unsold reserve address
UNSOLD_RESERVE = _unsoldReserve;
UNSOLD_RESERVE = _unsoldReserve;
11,651
69
// Throws if called by any account other than recharge eth address /
modifier onlyRechargeAddress() { require( msg.sender == rechargeAddress, "UnwrapTokenV1: caller is not the RECHARGE_ADDRESS" ); _; }
modifier onlyRechargeAddress() { require( msg.sender == rechargeAddress, "UnwrapTokenV1: caller is not the RECHARGE_ADDRESS" ); _; }
29,718
140
// if (tranche == Tranche.AA) {}v1: AA tranche disabled (S tranche is effectively AA)
if (tranche == Tranche.A) {
if (tranche == Tranche.A) {
18,298
1
// immutables
function ovl() external view returns (IOverlayV1Token); function feed() external view returns (address); function factory() external view returns (address);
function ovl() external view returns (IOverlayV1Token); function feed() external view returns (address); function factory() external view returns (address);
25,749
7
// Mapping of active trades. Key is a hash of the trade data
mapping (bytes32 => Escrow) public escrows;
mapping (bytes32 => Escrow) public escrows;
45,704
216
// this should be tightly linked
if (IcoState.SUCCEEDED == m_state) { onSuccess(); } else if (IcoState.FAILED == m_state) {
if (IcoState.SUCCEEDED == m_state) { onSuccess(); } else if (IcoState.FAILED == m_state) {
6,647
144
// if the stakedDays is less than the minimum, throw an error
require(stakedDays >= MIN_STAKE_DAYS, "stake days must be greater than 1"); uint256 curDay = _currentDay(); //ex. day 25 uint256 endOfStakeDay = startDay + stakedDays; //ex. Day 52
require(stakedDays >= MIN_STAKE_DAYS, "stake days must be greater than 1"); uint256 curDay = _currentDay(); //ex. day 25 uint256 endOfStakeDay = startDay + stakedDays; //ex. Day 52
5,858
18
// Check that the submitted block is extending the main chain
require(blockHeight > _heaviestHeight, ERR_NOT_MAIN_CHAIN);
require(blockHeight > _heaviestHeight, ERR_NOT_MAIN_CHAIN);
8,163
887
// Returns `sample`'s accumulator of the logarithm of the BPT price. /
function _accLogBptPrice(bytes32 sample) private pure returns (int256) { return sample.decodeInt53(_ACC_LOG_BPT_PRICE_OFFSET); }
function _accLogBptPrice(bytes32 sample) private pure returns (int256) { return sample.decodeInt53(_ACC_LOG_BPT_PRICE_OFFSET); }
3,329
15
// Mapping of addresses disbarred from holding any token.
mapping (address => bool) private _blacklistAddress;
mapping (address => bool) private _blacklistAddress;
54,760
356
// setting the msg.sender as the initial owner.
super.__Ownable_init();
super.__Ownable_init();
26,053
94
// Allows a Module to execute a Safe transaction without any further confirmations./to Destination address of module transaction./value Ether value of module transaction./data Data payload of module transaction./operation Operation type of module transaction.
function execTransactionFromModule( address to, uint256 value, bytes memory data, Enum.Operation operation
function execTransactionFromModule( address to, uint256 value, bytes memory data, Enum.Operation operation
58,101
11
// This emits when ownership of any NFT changes by any mechanism. /This event emits when NFTs are created (`from` == 0) and destroyed /(`to` == 0). Exception: during contract creation, any number of NFTs /may be created and assigned without emitting Transfer. At the time of /any transfer, the approved address for that NFT (if any) is reset to none.
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
20,702
2
// Only the contract creator can release funds from their HodlBox, and only after the defined number of blocks has passed.
if (msg.sender != hodler) throw; if (block.number < hodlTillBlock) throw; if (withdrawn) throw; if (hodling <= 0) throw; withdrawn = true; hodling = 0;
if (msg.sender != hodler) throw; if (block.number < hodlTillBlock) throw; if (withdrawn) throw; if (hodling <= 0) throw; withdrawn = true; hodling = 0;
48,481
12
// change base extension .json by _newBaseExtension/_newBaseExtension new base extension
function setBaseExtension(string memory _newBaseExtension) external onlyOwner { baseExtension = _newBaseExtension; }
function setBaseExtension(string memory _newBaseExtension) external onlyOwner { baseExtension = _newBaseExtension; }
29,392
16
// First, we allocate memory for `code` by retrieving the free memory pointer and then moving it ahead of `code` by the size of the creation code plus constructor arguments, and 32 bytes for the array length.
code := mload(0x40) mstore(0x40, add(code, add(codeSize, 32)))
code := mload(0x40) mstore(0x40, add(code, add(codeSize, 32)))
24,436
2
// @inheritdoc IFeeCollector
function distributeFees(address asset) public override onlyOwner returns (uint256 defaultFundsDelta, uint256 protocolFeesDelta) { uint256 distributionAmount = IERC20Minimal(asset).balanceOf(address(this)) - protocolFees[asset] - defaultFund[asset]; if ( defaultFundPaused ) { protocolFeesDelta = distributionAmount; protocolFees[asset] += protocolFeesDelta; } else {
function distributeFees(address asset) public override onlyOwner returns (uint256 defaultFundsDelta, uint256 protocolFeesDelta) { uint256 distributionAmount = IERC20Minimal(asset).balanceOf(address(this)) - protocolFees[asset] - defaultFund[asset]; if ( defaultFundPaused ) { protocolFeesDelta = distributionAmount; protocolFees[asset] += protocolFeesDelta; } else {
36,590
691
// Vote Delegation Functions _to address where message sender is assigning votesreturn success of message sender delegating votedelegate function does not allow assignment to burn /
function delegateVote(address _to) public returns (bool) { return _delegateVote(_msgSender(), _to); }
function delegateVote(address _to) public returns (bool) { return _delegateVote(_msgSender(), _to); }
32,835
53
// Functions required by IERC20Metadat // Functions required by IERC20Metadat - END // Functions required by IERC20 // Functions required by IERC20 - END / remove the amount from the sender's balance first
_reflectedBalances[sender] = _reflectedBalances[sender].sub(reflectedAmount); if (_isExcludedFromRewards[sender]) _balances[sender] = _balances[sender].sub(amount); _burnTokens( sender, amount, reflectedAmount );
_reflectedBalances[sender] = _reflectedBalances[sender].sub(reflectedAmount); if (_isExcludedFromRewards[sender]) _balances[sender] = _balances[sender].sub(amount); _burnTokens( sender, amount, reflectedAmount );
23,692
116
// AddressArrayUtils Set Protocol Utility functions to handle Address Arrays CHANGELOG:- 4/27/21: Added validatePairsWithArray methods /
library AddressArrayUtils { /** * Finds the index of the first occurrence of the given element. * @param A The input array to search * @param a The value to find * @return Returns (index and isIn) for the first occurrence starting from index 0 */ function indexOf(address[] memory A, address a) internal pure returns (uint256, bool) { uint256 length = A.length; for (uint256 i = 0; i < length; i++) { if (A[i] == a) { return (i, true); } } return (uint256(-1), false); } /** * Returns true if the value is present in the list. Uses indexOf internally. * @param A The input array to search * @param a The value to find * @return Returns isIn for the first occurrence starting from index 0 */ function contains(address[] memory A, address a) internal pure returns (bool) { (, bool isIn) = indexOf(A, a); return isIn; } /** * Returns true if there are 2 elements that are the same in an array * @param A The input array to search * @return Returns boolean for the first occurrence of a duplicate */ function hasDuplicate(address[] memory A) internal pure returns(bool) { require(A.length > 0, "A is empty"); for (uint256 i = 0; i < A.length - 1; i++) { address current = A[i]; for (uint256 j = i + 1; j < A.length; j++) { if (current == A[j]) { return true; } } } return false; } /** * @param A The input array to search * @param a The address to remove * @return Returns the array with the object removed. */ function remove(address[] memory A, address a) internal pure returns (address[] memory) { (uint256 index, bool isIn) = indexOf(A, a); if (!isIn) { revert("Address not in array."); } else { (address[] memory _A,) = pop(A, index); return _A; } } /** * @param A The input array to search * @param a The address to remove */ function removeStorage(address[] storage A, address a) internal { (uint256 index, bool isIn) = indexOf(A, a); if (!isIn) { revert("Address not in array."); } else { uint256 lastIndex = A.length - 1; // If the array would be empty, the previous line would throw, so no underflow here if (index != lastIndex) { A[index] = A[lastIndex]; } A.pop(); } } /** * Removes specified index from array * @param A The input array to search * @param index The index to remove * @return Returns the new array and the removed entry */ function pop(address[] memory A, uint256 index) internal pure returns (address[] memory, address) { uint256 length = A.length; require(index < A.length, "Index must be < A length"); address[] memory newAddresses = new address[](length - 1); for (uint256 i = 0; i < index; i++) { newAddresses[i] = A[i]; } for (uint256 j = index + 1; j < length; j++) { newAddresses[j - 1] = A[j]; } return (newAddresses, A[index]); } /** * Returns the combination of the two arrays * @param A The first array * @param B The second array * @return Returns A extended by B */ function extend(address[] memory A, address[] memory B) internal pure returns (address[] memory) { uint256 aLength = A.length; uint256 bLength = B.length; address[] memory newAddresses = new address[](aLength + bLength); for (uint256 i = 0; i < aLength; i++) { newAddresses[i] = A[i]; } for (uint256 j = 0; j < bLength; j++) { newAddresses[aLength + j] = B[j]; } return newAddresses; } /** * Validate that address and uint array lengths match. Validate address array is not empty * and contains no duplicate elements. * * @param A Array of addresses * @param B Array of uint */ function validatePairsWithArray(address[] memory A, uint[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate that address and bool array lengths match. Validate address array is not empty * and contains no duplicate elements. * * @param A Array of addresses * @param B Array of bool */ function validatePairsWithArray(address[] memory A, bool[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate that address and string array lengths match. Validate address array is not empty * and contains no duplicate elements. * * @param A Array of addresses * @param B Array of strings */ function validatePairsWithArray(address[] memory A, string[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate that address array lengths match, and calling address array are not empty * and contain no duplicate elements. * * @param A Array of addresses * @param B Array of addresses */ function validatePairsWithArray(address[] memory A, address[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate that address and bytes array lengths match. Validate address array is not empty * and contains no duplicate elements. * * @param A Array of addresses * @param B Array of bytes */ function validatePairsWithArray(address[] memory A, bytes[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate address array is not empty and contains no duplicate elements. * * @param A Array of addresses */ function _validateLengthAndUniqueness(address[] memory A) internal pure { require(A.length > 0, "Array length must be > 0"); require(!hasDuplicate(A), "Cannot duplicate addresses"); } }
library AddressArrayUtils { /** * Finds the index of the first occurrence of the given element. * @param A The input array to search * @param a The value to find * @return Returns (index and isIn) for the first occurrence starting from index 0 */ function indexOf(address[] memory A, address a) internal pure returns (uint256, bool) { uint256 length = A.length; for (uint256 i = 0; i < length; i++) { if (A[i] == a) { return (i, true); } } return (uint256(-1), false); } /** * Returns true if the value is present in the list. Uses indexOf internally. * @param A The input array to search * @param a The value to find * @return Returns isIn for the first occurrence starting from index 0 */ function contains(address[] memory A, address a) internal pure returns (bool) { (, bool isIn) = indexOf(A, a); return isIn; } /** * Returns true if there are 2 elements that are the same in an array * @param A The input array to search * @return Returns boolean for the first occurrence of a duplicate */ function hasDuplicate(address[] memory A) internal pure returns(bool) { require(A.length > 0, "A is empty"); for (uint256 i = 0; i < A.length - 1; i++) { address current = A[i]; for (uint256 j = i + 1; j < A.length; j++) { if (current == A[j]) { return true; } } } return false; } /** * @param A The input array to search * @param a The address to remove * @return Returns the array with the object removed. */ function remove(address[] memory A, address a) internal pure returns (address[] memory) { (uint256 index, bool isIn) = indexOf(A, a); if (!isIn) { revert("Address not in array."); } else { (address[] memory _A,) = pop(A, index); return _A; } } /** * @param A The input array to search * @param a The address to remove */ function removeStorage(address[] storage A, address a) internal { (uint256 index, bool isIn) = indexOf(A, a); if (!isIn) { revert("Address not in array."); } else { uint256 lastIndex = A.length - 1; // If the array would be empty, the previous line would throw, so no underflow here if (index != lastIndex) { A[index] = A[lastIndex]; } A.pop(); } } /** * Removes specified index from array * @param A The input array to search * @param index The index to remove * @return Returns the new array and the removed entry */ function pop(address[] memory A, uint256 index) internal pure returns (address[] memory, address) { uint256 length = A.length; require(index < A.length, "Index must be < A length"); address[] memory newAddresses = new address[](length - 1); for (uint256 i = 0; i < index; i++) { newAddresses[i] = A[i]; } for (uint256 j = index + 1; j < length; j++) { newAddresses[j - 1] = A[j]; } return (newAddresses, A[index]); } /** * Returns the combination of the two arrays * @param A The first array * @param B The second array * @return Returns A extended by B */ function extend(address[] memory A, address[] memory B) internal pure returns (address[] memory) { uint256 aLength = A.length; uint256 bLength = B.length; address[] memory newAddresses = new address[](aLength + bLength); for (uint256 i = 0; i < aLength; i++) { newAddresses[i] = A[i]; } for (uint256 j = 0; j < bLength; j++) { newAddresses[aLength + j] = B[j]; } return newAddresses; } /** * Validate that address and uint array lengths match. Validate address array is not empty * and contains no duplicate elements. * * @param A Array of addresses * @param B Array of uint */ function validatePairsWithArray(address[] memory A, uint[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate that address and bool array lengths match. Validate address array is not empty * and contains no duplicate elements. * * @param A Array of addresses * @param B Array of bool */ function validatePairsWithArray(address[] memory A, bool[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate that address and string array lengths match. Validate address array is not empty * and contains no duplicate elements. * * @param A Array of addresses * @param B Array of strings */ function validatePairsWithArray(address[] memory A, string[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate that address array lengths match, and calling address array are not empty * and contain no duplicate elements. * * @param A Array of addresses * @param B Array of addresses */ function validatePairsWithArray(address[] memory A, address[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate that address and bytes array lengths match. Validate address array is not empty * and contains no duplicate elements. * * @param A Array of addresses * @param B Array of bytes */ function validatePairsWithArray(address[] memory A, bytes[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate address array is not empty and contains no duplicate elements. * * @param A Array of addresses */ function _validateLengthAndUniqueness(address[] memory A) internal pure { require(A.length > 0, "Array length must be > 0"); require(!hasDuplicate(A), "Cannot duplicate addresses"); } }
28,959
3
// To be used for cross-chain RFQ-m trades, verified by the router.
bytes32 internal constant XCHAIN_QUOTE_TYPEHASH = keccak256( 'XChainQuote(bytes32 txid,uint256 srcChainId,uint256 dstChainId,bytes32 dstTrader,address srcPool,address srcExternalAccount,bytes32 dstPool,bytes32 dstExternalAccount,address baseToken,bytes32 quoteToken,uint256 baseTokenAmount,uint256 quoteTokenAmount,uint256 quoteExpiry)' ); mapping(bytes32 => bool) private _usedTxids;
bytes32 internal constant XCHAIN_QUOTE_TYPEHASH = keccak256( 'XChainQuote(bytes32 txid,uint256 srcChainId,uint256 dstChainId,bytes32 dstTrader,address srcPool,address srcExternalAccount,bytes32 dstPool,bytes32 dstExternalAccount,address baseToken,bytes32 quoteToken,uint256 baseTokenAmount,uint256 quoteTokenAmount,uint256 quoteExpiry)' ); mapping(bytes32 => bool) private _usedTxids;
29,433
130
// calculate new allocations given the total (not counting unlent balance)
_amountsFromAllocations(rebalancerLastAllocations, totalInUnderlying.sub(maxUnlentBalance)) );
_amountsFromAllocations(rebalancerLastAllocations, totalInUnderlying.sub(maxUnlentBalance)) );
66,022
36
// ERC20
if (pool.exchange_addrs[i] != DEFAULT_ADDRESS) transfer_token(pool.exchange_addrs[i], address(this), msg.sender, pool.exchanged_tokens[i]);
if (pool.exchange_addrs[i] != DEFAULT_ADDRESS) transfer_token(pool.exchange_addrs[i], address(this), msg.sender, pool.exchanged_tokens[i]);
5,955
17
// Triggers stopped state. /
function pause() public whenNotPaused onlyOwner { paused = true; emit Paused(msg.sender); }
function pause() public whenNotPaused onlyOwner { paused = true; emit Paused(msg.sender); }
15,583
87
// add balance
_yamBalances[to] = _yamBalances[to].add(yamValue);
_yamBalances[to] = _yamBalances[to].add(yamValue);
45,642
70
// it will white list one member
// @param _user {address} of user to whitelist // @return true if successful function addToWhiteList(address _user) external onlyOwner() { if (whiteList[_user] != true) { whiteList[_user] = true; totalWhiteListed++; emit LogWhiteListed(_user, totalWhiteListed); }else revert(); }
// @param _user {address} of user to whitelist // @return true if successful function addToWhiteList(address _user) external onlyOwner() { if (whiteList[_user] != true) { whiteList[_user] = true; totalWhiteListed++; emit LogWhiteListed(_user, totalWhiteListed); }else revert(); }
33,145
58
// Returns whether the ownership slot at `index` is initialized.An uninitialized slot does not necessarily mean that the slot has no owner. /
function _ownershipIsInitialized(uint256 index) internal view virtual returns (bool) { return _packedOwnerships[index] != 0; }
function _ownershipIsInitialized(uint256 index) internal view virtual returns (bool) { return _packedOwnerships[index] != 0; }
15,775
23
// note : pass the owner address in _address in frontend to withdraw matic to owner address
function withdrawMaticToAddress( uint256 _amount, address _address
function withdrawMaticToAddress( uint256 _amount, address _address
21,186
8
// nft => tokenId => offerer address => offer struct
mapping(address => mapping(uint256 => mapping(address => OfferNFT))) private offerNfts;
mapping(address => mapping(uint256 => mapping(address => OfferNFT))) private offerNfts;
23,749
49
// slength can contain both the length and contents of the array if length < 32 bytes so let's prepare for that v. http:solidity.readthedocs.io/en/latest/miscellaneous.htmllayout-of-state-variables-in-storage
switch add(lt(slength, 32), lt(newlength, 32)) case 2 {
switch add(lt(slength, 32), lt(newlength, 32)) case 2 {
47,675
92
// Truncate bytes array if its size is more than 20 bytes.NOTE: This function does not perform any checks on the received parameter.Make sure that the _bytes argument has a correct length, not less than 20 bytes.A case when _bytes has length less than 20 will lead to the undefined behaviour,since assembly will read data from memory that is not related to the _bytes argument. _bytes to be converted to address typereturn addr address included in the firsts 20 bytes of the bytes array in parameter. /
function bytesToAddress(bytes memory _bytes) internal pure returns (address addr) { assembly { addr := mload(add(_bytes, 20)) } }
function bytesToAddress(bytes memory _bytes) internal pure returns (address addr) { assembly { addr := mload(add(_bytes, 20)) } }
8,927
11
// clean up storage to save gas
userLocks[lock.owner].remove(lockId); tokenLocksByAddress[lock.lpToken].remove(lockId); delete tokenLocksById[lockId]; emit OnTokenUnlock(lockId);
userLocks[lock.owner].remove(lockId); tokenLocksByAddress[lock.lpToken].remove(lockId); delete tokenLocksById[lockId]; emit OnTokenUnlock(lockId);
15,655
92
// 1-of-1 Hou Yi
string public constant one9 = 'iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABwlBMVEUAAAD5VLT5VLT5aaX5ZGf5XI75uFL5ZGf5mHj5aaX5VLT5l2z563n5hYn52LT5VLT5VLT5aaX5ZGf5Y2f5mHj5fXr5X635ZYX5fW/5X635X635fpf5VLT5lWvt+Yv517X5fpf5VLT5aaX5aaX5p6r5em35uY350mX5hYn5uI351YX532j5vH/5aaX5dJ75XI75cX75dJ750aP563j5uYH5dJ75cH75kHz51Yb55Yf54Vr5W43571v5xlPf+Y7514X5Y2f5mHj5tYv54Gf54Fj5fpf5Y2f5yIPT+Z/r+X357Wn51Ff5mXn4+Xr5kn35x1T5fpf5rnD5+Xz5vXL5xlT5uFL501b5gHz5YHPg+Y6NRE35Z4ZuVCVoUByDOkEaMCpERESGUH1uOGVhRhQTJB4sLCxkZGSxb5bgmL+HeHK+qKLJg6vcxLxfLwAaGhoMDAxwYl2ejYbSZ7L5yYJMQz+gX4f5qnleUk/5ZGf5c3H5k335W41NQz+CKDK0n5mynpe3o52PT3dZT0uikYp0N2ExKygiQDlOKVEADwcKEwoOGhRUNVw3NzdxPGhJSUmDTnphYWFkLlsfGBcqKiogICAYGBioKdTJAAAAfHRSTlMAQICAgL9Av4D/v///v79/P7///3/AwP//v//AwP//v0D/f8D//////////79AwP//v/////////////9A////v///////gP///////////3//////////3///v/////////////////////////////////////9///+/oqUAywAAA5BJREFUeAFiGD6AEb80EyqXmYERRYiFgZUVj4FsbOysHABOqUGNbSgK96bTjZ3Utm3b7rz3f4spW1C3/4djH4MRQBQFCNAUGE6Q+noUzehzsRzHCzqFSEuyxWqzq5r3DqcLZ9Se3B6Z8bI+1UxzfmeA0uLNiCUYCkMPAP8nYB2RaCz+5p+YSKbkNJfOqAXehrO5PK0toFAMlMqVasai9RjkaqW66mCpNXLNFvSoIal2zWvWRkh3Al1nrz+wAG0pKD1UE5jQ0Xg8KRd0TVNvdUsFdCE4zc3mTEFLYLySN7hwLloWq7ZUZeOqmPLUlqu1Ra80QExttnOvx3A3ZVQAFDFlLchexHQdGRTVZ9euSyEKhxbgnce81B1VWO5QVJlJfD4eeDr76mHjhdqnPgcEPcynx4PFYnoR6MfDZDrefJJfzIBYC8fxeDwNyJnXEgC43h8/T3fzDPXqDNhqu5iuoMd93/XLRe3XwT5wgFbPI8W+ff9xrjSn+SL0PDzAL9LKIiFiIIiijbPCWeFn4BIs2Y77TEuk/rjLzakEh2o0bu+nuzQviZz/0v159d8l+8vvS7yVK9U3T2rqd0u91CiXm28UWvoXyca8qjcaxr5CLgg9AgdHu2I8RDEBTwKtdgCqifj5zcVx51RW6BJ6CZ3iShU9iXl32d8XS1I86BLjVgcBvFZcHx7fXo7GclGhgYFlmrrprWiDTW5Fk/sPpZhcerLMaw2aPj2eiX/Z3t46/DCBLsBHaMwRBFpPv4+DD0WdEr7F/GKJQGPw6zjqJgIBaDGfG9Bg5ZuAf6GWeuiUDHYSiKEoyp/OpolxNyZN2KsFZ3zUkff8X+/lJigrXjlJa1ycw00BZn192897FN53o9T5+Qkv3+pcWWi7YWZ9c602FFo5HI7DBfiAG1qZpmk8AVT4KGAqjyWWFZSVBSaOD/iQF17rysTnsF+oqsMV06C/QIevf/EOhzGfA6SP+4SzpZN5Ktxvp5EBZf3303yB3b82O1n+Aa++CtD7hvOdfUDtF2ZW5227TOiZwHm50Ttcs44/1nN+a/VP3+hthL7lAvVq62M1IOcD+dwu310JHE8NqPXWh8cG7rhvu/VW4cEGnM0AcOh3/TD4eEIz+B0wRD88td3DUDifqQsNyOnAVeCBeoG+5Xzwo4K7dagCfsBPB1AQdN3lRzYQlwIw4J0XTtYHgYJgQmPChwJIqBLBC3jk/V83lIjKF0Ik0gAAAABJRU5ErkJggg==';
string public constant one9 = 'iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABwlBMVEUAAAD5VLT5VLT5aaX5ZGf5XI75uFL5ZGf5mHj5aaX5VLT5l2z563n5hYn52LT5VLT5VLT5aaX5ZGf5Y2f5mHj5fXr5X635ZYX5fW/5X635X635fpf5VLT5lWvt+Yv517X5fpf5VLT5aaX5aaX5p6r5em35uY350mX5hYn5uI351YX532j5vH/5aaX5dJ75XI75cX75dJ750aP563j5uYH5dJ75cH75kHz51Yb55Yf54Vr5W43571v5xlPf+Y7514X5Y2f5mHj5tYv54Gf54Fj5fpf5Y2f5yIPT+Z/r+X357Wn51Ff5mXn4+Xr5kn35x1T5fpf5rnD5+Xz5vXL5xlT5uFL501b5gHz5YHPg+Y6NRE35Z4ZuVCVoUByDOkEaMCpERESGUH1uOGVhRhQTJB4sLCxkZGSxb5bgmL+HeHK+qKLJg6vcxLxfLwAaGhoMDAxwYl2ejYbSZ7L5yYJMQz+gX4f5qnleUk/5ZGf5c3H5k335W41NQz+CKDK0n5mynpe3o52PT3dZT0uikYp0N2ExKygiQDlOKVEADwcKEwoOGhRUNVw3NzdxPGhJSUmDTnphYWFkLlsfGBcqKiogICAYGBioKdTJAAAAfHRSTlMAQICAgL9Av4D/v///v79/P7///3/AwP//v//AwP//v0D/f8D//////////79AwP//v/////////////9A////v///////gP///////////3//////////3///v/////////////////////////////////////9///+/oqUAywAAA5BJREFUeAFiGD6AEb80EyqXmYERRYiFgZUVj4FsbOysHABOqUGNbSgK96bTjZ3Utm3b7rz3f4spW1C3/4djH4MRQBQFCNAUGE6Q+noUzehzsRzHCzqFSEuyxWqzq5r3DqcLZ9Se3B6Z8bI+1UxzfmeA0uLNiCUYCkMPAP8nYB2RaCz+5p+YSKbkNJfOqAXehrO5PK0toFAMlMqVasai9RjkaqW66mCpNXLNFvSoIal2zWvWRkh3Al1nrz+wAG0pKD1UE5jQ0Xg8KRd0TVNvdUsFdCE4zc3mTEFLYLySN7hwLloWq7ZUZeOqmPLUlqu1Ra80QExttnOvx3A3ZVQAFDFlLchexHQdGRTVZ9euSyEKhxbgnce81B1VWO5QVJlJfD4eeDr76mHjhdqnPgcEPcynx4PFYnoR6MfDZDrefJJfzIBYC8fxeDwNyJnXEgC43h8/T3fzDPXqDNhqu5iuoMd93/XLRe3XwT5wgFbPI8W+ff9xrjSn+SL0PDzAL9LKIiFiIIiijbPCWeFn4BIs2Y77TEuk/rjLzakEh2o0bu+nuzQviZz/0v159d8l+8vvS7yVK9U3T2rqd0u91CiXm28UWvoXyca8qjcaxr5CLgg9AgdHu2I8RDEBTwKtdgCqifj5zcVx51RW6BJ6CZ3iShU9iXl32d8XS1I86BLjVgcBvFZcHx7fXo7GclGhgYFlmrrprWiDTW5Fk/sPpZhcerLMaw2aPj2eiX/Z3t46/DCBLsBHaMwRBFpPv4+DD0WdEr7F/GKJQGPw6zjqJgIBaDGfG9Bg5ZuAf6GWeuiUDHYSiKEoyp/OpolxNyZN2KsFZ3zUkff8X+/lJigrXjlJa1ycw00BZn192897FN53o9T5+Qkv3+pcWWi7YWZ9c602FFo5HI7DBfiAG1qZpmk8AVT4KGAqjyWWFZSVBSaOD/iQF17rysTnsF+oqsMV06C/QIevf/EOhzGfA6SP+4SzpZN5Ktxvp5EBZf3303yB3b82O1n+Aa++CtD7hvOdfUDtF2ZW5227TOiZwHm50Ttcs44/1nN+a/VP3+hthL7lAvVq62M1IOcD+dwu310JHE8NqPXWh8cG7rhvu/VW4cEGnM0AcOh3/TD4eEIz+B0wRD88td3DUDifqQsNyOnAVeCBeoG+5Xzwo4K7dagCfsBPB1AQdN3lRzYQlwIw4J0XTtYHgYJgQmPChwJIqBLBC3jk/V83lIjKF0Ik0gAAAABJRU5ErkJggg==';
5,794
63
// A mapping of preSaleItem Type to Type Sequence Number to Collectible
mapping (uint256 => mapping (uint256 => mapping ( uint256 => uint256 ) ) ) public preSaleItemTypeToSequenceIdToCollectible;
mapping (uint256 => mapping (uint256 => mapping ( uint256 => uint256 ) ) ) public preSaleItemTypeToSequenceIdToCollectible;
18,620
202
// Approves tokens for the smart contract./
/// @dev Reverts with a {CallFailed} error if execution of the approval fails or returns an unexpected value. /// /// @param token The token to approve. /// @param spender The contract to spend the tokens. /// @param value The amount of tokens to approve. function safeApprove(address token, address spender, uint256 value) internal { (bool success, bytes memory data) = token.call( abi.encodeWithSelector(IERC20.approve.selector, spender, value) ); if (token.code.length == 0 || !success || (data.length != 0 && !abi.decode(data, (bool)))) { revert ERC20CallFailed(token, success, data); } }
/// @dev Reverts with a {CallFailed} error if execution of the approval fails or returns an unexpected value. /// /// @param token The token to approve. /// @param spender The contract to spend the tokens. /// @param value The amount of tokens to approve. function safeApprove(address token, address spender, uint256 value) internal { (bool success, bytes memory data) = token.call( abi.encodeWithSelector(IERC20.approve.selector, spender, value) ); if (token.code.length == 0 || !success || (data.length != 0 && !abi.decode(data, (bool)))) { revert ERC20CallFailed(token, success, data); } }
26,517
239
// event ConditionalTransferProcessed(
{ // Read the transfer Transfer memory transfer = readTx(data, offset); TransferAuxiliaryData memory auxData = abi.decode(auxiliaryData, (TransferAuxiliaryData)); // Fill in withdrawal data missing from DA transfer.validUntil = auxData.validUntil; transfer.maxFee = auxData.maxFee == 0 ? transfer.fee : auxData.maxFee; // Validate require(ctx.timestamp < transfer.validUntil, "TRANSFER_EXPIRED"); require(transfer.fee <= transfer.maxFee, "TRANSFER_FEE_TOO_HIGH"); // Calculate the tx hash bytes32 txHash = hashTx(ctx.DOMAIN_SEPARATOR, transfer); // Check the on-chain authorization S.requireAuthorizedTx(transfer.from, auxData.signature, txHash); //emit ConditionalTransferProcessed(from, to, tokenID, amount); }
{ // Read the transfer Transfer memory transfer = readTx(data, offset); TransferAuxiliaryData memory auxData = abi.decode(auxiliaryData, (TransferAuxiliaryData)); // Fill in withdrawal data missing from DA transfer.validUntil = auxData.validUntil; transfer.maxFee = auxData.maxFee == 0 ? transfer.fee : auxData.maxFee; // Validate require(ctx.timestamp < transfer.validUntil, "TRANSFER_EXPIRED"); require(transfer.fee <= transfer.maxFee, "TRANSFER_FEE_TOO_HIGH"); // Calculate the tx hash bytes32 txHash = hashTx(ctx.DOMAIN_SEPARATOR, transfer); // Check the on-chain authorization S.requireAuthorizedTx(transfer.from, auxData.signature, txHash); //emit ConditionalTransferProcessed(from, to, tokenID, amount); }
48,595
4
// duration of a slice period for the vesting in seconds
uint256 slicePeriodSeconds;
uint256 slicePeriodSeconds;
4,205
153
// case 2: R>1
payQuote = _RAboveBuyBaseToken(buyBaseAmount, _BASE_BALANCE_, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE;
payQuote = _RAboveBuyBaseToken(buyBaseAmount, _BASE_BALANCE_, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE;
32,188
84
// If there isn't enough in the allPrevInvestmentTotal for the subtracted amount
if ( usersLastAddedLiquidityEpochInvestmentDetails .allPrevInvestmentTotals < _amount ) {
if ( usersLastAddedLiquidityEpochInvestmentDetails .allPrevInvestmentTotals < _amount ) {
19,371
19
// Send a request from user to blockchain. Assumes price is including the cost for verification NOTE: use bytes memory as argument will increase the gas cost, one alternative will be uint type, may consifer in future.
function startRequest(bytes memory dataID) public payable returns (bool) { require(msg.value >= price, 'Not enough ether'); if(requestList[msg.sender].blockNumber == 0){ //never submitted before //register on List requestList[msg.sender].blockNumber = block.number; requestList[msg.sender].provider = address(0); requestList[msg.sender].validator = address(0); requestList[msg.sender].deposit = msg.value; //how much ether was sent to contract by the user, their "deposit" requestList[msg.sender].price = price; //set to price here, in future will need to be calculated and set later requestList[msg.sender].dataID = dataID; requestList[msg.sender].status = '0'; //pending = 0x30, is in ascii not number 0 pendingPool.push(msg.sender); emit IPFSInfo (msg.sender, "Request Added", dataID); return true; } else { //submitted before return updateRequest(dataID); } }
function startRequest(bytes memory dataID) public payable returns (bool) { require(msg.value >= price, 'Not enough ether'); if(requestList[msg.sender].blockNumber == 0){ //never submitted before //register on List requestList[msg.sender].blockNumber = block.number; requestList[msg.sender].provider = address(0); requestList[msg.sender].validator = address(0); requestList[msg.sender].deposit = msg.value; //how much ether was sent to contract by the user, their "deposit" requestList[msg.sender].price = price; //set to price here, in future will need to be calculated and set later requestList[msg.sender].dataID = dataID; requestList[msg.sender].status = '0'; //pending = 0x30, is in ascii not number 0 pendingPool.push(msg.sender); emit IPFSInfo (msg.sender, "Request Added", dataID); return true; } else { //submitted before return updateRequest(dataID); } }
13,390
27
// This implements an optional extension of {ERC721} defined in the EIP that addsenumerability of all the token ids in the contract as well as all token ids owned by eachaccount. /
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
58,086
269
// Update % lock for dev
function lockdevUpdate(uint _newdevlock) public onlyAuthorized { PERCENT_FOR_DEV = _newdevlock; }
function lockdevUpdate(uint _newdevlock) public onlyAuthorized { PERCENT_FOR_DEV = _newdevlock; }
24,520
80
// Returns all the relevant information about a specific collectible./_tokenId The tokenId of the collectible of interest.
function getCollectible(uint256 _tokenId) public view returns (uint256 tokenId, uint256 sellingPrice, address owner, uint256 nextSellingPrice
function getCollectible(uint256 _tokenId) public view returns (uint256 tokenId, uint256 sellingPrice, address owner, uint256 nextSellingPrice
54,584
59
// as wad wetWeaken + weStrengthen + dryWeaken - deadBranchGrowth
function weakBranchGrowth(uint256 newWetWeaken, uint256 newWetStrengthen, uint256 newDryWeaken, uint256 newDeadBranchGrowth, uint256 frailty) internal pure returns (int256) { // growth can be negative return Math.toInt256(PRBU.mul(frailty, newWetWeaken)) - Math.toInt256(newWetStrengthen) + Math.toInt256(PRBU.mul(frailty, newDryWeaken)) - Math.toInt256(newDeadBranchGrowth); }
function weakBranchGrowth(uint256 newWetWeaken, uint256 newWetStrengthen, uint256 newDryWeaken, uint256 newDeadBranchGrowth, uint256 frailty) internal pure returns (int256) { // growth can be negative return Math.toInt256(PRBU.mul(frailty, newWetWeaken)) - Math.toInt256(newWetStrengthen) + Math.toInt256(PRBU.mul(frailty, newDryWeaken)) - Math.toInt256(newDeadBranchGrowth); }
5,997