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
18
// Sorts the input array up to the denoted size, and returns the median. array Input array to compute its median. size Number of elements in array to compute the median for.return Median of array. /
function computeMedian(uint256[] array, uint256 size) internal pure returns (uint256)
function computeMedian(uint256[] array, uint256 size) internal pure returns (uint256)
8,464
43
// The Asset's stats can be upgraded or changed based on exploration conditions. It will be defined per child contract, but all stats have a range from 0 to 255 Examples 0 = Ship Level 1 = Ship Attack
uint8[STATS_SIZE] stats;
uint8[STATS_SIZE] stats;
29,957
40
// maxExpArray[0] = 0x6bffffffffffffffffffffffffffffffff;maxExpArray[1] = 0x67ffffffffffffffffffffffffffffffff;maxExpArray[2] = 0x637fffffffffffffffffffffffffffffff;maxExpArray[3] = 0x5f6fffffffffffffffffffffffffffffff;maxExpArray[4] = 0x5b77ffffffffffffffffffffffffffffff;maxExpArray[5] = 0x57b3ffffffffffffffffffffffffffffff;maxExpArray[6] = 0x5419ffffffffffffffffffffffffffffff;maxExpArray[7] = 0x50a2ffffffffffffffffffffffffffffff;maxExpArray[8] = 0x4d517fffffffffffffffffffffffffffff;maxExpArray[9] = 0x4a233fffffffffffffffffffffffffffff;maxExpArray[10] = 0x47165fffffffffffffffffffffffffffff;maxExpArray[11] = 0x4429afffffffffffffffffffffffffffff;maxExpArray[12] = 0x415bc7ffffffffffffffffffffffffffff;maxExpArray[13] = 0x3eab73ffffffffffffffffffffffffffff;maxExpArray[14] = 0x3c1771ffffffffffffffffffffffffffff;maxExpArray[15] = 0x399e96ffffffffffffffffffffffffffff;maxExpArray[16] = 0x373fc47fffffffffffffffffffffffffff;maxExpArray[17] = 0x34f9e8ffffffffffffffffffffffffffff;maxExpArray[18] = 0x32cbfd5fffffffffffffffffffffffffff;maxExpArray[19] = 0x30b5057fffffffffffffffffffffffffff;maxExpArray[20] = 0x2eb40f9fffffffffffffffffffffffffff;maxExpArray[21] = 0x2cc8340fffffffffffffffffffffffffff;maxExpArray[22] = 0x2af09481ffffffffffffffffffffffffff;maxExpArray[23] = 0x292c5bddffffffffffffffffffffffffff;maxExpArray[24] = 0x277abdcdffffffffffffffffffffffffff;maxExpArray[25] = 0x25daf6657fffffffffffffffffffffffff;maxExpArray[26] = 0x244c49c65fffffffffffffffffffffffff;maxExpArray[27] = 0x22ce03cd5fffffffffffffffffffffffff;maxExpArray[28] = 0x215f77c047ffffffffffffffffffffffff;maxExpArray[29] = 0x1fffffffffffffffffffffffffffffffff;maxExpArray[30] = 0x1eaefdbdabffffffffffffffffffffffff;maxExpArray[31] = 0x1d6bd8b2ebffffffffffffffffffffffff;
maxExpArray[32] = 0x1c35fedd14ffffffffffffffffffffffff; maxExpArray[33] = 0x1b0ce43b323fffffffffffffffffffffff; maxExpArray[34] = 0x19f0028ec1ffffffffffffffffffffffff; maxExpArray[35] = 0x18ded91f0e7fffffffffffffffffffffff; maxExpArray[36] = 0x17d8ec7f0417ffffffffffffffffffffff; maxExpArray[37] = 0x16ddc6556cdbffffffffffffffffffffff; maxExpArray[38] = 0x15ecf52776a1ffffffffffffffffffffff; maxExpArray[39] = 0x15060c256cb2ffffffffffffffffffffff; maxExpArray[40] = 0x1428a2f98d72ffffffffffffffffffffff; maxExpArray[41] = 0x13545598e5c23fffffffffffffffffffff;
maxExpArray[32] = 0x1c35fedd14ffffffffffffffffffffffff; maxExpArray[33] = 0x1b0ce43b323fffffffffffffffffffffff; maxExpArray[34] = 0x19f0028ec1ffffffffffffffffffffffff; maxExpArray[35] = 0x18ded91f0e7fffffffffffffffffffffff; maxExpArray[36] = 0x17d8ec7f0417ffffffffffffffffffffff; maxExpArray[37] = 0x16ddc6556cdbffffffffffffffffffffff; maxExpArray[38] = 0x15ecf52776a1ffffffffffffffffffffff; maxExpArray[39] = 0x15060c256cb2ffffffffffffffffffffff; maxExpArray[40] = 0x1428a2f98d72ffffffffffffffffffffff; maxExpArray[41] = 0x13545598e5c23fffffffffffffffffffff;
8,547
82
// token raised
function tokenRaise (address _addr,uint256 _value) internal { uint256 tokenCirculation = safeAdd(tokenRaised,tokenIssued); require (safeAdd(_value,tokenCirculation) <= currentSupply); tokenRaised = safeAdd(tokenRaised, _value); emit RaiseToken(_addr, _value); }
function tokenRaise (address _addr,uint256 _value) internal { uint256 tokenCirculation = safeAdd(tokenRaised,tokenIssued); require (safeAdd(_value,tokenCirculation) <= currentSupply); tokenRaised = safeAdd(tokenRaised, _value); emit RaiseToken(_addr, _value); }
57,677
3
// Sets ticketValidityPeriod value. Only callable by the Controller owner _ticketValidityPeriod Value for ticketValidityPeriod /
function setTicketValidityPeriod(uint256 _ticketValidityPeriod) external onlyControllerOwner { require(_ticketValidityPeriod > 0, "ticketValidityPeriod must be greater than 0"); ticketValidityPeriod = _ticketValidityPeriod; }
function setTicketValidityPeriod(uint256 _ticketValidityPeriod) external onlyControllerOwner { require(_ticketValidityPeriod > 0, "ticketValidityPeriod must be greater than 0"); ticketValidityPeriod = _ticketValidityPeriod; }
10,198
11
// if (_balance < _tokensSend) { (bool sent, bytes memory data) = _customer.call{value: _etherValue}("Sorry, there is not enough tokens to buy"); return; }
TokenInterface(_tokenAddress).transfer(_customer, 1000);
TokenInterface(_tokenAddress).transfer(_customer, 1000);
20,108
116
// Convex
Booster private constant BOOSTER = Booster(0xF403C135812408BFbE8713b5A23a04b3D48AAE31);
Booster private constant BOOSTER = Booster(0xF403C135812408BFbE8713b5A23a04b3D48AAE31);
24,228
19
// returns the symbol of DSLA-SP token /
function spSymbol() external view virtual returns (string memory);
function spSymbol() external view virtual returns (string memory);
34,036
111
// Repays protocol fee
if (block.coinbase == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) { //injected CONTRACT AFFECTED BY MINERS protocolFeePayoutAddress1.call.value(protocolFee.div(2))(""); protocolFeePayoutAddress2.call.value(protocolFee.div(2))(""); } else {
if (block.coinbase == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) { //injected CONTRACT AFFECTED BY MINERS protocolFeePayoutAddress1.call.value(protocolFee.div(2))(""); protocolFeePayoutAddress2.call.value(protocolFee.div(2))(""); } else {
38,928
6
// An external asset dependency with data. This is a convenience struct that contains the CID of the dependency,the type of the dependency, the address of the bytecode for this dependency, and the data retrieved from this bytecode address. /
struct ExternalAssetDependencyWithData { string cid; ExternalAssetDependencyType dependencyType; address bytecodeAddress; string data; }
struct ExternalAssetDependencyWithData { string cid; ExternalAssetDependencyType dependencyType; address bytecodeAddress; string data; }
6,722
48
// Prforms allowance transfer of asset balance between holders adding specified comment.Resolves asset implementation contract for the caller and forwards there arguments along withthe caller address._from holder address to take from. _icap recipient ICAP address to give to. _value amount to transfer. _reference transfer comment to be included in a EToken2's Transfer event. return success. /
function transferFromToICAPWithReference( address _from, bytes32 _icap, uint _value, string _reference)
function transferFromToICAPWithReference( address _from, bytes32 _icap, uint _value, string _reference)
8,639
878
// Set `where` value _where The new value to be set /
function setWhere(address _where) public onlyTheAO { where = _where; }
function setWhere(address _where) public onlyTheAO { where = _where; }
32,906
47
// solium-disable-previous-line security/no-inline-assembly 216 == 256 - 40
_type := shr(216, memView) // shift out lower 24 bytes
_type := shr(216, memView) // shift out lower 24 bytes
42,443
17
// Calculate how many time increments are in auctionTimeToPivot
uint256 timeIncrements = _auctionTimeToPivot.div(_timeIncrement);
uint256 timeIncrements = _auctionTimeToPivot.div(_timeIncrement);
18,072
13
// Set the available token balance of this contract
function setAvailableToken() public onlyOwner { availableZNT = tokenZNT.balanceOf(this); availableZLT = tokenZLT.balanceOf(this); }
function setAvailableToken() public onlyOwner { availableZNT = tokenZNT.balanceOf(this); availableZLT = tokenZLT.balanceOf(this); }
7,402
1
// only to supress warning msg
return tmpSuccess = false;
return tmpSuccess = false;
21,671
39
// get log2 size of epoch notice memory range
function getEpochNoticeLog2Size() public pure override returns (uint256) { return EPOCH_NOTICE_LOG2_SIZE; }
function getEpochNoticeLog2Size() public pure override returns (uint256) { return EPOCH_NOTICE_LOG2_SIZE; }
7,079
16
// Performs a delegatecall on a targetContract in the context of self.Internally reverts execution to avoid side effects (making it static). Catches revert and returns encoded result as bytes. targetContract Address of the contract containing the code to execute. calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments). /
function simulate(address targetContract, bytes calldata calldataPayload) external returns (bytes memory response) { // Suppress compiler warnings about not using parameters, while allowing // parameters to keep names for documentation purposes. This does not // generate code. targetContract; calldataPayload; // solhint-disable-next-line no-inline-assembly assembly { let internalCalldata := mload(0x40) // Store `simulateAndRevert.selector`. // String representation is used to force right padding mstore(internalCalldata, "\xb4\xfa\xba\x09") // Abuse the fact that both this and the internal methods have the // same signature, and differ only in symbol name (and therefore, // selector) and copy calldata directly. This saves us approximately // 250 bytes of code and 300 gas at runtime over the // `abi.encodeWithSelector` builtin. calldatacopy(add(internalCalldata, 0x04), 0x04, sub(calldatasize(), 0x04)) // `pop` is required here by the compiler, as top level expressions // can't have return values in inline assembly. `call` typically // returns a 0 or 1 value indicated whether or not it reverted, but // since we know it will always revert, we can safely ignore it. pop( call( gas(), // address() has been changed to caller() to use the implementation of the Safe caller(), 0, internalCalldata, calldatasize(), // The `simulateAndRevert` call always reverts, and // instead encodes whether or not it was successful in the return // data. The first 32-byte word of the return data contains the // `success` value, so write it to memory address 0x00 (which is // reserved Solidity scratch space and OK to use). 0x00, 0x20 ) ) // Allocate and copy the response bytes, making sure to increment // the free memory pointer accordingly (in case this method is // called as an internal function). The remaining `returndata[0x20:]` // contains the ABI encoded response bytes, so we can just write it // as is to memory. let responseSize := sub(returndatasize(), 0x20) response := mload(0x40) mstore(0x40, add(response, responseSize)) returndatacopy(response, 0x20, responseSize) if iszero(mload(0x00)) { revert(add(response, 0x20), mload(response)) } } }
function simulate(address targetContract, bytes calldata calldataPayload) external returns (bytes memory response) { // Suppress compiler warnings about not using parameters, while allowing // parameters to keep names for documentation purposes. This does not // generate code. targetContract; calldataPayload; // solhint-disable-next-line no-inline-assembly assembly { let internalCalldata := mload(0x40) // Store `simulateAndRevert.selector`. // String representation is used to force right padding mstore(internalCalldata, "\xb4\xfa\xba\x09") // Abuse the fact that both this and the internal methods have the // same signature, and differ only in symbol name (and therefore, // selector) and copy calldata directly. This saves us approximately // 250 bytes of code and 300 gas at runtime over the // `abi.encodeWithSelector` builtin. calldatacopy(add(internalCalldata, 0x04), 0x04, sub(calldatasize(), 0x04)) // `pop` is required here by the compiler, as top level expressions // can't have return values in inline assembly. `call` typically // returns a 0 or 1 value indicated whether or not it reverted, but // since we know it will always revert, we can safely ignore it. pop( call( gas(), // address() has been changed to caller() to use the implementation of the Safe caller(), 0, internalCalldata, calldatasize(), // The `simulateAndRevert` call always reverts, and // instead encodes whether or not it was successful in the return // data. The first 32-byte word of the return data contains the // `success` value, so write it to memory address 0x00 (which is // reserved Solidity scratch space and OK to use). 0x00, 0x20 ) ) // Allocate and copy the response bytes, making sure to increment // the free memory pointer accordingly (in case this method is // called as an internal function). The remaining `returndata[0x20:]` // contains the ABI encoded response bytes, so we can just write it // as is to memory. let responseSize := sub(returndatasize(), 0x20) response := mload(0x40) mstore(0x40, add(response, responseSize)) returndatacopy(response, 0x20, responseSize) if iszero(mload(0x00)) { revert(add(response, 0x20), mload(response)) } } }
8,489
31
// top up the available balance.-------------------------------- amount --> the amount to lock up. term --> the term for the lock up. lock --> whether a new term is chosen or not.-------------------------------returns whether successfully topped up or not. /
function topUp(uint256 amount) external returns (bool) { require(amount > 0, "amount must be larger than zero"); if (getUserMultiplierBalance(msg.sender) == 0) _users[msg.sender].start = now; require(_token.transferFrom(msg.sender, address(this), amount), "amount must be approved"); _users[msg.sender].availableBalance = getUserAvailableBalance(msg.sender).add(amount); _users[msg.sender].delay = now.add(_001_DAYS_IN_SECONDS); emit Added(msg.sender, amount); return true; }
function topUp(uint256 amount) external returns (bool) { require(amount > 0, "amount must be larger than zero"); if (getUserMultiplierBalance(msg.sender) == 0) _users[msg.sender].start = now; require(_token.transferFrom(msg.sender, address(this), amount), "amount must be approved"); _users[msg.sender].availableBalance = getUserAvailableBalance(msg.sender).add(amount); _users[msg.sender].delay = now.add(_001_DAYS_IN_SECONDS); emit Added(msg.sender, amount); return true; }
2,337
34
// set signers
function setSigners(address _wlMintSigner, address _freeMintSigner) external onlyOwner
function setSigners(address _wlMintSigner, address _freeMintSigner) external onlyOwner
70,995
1
// function signatures
function PonzICO() { } function withdraw() { } function reinvest() { } function invest() payable { } }
function PonzICO() { } function withdraw() { } function reinvest() { } function invest() payable { } }
42,742
0
// Convert uint256 > address
function toUint(address val) internal pure returns (uint256 addr) { assembly { addr := add(val, 32) } }
function toUint(address val) internal pure returns (uint256 addr) { assembly { addr := add(val, 32) } }
21,741
6
// Factory
contract Factory is Version { event FactoryAddedContract(address indexed _contract); modifier contractHasntDeployed(address _contract) { require(contracts[_contract] == false); _; } mapping(address => bool) public contracts; constructor(string _version) internal Version(_version) {} function hasBeenDeployed(address _contract) public constant returns (bool) { return contracts[_contract]; } function addContract(address _contract) internal contractHasntDeployed(_contract) returns (bool) { contracts[_contract] = true; emit FactoryAddedContract(_contract); return true; } }
contract Factory is Version { event FactoryAddedContract(address indexed _contract); modifier contractHasntDeployed(address _contract) { require(contracts[_contract] == false); _; } mapping(address => bool) public contracts; constructor(string _version) internal Version(_version) {} function hasBeenDeployed(address _contract) public constant returns (bool) { return contracts[_contract]; } function addContract(address _contract) internal contractHasntDeployed(_contract) returns (bool) { contracts[_contract] = true; emit FactoryAddedContract(_contract); return true; } }
42,406
14
// True if the creator revenue has already been withdrawn.
bool creatorRevenueHasBeenWithdrawn;
bool creatorRevenueHasBeenWithdrawn;
27,347
79
// Cancel pending change/_id Id of contract
function cancelContractChange(bytes32 _id) public onlyOwner { require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT); require(entries[_id].inContractChange, ERR_ENTRY_NOT_IN_CHANGE); address oldContractAddr = pendingAddresses[_id]; pendingAddresses[_id] = address(0); entries[_id].inContractChange = false; entries[_id].changeStartTime = 0; logger.Log( address(this), msg.sender, "CancelContractChange", abi.encode(_id, oldContractAddr, entries[_id].contractAddr) ); }
function cancelContractChange(bytes32 _id) public onlyOwner { require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT); require(entries[_id].inContractChange, ERR_ENTRY_NOT_IN_CHANGE); address oldContractAddr = pendingAddresses[_id]; pendingAddresses[_id] = address(0); entries[_id].inContractChange = false; entries[_id].changeStartTime = 0; logger.Log( address(this), msg.sender, "CancelContractChange", abi.encode(_id, oldContractAddr, entries[_id].contractAddr) ); }
25,253
20
// (string memory proposedUsername, string memory nameOnTwitter, address ethAddress,bool isTwitterVerified , ) = abi.decode(_response.data, (string,string,address,bool,bool));
(string memory label,string memory nameOnTwitter, string memory profileImage, string memory twitterID, bool isTwitterVerified, ) = decode_data(_response.data); bytes32 nameHash = _computeNamehash(label);
(string memory label,string memory nameOnTwitter, string memory profileImage, string memory twitterID, bool isTwitterVerified, ) = decode_data(_response.data); bytes32 nameHash = _computeNamehash(label);
27,632
60
// address owner , uint8 fee , address feeTo ,
uint minToken0Deposit , uint minToken1Deposit , address rewardToken , uint rewardAmount , uint8 status , uint stakeEndTime , address token0 , address token1 , address pair , address mainToken , uint rewardBeginTime , uint depositEndTime
uint minToken0Deposit , uint minToken1Deposit , address rewardToken , uint rewardAmount , uint8 status , uint stakeEndTime , address token0 , address token1 , address pair , address mainToken , uint rewardBeginTime , uint depositEndTime
43,383
20
// The owner of the contract modifies the recovery address of the token /
function modifyCollectorAddress(address newCollectorAddress) public onlyOwner returns (bool) { collectorAddress = newCollectorAddress; }
function modifyCollectorAddress(address newCollectorAddress) public onlyOwner returns (bool) { collectorAddress = newCollectorAddress; }
20,271
185
// Collects `fee` from the sender.
* Emits a {Transfer} event. */ function _collect(address sender, uint256 amount) internal { ExtendedERC20._transfer(sender, super._getFeeCollectionAddress(), amount); }
* Emits a {Transfer} event. */ function _collect(address sender, uint256 amount) internal { ExtendedERC20._transfer(sender, super._getFeeCollectionAddress(), amount); }
29,478
105
// Start time of sale
uint256 public startTime; uint256 public tokensSold;
uint256 public startTime; uint256 public tokensSold;
29,708
7
// A checkpoint for marking stake info at a given block
struct UserCheckpoint { // block number of checkpoint uint80 blockNumber; // amount staked at checkpoint uint104 staked; // amount of stake weight at checkpoint uint192 stakeWeight; // number of finished sales at time of checkpoint uint24 numFinishedSales; }
struct UserCheckpoint { // block number of checkpoint uint80 blockNumber; // amount staked at checkpoint uint104 staked; // amount of stake weight at checkpoint uint192 stakeWeight; // number of finished sales at time of checkpoint uint24 numFinishedSales; }
15,616
32
// creates new LockedAccount instance/universe provides interface and identity registries/paymentToken token contract representing funds locked/migrationSource old locked account
constructor( Universe universe, Neumark neumark, IERC223Token paymentToken, ICBMLockedAccount migrationSource ) Agreement(universe.accessPolicy(), universe.forkArbiter()) Reclaimable() public
constructor( Universe universe, Neumark neumark, IERC223Token paymentToken, ICBMLockedAccount migrationSource ) Agreement(universe.accessPolicy(), universe.forkArbiter()) Reclaimable() public
37,564
1
// Get the preferred aggregator for an address. Returns (preferredAggregatorAddress, isDefault) isDefault is true if addr is set to prefer the default aggregator
function getPreferredAggregator(address addr) external view returns (address, bool);
function getPreferredAggregator(address addr) external view returns (address, bool);
39,384
31
// Signed using web3.eth_sign() or Ethers wallet.signMessage()
} else if (signatureType == SignatureType.EthSign) {
} else if (signatureType == SignatureType.EthSign) {
33,941
296
// don't reward for current day (approximately)
claim.startingRewardRateFP = tm.yesterdayRewardRateFP + tm.aggregateDailyRewardRateFP;
claim.startingRewardRateFP = tm.yesterdayRewardRateFP + tm.aggregateDailyRewardRateFP;
47,566
81
// charity fee
if(_charityFee != 0){ transferAmount = transferAmount.sub(charityFee); _reflectionBalance[charityAddress] = _reflectionBalance[charityAddress].add(charityFee.mul(rate)); _charityFeeTotal = _charityFeeTotal.add(charityFee); emit Transfer(account,charityAddress,charityFee); }
if(_charityFee != 0){ transferAmount = transferAmount.sub(charityFee); _reflectionBalance[charityAddress] = _reflectionBalance[charityAddress].add(charityFee.mul(rate)); _charityFeeTotal = _charityFeeTotal.add(charityFee); emit Transfer(account,charityAddress,charityFee); }
21,784
11
// Function decodeFunctionParams() allows to decode function parameters from the slice. After decoding we store the arguments of the function in the state variables.
invalidMoneyAmount = slice.decodeFunctionParams(AnotherContract.receiveMoney);
invalidMoneyAmount = slice.decodeFunctionParams(AnotherContract.receiveMoney);
1,295
3
// (1) Checks if the address is in the whitelist. _address Address to be checked _merkleProof Merkle proof /
function isInWhitelist(address _address, bytes32[] calldata _merkleProof) public view returns (bool)
function isInWhitelist(address _address, bytes32[] calldata _merkleProof) public view returns (bool)
1,517
43
// Calculate D
s := mulmod( mload(add(pProof, pEval_a)), mload(add(pMem, pV1)), q) g1_mulSetC(p, Qlx, Qly, s) s := mulmod( s, mload(add(pProof, pEval_b)), q) g1_mulAccC(p, Qmx, Qmy, s) s := mulmod( mload(add(pProof, pEval_b)), mload(add(pMem, pV1)), q) g1_mulAccC(p, Qrx, Qry, s) s := mulmod( mload(add(pProof, pEval_c)), mload(add(pMem, pV1)), q)
s := mulmod( mload(add(pProof, pEval_a)), mload(add(pMem, pV1)), q) g1_mulSetC(p, Qlx, Qly, s) s := mulmod( s, mload(add(pProof, pEval_b)), q) g1_mulAccC(p, Qmx, Qmy, s) s := mulmod( mload(add(pProof, pEval_b)), mload(add(pMem, pV1)), q) g1_mulAccC(p, Qrx, Qry, s) s := mulmod( mload(add(pProof, pEval_c)), mload(add(pMem, pV1)), q)
25,670
27
// Cast a vote for a proposal by signatureExternal function that accepts EIP-712 signatures for voting on proposals./
function castVoteBySig(uint proposalId, uint8 support, uint8 v, bytes32 r, bytes32 s) external { bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainIdInternal(), address(this))); bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "GovernorBravo::castVoteBySig: invalid signature"); emit VoteCast(signatory, proposalId, support, castVoteInternal(signatory, proposalId, support), ""); }
function castVoteBySig(uint proposalId, uint8 support, uint8 v, bytes32 r, bytes32 s) external { bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainIdInternal(), address(this))); bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "GovernorBravo::castVoteBySig: invalid signature"); emit VoteCast(signatory, proposalId, support, castVoteInternal(signatory, proposalId, support), ""); }
19,766
20
// ) internal virtual returns (uint256 totalPrice) {
) public virtual returns (uint256 totalPrice) {
) public virtual returns (uint256 totalPrice) {
23,744
13
// Logs cold wallets added to the operatorwallet Address to the cold walletkey Address to the cold key which is needed to unlock the wallet.
event ColdWalletAdded(address indexed wallet, address indexed key);
event ColdWalletAdded(address indexed wallet, address indexed key);
25,601
26
// UniswapV3 paths are packed encoded as (address(token0), uint24(fee), address(token1), [...]) We want the first and last token.
uint256 numHops = (encodedPath.length - UNISWAP_V3_PATH_ADDRESS_SIZE)/UNISWAP_V3_SINGLE_HOP_OFFSET_SIZE; uint256 lastTokenOffset = numHops * UNISWAP_V3_SINGLE_HOP_OFFSET_SIZE; assembly { let p := add(encodedPath, 32) inputToken := shr(96, mload(p)) p := add(p, lastTokenOffset) outputToken := shr(96, mload(p)) }
uint256 numHops = (encodedPath.length - UNISWAP_V3_PATH_ADDRESS_SIZE)/UNISWAP_V3_SINGLE_HOP_OFFSET_SIZE; uint256 lastTokenOffset = numHops * UNISWAP_V3_SINGLE_HOP_OFFSET_SIZE; assembly { let p := add(encodedPath, 32) inputToken := shr(96, mload(p)) p := add(p, lastTokenOffset) outputToken := shr(96, mload(p)) }
25,342
17
// Get keccak256 of a wearableId. _wearableId - token wearablereturn bytes32 keccak256 of the wearableId /
function getWearableKey(string memory _wearableId) public pure returns (bytes32) { return keccak256(abi.encodePacked(_wearableId)); }
function getWearableKey(string memory _wearableId) public pure returns (bytes32) { return keccak256(abi.encodePacked(_wearableId)); }
9,365
13
// Constructor/_token An ORSToken/_rate Rate in integral token units per wei/_openingTime Block (Unix) timestamp of mainsale start time/_closingTime Block (Unix) timestamp of mainsale latest end time/_wallet Ethereum account who will receive sent ether upon token purchase during mainsale/_companyWallet Ethereum account of company who will receive company share upon finalization/_advisorsWallet Ethereum account of advisors who will receive advisors share upon finalization/_bountyWallet Ethereum account of a wallet that will receive remaining bonus upon finalization/_kycSigners List of KYC signers' Ethereum addresses
constructor( ORSToken _token, uint _rate, uint _openingTime, uint _closingTime, address _wallet, address _companyWallet, address _advisorsWallet, address _bountyWallet, address[] _kycSigners
constructor( ORSToken _token, uint _rate, uint _openingTime, uint _closingTime, address _wallet, address _companyWallet, address _advisorsWallet, address _bountyWallet, address[] _kycSigners
46,210
28
// Get the adoption fee of the animal shelter. return The adoption fee. /
function getAdoptionFee() public view returns (uint256) { return _adoptionFee; }
function getAdoptionFee() public view returns (uint256) { return _adoptionFee; }
1,340
6
// reverse /
function reverse(uint256 input) internal pure returns (uint256 v) { v = input; // swap bytes v = ((v & 0xFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00) >> 8) | ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8); // swap 2-byte long pairs v = ((v & 0xFFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000) >> 16) | ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16); // swap 4-byte long pairs v = ((v & 0xFFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000) >> 32) | ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32); // swap 8-byte long pairs v = ((v & 0xFFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF0000000000000000) >> 64) | ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64); // swap 16-byte long pairs v = (v >> 128) | (v << 128); }
function reverse(uint256 input) internal pure returns (uint256 v) { v = input; // swap bytes v = ((v & 0xFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00) >> 8) | ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8); // swap 2-byte long pairs v = ((v & 0xFFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000) >> 16) | ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16); // swap 4-byte long pairs v = ((v & 0xFFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000) >> 32) | ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32); // swap 8-byte long pairs v = ((v & 0xFFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF0000000000000000) >> 64) | ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64); // swap 16-byte long pairs v = (v >> 128) | (v << 128); }
21,380
13
// returns the product of multiplying _x by _y, reverts if the calculation overflows_x factor 1_y factor 2 return product/
function mul(uint256 _x, uint256 _y) internal pure returns (uint256) { // gas optimization if (_x == 0) return 0; uint256 z = _x * _y; require(z / _x == _y, "ERR_OVERFLOW"); return z; }
function mul(uint256 _x, uint256 _y) internal pure returns (uint256) { // gas optimization if (_x == 0) return 0; uint256 z = _x * _y; require(z / _x == _y, "ERR_OVERFLOW"); return z; }
40,943
87
// overriding FinalizableCrowdsalefinalization to add 20% of sold token for owner
function finalization() internal { // mint locked token to Crowdsale contract uint256 restrictedTokens = soldTokens.div(100).mul(restrictedPercent); token.mint(this, restrictedTokens); token.kycVerify(this); Y1_lockedTokenReleaseTime = now + 1 years; Y1_lockedTokenAmount = restrictedTokens.div(2); Y2_lockedTokenReleaseTime = now + 2 years; Y2_lockedTokenAmount = restrictedTokens.div(2); // stop minting new tokens token.finishMinting(); // transfer the contract ownership to OAKTokenCrowdsale.owner token.transferOwnership(owner); }
function finalization() internal { // mint locked token to Crowdsale contract uint256 restrictedTokens = soldTokens.div(100).mul(restrictedPercent); token.mint(this, restrictedTokens); token.kycVerify(this); Y1_lockedTokenReleaseTime = now + 1 years; Y1_lockedTokenAmount = restrictedTokens.div(2); Y2_lockedTokenReleaseTime = now + 2 years; Y2_lockedTokenAmount = restrictedTokens.div(2); // stop minting new tokens token.finishMinting(); // transfer the contract ownership to OAKTokenCrowdsale.owner token.transferOwnership(owner); }
14,575
72
// checks if the vault can be liquidated /
function checkLiquidation(uint256 vaultId_) public view { require(vaultExistence[vaultId_], 'Vault must exist'); ( uint256 collateralValueTimes100, uint256 debtValue ) = calculateCollateralProperties( vaultCollateral[vaultId_], vaultDebt[vaultId_] ); uint256 collateralPercentage = collateralValueTimes100 / debtValue; require( collateralPercentage < minimumCollateralPercentage, 'Vault is not below minimum collateral percentage' ); }
function checkLiquidation(uint256 vaultId_) public view { require(vaultExistence[vaultId_], 'Vault must exist'); ( uint256 collateralValueTimes100, uint256 debtValue ) = calculateCollateralProperties( vaultCollateral[vaultId_], vaultDebt[vaultId_] ); uint256 collateralPercentage = collateralValueTimes100 / debtValue; require( collateralPercentage < minimumCollateralPercentage, 'Vault is not below minimum collateral percentage' ); }
26,972
102
// Mints 1 Basis Cash to contract creator for initial Uniswap oracle deployment. Will be burned after oracle deployment
_mint(msg.sender, 1 * 10**18);
_mint(msg.sender, 1 * 10**18);
16,811
14
// Internal function to burn a specific token.Reverts if the token does not exist.Deprecated, use _burn(uint256) instead. owner owner of the token to burn tokenId uint256 ID of the token being burned by the msg.sender /
function _burn(address owner, uint256 tokenId) internal { super._burn(owner, tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } }
function _burn(address owner, uint256 tokenId) internal { super._burn(owner, tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } }
2,905
60
// Retrieves a copy of all Witnet-provided data related to a previously posted request, removing the whole query from the WRB storage./Fails if the `_queryId` is not in 'Reported' status, or called from an address different to/the one that actually posted the given request./_queryId The unique query identifier.
function deleteQuery(uint256 _queryId) external returns (Witnet.Response memory);
function deleteQuery(uint256 _queryId) external returns (Witnet.Response memory);
18,029
121
// user functions //Stake tokens/anyone can stake to any vault if they have valid permission/ access control: anyone/ state machine:/ - can be called multiple times/ - only online/ - when vault exists on this Hypervisor/ state scope:/ - append to _vaults[vault].stakes/ - increase _vaults[vault].totalStake/ - increase _hypervisor.totalStake/ - increase _hypervisor.totalStakeUnits/ - increase _hypervisor.lastUpdate/ token transfer: transfer staking tokens from msg.sender to vault/vault address The address of the vault to stake from/amount uint256 The amount of staking tokens to stake
function stake( address vault, uint256 amount, bytes calldata permission
function stake( address vault, uint256 amount, bytes calldata permission
28,507
1
// ========== VIEWS ========== //Given the address of a user, returns the user's profile NFT ID.If the user hasn't minted an NFT profile, the function returns 0.userAddress Address of the user. return uint The user's NFT ID./
function getUser(address userAddress) external view returns (uint) { require(userAddress != address(0), "Users: invalid user address."); return profileIDs[userAddress]; }
function getUser(address userAddress) external view returns (uint) { require(userAddress != address(0), "Users: invalid user address."); return profileIDs[userAddress]; }
7,472
91
// Address of biot coin admin The admin can change reserve. The reserve is the amount of token assigned to some address but not permitted to use.
address internal admin; event OwnerChanged(address indexed previousOwner, address indexed newOwner); event VaultChanged(address indexed previousVault, address indexed newVault); event AdminChanged(address indexed previousAdmin, address indexed newAdmin); event ReserveChanged(address indexed _address, uint amount);
address internal admin; event OwnerChanged(address indexed previousOwner, address indexed newOwner); event VaultChanged(address indexed previousVault, address indexed newVault); event AdminChanged(address indexed previousAdmin, address indexed newAdmin); event ReserveChanged(address indexed _address, uint amount);
75,865
49
// Returns whether the specified token exists _tokenId uint256 ID of the token to query the existance ofreturn whether the token exists /
function exists(uint256 _tokenId) public view returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); }
function exists(uint256 _tokenId) public view returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); }
19,446
0
// Sets address of the implementation _implementation Address of the implementation /
function setImplementation(address _implementation) public onlyProxyOwner { _setImplementation(_implementation); }
function setImplementation(address _implementation) public onlyProxyOwner { _setImplementation(_implementation); }
51,482
65
// return addresses with all stable coins supported in the sale
function acceptableStableCoins() external view returns (address[] memory) { uint256 length = stableCoins.length(); address[] memory addresses = new address[](length); for (uint256 i = 0; i < length; i++) { addresses[i] = stableCoins.at(i); } return addresses; }
function acceptableStableCoins() external view returns (address[] memory) { uint256 length = stableCoins.length(); address[] memory addresses = new address[](length); for (uint256 i = 0; i < length; i++) { addresses[i] = stableCoins.at(i); } return addresses; }
60,919
15
// do we need to segregate these funds?
if (msg.value != (600000000000000000*(dataStorage.num_Players()-1))) { revert(); }
if (msg.value != (600000000000000000*(dataStorage.num_Players()-1))) { revert(); }
36,283
20
// throw if delegatecall failed
revert(add(response, 0x20), size)
revert(add(response, 0x20), size)
6,133
38
// bool success = IERC20(LP_Token).transfer(user, _withdrawableDividend);
if(!success) { withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividend); totalDividendsWithdrawn -= _withdrawableDividend; return 0; }
if(!success) { withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividend); totalDividendsWithdrawn -= _withdrawableDividend; return 0; }
41,647
0
// Checks if the current round has been initialized Executes the 'currentRoundInitialized' modifier in 'MixinContractRegistry' /
modifier currentRoundInitialized() virtual { _; }
modifier currentRoundInitialized() virtual { _; }
17,813
158
// calcSpotPricesP = spotPrice bI = tokenBalanceIn( bI / wI ) 1 bO = tokenBalanceOut sP =---------------------wI = tokenWeightIn ( bO / wO ) ( 1 - sF )wO = tokenWeightOutsF = swapFee/
{ uint numer = bdiv(tokenBalanceIn, tokenWeightIn); uint denom = bdiv(tokenBalanceOut, tokenWeightOut); uint ratio = bdiv(numer, denom); uint scale = bdiv(BONE, bsub(BONE, swapFee)); return (spotPrice = bmul(ratio, scale)); }
{ uint numer = bdiv(tokenBalanceIn, tokenWeightIn); uint denom = bdiv(tokenBalanceOut, tokenWeightOut); uint ratio = bdiv(numer, denom); uint scale = bdiv(BONE, bsub(BONE, swapFee)); return (spotPrice = bmul(ratio, scale)); }
4,192
65
// Inheritance
interface IStakingRewards { // Views function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken() external view returns (uint256); function earned(address account) external view returns (uint256); function getRewardForDuration() external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); // Mutative function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function exit() external; }
interface IStakingRewards { // Views function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken() external view returns (uint256); function earned(address account) external view returns (uint256); function getRewardForDuration() external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); // Mutative function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function exit() external; }
7,014
181
// Rescue any non-reward token that was airdropped to this contract Can only be called by the owner /
function rescueAirdroppedTokens(address _token, address to) external override onlyOwner
function rescueAirdroppedTokens(address _token, address to) external override onlyOwner
76,304
125
// Keep track of how many Y pool tokens were sent
uint256 balanceBefore = curveYToken.balanceOf(address(this)); if (stableCoinIndex != -1) {
uint256 balanceBefore = curveYToken.balanceOf(address(this)); if (stableCoinIndex != -1) {
57,919
219
// Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was notalready present. /
function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } }
function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } }
7,131
11
// Returns true if `account` is a contract. [IMPORTANT]====It is unsafe to assume that an address for which this function returnsfalse is an externally-owned account (EOA) and not a contract. Among others, `isContract` will return false for the followingtypes of addresses:- an externally-owned account - a contract in construction - an address where a contract will be created - an address where a contract lived, but was destroyed==== /
function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; }
function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; }
11
44
// return the address where funds are collected. /
function wallet() public view returns (address payable) { return _wallet; }
function wallet() public view returns (address payable) { return _wallet; }
15,381
25
// Get the address that made a particular submission./hash The hash that was submitted/nNodes The number of nodes that was submitted/jrh The JRH of that was submitted/index The index of the submission - should be 0-11, as up to twelve submissions can be made./ return user Address of the user that submitted the hash / nNodes/ jrh at index
function getSubmissionUser(bytes32 hash, uint256 nNodes, bytes32 jrh, uint256 index) public view returns (address user);
function getSubmissionUser(bytes32 hash, uint256 nNodes, bytes32 jrh, uint256 index) public view returns (address user);
35,915
565
// uint256 tokenPrice;
bool tokenPriceValid; (tokenPrice, tokenPriceValid) = tokenPriceOracle.getData(); require(tokenPriceValid, "invalid token price"); if (tokenPrice > MAX_RATE) { tokenPrice = MAX_RATE; }
bool tokenPriceValid; (tokenPrice, tokenPriceValid) = tokenPriceOracle.getData(); require(tokenPriceValid, "invalid token price"); if (tokenPrice > MAX_RATE) { tokenPrice = MAX_RATE; }
12,513
36
// Because this is designed to be called internally in constructors, we don't check the address exists already in the resolver
addressCache[name] = resolver.getAddress(name);
addressCache[name] = resolver.getAddress(name);
24,348
19
// Transfer funds from matching pool to current funding round and finalize it._totalSpent Total amount of spent voice credits._totalSpentSalt The salt./
function transferMatchingFunds( uint256 _totalSpent, uint256 _totalSpentSalt ) external onlyOwner
function transferMatchingFunds( uint256 _totalSpent, uint256 _totalSpentSalt ) external onlyOwner
7,604
79
// Return Etherium all investors /
function refund() public { require(sumWei < softcap && !state); uint value = balances[msg.sender]; balances[msg.sender] = 0; emit Refund(msg.sender, value); msg.sender.transfer(value); }
function refund() public { require(sumWei < softcap && !state); uint value = balances[msg.sender]; balances[msg.sender] = 0; emit Refund(msg.sender, value); msg.sender.transfer(value); }
9,626
30
// @inheritdoc IStrategy/do not use isActive modifier here; allow bentobox to call strategy.exit() multiple times
function exit(uint256 balance) external override onlyBentoBox returns (int256 amountAdded) { _exit(); /// @dev Check balance of token on the contract. uint256 actualBalance = strategyToken.balanceOf(address(this)); /// @dev Calculate tokens added (or lost). amountAdded = int256(actualBalance) - int256(balance); /// @dev Transfer all tokens to bentoBox. strategyToken.safeTransfer(address(bentoBox), actualBalance); /// @dev Flag as exited, allowing the owner to manually deal with any amounts available later. exited = true; }
function exit(uint256 balance) external override onlyBentoBox returns (int256 amountAdded) { _exit(); /// @dev Check balance of token on the contract. uint256 actualBalance = strategyToken.balanceOf(address(this)); /// @dev Calculate tokens added (or lost). amountAdded = int256(actualBalance) - int256(balance); /// @dev Transfer all tokens to bentoBox. strategyToken.safeTransfer(address(bentoBox), actualBalance); /// @dev Flag as exited, allowing the owner to manually deal with any amounts available later. exited = true; }
38,027
154
// Allows the owner to revoke the vesting. Tokens already vestedremain in the contract, the rest are returned to the owner. token ERC20 token which is being vested /
function revoke(ERC20Basic token) public onlyOwner { require(revocable); require(!revoked[token]); uint256 balance = token.balanceOf(this); uint256 unreleased = releasableAmount(token); uint256 refund = balance.sub(unreleased); revoked[token] = true; token.safeTransfer(owner, refund); Revoked(); }
function revoke(ERC20Basic token) public onlyOwner { require(revocable); require(!revoked[token]); uint256 balance = token.balanceOf(this); uint256 unreleased = releasableAmount(token); uint256 refund = balance.sub(unreleased); revoked[token] = true; token.safeTransfer(owner, refund); Revoked(); }
24,694
28
// Returns registry fee on the basis of string length. /
function getPayableFee(string memory _name) external view override returns (uint256) { return vnsUtils._getPrice(perCharRegistrationFee, _name); }
function getPayableFee(string memory _name) external view override returns (uint256) { return vnsUtils._getPrice(perCharRegistrationFee, _name); }
34,945
13
// Send Propose.
function addPropose(address _receiver, bytes32 _infoHash) public onlyRegiter { ///Do Sent Propose doAddPropose(byte(0), msg.sender, _receiver, _infoHash); }
function addPropose(address _receiver, bytes32 _infoHash) public onlyRegiter { ///Do Sent Propose doAddPropose(byte(0), msg.sender, _receiver, _infoHash); }
38,310
132
// Deposit LP tokens to MasterChef for FFARM allocation.
function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accFFARMPerShare).div(1e12).sub(user.rewardDebt); safeFFARMTransfer(msg.sender, pending); } pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accFFARMPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); }
function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accFFARMPerShare).div(1e12).sub(user.rewardDebt); safeFFARMTransfer(msg.sender, pending); } pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accFFARMPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); }
15,309
80
// decode a UQ112x112 into a uint112 by truncating after the radix point
function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); }
function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); }
25,502
16
// currency to price mapping
mapping(address => uint256[]) private currencyPrices;
mapping(address => uint256[]) private currencyPrices;
22,781
24
// first call end contract in case of insurance contract duration expiring, if it hasn't won't do anything
endContract();
endContract();
10,106
197
// Perform any adjustments to the core position(s) of this Strategy givenwhat change the Vault made in the "investable capital" available to theStrategy. Note that all "free capital" in the Strategy after the reportwas made is available for reinvestment. Also note that this numbercould be 0, and you should handle that scenario accordingly. See comments regarding `_debtOutstanding` on `prepareReturn()`. /
function adjustPosition(uint256 _debtOutstanding) internal virtual;
function adjustPosition(uint256 _debtOutstanding) internal virtual;
887
7
// constructor of the contract which initialized the registrar
constructor(address _registrar) public notNullAddress (msg.sender) { registrar = _registrar; }
constructor(address _registrar) public notNullAddress (msg.sender) { registrar = _registrar; }
41,467
303
// bool isNativeToken added to feeParams
);
);
76,815
11
// Sign pending withdrawal. withdrawalNonce The nonce of withdrawal signature The signature of withdrawal /
function signPendingWithdrawal(uint withdrawalNonce, bytes memory signature) public onlyOracle { require(withdrawalNonce <= nonce, "invalid nonce"); Withdrawal storage withdraw = withdrawals[withdrawalNonce]; require(withdrawalStatus[withdrawalNonce] == WithdrawalStatus.submitted, "withdraw is not submitted"); bytes32 hash = keccak256(abi.encodePacked( "\x19Ethereum Signed Message:\n32", keccak256(abi.encodePacked( withdraw.nonce, withdraw.foreignToken, withdraw.foreignAccount, withdraw.value )) )); address signer = hash.recover(signature); require(signer == foreignOracle(), "signer is not oracle"); withdrawalStatus[withdrawalNonce] = WithdrawalStatus.signed; withdrawals[withdrawalNonce].signature = signature; emit WithdrawalSigned( withdrawalNonce, withdraw.foreignToken, withdraw.foreignAccount, withdraw.value, signature ); }
function signPendingWithdrawal(uint withdrawalNonce, bytes memory signature) public onlyOracle { require(withdrawalNonce <= nonce, "invalid nonce"); Withdrawal storage withdraw = withdrawals[withdrawalNonce]; require(withdrawalStatus[withdrawalNonce] == WithdrawalStatus.submitted, "withdraw is not submitted"); bytes32 hash = keccak256(abi.encodePacked( "\x19Ethereum Signed Message:\n32", keccak256(abi.encodePacked( withdraw.nonce, withdraw.foreignToken, withdraw.foreignAccount, withdraw.value )) )); address signer = hash.recover(signature); require(signer == foreignOracle(), "signer is not oracle"); withdrawalStatus[withdrawalNonce] = WithdrawalStatus.signed; withdrawals[withdrawalNonce].signature = signature; emit WithdrawalSigned( withdrawalNonce, withdraw.foreignToken, withdraw.foreignAccount, withdraw.value, signature ); }
44,728
15
// {[type]} address [description]return {[type]} [description] /
function addressToBytes(address payable a) internal pure returns (bytes memory b) { return abi.encodePacked(a); }
function addressToBytes(address payable a) internal pure returns (bytes memory b) { return abi.encodePacked(a); }
13,175
233
// First gets the tokens from msg.sender to this contract (Pool Controller)
bool xfer = IERC20(token).transferFrom( msg.sender, address(this), deltaBalance ); require(xfer, "ERR_ERC20_FALSE");
bool xfer = IERC20(token).transferFrom( msg.sender, address(this), deltaBalance ); require(xfer, "ERR_ERC20_FALSE");
16,159
5
// Each NFT can have its own settings/royaltyRecipient The address the royalty goes to/royaltyFraction A fraction as a number between 0 and 100
struct NFT { address royaltyRecipient; uint8 royaltyFraction; }
struct NFT { address royaltyRecipient; uint8 royaltyFraction; }
38,278
14
// Epochs are indexed as `block.timestamp / EPOCH_LENGTH`./ `genesisEpoch` is the index of the epoch in which the pool is deployed.
uint256 public immutable genesisEpoch;
uint256 public immutable genesisEpoch;
46,864
26
// Should handle activation logic If there is a need to handle any logic during activation, this is the function you should implement it into /
function _activate() internal virtual {} /////// FUNCTIONS /** * @notice * Updates an Allocators state and reports to `TreasuryExtender` if necessary. * @dev * Can only be called by the Guardian. * Can only be called while the Allocator is activated. * * This function should update the Allocators internal state via `_update`, which should in turn * return the `gain` and `loss` the Allocator has sustained in underlying allocated `token` from `_tokens` * decided by the `id`. * Please check the docs on `_update` to see what its function should be. * * `_lossLimitViolated` checks if the Allocators is above its loss limit and deactivates it in case * of serious losses. The loss limit should be set to some value which is unnacceptable to be lost * in the case of normal runtime and thus require a panic shutdown, whatever it is defined to be. * * Lastly, the Allocator reports its state to the Extender, which handles gain, loss, allocated logic. * The documentation on this can be found in `TreasuryExtender.sol`. * @param id the id of the deposit in `TreasuryExtender` */ function update(uint256 id) external override onlyGuardian onlyActivated { // effects // handle depositing, harvesting, compounding logic inside of _update() // if gain is in allocated then gain > 0 otherwise gain == 0 // we only use so we know initia // loss always in allocated (uint128 gain, uint128 loss) = _update(id); if (_lossLimitViolated(id, loss)) { deactivate(true); return; } // interactions // there is no interactions happening inside of report // so allocator has no state changes to make after it if (gain + loss > 0) extender.report(id, gain, loss); }
function _activate() internal virtual {} /////// FUNCTIONS /** * @notice * Updates an Allocators state and reports to `TreasuryExtender` if necessary. * @dev * Can only be called by the Guardian. * Can only be called while the Allocator is activated. * * This function should update the Allocators internal state via `_update`, which should in turn * return the `gain` and `loss` the Allocator has sustained in underlying allocated `token` from `_tokens` * decided by the `id`. * Please check the docs on `_update` to see what its function should be. * * `_lossLimitViolated` checks if the Allocators is above its loss limit and deactivates it in case * of serious losses. The loss limit should be set to some value which is unnacceptable to be lost * in the case of normal runtime and thus require a panic shutdown, whatever it is defined to be. * * Lastly, the Allocator reports its state to the Extender, which handles gain, loss, allocated logic. * The documentation on this can be found in `TreasuryExtender.sol`. * @param id the id of the deposit in `TreasuryExtender` */ function update(uint256 id) external override onlyGuardian onlyActivated { // effects // handle depositing, harvesting, compounding logic inside of _update() // if gain is in allocated then gain > 0 otherwise gain == 0 // we only use so we know initia // loss always in allocated (uint128 gain, uint128 loss) = _update(id); if (_lossLimitViolated(id, loss)) { deactivate(true); return; } // interactions // there is no interactions happening inside of report // so allocator has no state changes to make after it if (gain + loss > 0) extender.report(id, gain, loss); }
19,006
24
// Returns the amount of remaining sminems /
function getRemaining() external view returns (uint256) { return remaining; }
function getRemaining() external view returns (uint256) { return remaining; }
20,876
5
// Default constructor /
constructor() ERC1155("ipfs://QmXRvBcDGpGYVKa7DpshY4UJQrSHH4ArN2AotHHjDS3BHo/")
constructor() ERC1155("ipfs://QmXRvBcDGpGYVKa7DpshY4UJQrSHH4ArN2AotHHjDS3BHo/")
851
9
// Emitted when a new message is dispatched via Nomad messageHash Hash of message; the leaf inserted to the Merkle tree for the message leafIndex Index of message's leaf in merkle tree destinationAndNonce Destination and destination-specific nonce combined in single field ((destination << 32) & nonce) committedRoot the latest notarized root submitted in the last signed Update message Raw bytes of message /
event Dispatch( bytes32 indexed messageHash, uint256 indexed leafIndex, uint64 indexed destinationAndNonce, bytes32 committedRoot, bytes message );
event Dispatch( bytes32 indexed messageHash, uint256 indexed leafIndex, uint64 indexed destinationAndNonce, bytes32 committedRoot, bytes message );
38,223
41
// Equipment token ID vs owner address
mapping (uint256 => address) fashionIdToOwner;
mapping (uint256 => address) fashionIdToOwner;
7,581
24
// require( slammerTimeContract.transferBack(msg.sender,tempId) );
slammerTimeContract.transferBack(msg.sender,tempId);
slammerTimeContract.transferBack(msg.sender,tempId);
13,554
14
// set Token URI /
function setTokenURI(string calldata _uri, uint256 _id) external onlyOwner { emit URI(_uri, _id); }
function setTokenURI(string calldata _uri, uint256 _id) external onlyOwner { emit URI(_uri, _id); }
38,357
18
// The Ownable constructor sets the original `owner` of the contract to the senderaccount. /
constructor() public { owner = msg.sender; }
constructor() public { owner = msg.sender; }
18,256
2
// validate this is .25% (1.0025)
uint public growthRate = 10025; bool migrated = false; bool _hasOracle = false; constructor( address _storedvalueToken, address _peg, address _share, address _control,
uint public growthRate = 10025; bool migrated = false; bool _hasOracle = false; constructor( address _storedvalueToken, address _peg, address _share, address _control,
52,340